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");
325 PCR("uncondbrtarget");
328 // all I, ARM mode only, conditional/unconditional
342 /// X86PopulateOperands - Handles all the operands in an X86 instruction, adding
343 /// the appropriate flags to their descriptors
345 /// @operandFlags - A reference the array of operand flag objects
346 /// @inst - The instruction to use as a source of information
347 static void X86PopulateOperands(
348 LiteralConstantEmitter
*(&operandTypes
)[EDIS_MAX_OPERANDS
],
349 const CodeGenInstruction
&inst
) {
350 if (!inst
.TheDef
->isSubClassOf("X86Inst"))
354 unsigned int numOperands
= inst
.Operands
.size();
356 for (index
= 0; index
< numOperands
; ++index
) {
357 const CGIOperandList::OperandInfo
&operandInfo
= inst
.Operands
[index
];
358 Record
&rec
= *operandInfo
.Rec
;
360 if (X86TypeFromOpName(operandTypes
[index
], rec
.getName()) &&
361 !rec
.isSubClassOf("PointerLikeRegClass")) {
362 errs() << "Operand type: " << rec
.getName().c_str() << "\n";
363 errs() << "Operand name: " << operandInfo
.Name
.c_str() << "\n";
364 errs() << "Instruction name: " << inst
.TheDef
->getName().c_str() << "\n";
365 llvm_unreachable("Unhandled type");
370 /// decorate1 - Decorates a named operand with a new flag
372 /// @operandFlags - The array of operand flag objects, which don't have names
373 /// @inst - The CodeGenInstruction, which provides a way to translate
374 /// between names and operand indices
375 /// @opName - The name of the operand
376 /// @flag - The name of the flag to add
377 static inline void decorate1(
378 FlagsConstantEmitter
*(&operandFlags
)[EDIS_MAX_OPERANDS
],
379 const CodeGenInstruction
&inst
,
381 const char *opFlag
) {
384 opIndex
= inst
.Operands
.getOperandNamed(std::string(opName
));
386 operandFlags
[opIndex
]->addEntry(opFlag
);
389 #define DECORATE1(opName, opFlag) decorate1(operandFlags, inst, opName, opFlag)
391 #define MOV(source, target) { \
392 instType.set("kInstructionTypeMove"); \
393 DECORATE1(source, "kOperandFlagSource"); \
394 DECORATE1(target, "kOperandFlagTarget"); \
397 #define BRANCH(target) { \
398 instType.set("kInstructionTypeBranch"); \
399 DECORATE1(target, "kOperandFlagTarget"); \
402 #define PUSH(source) { \
403 instType.set("kInstructionTypePush"); \
404 DECORATE1(source, "kOperandFlagSource"); \
407 #define POP(target) { \
408 instType.set("kInstructionTypePop"); \
409 DECORATE1(target, "kOperandFlagTarget"); \
412 #define CALL(target) { \
413 instType.set("kInstructionTypeCall"); \
414 DECORATE1(target, "kOperandFlagTarget"); \
418 instType.set("kInstructionTypeReturn"); \
421 /// X86ExtractSemantics - Performs various checks on the name of an X86
422 /// instruction to determine what sort of an instruction it is and then adds
423 /// the appropriate flags to the instruction and its operands
425 /// @arg instType - A reference to the type for the instruction as a whole
426 /// @arg operandFlags - A reference to the array of operand flag object pointers
427 /// @arg inst - A reference to the original instruction
428 static void X86ExtractSemantics(
429 LiteralConstantEmitter
&instType
,
430 FlagsConstantEmitter
*(&operandFlags
)[EDIS_MAX_OPERANDS
],
431 const CodeGenInstruction
&inst
) {
432 const std::string
&name
= inst
.TheDef
->getName();
434 if (name
.find("MOV") != name
.npos
) {
435 if (name
.find("MOV_V") != name
.npos
) {
436 // ignore (this is a pseudoinstruction)
437 } else if (name
.find("MASK") != name
.npos
) {
438 // ignore (this is a masking move)
439 } else if (name
.find("r0") != name
.npos
) {
440 // ignore (this is a pseudoinstruction)
441 } else if (name
.find("PS") != name
.npos
||
442 name
.find("PD") != name
.npos
) {
443 // ignore (this is a shuffling move)
444 } else if (name
.find("MOVS") != name
.npos
) {
445 // ignore (this is a string move)
446 } else if (name
.find("_F") != name
.npos
) {
447 // TODO handle _F moves to ST(0)
448 } else if (name
.find("a") != name
.npos
) {
449 // TODO handle moves to/from %ax
450 } else if (name
.find("CMOV") != name
.npos
) {
452 } else if (name
.find("PC") != name
.npos
) {
459 if (name
.find("JMP") != name
.npos
||
460 name
.find("J") == 0) {
461 if (name
.find("FAR") != name
.npos
&& name
.find("i") != name
.npos
) {
468 if (name
.find("PUSH") != name
.npos
) {
469 if (name
.find("CS") != name
.npos
||
470 name
.find("DS") != name
.npos
||
471 name
.find("ES") != name
.npos
||
472 name
.find("FS") != name
.npos
||
473 name
.find("GS") != name
.npos
||
474 name
.find("SS") != name
.npos
) {
475 instType
.set("kInstructionTypePush");
476 // TODO add support for fixed operands
477 } else if (name
.find("F") != name
.npos
) {
478 // ignore (this pushes onto the FP stack)
479 } else if (name
.find("A") != name
.npos
) {
480 // ignore (pushes all GP registoers onto the stack)
481 } else if (name
[name
.length() - 1] == 'm') {
483 } else if (name
.find("i") != name
.npos
) {
490 if (name
.find("POP") != name
.npos
) {
491 if (name
.find("POPCNT") != name
.npos
) {
492 // ignore (not a real pop)
493 } else if (name
.find("CS") != name
.npos
||
494 name
.find("DS") != name
.npos
||
495 name
.find("ES") != name
.npos
||
496 name
.find("FS") != name
.npos
||
497 name
.find("GS") != name
.npos
||
498 name
.find("SS") != name
.npos
) {
499 instType
.set("kInstructionTypePop");
500 // TODO add support for fixed operands
501 } else if (name
.find("F") != name
.npos
) {
502 // ignore (this pops from the FP stack)
503 } else if (name
.find("A") != name
.npos
) {
504 // ignore (pushes all GP registoers onto the stack)
505 } else if (name
[name
.length() - 1] == 'm') {
512 if (name
.find("CALL") != name
.npos
) {
513 if (name
.find("ADJ") != name
.npos
) {
514 // ignore (not a call)
515 } else if (name
.find("SYSCALL") != name
.npos
) {
516 // ignore (doesn't go anywhere we know about)
517 } else if (name
.find("VMCALL") != name
.npos
) {
518 // ignore (rather different semantics than a regular call)
519 } else if (name
.find("FAR") != name
.npos
&& name
.find("i") != name
.npos
) {
526 if (name
.find("RET") != name
.npos
) {
538 /////////////////////////////////////////////////////
539 // Support functions for handling ARM instructions //
540 /////////////////////////////////////////////////////
542 #define SET(flag) { type->set(flag); return 0; }
544 #define REG(str) if (name == str) SET("kOperandTypeRegister");
545 #define IMM(str) if (name == str) SET("kOperandTypeImmediate");
547 #define MISC(str, type) if (name == str) SET(type);
549 /// ARMFlagFromOpName - Processes the name of a single ARM operand (which is
550 /// actually its type) and translates it into an operand type
552 /// @arg type - The type object to set
553 /// @arg name - The name of the operand
554 static int ARMFlagFromOpName(LiteralConstantEmitter
*type
,
555 const std::string
&name
) {
571 IMM("i32imm_hilo16");
572 IMM("bf_inv_mask_imm");
575 IMM("jtblock_operand");
581 IMM("cpinst_operand");
593 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("addrmodepc", "kOperandTypeARMAddrModePC"); // R, I
640 MISC("addrmode7", "kOperandTypeARMAddrMode7"); // R
641 MISC("reglist", "kOperandTypeARMRegisterList"); // I, R, ...
642 MISC("dpr_reglist", "kOperandTypeARMDPRRegisterList"); // I, R, ...
643 MISC("spr_reglist", "kOperandTypeARMSPRRegisterList"); // I, R, ...
644 MISC("it_mask", "kOperandTypeThumbITMask"); // I
645 MISC("t2addrmode_reg", "kOperandTypeThumb2AddrModeReg"); // R
646 MISC("t2addrmode_imm8", "kOperandTypeThumb2AddrModeImm8"); // R, I
647 MISC("t2am_imm8_offset", "kOperandTypeThumb2AddrModeImm8Offset");//I
648 MISC("t2addrmode_imm12", "kOperandTypeThumb2AddrModeImm12"); // R, I
649 MISC("t2addrmode_so_reg", "kOperandTypeThumb2AddrModeSoReg"); // R, R, I
650 MISC("t2addrmode_imm8s4", "kOperandTypeThumb2AddrModeImm8s4"); // R, I
651 MISC("t2am_imm8s4_offset", "kOperandTypeThumb2AddrModeImm8s4Offset");
653 MISC("tb_addrmode", "kOperandTypeARMTBAddrMode"); // I
654 MISC("t_addrmode_rrs1", "kOperandTypeThumbAddrModeRegS"); // R, R
655 MISC("t_addrmode_rrs2", "kOperandTypeThumbAddrModeRegS"); // R, R
656 MISC("t_addrmode_rrs4", "kOperandTypeThumbAddrModeRegS"); // R, R
657 MISC("t_addrmode_is1", "kOperandTypeThumbAddrModeImmS"); // R, I
658 MISC("t_addrmode_is2", "kOperandTypeThumbAddrModeImmS"); // R, I
659 MISC("t_addrmode_is4", "kOperandTypeThumbAddrModeImmS"); // R, I
660 MISC("t_addrmode_rr", "kOperandTypeThumbAddrModeRR"); // R, R
661 MISC("t_addrmode_sp", "kOperandTypeThumbAddrModeSP"); // R, I
662 MISC("t_addrmode_pc", "kOperandTypeThumbAddrModePC"); // R, I
678 /// ARMPopulateOperands - Handles all the operands in an ARM instruction, adding
679 /// the appropriate flags to their descriptors
681 /// @operandFlags - A reference the array of operand flag objects
682 /// @inst - The instruction to use as a source of information
683 static void ARMPopulateOperands(
684 LiteralConstantEmitter
*(&operandTypes
)[EDIS_MAX_OPERANDS
],
685 const CodeGenInstruction
&inst
) {
686 if (!inst
.TheDef
->isSubClassOf("InstARM") &&
687 !inst
.TheDef
->isSubClassOf("InstThumb"))
691 unsigned int numOperands
= inst
.Operands
.size();
693 if (numOperands
> EDIS_MAX_OPERANDS
) {
694 errs() << "numOperands == " << numOperands
<< " > " <<
695 EDIS_MAX_OPERANDS
<< '\n';
696 llvm_unreachable("Too many operands");
699 for (index
= 0; index
< numOperands
; ++index
) {
700 const CGIOperandList::OperandInfo
&operandInfo
= inst
.Operands
[index
];
701 Record
&rec
= *operandInfo
.Rec
;
703 if (ARMFlagFromOpName(operandTypes
[index
], rec
.getName())) {
704 errs() << "Operand type: " << rec
.getName() << '\n';
705 errs() << "Operand name: " << operandInfo
.Name
<< '\n';
706 errs() << "Instruction name: " << inst
.TheDef
->getName() << '\n';
707 llvm_unreachable("Unhandled type");
712 #define BRANCH(target) { \
713 instType.set("kInstructionTypeBranch"); \
714 DECORATE1(target, "kOperandFlagTarget"); \
717 /// ARMExtractSemantics - Performs various checks on the name of an ARM
718 /// instruction to determine what sort of an instruction it is and then adds
719 /// the appropriate flags to the instruction and its operands
721 /// @arg instType - A reference to the type for the instruction as a whole
722 /// @arg operandTypes - A reference to the array of operand type object pointers
723 /// @arg operandFlags - A reference to the array of operand flag object pointers
724 /// @arg inst - A reference to the original instruction
725 static void ARMExtractSemantics(
726 LiteralConstantEmitter
&instType
,
727 LiteralConstantEmitter
*(&operandTypes
)[EDIS_MAX_OPERANDS
],
728 FlagsConstantEmitter
*(&operandFlags
)[EDIS_MAX_OPERANDS
],
729 const CodeGenInstruction
&inst
) {
730 const std::string
&name
= inst
.TheDef
->getName();
732 if (name
== "tBcc" ||
741 if (name
== "tBLr9" ||
742 name
== "BLr9_pred" ||
743 name
== "tBLXi_r9" ||
744 name
== "tBLXr_r9" ||
751 opIndex
= inst
.Operands
.getOperandNamed("func");
752 if (operandTypes
[opIndex
]->is("kOperandTypeImmediate"))
753 operandTypes
[opIndex
]->set("kOperandTypeARMBranchTarget");
759 /// populateInstInfo - Fills an array of InstInfos with information about each
760 /// instruction in a target
762 /// @arg infoArray - The array of InstInfo objects to populate
763 /// @arg target - The CodeGenTarget to use as a source of instructions
764 static void populateInstInfo(CompoundConstantEmitter
&infoArray
,
765 CodeGenTarget
&target
) {
766 const std::vector
<const CodeGenInstruction
*> &numberedInstructions
=
767 target
.getInstructionsByEnumValue();
770 unsigned int numInstructions
= numberedInstructions
.size();
772 for (index
= 0; index
< numInstructions
; ++index
) {
773 const CodeGenInstruction
& inst
= *numberedInstructions
[index
];
775 CompoundConstantEmitter
*infoStruct
= new CompoundConstantEmitter
;
776 infoArray
.addEntry(infoStruct
);
778 LiteralConstantEmitter
*instType
= new LiteralConstantEmitter
;
779 infoStruct
->addEntry(instType
);
781 LiteralConstantEmitter
*numOperandsEmitter
=
782 new LiteralConstantEmitter(inst
.Operands
.size());
783 infoStruct
->addEntry(numOperandsEmitter
);
785 CompoundConstantEmitter
*operandTypeArray
= new CompoundConstantEmitter
;
786 infoStruct
->addEntry(operandTypeArray
);
788 LiteralConstantEmitter
*operandTypes
[EDIS_MAX_OPERANDS
];
790 CompoundConstantEmitter
*operandFlagArray
= new CompoundConstantEmitter
;
791 infoStruct
->addEntry(operandFlagArray
);
793 FlagsConstantEmitter
*operandFlags
[EDIS_MAX_OPERANDS
];
795 for (unsigned operandIndex
= 0;
796 operandIndex
< EDIS_MAX_OPERANDS
;
798 operandTypes
[operandIndex
] = new LiteralConstantEmitter
;
799 operandTypeArray
->addEntry(operandTypes
[operandIndex
]);
801 operandFlags
[operandIndex
] = new FlagsConstantEmitter
;
802 operandFlagArray
->addEntry(operandFlags
[operandIndex
]);
805 unsigned numSyntaxes
= 0;
807 if (target
.getName() == "X86") {
808 X86PopulateOperands(operandTypes
, inst
);
809 X86ExtractSemantics(*instType
, operandFlags
, inst
);
812 else if (target
.getName() == "ARM") {
813 ARMPopulateOperands(operandTypes
, inst
);
814 ARMExtractSemantics(*instType
, operandTypes
, operandFlags
, inst
);
818 CompoundConstantEmitter
*operandOrderArray
= new CompoundConstantEmitter
;
820 infoStruct
->addEntry(operandOrderArray
);
822 for (unsigned syntaxIndex
= 0;
823 syntaxIndex
< EDIS_MAX_SYNTAXES
;
825 CompoundConstantEmitter
*operandOrder
=
826 new CompoundConstantEmitter(EDIS_MAX_OPERANDS
);
828 operandOrderArray
->addEntry(operandOrder
);
830 if (syntaxIndex
< numSyntaxes
) {
831 populateOperandOrder(operandOrder
, inst
, syntaxIndex
);
839 static void emitCommonEnums(raw_ostream
&o
, unsigned int &i
) {
840 EnumEmitter
operandTypes("OperandTypes");
841 operandTypes
.addEntry("kOperandTypeNone");
842 operandTypes
.addEntry("kOperandTypeImmediate");
843 operandTypes
.addEntry("kOperandTypeRegister");
844 operandTypes
.addEntry("kOperandTypeX86Memory");
845 operandTypes
.addEntry("kOperandTypeX86EffectiveAddress");
846 operandTypes
.addEntry("kOperandTypeX86PCRelative");
847 operandTypes
.addEntry("kOperandTypeARMBranchTarget");
848 operandTypes
.addEntry("kOperandTypeARMSoReg");
849 operandTypes
.addEntry("kOperandTypeARMSoImm");
850 operandTypes
.addEntry("kOperandTypeARMRotImm");
851 operandTypes
.addEntry("kOperandTypeARMSoImm2Part");
852 operandTypes
.addEntry("kOperandTypeARMPredicate");
853 operandTypes
.addEntry("kOperandTypeAddrModeImm12");
854 operandTypes
.addEntry("kOperandTypeLdStSOReg");
855 operandTypes
.addEntry("kOperandTypeARMAddrMode2");
856 operandTypes
.addEntry("kOperandTypeARMAddrMode2Offset");
857 operandTypes
.addEntry("kOperandTypeARMAddrMode3");
858 operandTypes
.addEntry("kOperandTypeARMAddrMode3Offset");
859 operandTypes
.addEntry("kOperandTypeARMLdStmMode");
860 operandTypes
.addEntry("kOperandTypeARMAddrMode5");
861 operandTypes
.addEntry("kOperandTypeARMAddrMode6");
862 operandTypes
.addEntry("kOperandTypeARMAddrMode6Offset");
863 operandTypes
.addEntry("kOperandTypeARMAddrMode7");
864 operandTypes
.addEntry("kOperandTypeARMAddrModePC");
865 operandTypes
.addEntry("kOperandTypeARMRegisterList");
866 operandTypes
.addEntry("kOperandTypeARMDPRRegisterList");
867 operandTypes
.addEntry("kOperandTypeARMSPRRegisterList");
868 operandTypes
.addEntry("kOperandTypeARMTBAddrMode");
869 operandTypes
.addEntry("kOperandTypeThumbITMask");
870 operandTypes
.addEntry("kOperandTypeThumbAddrModeRegS");
871 operandTypes
.addEntry("kOperandTypeThumbAddrModeImmS");
872 operandTypes
.addEntry("kOperandTypeThumbAddrModeRR");
873 operandTypes
.addEntry("kOperandTypeThumbAddrModeSP");
874 operandTypes
.addEntry("kOperandTypeThumbAddrModePC");
875 operandTypes
.addEntry("kOperandTypeThumb2AddrModeReg");
876 operandTypes
.addEntry("kOperandTypeThumb2SoReg");
877 operandTypes
.addEntry("kOperandTypeThumb2SoImm");
878 operandTypes
.addEntry("kOperandTypeThumb2AddrModeImm8");
879 operandTypes
.addEntry("kOperandTypeThumb2AddrModeImm8Offset");
880 operandTypes
.addEntry("kOperandTypeThumb2AddrModeImm12");
881 operandTypes
.addEntry("kOperandTypeThumb2AddrModeSoReg");
882 operandTypes
.addEntry("kOperandTypeThumb2AddrModeImm8s4");
883 operandTypes
.addEntry("kOperandTypeThumb2AddrModeImm8s4Offset");
884 operandTypes
.emit(o
, i
);
888 EnumEmitter
operandFlags("OperandFlags");
889 operandFlags
.addEntry("kOperandFlagSource");
890 operandFlags
.addEntry("kOperandFlagTarget");
891 operandFlags
.emitAsFlags(o
, i
);
895 EnumEmitter
instructionTypes("InstructionTypes");
896 instructionTypes
.addEntry("kInstructionTypeNone");
897 instructionTypes
.addEntry("kInstructionTypeMove");
898 instructionTypes
.addEntry("kInstructionTypeBranch");
899 instructionTypes
.addEntry("kInstructionTypePush");
900 instructionTypes
.addEntry("kInstructionTypePop");
901 instructionTypes
.addEntry("kInstructionTypeCall");
902 instructionTypes
.addEntry("kInstructionTypeReturn");
903 instructionTypes
.emit(o
, i
);
908 void EDEmitter::run(raw_ostream
&o
) {
911 CompoundConstantEmitter infoArray
;
912 CodeGenTarget
target(Records
);
914 populateInstInfo(infoArray
, target
);
916 emitCommonEnums(o
, i
);
918 o
<< "namespace {\n";
920 o
<< "llvm::EDInstInfo instInfo" << target
.getName().c_str() << "[] = ";
921 infoArray
.emit(o
, i
);