blob: 0e09391e7829b9ec4a7ab4a2dd2efcdeea7a2333 [file] [log] [blame]
Alex Bradbury89718422017-10-19 21:37:38 +00001//===-- RISCVSubtarget.h - Define Subtarget for the RISCV -------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file declares the RISCV specific subclass of TargetSubtargetInfo.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_LIB_TARGET_RISCV_RISCVSUBTARGET_H
15#define LLVM_LIB_TARGET_RISCV_RISCVSUBTARGET_H
16
17#include "RISCVFrameLowering.h"
18#include "RISCVISelLowering.h"
19#include "RISCVInstrInfo.h"
20#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;
42 RISCVFrameLowering FrameLowering;
43 RISCVInstrInfo InstrInfo;
44 RISCVRegisterInfo RegInfo;
45 RISCVTargetLowering TLInfo;
46 SelectionDAGTargetInfo TSInfo;
47
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,
51 bool Is64Bit);
52
53public:
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);
57
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);
61
62 const RISCVFrameLowering *getFrameLowering() const override {
63 return &FrameLowering;
64 }
65 const RISCVInstrInfo *getInstrInfo() const override { return &InstrInfo; }
66 const RISCVRegisterInfo *getRegisterInfo() const override {
67 return &RegInfo;
68 }
69 const RISCVTargetLowering *getTargetLowering() const override {
70 return &TLInfo;
71 }
72 const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
73 return &TSInfo;
74 }
Alex Bradburya47514c2017-11-09 14:46:30 +000075 bool hasStdExtM() const { return HasStdExtM; }
Alex Bradbury8c345c52017-11-09 15:00:03 +000076 bool hasStdExtA() const { return HasStdExtA; }
Alex Bradbury0d6cf902017-12-07 10:26:05 +000077 bool hasStdExtF() const { return HasStdExtF; }
Alex Bradbury7bc2a952017-12-07 10:46:23 +000078 bool hasStdExtD() const { return HasStdExtD; }
Alex Bradbury9f6aec42017-12-07 12:50:32 +000079 bool hasStdExtC() const { return HasStdExtC; }
Alex Bradbury89718422017-10-19 21:37:38 +000080 bool is64Bit() const { return HasRV64; }
Shiva Chen39694252018-05-15 01:28:50 +000081 bool enableLinkerRelax() const { return EnableLinkerRelax; }
Alex Bradbury89718422017-10-19 21:37:38 +000082 MVT getXLenVT() const { return XLenVT; }
83 unsigned getXLen() const { return XLen; }
84};
85} // End llvm namespace
86
87#endif