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;
86 class RISCVTuneProcessorModel<string n,
88 list<SubtargetFeature> tunef = [],
89 list<SubtargetFeature> f = []>
90 : ProcessorModel<n, m, f,tunef>;
92 def GENERIC_RV32 : RISCVProcessorModel<"generic-rv32",
96 def GENERIC_RV64 : RISCVProcessorModel<"generic-rv64",
100 def GENERIC : RISCVTuneProcessorModel<"generic", NoSchedModel>;
103 def ROCKET_RV32 : RISCVProcessorModel<"rocket-rv32",
107 FeatureStdExtZifencei,
109 FeatureStdExtZidummy,
111 def ROCKET_RV64 : RISCVProcessorModel<"rocket-rv64",
115 FeatureStdExtZifencei,
117 FeatureStdExtZidummy,
119 def ROCKET : RISCVTuneProcessorModel<"rocket",
122 // CHECK: #ifdef GET_SUPPORTED_EXTENSIONS
123 // CHECK-NEXT: #undef GET_SUPPORTED_EXTENSIONS
125 // CHECK: static const RISCVSupportedExtension SupportedExtensions[] = {
126 // CHECK-NEXT: {"f", {2, 2}},
127 // CHECK-NEXT: {"i", {2, 1}},
128 // CHECK-NEXT: {"zicsr", {2, 0}},
129 // CHECK-NEXT: {"zifencei", {2, 0}},
132 // CHECK: static const RISCVSupportedExtension SupportedExperimentalExtensions[] = {
133 // CHECK-NEXT: {"zidummy", {0, 1}},
136 // CHECK: #endif // GET_SUPPORTED_EXTENSIONS
138 // CHECK: #ifdef GET_IMPLIED_EXTENSIONS
139 // CHECK-NEXT: #undef GET_IMPLIED_EXTENSIONS
141 // CHECK: static constexpr ImpliedExtsEntry ImpliedExts[] = {
142 // CHECK-NEXT: { {"f"}, "zicsr"},
145 // CHECK: #endif // GET_IMPLIED_EXTENSIONS
147 // CHECK: #ifdef GET_SUPPORTED_PROFILES
148 // CHECK-NEXT: #undef GET_SUPPORTED_PROFILES
150 // CHECK: static constexpr RISCVProfile SupportedProfiles[] = {
151 // CHECK-NEXT: {"dummy","rv64i2p1_f2p2_zidummy0p1"},
152 // CHECK-NEXT: {"rvi20u32","rv32i2p1"},
153 // CHECK-NEXT: {"rvi20u64","rv64i2p1"},
156 // CHECK: static constexpr RISCVProfile SupportedExperimentalProfiles[] = {
157 // CHECK-NEXT: {"rvi99u64","rv64i2p1"},
160 // CHECK: #endif // GET_SUPPORTED_PROFILES
162 // CHECK: #ifndef PROC
163 // CHECK-NEXT: #define PROC(ENUM, NAME, DEFAULT_MARCH, FAST_SCALAR_UNALIGN, FAST_VECTOR_UNALIGN)
164 // CHECK-NEXT: #endif
166 // CHECK: PROC(GENERIC_RV32, {"generic-rv32"}, {"rv32i2p1"}, 0, 0)
167 // CHECK-NEXT: PROC(GENERIC_RV64, {"generic-rv64"}, {"rv64i2p1"}, 0, 0)
168 // CHECK-NEXT: PROC(ROCKET_RV32, {"rocket-rv32"}, {"rv32i2p1_zicsr2p0_zidummy0p1_zifencei2p0"}, 0, 0)
169 // CHECK-NEXT: PROC(ROCKET_RV64, {"rocket-rv64"}, {"rv64i2p1_zicsr2p0_zidummy0p1_zifencei2p0"}, 0, 0)
171 // CHECK: #undef PROC
173 // CHECK: #ifndef TUNE_PROC
174 // CHECK-NEXT: #define TUNE_PROC(ENUM, NAME)
175 // CHECK-NEXT: #endif
177 // CHECK: TUNE_PROC(GENERIC, "generic")
178 // CHECK-NEXT: TUNE_PROC(ROCKET, "rocket")
180 // CHECK: #undef TUNE_PROC
182 // CHECK: #ifdef GET_RISCVExtensionBitmaskTable_IMPL
183 // CHECK-NEXT: static const RISCVExtensionBitmask ExtensionBitmask[]={
184 // CHECK-NEXT: {"f", 0, 5ULL},
185 // CHECK-NEXT: {"i", 0, 8ULL},
187 // CHECK-NEXT: #endif