aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/CSKY/CSKYSubtarget.h
blob: 9e7ad00c0a504eeaf60a2c819fc72b3293fb7c26 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
//===-- CSKYSubtarget.h - Define Subtarget for the CSKY----------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file declares the CSKY specific subclass of TargetSubtargetInfo.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIB_TARGET_CSKY_CSKYSUBTARGET_H
#define LLVM_LIB_TARGET_CSKY_CSKYSUBTARGET_H

#include "CSKYFrameLowering.h"
#include "CSKYISelLowering.h"
#include "CSKYInstrInfo.h"
#include "CSKYRegisterInfo.h"
#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/Target/TargetMachine.h"

#define GET_SUBTARGETINFO_HEADER
#include "CSKYGenSubtargetInfo.inc"

namespace llvm {
class StringRef;

class CSKYSubtarget : public CSKYGenSubtargetInfo {
  virtual void anchor();

  CSKYFrameLowering FrameLowering;
  CSKYInstrInfo InstrInfo;
  CSKYRegisterInfo RegInfo;
  CSKYTargetLowering TLInfo;
  SelectionDAGTargetInfo TSInfo;

  enum CSKYProcFamilyEnum {
    Others,

    CK801,
    CK802,
    CK803,
    CK803S,
    CK804,
    CK805,
    CK807,
    CK810,
    CK810V,
    CK860,
    CK860V
  };

  /// CSKYProcFamily - CSKY processor family: CK801, CK802, and others.
  CSKYProcFamilyEnum CSKYProcFamily = Others;

  bool UseHardFloat;
  bool UseHardFloatABI;
  bool HasFPUv2SingleFloat;
  bool HasFPUv2DoubleFloat;
  bool HasFPUv3HalfWord;
  bool HasFPUv3HalfFloat;
  bool HasFPUv3SingleFloat;
  bool HasFPUv3DoubleFloat;
  bool HasFdivdu;
  bool HasFLOATE1;
  bool HasFLOAT1E2;
  bool HasFLOAT1E3;
  bool HasFLOAT3E4;
  bool HasFLOAT7E60;
  bool HasBTST16;
  bool HasExtendLrw;
  bool HasTrust;
  bool HasJAVA;
  bool HasCache;
  bool HasNVIC;
  bool HasDSP;
  bool HasDSP1E2;
  bool HasDSPE60;
  bool HasDSPV2;
  bool HasDSP_Silan;
  bool HasDoloop;
  bool HasHardwareDivide;
  bool HasHighRegisters;
  bool HasVDSPV2;
  bool HasVDSP2E3;
  bool HasVDSP2E60F;
  bool ReadTPHard;
  bool HasVDSPV1_128;
  bool UseCCRT;
  bool DumpConstPool;
  bool EnableInterruptAttribute;
  bool HasPushPop;
  bool HasSTM;
  bool SmartMode;
  bool EnableStackSize;

  bool HasE1;
  bool HasE2;
  bool Has2E3;
  bool HasMP;
  bool Has3E3r1;
  bool Has3r1E3r2;
  bool Has3r2E3r3;
  bool Has3E7;
  bool HasMP1E2;
  bool Has7E10;
  bool Has10E60;

public:
  CSKYSubtarget(const Triple &TT, StringRef CPU, StringRef TuneCPU,
                StringRef FS, const TargetMachine &TM);

  const CSKYFrameLowering *getFrameLowering() const override {
    return &FrameLowering;
  }
  const CSKYInstrInfo *getInstrInfo() const override { return &InstrInfo; }
  const CSKYRegisterInfo *getRegisterInfo() const override { return &RegInfo; }
  const CSKYTargetLowering *getTargetLowering() const override {
    return &TLInfo;
  }
  const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
    return &TSInfo;
  }

  /// Initializes using the passed in CPU and feature strings so that we can
  /// use initializer lists for subtarget initialization.
  CSKYSubtarget &initializeSubtargetDependencies(const Triple &TT,
                                                 StringRef CPU,
                                                 StringRef TuneCPU,
                                                 StringRef FS);

