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");
598 IMM("imm0_65535_expr");
602 IMM("jt2block_operand");
609 IMM("neon_vcvt_imm32");
616 MISC("brtarget", "kOperandTypeARMBranchTarget"); // ?
617 MISC("uncondbrtarget", "kOperandTypeARMBranchTarget"); // ?
618 MISC("t_brtarget", "kOperandTypeARMBranchTarget"); // ?
619 MISC("t_bcctarget", "kOperandTypeARMBranchTarget"); // ?
620 MISC("t_cbtarget", "kOperandTypeARMBranchTarget"); // ?
621 MISC("bltarget", "kOperandTypeARMBranchTarget"); // ?
623 MISC("br_target", "kOperandTypeARMBranchTarget"); // ?
624 MISC("bl_target", "kOperandTypeARMBranchTarget"); // ?
626 MISC("t_bltarget", "kOperandTypeARMBranchTarget"); // ?
627 MISC("t_blxtarget", "kOperandTypeARMBranchTarget"); // ?
628 MISC("so_reg_imm", "kOperandTypeARMSoRegReg"); // R, R, I
629 MISC("so_reg_reg", "kOperandTypeARMSoRegImm"); // R, R, I
630 MISC("shift_so_reg_reg", "kOperandTypeARMSoRegReg"); // R, R, I
631 MISC("shift_so_reg_imm", "kOperandTypeARMSoRegImm"); // R, R, I
632 MISC("t2_so_reg", "kOperandTypeThumb2SoReg"); // R, I
633 MISC("so_imm", "kOperandTypeARMSoImm"); // I
634 MISC("rot_imm", "kOperandTypeARMRotImm"); // I
635 MISC("t2_so_imm", "kOperandTypeThumb2SoImm"); // I
636 MISC("so_imm2part", "kOperandTypeARMSoImm2Part"); // I
637 MISC("pred", "kOperandTypeARMPredicate"); // I, R
638 MISC("it_pred", "kOperandTypeARMPredicate"); // I
639 MISC("addrmode_imm12", "kOperandTypeAddrModeImm12"); // R, I
640 MISC("ldst_so_reg", "kOperandTypeLdStSOReg"); // R, R, I
641 MISC("addrmode2", "kOperandTypeARMAddrMode2"); // R, R, I
642 MISC("am2offset", "kOperandTypeARMAddrMode2Offset"); // R, I
643 MISC("addrmode3", "kOperandTypeARMAddrMode3"); // R, R, I
644 MISC("am3offset", "kOperandTypeARMAddrMode3Offset"); // R, I
645 MISC("ldstm_mode", "kOperandTypeARMLdStmMode"); // I
646 MISC("addrmode5", "kOperandTypeARMAddrMode5"); // R, I
647 MISC("addrmode6", "kOperandTypeARMAddrMode6"); // R, R, I, I
648 MISC("am6offset", "kOperandTypeARMAddrMode6Offset"); // R, I, I
649 MISC("addrmode6dup", "kOperandTypeARMAddrMode6"); // R, R, I, I
650 MISC("addrmode6oneL32", "kOperandTypeARMAddrMode6"); // R, R, I, I
651 MISC("addrmodepc", "kOperandTypeARMAddrModePC"); // R, I
652 MISC("addrmode7", "kOperandTypeARMAddrMode7"); // R
653 MISC("reglist", "kOperandTypeARMRegisterList"); // I, R, ...
654 MISC("dpr_reglist", "kOperandTypeARMDPRRegisterList"); // I, R, ...
655 MISC("spr_reglist", "kOperandTypeARMSPRRegisterList"); // I, R, ...
656 MISC("it_mask", "kOperandTypeThumbITMask"); // I
657 MISC("t2addrmode_reg", "kOperandTypeThumb2AddrModeReg"); // R
658 MISC("t2addrmode_imm8", "kOperandTypeThumb2AddrModeImm8"); // R, I
659 MISC("t2am_imm8_offset", "kOperandTypeThumb2AddrModeImm8Offset");//I
660 MISC("t2addrmode_imm12", "kOperandTypeThumb2AddrModeImm12"); // R, I
661 MISC("t2addrmode_so_reg", "kOperandTypeThumb2AddrModeSoReg"); // R, R, I
662 MISC("t2addrmode_imm8s4", "kOperandTypeThumb2AddrModeImm8s4"); // R, I
663 MISC("t2am_imm8s4_offset", "kOperandTypeThumb2AddrModeImm8s4Offset");
665 MISC("tb_addrmode", "kOperandTypeARMTBAddrMode"); // I
666 MISC("t_addrmode_rrs1", "kOperandTypeThumbAddrModeRegS1"); // R, R
667 MISC("t_addrmode_rrs2", "kOperandTypeThumbAddrModeRegS2"); // R, R
668 MISC("t_addrmode_rrs4", "kOperandTypeThumbAddrModeRegS4"); // R, R
669 MISC("t_addrmode_is1", "kOperandTypeThumbAddrModeImmS1"); // R, I
670 MISC("t_addrmode_is2", "kOperandTypeThumbAddrModeImmS2"); // R, I
671 MISC("t_addrmode_is4", "kOperandTypeThumbAddrModeImmS4"); // R, I
672 MISC("t_addrmode_rr", "kOperandTypeThumbAddrModeRR"); // R, R
673 MISC("t_addrmode_sp", "kOperandTypeThumbAddrModeSP"); // R, I
674 MISC("t_addrmode_pc", "kOperandTypeThumbAddrModePC"); // R, I
685 /// ARMPopulateOperands - Handles all the operands in an ARM instruction, adding
686 /// the appropriate flags to their descriptors
688 /// @operandFlags - A reference the array of operand flag objects
689 /// @inst - The instruction to use as a source of information
690 static void ARMPopulateOperands(
691 LiteralConstantEmitter *(&operandTypes)[EDIS_MAX_OPERANDS],
692 const CodeGenInstruction &inst) {
693 if (!inst.TheDef->isSubClassOf("InstARM") &&
694 !inst.TheDef->isSubClassOf("InstThumb"))
698 unsigned int numOperands = inst.Operands.size();
700 if (numOperands > EDIS_MAX_OPERANDS) {
701 errs() << "numOperands == " << numOperands << " > " <<
702 EDIS_MAX_OPERANDS << '\n';
703 llvm_unreachable("Too many operands");
706 for (index = 0; index < numOperands; ++index) {
707 const CGIOperandList::OperandInfo &operandInfo = inst.Operands[index];
708 Record &rec = *operandInfo.Rec;
710 if (ARMFlagFromOpName(operandTypes[index], rec.getName())) {
711 errs() << "Operand type: " << rec.getName() << '\n';
712 errs() << "Operand name: " << operandInfo.Name << '\n';
713 errs() << "Instruction name: " << inst.TheDef->getName() << '\n';
714 llvm_unreachable("Unhandled type");
719 #define BRANCH(target) { \
720 instType.set("kInstructionTypeBranch"); \
721 DECORATE1(target, "kOperandFlagTarget"); \
724 /// ARMExtractSemantics - Performs various checks on the name of an ARM
725 /// instruction to determine what sort of an instruction it is and then adds
726 /// the appropriate flags to the instruction and its operands
728 /// @arg instType - A reference to the type for the instruction as a whole
729 /// @arg operandTypes - A reference to the array of operand type object pointers
730 /// @arg operandFlags - A reference to the array of operand flag object pointers
731 /// @arg inst - A reference to the original instruction
732 static void ARMExtractSemantics(
733 LiteralConstantEmitter &instType,
734 LiteralConstantEmitter *(&operandTypes)[EDIS_MAX_OPERANDS],
735 FlagsConstantEmitter *(&operandFlags)[EDIS_MAX_OPERANDS],
736 const CodeGenInstruction &inst) {
737 const std::string &name = inst.TheDef->getName();
739 if (name == "tBcc" ||
748 if (name == "tBLr9" ||
749 name == "BLr9_pred" ||
750 name == "tBLXi_r9" ||
751 name == "tBLXr_r9" ||
758 opIndex = inst.Operands.getOperandNamed("func");
759 if (operandTypes[opIndex]->is("kOperandTypeImmediate"))
760 operandTypes[opIndex]->set("kOperandTypeARMBranchTarget");
766 /// populateInstInfo - Fills an array of InstInfos with information about each
767 /// instruction in a target
769 /// @arg infoArray - The array of InstInfo objects to populate
770 /// @arg target - The CodeGenTarget to use as a source of instructions
771 static void populateInstInfo(CompoundConstantEmitter &infoArray,
772 CodeGenTarget &target) {
773 const std::vector<const CodeGenInstruction*> &numberedInstructions =
774 target.getInstructionsByEnumValue();
777 unsigned int numInstructions = numberedInstructions.size();
779 for (index = 0; index < numInstructions; ++index) {
780 const CodeGenInstruction& inst = *numberedInstructions[index];
782 // We don't need to do anything for pseudo-instructions, as we'll never
783 // see them here. We'll only see real instructions.
787 CompoundConstantEmitter *infoStruct = new CompoundConstantEmitter;
788 infoArray.addEntry(infoStruct);
790 LiteralConstantEmitter *instType = new LiteralConstantEmitter;
791 infoStruct->addEntry(instType);
793 LiteralConstantEmitter *numOperandsEmitter =
794 new LiteralConstantEmitter(inst.Operands.size());
795 infoStruct->addEntry(numOperandsEmitter);
797 CompoundConstantEmitter *operandTypeArray = new CompoundConstantEmitter;
798 infoStruct->addEntry(operandTypeArray);
800 LiteralConstantEmitter *operandTypes[EDIS_MAX_OPERANDS];
802 CompoundConstantEmitter *operandFlagArray = new CompoundConstantEmitter;
803 infoStruct->addEntry(operandFlagArray);
805 FlagsConstantEmitter *operandFlags[EDIS_MAX_OPERANDS];
807 for (unsigned operandIndex = 0;
808 operandIndex < EDIS_MAX_OPERANDS;
810 operandTypes[operandIndex] = new LiteralConstantEmitter;
811 operandTypeArray->addEntry(operandTypes[operandIndex]);
813 operandFlags[operandIndex] = new FlagsConstantEmitter;
814 operandFlagArray->addEntry(operandFlags[operandIndex]);
817 unsigned numSyntaxes = 0;
819 if (target.getName() == "X86") {
820 X86PopulateOperands(operandTypes, inst);
821 X86ExtractSemantics(*instType, operandFlags, inst);
824 else if (target.getName() == "ARM") {
825 ARMPopulateOperands(operandTypes, inst);
826 ARMExtractSemantics(*instType, operandTypes, operandFlags, inst);
830 CompoundConstantEmitter *operandOrderArray = new CompoundConstantEmitter;
832 infoStruct->addEntry(operandOrderArray);
834 for (unsigned syntaxIndex = 0;
835 syntaxIndex < EDIS_MAX_SYNTAXES;
837 CompoundConstantEmitter *operandOrder =
838 new CompoundConstantEmitter(EDIS_MAX_OPERANDS);
840 operandOrderArray->addEntry(operandOrder);
842 if (syntaxIndex < numSyntaxes) {
843 populateOperandOrder(operandOrder, inst, syntaxIndex);
851 static void emitCommonEnums(raw_ostream &o, unsigned int &i) {
852 EnumEmitter operandTypes("OperandTypes");
853 operandTypes.addEntry("kOperandTypeNone");
854 operandTypes.addEntry("kOperandTypeImmediate");
855 operandTypes.addEntry("kOperandTypeRegister");
856 operandTypes.addEntry("kOperandTypeX86Memory");
857 operandTypes.addEntry("kOperandTypeX86EffectiveAddress");
858 operandTypes.addEntry("kOperandTypeX86PCRelative");
859 operandTypes.addEntry("kOperandTypeARMBranchTarget");
860 operandTypes.addEntry("kOperandTypeARMSoRegReg");
861 operandTypes.addEntry("kOperandTypeARMSoRegImm");
862 operandTypes.addEntry("kOperandTypeARMSoImm");
863 operandTypes.addEntry("kOperandTypeARMRotImm");
864 operandTypes.addEntry("kOperandTypeARMSoImm2Part");
865 operandTypes.addEntry("kOperandTypeARMPredicate");
866 operandTypes.addEntry("kOperandTypeAddrModeImm12");
867 operandTypes.addEntry("kOperandTypeLdStSOReg");
868 operandTypes.addEntry("kOperandTypeARMAddrMode2");
869 operandTypes.addEntry("kOperandTypeARMAddrMode2Offset");
870 operandTypes.addEntry("kOperandTypeARMAddrMode3");
871 operandTypes.addEntry("kOperandTypeARMAddrMode3Offset");
872 operandTypes.addEntry("kOperandTypeARMLdStmMode");
873 operandTypes.addEntry("kOperandTypeARMAddrMode5");
874 operandTypes.addEntry("kOperandTypeARMAddrMode6");
875 operandTypes.addEntry("kOperandTypeARMAddrMode6Offset");
876 operandTypes.addEntry("kOperandTypeARMAddrMode7");
877 operandTypes.addEntry("kOperandTypeARMAddrModePC");
878 operandTypes.addEntry("kOperandTypeARMRegisterList");
879 operandTypes.addEntry("kOperandTypeARMDPRRegisterList");
880 operandTypes.addEntry("kOperandTypeARMSPRRegisterList");
881 operandTypes.addEntry("kOperandTypeARMTBAddrMode");
882 operandTypes.addEntry("kOperandTypeThumbITMask");
883 operandTypes.addEntry("kOperandTypeThumbAddrModeImmS1");
884 operandTypes.addEntry("kOperandTypeThumbAddrModeImmS2");
885 operandTypes.addEntry("kOperandTypeThumbAddrModeImmS4");
886 operandTypes.addEntry("kOperandTypeThumbAddrModeRegS1");
887 operandTypes.addEntry("kOperandTypeThumbAddrModeRegS2");
888 operandTypes.addEntry("kOperandTypeThumbAddrModeRegS4");
889 operandTypes.addEntry("kOperandTypeThumbAddrModeRR");
890 operandTypes.addEntry("kOperandTypeThumbAddrModeSP");
891 operandTypes.addEntry("kOperandTypeThumbAddrModePC");
892 operandTypes.addEntry("kOperandTypeThumb2AddrModeReg");
893 operandTypes.addEntry("kOperandTypeThumb2SoReg");
894 operandTypes.addEntry("kOperandTypeThumb2SoImm");
895 operandTypes.addEntry("kOperandTypeThumb2AddrModeImm8");
896 operandTypes.addEntry("kOperandTypeThumb2AddrModeImm8Offset");
897 operandTypes.addEntry("kOperandTypeThumb2AddrModeImm12");
898 operandTypes.addEntry("kOperandTypeThumb2AddrModeSoReg");
899 operandTypes.addEntry("kOperandTypeThumb2AddrModeImm8s4");
900 operandTypes.addEntry("kOperandTypeThumb2AddrModeImm8s4Offset");
901 operandTypes.emit(o, i);
905 EnumEmitter operandFlags("OperandFlags");
906 operandFlags.addEntry("kOperandFlagSource");
907 operandFlags.addEntry("kOperandFlagTarget");
908 operandFlags.emitAsFlags(o, i);
912 EnumEmitter instructionTypes("InstructionTypes");
913 instructionTypes.addEntry("kInstructionTypeNone");
914 instructionTypes.addEntry("kInstructionTypeMove");
915 instructionTypes.addEntry("kInstructionTypeBranch");
916 instructionTypes.addEntry("kInstructionTypePush");
917 instructionTypes.addEntry("kInstructionTypePop");
918 instructionTypes.addEntry("kInstructionTypeCall");
919 instructionTypes.addEntry("kInstructionTypeReturn");
920 instructionTypes.emit(o, i);
925 void EDEmitter::run(raw_ostream &o) {
928 CompoundConstantEmitter infoArray;
929 CodeGenTarget target(Records);
931 populateInstInfo(infoArray, target);
933 emitCommonEnums(o, i);
935 o << "namespace {\n";
937 o << "llvm::EDInstInfo instInfo" << target.getName().c_str() << "[] = ";
938 infoArray.emit(o, i);