Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 1 | //===-- llvm/MC/MCInstrDesc.h - Instruction Descriptors -*- C++ -*-===// |
| 2 | // |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 3 | // 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 |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This file defines the MCOperandInfo and MCInstrDesc classes, which |
| 10 | // are used to describe target instructions and their operands. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef LLVM_MC_MCINSTRDESC_H |
| 15 | #define LLVM_MC_MCINSTRDESC_H |
| 16 | |
| 17 | #include "llvm/MC/MCRegisterInfo.h" |
| 18 | #include "llvm/Support/DataTypes.h" |
| 19 | #include <string> |
| 20 | |
| 21 | namespace llvm { |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 22 | |
| 23 | class MCInst; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 24 | |
| 25 | //===----------------------------------------------------------------------===// |
| 26 | // Machine Operand Flags and Description |
| 27 | //===----------------------------------------------------------------------===// |
| 28 | |
| 29 | namespace MCOI { |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 30 | /// Operand constraints. These are encoded in 16 bits with one of the |
| 31 | /// low-order 3 bits specifying that a constraint is present and the |
| 32 | /// corresponding high-order hex digit specifying the constraint value. |
| 33 | /// This allows for a maximum of 3 constraints. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 34 | enum OperandConstraint { |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 35 | TIED_TO = 0, // Must be allocated the same register as specified value. |
| 36 | EARLY_CLOBBER // If present, operand is an early clobber register. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 37 | }; |
| 38 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 39 | // Define a macro to produce each constraint value. |
| 40 | #define MCOI_TIED_TO(op) \ |
| 41 | ((1 << MCOI::TIED_TO) | ((op) << (4 + MCOI::TIED_TO * 4))) |
| 42 | |
| 43 | #define MCOI_EARLY_CLOBBER \ |
| 44 | (1 << MCOI::EARLY_CLOBBER) |
| 45 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 46 | /// These are flags set on operands, but should be considered |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 47 | /// private, all access should go through the MCOperandInfo accessors. |
| 48 | /// See the accessors for a description of what these are. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 49 | enum OperandFlags { |
| 50 | LookupPtrRegClass = 0, |
| 51 | Predicate, |
| 52 | OptionalDef, |
| 53 | BranchTarget |
| 54 | }; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 55 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 56 | /// Operands are tagged with one of the values of this enum. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 57 | enum OperandType { |
| 58 | OPERAND_UNKNOWN = 0, |
| 59 | OPERAND_IMMEDIATE = 1, |
| 60 | OPERAND_REGISTER = 2, |
| 61 | OPERAND_MEMORY = 3, |
| 62 | OPERAND_PCREL = 4, |
| 63 | |
| 64 | OPERAND_FIRST_GENERIC = 6, |
| 65 | OPERAND_GENERIC_0 = 6, |
| 66 | OPERAND_GENERIC_1 = 7, |
| 67 | OPERAND_GENERIC_2 = 8, |
| 68 | OPERAND_GENERIC_3 = 9, |
| 69 | OPERAND_GENERIC_4 = 10, |
| 70 | OPERAND_GENERIC_5 = 11, |
| 71 | OPERAND_LAST_GENERIC = 11, |
| 72 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 73 | OPERAND_FIRST_GENERIC_IMM = 12, |
| 74 | OPERAND_GENERIC_IMM_0 = 12, |
| 75 | OPERAND_LAST_GENERIC_IMM = 12, |
| 76 | |
| 77 | OPERAND_FIRST_TARGET = 13, |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 78 | }; |
| 79 | |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 80 | } |
| 81 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 82 | /// This holds information about one operand of a machine instruction, |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 83 | /// indicating the register class for register operands, etc. |
| 84 | class MCOperandInfo { |
| 85 | public: |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 86 | /// This specifies the register class enumeration of the operand |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 87 | /// if the operand is a register. If isLookupPtrRegClass is set, then this is |
| 88 | /// an index that is passed to TargetRegisterInfo::getPointerRegClass(x) to |
| 89 | /// get a dynamic register class. |
| 90 | int16_t RegClass; |
| 91 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 92 | /// These are flags from the MCOI::OperandFlags enum. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 93 | uint8_t Flags; |
| 94 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 95 | /// Information about the type of the operand. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 96 | uint8_t OperandType; |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 97 | |
| 98 | /// Operand constraints (see OperandConstraint enum). |
| 99 | uint16_t Constraints; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 100 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 101 | /// Set if this operand is a pointer value and it requires a callback |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 102 | /// to look up its register class. |
| 103 | bool isLookupPtrRegClass() const { |
| 104 | return Flags & (1 << MCOI::LookupPtrRegClass); |
| 105 | } |
| 106 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 107 | /// Set if this is one of the operands that made up of the predicate |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 108 | /// operand that controls an isPredicable() instruction. |
| 109 | bool isPredicate() const { return Flags & (1 << MCOI::Predicate); } |
| 110 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 111 | /// Set if this operand is a optional def. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 112 | bool isOptionalDef() const { return Flags & (1 << MCOI::OptionalDef); } |
| 113 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 114 | /// Set if this operand is a branch target. |
| 115 | bool isBranchTarget() const { return Flags & (1 << MCOI::BranchTarget); } |
| 116 | |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 117 | bool isGenericType() const { |
| 118 | return OperandType >= MCOI::OPERAND_FIRST_GENERIC && |
| 119 | OperandType <= MCOI::OPERAND_LAST_GENERIC; |
| 120 | } |
| 121 | |
| 122 | unsigned getGenericTypeIndex() const { |
| 123 | assert(isGenericType() && "non-generic types don't have an index"); |
| 124 | return OperandType - MCOI::OPERAND_FIRST_GENERIC; |
| 125 | } |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 126 | |
| 127 | bool isGenericImm() const { |
| 128 | return OperandType >= MCOI::OPERAND_FIRST_GENERIC_IMM && |
| 129 | OperandType <= MCOI::OPERAND_LAST_GENERIC_IMM; |
| 130 | } |
| 131 | |
| 132 | unsigned getGenericImmIndex() const { |
| 133 | assert(isGenericImm() && "non-generic immediates don't have an index"); |
| 134 | return OperandType - MCOI::OPERAND_FIRST_GENERIC_IMM; |
| 135 | } |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 136 | }; |
| 137 | |
| 138 | //===----------------------------------------------------------------------===// |
| 139 | // Machine Instruction Flags and Description |
| 140 | //===----------------------------------------------------------------------===// |
| 141 | |
| 142 | namespace MCID { |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 143 | /// These should be considered private to the implementation of the |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 144 | /// MCInstrDesc class. Clients should use the predicate methods on MCInstrDesc, |
| 145 | /// not use these directly. These all correspond to bitfields in the |
| 146 | /// MCInstrDesc::Flags field. |
| 147 | enum Flag { |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 148 | PreISelOpcode = 0, |
| 149 | Variadic, |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 150 | HasOptionalDef, |
| 151 | Pseudo, |
| 152 | Return, |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 153 | EHScopeReturn, |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 154 | Call, |
| 155 | Barrier, |
| 156 | Terminator, |
| 157 | Branch, |
| 158 | IndirectBranch, |
| 159 | Compare, |
| 160 | MoveImm, |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 161 | MoveReg, |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 162 | Bitcast, |
| 163 | Select, |
| 164 | DelaySlot, |
| 165 | FoldableAsLoad, |
| 166 | MayLoad, |
| 167 | MayStore, |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame] | 168 | MayRaiseFPException, |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 169 | Predicable, |
| 170 | NotDuplicable, |
| 171 | UnmodeledSideEffects, |
| 172 | Commutable, |
| 173 | ConvertibleTo3Addr, |
| 174 | UsesCustomInserter, |
| 175 | HasPostISelHook, |
| 176 | Rematerializable, |
| 177 | CheapAsAMove, |
| 178 | ExtraSrcRegAllocReq, |
| 179 | ExtraDefRegAllocReq, |
| 180 | RegSequence, |
| 181 | ExtractSubreg, |
| 182 | InsertSubreg, |
| 183 | Convergent, |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 184 | Add, |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 185 | Trap, |
| 186 | VariadicOpsAreDefs, |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 187 | Authenticated, |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 188 | }; |
| 189 | } |
| 190 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 191 | /// Describe properties that are true of each instruction in the target |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 192 | /// description file. This captures information about side effects, register |
| 193 | /// use and many other things. There is one instance of this struct for each |
| 194 | /// target instruction class, and the MachineInstr class points to this struct |
| 195 | /// directly to describe itself. |
| 196 | class MCInstrDesc { |
| 197 | public: |
| 198 | unsigned short Opcode; // The opcode number |
| 199 | unsigned short NumOperands; // Num of args (may be more if variable_ops) |
| 200 | unsigned char NumDefs; // Num of args that are definitions |
| 201 | unsigned char Size; // Number of bytes in encoding. |
| 202 | unsigned short SchedClass; // enum identifying instr sched class |
| 203 | uint64_t Flags; // Flags identifying machine instr class |
| 204 | uint64_t TSFlags; // Target Specific Flag values |
| 205 | const MCPhysReg *ImplicitUses; // Registers implicitly read by this instr |
| 206 | const MCPhysReg *ImplicitDefs; // Registers implicitly defined by this instr |
| 207 | const MCOperandInfo *OpInfo; // 'NumOperands' entries about operands |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 208 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 209 | /// Returns the value of the specified operand constraint if |
| 210 | /// it is present. Returns -1 if it is not present. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 211 | int getOperandConstraint(unsigned OpNum, |
| 212 | MCOI::OperandConstraint Constraint) const { |
| 213 | if (OpNum < NumOperands && |
| 214 | (OpInfo[OpNum].Constraints & (1 << Constraint))) { |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 215 | unsigned ValuePos = 4 + Constraint * 4; |
| 216 | return (int)(OpInfo[OpNum].Constraints >> ValuePos) & 0x0f; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 217 | } |
| 218 | return -1; |
| 219 | } |
| 220 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 221 | /// Return the opcode number for this descriptor. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 222 | unsigned getOpcode() const { return Opcode; } |
| 223 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 224 | /// Return the number of declared MachineOperands for this |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 225 | /// MachineInstruction. Note that variadic (isVariadic() returns true) |
| 226 | /// instructions may have additional operands at the end of the list, and note |
| 227 | /// that the machine instruction may include implicit register def/uses as |
| 228 | /// well. |
| 229 | unsigned getNumOperands() const { return NumOperands; } |
| 230 | |
| 231 | using const_opInfo_iterator = const MCOperandInfo *; |
| 232 | |
| 233 | const_opInfo_iterator opInfo_begin() const { return OpInfo; } |
| 234 | const_opInfo_iterator opInfo_end() const { return OpInfo + NumOperands; } |
| 235 | |
| 236 | iterator_range<const_opInfo_iterator> operands() const { |
| 237 | return make_range(opInfo_begin(), opInfo_end()); |
| 238 | } |
| 239 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 240 | /// Return the number of MachineOperands that are register |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 241 | /// definitions. Register definitions always occur at the start of the |
| 242 | /// machine operand list. This is the number of "outs" in the .td file, |
| 243 | /// and does not include implicit defs. |
| 244 | unsigned getNumDefs() const { return NumDefs; } |
| 245 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 246 | /// Return flags of this instruction. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 247 | uint64_t getFlags() const { return Flags; } |
| 248 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 249 | /// \returns true if this instruction is emitted before instruction selection |
| 250 | /// and should be legalized/regbankselected/selected. |
| 251 | bool isPreISelOpcode() const { return Flags & (1ULL << MCID::PreISelOpcode); } |
| 252 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 253 | /// Return true if this instruction can have a variable number of |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 254 | /// operands. In this case, the variable operands will be after the normal |
| 255 | /// operands but before the implicit definitions and uses (if any are |
| 256 | /// present). |
| 257 | bool isVariadic() const { return Flags & (1ULL << MCID::Variadic); } |
| 258 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 259 | /// Set if this instruction has an optional definition, e.g. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 260 | /// ARM instructions which can set condition code if 's' bit is set. |
| 261 | bool hasOptionalDef() const { return Flags & (1ULL << MCID::HasOptionalDef); } |
| 262 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 263 | /// Return true if this is a pseudo instruction that doesn't |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 264 | /// correspond to a real machine instruction. |
| 265 | bool isPseudo() const { return Flags & (1ULL << MCID::Pseudo); } |
| 266 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 267 | /// Return true if the instruction is a return. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 268 | bool isReturn() const { return Flags & (1ULL << MCID::Return); } |
| 269 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 270 | /// Return true if the instruction is an add instruction. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 271 | bool isAdd() const { return Flags & (1ULL << MCID::Add); } |
| 272 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 273 | /// Return true if this instruction is a trap. |
| 274 | bool isTrap() const { return Flags & (1ULL << MCID::Trap); } |
| 275 | |
| 276 | /// Return true if the instruction is a register to register move. |
| 277 | bool isMoveReg() const { return Flags & (1ULL << MCID::MoveReg); } |
| 278 | |
| 279 | /// Return true if the instruction is a call. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 280 | bool isCall() const { return Flags & (1ULL << MCID::Call); } |
| 281 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 282 | /// Returns true if the specified instruction stops control flow |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 283 | /// from executing the instruction immediately following it. Examples include |
| 284 | /// unconditional branches and return instructions. |
| 285 | bool isBarrier() const { return Flags & (1ULL << MCID::Barrier); } |
| 286 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 287 | /// Returns true if this instruction part of the terminator for |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 288 | /// a basic block. Typically this is things like return and branch |
| 289 | /// instructions. |
| 290 | /// |
| 291 | /// Various passes use this to insert code into the bottom of a basic block, |
| 292 | /// but before control flow occurs. |
| 293 | bool isTerminator() const { return Flags & (1ULL << MCID::Terminator); } |
| 294 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 295 | /// Returns true if this is a conditional, unconditional, or |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 296 | /// indirect branch. Predicates below can be used to discriminate between |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 297 | /// these cases, and the TargetInstrInfo::analyzeBranch method can be used to |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 298 | /// get more information. |
| 299 | bool isBranch() const { return Flags & (1ULL << MCID::Branch); } |
| 300 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 301 | /// Return true if this is an indirect branch, such as a |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 302 | /// branch through a register. |
| 303 | bool isIndirectBranch() const { return Flags & (1ULL << MCID::IndirectBranch); } |
| 304 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 305 | /// Return true if this is a branch which may fall |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 306 | /// through to the next instruction or may transfer control flow to some other |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 307 | /// block. The TargetInstrInfo::analyzeBranch method can be used to get more |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 308 | /// information about this branch. |
| 309 | bool isConditionalBranch() const { |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 310 | return isBranch() && !isBarrier() && !isIndirectBranch(); |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 311 | } |
| 312 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 313 | /// Return true if this is a branch which always |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 314 | /// transfers control flow to some other block. The |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 315 | /// TargetInstrInfo::analyzeBranch method can be used to get more information |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 316 | /// about this branch. |
| 317 | bool isUnconditionalBranch() const { |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 318 | return isBranch() && isBarrier() && !isIndirectBranch(); |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 319 | } |
| 320 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 321 | /// Return true if this is a branch or an instruction which directly |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 322 | /// writes to the program counter. Considered 'may' affect rather than |
| 323 | /// 'does' affect as things like predication are not taken into account. |
| 324 | bool mayAffectControlFlow(const MCInst &MI, const MCRegisterInfo &RI) const; |
| 325 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 326 | /// Return true if this instruction has a predicate operand |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 327 | /// that controls execution. It may be set to 'always', or may be set to other |
| 328 | /// values. There are various methods in TargetInstrInfo that can be used to |
| 329 | /// control and modify the predicate in this instruction. |
| 330 | bool isPredicable() const { return Flags & (1ULL << MCID::Predicable); } |
| 331 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 332 | /// Return true if this instruction is a comparison. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 333 | bool isCompare() const { return Flags & (1ULL << MCID::Compare); } |
| 334 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 335 | /// Return true if this instruction is a move immediate |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 336 | /// (including conditional moves) instruction. |
| 337 | bool isMoveImmediate() const { return Flags & (1ULL << MCID::MoveImm); } |
| 338 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 339 | /// Return true if this instruction is a bitcast instruction. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 340 | bool isBitcast() const { return Flags & (1ULL << MCID::Bitcast); } |
| 341 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 342 | /// Return true if this is a select instruction. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 343 | bool isSelect() const { return Flags & (1ULL << MCID::Select); } |
| 344 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 345 | /// Return true if this instruction cannot be safely |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 346 | /// duplicated. For example, if the instruction has a unique labels attached |
| 347 | /// to it, duplicating it would cause multiple definition errors. |
| 348 | bool isNotDuplicable() const { return Flags & (1ULL << MCID::NotDuplicable); } |
| 349 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 350 | /// Returns true if the specified instruction has a delay slot which |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 351 | /// must be filled by the code generator. |
| 352 | bool hasDelaySlot() const { return Flags & (1ULL << MCID::DelaySlot); } |
| 353 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 354 | /// Return true for instructions that can be folded as memory operands |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 355 | /// in other instructions. The most common use for this is instructions that |
| 356 | /// are simple loads from memory that don't modify the loaded value in any |
| 357 | /// way, but it can also be used for instructions that can be expressed as |
| 358 | /// constant-pool loads, such as V_SETALLONES on x86, to allow them to be |
| 359 | /// folded when it is beneficial. This should only be set on instructions |
| 360 | /// that return a value in their only virtual register definition. |
| 361 | bool canFoldAsLoad() const { return Flags & (1ULL << MCID::FoldableAsLoad); } |
| 362 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 363 | /// Return true if this instruction behaves |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 364 | /// the same way as the generic REG_SEQUENCE instructions. |
| 365 | /// E.g., on ARM, |
| 366 | /// dX VMOVDRR rY, rZ |
| 367 | /// is equivalent to |
| 368 | /// dX = REG_SEQUENCE rY, ssub_0, rZ, ssub_1. |
| 369 | /// |
| 370 | /// Note that for the optimizers to be able to take advantage of |
| 371 | /// this property, TargetInstrInfo::getRegSequenceLikeInputs has to be |
| 372 | /// override accordingly. |
| 373 | bool isRegSequenceLike() const { return Flags & (1ULL << MCID::RegSequence); } |
| 374 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 375 | /// Return true if this instruction behaves |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 376 | /// the same way as the generic EXTRACT_SUBREG instructions. |
| 377 | /// E.g., on ARM, |
| 378 | /// rX, rY VMOVRRD dZ |
| 379 | /// is equivalent to two EXTRACT_SUBREG: |
| 380 | /// rX = EXTRACT_SUBREG dZ, ssub_0 |
| 381 | /// rY = EXTRACT_SUBREG dZ, ssub_1 |
| 382 | /// |
| 383 | /// Note that for the optimizers to be able to take advantage of |
| 384 | /// this property, TargetInstrInfo::getExtractSubregLikeInputs has to be |
| 385 | /// override accordingly. |
| 386 | bool isExtractSubregLike() const { |
| 387 | return Flags & (1ULL << MCID::ExtractSubreg); |
| 388 | } |
| 389 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 390 | /// Return true if this instruction behaves |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 391 | /// the same way as the generic INSERT_SUBREG instructions. |
| 392 | /// E.g., on ARM, |
| 393 | /// dX = VSETLNi32 dY, rZ, Imm |
| 394 | /// is equivalent to a INSERT_SUBREG: |
| 395 | /// dX = INSERT_SUBREG dY, rZ, translateImmToSubIdx(Imm) |
| 396 | /// |
| 397 | /// Note that for the optimizers to be able to take advantage of |
| 398 | /// this property, TargetInstrInfo::getInsertSubregLikeInputs has to be |
| 399 | /// override accordingly. |
| 400 | bool isInsertSubregLike() const { return Flags & (1ULL << MCID::InsertSubreg); } |
| 401 | |
| 402 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 403 | /// Return true if this instruction is convergent. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 404 | /// |
| 405 | /// Convergent instructions may not be made control-dependent on any |
| 406 | /// additional values. |
| 407 | bool isConvergent() const { return Flags & (1ULL << MCID::Convergent); } |
| 408 | |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 409 | /// Return true if variadic operands of this instruction are definitions. |
| 410 | bool variadicOpsAreDefs() const { |
| 411 | return Flags & (1ULL << MCID::VariadicOpsAreDefs); |
| 412 | } |
| 413 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 414 | /// Return true if this instruction authenticates a pointer (e.g. LDRAx/BRAx |
| 415 | /// from ARMv8.3, which perform loads/branches with authentication). |
| 416 | /// |
| 417 | /// An authenticated instruction may fail in an ABI-defined manner when |
| 418 | /// operating on an invalid signed pointer. |
| 419 | bool isAuthenticated() const { |
| 420 | return Flags & (1ULL << MCID::Authenticated); |
| 421 | } |
| 422 | |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 423 | //===--------------------------------------------------------------------===// |
| 424 | // Side Effect Analysis |
| 425 | //===--------------------------------------------------------------------===// |
| 426 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 427 | /// Return true if this instruction could possibly read memory. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 428 | /// Instructions with this flag set are not necessarily simple load |
| 429 | /// instructions, they may load a value and modify it, for example. |
| 430 | bool mayLoad() const { return Flags & (1ULL << MCID::MayLoad); } |
| 431 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 432 | /// Return true if this instruction could possibly modify memory. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 433 | /// Instructions with this flag set are not necessarily simple store |
| 434 | /// instructions, they may store a modified value based on their operands, or |
| 435 | /// may not actually modify anything, for example. |
| 436 | bool mayStore() const { return Flags & (1ULL << MCID::MayStore); } |
| 437 | |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame] | 438 | /// Return true if this instruction may raise a floating-point exception. |
| 439 | bool mayRaiseFPException() const { |
| 440 | return Flags & (1ULL << MCID::MayRaiseFPException); |
| 441 | } |
| 442 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 443 | /// Return true if this instruction has side |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 444 | /// effects that are not modeled by other flags. This does not return true |
| 445 | /// for instructions whose effects are captured by: |
| 446 | /// |
| 447 | /// 1. Their operand list and implicit definition/use list. Register use/def |
| 448 | /// info is explicit for instructions. |
| 449 | /// 2. Memory accesses. Use mayLoad/mayStore. |
| 450 | /// 3. Calling, branching, returning: use isCall/isReturn/isBranch. |
| 451 | /// |
| 452 | /// Examples of side effects would be modifying 'invisible' machine state like |
| 453 | /// a control register, flushing a cache, modifying a register invisible to |
| 454 | /// LLVM, etc. |
| 455 | bool hasUnmodeledSideEffects() const { |
| 456 | return Flags & (1ULL << MCID::UnmodeledSideEffects); |
| 457 | } |
| 458 | |
| 459 | //===--------------------------------------------------------------------===// |
| 460 | // Flags that indicate whether an instruction can be modified by a method. |
| 461 | //===--------------------------------------------------------------------===// |
| 462 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 463 | /// Return true if this may be a 2- or 3-address instruction (of the |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 464 | /// form "X = op Y, Z, ..."), which produces the same result if Y and Z are |
| 465 | /// exchanged. If this flag is set, then the |
| 466 | /// TargetInstrInfo::commuteInstruction method may be used to hack on the |
| 467 | /// instruction. |
| 468 | /// |
| 469 | /// Note that this flag may be set on instructions that are only commutable |
| 470 | /// sometimes. In these cases, the call to commuteInstruction will fail. |
| 471 | /// Also note that some instructions require non-trivial modification to |
| 472 | /// commute them. |
| 473 | bool isCommutable() const { return Flags & (1ULL << MCID::Commutable); } |
| 474 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 475 | /// Return true if this is a 2-address instruction which can be changed |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 476 | /// into a 3-address instruction if needed. Doing this transformation can be |
| 477 | /// profitable in the register allocator, because it means that the |
| 478 | /// instruction can use a 2-address form if possible, but degrade into a less |
| 479 | /// efficient form if the source and dest register cannot be assigned to the |
| 480 | /// same register. For example, this allows the x86 backend to turn a "shl |
| 481 | /// reg, 3" instruction into an LEA instruction, which is the same speed as |
| 482 | /// the shift but has bigger code size. |
| 483 | /// |
| 484 | /// If this returns true, then the target must implement the |
| 485 | /// TargetInstrInfo::convertToThreeAddress method for this instruction, which |
| 486 | /// is allowed to fail if the transformation isn't valid for this specific |
| 487 | /// instruction (e.g. shl reg, 4 on x86). |
| 488 | /// |
| 489 | bool isConvertibleTo3Addr() const { |
| 490 | return Flags & (1ULL << MCID::ConvertibleTo3Addr); |
| 491 | } |
| 492 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 493 | /// Return true if this instruction requires custom insertion support |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 494 | /// when the DAG scheduler is inserting it into a machine basic block. If |
| 495 | /// this is true for the instruction, it basically means that it is a pseudo |
| 496 | /// instruction used at SelectionDAG time that is expanded out into magic code |
| 497 | /// by the target when MachineInstrs are formed. |
| 498 | /// |
| 499 | /// If this is true, the TargetLoweringInfo::InsertAtEndOfBasicBlock method |
| 500 | /// is used to insert this into the MachineBasicBlock. |
| 501 | bool usesCustomInsertionHook() const { |
| 502 | return Flags & (1ULL << MCID::UsesCustomInserter); |
| 503 | } |
| 504 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 505 | /// Return true if this instruction requires *adjustment* after |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 506 | /// instruction selection by calling a target hook. For example, this can be |
| 507 | /// used to fill in ARM 's' optional operand depending on whether the |
| 508 | /// conditional flag register is used. |
| 509 | bool hasPostISelHook() const { return Flags & (1ULL << MCID::HasPostISelHook); } |
| 510 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 511 | /// Returns true if this instruction is a candidate for remat. This |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 512 | /// flag is only used in TargetInstrInfo method isTriviallyRematerializable. |
| 513 | /// |
| 514 | /// If this flag is set, the isReallyTriviallyReMaterializable() |
| 515 | /// or isReallyTriviallyReMaterializableGeneric methods are called to verify |
| 516 | /// the instruction is really rematable. |
| 517 | bool isRematerializable() const { |
| 518 | return Flags & (1ULL << MCID::Rematerializable); |
| 519 | } |
| 520 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 521 | /// Returns true if this instruction has the same cost (or less) than a |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 522 | /// move instruction. This is useful during certain types of optimizations |
| 523 | /// (e.g., remat during two-address conversion or machine licm) where we would |
| 524 | /// like to remat or hoist the instruction, but not if it costs more than |
| 525 | /// moving the instruction into the appropriate register. Note, we are not |
| 526 | /// marking copies from and to the same register class with this flag. |
| 527 | /// |
| 528 | /// This method could be called by interface TargetInstrInfo::isAsCheapAsAMove |
| 529 | /// for different subtargets. |
| 530 | bool isAsCheapAsAMove() const { return Flags & (1ULL << MCID::CheapAsAMove); } |
| 531 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 532 | /// Returns true if this instruction source operands have special |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 533 | /// register allocation requirements that are not captured by the operand |
| 534 | /// register classes. e.g. ARM::STRD's two source registers must be an even / |
| 535 | /// odd pair, ARM::STM registers have to be in ascending order. Post-register |
| 536 | /// allocation passes should not attempt to change allocations for sources of |
| 537 | /// instructions with this flag. |
| 538 | bool hasExtraSrcRegAllocReq() const { |
| 539 | return Flags & (1ULL << MCID::ExtraSrcRegAllocReq); |
| 540 | } |
| 541 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 542 | /// Returns true if this instruction def operands have special register |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 543 | /// allocation requirements that are not captured by the operand register |
| 544 | /// classes. e.g. ARM::LDRD's two def registers must be an even / odd pair, |
| 545 | /// ARM::LDM registers have to be in ascending order. Post-register |
| 546 | /// allocation passes should not attempt to change allocations for definitions |
| 547 | /// of instructions with this flag. |
| 548 | bool hasExtraDefRegAllocReq() const { |
| 549 | return Flags & (1ULL << MCID::ExtraDefRegAllocReq); |
| 550 | } |
| 551 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 552 | /// Return a list of registers that are potentially read by any |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 553 | /// instance of this machine instruction. For example, on X86, the "adc" |
| 554 | /// instruction adds two register operands and adds the carry bit in from the |
| 555 | /// flags register. In this case, the instruction is marked as implicitly |
| 556 | /// reading the flags. Likewise, the variable shift instruction on X86 is |
| 557 | /// marked as implicitly reading the 'CL' register, which it always does. |
| 558 | /// |
| 559 | /// This method returns null if the instruction has no implicit uses. |
| 560 | const MCPhysReg *getImplicitUses() const { return ImplicitUses; } |
| 561 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 562 | /// Return the number of implicit uses this instruction has. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 563 | unsigned getNumImplicitUses() const { |
| 564 | if (!ImplicitUses) |
| 565 | return 0; |
| 566 | unsigned i = 0; |
| 567 | for (; ImplicitUses[i]; ++i) /*empty*/ |
| 568 | ; |
| 569 | return i; |
| 570 | } |
| 571 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 572 | /// Return a list of registers that are potentially written by any |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 573 | /// instance of this machine instruction. For example, on X86, many |
| 574 | /// instructions implicitly set the flags register. In this case, they are |
| 575 | /// marked as setting the FLAGS. Likewise, many instructions always deposit |
| 576 | /// their result in a physical register. For example, the X86 divide |
| 577 | /// instruction always deposits the quotient and remainder in the EAX/EDX |
| 578 | /// registers. For that instruction, this will return a list containing the |
| 579 | /// EAX/EDX/EFLAGS registers. |
| 580 | /// |
| 581 | /// This method returns null if the instruction has no implicit defs. |
| 582 | const MCPhysReg *getImplicitDefs() const { return ImplicitDefs; } |
| 583 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 584 | /// Return the number of implicit defs this instruct has. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 585 | unsigned getNumImplicitDefs() const { |
| 586 | if (!ImplicitDefs) |
| 587 | return 0; |
| 588 | unsigned i = 0; |
| 589 | for (; ImplicitDefs[i]; ++i) /*empty*/ |
| 590 | ; |
| 591 | return i; |
| 592 | } |
| 593 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 594 | /// Return true if this instruction implicitly |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 595 | /// uses the specified physical register. |
| 596 | bool hasImplicitUseOfPhysReg(unsigned Reg) const { |
| 597 | if (const MCPhysReg *ImpUses = ImplicitUses) |
| 598 | for (; *ImpUses; ++ImpUses) |
| 599 | if (*ImpUses == Reg) |
| 600 | return true; |
| 601 | return false; |
| 602 | } |
| 603 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 604 | /// Return true if this instruction implicitly |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 605 | /// defines the specified physical register. |
| 606 | bool hasImplicitDefOfPhysReg(unsigned Reg, |
| 607 | const MCRegisterInfo *MRI = nullptr) const; |
| 608 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 609 | /// Return the scheduling class for this instruction. The |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 610 | /// scheduling class is an index into the InstrItineraryData table. This |
| 611 | /// returns zero if there is no known scheduling information for the |
| 612 | /// instruction. |
| 613 | unsigned getSchedClass() const { return SchedClass; } |
| 614 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 615 | /// Return the number of bytes in the encoding of this instruction, |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 616 | /// or zero if the encoding size cannot be known from the opcode. |
| 617 | unsigned getSize() const { return Size; } |
| 618 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 619 | /// Find the index of the first operand in the |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 620 | /// operand list that is used to represent the predicate. It returns -1 if |
| 621 | /// none is found. |
| 622 | int findFirstPredOperandIdx() const { |
| 623 | if (isPredicable()) { |
| 624 | for (unsigned i = 0, e = getNumOperands(); i != e; ++i) |
| 625 | if (OpInfo[i].isPredicate()) |
| 626 | return i; |
| 627 | } |
| 628 | return -1; |
| 629 | } |
| 630 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 631 | /// Return true if this instruction defines the specified physical |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 632 | /// register, either explicitly or implicitly. |
| 633 | bool hasDefOfPhysReg(const MCInst &MI, unsigned Reg, |
| 634 | const MCRegisterInfo &RI) const; |
| 635 | }; |
| 636 | |
| 637 | } // end namespace llvm |
| 638 | |
| 639 | #endif |