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