Nikolai Bozhenov | ebbde14 | 2017-09-19 11:54:29 +0000 | [diff] [blame] | 1 | //===-- Nios2Subtarget.h - Define Subtarget for the Nios2 -------*- 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 Nios2 specific subclass of TargetSubtargetInfo. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef LLVM_LIB_TARGET_NIOS2_NIOS2SUBTARGET_H |
| 15 | #define LLVM_LIB_TARGET_NIOS2_NIOS2SUBTARGET_H |
| 16 | |
| 17 | #include "Nios2FrameLowering.h" |
Nikolai Bozhenov | 1cf9c54 | 2017-12-07 12:35:02 +0000 | [diff] [blame] | 18 | #include "Nios2ISelLowering.h" |
Nikolai Bozhenov | ebbde14 | 2017-09-19 11:54:29 +0000 | [diff] [blame] | 19 | #include "Nios2InstrInfo.h" |
Nikolai Bozhenov | 1cf9c54 | 2017-12-07 12:35:02 +0000 | [diff] [blame] | 20 | #include "llvm/CodeGen/SelectionDAGTargetInfo.h" |
| 21 | #include "llvm/CodeGen/TargetFrameLowering.h" |
David Blaikie | b3bde2e | 2017-11-17 01:07:10 +0000 | [diff] [blame] | 22 | #include "llvm/CodeGen/TargetSubtargetInfo.h" |
Nikolai Bozhenov | ebbde14 | 2017-09-19 11:54:29 +0000 | [diff] [blame] | 23 | |
| 24 | #define GET_SUBTARGETINFO_HEADER |
| 25 | #include "Nios2GenSubtargetInfo.inc" |
| 26 | |
| 27 | namespace llvm { |
| 28 | class StringRef; |
| 29 | |
| 30 | class Nios2TargetMachine; |
| 31 | |
| 32 | class Nios2Subtarget : public Nios2GenSubtargetInfo { |
| 33 | virtual void anchor(); |
| 34 | |
| 35 | public: |
| 36 | // Nios2 R2 features |
| 37 | // Bit manipulation instructions extension |
| 38 | bool HasBMX; |
| 39 | // Code Density instructions extension |
| 40 | bool HasCDX; |
| 41 | // Multi-Processor instructions extension |
| 42 | bool HasMPX; |
| 43 | // New mandatory instructions |
| 44 | bool HasR2Mandatory; |
| 45 | |
| 46 | protected: |
| 47 | enum Nios2ArchEnum { |
| 48 | // Nios2 R1 ISA |
| 49 | Nios2r1, |
| 50 | // Nios2 R2 ISA |
| 51 | Nios2r2 |
| 52 | }; |
| 53 | |
| 54 | // Nios2 architecture version |
| 55 | Nios2ArchEnum Nios2ArchVersion; |
| 56 | |
Nikolai Bozhenov | ebbde14 | 2017-09-19 11:54:29 +0000 | [diff] [blame] | 57 | Triple TargetTriple; |
| 58 | |
Nikolai Bozhenov | 1cf9c54 | 2017-12-07 12:35:02 +0000 | [diff] [blame] | 59 | Nios2InstrInfo InstrInfo; |
| 60 | Nios2TargetLowering TLInfo; |
| 61 | SelectionDAGTargetInfo TSInfo; |
| 62 | Nios2FrameLowering FrameLowering; |
Nikolai Bozhenov | ebbde14 | 2017-09-19 11:54:29 +0000 | [diff] [blame] | 63 | |
| 64 | public: |
| 65 | /// This constructor initializes the data members to match that |
| 66 | /// of the specified triple. |
| 67 | Nios2Subtarget(const Triple &TT, const std::string &CPU, |
Nikolai Bozhenov | 1cf9c54 | 2017-12-07 12:35:02 +0000 | [diff] [blame] | 68 | const std::string &FS, const TargetMachine &TM); |
Nikolai Bozhenov | ebbde14 | 2017-09-19 11:54:29 +0000 | [diff] [blame] | 69 | |
| 70 | /// ParseSubtargetFeatures - Parses features string setting specified |
| 71 | /// subtarget options. Definition of function is auto generated by tblgen. |
| 72 | void ParseSubtargetFeatures(StringRef CPU, StringRef FS); |
| 73 | |
| 74 | bool hasNios2r1() const { return Nios2ArchVersion >= Nios2r1; } |
| 75 | bool isNios2r1() const { return Nios2ArchVersion == Nios2r1; } |
| 76 | bool hasNios2r2() const { return Nios2ArchVersion >= Nios2r2; } |
| 77 | bool isNios2r2() const { return Nios2ArchVersion == Nios2r2; } |
| 78 | |
Nikolai Bozhenov | 1cf9c54 | 2017-12-07 12:35:02 +0000 | [diff] [blame] | 79 | Nios2Subtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS); |
Nikolai Bozhenov | ebbde14 | 2017-09-19 11:54:29 +0000 | [diff] [blame] | 80 | |
Nikolai Bozhenov | 1cf9c54 | 2017-12-07 12:35:02 +0000 | [diff] [blame] | 81 | const Nios2InstrInfo *getInstrInfo() const override { return &InstrInfo; } |
Nikolai Bozhenov | ebbde14 | 2017-09-19 11:54:29 +0000 | [diff] [blame] | 82 | const TargetFrameLowering *getFrameLowering() const override { |
Nikolai Bozhenov | 1cf9c54 | 2017-12-07 12:35:02 +0000 | [diff] [blame] | 83 | return &FrameLowering; |
Nikolai Bozhenov | ebbde14 | 2017-09-19 11:54:29 +0000 | [diff] [blame] | 84 | } |
| 85 | const Nios2RegisterInfo *getRegisterInfo() const override { |
Nikolai Bozhenov | 1cf9c54 | 2017-12-07 12:35:02 +0000 | [diff] [blame] | 86 | return &InstrInfo.getRegisterInfo(); |
| 87 | } |
| 88 | const Nios2TargetLowering *getTargetLowering() const override { |
| 89 | return &TLInfo; |
| 90 | } |
| 91 | const SelectionDAGTargetInfo *getSelectionDAGInfo() const override { |
| 92 | return &TSInfo; |
Nikolai Bozhenov | ebbde14 | 2017-09-19 11:54:29 +0000 | [diff] [blame] | 93 | } |
| 94 | }; |
| 95 | } // namespace llvm |
| 96 | |
| 97 | #endif |