move target-independent opcodes out of TargetInstrInfo
[oota-llvm.git] / include / llvm / Target / TargetInstrInfo.h
1 //===-- llvm/Target/TargetInstrInfo.h - Instruction Info --------*- 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 describes the target machine instruction set to the code generator.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_TARGET_TARGETINSTRINFO_H
15 #define LLVM_TARGET_TARGETINSTRINFO_H
16
17 #include "llvm/Target/TargetInstrDesc.h"
18 #include "llvm/CodeGen/MachineFunction.h"
19
20 namespace llvm {
21
22 class MCAsmInfo;
23 class TargetRegisterClass;
24 class TargetRegisterInfo;
25 class LiveVariables;
26 class CalleeSavedInfo;
27 class SDNode;
28 class SelectionDAG;
29 class MachineMemOperand;
30
31 template<class T> class SmallVectorImpl;
32
33
34 //---------------------------------------------------------------------------
35 ///
36 /// TargetInstrInfo - Interface to description of machine instruction set
37 ///
38 class TargetInstrInfo {
39   const TargetInstrDesc *Descriptors; // Raw array to allow static init'n
40   unsigned NumOpcodes;                // Number of entries in the desc array
41
42   TargetInstrInfo(const TargetInstrInfo &);  // DO NOT IMPLEMENT
43   void operator=(const TargetInstrInfo &);   // DO NOT IMPLEMENT
44 public:
45   TargetInstrInfo(const TargetInstrDesc *desc, unsigned NumOpcodes);
46   virtual ~TargetInstrInfo();
47
48   unsigned getNumOpcodes() const { return NumOpcodes; }
49
50   /// get - Return the machine instruction descriptor that corresponds to the
51   /// specified instruction opcode.
52   ///
53   const TargetInstrDesc &get(unsigned Opcode) const {
54     assert(Opcode < NumOpcodes && "Invalid opcode!");
55     return Descriptors[Opcode];
56   }
57
58   /// isTriviallyReMaterializable - Return true if the instruction is trivially
59   /// rematerializable, meaning it has no side effects and requires no operands
60   /// that aren't always available.
61   bool isTriviallyReMaterializable(const MachineInstr *MI,
62                                    AliasAnalysis *AA = 0) const {
63     return MI->getOpcode() == TargetOpcode::IMPLICIT_DEF ||
64            (MI->getDesc().isRematerializable() &&
65             (isReallyTriviallyReMaterializable(MI, AA) ||
66              isReallyTriviallyReMaterializableGeneric(MI, AA)));
67   }
68
69 protected:
70   /// isReallyTriviallyReMaterializable - For instructions with opcodes for
71   /// which the M_REMATERIALIZABLE flag is set, this hook lets the target
72   /// specify whether the instruction is actually trivially rematerializable,
73   /// taking into consideration its operands. This predicate must return false
74   /// if the instruction has any side effects other than producing a value, or
75   /// if it requres any address registers that are not always available.
76   virtual bool isReallyTriviallyReMaterializable(const MachineInstr *MI,
77                                                  AliasAnalysis *AA) const {
78     return false;
79   }
80
81 private:
82   /// isReallyTriviallyReMaterializableGeneric - For instructions with opcodes
83   /// for which the M_REMATERIALIZABLE flag is set and the target hook
84   /// isReallyTriviallyReMaterializable returns false, this function does
85   /// target-independent tests to determine if the instruction is really
86   /// trivially rematerializable.
87   bool isReallyTriviallyReMaterializableGeneric(const MachineInstr *MI,
88                                                 AliasAnalysis *AA) const;
89
90 public:
91   /// isMoveInstr - Return true if the instruction is a register to register
92   /// move and return the source and dest operands and their sub-register
93   /// indices by reference.
94   virtual bool isMoveInstr(const MachineInstr& MI,
95                            unsigned& SrcReg, unsigned& DstReg,
96                            unsigned& SrcSubIdx, unsigned& DstSubIdx) const {
97     return false;
98   }
99
100   /// isCoalescableExtInstr - Return true if the instruction is a "coalescable"
101   /// extension instruction. That is, it's like a copy where it's legal for the
102   /// source to overlap the destination. e.g. X86::MOVSX64rr32. If this returns
103   /// true, then it's expected the pre-extension value is available as a subreg
104   /// of the result register. This also returns the sub-register index in
105   /// SubIdx.
106   virtual bool isCoalescableExtInstr(const MachineInstr &MI,
107                                      unsigned &SrcReg, unsigned &DstReg,
108                                      unsigned &SubIdx) const {
109     return false;
110   }
111
112   /// isIdentityCopy - Return true if the instruction is a copy (or
113   /// extract_subreg, insert_subreg, subreg_to_reg) where the source and
114   /// destination registers are the same.
115   bool isIdentityCopy(const MachineInstr &MI) const {
116     unsigned SrcReg, DstReg, SrcSubIdx, DstSubIdx;
117     if (isMoveInstr(MI, SrcReg, DstReg, SrcSubIdx, DstSubIdx) &&
118         SrcReg == DstReg)
119       return true;
120
121     if (MI.getOpcode() == TargetOpcode::EXTRACT_SUBREG &&
122         MI.getOperand(0).getReg() == MI.getOperand(1).getReg())
123     return true;
124
125     if ((MI.getOpcode() == TargetOpcode::INSERT_SUBREG ||
126          MI.getOpcode() == TargetOpcode::SUBREG_TO_REG) &&
127         MI.getOperand(0).getReg() == MI.getOperand(2).getReg())
128       return true;
129     return false;
130   }
131   
132   /// isLoadFromStackSlot - If the specified machine instruction is a direct
133   /// load from a stack slot, return the virtual or physical register number of
134   /// the destination along with the FrameIndex of the loaded stack slot.  If
135   /// not, return 0.  This predicate must return 0 if the instruction has
136   /// any side effects other than loading from the stack slot.
137   virtual unsigned isLoadFromStackSlot(const MachineInstr *MI,
138                                        int &FrameIndex) const {
139     return 0;
140   }
141
142   /// isLoadFromStackSlotPostFE - Check for post-frame ptr elimination
143   /// stack locations as well.  This uses a heuristic so it isn't
144   /// reliable for correctness.
145   virtual unsigned isLoadFromStackSlotPostFE(const MachineInstr *MI,
146                                              int &FrameIndex) const {
147     return 0;
148   }
149
150   /// hasLoadFromStackSlot - If the specified machine instruction has
151   /// a load from a stack slot, return true along with the FrameIndex
152   /// of the loaded stack slot and the machine mem operand containing
153   /// the reference.  If not, return false.  Unlike
154   /// isLoadFromStackSlot, this returns true for any instructions that
155   /// loads from the stack.  This is just a hint, as some cases may be
156   /// missed.
157   virtual bool hasLoadFromStackSlot(const MachineInstr *MI,
158                                     const MachineMemOperand *&MMO,
159                                     int &FrameIndex) const {
160     return 0;
161   }
162   
163   /// isStoreToStackSlot - If the specified machine instruction is a direct
164   /// store to a stack slot, return the virtual or physical register number of
165   /// the source reg along with the FrameIndex of the loaded stack slot.  If
166   /// not, return 0.  This predicate must return 0 if the instruction has
167   /// any side effects other than storing to the stack slot.
168   virtual unsigned isStoreToStackSlot(const MachineInstr *MI,
169                                       int &FrameIndex) const {
170     return 0;
171   }
172
173   /// isStoreToStackSlotPostFE - Check for post-frame ptr elimination
174   /// stack locations as well.  This uses a heuristic so it isn't
175   /// reliable for correctness.
176   virtual unsigned isStoreToStackSlotPostFE(const MachineInstr *MI,
177                                             int &FrameIndex) const {
178     return 0;
179   }
180
181   /// hasStoreToStackSlot - If the specified machine instruction has a
182   /// store to a stack slot, return true along with the FrameIndex of
183   /// the loaded stack slot and the machine mem operand containing the
184   /// reference.  If not, return false.  Unlike isStoreToStackSlot,
185   /// this returns true for any instructions that loads from the
186   /// stack.  This is just a hint, as some cases may be missed.
187   virtual bool hasStoreToStackSlot(const MachineInstr *MI,
188                                    const MachineMemOperand *&MMO,
189                                    int &FrameIndex) const {
190     return 0;
191   }
192
193   /// reMaterialize - Re-issue the specified 'original' instruction at the
194   /// specific location targeting a new destination register.
195   virtual void reMaterialize(MachineBasicBlock &MBB,
196                              MachineBasicBlock::iterator MI,
197                              unsigned DestReg, unsigned SubIdx,
198                              const MachineInstr *Orig,
199                              const TargetRegisterInfo *TRI) const = 0;
200
201   /// duplicate - Create a duplicate of the Orig instruction in MF. This is like
202   /// MachineFunction::CloneMachineInstr(), but the target may update operands
203   /// that are required to be unique.
204   ///
205   /// The instruction must be duplicable as indicated by isNotDuplicable().
206   virtual MachineInstr *duplicate(MachineInstr *Orig,
207                                   MachineFunction &MF) const = 0;
208
209   /// convertToThreeAddress - This method must be implemented by targets that
210   /// set the M_CONVERTIBLE_TO_3_ADDR flag.  When this flag is set, the target
211   /// may be able to convert a two-address instruction into one or more true
212   /// three-address instructions on demand.  This allows the X86 target (for
213   /// example) to convert ADD and SHL instructions into LEA instructions if they
214   /// would require register copies due to two-addressness.
215   ///
216   /// This method returns a null pointer if the transformation cannot be
217   /// performed, otherwise it returns the last new instruction.
218   ///
219   virtual MachineInstr *
220   convertToThreeAddress(MachineFunction::iterator &MFI,
221                    MachineBasicBlock::iterator &MBBI, LiveVariables *LV) const {
222     return 0;
223   }
224
225   /// commuteInstruction - If a target has any instructions that are commutable,
226   /// but require converting to a different instruction or making non-trivial
227   /// changes to commute them, this method can overloaded to do this.  The
228   /// default implementation of this method simply swaps the first two operands
229   /// of MI and returns it.
230   ///
231   /// If a target wants to make more aggressive changes, they can construct and
232   /// return a new machine instruction.  If an instruction cannot commute, it
233   /// can also return null.
234   ///
235   /// If NewMI is true, then a new machine instruction must be created.
236   ///
237   virtual MachineInstr *commuteInstruction(MachineInstr *MI,
238                                            bool NewMI = false) const = 0;
239
240   /// findCommutedOpIndices - If specified MI is commutable, return the two
241   /// operand indices that would swap value. Return true if the instruction
242   /// is not in a form which this routine understands.
243   virtual bool findCommutedOpIndices(MachineInstr *MI, unsigned &SrcOpIdx1,
244                                      unsigned &SrcOpIdx2) const = 0;
245
246   /// isIdentical - Return true if two instructions are identical. This differs
247   /// from MachineInstr::isIdenticalTo() in that it does not require the
248   /// virtual destination registers to be the same. This is used by MachineLICM
249   /// and other MI passes to perform CSE.
250   virtual bool isIdentical(const MachineInstr *MI,
251                            const MachineInstr *Other,
252                            const MachineRegisterInfo *MRI) const = 0;
253
254   /// AnalyzeBranch - Analyze the branching code at the end of MBB, returning
255   /// true if it cannot be understood (e.g. it's a switch dispatch or isn't
256   /// implemented for a target).  Upon success, this returns false and returns
257   /// with the following information in various cases:
258   ///
259   /// 1. If this block ends with no branches (it just falls through to its succ)
260   ///    just return false, leaving TBB/FBB null.
261   /// 2. If this block ends with only an unconditional branch, it sets TBB to be
262   ///    the destination block.
263   /// 3. If this block ends with a conditional branch and it falls through to a
264   ///    successor block, it sets TBB to be the branch destination block and a
265   ///    list of operands that evaluate the condition. These operands can be
266   ///    passed to other TargetInstrInfo methods to create new branches.
267   /// 4. If this block ends with a conditional branch followed by an
268   ///    unconditional branch, it returns the 'true' destination in TBB, the
269   ///    'false' destination in FBB, and a list of operands that evaluate the
270   ///    condition.  These operands can be passed to other TargetInstrInfo
271   ///    methods to create new branches.
272   ///
273   /// Note that RemoveBranch and InsertBranch must be implemented to support
274   /// cases where this method returns success.
275   ///
276   /// If AllowModify is true, then this routine is allowed to modify the basic
277   /// block (e.g. delete instructions after the unconditional branch).
278   ///
279   virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
280                              MachineBasicBlock *&FBB,
281                              SmallVectorImpl<MachineOperand> &Cond,
282                              bool AllowModify = false) const {
283     return true;
284   }
285
286   /// RemoveBranch - Remove the branching code at the end of the specific MBB.
287   /// This is only invoked in cases where AnalyzeBranch returns success. It
288   /// returns the number of instructions that were removed.
289   virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const {
290     assert(0 && "Target didn't implement TargetInstrInfo::RemoveBranch!"); 
291     return 0;
292   }
293
294   /// InsertBranch - Insert branch code into the end of the specified
295   /// MachineBasicBlock.  The operands to this method are the same as those
296   /// returned by AnalyzeBranch.  This is only invoked in cases where
297   /// AnalyzeBranch returns success. It returns the number of instructions
298   /// inserted.
299   ///
300   /// It is also invoked by tail merging to add unconditional branches in
301   /// cases where AnalyzeBranch doesn't apply because there was no original
302   /// branch to analyze.  At least this much must be implemented, else tail
303   /// merging needs to be disabled.
304   virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
305                             MachineBasicBlock *FBB,
306                             const SmallVectorImpl<MachineOperand> &Cond) const {
307     assert(0 && "Target didn't implement TargetInstrInfo::InsertBranch!"); 
308     return 0;
309   }
310   
311   /// copyRegToReg - Emit instructions to copy between a pair of registers. It
312   /// returns false if the target does not how to copy between the specified
313   /// registers.
314   virtual bool copyRegToReg(MachineBasicBlock &MBB,
315                             MachineBasicBlock::iterator MI,
316                             unsigned DestReg, unsigned SrcReg,
317                             const TargetRegisterClass *DestRC,
318                             const TargetRegisterClass *SrcRC) const {
319     assert(0 && "Target didn't implement TargetInstrInfo::copyRegToReg!");
320     return false;
321   }
322   
323   /// storeRegToStackSlot - Store the specified register of the given register
324   /// class to the specified stack frame index. The store instruction is to be
325   /// added to the given machine basic block before the specified machine
326   /// instruction. If isKill is true, the register operand is the last use and
327   /// must be marked kill.
328   virtual void storeRegToStackSlot(MachineBasicBlock &MBB,
329                                    MachineBasicBlock::iterator MI,
330                                    unsigned SrcReg, bool isKill, int FrameIndex,
331                                    const TargetRegisterClass *RC) const {
332     assert(0 && "Target didn't implement TargetInstrInfo::storeRegToStackSlot!");
333   }
334
335   /// loadRegFromStackSlot - Load the specified register of the given register
336   /// class from the specified stack frame index. The load instruction is to be
337   /// added to the given machine basic block before the specified machine
338   /// instruction.
339   virtual void loadRegFromStackSlot(MachineBasicBlock &MBB,
340                                     MachineBasicBlock::iterator MI,
341                                     unsigned DestReg, int FrameIndex,
342                                     const TargetRegisterClass *RC) const {
343     assert(0 && "Target didn't implement TargetInstrInfo::loadRegFromStackSlot!");
344   }
345   
346   /// spillCalleeSavedRegisters - Issues instruction(s) to spill all callee
347   /// saved registers and returns true if it isn't possible / profitable to do
348   /// so by issuing a series of store instructions via
349   /// storeRegToStackSlot(). Returns false otherwise.
350   virtual bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
351                                          MachineBasicBlock::iterator MI,
352                                 const std::vector<CalleeSavedInfo> &CSI) const {
353     return false;
354   }
355
356   /// restoreCalleeSavedRegisters - Issues instruction(s) to restore all callee
357   /// saved registers and returns true if it isn't possible / profitable to do
358   /// so by issuing a series of load instructions via loadRegToStackSlot().
359   /// Returns false otherwise.
360   virtual bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
361                                            MachineBasicBlock::iterator MI,
362                                 const std::vector<CalleeSavedInfo> &CSI) const {
363     return false;
364   }
365   
366   /// foldMemoryOperand - Attempt to fold a load or store of the specified stack
367   /// slot into the specified machine instruction for the specified operand(s).
368   /// If this is possible, a new instruction is returned with the specified
369   /// operand folded, otherwise NULL is returned. The client is responsible for
370   /// removing the old instruction and adding the new one in the instruction
371   /// stream.
372   MachineInstr* foldMemoryOperand(MachineFunction &MF,
373                                   MachineInstr* MI,
374                                   const SmallVectorImpl<unsigned> &Ops,
375                                   int FrameIndex) const;
376
377   /// foldMemoryOperand - Same as the previous version except it allows folding
378   /// of any load and store from / to any address, not just from a specific
379   /// stack slot.
380   MachineInstr* foldMemoryOperand(MachineFunction &MF,
381                                   MachineInstr* MI,
382                                   const SmallVectorImpl<unsigned> &Ops,
383                                   MachineInstr* LoadMI) const;
384
385 protected:
386   /// foldMemoryOperandImpl - Target-dependent implementation for
387   /// foldMemoryOperand. Target-independent code in foldMemoryOperand will
388   /// take care of adding a MachineMemOperand to the newly created instruction.
389   virtual MachineInstr* foldMemoryOperandImpl(MachineFunction &MF,
390                                           MachineInstr* MI,
391                                           const SmallVectorImpl<unsigned> &Ops,
392                                           int FrameIndex) const {
393     return 0;
394   }
395
396   /// foldMemoryOperandImpl - Target-dependent implementation for
397   /// foldMemoryOperand. Target-independent code in foldMemoryOperand will
398   /// take care of adding a MachineMemOperand to the newly created instruction.
399   virtual MachineInstr* foldMemoryOperandImpl(MachineFunction &MF,
400                                               MachineInstr* MI,
401                                               const SmallVectorImpl<unsigned> &Ops,
402                                               MachineInstr* LoadMI) const {
403     return 0;
404   }
405
406 public:
407   /// canFoldMemoryOperand - Returns true for the specified load / store if
408   /// folding is possible.
409   virtual
410   bool canFoldMemoryOperand(const MachineInstr *MI,
411                             const SmallVectorImpl<unsigned> &Ops) const {
412     return false;
413   }
414
415   /// unfoldMemoryOperand - Separate a single instruction which folded a load or
416   /// a store or a load and a store into two or more instruction. If this is
417   /// possible, returns true as well as the new instructions by reference.
418   virtual bool unfoldMemoryOperand(MachineFunction &MF, MachineInstr *MI,
419                                 unsigned Reg, bool UnfoldLoad, bool UnfoldStore,
420                                  SmallVectorImpl<MachineInstr*> &NewMIs) const{
421     return false;
422   }
423
424   virtual bool unfoldMemoryOperand(SelectionDAG &DAG, SDNode *N,
425                                    SmallVectorImpl<SDNode*> &NewNodes) const {
426     return false;
427   }
428
429   /// getOpcodeAfterMemoryUnfold - Returns the opcode of the would be new
430   /// instruction after load / store are unfolded from an instruction of the
431   /// specified opcode. It returns zero if the specified unfolding is not
432   /// possible. If LoadRegIndex is non-null, it is filled in with the operand
433   /// index of the operand which will hold the register holding the loaded
434   /// value.
435   virtual unsigned getOpcodeAfterMemoryUnfold(unsigned Opc,
436                                       bool UnfoldLoad, bool UnfoldStore,
437                                       unsigned *LoadRegIndex = 0) const {
438     return 0;
439   }
440
441   /// areLoadsFromSameBasePtr - This is used by the pre-regalloc scheduler
442   /// to determine if two loads are loading from the same base address. It
443   /// should only return true if the base pointers are the same and the
444   /// only differences between the two addresses are the offset. It also returns
445   /// the offsets by reference.
446   virtual bool areLoadsFromSameBasePtr(SDNode *Load1, SDNode *Load2,
447                                        int64_t &Offset1, int64_t &Offset2) const {
448     return false;
449   }
450
451   /// shouldScheduleLoadsNear - This is a used by the pre-regalloc scheduler to
452   /// determine (in conjuction with areLoadsFromSameBasePtr) if two loads should
453   /// be scheduled togther. On some targets if two loads are loading from
454   /// addresses in the same cache line, it's better if they are scheduled
455   /// together. This function takes two integers that represent the load offsets
456   /// from the common base address. It returns true if it decides it's desirable
457   /// to schedule the two loads together. "NumLoads" is the number of loads that
458   /// have already been scheduled after Load1.
459   virtual bool shouldScheduleLoadsNear(SDNode *Load1, SDNode *Load2,
460                                        int64_t Offset1, int64_t Offset2,
461                                        unsigned NumLoads) const {
462     return false;
463   }
464   
465   /// ReverseBranchCondition - Reverses the branch condition of the specified
466   /// condition list, returning false on success and true if it cannot be
467   /// reversed.
468   virtual
469   bool ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const {
470     return true;
471   }
472   
473   /// insertNoop - Insert a noop into the instruction stream at the specified
474   /// point.
475   virtual void insertNoop(MachineBasicBlock &MBB, 
476                           MachineBasicBlock::iterator MI) const;
477   
478   /// isPredicated - Returns true if the instruction is already predicated.
479   ///
480   virtual bool isPredicated(const MachineInstr *MI) const {
481     return false;
482   }
483
484   /// isUnpredicatedTerminator - Returns true if the instruction is a
485   /// terminator instruction that has not been predicated.
486   virtual bool isUnpredicatedTerminator(const MachineInstr *MI) const;
487
488   /// PredicateInstruction - Convert the instruction into a predicated
489   /// instruction. It returns true if the operation was successful.
490   virtual
491   bool PredicateInstruction(MachineInstr *MI,
492                         const SmallVectorImpl<MachineOperand> &Pred) const = 0;
493
494   /// SubsumesPredicate - Returns true if the first specified predicate
495   /// subsumes the second, e.g. GE subsumes GT.
496   virtual
497   bool SubsumesPredicate(const SmallVectorImpl<MachineOperand> &Pred1,
498                          const SmallVectorImpl<MachineOperand> &Pred2) const {
499     return false;
500   }
501
502   /// DefinesPredicate - If the specified instruction defines any predicate
503   /// or condition code register(s) used for predication, returns true as well
504   /// as the definition predicate(s) by reference.
505   virtual bool DefinesPredicate(MachineInstr *MI,
506                                 std::vector<MachineOperand> &Pred) const {
507     return false;
508   }
509
510   /// isPredicable - Return true if the specified instruction can be predicated.
511   /// By default, this returns true for every instruction with a
512   /// PredicateOperand.
513   virtual bool isPredicable(MachineInstr *MI) const {
514     return MI->getDesc().isPredicable();
515   }
516
517   /// isSafeToMoveRegClassDefs - Return true if it's safe to move a machine
518   /// instruction that defines the specified register class.
519   virtual bool isSafeToMoveRegClassDefs(const TargetRegisterClass *RC) const {
520     return true;
521   }
522
523   /// GetInstSize - Returns the size of the specified Instruction.
524   /// 
525   virtual unsigned GetInstSizeInBytes(const MachineInstr *MI) const {
526     assert(0 && "Target didn't implement TargetInstrInfo::GetInstSize!");
527     return 0;
528   }
529
530   /// GetFunctionSizeInBytes - Returns the size of the specified
531   /// MachineFunction.
532   /// 
533   virtual unsigned GetFunctionSizeInBytes(const MachineFunction &MF) const = 0;
534   
535   /// Measure the specified inline asm to determine an approximation of its
536   /// length.
537   virtual unsigned getInlineAsmLength(const char *Str,
538                                       const MCAsmInfo &MAI) const;
539 };
540
541 /// TargetInstrInfoImpl - This is the default implementation of
542 /// TargetInstrInfo, which just provides a couple of default implementations
543 /// for various methods.  This separated out because it is implemented in
544 /// libcodegen, not in libtarget.
545 class TargetInstrInfoImpl : public TargetInstrInfo {
546 protected:
547   TargetInstrInfoImpl(const TargetInstrDesc *desc, unsigned NumOpcodes)
548   : TargetInstrInfo(desc, NumOpcodes) {}
549 public:
550   virtual MachineInstr *commuteInstruction(MachineInstr *MI,
551                                            bool NewMI = false) const;
552   virtual bool findCommutedOpIndices(MachineInstr *MI, unsigned &SrcOpIdx1,
553                                      unsigned &SrcOpIdx2) const;
554   virtual bool PredicateInstruction(MachineInstr *MI,
555                             const SmallVectorImpl<MachineOperand> &Pred) const;
556   virtual void reMaterialize(MachineBasicBlock &MBB,
557                              MachineBasicBlock::iterator MI,
558                              unsigned DestReg, unsigned SubReg,
559                              const MachineInstr *Orig,
560                              const TargetRegisterInfo *TRI) const;
561   virtual MachineInstr *duplicate(MachineInstr *Orig,
562                                   MachineFunction &MF) const;
563   virtual bool isIdentical(const MachineInstr *MI,
564                            const MachineInstr *Other,
565                            const MachineRegisterInfo *MRI) const;
566
567   virtual unsigned GetFunctionSizeInBytes(const MachineFunction &MF) const;
568 };
569
570 } // End llvm namespace
571
572 #endif