xref: /aosp_15_r20/external/llvm/utils/TableGen/CodeGenInstruction.h (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker //===- CodeGenInstruction.h - Instruction Class Wrapper ---------*- C++ -*-===//
2*9880d681SAndroid Build Coastguard Worker //
3*9880d681SAndroid Build Coastguard Worker //                     The LLVM Compiler Infrastructure
4*9880d681SAndroid Build Coastguard Worker //
5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source
6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details.
7*9880d681SAndroid Build Coastguard Worker //
8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
9*9880d681SAndroid Build Coastguard Worker //
10*9880d681SAndroid Build Coastguard Worker // This file defines a wrapper class for the 'Instruction' TableGen class.
11*9880d681SAndroid Build Coastguard Worker //
12*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
13*9880d681SAndroid Build Coastguard Worker 
14*9880d681SAndroid Build Coastguard Worker #ifndef LLVM_UTILS_TABLEGEN_CODEGENINSTRUCTION_H
15*9880d681SAndroid Build Coastguard Worker #define LLVM_UTILS_TABLEGEN_CODEGENINSTRUCTION_H
16*9880d681SAndroid Build Coastguard Worker 
17*9880d681SAndroid Build Coastguard Worker #include "llvm/ADT/StringRef.h"
18*9880d681SAndroid Build Coastguard Worker #include "llvm/CodeGen/MachineValueType.h"
19*9880d681SAndroid Build Coastguard Worker #include "llvm/Support/SMLoc.h"
20*9880d681SAndroid Build Coastguard Worker #include <string>
21*9880d681SAndroid Build Coastguard Worker #include <utility>
22*9880d681SAndroid Build Coastguard Worker #include <vector>
23*9880d681SAndroid Build Coastguard Worker 
24*9880d681SAndroid Build Coastguard Worker namespace llvm {
25*9880d681SAndroid Build Coastguard Worker template <typename T> class ArrayRef;
26*9880d681SAndroid Build Coastguard Worker   class Record;
27*9880d681SAndroid Build Coastguard Worker   class DagInit;
28*9880d681SAndroid Build Coastguard Worker   class CodeGenTarget;
29*9880d681SAndroid Build Coastguard Worker 
30*9880d681SAndroid Build Coastguard Worker   class CGIOperandList {
31*9880d681SAndroid Build Coastguard Worker   public:
32*9880d681SAndroid Build Coastguard Worker     class ConstraintInfo {
33*9880d681SAndroid Build Coastguard Worker       enum { None, EarlyClobber, Tied } Kind;
34*9880d681SAndroid Build Coastguard Worker       unsigned OtherTiedOperand;
35*9880d681SAndroid Build Coastguard Worker     public:
ConstraintInfo()36*9880d681SAndroid Build Coastguard Worker       ConstraintInfo() : Kind(None) {}
37*9880d681SAndroid Build Coastguard Worker 
getEarlyClobber()38*9880d681SAndroid Build Coastguard Worker       static ConstraintInfo getEarlyClobber() {
39*9880d681SAndroid Build Coastguard Worker         ConstraintInfo I;
40*9880d681SAndroid Build Coastguard Worker         I.Kind = EarlyClobber;
41*9880d681SAndroid Build Coastguard Worker         I.OtherTiedOperand = 0;
42*9880d681SAndroid Build Coastguard Worker         return I;
43*9880d681SAndroid Build Coastguard Worker       }
44*9880d681SAndroid Build Coastguard Worker 
getTied(unsigned Op)45*9880d681SAndroid Build Coastguard Worker       static ConstraintInfo getTied(unsigned Op) {
46*9880d681SAndroid Build Coastguard Worker         ConstraintInfo I;
47*9880d681SAndroid Build Coastguard Worker         I.Kind = Tied;
48*9880d681SAndroid Build Coastguard Worker         I.OtherTiedOperand = Op;
49*9880d681SAndroid Build Coastguard Worker         return I;
50*9880d681SAndroid Build Coastguard Worker       }
51*9880d681SAndroid Build Coastguard Worker 
isNone()52*9880d681SAndroid Build Coastguard Worker       bool isNone() const { return Kind == None; }
isEarlyClobber()53*9880d681SAndroid Build Coastguard Worker       bool isEarlyClobber() const { return Kind == EarlyClobber; }
isTied()54*9880d681SAndroid Build Coastguard Worker       bool isTied() const { return Kind == Tied; }
55*9880d681SAndroid Build Coastguard Worker 
getTiedOperand()56*9880d681SAndroid Build Coastguard Worker       unsigned getTiedOperand() const {
57*9880d681SAndroid Build Coastguard Worker         assert(isTied());
58*9880d681SAndroid Build Coastguard Worker         return OtherTiedOperand;
59*9880d681SAndroid Build Coastguard Worker       }
60*9880d681SAndroid Build Coastguard Worker     };
61*9880d681SAndroid Build Coastguard Worker 
62*9880d681SAndroid Build Coastguard Worker     /// OperandInfo - The information we keep track of for each operand in the
63*9880d681SAndroid Build Coastguard Worker     /// operand list for a tablegen instruction.
64*9880d681SAndroid Build Coastguard Worker     struct OperandInfo {
65*9880d681SAndroid Build Coastguard Worker       /// Rec - The definition this operand is declared as.
66*9880d681SAndroid Build Coastguard Worker       ///
67*9880d681SAndroid Build Coastguard Worker       Record *Rec;
68*9880d681SAndroid Build Coastguard Worker 
69*9880d681SAndroid Build Coastguard Worker       /// Name - If this operand was assigned a symbolic name, this is it,
70*9880d681SAndroid Build Coastguard Worker       /// otherwise, it's empty.
71*9880d681SAndroid Build Coastguard Worker       std::string Name;
72*9880d681SAndroid Build Coastguard Worker 
73*9880d681SAndroid Build Coastguard Worker       /// PrinterMethodName - The method used to print operands of this type in
74*9880d681SAndroid Build Coastguard Worker       /// the asmprinter.
75*9880d681SAndroid Build Coastguard Worker       std::string PrinterMethodName;
76*9880d681SAndroid Build Coastguard Worker 
77*9880d681SAndroid Build Coastguard Worker       /// EncoderMethodName - The method used to get the machine operand value
78*9880d681SAndroid Build Coastguard Worker       /// for binary encoding. "getMachineOpValue" by default.
79*9880d681SAndroid Build Coastguard Worker       std::string EncoderMethodName;
80*9880d681SAndroid Build Coastguard Worker 
81*9880d681SAndroid Build Coastguard Worker       /// OperandType - A value from MCOI::OperandType representing the type of
82*9880d681SAndroid Build Coastguard Worker       /// the operand.
83*9880d681SAndroid Build Coastguard Worker       std::string OperandType;
84*9880d681SAndroid Build Coastguard Worker 
85*9880d681SAndroid Build Coastguard Worker       /// MIOperandNo - Currently (this is meant to be phased out), some logical
86*9880d681SAndroid Build Coastguard Worker       /// operands correspond to multiple MachineInstr operands.  In the X86
87*9880d681SAndroid Build Coastguard Worker       /// target for example, one address operand is represented as 4
88*9880d681SAndroid Build Coastguard Worker       /// MachineOperands.  Because of this, the operand number in the
89*9880d681SAndroid Build Coastguard Worker       /// OperandList may not match the MachineInstr operand num.  Until it
90*9880d681SAndroid Build Coastguard Worker       /// does, this contains the MI operand index of this operand.
91*9880d681SAndroid Build Coastguard Worker       unsigned MIOperandNo;
92*9880d681SAndroid Build Coastguard Worker       unsigned MINumOperands;   // The number of operands.
93*9880d681SAndroid Build Coastguard Worker 
94*9880d681SAndroid Build Coastguard Worker       /// DoNotEncode - Bools are set to true in this vector for each operand in
95*9880d681SAndroid Build Coastguard Worker       /// the DisableEncoding list.  These should not be emitted by the code
96*9880d681SAndroid Build Coastguard Worker       /// emitter.
97*9880d681SAndroid Build Coastguard Worker       std::vector<bool> DoNotEncode;
98*9880d681SAndroid Build Coastguard Worker 
99*9880d681SAndroid Build Coastguard Worker       /// MIOperandInfo - Default MI operand type. Note an operand may be made
100*9880d681SAndroid Build Coastguard Worker       /// up of multiple MI operands.
101*9880d681SAndroid Build Coastguard Worker       DagInit *MIOperandInfo;
102*9880d681SAndroid Build Coastguard Worker 
103*9880d681SAndroid Build Coastguard Worker       /// Constraint info for this operand.  This operand can have pieces, so we
104*9880d681SAndroid Build Coastguard Worker       /// track constraint info for each.
105*9880d681SAndroid Build Coastguard Worker       std::vector<ConstraintInfo> Constraints;
106*9880d681SAndroid Build Coastguard Worker 
OperandInfoOperandInfo107*9880d681SAndroid Build Coastguard Worker       OperandInfo(Record *R, const std::string &N, const std::string &PMN,
108*9880d681SAndroid Build Coastguard Worker                   const std::string &EMN, const std::string &OT, unsigned MION,
109*9880d681SAndroid Build Coastguard Worker                   unsigned MINO, DagInit *MIOI)
110*9880d681SAndroid Build Coastguard Worker       : Rec(R), Name(N), PrinterMethodName(PMN), EncoderMethodName(EMN),
111*9880d681SAndroid Build Coastguard Worker         OperandType(OT), MIOperandNo(MION), MINumOperands(MINO),
112*9880d681SAndroid Build Coastguard Worker         MIOperandInfo(MIOI) {}
113*9880d681SAndroid Build Coastguard Worker 
114*9880d681SAndroid Build Coastguard Worker 
115*9880d681SAndroid Build Coastguard Worker       /// getTiedOperand - If this operand is tied to another one, return the
116*9880d681SAndroid Build Coastguard Worker       /// other operand number.  Otherwise, return -1.
getTiedRegisterOperandInfo117*9880d681SAndroid Build Coastguard Worker       int getTiedRegister() const {
118*9880d681SAndroid Build Coastguard Worker         for (unsigned j = 0, e = Constraints.size(); j != e; ++j) {
119*9880d681SAndroid Build Coastguard Worker           const CGIOperandList::ConstraintInfo &CI = Constraints[j];
120*9880d681SAndroid Build Coastguard Worker           if (CI.isTied()) return CI.getTiedOperand();
121*9880d681SAndroid Build Coastguard Worker         }
122*9880d681SAndroid Build Coastguard Worker         return -1;
123*9880d681SAndroid Build Coastguard Worker       }
124*9880d681SAndroid Build Coastguard Worker     };
125*9880d681SAndroid Build Coastguard Worker 
126*9880d681SAndroid Build Coastguard Worker     CGIOperandList(Record *D);
127*9880d681SAndroid Build Coastguard Worker 
128*9880d681SAndroid Build Coastguard Worker     Record *TheDef;            // The actual record containing this OperandList.
129*9880d681SAndroid Build Coastguard Worker 
130*9880d681SAndroid Build Coastguard Worker     /// NumDefs - Number of def operands declared, this is the number of
131*9880d681SAndroid Build Coastguard Worker     /// elements in the instruction's (outs) list.
132*9880d681SAndroid Build Coastguard Worker     ///
133*9880d681SAndroid Build Coastguard Worker     unsigned NumDefs;
134*9880d681SAndroid Build Coastguard Worker 
135*9880d681SAndroid Build Coastguard Worker     /// OperandList - The list of declared operands, along with their declared
136*9880d681SAndroid Build Coastguard Worker     /// type (which is a record).
137*9880d681SAndroid Build Coastguard Worker     std::vector<OperandInfo> OperandList;
138*9880d681SAndroid Build Coastguard Worker 
139*9880d681SAndroid Build Coastguard Worker     // Information gleaned from the operand list.
140*9880d681SAndroid Build Coastguard Worker     bool isPredicable;
141*9880d681SAndroid Build Coastguard Worker     bool hasOptionalDef;
142*9880d681SAndroid Build Coastguard Worker     bool isVariadic;
143*9880d681SAndroid Build Coastguard Worker 
144*9880d681SAndroid Build Coastguard Worker     // Provide transparent accessors to the operand list.
empty()145*9880d681SAndroid Build Coastguard Worker     bool empty() const { return OperandList.empty(); }
size()146*9880d681SAndroid Build Coastguard Worker     unsigned size() const { return OperandList.size(); }
147*9880d681SAndroid Build Coastguard Worker     const OperandInfo &operator[](unsigned i) const { return OperandList[i]; }
148*9880d681SAndroid Build Coastguard Worker     OperandInfo &operator[](unsigned i) { return OperandList[i]; }
back()149*9880d681SAndroid Build Coastguard Worker     OperandInfo &back() { return OperandList.back(); }
back()150*9880d681SAndroid Build Coastguard Worker     const OperandInfo &back() const { return OperandList.back(); }
151*9880d681SAndroid Build Coastguard Worker 
152*9880d681SAndroid Build Coastguard Worker     typedef std::vector<OperandInfo>::iterator iterator;
153*9880d681SAndroid Build Coastguard Worker     typedef std::vector<OperandInfo>::const_iterator const_iterator;
begin()154*9880d681SAndroid Build Coastguard Worker     iterator begin() { return OperandList.begin(); }
begin()155*9880d681SAndroid Build Coastguard Worker     const_iterator begin() const { return OperandList.begin(); }
end()156*9880d681SAndroid Build Coastguard Worker     iterator end() { return OperandList.end(); }
end()157*9880d681SAndroid Build Coastguard Worker     const_iterator end() const { return OperandList.end(); }
158*9880d681SAndroid Build Coastguard Worker 
159*9880d681SAndroid Build Coastguard Worker     /// getOperandNamed - Return the index of the operand with the specified
160*9880d681SAndroid Build Coastguard Worker     /// non-empty name.  If the instruction does not have an operand with the
161*9880d681SAndroid Build Coastguard Worker     /// specified name, abort.
162*9880d681SAndroid Build Coastguard Worker     unsigned getOperandNamed(StringRef Name) const;
163*9880d681SAndroid Build Coastguard Worker 
164*9880d681SAndroid Build Coastguard Worker     /// hasOperandNamed - Query whether the instruction has an operand of the
165*9880d681SAndroid Build Coastguard Worker     /// given name. If so, return true and set OpIdx to the index of the
166*9880d681SAndroid Build Coastguard Worker     /// operand. Otherwise, return false.
167*9880d681SAndroid Build Coastguard Worker     bool hasOperandNamed(StringRef Name, unsigned &OpIdx) const;
168*9880d681SAndroid Build Coastguard Worker 
169*9880d681SAndroid Build Coastguard Worker     /// ParseOperandName - Parse an operand name like "$foo" or "$foo.bar",
170*9880d681SAndroid Build Coastguard Worker     /// where $foo is a whole operand and $foo.bar refers to a suboperand.
171*9880d681SAndroid Build Coastguard Worker     /// This aborts if the name is invalid.  If AllowWholeOp is true, references
172*9880d681SAndroid Build Coastguard Worker     /// to operands with suboperands are allowed, otherwise not.
173*9880d681SAndroid Build Coastguard Worker     std::pair<unsigned,unsigned> ParseOperandName(const std::string &Op,
174*9880d681SAndroid Build Coastguard Worker                                                   bool AllowWholeOp = true);
175*9880d681SAndroid Build Coastguard Worker 
176*9880d681SAndroid Build Coastguard Worker     /// getFlattenedOperandNumber - Flatten a operand/suboperand pair into a
177*9880d681SAndroid Build Coastguard Worker     /// flat machineinstr operand #.
getFlattenedOperandNumber(std::pair<unsigned,unsigned> Op)178*9880d681SAndroid Build Coastguard Worker     unsigned getFlattenedOperandNumber(std::pair<unsigned,unsigned> Op) const {
179*9880d681SAndroid Build Coastguard Worker       return OperandList[Op.first].MIOperandNo + Op.second;
180*9880d681SAndroid Build Coastguard Worker     }
181*9880d681SAndroid Build Coastguard Worker 
182*9880d681SAndroid Build Coastguard Worker     /// getSubOperandNumber - Unflatten a operand number into an
183*9880d681SAndroid Build Coastguard Worker     /// operand/suboperand pair.
getSubOperandNumber(unsigned Op)184*9880d681SAndroid Build Coastguard Worker     std::pair<unsigned,unsigned> getSubOperandNumber(unsigned Op) const {
185*9880d681SAndroid Build Coastguard Worker       for (unsigned i = 0; ; ++i) {
186*9880d681SAndroid Build Coastguard Worker         assert(i < OperandList.size() && "Invalid flat operand #");
187*9880d681SAndroid Build Coastguard Worker         if (OperandList[i].MIOperandNo+OperandList[i].MINumOperands > Op)
188*9880d681SAndroid Build Coastguard Worker           return std::make_pair(i, Op-OperandList[i].MIOperandNo);
189*9880d681SAndroid Build Coastguard Worker       }
190*9880d681SAndroid Build Coastguard Worker     }
191*9880d681SAndroid Build Coastguard Worker 
192*9880d681SAndroid Build Coastguard Worker 
193*9880d681SAndroid Build Coastguard Worker     /// isFlatOperandNotEmitted - Return true if the specified flat operand #
194*9880d681SAndroid Build Coastguard Worker     /// should not be emitted with the code emitter.
isFlatOperandNotEmitted(unsigned FlatOpNo)195*9880d681SAndroid Build Coastguard Worker     bool isFlatOperandNotEmitted(unsigned FlatOpNo) const {
196*9880d681SAndroid Build Coastguard Worker       std::pair<unsigned,unsigned> Op = getSubOperandNumber(FlatOpNo);
197*9880d681SAndroid Build Coastguard Worker       if (OperandList[Op.first].DoNotEncode.size() > Op.second)
198*9880d681SAndroid Build Coastguard Worker         return OperandList[Op.first].DoNotEncode[Op.second];
199*9880d681SAndroid Build Coastguard Worker       return false;
200*9880d681SAndroid Build Coastguard Worker     }
201*9880d681SAndroid Build Coastguard Worker 
202*9880d681SAndroid Build Coastguard Worker     void ProcessDisableEncoding(std::string Value);
203*9880d681SAndroid Build Coastguard Worker   };
204*9880d681SAndroid Build Coastguard Worker 
205*9880d681SAndroid Build Coastguard Worker 
206*9880d681SAndroid Build Coastguard Worker   class CodeGenInstruction {
207*9880d681SAndroid Build Coastguard Worker   public:
208*9880d681SAndroid Build Coastguard Worker     Record *TheDef;            // The actual record defining this instruction.
209*9880d681SAndroid Build Coastguard Worker     std::string Namespace;     // The namespace the instruction is in.
210*9880d681SAndroid Build Coastguard Worker 
211*9880d681SAndroid Build Coastguard Worker     /// AsmString - The format string used to emit a .s file for the
212*9880d681SAndroid Build Coastguard Worker     /// instruction.
213*9880d681SAndroid Build Coastguard Worker     std::string AsmString;
214*9880d681SAndroid Build Coastguard Worker 
215*9880d681SAndroid Build Coastguard Worker     /// Operands - This is information about the (ins) and (outs) list specified
216*9880d681SAndroid Build Coastguard Worker     /// to the instruction.
217*9880d681SAndroid Build Coastguard Worker     CGIOperandList Operands;
218*9880d681SAndroid Build Coastguard Worker 
219*9880d681SAndroid Build Coastguard Worker     /// ImplicitDefs/ImplicitUses - These are lists of registers that are
220*9880d681SAndroid Build Coastguard Worker     /// implicitly defined and used by the instruction.
221*9880d681SAndroid Build Coastguard Worker     std::vector<Record*> ImplicitDefs, ImplicitUses;
222*9880d681SAndroid Build Coastguard Worker 
223*9880d681SAndroid Build Coastguard Worker     // Various boolean values we track for the instruction.
224*9880d681SAndroid Build Coastguard Worker     bool isReturn : 1;
225*9880d681SAndroid Build Coastguard Worker     bool isBranch : 1;
226*9880d681SAndroid Build Coastguard Worker     bool isIndirectBranch : 1;
227*9880d681SAndroid Build Coastguard Worker     bool isCompare : 1;
228*9880d681SAndroid Build Coastguard Worker     bool isMoveImm : 1;
229*9880d681SAndroid Build Coastguard Worker     bool isBitcast : 1;
230*9880d681SAndroid Build Coastguard Worker     bool isSelect : 1;
231*9880d681SAndroid Build Coastguard Worker     bool isBarrier : 1;
232*9880d681SAndroid Build Coastguard Worker     bool isCall : 1;
233*9880d681SAndroid Build Coastguard Worker     bool canFoldAsLoad : 1;
234*9880d681SAndroid Build Coastguard Worker     bool mayLoad : 1;
235*9880d681SAndroid Build Coastguard Worker     bool mayLoad_Unset : 1;
236*9880d681SAndroid Build Coastguard Worker     bool mayStore : 1;
237*9880d681SAndroid Build Coastguard Worker     bool mayStore_Unset : 1;
238*9880d681SAndroid Build Coastguard Worker     bool isPredicable : 1;
239*9880d681SAndroid Build Coastguard Worker     bool isConvertibleToThreeAddress : 1;
240*9880d681SAndroid Build Coastguard Worker     bool isCommutable : 1;
241*9880d681SAndroid Build Coastguard Worker     bool isTerminator : 1;
242*9880d681SAndroid Build Coastguard Worker     bool isReMaterializable : 1;
243*9880d681SAndroid Build Coastguard Worker     bool hasDelaySlot : 1;
244*9880d681SAndroid Build Coastguard Worker     bool usesCustomInserter : 1;
245*9880d681SAndroid Build Coastguard Worker     bool hasPostISelHook : 1;
246*9880d681SAndroid Build Coastguard Worker     bool hasCtrlDep : 1;
247*9880d681SAndroid Build Coastguard Worker     bool isNotDuplicable : 1;
248*9880d681SAndroid Build Coastguard Worker     bool hasSideEffects : 1;
249*9880d681SAndroid Build Coastguard Worker     bool hasSideEffects_Unset : 1;
250*9880d681SAndroid Build Coastguard Worker     bool isAsCheapAsAMove : 1;
251*9880d681SAndroid Build Coastguard Worker     bool hasExtraSrcRegAllocReq : 1;
252*9880d681SAndroid Build Coastguard Worker     bool hasExtraDefRegAllocReq : 1;
253*9880d681SAndroid Build Coastguard Worker     bool isCodeGenOnly : 1;
254*9880d681SAndroid Build Coastguard Worker     bool isPseudo : 1;
255*9880d681SAndroid Build Coastguard Worker     bool isRegSequence : 1;
256*9880d681SAndroid Build Coastguard Worker     bool isExtractSubreg : 1;
257*9880d681SAndroid Build Coastguard Worker     bool isInsertSubreg : 1;
258*9880d681SAndroid Build Coastguard Worker     bool isConvergent : 1;
259*9880d681SAndroid Build Coastguard Worker     bool hasNoSchedulingInfo : 1;
260*9880d681SAndroid Build Coastguard Worker 
261*9880d681SAndroid Build Coastguard Worker     std::string DeprecatedReason;
262*9880d681SAndroid Build Coastguard Worker     bool HasComplexDeprecationPredicate;
263*9880d681SAndroid Build Coastguard Worker 
264*9880d681SAndroid Build Coastguard Worker     /// Are there any undefined flags?
hasUndefFlags()265*9880d681SAndroid Build Coastguard Worker     bool hasUndefFlags() const {
266*9880d681SAndroid Build Coastguard Worker       return mayLoad_Unset || mayStore_Unset || hasSideEffects_Unset;
267*9880d681SAndroid Build Coastguard Worker     }
268*9880d681SAndroid Build Coastguard Worker 
269*9880d681SAndroid Build Coastguard Worker     // The record used to infer instruction flags, or NULL if no flag values
270*9880d681SAndroid Build Coastguard Worker     // have been inferred.
271*9880d681SAndroid Build Coastguard Worker     Record *InferredFrom;
272*9880d681SAndroid Build Coastguard Worker 
273*9880d681SAndroid Build Coastguard Worker     CodeGenInstruction(Record *R);
274*9880d681SAndroid Build Coastguard Worker 
275*9880d681SAndroid Build Coastguard Worker     /// HasOneImplicitDefWithKnownVT - If the instruction has at least one
276*9880d681SAndroid Build Coastguard Worker     /// implicit def and it has a known VT, return the VT, otherwise return
277*9880d681SAndroid Build Coastguard Worker     /// MVT::Other.
278*9880d681SAndroid Build Coastguard Worker     MVT::SimpleValueType
279*9880d681SAndroid Build Coastguard Worker       HasOneImplicitDefWithKnownVT(const CodeGenTarget &TargetInfo) const;
280*9880d681SAndroid Build Coastguard Worker 
281*9880d681SAndroid Build Coastguard Worker 
282*9880d681SAndroid Build Coastguard Worker     /// FlattenAsmStringVariants - Flatten the specified AsmString to only
283*9880d681SAndroid Build Coastguard Worker     /// include text from the specified variant, returning the new string.
284*9880d681SAndroid Build Coastguard Worker     static std::string FlattenAsmStringVariants(StringRef AsmString,
285*9880d681SAndroid Build Coastguard Worker                                                 unsigned Variant);
286*9880d681SAndroid Build Coastguard Worker   };
287*9880d681SAndroid Build Coastguard Worker 
288*9880d681SAndroid Build Coastguard Worker 
289*9880d681SAndroid Build Coastguard Worker   /// CodeGenInstAlias - This represents an InstAlias definition.
290*9880d681SAndroid Build Coastguard Worker   class CodeGenInstAlias {
291*9880d681SAndroid Build Coastguard Worker   public:
292*9880d681SAndroid Build Coastguard Worker     Record *TheDef;            // The actual record defining this InstAlias.
293*9880d681SAndroid Build Coastguard Worker 
294*9880d681SAndroid Build Coastguard Worker     /// AsmString - The format string used to emit a .s file for the
295*9880d681SAndroid Build Coastguard Worker     /// instruction.
296*9880d681SAndroid Build Coastguard Worker     std::string AsmString;
297*9880d681SAndroid Build Coastguard Worker 
298*9880d681SAndroid Build Coastguard Worker     /// Result - The result instruction.
299*9880d681SAndroid Build Coastguard Worker     DagInit *Result;
300*9880d681SAndroid Build Coastguard Worker 
301*9880d681SAndroid Build Coastguard Worker     /// ResultInst - The instruction generated by the alias (decoded from
302*9880d681SAndroid Build Coastguard Worker     /// Result).
303*9880d681SAndroid Build Coastguard Worker     CodeGenInstruction *ResultInst;
304*9880d681SAndroid Build Coastguard Worker 
305*9880d681SAndroid Build Coastguard Worker 
306*9880d681SAndroid Build Coastguard Worker     struct ResultOperand {
307*9880d681SAndroid Build Coastguard Worker     private:
308*9880d681SAndroid Build Coastguard Worker       std::string Name;
309*9880d681SAndroid Build Coastguard Worker       Record *R;
310*9880d681SAndroid Build Coastguard Worker 
311*9880d681SAndroid Build Coastguard Worker       int64_t Imm;
312*9880d681SAndroid Build Coastguard Worker     public:
313*9880d681SAndroid Build Coastguard Worker       enum {
314*9880d681SAndroid Build Coastguard Worker         K_Record,
315*9880d681SAndroid Build Coastguard Worker         K_Imm,
316*9880d681SAndroid Build Coastguard Worker         K_Reg
317*9880d681SAndroid Build Coastguard Worker       } Kind;
318*9880d681SAndroid Build Coastguard Worker 
ResultOperandResultOperand319*9880d681SAndroid Build Coastguard Worker       ResultOperand(std::string N, Record *r)
320*9880d681SAndroid Build Coastguard Worker           : Name(std::move(N)), R(r), Kind(K_Record) {}
ResultOperandResultOperand321*9880d681SAndroid Build Coastguard Worker       ResultOperand(int64_t I) : Imm(I), Kind(K_Imm) {}
ResultOperandResultOperand322*9880d681SAndroid Build Coastguard Worker       ResultOperand(Record *r) : R(r), Kind(K_Reg) {}
323*9880d681SAndroid Build Coastguard Worker 
isRecordResultOperand324*9880d681SAndroid Build Coastguard Worker       bool isRecord() const { return Kind == K_Record; }
isImmResultOperand325*9880d681SAndroid Build Coastguard Worker       bool isImm() const { return Kind == K_Imm; }
isRegResultOperand326*9880d681SAndroid Build Coastguard Worker       bool isReg() const { return Kind == K_Reg; }
327*9880d681SAndroid Build Coastguard Worker 
getNameResultOperand328*9880d681SAndroid Build Coastguard Worker       StringRef getName() const { assert(isRecord()); return Name; }
getRecordResultOperand329*9880d681SAndroid Build Coastguard Worker       Record *getRecord() const { assert(isRecord()); return R; }
getImmResultOperand330*9880d681SAndroid Build Coastguard Worker       int64_t getImm() const { assert(isImm()); return Imm; }
getRegisterResultOperand331*9880d681SAndroid Build Coastguard Worker       Record *getRegister() const { assert(isReg()); return R; }
332*9880d681SAndroid Build Coastguard Worker 
333*9880d681SAndroid Build Coastguard Worker       unsigned getMINumOperands() const;
334*9880d681SAndroid Build Coastguard Worker     };
335*9880d681SAndroid Build Coastguard Worker 
336*9880d681SAndroid Build Coastguard Worker     /// ResultOperands - The decoded operands for the result instruction.
337*9880d681SAndroid Build Coastguard Worker     std::vector<ResultOperand> ResultOperands;
338*9880d681SAndroid Build Coastguard Worker 
339*9880d681SAndroid Build Coastguard Worker     /// ResultInstOperandIndex - For each operand, this vector holds a pair of
340*9880d681SAndroid Build Coastguard Worker     /// indices to identify the corresponding operand in the result
341*9880d681SAndroid Build Coastguard Worker     /// instruction.  The first index specifies the operand and the second
342*9880d681SAndroid Build Coastguard Worker     /// index specifies the suboperand.  If there are no suboperands or if all
343*9880d681SAndroid Build Coastguard Worker     /// of them are matched by the operand, the second value should be -1.
344*9880d681SAndroid Build Coastguard Worker     std::vector<std::pair<unsigned, int> > ResultInstOperandIndex;
345*9880d681SAndroid Build Coastguard Worker 
346*9880d681SAndroid Build Coastguard Worker     CodeGenInstAlias(Record *R, unsigned Variant, CodeGenTarget &T);
347*9880d681SAndroid Build Coastguard Worker 
348*9880d681SAndroid Build Coastguard Worker     bool tryAliasOpMatch(DagInit *Result, unsigned AliasOpNo,
349*9880d681SAndroid Build Coastguard Worker                          Record *InstOpRec, bool hasSubOps, ArrayRef<SMLoc> Loc,
350*9880d681SAndroid Build Coastguard Worker                          CodeGenTarget &T, ResultOperand &ResOp);
351*9880d681SAndroid Build Coastguard Worker   };
352*9880d681SAndroid Build Coastguard Worker }
353*9880d681SAndroid Build Coastguard Worker 
354*9880d681SAndroid Build Coastguard Worker #endif
355