  // Generated by inc file
  void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);

  bool useHardFloatABI() const;
  bool useHardFloat() const { return UseHardFloat; }
  bool hasFPUv2SingleFloat() const { return HasFPUv2SingleFloat; }
  bool hasFPUv2DoubleFloat() const { return HasFPUv2DoubleFloat; }
  bool hasFPUv2() const { return HasFPUv2SingleFloat || HasFPUv2DoubleFloat; }
  bool hasFPUv3HalfWord() const { return HasFPUv3HalfWord; }
  bool hasFPUv3HalfFloat() const { return HasFPUv3HalfFloat; }
  bool hasFPUv3SingleFloat() const { return HasFPUv3SingleFloat; }
  bool hasFPUv3DoubleFloat() const { return HasFPUv3DoubleFloat; }
  bool hasFPUv3() const {
    return HasFPUv3HalfFloat || HasFPUv3SingleFloat || HasFPUv3DoubleFloat;
  }
  bool hasAnyFloatExt() const { return hasFPUv2() || hasFPUv3(); };
  bool hasFdivdu() const { return HasFdivdu; }
  bool hasFLOATE1() const { return HasFLOATE1; }
  bool hasFLOAT1E2() const { return HasFLOAT1E2; }
  bool hasFLOAT1E3() const { return HasFLOAT1E3; }
  bool hasFLOAT3E4() const { return HasFLOAT3E4; }
  bool hasFLOAT7E60() const { return HasFLOAT7E60; }
  bool hasExtendLrw() const { return HasExtendLrw; }
  bool hasBTST16() const { return HasBTST16; }
  bool hasTrust() const { return HasTrust; }
  bool hasJAVA() const { return HasJAVA; }
  bool hasCache() const { return HasCache; }
  bool hasNVIC() const { return HasNVIC; }
  bool hasDSP() const { return HasDSP; }
  bool hasDSP1E2() const { return HasDSP1E2; }
  bool hasDSPE60() const { return HasDSPE60; }
  bool hasDSPV2() const { return HasDSPV2; }
  bool hasDSP_Silan() const { return HasDSP_Silan; }
  bool hasDoloop() const { return HasDoloop; }
  bool hasHighRegisters() const { return HasHighRegisters; }
  bool hasVDSPV2() const { return HasVDSPV2; }
  bool hasVDSPV2_FLOAT() const { return HasVDSPV2 && UseHardFloat; }
  bool hasVDSPV2_HALF() const {
    return HasVDSPV2 && UseHardFloat && HasFPUv3HalfFloat;
  }
  bool hasVDSP2E3() const { return HasVDSP2E3; }
  bool hasVDSP2E60F() const { return HasVDSP2E60F; }
  bool readTPHard() const { return ReadTPHard; }
  bool hasVDSPV1_128() const { return HasVDSPV1_128; }
  bool useCCRT() const { return UseCCRT; }
  bool dumpConstPool() const { return DumpConstPool; }
  bool enableInterruptAttribute() const { return EnableInterruptAttribute; }
  bool hasPushPop() const { return HasPushPop; }
  bool hasSTM() const { return HasSTM; }
  bool smartMode() const { return SmartMode; }
  bool enableStackSize() const { return EnableStackSize; }

  bool hasE1() const { return HasE1; }
  bool hasE2() const { return HasE2; }
  bool has2E3() const { return Has2E3; }
  bool has3r1E3r2() const { return Has3r1E3r2; }
  bool has3r2E3r3() const { return Has3r2E3r3; }
  bool has3E3r1() const { return Has3E3r1; }
  bool has3E7() const { return Has3E7; }
  bool hasMP() const { return HasMP; }
  bool hasMP1E2() const { return HasMP1E2; }
  bool has7E10() const { return Has7E10; }
  bool has10E60() const { return Has10E60; }

  bool isCK801() const { return CSKYProcFamily == CK801; }
  bool isCK802() const { return CSKYProcFamily == CK802; }
  bool isCK803() const { return CSKYProcFamily == CK803; }
  bool isCK803S() const { return CSKYProcFamily == CK803S; }
  bool isCK804() const { return CSKYProcFamily == CK804; }
  bool isCK805() const { return CSKYProcFamily == CK805; }
  bool isCK807() const { return CSKYProcFamily == CK807; }
  bool isCK810() const { return CSKYProcFamily == CK810; }
  bool isCK810V() const { return CSKYProcFamily == CK810V; }
  bool isCK860() const { return CSKYProcFamily == CK860; }
  bool isCK860V() const { return CSKYProcFamily == CK860V; }
};
} // namespace llvm

#endif // LLVM_LIB_TARGET_CSKY_CSKYSUBTARGET_H