LLVM API Documentation
00001 //===- PPCInstrInfo.h - PowerPC Instruction Information ---------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file contains the PowerPC implementation of the TargetInstrInfo class. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef POWERPC32_INSTRUCTIONINFO_H 00015 #define POWERPC32_INSTRUCTIONINFO_H 00016 00017 #include "PPC.h" 00018 #include "llvm/Target/TargetInstrInfo.h" 00019 #include "PPCRegisterInfo.h" 00020 00021 namespace llvm { 00022 00023 /// PPCII - This namespace holds all of the PowerPC target-specific 00024 /// per-instruction flags. These must match the corresponding definitions in 00025 /// PPC.td and PPCInstrFormats.td. 00026 namespace PPCII { 00027 enum { 00028 // PPC970 Instruction Flags. These flags describe the characteristics of the 00029 // PowerPC 970 (aka G5) dispatch groups and how they are formed out of 00030 // raw machine instructions. 00031 00032 /// PPC970_First - This instruction starts a new dispatch group, so it will 00033 /// always be the first one in the group. 00034 PPC970_First = 0x1, 00035 00036 /// PPC970_Single - This instruction starts a new dispatch group and 00037 /// terminates it, so it will be the sole instruction in the group. 00038 PPC970_Single = 0x2, 00039 00040 /// PPC970_Cracked - This instruction is cracked into two pieces, requiring 00041 /// two dispatch pipes to be available to issue. 00042 PPC970_Cracked = 0x4, 00043 00044 /// PPC970_Mask/Shift - This is a bitmask that selects the pipeline type that 00045 /// an instruction is issued to. 00046 PPC970_Shift = 3, 00047 PPC970_Mask = 0x07 << PPC970_Shift 00048 }; 00049 enum PPC970_Unit { 00050 /// These are the various PPC970 execution unit pipelines. Each instruction 00051 /// is one of these. 00052 PPC970_Pseudo = 0 << PPC970_Shift, // Pseudo instruction 00053 PPC970_FXU = 1 << PPC970_Shift, // Fixed Point (aka Integer/ALU) Unit 00054 PPC970_LSU = 2 << PPC970_Shift, // Load Store Unit 00055 PPC970_FPU = 3 << PPC970_Shift, // Floating Point Unit 00056 PPC970_CRU = 4 << PPC970_Shift, // Control Register Unit 00057 PPC970_VALU = 5 << PPC970_Shift, // Vector ALU 00058 PPC970_VPERM = 6 << PPC970_Shift, // Vector Permute Unit 00059 PPC970_BRU = 7 << PPC970_Shift // Branch Unit 00060 }; 00061 } 00062 00063 00064 class PPCInstrInfo : public TargetInstrInfoImpl { 00065 PPCTargetMachine &TM; 00066 const PPCRegisterInfo RI; 00067 00068 bool StoreRegToStackSlot(MachineFunction &MF, 00069 unsigned SrcReg, bool isKill, int FrameIdx, 00070 const TargetRegisterClass *RC, 00071 SmallVectorImpl<MachineInstr*> &NewMIs) const; 00072 void LoadRegFromStackSlot(MachineFunction &MF, 00073 unsigned DestReg, int FrameIdx, 00074 const TargetRegisterClass *RC, 00075 SmallVectorImpl<MachineInstr*> &NewMIs) const; 00076 public: 00077 explicit PPCInstrInfo(PPCTargetMachine &TM); 00078 00079 /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As 00080 /// such, whenever a client has an instance of instruction info, it should 00081 /// always be able to get register info as well (through this method). 00082 /// 00083 virtual const PPCRegisterInfo &getRegisterInfo() const { return RI; } 00084 00085 /// getPointerRegClass - Return the register class to use to hold pointers. 00086 /// This is used for addressing modes. 00087 virtual const TargetRegisterClass *getPointerRegClass() const; 00088 00089 // Return true if the instruction is a register to register move and 00090 // leave the source and dest operands in the passed parameters. 00091 // 00092 virtual bool isMoveInstr(const MachineInstr& MI, 00093 unsigned& sourceReg, 00094 unsigned& destReg) const; 00095 00096 unsigned isLoadFromStackSlot(const MachineInstr *MI, 00097 int &FrameIndex) const; 00098 unsigned isStoreToStackSlot(const MachineInstr *MI, 00099 int &FrameIndex) const; 00100 00101 // commuteInstruction - We can commute rlwimi instructions, but only if the 00102 // rotate amt is zero. We also have to munge the immediates a bit. 00103 virtual MachineInstr *commuteInstruction(MachineInstr *MI, bool NewMI) const; 00104 00105 virtual void insertNoop(MachineBasicBlock &MBB, 00106 MachineBasicBlock::iterator MI) const; 00107 00108 00109 // Branch analysis. 00110 virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, 00111 MachineBasicBlock *&FBB, 00112 SmallVectorImpl<MachineOperand> &Cond) const; 00113 virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const; 00114 virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, 00115 MachineBasicBlock *FBB, 00116 const SmallVectorImpl<MachineOperand> &Cond) const; 00117 virtual bool copyRegToReg(MachineBasicBlock &MBB, 00118 MachineBasicBlock::iterator MI, 00119 unsigned DestReg, unsigned SrcReg, 00120 const TargetRegisterClass *DestRC, 00121 const TargetRegisterClass *SrcRC) const; 00122 00123 virtual void storeRegToStackSlot(MachineBasicBlock &MBB, 00124 MachineBasicBlock::iterator MBBI, 00125 unsigned SrcReg, bool isKill, int FrameIndex, 00126 const TargetRegisterClass *RC) const; 00127 00128 virtual void storeRegToAddr(MachineFunction &MF, unsigned SrcReg, bool isKill, 00129 SmallVectorImpl<MachineOperand> &Addr, 00130 const TargetRegisterClass *RC, 00131 SmallVectorImpl<MachineInstr*> &NewMIs) const; 00132 00133 virtual void loadRegFromStackSlot(MachineBasicBlock &MBB, 00134 MachineBasicBlock::iterator MBBI, 00135 unsigned DestReg, int FrameIndex, 00136 const TargetRegisterClass *RC) const; 00137 00138 virtual void loadRegFromAddr(MachineFunction &MF, unsigned DestReg, 00139 SmallVectorImpl<MachineOperand> &Addr, 00140 const TargetRegisterClass *RC, 00141 SmallVectorImpl<MachineInstr*> &NewMIs) const; 00142 00143 /// foldMemoryOperand - PowerPC (like most RISC's) can only fold spills into 00144 /// copy instructions, turning them into load/store instructions. 00145 virtual MachineInstr* foldMemoryOperandImpl(MachineFunction &MF, 00146 MachineInstr* MI, 00147 const SmallVectorImpl<unsigned> &Ops, 00148 int FrameIndex) const; 00149 00150 virtual MachineInstr* foldMemoryOperandImpl(MachineFunction &MF, 00151 MachineInstr* MI, 00152 const SmallVectorImpl<unsigned> &Ops, 00153 MachineInstr* LoadMI) const { 00154 return 0; 00155 } 00156 00157 virtual bool canFoldMemoryOperand(const MachineInstr *MI, 00158 const SmallVectorImpl<unsigned> &Ops) const; 00159 00160 virtual bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const; 00161 virtual 00162 bool ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const; 00163 00164 /// GetInstSize - Return the number of bytes of code the specified 00165 /// instruction may be. This returns the maximum number of bytes. 00166 /// 00167 virtual unsigned GetInstSizeInBytes(const MachineInstr *MI) const; 00168 }; 00169 00170 } 00171 00172 #endif
This web site is hosted by the Computer Science Department at the University of Illinois at Urbana-Champaign.