• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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"
18 #include "Nios2ISelLowering.h"
19 #include "Nios2InstrInfo.h"
20 #include "llvm/CodeGen/SelectionDAGTargetInfo.h"
21 #include "llvm/CodeGen/TargetFrameLowering.h"
22 #include "llvm/CodeGen/TargetSubtargetInfo.h"
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 
57   Triple TargetTriple;
58 
59   Nios2InstrInfo InstrInfo;
60   Nios2TargetLowering TLInfo;
61   SelectionDAGTargetInfo TSInfo;
62   Nios2FrameLowering FrameLowering;
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,
68                  const std::string &FS, const TargetMachine &TM);
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 
hasNios2r1()74   bool hasNios2r1() const { return Nios2ArchVersion >= Nios2r1; }
isNios2r1()75   bool isNios2r1() const { return Nios2ArchVersion == Nios2r1; }
hasNios2r2()76   bool hasNios2r2() const { return Nios2ArchVersion >= Nios2r2; }
isNios2r2()77   bool isNios2r2() const { return Nios2ArchVersion == Nios2r2; }
78 
79   Nios2Subtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
80 
getInstrInfo()81   const Nios2InstrInfo *getInstrInfo() const override { return &InstrInfo; }
getFrameLowering()82   const TargetFrameLowering *getFrameLowering() const override {
83     return &FrameLowering;
84   }
getRegisterInfo()85   const Nios2RegisterInfo *getRegisterInfo() const override {
86     return &InstrInfo.getRegisterInfo();
87   }
getTargetLowering()88   const Nios2TargetLowering *getTargetLowering() const override {
89     return &TLInfo;
90   }
getSelectionDAGInfo()91   const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
92     return &TSInfo;
93   }
94 };
95 } // namespace llvm
96 
97 #endif
98