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"
33 ///////////////////////////////////////////////////////////
34 // Support classes for emitting nested C data structures //
35 ///////////////////////////////////////////////////////////
42 std::vector<std::string> Entries;
44 EnumEmitter(const char *N) : Name(N) {
46 int addEntry(const char *e) {
47 Entries.push_back(std::string(e));
48 return Entries.size() - 1;
50 void emit(raw_ostream &o, unsigned int &i) {
51 o.indent(i) << "enum " << Name.c_str() << " {" << "\n";
54 unsigned int index = 0;
55 unsigned int numEntries = Entries.size();
56 for (index = 0; index < numEntries; ++index) {
57 o.indent(i) << Entries[index];
58 if (index < (numEntries - 1))
64 o.indent(i) << "};" << "\n";
67 void emitAsFlags(raw_ostream &o, unsigned int &i) {
68 o.indent(i) << "enum " << Name.c_str() << " {" << "\n";
71 unsigned int index = 0;
72 unsigned int numEntries = Entries.size();
73 unsigned int flag = 1;
74 for (index = 0; index < numEntries; ++index) {
75 o.indent(i) << Entries[index] << " = " << format("0x%x", flag);
76 if (index < (numEntries - 1))
83 o.indent(i) << "};" << "\n";
87 class ConstantEmitter {
89 virtual ~ConstantEmitter() { }
90 virtual void emit(raw_ostream &o, unsigned int &i) = 0;
93 class LiteralConstantEmitter : public ConstantEmitter {
101 LiteralConstantEmitter(int number = 0) :
105 void set(const char *string) {
110 bool is(const char *string) {
111 return !strcmp(String, string);
113 void emit(raw_ostream &o, unsigned int &i) {
121 class CompoundConstantEmitter : public ConstantEmitter {
123 unsigned int Padding;
124 std::vector<ConstantEmitter *> Entries;
126 CompoundConstantEmitter(unsigned int padding = 0) : Padding(padding) {
128 CompoundConstantEmitter &addEntry(ConstantEmitter *e) {
129 Entries.push_back(e);
133 ~CompoundConstantEmitter() {
134 while (Entries.size()) {
135 ConstantEmitter *entry = Entries.back();
140 void emit(raw_ostream &o, unsigned int &i) {
145 unsigned int numEntries = Entries.size();
147 unsigned int numToPrint;
150 if (numEntries > Padding) {
151 fprintf(stderr, "%u entries but %u padding\n", numEntries, Padding);
152 llvm_unreachable("More entries than padding");
154 numToPrint = Padding;
156 numToPrint = numEntries;
159 for (index = 0; index < numToPrint; ++index) {
161 if (index < numEntries)
162 Entries[index]->emit(o, i);
166 if (index < (numToPrint - 1))
176 class FlagsConstantEmitter : public ConstantEmitter {
178 std::vector<std::string> Flags;
180 FlagsConstantEmitter() {
182 FlagsConstantEmitter &addEntry(const char *f) {
183 Flags.push_back(std::string(f));
186 void emit(raw_ostream &o, unsigned int &i) {
188 unsigned int numFlags = Flags.size();
192 for (index = 0; index < numFlags; ++index) {
193 o << Flags[index].c_str();
194 if (index < (numFlags - 1))
201 EDEmitter::EDEmitter(RecordKeeper &R) : Records(R) {
204 /// populateOperandOrder - Accepts a CodeGenInstruction and generates its
205 /// AsmWriterInst for the desired assembly syntax, giving an ordered list of
206 /// operands in the order they appear in the printed instruction. Then, for
207 /// each entry in that list, determines the index of the same operand in the
208 /// CodeGenInstruction, and emits the resulting mapping into an array, filling
209 /// in unused slots with -1.
211 /// @arg operandOrder - The array that will be populated with the operand
212 /// mapping. Each entry will contain -1 (invalid index
213 /// into the operands present in the AsmString) or a number
214 /// representing an index in the operand descriptor array.
215 /// @arg inst - The instruction to use when looking up the operands
216 /// @arg syntax - The syntax to use, according to LLVM's enumeration
217 void populateOperandOrder(CompoundConstantEmitter *operandOrder,
218 const CodeGenInstruction &inst,
220 unsigned int numArgs = 0;
222 AsmWriterInst awInst(inst, syntax, -1, -1);
224 std::vector<AsmWriterOperand>::iterator operandIterator;
226 for (operandIterator = awInst.Operands.begin();
227 operandIterator != awInst.Operands.end();
229 if (operandIterator->OperandType ==
230 AsmWriterOperand::isMachineInstrOperand) {
231 operandOrder->addEntry(
232 new LiteralConstantEmitter(operandIterator->CGIOpNo));
238 /////////////////////////////////////////////////////
239 // Support functions for handling X86 instructions //
240 /////////////////////////////////////////////////////
242 #define SET(flag) { type->set(flag); return 0; }
244 #define REG(str) if (name == str) SET("kOperandTypeRegister");
245 #define MEM(str) if (name == str) SET("kOperandTypeX86Memory");
246 #define LEA(str) if (name == str) SET("kOperandTypeX86EffectiveAddress");
247 #define IMM(str) if (name == str) SET("kOperandTypeImmediate");
248 #define PCR(str) if (name == str) SET("kOperandTypeX86PCRelative");
250 /// X86TypeFromOpName - Processes the name of a single X86 operand (which is
251 /// actually its type) and translates it into an operand type
253 /// @arg flags - The type object to set
254 /// @arg name - The name of the operand
255 static int X86TypeFromOpName(LiteralConstantEmitter *type,
256 const std::string &name) {
318 PCR("i64i32imm_pcrel");
338 /// X86PopulateOperands - Handles all the operands in an X86 instruction, adding
339 /// the appropriate flags to their descriptors
341 /// @operandFlags - A reference the array of operand flag objects
342 /// @inst - The instruction to use as a source of information
343 static void X86PopulateOperands(
344 LiteralConstantEmitter *(&operandTypes)[EDIS_MAX_OPERANDS],
345 const CodeGenInstruction &inst) {
346 if (!inst.TheDef->isSubClassOf("X86Inst"))
350 unsigned int numOperands = inst.Operands.size();
352 for (index = 0; index < numOperands; ++index) {
353 const CGIOperandList::OperandInfo &operandInfo = inst.Operands[index];
354 Record &rec = *operandInfo.Rec;
356 if (X86TypeFromOpName(operandTypes[index], rec.getName())) {
357 errs() << "Operand type: " << rec.getName().c_str() << "\n";
358 errs() << "Operand name: " << operandInfo.Name.c_str() << "\n";
359 errs() << "Instruction name: " << inst.TheDef->getName().c_str() << "\n";
360 llvm_unreachable("Unhandled type");
365 /// decorate1 - Decorates a named operand with a new flag
367 /// @operandFlags - The array of operand flag objects, which don't have names
368 /// @inst - The CodeGenInstruction, which provides a way to translate
369 /// between names and operand indices
370 /// @opName - The name of the operand
371 /// @flag - The name of the flag to add
372 static inline void decorate1(
373 FlagsConstantEmitter *(&operandFlags)[EDIS_MAX_OPERANDS],
374 const CodeGenInstruction &inst,
376 const char *opFlag) {
379 opIndex = inst.Operands.getOperandNamed(std::string(opName));
381 operandFlags[opIndex]->addEntry(opFlag);
384 #define DECORATE1(opName, opFlag) decorate1(operandFlags, inst, opName, opFlag)
386 #define MOV(source, target) { \
387 instType.set("kInstructionTypeMove"); \
388 DECORATE1(source, "kOperandFlagSource"); \
389 DECORATE1(target, "kOperandFlagTarget"); \
392 #define BRANCH(target) { \
393 instType.set("kInstructionTypeBranch"); \
394 DECORATE1(target, "kOperandFlagTarget"); \
397 #define PUSH(source) { \
398 instType.set("kInstructionTypePush"); \
399 DECORATE1(source, "kOperandFlagSource"); \
402 #define POP(target) { \
403 instType.set("kInstructionTypePop"); \
404 DECORATE1(target, "kOperandFlagTarget"); \
407 #define CALL(target) { \
408 instType.set("kInstructionTypeCall"); \
409 DECORATE1(target, "kOperandFlagTarget"); \
413 instType.set("kInstructionTypeReturn"); \
416 /// X86ExtractSemantics - Performs various checks on the name of an X86
417 /// instruction to determine what sort of an instruction it is and then adds
418 /// the appropriate flags to the instruction and its operands
420 /// @arg instType - A reference to the type for the instruction as a whole
421 /// @arg operandFlags - A reference to the array of operand flag object pointers
422 /// @arg inst - A reference to the original instruction
423 static void X86ExtractSemantics(
424 LiteralConstantEmitter &instType,
425 FlagsConstantEmitter *(&operandFlags)[EDIS_MAX_OPERANDS],
426 const CodeGenInstruction &inst) {
427 const std::string &name = inst.TheDef->getName();
429 if (name.find("MOV") != name.npos) {
430 if (name.find("MOV_V") != name.npos) {
431 // ignore (this is a pseudoinstruction)
432 } else if (name.find("MASK") != name.npos) {
433 // ignore (this is a masking move)
434 } else if (name.find("r0") != name.npos) {
435 // ignore (this is a pseudoinstruction)
436 } else if (name.find("PS") != name.npos ||
437 name.find("PD") != name.npos) {
438 // ignore (this is a shuffling move)
439 } else if (name.find("MOVS") != name.npos) {
440 // ignore (this is a string move)
441 } else if (name.find("_F") != name.npos) {
442 // TODO handle _F moves to ST(0)
443 } else if (name.find("a") != name.npos) {
444 // TODO handle moves to/from %ax
445 } else if (name.find("CMOV") != name.npos) {
447 } else if (name.find("PC") != name.npos) {
454 if (name.find("JMP") != name.npos ||
455 name.find("J") == 0) {
456 if (name.find("FAR") != name.npos && name.find("i") != name.npos) {
463 if (name.find("PUSH") != name.npos) {
464 if (name.find("CS") != name.npos ||
465 name.find("DS") != name.npos ||
466 name.find("ES") != name.npos ||
467 name.find("FS") != name.npos ||
468 name.find("GS") != name.npos ||
469 name.find("SS") != name.npos) {
470 instType.set("kInstructionTypePush");
471 // TODO add support for fixed operands
472 } else if (name.find("F") != name.npos) {
473 // ignore (this pushes onto the FP stack)
474 } else if (name.find("A") != name.npos) {
475 // ignore (pushes all GP registoers onto the stack)
476 } else if (name[name.length() - 1] == 'm') {
478 } else if (name.find("i") != name.npos) {
485 if (name.find("POP") != name.npos) {
486 if (name.find("POPCNT") != name.npos) {
487 // ignore (not a real pop)
488 } else if (name.find("CS") != name.npos ||
489 name.find("DS") != name.npos ||
490 name.find("ES") != name.npos ||
491 name.find("FS") != name.npos ||
492 name.find("GS") != name.npos ||
493 name.find("SS") != name.npos) {
494 instType.set("kInstructionTypePop");
495 // TODO add support for fixed operands
496 } else if (name.find("F") != name.npos) {
497 // ignore (this pops from the FP stack)
498 } else if (name.find("A") != name.npos) {
499 // ignore (pushes all GP registoers onto the stack)
500 } else if (name[name.length() - 1] == 'm') {
507 if (name.find("CALL") != name.npos) {
508 if (name.find("ADJ") != name.npos) {
509 // ignore (not a call)
510 } else if (name.find("SYSCALL") != name.npos) {
511 // ignore (doesn't go anywhere we know about)
512 } else if (name.find("VMCALL") != name.npos) {
513 // ignore (rather different semantics than a regular call)
514 } else if (name.find("FAR") != name.npos && name.find("i") != name.npos) {
521 if (name.find("RET") != name.npos) {
533 /////////////////////////////////////////////////////
534 // Support functions for handling ARM instructions //
535 /////////////////////////////////////////////////////
537 #define SET(flag) { type->set(flag); return 0; }
539 #define REG(str) if (name == str) SET("kOperandTypeRegister");
540 #define IMM(str) if (name == str) SET("kOperandTypeImmediate");
542 #define MISC(str, type) if (name == str) SET(type);
544 /// ARMFlagFromOpName - Processes the name of a single ARM operand (which is
545 /// actually its type) and translates it into an operand type
547 /// @arg type - The type object to set
548 /// @arg name - The name of the operand
549 static int ARMFlagFromOpName(LiteralConstantEmitter *type,
550 const std::string &name) {
567 IMM("bf_inv_mask_imm");
568 IMM("jtblock_operand");
570 IMM("cpinst_operand");
582 IMM("jt2block_operand");
587 IMM("neon_vcvt_imm32");
589 MISC("brtarget", "kOperandTypeARMBranchTarget"); // ?
590 MISC("t_brtarget", "kOperandTypeARMBranchTarget"); // ?
591 MISC("t_bcctarget", "kOperandTypeARMBranchTarget"); // ?
592 MISC("t_cbtarget", "kOperandTypeARMBranchTarget"); // ?
593 MISC("bltarget", "kOperandTypeARMBranchTarget"); // ?
594 MISC("t_bltarget", "kOperandTypeARMBranchTarget"); // ?
595 MISC("t_blxtarget", "kOperandTypeARMBranchTarget"); // ?
596 MISC("so_reg", "kOperandTypeARMSoReg"); // R, R, I
597 MISC("shift_so_reg", "kOperandTypeARMSoReg"); // R, R, I
598 MISC("t2_so_reg", "kOperandTypeThumb2SoReg"); // R, I
599 MISC("so_imm", "kOperandTypeARMSoImm"); // I
600 MISC("rot_imm", "kOperandTypeARMRotImm"); // I
601 MISC("t2_so_imm", "kOperandTypeThumb2SoImm"); // I
602 MISC("so_imm2part", "kOperandTypeARMSoImm2Part"); // I
603 MISC("pred", "kOperandTypeARMPredicate"); // I, R
604 MISC("it_pred", "kOperandTypeARMPredicate"); // I
605 MISC("addrmode_imm12", "kOperandTypeAddrModeImm12"); // R, I
606 MISC("ldst_so_reg", "kOperandTypeLdStSOReg"); // R, R, I
607 MISC("addrmode2", "kOperandTypeARMAddrMode2"); // R, R, I
608 MISC("am2offset", "kOperandTypeARMAddrMode2Offset"); // R, I
609 MISC("addrmode3", "kOperandTypeARMAddrMode3"); // R, R, I
610 MISC("am3offset", "kOperandTypeARMAddrMode3Offset"); // R, I
611 MISC("ldstm_mode", "kOperandTypeARMLdStmMode"); // I
612 MISC("addrmode5", "kOperandTypeARMAddrMode5"); // R, I
613 MISC("addrmode6", "kOperandTypeARMAddrMode6"); // R, R, I, I
614 MISC("am6offset", "kOperandTypeARMAddrMode6Offset"); // R, I, I
615 MISC("addrmode6dup", "kOperandTypeARMAddrMode6"); // R, R, I, I
616 MISC("addrmodepc", "kOperandTypeARMAddrModePC"); // R, I
617 MISC("reglist", "kOperandTypeARMRegisterList"); // I, R, ...
618 MISC("dpr_reglist", "kOperandTypeARMDPRRegisterList"); // I, R, ...
619 MISC("spr_reglist", "kOperandTypeARMSPRRegisterList"); // I, R, ...
620 MISC("it_mask", "kOperandTypeThumbITMask"); // I
621 MISC("t2addrmode_imm8", "kOperandTypeThumb2AddrModeImm8"); // R, I
622 MISC("t2am_imm8_offset", "kOperandTypeThumb2AddrModeImm8Offset");//I
623 MISC("t2addrmode_imm12", "kOperandTypeThumb2AddrModeImm12"); // R, I
624 MISC("t2addrmode_so_reg", "kOperandTypeThumb2AddrModeSoReg"); // R, R, I
625 MISC("t2addrmode_imm8s4", "kOperandTypeThumb2AddrModeImm8s4"); // R, I
626 MISC("t2am_imm8s4_offset", "kOperandTypeThumb2AddrModeImm8s4Offset");
628 MISC("tb_addrmode", "kOperandTypeARMTBAddrMode"); // I
629 MISC("t_addrmode_s1", "kOperandTypeThumbAddrModeS1"); // R, I, R
630 MISC("t_addrmode_s2", "kOperandTypeThumbAddrModeS2"); // R, I, R
631 MISC("t_addrmode_s4", "kOperandTypeThumbAddrModeS4"); // R, I, R
632 MISC("t_addrmode_rr", "kOperandTypeThumbAddrModeRR"); // R, R
633 MISC("t_addrmode_sp", "kOperandTypeThumbAddrModeSP"); // R, I
634 MISC("t_addrmode_pc", "kOperandTypeThumbAddrModePC"); // R, I
650 /// ARMPopulateOperands - Handles all the operands in an ARM instruction, adding
651 /// the appropriate flags to their descriptors
653 /// @operandFlags - A reference the array of operand flag objects
654 /// @inst - The instruction to use as a source of information
655 static void ARMPopulateOperands(
656 LiteralConstantEmitter *(&operandTypes)[EDIS_MAX_OPERANDS],
657 const CodeGenInstruction &inst) {
658 if (!inst.TheDef->isSubClassOf("InstARM") &&
659 !inst.TheDef->isSubClassOf("InstThumb"))
663 unsigned int numOperands = inst.Operands.size();
665 if (numOperands > EDIS_MAX_OPERANDS) {
666 errs() << "numOperands == " << numOperands << " > " <<
667 EDIS_MAX_OPERANDS << '\n';
668 llvm_unreachable("Too many operands");
671 for (index = 0; index < numOperands; ++index) {
672 const CGIOperandList::OperandInfo &operandInfo = inst.Operands[index];
673 Record &rec = *operandInfo.Rec;
675 if (ARMFlagFromOpName(operandTypes[index], rec.getName())) {
676 errs() << "Operand type: " << rec.getName() << '\n';
677 errs() << "Operand name: " << operandInfo.Name << '\n';
678 errs() << "Instruction name: " << inst.TheDef->getName() << '\n';
679 llvm_unreachable("Unhandled type");
684 #define BRANCH(target) { \
685 instType.set("kInstructionTypeBranch"); \
686 DECORATE1(target, "kOperandFlagTarget"); \
689 /// ARMExtractSemantics - Performs various checks on the name of an ARM
690 /// instruction to determine what sort of an instruction it is and then adds
691 /// the appropriate flags to the instruction and its operands
693 /// @arg instType - A reference to the type for the instruction as a whole
694 /// @arg operandTypes - A reference to the array of operand type object pointers
695 /// @arg operandFlags - A reference to the array of operand flag object pointers
696 /// @arg inst - A reference to the original instruction
697 static void ARMExtractSemantics(
698 LiteralConstantEmitter &instType,
699 LiteralConstantEmitter *(&operandTypes)[EDIS_MAX_OPERANDS],
700 FlagsConstantEmitter *(&operandFlags)[EDIS_MAX_OPERANDS],
701 const CodeGenInstruction &inst) {
702 const std::string &name = inst.TheDef->getName();
704 if (name == "tBcc" ||
713 if (name == "tBLr9" ||
714 name == "BLr9_pred" ||
715 name == "tBLXi_r9" ||
716 name == "tBLXr_r9" ||
723 opIndex = inst.Operands.getOperandNamed("func");
724 if (operandTypes[opIndex]->is("kOperandTypeImmediate"))
725 operandTypes[opIndex]->set("kOperandTypeARMBranchTarget");
731 /// populateInstInfo - Fills an array of InstInfos with information about each
732 /// instruction in a target
734 /// @arg infoArray - The array of InstInfo objects to populate
735 /// @arg target - The CodeGenTarget to use as a source of instructions
736 static void populateInstInfo(CompoundConstantEmitter &infoArray,
737 CodeGenTarget &target) {
738 const std::vector<const CodeGenInstruction*> &numberedInstructions =
739 target.getInstructionsByEnumValue();
742 unsigned int numInstructions = numberedInstructions.size();
744 for (index = 0; index < numInstructions; ++index) {
745 const CodeGenInstruction& inst = *numberedInstructions[index];
747 CompoundConstantEmitter *infoStruct = new CompoundConstantEmitter;
748 infoArray.addEntry(infoStruct);
750 LiteralConstantEmitter *instType = new LiteralConstantEmitter;
751 infoStruct->addEntry(instType);
753 LiteralConstantEmitter *numOperandsEmitter =
754 new LiteralConstantEmitter(inst.Operands.size());
755 infoStruct->addEntry(numOperandsEmitter);
757 CompoundConstantEmitter *operandTypeArray = new CompoundConstantEmitter;
758 infoStruct->addEntry(operandTypeArray);
760 LiteralConstantEmitter *operandTypes[EDIS_MAX_OPERANDS];
762 CompoundConstantEmitter *operandFlagArray = new CompoundConstantEmitter;
763 infoStruct->addEntry(operandFlagArray);
765 FlagsConstantEmitter *operandFlags[EDIS_MAX_OPERANDS];
767 for (unsigned operandIndex = 0;
768 operandIndex < EDIS_MAX_OPERANDS;
770 operandTypes[operandIndex] = new LiteralConstantEmitter;
771 operandTypeArray->addEntry(operandTypes[operandIndex]);
773 operandFlags[operandIndex] = new FlagsConstantEmitter;
774 operandFlagArray->addEntry(operandFlags[operandIndex]);
777 unsigned numSyntaxes = 0;
779 if (target.getName() == "X86") {
780 X86PopulateOperands(operandTypes, inst);
781 X86ExtractSemantics(*instType, operandFlags, inst);
784 else if (target.getName() == "ARM") {
785 ARMPopulateOperands(operandTypes, inst);
786 ARMExtractSemantics(*instType, operandTypes, operandFlags, inst);
790 CompoundConstantEmitter *operandOrderArray = new CompoundConstantEmitter;
792 infoStruct->addEntry(operandOrderArray);
794 for (unsigned syntaxIndex = 0;
795 syntaxIndex < EDIS_MAX_SYNTAXES;
797 CompoundConstantEmitter *operandOrder =
798 new CompoundConstantEmitter(EDIS_MAX_OPERANDS);
800 operandOrderArray->addEntry(operandOrder);
802 if (syntaxIndex < numSyntaxes) {
803 populateOperandOrder(operandOrder, inst, syntaxIndex);
811 static void emitCommonEnums(raw_ostream &o, unsigned int &i) {
812 EnumEmitter operandTypes("OperandTypes");
813 operandTypes.addEntry("kOperandTypeNone");
814 operandTypes.addEntry("kOperandTypeImmediate");
815 operandTypes.addEntry("kOperandTypeRegister");
816 operandTypes.addEntry("kOperandTypeX86Memory");
817 operandTypes.addEntry("kOperandTypeX86EffectiveAddress");
818 operandTypes.addEntry("kOperandTypeX86PCRelative");
819 operandTypes.addEntry("kOperandTypeARMBranchTarget");
820 operandTypes.addEntry("kOperandTypeARMSoReg");
821 operandTypes.addEntry("kOperandTypeARMSoImm");
822 operandTypes.addEntry("kOperandTypeARMRotImm");
823 operandTypes.addEntry("kOperandTypeARMSoImm2Part");
824 operandTypes.addEntry("kOperandTypeARMPredicate");
825 operandTypes.addEntry("kOperandTypeAddrModeImm12");
826 operandTypes.addEntry("kOperandTypeLdStSOReg");
827 operandTypes.addEntry("kOperandTypeARMAddrMode2");
828 operandTypes.addEntry("kOperandTypeARMAddrMode2Offset");
829 operandTypes.addEntry("kOperandTypeARMAddrMode3");
830 operandTypes.addEntry("kOperandTypeARMAddrMode3Offset");
831 operandTypes.addEntry("kOperandTypeARMLdStmMode");
832 operandTypes.addEntry("kOperandTypeARMAddrMode5");
833 operandTypes.addEntry("kOperandTypeARMAddrMode6");
834 operandTypes.addEntry("kOperandTypeARMAddrMode6Offset");
835 operandTypes.addEntry("kOperandTypeARMAddrModePC");
836 operandTypes.addEntry("kOperandTypeARMRegisterList");
837 operandTypes.addEntry("kOperandTypeARMDPRRegisterList");
838 operandTypes.addEntry("kOperandTypeARMSPRRegisterList");
839 operandTypes.addEntry("kOperandTypeARMTBAddrMode");
840 operandTypes.addEntry("kOperandTypeThumbITMask");
841 operandTypes.addEntry("kOperandTypeThumbAddrModeS1");
842 operandTypes.addEntry("kOperandTypeThumbAddrModeS2");
843 operandTypes.addEntry("kOperandTypeThumbAddrModeS4");
844 operandTypes.addEntry("kOperandTypeThumbAddrModeRR");
845 operandTypes.addEntry("kOperandTypeThumbAddrModeSP");
846 operandTypes.addEntry("kOperandTypeThumbAddrModePC");
847 operandTypes.addEntry("kOperandTypeThumb2SoReg");
848 operandTypes.addEntry("kOperandTypeThumb2SoImm");
849 operandTypes.addEntry("kOperandTypeThumb2AddrModeImm8");
850 operandTypes.addEntry("kOperandTypeThumb2AddrModeImm8Offset");
851 operandTypes.addEntry("kOperandTypeThumb2AddrModeImm12");
852 operandTypes.addEntry("kOperandTypeThumb2AddrModeSoReg");
853 operandTypes.addEntry("kOperandTypeThumb2AddrModeImm8s4");
854 operandTypes.addEntry("kOperandTypeThumb2AddrModeImm8s4Offset");
855 operandTypes.emit(o, i);
859 EnumEmitter operandFlags("OperandFlags");
860 operandFlags.addEntry("kOperandFlagSource");
861 operandFlags.addEntry("kOperandFlagTarget");
862 operandFlags.emitAsFlags(o, i);
866 EnumEmitter instructionTypes("InstructionTypes");
867 instructionTypes.addEntry("kInstructionTypeNone");
868 instructionTypes.addEntry("kInstructionTypeMove");
869 instructionTypes.addEntry("kInstructionTypeBranch");
870 instructionTypes.addEntry("kInstructionTypePush");
871 instructionTypes.addEntry("kInstructionTypePop");
872 instructionTypes.addEntry("kInstructionTypeCall");
873 instructionTypes.addEntry("kInstructionTypeReturn");
874 instructionTypes.emit(o, i);
879 void EDEmitter::run(raw_ostream &o) {
882 CompoundConstantEmitter infoArray;
883 CodeGenTarget target;
885 populateInstInfo(infoArray, target);
887 emitCommonEnums(o, i);
889 o << "namespace {\n";
891 o << "llvm::EDInstInfo instInfo" << target.getName().c_str() << "[] = ";
892 infoArray.emit(o, i);