blob: 0373d542d4bfde8075929309d09c191b3c10d7ca [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"
19#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
David Blaikieb3bde2e2017-11-17 01:07:10 +000020#include "llvm/CodeGen/TargetSubtargetInfo.h"
Alex Bradbury89718422017-10-19 21:37:38 +000021#include "llvm/IR/DataLayout.h"
22#include "llvm/Target/TargetMachine.h"
Alex Bradbury89718422017-10-19 21:37:38 +000023
24#define GET_SUBTARGETINFO_HEADER
25#include "RISCVGenSubtargetInfo.inc"
26
27namespace llvm {
28class StringRef;
29
30class RISCVSubtarget : public RISCVGenSubtargetInfo {
31 virtual void anchor();
Alex Bradbury8c345c52017-11-09 15:00:03 +000032 bool HasStdExtM = false;
33 bool HasStdExtA = false;
Alex Bradbury0d6cf902017-12-07 10:26:05 +000034 bool HasStdExtF = false;
Alex Bradbury7bc2a952017-12-07 10:46:23 +000035 bool HasStdExtD = false;
Alex Bradbury9f6aec42017-12-07 12:50:32 +000036 bool HasStdExtC = false;
Alex Bradbury89718422017-10-19 21:37:38 +000037 bool HasRV64 = false;
Shiva Chen39694252018-05-15 01:28:50 +000038 bool EnableLinkerRelax = false;
Alex Bradbury89718422017-10-19 21:37:38 +000039 unsigned XLen = 32;
40 MVT XLenVT = MVT::i32;
41 RISCVFrameLowering FrameLowering;
42 RISCVInstrInfo InstrInfo;
43 RISCVRegisterInfo RegInfo;
44 RISCVTargetLowering TLInfo;
45 SelectionDAGTargetInfo TSInfo;
46
47 /// Initializes using the passed in CPU and feature strings so that we can
48 /// use initializer lists for subtarget initialization.
49 RISCVSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS,
50 bool Is64Bit);
51
52public:
53 // Initializes the data members to match that of the specified triple.
Alex Bradbury6aae2162019-02-19 14:42:00 +000054 RISCVSubtarget(const Triple &TT, StringRef CPU, StringRef FS,
55 const TargetMachine &TM);
Alex Bradbury89718422017-10-19 21:37:38 +000056
57 // Parses features string setting specified subtarget options. The
58 // definition of this function is auto-generated by tblgen.
59 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
60
61 const RISCVFrameLowering *getFrameLowering() const override {
62 return &FrameLowering;
63 }
64 const RISCVInstrInfo *getInstrInfo() const override { return &InstrInfo; }
65 const RISCVRegisterInfo *getRegisterInfo() const override {
66 return &RegInfo;
67 }
68 const RISCVTargetLowering *getTargetLowering() const override {
69 return &TLInfo;
70 }
71 const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
72 return &TSInfo;
73 }
Alex Bradburya47514c2017-11-09 14:46:30 +000074 bool hasStdExtM() const { return HasStdExtM; }
Alex Bradbury8c345c52017-11-09 15:00:03 +000075 bool hasStdExtA() const { return HasStdExtA; }
Alex Bradbury0d6cf902017-12-07 10:26:05 +000076 bool hasStdExtF() const { return HasStdExtF; }
Alex Bradbury7bc2a952017-12-07 10:46:23 +000077 bool hasStdExtD() const { return HasStdExtD; }
Alex Bradbury9f6aec42017-12-07 12:50:32 +000078 bool hasStdExtC() const { return HasStdExtC; }
Alex Bradbury89718422017-10-19 21:37:38 +000079 bool is64Bit() const { return HasRV64; }
Shiva Chen39694252018-05-15 01:28:50 +000080 bool enableLinkerRelax() const { return EnableLinkerRelax; }
Alex Bradbury89718422017-10-19 21:37:38 +000081 MVT getXLenVT() const { return XLenVT; }
82 unsigned getXLen() const { return XLen; }
83};
84} // End llvm namespace
85
86#endif