|
41 | 41 | using namespace llvm; |
42 | 42 |
|
43 | 43 | static cl::OptionCategory InstrInfoEmitterCat("Options for -gen-instr-info"); |
| 44 | + |
| 45 | +static cl::opt<bool> |
| 46 | + EnableOperandTypeMappings("emit-operand-types", |
| 47 | + cl::desc("Emit operand type mappings"), |
| 48 | + cl::cat(InstrInfoEmitterCat), cl::init(false)); |
| 49 | + |
| 50 | +static cl::opt<bool> EnableLogicalOperandSizeMappings( |
| 51 | + "emit-logical-operand-size", cl::desc("Emit logical operand size mappings"), |
| 52 | + cl::cat(InstrInfoEmitterCat), cl::init(false)); |
| 53 | + |
44 | 54 | static cl::opt<bool> ExpandMIOperandInfo( |
45 | 55 | "instr-info-expand-mi-operand-info", |
46 | 56 | cl::desc("Expand operand's MIOperandInfo DAG into suboperands"), |
@@ -338,8 +348,8 @@ void InstrInfoEmitter::emitOperandNameMappings( |
338 | 348 | void InstrInfoEmitter::emitOperandTypeMappings( |
339 | 349 | raw_ostream &OS, const CodeGenTarget &Target, |
340 | 350 | ArrayRef<const CodeGenInstruction *> NumberedInstructions) { |
341 | | - |
342 | 351 | StringRef Namespace = Target.getInstNamespace(); |
| 352 | + |
343 | 353 | ArrayRef<const Record *> Operands = |
344 | 354 | Records.getAllDerivedDefinitions("Operand"); |
345 | 355 | ArrayRef<const Record *> RegisterOperands = |
@@ -461,10 +471,10 @@ void InstrInfoEmitter::emitOperandTypeMappings( |
461 | 471 | SizeToOperandName[Size].push_back(Op->getName()); |
462 | 472 | } |
463 | 473 | OS << " default: return 0;\n"; |
464 | | - for (const auto &KV : SizeToOperandName) { |
465 | | - for (const StringRef &OperandName : KV.second) |
| 474 | + for (const auto &[Size, Names] : SizeToOperandName) { |
| 475 | + for (const StringRef &OperandName : Names) |
466 | 476 | OS << " case OpTypes::" << OperandName << ":\n"; |
467 | | - OS << " return " << KV.first << ";\n\n"; |
| 477 | + OS << " return " << Size << ";\n\n"; |
468 | 478 | } |
469 | 479 | OS << " }\n}\n"; |
470 | 480 | OS << "} // end namespace llvm::" << Namespace << "\n"; |
@@ -1124,11 +1134,15 @@ void InstrInfoEmitter::run(raw_ostream &OS) { |
1124 | 1134 | Timer.startTimer("Emit operand name mappings"); |
1125 | 1135 | emitOperandNameMappings(OS, Target, NumberedInstructions); |
1126 | 1136 |
|
1127 | | - Timer.startTimer("Emit operand type mappings"); |
1128 | | - emitOperandTypeMappings(OS, Target, NumberedInstructions); |
| 1137 | + if (EnableOperandTypeMappings) { |
| 1138 | + Timer.startTimer("Emit operand type mappings"); |
| 1139 | + emitOperandTypeMappings(OS, Target, NumberedInstructions); |
| 1140 | + } |
1129 | 1141 |
|
1130 | | - Timer.startTimer("Emit logical operand size mappings"); |
1131 | | - emitLogicalOperandSizeMappings(OS, TargetName, NumberedInstructions); |
| 1142 | + if (EnableLogicalOperandSizeMappings) { |
| 1143 | + Timer.startTimer("Emit logical operand size mappings"); |
| 1144 | + emitLogicalOperandSizeMappings(OS, TargetName, NumberedInstructions); |
| 1145 | + } |
1132 | 1146 |
|
1133 | 1147 | Timer.startTimer("Emit logical operand type mappings"); |
1134 | 1148 | emitLogicalOperandTypeMappings(OS, TargetName, NumberedInstructions); |
|
0 commit comments