xref: /freebsd-src/contrib/llvm-project/llvm/lib/Target/CSKY/CSKYSubtarget.h (revision 81ad626541db97eb356e2c1d4a20eb2a26a766ab)
1349cc55cSDimitry Andric //===-- CSKYSubtarget.h - Define Subtarget for the CSKY----------*- C++ -*-===//
2349cc55cSDimitry Andric //
3349cc55cSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4349cc55cSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5349cc55cSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6349cc55cSDimitry Andric //
7349cc55cSDimitry Andric //===----------------------------------------------------------------------===//
8349cc55cSDimitry Andric //
9349cc55cSDimitry Andric // This file declares the CSKY specific subclass of TargetSubtargetInfo.
10349cc55cSDimitry Andric //
11349cc55cSDimitry Andric //===----------------------------------------------------------------------===//
12349cc55cSDimitry Andric 
13349cc55cSDimitry Andric #ifndef LLVM_LIB_TARGET_CSKY_CSKYSUBTARGET_H
14349cc55cSDimitry Andric #define LLVM_LIB_TARGET_CSKY_CSKYSUBTARGET_H
15349cc55cSDimitry Andric 
16349cc55cSDimitry Andric #include "CSKYFrameLowering.h"
17349cc55cSDimitry Andric #include "CSKYISelLowering.h"
18349cc55cSDimitry Andric #include "CSKYInstrInfo.h"
19349cc55cSDimitry Andric #include "CSKYRegisterInfo.h"
20349cc55cSDimitry Andric #include "llvm/CodeGen/SelectionDAGTargetInfo.h"
21349cc55cSDimitry Andric #include "llvm/CodeGen/TargetSubtargetInfo.h"
22349cc55cSDimitry Andric #include "llvm/Target/TargetMachine.h"
23349cc55cSDimitry Andric 
24349cc55cSDimitry Andric #define GET_SUBTARGETINFO_HEADER
25349cc55cSDimitry Andric #include "CSKYGenSubtargetInfo.inc"
26349cc55cSDimitry Andric 
27349cc55cSDimitry Andric namespace llvm {
28349cc55cSDimitry Andric class StringRef;
29349cc55cSDimitry Andric 
30349cc55cSDimitry Andric class CSKYSubtarget : public CSKYGenSubtargetInfo {
31349cc55cSDimitry Andric   virtual void anchor();
32349cc55cSDimitry Andric 
33349cc55cSDimitry Andric   CSKYFrameLowering FrameLowering;
34349cc55cSDimitry Andric   CSKYInstrInfo InstrInfo;
35349cc55cSDimitry Andric   CSKYRegisterInfo RegInfo;
36349cc55cSDimitry Andric   CSKYTargetLowering TLInfo;
37349cc55cSDimitry Andric   SelectionDAGTargetInfo TSInfo;
38349cc55cSDimitry Andric 
39*81ad6265SDimitry Andric   enum CSKYProcFamilyEnum {
40*81ad6265SDimitry Andric     Others,
41*81ad6265SDimitry Andric 
42*81ad6265SDimitry Andric     CK801,
43*81ad6265SDimitry Andric     CK802,
44*81ad6265SDimitry Andric     CK803,
45*81ad6265SDimitry Andric     CK803S,
46*81ad6265SDimitry Andric     CK804,
47*81ad6265SDimitry Andric     CK805,
48*81ad6265SDimitry Andric     CK807,
49*81ad6265SDimitry Andric     CK810,
50*81ad6265SDimitry Andric     CK810V,
51*81ad6265SDimitry Andric     CK860,
52*81ad6265SDimitry Andric     CK860V
53*81ad6265SDimitry Andric   };
54*81ad6265SDimitry Andric 
55*81ad6265SDimitry Andric   /// CSKYProcFamily - CSKY processor family: CK801, CK802, and others.
56*81ad6265SDimitry Andric   CSKYProcFamilyEnum CSKYProcFamily = Others;
57*81ad6265SDimitry Andric 
58349cc55cSDimitry Andric   bool UseHardFloat;
59349cc55cSDimitry Andric   bool UseHardFloatABI;
60349cc55cSDimitry Andric   bool HasFPUv2SingleFloat;
61349cc55cSDimitry Andric   bool HasFPUv2DoubleFloat;
62*81ad6265SDimitry Andric   bool HasFPUv3HalfWord;
63*81ad6265SDimitry Andric   bool HasFPUv3HalfFloat;
64349cc55cSDimitry Andric   bool HasFPUv3SingleFloat;
65349cc55cSDimitry Andric   bool HasFPUv3DoubleFloat;
66*81ad6265SDimitry Andric   bool HasFdivdu;
67*81ad6265SDimitry Andric   bool HasFLOATE1;
68*81ad6265SDimitry Andric   bool HasFLOAT1E2;
69*81ad6265SDimitry Andric   bool HasFLOAT1E3;
70*81ad6265SDimitry Andric   bool HasFLOAT3E4;
71*81ad6265SDimitry Andric   bool HasFLOAT7E60;
72349cc55cSDimitry Andric   bool HasBTST16;
73349cc55cSDimitry Andric   bool HasExtendLrw;
74*81ad6265SDimitry Andric   bool HasTrust;
75*81ad6265SDimitry Andric   bool HasJAVA;
76*81ad6265SDimitry Andric   bool HasCache;
77*81ad6265SDimitry Andric   bool HasNVIC;
78*81ad6265SDimitry Andric   bool HasDSP;
79*81ad6265SDimitry Andric   bool HasDSP1E2;
80*81ad6265SDimitry Andric   bool HasDSPE60;
81*81ad6265SDimitry Andric   bool HasDSPV2;
82*81ad6265SDimitry Andric   bool HasDSP_Silan;
83349cc55cSDimitry Andric   bool HasDoloop;
84*81ad6265SDimitry Andric   bool HasHardwareDivide;
85349cc55cSDimitry Andric   bool HasHighRegisters;
86*81ad6265SDimitry Andric   bool HasVDSPV2;
87*81ad6265SDimitry Andric   bool HasVDSP2E3;
88*81ad6265SDimitry Andric   bool HasVDSP2E60F;
89*81ad6265SDimitry Andric   bool ReadTPHard;
90*81ad6265SDimitry Andric   bool HasVDSPV1_128;
91*81ad6265SDimitry Andric   bool UseCCRT;
92*81ad6265SDimitry Andric   bool DumpConstPool;
93*81ad6265SDimitry Andric   bool EnableInterruptAttribute;
94*81ad6265SDimitry Andric   bool HasPushPop;
95*81ad6265SDimitry Andric   bool HasSTM;
96*81ad6265SDimitry Andric   bool SmartMode;
97*81ad6265SDimitry Andric   bool EnableStackSize;
98349cc55cSDimitry Andric 
99349cc55cSDimitry Andric   bool HasE1;
100349cc55cSDimitry Andric   bool HasE2;
101349cc55cSDimitry Andric   bool Has2E3;
102349cc55cSDimitry Andric   bool HasMP;
103349cc55cSDimitry Andric   bool Has3E3r1;
104349cc55cSDimitry Andric   bool Has3r1E3r2;
105349cc55cSDimitry Andric   bool Has3r2E3r3;
106349cc55cSDimitry Andric   bool Has3E7;
107349cc55cSDimitry Andric   bool HasMP1E2;
108349cc55cSDimitry Andric   bool Has7E10;
109349cc55cSDimitry Andric   bool Has10E60;
110349cc55cSDimitry Andric 
111349cc55cSDimitry Andric public:
112349cc55cSDimitry Andric   CSKYSubtarget(const Triple &TT, StringRef CPU, StringRef TuneCPU,
113349cc55cSDimitry Andric                 StringRef FS, const TargetMachine &TM);
114349cc55cSDimitry Andric 
115349cc55cSDimitry Andric   const CSKYFrameLowering *getFrameLowering() const override {
116349cc55cSDimitry Andric     return &FrameLowering;
117349cc55cSDimitry Andric   }
118349cc55cSDimitry Andric   const CSKYInstrInfo *getInstrInfo() const override { return &InstrInfo; }
119349cc55cSDimitry Andric   const CSKYRegisterInfo *getRegisterInfo() const override { return &RegInfo; }
120349cc55cSDimitry Andric   const CSKYTargetLowering *getTargetLowering() const override {
121349cc55cSDimitry Andric     return &TLInfo;
122349cc55cSDimitry Andric   }
123349cc55cSDimitry Andric   const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
124349cc55cSDimitry Andric     return &TSInfo;
125349cc55cSDimitry Andric   }
126349cc55cSDimitry Andric 
127349cc55cSDimitry Andric   /// Initializes using the passed in CPU and feature strings so that we can
128349cc55cSDimitry Andric   /// use initializer lists for subtarget initialization.
129349cc55cSDimitry Andric   CSKYSubtarget &initializeSubtargetDependencies(const Triple &TT,
130349cc55cSDimitry Andric                                                  StringRef CPU,
131349cc55cSDimitry Andric                                                  StringRef TuneCPU,
132349cc55cSDimitry Andric                                                  StringRef FS);
133349cc55cSDimitry Andric 
134349cc55cSDimitry Andric   // Generated by inc file
135349cc55cSDimitry Andric   void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);
136349cc55cSDimitry Andric 
137349cc55cSDimitry Andric   bool useHardFloatABI() const;
138349cc55cSDimitry Andric   bool useHardFloat() const { return UseHardFloat; }
139349cc55cSDimitry Andric   bool hasFPUv2SingleFloat() const { return HasFPUv2SingleFloat; }
140349cc55cSDimitry Andric   bool hasFPUv2DoubleFloat() const { return HasFPUv2DoubleFloat; }
141349cc55cSDimitry Andric   bool hasFPUv2() const { return HasFPUv2SingleFloat || HasFPUv2DoubleFloat; }
142*81ad6265SDimitry Andric   bool hasFPUv3HalfWord() const { return HasFPUv3HalfWord; }
143*81ad6265SDimitry Andric   bool hasFPUv3HalfFloat() const { return HasFPUv3HalfFloat; }
144349cc55cSDimitry Andric   bool hasFPUv3SingleFloat() const { return HasFPUv3SingleFloat; }
145349cc55cSDimitry Andric   bool hasFPUv3DoubleFloat() const { return HasFPUv3DoubleFloat; }
146*81ad6265SDimitry Andric   bool hasFPUv3() const {
147*81ad6265SDimitry Andric     return HasFPUv3HalfFloat || HasFPUv3SingleFloat || HasFPUv3DoubleFloat;
148*81ad6265SDimitry Andric   }
149349cc55cSDimitry Andric   bool hasAnyFloatExt() const { return hasFPUv2() || hasFPUv3(); };
150*81ad6265SDimitry Andric   bool hasFdivdu() const { return HasFdivdu; }
151*81ad6265SDimitry Andric   bool hasFLOATE1() const { return HasFLOATE1; }
152*81ad6265SDimitry Andric   bool hasFLOAT1E2() const { return HasFLOAT1E2; }
153*81ad6265SDimitry Andric   bool hasFLOAT1E3() const { return HasFLOAT1E3; }
154*81ad6265SDimitry Andric   bool hasFLOAT3E4() const { return HasFLOAT3E4; }
155*81ad6265SDimitry Andric   bool hasFLOAT7E60() const { return HasFLOAT7E60; }
156349cc55cSDimitry Andric   bool hasExtendLrw() const { return HasExtendLrw; }
157*81ad6265SDimitry Andric   bool hasBTST16() const { return HasBTST16; }
158*81ad6265SDimitry Andric   bool hasTrust() const { return HasTrust; }
159*81ad6265SDimitry Andric   bool hasJAVA() const { return HasJAVA; }
160*81ad6265SDimitry Andric   bool hasCache() const { return HasCache; }
161*81ad6265SDimitry Andric   bool hasNVIC() const { return HasNVIC; }
162*81ad6265SDimitry Andric   bool hasDSP() const { return HasDSP; }
163*81ad6265SDimitry Andric   bool hasDSP1E2() const { return HasDSP1E2; }
164*81ad6265SDimitry Andric   bool hasDSPE60() const { return HasDSPE60; }
165*81ad6265SDimitry Andric   bool hasDSPV2() const { return HasDSPV2; }
166*81ad6265SDimitry Andric   bool hasDSP_Silan() const { return HasDSP_Silan; }
167349cc55cSDimitry Andric   bool hasDoloop() const { return HasDoloop; }
168349cc55cSDimitry Andric   bool hasHighRegisters() const { return HasHighRegisters; }
169*81ad6265SDimitry Andric   bool hasVDSPV2() const { return HasVDSPV2; }
170*81ad6265SDimitry Andric   bool hasVDSPV2_FLOAT() const { return HasVDSPV2 && UseHardFloat; }
171*81ad6265SDimitry Andric   bool hasVDSPV2_HALF() const {
172*81ad6265SDimitry Andric     return HasVDSPV2 && UseHardFloat && HasFPUv3HalfFloat;
173*81ad6265SDimitry Andric   }
174*81ad6265SDimitry Andric   bool hasVDSP2E3() const { return HasVDSP2E3; }
175*81ad6265SDimitry Andric   bool hasVDSP2E60F() const { return HasVDSP2E60F; }
176*81ad6265SDimitry Andric   bool readTPHard() const { return ReadTPHard; }
177*81ad6265SDimitry Andric   bool hasVDSPV1_128() const { return HasVDSPV1_128; }
178*81ad6265SDimitry Andric   bool useCCRT() const { return UseCCRT; }
179*81ad6265SDimitry Andric   bool dumpConstPool() const { return DumpConstPool; }
180*81ad6265SDimitry Andric   bool enableInterruptAttribute() const { return EnableInterruptAttribute; }
181*81ad6265SDimitry Andric   bool hasPushPop() const { return HasPushPop; }
182*81ad6265SDimitry Andric   bool hasSTM() const { return HasSTM; }
183*81ad6265SDimitry Andric   bool smartMode() const { return SmartMode; }
184*81ad6265SDimitry Andric   bool enableStackSize() const { return EnableStackSize; }
185349cc55cSDimitry Andric 
186349cc55cSDimitry Andric   bool hasE1() const { return HasE1; }
187349cc55cSDimitry Andric   bool hasE2() const { return HasE2; }
188349cc55cSDimitry Andric   bool has2E3() const { return Has2E3; }
189349cc55cSDimitry Andric   bool has3r1E3r2() const { return Has3r1E3r2; }
190349cc55cSDimitry Andric   bool has3r2E3r3() const { return Has3r2E3r3; }
191349cc55cSDimitry Andric   bool has3E3r1() const { return Has3E3r1; }
192349cc55cSDimitry Andric   bool has3E7() const { return Has3E7; }
193349cc55cSDimitry Andric   bool hasMP() const { return HasMP; }
194349cc55cSDimitry Andric   bool hasMP1E2() const { return HasMP1E2; }
195349cc55cSDimitry Andric   bool has7E10() const { return Has7E10; }
196349cc55cSDimitry Andric   bool has10E60() const { return Has10E60; }
197*81ad6265SDimitry Andric 
198*81ad6265SDimitry Andric   bool isCK801() const { return CSKYProcFamily == CK801; }
199*81ad6265SDimitry Andric   bool isCK802() const { return CSKYProcFamily == CK802; }
200*81ad6265SDimitry Andric   bool isCK803() const { return CSKYProcFamily == CK803; }
201*81ad6265SDimitry Andric   bool isCK803S() const { return CSKYProcFamily == CK803S; }
202*81ad6265SDimitry Andric   bool isCK804() const { return CSKYProcFamily == CK804; }
203*81ad6265SDimitry Andric   bool isCK805() const { return CSKYProcFamily == CK805; }
204*81ad6265SDimitry Andric   bool isCK807() const { return CSKYProcFamily == CK807; }
205*81ad6265SDimitry Andric   bool isCK810() const { return CSKYProcFamily == CK810; }
206*81ad6265SDimitry Andric   bool isCK810V() const { return CSKYProcFamily == CK810V; }
207*81ad6265SDimitry Andric   bool isCK860() const { return CSKYProcFamily == CK860; }
208*81ad6265SDimitry Andric   bool isCK860V() const { return CSKYProcFamily == CK860V; }
209349cc55cSDimitry Andric };
210349cc55cSDimitry Andric } // namespace llvm
211349cc55cSDimitry Andric 
212349cc55cSDimitry Andric #endif // LLVM_LIB_TARGET_CSKY_CSKYSUBTARGET_H
213