xref: /freebsd/contrib/llvm-project/llvm/lib/Target/Mips/MipsSubtarget.h (revision e8d8bef961a50d4dc22501cde4fb9fb0be1b2532)
10b57cec5SDimitry Andric //===-- MipsSubtarget.h - Define Subtarget for the Mips ---------*- C++ -*-===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric //
90b57cec5SDimitry Andric // This file declares the Mips specific subclass of TargetSubtargetInfo.
100b57cec5SDimitry Andric //
110b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
120b57cec5SDimitry Andric 
130b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_MIPS_MIPSSUBTARGET_H
140b57cec5SDimitry Andric #define LLVM_LIB_TARGET_MIPS_MIPSSUBTARGET_H
150b57cec5SDimitry Andric 
160b57cec5SDimitry Andric #include "MCTargetDesc/MipsABIInfo.h"
170b57cec5SDimitry Andric #include "MipsFrameLowering.h"
180b57cec5SDimitry Andric #include "MipsISelLowering.h"
190b57cec5SDimitry Andric #include "MipsInstrInfo.h"
200b57cec5SDimitry Andric #include "llvm/CodeGen/SelectionDAGTargetInfo.h"
210b57cec5SDimitry Andric #include "llvm/CodeGen/TargetSubtargetInfo.h"
220b57cec5SDimitry Andric #include "llvm/CodeGen/GlobalISel/CallLowering.h"
230b57cec5SDimitry Andric #include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
240b57cec5SDimitry Andric #include "llvm/CodeGen/GlobalISel/RegisterBankInfo.h"
250b57cec5SDimitry Andric #include "llvm/CodeGen/GlobalISel/InstructionSelector.h"
260b57cec5SDimitry Andric #include "llvm/IR/DataLayout.h"
270b57cec5SDimitry Andric #include "llvm/MC/MCInstrItineraries.h"
280b57cec5SDimitry Andric #include "llvm/Support/ErrorHandling.h"
290b57cec5SDimitry Andric #include <string>
300b57cec5SDimitry Andric 
310b57cec5SDimitry Andric #define GET_SUBTARGETINFO_HEADER
320b57cec5SDimitry Andric #include "MipsGenSubtargetInfo.inc"
330b57cec5SDimitry Andric 
340b57cec5SDimitry Andric namespace llvm {
350b57cec5SDimitry Andric class StringRef;
360b57cec5SDimitry Andric 
370b57cec5SDimitry Andric class MipsTargetMachine;
380b57cec5SDimitry Andric 
390b57cec5SDimitry Andric class MipsSubtarget : public MipsGenSubtargetInfo {
400b57cec5SDimitry Andric   virtual void anchor();
410b57cec5SDimitry Andric 
420b57cec5SDimitry Andric   enum MipsArchEnum {
430b57cec5SDimitry Andric     MipsDefault,
440b57cec5SDimitry Andric     Mips1, Mips2, Mips32, Mips32r2, Mips32r3, Mips32r5, Mips32r6, Mips32Max,
450b57cec5SDimitry Andric     Mips3, Mips4, Mips5, Mips64, Mips64r2, Mips64r3, Mips64r5, Mips64r6
460b57cec5SDimitry Andric   };
470b57cec5SDimitry Andric 
480b57cec5SDimitry Andric   enum class CPU { P5600 };
490b57cec5SDimitry Andric 
500b57cec5SDimitry Andric   // Used to avoid printing dsp warnings multiple times.
510b57cec5SDimitry Andric   static bool DspWarningPrinted;
520b57cec5SDimitry Andric 
530b57cec5SDimitry Andric   // Used to avoid printing msa warnings multiple times.
540b57cec5SDimitry Andric   static bool MSAWarningPrinted;
550b57cec5SDimitry Andric 
560b57cec5SDimitry Andric   // Used to avoid printing crc warnings multiple times.
570b57cec5SDimitry Andric   static bool CRCWarningPrinted;
580b57cec5SDimitry Andric 
590b57cec5SDimitry Andric   // Used to avoid printing ginv warnings multiple times.
600b57cec5SDimitry Andric   static bool GINVWarningPrinted;
610b57cec5SDimitry Andric 
620b57cec5SDimitry Andric   // Used to avoid printing virt warnings multiple times.
630b57cec5SDimitry Andric   static bool VirtWarningPrinted;
640b57cec5SDimitry Andric 
650b57cec5SDimitry Andric   // Mips architecture version
660b57cec5SDimitry Andric   MipsArchEnum MipsArchVersion;
670b57cec5SDimitry Andric 
680b57cec5SDimitry Andric   // Processor implementation (unused but required to exist by
690b57cec5SDimitry Andric   // tablegen-erated code).
700b57cec5SDimitry Andric   CPU ProcImpl;
710b57cec5SDimitry Andric 
720b57cec5SDimitry Andric   // IsLittle - The target is Little Endian
730b57cec5SDimitry Andric   bool IsLittle;
740b57cec5SDimitry Andric 
750b57cec5SDimitry Andric   // IsSoftFloat - The target does not support any floating point instructions.
760b57cec5SDimitry Andric   bool IsSoftFloat;
770b57cec5SDimitry Andric 
780b57cec5SDimitry Andric   // IsSingleFloat - The target only supports single precision float
790b57cec5SDimitry Andric   // point operations. This enable the target to use all 32 32-bit
800b57cec5SDimitry Andric   // floating point registers instead of only using even ones.
810b57cec5SDimitry Andric   bool IsSingleFloat;
820b57cec5SDimitry Andric 
830b57cec5SDimitry Andric   // IsFPXX - MIPS O32 modeless ABI.
840b57cec5SDimitry Andric   bool IsFPXX;
850b57cec5SDimitry Andric 
860b57cec5SDimitry Andric   // NoABICalls - Disable SVR4-style position-independent code.
870b57cec5SDimitry Andric   bool NoABICalls;
880b57cec5SDimitry Andric 
890b57cec5SDimitry Andric   // Abs2008 - Use IEEE 754-2008 abs.fmt instruction.
900b57cec5SDimitry Andric   bool Abs2008;
910b57cec5SDimitry Andric 
920b57cec5SDimitry Andric   // IsFP64bit - The target processor has 64-bit floating point registers.
930b57cec5SDimitry Andric   bool IsFP64bit;
940b57cec5SDimitry Andric 
950b57cec5SDimitry Andric   /// Are odd single-precision registers permitted?
960b57cec5SDimitry Andric   /// This corresponds to -modd-spreg and -mno-odd-spreg
970b57cec5SDimitry Andric   bool UseOddSPReg;
980b57cec5SDimitry Andric 
990b57cec5SDimitry Andric   // IsNan2008 - IEEE 754-2008 NaN encoding.
1000b57cec5SDimitry Andric   bool IsNaN2008bit;
1010b57cec5SDimitry Andric 
1020b57cec5SDimitry Andric   // IsGP64bit - General-purpose registers are 64 bits wide
1030b57cec5SDimitry Andric   bool IsGP64bit;
1040b57cec5SDimitry Andric 
1050b57cec5SDimitry Andric   // IsPTR64bit - Pointers are 64 bit wide
1060b57cec5SDimitry Andric   bool IsPTR64bit;
1070b57cec5SDimitry Andric 
1080b57cec5SDimitry Andric   // HasVFPU - Processor has a vector floating point unit.
1090b57cec5SDimitry Andric   bool HasVFPU;
1100b57cec5SDimitry Andric 
1110b57cec5SDimitry Andric   // CPU supports cnMIPS (Cavium Networks Octeon CPU).
1120b57cec5SDimitry Andric   bool HasCnMips;
1130b57cec5SDimitry Andric 
1140b57cec5SDimitry Andric   // CPU supports cnMIPSP (Cavium Networks Octeon+ CPU).
1150b57cec5SDimitry Andric   bool HasCnMipsP;
1160b57cec5SDimitry Andric 
1170b57cec5SDimitry Andric   // isLinux - Target system is Linux. Is false we consider ELFOS for now.
1180b57cec5SDimitry Andric   bool IsLinux;
1190b57cec5SDimitry Andric 
1200b57cec5SDimitry Andric   // UseSmallSection - Small section is used.
1210b57cec5SDimitry Andric   bool UseSmallSection;
1220b57cec5SDimitry Andric 
1230b57cec5SDimitry Andric   /// Features related to the presence of specific instructions.
1240b57cec5SDimitry Andric 
1250b57cec5SDimitry Andric   // HasMips3_32 - The subset of MIPS-III instructions added to MIPS32
1260b57cec5SDimitry Andric   bool HasMips3_32;
1270b57cec5SDimitry Andric 
1280b57cec5SDimitry Andric   // HasMips3_32r2 - The subset of MIPS-III instructions added to MIPS32r2
1290b57cec5SDimitry Andric   bool HasMips3_32r2;
1300b57cec5SDimitry Andric 
1310b57cec5SDimitry Andric   // HasMips4_32 - Has the subset of MIPS-IV present in MIPS32
1320b57cec5SDimitry Andric   bool HasMips4_32;
1330b57cec5SDimitry Andric 
1340b57cec5SDimitry Andric   // HasMips4_32r2 - Has the subset of MIPS-IV present in MIPS32r2
1350b57cec5SDimitry Andric   bool HasMips4_32r2;
1360b57cec5SDimitry Andric 
1370b57cec5SDimitry Andric   // HasMips5_32r2 - Has the subset of MIPS-V present in MIPS32r2
1380b57cec5SDimitry Andric   bool HasMips5_32r2;
1390b57cec5SDimitry Andric 
1400b57cec5SDimitry Andric   // InMips16 -- can process Mips16 instructions
1410b57cec5SDimitry Andric   bool InMips16Mode;
1420b57cec5SDimitry Andric 
1430b57cec5SDimitry Andric   // Mips16 hard float
1440b57cec5SDimitry Andric   bool InMips16HardFloat;
1450b57cec5SDimitry Andric 
1460b57cec5SDimitry Andric   // InMicroMips -- can process MicroMips instructions
1470b57cec5SDimitry Andric   bool InMicroMipsMode;
1480b57cec5SDimitry Andric 
1490b57cec5SDimitry Andric   // HasDSP, HasDSPR2, HasDSPR3 -- supports DSP ASE.
1500b57cec5SDimitry Andric   bool HasDSP, HasDSPR2, HasDSPR3;
1510b57cec5SDimitry Andric 
1525ffd83dbSDimitry Andric   // Has3D -- Supports Mips3D ASE.
1535ffd83dbSDimitry Andric   bool Has3D;
1545ffd83dbSDimitry Andric 
1550b57cec5SDimitry Andric   // Allow mixed Mips16 and Mips32 in one source file
1560b57cec5SDimitry Andric   bool AllowMixed16_32;
1570b57cec5SDimitry Andric 
1580b57cec5SDimitry Andric   // Optimize for space by compiling all functions as Mips 16 unless
1590b57cec5SDimitry Andric   // it needs floating point. Functions needing floating point are
1600b57cec5SDimitry Andric   // compiled as Mips32
1610b57cec5SDimitry Andric   bool Os16;
1620b57cec5SDimitry Andric 
1630b57cec5SDimitry Andric   // HasMSA -- supports MSA ASE.
1640b57cec5SDimitry Andric   bool HasMSA;
1650b57cec5SDimitry Andric 
1660b57cec5SDimitry Andric   // UseTCCInDIV -- Enables the use of trapping in the assembler.
1670b57cec5SDimitry Andric   bool UseTCCInDIV;
1680b57cec5SDimitry Andric 
1690b57cec5SDimitry Andric   // Sym32 -- On Mips64 symbols are 32 bits.
1700b57cec5SDimitry Andric   bool HasSym32;
1710b57cec5SDimitry Andric 
1720b57cec5SDimitry Andric   // HasEVA -- supports EVA ASE.
1730b57cec5SDimitry Andric   bool HasEVA;
1740b57cec5SDimitry Andric 
1750b57cec5SDimitry Andric   // nomadd4 - disables generation of 4-operand madd.s, madd.d and
1760b57cec5SDimitry Andric   // related instructions.
1770b57cec5SDimitry Andric   bool DisableMadd4;
1780b57cec5SDimitry Andric 
1790b57cec5SDimitry Andric   // HasMT -- support MT ASE.
1800b57cec5SDimitry Andric   bool HasMT;
1810b57cec5SDimitry Andric 
1820b57cec5SDimitry Andric   // HasCRC -- supports R6 CRC ASE
1830b57cec5SDimitry Andric   bool HasCRC;
1840b57cec5SDimitry Andric 
1850b57cec5SDimitry Andric   // HasVirt -- supports Virtualization ASE
1860b57cec5SDimitry Andric   bool HasVirt;
1870b57cec5SDimitry Andric 
1880b57cec5SDimitry Andric   // HasGINV -- supports R6 Global INValidate ASE
1890b57cec5SDimitry Andric   bool HasGINV;
1900b57cec5SDimitry Andric 
1910b57cec5SDimitry Andric   // Use hazard variants of the jump register instructions for indirect
1920b57cec5SDimitry Andric   // function calls and jump tables.
1930b57cec5SDimitry Andric   bool UseIndirectJumpsHazard;
1940b57cec5SDimitry Andric 
1950b57cec5SDimitry Andric   // Disable use of the `jal` instruction.
1960b57cec5SDimitry Andric   bool UseLongCalls = false;
1970b57cec5SDimitry Andric 
1988bcb0991SDimitry Andric   // Assume 32-bit GOT.
1998bcb0991SDimitry Andric   bool UseXGOT = false;
2008bcb0991SDimitry Andric 
2010b57cec5SDimitry Andric   /// The minimum alignment known to hold of the stack frame on
2020b57cec5SDimitry Andric   /// entry to the function and which must be maintained by every function.
2038bcb0991SDimitry Andric   Align stackAlignment;
2040b57cec5SDimitry Andric 
2050b57cec5SDimitry Andric   /// The overridden stack alignment.
2068bcb0991SDimitry Andric   MaybeAlign StackAlignOverride;
2070b57cec5SDimitry Andric 
2080b57cec5SDimitry Andric   InstrItineraryData InstrItins;
2090b57cec5SDimitry Andric 
2100b57cec5SDimitry Andric   // We can override the determination of whether we are in mips16 mode
2110b57cec5SDimitry Andric   // as from the command line
2120b57cec5SDimitry Andric   enum {NoOverride, Mips16Override, NoMips16Override} OverrideMode;
2130b57cec5SDimitry Andric 
2140b57cec5SDimitry Andric   const MipsTargetMachine &TM;
2150b57cec5SDimitry Andric 
2160b57cec5SDimitry Andric   Triple TargetTriple;
2170b57cec5SDimitry Andric 
2180b57cec5SDimitry Andric   const SelectionDAGTargetInfo TSInfo;
2190b57cec5SDimitry Andric   std::unique_ptr<const MipsInstrInfo> InstrInfo;
2200b57cec5SDimitry Andric   std::unique_ptr<const MipsFrameLowering> FrameLowering;
2210b57cec5SDimitry Andric   std::unique_ptr<const MipsTargetLowering> TLInfo;
2220b57cec5SDimitry Andric 
2230b57cec5SDimitry Andric public:
2240b57cec5SDimitry Andric   bool isPositionIndependent() const;
2250b57cec5SDimitry Andric   /// This overrides the PostRAScheduler bit in the SchedModel for each CPU.
2260b57cec5SDimitry Andric   bool enablePostRAScheduler() const override;
2270b57cec5SDimitry Andric   void getCriticalPathRCs(RegClassVector &CriticalPathRCs) const override;
2280b57cec5SDimitry Andric   CodeGenOpt::Level getOptLevelToEnablePostRAScheduler() const override;
2290b57cec5SDimitry Andric 
2300b57cec5SDimitry Andric   bool isABI_N64() const;
2310b57cec5SDimitry Andric   bool isABI_N32() const;
2320b57cec5SDimitry Andric   bool isABI_O32() const;
2330b57cec5SDimitry Andric   const MipsABIInfo &getABI() const;
2340b57cec5SDimitry Andric   bool isABI_FPXX() const { return isABI_O32() && IsFPXX; }
2350b57cec5SDimitry Andric 
2360b57cec5SDimitry Andric   /// This constructor initializes the data members to match that
2370b57cec5SDimitry Andric   /// of the specified triple.
2380b57cec5SDimitry Andric   MipsSubtarget(const Triple &TT, StringRef CPU, StringRef FS, bool little,
2398bcb0991SDimitry Andric                 const MipsTargetMachine &TM, MaybeAlign StackAlignOverride);
2400b57cec5SDimitry Andric 
2410b57cec5SDimitry Andric   /// ParseSubtargetFeatures - Parses features string setting specified
2420b57cec5SDimitry Andric   /// subtarget options.  Definition of function is auto generated by tblgen.
243*e8d8bef9SDimitry Andric   void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);
2440b57cec5SDimitry Andric 
2450b57cec5SDimitry Andric   bool hasMips1() const { return MipsArchVersion >= Mips1; }
2460b57cec5SDimitry Andric   bool hasMips2() const { return MipsArchVersion >= Mips2; }
2470b57cec5SDimitry Andric   bool hasMips3() const { return MipsArchVersion >= Mips3; }
2480b57cec5SDimitry Andric   bool hasMips4() const { return MipsArchVersion >= Mips4; }
2490b57cec5SDimitry Andric   bool hasMips5() const { return MipsArchVersion >= Mips5; }
2500b57cec5SDimitry Andric   bool hasMips4_32() const { return HasMips4_32; }
2510b57cec5SDimitry Andric   bool hasMips4_32r2() const { return HasMips4_32r2; }
2520b57cec5SDimitry Andric   bool hasMips32() const {
2530b57cec5SDimitry Andric     return (MipsArchVersion >= Mips32 && MipsArchVersion < Mips32Max) ||
2540b57cec5SDimitry Andric            hasMips64();
2550b57cec5SDimitry Andric   }
2560b57cec5SDimitry Andric   bool hasMips32r2() const {
2570b57cec5SDimitry Andric     return (MipsArchVersion >= Mips32r2 && MipsArchVersion < Mips32Max) ||
2580b57cec5SDimitry Andric            hasMips64r2();
2590b57cec5SDimitry Andric   }
2600b57cec5SDimitry Andric   bool hasMips32r3() const {
2610b57cec5SDimitry Andric     return (MipsArchVersion >= Mips32r3 && MipsArchVersion < Mips32Max) ||
2620b57cec5SDimitry Andric            hasMips64r2();
2630b57cec5SDimitry Andric   }
2640b57cec5SDimitry Andric   bool hasMips32r5() const {
2650b57cec5SDimitry Andric     return (MipsArchVersion >= Mips32r5 && MipsArchVersion < Mips32Max) ||
2660b57cec5SDimitry Andric            hasMips64r5();
2670b57cec5SDimitry Andric   }
2680b57cec5SDimitry Andric   bool hasMips32r6() const {
2690b57cec5SDimitry Andric     return (MipsArchVersion >= Mips32r6 && MipsArchVersion < Mips32Max) ||
2700b57cec5SDimitry Andric            hasMips64r6();
2710b57cec5SDimitry Andric   }
2720b57cec5SDimitry Andric   bool hasMips64() const { return MipsArchVersion >= Mips64; }
2730b57cec5SDimitry Andric   bool hasMips64r2() const { return MipsArchVersion >= Mips64r2; }
2740b57cec5SDimitry Andric   bool hasMips64r3() const { return MipsArchVersion >= Mips64r3; }
2750b57cec5SDimitry Andric   bool hasMips64r5() const { return MipsArchVersion >= Mips64r5; }
2760b57cec5SDimitry Andric   bool hasMips64r6() const { return MipsArchVersion >= Mips64r6; }
2770b57cec5SDimitry Andric 
2780b57cec5SDimitry Andric   bool hasCnMips() const { return HasCnMips; }
2790b57cec5SDimitry Andric   bool hasCnMipsP() const { return HasCnMipsP; }
2800b57cec5SDimitry Andric 
2810b57cec5SDimitry Andric   bool isLittle() const { return IsLittle; }
2820b57cec5SDimitry Andric   bool isABICalls() const { return !NoABICalls; }
2830b57cec5SDimitry Andric   bool isFPXX() const { return IsFPXX; }
2840b57cec5SDimitry Andric   bool isFP64bit() const { return IsFP64bit; }
2850b57cec5SDimitry Andric   bool useOddSPReg() const { return UseOddSPReg; }
2860b57cec5SDimitry Andric   bool noOddSPReg() const { return !UseOddSPReg; }
2870b57cec5SDimitry Andric   bool isNaN2008() const { return IsNaN2008bit; }
2880b57cec5SDimitry Andric   bool inAbs2008Mode() const { return Abs2008; }
2890b57cec5SDimitry Andric   bool isGP64bit() const { return IsGP64bit; }
2900b57cec5SDimitry Andric   bool isGP32bit() const { return !IsGP64bit; }
2910b57cec5SDimitry Andric   unsigned getGPRSizeInBytes() const { return isGP64bit() ? 8 : 4; }
2920b57cec5SDimitry Andric   bool isPTR64bit() const { return IsPTR64bit; }
2930b57cec5SDimitry Andric   bool isPTR32bit() const { return !IsPTR64bit; }
2940b57cec5SDimitry Andric   bool hasSym32() const {
2950b57cec5SDimitry Andric     return (HasSym32 && isABI_N64()) || isABI_N32() || isABI_O32();
2960b57cec5SDimitry Andric   }
2970b57cec5SDimitry Andric   bool isSingleFloat() const { return IsSingleFloat; }
2980b57cec5SDimitry Andric   bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); }
2990b57cec5SDimitry Andric   bool hasVFPU() const { return HasVFPU; }
3000b57cec5SDimitry Andric   bool inMips16Mode() const { return InMips16Mode; }
3010b57cec5SDimitry Andric   bool inMips16ModeDefault() const {
3020b57cec5SDimitry Andric     return InMips16Mode;
3030b57cec5SDimitry Andric   }
3040b57cec5SDimitry Andric   // Hard float for mips16 means essentially to compile as soft float
3050b57cec5SDimitry Andric   // but to use a runtime library for soft float that is written with
3060b57cec5SDimitry Andric   // native mips32 floating point instructions (those runtime routines
3070b57cec5SDimitry Andric   // run in mips32 hard float mode).
3080b57cec5SDimitry Andric   bool inMips16HardFloat() const {
3090b57cec5SDimitry Andric     return inMips16Mode() && InMips16HardFloat;
3100b57cec5SDimitry Andric   }
3110b57cec5SDimitry Andric   bool inMicroMipsMode() const { return InMicroMipsMode && !InMips16Mode; }
3120b57cec5SDimitry Andric   bool inMicroMips32r6Mode() const {
3130b57cec5SDimitry Andric     return inMicroMipsMode() && hasMips32r6();
3140b57cec5SDimitry Andric   }
3150b57cec5SDimitry Andric   bool hasDSP() const { return HasDSP; }
3160b57cec5SDimitry Andric   bool hasDSPR2() const { return HasDSPR2; }
3170b57cec5SDimitry Andric   bool hasDSPR3() const { return HasDSPR3; }
3185ffd83dbSDimitry Andric   bool has3D() const { return Has3D; }
3190b57cec5SDimitry Andric   bool hasMSA() const { return HasMSA; }
3200b57cec5SDimitry Andric   bool disableMadd4() const { return DisableMadd4; }
3210b57cec5SDimitry Andric   bool hasEVA() const { return HasEVA; }
3220b57cec5SDimitry Andric   bool hasMT() const { return HasMT; }
3230b57cec5SDimitry Andric   bool hasCRC() const { return HasCRC; }
3240b57cec5SDimitry Andric   bool hasVirt() const { return HasVirt; }
3250b57cec5SDimitry Andric   bool hasGINV() const { return HasGINV; }
3260b57cec5SDimitry Andric   bool useIndirectJumpsHazard() const {
3270b57cec5SDimitry Andric     return UseIndirectJumpsHazard && hasMips32r2();
3280b57cec5SDimitry Andric   }
3290b57cec5SDimitry Andric   bool useSmallSection() const { return UseSmallSection; }
3300b57cec5SDimitry Andric 
3310b57cec5SDimitry Andric   bool hasStandardEncoding() const { return !InMips16Mode && !InMicroMipsMode; }
3320b57cec5SDimitry Andric 
3330b57cec5SDimitry Andric   bool useSoftFloat() const { return IsSoftFloat; }
3340b57cec5SDimitry Andric 
3350b57cec5SDimitry Andric   bool useLongCalls() const { return UseLongCalls; }
3360b57cec5SDimitry Andric 
3378bcb0991SDimitry Andric   bool useXGOT() const { return UseXGOT; }
3388bcb0991SDimitry Andric 
3390b57cec5SDimitry Andric   bool enableLongBranchPass() const {
3400b57cec5SDimitry Andric     return hasStandardEncoding() || inMicroMipsMode() || allowMixed16_32();
3410b57cec5SDimitry Andric   }
3420b57cec5SDimitry Andric 
3430b57cec5SDimitry Andric   /// Features related to the presence of specific instructions.
3440b57cec5SDimitry Andric   bool hasExtractInsert() const { return !inMips16Mode() && hasMips32r2(); }
3450b57cec5SDimitry Andric   bool hasMTHC1() const { return hasMips32r2(); }
3460b57cec5SDimitry Andric 
3470b57cec5SDimitry Andric   bool allowMixed16_32() const { return inMips16ModeDefault() |
3480b57cec5SDimitry Andric                                         AllowMixed16_32; }
3490b57cec5SDimitry Andric 
3500b57cec5SDimitry Andric   bool os16() const { return Os16; }
3510b57cec5SDimitry Andric 
3520b57cec5SDimitry Andric   bool isTargetNaCl() const { return TargetTriple.isOSNaCl(); }
3530b57cec5SDimitry Andric 
3540b57cec5SDimitry Andric   bool isXRaySupported() const override { return true; }
3550b57cec5SDimitry Andric 
3560b57cec5SDimitry Andric   // for now constant islands are on for the whole compilation unit but we only
3570b57cec5SDimitry Andric   // really use them if in addition we are in mips16 mode
3580b57cec5SDimitry Andric   static bool useConstantIslands();
3590b57cec5SDimitry Andric 
3608bcb0991SDimitry Andric   Align getStackAlignment() const { return stackAlignment; }
3610b57cec5SDimitry Andric 
3620b57cec5SDimitry Andric   // Grab relocation model
3630b57cec5SDimitry Andric   Reloc::Model getRelocationModel() const;
3640b57cec5SDimitry Andric 
3650b57cec5SDimitry Andric   MipsSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS,
3660b57cec5SDimitry Andric                                                  const TargetMachine &TM);
3670b57cec5SDimitry Andric 
3680b57cec5SDimitry Andric   /// Does the system support unaligned memory access.
3690b57cec5SDimitry Andric   ///
3700b57cec5SDimitry Andric   /// MIPS32r6/MIPS64r6 require full unaligned access support but does not
3710b57cec5SDimitry Andric   /// specify which component of the system provides it. Hardware, software, and
3720b57cec5SDimitry Andric   /// hybrid implementations are all valid.
3730b57cec5SDimitry Andric   bool systemSupportsUnalignedAccess() const { return hasMips32r6(); }
3740b57cec5SDimitry Andric 
3750b57cec5SDimitry Andric   // Set helper classes
3760b57cec5SDimitry Andric   void setHelperClassesMips16();
3770b57cec5SDimitry Andric   void setHelperClassesMipsSE();
3780b57cec5SDimitry Andric 
3790b57cec5SDimitry Andric   const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
3800b57cec5SDimitry Andric     return &TSInfo;
3810b57cec5SDimitry Andric   }
3820b57cec5SDimitry Andric   const MipsInstrInfo *getInstrInfo() const override { return InstrInfo.get(); }
3830b57cec5SDimitry Andric   const TargetFrameLowering *getFrameLowering() const override {
3840b57cec5SDimitry Andric     return FrameLowering.get();
3850b57cec5SDimitry Andric   }
3860b57cec5SDimitry Andric   const MipsRegisterInfo *getRegisterInfo() const override {
3870b57cec5SDimitry Andric     return &InstrInfo->getRegisterInfo();
3880b57cec5SDimitry Andric   }
3890b57cec5SDimitry Andric   const MipsTargetLowering *getTargetLowering() const override {
3900b57cec5SDimitry Andric     return TLInfo.get();
3910b57cec5SDimitry Andric   }
3920b57cec5SDimitry Andric   const InstrItineraryData *getInstrItineraryData() const override {
3930b57cec5SDimitry Andric     return &InstrItins;
3940b57cec5SDimitry Andric   }
3950b57cec5SDimitry Andric 
3960b57cec5SDimitry Andric protected:
3970b57cec5SDimitry Andric   // GlobalISel related APIs.
3980b57cec5SDimitry Andric   std::unique_ptr<CallLowering> CallLoweringInfo;
3990b57cec5SDimitry Andric   std::unique_ptr<LegalizerInfo> Legalizer;
4000b57cec5SDimitry Andric   std::unique_ptr<RegisterBankInfo> RegBankInfo;
4010b57cec5SDimitry Andric   std::unique_ptr<InstructionSelector> InstSelector;
4020b57cec5SDimitry Andric 
4030b57cec5SDimitry Andric public:
4040b57cec5SDimitry Andric   const CallLowering *getCallLowering() const override;
4050b57cec5SDimitry Andric   const LegalizerInfo *getLegalizerInfo() const override;
4060b57cec5SDimitry Andric   const RegisterBankInfo *getRegBankInfo() const override;
4078bcb0991SDimitry Andric   InstructionSelector *getInstructionSelector() const override;
4080b57cec5SDimitry Andric };
4090b57cec5SDimitry Andric } // End llvm namespace
4100b57cec5SDimitry Andric 
4110b57cec5SDimitry Andric #endif
412