blob: 106ff49f021a650f7ebff0c1471e143d04459099 [file] [log] [blame]
Alex Bradbury89718422017-10-19 21:37:38 +00001//===-- RISCVSubtarget.h - Define Subtarget for the RISCV -------*- C++ -*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Alex Bradbury89718422017-10-19 21:37:38 +00006//
7//===----------------------------------------------------------------------===//
8//
9// This file declares the RISCV specific subclass of TargetSubtargetInfo.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_TARGET_RISCV_RISCVSUBTARGET_H
14#define LLVM_LIB_TARGET_RISCV_RISCVSUBTARGET_H
15
16#include "RISCVFrameLowering.h"
17#include "RISCVISelLowering.h"
18#include "RISCVInstrInfo.h"
Alex Bradburyfea49572019-03-09 09:28:06 +000019#include "Utils/RISCVBaseInfo.h"
Alex Bradbury89718422017-10-19 21:37:38 +000020#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
David Blaikieb3bde2e2017-11-17 01:07:10 +000021#include "llvm/CodeGen/TargetSubtargetInfo.h"
Alex Bradbury89718422017-10-19 21:37:38 +000022#include "llvm/IR/DataLayout.h"
23#include "llvm/Target/TargetMachine.h"
Alex Bradbury89718422017-10-19 21:37:38 +000024
25#define GET_SUBTARGETINFO_HEADER
26#include "RISCVGenSubtargetInfo.inc"
27
28namespace llvm {
29class StringRef;
30
31class RISCVSubtarget : public RISCVGenSubtargetInfo {
32 virtual void anchor();
Alex Bradbury8c345c52017-11-09 15:00:03 +000033 bool HasStdExtM = false;
34 bool HasStdExtA = false;
Alex Bradbury0d6cf902017-12-07 10:26:05 +000035 bool HasStdExtF = false;
Alex Bradbury7bc2a952017-12-07 10:46:23 +000036 bool HasStdExtD = false;
Alex Bradbury9f6aec42017-12-07 12:50:32 +000037 bool HasStdExtC = false;
Alex Bradbury89718422017-10-19 21:37:38 +000038 bool HasRV64 = false;
Alex Bradburydab1f6f2019-03-22 11:21:40 +000039 bool IsRV32E = false;
Shiva Chen39694252018-05-15 01:28:50 +000040 bool EnableLinkerRelax = false;
Alex Bradbury89718422017-10-19 21:37:38 +000041 unsigned XLen = 32;
42 MVT XLenVT = MVT::i32;
Alex Bradburyfea49572019-03-09 09:28:06 +000043 RISCVABI::ABI TargetABI = RISCVABI::ABI_Unknown;
Alex Bradbury89718422017-10-19 21:37:38 +000044 RISCVFrameLowering FrameLowering;
45 RISCVInstrInfo InstrInfo;
46 RISCVRegisterInfo RegInfo;
47 RISCVTargetLowering TLInfo;
48 SelectionDAGTargetInfo TSInfo;
49
50 /// Initializes using the passed in CPU and feature strings so that we can
51 /// use initializer lists for subtarget initialization.
Alex Bradburyfea49572019-03-09 09:28:06 +000052 RISCVSubtarget &initializeSubtargetDependencies(const Triple &TT,
53 StringRef CPU, StringRef FS,
54 StringRef ABIName);
Alex Bradbury89718422017-10-19 21:37:38 +000055
56public:
57 // Initializes the data members to match that of the specified triple.
Alex Bradbury6aae2162019-02-19 14:42:00 +000058 RISCVSubtarget(const Triple &TT, StringRef CPU, StringRef FS,
Alex Bradburyfea49572019-03-09 09:28:06 +000059 StringRef ABIName, const TargetMachine &TM);
Alex Bradbury89718422017-10-19 21:37:38 +000060
61 // Parses features string setting specified subtarget options. The
62 // definition of this function is auto-generated by tblgen.
63 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
64
65 const RISCVFrameLowering *getFrameLowering() const override {
66 return &FrameLowering;
67 }
68 const RISCVInstrInfo *getInstrInfo() const override { return &InstrInfo; }
69 const RISCVRegisterInfo *getRegisterInfo() const override {
70 return &RegInfo;
71 }
72 const RISCVTargetLowering *getTargetLowering() const override {
73 return &TLInfo;
74 }
75 const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
76 return &TSInfo;
77 }
Alex Bradburya47514c2017-11-09 14:46:30 +000078 bool hasStdExtM() const { return HasStdExtM; }
Alex Bradbury8c345c52017-11-09 15:00:03 +000079 bool hasStdExtA() const { return HasStdExtA; }
Alex Bradbury0d6cf902017-12-07 10:26:05 +000080 bool hasStdExtF() const { return HasStdExtF; }
Alex Bradbury7bc2a952017-12-07 10:46:23 +000081 bool hasStdExtD() const { return HasStdExtD; }
Alex Bradbury9f6aec42017-12-07 12:50:32 +000082 bool hasStdExtC() const { return HasStdExtC; }
Alex Bradbury89718422017-10-19 21:37:38 +000083 bool is64Bit() const { return HasRV64; }
Alex Bradburydab1f6f2019-03-22 11:21:40 +000084 bool isRV32E() const { return IsRV32E; }
Shiva Chen39694252018-05-15 01:28:50 +000085 bool enableLinkerRelax() const { return EnableLinkerRelax; }
Alex Bradbury89718422017-10-19 21:37:38 +000086 MVT getXLenVT() const { return XLenVT; }
87 unsigned getXLen() const { return XLen; }
Alex Bradburyfea49572019-03-09 09:28:06 +000088 RISCVABI::ABI getTargetABI() const { return TargetABI; }
Alex Bradbury89718422017-10-19 21:37:38 +000089};
90} // End llvm namespace
91
92#endif