From de9e333e18bbae2a29043deeb8e522cc0fa09036 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Tue, 31 Jul 2012 06:02:05 +0000 Subject: [PATCH] Tidy up. Move for loop index declarations into for statements. Use unsigned instead of uint16_t for loop indices. Use unsigned instead of uint32_t for arguments to raw_ostream.indent. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161033 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/X86DisassemblerTables.cpp | 65 ++++++++++-------------- 1 file changed, 26 insertions(+), 39 deletions(-) diff --git a/utils/TableGen/X86DisassemblerTables.cpp b/utils/TableGen/X86DisassemblerTables.cpp index 587d89fc4dd..c19520d317b 100644 --- a/utils/TableGen/X86DisassemblerTables.cpp +++ b/utils/TableGen/X86DisassemblerTables.cpp @@ -170,7 +170,7 @@ static inline const char* stringForOperandEncoding(OperandEncoding encoding) { } } -void DisassemblerTables::emitOneID(raw_ostream &o, uint32_t &i, InstrUID id, +void DisassemblerTables::emitOneID(raw_ostream &o, unsigned &i, InstrUID id, bool addComma) const { if (id) o.indent(i * 2) << format("0x%hx", id); @@ -195,7 +195,7 @@ void DisassemblerTables::emitOneID(raw_ostream &o, uint32_t &i, InstrUID id, /// /// @param o - The output stream on which to emit the table. /// @param i - The indentation level for that output stream. -static void emitEmptyTable(raw_ostream &o, uint32_t &i) { +static void emitEmptyTable(raw_ostream &o, unsigned &i) { o.indent(i * 2) << "0x0, /* EmptyTable */\n"; } @@ -209,9 +209,7 @@ static ModRMDecisionType getDecisionType(ModRMDecision &decision) { bool satisfiesSplitRM = true; bool satisfiesSplitReg = true; - uint16_t index; - - for (index = 0; index < 256; ++index) { + for (unsigned index = 0; index < 256; ++index) { if (decision.instructionIDs[index] != decision.instructionIDs[0]) satisfiesOneEntry = false; @@ -295,12 +293,11 @@ DisassemblerTables::~DisassemblerTables() { } void DisassemblerTables::emitModRMDecision(raw_ostream &o1, raw_ostream &o2, - uint32_t &i1, uint32_t &i2, + unsigned &i1, unsigned &i2, ModRMDecision &decision) const { - static uint64_t sTableNumber = 0; - static uint64_t sEntryNumber = 1; + static uint32_t sTableNumber = 0; + static uint32_t sEntryNumber = 1; ModRMDecisionType dt = getDecisionType(decision); - uint16_t index; if (dt == MODRM_ONEENTRY && decision.instructionIDs[0] == 0) { @@ -329,13 +326,13 @@ void DisassemblerTables::emitModRMDecision(raw_ostream &o1, raw_ostream &o2, emitOneID(o1, i1, decision.instructionIDs[0xc0], true); // mod = 0b11 break; case MODRM_SPLITREG: - for (index = 0; index < 64; index += 8) + for (unsigned index = 0; index < 64; index += 8) emitOneID(o1, i1, decision.instructionIDs[index], true); - for (index = 0xc0; index < 256; index += 8) + for (unsigned index = 0xc0; index < 256; index += 8) emitOneID(o1, i1, decision.instructionIDs[index], true); break; case MODRM_FULL: - for (index = 0; index < 256; ++index) + for (unsigned index = 0; index < 256; ++index) emitOneID(o1, i1, decision.instructionIDs[index], true); break; } @@ -372,16 +369,14 @@ void DisassemblerTables::emitModRMDecision(raw_ostream &o1, raw_ostream &o2, } void DisassemblerTables::emitOpcodeDecision(raw_ostream &o1, raw_ostream &o2, - uint32_t &i1, uint32_t &i2, + unsigned &i1, unsigned &i2, OpcodeDecision &decision) const { - uint16_t index; - o2.indent(i2) << "{ /* struct OpcodeDecision */" << "\n"; i2++; o2.indent(i2) << "{" << "\n"; i2++; - for (index = 0; index < 256; ++index) { + for (unsigned index = 0; index < 256; ++index) { o2.indent(i2); o2 << "/* 0x" << format("%02hhx", index) << " */" << "\n"; @@ -401,7 +396,7 @@ void DisassemblerTables::emitOpcodeDecision(raw_ostream &o1, raw_ostream &o2, } void DisassemblerTables::emitContextDecision(raw_ostream &o1, raw_ostream &o2, - uint32_t &i1, uint32_t &i2, + unsigned &i1, unsigned &i2, ContextDecision &decision, const char* name) const { o2.indent(i2) << "static const struct ContextDecision " << name << " = {\n"; @@ -409,9 +404,7 @@ void DisassemblerTables::emitContextDecision(raw_ostream &o1, raw_ostream &o2, o2.indent(i2) << "{ /* opcodeDecisions */" << "\n"; i2++; - unsigned index; - - for (index = 0; index < IC_max; ++index) { + for (unsigned index = 0; index < IC_max; ++index) { o2.indent(i2) << "/* "; o2 << stringForContext((InstructionContext)index); o2 << " */"; @@ -429,17 +422,16 @@ void DisassemblerTables::emitContextDecision(raw_ostream &o1, raw_ostream &o2, o2.indent(i2) << "};" << "\n"; } -void DisassemblerTables::emitInstructionInfo(raw_ostream &o, uint32_t &i) - const { +void DisassemblerTables::emitInstructionInfo(raw_ostream &o, + unsigned &i) const { o.indent(i * 2) << "static const struct InstructionSpecifier "; o << INSTRUCTIONS_STR "[" << InstructionSpecifiers.size() << "] = {\n"; i++; - uint16_t numInstructions = InstructionSpecifiers.size(); - uint16_t index, operandIndex; + unsigned numInstructions = InstructionSpecifiers.size(); - for (index = 0; index < numInstructions; ++index) { + for (unsigned index = 0; index < numInstructions; ++index) { o.indent(i * 2) << "{ /* " << index << " */" << "\n"; i++; @@ -454,7 +446,8 @@ void DisassemblerTables::emitInstructionInfo(raw_ostream &o, uint32_t &i) o.indent(i * 2) << "{" << "\n"; i++; - for (operandIndex = 0; operandIndex < X86_MAX_OPERANDS; ++operandIndex) { + for (unsigned operandIndex = 0; operandIndex < X86_MAX_OPERANDS; + ++operandIndex) { o.indent(i * 2) << "{ "; o <