blob: 1f08ce481a8989541c7a447a424d2072b2a2f862 [file] [log] [blame]
Chris Lattnerc860eca2004-08-01 05:04:00 +00001//===- CodeGenInstruction.h - Instruction Class Wrapper ---------*- C++ -*-===//
Misha Brukman650ba8e2005-04-22 00:00:37 +00002//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Misha Brukman650ba8e2005-04-22 00:00:37 +00006//
Chris Lattnerc860eca2004-08-01 05:04:00 +00007//===----------------------------------------------------------------------===//
8//
9// This file defines a wrapper class for the 'Instruction' TableGen class.
10//
11//===----------------------------------------------------------------------===//
12
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000013#ifndef LLVM_UTILS_TABLEGEN_CODEGENINSTRUCTION_H
14#define LLVM_UTILS_TABLEGEN_CODEGENINSTRUCTION_H
Chris Lattnerc860eca2004-08-01 05:04:00 +000015
Chris Lattner8ffd1292010-11-06 06:39:47 +000016#include "llvm/ADT/StringRef.h"
David Blaikie13e77db2018-03-23 23:58:25 +000017#include "llvm/Support/MachineValueType.h"
Craig Topperf7ce7242015-06-08 01:35:40 +000018#include "llvm/Support/SMLoc.h"
Chris Lattnerc860eca2004-08-01 05:04:00 +000019#include <string>
Chris Lattnerc860eca2004-08-01 05:04:00 +000020#include <utility>
Chandler Carruth91d19d82012-12-04 10:37:14 +000021#include <vector>
Chris Lattnerc860eca2004-08-01 05:04:00 +000022
23namespace llvm {
Mehdi Aminib550cb12016-04-18 09:17:29 +000024template <typename T> class ArrayRef;
Chris Lattnerc860eca2004-08-01 05:04:00 +000025 class Record;
Chris Lattner6bc03042005-11-19 07:05:57 +000026 class DagInit;
Chris Lattner7bc5d9b2010-03-27 20:09:24 +000027 class CodeGenTarget;
Jim Grosbach876ee072011-03-14 17:32:49 +000028
Chris Lattnerd8adec72010-11-01 04:03:32 +000029 class CGIOperandList {
Jeff Cohen7d6f3db2006-11-05 19:31:28 +000030 public:
Chris Lattnera9dfb1b2010-02-10 01:45:28 +000031 class ConstraintInfo {
Simon Pilgrimcca01c02019-11-06 16:30:04 +000032 enum { None, EarlyClobber, Tied } Kind = None;
33 unsigned OtherTiedOperand = 0;
34
Chris Lattnera9dfb1b2010-02-10 01:45:28 +000035 public:
Simon Pilgrimcca01c02019-11-06 16:30:04 +000036 ConstraintInfo() = default;
Jim Grosbach876ee072011-03-14 17:32:49 +000037
Chris Lattnera9dfb1b2010-02-10 01:45:28 +000038 static ConstraintInfo getEarlyClobber() {
39 ConstraintInfo I;
40 I.Kind = EarlyClobber;
Chris Lattner0d7b5e52010-02-10 21:22:51 +000041 I.OtherTiedOperand = 0;
Chris Lattnera9dfb1b2010-02-10 01:45:28 +000042 return I;
43 }
Jim Grosbach876ee072011-03-14 17:32:49 +000044
Chris Lattnera9dfb1b2010-02-10 01:45:28 +000045 static ConstraintInfo getTied(unsigned Op) {
46 ConstraintInfo I;
47 I.Kind = Tied;
48 I.OtherTiedOperand = Op;
49 return I;
50 }
Jim Grosbach876ee072011-03-14 17:32:49 +000051
Chris Lattnera9dfb1b2010-02-10 01:45:28 +000052 bool isNone() const { return Kind == None; }
53 bool isEarlyClobber() const { return Kind == EarlyClobber; }
54 bool isTied() const { return Kind == Tied; }
Jim Grosbach876ee072011-03-14 17:32:49 +000055
Chris Lattnera9dfb1b2010-02-10 01:45:28 +000056 unsigned getTiedOperand() const {
57 assert(isTied());
58 return OtherTiedOperand;
59 }
Simon Tatham34860552018-11-28 11:43:49 +000060
61 bool operator==(const ConstraintInfo &RHS) const {
62 if (Kind != RHS.Kind)
63 return false;
64 if (Kind == Tied && OtherTiedOperand != RHS.OtherTiedOperand)
65 return false;
66 return true;
67 }
Haojian Wuf838e902018-11-28 12:32:53 +000068 bool operator!=(const ConstraintInfo &RHS) const {
69 return !(*this == RHS);
70 }
Chris Lattnera9dfb1b2010-02-10 01:45:28 +000071 };
Jim Grosbach2f0be8f2010-10-08 18:09:59 +000072
Chris Lattner3bc477a2004-08-11 02:22:39 +000073 /// OperandInfo - The information we keep track of for each operand in the
74 /// operand list for a tablegen instruction.
Chris Lattner55726822004-08-01 07:42:39 +000075 struct OperandInfo {
Chris Lattner3bc477a2004-08-11 02:22:39 +000076 /// Rec - The definition this operand is declared as.
Chris Lattner220d0012005-08-19 16:57:28 +000077 ///
Chris Lattner55726822004-08-01 07:42:39 +000078 Record *Rec;
Jim Grosbach876ee072011-03-14 17:32:49 +000079
Chris Lattner3bc477a2004-08-11 02:22:39 +000080 /// Name - If this operand was assigned a symbolic name, this is it,
81 /// otherwise, it's empty.
Chris Lattner55726822004-08-01 07:42:39 +000082 std::string Name;
Jim Grosbach876ee072011-03-14 17:32:49 +000083
Chris Lattner3bc477a2004-08-11 02:22:39 +000084 /// PrinterMethodName - The method used to print operands of this type in
85 /// the asmprinter.
86 std::string PrinterMethodName;
Jim Grosbach876ee072011-03-14 17:32:49 +000087
Jim Grosbach51a12eb2010-10-12 22:21:57 +000088 /// EncoderMethodName - The method used to get the machine operand value
89 /// for binary encoding. "getMachineOpValue" by default.
90 std::string EncoderMethodName;
Jim Grosbach876ee072011-03-14 17:32:49 +000091
Benjamin Kramerc8dc46b2011-07-14 21:47:18 +000092 /// OperandType - A value from MCOI::OperandType representing the type of
93 /// the operand.
94 std::string OperandType;
95
Chris Lattner3bc477a2004-08-11 02:22:39 +000096 /// MIOperandNo - Currently (this is meant to be phased out), some logical
97 /// operands correspond to multiple MachineInstr operands. In the X86
98 /// target for example, one address operand is represented as 4
99 /// MachineOperands. Because of this, the operand number in the
100 /// OperandList may not match the MachineInstr operand num. Until it
101 /// does, this contains the MI operand index of this operand.
102 unsigned MIOperandNo;
Chris Lattner17727ba2005-08-18 23:38:41 +0000103 unsigned MINumOperands; // The number of operands.
Jim Grosbach876ee072011-03-14 17:32:49 +0000104
Chris Lattner78a403f2006-11-15 23:23:02 +0000105 /// DoNotEncode - Bools are set to true in this vector for each operand in
106 /// the DisableEncoding list. These should not be emitted by the code
107 /// emitter.
108 std::vector<bool> DoNotEncode;
Jim Grosbach876ee072011-03-14 17:32:49 +0000109
Nate Begemane479ccb2005-11-30 23:58:18 +0000110 /// MIOperandInfo - Default MI operand type. Note an operand may be made
111 /// up of multiple MI operands.
David Greeneaf8ee2c2011-07-29 22:43:06 +0000112 DagInit *MIOperandInfo;
Jim Grosbach876ee072011-03-14 17:32:49 +0000113
Chris Lattnerc94f2142006-11-15 02:38:17 +0000114 /// Constraint info for this operand. This operand can have pieces, so we
115 /// track constraint info for each.
Chris Lattnera9dfb1b2010-02-10 01:45:28 +0000116 std::vector<ConstraintInfo> Constraints;
Jim Grosbach876ee072011-03-14 17:32:49 +0000117
Jim Grosbach2f0be8f2010-10-08 18:09:59 +0000118 OperandInfo(Record *R, const std::string &N, const std::string &PMN,
Benjamin Kramerc8dc46b2011-07-14 21:47:18 +0000119 const std::string &EMN, const std::string &OT, unsigned MION,
David Greeneaf8ee2c2011-07-29 22:43:06 +0000120 unsigned MINO, DagInit *MIOI)
Chris Lattnerd8adec72010-11-01 04:03:32 +0000121 : Rec(R), Name(N), PrinterMethodName(PMN), EncoderMethodName(EMN),
Benjamin Kramerc8dc46b2011-07-14 21:47:18 +0000122 OperandType(OT), MIOperandNo(MION), MINumOperands(MINO),
123 MIOperandInfo(MIOI) {}
Jim Grosbach876ee072011-03-14 17:32:49 +0000124
125
Chris Lattnere032dbf2010-11-02 22:55:03 +0000126 /// getTiedOperand - If this operand is tied to another one, return the
127 /// other operand number. Otherwise, return -1.
128 int getTiedRegister() const {
129 for (unsigned j = 0, e = Constraints.size(); j != e; ++j) {
130 const CGIOperandList::ConstraintInfo &CI = Constraints[j];
131 if (CI.isTied()) return CI.getTiedOperand();
132 }
133 return -1;
134 }
Chris Lattner55726822004-08-01 07:42:39 +0000135 };
Jim Grosbach876ee072011-03-14 17:32:49 +0000136
Chris Lattnerd8adec72010-11-01 04:03:32 +0000137 CGIOperandList(Record *D);
Jim Grosbach876ee072011-03-14 17:32:49 +0000138
Chris Lattnerd8adec72010-11-01 04:03:32 +0000139 Record *TheDef; // The actual record containing this OperandList.
Misha Brukman650ba8e2005-04-22 00:00:37 +0000140
Chris Lattner5f418ea2010-03-18 20:50:52 +0000141 /// NumDefs - Number of def operands declared, this is the number of
142 /// elements in the instruction's (outs) list.
Evan Cheng94b5a802007-07-19 01:14:50 +0000143 ///
144 unsigned NumDefs;
Jim Grosbach876ee072011-03-14 17:32:49 +0000145
Chris Lattnerc860eca2004-08-01 05:04:00 +0000146 /// OperandList - The list of declared operands, along with their declared
147 /// type (which is a record).
Chris Lattner55726822004-08-01 07:42:39 +0000148 std::vector<OperandInfo> OperandList;
Jim Grosbach876ee072011-03-14 17:32:49 +0000149
Chris Lattnerd8adec72010-11-01 04:03:32 +0000150 // Information gleaned from the operand list.
151 bool isPredicable;
152 bool hasOptionalDef;
153 bool isVariadic;
Jim Grosbach876ee072011-03-14 17:32:49 +0000154
Chris Lattnerd8adec72010-11-01 04:03:32 +0000155 // Provide transparent accessors to the operand list.
Chris Lattner90803912011-04-17 22:24:13 +0000156 bool empty() const { return OperandList.empty(); }
Chris Lattnerd8adec72010-11-01 04:03:32 +0000157 unsigned size() const { return OperandList.size(); }
158 const OperandInfo &operator[](unsigned i) const { return OperandList[i]; }
159 OperandInfo &operator[](unsigned i) { return OperandList[i]; }
160 OperandInfo &back() { return OperandList.back(); }
161 const OperandInfo &back() const { return OperandList.back(); }
Jim Grosbach876ee072011-03-14 17:32:49 +0000162
Jim Grosbach0e28a352014-04-18 02:08:58 +0000163 typedef std::vector<OperandInfo>::iterator iterator;
164 typedef std::vector<OperandInfo>::const_iterator const_iterator;
165 iterator begin() { return OperandList.begin(); }
166 const_iterator begin() const { return OperandList.begin(); }
167 iterator end() { return OperandList.end(); }
168 const_iterator end() const { return OperandList.end(); }
169
Chris Lattnerd8adec72010-11-01 04:03:32 +0000170 /// getOperandNamed - Return the index of the operand with the specified
171 /// non-empty name. If the instruction does not have an operand with the
Joerg Sonnenberger635debe2012-10-25 20:33:17 +0000172 /// specified name, abort.
Chris Lattnerd8adec72010-11-01 04:03:32 +0000173 unsigned getOperandNamed(StringRef Name) const;
Jim Grosbach876ee072011-03-14 17:32:49 +0000174
Chris Lattnerd8adec72010-11-01 04:03:32 +0000175 /// hasOperandNamed - Query whether the instruction has an operand of the
176 /// given name. If so, return true and set OpIdx to the index of the
177 /// operand. Otherwise, return false.
178 bool hasOperandNamed(StringRef Name, unsigned &OpIdx) const;
Jim Grosbach876ee072011-03-14 17:32:49 +0000179
Chris Lattnerd8adec72010-11-01 04:03:32 +0000180 /// ParseOperandName - Parse an operand name like "$foo" or "$foo.bar",
181 /// where $foo is a whole operand and $foo.bar refers to a suboperand.
Joerg Sonnenberger635debe2012-10-25 20:33:17 +0000182 /// This aborts if the name is invalid. If AllowWholeOp is true, references
183 /// to operands with suboperands are allowed, otherwise not.
Chris Lattnerd8adec72010-11-01 04:03:32 +0000184 std::pair<unsigned,unsigned> ParseOperandName(const std::string &Op,
185 bool AllowWholeOp = true);
Jim Grosbach876ee072011-03-14 17:32:49 +0000186
Chris Lattnerd8adec72010-11-01 04:03:32 +0000187 /// getFlattenedOperandNumber - Flatten a operand/suboperand pair into a
188 /// flat machineinstr operand #.
189 unsigned getFlattenedOperandNumber(std::pair<unsigned,unsigned> Op) const {
190 return OperandList[Op.first].MIOperandNo + Op.second;
191 }
Jim Grosbach876ee072011-03-14 17:32:49 +0000192
Chris Lattnerd8adec72010-11-01 04:03:32 +0000193 /// getSubOperandNumber - Unflatten a operand number into an
194 /// operand/suboperand pair.
195 std::pair<unsigned,unsigned> getSubOperandNumber(unsigned Op) const {
196 for (unsigned i = 0; ; ++i) {
197 assert(i < OperandList.size() && "Invalid flat operand #");
198 if (OperandList[i].MIOperandNo+OperandList[i].MINumOperands > Op)
199 return std::make_pair(i, Op-OperandList[i].MIOperandNo);
200 }
201 }
Jim Grosbach876ee072011-03-14 17:32:49 +0000202
203
Chris Lattnerd8adec72010-11-01 04:03:32 +0000204 /// isFlatOperandNotEmitted - Return true if the specified flat operand #
205 /// should not be emitted with the code emitter.
206 bool isFlatOperandNotEmitted(unsigned FlatOpNo) const {
207 std::pair<unsigned,unsigned> Op = getSubOperandNumber(FlatOpNo);
208 if (OperandList[Op.first].DoNotEncode.size() > Op.second)
209 return OperandList[Op.first].DoNotEncode[Op.second];
210 return false;
211 }
Jim Grosbach876ee072011-03-14 17:32:49 +0000212
Chris Lattnerd8adec72010-11-01 04:03:32 +0000213 void ProcessDisableEncoding(std::string Value);
214 };
Jim Grosbach876ee072011-03-14 17:32:49 +0000215
Chris Lattnerd8adec72010-11-01 04:03:32 +0000216
217 class CodeGenInstruction {
218 public:
219 Record *TheDef; // The actual record defining this instruction.
Craig Topper86a9aee2017-07-07 06:22:35 +0000220 StringRef Namespace; // The namespace the instruction is in.
Chris Lattnerd8adec72010-11-01 04:03:32 +0000221
222 /// AsmString - The format string used to emit a .s file for the
223 /// instruction.
224 std::string AsmString;
225
226 /// Operands - This is information about the (ins) and (outs) list specified
227 /// to the instruction.
228 CGIOperandList Operands;
Chris Lattnerc860eca2004-08-01 05:04:00 +0000229
Chris Lattner2130a3e2010-03-18 21:42:03 +0000230 /// ImplicitDefs/ImplicitUses - These are lists of registers that are
231 /// implicitly defined and used by the instruction.
232 std::vector<Record*> ImplicitDefs, ImplicitUses;
233
Chris Lattnerc860eca2004-08-01 05:04:00 +0000234 // Various boolean values we track for the instruction.
Matt Arsenault27269052019-10-07 18:43:29 +0000235 bool isPreISelOpcode : 1;
Craig Topperbc9486b2014-02-05 09:10:40 +0000236 bool isReturn : 1;
Heejin Ahned5e06b2018-08-21 19:44:11 +0000237 bool isEHScopeReturn : 1;
Craig Topperbc9486b2014-02-05 09:10:40 +0000238 bool isBranch : 1;
239 bool isIndirectBranch : 1;
240 bool isCompare : 1;
241 bool isMoveImm : 1;
Petar Jovanovicc0510002018-05-23 15:28:28 +0000242 bool isMoveReg : 1;
Craig Topperbc9486b2014-02-05 09:10:40 +0000243 bool isBitcast : 1;
244 bool isSelect : 1;
245 bool isBarrier : 1;
246 bool isCall : 1;
Sjoerd Meijer724023a2016-09-14 08:20:03 +0000247 bool isAdd : 1;
Joel Galenson06e7e572018-07-13 15:19:33 +0000248 bool isTrap : 1;
Craig Topperbc9486b2014-02-05 09:10:40 +0000249 bool canFoldAsLoad : 1;
250 bool mayLoad : 1;
251 bool mayLoad_Unset : 1;
252 bool mayStore : 1;
253 bool mayStore_Unset : 1;
Ulrich Weigand6c5d5ce2019-06-05 22:33:10 +0000254 bool mayRaiseFPException : 1;
Craig Topperbc9486b2014-02-05 09:10:40 +0000255 bool isPredicable : 1;
256 bool isConvertibleToThreeAddress : 1;
257 bool isCommutable : 1;
258 bool isTerminator : 1;
259 bool isReMaterializable : 1;
260 bool hasDelaySlot : 1;
261 bool usesCustomInserter : 1;
262 bool hasPostISelHook : 1;
263 bool hasCtrlDep : 1;
264 bool isNotDuplicable : 1;
265 bool hasSideEffects : 1;
266 bool hasSideEffects_Unset : 1;
Craig Topperbc9486b2014-02-05 09:10:40 +0000267 bool isAsCheapAsAMove : 1;
268 bool hasExtraSrcRegAllocReq : 1;
269 bool hasExtraDefRegAllocReq : 1;
270 bool isCodeGenOnly : 1;
271 bool isPseudo : 1;
Quentin Colombetd533cdf2014-08-11 22:17:14 +0000272 bool isRegSequence : 1;
Quentin Colombet7e75cba2014-08-20 21:51:26 +0000273 bool isExtractSubreg : 1;
Quentin Colombet7e3da662014-08-20 23:49:36 +0000274 bool isInsertSubreg : 1;
Owen Andersonabaa5232015-05-28 18:33:39 +0000275 bool isConvergent : 1;
Matthias Braun8e0a7342016-03-01 20:03:11 +0000276 bool hasNoSchedulingInfo : 1;
Simon Dardis13de5552018-05-22 14:36:58 +0000277 bool FastISelShouldIgnore : 1;
Ulrich Weigandc48aefb2018-07-13 13:18:00 +0000278 bool hasChain : 1;
279 bool hasChain_Inferred : 1;
Oliver Stannard4cf35b42018-12-03 10:32:42 +0000280 bool variadicOpsAreDefs : 1;
Vedant Kumara9052b42019-11-14 13:11:34 -0800281 bool isAuthenticated : 1;
Jim Grosbach2f0be8f2010-10-08 18:09:59 +0000282
Joey Gouly0e76fa72013-09-12 10:28:05 +0000283 std::string DeprecatedReason;
284 bool HasComplexDeprecationPredicate;
285
Jakob Stoklund Olesen94ed4d42012-08-24 00:31:16 +0000286 /// Are there any undefined flags?
287 bool hasUndefFlags() const {
288 return mayLoad_Unset || mayStore_Unset || hasSideEffects_Unset;
289 }
290
291 // The record used to infer instruction flags, or NULL if no flag values
292 // have been inferred.
293 Record *InferredFrom;
Chris Lattnerc860eca2004-08-01 05:04:00 +0000294
Chris Lattnera3977162010-11-01 02:15:23 +0000295 CodeGenInstruction(Record *R);
Chris Lattner55726822004-08-01 07:42:39 +0000296
Chris Lattner7bc5d9b2010-03-27 20:09:24 +0000297 /// HasOneImplicitDefWithKnownVT - If the instruction has at least one
298 /// implicit def and it has a known VT, return the VT, otherwise return
299 /// MVT::Other.
Jim Grosbach2f0be8f2010-10-08 18:09:59 +0000300 MVT::SimpleValueType
Chris Lattner7bc5d9b2010-03-27 20:09:24 +0000301 HasOneImplicitDefWithKnownVT(const CodeGenTarget &TargetInfo) const;
Jim Grosbach876ee072011-03-14 17:32:49 +0000302
303
Chris Lattner25d9c7f2010-11-01 01:07:14 +0000304 /// FlattenAsmStringVariants - Flatten the specified AsmString to only
305 /// include text from the specified variant, returning the new string.
306 static std::string FlattenAsmStringVariants(StringRef AsmString,
307 unsigned Variant);
Daniel Sandersc54aa9c2017-11-18 00:16:44 +0000308
309 // Is the specified operand in a generic instruction implicitly a pointer.
310 // This can be used on intructions that use typeN or ptypeN to identify
311 // operands that should be considered as pointers even though SelectionDAG
312 // didn't make a distinction between integer and pointers.
Matt Arsenault10edb1d2020-01-08 15:40:37 -0500313 bool isOperandAPointer(unsigned i) const {
314 return isOperandImpl(i, "IsPointer");
315 }
316
317 /// Check if the operand is required to be an immediate.
318 bool isOperandImmArg(unsigned i) const {
319 return isOperandImpl(i, "IsImmediate");
320 }
321
322 private:
323 bool isOperandImpl(unsigned i, StringRef PropertyName) const;
Chris Lattnerc860eca2004-08-01 05:04:00 +0000324 };
Jim Grosbach876ee072011-03-14 17:32:49 +0000325
326
Chris Lattner488c2012010-11-01 04:05:41 +0000327 /// CodeGenInstAlias - This represents an InstAlias definition.
328 class CodeGenInstAlias {
329 public:
330 Record *TheDef; // The actual record defining this InstAlias.
Jim Grosbach876ee072011-03-14 17:32:49 +0000331
Chris Lattner488c2012010-11-01 04:05:41 +0000332 /// AsmString - The format string used to emit a .s file for the
333 /// instruction.
334 std::string AsmString;
Jim Grosbach876ee072011-03-14 17:32:49 +0000335
Chris Lattnerdd3b09c2010-11-01 05:34:34 +0000336 /// Result - The result instruction.
David Greeneaf8ee2c2011-07-29 22:43:06 +0000337 DagInit *Result;
Jim Grosbach876ee072011-03-14 17:32:49 +0000338
Chris Lattner8ffd1292010-11-06 06:39:47 +0000339 /// ResultInst - The instruction generated by the alias (decoded from
340 /// Result).
341 CodeGenInstruction *ResultInst;
Jim Grosbach876ee072011-03-14 17:32:49 +0000342
343
Chris Lattner8ffd1292010-11-06 06:39:47 +0000344 struct ResultOperand {
Chris Lattnerb6f8e822010-11-06 19:25:43 +0000345 private:
Owen Andersonda6bd3e2012-06-08 00:25:03 +0000346 std::string Name;
Simon Pilgrimcca01c02019-11-06 16:30:04 +0000347 Record *R = nullptr;
348 int64_t Imm = 0;
Jim Grosbach876ee072011-03-14 17:32:49 +0000349
Jim Grosbach876ee072011-03-14 17:32:49 +0000350 public:
Chris Lattnerb6f8e822010-11-06 19:25:43 +0000351 enum {
352 K_Record,
Chris Lattner4869d342010-11-06 19:57:21 +0000353 K_Imm,
354 K_Reg
Chris Lattnerb6f8e822010-11-06 19:25:43 +0000355 } Kind;
Jim Grosbach876ee072011-03-14 17:32:49 +0000356
Benjamin Kramer82de7d32016-05-27 14:27:24 +0000357 ResultOperand(std::string N, Record *r)
358 : Name(std::move(N)), R(r), Kind(K_Record) {}
Chris Lattnerb6f8e822010-11-06 19:25:43 +0000359 ResultOperand(int64_t I) : Imm(I), Kind(K_Imm) {}
Chris Lattner4869d342010-11-06 19:57:21 +0000360 ResultOperand(Record *r) : R(r), Kind(K_Reg) {}
Chris Lattnerb6f8e822010-11-06 19:25:43 +0000361
362 bool isRecord() const { return Kind == K_Record; }
363 bool isImm() const { return Kind == K_Imm; }
Chris Lattner4869d342010-11-06 19:57:21 +0000364 bool isReg() const { return Kind == K_Reg; }
Jim Grosbach876ee072011-03-14 17:32:49 +0000365
Chris Lattnerb6f8e822010-11-06 19:25:43 +0000366 StringRef getName() const { assert(isRecord()); return Name; }
367 Record *getRecord() const { assert(isRecord()); return R; }
368 int64_t getImm() const { assert(isImm()); return Imm; }
Chris Lattner4869d342010-11-06 19:57:21 +0000369 Record *getRegister() const { assert(isReg()); return R; }
Tim Northover60091cf2014-05-15 13:36:01 +0000370
371 unsigned getMINumOperands() const;
Chris Lattner8ffd1292010-11-06 06:39:47 +0000372 };
Jim Grosbach876ee072011-03-14 17:32:49 +0000373
Chris Lattner8ffd1292010-11-06 06:39:47 +0000374 /// ResultOperands - The decoded operands for the result instruction.
375 std::vector<ResultOperand> ResultOperands;
Bob Wilsonf3f28352011-01-20 18:38:02 +0000376
Bob Wilsonb9b24222011-01-26 19:44:55 +0000377 /// ResultInstOperandIndex - For each operand, this vector holds a pair of
378 /// indices to identify the corresponding operand in the result
379 /// instruction. The first index specifies the operand and the second
380 /// index specifies the suboperand. If there are no suboperands or if all
381 /// of them are matched by the operand, the second value should be -1.
382 std::vector<std::pair<unsigned, int> > ResultInstOperandIndex;
Jim Grosbach876ee072011-03-14 17:32:49 +0000383
Craig Topper2be74392018-06-18 01:28:01 +0000384 CodeGenInstAlias(Record *R, CodeGenTarget &T);
Bob Wilsonb9b24222011-01-26 19:44:55 +0000385
David Greeneaf8ee2c2011-07-29 22:43:06 +0000386 bool tryAliasOpMatch(DagInit *Result, unsigned AliasOpNo,
Jakob Stoklund Olesend7b66962012-08-22 23:33:58 +0000387 Record *InstOpRec, bool hasSubOps, ArrayRef<SMLoc> Loc,
Bob Wilsonb9b24222011-01-26 19:44:55 +0000388 CodeGenTarget &T, ResultOperand &ResOp);
Jim Grosbach876ee072011-03-14 17:32:49 +0000389 };
Chris Lattner488c2012010-11-01 04:05:41 +0000390}
Chris Lattnerc860eca2004-08-01 05:04:00 +0000391
392#endif