blob: 2cb28425df7aa432cac914d8f8371b903f05cfe7 [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 {
32 enum { None, EarlyClobber, Tied } Kind;
33 unsigned OtherTiedOperand;
34 public:
35 ConstraintInfo() : Kind(None) {}
Jim Grosbach876ee072011-03-14 17:32:49 +000036
Chris Lattnera9dfb1b2010-02-10 01:45:28 +000037 static ConstraintInfo getEarlyClobber() {
38 ConstraintInfo I;
39 I.Kind = EarlyClobber;
Chris Lattner0d7b5e52010-02-10 21:22:51 +000040 I.OtherTiedOperand = 0;
Chris Lattnera9dfb1b2010-02-10 01:45:28 +000041 return I;
42 }
Jim Grosbach876ee072011-03-14 17:32:49 +000043
Chris Lattnera9dfb1b2010-02-10 01:45:28 +000044 static ConstraintInfo getTied(unsigned Op) {
45 ConstraintInfo I;
46 I.Kind = Tied;
47 I.OtherTiedOperand = Op;
48 return I;
49 }
Jim Grosbach876ee072011-03-14 17:32:49 +000050
Chris Lattnera9dfb1b2010-02-10 01:45:28 +000051 bool isNone() const { return Kind == None; }
52 bool isEarlyClobber() const { return Kind == EarlyClobber; }
53 bool isTied() const { return Kind == Tied; }
Jim Grosbach876ee072011-03-14 17:32:49 +000054
Chris Lattnera9dfb1b2010-02-10 01:45:28 +000055 unsigned getTiedOperand() const {
56 assert(isTied());
57 return OtherTiedOperand;
58 }
Simon Tatham34860552018-11-28 11:43:49 +000059
60 bool operator==(const ConstraintInfo &RHS) const {
61 if (Kind != RHS.Kind)
62 return false;
63 if (Kind == Tied && OtherTiedOperand != RHS.OtherTiedOperand)
64 return false;
65 return true;
66 }
Haojian Wuf838e902018-11-28 12:32:53 +000067 bool operator!=(const ConstraintInfo &RHS) const {
68 return !(*this == RHS);
69 }
Chris Lattnera9dfb1b2010-02-10 01:45:28 +000070 };
Jim Grosbach2f0be8f2010-10-08 18:09:59 +000071
Chris Lattner3bc477a2004-08-11 02:22:39 +000072 /// OperandInfo - The information we keep track of for each operand in the
73 /// operand list for a tablegen instruction.
Chris Lattner55726822004-08-01 07:42:39 +000074 struct OperandInfo {
Chris Lattner3bc477a2004-08-11 02:22:39 +000075 /// Rec - The definition this operand is declared as.
Chris Lattner220d0012005-08-19 16:57:28 +000076 ///
Chris Lattner55726822004-08-01 07:42:39 +000077 Record *Rec;
Jim Grosbach876ee072011-03-14 17:32:49 +000078
Chris Lattner3bc477a2004-08-11 02:22:39 +000079 /// Name - If this operand was assigned a symbolic name, this is it,
80 /// otherwise, it's empty.
Chris Lattner55726822004-08-01 07:42:39 +000081 std::string Name;
Jim Grosbach876ee072011-03-14 17:32:49 +000082
Chris Lattner3bc477a2004-08-11 02:22:39 +000083 /// PrinterMethodName - The method used to print operands of this type in
84 /// the asmprinter.
85 std::string PrinterMethodName;
Jim Grosbach876ee072011-03-14 17:32:49 +000086
Jim Grosbach51a12eb2010-10-12 22:21:57 +000087 /// EncoderMethodName - The method used to get the machine operand value
88 /// for binary encoding. "getMachineOpValue" by default.
89 std::string EncoderMethodName;
Jim Grosbach876ee072011-03-14 17:32:49 +000090
Benjamin Kramerc8dc46b2011-07-14 21:47:18 +000091 /// OperandType - A value from MCOI::OperandType representing the type of
92 /// the operand.
93 std::string OperandType;
94
Chris Lattner3bc477a2004-08-11 02:22:39 +000095 /// MIOperandNo - Currently (this is meant to be phased out), some logical
96 /// operands correspond to multiple MachineInstr operands. In the X86
97 /// target for example, one address operand is represented as 4
98 /// MachineOperands. Because of this, the operand number in the
99 /// OperandList may not match the MachineInstr operand num. Until it
100 /// does, this contains the MI operand index of this operand.
101 unsigned MIOperandNo;
Chris Lattner17727ba2005-08-18 23:38:41 +0000102 unsigned MINumOperands; // The number of operands.
Jim Grosbach876ee072011-03-14 17:32:49 +0000103
Chris Lattner78a403f2006-11-15 23:23:02 +0000104 /// DoNotEncode - Bools are set to true in this vector for each operand in
105 /// the DisableEncoding list. These should not be emitted by the code
106 /// emitter.
107 std::vector<bool> DoNotEncode;
Jim Grosbach876ee072011-03-14 17:32:49 +0000108
Nate Begemane479ccb2005-11-30 23:58:18 +0000109 /// MIOperandInfo - Default MI operand type. Note an operand may be made
110 /// up of multiple MI operands.
David Greeneaf8ee2c2011-07-29 22:43:06 +0000111 DagInit *MIOperandInfo;
Jim Grosbach876ee072011-03-14 17:32:49 +0000112
Chris Lattnerc94f2142006-11-15 02:38:17 +0000113 /// Constraint info for this operand. This operand can have pieces, so we
114 /// track constraint info for each.
Chris Lattnera9dfb1b2010-02-10 01:45:28 +0000115 std::vector<ConstraintInfo> Constraints;
Jim Grosbach876ee072011-03-14 17:32:49 +0000116
Jim Grosbach2f0be8f2010-10-08 18:09:59 +0000117 OperandInfo(Record *R, const std::string &N, const std::string &PMN,
Benjamin Kramerc8dc46b2011-07-14 21:47:18 +0000118 const std::string &EMN, const std::string &OT, unsigned MION,
David Greeneaf8ee2c2011-07-29 22:43:06 +0000119 unsigned MINO, DagInit *MIOI)
Chris Lattnerd8adec72010-11-01 04:03:32 +0000120 : Rec(R), Name(N), PrinterMethodName(PMN), EncoderMethodName(EMN),
Benjamin Kramerc8dc46b2011-07-14 21:47:18 +0000121 OperandType(OT), MIOperandNo(MION), MINumOperands(MINO),
122 MIOperandInfo(MIOI) {}
Jim Grosbach876ee072011-03-14 17:32:49 +0000123
124
Chris Lattnere032dbf2010-11-02 22:55:03 +0000125 /// getTiedOperand - If this operand is tied to another one, return the
126 /// other operand number. Otherwise, return -1.
127 int getTiedRegister() const {
128 for (unsigned j = 0, e = Constraints.size(); j != e; ++j) {
129 const CGIOperandList::ConstraintInfo &CI = Constraints[j];
130 if (CI.isTied()) return CI.getTiedOperand();
131 }
132 return -1;
133 }
Chris Lattner55726822004-08-01 07:42:39 +0000134 };
Jim Grosbach876ee072011-03-14 17:32:49 +0000135
Chris Lattnerd8adec72010-11-01 04:03:32 +0000136 CGIOperandList(Record *D);
Jim Grosbach876ee072011-03-14 17:32:49 +0000137
Chris Lattnerd8adec72010-11-01 04:03:32 +0000138 Record *TheDef; // The actual record containing this OperandList.
Misha Brukman650ba8e2005-04-22 00:00:37 +0000139
Chris Lattner5f418ea2010-03-18 20:50:52 +0000140 /// NumDefs - Number of def operands declared, this is the number of
141 /// elements in the instruction's (outs) list.
Evan Cheng94b5a802007-07-19 01:14:50 +0000142 ///
143 unsigned NumDefs;
Jim Grosbach876ee072011-03-14 17:32:49 +0000144
Chris Lattnerc860eca2004-08-01 05:04:00 +0000145 /// OperandList - The list of declared operands, along with their declared
146 /// type (which is a record).
Chris Lattner55726822004-08-01 07:42:39 +0000147 std::vector<OperandInfo> OperandList;
Jim Grosbach876ee072011-03-14 17:32:49 +0000148
Chris Lattnerd8adec72010-11-01 04:03:32 +0000149 // Information gleaned from the operand list.
150 bool isPredicable;
151 bool hasOptionalDef;
152 bool isVariadic;
Jim Grosbach876ee072011-03-14 17:32:49 +0000153
Chris Lattnerd8adec72010-11-01 04:03:32 +0000154 // Provide transparent accessors to the operand list.
Chris Lattner90803912011-04-17 22:24:13 +0000155 bool empty() const { return OperandList.empty(); }
Chris Lattnerd8adec72010-11-01 04:03:32 +0000156 unsigned size() const { return OperandList.size(); }
157 const OperandInfo &operator[](unsigned i) const { return OperandList[i]; }
158 OperandInfo &operator[](unsigned i) { return OperandList[i]; }
159 OperandInfo &back() { return OperandList.back(); }
160 const OperandInfo &back() const { return OperandList.back(); }
Jim Grosbach876ee072011-03-14 17:32:49 +0000161
Jim Grosbach0e28a352014-04-18 02:08:58 +0000162 typedef std::vector<OperandInfo>::iterator iterator;
163 typedef std::vector<OperandInfo>::const_iterator const_iterator;
164 iterator begin() { return OperandList.begin(); }
165 const_iterator begin() const { return OperandList.begin(); }
166 iterator end() { return OperandList.end(); }
167 const_iterator end() const { return OperandList.end(); }
168
Chris Lattnerd8adec72010-11-01 04:03:32 +0000169 /// getOperandNamed - Return the index of the operand with the specified
170 /// non-empty name. If the instruction does not have an operand with the
Joerg Sonnenberger635debe2012-10-25 20:33:17 +0000171 /// specified name, abort.
Chris Lattnerd8adec72010-11-01 04:03:32 +0000172 unsigned getOperandNamed(StringRef Name) const;
Jim Grosbach876ee072011-03-14 17:32:49 +0000173
Chris Lattnerd8adec72010-11-01 04:03:32 +0000174 /// hasOperandNamed - Query whether the instruction has an operand of the
175 /// given name. If so, return true and set OpIdx to the index of the
176 /// operand. Otherwise, return false.
177 bool hasOperandNamed(StringRef Name, unsigned &OpIdx) const;
Jim Grosbach876ee072011-03-14 17:32:49 +0000178
Chris Lattnerd8adec72010-11-01 04:03:32 +0000179 /// ParseOperandName - Parse an operand name like "$foo" or "$foo.bar",
180 /// where $foo is a whole operand and $foo.bar refers to a suboperand.
Joerg Sonnenberger635debe2012-10-25 20:33:17 +0000181 /// This aborts if the name is invalid. If AllowWholeOp is true, references
182 /// to operands with suboperands are allowed, otherwise not.
Chris Lattnerd8adec72010-11-01 04:03:32 +0000183 std::pair<unsigned,unsigned> ParseOperandName(const std::string &Op,
184 bool AllowWholeOp = true);
Jim Grosbach876ee072011-03-14 17:32:49 +0000185
Chris Lattnerd8adec72010-11-01 04:03:32 +0000186 /// getFlattenedOperandNumber - Flatten a operand/suboperand pair into a
187 /// flat machineinstr operand #.
188 unsigned getFlattenedOperandNumber(std::pair<unsigned,unsigned> Op) const {
189 return OperandList[Op.first].MIOperandNo + Op.second;
190 }
Jim Grosbach876ee072011-03-14 17:32:49 +0000191
Chris Lattnerd8adec72010-11-01 04:03:32 +0000192 /// getSubOperandNumber - Unflatten a operand number into an
193 /// operand/suboperand pair.
194 std::pair<unsigned,unsigned> getSubOperandNumber(unsigned Op) const {
195 for (unsigned i = 0; ; ++i) {
196 assert(i < OperandList.size() && "Invalid flat operand #");
197 if (OperandList[i].MIOperandNo+OperandList[i].MINumOperands > Op)
198 return std::make_pair(i, Op-OperandList[i].MIOperandNo);
199 }
200 }
Jim Grosbach876ee072011-03-14 17:32:49 +0000201
202
Chris Lattnerd8adec72010-11-01 04:03:32 +0000203 /// isFlatOperandNotEmitted - Return true if the specified flat operand #
204 /// should not be emitted with the code emitter.
205 bool isFlatOperandNotEmitted(unsigned FlatOpNo) const {
206 std::pair<unsigned,unsigned> Op = getSubOperandNumber(FlatOpNo);
207 if (OperandList[Op.first].DoNotEncode.size() > Op.second)
208 return OperandList[Op.first].DoNotEncode[Op.second];
209 return false;
210 }
Jim Grosbach876ee072011-03-14 17:32:49 +0000211
Chris Lattnerd8adec72010-11-01 04:03:32 +0000212 void ProcessDisableEncoding(std::string Value);
213 };
Jim Grosbach876ee072011-03-14 17:32:49 +0000214
Chris Lattnerd8adec72010-11-01 04:03:32 +0000215
216 class CodeGenInstruction {
217 public:
218 Record *TheDef; // The actual record defining this instruction.
Craig Topper86a9aee2017-07-07 06:22:35 +0000219 StringRef Namespace; // The namespace the instruction is in.
Chris Lattnerd8adec72010-11-01 04:03:32 +0000220
221 /// AsmString - The format string used to emit a .s file for the
222 /// instruction.
223 std::string AsmString;
224
225 /// Operands - This is information about the (ins) and (outs) list specified
226 /// to the instruction.
227 CGIOperandList Operands;
Chris Lattnerc860eca2004-08-01 05:04:00 +0000228
Chris Lattner2130a3e2010-03-18 21:42:03 +0000229 /// ImplicitDefs/ImplicitUses - These are lists of registers that are
230 /// implicitly defined and used by the instruction.
231 std::vector<Record*> ImplicitDefs, ImplicitUses;
232
Chris Lattnerc860eca2004-08-01 05:04:00 +0000233 // Various boolean values we track for the instruction.
Matt Arsenault27269052019-10-07 18:43:29 +0000234 bool isPreISelOpcode : 1;
Craig Topperbc9486b2014-02-05 09:10:40 +0000235 bool isReturn : 1;
Heejin Ahned5e06b2018-08-21 19:44:11 +0000236 bool isEHScopeReturn : 1;
Craig Topperbc9486b2014-02-05 09:10:40 +0000237 bool isBranch : 1;
238 bool isIndirectBranch : 1;
239 bool isCompare : 1;
240 bool isMoveImm : 1;
Petar Jovanovicc0510002018-05-23 15:28:28 +0000241 bool isMoveReg : 1;
Craig Topperbc9486b2014-02-05 09:10:40 +0000242 bool isBitcast : 1;
243 bool isSelect : 1;
244 bool isBarrier : 1;
245 bool isCall : 1;
Sjoerd Meijer724023a2016-09-14 08:20:03 +0000246 bool isAdd : 1;
Joel Galenson06e7e572018-07-13 15:19:33 +0000247 bool isTrap : 1;
Craig Topperbc9486b2014-02-05 09:10:40 +0000248 bool canFoldAsLoad : 1;
249 bool mayLoad : 1;
250 bool mayLoad_Unset : 1;
251 bool mayStore : 1;
252 bool mayStore_Unset : 1;
Ulrich Weigand6c5d5ce2019-06-05 22:33:10 +0000253 bool mayRaiseFPException : 1;
Craig Topperbc9486b2014-02-05 09:10:40 +0000254 bool isPredicable : 1;
255 bool isConvertibleToThreeAddress : 1;
256 bool isCommutable : 1;
257 bool isTerminator : 1;
258 bool isReMaterializable : 1;
259 bool hasDelaySlot : 1;
260 bool usesCustomInserter : 1;
261 bool hasPostISelHook : 1;
262 bool hasCtrlDep : 1;
263 bool isNotDuplicable : 1;
264 bool hasSideEffects : 1;
265 bool hasSideEffects_Unset : 1;
Craig Topperbc9486b2014-02-05 09:10:40 +0000266 bool isAsCheapAsAMove : 1;
267 bool hasExtraSrcRegAllocReq : 1;
268 bool hasExtraDefRegAllocReq : 1;
269 bool isCodeGenOnly : 1;
270 bool isPseudo : 1;
Quentin Colombetd533cdf2014-08-11 22:17:14 +0000271 bool isRegSequence : 1;
Quentin Colombet7e75cba2014-08-20 21:51:26 +0000272 bool isExtractSubreg : 1;
Quentin Colombet7e3da662014-08-20 23:49:36 +0000273 bool isInsertSubreg : 1;
Owen Andersonabaa5232015-05-28 18:33:39 +0000274 bool isConvergent : 1;
Matthias Braun8e0a7342016-03-01 20:03:11 +0000275 bool hasNoSchedulingInfo : 1;
Simon Dardis13de5552018-05-22 14:36:58 +0000276 bool FastISelShouldIgnore : 1;
Ulrich Weigandc48aefb2018-07-13 13:18:00 +0000277 bool hasChain : 1;
278 bool hasChain_Inferred : 1;
Oliver Stannard4cf35b42018-12-03 10:32:42 +0000279 bool variadicOpsAreDefs : 1;
Jim Grosbach2f0be8f2010-10-08 18:09:59 +0000280
Joey Gouly0e76fa72013-09-12 10:28:05 +0000281 std::string DeprecatedReason;
282 bool HasComplexDeprecationPredicate;
283
Jakob Stoklund Olesen94ed4d42012-08-24 00:31:16 +0000284 /// Are there any undefined flags?
285 bool hasUndefFlags() const {
286 return mayLoad_Unset || mayStore_Unset || hasSideEffects_Unset;
287 }
288
289 // The record used to infer instruction flags, or NULL if no flag values
290 // have been inferred.
291 Record *InferredFrom;
Chris Lattnerc860eca2004-08-01 05:04:00 +0000292
Chris Lattnera3977162010-11-01 02:15:23 +0000293 CodeGenInstruction(Record *R);
Chris Lattner55726822004-08-01 07:42:39 +0000294
Chris Lattner7bc5d9b2010-03-27 20:09:24 +0000295 /// HasOneImplicitDefWithKnownVT - If the instruction has at least one
296 /// implicit def and it has a known VT, return the VT, otherwise return
297 /// MVT::Other.
Jim Grosbach2f0be8f2010-10-08 18:09:59 +0000298 MVT::SimpleValueType
Chris Lattner7bc5d9b2010-03-27 20:09:24 +0000299 HasOneImplicitDefWithKnownVT(const CodeGenTarget &TargetInfo) const;
Jim Grosbach876ee072011-03-14 17:32:49 +0000300
301
Chris Lattner25d9c7f2010-11-01 01:07:14 +0000302 /// FlattenAsmStringVariants - Flatten the specified AsmString to only
303 /// include text from the specified variant, returning the new string.
304 static std::string FlattenAsmStringVariants(StringRef AsmString,
305 unsigned Variant);
Daniel Sandersc54aa9c2017-11-18 00:16:44 +0000306
307 // Is the specified operand in a generic instruction implicitly a pointer.
308 // This can be used on intructions that use typeN or ptypeN to identify
309 // operands that should be considered as pointers even though SelectionDAG
310 // didn't make a distinction between integer and pointers.
311 bool isOperandAPointer(unsigned i) const;
Chris Lattnerc860eca2004-08-01 05:04:00 +0000312 };
Jim Grosbach876ee072011-03-14 17:32:49 +0000313
314
Chris Lattner488c2012010-11-01 04:05:41 +0000315 /// CodeGenInstAlias - This represents an InstAlias definition.
316 class CodeGenInstAlias {
317 public:
318 Record *TheDef; // The actual record defining this InstAlias.
Jim Grosbach876ee072011-03-14 17:32:49 +0000319
Chris Lattner488c2012010-11-01 04:05:41 +0000320 /// AsmString - The format string used to emit a .s file for the
321 /// instruction.
322 std::string AsmString;
Jim Grosbach876ee072011-03-14 17:32:49 +0000323
Chris Lattnerdd3b09c2010-11-01 05:34:34 +0000324 /// Result - The result instruction.
David Greeneaf8ee2c2011-07-29 22:43:06 +0000325 DagInit *Result;
Jim Grosbach876ee072011-03-14 17:32:49 +0000326
Chris Lattner8ffd1292010-11-06 06:39:47 +0000327 /// ResultInst - The instruction generated by the alias (decoded from
328 /// Result).
329 CodeGenInstruction *ResultInst;
Jim Grosbach876ee072011-03-14 17:32:49 +0000330
331
Chris Lattner8ffd1292010-11-06 06:39:47 +0000332 struct ResultOperand {
Chris Lattnerb6f8e822010-11-06 19:25:43 +0000333 private:
Owen Andersonda6bd3e2012-06-08 00:25:03 +0000334 std::string Name;
Chris Lattner8ffd1292010-11-06 06:39:47 +0000335 Record *R;
Jim Grosbach876ee072011-03-14 17:32:49 +0000336
Chris Lattnerb6f8e822010-11-06 19:25:43 +0000337 int64_t Imm;
Jim Grosbach876ee072011-03-14 17:32:49 +0000338 public:
Chris Lattnerb6f8e822010-11-06 19:25:43 +0000339 enum {
340 K_Record,
Chris Lattner4869d342010-11-06 19:57:21 +0000341 K_Imm,
342 K_Reg
Chris Lattnerb6f8e822010-11-06 19:25:43 +0000343 } Kind;
Jim Grosbach876ee072011-03-14 17:32:49 +0000344
Benjamin Kramer82de7d32016-05-27 14:27:24 +0000345 ResultOperand(std::string N, Record *r)
346 : Name(std::move(N)), R(r), Kind(K_Record) {}
Chris Lattnerb6f8e822010-11-06 19:25:43 +0000347 ResultOperand(int64_t I) : Imm(I), Kind(K_Imm) {}
Chris Lattner4869d342010-11-06 19:57:21 +0000348 ResultOperand(Record *r) : R(r), Kind(K_Reg) {}
Chris Lattnerb6f8e822010-11-06 19:25:43 +0000349
350 bool isRecord() const { return Kind == K_Record; }
351 bool isImm() const { return Kind == K_Imm; }
Chris Lattner4869d342010-11-06 19:57:21 +0000352 bool isReg() const { return Kind == K_Reg; }
Jim Grosbach876ee072011-03-14 17:32:49 +0000353
Chris Lattnerb6f8e822010-11-06 19:25:43 +0000354 StringRef getName() const { assert(isRecord()); return Name; }
355 Record *getRecord() const { assert(isRecord()); return R; }
356 int64_t getImm() const { assert(isImm()); return Imm; }
Chris Lattner4869d342010-11-06 19:57:21 +0000357 Record *getRegister() const { assert(isReg()); return R; }
Tim Northover60091cf2014-05-15 13:36:01 +0000358
359 unsigned getMINumOperands() const;
Chris Lattner8ffd1292010-11-06 06:39:47 +0000360 };
Jim Grosbach876ee072011-03-14 17:32:49 +0000361
Chris Lattner8ffd1292010-11-06 06:39:47 +0000362 /// ResultOperands - The decoded operands for the result instruction.
363 std::vector<ResultOperand> ResultOperands;
Bob Wilsonf3f28352011-01-20 18:38:02 +0000364
Bob Wilsonb9b24222011-01-26 19:44:55 +0000365 /// ResultInstOperandIndex - For each operand, this vector holds a pair of
366 /// indices to identify the corresponding operand in the result
367 /// instruction. The first index specifies the operand and the second
368 /// index specifies the suboperand. If there are no suboperands or if all
369 /// of them are matched by the operand, the second value should be -1.
370 std::vector<std::pair<unsigned, int> > ResultInstOperandIndex;
Jim Grosbach876ee072011-03-14 17:32:49 +0000371
Craig Topper2be74392018-06-18 01:28:01 +0000372 CodeGenInstAlias(Record *R, CodeGenTarget &T);
Bob Wilsonb9b24222011-01-26 19:44:55 +0000373
David Greeneaf8ee2c2011-07-29 22:43:06 +0000374 bool tryAliasOpMatch(DagInit *Result, unsigned AliasOpNo,
Jakob Stoklund Olesend7b66962012-08-22 23:33:58 +0000375 Record *InstOpRec, bool hasSubOps, ArrayRef<SMLoc> Loc,
Bob Wilsonb9b24222011-01-26 19:44:55 +0000376 CodeGenTarget &T, ResultOperand &ResOp);
Jim Grosbach876ee072011-03-14 17:32:49 +0000377 };
Chris Lattner488c2012010-11-01 04:05:41 +0000378}
Chris Lattnerc860eca2004-08-01 05:04:00 +0000379
380#endif