xref: /freebsd/contrib/llvm-project/llvm/lib/Target/CSKY/CSKYSubtarget.cpp (revision 257e70f1d5ee61037c8c59b116538d3b6b1427a2)
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 #include "CSKYSubtarget.h"
14 #include "llvm/CodeGen/MachineFrameInfo.h"
15 
16 using namespace llvm;
17 
18 #define DEBUG_TYPE "csky-subtarget"
19 #define GET_SUBTARGETINFO_TARGET_DESC
20 #define GET_SUBTARGETINFO_CTOR
21 #include "CSKYGenSubtargetInfo.inc"
22 
23 void CSKYSubtarget::anchor() {}
24 
25 CSKYSubtarget &CSKYSubtarget::initializeSubtargetDependencies(
26     const Triple &TT, StringRef CPUName, StringRef TuneCPUName, StringRef FS) {
27 
28   if (CPUName.empty())
29     CPUName = "generic";
30   if (TuneCPUName.empty())
31     TuneCPUName = CPUName;
32 
33   UseHardFloat = false;
34   UseHardFloatABI = false;
35   HasFPUv2SingleFloat = false;
36   HasFPUv2DoubleFloat = false;
37   HasFPUv3HalfWord = false;
38   HasFPUv3HalfFloat = false;
39   HasFPUv3SingleFloat = false;
40   HasFPUv3DoubleFloat = false;
41   HasFdivdu = false;
42   HasFLOATE1 = false;
43   HasFLOAT1E2 = false;
44   HasFLOAT1E3 = false;
45   HasFLOAT3E4 = false;
46   HasFLOAT7E60 = false;
47   HasExtendLrw = false;
48   HasBTST16 = false;
49   HasTrust = false;
50   HasJAVA = false;
51   HasCache = false;
52   HasNVIC = false;
53   HasDSP = false;
54   HasDSP1E2 = false;
55   HasDSPE60 = false;
56   HasDSPV2 = false;
57   HasDSP_Silan = false;
58   HasDoloop = false;
59   HasHardwareDivide = false;
60   HasHighRegisters = false;
61   HasVDSPV2 = false;
62   HasVDSP2E3 = false;
63   HasVDSP2E60F = false;
64   ReadTPHard = false;
65   HasVDSPV1_128 = false;
66   UseCCRT = false;
67   DumpConstPool = false;
68   EnableInterruptAttribute = false;
69   HasPushPop = false;
70   HasSTM = false;
71   SmartMode = false;
72   EnableStackSize = false;
73 
74   HasE1 = false;
75   HasE2 = false;
76   Has2E3 = false;
77   HasMP = false;
78   Has3E3r1 = false;
79   Has3r1E3r2 = false;
80   Has3r2E3r3 = false;
81   Has3E7 = false;
82   HasMP1E2 = false;
83   Has7E10 = false;
84   Has10E60 = false;
85 
86   ParseSubtargetFeatures(CPUName, TuneCPUName, FS);
87   return *this;
88 }
89 
90 CSKYSubtarget::CSKYSubtarget(const Triple &TT, StringRef CPU, StringRef TuneCPU,
91                              StringRef FS, const TargetMachine &TM)
92     : CSKYGenSubtargetInfo(TT, CPU, TuneCPU, FS),
93       FrameLowering(initializeSubtargetDependencies(TT, CPU, TuneCPU, FS)),
94       InstrInfo(*this), RegInfo(), TLInfo(TM, *this) {}
95 
96 bool CSKYSubtarget::useHardFloatABI() const {
97   auto FloatABI = getTargetLowering()->getTargetMachine().Options.FloatABIType;
98 
99   if (FloatABI == FloatABI::Default)
100     return UseHardFloatABI;
101   else
102     return FloatABI == FloatABI::Hard;
103 }
104