1 //===-- RISCVSubtarget.h - Define Subtarget for the RISCV -------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the RISCV specific subclass of TargetSubtargetInfo.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_TARGET_RISCV_RISCVSUBTARGET_H
15 #define LLVM_LIB_TARGET_RISCV_RISCVSUBTARGET_H
17 #include "RISCVFrameLowering.h"
18 #include "RISCVISelLowering.h"
19 #include "RISCVInstrInfo.h"
20 #include "llvm/CodeGen/SelectionDAGTargetInfo.h"
21 #include "llvm/CodeGen/TargetSubtargetInfo.h"
22 #include "llvm/IR/DataLayout.h"
23 #include "llvm/Target/TargetMachine.h"
25 #define GET_SUBTARGETINFO_HEADER
26 #include "RISCVGenSubtargetInfo.inc"
31 class RISCVSubtarget : public RISCVGenSubtargetInfo {
32 virtual void anchor();
33 bool HasStdExtM = false;
34 bool HasStdExtA = false;
35 bool HasStdExtF = false;
36 bool HasStdExtD = false;
37 bool HasStdExtC = false;
39 bool EnableLinkerRelax = false;
41 MVT XLenVT = MVT::i32;
42 RISCVFrameLowering FrameLowering;
43 RISCVInstrInfo InstrInfo;
44 RISCVRegisterInfo RegInfo;
45 RISCVTargetLowering TLInfo;
46 SelectionDAGTargetInfo TSInfo;
48 /// Initializes using the passed in CPU and feature strings so that we can
49 /// use initializer lists for subtarget initialization.
50 RISCVSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS,
54 // Initializes the data members to match that of the specified triple.
55 RISCVSubtarget(const Triple &TT, const std::string &CPU,
56 const std::string &FS, const TargetMachine &TM);
58 // Parses features string setting specified subtarget options. The
59 // definition of this function is auto-generated by tblgen.
60 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
62 const RISCVFrameLowering *getFrameLowering() const override {
63 return &FrameLowering;
65 const RISCVInstrInfo *getInstrInfo() const override { return &InstrInfo; }
66 const RISCVRegisterInfo *getRegisterInfo() const override {
69 const RISCVTargetLowering *getTargetLowering() const override {
72 const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
75 bool hasStdExtM() const { return HasStdExtM; }
76 bool hasStdExtA() const { return HasStdExtA; }
77 bool hasStdExtF() const { return HasStdExtF; }
78 bool hasStdExtD() const { return HasStdExtD; }
79 bool hasStdExtC() const { return HasStdExtC; }
80 bool is64Bit() const { return HasRV64; }
81 bool enableLinkerRelax() const { return EnableLinkerRelax; }
82 MVT getXLenVT() const { return XLenVT; }
83 unsigned getXLen() const { return XLen; }
85 } // End llvm namespace