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");
337 /// X86PopulateOperands - Handles all the operands in an X86 instruction, adding
338 /// the appropriate flags to their descriptors
340 /// @operandFlags - A reference the array of operand flag objects
341 /// @inst - The instruction to use as a source of information
342 static void X86PopulateOperands(
343 LiteralConstantEmitter
*(&operandTypes
)[EDIS_MAX_OPERANDS
],
344 const CodeGenInstruction
&inst
) {
345 if (!inst
.TheDef
->isSubClassOf("X86Inst"))
349 unsigned int numOperands
= inst
.Operands
.size();
351 for (index
= 0; index
< numOperands
; ++index
) {
352 const CGIOperandList::OperandInfo
&operandInfo
= inst
.Operands
[index
];
353 Record
&rec
= *operandInfo
.Rec
;
355 if (X86TypeFromOpName(operandTypes
[index
], rec
.getName())) {
356 errs() << "Operand type: " << rec
.getName().c_str() << "\n";
357 errs() << "Operand name: " << operandInfo
.Name
.c_str() << "\n";
358 errs() << "Instruction name: " << inst
.TheDef
->getName().c_str() << "\n";
359 llvm_unreachable("Unhandled type");
364 /// decorate1 - Decorates a named operand with a new flag
366 /// @operandFlags - The array of operand flag objects, which don't have names
367 /// @inst - The CodeGenInstruction, which provides a way to translate
368 /// between names and operand indices
369 /// @opName - The name of the operand
370 /// @flag - The name of the flag to add
371 static inline void decorate1(
372 FlagsConstantEmitter
*(&operandFlags
)[EDIS_MAX_OPERANDS
],
373 const CodeGenInstruction
&inst
,
375 const char *opFlag
) {
378 opIndex
= inst
.Operands
.getOperandNamed(std::string(opName
));
380 operandFlags
[opIndex
]->addEntry(opFlag
);
383 #define DECORATE1(opName, opFlag) decorate1(operandFlags, inst, opName, opFlag)
385 #define MOV(source, target) { \
386 instType.set("kInstructionTypeMove"); \
387 DECORATE1(source, "kOperandFlagSource"); \
388 DECORATE1(target, "kOperandFlagTarget"); \
391 #define BRANCH(target) { \
392 instType.set("kInstructionTypeBranch"); \
393 DECORATE1(target, "kOperandFlagTarget"); \
396 #define PUSH(source) { \
397 instType.set("kInstructionTypePush"); \
398 DECORATE1(source, "kOperandFlagSource"); \
401 #define POP(target) { \
402 instType.set("kInstructionTypePop"); \
403 DECORATE1(target, "kOperandFlagTarget"); \
406 #define CALL(target) { \
407 instType.set("kInstructionTypeCall"); \
408 DECORATE1(target, "kOperandFlagTarget"); \
412 instType.set("kInstructionTypeReturn"); \
415 /// X86ExtractSemantics - Performs various checks on the name of an X86
416 /// instruction to determine what sort of an instruction it is and then adds
417 /// the appropriate flags to the instruction and its operands
419 /// @arg instType - A reference to the type for the instruction as a whole
420 /// @arg operandFlags - A reference to the array of operand flag object pointers
421 /// @arg inst - A reference to the original instruction
422 static void X86ExtractSemantics(
423 LiteralConstantEmitter
&instType
,
424 FlagsConstantEmitter
*(&operandFlags
)[EDIS_MAX_OPERANDS
],
425 const CodeGenInstruction
&inst
) {
426 const std::string
&name
= inst
.TheDef
->getName();
428 if (name
.find("MOV") != name
.npos
) {
429 if (name
.find("MOV_V") != name
.npos
) {
430 // ignore (this is a pseudoinstruction)
431 } else if (name
.find("MASK") != name
.npos
) {
432 // ignore (this is a masking move)
433 } else if (name
.find("r0") != name
.npos
) {
434 // ignore (this is a pseudoinstruction)
435 } else if (name
.find("PS") != name
.npos
||
436 name
.find("PD") != name
.npos
) {
437 // ignore (this is a shuffling move)
438 } else if (name
.find("MOVS") != name
.npos
) {
439 // ignore (this is a string move)
440 } else if (name
.find("_F") != name
.npos
) {
441 // TODO handle _F moves to ST(0)
442 } else if (name
.find("a") != name
.npos
) {
443 // TODO handle moves to/from %ax
444 } else if (name
.find("CMOV") != name
.npos
) {
446 } else if (name
.find("PC") != name
.npos
) {
453 if (name
.find("JMP") != name
.npos
||
454 name
.find("J") == 0) {
455 if (name
.find("FAR") != name
.npos
&& name
.find("i") != name
.npos
) {
462 if (name
.find("PUSH") != name
.npos
) {
463 if (name
.find("CS") != name
.npos
||
464 name
.find("DS") != name
.npos
||
465 name
.find("ES") != name
.npos
||
466 name
.find("FS") != name
.npos
||
467 name
.find("GS") != name
.npos
||
468 name
.find("SS") != name
.npos
) {
469 instType
.set("kInstructionTypePush");
470 // TODO add support for fixed operands
471 } else if (name
.find("F") != name
.npos
) {
472 // ignore (this pushes onto the FP stack)
473 } else if (name
.find("A") != name
.npos
) {
474 // ignore (pushes all GP registoers onto the stack)
475 } else if (name
[name
.length() - 1] == 'm') {
477 } else if (name
.find("i") != name
.npos
) {
484 if (name
.find("POP") != name
.npos
) {
485 if (name
.find("POPCNT") != name
.npos
) {
486 // ignore (not a real pop)
487 } else if (name
.find("CS") != name
.npos
||
488 name
.find("DS") != name
.npos
||
489 name
.find("ES") != name
.npos
||
490 name
.find("FS") != name
.npos
||
491 name
.find("GS") != name
.npos
||
492 name
.find("SS") != name
.npos
) {
493 instType
.set("kInstructionTypePop");
494 // TODO add support for fixed operands
495 } else if (name
.find("F") != name
.npos
) {
496 // ignore (this pops from the FP stack)
497 } else if (name
.find("A") != name
.npos
) {
498 // ignore (pushes all GP registoers onto the stack)
499 } else if (name
[name
.length() - 1] == 'm') {
506 if (name
.find("CALL") != name
.npos
) {
507 if (name
.find("ADJ") != name
.npos
) {
508 // ignore (not a call)
509 } else if (name
.find("SYSCALL") != name
.npos
) {
510 // ignore (doesn't go anywhere we know about)
511 } else if (name
.find("VMCALL") != name
.npos
) {
512 // ignore (rather different semantics than a regular call)
513 } else if (name
.find("FAR") != name
.npos
&& name
.find("i") != name
.npos
) {
520 if (name
.find("RET") != name
.npos
) {
532 /////////////////////////////////////////////////////
533 // Support functions for handling ARM instructions //
534 /////////////////////////////////////////////////////
536 #define SET(flag) { type->set(flag); return 0; }
538 #define REG(str) if (name == str) SET("kOperandTypeRegister");
539 #define IMM(str) if (name == str) SET("kOperandTypeImmediate");
541 #define MISC(str, type) if (name == str) SET(type);
543 /// ARMFlagFromOpName - Processes the name of a single ARM operand (which is
544 /// actually its type) and translates it into an operand type
546 /// @arg type - The type object to set
547 /// @arg name - The name of the operand
548 static int ARMFlagFromOpName(LiteralConstantEmitter
*type
,
549 const std::string
&name
) {
565 IMM("bf_inv_mask_imm");
566 IMM("jtblock_operand");
568 IMM("cpinst_operand");
580 IMM("jt2block_operand");
584 IMM("neon_vcvt_imm32");
586 MISC("brtarget", "kOperandTypeARMBranchTarget"); // ?
587 MISC("so_reg", "kOperandTypeARMSoReg"); // R, R, I
588 MISC("shift_so_reg", "kOperandTypeARMSoReg"); // R, R, I
589 MISC("t2_so_reg", "kOperandTypeThumb2SoReg"); // R, I
590 MISC("so_imm", "kOperandTypeARMSoImm"); // I
591 MISC("rot_imm", "kOperandTypeARMRotImm"); // I
592 MISC("t2_so_imm", "kOperandTypeThumb2SoImm"); // I
593 MISC("so_imm2part", "kOperandTypeARMSoImm2Part"); // I
594 MISC("pred", "kOperandTypeARMPredicate"); // I, R
595 MISC("it_pred", "kOperandTypeARMPredicate"); // I
596 MISC("addrmode_imm12", "kOperandTypeAddrModeImm12"); // R, I
597 MISC("ldst_so_reg", "kOperandTypeLdStSOReg"); // R, R, I
598 MISC("addrmode2", "kOperandTypeARMAddrMode2"); // R, R, I
599 MISC("am2offset", "kOperandTypeARMAddrMode2Offset"); // R, I
600 MISC("addrmode3", "kOperandTypeARMAddrMode3"); // R, R, I
601 MISC("am3offset", "kOperandTypeARMAddrMode3Offset"); // R, I
602 MISC("ldstm_mode", "kOperandTypeARMLdStmMode"); // I
603 MISC("addrmode5", "kOperandTypeARMAddrMode5"); // R, I
604 MISC("addrmode6", "kOperandTypeARMAddrMode6"); // R, R, I, I
605 MISC("am6offset", "kOperandTypeARMAddrMode6Offset"); // R, I, I
606 MISC("addrmodepc", "kOperandTypeARMAddrModePC"); // R, I
607 MISC("reglist", "kOperandTypeARMRegisterList"); // I, R, ...
608 MISC("it_mask", "kOperandTypeThumbITMask"); // I
609 MISC("t2addrmode_imm8", "kOperandTypeThumb2AddrModeImm8"); // R, I
610 MISC("t2am_imm8_offset", "kOperandTypeThumb2AddrModeImm8Offset");//I
611 MISC("t2addrmode_imm12", "kOperandTypeThumb2AddrModeImm12"); // R, I
612 MISC("t2addrmode_so_reg", "kOperandTypeThumb2AddrModeSoReg"); // R, R, I
613 MISC("t2addrmode_imm8s4", "kOperandTypeThumb2AddrModeImm8s4"); // R, I
614 MISC("t2am_imm8s4_offset", "kOperandTypeThumb2AddrModeImm8s4Offset");
616 MISC("tb_addrmode", "kOperandTypeARMTBAddrMode"); // I
617 MISC("t_addrmode_s1", "kOperandTypeThumbAddrModeS1"); // R, I, R
618 MISC("t_addrmode_s2", "kOperandTypeThumbAddrModeS2"); // R, I, R
619 MISC("t_addrmode_s4", "kOperandTypeThumbAddrModeS4"); // R, I, R
620 MISC("t_addrmode_rr", "kOperandTypeThumbAddrModeRR"); // R, R
621 MISC("t_addrmode_sp", "kOperandTypeThumbAddrModeSP"); // R, I
637 /// ARMPopulateOperands - Handles all the operands in an ARM instruction, adding
638 /// the appropriate flags to their descriptors
640 /// @operandFlags - A reference the array of operand flag objects
641 /// @inst - The instruction to use as a source of information
642 static void ARMPopulateOperands(
643 LiteralConstantEmitter
*(&operandTypes
)[EDIS_MAX_OPERANDS
],
644 const CodeGenInstruction
&inst
) {
645 if (!inst
.TheDef
->isSubClassOf("InstARM") &&
646 !inst
.TheDef
->isSubClassOf("InstThumb"))
650 unsigned int numOperands
= inst
.Operands
.size();
652 if (numOperands
> EDIS_MAX_OPERANDS
) {
653 errs() << "numOperands == " << numOperands
<< " > " <<
654 EDIS_MAX_OPERANDS
<< '\n';
655 llvm_unreachable("Too many operands");
658 for (index
= 0; index
< numOperands
; ++index
) {
659 const CGIOperandList::OperandInfo
&operandInfo
= inst
.Operands
[index
];
660 Record
&rec
= *operandInfo
.Rec
;
662 if (ARMFlagFromOpName(operandTypes
[index
], rec
.getName())) {
663 errs() << "Operand type: " << rec
.getName() << '\n';
664 errs() << "Operand name: " << operandInfo
.Name
<< '\n';
665 errs() << "Instruction name: " << inst
.TheDef
->getName() << '\n';
666 llvm_unreachable("Unhandled type");
671 #define BRANCH(target) { \
672 instType.set("kInstructionTypeBranch"); \
673 DECORATE1(target, "kOperandFlagTarget"); \
676 /// ARMExtractSemantics - Performs various checks on the name of an ARM
677 /// instruction to determine what sort of an instruction it is and then adds
678 /// the appropriate flags to the instruction and its operands
680 /// @arg instType - A reference to the type for the instruction as a whole
681 /// @arg operandTypes - A reference to the array of operand type object pointers
682 /// @arg operandFlags - A reference to the array of operand flag object pointers
683 /// @arg inst - A reference to the original instruction
684 static void ARMExtractSemantics(
685 LiteralConstantEmitter
&instType
,
686 LiteralConstantEmitter
*(&operandTypes
)[EDIS_MAX_OPERANDS
],
687 FlagsConstantEmitter
*(&operandFlags
)[EDIS_MAX_OPERANDS
],
688 const CodeGenInstruction
&inst
) {
689 const std::string
&name
= inst
.TheDef
->getName();
691 if (name
== "tBcc" ||
700 if (name
== "tBLr9" ||
701 name
== "BLr9_pred" ||
702 name
== "tBLXi_r9" ||
703 name
== "tBLXr_r9" ||
710 opIndex
= inst
.Operands
.getOperandNamed("func");
711 if (operandTypes
[opIndex
]->is("kOperandTypeImmediate"))
712 operandTypes
[opIndex
]->set("kOperandTypeARMBranchTarget");
718 /// populateInstInfo - Fills an array of InstInfos with information about each
719 /// instruction in a target
721 /// @arg infoArray - The array of InstInfo objects to populate
722 /// @arg target - The CodeGenTarget to use as a source of instructions
723 static void populateInstInfo(CompoundConstantEmitter
&infoArray
,
724 CodeGenTarget
&target
) {
725 const std::vector
<const CodeGenInstruction
*> &numberedInstructions
=
726 target
.getInstructionsByEnumValue();
729 unsigned int numInstructions
= numberedInstructions
.size();
731 for (index
= 0; index
< numInstructions
; ++index
) {
732 const CodeGenInstruction
& inst
= *numberedInstructions
[index
];
734 CompoundConstantEmitter
*infoStruct
= new CompoundConstantEmitter
;
735 infoArray
.addEntry(infoStruct
);
737 LiteralConstantEmitter
*instType
= new LiteralConstantEmitter
;
738 infoStruct
->addEntry(instType
);
740 LiteralConstantEmitter
*numOperandsEmitter
=
741 new LiteralConstantEmitter(inst
.Operands
.size());
742 infoStruct
->addEntry(numOperandsEmitter
);
744 CompoundConstantEmitter
*operandTypeArray
= new CompoundConstantEmitter
;
745 infoStruct
->addEntry(operandTypeArray
);
747 LiteralConstantEmitter
*operandTypes
[EDIS_MAX_OPERANDS
];
749 CompoundConstantEmitter
*operandFlagArray
= new CompoundConstantEmitter
;
750 infoStruct
->addEntry(operandFlagArray
);
752 FlagsConstantEmitter
*operandFlags
[EDIS_MAX_OPERANDS
];
754 for (unsigned operandIndex
= 0;
755 operandIndex
< EDIS_MAX_OPERANDS
;
757 operandTypes
[operandIndex
] = new LiteralConstantEmitter
;
758 operandTypeArray
->addEntry(operandTypes
[operandIndex
]);
760 operandFlags
[operandIndex
] = new FlagsConstantEmitter
;
761 operandFlagArray
->addEntry(operandFlags
[operandIndex
]);
764 unsigned numSyntaxes
= 0;
766 if (target
.getName() == "X86") {
767 X86PopulateOperands(operandTypes
, inst
);
768 X86ExtractSemantics(*instType
, operandFlags
, inst
);
771 else if (target
.getName() == "ARM") {
772 ARMPopulateOperands(operandTypes
, inst
);
773 ARMExtractSemantics(*instType
, operandTypes
, operandFlags
, inst
);
777 CompoundConstantEmitter
*operandOrderArray
= new CompoundConstantEmitter
;
779 infoStruct
->addEntry(operandOrderArray
);
781 for (unsigned syntaxIndex
= 0;
782 syntaxIndex
< EDIS_MAX_SYNTAXES
;
784 CompoundConstantEmitter
*operandOrder
=
785 new CompoundConstantEmitter(EDIS_MAX_OPERANDS
);
787 operandOrderArray
->addEntry(operandOrder
);
789 if (syntaxIndex
< numSyntaxes
) {
790 populateOperandOrder(operandOrder
, inst
, syntaxIndex
);
798 static void emitCommonEnums(raw_ostream
&o
, unsigned int &i
) {
799 EnumEmitter
operandTypes("OperandTypes");
800 operandTypes
.addEntry("kOperandTypeNone");
801 operandTypes
.addEntry("kOperandTypeImmediate");
802 operandTypes
.addEntry("kOperandTypeRegister");
803 operandTypes
.addEntry("kOperandTypeX86Memory");
804 operandTypes
.addEntry("kOperandTypeX86EffectiveAddress");
805 operandTypes
.addEntry("kOperandTypeX86PCRelative");
806 operandTypes
.addEntry("kOperandTypeARMBranchTarget");
807 operandTypes
.addEntry("kOperandTypeARMSoReg");
808 operandTypes
.addEntry("kOperandTypeARMSoImm");
809 operandTypes
.addEntry("kOperandTypeARMRotImm");
810 operandTypes
.addEntry("kOperandTypeARMSoImm2Part");
811 operandTypes
.addEntry("kOperandTypeARMPredicate");
812 operandTypes
.addEntry("kOperandTypeAddrModeImm12");
813 operandTypes
.addEntry("kOperandTypeLdStSOReg");
814 operandTypes
.addEntry("kOperandTypeARMAddrMode2");
815 operandTypes
.addEntry("kOperandTypeARMAddrMode2Offset");
816 operandTypes
.addEntry("kOperandTypeARMAddrMode3");
817 operandTypes
.addEntry("kOperandTypeARMAddrMode3Offset");
818 operandTypes
.addEntry("kOperandTypeARMLdStmMode");
819 operandTypes
.addEntry("kOperandTypeARMAddrMode5");
820 operandTypes
.addEntry("kOperandTypeARMAddrMode6");
821 operandTypes
.addEntry("kOperandTypeARMAddrMode6Offset");
822 operandTypes
.addEntry("kOperandTypeARMAddrModePC");
823 operandTypes
.addEntry("kOperandTypeARMRegisterList");
824 operandTypes
.addEntry("kOperandTypeARMTBAddrMode");
825 operandTypes
.addEntry("kOperandTypeThumbITMask");
826 operandTypes
.addEntry("kOperandTypeThumbAddrModeS1");
827 operandTypes
.addEntry("kOperandTypeThumbAddrModeS2");
828 operandTypes
.addEntry("kOperandTypeThumbAddrModeS4");
829 operandTypes
.addEntry("kOperandTypeThumbAddrModeRR");
830 operandTypes
.addEntry("kOperandTypeThumbAddrModeSP");
831 operandTypes
.addEntry("kOperandTypeThumb2SoReg");
832 operandTypes
.addEntry("kOperandTypeThumb2SoImm");
833 operandTypes
.addEntry("kOperandTypeThumb2AddrModeImm8");
834 operandTypes
.addEntry("kOperandTypeThumb2AddrModeImm8Offset");
835 operandTypes
.addEntry("kOperandTypeThumb2AddrModeImm12");
836 operandTypes
.addEntry("kOperandTypeThumb2AddrModeSoReg");
837 operandTypes
.addEntry("kOperandTypeThumb2AddrModeImm8s4");
838 operandTypes
.addEntry("kOperandTypeThumb2AddrModeImm8s4Offset");
839 operandTypes
.emit(o
, i
);
843 EnumEmitter
operandFlags("OperandFlags");
844 operandFlags
.addEntry("kOperandFlagSource");
845 operandFlags
.addEntry("kOperandFlagTarget");
846 operandFlags
.emitAsFlags(o
, i
);
850 EnumEmitter
instructionTypes("InstructionTypes");
851 instructionTypes
.addEntry("kInstructionTypeNone");
852 instructionTypes
.addEntry("kInstructionTypeMove");
853 instructionTypes
.addEntry("kInstructionTypeBranch");
854 instructionTypes
.addEntry("kInstructionTypePush");
855 instructionTypes
.addEntry("kInstructionTypePop");
856 instructionTypes
.addEntry("kInstructionTypeCall");
857 instructionTypes
.addEntry("kInstructionTypeReturn");
858 instructionTypes
.emit(o
, i
);
863 void EDEmitter::run(raw_ostream
&o
) {
866 CompoundConstantEmitter infoArray
;
867 CodeGenTarget target
;
869 populateInstInfo(infoArray
, target
);
871 emitCommonEnums(o
, i
);
873 o
<< "namespace {\n";
875 o
<< "llvm::EDInstInfo instInfo" << target
.getName().c_str() << "[] = ";
876 infoArray
.emit(o
, i
);