1 //===- CodeGenInstruction.h - Instruction Class Wrapper ---------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines a wrapper class for the 'Instruction' TableGen class.
12 //===----------------------------------------------------------------------===//
14 #ifndef CODEGEN_INSTRUCTION_H
15 #define CODEGEN_INSTRUCTION_H
17 #include "llvm/CodeGen/ValueTypes.h"
26 struct CodeGenInstruction {
27 Record *TheDef; // The actual record defining this instruction.
28 std::string Name; // Contents of the 'Name' field.
29 std::string Namespace; // The namespace the instruction is in.
31 /// AsmString - The format string used to emit a .s file for the
33 std::string AsmString;
35 /// OperandInfo - The information we keep track of for each operand in the
36 /// operand list for a tablegen instruction.
38 /// Rec - The definition this operand is declared as.
42 /// Name - If this operand was assigned a symbolic name, this is it,
43 /// otherwise, it's empty.
46 /// PrinterMethodName - The method used to print operands of this type in
48 std::string PrinterMethodName;
50 /// MIOperandNo - Currently (this is meant to be phased out), some logical
51 /// operands correspond to multiple MachineInstr operands. In the X86
52 /// target for example, one address operand is represented as 4
53 /// MachineOperands. Because of this, the operand number in the
54 /// OperandList may not match the MachineInstr operand num. Until it
55 /// does, this contains the MI operand index of this operand.
57 unsigned MINumOperands; // The number of operands.
59 /// MIOperandInfo - Default MI operand type. Note an operand may be made
60 /// up of multiple MI operands.
61 DagInit *MIOperandInfo;
63 OperandInfo(Record *R, const std::string &N, const std::string &PMN,
64 unsigned MION, unsigned MINO, DagInit *MIOI)
65 : Rec(R), Name(N), PrinterMethodName(PMN), MIOperandNo(MION),
66 MINumOperands(MINO), MIOperandInfo(MIOI) {}
69 /// OperandList - The list of declared operands, along with their declared
70 /// type (which is a record).
71 std::vector<OperandInfo> OperandList;
73 // Various boolean values we track for the instruction.
81 bool isConvertibleToThreeAddress;
85 bool usesCustomDAGSchedInserter;
86 bool hasVariableNumberOfOperands;
89 CodeGenInstruction(Record *R, const std::string &AsmStr);
91 /// getOperandNamed - Return the index of the operand with the specified
92 /// non-empty name. If the instruction does not have an operand with the
93 /// specified name, throw an exception.
94 unsigned getOperandNamed(const std::string &Name) const;