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/CodeGen/TargetFrameLowering.h"
     22 #include "llvm/CodeGen/TargetSubtargetInfo.h"
     23 #include "llvm/IR/DataLayout.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 UseSoftMulDiv;
     36   bool IsV9;
     37   bool IsLeon;
     38   bool V8DeprecatedInsts;
     39   bool IsVIS, IsVIS2, IsVIS3;
     40   bool Is64Bit;
     41   bool HasHardQuad;
     42   bool UsePopc;
     43   bool UseSoftFloat;
     44   bool HasNoFSMULD;
     45   bool HasNoFMULS;
     46 
     47   // LEON features
     48   bool HasUmacSmac;
     49   bool HasLeonCasa;
     50   bool InsertNOPLoad;
     51   bool FixAllFDIVSQRT;
     52   bool DetectRoundChange;
     53 
     54   SparcInstrInfo InstrInfo;
     55   SparcTargetLowering TLInfo;
     56   SelectionDAGTargetInfo TSInfo;
     57   SparcFrameLowering FrameLowering;
     58 
     59 public:
     60   SparcSubtarget(const Triple &TT, const std::string &CPU,
     61                  const std::string &FS, const TargetMachine &TM, bool is64bit);
     62 
     63   const SparcInstrInfo *getInstrInfo() const override { return &InstrInfo; }
     64   const TargetFrameLowering *getFrameLowering() const override {
     65     return &FrameLowering;
     66   }
     67   const SparcRegisterInfo *getRegisterInfo() const override {
     68     return &InstrInfo.getRegisterInfo();
     69   }
     70   const SparcTargetLowering *getTargetLowering() const override {
     71     return &TLInfo;
     72   }
     73   const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
     74     return &TSInfo;
     75   }
     76 
     77   bool enableMachineScheduler() const override;
     78 
     79   bool useSoftMulDiv() const { return UseSoftMulDiv; }
     80   bool isV9() const { return IsV9; }
     81   bool isLeon() const { return IsLeon; }
     82   bool isVIS() const { return IsVIS; }
     83   bool isVIS2() const { return IsVIS2; }
     84   bool isVIS3() const { return IsVIS3; }
     85   bool useDeprecatedV8Instructions() const { return V8DeprecatedInsts; }
     86   bool hasHardQuad() const { return HasHardQuad; }
     87   bool usePopc() const { return UsePopc; }
     88   bool useSoftFloat() const { return UseSoftFloat; }
     89   bool hasNoFSMULD() const { return HasNoFSMULD; }
     90   bool hasNoFMULS() const { return HasNoFMULS; }
     91 
     92   // Leon options
     93   bool hasUmacSmac() const { return HasUmacSmac; }
     94   bool hasLeonCasa() const { return HasLeonCasa; }
     95   bool insertNOPLoad() const { return InsertNOPLoad; }
     96   bool fixAllFDIVSQRT() const { return FixAllFDIVSQRT; }
     97   bool detectRoundChange() const { return DetectRoundChange; }
     98 
     99   /// ParseSubtargetFeatures - Parses features string setting specified
    100   /// subtarget options.  Definition of function is auto generated by tblgen.
    101   void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
    102   SparcSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
    103 
    104   bool is64Bit() const { return Is64Bit; }
    105 
    106   /// The 64-bit ABI uses biased stack and frame pointers, so the stack frame
    107   /// of the current function is the area from [%sp+BIAS] to [%fp+BIAS].
    108   int64_t getStackPointerBias() const {
    109     return is64Bit() ? 2047 : 0;
    110   }
    111 
    112   /// Given a actual stack size as determined by FrameInfo, this function
    113   /// returns adjusted framesize which includes space for register window
    114   /// spills and arguments.
    115   int getAdjustedFrameSize(int stackSize) const;
    116 
    117   bool isTargetLinux() const { return TargetTriple.isOSLinux(); }
    118 };
    119 
    120 } // end namespace llvm
    121 
    122 #endif
    123