diff options
Diffstat (limited to 'lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp')
-rw-r--r-- | lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp | 61 |
1 files changed, 29 insertions, 32 deletions
diff --git a/lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp b/lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp index 070b365fd4..632f3b5c7c 100644 --- a/lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp +++ b/lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp @@ -47,9 +47,6 @@ struct ContextDecision { #include "X86GenDisassemblerTables.inc" -#define TRUE 1 -#define FALSE 0 - #ifndef NDEBUG #define debug(s) do { Debug(__FILE__, __LINE__, s); } while (0) #else @@ -78,7 +75,7 @@ static InstructionContext contextForAttrs(uint16_t attrMask) { * contextForAttrs. * @param opcode - The last byte of the instruction's opcode, not counting * ModR/M extensions and escapes. - * @return - TRUE if the ModR/M byte is required, FALSE otherwise. + * @return - true if the ModR/M byte is required, false otherwise. */ static int modRMRequired(OpcodeType type, InstructionContext insnContext, @@ -309,15 +306,15 @@ static void setPrefixPresent(struct InternalInstruction* insn, * @param location - The location to query. * @return - Whether the prefix is at that location. */ -static BOOL isPrefixAtLocation(struct InternalInstruction* insn, +static bool isPrefixAtLocation(struct InternalInstruction* insn, uint8_t prefix, uint64_t location) { if (insn->prefixPresent[prefix] == 1 && insn->prefixLocations[prefix] == location) - return TRUE; + return true; else - return FALSE; + return false; } /* @@ -330,14 +327,14 @@ static BOOL isPrefixAtLocation(struct InternalInstruction* insn, * bytes, and no prefixes conflicted; nonzero otherwise. */ static int readPrefixes(struct InternalInstruction* insn) { - BOOL isPrefix = TRUE; - BOOL prefixGroups[4] = { FALSE }; + bool isPrefix = true; + bool prefixGroups[4] = { false }; uint64_t prefixLocation; uint8_t byte = 0; uint8_t nextByte; - BOOL hasAdSize = FALSE; - BOOL hasOpSize = FALSE; + bool hasAdSize = false; + bool hasOpSize = false; dbgprintf(insn, "readPrefixes()"); @@ -369,7 +366,7 @@ static int readPrefixes(struct InternalInstruction* insn) { if ((byte == 0xf2 || byte == 0xf3) && ((nextByte == 0xf0) | ((nextByte & 0xfe) == 0x86 || (nextByte & 0xf8) == 0x90))) - insn->xAcquireRelease = TRUE; + insn->xAcquireRelease = true; /* * Also if the byte is 0xf3, and the following condition is met: * - it is followed by a "mov mem, reg" (opcode 0x88/0x89) or @@ -379,7 +376,7 @@ static int readPrefixes(struct InternalInstruction* insn) { if (byte == 0xf3 && (nextByte == 0x88 || nextByte == 0x89 || nextByte == 0xc6 || nextByte == 0xc7)) - insn->xAcquireRelease = TRUE; + insn->xAcquireRelease = true; if (insn->mode == MODE_64BIT && (nextByte & 0xf0) == 0x40) { if (consumeByte(insn, &nextByte)) return -1; @@ -397,7 +394,7 @@ static int readPrefixes(struct InternalInstruction* insn) { case 0xf3: /* REP or REPE/REPZ */ if (prefixGroups[0]) dbgprintf(insn, "Redundant Group 1 prefix"); - prefixGroups[0] = TRUE; + prefixGroups[0] = true; setPrefixPresent(insn, byte, prefixLocation); break; case 0x2e: /* CS segment override -OR- Branch not taken */ @@ -431,25 +428,25 @@ static int readPrefixes(struct InternalInstruction* insn) { } if (prefixGroups[1]) dbgprintf(insn, "Redundant Group 2 prefix"); - prefixGroups[1] = TRUE; + prefixGroups[1] = true; setPrefixPresent(insn, byte, prefixLocation); break; case 0x66: /* Operand-size override */ if (prefixGroups[2]) dbgprintf(insn, "Redundant Group 3 prefix"); - prefixGroups[2] = TRUE; - hasOpSize = TRUE; + prefixGroups[2] = true; + hasOpSize = true; setPrefixPresent(insn, byte, prefixLocation); break; case 0x67: /* Address-size override */ if (prefixGroups[3]) dbgprintf(insn, "Redundant Group 4 prefix"); - prefixGroups[3] = TRUE; - hasAdSize = TRUE; + prefixGroups[3] = true; + hasAdSize = true; setPrefixPresent(insn, byte, prefixLocation); break; default: /* Not a prefix byte */ - isPrefix = FALSE; + isPrefix = false; break; } @@ -574,7 +571,7 @@ static int readPrefixes(struct InternalInstruction* insn) { default: break; case VEX_PREFIX_66: - hasOpSize = TRUE; + hasOpSize = true; break; } @@ -620,7 +617,7 @@ static int readPrefixes(struct InternalInstruction* insn) { default: break; case VEX_PREFIX_66: - hasOpSize = TRUE; + hasOpSize = true; break; } @@ -815,7 +812,7 @@ static int readModRM(struct InternalInstruction* insn); static int getIDWithAttrMask(uint16_t* instructionID, struct InternalInstruction* insn, uint16_t attrMask) { - BOOL hasModRMExtension; + bool hasModRMExtension; InstructionContext instructionClass = contextForAttrs(attrMask); @@ -848,14 +845,14 @@ static int getIDWithAttrMask(uint16_t* instructionID, * @param orig - The instruction that is not 16-bit * @param equiv - The instruction that is 16-bit */ -static BOOL is16BitEquivalent(const char* orig, const char* equiv) { +static bool is16BitEquivalent(const char* orig, const char* equiv) { off_t i; for (i = 0;; i++) { if (orig[i] == '\0' && equiv[i] == '\0') - return TRUE; + return true; if (orig[i] == '\0' || equiv[i] == '\0') - return FALSE; + return false; if (orig[i] != equiv[i]) { if ((orig[i] == 'Q' || orig[i] == 'L') && equiv[i] == 'W') continue; @@ -863,7 +860,7 @@ static BOOL is16BitEquivalent(const char* orig, const char* equiv) { continue; if ((orig[i] == '4' || orig[i] == '2') && equiv[i] == '6') continue; - return FALSE; + return false; } } } @@ -1108,7 +1105,7 @@ static int readSIB(struct InternalInstruction* insn) { if (insn->consumedSIB) return 0; - insn->consumedSIB = TRUE; + insn->consumedSIB = true; switch (insn->addressSize) { case 2: @@ -1206,12 +1203,12 @@ static int readDisplacement(struct InternalInstruction* insn) { if (insn->consumedDisplacement) return 0; - insn->consumedDisplacement = TRUE; + insn->consumedDisplacement = true; insn->displacementOffset = insn->readerCursor - insn->startLocation; switch (insn->eaDisplacement) { case EA_DISP_NONE: - insn->consumedDisplacement = FALSE; + insn->consumedDisplacement = false; break; case EA_DISP_8: if (consumeInt8(insn, &d8)) @@ -1230,7 +1227,7 @@ static int readDisplacement(struct InternalInstruction* insn) { break; } - insn->consumedDisplacement = TRUE; + insn->consumedDisplacement = true; return 0; } @@ -1251,7 +1248,7 @@ static int readModRM(struct InternalInstruction* insn) { if (consumeByte(insn, &insn->modRM)) return -1; - insn->consumedModRM = TRUE; + insn->consumedModRM = true; mod = modFromModRM(insn->modRM); rm = rmFromModRM(insn->modRM); |