xref: /llvm-project/llvm/lib/Target/CSKY/CSKYSubtarget.h (revision 6d05f3f56e22ab9420c71062e2a0c8923aa2a2d7)
1de10a02fSZi Xuan Wu //===-- CSKYSubtarget.h - Define Subtarget for the CSKY----------*- C++ -*-===//
2de10a02fSZi Xuan Wu //
3de10a02fSZi Xuan Wu // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4de10a02fSZi Xuan Wu // See https://llvm.org/LICENSE.txt for license information.
5de10a02fSZi Xuan Wu // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6de10a02fSZi Xuan Wu //
7de10a02fSZi Xuan Wu //===----------------------------------------------------------------------===//
8de10a02fSZi Xuan Wu //
9de10a02fSZi Xuan Wu // This file declares the CSKY specific subclass of TargetSubtargetInfo.
10de10a02fSZi Xuan Wu //
11de10a02fSZi Xuan Wu //===----------------------------------------------------------------------===//
12de10a02fSZi Xuan Wu 
13de10a02fSZi Xuan Wu #ifndef LLVM_LIB_TARGET_CSKY_CSKYSUBTARGET_H
14de10a02fSZi Xuan Wu #define LLVM_LIB_TARGET_CSKY_CSKYSUBTARGET_H
15de10a02fSZi Xuan Wu 
16cf78715cSZi Xuan Wu #include "CSKYFrameLowering.h"
17cf78715cSZi Xuan Wu #include "CSKYISelLowering.h"
18cf78715cSZi Xuan Wu #include "CSKYInstrInfo.h"
19cf78715cSZi Xuan Wu #include "CSKYRegisterInfo.h"
20de10a02fSZi Xuan Wu #include "llvm/CodeGen/SelectionDAGTargetInfo.h"
21de10a02fSZi Xuan Wu #include "llvm/CodeGen/TargetSubtargetInfo.h"
22de10a02fSZi Xuan Wu #include "llvm/Target/TargetMachine.h"
23de10a02fSZi Xuan Wu 
24de10a02fSZi Xuan Wu #define GET_SUBTARGETINFO_HEADER
25de10a02fSZi Xuan Wu #include "CSKYGenSubtargetInfo.inc"
26de10a02fSZi Xuan Wu 
27de10a02fSZi Xuan Wu namespace llvm {
28de10a02fSZi Xuan Wu class StringRef;
29de10a02fSZi Xuan Wu 
30de10a02fSZi Xuan Wu class CSKYSubtarget : public CSKYGenSubtargetInfo {
31de10a02fSZi Xuan Wu   virtual void anchor();
32de10a02fSZi Xuan Wu 
33de10a02fSZi Xuan Wu   CSKYFrameLowering FrameLowering;
34de10a02fSZi Xuan Wu   CSKYInstrInfo InstrInfo;
35de10a02fSZi Xuan Wu   CSKYRegisterInfo RegInfo;
36de10a02fSZi Xuan Wu   CSKYTargetLowering TLInfo;
37de10a02fSZi Xuan Wu   SelectionDAGTargetInfo TSInfo;
38de10a02fSZi Xuan Wu 
399ee96aaaSZi Xuan Wu   enum CSKYProcFamilyEnum {
409ee96aaaSZi Xuan Wu     Others,
419ee96aaaSZi Xuan Wu 
429ee96aaaSZi Xuan Wu     CK801,
439ee96aaaSZi Xuan Wu     CK802,
449ee96aaaSZi Xuan Wu     CK803,
459ee96aaaSZi Xuan Wu     CK803S,
469ee96aaaSZi Xuan Wu     CK804,
479ee96aaaSZi Xuan Wu     CK805,
489ee96aaaSZi Xuan Wu     CK807,
499ee96aaaSZi Xuan Wu     CK810,
509ee96aaaSZi Xuan Wu     CK810V,
519ee96aaaSZi Xuan Wu     CK860,
529ee96aaaSZi Xuan Wu     CK860V
539ee96aaaSZi Xuan Wu   };
549ee96aaaSZi Xuan Wu 
559ee96aaaSZi Xuan Wu   /// CSKYProcFamily - CSKY processor family: CK801, CK802, and others.
569ee96aaaSZi Xuan Wu   CSKYProcFamilyEnum CSKYProcFamily = Others;
579ee96aaaSZi Xuan Wu 
58cf78715cSZi Xuan Wu   bool UseHardFloat;
59cf78715cSZi Xuan Wu   bool UseHardFloatABI;
60cf78715cSZi Xuan Wu   bool HasFPUv2SingleFloat;
61cf78715cSZi Xuan Wu   bool HasFPUv2DoubleFloat;
629ee96aaaSZi Xuan Wu   bool HasFPUv3HalfWord;
639ee96aaaSZi Xuan Wu   bool HasFPUv3HalfFloat;
64cf78715cSZi Xuan Wu   bool HasFPUv3SingleFloat;
65cf78715cSZi Xuan Wu   bool HasFPUv3DoubleFloat;
669ee96aaaSZi Xuan Wu   bool HasFdivdu;
679ee96aaaSZi Xuan Wu   bool HasFLOATE1;
689ee96aaaSZi Xuan Wu   bool HasFLOAT1E2;
699ee96aaaSZi Xuan Wu   bool HasFLOAT1E3;
709ee96aaaSZi Xuan Wu   bool HasFLOAT3E4;
719ee96aaaSZi Xuan Wu   bool HasFLOAT7E60;
724fb282feSZi Xuan Wu   bool HasBTST16;
73cf78715cSZi Xuan Wu   bool HasExtendLrw;
749ee96aaaSZi Xuan Wu   bool HasTrust;
759ee96aaaSZi Xuan Wu   bool HasJAVA;
769ee96aaaSZi Xuan Wu   bool HasCache;
779ee96aaaSZi Xuan Wu   bool HasNVIC;
789ee96aaaSZi Xuan Wu   bool HasDSP;
799ee96aaaSZi Xuan Wu   bool HasDSP1E2;
809ee96aaaSZi Xuan Wu   bool HasDSPE60;
819ee96aaaSZi Xuan Wu   bool HasDSPV2;
829ee96aaaSZi Xuan Wu   bool HasDSP_Silan;
83cf78715cSZi Xuan Wu   bool HasDoloop;
849ee96aaaSZi Xuan Wu   bool HasHardwareDivide;
85cf78715cSZi Xuan Wu   bool HasHighRegisters;
869ee96aaaSZi Xuan Wu   bool HasVDSPV2;
879ee96aaaSZi Xuan Wu   bool HasVDSP2E3;
889ee96aaaSZi Xuan Wu   bool HasVDSP2E60F;
899ee96aaaSZi Xuan Wu   bool ReadTPHard;
909ee96aaaSZi Xuan Wu   bool HasVDSPV1_128;
919ee96aaaSZi Xuan Wu   bool UseCCRT;
929ee96aaaSZi Xuan Wu   bool DumpConstPool;
939ee96aaaSZi Xuan Wu   bool EnableInterruptAttribute;
949ee96aaaSZi Xuan Wu   bool HasPushPop;
959ee96aaaSZi Xuan Wu   bool HasSTM;
969ee96aaaSZi Xuan Wu   bool SmartMode;
979ee96aaaSZi Xuan Wu   bool EnableStackSize;
98cf78715cSZi Xuan Wu 
99de10a02fSZi Xuan Wu   bool HasE1;
100de10a02fSZi Xuan Wu   bool HasE2;
101de10a02fSZi Xuan Wu   bool Has2E3;
102de10a02fSZi Xuan Wu   bool HasMP;
103de10a02fSZi Xuan Wu   bool Has3E3r1;
104de10a02fSZi Xuan Wu   bool Has3r1E3r2;
105de10a02fSZi Xuan Wu   bool Has3r2E3r3;
106de10a02fSZi Xuan Wu   bool Has3E7;
107de10a02fSZi Xuan Wu   bool HasMP1E2;
108de10a02fSZi Xuan Wu   bool Has7E10;
109de10a02fSZi Xuan Wu   bool Has10E60;
110de10a02fSZi Xuan Wu 
111de10a02fSZi Xuan Wu public:
112de10a02fSZi Xuan Wu   CSKYSubtarget(const Triple &TT, StringRef CPU, StringRef TuneCPU,
113de10a02fSZi Xuan Wu                 StringRef FS, const TargetMachine &TM);
114de10a02fSZi Xuan Wu 
getFrameLowering()115de10a02fSZi Xuan Wu   const CSKYFrameLowering *getFrameLowering() const override {
116de10a02fSZi Xuan Wu     return &FrameLowering;
117de10a02fSZi Xuan Wu   }
getInstrInfo()118de10a02fSZi Xuan Wu   const CSKYInstrInfo *getInstrInfo() const override { return &InstrInfo; }
getRegisterInfo()119de10a02fSZi Xuan Wu   const CSKYRegisterInfo *getRegisterInfo() const override { return &RegInfo; }
getTargetLowering()120de10a02fSZi Xuan Wu   const CSKYTargetLowering *getTargetLowering() const override {
121de10a02fSZi Xuan Wu     return &TLInfo;
122de10a02fSZi Xuan Wu   }
getSelectionDAGInfo()123de10a02fSZi Xuan Wu   const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
124de10a02fSZi Xuan Wu     return &TSInfo;
125de10a02fSZi Xuan Wu   }
126de10a02fSZi Xuan Wu 
127de10a02fSZi Xuan Wu   /// Initializes using the passed in CPU and feature strings so that we can
128de10a02fSZi Xuan Wu   /// use initializer lists for subtarget initialization.
129de10a02fSZi Xuan Wu   CSKYSubtarget &initializeSubtargetDependencies(const Triple &TT,
130de10a02fSZi Xuan Wu                                                  StringRef CPU,
131de10a02fSZi Xuan Wu                                                  StringRef TuneCPU,
132de10a02fSZi Xuan Wu                                                  StringRef FS);
133de10a02fSZi Xuan Wu 
134de10a02fSZi Xuan Wu   // Generated by inc file
135de10a02fSZi Xuan Wu   void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);
136de10a02fSZi Xuan Wu 
137cf78715cSZi Xuan Wu   bool useHardFloatABI() const;
useHardFloat()138cf78715cSZi Xuan Wu   bool useHardFloat() const { return UseHardFloat; }
hasFPUv2SingleFloat()139cf78715cSZi Xuan Wu   bool hasFPUv2SingleFloat() const { return HasFPUv2SingleFloat; }
hasFPUv2DoubleFloat()140cf78715cSZi Xuan Wu   bool hasFPUv2DoubleFloat() const { return HasFPUv2DoubleFloat; }
hasFPUv2()141cf78715cSZi Xuan Wu   bool hasFPUv2() const { return HasFPUv2SingleFloat || HasFPUv2DoubleFloat; }
hasFPUv3HalfWord()1429ee96aaaSZi Xuan Wu   bool hasFPUv3HalfWord() const { return HasFPUv3HalfWord; }
hasFPUv3HalfFloat()1439ee96aaaSZi Xuan Wu   bool hasFPUv3HalfFloat() const { return HasFPUv3HalfFloat; }
hasFPUv3SingleFloat()144cf78715cSZi Xuan Wu   bool hasFPUv3SingleFloat() const { return HasFPUv3SingleFloat; }
hasFPUv3DoubleFloat()145cf78715cSZi Xuan Wu   bool hasFPUv3DoubleFloat() const { return HasFPUv3DoubleFloat; }
hasFPUv3()1469ee96aaaSZi Xuan Wu   bool hasFPUv3() const {
1479ee96aaaSZi Xuan Wu     return HasFPUv3HalfFloat || HasFPUv3SingleFloat || HasFPUv3DoubleFloat;
1489ee96aaaSZi Xuan Wu   }
hasAnyFloatExt()149cf78715cSZi Xuan Wu   bool hasAnyFloatExt() const { return hasFPUv2() || hasFPUv3(); };
hasFdivdu()1509ee96aaaSZi Xuan Wu   bool hasFdivdu() const { return HasFdivdu; }
hasFLOATE1()1519ee96aaaSZi Xuan Wu   bool hasFLOATE1() const { return HasFLOATE1; }
hasFLOAT1E2()1529ee96aaaSZi Xuan Wu   bool hasFLOAT1E2() const { return HasFLOAT1E2; }
hasFLOAT1E3()1539ee96aaaSZi Xuan Wu   bool hasFLOAT1E3() const { return HasFLOAT1E3; }
hasFLOAT3E4()1549ee96aaaSZi Xuan Wu   bool hasFLOAT3E4() const { return HasFLOAT3E4; }
hasFLOAT7E60()1559ee96aaaSZi Xuan Wu   bool hasFLOAT7E60() const { return HasFLOAT7E60; }
hasExtendLrw()156cf78715cSZi Xuan Wu   bool hasExtendLrw() const { return HasExtendLrw; }
hasBTST16()1579ee96aaaSZi Xuan Wu   bool hasBTST16() const { return HasBTST16; }
hasTrust()1589ee96aaaSZi Xuan Wu   bool hasTrust() const { return HasTrust; }
hasJAVA()1599ee96aaaSZi Xuan Wu   bool hasJAVA() const { return HasJAVA; }
hasCache()1609ee96aaaSZi Xuan Wu   bool hasCache() const { return HasCache; }
hasNVIC()1619ee96aaaSZi Xuan Wu   bool hasNVIC() const { return HasNVIC; }
hasDSP()1629ee96aaaSZi Xuan Wu   bool hasDSP() const { return HasDSP; }
hasDSP1E2()1639ee96aaaSZi Xuan Wu   bool hasDSP1E2() const { return HasDSP1E2; }
hasDSPE60()1649ee96aaaSZi Xuan Wu   bool hasDSPE60() const { return HasDSPE60; }
hasDSPV2()1659ee96aaaSZi Xuan Wu   bool hasDSPV2() const { return HasDSPV2; }
hasDSP_Silan()1669ee96aaaSZi Xuan Wu   bool hasDSP_Silan() const { return HasDSP_Silan; }
hasDoloop()167cf78715cSZi Xuan Wu   bool hasDoloop() const { return HasDoloop; }
hasHighRegisters()168cf78715cSZi Xuan Wu   bool hasHighRegisters() const { return HasHighRegisters; }
hasVDSPV2()1699ee96aaaSZi Xuan Wu   bool hasVDSPV2() const { return HasVDSPV2; }
hasVDSPV2_FLOAT()1709ee96aaaSZi Xuan Wu   bool hasVDSPV2_FLOAT() const { return HasVDSPV2 && UseHardFloat; }
hasVDSPV2_HALF()1719ee96aaaSZi Xuan Wu   bool hasVDSPV2_HALF() const {
1729ee96aaaSZi Xuan Wu     return HasVDSPV2 && UseHardFloat && HasFPUv3HalfFloat;
1739ee96aaaSZi Xuan Wu   }
hasVDSP2E3()1749ee96aaaSZi Xuan Wu   bool hasVDSP2E3() const { return HasVDSP2E3; }
hasVDSP2E60F()1759ee96aaaSZi Xuan Wu   bool hasVDSP2E60F() const { return HasVDSP2E60F; }
readTPHard()1769ee96aaaSZi Xuan Wu   bool readTPHard() const { return ReadTPHard; }
hasVDSPV1_128()1779ee96aaaSZi Xuan Wu   bool hasVDSPV1_128() const { return HasVDSPV1_128; }
useCCRT()1789ee96aaaSZi Xuan Wu   bool useCCRT() const { return UseCCRT; }
dumpConstPool()1799ee96aaaSZi Xuan Wu   bool dumpConstPool() const { return DumpConstPool; }
enableInterruptAttribute()1809ee96aaaSZi Xuan Wu   bool enableInterruptAttribute() const { return EnableInterruptAttribute; }
hasPushPop()1819ee96aaaSZi Xuan Wu   bool hasPushPop() const { return HasPushPop; }
hasSTM()1829ee96aaaSZi Xuan Wu   bool hasSTM() const { return HasSTM; }
smartMode()1839ee96aaaSZi Xuan Wu   bool smartMode() const { return SmartMode; }
enableStackSize()1849ee96aaaSZi Xuan Wu   bool enableStackSize() const { return EnableStackSize; }
185cf78715cSZi Xuan Wu 
hasE1()186de10a02fSZi Xuan Wu   bool hasE1() const { return HasE1; }
hasE2()187de10a02fSZi Xuan Wu   bool hasE2() const { return HasE2; }
has2E3()188de10a02fSZi Xuan Wu   bool has2E3() const { return Has2E3; }
has3r1E3r2()189de10a02fSZi Xuan Wu   bool has3r1E3r2() const { return Has3r1E3r2; }
has3r2E3r3()190de10a02fSZi Xuan Wu   bool has3r2E3r3() const { return Has3r2E3r3; }
has3E3r1()191de10a02fSZi Xuan Wu   bool has3E3r1() const { return Has3E3r1; }
has3E7()192de10a02fSZi Xuan Wu   bool has3E7() const { return Has3E7; }
hasMP()193de10a02fSZi Xuan Wu   bool hasMP() const { return HasMP; }
hasMP1E2()194de10a02fSZi Xuan Wu   bool hasMP1E2() const { return HasMP1E2; }
has7E10()195de10a02fSZi Xuan Wu   bool has7E10() const { return Has7E10; }
has10E60()196de10a02fSZi Xuan Wu   bool has10E60() const { return Has10E60; }
1979ee96aaaSZi Xuan Wu 
isCK801()1989ee96aaaSZi Xuan Wu   bool isCK801() const { return CSKYProcFamily == CK801; }
isCK802()1999ee96aaaSZi Xuan Wu   bool isCK802() const { return CSKYProcFamily == CK802; }
isCK803()2009ee96aaaSZi Xuan Wu   bool isCK803() const { return CSKYProcFamily == CK803; }
isCK803S()2019ee96aaaSZi Xuan Wu   bool isCK803S() const { return CSKYProcFamily == CK803S; }
isCK804()2029ee96aaaSZi Xuan Wu   bool isCK804() const { return CSKYProcFamily == CK804; }
isCK805()2039ee96aaaSZi Xuan Wu   bool isCK805() const { return CSKYProcFamily == CK805; }
isCK807()2049ee96aaaSZi Xuan Wu   bool isCK807() const { return CSKYProcFamily == CK807; }
isCK810()2059ee96aaaSZi Xuan Wu   bool isCK810() const { return CSKYProcFamily == CK810; }
isCK810V()2069ee96aaaSZi Xuan Wu   bool isCK810V() const { return CSKYProcFamily == CK810V; }
isCK860()2079ee96aaaSZi Xuan Wu   bool isCK860() const { return CSKYProcFamily == CK860; }
isCK860V()2089ee96aaaSZi Xuan Wu   bool isCK860V() const { return CSKYProcFamily == CK860V; }
209*6d05f3f5SBen Shi 
210*6d05f3f5SBen Shi   const unsigned XLen = 32;
211de10a02fSZi Xuan Wu };
212de10a02fSZi Xuan Wu } // namespace llvm
213de10a02fSZi Xuan Wu 
214de10a02fSZi Xuan Wu #endif // LLVM_LIB_TARGET_CSKY_CSKYSUBTARGET_H
215