1 // RUN: llvm-tblgen -gen-riscv-target-def -I %p/../../include %s | FileCheck %s
3 include "llvm/Target/Target.td"
5 class RISCVExtension<string name, int major, int minor, string desc,
6 list<SubtargetFeature> implies = [],
7 string fieldname = !subst("Feature", "Has", NAME),
9 : SubtargetFeature<name, fieldname, value, desc, implies> {
10 int MajorVersion = major;
11 int MinorVersion = minor;
12 bit Experimental = false;
15 class RISCVExtensionBitmask<bits<3> groupID, int bitPos> {
16 int GroupID = groupID;
20 class RISCVExperimentalExtension<string name, int major, int minor, string desc,
21 list<RISCVExtension> implies = [],
22 string fieldname = !subst("Feature", "Has", NAME),
23 string value = "true">
24 : RISCVExtension<"experimental-"#name, major, minor, desc, implies,
26 let Experimental = true;
30 : RISCVExtension<"i", 2, 1,
31 "'I' (Base Integer Instruction Set)">,
32 RISCVExtensionBitmask<0, 8>;
34 def FeatureStdExtZicsr
35 : RISCVExtension<"zicsr", 2, 0,
38 def FeatureStdExtZifencei
39 : RISCVExtension<"zifencei", 2, 0,
40 "'Zifencei' (fence.i)">;
43 : RISCVExtension<"f", 2, 2,
44 "'F' (Single-Precision Floating-Point)",
45 [FeatureStdExtZicsr]>,
46 RISCVExtensionBitmask<0, 5>;
48 def FeatureStdExtZidummy
49 : RISCVExperimentalExtension<"zidummy", 0, 1,
53 : SubtargetFeature<"32bit", "IsRV32", "true", "Implements RV32">;
55 : SubtargetFeature<"64bit", "IsRV64", "true", "Implements RV64">;
57 // Dummy feature that isn't an extension.
59 : SubtargetFeature<"dummy", "Dummy", "true", "Dummy">;
61 class RISCVProfile<string name, list<SubtargetFeature> features>
62 : SubtargetFeature<name, "Is" # NAME, "true",
63 "RISC-V " # name # " profile", features> {
64 bit Experimental = false;
66 class RISCVExperimentalProfile<string name, list<SubtargetFeature> features>
67 : RISCVProfile<"experimental-"#name, features> {
68 let Experimental = true;
71 def RVI20U32 : RISCVProfile<"rvi20u32", [Feature32Bit, FeatureStdExtI]>;
72 def RVI20U64 : RISCVProfile<"rvi20u64", [Feature64Bit, FeatureStdExtI]>;
73 def ProfileDummy : RISCVProfile<"dummy", [Feature64Bit, FeatureStdExtI,
74 FeatureStdExtF, FeatureStdExtZidummy]>;
75 def RVI99U64 : RISCVExperimentalProfile<"rvi99u64", [Feature64Bit, FeatureStdExtI]>;
77 class RISCVProcessorModel<string n,
79 list<SubtargetFeature> f,
80 list<SubtargetFeature> tunef = [],
81 string default_march = "">
82 : ProcessorModel<n, m, f, tunef> {
83 string DefaultMarch = default_march;
89 class RISCVTuneProcessorModel<string n,
91 list<SubtargetFeature> tunef = [],
92 list<SubtargetFeature> f = []>
93 : ProcessorModel<n, m, f,tunef>;
95 def GENERIC_RV32 : RISCVProcessorModel<"generic-rv32",
99 def GENERIC_RV64 : RISCVProcessorModel<"generic-rv64",
103 def GENERIC : RISCVTuneProcessorModel<"generic", NoSchedModel>;
106 def ROCKET_RV32 : RISCVProcessorModel<"rocket-rv32",
110 FeatureStdExtZifencei,
112 FeatureStdExtZidummy,
114 def ROCKET_RV64 : RISCVProcessorModel<"rocket-rv64",
118 FeatureStdExtZifencei,
120 FeatureStdExtZidummy,
122 def ROCKET : RISCVTuneProcessorModel<"rocket",
125 // CHECK: #ifdef GET_SUPPORTED_EXTENSIONS
126 // CHECK-NEXT: #undef GET_SUPPORTED_EXTENSIONS
128 // CHECK: static const RISCVSupportedExtension SupportedExtensions[] = {
129 // CHECK-NEXT: {"f", {2, 2}},
130 // CHECK-NEXT: {"i", {2, 1}},
131 // CHECK-NEXT: {"zicsr", {2, 0}},
132 // CHECK-NEXT: {"zifencei", {2, 0}},
135 // CHECK: static const RISCVSupportedExtension SupportedExperimentalExtensions[] = {
136 // CHECK-NEXT: {"zidummy", {0, 1}},
139 // CHECK: #endif // GET_SUPPORTED_EXTENSIONS
141 // CHECK: #ifdef GET_IMPLIED_EXTENSIONS
142 // CHECK-NEXT: #undef GET_IMPLIED_EXTENSIONS
144 // CHECK: static constexpr ImpliedExtsEntry ImpliedExts[] = {
145 // CHECK-NEXT: { {"f"}, "zicsr"},
148 // CHECK: #endif // GET_IMPLIED_EXTENSIONS
150 // CHECK: #ifdef GET_SUPPORTED_PROFILES
151 // CHECK-NEXT: #undef GET_SUPPORTED_PROFILES
153 // CHECK: static constexpr RISCVProfile SupportedProfiles[] = {
154 // CHECK-NEXT: {"dummy","rv64i2p1_f2p2_zidummy0p1"},
155 // CHECK-NEXT: {"rvi20u32","rv32i2p1"},
156 // CHECK-NEXT: {"rvi20u64","rv64i2p1"},
159 // CHECK: static constexpr RISCVProfile SupportedExperimentalProfiles[] = {
160 // CHECK-NEXT: {"rvi99u64","rv64i2p1"},
163 // CHECK: #endif // GET_SUPPORTED_PROFILES
165 // CHECK: #ifndef PROC
166 // CHECK-NEXT: #define PROC(ENUM, NAME, DEFAULT_MARCH, FAST_SCALAR_UNALIGN, FAST_VECTOR_UNALIGN, MVENDORID, MARCHID, MIMPID)
167 // CHECK-NEXT: #endif
169 // CHECK: PROC(GENERIC_RV32, {"generic-rv32"}, {"rv32i2p1"}, 0, 0, 0x00000000, 0x0000000000000000, 0x0000000000000000)
170 // CHECK-NEXT: PROC(GENERIC_RV64, {"generic-rv64"}, {"rv64i2p1"}, 0, 0, 0x00000000, 0x0000000000000000, 0x0000000000000000)
171 // CHECK-NEXT: PROC(ROCKET_RV32, {"rocket-rv32"}, {"rv32i2p1_zicsr2p0_zidummy0p1_zifencei2p0"}, 0, 0, 0x00000000, 0x0000000000000000, 0x0000000000000000)
172 // CHECK-NEXT: PROC(ROCKET_RV64, {"rocket-rv64"}, {"rv64i2p1_zicsr2p0_zidummy0p1_zifencei2p0"}, 0, 0, 0x00000000, 0x0000000000000000, 0x0000000000000000)
174 // CHECK: #undef PROC
176 // CHECK: #ifndef TUNE_PROC
177 // CHECK-NEXT: #define TUNE_PROC(ENUM, NAME)
178 // CHECK-NEXT: #endif
180 // CHECK: TUNE_PROC(GENERIC, "generic")
181 // CHECK-NEXT: TUNE_PROC(ROCKET, "rocket")
183 // CHECK: #undef TUNE_PROC
185 // CHECK: #ifdef GET_RISCVExtensionBitmaskTable_IMPL
186 // CHECK-NEXT: static const RISCVExtensionBitmask ExtensionBitmask[]={
187 // CHECK-NEXT: {"f", 0, 5ULL},
188 // CHECK-NEXT: {"i", 0, 8ULL},
190 // CHECK-NEXT: #endif