xref: /freebsd-src/contrib/llvm-project/llvm/lib/Target/CSKY/CSKYSubtarget.h (revision 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e)
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 
3981ad6265SDimitry Andric   enum CSKYProcFamilyEnum {
4081ad6265SDimitry Andric     Others,
4181ad6265SDimitry Andric 
4281ad6265SDimitry Andric     CK801,
4381ad6265SDimitry Andric     CK802,
4481ad6265SDimitry Andric     CK803,
4581ad6265SDimitry Andric     CK803S,
4681ad6265SDimitry Andric     CK804,
4781ad6265SDimitry Andric     CK805,
4881ad6265SDimitry Andric     CK807,
4981ad6265SDimitry Andric     CK810,
5081ad6265SDimitry Andric     CK810V,
5181ad6265SDimitry Andric     CK860,
5281ad6265SDimitry Andric     CK860V
5381ad6265SDimitry Andric   };
5481ad6265SDimitry Andric 
5581ad6265SDimitry Andric   /// CSKYProcFamily - CSKY processor family: CK801, CK802, and others.
5681ad6265SDimitry Andric   CSKYProcFamilyEnum CSKYProcFamily = Others;
5781ad6265SDimitry Andric 
58349cc55cSDimitry Andric   bool UseHardFloat;
59349cc55cSDimitry Andric   bool UseHardFloatABI;
60349cc55cSDimitry Andric   bool HasFPUv2SingleFloat;
61349cc55cSDimitry Andric   bool HasFPUv2DoubleFloat;
6281ad6265SDimitry Andric   bool HasFPUv3HalfWord;
6381ad6265SDimitry Andric   bool HasFPUv3HalfFloat;
64349cc55cSDimitry Andric   bool HasFPUv3SingleFloat;
65349cc55cSDimitry Andric   bool HasFPUv3DoubleFloat;
6681ad6265SDimitry Andric   bool HasFdivdu;
6781ad6265SDimitry Andric   bool HasFLOATE1;
6881ad6265SDimitry Andric   bool HasFLOAT1E2;
6981ad6265SDimitry Andric   bool HasFLOAT1E3;
7081ad6265SDimitry Andric   bool HasFLOAT3E4;
7181ad6265SDimitry Andric   bool HasFLOAT7E60;
72349cc55cSDimitry Andric   bool HasBTST16;
73349cc55cSDimitry Andric   bool HasExtendLrw;
7481ad6265SDimitry Andric   bool HasTrust;
7581ad6265SDimitry Andric   bool HasJAVA;
7681ad6265SDimitry Andric   bool HasCache;
7781ad6265SDimitry Andric   bool HasNVIC;
7881ad6265SDimitry Andric   bool HasDSP;
7981ad6265SDimitry Andric   bool HasDSP1E2;
8081ad6265SDimitry Andric   bool HasDSPE60;
8181ad6265SDimitry Andric   bool HasDSPV2;
8281ad6265SDimitry Andric   bool HasDSP_Silan;
83349cc55cSDimitry Andric   bool HasDoloop;
8481ad6265SDimitry Andric   bool HasHardwareDivide;
85349cc55cSDimitry Andric   bool HasHighRegisters;
8681ad6265SDimitry Andric   bool HasVDSPV2;
8781ad6265SDimitry Andric   bool HasVDSP2E3;
8881ad6265SDimitry Andric   bool HasVDSP2E60F;
8981ad6265SDimitry Andric   bool ReadTPHard;
9081ad6265SDimitry Andric   bool HasVDSPV1_128;
9181ad6265SDimitry Andric   bool UseCCRT;
9281ad6265SDimitry Andric   bool DumpConstPool;
9381ad6265SDimitry Andric   bool EnableInterruptAttribute;
9481ad6265SDimitry Andric   bool HasPushPop;
9581ad6265SDimitry Andric   bool HasSTM;
9681ad6265SDimitry Andric   bool SmartMode;
9781ad6265SDimitry 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 
getFrameLowering()115349cc55cSDimitry Andric   const CSKYFrameLowering *getFrameLowering() const override {
116349cc55cSDimitry Andric     return &FrameLowering;
117349cc55cSDimitry Andric   }
getInstrInfo()118349cc55cSDimitry Andric   const CSKYInstrInfo *getInstrInfo() const override { return &InstrInfo; }
getRegisterInfo()119349cc55cSDimitry Andric   const CSKYRegisterInfo *getRegisterInfo() const override { return &RegInfo; }
getTargetLowering()120349cc55cSDimitry Andric   const CSKYTargetLowering *getTargetLowering() const override {
121349cc55cSDimitry Andric     return &TLInfo;
122349cc55cSDimitry Andric   }
getSelectionDAGInfo()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;
useHardFloat()138349cc55cSDimitry Andric   bool useHardFloat() const { return UseHardFloat; }
hasFPUv2SingleFloat()139349cc55cSDimitry Andric   bool hasFPUv2SingleFloat() const { return HasFPUv2SingleFloat; }
hasFPUv2DoubleFloat()140349cc55cSDimitry Andric   bool hasFPUv2DoubleFloat() const { return HasFPUv2DoubleFloat; }
hasFPUv2()141349cc55cSDimitry Andric   bool hasFPUv2() const { return HasFPUv2SingleFloat || HasFPUv2DoubleFloat; }
hasFPUv3HalfWord()14281ad6265SDimitry Andric   bool hasFPUv3HalfWord() const { return HasFPUv3HalfWord; }
hasFPUv3HalfFloat()14381ad6265SDimitry Andric   bool hasFPUv3HalfFloat() const { return HasFPUv3HalfFloat; }
hasFPUv3SingleFloat()144349cc55cSDimitry Andric   bool hasFPUv3SingleFloat() const { return HasFPUv3SingleFloat; }
hasFPUv3DoubleFloat()145349cc55cSDimitry Andric   bool hasFPUv3DoubleFloat() const { return HasFPUv3DoubleFloat; }
hasFPUv3()14681ad6265SDimitry Andric   bool hasFPUv3() const {
14781ad6265SDimitry Andric     return HasFPUv3HalfFloat || HasFPUv3SingleFloat || HasFPUv3DoubleFloat;
14881ad6265SDimitry Andric   }
hasAnyFloatExt()149349cc55cSDimitry Andric   bool hasAnyFloatExt() const { return hasFPUv2() || hasFPUv3(); };
hasFdivdu()15081ad6265SDimitry Andric   bool hasFdivdu() const { return HasFdivdu; }
hasFLOATE1()15181ad6265SDimitry Andric   bool hasFLOATE1() const { return HasFLOATE1; }
hasFLOAT1E2()15281ad6265SDimitry Andric   bool hasFLOAT1E2() const { return HasFLOAT1E2; }
hasFLOAT1E3()15381ad6265SDimitry Andric   bool hasFLOAT1E3() const { return HasFLOAT1E3; }
hasFLOAT3E4()15481ad6265SDimitry Andric   bool hasFLOAT3E4() const { return HasFLOAT3E4; }
hasFLOAT7E60()15581ad6265SDimitry Andric   bool hasFLOAT7E60() const { return HasFLOAT7E60; }
hasExtendLrw()156349cc55cSDimitry Andric   bool hasExtendLrw() const { return HasExtendLrw; }
hasBTST16()15781ad6265SDimitry Andric   bool hasBTST16() const { return HasBTST16; }
hasTrust()15881ad6265SDimitry Andric   bool hasTrust() const { return HasTrust; }
hasJAVA()15981ad6265SDimitry Andric   bool hasJAVA() const { return HasJAVA; }
hasCache()16081ad6265SDimitry Andric   bool hasCache() const { return HasCache; }
hasNVIC()16181ad6265SDimitry Andric   bool hasNVIC() const { return HasNVIC; }
hasDSP()16281ad6265SDimitry Andric   bool hasDSP() const { return HasDSP; }
hasDSP1E2()16381ad6265SDimitry Andric   bool hasDSP1E2() const { return HasDSP1E2; }
hasDSPE60()16481ad6265SDimitry Andric   bool hasDSPE60() const { return HasDSPE60; }
hasDSPV2()16581ad6265SDimitry Andric   bool hasDSPV2() const { return HasDSPV2; }
hasDSP_Silan()16681ad6265SDimitry Andric   bool hasDSP_Silan() const { return HasDSP_Silan; }
hasDoloop()167349cc55cSDimitry Andric   bool hasDoloop() const { return HasDoloop; }
hasHighRegisters()168349cc55cSDimitry Andric   bool hasHighRegisters() const { return HasHighRegisters; }
hasVDSPV2()16981ad6265SDimitry Andric   bool hasVDSPV2() const { return HasVDSPV2; }
hasVDSPV2_FLOAT()17081ad6265SDimitry Andric   bool hasVDSPV2_FLOAT() const { return HasVDSPV2 && UseHardFloat; }
hasVDSPV2_HALF()17181ad6265SDimitry Andric   bool hasVDSPV2_HALF() const {
17281ad6265SDimitry Andric     return HasVDSPV2 && UseHardFloat && HasFPUv3HalfFloat;
17381ad6265SDimitry Andric   }
hasVDSP2E3()17481ad6265SDimitry Andric   bool hasVDSP2E3() const { return HasVDSP2E3; }
hasVDSP2E60F()17581ad6265SDimitry Andric   bool hasVDSP2E60F() const { return HasVDSP2E60F; }
readTPHard()17681ad6265SDimitry Andric   bool readTPHard() const { return ReadTPHard; }
hasVDSPV1_128()17781ad6265SDimitry Andric   bool hasVDSPV1_128() const { return HasVDSPV1_128; }
useCCRT()17881ad6265SDimitry Andric   bool useCCRT() const { return UseCCRT; }
dumpConstPool()17981ad6265SDimitry Andric   bool dumpConstPool() const { return DumpConstPool; }
enableInterruptAttribute()18081ad6265SDimitry Andric   bool enableInterruptAttribute() const { return EnableInterruptAttribute; }
hasPushPop()18181ad6265SDimitry Andric   bool hasPushPop() const { return HasPushPop; }
hasSTM()18281ad6265SDimitry Andric   bool hasSTM() const { return HasSTM; }
smartMode()18381ad6265SDimitry Andric   bool smartMode() const { return SmartMode; }
enableStackSize()18481ad6265SDimitry Andric   bool enableStackSize() const { return EnableStackSize; }
185349cc55cSDimitry Andric 
hasE1()186349cc55cSDimitry Andric   bool hasE1() const { return HasE1; }
hasE2()187349cc55cSDimitry Andric   bool hasE2() const { return HasE2; }
has2E3()188349cc55cSDimitry Andric   bool has2E3() const { return Has2E3; }
has3r1E3r2()189349cc55cSDimitry Andric   bool has3r1E3r2() const { return Has3r1E3r2; }
has3r2E3r3()190349cc55cSDimitry Andric   bool has3r2E3r3() const { return Has3r2E3r3; }
has3E3r1()191349cc55cSDimitry Andric   bool has3E3r1() const { return Has3E3r1; }
has3E7()192349cc55cSDimitry Andric   bool has3E7() const { return Has3E7; }
hasMP()193349cc55cSDimitry Andric   bool hasMP() const { return HasMP; }
hasMP1E2()194349cc55cSDimitry Andric   bool hasMP1E2() const { return HasMP1E2; }
has7E10()195349cc55cSDimitry Andric   bool has7E10() const { return Has7E10; }
has10E60()196349cc55cSDimitry Andric   bool has10E60() const { return Has10E60; }
19781ad6265SDimitry Andric 
isCK801()19881ad6265SDimitry Andric   bool isCK801() const { return CSKYProcFamily == CK801; }
isCK802()19981ad6265SDimitry Andric   bool isCK802() const { return CSKYProcFamily == CK802; }
isCK803()20081ad6265SDimitry Andric   bool isCK803() const { return CSKYProcFamily == CK803; }
isCK803S()20181ad6265SDimitry Andric   bool isCK803S() const { return CSKYProcFamily == CK803S; }
isCK804()20281ad6265SDimitry Andric   bool isCK804() const { return CSKYProcFamily == CK804; }
isCK805()20381ad6265SDimitry Andric   bool isCK805() const { return CSKYProcFamily == CK805; }
isCK807()20481ad6265SDimitry Andric   bool isCK807() const { return CSKYProcFamily == CK807; }
isCK810()20581ad6265SDimitry Andric   bool isCK810() const { return CSKYProcFamily == CK810; }
isCK810V()20681ad6265SDimitry Andric   bool isCK810V() const { return CSKYProcFamily == CK810V; }
isCK860()20781ad6265SDimitry Andric   bool isCK860() const { return CSKYProcFamily == CK860; }
isCK860V()20881ad6265SDimitry Andric   bool isCK860V() const { return CSKYProcFamily == CK860V; }
209*06c3fb27SDimitry Andric 
210*06c3fb27SDimitry Andric   const unsigned XLen = 32;
211349cc55cSDimitry Andric };
212349cc55cSDimitry Andric } // namespace llvm
213349cc55cSDimitry Andric 
214349cc55cSDimitry Andric #endif // LLVM_LIB_TARGET_CSKY_CSKYSUBTARGET_H
215