TargetInstrInfo.h revision 9f8fea3531f8f8d04d1e183ff570be37d41d13f5
1075b4a066db31f48e0f6daec34b1ff463523cd3fChris Lattner//===-- llvm/Target/TargetInstrInfo.h - Instruction Info --------*- C++ -*-===//
234695381d626485a560594f162701088079589dfMisha Brukman//
36fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell//                     The LLVM Compiler Infrastructure
46fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell//
57ed47a13356daed2a34cd2209a31f92552e3bdd8Chris Lattner// This file is distributed under the University of Illinois Open Source
67ed47a13356daed2a34cd2209a31f92552e3bdd8Chris Lattner// License. See LICENSE.TXT for details.
734695381d626485a560594f162701088079589dfMisha Brukman//
86fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell//===----------------------------------------------------------------------===//
9a578a6d054e8219c730840700d8d5fd29f15a962Vikram S. Adve//
10a578a6d054e8219c730840700d8d5fd29f15a962Vikram S. Adve// This file describes the target machine instructions to the code generator.
11a578a6d054e8219c730840700d8d5fd29f15a962Vikram S. Adve//
12f6d12fbd9cc0355978a739f5ab213eff85b75a19Chris Lattner//===----------------------------------------------------------------------===//
13a578a6d054e8219c730840700d8d5fd29f15a962Vikram S. Adve
143501feab811c86c9659248a4875fc31a3165f84dChris Lattner#ifndef LLVM_TARGET_TARGETINSTRINFO_H
153501feab811c86c9659248a4875fc31a3165f84dChris Lattner#define LLVM_TARGET_TARGETINSTRINFO_H
16a578a6d054e8219c730840700d8d5fd29f15a962Vikram S. Adve
17d3f99e2bbf5e62261c8948127aacfe9a7d3b2456Chris Lattner#include "llvm/Target/TargetInstrDesc.h"
186c14147d934bd644fc9d24a3b36f3c38799a3401Evan Cheng#include "llvm/CodeGen/MachineFunction.h"
19a578a6d054e8219c730840700d8d5fd29f15a962Vikram S. Adve
20d0fde30ce850b78371fd1386338350591f9ff494Brian Gaekenamespace llvm {
21d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke
22ae72f4a642192abab5a2d10592200a94fcba61deChris Lattnerclass TargetRegisterClass;
236c14147d934bd644fc9d24a3b36f3c38799a3401Evan Chengclass LiveVariables;
24d94b6a16fec7d5021e3922b0e34f9ddb268d54b1Owen Andersonclass CalleeSavedInfo;
2543dbe05279b753aabda571d9c83eaeb36987001aOwen Andersonclass SDNode;
2643dbe05279b753aabda571d9c83eaeb36987001aOwen Andersonclass SelectionDAG;
27a578a6d054e8219c730840700d8d5fd29f15a962Vikram S. Adve
28f6372aa1cc568df19da7c5023e83c75aa9404a07Owen Andersontemplate<class T> class SmallVectorImpl;
29f6372aa1cc568df19da7c5023e83c75aa9404a07Owen Anderson
30a578a6d054e8219c730840700d8d5fd29f15a962Vikram S. Adve
313501feab811c86c9659248a4875fc31a3165f84dChris Lattner//---------------------------------------------------------------------------
3234695381d626485a560594f162701088079589dfMisha Brukman///
333501feab811c86c9659248a4875fc31a3165f84dChris Lattner/// TargetInstrInfo - Interface to description of machine instructions
3434695381d626485a560594f162701088079589dfMisha Brukman///
35075b4a066db31f48e0f6daec34b1ff463523cd3fChris Lattnerclass TargetInstrInfo {
36749c6f6b5ed301c84aac562e414486549d7b98ebChris Lattner  const TargetInstrDesc *Descriptors; // Raw array to allow static init'n
37749c6f6b5ed301c84aac562e414486549d7b98ebChris Lattner  unsigned NumOpcodes;                // Number of entries in the desc array
3834695381d626485a560594f162701088079589dfMisha Brukman
39075b4a066db31f48e0f6daec34b1ff463523cd3fChris Lattner  TargetInstrInfo(const TargetInstrInfo &);  // DO NOT IMPLEMENT
40075b4a066db31f48e0f6daec34b1ff463523cd3fChris Lattner  void operator=(const TargetInstrInfo &);   // DO NOT IMPLEMENT
41a578a6d054e8219c730840700d8d5fd29f15a962Vikram S. Advepublic:
42749c6f6b5ed301c84aac562e414486549d7b98ebChris Lattner  TargetInstrInfo(const TargetInstrDesc *desc, unsigned NumOpcodes);
43075b4a066db31f48e0f6daec34b1ff463523cd3fChris Lattner  virtual ~TargetInstrInfo();
4470535c608d88ce25fb992dba3b6d3d0176153a09Chris Lattner
454ed88eb8229848cd6add06a1ec90e497e382306fChris Lattner  // Invariant opcodes: All instruction sets have these as their low opcodes.
464ed88eb8229848cd6add06a1ec90e497e382306fChris Lattner  enum {
474ed88eb8229848cd6add06a1ec90e497e382306fChris Lattner    PHI = 0,
481ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey    INLINEASM = 1,
4908d52071bae2f8cc2e9aa6a451118b83d043813bChristopher Lamb    LABEL = 2,
50a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng    DECLARE = 3,
51a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng    EXTRACT_SUBREG = 4,
52da47e6e0d003c873da960361549e57ee4617c301Evan Cheng    INSERT_SUBREG = 5,
53c9298235251b014e86a7368d92b589d093acb64aChristopher Lamb    IMPLICIT_DEF = 6,
54c9298235251b014e86a7368d92b589d093acb64aChristopher Lamb    SUBREG_TO_REG = 7
556634e26aa11b0e2eabde8b3b463bb943364f8d9dChristopher Lamb  };
5634695381d626485a560594f162701088079589dfMisha Brukman
57bceb68807fdb86c794bc8d8f8aef0940f12c2cebChris Lattner  unsigned getNumOpcodes() const { return NumOpcodes; }
5834695381d626485a560594f162701088079589dfMisha Brukman
59e30eeaaf72b461aebf3dfcdd7c119eea76458561Chris Lattner  /// get - Return the machine instruction descriptor that corresponds to the
60e30eeaaf72b461aebf3dfcdd7c119eea76458561Chris Lattner  /// specified instruction opcode.
61e30eeaaf72b461aebf3dfcdd7c119eea76458561Chris Lattner  ///
62749c6f6b5ed301c84aac562e414486549d7b98ebChris Lattner  const TargetInstrDesc &get(unsigned Opcode) const {
63749c6f6b5ed301c84aac562e414486549d7b98ebChris Lattner    assert(Opcode < NumOpcodes && "Invalid opcode!");
64749c6f6b5ed301c84aac562e414486549d7b98ebChris Lattner    return Descriptors[Opcode];
65a578a6d054e8219c730840700d8d5fd29f15a962Vikram S. Adve  }
664683f9bfb4dc2f5557e8a7a229912e7f2ed366caChris Lattner
67041b3f835682588cb63df7e609d726369dd6b7d3Bill Wendling  /// isTriviallyReMaterializable - Return true if the instruction is trivially
68d45eddd214061bf12ad1e6b86497a41725e61d75Dan Gohman  /// rematerializable, meaning it has no side effects and requires no operands
69d45eddd214061bf12ad1e6b86497a41725e61d75Dan Gohman  /// that aren't always available.
709f8fea3531f8f8d04d1e183ff570be37d41d13f5Bill Wendling  bool isTriviallyReMaterializable(const MachineInstr *MI) const {
71749c6f6b5ed301c84aac562e414486549d7b98ebChris Lattner    return MI->getDesc().isRematerializable() &&
72041b3f835682588cb63df7e609d726369dd6b7d3Bill Wendling           isReallyTriviallyReMaterializable(MI);
73d45eddd214061bf12ad1e6b86497a41725e61d75Dan Gohman  }
74d45eddd214061bf12ad1e6b86497a41725e61d75Dan Gohman
75d45eddd214061bf12ad1e6b86497a41725e61d75Dan Gohmanprotected:
76041b3f835682588cb63df7e609d726369dd6b7d3Bill Wendling  /// isReallyTriviallyReMaterializable - For instructions with opcodes for
77041b3f835682588cb63df7e609d726369dd6b7d3Bill Wendling  /// which the M_REMATERIALIZABLE flag is set, this function tests whether the
78041b3f835682588cb63df7e609d726369dd6b7d3Bill Wendling  /// instruction itself is actually trivially rematerializable, considering
79041b3f835682588cb63df7e609d726369dd6b7d3Bill Wendling  /// its operands.  This is used for targets that have instructions that are
80041b3f835682588cb63df7e609d726369dd6b7d3Bill Wendling  /// only trivially rematerializable for specific uses.  This predicate must
81041b3f835682588cb63df7e609d726369dd6b7d3Bill Wendling  /// return false if the instruction has any side effects other than
82041b3f835682588cb63df7e609d726369dd6b7d3Bill Wendling  /// producing a value, or if it requres any address registers that are not
83041b3f835682588cb63df7e609d726369dd6b7d3Bill Wendling  /// always available.
849f8fea3531f8f8d04d1e183ff570be37d41d13f5Bill Wendling  virtual bool isReallyTriviallyReMaterializable(const MachineInstr *MI) const {
85d45eddd214061bf12ad1e6b86497a41725e61d75Dan Gohman    return true;
86d45eddd214061bf12ad1e6b86497a41725e61d75Dan Gohman  }
87d45eddd214061bf12ad1e6b86497a41725e61d75Dan Gohman
88d45eddd214061bf12ad1e6b86497a41725e61d75Dan Gohmanpublic:
890cad9f53b15b7308e977864d681f710646e7d376Alkis Evlogimenos  /// Return true if the instruction is a register to register move
900cad9f53b15b7308e977864d681f710646e7d376Alkis Evlogimenos  /// and leave the source and dest operands in the passed parameters.
915e30002af70ef09a42cac155d9196f7f0f3b1695Alkis Evlogimenos  virtual bool isMoveInstr(const MachineInstr& MI,
925e30002af70ef09a42cac155d9196f7f0f3b1695Alkis Evlogimenos                           unsigned& sourceReg,
935e30002af70ef09a42cac155d9196f7f0f3b1695Alkis Evlogimenos                           unsigned& destReg) const {
945e30002af70ef09a42cac155d9196f7f0f3b1695Alkis Evlogimenos    return false;
955e30002af70ef09a42cac155d9196f7f0f3b1695Alkis Evlogimenos  }
96af9fa2bd0c1ee25f3adda96b3e5d7129fbab393aChris Lattner
97af9fa2bd0c1ee25f3adda96b3e5d7129fbab393aChris Lattner  /// isLoadFromStackSlot - If the specified machine instruction is a direct
98af9fa2bd0c1ee25f3adda96b3e5d7129fbab393aChris Lattner  /// load from a stack slot, return the virtual or physical register number of
99af9fa2bd0c1ee25f3adda96b3e5d7129fbab393aChris Lattner  /// the destination along with the FrameIndex of the loaded stack slot.  If
100af9fa2bd0c1ee25f3adda96b3e5d7129fbab393aChris Lattner  /// not, return 0.  This predicate must return 0 if the instruction has
101af9fa2bd0c1ee25f3adda96b3e5d7129fbab393aChris Lattner  /// any side effects other than loading from the stack slot.
102af9fa2bd0c1ee25f3adda96b3e5d7129fbab393aChris Lattner  virtual unsigned isLoadFromStackSlot(MachineInstr *MI, int &FrameIndex) const{
103af9fa2bd0c1ee25f3adda96b3e5d7129fbab393aChris Lattner    return 0;
104af9fa2bd0c1ee25f3adda96b3e5d7129fbab393aChris Lattner  }
105af9fa2bd0c1ee25f3adda96b3e5d7129fbab393aChris Lattner
106af9fa2bd0c1ee25f3adda96b3e5d7129fbab393aChris Lattner  /// isStoreToStackSlot - If the specified machine instruction is a direct
107af9fa2bd0c1ee25f3adda96b3e5d7129fbab393aChris Lattner  /// store to a stack slot, return the virtual or physical register number of
108af9fa2bd0c1ee25f3adda96b3e5d7129fbab393aChris Lattner  /// the source reg along with the FrameIndex of the loaded stack slot.  If
109af9fa2bd0c1ee25f3adda96b3e5d7129fbab393aChris Lattner  /// not, return 0.  This predicate must return 0 if the instruction has
110af9fa2bd0c1ee25f3adda96b3e5d7129fbab393aChris Lattner  /// any side effects other than storing to the stack slot.
111af9fa2bd0c1ee25f3adda96b3e5d7129fbab393aChris Lattner  virtual unsigned isStoreToStackSlot(MachineInstr *MI, int &FrameIndex) const {
112af9fa2bd0c1ee25f3adda96b3e5d7129fbab393aChris Lattner    return 0;
113af9fa2bd0c1ee25f3adda96b3e5d7129fbab393aChris Lattner  }
1145e30002af70ef09a42cac155d9196f7f0f3b1695Alkis Evlogimenos
115ca1267c02b025cc719190b05f9e1a5d174a9caf7Evan Cheng  /// reMaterialize - Re-issue the specified 'original' instruction at the
116ca1267c02b025cc719190b05f9e1a5d174a9caf7Evan Cheng  /// specific location targeting a new destination register.
117ca1267c02b025cc719190b05f9e1a5d174a9caf7Evan Cheng  virtual void reMaterialize(MachineBasicBlock &MBB,
118ca1267c02b025cc719190b05f9e1a5d174a9caf7Evan Cheng                             MachineBasicBlock::iterator MI,
119ca1267c02b025cc719190b05f9e1a5d174a9caf7Evan Cheng                             unsigned DestReg,
120ca1267c02b025cc719190b05f9e1a5d174a9caf7Evan Cheng                             const MachineInstr *Orig) const = 0;
121ca1267c02b025cc719190b05f9e1a5d174a9caf7Evan Cheng
122a22edc82cab86be4cb8876da1e6e78f82bb47a3eChris Lattner  /// isInvariantLoad - Return true if the specified instruction (which is
123a22edc82cab86be4cb8876da1e6e78f82bb47a3eChris Lattner  /// marked mayLoad) is loading from a location whose value is invariant across
124a22edc82cab86be4cb8876da1e6e78f82bb47a3eChris Lattner  /// the function.  For example, loading a value from the constant pool or from
125a22edc82cab86be4cb8876da1e6e78f82bb47a3eChris Lattner  /// from the argument area of a function if it does not change.  This should
126a22edc82cab86be4cb8876da1e6e78f82bb47a3eChris Lattner  /// only return true of *all* loads the instruction does are invariant (if it
127a22edc82cab86be4cb8876da1e6e78f82bb47a3eChris Lattner  /// does multiple loads).
128a22edc82cab86be4cb8876da1e6e78f82bb47a3eChris Lattner  virtual bool isInvariantLoad(MachineInstr *MI) const {
129a22edc82cab86be4cb8876da1e6e78f82bb47a3eChris Lattner    return false;
130a22edc82cab86be4cb8876da1e6e78f82bb47a3eChris Lattner  }
131a22edc82cab86be4cb8876da1e6e78f82bb47a3eChris Lattner
13215f63ad2e59998f0bf1a3a23547582074391f650Chris Lattner  /// convertToThreeAddress - This method must be implemented by targets that
13315f63ad2e59998f0bf1a3a23547582074391f650Chris Lattner  /// set the M_CONVERTIBLE_TO_3_ADDR flag.  When this flag is set, the target
1342c8c3e2e31e641085060edce0ddde3833ffa53daDan Gohman  /// may be able to convert a two-address instruction into one or more true
1356c14147d934bd644fc9d24a3b36f3c38799a3401Evan Cheng  /// three-address instructions on demand.  This allows the X86 target (for
13615f63ad2e59998f0bf1a3a23547582074391f650Chris Lattner  /// example) to convert ADD and SHL instructions into LEA instructions if they
13715f63ad2e59998f0bf1a3a23547582074391f650Chris Lattner  /// would require register copies due to two-addressness.
13815f63ad2e59998f0bf1a3a23547582074391f650Chris Lattner  ///
13915f63ad2e59998f0bf1a3a23547582074391f650Chris Lattner  /// This method returns a null pointer if the transformation cannot be
1406c14147d934bd644fc9d24a3b36f3c38799a3401Evan Cheng  /// performed, otherwise it returns the last new instruction.
14115f63ad2e59998f0bf1a3a23547582074391f650Chris Lattner  ///
1426c14147d934bd644fc9d24a3b36f3c38799a3401Evan Cheng  virtual MachineInstr *
1436c14147d934bd644fc9d24a3b36f3c38799a3401Evan Cheng  convertToThreeAddress(MachineFunction::iterator &MFI,
1446c14147d934bd644fc9d24a3b36f3c38799a3401Evan Cheng                   MachineBasicBlock::iterator &MBBI, LiveVariables &LV) const {
14515f63ad2e59998f0bf1a3a23547582074391f650Chris Lattner    return 0;
14615f63ad2e59998f0bf1a3a23547582074391f650Chris Lattner  }
14715f63ad2e59998f0bf1a3a23547582074391f650Chris Lattner
148d7e2fe40e42dffa04a770191c3414446d5e8c30aChris Lattner  /// commuteInstruction - If a target has any instructions that are commutable,
149d7e2fe40e42dffa04a770191c3414446d5e8c30aChris Lattner  /// but require converting to a different instruction or making non-trivial
150d7e2fe40e42dffa04a770191c3414446d5e8c30aChris Lattner  /// changes to commute them, this method can overloaded to do this.  The
151d7e2fe40e42dffa04a770191c3414446d5e8c30aChris Lattner  /// default implementation of this method simply swaps the first two operands
152d7e2fe40e42dffa04a770191c3414446d5e8c30aChris Lattner  /// of MI and returns it.
153d7e2fe40e42dffa04a770191c3414446d5e8c30aChris Lattner  ///
154d7e2fe40e42dffa04a770191c3414446d5e8c30aChris Lattner  /// If a target wants to make more aggressive changes, they can construct and
155d7e2fe40e42dffa04a770191c3414446d5e8c30aChris Lattner  /// return a new machine instruction.  If an instruction cannot commute, it
156d7e2fe40e42dffa04a770191c3414446d5e8c30aChris Lattner  /// can also return null.
157d7e2fe40e42dffa04a770191c3414446d5e8c30aChris Lattner  ///
158641055225092833197efe8e5bce01d50bcf1daaeChris Lattner  virtual MachineInstr *commuteInstruction(MachineInstr *MI) const = 0;
159d7e2fe40e42dffa04a770191c3414446d5e8c30aChris Lattner
160f20db159541bf27f5d2fdf8d4ba1c8b270b936dfEvan Cheng  /// CommuteChangesDestination - Return true if commuting the specified
161f20db159541bf27f5d2fdf8d4ba1c8b270b936dfEvan Cheng  /// instruction will also changes the destination operand. Also return the
162f20db159541bf27f5d2fdf8d4ba1c8b270b936dfEvan Cheng  /// current operand index of the would be new destination register by
163f20db159541bf27f5d2fdf8d4ba1c8b270b936dfEvan Cheng  /// reference. This can happen when the commutable instruction is also a
164f20db159541bf27f5d2fdf8d4ba1c8b270b936dfEvan Cheng  /// two-address instruction.
165f20db159541bf27f5d2fdf8d4ba1c8b270b936dfEvan Cheng  virtual bool CommuteChangesDestination(MachineInstr *MI,
166f20db159541bf27f5d2fdf8d4ba1c8b270b936dfEvan Cheng                                         unsigned &OpIdx) const = 0;
167f20db159541bf27f5d2fdf8d4ba1c8b270b936dfEvan Cheng
168b2cd26127973b97c3ed8d74a063e70a259369e44Chris Lattner  /// AnalyzeBranch - Analyze the branching code at the end of MBB, returning
169b2cd26127973b97c3ed8d74a063e70a259369e44Chris Lattner  /// true if it cannot be understood (e.g. it's a switch dispatch or isn't
170b2cd26127973b97c3ed8d74a063e70a259369e44Chris Lattner  /// implemented for a target).  Upon success, this returns false and returns
171b2cd26127973b97c3ed8d74a063e70a259369e44Chris Lattner  /// with the following information in various cases:
172b2cd26127973b97c3ed8d74a063e70a259369e44Chris Lattner  ///
17372dc5852684bd56af68b3f344b295d9ff5c3a13fChris Lattner  /// 1. If this block ends with no branches (it just falls through to its succ)
17472dc5852684bd56af68b3f344b295d9ff5c3a13fChris Lattner  ///    just return false, leaving TBB/FBB null.
17572dc5852684bd56af68b3f344b295d9ff5c3a13fChris Lattner  /// 2. If this block ends with only an unconditional branch, it sets TBB to be
176b2cd26127973b97c3ed8d74a063e70a259369e44Chris Lattner  ///    the destination block.
1776c1d2b90e31ea3337705372d1757727d6764686dEvan Cheng  /// 3. If this block ends with an conditional branch and it falls through to
1786c1d2b90e31ea3337705372d1757727d6764686dEvan Cheng  ///    an successor block, it sets TBB to be the branch destination block and a
1796c1d2b90e31ea3337705372d1757727d6764686dEvan Cheng  ///    list of operands that evaluate the condition. These
1806c1d2b90e31ea3337705372d1757727d6764686dEvan Cheng  ///    operands can be passed to other TargetInstrInfo methods to create new
1816c1d2b90e31ea3337705372d1757727d6764686dEvan Cheng  ///    branches.
1826c1d2b90e31ea3337705372d1757727d6764686dEvan Cheng  /// 4. If this block ends with an conditional branch and an unconditional
1836c1d2b90e31ea3337705372d1757727d6764686dEvan Cheng  ///    block, it returns the 'true' destination in TBB, the 'false' destination
1846c1d2b90e31ea3337705372d1757727d6764686dEvan Cheng  ///    in FBB, and a list of operands that evaluate the condition. These
1856c1d2b90e31ea3337705372d1757727d6764686dEvan Cheng  ///    operands can be passed to other TargetInstrInfo methods to create new
1866c1d2b90e31ea3337705372d1757727d6764686dEvan Cheng  ///    branches.
187b2cd26127973b97c3ed8d74a063e70a259369e44Chris Lattner  ///
188b2cd26127973b97c3ed8d74a063e70a259369e44Chris Lattner  /// Note that RemoveBranch and InsertBranch must be implemented to support
189b2cd26127973b97c3ed8d74a063e70a259369e44Chris Lattner  /// cases where this method returns success.
190b2cd26127973b97c3ed8d74a063e70a259369e44Chris Lattner  ///
191b2cd26127973b97c3ed8d74a063e70a259369e44Chris Lattner  virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
192b2cd26127973b97c3ed8d74a063e70a259369e44Chris Lattner                             MachineBasicBlock *&FBB,
193b2cd26127973b97c3ed8d74a063e70a259369e44Chris Lattner                             std::vector<MachineOperand> &Cond) const {
194b2cd26127973b97c3ed8d74a063e70a259369e44Chris Lattner    return true;
195905f7af59cb85ea71b6c011f1e79f24f8db16efcAlkis Evlogimenos  }
196b2cd26127973b97c3ed8d74a063e70a259369e44Chris Lattner
197b2cd26127973b97c3ed8d74a063e70a259369e44Chris Lattner  /// RemoveBranch - Remove the branching code at the end of the specific MBB.
198b5cdaa257e167a08a8a54ea9249d847ccc415ce0Evan Cheng  /// this is only invoked in cases where AnalyzeBranch returns success. It
199b5cdaa257e167a08a8a54ea9249d847ccc415ce0Evan Cheng  /// returns the number of instructions that were removed.
200b5cdaa257e167a08a8a54ea9249d847ccc415ce0Evan Cheng  virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const {
201b2cd26127973b97c3ed8d74a063e70a259369e44Chris Lattner    assert(0 && "Target didn't implement TargetInstrInfo::RemoveBranch!");
202b5cdaa257e167a08a8a54ea9249d847ccc415ce0Evan Cheng    return 0;
203b2cd26127973b97c3ed8d74a063e70a259369e44Chris Lattner  }
204b2cd26127973b97c3ed8d74a063e70a259369e44Chris Lattner
205b2cd26127973b97c3ed8d74a063e70a259369e44Chris Lattner  /// InsertBranch - Insert a branch into the end of the specified
206b2cd26127973b97c3ed8d74a063e70a259369e44Chris Lattner  /// MachineBasicBlock.  This operands to this method are the same as those
20733644ba8d22a91b8fe0f0da3d73fc7cf38a46b06Chris Lattner  /// returned by AnalyzeBranch.  This is invoked in cases where AnalyzeBranch
20833644ba8d22a91b8fe0f0da3d73fc7cf38a46b06Chris Lattner  /// returns success and when an unconditional branch (TBB is non-null, FBB is
209b5cdaa257e167a08a8a54ea9249d847ccc415ce0Evan Cheng  /// null, Cond is empty) needs to be inserted. It returns the number of
210b5cdaa257e167a08a8a54ea9249d847ccc415ce0Evan Cheng  /// instructions inserted.
211b5cdaa257e167a08a8a54ea9249d847ccc415ce0Evan Cheng  virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
212d51c87f22f9b666204b27b301af771bc5badc142Chris Lattner                            MachineBasicBlock *FBB,
213d51c87f22f9b666204b27b301af771bc5badc142Chris Lattner                            const std::vector<MachineOperand> &Cond) const {
21424321d7e23a482cbd0b7502f43e9026f87a3684dRafael Espindola    assert(0 && "Target didn't implement TargetInstrInfo::InsertBranch!");
215b5cdaa257e167a08a8a54ea9249d847ccc415ce0Evan Cheng    return 0;
216b2cd26127973b97c3ed8d74a063e70a259369e44Chris Lattner  }
217b2cd26127973b97c3ed8d74a063e70a259369e44Chris Lattner
218d10fd9791c20fd8368fa0ce94b626b769c6c8ba0Owen Anderson  /// copyRegToReg - Add a copy between a pair of registers
219d10fd9791c20fd8368fa0ce94b626b769c6c8ba0Owen Anderson  virtual void copyRegToReg(MachineBasicBlock &MBB,
220d10fd9791c20fd8368fa0ce94b626b769c6c8ba0Owen Anderson                            MachineBasicBlock::iterator MI,
221d10fd9791c20fd8368fa0ce94b626b769c6c8ba0Owen Anderson                            unsigned DestReg, unsigned SrcReg,
222d10fd9791c20fd8368fa0ce94b626b769c6c8ba0Owen Anderson                            const TargetRegisterClass *DestRC,
223d10fd9791c20fd8368fa0ce94b626b769c6c8ba0Owen Anderson                            const TargetRegisterClass *SrcRC) const {
224d10fd9791c20fd8368fa0ce94b626b769c6c8ba0Owen Anderson    assert(0 && "Target didn't implement TargetInstrInfo::copyRegToReg!");
225d10fd9791c20fd8368fa0ce94b626b769c6c8ba0Owen Anderson  }
226d10fd9791c20fd8368fa0ce94b626b769c6c8ba0Owen Anderson
227f6372aa1cc568df19da7c5023e83c75aa9404a07Owen Anderson  virtual void storeRegToStackSlot(MachineBasicBlock &MBB,
228f6372aa1cc568df19da7c5023e83c75aa9404a07Owen Anderson                                   MachineBasicBlock::iterator MI,
229f6372aa1cc568df19da7c5023e83c75aa9404a07Owen Anderson                                   unsigned SrcReg, bool isKill, int FrameIndex,
230f6372aa1cc568df19da7c5023e83c75aa9404a07Owen Anderson                                   const TargetRegisterClass *RC) const {
231f6372aa1cc568df19da7c5023e83c75aa9404a07Owen Anderson    assert(0 && "Target didn't implement TargetInstrInfo::storeRegToStackSlot!");
232f6372aa1cc568df19da7c5023e83c75aa9404a07Owen Anderson  }
233f6372aa1cc568df19da7c5023e83c75aa9404a07Owen Anderson
234f6372aa1cc568df19da7c5023e83c75aa9404a07Owen Anderson  virtual void storeRegToAddr(MachineFunction &MF, unsigned SrcReg, bool isKill,
235f6372aa1cc568df19da7c5023e83c75aa9404a07Owen Anderson                              SmallVectorImpl<MachineOperand> &Addr,
236f6372aa1cc568df19da7c5023e83c75aa9404a07Owen Anderson                              const TargetRegisterClass *RC,
237f6372aa1cc568df19da7c5023e83c75aa9404a07Owen Anderson                              SmallVectorImpl<MachineInstr*> &NewMIs) const {
238f6372aa1cc568df19da7c5023e83c75aa9404a07Owen Anderson    assert(0 && "Target didn't implement TargetInstrInfo::storeRegToAddr!");
239f6372aa1cc568df19da7c5023e83c75aa9404a07Owen Anderson  }
240f6372aa1cc568df19da7c5023e83c75aa9404a07Owen Anderson
241f6372aa1cc568df19da7c5023e83c75aa9404a07Owen Anderson  virtual void loadRegFromStackSlot(MachineBasicBlock &MBB,
242f6372aa1cc568df19da7c5023e83c75aa9404a07Owen Anderson                                    MachineBasicBlock::iterator MI,
243f6372aa1cc568df19da7c5023e83c75aa9404a07Owen Anderson                                    unsigned DestReg, int FrameIndex,
244f6372aa1cc568df19da7c5023e83c75aa9404a07Owen Anderson                                    const TargetRegisterClass *RC) const {
245f6372aa1cc568df19da7c5023e83c75aa9404a07Owen Anderson    assert(0 && "Target didn't implement TargetInstrInfo::loadRegFromStackSlot!");
246f6372aa1cc568df19da7c5023e83c75aa9404a07Owen Anderson  }
247f6372aa1cc568df19da7c5023e83c75aa9404a07Owen Anderson
248f6372aa1cc568df19da7c5023e83c75aa9404a07Owen Anderson  virtual void loadRegFromAddr(MachineFunction &MF, unsigned DestReg,
249f6372aa1cc568df19da7c5023e83c75aa9404a07Owen Anderson                               SmallVectorImpl<MachineOperand> &Addr,
250f6372aa1cc568df19da7c5023e83c75aa9404a07Owen Anderson                               const TargetRegisterClass *RC,
251f6372aa1cc568df19da7c5023e83c75aa9404a07Owen Anderson                               SmallVectorImpl<MachineInstr*> &NewMIs) const {
252f6372aa1cc568df19da7c5023e83c75aa9404a07Owen Anderson    assert(0 && "Target didn't implement TargetInstrInfo::loadRegFromAddr!");
253f6372aa1cc568df19da7c5023e83c75aa9404a07Owen Anderson  }
254f6372aa1cc568df19da7c5023e83c75aa9404a07Owen Anderson
255d94b6a16fec7d5021e3922b0e34f9ddb268d54b1Owen Anderson  /// spillCalleeSavedRegisters - Issues instruction(s) to spill all callee
256d94b6a16fec7d5021e3922b0e34f9ddb268d54b1Owen Anderson  /// saved registers and returns true if it isn't possible / profitable to do
257d94b6a16fec7d5021e3922b0e34f9ddb268d54b1Owen Anderson  /// so by issuing a series of store instructions via
258d94b6a16fec7d5021e3922b0e34f9ddb268d54b1Owen Anderson  /// storeRegToStackSlot(). Returns false otherwise.
259d94b6a16fec7d5021e3922b0e34f9ddb268d54b1Owen Anderson  virtual bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
260d94b6a16fec7d5021e3922b0e34f9ddb268d54b1Owen Anderson                                         MachineBasicBlock::iterator MI,
261d94b6a16fec7d5021e3922b0e34f9ddb268d54b1Owen Anderson                                const std::vector<CalleeSavedInfo> &CSI) const {
262d94b6a16fec7d5021e3922b0e34f9ddb268d54b1Owen Anderson    return false;
263d94b6a16fec7d5021e3922b0e34f9ddb268d54b1Owen Anderson  }
264d94b6a16fec7d5021e3922b0e34f9ddb268d54b1Owen Anderson
265d94b6a16fec7d5021e3922b0e34f9ddb268d54b1Owen Anderson  /// restoreCalleeSavedRegisters - Issues instruction(s) to restore all callee
266d94b6a16fec7d5021e3922b0e34f9ddb268d54b1Owen Anderson  /// saved registers and returns true if it isn't possible / profitable to do
267d94b6a16fec7d5021e3922b0e34f9ddb268d54b1Owen Anderson  /// so by issuing a series of load instructions via loadRegToStackSlot().
268d94b6a16fec7d5021e3922b0e34f9ddb268d54b1Owen Anderson  /// Returns false otherwise.
269d94b6a16fec7d5021e3922b0e34f9ddb268d54b1Owen Anderson  virtual bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
270d94b6a16fec7d5021e3922b0e34f9ddb268d54b1Owen Anderson                                           MachineBasicBlock::iterator MI,
271d94b6a16fec7d5021e3922b0e34f9ddb268d54b1Owen Anderson                                const std::vector<CalleeSavedInfo> &CSI) const {
272d94b6a16fec7d5021e3922b0e34f9ddb268d54b1Owen Anderson    return false;
273d94b6a16fec7d5021e3922b0e34f9ddb268d54b1Owen Anderson  }
274d94b6a16fec7d5021e3922b0e34f9ddb268d54b1Owen Anderson
27543dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson  /// foldMemoryOperand - Attempt to fold a load or store of the specified stack
27643dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson  /// slot into the specified machine instruction for the specified operand(s).
27743dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson  /// If this is possible, a new instruction is returned with the specified
27843dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson  /// operand folded, otherwise NULL is returned. The client is responsible for
27943dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson  /// removing the old instruction and adding the new one in the instruction
28043dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson  /// stream.
2815fd79d0560570fed977788a86fa038b898564dfaEvan Cheng  virtual MachineInstr* foldMemoryOperand(MachineFunction &MF,
2825fd79d0560570fed977788a86fa038b898564dfaEvan Cheng                                          MachineInstr* MI,
28343dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson                                          SmallVectorImpl<unsigned> &Ops,
28443dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson                                          int FrameIndex) const {
28543dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson    return 0;
28643dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson  }
28743dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson
28843dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson  /// foldMemoryOperand - Same as the previous version except it allows folding
28943dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson  /// of any load and store from / to any address, not just from a specific
29043dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson  /// stack slot.
2915fd79d0560570fed977788a86fa038b898564dfaEvan Cheng  virtual MachineInstr* foldMemoryOperand(MachineFunction &MF,
2925fd79d0560570fed977788a86fa038b898564dfaEvan Cheng                                          MachineInstr* MI,
29343dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson                                          SmallVectorImpl<unsigned> &Ops,
29443dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson                                          MachineInstr* LoadMI) const {
29543dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson    return 0;
29643dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson  }
29743dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson
29843dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson  /// canFoldMemoryOperand - Returns true if the specified load / store is
29943dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson  /// folding is possible.
30043dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson  virtual
30143dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson  bool canFoldMemoryOperand(MachineInstr *MI,
30243dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson                            SmallVectorImpl<unsigned> &Ops) const{
30343dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson    return false;
30443dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson  }
30543dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson
30643dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson  /// unfoldMemoryOperand - Separate a single instruction which folded a load or
30743dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson  /// a store or a load and a store into two or more instruction. If this is
30843dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson  /// possible, returns true as well as the new instructions by reference.
30943dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson  virtual bool unfoldMemoryOperand(MachineFunction &MF, MachineInstr *MI,
31043dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson                                unsigned Reg, bool UnfoldLoad, bool UnfoldStore,
31143dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson                                  SmallVectorImpl<MachineInstr*> &NewMIs) const{
31243dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson    return false;
31343dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson  }
31443dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson
31543dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson  virtual bool unfoldMemoryOperand(SelectionDAG &DAG, SDNode *N,
31643dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson                                   SmallVectorImpl<SDNode*> &NewNodes) const {
31743dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson    return false;
31843dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson  }
31943dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson
32043dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson  /// getOpcodeAfterMemoryUnfold - Returns the opcode of the would be new
32143dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson  /// instruction after load / store are unfolded from an instruction of the
32243dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson  /// specified opcode. It returns zero if the specified unfolding is not
32343dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson  /// possible.
32443dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson  virtual unsigned getOpcodeAfterMemoryUnfold(unsigned Opc,
32543dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson                                      bool UnfoldLoad, bool UnfoldStore) const {
32643dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson    return 0;
32743dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson  }
32843dbe05279b753aabda571d9c83eaeb36987001aOwen Anderson
329c24ff8ed12d01a1b1d2fac57876fc7580024ec49Chris Lattner  /// BlockHasNoFallThrough - Return true if the specified block does not
330c24ff8ed12d01a1b1d2fac57876fc7580024ec49Chris Lattner  /// fall-through into its successor block.  This is primarily used when a
331c24ff8ed12d01a1b1d2fac57876fc7580024ec49Chris Lattner  /// branch is unanalyzable.  It is useful for things like unconditional
332c24ff8ed12d01a1b1d2fac57876fc7580024ec49Chris Lattner  /// indirect branches (jump tables).
333c24ff8ed12d01a1b1d2fac57876fc7580024ec49Chris Lattner  virtual bool BlockHasNoFallThrough(MachineBasicBlock &MBB) const {
334c24ff8ed12d01a1b1d2fac57876fc7580024ec49Chris Lattner    return false;
335c24ff8ed12d01a1b1d2fac57876fc7580024ec49Chris Lattner  }
336c24ff8ed12d01a1b1d2fac57876fc7580024ec49Chris Lattner
3375f1e4dbdf77de6887441af20857967a3d24c01abChris Lattner  /// ReverseBranchCondition - Reverses the branch condition of the specified
3385f1e4dbdf77de6887441af20857967a3d24c01abChris Lattner  /// condition list, returning false on success and true if it cannot be
3395f1e4dbdf77de6887441af20857967a3d24c01abChris Lattner  /// reversed.
3405f1e4dbdf77de6887441af20857967a3d24c01abChris Lattner  virtual bool ReverseBranchCondition(std::vector<MachineOperand> &Cond) const {
3415f1e4dbdf77de6887441af20857967a3d24c01abChris Lattner    return true;
342905f7af59cb85ea71b6c011f1e79f24f8db16efcAlkis Evlogimenos  }
3430271077eba5f62796f4c725baa8e7fc88bf97650Chris Lattner
34465e9f3969bec427f14d41f0aaef12ed689ca85b5Chris Lattner  /// insertNoop - Insert a noop into the instruction stream at the specified
34565e9f3969bec427f14d41f0aaef12ed689ca85b5Chris Lattner  /// point.
34665e9f3969bec427f14d41f0aaef12ed689ca85b5Chris Lattner  virtual void insertNoop(MachineBasicBlock &MBB,
34765e9f3969bec427f14d41f0aaef12ed689ca85b5Chris Lattner                          MachineBasicBlock::iterator MI) const {
34865e9f3969bec427f14d41f0aaef12ed689ca85b5Chris Lattner    assert(0 && "Target didn't implement insertNoop!");
34965e9f3969bec427f14d41f0aaef12ed689ca85b5Chris Lattner    abort();
35065e9f3969bec427f14d41f0aaef12ed689ca85b5Chris Lattner  }
35121d03f2de0087d60dbf575d95924404a97852879Evan Cheng
352bfd2ec4a8ef51ebe982363a7e8d7156fdb3827d8Evan Cheng  /// isPredicated - Returns true if the instruction is already predicated.
3534f85cd77046d76bd9091aa6caa06e767bd22f64cEvan Cheng  ///
354f277ee4be7edabb759a7f78138b693d72d0c263fEvan Cheng  virtual bool isPredicated(const MachineInstr *MI) const {
3554f85cd77046d76bd9091aa6caa06e767bd22f64cEvan Cheng    return false;
3564f85cd77046d76bd9091aa6caa06e767bd22f64cEvan Cheng  }
3574f85cd77046d76bd9091aa6caa06e767bd22f64cEvan Cheng
358bfd2ec4a8ef51ebe982363a7e8d7156fdb3827d8Evan Cheng  /// isUnpredicatedTerminator - Returns true if the instruction is a
359bfd2ec4a8ef51ebe982363a7e8d7156fdb3827d8Evan Cheng  /// terminator instruction that has not been predicated.
360318093b6f8d21ac8eab34573b0526984895fe941Dale Johannesen  virtual bool isUnpredicatedTerminator(const MachineInstr *MI) const;
361bfd2ec4a8ef51ebe982363a7e8d7156fdb3827d8Evan Cheng
3620402e170e8058cc5256e0c7b94ae37484253d73dEvan Cheng  /// PredicateInstruction - Convert the instruction into a predicated
36302c602b333ed2a1a13a17981f3c3f2f5463d5e5cEvan Cheng  /// instruction. It returns true if the operation was successful.
364f277ee4be7edabb759a7f78138b693d72d0c263fEvan Cheng  virtual
365f277ee4be7edabb759a7f78138b693d72d0c263fEvan Cheng  bool PredicateInstruction(MachineInstr *MI,
366641055225092833197efe8e5bce01d50bcf1daaeChris Lattner                            const std::vector<MachineOperand> &Pred) const = 0;
3674f85cd77046d76bd9091aa6caa06e767bd22f64cEvan Cheng
368bfd2ec4a8ef51ebe982363a7e8d7156fdb3827d8Evan Cheng  /// SubsumesPredicate - Returns true if the first specified predicate
3694f85cd77046d76bd9091aa6caa06e767bd22f64cEvan Cheng  /// subsumes the second, e.g. GE subsumes GT.
370f277ee4be7edabb759a7f78138b693d72d0c263fEvan Cheng  virtual
371f277ee4be7edabb759a7f78138b693d72d0c263fEvan Cheng  bool SubsumesPredicate(const std::vector<MachineOperand> &Pred1,
372f277ee4be7edabb759a7f78138b693d72d0c263fEvan Cheng                         const std::vector<MachineOperand> &Pred2) const {
3734f85cd77046d76bd9091aa6caa06e767bd22f64cEvan Cheng    return false;
3744f85cd77046d76bd9091aa6caa06e767bd22f64cEvan Cheng  }
3750402e170e8058cc5256e0c7b94ae37484253d73dEvan Cheng
376ed80ef6089ef83bd1c79f1477d7a12a949474af5Evan Cheng  /// DefinesPredicate - If the specified instruction defines any predicate
377ed80ef6089ef83bd1c79f1477d7a12a949474af5Evan Cheng  /// or condition code register(s) used for predication, returns true as well
378ed80ef6089ef83bd1c79f1477d7a12a949474af5Evan Cheng  /// as the definition predicate(s) by reference.
379ed80ef6089ef83bd1c79f1477d7a12a949474af5Evan Cheng  virtual bool DefinesPredicate(MachineInstr *MI,
380ed80ef6089ef83bd1c79f1477d7a12a949474af5Evan Cheng                                std::vector<MachineOperand> &Pred) const {
381ed80ef6089ef83bd1c79f1477d7a12a949474af5Evan Cheng    return false;
382ed80ef6089ef83bd1c79f1477d7a12a949474af5Evan Cheng  }
383ed80ef6089ef83bd1c79f1477d7a12a949474af5Evan Cheng
38421d03f2de0087d60dbf575d95924404a97852879Evan Cheng  /// getPointerRegClass - Returns a TargetRegisterClass used for pointer
38521d03f2de0087d60dbf575d95924404a97852879Evan Cheng  /// values.
38621d03f2de0087d60dbf575d95924404a97852879Evan Cheng  virtual const TargetRegisterClass *getPointerRegClass() const {
38721d03f2de0087d60dbf575d95924404a97852879Evan Cheng    assert(0 && "Target didn't implement getPointerRegClass!");
38821d03f2de0087d60dbf575d95924404a97852879Evan Cheng    abort();
389fb062ece96092e70a835c0d462613b07228d60a3Jeff Cohen    return 0; // Must return a value in order to compile with VS 2005
39021d03f2de0087d60dbf575d95924404a97852879Evan Cheng  }
39152e724ad7e679ee590f4bd763d55280586a8f1bcNicolas Geoffray
39252e724ad7e679ee590f4bd763d55280586a8f1bcNicolas Geoffray  /// GetInstSize - Returns the size of the specified Instruction.
39352e724ad7e679ee590f4bd763d55280586a8f1bcNicolas Geoffray  ///
39452e724ad7e679ee590f4bd763d55280586a8f1bcNicolas Geoffray  virtual unsigned GetInstSizeInBytes(const MachineInstr *MI) const {
39552e724ad7e679ee590f4bd763d55280586a8f1bcNicolas Geoffray    assert(0 && "Target didn't implement TargetInstrInfo::GetInstSize!");
39652e724ad7e679ee590f4bd763d55280586a8f1bcNicolas Geoffray    return 0;
39752e724ad7e679ee590f4bd763d55280586a8f1bcNicolas Geoffray  }
39852e724ad7e679ee590f4bd763d55280586a8f1bcNicolas Geoffray
39952e724ad7e679ee590f4bd763d55280586a8f1bcNicolas Geoffray  /// GetFunctionSizeInBytes - Returns the size of the specified MachineFunction.
40052e724ad7e679ee590f4bd763d55280586a8f1bcNicolas Geoffray  ///
40152e724ad7e679ee590f4bd763d55280586a8f1bcNicolas Geoffray  virtual unsigned GetFunctionSizeInBytes(const MachineFunction &MF) const = 0;
40252e724ad7e679ee590f4bd763d55280586a8f1bcNicolas Geoffray
403a578a6d054e8219c730840700d8d5fd29f15a962Vikram S. Adve};
404a578a6d054e8219c730840700d8d5fd29f15a962Vikram S. Adve
405641055225092833197efe8e5bce01d50bcf1daaeChris Lattner/// TargetInstrInfoImpl - This is the default implementation of
406641055225092833197efe8e5bce01d50bcf1daaeChris Lattner/// TargetInstrInfo, which just provides a couple of default implementations
407641055225092833197efe8e5bce01d50bcf1daaeChris Lattner/// for various methods.  This separated out because it is implemented in
408641055225092833197efe8e5bce01d50bcf1daaeChris Lattner/// libcodegen, not in libtarget.
409641055225092833197efe8e5bce01d50bcf1daaeChris Lattnerclass TargetInstrInfoImpl : public TargetInstrInfo {
410641055225092833197efe8e5bce01d50bcf1daaeChris Lattnerprotected:
411749c6f6b5ed301c84aac562e414486549d7b98ebChris Lattner  TargetInstrInfoImpl(const TargetInstrDesc *desc, unsigned NumOpcodes)
412641055225092833197efe8e5bce01d50bcf1daaeChris Lattner  : TargetInstrInfo(desc, NumOpcodes) {}
413641055225092833197efe8e5bce01d50bcf1daaeChris Lattnerpublic:
414641055225092833197efe8e5bce01d50bcf1daaeChris Lattner  virtual MachineInstr *commuteInstruction(MachineInstr *MI) const;
415f20db159541bf27f5d2fdf8d4ba1c8b270b936dfEvan Cheng  virtual bool CommuteChangesDestination(MachineInstr *MI,
416f20db159541bf27f5d2fdf8d4ba1c8b270b936dfEvan Cheng                                         unsigned &OpIdx) const;
417641055225092833197efe8e5bce01d50bcf1daaeChris Lattner  virtual bool PredicateInstruction(MachineInstr *MI,
418641055225092833197efe8e5bce01d50bcf1daaeChris Lattner                              const std::vector<MachineOperand> &Pred) const;
419ca1267c02b025cc719190b05f9e1a5d174a9caf7Evan Cheng  virtual void reMaterialize(MachineBasicBlock &MBB,
420ca1267c02b025cc719190b05f9e1a5d174a9caf7Evan Cheng                             MachineBasicBlock::iterator MI,
421ca1267c02b025cc719190b05f9e1a5d174a9caf7Evan Cheng                             unsigned DestReg,
422ca1267c02b025cc719190b05f9e1a5d174a9caf7Evan Cheng                             const MachineInstr *Orig) const;
42352e724ad7e679ee590f4bd763d55280586a8f1bcNicolas Geoffray  virtual unsigned GetFunctionSizeInBytes(const MachineFunction &MF) const;
424641055225092833197efe8e5bce01d50bcf1daaeChris Lattner};
425641055225092833197efe8e5bce01d50bcf1daaeChris Lattner
426d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke} // End llvm namespace
427d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke
428a578a6d054e8219c730840700d8d5fd29f15a962Vikram S. Adve#endif
429