blob: 7080ce58efa19a60879512debf1d7837ee75ff95 [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 Bradbury89718422017-10-19 21:37:38 +000035 bool HasRV64 = false;
36 unsigned XLen = 32;
37 MVT XLenVT = MVT::i32;
38 RISCVFrameLowering FrameLowering;
39 RISCVInstrInfo InstrInfo;
40 RISCVRegisterInfo RegInfo;
41 RISCVTargetLowering TLInfo;
42 SelectionDAGTargetInfo TSInfo;
43
44 /// Initializes using the passed in CPU and feature strings so that we can
45 /// use initializer lists for subtarget initialization.
46 RISCVSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS,
47 bool Is64Bit);
48
49public:
50 // Initializes the data members to match that of the specified triple.
51 RISCVSubtarget(const Triple &TT, const std::string &CPU,
52 const std::string &FS, const TargetMachine &TM);
53
54 // Parses features string setting specified subtarget options. The
55 // definition of this function is auto-generated by tblgen.
56 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
57
58 const RISCVFrameLowering *getFrameLowering() const override {
59 return &FrameLowering;
60 }
61 const RISCVInstrInfo *getInstrInfo() const override { return &InstrInfo; }
62 const RISCVRegisterInfo *getRegisterInfo() const override {
63 return &RegInfo;
64 }
65 const RISCVTargetLowering *getTargetLowering() const override {
66 return &TLInfo;
67 }
68 const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
69 return &TSInfo;
70 }
Alex Bradburya47514c2017-11-09 14:46:30 +000071 bool hasStdExtM() const { return HasStdExtM; }
Alex Bradbury8c345c52017-11-09 15:00:03 +000072 bool hasStdExtA() const { return HasStdExtA; }
Alex Bradbury89718422017-10-19 21:37:38 +000073 bool is64Bit() const { return HasRV64; }
74 MVT getXLenVT() const { return XLenVT; }
75 unsigned getXLen() const { return XLen; }
76};
77} // End llvm namespace
78
79#endif