Home | History | Annotate | Download | only in Sparc
      1 //===-- SparcSubtarget.h - Define Subtarget for the SPARC -------*- C++ -*-===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 //
     10 // This file declares the SPARC specific subclass of TargetSubtargetInfo.
     11 //
     12 //===----------------------------------------------------------------------===//
     13 
     14 #ifndef LLVM_LIB_TARGET_SPARC_SPARCSUBTARGET_H
     15 #define LLVM_LIB_TARGET_SPARC_SPARCSUBTARGET_H
     16 
     17 #include "SparcFrameLowering.h"
     18 #include "SparcISelLowering.h"
     19 #include "SparcInstrInfo.h"
     20 #include "llvm/CodeGen/SelectionDAGTargetInfo.h"
     21 #include "llvm/IR/DataLayout.h"
     22 #include "llvm/Target/TargetFrameLowering.h"
     23 #include "llvm/Target/TargetSubtargetInfo.h"
     24 #include <string>
     25 
     26 #define GET_SUBTARGETINFO_HEADER
     27 #include "SparcGenSubtargetInfo.inc"
     28 
     29 namespace llvm {
     30 class StringRef;
     31 
     32 class SparcSubtarget : public SparcGenSubtargetInfo {
     33   Triple TargetTriple;
     34   virtual void anchor();
     35   bool IsV9;
     36   bool IsLeon;
     37   bool V8DeprecatedInsts;
     38   bool IsVIS, IsVIS2, IsVIS3;
     39   bool Is64Bit;
     40   bool HasHardQuad;
     41   bool UsePopc;
     42   bool UseSoftFloat;
     43 
     44   // LEON features
     45   bool HasUmacSmac;
     46   bool HasLeonCasa;
     47   bool InsertNOPLoad;
     48   bool FixFSMULD;
     49   bool ReplaceFMULS;
     50   bool FixAllFDIVSQRT;
     51   bool UseSoftFpu;
     52   bool PerformSDIVReplace;
     53   bool FixCallImmediates;
     54   bool IgnoreZeroFlag;
     55   bool InsertNOPDoublePrecision;
     56   bool PreventRoundChange;
     57   bool FlushCacheLineSWAP;
     58   bool InsertNOPsLoadStore;
     59 
     60   SparcInstrInfo InstrInfo;
     61   SparcTargetLowering TLInfo;
     62   SelectionDAGTargetInfo TSInfo;
     63   SparcFrameLowering FrameLowering;
     64 
     65 public:
     66   SparcSubtarget(const Triple &TT, const std::string &CPU,
     67                  const std::string &FS, const TargetMachine &TM, bool is64bit);
     68 
     69   const SparcInstrInfo *getInstrInfo() const override { return &InstrInfo; }
     70   const TargetFrameLowering *getFrameLowering() const override {
     71     return &FrameLowering;
     72   }
     73   const SparcRegisterInfo *getRegisterInfo() const override {
     74     return &InstrInfo.getRegisterInfo();
     75   }
     76   const SparcTargetLowering *getTargetLowering() const override {
     77     return &TLInfo;
     78   }
     79   const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
     80     return &TSInfo;
     81   }
     82 
     83   bool enableMachineScheduler() const override;
     84 
     85   bool isV9() const { return IsV9; }
     86   bool isLeon() const { return IsLeon; }
     87   bool isVIS() const { return IsVIS; }
     88   bool isVIS2() const { return IsVIS2; }
     89   bool isVIS3() const { return IsVIS3; }
     90   bool useDeprecatedV8Instructions() const { return V8DeprecatedInsts; }
     91   bool hasHardQuad() const { return HasHardQuad; }
     92   bool usePopc() const { return UsePopc; }
     93   bool useSoftFloat() const { return UseSoftFloat; }
     94 
     95   // Leon options
     96   bool useSoftFpu() const { return UseSoftFpu; }
     97   bool hasLeonCasa() const { return HasLeonCasa; }
     98   bool hasUmacSmac() const { return HasUmacSmac; }
     99   bool performSDIVReplace() const { return PerformSDIVReplace; }
    100   bool fixCallImmediates() const { return FixCallImmediates; }
    101   bool ignoreZeroFlag() const { return IgnoreZeroFlag; }
    102   bool insertNOPDoublePrecision() const { return InsertNOPDoublePrecision; }
    103   bool fixFSMULD() const { return FixFSMULD; }
    104   bool replaceFMULS() const { return ReplaceFMULS; }
    105   bool preventRoundChange() const { return PreventRoundChange; }
    106   bool fixAllFDIVSQRT() const { return FixAllFDIVSQRT; }
    107   bool flushCacheLineSWAP() const { return FlushCacheLineSWAP; }
    108   bool insertNOPsLoadStore() const { return InsertNOPsLoadStore; }
    109   bool insertNOPLoad() const { return InsertNOPLoad; }
    110 
    111   /// ParseSubtargetFeatures - Parses features string setting specified
    112   /// subtarget options.  Definition of function is auto generated by tblgen.
    113   void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
    114   SparcSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
    115 
    116   bool is64Bit() const { return Is64Bit; }
    117 
    118   /// The 64-bit ABI uses biased stack and frame pointers, so the stack frame
    119   /// of the current function is the area from [%sp+BIAS] to [%fp+BIAS].
    120   int64_t getStackPointerBias() const {
    121     return is64Bit() ? 2047 : 0;
    122   }
    123 
    124   /// Given a actual stack size as determined by FrameInfo, this function
    125   /// returns adjusted framesize which includes space for register window
    126   /// spills and arguments.
    127   int getAdjustedFrameSize(int stackSize) const;
    128 
    129   bool isTargetLinux() const { return TargetTriple.isOSLinux(); }
    130 };
    131 
    132 } // end namespace llvm
    133 
    134 #endif
    135