SparcSubtarget.h revision 360660
12Sjlaskey//===-- SparcSubtarget.h - Define Subtarget for the SPARC -------*- C++ -*-===//
26Sjlaskey//
32Sjlaskey// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4877Sattila// See https://llvm.org/LICENSE.txt for license information.
52Sjlaskey// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
62Sjlaskey//
72Sjlaskey//===----------------------------------------------------------------------===//
8877Sattila//
92Sjlaskey// This file declares the SPARC specific subclass of TargetSubtargetInfo.
102Sjlaskey//
112Sjlaskey//===----------------------------------------------------------------------===//
122Sjlaskey
132Sjlaskey#ifndef LLVM_LIB_TARGET_SPARC_SPARCSUBTARGET_H
14877Sattila#define LLVM_LIB_TARGET_SPARC_SPARCSUBTARGET_H
152Sjlaskey
162Sjlaskey#include "SparcFrameLowering.h"
172Sjlaskey#include "SparcISelLowering.h"
18877Sattila#include "SparcInstrInfo.h"
192Sjlaskey#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
202Sjlaskey#include "llvm/CodeGen/TargetFrameLowering.h"
212Sjlaskey#include "llvm/CodeGen/TargetSubtargetInfo.h"
222Sjlaskey#include "llvm/IR/DataLayout.h"
232Sjlaskey#include <string>
242Sjlaskey
252Sjlaskey#define GET_SUBTARGETINFO_HEADER
262Sjlaskey#include "SparcGenSubtargetInfo.inc"
272Sjlaskey
282Sjlaskeynamespace llvm {
292Sjlaskeyclass StringRef;
302Sjlaskey
312Sjlaskeyclass SparcSubtarget : public SparcGenSubtargetInfo {
322Sjlaskey  Triple TargetTriple;
332Sjlaskey  virtual void anchor();
342Sjlaskey  bool UseSoftMulDiv;
352Sjlaskey  bool IsV9;
362Sjlaskey  bool IsLeon;
372Sjlaskey  bool V8DeprecatedInsts;
382Sjlaskey  bool IsVIS, IsVIS2, IsVIS3;
392Sjlaskey  bool Is64Bit;
402Sjlaskey  bool HasHardQuad;
412Sjlaskey  bool UsePopc;
42  bool UseSoftFloat;
43  bool HasNoFSMULD;
44  bool HasNoFMULS;
45
46  // LEON features
47  bool HasUmacSmac;
48  bool HasLeonCasa;
49  bool HasPWRPSR;
50  bool InsertNOPLoad;
51  bool FixAllFDIVSQRT;
52  bool DetectRoundChange;
53  bool HasLeonCycleCounter;
54
55  SparcInstrInfo InstrInfo;
56  SparcTargetLowering TLInfo;
57  SelectionDAGTargetInfo TSInfo;
58  SparcFrameLowering FrameLowering;
59
60public:
61  SparcSubtarget(const Triple &TT, const std::string &CPU,
62                 const std::string &FS, const TargetMachine &TM, bool is64bit);
63
64  const SparcInstrInfo *getInstrInfo() const override { return &InstrInfo; }
65  const TargetFrameLowering *getFrameLowering() const override {
66    return &FrameLowering;
67  }
68  const SparcRegisterInfo *getRegisterInfo() const override {
69    return &InstrInfo.getRegisterInfo();
70  }
71  const SparcTargetLowering *getTargetLowering() const override {
72    return &TLInfo;
73  }
74  const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
75    return &TSInfo;
76  }
77
78  bool enableMachineScheduler() const override;
79
80  bool useSoftMulDiv() const { return UseSoftMulDiv; }
81  bool isV9() const { return IsV9; }
82  bool isLeon() const { return IsLeon; }
83  bool isVIS() const { return IsVIS; }
84  bool isVIS2() const { return IsVIS2; }
85  bool isVIS3() const { return IsVIS3; }
86  bool useDeprecatedV8Instructions() const { return V8DeprecatedInsts; }
87  bool hasHardQuad() const { return HasHardQuad; }
88  bool usePopc() const { return UsePopc; }
89  bool useSoftFloat() const { return UseSoftFloat; }
90  bool hasNoFSMULD() const { return HasNoFSMULD; }
91  bool hasNoFMULS() const { return HasNoFMULS; }
92
93  // Leon options
94  bool hasUmacSmac() const { return HasUmacSmac; }
95  bool hasLeonCasa() const { return HasLeonCasa; }
96  bool hasPWRPSR() const { return HasPWRPSR; }
97  bool insertNOPLoad() const { return InsertNOPLoad; }
98  bool fixAllFDIVSQRT() const { return FixAllFDIVSQRT; }
99  bool detectRoundChange() const { return DetectRoundChange; }
100  bool hasLeonCycleCounter() const { return HasLeonCycleCounter; }
101
102  /// ParseSubtargetFeatures - Parses features string setting specified
103  /// subtarget options.  Definition of function is auto generated by tblgen.
104  void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
105  SparcSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
106
107  bool is64Bit() const { return Is64Bit; }
108
109  /// The 64-bit ABI uses biased stack and frame pointers, so the stack frame
110  /// of the current function is the area from [%sp+BIAS] to [%fp+BIAS].
111  int64_t getStackPointerBias() const {
112    return is64Bit() ? 2047 : 0;
113  }
114
115  /// Given a actual stack size as determined by FrameInfo, this function
116  /// returns adjusted framesize which includes space for register window
117  /// spills and arguments.
118  int getAdjustedFrameSize(int stackSize) const;
119
120  bool isTargetLinux() const { return TargetTriple.isOSLinux(); }
121};
122
123} // end namespace llvm
124
125#endif
126