Skip to content

Commit eb05457

Browse files
committed
[X86] Add function isPrefix()
Currently some prefixes are emitted as instructions, to distinguish them from real instruction, fuction isPrefix() is added. The kinds of prefix are consistent with X86GenInstrInfo.inc. Differential Revision: https://reviews.llvm.org/D73013
1 parent 0e67212 commit eb05457

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,33 @@ namespace X86 {
346346
llvm_unreachable("unknown fusion type");
347347
}
348348

349+
/// \returns true if the instruction with given opcode is a prefix.
350+
inline bool isPrefix(unsigned Opcode) {
351+
switch (Opcode) {
352+
default:
353+
return false;
354+
// segment override prefix
355+
case X86::CS_PREFIX:
356+
case X86::DS_PREFIX:
357+
case X86::ES_PREFIX:
358+
case X86::FS_PREFIX:
359+
case X86::GS_PREFIX:
360+
case X86::SS_PREFIX:
361+
// operand-size override prefix
362+
case X86::DATA16_PREFIX:
363+
// lock and repeat prefix
364+
case X86::LOCK_PREFIX:
365+
case X86::REPNE_PREFIX:
366+
case X86::REP_PREFIX:
367+
// rex64 prefix
368+
case X86::REX64_PREFIX:
369+
// acquire and release prefix
370+
case X86::XACQUIRE_PREFIX:
371+
case X86::XRELEASE_PREFIX:
372+
return true;
373+
}
374+
}
375+
349376
/// Defines the possible values of the branch boundary alignment mask.
350377
enum AlignBranchBoundaryKind : uint8_t {
351378
AlignBranchNone = 0,

0 commit comments

Comments
 (0)