MCInstrDesc.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. //===-- llvm/MC/MCInstrDesc.h - Instruction Descriptors -*- C++ -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // This file defines the MCOperandInfo and MCInstrDesc classes, which
  11. // are used to describe target instructions and their operands.
  12. //
  13. //===----------------------------------------------------------------------===//
  14. #ifndef LLVM_MC_MCINSTRDESC_H
  15. #define LLVM_MC_MCINSTRDESC_H
  16. #include "llvm/Support/DataTypes.h"
  17. #include <string>
  18. namespace llvm {
  19. class MCInst;
  20. class MCRegisterInfo;
  21. class MCSubtargetInfo;
  22. class FeatureBitset;
  23. //===----------------------------------------------------------------------===//
  24. // Machine Operand Flags and Description
  25. //===----------------------------------------------------------------------===//
  26. namespace MCOI {
  27. // Operand constraints
  28. enum OperandConstraint {
  29. TIED_TO = 0, // Must be allocated the same register as.
  30. EARLY_CLOBBER // Operand is an early clobber register operand
  31. };
  32. /// \brief These are flags set on operands, but should be considered
  33. /// private, all access should go through the MCOperandInfo accessors.
  34. /// See the accessors for a description of what these are.
  35. enum OperandFlags { LookupPtrRegClass = 0, Predicate, OptionalDef };
  36. /// \brief Operands are tagged with one of the values of this enum.
  37. enum OperandType {
  38. OPERAND_UNKNOWN = 0,
  39. OPERAND_IMMEDIATE = 1,
  40. OPERAND_REGISTER = 2,
  41. OPERAND_MEMORY = 3,
  42. OPERAND_PCREL = 4,
  43. OPERAND_FIRST_TARGET = 5
  44. };
  45. }
  46. /// \brief This holds information about one operand of a machine instruction,
  47. /// indicating the register class for register operands, etc.
  48. class MCOperandInfo {
  49. public:
  50. /// \brief This specifies the register class enumeration of the operand
  51. /// if the operand is a register. If isLookupPtrRegClass is set, then this is
  52. /// an index that is passed to TargetRegisterInfo::getPointerRegClass(x) to
  53. /// get a dynamic register class.
  54. int16_t RegClass;
  55. /// \brief These are flags from the MCOI::OperandFlags enum.
  56. uint8_t Flags;
  57. /// \brief Information about the type of the operand.
  58. uint8_t OperandType;
  59. /// \brief The lower 16 bits are used to specify which constraints are set.
  60. /// The higher 16 bits are used to specify the value of constraints (4 bits
  61. /// each).
  62. uint32_t Constraints;
  63. /// \brief Set if this operand is a pointer value and it requires a callback
  64. /// to look up its register class.
  65. bool isLookupPtrRegClass() const {
  66. return Flags & (1 << MCOI::LookupPtrRegClass);
  67. }
  68. /// \brief Set if this is one of the operands that made up of the predicate
  69. /// operand that controls an isPredicable() instruction.
  70. bool isPredicate() const { return Flags & (1 << MCOI::Predicate); }
  71. /// \brief Set if this operand is a optional def.
  72. bool isOptionalDef() const { return Flags & (1 << MCOI::OptionalDef); }
  73. };
  74. //===----------------------------------------------------------------------===//
  75. // Machine Instruction Flags and Description
  76. // //
  77. ///////////////////////////////////////////////////////////////////////////////
  78. namespace MCID {
  79. /// \brief These should be considered private to the implementation of the
  80. /// MCInstrDesc class. Clients should use the predicate methods on MCInstrDesc,
  81. /// not use these directly. These all correspond to bitfields in the
  82. /// MCInstrDesc::Flags field.
  83. enum Flag {
  84. Variadic = 0,
  85. HasOptionalDef,
  86. Pseudo,
  87. Return,
  88. Call,
  89. Barrier,
  90. Terminator,
  91. Branch,
  92. IndirectBranch,
  93. Compare,
  94. MoveImm,
  95. Bitcast,
  96. Select,
  97. DelaySlot,
  98. FoldableAsLoad,
  99. MayLoad,
  100. MayStore,
  101. Predicable,
  102. NotDuplicable,
  103. UnmodeledSideEffects,
  104. Commutable,
  105. ConvertibleTo3Addr,
  106. UsesCustomInserter,
  107. HasPostISelHook,
  108. Rematerializable,
  109. CheapAsAMove,
  110. ExtraSrcRegAllocReq,
  111. ExtraDefRegAllocReq,
  112. RegSequence,
  113. ExtractSubreg,
  114. InsertSubreg,
  115. Convergent
  116. };
  117. }
  118. /// \brief Describe properties that are true of each instruction in the target
  119. /// description file. This captures information about side effects, register
  120. /// use and many other things. There is one instance of this struct for each
  121. /// target instruction class, and the MachineInstr class points to this struct
  122. /// directly to describe itself.
  123. class MCInstrDesc {
  124. public:
  125. unsigned short Opcode; // The opcode number
  126. unsigned short NumOperands; // Num of args (may be more if variable_ops)
  127. unsigned char NumDefs; // Num of args that are definitions
  128. unsigned char Size; // Number of bytes in encoding.
  129. unsigned short SchedClass; // enum identifying instr sched class
  130. uint64_t Flags; // Flags identifying machine instr class
  131. uint64_t TSFlags; // Target Specific Flag values
  132. const uint16_t *ImplicitUses; // Registers implicitly read by this instr
  133. const uint16_t *ImplicitDefs; // Registers implicitly defined by this instr
  134. const MCOperandInfo *OpInfo; // 'NumOperands' entries about operands
  135. // Subtarget feature that this is deprecated on, if any
  136. // -1 implies this is not deprecated by any single feature. It may still be
  137. // deprecated due to a "complex" reason, below.
  138. int64_t DeprecatedFeature;
  139. // A complex method to determine is a certain is deprecated or not, and return
  140. // the reason for deprecation.
  141. bool (*ComplexDeprecationInfo)(MCInst &, const MCSubtargetInfo &,
  142. std::string &);
  143. /// \brief Returns the value of the specific constraint if
  144. /// it is set. Returns -1 if it is not set.
  145. int getOperandConstraint(unsigned OpNum,
  146. MCOI::OperandConstraint Constraint) const {
  147. if (OpNum < NumOperands &&
  148. (OpInfo[OpNum].Constraints & (1 << Constraint))) {
  149. unsigned Pos = 16 + Constraint * 4;
  150. return (int)(OpInfo[OpNum].Constraints >> Pos) & 0xf;
  151. }
  152. return -1;
  153. }
  154. /// \brief Returns true if a certain instruction is deprecated and if so
  155. /// returns the reason in \p Info.
  156. bool getDeprecatedInfo(MCInst &MI, const MCSubtargetInfo &STI,
  157. std::string &Info) const;
  158. /// \brief Return the opcode number for this descriptor.
  159. unsigned getOpcode() const { return Opcode; }
  160. /// \brief Return the number of declared MachineOperands for this
  161. /// MachineInstruction. Note that variadic (isVariadic() returns true)
  162. /// instructions may have additional operands at the end of the list, and note
  163. /// that the machine instruction may include implicit register def/uses as
  164. /// well.
  165. unsigned getNumOperands() const { return NumOperands; }
  166. /// \brief Return the number of MachineOperands that are register
  167. /// definitions. Register definitions always occur at the start of the
  168. /// machine operand list. This is the number of "outs" in the .td file,
  169. /// and does not include implicit defs.
  170. unsigned getNumDefs() const { return NumDefs; }
  171. /// \brief Return flags of this instruction.
  172. unsigned getFlags() const { return Flags; }
  173. /// \brief Return true if this instruction can have a variable number of
  174. /// operands. In this case, the variable operands will be after the normal
  175. /// operands but before the implicit definitions and uses (if any are
  176. /// present).
  177. bool isVariadic() const { return Flags & (1 << MCID::Variadic); }
  178. /// \brief Set if this instruction has an optional definition, e.g.
  179. /// ARM instructions which can set condition code if 's' bit is set.
  180. bool hasOptionalDef() const { return Flags & (1 << MCID::HasOptionalDef); }
  181. /// \brief Return true if this is a pseudo instruction that doesn't
  182. /// correspond to a real machine instruction.
  183. bool isPseudo() const { return Flags & (1 << MCID::Pseudo); }
  184. /// \brief Return true if the instruction is a return.
  185. bool isReturn() const { return Flags & (1 << MCID::Return); }
  186. /// \brief Return true if the instruction is a call.
  187. bool isCall() const { return Flags & (1 << MCID::Call); }
  188. /// \brief Returns true if the specified instruction stops control flow
  189. /// from executing the instruction immediately following it. Examples include
  190. /// unconditional branches and return instructions.
  191. bool isBarrier() const { return Flags & (1 << MCID::Barrier); }
  192. /// \brief Returns true if this instruction part of the terminator for
  193. /// a basic block. Typically this is things like return and branch
  194. /// instructions.
  195. ///
  196. /// Various passes use this to insert code into the bottom of a basic block,
  197. /// but before control flow occurs.
  198. bool isTerminator() const { return Flags & (1 << MCID::Terminator); }
  199. /// \brief Returns true if this is a conditional, unconditional, or
  200. /// indirect branch. Predicates below can be used to discriminate between
  201. /// these cases, and the TargetInstrInfo::AnalyzeBranch method can be used to
  202. /// get more information.
  203. bool isBranch() const { return Flags & (1 << MCID::Branch); }
  204. /// \brief Return true if this is an indirect branch, such as a
  205. /// branch through a register.
  206. bool isIndirectBranch() const { return Flags & (1 << MCID::IndirectBranch); }
  207. /// \brief Return true if this is a branch which may fall
  208. /// through to the next instruction or may transfer control flow to some other
  209. /// block. The TargetInstrInfo::AnalyzeBranch method can be used to get more
  210. /// information about this branch.
  211. bool isConditionalBranch() const {
  212. return isBranch() & !isBarrier() & !isIndirectBranch();
  213. }
  214. /// \brief Return true if this is a branch which always
  215. /// transfers control flow to some other block. The
  216. /// TargetInstrInfo::AnalyzeBranch method can be used to get more information
  217. /// about this branch.
  218. bool isUnconditionalBranch() const {
  219. return isBranch() & isBarrier() & !isIndirectBranch();
  220. }
  221. /// \brief Return true if this is a branch or an instruction which directly
  222. /// writes to the program counter. Considered 'may' affect rather than
  223. /// 'does' affect as things like predication are not taken into account.
  224. bool mayAffectControlFlow(const MCInst &MI, const MCRegisterInfo &RI) const;
  225. /// \brief Return true if this instruction has a predicate operand
  226. /// that controls execution. It may be set to 'always', or may be set to other
  227. /// values. There are various methods in TargetInstrInfo that can be used to
  228. /// control and modify the predicate in this instruction.
  229. bool isPredicable() const { return Flags & (1 << MCID::Predicable); }
  230. /// \brief Return true if this instruction is a comparison.
  231. bool isCompare() const { return Flags & (1 << MCID::Compare); }
  232. /// \brief Return true if this instruction is a move immediate
  233. /// (including conditional moves) instruction.
  234. bool isMoveImmediate() const { return Flags & (1 << MCID::MoveImm); }
  235. /// \brief Return true if this instruction is a bitcast instruction.
  236. bool isBitcast() const { return Flags & (1 << MCID::Bitcast); }
  237. /// \brief Return true if this is a select instruction.
  238. bool isSelect() const { return Flags & (1 << MCID::Select); }
  239. /// \brief Return true if this instruction cannot be safely
  240. /// duplicated. For example, if the instruction has a unique labels attached
  241. /// to it, duplicating it would cause multiple definition errors.
  242. bool isNotDuplicable() const { return Flags & (1 << MCID::NotDuplicable); }
  243. /// \brief Returns true if the specified instruction has a delay slot which
  244. /// must be filled by the code generator.
  245. bool hasDelaySlot() const { return Flags & (1 << MCID::DelaySlot); }
  246. /// \brief Return true for instructions that can be folded as memory operands
  247. /// in other instructions. The most common use for this is instructions that
  248. /// are simple loads from memory that don't modify the loaded value in any
  249. /// way, but it can also be used for instructions that can be expressed as
  250. /// constant-pool loads, such as V_SETALLONES on x86, to allow them to be
  251. /// folded when it is beneficial. This should only be set on instructions
  252. /// that return a value in their only virtual register definition.
  253. bool canFoldAsLoad() const { return Flags & (1 << MCID::FoldableAsLoad); }
  254. /// \brief Return true if this instruction behaves
  255. /// the same way as the generic REG_SEQUENCE instructions.
  256. /// E.g., on ARM,
  257. /// dX VMOVDRR rY, rZ
  258. /// is equivalent to
  259. /// dX = REG_SEQUENCE rY, ssub_0, rZ, ssub_1.
  260. ///
  261. /// Note that for the optimizers to be able to take advantage of
  262. /// this property, TargetInstrInfo::getRegSequenceLikeInputs has to be
  263. /// override accordingly.
  264. bool isRegSequenceLike() const { return Flags & (1 << MCID::RegSequence); }
  265. /// \brief Return true if this instruction behaves
  266. /// the same way as the generic EXTRACT_SUBREG instructions.
  267. /// E.g., on ARM,
  268. /// rX, rY VMOVRRD dZ
  269. /// is equivalent to two EXTRACT_SUBREG:
  270. /// rX = EXTRACT_SUBREG dZ, ssub_0
  271. /// rY = EXTRACT_SUBREG dZ, ssub_1
  272. ///
  273. /// Note that for the optimizers to be able to take advantage of
  274. /// this property, TargetInstrInfo::getExtractSubregLikeInputs has to be
  275. /// override accordingly.
  276. bool isExtractSubregLike() const {
  277. return Flags & (1 << MCID::ExtractSubreg);
  278. }
  279. /// \brief Return true if this instruction behaves
  280. /// the same way as the generic INSERT_SUBREG instructions.
  281. /// E.g., on ARM,
  282. /// dX = VSETLNi32 dY, rZ, Imm
  283. /// is equivalent to a INSERT_SUBREG:
  284. /// dX = INSERT_SUBREG dY, rZ, translateImmToSubIdx(Imm)
  285. ///
  286. /// Note that for the optimizers to be able to take advantage of
  287. /// this property, TargetInstrInfo::getInsertSubregLikeInputs has to be
  288. /// override accordingly.
  289. bool isInsertSubregLike() const { return Flags & (1 << MCID::InsertSubreg); }
  290. /// \brief Return true if this instruction is convergent.
  291. ///
  292. /// Convergent instructions may only be moved to locations that are
  293. /// control-equivalent to their original positions.
  294. bool isConvergent() const { return Flags & (1 << MCID::Convergent); }
  295. //===--------------------------------------------------------------------===//
  296. // Side Effect Analysis
  297. //===--------------------------------------------------------------------===//
  298. /// \brief Return true if this instruction could possibly read memory.
  299. /// Instructions with this flag set are not necessarily simple load
  300. /// instructions, they may load a value and modify it, for example.
  301. bool mayLoad() const { return Flags & (1 << MCID::MayLoad); }
  302. /// \brief Return true if this instruction could possibly modify memory.
  303. /// Instructions with this flag set are not necessarily simple store
  304. /// instructions, they may store a modified value based on their operands, or
  305. /// may not actually modify anything, for example.
  306. bool mayStore() const { return Flags & (1 << MCID::MayStore); }
  307. /// \brief Return true if this instruction has side
  308. /// effects that are not modeled by other flags. This does not return true
  309. /// for instructions whose effects are captured by:
  310. ///
  311. /// 1. Their operand list and implicit definition/use list. Register use/def
  312. /// info is explicit for instructions.
  313. /// 2. Memory accesses. Use mayLoad/mayStore.
  314. /// 3. Calling, branching, returning: use isCall/isReturn/isBranch.
  315. ///
  316. /// Examples of side effects would be modifying 'invisible' machine state like
  317. /// a control register, flushing a cache, modifying a register invisible to
  318. /// LLVM, etc.
  319. bool hasUnmodeledSideEffects() const {
  320. return Flags & (1 << MCID::UnmodeledSideEffects);
  321. }
  322. //===--------------------------------------------------------------------===//
  323. // Flags that indicate whether an instruction can be modified by a method.
  324. //===--------------------------------------------------------------------===//
  325. /// \brief Return true if this may be a 2- or 3-address instruction (of the
  326. /// form "X = op Y, Z, ..."), which produces the same result if Y and Z are
  327. /// exchanged. If this flag is set, then the
  328. /// TargetInstrInfo::commuteInstruction method may be used to hack on the
  329. /// instruction.
  330. ///
  331. /// Note that this flag may be set on instructions that are only commutable
  332. /// sometimes. In these cases, the call to commuteInstruction will fail.
  333. /// Also note that some instructions require non-trivial modification to
  334. /// commute them.
  335. bool isCommutable() const { return Flags & (1 << MCID::Commutable); }
  336. /// \brief Return true if this is a 2-address instruction which can be changed
  337. /// into a 3-address instruction if needed. Doing this transformation can be
  338. /// profitable in the register allocator, because it means that the
  339. /// instruction can use a 2-address form if possible, but degrade into a less
  340. /// efficient form if the source and dest register cannot be assigned to the
  341. /// same register. For example, this allows the x86 backend to turn a "shl
  342. /// reg, 3" instruction into an LEA instruction, which is the same speed as
  343. /// the shift but has bigger code size.
  344. ///
  345. /// If this returns true, then the target must implement the
  346. /// TargetInstrInfo::convertToThreeAddress method for this instruction, which
  347. /// is allowed to fail if the transformation isn't valid for this specific
  348. /// instruction (e.g. shl reg, 4 on x86).
  349. ///
  350. bool isConvertibleTo3Addr() const {
  351. return Flags & (1 << MCID::ConvertibleTo3Addr);
  352. }
  353. /// \brief Return true if this instruction requires custom insertion support
  354. /// when the DAG scheduler is inserting it into a machine basic block. If
  355. /// this is true for the instruction, it basically means that it is a pseudo
  356. /// instruction used at SelectionDAG time that is expanded out into magic code
  357. /// by the target when MachineInstrs are formed.
  358. ///
  359. /// If this is true, the TargetLoweringInfo::InsertAtEndOfBasicBlock method
  360. /// is used to insert this into the MachineBasicBlock.
  361. bool usesCustomInsertionHook() const {
  362. return Flags & (1 << MCID::UsesCustomInserter);
  363. }
  364. /// \brief Return true if this instruction requires *adjustment* after
  365. /// instruction selection by calling a target hook. For example, this can be
  366. /// used to fill in ARM 's' optional operand depending on whether the
  367. /// conditional flag register is used.
  368. bool hasPostISelHook() const { return Flags & (1 << MCID::HasPostISelHook); }
  369. /// \brief Returns true if this instruction is a candidate for remat. This
  370. /// flag is only used in TargetInstrInfo method isTriviallyRematerializable.
  371. ///
  372. /// If this flag is set, the isReallyTriviallyReMaterializable()
  373. /// or isReallyTriviallyReMaterializableGeneric methods are called to verify
  374. /// the instruction is really rematable.
  375. bool isRematerializable() const {
  376. return Flags & (1 << MCID::Rematerializable);
  377. }
  378. /// \brief Returns true if this instruction has the same cost (or less) than a
  379. /// move instruction. This is useful during certain types of optimizations
  380. /// (e.g., remat during two-address conversion or machine licm) where we would
  381. /// like to remat or hoist the instruction, but not if it costs more than
  382. /// moving the instruction into the appropriate register. Note, we are not
  383. /// marking copies from and to the same register class with this flag.
  384. ///
  385. /// This method could be called by interface TargetInstrInfo::isAsCheapAsAMove
  386. /// for different subtargets.
  387. bool isAsCheapAsAMove() const { return Flags & (1 << MCID::CheapAsAMove); }
  388. /// \brief Returns true if this instruction source operands have special
  389. /// register allocation requirements that are not captured by the operand
  390. /// register classes. e.g. ARM::STRD's two source registers must be an even /
  391. /// odd pair, ARM::STM registers have to be in ascending order. Post-register
  392. /// allocation passes should not attempt to change allocations for sources of
  393. /// instructions with this flag.
  394. bool hasExtraSrcRegAllocReq() const {
  395. return Flags & (1 << MCID::ExtraSrcRegAllocReq);
  396. }
  397. /// \brief Returns true if this instruction def operands have special register
  398. /// allocation requirements that are not captured by the operand register
  399. /// classes. e.g. ARM::LDRD's two def registers must be an even / odd pair,
  400. /// ARM::LDM registers have to be in ascending order. Post-register
  401. /// allocation passes should not attempt to change allocations for definitions
  402. /// of instructions with this flag.
  403. bool hasExtraDefRegAllocReq() const {
  404. return Flags & (1 << MCID::ExtraDefRegAllocReq);
  405. }
  406. /// \brief Return a list of registers that are potentially read by any
  407. /// instance of this machine instruction. For example, on X86, the "adc"
  408. /// instruction adds two register operands and adds the carry bit in from the
  409. /// flags register. In this case, the instruction is marked as implicitly
  410. /// reading the flags. Likewise, the variable shift instruction on X86 is
  411. /// marked as implicitly reading the 'CL' register, which it always does.
  412. ///
  413. /// This method returns null if the instruction has no implicit uses.
  414. const uint16_t *getImplicitUses() const { return ImplicitUses; }
  415. /// \brief Return the number of implicit uses this instruction has.
  416. unsigned getNumImplicitUses() const {
  417. if (!ImplicitUses)
  418. return 0;
  419. unsigned i = 0;
  420. for (; ImplicitUses[i]; ++i) /*empty*/
  421. ;
  422. return i;
  423. }
  424. /// \brief Return a list of registers that are potentially written by any
  425. /// instance of this machine instruction. For example, on X86, many
  426. /// instructions implicitly set the flags register. In this case, they are
  427. /// marked as setting the FLAGS. Likewise, many instructions always deposit
  428. /// their result in a physical register. For example, the X86 divide
  429. /// instruction always deposits the quotient and remainder in the EAX/EDX
  430. /// registers. For that instruction, this will return a list containing the
  431. /// EAX/EDX/EFLAGS registers.
  432. ///
  433. /// This method returns null if the instruction has no implicit defs.
  434. const uint16_t *getImplicitDefs() const { return ImplicitDefs; }
  435. /// \brief Return the number of implicit defs this instruct has.
  436. unsigned getNumImplicitDefs() const {
  437. if (!ImplicitDefs)
  438. return 0;
  439. unsigned i = 0;
  440. for (; ImplicitDefs[i]; ++i) /*empty*/
  441. ;
  442. return i;
  443. }
  444. /// \brief Return true if this instruction implicitly
  445. /// uses the specified physical register.
  446. bool hasImplicitUseOfPhysReg(unsigned Reg) const {
  447. if (const uint16_t *ImpUses = ImplicitUses)
  448. for (; *ImpUses; ++ImpUses)
  449. if (*ImpUses == Reg)
  450. return true;
  451. return false;
  452. }
  453. /// \brief Return true if this instruction implicitly
  454. /// defines the specified physical register.
  455. bool hasImplicitDefOfPhysReg(unsigned Reg,
  456. const MCRegisterInfo *MRI = nullptr) const;
  457. /// \brief Return the scheduling class for this instruction. The
  458. /// scheduling class is an index into the InstrItineraryData table. This
  459. /// returns zero if there is no known scheduling information for the
  460. /// instruction.
  461. unsigned getSchedClass() const { return SchedClass; }
  462. /// \brief Return the number of bytes in the encoding of this instruction,
  463. /// or zero if the encoding size cannot be known from the opcode.
  464. unsigned getSize() const { return Size; }
  465. /// \brief Find the index of the first operand in the
  466. /// operand list that is used to represent the predicate. It returns -1 if
  467. /// none is found.
  468. int findFirstPredOperandIdx() const {
  469. if (isPredicable()) {
  470. for (unsigned i = 0, e = getNumOperands(); i != e; ++i)
  471. if (OpInfo[i].isPredicate())
  472. return i;
  473. }
  474. return -1;
  475. }
  476. private:
  477. /// \brief Return true if this instruction defines the specified physical
  478. /// register, either explicitly or implicitly.
  479. bool hasDefOfPhysReg(const MCInst &MI, unsigned Reg,
  480. const MCRegisterInfo &RI) const;
  481. };
  482. } // end namespace llvm
  483. #endif