blob: 657b0e656202e8749e5034a2d09f67fec601e63b [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"
21#include "llvm/IR/DataLayout.h"
22#include "llvm/Target/TargetMachine.h"
23#include "llvm/Target/TargetSubtargetInfo.h"
24
25#define GET_SUBTARGETINFO_HEADER
26#include "RISCVGenSubtargetInfo.inc"
27
28namespace llvm {
29class StringRef;
30
31class RISCVSubtarget : public RISCVGenSubtargetInfo {
32 virtual void anchor();
33 bool HasRV64 = false;
34 unsigned XLen = 32;
35 MVT XLenVT = MVT::i32;
36 RISCVFrameLowering FrameLowering;
37 RISCVInstrInfo InstrInfo;
38 RISCVRegisterInfo RegInfo;
39 RISCVTargetLowering TLInfo;
40 SelectionDAGTargetInfo TSInfo;
41
42 /// Initializes using the passed in CPU and feature strings so that we can
43 /// use initializer lists for subtarget initialization.
44 RISCVSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS,
45 bool Is64Bit);
46
47public:
48 // Initializes the data members to match that of the specified triple.
49 RISCVSubtarget(const Triple &TT, const std::string &CPU,
50 const std::string &FS, const TargetMachine &TM);
51
52 // Parses features string setting specified subtarget options. The
53 // definition of this function is auto-generated by tblgen.
54 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
55
56 const RISCVFrameLowering *getFrameLowering() const override {
57 return &FrameLowering;
58 }
59 const RISCVInstrInfo *getInstrInfo() const override { return &InstrInfo; }
60 const RISCVRegisterInfo *getRegisterInfo() const override {
61 return &RegInfo;
62 }
63 const RISCVTargetLowering *getTargetLowering() const override {
64 return &TLInfo;
65 }
66 const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
67 return &TSInfo;
68 }
69 bool is64Bit() const { return HasRV64; }
70 MVT getXLenVT() const { return XLenVT; }
71 unsigned getXLen() const { return XLen; }
72};
73} // End llvm namespace
74
75#endif