1 //===-- MipsSubtarget.h - Define Subtarget for the Mips ---------*- 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 declares the Mips specific subclass of TargetSubtargetInfo.
12 //===----------------------------------------------------------------------===//
14 #ifndef MIPSSUBTARGET_H
15 #define MIPSSUBTARGET_H
17 #include "llvm/MC/MCInstrItineraries.h"
18 #include "llvm/Support/ErrorHandling.h"
19 #include "llvm/Target/TargetSubtargetInfo.h"
22 #define GET_SUBTARGETINFO_HEADER
23 #include "MipsGenSubtargetInfo.inc"
28 class MipsTargetMachine;
30 class MipsSubtarget : public MipsGenSubtargetInfo {
31 virtual void anchor();
34 // NOTE: O64 will not be supported.
36 UnknownABI, O32, N32, N64, EABI
41 Mips1, Mips2, Mips32, Mips32r2, Mips32r6, Mips3, Mips4, Mips5, Mips64,
45 // Mips architecture version
46 MipsArchEnum MipsArchVersion;
48 // Mips supported ABIs
51 // IsLittle - The target is Little Endian
54 // IsSingleFloat - The target only supports single precision float
55 // point operations. This enable the target to use all 32 32-bit
56 // floating point registers instead of only using even ones.
59 // IsFP64bit - The target processor has 64-bit floating point registers.
62 // IsNan2008 - IEEE 754-2008 NaN encoding.
65 // IsFP64bit - General-purpose registers are 64 bits wide
68 // HasVFPU - Processor has a vector floating point unit.
71 // CPU supports cnMIPS (Cavium Networks Octeon CPU).
74 // isLinux - Target system is Linux. Is false we consider ELFOS for now.
77 // UseSmallSection - Small section is used.
80 /// Features related to the presence of specific instructions.
82 // HasMips3_32 - The subset of MIPS-III instructions added to MIPS32
85 // HasMips4_32 - Has the subset of MIPS-IV present in MIPS32
88 // HasMips4_32r2 - Has the subset of MIPS-IV present in MIPS32r2
91 // HasSEInReg - SEB and SEH (signext in register) instructions.
94 // HasSwap - Byte and half swap instructions.
97 // HasBitCount - Count leading '1' and '0' bits.
100 // InMips16 -- can process Mips16 instructions
104 bool InMips16HardFloat;
106 // PreviousInMips16 -- the function we just processed was in Mips 16 Mode
107 bool PreviousInMips16Mode;
109 // InMicroMips -- can process MicroMips instructions
110 bool InMicroMipsMode;
112 // HasDSP, HasDSPR2 -- supports DSP ASE.
113 bool HasDSP, HasDSPR2;
115 // Allow mixed Mips16 and Mips32 in one source file
116 bool AllowMixed16_32;
118 // Optimize for space by compiling all functions as Mips 16 unless
119 // it needs floating point. Functions needing floating point are
120 // compiled as Mips32
123 // HasMSA -- supports MSA ASE.
126 InstrItineraryData InstrItins;
131 // We can override the determination of whether we are in mips16 mode
132 // as from the command line
133 enum {NoOverride, Mips16Override, NoMips16Override} OverrideMode;
135 MipsTargetMachine *TM;
139 bool enablePostRAScheduler(CodeGenOpt::Level OptLevel,
140 AntiDepBreakMode& Mode,
141 RegClassVector& CriticalPathRCs) const override;
143 /// Only O32 and EABI supported right now.
144 bool isABI_EABI() const { return MipsABI == EABI; }
145 bool isABI_N64() const { return MipsABI == N64; }
146 bool isABI_N32() const { return MipsABI == N32; }
147 bool isABI_O32() const { return MipsABI == O32; }
148 unsigned getTargetABI() const { return MipsABI; }
150 /// This constructor initializes the data members to match that
151 /// of the specified triple.
152 MipsSubtarget(const std::string &TT, const std::string &CPU,
153 const std::string &FS, bool little, Reloc::Model RM,
154 MipsTargetMachine *TM);
156 /// ParseSubtargetFeatures - Parses features string setting specified
157 /// subtarget options. Definition of function is auto generated by tblgen.
158 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
160 bool hasMips2() const { return MipsArchVersion >= Mips2; }
161 bool hasMips3() const { return MipsArchVersion >= Mips3; }
162 bool hasMips4_32() const { return HasMips4_32; }
163 bool hasMips4_32r2() const { return HasMips4_32r2; }
164 bool hasMips32() const { return MipsArchVersion >= Mips32; }
165 bool hasMips32r2() const { return MipsArchVersion == Mips32r2 ||
166 MipsArchVersion == Mips64r2; }
167 bool hasMips32r6() const { return MipsArchVersion == Mips32r6 ||
168 MipsArchVersion == Mips64r6; }
169 bool hasMips64() const { return MipsArchVersion >= Mips64; }
170 bool hasMips64r2() const { return MipsArchVersion == Mips64r2; }
171 bool hasMips64r6() const { return MipsArchVersion == Mips64r6; }
173 bool hasCnMips() const { return HasCnMips; }
175 bool isLittle() const { return IsLittle; }
176 bool isFP64bit() const { return IsFP64bit; }
177 bool isNaN2008() const { return IsNaN2008bit; }
178 bool isNotFP64bit() const { return !IsFP64bit; }
179 bool isGP64bit() const { return IsGP64bit; }
180 bool isGP32bit() const { return !IsGP64bit; }
181 bool isSingleFloat() const { return IsSingleFloat; }
182 bool isNotSingleFloat() const { return !IsSingleFloat; }
183 bool hasVFPU() const { return HasVFPU; }
184 bool inMips16Mode() const {
185 switch (OverrideMode) {
190 case NoMips16Override:
193 llvm_unreachable("Unexpected mode");
195 bool inMips16ModeDefault() const {
198 bool inMips16HardFloat() const {
199 return inMips16Mode() && InMips16HardFloat;
201 bool inMicroMipsMode() const { return InMicroMipsMode; }
202 bool hasDSP() const { return HasDSP; }
203 bool hasDSPR2() const { return HasDSPR2; }
204 bool hasMSA() const { return HasMSA; }
205 bool isLinux() const { return IsLinux; }
206 bool useSmallSection() const { return UseSmallSection; }
208 bool hasStandardEncoding() const { return !inMips16Mode(); }
210 bool mipsSEUsesSoftFloat() const;
212 bool enableLongBranchPass() const {
213 return hasStandardEncoding() || allowMixed16_32();
216 /// Features related to the presence of specific instructions.
217 bool hasSEInReg() const { return HasSEInReg; }
218 bool hasSwap() const { return HasSwap; }
219 bool hasBitCount() const { return HasBitCount; }
220 bool hasExtractInsert() const { return !inMips16Mode() && hasMips32r2(); }
222 const InstrItineraryData &getInstrItineraryData() const { return InstrItins; }
223 bool allowMixed16_32() const { return inMips16ModeDefault() |
226 bool os16() const { return Os16;};
228 bool isTargetNaCl() const { return TargetTriple.isOSNaCl(); }
229 bool isNotTargetNaCl() const { return !TargetTriple.isOSNaCl(); }
231 // for now constant islands are on for the whole compilation unit but we only
232 // really use them if in addition we are in mips16 mode
233 static bool useConstantIslands();
235 unsigned stackAlignment() const { return hasMips64() ? 16 : 8; }
237 // Grab relocation model
238 Reloc::Model getRelocationModel() const {return RM;}
240 /// \brief Reset the subtarget for the Mips target.
241 void resetSubtarget(MachineFunction *MF);
245 } // End llvm namespace