Chris Lattner | c860eca | 2004-08-01 05:04:00 +0000 | [diff] [blame] | 1 | //===- CodeGenInstruction.h - Instruction Class Wrapper ---------*- C++ -*-===// |
Misha Brukman | 650ba8e | 2005-04-22 00:00:37 +0000 | [diff] [blame] | 2 | // |
Chris Lattner | c860eca | 2004-08-01 05:04:00 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 8adcd9f | 2007-12-29 20:37:13 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Misha Brukman | 650ba8e | 2005-04-22 00:00:37 +0000 | [diff] [blame] | 7 | // |
Chris Lattner | c860eca | 2004-08-01 05:04:00 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines a wrapper class for the 'Instruction' TableGen class. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 14 | #ifndef LLVM_UTILS_TABLEGEN_CODEGENINSTRUCTION_H |
| 15 | #define LLVM_UTILS_TABLEGEN_CODEGENINSTRUCTION_H |
Chris Lattner | c860eca | 2004-08-01 05:04:00 +0000 | [diff] [blame] | 16 | |
Chris Lattner | 8ffd129 | 2010-11-06 06:39:47 +0000 | [diff] [blame] | 17 | #include "llvm/ADT/StringRef.h" |
David Blaikie | 13e77db | 2018-03-23 23:58:25 +0000 | [diff] [blame] | 18 | #include "llvm/Support/MachineValueType.h" |
Craig Topper | f7ce724 | 2015-06-08 01:35:40 +0000 | [diff] [blame] | 19 | #include "llvm/Support/SMLoc.h" |
Chris Lattner | c860eca | 2004-08-01 05:04:00 +0000 | [diff] [blame] | 20 | #include <string> |
Chris Lattner | c860eca | 2004-08-01 05:04:00 +0000 | [diff] [blame] | 21 | #include <utility> |
Chandler Carruth | 91d19d8 | 2012-12-04 10:37:14 +0000 | [diff] [blame] | 22 | #include <vector> |
Chris Lattner | c860eca | 2004-08-01 05:04:00 +0000 | [diff] [blame] | 23 | |
| 24 | namespace llvm { |
Mehdi Amini | b550cb1 | 2016-04-18 09:17:29 +0000 | [diff] [blame] | 25 | template <typename T> class ArrayRef; |
Chris Lattner | c860eca | 2004-08-01 05:04:00 +0000 | [diff] [blame] | 26 | class Record; |
Chris Lattner | 6bc0304 | 2005-11-19 07:05:57 +0000 | [diff] [blame] | 27 | class DagInit; |
Chris Lattner | 7bc5d9b | 2010-03-27 20:09:24 +0000 | [diff] [blame] | 28 | class CodeGenTarget; |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 29 | |
Chris Lattner | d8adec7 | 2010-11-01 04:03:32 +0000 | [diff] [blame] | 30 | class CGIOperandList { |
Jeff Cohen | 7d6f3db | 2006-11-05 19:31:28 +0000 | [diff] [blame] | 31 | public: |
Chris Lattner | a9dfb1b | 2010-02-10 01:45:28 +0000 | [diff] [blame] | 32 | class ConstraintInfo { |
| 33 | enum { None, EarlyClobber, Tied } Kind; |
| 34 | unsigned OtherTiedOperand; |
| 35 | public: |
| 36 | ConstraintInfo() : Kind(None) {} |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 37 | |
Chris Lattner | a9dfb1b | 2010-02-10 01:45:28 +0000 | [diff] [blame] | 38 | static ConstraintInfo getEarlyClobber() { |
| 39 | ConstraintInfo I; |
| 40 | I.Kind = EarlyClobber; |
Chris Lattner | 0d7b5e5 | 2010-02-10 21:22:51 +0000 | [diff] [blame] | 41 | I.OtherTiedOperand = 0; |
Chris Lattner | a9dfb1b | 2010-02-10 01:45:28 +0000 | [diff] [blame] | 42 | return I; |
| 43 | } |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 44 | |
Chris Lattner | a9dfb1b | 2010-02-10 01:45:28 +0000 | [diff] [blame] | 45 | static ConstraintInfo getTied(unsigned Op) { |
| 46 | ConstraintInfo I; |
| 47 | I.Kind = Tied; |
| 48 | I.OtherTiedOperand = Op; |
| 49 | return I; |
| 50 | } |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 51 | |
Chris Lattner | a9dfb1b | 2010-02-10 01:45:28 +0000 | [diff] [blame] | 52 | bool isNone() const { return Kind == None; } |
| 53 | bool isEarlyClobber() const { return Kind == EarlyClobber; } |
| 54 | bool isTied() const { return Kind == Tied; } |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 55 | |
Chris Lattner | a9dfb1b | 2010-02-10 01:45:28 +0000 | [diff] [blame] | 56 | unsigned getTiedOperand() const { |
| 57 | assert(isTied()); |
| 58 | return OtherTiedOperand; |
| 59 | } |
Simon Tatham | 3486055 | 2018-11-28 11:43:49 +0000 | [diff] [blame] | 60 | |
| 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 | } |
| 68 | bool operator!=(const ConstraintInfo &RHS) const { return *this != RHS; } |
Chris Lattner | a9dfb1b | 2010-02-10 01:45:28 +0000 | [diff] [blame] | 69 | }; |
Jim Grosbach | 2f0be8f | 2010-10-08 18:09:59 +0000 | [diff] [blame] | 70 | |
Chris Lattner | 3bc477a | 2004-08-11 02:22:39 +0000 | [diff] [blame] | 71 | /// OperandInfo - The information we keep track of for each operand in the |
| 72 | /// operand list for a tablegen instruction. |
Chris Lattner | 5572682 | 2004-08-01 07:42:39 +0000 | [diff] [blame] | 73 | struct OperandInfo { |
Chris Lattner | 3bc477a | 2004-08-11 02:22:39 +0000 | [diff] [blame] | 74 | /// Rec - The definition this operand is declared as. |
Chris Lattner | 220d001 | 2005-08-19 16:57:28 +0000 | [diff] [blame] | 75 | /// |
Chris Lattner | 5572682 | 2004-08-01 07:42:39 +0000 | [diff] [blame] | 76 | Record *Rec; |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 77 | |
Chris Lattner | 3bc477a | 2004-08-11 02:22:39 +0000 | [diff] [blame] | 78 | /// Name - If this operand was assigned a symbolic name, this is it, |
| 79 | /// otherwise, it's empty. |
Chris Lattner | 5572682 | 2004-08-01 07:42:39 +0000 | [diff] [blame] | 80 | std::string Name; |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 81 | |
Chris Lattner | 3bc477a | 2004-08-11 02:22:39 +0000 | [diff] [blame] | 82 | /// PrinterMethodName - The method used to print operands of this type in |
| 83 | /// the asmprinter. |
| 84 | std::string PrinterMethodName; |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 85 | |
Jim Grosbach | 51a12eb | 2010-10-12 22:21:57 +0000 | [diff] [blame] | 86 | /// EncoderMethodName - The method used to get the machine operand value |
| 87 | /// for binary encoding. "getMachineOpValue" by default. |
| 88 | std::string EncoderMethodName; |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 89 | |
Benjamin Kramer | c8dc46b | 2011-07-14 21:47:18 +0000 | [diff] [blame] | 90 | /// OperandType - A value from MCOI::OperandType representing the type of |
| 91 | /// the operand. |
| 92 | std::string OperandType; |
| 93 | |
Chris Lattner | 3bc477a | 2004-08-11 02:22:39 +0000 | [diff] [blame] | 94 | /// MIOperandNo - Currently (this is meant to be phased out), some logical |
| 95 | /// operands correspond to multiple MachineInstr operands. In the X86 |
| 96 | /// target for example, one address operand is represented as 4 |
| 97 | /// MachineOperands. Because of this, the operand number in the |
| 98 | /// OperandList may not match the MachineInstr operand num. Until it |
| 99 | /// does, this contains the MI operand index of this operand. |
| 100 | unsigned MIOperandNo; |
Chris Lattner | 17727ba | 2005-08-18 23:38:41 +0000 | [diff] [blame] | 101 | unsigned MINumOperands; // The number of operands. |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 102 | |
Chris Lattner | 78a403f | 2006-11-15 23:23:02 +0000 | [diff] [blame] | 103 | /// DoNotEncode - Bools are set to true in this vector for each operand in |
| 104 | /// the DisableEncoding list. These should not be emitted by the code |
| 105 | /// emitter. |
| 106 | std::vector<bool> DoNotEncode; |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 107 | |
Nate Begeman | e479ccb | 2005-11-30 23:58:18 +0000 | [diff] [blame] | 108 | /// MIOperandInfo - Default MI operand type. Note an operand may be made |
| 109 | /// up of multiple MI operands. |
David Greene | af8ee2c | 2011-07-29 22:43:06 +0000 | [diff] [blame] | 110 | DagInit *MIOperandInfo; |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 111 | |
Chris Lattner | c94f214 | 2006-11-15 02:38:17 +0000 | [diff] [blame] | 112 | /// Constraint info for this operand. This operand can have pieces, so we |
| 113 | /// track constraint info for each. |
Chris Lattner | a9dfb1b | 2010-02-10 01:45:28 +0000 | [diff] [blame] | 114 | std::vector<ConstraintInfo> Constraints; |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 115 | |
Jim Grosbach | 2f0be8f | 2010-10-08 18:09:59 +0000 | [diff] [blame] | 116 | OperandInfo(Record *R, const std::string &N, const std::string &PMN, |
Benjamin Kramer | c8dc46b | 2011-07-14 21:47:18 +0000 | [diff] [blame] | 117 | const std::string &EMN, const std::string &OT, unsigned MION, |
David Greene | af8ee2c | 2011-07-29 22:43:06 +0000 | [diff] [blame] | 118 | unsigned MINO, DagInit *MIOI) |
Chris Lattner | d8adec7 | 2010-11-01 04:03:32 +0000 | [diff] [blame] | 119 | : Rec(R), Name(N), PrinterMethodName(PMN), EncoderMethodName(EMN), |
Benjamin Kramer | c8dc46b | 2011-07-14 21:47:18 +0000 | [diff] [blame] | 120 | OperandType(OT), MIOperandNo(MION), MINumOperands(MINO), |
| 121 | MIOperandInfo(MIOI) {} |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 122 | |
| 123 | |
Chris Lattner | e032dbf | 2010-11-02 22:55:03 +0000 | [diff] [blame] | 124 | /// getTiedOperand - If this operand is tied to another one, return the |
| 125 | /// other operand number. Otherwise, return -1. |
| 126 | int getTiedRegister() const { |
| 127 | for (unsigned j = 0, e = Constraints.size(); j != e; ++j) { |
| 128 | const CGIOperandList::ConstraintInfo &CI = Constraints[j]; |
| 129 | if (CI.isTied()) return CI.getTiedOperand(); |
| 130 | } |
| 131 | return -1; |
| 132 | } |
Chris Lattner | 5572682 | 2004-08-01 07:42:39 +0000 | [diff] [blame] | 133 | }; |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 134 | |
Chris Lattner | d8adec7 | 2010-11-01 04:03:32 +0000 | [diff] [blame] | 135 | CGIOperandList(Record *D); |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 136 | |
Chris Lattner | d8adec7 | 2010-11-01 04:03:32 +0000 | [diff] [blame] | 137 | Record *TheDef; // The actual record containing this OperandList. |
Misha Brukman | 650ba8e | 2005-04-22 00:00:37 +0000 | [diff] [blame] | 138 | |
Chris Lattner | 5f418ea | 2010-03-18 20:50:52 +0000 | [diff] [blame] | 139 | /// NumDefs - Number of def operands declared, this is the number of |
| 140 | /// elements in the instruction's (outs) list. |
Evan Cheng | 94b5a80 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 141 | /// |
| 142 | unsigned NumDefs; |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 143 | |
Chris Lattner | c860eca | 2004-08-01 05:04:00 +0000 | [diff] [blame] | 144 | /// OperandList - The list of declared operands, along with their declared |
| 145 | /// type (which is a record). |
Chris Lattner | 5572682 | 2004-08-01 07:42:39 +0000 | [diff] [blame] | 146 | std::vector<OperandInfo> OperandList; |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 147 | |
Chris Lattner | d8adec7 | 2010-11-01 04:03:32 +0000 | [diff] [blame] | 148 | // Information gleaned from the operand list. |
| 149 | bool isPredicable; |
| 150 | bool hasOptionalDef; |
| 151 | bool isVariadic; |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 152 | |
Chris Lattner | d8adec7 | 2010-11-01 04:03:32 +0000 | [diff] [blame] | 153 | // Provide transparent accessors to the operand list. |
Chris Lattner | 9080391 | 2011-04-17 22:24:13 +0000 | [diff] [blame] | 154 | bool empty() const { return OperandList.empty(); } |
Chris Lattner | d8adec7 | 2010-11-01 04:03:32 +0000 | [diff] [blame] | 155 | unsigned size() const { return OperandList.size(); } |
| 156 | const OperandInfo &operator[](unsigned i) const { return OperandList[i]; } |
| 157 | OperandInfo &operator[](unsigned i) { return OperandList[i]; } |
| 158 | OperandInfo &back() { return OperandList.back(); } |
| 159 | const OperandInfo &back() const { return OperandList.back(); } |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 160 | |
Jim Grosbach | 0e28a35 | 2014-04-18 02:08:58 +0000 | [diff] [blame] | 161 | typedef std::vector<OperandInfo>::iterator iterator; |
| 162 | typedef std::vector<OperandInfo>::const_iterator const_iterator; |
| 163 | iterator begin() { return OperandList.begin(); } |
| 164 | const_iterator begin() const { return OperandList.begin(); } |
| 165 | iterator end() { return OperandList.end(); } |
| 166 | const_iterator end() const { return OperandList.end(); } |
| 167 | |
Chris Lattner | d8adec7 | 2010-11-01 04:03:32 +0000 | [diff] [blame] | 168 | /// getOperandNamed - Return the index of the operand with the specified |
| 169 | /// non-empty name. If the instruction does not have an operand with the |
Joerg Sonnenberger | 635debe | 2012-10-25 20:33:17 +0000 | [diff] [blame] | 170 | /// specified name, abort. |
Chris Lattner | d8adec7 | 2010-11-01 04:03:32 +0000 | [diff] [blame] | 171 | unsigned getOperandNamed(StringRef Name) const; |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 172 | |
Chris Lattner | d8adec7 | 2010-11-01 04:03:32 +0000 | [diff] [blame] | 173 | /// hasOperandNamed - Query whether the instruction has an operand of the |
| 174 | /// given name. If so, return true and set OpIdx to the index of the |
| 175 | /// operand. Otherwise, return false. |
| 176 | bool hasOperandNamed(StringRef Name, unsigned &OpIdx) const; |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 177 | |
Chris Lattner | d8adec7 | 2010-11-01 04:03:32 +0000 | [diff] [blame] | 178 | /// ParseOperandName - Parse an operand name like "$foo" or "$foo.bar", |
| 179 | /// where $foo is a whole operand and $foo.bar refers to a suboperand. |
Joerg Sonnenberger | 635debe | 2012-10-25 20:33:17 +0000 | [diff] [blame] | 180 | /// This aborts if the name is invalid. If AllowWholeOp is true, references |
| 181 | /// to operands with suboperands are allowed, otherwise not. |
Chris Lattner | d8adec7 | 2010-11-01 04:03:32 +0000 | [diff] [blame] | 182 | std::pair<unsigned,unsigned> ParseOperandName(const std::string &Op, |
| 183 | bool AllowWholeOp = true); |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 184 | |
Chris Lattner | d8adec7 | 2010-11-01 04:03:32 +0000 | [diff] [blame] | 185 | /// getFlattenedOperandNumber - Flatten a operand/suboperand pair into a |
| 186 | /// flat machineinstr operand #. |
| 187 | unsigned getFlattenedOperandNumber(std::pair<unsigned,unsigned> Op) const { |
| 188 | return OperandList[Op.first].MIOperandNo + Op.second; |
| 189 | } |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 190 | |
Chris Lattner | d8adec7 | 2010-11-01 04:03:32 +0000 | [diff] [blame] | 191 | /// getSubOperandNumber - Unflatten a operand number into an |
| 192 | /// operand/suboperand pair. |
| 193 | std::pair<unsigned,unsigned> getSubOperandNumber(unsigned Op) const { |
| 194 | for (unsigned i = 0; ; ++i) { |
| 195 | assert(i < OperandList.size() && "Invalid flat operand #"); |
| 196 | if (OperandList[i].MIOperandNo+OperandList[i].MINumOperands > Op) |
| 197 | return std::make_pair(i, Op-OperandList[i].MIOperandNo); |
| 198 | } |
| 199 | } |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 200 | |
| 201 | |
Chris Lattner | d8adec7 | 2010-11-01 04:03:32 +0000 | [diff] [blame] | 202 | /// isFlatOperandNotEmitted - Return true if the specified flat operand # |
| 203 | /// should not be emitted with the code emitter. |
| 204 | bool isFlatOperandNotEmitted(unsigned FlatOpNo) const { |
| 205 | std::pair<unsigned,unsigned> Op = getSubOperandNumber(FlatOpNo); |
| 206 | if (OperandList[Op.first].DoNotEncode.size() > Op.second) |
| 207 | return OperandList[Op.first].DoNotEncode[Op.second]; |
| 208 | return false; |
| 209 | } |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 210 | |
Chris Lattner | d8adec7 | 2010-11-01 04:03:32 +0000 | [diff] [blame] | 211 | void ProcessDisableEncoding(std::string Value); |
| 212 | }; |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 213 | |
Chris Lattner | d8adec7 | 2010-11-01 04:03:32 +0000 | [diff] [blame] | 214 | |
| 215 | class CodeGenInstruction { |
| 216 | public: |
| 217 | Record *TheDef; // The actual record defining this instruction. |
Craig Topper | 86a9aee | 2017-07-07 06:22:35 +0000 | [diff] [blame] | 218 | StringRef Namespace; // The namespace the instruction is in. |
Chris Lattner | d8adec7 | 2010-11-01 04:03:32 +0000 | [diff] [blame] | 219 | |
| 220 | /// AsmString - The format string used to emit a .s file for the |
| 221 | /// instruction. |
| 222 | std::string AsmString; |
| 223 | |
| 224 | /// Operands - This is information about the (ins) and (outs) list specified |
| 225 | /// to the instruction. |
| 226 | CGIOperandList Operands; |
Chris Lattner | c860eca | 2004-08-01 05:04:00 +0000 | [diff] [blame] | 227 | |
Chris Lattner | 2130a3e | 2010-03-18 21:42:03 +0000 | [diff] [blame] | 228 | /// ImplicitDefs/ImplicitUses - These are lists of registers that are |
| 229 | /// implicitly defined and used by the instruction. |
| 230 | std::vector<Record*> ImplicitDefs, ImplicitUses; |
| 231 | |
Chris Lattner | c860eca | 2004-08-01 05:04:00 +0000 | [diff] [blame] | 232 | // Various boolean values we track for the instruction. |
Craig Topper | bc9486b | 2014-02-05 09:10:40 +0000 | [diff] [blame] | 233 | bool isReturn : 1; |
Heejin Ahn | ed5e06b | 2018-08-21 19:44:11 +0000 | [diff] [blame] | 234 | bool isEHScopeReturn : 1; |
Craig Topper | bc9486b | 2014-02-05 09:10:40 +0000 | [diff] [blame] | 235 | bool isBranch : 1; |
| 236 | bool isIndirectBranch : 1; |
| 237 | bool isCompare : 1; |
| 238 | bool isMoveImm : 1; |
Petar Jovanovic | c051000 | 2018-05-23 15:28:28 +0000 | [diff] [blame] | 239 | bool isMoveReg : 1; |
Craig Topper | bc9486b | 2014-02-05 09:10:40 +0000 | [diff] [blame] | 240 | bool isBitcast : 1; |
| 241 | bool isSelect : 1; |
| 242 | bool isBarrier : 1; |
| 243 | bool isCall : 1; |
Sjoerd Meijer | 724023a | 2016-09-14 08:20:03 +0000 | [diff] [blame] | 244 | bool isAdd : 1; |
Joel Galenson | 06e7e57 | 2018-07-13 15:19:33 +0000 | [diff] [blame] | 245 | bool isTrap : 1; |
Craig Topper | bc9486b | 2014-02-05 09:10:40 +0000 | [diff] [blame] | 246 | bool canFoldAsLoad : 1; |
| 247 | bool mayLoad : 1; |
| 248 | bool mayLoad_Unset : 1; |
| 249 | bool mayStore : 1; |
| 250 | bool mayStore_Unset : 1; |
| 251 | bool isPredicable : 1; |
| 252 | bool isConvertibleToThreeAddress : 1; |
| 253 | bool isCommutable : 1; |
| 254 | bool isTerminator : 1; |
| 255 | bool isReMaterializable : 1; |
| 256 | bool hasDelaySlot : 1; |
| 257 | bool usesCustomInserter : 1; |
| 258 | bool hasPostISelHook : 1; |
| 259 | bool hasCtrlDep : 1; |
| 260 | bool isNotDuplicable : 1; |
| 261 | bool hasSideEffects : 1; |
| 262 | bool hasSideEffects_Unset : 1; |
Craig Topper | bc9486b | 2014-02-05 09:10:40 +0000 | [diff] [blame] | 263 | bool isAsCheapAsAMove : 1; |
| 264 | bool hasExtraSrcRegAllocReq : 1; |
| 265 | bool hasExtraDefRegAllocReq : 1; |
| 266 | bool isCodeGenOnly : 1; |
| 267 | bool isPseudo : 1; |
Quentin Colombet | d533cdf | 2014-08-11 22:17:14 +0000 | [diff] [blame] | 268 | bool isRegSequence : 1; |
Quentin Colombet | 7e75cba | 2014-08-20 21:51:26 +0000 | [diff] [blame] | 269 | bool isExtractSubreg : 1; |
Quentin Colombet | 7e3da66 | 2014-08-20 23:49:36 +0000 | [diff] [blame] | 270 | bool isInsertSubreg : 1; |
Owen Anderson | abaa523 | 2015-05-28 18:33:39 +0000 | [diff] [blame] | 271 | bool isConvergent : 1; |
Matthias Braun | 8e0a734 | 2016-03-01 20:03:11 +0000 | [diff] [blame] | 272 | bool hasNoSchedulingInfo : 1; |
Simon Dardis | 13de555 | 2018-05-22 14:36:58 +0000 | [diff] [blame] | 273 | bool FastISelShouldIgnore : 1; |
Ulrich Weigand | c48aefb | 2018-07-13 13:18:00 +0000 | [diff] [blame] | 274 | bool hasChain : 1; |
| 275 | bool hasChain_Inferred : 1; |
Jim Grosbach | 2f0be8f | 2010-10-08 18:09:59 +0000 | [diff] [blame] | 276 | |
Joey Gouly | 0e76fa7 | 2013-09-12 10:28:05 +0000 | [diff] [blame] | 277 | std::string DeprecatedReason; |
| 278 | bool HasComplexDeprecationPredicate; |
| 279 | |
Jakob Stoklund Olesen | 94ed4d4 | 2012-08-24 00:31:16 +0000 | [diff] [blame] | 280 | /// Are there any undefined flags? |
| 281 | bool hasUndefFlags() const { |
| 282 | return mayLoad_Unset || mayStore_Unset || hasSideEffects_Unset; |
| 283 | } |
| 284 | |
| 285 | // The record used to infer instruction flags, or NULL if no flag values |
| 286 | // have been inferred. |
| 287 | Record *InferredFrom; |
Chris Lattner | c860eca | 2004-08-01 05:04:00 +0000 | [diff] [blame] | 288 | |
Chris Lattner | a397716 | 2010-11-01 02:15:23 +0000 | [diff] [blame] | 289 | CodeGenInstruction(Record *R); |
Chris Lattner | 5572682 | 2004-08-01 07:42:39 +0000 | [diff] [blame] | 290 | |
Chris Lattner | 7bc5d9b | 2010-03-27 20:09:24 +0000 | [diff] [blame] | 291 | /// HasOneImplicitDefWithKnownVT - If the instruction has at least one |
| 292 | /// implicit def and it has a known VT, return the VT, otherwise return |
| 293 | /// MVT::Other. |
Jim Grosbach | 2f0be8f | 2010-10-08 18:09:59 +0000 | [diff] [blame] | 294 | MVT::SimpleValueType |
Chris Lattner | 7bc5d9b | 2010-03-27 20:09:24 +0000 | [diff] [blame] | 295 | HasOneImplicitDefWithKnownVT(const CodeGenTarget &TargetInfo) const; |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 296 | |
| 297 | |
Chris Lattner | 25d9c7f | 2010-11-01 01:07:14 +0000 | [diff] [blame] | 298 | /// FlattenAsmStringVariants - Flatten the specified AsmString to only |
| 299 | /// include text from the specified variant, returning the new string. |
| 300 | static std::string FlattenAsmStringVariants(StringRef AsmString, |
| 301 | unsigned Variant); |
Daniel Sanders | c54aa9c | 2017-11-18 00:16:44 +0000 | [diff] [blame] | 302 | |
| 303 | // Is the specified operand in a generic instruction implicitly a pointer. |
| 304 | // This can be used on intructions that use typeN or ptypeN to identify |
| 305 | // operands that should be considered as pointers even though SelectionDAG |
| 306 | // didn't make a distinction between integer and pointers. |
| 307 | bool isOperandAPointer(unsigned i) const; |
Chris Lattner | c860eca | 2004-08-01 05:04:00 +0000 | [diff] [blame] | 308 | }; |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 309 | |
| 310 | |
Chris Lattner | 488c201 | 2010-11-01 04:05:41 +0000 | [diff] [blame] | 311 | /// CodeGenInstAlias - This represents an InstAlias definition. |
| 312 | class CodeGenInstAlias { |
| 313 | public: |
| 314 | Record *TheDef; // The actual record defining this InstAlias. |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 315 | |
Chris Lattner | 488c201 | 2010-11-01 04:05:41 +0000 | [diff] [blame] | 316 | /// AsmString - The format string used to emit a .s file for the |
| 317 | /// instruction. |
| 318 | std::string AsmString; |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 319 | |
Chris Lattner | dd3b09c | 2010-11-01 05:34:34 +0000 | [diff] [blame] | 320 | /// Result - The result instruction. |
David Greene | af8ee2c | 2011-07-29 22:43:06 +0000 | [diff] [blame] | 321 | DagInit *Result; |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 322 | |
Chris Lattner | 8ffd129 | 2010-11-06 06:39:47 +0000 | [diff] [blame] | 323 | /// ResultInst - The instruction generated by the alias (decoded from |
| 324 | /// Result). |
| 325 | CodeGenInstruction *ResultInst; |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 326 | |
| 327 | |
Chris Lattner | 8ffd129 | 2010-11-06 06:39:47 +0000 | [diff] [blame] | 328 | struct ResultOperand { |
Chris Lattner | b6f8e82 | 2010-11-06 19:25:43 +0000 | [diff] [blame] | 329 | private: |
Owen Anderson | da6bd3e | 2012-06-08 00:25:03 +0000 | [diff] [blame] | 330 | std::string Name; |
Chris Lattner | 8ffd129 | 2010-11-06 06:39:47 +0000 | [diff] [blame] | 331 | Record *R; |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 332 | |
Chris Lattner | b6f8e82 | 2010-11-06 19:25:43 +0000 | [diff] [blame] | 333 | int64_t Imm; |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 334 | public: |
Chris Lattner | b6f8e82 | 2010-11-06 19:25:43 +0000 | [diff] [blame] | 335 | enum { |
| 336 | K_Record, |
Chris Lattner | 4869d34 | 2010-11-06 19:57:21 +0000 | [diff] [blame] | 337 | K_Imm, |
| 338 | K_Reg |
Chris Lattner | b6f8e82 | 2010-11-06 19:25:43 +0000 | [diff] [blame] | 339 | } Kind; |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 340 | |
Benjamin Kramer | 82de7d3 | 2016-05-27 14:27:24 +0000 | [diff] [blame] | 341 | ResultOperand(std::string N, Record *r) |
| 342 | : Name(std::move(N)), R(r), Kind(K_Record) {} |
Chris Lattner | b6f8e82 | 2010-11-06 19:25:43 +0000 | [diff] [blame] | 343 | ResultOperand(int64_t I) : Imm(I), Kind(K_Imm) {} |
Chris Lattner | 4869d34 | 2010-11-06 19:57:21 +0000 | [diff] [blame] | 344 | ResultOperand(Record *r) : R(r), Kind(K_Reg) {} |
Chris Lattner | b6f8e82 | 2010-11-06 19:25:43 +0000 | [diff] [blame] | 345 | |
| 346 | bool isRecord() const { return Kind == K_Record; } |
| 347 | bool isImm() const { return Kind == K_Imm; } |
Chris Lattner | 4869d34 | 2010-11-06 19:57:21 +0000 | [diff] [blame] | 348 | bool isReg() const { return Kind == K_Reg; } |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 349 | |
Chris Lattner | b6f8e82 | 2010-11-06 19:25:43 +0000 | [diff] [blame] | 350 | StringRef getName() const { assert(isRecord()); return Name; } |
| 351 | Record *getRecord() const { assert(isRecord()); return R; } |
| 352 | int64_t getImm() const { assert(isImm()); return Imm; } |
Chris Lattner | 4869d34 | 2010-11-06 19:57:21 +0000 | [diff] [blame] | 353 | Record *getRegister() const { assert(isReg()); return R; } |
Tim Northover | 60091cf | 2014-05-15 13:36:01 +0000 | [diff] [blame] | 354 | |
| 355 | unsigned getMINumOperands() const; |
Chris Lattner | 8ffd129 | 2010-11-06 06:39:47 +0000 | [diff] [blame] | 356 | }; |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 357 | |
Chris Lattner | 8ffd129 | 2010-11-06 06:39:47 +0000 | [diff] [blame] | 358 | /// ResultOperands - The decoded operands for the result instruction. |
| 359 | std::vector<ResultOperand> ResultOperands; |
Bob Wilson | f3f2835 | 2011-01-20 18:38:02 +0000 | [diff] [blame] | 360 | |
Bob Wilson | b9b2422 | 2011-01-26 19:44:55 +0000 | [diff] [blame] | 361 | /// ResultInstOperandIndex - For each operand, this vector holds a pair of |
| 362 | /// indices to identify the corresponding operand in the result |
| 363 | /// instruction. The first index specifies the operand and the second |
| 364 | /// index specifies the suboperand. If there are no suboperands or if all |
| 365 | /// of them are matched by the operand, the second value should be -1. |
| 366 | std::vector<std::pair<unsigned, int> > ResultInstOperandIndex; |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 367 | |
Craig Topper | 2be7439 | 2018-06-18 01:28:01 +0000 | [diff] [blame] | 368 | CodeGenInstAlias(Record *R, CodeGenTarget &T); |
Bob Wilson | b9b2422 | 2011-01-26 19:44:55 +0000 | [diff] [blame] | 369 | |
David Greene | af8ee2c | 2011-07-29 22:43:06 +0000 | [diff] [blame] | 370 | bool tryAliasOpMatch(DagInit *Result, unsigned AliasOpNo, |
Jakob Stoklund Olesen | d7b6696 | 2012-08-22 23:33:58 +0000 | [diff] [blame] | 371 | Record *InstOpRec, bool hasSubOps, ArrayRef<SMLoc> Loc, |
Bob Wilson | b9b2422 | 2011-01-26 19:44:55 +0000 | [diff] [blame] | 372 | CodeGenTarget &T, ResultOperand &ResOp); |
Jim Grosbach | 876ee07 | 2011-03-14 17:32:49 +0000 | [diff] [blame] | 373 | }; |
Chris Lattner | 488c201 | 2010-11-01 04:05:41 +0000 | [diff] [blame] | 374 | } |
Chris Lattner | c860eca | 2004-08-01 05:04:00 +0000 | [diff] [blame] | 375 | |
| 376 | #endif |