1 //===- MBlazeInstrInfo.h - MBlaze Instruction Information -------*- 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 contains the MBlaze implementation of the TargetInstrInfo class.
12 //===----------------------------------------------------------------------===//
14 #ifndef MBLAZEINSTRUCTIONINFO_H
15 #define MBLAZEINSTRUCTIONINFO_H
18 #include "llvm/Support/ErrorHandling.h"
19 #include "llvm/Target/TargetInstrInfo.h"
20 #include "MBlazeRegisterInfo.h"
26 // MBlaze Branch Codes
35 // MBlaze Condition Codes
37 // To be used with float branch True
55 // To be used with float branch False
56 // This conditions have the same mnemonic as the
57 // above ones, but are used with a branch False;
75 // Only integer conditions
85 // Turn condition code into conditional branch opcode.
86 unsigned GetCondBranchFromCond(CondCode CC);
88 /// GetOppositeBranchCondition - Return the inverse of the specified cond,
89 /// e.g. turning COND_E to COND_NE.
90 CondCode GetOppositeBranchCondition(MBlaze::CondCode CC);
92 /// MBlazeCCToString - Map each FP condition code to its string
93 inline static const char *MBlazeFCCToString(MBlaze::CondCode CC)
96 default: llvm_unreachable("Unknown condition code");
98 case FCOND_T: return "f";
100 case FCOND_OR: return "un";
102 case FCOND_NEQ: return "eq";
104 case FCOND_OGL: return "ueq";
106 case FCOND_UGE: return "olt";
108 case FCOND_OGE: return "ult";
110 case FCOND_UGT: return "ole";
112 case FCOND_OGT: return "ule";
114 case FCOND_ST: return "sf";
116 case FCOND_GLE: return "ngle";
118 case FCOND_SNE: return "seq";
120 case FCOND_GL: return "ngl";
122 case FCOND_NLT: return "lt";
124 case FCOND_GE: return "ge";
126 case FCOND_NLE: return "nle";
128 case FCOND_GT: return "gt";
133 /// MBlazeII - This namespace holds all of the target specific flags that
134 /// instruction info tracks.
138 // PseudoFrm - This represents an instruction that is a pseudo instruction
139 // or one that has not been implemented yet. It is illegal to code generate
140 // it, but tolerated for intermediate implementation stages.
164 //===------------------------------------------------------------------===//
165 // MBlaze Specific MachineOperand flags.
168 /// MO_GOT - Represents the offset into the global offset table at which
169 /// the address the relocation entry symbol resides during execution.
172 /// MO_GOT_CALL - Represents the offset into the global offset table at
173 /// which the address of a call site relocation entry symbol resides
174 /// during execution. This is different from the above since this flag
175 /// can only be present in call instructions.
178 /// MO_GPREL - Represents the offset from the current gp value to be used
179 /// for the relocatable object file being produced.
182 /// MO_ABS_HILO - Represents the hi or low part of an absolute symbol
189 class MBlazeInstrInfo : public TargetInstrInfoImpl {
190 MBlazeTargetMachine &TM;
191 const MBlazeRegisterInfo RI;
193 explicit MBlazeInstrInfo(MBlazeTargetMachine &TM);
195 /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
196 /// such, whenever a client has an instance of instruction info, it should
197 /// always be able to get register info as well (through this method).
199 virtual const MBlazeRegisterInfo &getRegisterInfo() const { return RI; }
201 /// isLoadFromStackSlot - If the specified machine instruction is a direct
202 /// load from a stack slot, return the virtual or physical register number of
203 /// the destination along with the FrameIndex of the loaded stack slot. If
204 /// not, return 0. This predicate must return 0 if the instruction has
205 /// any side effects other than loading from the stack slot.
206 virtual unsigned isLoadFromStackSlot(const MachineInstr *MI,
207 int &FrameIndex) const;
209 /// isStoreToStackSlot - If the specified machine instruction is a direct
210 /// store to a stack slot, return the virtual or physical register number of
211 /// the source reg along with the FrameIndex of the loaded stack slot. If
212 /// not, return 0. This predicate must return 0 if the instruction has
213 /// any side effects other than storing to the stack slot.
214 virtual unsigned isStoreToStackSlot(const MachineInstr *MI,
215 int &FrameIndex) const;
218 virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
219 MachineBasicBlock *FBB,
220 const SmallVectorImpl<MachineOperand> &Cond,
222 virtual void copyPhysReg(MachineBasicBlock &MBB,
223 MachineBasicBlock::iterator I, DebugLoc DL,
224 unsigned DestReg, unsigned SrcReg,
226 virtual void storeRegToStackSlot(MachineBasicBlock &MBB,
227 MachineBasicBlock::iterator MBBI,
228 unsigned SrcReg, bool isKill, int FrameIndex,
229 const TargetRegisterClass *RC,
230 const TargetRegisterInfo *TRI) const;
232 virtual void loadRegFromStackSlot(MachineBasicBlock &MBB,
233 MachineBasicBlock::iterator MBBI,
234 unsigned DestReg, int FrameIndex,
235 const TargetRegisterClass *RC,
236 const TargetRegisterInfo *TRI) const;
238 /// Insert nop instruction when hazard condition is found
239 virtual void insertNoop(MachineBasicBlock &MBB,
240 MachineBasicBlock::iterator MI) const;
242 /// getGlobalBaseReg - Return a virtual register initialized with the
243 /// the global base register value. Output instructions required to
244 /// initialize the register in the function entry block, if necessary.
246 unsigned getGlobalBaseReg(MachineFunction *MF) const;