Mark a static table as const. Shrink opcode size in static tables to uint16_t. Simplify loop iterating over one of those tables. No functional change intended.

llvm-svn: 157367
This commit is contained in:
Craig Topper 2012-05-24 03:59:11 +00:00
parent 777e6d01ea
commit 2fbd130a79
1 changed files with 9 additions and 14 deletions

View File

@ -51,9 +51,9 @@ WidenVMOVS("widen-vmovs", cl::Hidden, cl::init(true),
/// ARM_MLxEntry - Record information about MLA / MLS instructions. /// ARM_MLxEntry - Record information about MLA / MLS instructions.
struct ARM_MLxEntry { struct ARM_MLxEntry {
unsigned MLxOpc; // MLA / MLS opcode uint16_t MLxOpc; // MLA / MLS opcode
unsigned MulOpc; // Expanded multiplication opcode uint16_t MulOpc; // Expanded multiplication opcode
unsigned AddSubOpc; // Expanded add / sub opcode uint16_t AddSubOpc; // Expanded add / sub opcode
bool NegAcc; // True if the acc is negated before the add / sub. bool NegAcc; // True if the acc is negated before the add / sub.
bool HasLane; // True if instruction has an extra "lane" operand. bool HasLane; // True if instruction has an extra "lane" operand.
}; };
@ -1531,11 +1531,11 @@ ARMBaseInstrInfo::commuteInstruction(MachineInstr *MI, bool NewMI) const {
/// This will go away once we can teach tblgen how to set the optional CPSR def /// This will go away once we can teach tblgen how to set the optional CPSR def
/// operand itself. /// operand itself.
struct AddSubFlagsOpcodePair { struct AddSubFlagsOpcodePair {
unsigned PseudoOpc; uint16_t PseudoOpc;
unsigned MachineOpc; uint16_t MachineOpc;
}; };
static AddSubFlagsOpcodePair AddSubFlagsOpcodeMap[] = { static const AddSubFlagsOpcodePair AddSubFlagsOpcodeMap[] = {
{ARM::ADDSri, ARM::ADDri}, {ARM::ADDSri, ARM::ADDri},
{ARM::ADDSrr, ARM::ADDrr}, {ARM::ADDSrr, ARM::ADDrr},
{ARM::ADDSrsi, ARM::ADDrsi}, {ARM::ADDSrsi, ARM::ADDrsi},
@ -1563,14 +1563,9 @@ static AddSubFlagsOpcodePair AddSubFlagsOpcodeMap[] = {
}; };
unsigned llvm::convertAddSubFlagsOpcode(unsigned OldOpc) { unsigned llvm::convertAddSubFlagsOpcode(unsigned OldOpc) {
static const int NPairs = for (unsigned i = 0, e = array_lengthof(AddSubFlagsOpcodeMap); i != e; ++i)
sizeof(AddSubFlagsOpcodeMap) / sizeof(AddSubFlagsOpcodePair); if (OldOpc == AddSubFlagsOpcodeMap[i].PseudoOpc)
for (AddSubFlagsOpcodePair *OpcPair = &AddSubFlagsOpcodeMap[0], return AddSubFlagsOpcodeMap[i].MachineOpc;
*End = &AddSubFlagsOpcodeMap[NPairs]; OpcPair != End; ++OpcPair) {
if (OldOpc == OpcPair->PseudoOpc) {
return OpcPair->MachineOpc;
}
}
return 0; return 0;
} }