• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
getInstrInfo()69   const SparcInstrInfo *getInstrInfo() const override { return &InstrInfo; }
getFrameLowering()70   const TargetFrameLowering *getFrameLowering() const override {
71     return &FrameLowering;
72   }
getRegisterInfo()73   const SparcRegisterInfo *getRegisterInfo() const override {
74     return &InstrInfo.getRegisterInfo();
75   }
getTargetLowering()76   const SparcTargetLowering *getTargetLowering() const override {
77     return &TLInfo;
78   }
getSelectionDAGInfo()79   const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
80     return &TSInfo;
81   }
82 
83   bool enableMachineScheduler() const override;
84 
isV9()85   bool isV9() const { return IsV9; }
isLeon()86   bool isLeon() const { return IsLeon; }
isVIS()87   bool isVIS() const { return IsVIS; }
isVIS2()88   bool isVIS2() const { return IsVIS2; }
isVIS3()89   bool isVIS3() const { return IsVIS3; }
useDeprecatedV8Instructions()90   bool useDeprecatedV8Instructions() const { return V8DeprecatedInsts; }
hasHardQuad()91   bool hasHardQuad() const { return HasHardQuad; }
usePopc()92   bool usePopc() const { return UsePopc; }
useSoftFloat()93   bool useSoftFloat() const { return UseSoftFloat; }
94 
95   // Leon options
useSoftFpu()96   bool useSoftFpu() const { return UseSoftFpu; }
hasLeonCasa()97   bool hasLeonCasa() const { return HasLeonCasa; }
hasUmacSmac()98   bool hasUmacSmac() const { return HasUmacSmac; }
performSDIVReplace()99   bool performSDIVReplace() const { return PerformSDIVReplace; }
fixCallImmediates()100   bool fixCallImmediates() const { return FixCallImmediates; }
ignoreZeroFlag()101   bool ignoreZeroFlag() const { return IgnoreZeroFlag; }
insertNOPDoublePrecision()102   bool insertNOPDoublePrecision() const { return InsertNOPDoublePrecision; }
fixFSMULD()103   bool fixFSMULD() const { return FixFSMULD; }
replaceFMULS()104   bool replaceFMULS() const { return ReplaceFMULS; }
preventRoundChange()105   bool preventRoundChange() const { return PreventRoundChange; }
fixAllFDIVSQRT()106   bool fixAllFDIVSQRT() const { return FixAllFDIVSQRT; }
flushCacheLineSWAP()107   bool flushCacheLineSWAP() const { return FlushCacheLineSWAP; }
insertNOPsLoadStore()108   bool insertNOPsLoadStore() const { return InsertNOPsLoadStore; }
insertNOPLoad()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 
is64Bit()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].
getStackPointerBias()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 
isTargetLinux()129   bool isTargetLinux() const { return TargetTriple.isOSLinux(); }
130 };
131 
132 } // end namespace llvm
133 
134 #endif
135