|
|
|||
File indexing completed on 2026-05-10 08:44:14
0001 //===-- llvm/MC/MCInstrDesc.h - Instruction Descriptors -*- C++ -*-===// 0002 // 0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 0004 // See https://llvm.org/LICENSE.txt for license information. 0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 0006 // 0007 //===----------------------------------------------------------------------===// 0008 // 0009 // This file defines the MCOperandInfo and MCInstrDesc classes, which 0010 // are used to describe target instructions and their operands. 0011 // 0012 //===----------------------------------------------------------------------===// 0013 0014 #ifndef LLVM_MC_MCINSTRDESC_H 0015 #define LLVM_MC_MCINSTRDESC_H 0016 0017 #include "llvm/ADT/ArrayRef.h" 0018 #include "llvm/ADT/iterator_range.h" 0019 #include "llvm/MC/MCRegister.h" 0020 0021 namespace llvm { 0022 class MCRegisterInfo; 0023 0024 class MCInst; 0025 0026 //===----------------------------------------------------------------------===// 0027 // Machine Operand Flags and Description 0028 //===----------------------------------------------------------------------===// 0029 0030 namespace MCOI { 0031 /// Operand constraints. These are encoded in 16 bits with one of the 0032 /// low-order 3 bits specifying that a constraint is present and the 0033 /// corresponding high-order hex digit specifying the constraint value. 0034 /// This allows for a maximum of 3 constraints. 0035 enum OperandConstraint { 0036 TIED_TO = 0, // Must be allocated the same register as specified value. 0037 EARLY_CLOBBER // If present, operand is an early clobber register. 0038 }; 0039 0040 // Define a macro to produce each constraint value. 0041 #define MCOI_TIED_TO(op) \ 0042 ((1 << MCOI::TIED_TO) | ((op) << (4 + MCOI::TIED_TO * 4))) 0043 0044 #define MCOI_EARLY_CLOBBER \ 0045 (1 << MCOI::EARLY_CLOBBER) 0046 0047 /// These are flags set on operands, but should be considered 0048 /// private, all access should go through the MCOperandInfo accessors. 0049 /// See the accessors for a description of what these are. 0050 enum OperandFlags { 0051 LookupPtrRegClass = 0, 0052 Predicate, 0053 OptionalDef, 0054 BranchTarget 0055 }; 0056 0057 /// Operands are tagged with one of the values of this enum. 0058 enum OperandType { 0059 OPERAND_UNKNOWN = 0, 0060 OPERAND_IMMEDIATE = 1, 0061 OPERAND_REGISTER = 2, 0062 OPERAND_MEMORY = 3, 0063 OPERAND_PCREL = 4, 0064 0065 OPERAND_FIRST_GENERIC = 6, 0066 OPERAND_GENERIC_0 = 6, 0067 OPERAND_GENERIC_1 = 7, 0068 OPERAND_GENERIC_2 = 8, 0069 OPERAND_GENERIC_3 = 9, 0070 OPERAND_GENERIC_4 = 10, 0071 OPERAND_GENERIC_5 = 11, 0072 OPERAND_LAST_GENERIC = 11, 0073 0074 OPERAND_FIRST_GENERIC_IMM = 12, 0075 OPERAND_GENERIC_IMM_0 = 12, 0076 OPERAND_LAST_GENERIC_IMM = 12, 0077 0078 OPERAND_FIRST_TARGET = 13, 0079 }; 0080 0081 } // namespace MCOI 0082 0083 /// This holds information about one operand of a machine instruction, 0084 /// indicating the register class for register operands, etc. 0085 class MCOperandInfo { 0086 public: 0087 /// This specifies the register class enumeration of the operand 0088 /// if the operand is a register. If isLookupPtrRegClass is set, then this is 0089 /// an index that is passed to TargetRegisterInfo::getPointerRegClass(x) to 0090 /// get a dynamic register class. 0091 int16_t RegClass; 0092 0093 /// These are flags from the MCOI::OperandFlags enum. 0094 uint8_t Flags; 0095 0096 /// Information about the type of the operand. 0097 uint8_t OperandType; 0098 0099 /// Operand constraints (see OperandConstraint enum). 0100 uint16_t Constraints; 0101 0102 /// Set if this operand is a pointer value and it requires a callback 0103 /// to look up its register class. 0104 bool isLookupPtrRegClass() const { 0105 return Flags & (1 << MCOI::LookupPtrRegClass); 0106 } 0107 0108 /// Set if this is one of the operands that made up of the predicate 0109 /// operand that controls an isPredicable() instruction. 0110 bool isPredicate() const { return Flags & (1 << MCOI::Predicate); } 0111 0112 /// Set if this operand is a optional def. 0113 bool isOptionalDef() const { return Flags & (1 << MCOI::OptionalDef); } 0114 0115 /// Set if this operand is a branch target. 0116 bool isBranchTarget() const { return Flags & (1 << MCOI::BranchTarget); } 0117 0118 bool isGenericType() const { 0119 return OperandType >= MCOI::OPERAND_FIRST_GENERIC && 0120 OperandType <= MCOI::OPERAND_LAST_GENERIC; 0121 } 0122 0123 unsigned getGenericTypeIndex() const { 0124 assert(isGenericType() && "non-generic types don't have an index"); 0125 return OperandType - MCOI::OPERAND_FIRST_GENERIC; 0126 } 0127 0128 bool isGenericImm() const { 0129 return OperandType >= MCOI::OPERAND_FIRST_GENERIC_IMM && 0130 OperandType <= MCOI::OPERAND_LAST_GENERIC_IMM; 0131 } 0132 0133 unsigned getGenericImmIndex() const { 0134 assert(isGenericImm() && "non-generic immediates don't have an index"); 0135 return OperandType - MCOI::OPERAND_FIRST_GENERIC_IMM; 0136 } 0137 }; 0138 0139 //===----------------------------------------------------------------------===// 0140 // Machine Instruction Flags and Description 0141 //===----------------------------------------------------------------------===// 0142 0143 namespace MCID { 0144 /// These should be considered private to the implementation of the 0145 /// MCInstrDesc class. Clients should use the predicate methods on MCInstrDesc, 0146 /// not use these directly. These all correspond to bitfields in the 0147 /// MCInstrDesc::Flags field. 0148 enum Flag { 0149 PreISelOpcode = 0, 0150 Variadic, 0151 HasOptionalDef, 0152 Pseudo, 0153 Meta, 0154 Return, 0155 EHScopeReturn, 0156 Call, 0157 Barrier, 0158 Terminator, 0159 Branch, 0160 IndirectBranch, 0161 Compare, 0162 MoveImm, 0163 MoveReg, 0164 Bitcast, 0165 Select, 0166 DelaySlot, 0167 FoldableAsLoad, 0168 MayLoad, 0169 MayStore, 0170 MayRaiseFPException, 0171 Predicable, 0172 NotDuplicable, 0173 UnmodeledSideEffects, 0174 Commutable, 0175 ConvertibleTo3Addr, 0176 UsesCustomInserter, 0177 HasPostISelHook, 0178 Rematerializable, 0179 CheapAsAMove, 0180 ExtraSrcRegAllocReq, 0181 ExtraDefRegAllocReq, 0182 RegSequence, 0183 ExtractSubreg, 0184 InsertSubreg, 0185 Convergent, 0186 Add, 0187 Trap, 0188 VariadicOpsAreDefs, 0189 Authenticated, 0190 }; 0191 } // namespace MCID 0192 0193 /// Describe properties that are true of each instruction in the target 0194 /// description file. This captures information about side effects, register 0195 /// use and many other things. There is one instance of this struct for each 0196 /// target instruction class, and the MachineInstr class points to this struct 0197 /// directly to describe itself. 0198 class MCInstrDesc { 0199 public: 0200 // FIXME: Disable copies and moves. 0201 // Do not allow MCInstrDescs to be copied or moved. They should only exist in 0202 // the <Target>Insts table because they rely on knowing their own address to 0203 // find other information elsewhere in the same table. 0204 0205 unsigned short Opcode; // The opcode number 0206 unsigned short NumOperands; // Num of args (may be more if variable_ops) 0207 unsigned char NumDefs; // Num of args that are definitions 0208 unsigned char Size; // Number of bytes in encoding. 0209 unsigned short SchedClass; // enum identifying instr sched class 0210 unsigned char NumImplicitUses; // Num of regs implicitly used 0211 unsigned char NumImplicitDefs; // Num of regs implicitly defined 0212 unsigned short ImplicitOffset; // Offset to start of implicit op list 0213 unsigned short OpInfoOffset; // Offset to info about operands 0214 uint64_t Flags; // Flags identifying machine instr class 0215 uint64_t TSFlags; // Target Specific Flag values 0216 0217 /// Returns the value of the specified operand constraint if 0218 /// it is present. Returns -1 if it is not present. 0219 int getOperandConstraint(unsigned OpNum, 0220 MCOI::OperandConstraint Constraint) const { 0221 if (OpNum < NumOperands && 0222 (operands()[OpNum].Constraints & (1 << Constraint))) { 0223 unsigned ValuePos = 4 + Constraint * 4; 0224 return (int)(operands()[OpNum].Constraints >> ValuePos) & 0x0f; 0225 } 0226 return -1; 0227 } 0228 0229 /// Return the opcode number for this descriptor. 0230 unsigned getOpcode() const { return Opcode; } 0231 0232 /// Return the number of declared MachineOperands for this 0233 /// MachineInstruction. Note that variadic (isVariadic() returns true) 0234 /// instructions may have additional operands at the end of the list, and note 0235 /// that the machine instruction may include implicit register def/uses as 0236 /// well. 0237 unsigned getNumOperands() const { return NumOperands; } 0238 0239 ArrayRef<MCOperandInfo> operands() const { 0240 auto OpInfo = reinterpret_cast<const MCOperandInfo *>(this + Opcode + 1); 0241 return ArrayRef(OpInfo + OpInfoOffset, NumOperands); 0242 } 0243 0244 /// Return the number of MachineOperands that are register 0245 /// definitions. Register definitions always occur at the start of the 0246 /// machine operand list. This is the number of "outs" in the .td file, 0247 /// and does not include implicit defs. 0248 unsigned getNumDefs() const { return NumDefs; } 0249 0250 /// Return flags of this instruction. 0251 uint64_t getFlags() const { return Flags; } 0252 0253 /// \returns true if this instruction is emitted before instruction selection 0254 /// and should be legalized/regbankselected/selected. 0255 bool isPreISelOpcode() const { return Flags & (1ULL << MCID::PreISelOpcode); } 0256 0257 /// Return true if this instruction can have a variable number of 0258 /// operands. In this case, the variable operands will be after the normal 0259 /// operands but before the implicit definitions and uses (if any are 0260 /// present). 0261 bool isVariadic() const { return Flags & (1ULL << MCID::Variadic); } 0262 0263 /// Set if this instruction has an optional definition, e.g. 0264 /// ARM instructions which can set condition code if 's' bit is set. 0265 bool hasOptionalDef() const { return Flags & (1ULL << MCID::HasOptionalDef); } 0266 0267 /// Return true if this is a pseudo instruction that doesn't 0268 /// correspond to a real machine instruction. 0269 bool isPseudo() const { return Flags & (1ULL << MCID::Pseudo); } 0270 0271 /// Return true if this is a meta instruction that doesn't 0272 /// produce any output in the form of executable instructions. 0273 bool isMetaInstruction() const { return Flags & (1ULL << MCID::Meta); } 0274 0275 /// Return true if the instruction is a return. 0276 bool isReturn() const { return Flags & (1ULL << MCID::Return); } 0277 0278 /// Return true if the instruction is an add instruction. 0279 bool isAdd() const { return Flags & (1ULL << MCID::Add); } 0280 0281 /// Return true if this instruction is a trap. 0282 bool isTrap() const { return Flags & (1ULL << MCID::Trap); } 0283 0284 /// Return true if the instruction is a register to register move. 0285 bool isMoveReg() const { return Flags & (1ULL << MCID::MoveReg); } 0286 0287 /// Return true if the instruction is a call. 0288 bool isCall() const { return Flags & (1ULL << MCID::Call); } 0289 0290 /// Returns true if the specified instruction stops control flow 0291 /// from executing the instruction immediately following it. Examples include 0292 /// unconditional branches and return instructions. 0293 bool isBarrier() const { return Flags & (1ULL << MCID::Barrier); } 0294 0295 /// Returns true if this instruction part of the terminator for 0296 /// a basic block. Typically this is things like return and branch 0297 /// instructions. 0298 /// 0299 /// Various passes use this to insert code into the bottom of a basic block, 0300 /// but before control flow occurs. 0301 bool isTerminator() const { return Flags & (1ULL << MCID::Terminator); } 0302 0303 /// Returns true if this is a conditional, unconditional, or 0304 /// indirect branch. Predicates below can be used to discriminate between 0305 /// these cases, and the TargetInstrInfo::analyzeBranch method can be used to 0306 /// get more information. 0307 bool isBranch() const { return Flags & (1ULL << MCID::Branch); } 0308 0309 /// Return true if this is an indirect branch, such as a 0310 /// branch through a register. 0311 bool isIndirectBranch() const { return Flags & (1ULL << MCID::IndirectBranch); } 0312 0313 /// Return true if this is a branch which may fall 0314 /// through to the next instruction or may transfer control flow to some other 0315 /// block. The TargetInstrInfo::analyzeBranch method can be used to get more 0316 /// information about this branch. 0317 bool isConditionalBranch() const { 0318 return isBranch() && !isBarrier() && !isIndirectBranch(); 0319 } 0320 0321 /// Return true if this is a branch which always 0322 /// transfers control flow to some other block. The 0323 /// TargetInstrInfo::analyzeBranch method can be used to get more information 0324 /// about this branch. 0325 bool isUnconditionalBranch() const { 0326 return isBranch() && isBarrier() && !isIndirectBranch(); 0327 } 0328 0329 /// Return true if this is a branch or an instruction which directly 0330 /// writes to the program counter. Considered 'may' affect rather than 0331 /// 'does' affect as things like predication are not taken into account. 0332 bool mayAffectControlFlow(const MCInst &MI, const MCRegisterInfo &RI) const; 0333 0334 /// Return true if this instruction has a predicate operand 0335 /// that controls execution. It may be set to 'always', or may be set to other 0336 /// values. There are various methods in TargetInstrInfo that can be used to 0337 /// control and modify the predicate in this instruction. 0338 bool isPredicable() const { return Flags & (1ULL << MCID::Predicable); } 0339 0340 /// Return true if this instruction is a comparison. 0341 bool isCompare() const { return Flags & (1ULL << MCID::Compare); } 0342 0343 /// Return true if this instruction is a move immediate 0344 /// (including conditional moves) instruction. 0345 bool isMoveImmediate() const { return Flags & (1ULL << MCID::MoveImm); } 0346 0347 /// Return true if this instruction is a bitcast instruction. 0348 bool isBitcast() const { return Flags & (1ULL << MCID::Bitcast); } 0349 0350 /// Return true if this is a select instruction. 0351 bool isSelect() const { return Flags & (1ULL << MCID::Select); } 0352 0353 /// Return true if this instruction cannot be safely 0354 /// duplicated. For example, if the instruction has a unique labels attached 0355 /// to it, duplicating it would cause multiple definition errors. 0356 bool isNotDuplicable() const { return Flags & (1ULL << MCID::NotDuplicable); } 0357 0358 /// Returns true if the specified instruction has a delay slot which 0359 /// must be filled by the code generator. 0360 bool hasDelaySlot() const { return Flags & (1ULL << MCID::DelaySlot); } 0361 0362 /// Return true for instructions that can be folded as memory operands 0363 /// in other instructions. The most common use for this is instructions that 0364 /// are simple loads from memory that don't modify the loaded value in any 0365 /// way, but it can also be used for instructions that can be expressed as 0366 /// constant-pool loads, such as V_SETALLONES on x86, to allow them to be 0367 /// folded when it is beneficial. This should only be set on instructions 0368 /// that return a value in their only virtual register definition. 0369 bool canFoldAsLoad() const { return Flags & (1ULL << MCID::FoldableAsLoad); } 0370 0371 /// Return true if this instruction behaves 0372 /// the same way as the generic REG_SEQUENCE instructions. 0373 /// E.g., on ARM, 0374 /// dX VMOVDRR rY, rZ 0375 /// is equivalent to 0376 /// dX = REG_SEQUENCE rY, ssub_0, rZ, ssub_1. 0377 /// 0378 /// Note that for the optimizers to be able to take advantage of 0379 /// this property, TargetInstrInfo::getRegSequenceLikeInputs has to be 0380 /// override accordingly. 0381 bool isRegSequenceLike() const { return Flags & (1ULL << MCID::RegSequence); } 0382 0383 /// Return true if this instruction behaves 0384 /// the same way as the generic EXTRACT_SUBREG instructions. 0385 /// E.g., on ARM, 0386 /// rX, rY VMOVRRD dZ 0387 /// is equivalent to two EXTRACT_SUBREG: 0388 /// rX = EXTRACT_SUBREG dZ, ssub_0 0389 /// rY = EXTRACT_SUBREG dZ, ssub_1 0390 /// 0391 /// Note that for the optimizers to be able to take advantage of 0392 /// this property, TargetInstrInfo::getExtractSubregLikeInputs has to be 0393 /// override accordingly. 0394 bool isExtractSubregLike() const { 0395 return Flags & (1ULL << MCID::ExtractSubreg); 0396 } 0397 0398 /// Return true if this instruction behaves 0399 /// the same way as the generic INSERT_SUBREG instructions. 0400 /// E.g., on ARM, 0401 /// dX = VSETLNi32 dY, rZ, Imm 0402 /// is equivalent to a INSERT_SUBREG: 0403 /// dX = INSERT_SUBREG dY, rZ, translateImmToSubIdx(Imm) 0404 /// 0405 /// Note that for the optimizers to be able to take advantage of 0406 /// this property, TargetInstrInfo::getInsertSubregLikeInputs has to be 0407 /// override accordingly. 0408 bool isInsertSubregLike() const { return Flags & (1ULL << MCID::InsertSubreg); } 0409 0410 0411 /// Return true if this instruction is convergent. 0412 /// 0413 /// Convergent instructions may not be made control-dependent on any 0414 /// additional values. 0415 bool isConvergent() const { return Flags & (1ULL << MCID::Convergent); } 0416 0417 /// Return true if variadic operands of this instruction are definitions. 0418 bool variadicOpsAreDefs() const { 0419 return Flags & (1ULL << MCID::VariadicOpsAreDefs); 0420 } 0421 0422 /// Return true if this instruction authenticates a pointer (e.g. LDRAx/BRAx 0423 /// from ARMv8.3, which perform loads/branches with authentication). 0424 /// 0425 /// An authenticated instruction may fail in an ABI-defined manner when 0426 /// operating on an invalid signed pointer. 0427 bool isAuthenticated() const { 0428 return Flags & (1ULL << MCID::Authenticated); 0429 } 0430 0431 //===--------------------------------------------------------------------===// 0432 // Side Effect Analysis 0433 //===--------------------------------------------------------------------===// 0434 0435 /// Return true if this instruction could possibly read memory. 0436 /// Instructions with this flag set are not necessarily simple load 0437 /// instructions, they may load a value and modify it, for example. 0438 bool mayLoad() const { return Flags & (1ULL << MCID::MayLoad); } 0439 0440 /// Return true if this instruction could possibly modify memory. 0441 /// Instructions with this flag set are not necessarily simple store 0442 /// instructions, they may store a modified value based on their operands, or 0443 /// may not actually modify anything, for example. 0444 bool mayStore() const { return Flags & (1ULL << MCID::MayStore); } 0445 0446 /// Return true if this instruction may raise a floating-point exception. 0447 bool mayRaiseFPException() const { 0448 return Flags & (1ULL << MCID::MayRaiseFPException); 0449 } 0450 0451 /// Return true if this instruction has side 0452 /// effects that are not modeled by other flags. This does not return true 0453 /// for instructions whose effects are captured by: 0454 /// 0455 /// 1. Their operand list and implicit definition/use list. Register use/def 0456 /// info is explicit for instructions. 0457 /// 2. Memory accesses. Use mayLoad/mayStore. 0458 /// 3. Calling, branching, returning: use isCall/isReturn/isBranch. 0459 /// 0460 /// Examples of side effects would be modifying 'invisible' machine state like 0461 /// a control register, flushing a cache, modifying a register invisible to 0462 /// LLVM, etc. 0463 bool hasUnmodeledSideEffects() const { 0464 return Flags & (1ULL << MCID::UnmodeledSideEffects); 0465 } 0466 0467 //===--------------------------------------------------------------------===// 0468 // Flags that indicate whether an instruction can be modified by a method. 0469 //===--------------------------------------------------------------------===// 0470 0471 /// Return true if this may be a 2- or 3-address instruction (of the 0472 /// form "X = op Y, Z, ..."), which produces the same result if Y and Z are 0473 /// exchanged. If this flag is set, then the 0474 /// TargetInstrInfo::commuteInstruction method may be used to hack on the 0475 /// instruction. 0476 /// 0477 /// Note that this flag may be set on instructions that are only commutable 0478 /// sometimes. In these cases, the call to commuteInstruction will fail. 0479 /// Also note that some instructions require non-trivial modification to 0480 /// commute them. 0481 bool isCommutable() const { return Flags & (1ULL << MCID::Commutable); } 0482 0483 /// Return true if this is a 2-address instruction which can be changed 0484 /// into a 3-address instruction if needed. Doing this transformation can be 0485 /// profitable in the register allocator, because it means that the 0486 /// instruction can use a 2-address form if possible, but degrade into a less 0487 /// efficient form if the source and dest register cannot be assigned to the 0488 /// same register. For example, this allows the x86 backend to turn a "shl 0489 /// reg, 3" instruction into an LEA instruction, which is the same speed as 0490 /// the shift but has bigger code size. 0491 /// 0492 /// If this returns true, then the target must implement the 0493 /// TargetInstrInfo::convertToThreeAddress method for this instruction, which 0494 /// is allowed to fail if the transformation isn't valid for this specific 0495 /// instruction (e.g. shl reg, 4 on x86). 0496 /// 0497 bool isConvertibleTo3Addr() const { 0498 return Flags & (1ULL << MCID::ConvertibleTo3Addr); 0499 } 0500 0501 /// Return true if this instruction requires custom insertion support 0502 /// when the DAG scheduler is inserting it into a machine basic block. If 0503 /// this is true for the instruction, it basically means that it is a pseudo 0504 /// instruction used at SelectionDAG time that is expanded out into magic code 0505 /// by the target when MachineInstrs are formed. 0506 /// 0507 /// If this is true, the TargetLoweringInfo::InsertAtEndOfBasicBlock method 0508 /// is used to insert this into the MachineBasicBlock. 0509 bool usesCustomInsertionHook() const { 0510 return Flags & (1ULL << MCID::UsesCustomInserter); 0511 } 0512 0513 /// Return true if this instruction requires *adjustment* after 0514 /// instruction selection by calling a target hook. For example, this can be 0515 /// used to fill in ARM 's' optional operand depending on whether the 0516 /// conditional flag register is used. 0517 bool hasPostISelHook() const { return Flags & (1ULL << MCID::HasPostISelHook); } 0518 0519 /// Returns true if this instruction is a candidate for remat. This 0520 /// flag is only used in TargetInstrInfo method isTriviallyRematerializable. 0521 /// 0522 /// If this flag is set, the isReallyTriviallyReMaterializable() method is 0523 /// called to verify the instruction is really rematerializable. 0524 bool isRematerializable() const { 0525 return Flags & (1ULL << MCID::Rematerializable); 0526 } 0527 0528 /// Returns true if this instruction has the same cost (or less) than a 0529 /// move instruction. This is useful during certain types of optimizations 0530 /// (e.g., remat during two-address conversion or machine licm) where we would 0531 /// like to remat or hoist the instruction, but not if it costs more than 0532 /// moving the instruction into the appropriate register. Note, we are not 0533 /// marking copies from and to the same register class with this flag. 0534 /// 0535 /// This method could be called by interface TargetInstrInfo::isAsCheapAsAMove 0536 /// for different subtargets. 0537 bool isAsCheapAsAMove() const { return Flags & (1ULL << MCID::CheapAsAMove); } 0538 0539 /// Returns true if this instruction source operands have special 0540 /// register allocation requirements that are not captured by the operand 0541 /// register classes. e.g. ARM::STRD's two source registers must be an even / 0542 /// odd pair, ARM::STM registers have to be in ascending order. Post-register 0543 /// allocation passes should not attempt to change allocations for sources of 0544 /// instructions with this flag. 0545 bool hasExtraSrcRegAllocReq() const { 0546 return Flags & (1ULL << MCID::ExtraSrcRegAllocReq); 0547 } 0548 0549 /// Returns true if this instruction def operands have special register 0550 /// allocation requirements that are not captured by the operand register 0551 /// classes. e.g. ARM::LDRD's two def registers must be an even / odd pair, 0552 /// ARM::LDM registers have to be in ascending order. Post-register 0553 /// allocation passes should not attempt to change allocations for definitions 0554 /// of instructions with this flag. 0555 bool hasExtraDefRegAllocReq() const { 0556 return Flags & (1ULL << MCID::ExtraDefRegAllocReq); 0557 } 0558 0559 /// Return a list of registers that are potentially read by any 0560 /// instance of this machine instruction. For example, on X86, the "adc" 0561 /// instruction adds two register operands and adds the carry bit in from the 0562 /// flags register. In this case, the instruction is marked as implicitly 0563 /// reading the flags. Likewise, the variable shift instruction on X86 is 0564 /// marked as implicitly reading the 'CL' register, which it always does. 0565 ArrayRef<MCPhysReg> implicit_uses() const { 0566 auto ImplicitOps = 0567 reinterpret_cast<const MCPhysReg *>(this + Opcode + 1) + ImplicitOffset; 0568 return {ImplicitOps, NumImplicitUses}; 0569 } 0570 0571 /// Return a list of registers that are potentially written by any 0572 /// instance of this machine instruction. For example, on X86, many 0573 /// instructions implicitly set the flags register. In this case, they are 0574 /// marked as setting the FLAGS. Likewise, many instructions always deposit 0575 /// their result in a physical register. For example, the X86 divide 0576 /// instruction always deposits the quotient and remainder in the EAX/EDX 0577 /// registers. For that instruction, this will return a list containing the 0578 /// EAX/EDX/EFLAGS registers. 0579 ArrayRef<MCPhysReg> implicit_defs() const { 0580 auto ImplicitOps = 0581 reinterpret_cast<const MCPhysReg *>(this + Opcode + 1) + ImplicitOffset; 0582 return {ImplicitOps + NumImplicitUses, NumImplicitDefs}; 0583 } 0584 0585 /// Return true if this instruction implicitly 0586 /// uses the specified physical register. 0587 bool hasImplicitUseOfPhysReg(MCRegister Reg) const { 0588 return is_contained(implicit_uses(), Reg); 0589 } 0590 0591 /// Return true if this instruction implicitly 0592 /// defines the specified physical register. 0593 bool hasImplicitDefOfPhysReg(MCRegister Reg, 0594 const MCRegisterInfo *MRI = nullptr) const; 0595 0596 /// Return the scheduling class for this instruction. The 0597 /// scheduling class is an index into the InstrItineraryData table. This 0598 /// returns zero if there is no known scheduling information for the 0599 /// instruction. 0600 unsigned getSchedClass() const { return SchedClass; } 0601 0602 /// Return the number of bytes in the encoding of this instruction, 0603 /// or zero if the encoding size cannot be known from the opcode. 0604 unsigned getSize() const { return Size; } 0605 0606 /// Find the index of the first operand in the 0607 /// operand list that is used to represent the predicate. It returns -1 if 0608 /// none is found. 0609 int findFirstPredOperandIdx() const { 0610 if (isPredicable()) { 0611 for (unsigned i = 0, e = getNumOperands(); i != e; ++i) 0612 if (operands()[i].isPredicate()) 0613 return i; 0614 } 0615 return -1; 0616 } 0617 0618 /// Return true if this instruction defines the specified physical 0619 /// register, either explicitly or implicitly. 0620 bool hasDefOfPhysReg(const MCInst &MI, MCRegister Reg, 0621 const MCRegisterInfo &RI) const; 0622 }; 0623 0624 } // end namespace llvm 0625 0626 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|