xref: /freebsd/contrib/llvm-project/llvm/lib/Target/CSKY/CSKYSubtarget.cpp (revision 8ddb146abcdf061be9f2c0db7e391697dafad85c)
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 
15 using namespace llvm;
16 
17 #define DEBUG_TYPE "csky-subtarget"
18 #define GET_SUBTARGETINFO_TARGET_DESC
19 #define GET_SUBTARGETINFO_CTOR
20 #include "CSKYGenSubtargetInfo.inc"
21 
22 void CSKYSubtarget::anchor() {}
23 
24 CSKYSubtarget &CSKYSubtarget::initializeSubtargetDependencies(
25     const Triple &TT, StringRef CPUName, StringRef TuneCPUName, StringRef FS) {
26 
27   if (CPUName.empty())
28     CPUName = "generic";
29   if (TuneCPUName.empty())
30     TuneCPUName = CPUName;
31 
32   UseHardFloat = false;
33   UseHardFloatABI = false;
34   HasFPUv2SingleFloat = false;
35   HasFPUv2DoubleFloat = false;
36   HasFPUv3SingleFloat = false;
37   HasFPUv3DoubleFloat = false;
38 
39   HasBTST16 = false;
40   HasJAVA = false;
41   HasExtendLrw = false;
42   HasDoloop = false;
43   HasHighRegisters = false;
44 
45   HasE1 = false;
46   HasE2 = false;
47   Has2E3 = false;
48   HasMP = false;
49   Has3E3r1 = false;
50   Has3r1E3r2 = false;
51   Has3r2E3r3 = false;
52   Has3E7 = false;
53   HasMP1E2 = false;
54   Has7E10 = false;
55   Has10E60 = false;
56 
57   ParseSubtargetFeatures(CPUName, TuneCPUName, FS);
58   return *this;
59 }
60 
61 CSKYSubtarget::CSKYSubtarget(const Triple &TT, StringRef CPU, StringRef TuneCPU,
62                              StringRef FS, const TargetMachine &TM)
63     : CSKYGenSubtargetInfo(TT, CPU, TuneCPU, FS),
64       FrameLowering(initializeSubtargetDependencies(TT, CPU, TuneCPU, FS)),
65       InstrInfo(*this), RegInfo(), TLInfo(TM, *this) {}
66 
67 bool CSKYSubtarget::useHardFloatABI() const {
68   auto FloatABI = getTargetLowering()->getTargetMachine().Options.FloatABIType;
69 
70   if (FloatABI == FloatABI::Default)
71     return UseHardFloatABI;
72   else
73     return FloatABI == FloatABI::Hard;
74 }
75