xref: /freebsd/contrib/llvm-project/llvm/lib/Target/CSKY/CSKYSubtarget.h (revision 700637cbb5e582861067a11aaca4d053546871d2)
1 //===-- CSKYSubtarget.h - Define Subtarget for the CSKY----------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file declares the CSKY specific subclass of TargetSubtargetInfo.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_LIB_TARGET_CSKY_CSKYSUBTARGET_H
14 #define LLVM_LIB_TARGET_CSKY_CSKYSUBTARGET_H
15 
16 #include "CSKYFrameLowering.h"
17 #include "CSKYISelLowering.h"
18 #include "CSKYInstrInfo.h"
19 #include "CSKYRegisterInfo.h"
20 #include "llvm/CodeGen/TargetSubtargetInfo.h"
21 #include "llvm/Target/TargetMachine.h"
22 
23 #define GET_SUBTARGETINFO_HEADER
24 #include "CSKYGenSubtargetInfo.inc"
25 
26 namespace llvm {
27 class StringRef;
28 
29 class CSKYSubtarget : public CSKYGenSubtargetInfo {
30   virtual void anchor();
31 
32   CSKYFrameLowering FrameLowering;
33   CSKYInstrInfo InstrInfo;
34   CSKYRegisterInfo RegInfo;
35   CSKYTargetLowering TLInfo;
36   std::unique_ptr<const SelectionDAGTargetInfo> TSInfo;
37 
38   enum CSKYProcFamilyEnum {
39     Others,
40 
41     CK801,
42     CK802,
43     CK803,
44     CK803S,
45     CK804,
46     CK805,
47     CK807,
48     CK810,
49     CK810V,
50     CK860,
51     CK860V
52   };
53 
54   /// CSKYProcFamily - CSKY processor family: CK801, CK802, and others.
55   CSKYProcFamilyEnum CSKYProcFamily = Others;
56 
57   bool UseHardFloat;
58   bool UseHardFloatABI;
59   bool HasFPUv2SingleFloat;
60   bool HasFPUv2DoubleFloat;
61   bool HasFPUv3HalfWord;
62   bool HasFPUv3HalfFloat;
63   bool HasFPUv3SingleFloat;
64   bool HasFPUv3DoubleFloat;
65   bool HasFdivdu;
66   bool HasFLOATE1;
67   bool HasFLOAT1E2;
68   bool HasFLOAT1E3;
69   bool HasFLOAT3E4;
70   bool HasFLOAT7E60;
71   bool HasBTST16;
72   bool HasExtendLrw;
73   bool HasTrust;
74   bool HasJAVA;
75   bool HasCache;
76   bool HasNVIC;
77   bool HasDSP;
78   bool HasDSP1E2;
79   bool HasDSPE60;
80   bool HasDSPV2;
81   bool HasDSP_Silan;
82   bool HasDoloop;
83   bool HasHardwareDivide;
84   bool HasHighRegisters;
85   bool HasVDSPV2;
86   bool HasVDSP2E3;
87   bool HasVDSP2E60F;
88   bool ReadTPHard;
89   bool HasVDSPV1_128;
90   bool UseCCRT;
91   bool DumpConstPool;
92   bool EnableInterruptAttribute;
93   bool HasPushPop;
94   bool HasSTM;
95   bool SmartMode;
96   bool EnableStackSize;
97 
98   bool HasE1;
99   bool HasE2;
100   bool Has2E3;
101   bool HasMP;
102   bool Has3E3r1;
103   bool Has3r1E3r2;
104   bool Has3r2E3r3;
105   bool Has3E7;
106   bool HasMP1E2;
107   bool Has7E10;
108   bool Has10E60;
109 
110 public:
111   CSKYSubtarget(const Triple &TT, StringRef CPU, StringRef TuneCPU,
112                 StringRef FS, const TargetMachine &TM);
113 
114   ~CSKYSubtarget() override;
115 
getFrameLowering()116   const CSKYFrameLowering *getFrameLowering() const override {
117     return &FrameLowering;
118   }
getInstrInfo()119   const CSKYInstrInfo *getInstrInfo() const override { return &InstrInfo; }
getRegisterInfo()120   const CSKYRegisterInfo *getRegisterInfo() const override { return &RegInfo; }
getTargetLowering()121   const CSKYTargetLowering *getTargetLowering() const override {
122     return &TLInfo;
123   }
124 
125   const SelectionDAGTargetInfo *getSelectionDAGInfo() const override;
126 
127   /// Initializes using the passed in CPU and feature strings so that we can
128   /// use initializer lists for subtarget initialization.
129   CSKYSubtarget &initializeSubtargetDependencies(const Triple &TT,
130                                                  StringRef CPU,
131                                                  StringRef TuneCPU,
132                                                  StringRef FS);
133 
134   // Generated by inc file
135   void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);
136 
137   bool useHardFloatABI() const;
useHardFloat()138   bool useHardFloat() const { return UseHardFloat; }
hasFPUv2SingleFloat()139   bool hasFPUv2SingleFloat() const { return HasFPUv2SingleFloat; }
hasFPUv2DoubleFloat()140   bool hasFPUv2DoubleFloat() const { return HasFPUv2DoubleFloat; }
hasFPUv2()141   bool hasFPUv2() const { return HasFPUv2SingleFloat || HasFPUv2DoubleFloat; }
hasFPUv3HalfWord()142   bool hasFPUv3HalfWord() const { return HasFPUv3HalfWord; }
hasFPUv3HalfFloat()143   bool hasFPUv3HalfFloat() const { return HasFPUv3HalfFloat; }
hasFPUv3SingleFloat()144   bool hasFPUv3SingleFloat() const { return HasFPUv3SingleFloat; }
hasFPUv3DoubleFloat()145   bool hasFPUv3DoubleFloat() const { return HasFPUv3DoubleFloat; }
hasFPUv3()146   bool hasFPUv3() const {
147     return HasFPUv3HalfFloat || HasFPUv3SingleFloat || HasFPUv3DoubleFloat;
148   }
hasAnyFloatExt()149   bool hasAnyFloatExt() const { return hasFPUv2() || hasFPUv3(); };
hasFdivdu()150   bool hasFdivdu() const { return HasFdivdu; }
hasFLOATE1()151   bool hasFLOATE1() const { return HasFLOATE1; }
hasFLOAT1E2()152   bool hasFLOAT1E2() const { return HasFLOAT1E2; }
hasFLOAT1E3()153   bool hasFLOAT1E3() const { return HasFLOAT1E3; }
hasFLOAT3E4()154   bool hasFLOAT3E4() const { return HasFLOAT3E4; }
hasFLOAT7E60()155   bool hasFLOAT7E60() const { return HasFLOAT7E60; }
hasExtendLrw()156   bool hasExtendLrw() const { return HasExtendLrw; }
hasBTST16()157   bool hasBTST16() const { return HasBTST16; }
hasTrust()158   bool hasTrust() const { return HasTrust; }
hasJAVA()159   bool hasJAVA() const { return HasJAVA; }
hasCache()160   bool hasCache() const { return HasCache; }
hasNVIC()161   bool hasNVIC() const { return HasNVIC; }
hasDSP()162   bool hasDSP() const { return HasDSP; }
hasDSP1E2()163   bool hasDSP1E2() const { return HasDSP1E2; }
hasDSPE60()164   bool hasDSPE60() const { return HasDSPE60; }
hasDSPV2()165   bool hasDSPV2() const { return HasDSPV2; }
hasDSP_Silan()166   bool hasDSP_Silan() const { return HasDSP_Silan; }
hasDoloop()167   bool hasDoloop() const { return HasDoloop; }
hasHighRegisters()168   bool hasHighRegisters() const { return HasHighRegisters; }
hasVDSPV2()169   bool hasVDSPV2() const { return HasVDSPV2; }
hasVDSPV2_FLOAT()170   bool hasVDSPV2_FLOAT() const { return HasVDSPV2 && UseHardFloat; }
hasVDSPV2_HALF()171   bool hasVDSPV2_HALF() const {
172     return HasVDSPV2 && UseHardFloat && HasFPUv3HalfFloat;
173   }
hasVDSP2E3()174   bool hasVDSP2E3() const { return HasVDSP2E3; }
hasVDSP2E60F()175   bool hasVDSP2E60F() const { return HasVDSP2E60F; }
readTPHard()176   bool readTPHard() const { return ReadTPHard; }
hasVDSPV1_128()177   bool hasVDSPV1_128() const { return HasVDSPV1_128; }
useCCRT()178   bool useCCRT() const { return UseCCRT; }
dumpConstPool()179   bool dumpConstPool() const { return DumpConstPool; }
enableInterruptAttribute()180   bool enableInterruptAttribute() const { return EnableInterruptAttribute; }
hasPushPop()181   bool hasPushPop() const { return HasPushPop; }
hasSTM()182   bool hasSTM() const { return HasSTM; }
smartMode()183   bool smartMode() const { return SmartMode; }
enableStackSize()184   bool enableStackSize() const { return EnableStackSize; }
185 
hasE1()186   bool hasE1() const { return HasE1; }
hasE2()187   bool hasE2() const { return HasE2; }
has2E3()188   bool has2E3() const { return Has2E3; }
has3r1E3r2()189   bool has3r1E3r2() const { return Has3r1E3r2; }
has3r2E3r3()190   bool has3r2E3r3() const { return Has3r2E3r3; }
has3E3r1()191   bool has3E3r1() const { return Has3E3r1; }
has3E7()192   bool has3E7() const { return Has3E7; }
hasMP()193   bool hasMP() const { return HasMP; }
hasMP1E2()194   bool hasMP1E2() const { return HasMP1E2; }
has7E10()195   bool has7E10() const { return Has7E10; }
has10E60()196   bool has10E60() const { return Has10E60; }
197 
isCK801()198   bool isCK801() const { return CSKYProcFamily == CK801; }
isCK802()199   bool isCK802() const { return CSKYProcFamily == CK802; }
isCK803()200   bool isCK803() const { return CSKYProcFamily == CK803; }
isCK803S()201   bool isCK803S() const { return CSKYProcFamily == CK803S; }
isCK804()202   bool isCK804() const { return CSKYProcFamily == CK804; }
isCK805()203   bool isCK805() const { return CSKYProcFamily == CK805; }
isCK807()204   bool isCK807() const { return CSKYProcFamily == CK807; }
isCK810()205   bool isCK810() const { return CSKYProcFamily == CK810; }
isCK810V()206   bool isCK810V() const { return CSKYProcFamily == CK810V; }
isCK860()207   bool isCK860() const { return CSKYProcFamily == CK860; }
isCK860V()208   bool isCK860V() const { return CSKYProcFamily == CK860V; }
209 
210   const unsigned XLen = 32;
211 };
212 } // namespace llvm
213 
214 #endif // LLVM_LIB_TARGET_CSKY_CSKYSUBTARGET_H
215