1 //===-- llvm/Target/TargetInstrInfo.h - Instruction Info --------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the target machine instruction set to the code generator.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_TARGET_TARGETINSTRINFO_H
15 #define LLVM_TARGET_TARGETINSTRINFO_H
17 #include "llvm/Target/TargetInstrDesc.h"
18 #include "llvm/CodeGen/MachineFunction.h"
22 class CalleeSavedInfo;
23 class InstrItineraryData;
26 class MachineMemOperand;
30 class ScheduleHazardRecognizer;
32 class TargetRegisterClass;
33 class TargetRegisterInfo;
35 template<class T> class SmallVectorImpl;
38 //---------------------------------------------------------------------------
40 /// TargetInstrInfo - Interface to description of machine instruction set
42 class TargetInstrInfo {
43 const TargetInstrDesc *Descriptors; // Raw array to allow static init'n
44 unsigned NumOpcodes; // Number of entries in the desc array
46 TargetInstrInfo(const TargetInstrInfo &); // DO NOT IMPLEMENT
47 void operator=(const TargetInstrInfo &); // DO NOT IMPLEMENT
49 TargetInstrInfo(const TargetInstrDesc *desc, unsigned NumOpcodes);
50 virtual ~TargetInstrInfo();
52 unsigned getNumOpcodes() const { return NumOpcodes; }
54 /// get - Return the machine instruction descriptor that corresponds to the
55 /// specified instruction opcode.
57 const TargetInstrDesc &get(unsigned Opcode) const {
58 assert(Opcode < NumOpcodes && "Invalid opcode!");
59 return Descriptors[Opcode];
62 /// isTriviallyReMaterializable - Return true if the instruction is trivially
63 /// rematerializable, meaning it has no side effects and requires no operands
64 /// that aren't always available.
65 bool isTriviallyReMaterializable(const MachineInstr *MI,
66 AliasAnalysis *AA = 0) const {
67 return MI->getOpcode() == TargetOpcode::IMPLICIT_DEF ||
68 (MI->getDesc().isRematerializable() &&
69 (isReallyTriviallyReMaterializable(MI, AA) ||
70 isReallyTriviallyReMaterializableGeneric(MI, AA)));
74 /// isReallyTriviallyReMaterializable - For instructions with opcodes for
75 /// which the M_REMATERIALIZABLE flag is set, this hook lets the target
76 /// specify whether the instruction is actually trivially rematerializable,
77 /// taking into consideration its operands. This predicate must return false
78 /// if the instruction has any side effects other than producing a value, or
79 /// if it requres any address registers that are not always available.
80 virtual bool isReallyTriviallyReMaterializable(const MachineInstr *MI,
81 AliasAnalysis *AA) const {
86 /// isReallyTriviallyReMaterializableGeneric - For instructions with opcodes
87 /// for which the M_REMATERIALIZABLE flag is set and the target hook
88 /// isReallyTriviallyReMaterializable returns false, this function does
89 /// target-independent tests to determine if the instruction is really
90 /// trivially rematerializable.
91 bool isReallyTriviallyReMaterializableGeneric(const MachineInstr *MI,
92 AliasAnalysis *AA) const;
95 /// isMoveInstr - Return true if the instruction is a register to register
96 /// move and return the source and dest operands and their sub-register
97 /// indices by reference.
98 virtual bool isMoveInstr(const MachineInstr& MI,
99 unsigned& SrcReg, unsigned& DstReg,
100 unsigned& SrcSubIdx, unsigned& DstSubIdx) const {
104 /// isCoalescableExtInstr - Return true if the instruction is a "coalescable"
105 /// extension instruction. That is, it's like a copy where it's legal for the
106 /// source to overlap the destination. e.g. X86::MOVSX64rr32. If this returns
107 /// true, then it's expected the pre-extension value is available as a subreg
108 /// of the result register. This also returns the sub-register index in
110 virtual bool isCoalescableExtInstr(const MachineInstr &MI,
111 unsigned &SrcReg, unsigned &DstReg,
112 unsigned &SubIdx) const {
116 /// isIdentityCopy - Return true if the instruction is a copy (or
117 /// extract_subreg, insert_subreg, subreg_to_reg) where the source and
118 /// destination registers are the same.
119 bool isIdentityCopy(const MachineInstr &MI) const {
120 unsigned SrcReg, DstReg, SrcSubIdx, DstSubIdx;
121 if (isMoveInstr(MI, SrcReg, DstReg, SrcSubIdx, DstSubIdx) &&
125 if (MI.getOpcode() == TargetOpcode::EXTRACT_SUBREG &&
126 MI.getOperand(0).getReg() == MI.getOperand(1).getReg())
129 if ((MI.getOpcode() == TargetOpcode::INSERT_SUBREG ||
130 MI.getOpcode() == TargetOpcode::SUBREG_TO_REG) &&
131 MI.getOperand(0).getReg() == MI.getOperand(2).getReg())
136 /// isLoadFromStackSlot - If the specified machine instruction is a direct
137 /// load from a stack slot, return the virtual or physical register number of
138 /// the destination along with the FrameIndex of the loaded stack slot. If
139 /// not, return 0. This predicate must return 0 if the instruction has
140 /// any side effects other than loading from the stack slot.
141 virtual unsigned isLoadFromStackSlot(const MachineInstr *MI,
142 int &FrameIndex) const {
146 /// isLoadFromStackSlotPostFE - Check for post-frame ptr elimination
147 /// stack locations as well. This uses a heuristic so it isn't
148 /// reliable for correctness.
149 virtual unsigned isLoadFromStackSlotPostFE(const MachineInstr *MI,
150 int &FrameIndex) const {
154 /// hasLoadFromStackSlot - If the specified machine instruction has
155 /// a load from a stack slot, return true along with the FrameIndex
156 /// of the loaded stack slot and the machine mem operand containing
157 /// the reference. If not, return false. Unlike
158 /// isLoadFromStackSlot, this returns true for any instructions that
159 /// loads from the stack. This is just a hint, as some cases may be
161 virtual bool hasLoadFromStackSlot(const MachineInstr *MI,
162 const MachineMemOperand *&MMO,
163 int &FrameIndex) const {
167 /// isStoreToStackSlot - If the specified machine instruction is a direct
168 /// store to a stack slot, return the virtual or physical register number of
169 /// the source reg along with the FrameIndex of the loaded stack slot. If
170 /// not, return 0. This predicate must return 0 if the instruction has
171 /// any side effects other than storing to the stack slot.
172 virtual unsigned isStoreToStackSlot(const MachineInstr *MI,
173 int &FrameIndex) const {
177 /// isStoreToStackSlotPostFE - Check for post-frame ptr elimination
178 /// stack locations as well. This uses a heuristic so it isn't
179 /// reliable for correctness.
180 virtual unsigned isStoreToStackSlotPostFE(const MachineInstr *MI,
181 int &FrameIndex) const {
185 /// hasStoreToStackSlot - If the specified machine instruction has a
186 /// store to a stack slot, return true along with the FrameIndex of
187 /// the loaded stack slot and the machine mem operand containing the
188 /// reference. If not, return false. Unlike isStoreToStackSlot,
189 /// this returns true for any instructions that stores to the
190 /// stack. This is just a hint, as some cases may be missed.
191 virtual bool hasStoreToStackSlot(const MachineInstr *MI,
192 const MachineMemOperand *&MMO,
193 int &FrameIndex) const {
197 /// reMaterialize - Re-issue the specified 'original' instruction at the
198 /// specific location targeting a new destination register.
199 /// The register in Orig->getOperand(0).getReg() will be substituted by
200 /// DestReg:SubIdx. Any existing subreg index is preserved or composed with
202 virtual void reMaterialize(MachineBasicBlock &MBB,
203 MachineBasicBlock::iterator MI,
204 unsigned DestReg, unsigned SubIdx,
205 const MachineInstr *Orig,
206 const TargetRegisterInfo &TRI) const = 0;
208 /// scheduleTwoAddrSource - Schedule the copy / re-mat of the source of the
209 /// two-addrss instruction inserted by two-address pass.
210 virtual void scheduleTwoAddrSource(MachineInstr *SrcMI,
212 const TargetRegisterInfo &TRI) const {
216 /// duplicate - Create a duplicate of the Orig instruction in MF. This is like
217 /// MachineFunction::CloneMachineInstr(), but the target may update operands
218 /// that are required to be unique.
220 /// The instruction must be duplicable as indicated by isNotDuplicable().
221 virtual MachineInstr *duplicate(MachineInstr *Orig,
222 MachineFunction &MF) const = 0;
224 /// convertToThreeAddress - This method must be implemented by targets that
225 /// set the M_CONVERTIBLE_TO_3_ADDR flag. When this flag is set, the target
226 /// may be able to convert a two-address instruction into one or more true
227 /// three-address instructions on demand. This allows the X86 target (for
228 /// example) to convert ADD and SHL instructions into LEA instructions if they
229 /// would require register copies due to two-addressness.
231 /// This method returns a null pointer if the transformation cannot be
232 /// performed, otherwise it returns the last new instruction.
234 virtual MachineInstr *
235 convertToThreeAddress(MachineFunction::iterator &MFI,
236 MachineBasicBlock::iterator &MBBI, LiveVariables *LV) const {
240 /// commuteInstruction - If a target has any instructions that are
241 /// commutable but require converting to different instructions or making
242 /// non-trivial changes to commute them, this method can overloaded to do
243 /// that. The default implementation simply swaps the commutable operands.
244 /// If NewMI is false, MI is modified in place and returned; otherwise, a
245 /// new machine instruction is created and returned. Do not call this
246 /// method for a non-commutable instruction, but there may be some cases
247 /// where this method fails and returns null.
248 virtual MachineInstr *commuteInstruction(MachineInstr *MI,
249 bool NewMI = false) const = 0;
251 /// findCommutedOpIndices - If specified MI is commutable, return the two
252 /// operand indices that would swap value. Return false if the instruction
253 /// is not in a form which this routine understands.
254 virtual bool findCommutedOpIndices(MachineInstr *MI, unsigned &SrcOpIdx1,
255 unsigned &SrcOpIdx2) const = 0;
257 /// produceSameValue - Return true if two machine instructions would produce
258 /// identical values. By default, this is only true when the two instructions
259 /// are deemed identical except for defs.
260 virtual bool produceSameValue(const MachineInstr *MI0,
261 const MachineInstr *MI1) const = 0;
263 /// AnalyzeBranch - Analyze the branching code at the end of MBB, returning
264 /// true if it cannot be understood (e.g. it's a switch dispatch or isn't
265 /// implemented for a target). Upon success, this returns false and returns
266 /// with the following information in various cases:
268 /// 1. If this block ends with no branches (it just falls through to its succ)
269 /// just return false, leaving TBB/FBB null.
270 /// 2. If this block ends with only an unconditional branch, it sets TBB to be
271 /// the destination block.
272 /// 3. If this block ends with a conditional branch and it falls through to a
273 /// successor block, it sets TBB to be the branch destination block and a
274 /// list of operands that evaluate the condition. These operands can be
275 /// passed to other TargetInstrInfo methods to create new branches.
276 /// 4. If this block ends with a conditional branch followed by an
277 /// unconditional branch, it returns the 'true' destination in TBB, the
278 /// 'false' destination in FBB, and a list of operands that evaluate the
279 /// condition. These operands can be passed to other TargetInstrInfo
280 /// methods to create new branches.
282 /// Note that RemoveBranch and InsertBranch must be implemented to support
283 /// cases where this method returns success.
285 /// If AllowModify is true, then this routine is allowed to modify the basic
286 /// block (e.g. delete instructions after the unconditional branch).
288 virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
289 MachineBasicBlock *&FBB,
290 SmallVectorImpl<MachineOperand> &Cond,
291 bool AllowModify = false) const {
295 /// RemoveBranch - Remove the branching code at the end of the specific MBB.
296 /// This is only invoked in cases where AnalyzeBranch returns success. It
297 /// returns the number of instructions that were removed.
298 virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const {
299 assert(0 && "Target didn't implement TargetInstrInfo::RemoveBranch!");
303 /// InsertBranch - Insert branch code into the end of the specified
304 /// MachineBasicBlock. The operands to this method are the same as those
305 /// returned by AnalyzeBranch. This is only invoked in cases where
306 /// AnalyzeBranch returns success. It returns the number of instructions
309 /// It is also invoked by tail merging to add unconditional branches in
310 /// cases where AnalyzeBranch doesn't apply because there was no original
311 /// branch to analyze. At least this much must be implemented, else tail
312 /// merging needs to be disabled.
313 virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
314 MachineBasicBlock *FBB,
315 const SmallVectorImpl<MachineOperand> &Cond,
317 assert(0 && "Target didn't implement TargetInstrInfo::InsertBranch!");
321 /// ReplaceTailWithBranchTo - Delete the instruction OldInst and everything
322 /// after it, replacing it with an unconditional branch to NewDest. This is
323 /// used by the tail merging pass.
324 virtual void ReplaceTailWithBranchTo(MachineBasicBlock::iterator Tail,
325 MachineBasicBlock *NewDest) const = 0;
327 /// isLegalToSplitMBBAt - Return true if it's legal to split the given basic
328 /// block at the specified instruction (i.e. instruction would be the start
329 /// of a new basic block).
330 virtual bool isLegalToSplitMBBAt(MachineBasicBlock &MBB,
331 MachineBasicBlock::iterator MBBI) const {
335 /// isProfitableToIfCvt - Return true if it's profitable to first "NumInstrs"
336 /// of the specified basic block.
338 bool isProfitableToIfCvt(MachineBasicBlock &MBB, unsigned NumInstrs) const {
342 /// isProfitableToIfCvt - Second variant of isProfitableToIfCvt, this one
343 /// checks for the case where two basic blocks from true and false path
344 /// of a if-then-else (diamond) are predicated on mutally exclusive
347 isProfitableToIfCvt(MachineBasicBlock &TMBB, unsigned NumTInstrs,
348 MachineBasicBlock &FMBB, unsigned NumFInstrs) const {
352 /// isProfitableToDupForIfCvt - Return true if it's profitable for
353 /// if-converter to duplicate a specific number of instructions in the
354 /// specified MBB to enable if-conversion.
356 isProfitableToDupForIfCvt(MachineBasicBlock &MBB,unsigned NumInstrs) const {
360 /// copyRegToReg - Emit instructions to copy between a pair of registers. It
361 /// returns false if the target does not how to copy between the specified
363 virtual bool copyRegToReg(MachineBasicBlock &MBB,
364 MachineBasicBlock::iterator MI,
365 unsigned DestReg, unsigned SrcReg,
366 const TargetRegisterClass *DestRC,
367 const TargetRegisterClass *SrcRC,
369 assert(0 && "Target didn't implement TargetInstrInfo::copyRegToReg!");
373 /// copyPhysReg - Emit instructions to copy a pair of physical registers.
374 virtual void copyPhysReg(MachineBasicBlock &MBB,
375 MachineBasicBlock::iterator MI, DebugLoc DL,
376 unsigned DestReg, unsigned SrcReg,
377 bool KillSrc) const =0;
379 /// storeRegToStackSlot - Store the specified register of the given register
380 /// class to the specified stack frame index. The store instruction is to be
381 /// added to the given machine basic block before the specified machine
382 /// instruction. If isKill is true, the register operand is the last use and
383 /// must be marked kill.
384 virtual void storeRegToStackSlot(MachineBasicBlock &MBB,
385 MachineBasicBlock::iterator MI,
386 unsigned SrcReg, bool isKill, int FrameIndex,
387 const TargetRegisterClass *RC,
388 const TargetRegisterInfo *TRI) const {
389 assert(0 && "Target didn't implement TargetInstrInfo::storeRegToStackSlot!");
392 /// loadRegFromStackSlot - Load the specified register of the given register
393 /// class from the specified stack frame index. The load instruction is to be
394 /// added to the given machine basic block before the specified machine
396 virtual void loadRegFromStackSlot(MachineBasicBlock &MBB,
397 MachineBasicBlock::iterator MI,
398 unsigned DestReg, int FrameIndex,
399 const TargetRegisterClass *RC,
400 const TargetRegisterInfo *TRI) const {
401 assert(0 && "Target didn't implement TargetInstrInfo::loadRegFromStackSlot!");
404 /// spillCalleeSavedRegisters - Issues instruction(s) to spill all callee
405 /// saved registers and returns true if it isn't possible / profitable to do
406 /// so by issuing a series of store instructions via
407 /// storeRegToStackSlot(). Returns false otherwise.
408 virtual bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
409 MachineBasicBlock::iterator MI,
410 const std::vector<CalleeSavedInfo> &CSI,
411 const TargetRegisterInfo *TRI) const {
415 /// restoreCalleeSavedRegisters - Issues instruction(s) to restore all callee
416 /// saved registers and returns true if it isn't possible / profitable to do
417 /// so by issuing a series of load instructions via loadRegToStackSlot().
418 /// Returns false otherwise.
419 virtual bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
420 MachineBasicBlock::iterator MI,
421 const std::vector<CalleeSavedInfo> &CSI,
422 const TargetRegisterInfo *TRI) const {
426 /// emitFrameIndexDebugValue - Emit a target-dependent form of
427 /// DBG_VALUE encoding the address of a frame index. Addresses would
428 /// normally be lowered the same way as other addresses on the target,
429 /// e.g. in load instructions. For targets that do not support this
430 /// the debug info is simply lost.
431 /// If you add this for a target you should handle this DBG_VALUE in the
432 /// target-specific AsmPrinter code as well; you will probably get invalid
433 /// assembly output if you don't.
434 virtual MachineInstr *emitFrameIndexDebugValue(MachineFunction &MF,
442 /// foldMemoryOperand - Attempt to fold a load or store of the specified stack
443 /// slot into the specified machine instruction for the specified operand(s).
444 /// If this is possible, a new instruction is returned with the specified
445 /// operand folded, otherwise NULL is returned. The client is responsible for
446 /// removing the old instruction and adding the new one in the instruction
448 MachineInstr* foldMemoryOperand(MachineFunction &MF,
450 const SmallVectorImpl<unsigned> &Ops,
451 int FrameIndex) const;
453 /// foldMemoryOperand - Same as the previous version except it allows folding
454 /// of any load and store from / to any address, not just from a specific
456 MachineInstr* foldMemoryOperand(MachineFunction &MF,
458 const SmallVectorImpl<unsigned> &Ops,
459 MachineInstr* LoadMI) const;
462 /// foldMemoryOperandImpl - Target-dependent implementation for
463 /// foldMemoryOperand. Target-independent code in foldMemoryOperand will
464 /// take care of adding a MachineMemOperand to the newly created instruction.
465 virtual MachineInstr* foldMemoryOperandImpl(MachineFunction &MF,
467 const SmallVectorImpl<unsigned> &Ops,
468 int FrameIndex) const {
472 /// foldMemoryOperandImpl - Target-dependent implementation for
473 /// foldMemoryOperand. Target-independent code in foldMemoryOperand will
474 /// take care of adding a MachineMemOperand to the newly created instruction.
475 virtual MachineInstr* foldMemoryOperandImpl(MachineFunction &MF,
477 const SmallVectorImpl<unsigned> &Ops,
478 MachineInstr* LoadMI) const {
483 /// canFoldMemoryOperand - Returns true for the specified load / store if
484 /// folding is possible.
486 bool canFoldMemoryOperand(const MachineInstr *MI,
487 const SmallVectorImpl<unsigned> &Ops) const {
491 /// unfoldMemoryOperand - Separate a single instruction which folded a load or
492 /// a store or a load and a store into two or more instruction. If this is
493 /// possible, returns true as well as the new instructions by reference.
494 virtual bool unfoldMemoryOperand(MachineFunction &MF, MachineInstr *MI,
495 unsigned Reg, bool UnfoldLoad, bool UnfoldStore,
496 SmallVectorImpl<MachineInstr*> &NewMIs) const{
500 virtual bool unfoldMemoryOperand(SelectionDAG &DAG, SDNode *N,
501 SmallVectorImpl<SDNode*> &NewNodes) const {
505 /// getOpcodeAfterMemoryUnfold - Returns the opcode of the would be new
506 /// instruction after load / store are unfolded from an instruction of the
507 /// specified opcode. It returns zero if the specified unfolding is not
508 /// possible. If LoadRegIndex is non-null, it is filled in with the operand
509 /// index of the operand which will hold the register holding the loaded
511 virtual unsigned getOpcodeAfterMemoryUnfold(unsigned Opc,
512 bool UnfoldLoad, bool UnfoldStore,
513 unsigned *LoadRegIndex = 0) const {
517 /// areLoadsFromSameBasePtr - This is used by the pre-regalloc scheduler
518 /// to determine if two loads are loading from the same base address. It
519 /// should only return true if the base pointers are the same and the
520 /// only differences between the two addresses are the offset. It also returns
521 /// the offsets by reference.
522 virtual bool areLoadsFromSameBasePtr(SDNode *Load1, SDNode *Load2,
523 int64_t &Offset1, int64_t &Offset2) const {
527 /// shouldScheduleLoadsNear - This is a used by the pre-regalloc scheduler to
528 /// determine (in conjuction with areLoadsFromSameBasePtr) if two loads should
529 /// be scheduled togther. On some targets if two loads are loading from
530 /// addresses in the same cache line, it's better if they are scheduled
531 /// together. This function takes two integers that represent the load offsets
532 /// from the common base address. It returns true if it decides it's desirable
533 /// to schedule the two loads together. "NumLoads" is the number of loads that
534 /// have already been scheduled after Load1.
535 virtual bool shouldScheduleLoadsNear(SDNode *Load1, SDNode *Load2,
536 int64_t Offset1, int64_t Offset2,
537 unsigned NumLoads) const {
541 /// ReverseBranchCondition - Reverses the branch condition of the specified
542 /// condition list, returning false on success and true if it cannot be
545 bool ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const {
549 /// insertNoop - Insert a noop into the instruction stream at the specified
551 virtual void insertNoop(MachineBasicBlock &MBB,
552 MachineBasicBlock::iterator MI) const;
555 /// getNoopForMachoTarget - Return the noop instruction to use for a noop.
556 virtual void getNoopForMachoTarget(MCInst &NopInst) const {
557 // Default to just using 'nop' string.
561 /// isPredicated - Returns true if the instruction is already predicated.
563 virtual bool isPredicated(const MachineInstr *MI) const {
567 /// isUnpredicatedTerminator - Returns true if the instruction is a
568 /// terminator instruction that has not been predicated.
569 virtual bool isUnpredicatedTerminator(const MachineInstr *MI) const;
571 /// PredicateInstruction - Convert the instruction into a predicated
572 /// instruction. It returns true if the operation was successful.
574 bool PredicateInstruction(MachineInstr *MI,
575 const SmallVectorImpl<MachineOperand> &Pred) const = 0;
577 /// SubsumesPredicate - Returns true if the first specified predicate
578 /// subsumes the second, e.g. GE subsumes GT.
580 bool SubsumesPredicate(const SmallVectorImpl<MachineOperand> &Pred1,
581 const SmallVectorImpl<MachineOperand> &Pred2) const {
585 /// DefinesPredicate - If the specified instruction defines any predicate
586 /// or condition code register(s) used for predication, returns true as well
587 /// as the definition predicate(s) by reference.
588 virtual bool DefinesPredicate(MachineInstr *MI,
589 std::vector<MachineOperand> &Pred) const {
593 /// isPredicable - Return true if the specified instruction can be predicated.
594 /// By default, this returns true for every instruction with a
595 /// PredicateOperand.
596 virtual bool isPredicable(MachineInstr *MI) const {
597 return MI->getDesc().isPredicable();
600 /// isSafeToMoveRegClassDefs - Return true if it's safe to move a machine
601 /// instruction that defines the specified register class.
602 virtual bool isSafeToMoveRegClassDefs(const TargetRegisterClass *RC) const {
606 /// isSchedulingBoundary - Test if the given instruction should be
607 /// considered a scheduling boundary. This primarily includes labels and
609 virtual bool isSchedulingBoundary(const MachineInstr *MI,
610 const MachineBasicBlock *MBB,
611 const MachineFunction &MF) const = 0;
613 /// GetInstSize - Returns the size of the specified Instruction.
615 virtual unsigned GetInstSizeInBytes(const MachineInstr *MI) const {
616 assert(0 && "Target didn't implement TargetInstrInfo::GetInstSize!");
620 /// GetFunctionSizeInBytes - Returns the size of the specified
623 virtual unsigned GetFunctionSizeInBytes(const MachineFunction &MF) const = 0;
625 /// Measure the specified inline asm to determine an approximation of its
627 virtual unsigned getInlineAsmLength(const char *Str,
628 const MCAsmInfo &MAI) const;
630 /// CreateTargetHazardRecognizer - Allocate and return a hazard recognizer
631 /// to use for this target when scheduling the machine instructions after
632 /// register allocation.
633 virtual ScheduleHazardRecognizer*
634 CreateTargetPostRAHazardRecognizer(const InstrItineraryData&) const = 0;
637 /// TargetInstrInfoImpl - This is the default implementation of
638 /// TargetInstrInfo, which just provides a couple of default implementations
639 /// for various methods. This separated out because it is implemented in
640 /// libcodegen, not in libtarget.
641 class TargetInstrInfoImpl : public TargetInstrInfo {
643 TargetInstrInfoImpl(const TargetInstrDesc *desc, unsigned NumOpcodes)
644 : TargetInstrInfo(desc, NumOpcodes) {}
646 virtual void ReplaceTailWithBranchTo(MachineBasicBlock::iterator OldInst,
647 MachineBasicBlock *NewDest) const;
648 virtual MachineInstr *commuteInstruction(MachineInstr *MI,
649 bool NewMI = false) const;
650 virtual bool findCommutedOpIndices(MachineInstr *MI, unsigned &SrcOpIdx1,
651 unsigned &SrcOpIdx2) const;
652 virtual bool PredicateInstruction(MachineInstr *MI,
653 const SmallVectorImpl<MachineOperand> &Pred) const;
654 virtual void reMaterialize(MachineBasicBlock &MBB,
655 MachineBasicBlock::iterator MI,
656 unsigned DestReg, unsigned SubReg,
657 const MachineInstr *Orig,
658 const TargetRegisterInfo &TRI) const;
659 virtual MachineInstr *duplicate(MachineInstr *Orig,
660 MachineFunction &MF) const;
661 virtual bool produceSameValue(const MachineInstr *MI0,
662 const MachineInstr *MI1) const;
663 virtual bool isSchedulingBoundary(const MachineInstr *MI,
664 const MachineBasicBlock *MBB,
665 const MachineFunction &MF) const;
666 virtual unsigned GetFunctionSizeInBytes(const MachineFunction &MF) const;
668 virtual ScheduleHazardRecognizer *
669 CreateTargetPostRAHazardRecognizer(const InstrItineraryData&) const;
670 virtual void copyPhysReg(MachineBasicBlock &MBB,
671 MachineBasicBlock::iterator MI, DebugLoc DL,
672 unsigned DestReg, unsigned SrcReg,
676 } // End llvm namespace