1 //===- EDEmitter.cpp - Generate instruction descriptions for ED -*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This tablegen backend is responsible for emitting a description of each
11 // instruction in a format that the enhanced disassembler can use to tokenize
12 // and parse instructions.
14 //===----------------------------------------------------------------------===//
16 #include "EDEmitter.h"
18 #include "AsmWriterInst.h"
19 #include "CodeGenTarget.h"
22 #include "llvm/MC/EDInstInfo.h"
23 #include "llvm/Support/ErrorHandling.h"
24 #include "llvm/Support/Format.h"
25 #include "llvm/Support/raw_ostream.h"
32 ///////////////////////////////////////////////////////////
33 // Support classes for emitting nested C data structures //
34 ///////////////////////////////////////////////////////////
41 std::vector<std::string> Entries;
43 EnumEmitter(const char *N) : Name(N) {
45 int addEntry(const char *e) {
46 Entries.push_back(std::string(e));
47 return Entries.size() - 1;
49 void emit(raw_ostream &o, unsigned int &i) {
50 o.indent(i) << "enum " << Name.c_str() << " {" << "\n";
53 unsigned int index = 0;
54 unsigned int numEntries = Entries.size();
55 for (index = 0; index < numEntries; ++index) {
56 o.indent(i) << Entries[index];
57 if (index < (numEntries - 1))
63 o.indent(i) << "};" << "\n";
66 void emitAsFlags(raw_ostream &o, unsigned int &i) {
67 o.indent(i) << "enum " << Name.c_str() << " {" << "\n";
70 unsigned int index = 0;
71 unsigned int numEntries = Entries.size();
72 unsigned int flag = 1;
73 for (index = 0; index < numEntries; ++index) {
74 o.indent(i) << Entries[index] << " = " << format("0x%x", flag);
75 if (index < (numEntries - 1))
82 o.indent(i) << "};" << "\n";
86 class ConstantEmitter {
88 virtual ~ConstantEmitter() { }
89 virtual void emit(raw_ostream &o, unsigned int &i) = 0;
92 class LiteralConstantEmitter : public ConstantEmitter {
100 LiteralConstantEmitter(int number = 0) :
104 void set(const char *string) {
109 bool is(const char *string) {
110 return !strcmp(String, string);
112 void emit(raw_ostream &o, unsigned int &i) {
120 class CompoundConstantEmitter : public ConstantEmitter {
122 unsigned int Padding;
123 std::vector<ConstantEmitter *> Entries;
125 CompoundConstantEmitter(unsigned int padding = 0) : Padding(padding) {
127 CompoundConstantEmitter &addEntry(ConstantEmitter *e) {
128 Entries.push_back(e);
132 ~CompoundConstantEmitter() {
133 while (Entries.size()) {
134 ConstantEmitter *entry = Entries.back();
139 void emit(raw_ostream &o, unsigned int &i) {
144 unsigned int numEntries = Entries.size();
146 unsigned int numToPrint;
149 if (numEntries > Padding) {
150 fprintf(stderr, "%u entries but %u padding\n", numEntries, Padding);
151 llvm_unreachable("More entries than padding");
153 numToPrint = Padding;
155 numToPrint = numEntries;
158 for (index = 0; index < numToPrint; ++index) {
160 if (index < numEntries)
161 Entries[index]->emit(o, i);
165 if (index < (numToPrint - 1))
175 class FlagsConstantEmitter : public ConstantEmitter {
177 std::vector<std::string> Flags;
179 FlagsConstantEmitter() {
181 FlagsConstantEmitter &addEntry(const char *f) {
182 Flags.push_back(std::string(f));
185 void emit(raw_ostream &o, unsigned int &i) {
187 unsigned int numFlags = Flags.size();
191 for (index = 0; index < numFlags; ++index) {
192 o << Flags[index].c_str();
193 if (index < (numFlags - 1))
200 EDEmitter::EDEmitter(RecordKeeper &R) : Records(R) {
203 /// populateOperandOrder - Accepts a CodeGenInstruction and generates its
204 /// AsmWriterInst for the desired assembly syntax, giving an ordered list of
205 /// operands in the order they appear in the printed instruction. Then, for
206 /// each entry in that list, determines the index of the same operand in the
207 /// CodeGenInstruction, and emits the resulting mapping into an array, filling
208 /// in unused slots with -1.
210 /// @arg operandOrder - The array that will be populated with the operand
211 /// mapping. Each entry will contain -1 (invalid index
212 /// into the operands present in the AsmString) or a number
213 /// representing an index in the operand descriptor array.
214 /// @arg inst - The instruction to use when looking up the operands
215 /// @arg syntax - The syntax to use, according to LLVM's enumeration
216 void populateOperandOrder(CompoundConstantEmitter *operandOrder,
217 const CodeGenInstruction &inst,
219 unsigned int numArgs = 0;
221 AsmWriterInst awInst(inst, syntax, -1, -1);
223 std::vector<AsmWriterOperand>::iterator operandIterator;
225 for (operandIterator = awInst.Operands.begin();
226 operandIterator != awInst.Operands.end();
228 if (operandIterator->OperandType ==
229 AsmWriterOperand::isMachineInstrOperand) {
230 operandOrder->addEntry(
231 new LiteralConstantEmitter(operandIterator->CGIOpNo));
237 /////////////////////////////////////////////////////
238 // Support functions for handling X86 instructions //
239 /////////////////////////////////////////////////////
241 #define SET(flag) { type->set(flag); return 0; }
243 #define REG(str) if (name == str) SET("kOperandTypeRegister");
244 #define MEM(str) if (name == str) SET("kOperandTypeX86Memory");
245 #define LEA(str) if (name == str) SET("kOperandTypeX86EffectiveAddress");
246 #define IMM(str) if (name == str) SET("kOperandTypeImmediate");
247 #define PCR(str) if (name == str) SET("kOperandTypeX86PCRelative");
249 /// X86TypeFromOpName - Processes the name of a single X86 operand (which is
250 /// actually its type) and translates it into an operand type
252 /// @arg flags - The type object to set
253 /// @arg name - The name of the operand
254 static int X86TypeFromOpName(LiteralConstantEmitter *type,
255 const std::string &name) {
317 PCR("i64i32imm_pcrel");
324 PCR("uncondbrtarget");
327 // all I, ARM mode only, conditional/unconditional
341 /// X86PopulateOperands - Handles all the operands in an X86 instruction, adding
342 /// the appropriate flags to their descriptors
344 /// @operandFlags - A reference the array of operand flag objects
345 /// @inst - The instruction to use as a source of information
346 static void X86PopulateOperands(
347 LiteralConstantEmitter *(&operandTypes)[EDIS_MAX_OPERANDS],
348 const CodeGenInstruction &inst) {
349 if (!inst.TheDef->isSubClassOf("X86Inst"))
353 unsigned int numOperands = inst.Operands.size();
355 for (index = 0; index < numOperands; ++index) {
356 const CGIOperandList::OperandInfo &operandInfo = inst.Operands[index];
357 Record &rec = *operandInfo.Rec;
359 if (X86TypeFromOpName(operandTypes[index], rec.getName()) &&
360 !rec.isSubClassOf("PointerLikeRegClass")) {
361 errs() << "Operand type: " << rec.getName().c_str() << "\n";
362 errs() << "Operand name: " << operandInfo.Name.c_str() << "\n";
363 errs() << "Instruction name: " << inst.TheDef->getName().c_str() << "\n";
364 llvm_unreachable("Unhandled type");
369 /// decorate1 - Decorates a named operand with a new flag
371 /// @operandFlags - The array of operand flag objects, which don't have names
372 /// @inst - The CodeGenInstruction, which provides a way to translate
373 /// between names and operand indices
374 /// @opName - The name of the operand
375 /// @flag - The name of the flag to add
376 static inline void decorate1(
377 FlagsConstantEmitter *(&operandFlags)[EDIS_MAX_OPERANDS],
378 const CodeGenInstruction &inst,
380 const char *opFlag) {
383 opIndex = inst.Operands.getOperandNamed(std::string(opName));
385 operandFlags[opIndex]->addEntry(opFlag);
388 #define DECORATE1(opName, opFlag) decorate1(operandFlags, inst, opName, opFlag)
390 #define MOV(source, target) { \
391 instType.set("kInstructionTypeMove"); \
392 DECORATE1(source, "kOperandFlagSource"); \
393 DECORATE1(target, "kOperandFlagTarget"); \
396 #define BRANCH(target) { \
397 instType.set("kInstructionTypeBranch"); \
398 DECORATE1(target, "kOperandFlagTarget"); \
401 #define PUSH(source) { \
402 instType.set("kInstructionTypePush"); \
403 DECORATE1(source, "kOperandFlagSource"); \
406 #define POP(target) { \
407 instType.set("kInstructionTypePop"); \
408 DECORATE1(target, "kOperandFlagTarget"); \
411 #define CALL(target) { \
412 instType.set("kInstructionTypeCall"); \
413 DECORATE1(target, "kOperandFlagTarget"); \
417 instType.set("kInstructionTypeReturn"); \
420 /// X86ExtractSemantics - Performs various checks on the name of an X86
421 /// instruction to determine what sort of an instruction it is and then adds
422 /// the appropriate flags to the instruction and its operands
424 /// @arg instType - A reference to the type for the instruction as a whole
425 /// @arg operandFlags - A reference to the array of operand flag object pointers
426 /// @arg inst - A reference to the original instruction
427 static void X86ExtractSemantics(
428 LiteralConstantEmitter &instType,
429 FlagsConstantEmitter *(&operandFlags)[EDIS_MAX_OPERANDS],
430 const CodeGenInstruction &inst) {
431 const std::string &name = inst.TheDef->getName();
433 if (name.find("MOV") != name.npos) {
434 if (name.find("MOV_V") != name.npos) {
435 // ignore (this is a pseudoinstruction)
436 } else if (name.find("MASK") != name.npos) {
437 // ignore (this is a masking move)
438 } else if (name.find("r0") != name.npos) {
439 // ignore (this is a pseudoinstruction)
440 } else if (name.find("PS") != name.npos ||
441 name.find("PD") != name.npos) {
442 // ignore (this is a shuffling move)
443 } else if (name.find("MOVS") != name.npos) {
444 // ignore (this is a string move)
445 } else if (name.find("_F") != name.npos) {
446 // TODO handle _F moves to ST(0)
447 } else if (name.find("a") != name.npos) {
448 // TODO handle moves to/from %ax
449 } else if (name.find("CMOV") != name.npos) {
451 } else if (name.find("PC") != name.npos) {
458 if (name.find("JMP") != name.npos ||
459 name.find("J") == 0) {
460 if (name.find("FAR") != name.npos && name.find("i") != name.npos) {
467 if (name.find("PUSH") != name.npos) {
468 if (name.find("CS") != name.npos ||
469 name.find("DS") != name.npos ||
470 name.find("ES") != name.npos ||
471 name.find("FS") != name.npos ||
472 name.find("GS") != name.npos ||
473 name.find("SS") != name.npos) {
474 instType.set("kInstructionTypePush");
475 // TODO add support for fixed operands
476 } else if (name.find("F") != name.npos) {
477 // ignore (this pushes onto the FP stack)
478 } else if (name.find("A") != name.npos) {
479 // ignore (pushes all GP registoers onto the stack)
480 } else if (name[name.length() - 1] == 'm') {
482 } else if (name.find("i") != name.npos) {
489 if (name.find("POP") != name.npos) {
490 if (name.find("POPCNT") != name.npos) {
491 // ignore (not a real pop)
492 } else if (name.find("CS") != name.npos ||
493 name.find("DS") != name.npos ||
494 name.find("ES") != name.npos ||
495 name.find("FS") != name.npos ||
496 name.find("GS") != name.npos ||
497 name.find("SS") != name.npos) {
498 instType.set("kInstructionTypePop");
499 // TODO add support for fixed operands
500 } else if (name.find("F") != name.npos) {
501 // ignore (this pops from the FP stack)
502 } else if (name.find("A") != name.npos) {
503 // ignore (pushes all GP registoers onto the stack)
504 } else if (name[name.length() - 1] == 'm') {
511 if (name.find("CALL") != name.npos) {
512 if (name.find("ADJ") != name.npos) {
513 // ignore (not a call)
514 } else if (name.find("SYSCALL") != name.npos) {
515 // ignore (doesn't go anywhere we know about)
516 } else if (name.find("VMCALL") != name.npos) {
517 // ignore (rather different semantics than a regular call)
518 } else if (name.find("FAR") != name.npos && name.find("i") != name.npos) {
525 if (name.find("RET") != name.npos) {
537 /////////////////////////////////////////////////////
538 // Support functions for handling ARM instructions //
539 /////////////////////////////////////////////////////
541 #define SET(flag) { type->set(flag); return 0; }
543 #define REG(str) if (name == str) SET("kOperandTypeRegister");
544 #define IMM(str) if (name == str) SET("kOperandTypeImmediate");
546 #define MISC(str, type) if (name == str) SET(type);
548 /// ARMFlagFromOpName - Processes the name of a single ARM operand (which is
549 /// actually its type) and translates it into an operand type
551 /// @arg type - The type object to set
552 /// @arg name - The name of the operand
553 static int ARMFlagFromOpName(LiteralConstantEmitter *type,
554 const std::string &name) {
570 IMM("i32imm_hilo16");
571 IMM("bf_inv_mask_imm");
574 IMM("jtblock_operand");
580 IMM("cpinst_operand");
592 IMM("jt2block_operand");
600 IMM("neon_vcvt_imm32");
607 MISC("brtarget", "kOperandTypeARMBranchTarget"); // ?
608 MISC("uncondbrtarget", "kOperandTypeARMBranchTarget"); // ?
609 MISC("t_brtarget", "kOperandTypeARMBranchTarget"); // ?
610 MISC("t_bcctarget", "kOperandTypeARMBranchTarget"); // ?
611 MISC("t_cbtarget", "kOperandTypeARMBranchTarget"); // ?
612 MISC("bltarget", "kOperandTypeARMBranchTarget"); // ?
614 MISC("br_target", "kOperandTypeARMBranchTarget"); // ?
615 MISC("bl_target", "kOperandTypeARMBranchTarget"); // ?
617 MISC("t_bltarget", "kOperandTypeARMBranchTarget"); // ?
618 MISC("t_blxtarget", "kOperandTypeARMBranchTarget"); // ?
619 MISC("so_reg", "kOperandTypeARMSoReg"); // R, R, I
620 MISC("shift_so_reg", "kOperandTypeARMSoReg"); // R, R, I
621 MISC("t2_so_reg", "kOperandTypeThumb2SoReg"); // R, I
622 MISC("so_imm", "kOperandTypeARMSoImm"); // I
623 MISC("rot_imm", "kOperandTypeARMRotImm"); // I
624 MISC("t2_so_imm", "kOperandTypeThumb2SoImm"); // I
625 MISC("so_imm2part", "kOperandTypeARMSoImm2Part"); // I
626 MISC("pred", "kOperandTypeARMPredicate"); // I, R
627 MISC("it_pred", "kOperandTypeARMPredicate"); // I
628 MISC("addrmode_imm12", "kOperandTypeAddrModeImm12"); // R, I
629 MISC("ldst_so_reg", "kOperandTypeLdStSOReg"); // R, R, I
630 MISC("addrmode2", "kOperandTypeARMAddrMode2"); // R, R, I
631 MISC("am2offset", "kOperandTypeARMAddrMode2Offset"); // R, I
632 MISC("addrmode3", "kOperandTypeARMAddrMode3"); // R, R, I
633 MISC("am3offset", "kOperandTypeARMAddrMode3Offset"); // R, I
634 MISC("ldstm_mode", "kOperandTypeARMLdStmMode"); // I
635 MISC("addrmode5", "kOperandTypeARMAddrMode5"); // R, I
636 MISC("addrmode6", "kOperandTypeARMAddrMode6"); // R, R, I, I
637 MISC("am6offset", "kOperandTypeARMAddrMode6Offset"); // R, I, I
638 MISC("addrmode6dup", "kOperandTypeARMAddrMode6"); // R, R, I, I
639 MISC("addrmode6oneL32", "kOperandTypeARMAddrMode6"); // R, R, I, I
640 MISC("addrmodepc", "kOperandTypeARMAddrModePC"); // R, I
641 MISC("addrmode7", "kOperandTypeARMAddrMode7"); // R
642 MISC("reglist", "kOperandTypeARMRegisterList"); // I, R, ...
643 MISC("dpr_reglist", "kOperandTypeARMDPRRegisterList"); // I, R, ...
644 MISC("spr_reglist", "kOperandTypeARMSPRRegisterList"); // I, R, ...
645 MISC("it_mask", "kOperandTypeThumbITMask"); // I
646 MISC("t2addrmode_reg", "kOperandTypeThumb2AddrModeReg"); // R
647 MISC("t2addrmode_imm8", "kOperandTypeThumb2AddrModeImm8"); // R, I
648 MISC("t2am_imm8_offset", "kOperandTypeThumb2AddrModeImm8Offset");//I
649 MISC("t2addrmode_imm12", "kOperandTypeThumb2AddrModeImm12"); // R, I
650 MISC("t2addrmode_so_reg", "kOperandTypeThumb2AddrModeSoReg"); // R, R, I
651 MISC("t2addrmode_imm8s4", "kOperandTypeThumb2AddrModeImm8s4"); // R, I
652 MISC("t2am_imm8s4_offset", "kOperandTypeThumb2AddrModeImm8s4Offset");
654 MISC("tb_addrmode", "kOperandTypeARMTBAddrMode"); // I
655 MISC("t_addrmode_rrs1", "kOperandTypeThumbAddrModeRegS"); // R, R
656 MISC("t_addrmode_rrs2", "kOperandTypeThumbAddrModeRegS"); // R, R
657 MISC("t_addrmode_rrs4", "kOperandTypeThumbAddrModeRegS"); // R, R
658 MISC("t_addrmode_is1", "kOperandTypeThumbAddrModeImmS"); // R, I
659 MISC("t_addrmode_is2", "kOperandTypeThumbAddrModeImmS"); // R, I
660 MISC("t_addrmode_is4", "kOperandTypeThumbAddrModeImmS"); // R, I
661 MISC("t_addrmode_rr", "kOperandTypeThumbAddrModeRR"); // R, R
662 MISC("t_addrmode_sp", "kOperandTypeThumbAddrModeSP"); // R, I
663 MISC("t_addrmode_pc", "kOperandTypeThumbAddrModePC"); // R, I
679 /// ARMPopulateOperands - Handles all the operands in an ARM instruction, adding
680 /// the appropriate flags to their descriptors
682 /// @operandFlags - A reference the array of operand flag objects
683 /// @inst - The instruction to use as a source of information
684 static void ARMPopulateOperands(
685 LiteralConstantEmitter *(&operandTypes)[EDIS_MAX_OPERANDS],
686 const CodeGenInstruction &inst) {
687 if (!inst.TheDef->isSubClassOf("InstARM") &&
688 !inst.TheDef->isSubClassOf("InstThumb"))
692 unsigned int numOperands = inst.Operands.size();
694 if (numOperands > EDIS_MAX_OPERANDS) {
695 errs() << "numOperands == " << numOperands << " > " <<
696 EDIS_MAX_OPERANDS << '\n';
697 llvm_unreachable("Too many operands");
700 for (index = 0; index < numOperands; ++index) {
701 const CGIOperandList::OperandInfo &operandInfo = inst.Operands[index];
702 Record &rec = *operandInfo.Rec;
704 if (ARMFlagFromOpName(operandTypes[index], rec.getName())) {
705 errs() << "Operand type: " << rec.getName() << '\n';
706 errs() << "Operand name: " << operandInfo.Name << '\n';
707 errs() << "Instruction name: " << inst.TheDef->getName() << '\n';
708 llvm_unreachable("Unhandled type");
713 #define BRANCH(target) { \
714 instType.set("kInstructionTypeBranch"); \
715 DECORATE1(target, "kOperandFlagTarget"); \
718 /// ARMExtractSemantics - Performs various checks on the name of an ARM
719 /// instruction to determine what sort of an instruction it is and then adds
720 /// the appropriate flags to the instruction and its operands
722 /// @arg instType - A reference to the type for the instruction as a whole
723 /// @arg operandTypes - A reference to the array of operand type object pointers
724 /// @arg operandFlags - A reference to the array of operand flag object pointers
725 /// @arg inst - A reference to the original instruction
726 static void ARMExtractSemantics(
727 LiteralConstantEmitter &instType,
728 LiteralConstantEmitter *(&operandTypes)[EDIS_MAX_OPERANDS],
729 FlagsConstantEmitter *(&operandFlags)[EDIS_MAX_OPERANDS],
730 const CodeGenInstruction &inst) {
731 const std::string &name = inst.TheDef->getName();
733 if (name == "tBcc" ||
742 if (name == "tBLr9" ||
743 name == "BLr9_pred" ||
744 name == "tBLXi_r9" ||
745 name == "tBLXr_r9" ||
752 opIndex = inst.Operands.getOperandNamed("func");
753 if (operandTypes[opIndex]->is("kOperandTypeImmediate"))
754 operandTypes[opIndex]->set("kOperandTypeARMBranchTarget");
760 /// populateInstInfo - Fills an array of InstInfos with information about each
761 /// instruction in a target
763 /// @arg infoArray - The array of InstInfo objects to populate
764 /// @arg target - The CodeGenTarget to use as a source of instructions
765 static void populateInstInfo(CompoundConstantEmitter &infoArray,
766 CodeGenTarget &target) {
767 const std::vector<const CodeGenInstruction*> &numberedInstructions =
768 target.getInstructionsByEnumValue();
771 unsigned int numInstructions = numberedInstructions.size();
773 for (index = 0; index < numInstructions; ++index) {
774 const CodeGenInstruction& inst = *numberedInstructions[index];
776 CompoundConstantEmitter *infoStruct = new CompoundConstantEmitter;
777 infoArray.addEntry(infoStruct);
779 LiteralConstantEmitter *instType = new LiteralConstantEmitter;
780 infoStruct->addEntry(instType);
782 LiteralConstantEmitter *numOperandsEmitter =
783 new LiteralConstantEmitter(inst.Operands.size());
784 infoStruct->addEntry(numOperandsEmitter);
786 CompoundConstantEmitter *operandTypeArray = new CompoundConstantEmitter;
787 infoStruct->addEntry(operandTypeArray);
789 LiteralConstantEmitter *operandTypes[EDIS_MAX_OPERANDS];
791 CompoundConstantEmitter *operandFlagArray = new CompoundConstantEmitter;
792 infoStruct->addEntry(operandFlagArray);
794 FlagsConstantEmitter *operandFlags[EDIS_MAX_OPERANDS];
796 for (unsigned operandIndex = 0;
797 operandIndex < EDIS_MAX_OPERANDS;
799 operandTypes[operandIndex] = new LiteralConstantEmitter;
800 operandTypeArray->addEntry(operandTypes[operandIndex]);
802 operandFlags[operandIndex] = new FlagsConstantEmitter;
803 operandFlagArray->addEntry(operandFlags[operandIndex]);
806 unsigned numSyntaxes = 0;
808 if (target.getName() == "X86") {
809 X86PopulateOperands(operandTypes, inst);
810 X86ExtractSemantics(*instType, operandFlags, inst);
813 else if (target.getName() == "ARM") {
814 ARMPopulateOperands(operandTypes, inst);
815 ARMExtractSemantics(*instType, operandTypes, operandFlags, inst);
819 CompoundConstantEmitter *operandOrderArray = new CompoundConstantEmitter;
821 infoStruct->addEntry(operandOrderArray);
823 for (unsigned syntaxIndex = 0;
824 syntaxIndex < EDIS_MAX_SYNTAXES;
826 CompoundConstantEmitter *operandOrder =
827 new CompoundConstantEmitter(EDIS_MAX_OPERANDS);
829 operandOrderArray->addEntry(operandOrder);
831 if (syntaxIndex < numSyntaxes) {
832 populateOperandOrder(operandOrder, inst, syntaxIndex);
840 static void emitCommonEnums(raw_ostream &o, unsigned int &i) {
841 EnumEmitter operandTypes("OperandTypes");
842 operandTypes.addEntry("kOperandTypeNone");
843 operandTypes.addEntry("kOperandTypeImmediate");
844 operandTypes.addEntry("kOperandTypeRegister");
845 operandTypes.addEntry("kOperandTypeX86Memory");
846 operandTypes.addEntry("kOperandTypeX86EffectiveAddress");
847 operandTypes.addEntry("kOperandTypeX86PCRelative");
848 operandTypes.addEntry("kOperandTypeARMBranchTarget");
849 operandTypes.addEntry("kOperandTypeARMSoReg");
850 operandTypes.addEntry("kOperandTypeARMSoImm");
851 operandTypes.addEntry("kOperandTypeARMRotImm");
852 operandTypes.addEntry("kOperandTypeARMSoImm2Part");
853 operandTypes.addEntry("kOperandTypeARMPredicate");
854 operandTypes.addEntry("kOperandTypeAddrModeImm12");
855 operandTypes.addEntry("kOperandTypeLdStSOReg");
856 operandTypes.addEntry("kOperandTypeARMAddrMode2");
857 operandTypes.addEntry("kOperandTypeARMAddrMode2Offset");
858 operandTypes.addEntry("kOperandTypeARMAddrMode3");
859 operandTypes.addEntry("kOperandTypeARMAddrMode3Offset");
860 operandTypes.addEntry("kOperandTypeARMLdStmMode");
861 operandTypes.addEntry("kOperandTypeARMAddrMode5");
862 operandTypes.addEntry("kOperandTypeARMAddrMode6");
863 operandTypes.addEntry("kOperandTypeARMAddrMode6Offset");
864 operandTypes.addEntry("kOperandTypeARMAddrMode7");
865 operandTypes.addEntry("kOperandTypeARMAddrModePC");
866 operandTypes.addEntry("kOperandTypeARMRegisterList");
867 operandTypes.addEntry("kOperandTypeARMDPRRegisterList");
868 operandTypes.addEntry("kOperandTypeARMSPRRegisterList");
869 operandTypes.addEntry("kOperandTypeARMTBAddrMode");
870 operandTypes.addEntry("kOperandTypeThumbITMask");
871 operandTypes.addEntry("kOperandTypeThumbAddrModeRegS");
872 operandTypes.addEntry("kOperandTypeThumbAddrModeImmS");
873 operandTypes.addEntry("kOperandTypeThumbAddrModeRR");
874 operandTypes.addEntry("kOperandTypeThumbAddrModeSP");
875 operandTypes.addEntry("kOperandTypeThumbAddrModePC");
876 operandTypes.addEntry("kOperandTypeThumb2AddrModeReg");
877 operandTypes.addEntry("kOperandTypeThumb2SoReg");
878 operandTypes.addEntry("kOperandTypeThumb2SoImm");
879 operandTypes.addEntry("kOperandTypeThumb2AddrModeImm8");
880 operandTypes.addEntry("kOperandTypeThumb2AddrModeImm8Offset");
881 operandTypes.addEntry("kOperandTypeThumb2AddrModeImm12");
882 operandTypes.addEntry("kOperandTypeThumb2AddrModeSoReg");
883 operandTypes.addEntry("kOperandTypeThumb2AddrModeImm8s4");
884 operandTypes.addEntry("kOperandTypeThumb2AddrModeImm8s4Offset");
885 operandTypes.emit(o, i);
889 EnumEmitter operandFlags("OperandFlags");
890 operandFlags.addEntry("kOperandFlagSource");
891 operandFlags.addEntry("kOperandFlagTarget");
892 operandFlags.emitAsFlags(o, i);
896 EnumEmitter instructionTypes("InstructionTypes");
897 instructionTypes.addEntry("kInstructionTypeNone");
898 instructionTypes.addEntry("kInstructionTypeMove");
899 instructionTypes.addEntry("kInstructionTypeBranch");
900 instructionTypes.addEntry("kInstructionTypePush");
901 instructionTypes.addEntry("kInstructionTypePop");
902 instructionTypes.addEntry("kInstructionTypeCall");
903 instructionTypes.addEntry("kInstructionTypeReturn");
904 instructionTypes.emit(o, i);
909 void EDEmitter::run(raw_ostream &o) {
912 CompoundConstantEmitter infoArray;
913 CodeGenTarget target(Records);
915 populateInstInfo(infoArray, target);
917 emitCommonEnums(o, i);
919 o << "namespace {\n";
921 o << "llvm::EDInstInfo instInfo" << target.getName().c_str() << "[] = ";
922 infoArray.emit(o, i);