spell this variable right
[oota-llvm.git] / utils / TableGen / CodeGenInstruction.h
1 //===- CodeGenInstruction.h - Instruction Class Wrapper ---------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
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.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines a wrapper class for the 'Instruction' TableGen class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef CODEGEN_INSTRUCTION_H
15 #define CODEGEN_INSTRUCTION_H
16
17 #include "llvm/CodeGen/ValueTypes.h"
18 #include <string>
19 #include <vector>
20 #include <utility>
21
22 namespace llvm {
23   class Record;
24
25   struct CodeGenInstruction {
26     Record *TheDef;            // The actual record defining this instruction.
27     std::string Name;          // Contents of the 'Name' field.
28     std::string Namespace;     // The namespace the instruction is in.
29
30     /// AsmString - The format string used to emit a .s file for the
31     /// instruction.
32     std::string AsmString;
33
34     /// OperandInfo - The information we keep track of for each operand in the
35     /// operand list for a tablegen instruction.
36     struct OperandInfo {
37       /// Rec - The definition this operand is declared as.
38       ///
39       Record *Rec;
40
41       /// Ty - The MachineValueType of the operand.
42       ///
43       MVT::ValueType Ty;
44
45       /// Name - If this operand was assigned a symbolic name, this is it,
46       /// otherwise, it's empty.
47       std::string Name;
48
49       /// PrinterMethodName - The method used to print operands of this type in
50       /// the asmprinter.
51       std::string PrinterMethodName;
52
53       /// MIOperandNo - Currently (this is meant to be phased out), some logical
54       /// operands correspond to multiple MachineInstr operands.  In the X86
55       /// target for example, one address operand is represented as 4
56       /// MachineOperands.  Because of this, the operand number in the
57       /// OperandList may not match the MachineInstr operand num.  Until it
58       /// does, this contains the MI operand index of this operand.
59       unsigned MIOperandNo;
60       unsigned MINumOperands;   // The number of operands.
61
62       OperandInfo(Record *R, MVT::ValueType T, const std::string &N,
63                   const std::string &PMN, unsigned MION, unsigned MINO)
64         : Rec(R), Ty(T), Name(N), PrinterMethodName(PMN), MIOperandNo(MION),
65           MINumOperands(MINO) {}
66     };
67
68     /// OperandList - The list of declared operands, along with their declared
69     /// type (which is a record).
70     std::vector<OperandInfo> OperandList;
71
72     // Various boolean values we track for the instruction.
73     bool isReturn;
74     bool isBranch;
75     bool isBarrier;
76     bool isCall;
77     bool isLoad;
78     bool isStore;
79     bool isTwoAddress;
80     bool isConvertibleToThreeAddress;
81     bool isCommutable;
82     bool isTerminator;
83     bool hasDelaySlot;
84     bool usesCustomDAGSchedInserter;
85     bool hasVariableNumberOfOperands;
86
87     CodeGenInstruction(Record *R, const std::string &AsmStr);
88
89     /// getOperandNamed - Return the index of the operand with the specified
90     /// non-empty name.  If the instruction does not have an operand with the
91     /// specified name, throw an exception.
92     unsigned getOperandNamed(const std::string &Name) const;
93   };
94 }
95
96 #endif