blob: 6c10ee44fd6d6480a12016418e12d1f0631e115f [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;
Shiva Chen39694252018-05-15 01:28:50 +000039 bool EnableLinkerRelax = false;
Alex Bradbury89718422017-10-19 21:37:38 +000040 unsigned XLen = 32;
41 MVT XLenVT = MVT::i32;
Alex Bradburyfea49572019-03-09 09:28:06 +000042 RISCVABI::ABI TargetABI = RISCVABI::ABI_Unknown;
Alex Bradbury89718422017-10-19 21:37:38 +000043 RISCVFrameLowering FrameLowering;
44 RISCVInstrInfo InstrInfo;
45 RISCVRegisterInfo RegInfo;
46 RISCVTargetLowering TLInfo;
47 SelectionDAGTargetInfo TSInfo;
48
49 /// Initializes using the passed in CPU and feature strings so that we can
50 /// use initializer lists for subtarget initialization.
Alex Bradburyfea49572019-03-09 09:28:06 +000051 RISCVSubtarget &initializeSubtargetDependencies(const Triple &TT,
52 StringRef CPU, StringRef FS,
53 StringRef ABIName);
Alex Bradbury89718422017-10-19 21:37:38 +000054
55public:
56 // Initializes the data members to match that of the specified triple.
Alex Bradbury6aae2162019-02-19 14:42:00 +000057 RISCVSubtarget(const Triple &TT, StringRef CPU, StringRef FS,
Alex Bradburyfea49572019-03-09 09:28:06 +000058 StringRef ABIName, const TargetMachine &TM);
Alex Bradbury89718422017-10-19 21:37:38 +000059
60 // Parses features string setting specified subtarget options. The
61 // definition of this function is auto-generated by tblgen.
62 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
63
64 const RISCVFrameLowering *getFrameLowering() const override {
65 return &FrameLowering;
66 }
67 const RISCVInstrInfo *getInstrInfo() const override { return &InstrInfo; }
68 const RISCVRegisterInfo *getRegisterInfo() const override {
69 return &RegInfo;
70 }
71 const RISCVTargetLowering *getTargetLowering() const override {
72 return &TLInfo;
73 }
74 const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
75 return &TSInfo;
76 }
Alex Bradburya47514c2017-11-09 14:46:30 +000077 bool hasStdExtM() const { return HasStdExtM; }
Alex Bradbury8c345c52017-11-09 15:00:03 +000078 bool hasStdExtA() const { return HasStdExtA; }
Alex Bradbury0d6cf902017-12-07 10:26:05 +000079 bool hasStdExtF() const { return HasStdExtF; }
Alex Bradbury7bc2a952017-12-07 10:46:23 +000080 bool hasStdExtD() const { return HasStdExtD; }
Alex Bradbury9f6aec42017-12-07 12:50:32 +000081 bool hasStdExtC() const { return HasStdExtC; }
Alex Bradbury89718422017-10-19 21:37:38 +000082 bool is64Bit() const { return HasRV64; }
Shiva Chen39694252018-05-15 01:28:50 +000083 bool enableLinkerRelax() const { return EnableLinkerRelax; }
Alex Bradbury89718422017-10-19 21:37:38 +000084 MVT getXLenVT() const { return XLenVT; }
85 unsigned getXLen() const { return XLen; }
Alex Bradburyfea49572019-03-09 09:28:06 +000086 RISCVABI::ABI getTargetABI() const { return TargetABI; }
Alex Bradbury89718422017-10-19 21:37:38 +000087};
88} // End llvm namespace
89
90#endif