LLVM API Documentation
00001 //===-- llvm/MC/MCInstrDesc.h - Instruction Descriptors -*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file defines the MCOperandInfo and MCInstrDesc classes, which 00011 // are used to describe target instructions and their operands. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #ifndef LLVM_MC_MCINSTRDESC_H 00016 #define LLVM_MC_MCINSTRDESC_H 00017 00018 #include "llvm/MC/MCInst.h" 00019 #include "llvm/MC/MCRegisterInfo.h" 00020 #include "llvm/MC/MCSubtargetInfo.h" 00021 #include "llvm/Support/DataTypes.h" 00022 00023 namespace llvm { 00024 00025 //===----------------------------------------------------------------------===// 00026 // Machine Operand Flags and Description 00027 //===----------------------------------------------------------------------===// 00028 00029 namespace MCOI { 00030 // Operand constraints 00031 enum OperandConstraint { 00032 TIED_TO = 0, // Must be allocated the same register as. 00033 EARLY_CLOBBER // Operand is an early clobber register operand 00034 }; 00035 00036 /// OperandFlags - These are flags set on operands, but should be considered 00037 /// private, all access should go through the MCOperandInfo accessors. 00038 /// See the accessors for a description of what these are. 00039 enum OperandFlags { 00040 LookupPtrRegClass = 0, 00041 Predicate, 00042 OptionalDef 00043 }; 00044 00045 /// Operand Type - Operands are tagged with one of the values of this enum. 00046 enum OperandType { 00047 OPERAND_UNKNOWN, 00048 OPERAND_IMMEDIATE, 00049 OPERAND_REGISTER, 00050 OPERAND_MEMORY, 00051 OPERAND_PCREL 00052 }; 00053 } 00054 00055 /// MCOperandInfo - This holds information about one operand of a machine 00056 /// instruction, indicating the register class for register operands, etc. 00057 /// 00058 class MCOperandInfo { 00059 public: 00060 /// RegClass - This specifies the register class enumeration of the operand 00061 /// if the operand is a register. If isLookupPtrRegClass is set, then this is 00062 /// an index that is passed to TargetRegisterInfo::getPointerRegClass(x) to 00063 /// get a dynamic register class. 00064 int16_t RegClass; 00065 00066 /// Flags - These are flags from the MCOI::OperandFlags enum. 00067 uint8_t Flags; 00068 00069 /// OperandType - Information about the type of the operand. 00070 uint8_t OperandType; 00071 00072 /// Lower 16 bits are used to specify which constraints are set. The higher 16 00073 /// bits are used to specify the value of constraints (4 bits each). 00074 uint32_t Constraints; 00075 /// Currently no other information. 00076 00077 /// isLookupPtrRegClass - Set if this operand is a pointer value and it 00078 /// requires a callback to look up its register class. 00079 bool isLookupPtrRegClass() const {return Flags&(1 <<MCOI::LookupPtrRegClass);} 00080 00081 /// isPredicate - Set if this is one of the operands that made up of 00082 /// the predicate operand that controls an isPredicable() instruction. 00083 bool isPredicate() const { return Flags & (1 << MCOI::Predicate); } 00084 00085 /// isOptionalDef - Set if this operand is a optional def. 00086 /// 00087 bool isOptionalDef() const { return Flags & (1 << MCOI::OptionalDef); } 00088 }; 00089 00090 00091 //===----------------------------------------------------------------------===// 00092 // Machine Instruction Flags and Description 00093 //===----------------------------------------------------------------------===// 00094 00095 /// MCInstrDesc flags - These should be considered private to the 00096 /// implementation of the MCInstrDesc class. Clients should use the predicate 00097 /// methods on MCInstrDesc, not use these directly. These all correspond to 00098 /// bitfields in the MCInstrDesc::Flags field. 00099 namespace MCID { 00100 enum { 00101 Variadic = 0, 00102 HasOptionalDef, 00103 Pseudo, 00104 Return, 00105 Call, 00106 Barrier, 00107 Terminator, 00108 Branch, 00109 IndirectBranch, 00110 Compare, 00111 MoveImm, 00112 Bitcast, 00113 Select, 00114 DelaySlot, 00115 FoldableAsLoad, 00116 MayLoad, 00117 MayStore, 00118 Predicable, 00119 NotDuplicable, 00120 UnmodeledSideEffects, 00121 Commutable, 00122 ConvertibleTo3Addr, 00123 UsesCustomInserter, 00124 HasPostISelHook, 00125 Rematerializable, 00126 CheapAsAMove, 00127 ExtraSrcRegAllocReq, 00128 ExtraDefRegAllocReq, 00129 RegSequence, 00130 ExtractSubreg, 00131 InsertSubreg 00132 }; 00133 } 00134 00135 /// MCInstrDesc - Describe properties that are true of each instruction in the 00136 /// target description file. This captures information about side effects, 00137 /// register use and many other things. There is one instance of this struct 00138 /// for each target instruction class, and the MachineInstr class points to 00139 /// this struct directly to describe itself. 00140 class MCInstrDesc { 00141 public: 00142 unsigned short Opcode; // The opcode number 00143 unsigned short NumOperands; // Num of args (may be more if variable_ops) 00144 unsigned short NumDefs; // Num of args that are definitions 00145 unsigned short SchedClass; // enum identifying instr sched class 00146 unsigned short Size; // Number of bytes in encoding. 00147 unsigned Flags; // Flags identifying machine instr class 00148 uint64_t TSFlags; // Target Specific Flag values 00149 const uint16_t *ImplicitUses; // Registers implicitly read by this instr 00150 const uint16_t *ImplicitDefs; // Registers implicitly defined by this instr 00151 const MCOperandInfo *OpInfo; // 'NumOperands' entries about operands 00152 uint64_t DeprecatedFeatureMask;// Feature bits that this is deprecated on, if any 00153 // A complex method to determine is a certain is deprecated or not, and return 00154 // the reason for deprecation. 00155 bool (*ComplexDeprecationInfo)(MCInst &, MCSubtargetInfo &, std::string &); 00156 00157 /// \brief Returns the value of the specific constraint if 00158 /// it is set. Returns -1 if it is not set. 00159 int getOperandConstraint(unsigned OpNum, 00160 MCOI::OperandConstraint Constraint) const { 00161 if (OpNum < NumOperands && 00162 (OpInfo[OpNum].Constraints & (1 << Constraint))) { 00163 unsigned Pos = 16 + Constraint * 4; 00164 return (int)(OpInfo[OpNum].Constraints >> Pos) & 0xf; 00165 } 00166 return -1; 00167 } 00168 00169 /// \brief Returns true if a certain instruction is deprecated and if so 00170 /// returns the reason in \p Info. 00171 bool getDeprecatedInfo(MCInst &MI, MCSubtargetInfo &STI, 00172 std::string &Info) const { 00173 if (ComplexDeprecationInfo) 00174 return ComplexDeprecationInfo(MI, STI, Info); 00175 if ((DeprecatedFeatureMask & STI.getFeatureBits()) != 0) { 00176 // FIXME: it would be nice to include the subtarget feature here. 00177 Info = "deprecated"; 00178 return true; 00179 } 00180 return false; 00181 } 00182 00183 /// \brief Return the opcode number for this descriptor. 00184 unsigned getOpcode() const { 00185 return Opcode; 00186 } 00187 00188 /// \brief Return the number of declared MachineOperands for this 00189 /// MachineInstruction. Note that variadic (isVariadic() returns true) 00190 /// instructions may have additional operands at the end of the list, and note 00191 /// that the machine instruction may include implicit register def/uses as 00192 /// well. 00193 unsigned getNumOperands() const { 00194 return NumOperands; 00195 } 00196 00197 /// \brief Return the number of MachineOperands that are register 00198 /// definitions. Register definitions always occur at the start of the 00199 /// machine operand list. This is the number of "outs" in the .td file, 00200 /// and does not include implicit defs. 00201 unsigned getNumDefs() const { 00202 return NumDefs; 00203 } 00204 00205 /// \brief Return flags of this instruction. 00206 unsigned getFlags() const { return Flags; } 00207 00208 /// \brief Return true if this instruction can have a variable number of 00209 /// operands. In this case, the variable operands will be after the normal 00210 /// operands but before the implicit definitions and uses (if any are 00211 /// present). 00212 bool isVariadic() const { 00213 return Flags & (1 << MCID::Variadic); 00214 } 00215 00216 /// \brief Set if this instruction has an optional definition, e.g. 00217 /// ARM instructions which can set condition code if 's' bit is set. 00218 bool hasOptionalDef() const { 00219 return Flags & (1 << MCID::HasOptionalDef); 00220 } 00221 00222 /// \brief Return true if this is a pseudo instruction that doesn't 00223 /// correspond to a real machine instruction. 00224 /// 00225 bool isPseudo() const { 00226 return Flags & (1 << MCID::Pseudo); 00227 } 00228 00229 /// \brief Return true if the instruction is a return. 00230 bool isReturn() const { 00231 return Flags & (1 << MCID::Return); 00232 } 00233 00234 /// \brief Return true if the instruction is a call. 00235 bool isCall() const { 00236 return Flags & (1 << MCID::Call); 00237 } 00238 00239 /// \brief Returns true if the specified instruction stops control flow 00240 /// from executing the instruction immediately following it. Examples include 00241 /// unconditional branches and return instructions. 00242 bool isBarrier() const { 00243 return Flags & (1 << MCID::Barrier); 00244 } 00245 00246 /// \brief Returns true if this instruction part of the terminator for 00247 /// a basic block. Typically this is things like return and branch 00248 /// instructions. 00249 /// 00250 /// Various passes use this to insert code into the bottom of a basic block, 00251 /// but before control flow occurs. 00252 bool isTerminator() const { 00253 return Flags & (1 << MCID::Terminator); 00254 } 00255 00256 /// \brief Returns true if this is a conditional, unconditional, or 00257 /// indirect branch. Predicates below can be used to discriminate between 00258 /// these cases, and the TargetInstrInfo::AnalyzeBranch method can be used to 00259 /// get more information. 00260 bool isBranch() const { 00261 return Flags & (1 << MCID::Branch); 00262 } 00263 00264 /// \brief Return true if this is an indirect branch, such as a 00265 /// branch through a register. 00266 bool isIndirectBranch() const { 00267 return Flags & (1 << MCID::IndirectBranch); 00268 } 00269 00270 /// \brief Return true if this is a branch which may fall 00271 /// through to the next instruction or may transfer control flow to some other 00272 /// block. The TargetInstrInfo::AnalyzeBranch method can be used to get more 00273 /// information about this branch. 00274 bool isConditionalBranch() const { 00275 return isBranch() & !isBarrier() & !isIndirectBranch(); 00276 } 00277 00278 /// \brief Return true if this is a branch which always 00279 /// transfers control flow to some other block. The 00280 /// TargetInstrInfo::AnalyzeBranch method can be used to get more information 00281 /// about this branch. 00282 bool isUnconditionalBranch() const { 00283 return isBranch() & isBarrier() & !isIndirectBranch(); 00284 } 00285 00286 /// \brief Return true if this is a branch or an instruction which directly 00287 /// writes to the program counter. Considered 'may' affect rather than 00288 /// 'does' affect as things like predication are not taken into account. 00289 bool mayAffectControlFlow(const MCInst &MI, const MCRegisterInfo &RI) const { 00290 if (isBranch() || isCall() || isReturn() || isIndirectBranch()) 00291 return true; 00292 unsigned PC = RI.getProgramCounter(); 00293 if (PC == 0) 00294 return false; 00295 if (hasDefOfPhysReg(MI, PC, RI)) 00296 return true; 00297 // A variadic instruction may define PC in the variable operand list. 00298 // There's currently no indication of which entries in a variable 00299 // list are defs and which are uses. While that's the case, this function 00300 // needs to assume they're defs in order to be conservatively correct. 00301 for (int i = NumOperands, e = MI.getNumOperands(); i != e; ++i) { 00302 if (MI.getOperand(i).isReg() && 00303 RI.isSubRegisterEq(PC, MI.getOperand(i).getReg())) 00304 return true; 00305 } 00306 return false; 00307 } 00308 00309 /// \brief Return true if this instruction has a predicate operand 00310 /// that controls execution. It may be set to 'always', or may be set to other 00311 /// values. There are various methods in TargetInstrInfo that can be used to 00312 /// control and modify the predicate in this instruction. 00313 bool isPredicable() const { 00314 return Flags & (1 << MCID::Predicable); 00315 } 00316 00317 /// \brief Return true if this instruction is a comparison. 00318 bool isCompare() const { 00319 return Flags & (1 << MCID::Compare); 00320 } 00321 00322 /// \brief Return true if this instruction is a move immediate 00323 /// (including conditional moves) instruction. 00324 bool isMoveImmediate() const { 00325 return Flags & (1 << MCID::MoveImm); 00326 } 00327 00328 /// \brief Return true if this instruction is a bitcast instruction. 00329 bool isBitcast() const { 00330 return Flags & (1 << MCID::Bitcast); 00331 } 00332 00333 /// \brief Return true if this is a select instruction. 00334 bool isSelect() const { 00335 return Flags & (1 << MCID::Select); 00336 } 00337 00338 /// \brief Return true if this instruction cannot be safely 00339 /// duplicated. For example, if the instruction has a unique labels attached 00340 /// to it, duplicating it would cause multiple definition errors. 00341 bool isNotDuplicable() const { 00342 return Flags & (1 << MCID::NotDuplicable); 00343 } 00344 00345 /// hasDelaySlot - Returns true if the specified instruction has a delay slot 00346 /// which must be filled by the code generator. 00347 bool hasDelaySlot() const { 00348 return Flags & (1 << MCID::DelaySlot); 00349 } 00350 00351 /// canFoldAsLoad - Return true for instructions that can be folded as 00352 /// memory operands in other instructions. The most common use for this 00353 /// is instructions that are simple loads from memory that don't modify 00354 /// the loaded value in any way, but it can also be used for instructions 00355 /// that can be expressed as constant-pool loads, such as V_SETALLONES 00356 /// on x86, to allow them to be folded when it is beneficial. 00357 /// This should only be set on instructions that return a value in their 00358 /// only virtual register definition. 00359 bool canFoldAsLoad() const { 00360 return Flags & (1 << MCID::FoldableAsLoad); 00361 } 00362 00363 /// \brief Return true if this instruction behaves 00364 /// the same way as the generic REG_SEQUENCE instructions. 00365 /// E.g., on ARM, 00366 /// dX VMOVDRR rY, rZ 00367 /// is equivalent to 00368 /// dX = REG_SEQUENCE rY, ssub_0, rZ, ssub_1. 00369 /// 00370 /// Note that for the optimizers to be able to take advantage of 00371 /// this property, TargetInstrInfo::getRegSequenceLikeInputs has to be 00372 /// override accordingly. 00373 bool isRegSequenceLike() const { return Flags & (1 << MCID::RegSequence); } 00374 00375 /// \brief Return true if this instruction behaves 00376 /// the same way as the generic EXTRACT_SUBREG instructions. 00377 /// E.g., on ARM, 00378 /// rX, rY VMOVRRD dZ 00379 /// is equivalent to two EXTRACT_SUBREG: 00380 /// rX = EXTRACT_SUBREG dZ, ssub_0 00381 /// rY = EXTRACT_SUBREG dZ, ssub_1 00382 /// 00383 /// Note that for the optimizers to be able to take advantage of 00384 /// this property, TargetInstrInfo::getExtractSubregLikeInputs has to be 00385 /// override accordingly. 00386 bool isExtractSubregLike() const { 00387 return Flags & (1 << MCID::ExtractSubreg); 00388 } 00389 00390 /// \brief Return true if this instruction behaves 00391 /// the same way as the generic INSERT_SUBREG instructions. 00392 /// E.g., on ARM, 00393 /// dX = VSETLNi32 dY, rZ, Imm 00394 /// is equivalent to a INSERT_SUBREG: 00395 /// dX = INSERT_SUBREG dY, rZ, translateImmToSubIdx(Imm) 00396 /// 00397 /// Note that for the optimizers to be able to take advantage of 00398 /// this property, TargetInstrInfo::getInsertSubregLikeInputs has to be 00399 /// override accordingly. 00400 bool isInsertSubregLike() const { 00401 return Flags & (1 << MCID::InsertSubreg); 00402 } 00403 00404 //===--------------------------------------------------------------------===// 00405 // Side Effect Analysis 00406 //===--------------------------------------------------------------------===// 00407 00408 /// \brief Return true if this instruction could possibly read memory. 00409 /// Instructions with this flag set are not necessarily simple load 00410 /// instructions, they may load a value and modify it, for example. 00411 bool mayLoad() const { 00412 return Flags & (1 << MCID::MayLoad); 00413 } 00414 00415 00416 /// \brief Return true if this instruction could possibly modify memory. 00417 /// Instructions with this flag set are not necessarily simple store 00418 /// instructions, they may store a modified value based on their operands, or 00419 /// may not actually modify anything, for example. 00420 bool mayStore() const { 00421 return Flags & (1 << MCID::MayStore); 00422 } 00423 00424 /// hasUnmodeledSideEffects - Return true if this instruction has side 00425 /// effects that are not modeled by other flags. This does not return true 00426 /// for instructions whose effects are captured by: 00427 /// 00428 /// 1. Their operand list and implicit definition/use list. Register use/def 00429 /// info is explicit for instructions. 00430 /// 2. Memory accesses. Use mayLoad/mayStore. 00431 /// 3. Calling, branching, returning: use isCall/isReturn/isBranch. 00432 /// 00433 /// Examples of side effects would be modifying 'invisible' machine state like 00434 /// a control register, flushing a cache, modifying a register invisible to 00435 /// LLVM, etc. 00436 /// 00437 bool hasUnmodeledSideEffects() const { 00438 return Flags & (1 << MCID::UnmodeledSideEffects); 00439 } 00440 00441 //===--------------------------------------------------------------------===// 00442 // Flags that indicate whether an instruction can be modified by a method. 00443 //===--------------------------------------------------------------------===// 00444 00445 /// isCommutable - Return true if this may be a 2- or 3-address 00446 /// instruction (of the form "X = op Y, Z, ..."), which produces the same 00447 /// result if Y and Z are exchanged. If this flag is set, then the 00448 /// TargetInstrInfo::commuteInstruction method may be used to hack on the 00449 /// instruction. 00450 /// 00451 /// Note that this flag may be set on instructions that are only commutable 00452 /// sometimes. In these cases, the call to commuteInstruction will fail. 00453 /// Also note that some instructions require non-trivial modification to 00454 /// commute them. 00455 bool isCommutable() const { 00456 return Flags & (1 << MCID::Commutable); 00457 } 00458 00459 /// isConvertibleTo3Addr - Return true if this is a 2-address instruction 00460 /// which can be changed into a 3-address instruction if needed. Doing this 00461 /// transformation can be profitable in the register allocator, because it 00462 /// means that the instruction can use a 2-address form if possible, but 00463 /// degrade into a less efficient form if the source and dest register cannot 00464 /// be assigned to the same register. For example, this allows the x86 00465 /// backend to turn a "shl reg, 3" instruction into an LEA instruction, which 00466 /// is the same speed as the shift but has bigger code size. 00467 /// 00468 /// If this returns true, then the target must implement the 00469 /// TargetInstrInfo::convertToThreeAddress method for this instruction, which 00470 /// is allowed to fail if the transformation isn't valid for this specific 00471 /// instruction (e.g. shl reg, 4 on x86). 00472 /// 00473 bool isConvertibleTo3Addr() const { 00474 return Flags & (1 << MCID::ConvertibleTo3Addr); 00475 } 00476 00477 /// usesCustomInsertionHook - Return true if this instruction requires 00478 /// custom insertion support when the DAG scheduler is inserting it into a 00479 /// machine basic block. If this is true for the instruction, it basically 00480 /// means that it is a pseudo instruction used at SelectionDAG time that is 00481 /// expanded out into magic code by the target when MachineInstrs are formed. 00482 /// 00483 /// If this is true, the TargetLoweringInfo::InsertAtEndOfBasicBlock method 00484 /// is used to insert this into the MachineBasicBlock. 00485 bool usesCustomInsertionHook() const { 00486 return Flags & (1 << MCID::UsesCustomInserter); 00487 } 00488 00489 /// hasPostISelHook - Return true if this instruction requires *adjustment* 00490 /// after instruction selection by calling a target hook. For example, this 00491 /// can be used to fill in ARM 's' optional operand depending on whether 00492 /// the conditional flag register is used. 00493 bool hasPostISelHook() const { 00494 return Flags & (1 << MCID::HasPostISelHook); 00495 } 00496 00497 /// isRematerializable - Returns true if this instruction is a candidate for 00498 /// remat. This flag is only used in TargetInstrInfo method 00499 /// isTriviallyRematerializable. 00500 /// 00501 /// If this flag is set, the isReallyTriviallyReMaterializable() 00502 /// or isReallyTriviallyReMaterializableGeneric methods are called to verify 00503 /// the instruction is really rematable. 00504 bool isRematerializable() const { 00505 return Flags & (1 << MCID::Rematerializable); 00506 } 00507 00508 /// isAsCheapAsAMove - Returns true if this instruction has the same cost (or 00509 /// less) than a move instruction. This is useful during certain types of 00510 /// optimizations (e.g., remat during two-address conversion or machine licm) 00511 /// where we would like to remat or hoist the instruction, but not if it costs 00512 /// more than moving the instruction into the appropriate register. Note, we 00513 /// are not marking copies from and to the same register class with this flag. 00514 /// 00515 /// This method could be called by interface TargetInstrInfo::isAsCheapAsAMove 00516 /// for different subtargets. 00517 bool isAsCheapAsAMove() const { 00518 return Flags & (1 << MCID::CheapAsAMove); 00519 } 00520 00521 /// hasExtraSrcRegAllocReq - Returns true if this instruction source operands 00522 /// have special register allocation requirements that are not captured by the 00523 /// operand register classes. e.g. ARM::STRD's two source registers must be an 00524 /// even / odd pair, ARM::STM registers have to be in ascending order. 00525 /// Post-register allocation passes should not attempt to change allocations 00526 /// for sources of instructions with this flag. 00527 bool hasExtraSrcRegAllocReq() const { 00528 return Flags & (1 << MCID::ExtraSrcRegAllocReq); 00529 } 00530 00531 /// hasExtraDefRegAllocReq - Returns true if this instruction def operands 00532 /// have special register allocation requirements that are not captured by the 00533 /// operand register classes. e.g. ARM::LDRD's two def registers must be an 00534 /// even / odd pair, ARM::LDM registers have to be in ascending order. 00535 /// Post-register allocation passes should not attempt to change allocations 00536 /// for definitions of instructions with this flag. 00537 bool hasExtraDefRegAllocReq() const { 00538 return Flags & (1 << MCID::ExtraDefRegAllocReq); 00539 } 00540 00541 00542 /// getImplicitUses - Return a list of registers that are potentially 00543 /// read by any instance of this machine instruction. For example, on X86, 00544 /// the "adc" instruction adds two register operands and adds the carry bit in 00545 /// from the flags register. In this case, the instruction is marked as 00546 /// implicitly reading the flags. Likewise, the variable shift instruction on 00547 /// X86 is marked as implicitly reading the 'CL' register, which it always 00548 /// does. 00549 /// 00550 /// This method returns null if the instruction has no implicit uses. 00551 const uint16_t *getImplicitUses() const { 00552 return ImplicitUses; 00553 } 00554 00555 /// \brief Return the number of implicit uses this instruction has. 00556 unsigned getNumImplicitUses() const { 00557 if (!ImplicitUses) return 0; 00558 unsigned i = 0; 00559 for (; ImplicitUses[i]; ++i) /*empty*/; 00560 return i; 00561 } 00562 00563 /// getImplicitDefs - Return a list of registers that are potentially 00564 /// written by any instance of this machine instruction. For example, on X86, 00565 /// many instructions implicitly set the flags register. In this case, they 00566 /// are marked as setting the FLAGS. Likewise, many instructions always 00567 /// deposit their result in a physical register. For example, the X86 divide 00568 /// instruction always deposits the quotient and remainder in the EAX/EDX 00569 /// registers. For that instruction, this will return a list containing the 00570 /// EAX/EDX/EFLAGS registers. 00571 /// 00572 /// This method returns null if the instruction has no implicit defs. 00573 const uint16_t *getImplicitDefs() const { 00574 return ImplicitDefs; 00575 } 00576 00577 /// \brief Return the number of implicit defs this instruct has. 00578 unsigned getNumImplicitDefs() const { 00579 if (!ImplicitDefs) return 0; 00580 unsigned i = 0; 00581 for (; ImplicitDefs[i]; ++i) /*empty*/; 00582 return i; 00583 } 00584 00585 /// \brief Return true if this instruction implicitly 00586 /// uses the specified physical register. 00587 bool hasImplicitUseOfPhysReg(unsigned Reg) const { 00588 if (const uint16_t *ImpUses = ImplicitUses) 00589 for (; *ImpUses; ++ImpUses) 00590 if (*ImpUses == Reg) return true; 00591 return false; 00592 } 00593 00594 /// \brief Return true if this instruction implicitly 00595 /// defines the specified physical register. 00596 bool hasImplicitDefOfPhysReg(unsigned Reg, 00597 const MCRegisterInfo *MRI = nullptr) const { 00598 if (const uint16_t *ImpDefs = ImplicitDefs) 00599 for (; *ImpDefs; ++ImpDefs) 00600 if (*ImpDefs == Reg || (MRI && MRI->isSubRegister(Reg, *ImpDefs))) 00601 return true; 00602 return false; 00603 } 00604 00605 /// \brief Return true if this instruction defines the specified physical 00606 /// register, either explicitly or implicitly. 00607 bool hasDefOfPhysReg(const MCInst &MI, unsigned Reg, 00608 const MCRegisterInfo &RI) const { 00609 for (int i = 0, e = NumDefs; i != e; ++i) 00610 if (MI.getOperand(i).isReg() && 00611 RI.isSubRegisterEq(Reg, MI.getOperand(i).getReg())) 00612 return true; 00613 return hasImplicitDefOfPhysReg(Reg, &RI); 00614 } 00615 00616 /// \brief Return the scheduling class for this instruction. The 00617 /// scheduling class is an index into the InstrItineraryData table. This 00618 /// returns zero if there is no known scheduling information for the 00619 /// instruction. 00620 unsigned getSchedClass() const { 00621 return SchedClass; 00622 } 00623 00624 /// \brief Return the number of bytes in the encoding of this instruction, 00625 /// or zero if the encoding size cannot be known from the opcode. 00626 unsigned getSize() const { 00627 return Size; 00628 } 00629 00630 /// \brief Find the index of the first operand in the 00631 /// operand list that is used to represent the predicate. It returns -1 if 00632 /// none is found. 00633 int findFirstPredOperandIdx() const { 00634 if (isPredicable()) { 00635 for (unsigned i = 0, e = getNumOperands(); i != e; ++i) 00636 if (OpInfo[i].isPredicate()) 00637 return i; 00638 } 00639 return -1; 00640 } 00641 }; 00642 00643 } // end namespace llvm 00644 00645 #endif