Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 1 | //===-- 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 Blaikie | b3bde2e | 2017-11-17 01:07:10 +0000 | [diff] [blame] | 21 | #include "llvm/CodeGen/TargetSubtargetInfo.h" |
Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 22 | #include "llvm/IR/DataLayout.h" |
| 23 | #include "llvm/Target/TargetMachine.h" |
Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 24 | |
| 25 | #define GET_SUBTARGETINFO_HEADER |
| 26 | #include "RISCVGenSubtargetInfo.inc" |
| 27 | |
| 28 | namespace llvm { |
| 29 | class StringRef; |
| 30 | |
| 31 | class RISCVSubtarget : public RISCVGenSubtargetInfo { |
| 32 | virtual void anchor(); |
Alex Bradbury | 8c345c5 | 2017-11-09 15:00:03 +0000 | [diff] [blame] | 33 | bool HasStdExtM = false; |
| 34 | bool HasStdExtA = false; |
Alex Bradbury | 0d6cf90 | 2017-12-07 10:26:05 +0000 | [diff] [blame] | 35 | bool HasStdExtF = false; |
Alex Bradbury | 7bc2a95 | 2017-12-07 10:46:23 +0000 | [diff] [blame] | 36 | bool HasStdExtD = false; |
Alex Bradbury | 9f6aec4 | 2017-12-07 12:50:32 +0000 | [diff] [blame] | 37 | bool HasStdExtC = false; |
Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 38 | bool HasRV64 = false; |
| 39 | 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 | |
| 52 | public: |
| 53 | // Initializes the data members to match that of the specified triple. |
| 54 | RISCVSubtarget(const Triple &TT, const std::string &CPU, |
| 55 | const std::string &FS, const TargetMachine &TM); |
| 56 | |
| 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 Bradbury | a47514c | 2017-11-09 14:46:30 +0000 | [diff] [blame] | 74 | bool hasStdExtM() const { return HasStdExtM; } |
Alex Bradbury | 8c345c5 | 2017-11-09 15:00:03 +0000 | [diff] [blame] | 75 | bool hasStdExtA() const { return HasStdExtA; } |
Alex Bradbury | 0d6cf90 | 2017-12-07 10:26:05 +0000 | [diff] [blame] | 76 | bool hasStdExtF() const { return HasStdExtF; } |
Alex Bradbury | 7bc2a95 | 2017-12-07 10:46:23 +0000 | [diff] [blame] | 77 | bool hasStdExtD() const { return HasStdExtD; } |
Alex Bradbury | 9f6aec4 | 2017-12-07 12:50:32 +0000 | [diff] [blame] | 78 | bool hasStdExtC() const { return HasStdExtC; } |
Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 79 | bool is64Bit() const { return HasRV64; } |
| 80 | MVT getXLenVT() const { return XLenVT; } |
| 81 | unsigned getXLen() const { return XLen; } |
| 82 | }; |
| 83 | } // End llvm namespace |
| 84 | |
| 85 | #endif |