Skip to content

Commit 5c5a56e

Browse files
committed
[RISCV] Generate RISCVISAInfo table from RISCVFeatures.td.
This generates the SupportedExtensions and ImpliedExts information from the RISCVExtension records found in RISCVFeatures.td. Some implied extension strings aren't quite in the same order, in the individual implication tables. But the list of strings was checked to be the same. I've added the new information to the existing RISCVTargetParserDef.inc and RISCVTargetDefEmitter.cpp so we don't need to re-parse the entirety of RISCV.td a second time for a new file.
1 parent a45eb62 commit 5c5a56e

File tree

2 files changed

+106
-320
lines changed

2 files changed

+106
-320
lines changed

llvm/lib/TargetParser/RISCVISAInfo.cpp

Lines changed: 4 additions & 319 deletions
Original file line numberDiff line numberDiff line change
@@ -47,204 +47,8 @@ static const char *RISCVGImplications[] = {
4747
"i", "m", "a", "f", "d", "zicsr", "zifencei"
4848
};
4949

50-
// NOTE: This table should be sorted alphabetically by extension name.
51-
static const RISCVSupportedExtension SupportedExtensions[] = {
52-
{"a", {2, 1}},
53-
{"c", {2, 0}},
54-
{"d", {2, 2}},
55-
{"e", {2, 0}},
56-
{"f", {2, 2}},
57-
{"h", {1, 0}},
58-
{"i", {2, 1}},
59-
{"m", {2, 0}},
60-
61-
{"shcounterenw", {1, 0}},
62-
{"shgatpa", {1, 0}},
63-
{"shtvala", {1, 0}},
64-
{"shvsatpa", {1, 0}},
65-
{"shvstvala", {1, 0}},
66-
{"shvstvecd", {1, 0}},
67-
{"smaia", {1, 0}},
68-
{"smepmp", {1, 0}},
69-
{"ssaia", {1, 0}},
70-
{"ssccptr", {1, 0}},
71-
{"sscofpmf", {1, 0}},
72-
{"sscounterenw", {1, 0}},
73-
{"ssstateen", {1, 0}},
74-
{"ssstrict", {1, 0}},
75-
{"sstc", {1, 0}},
76-
{"sstvala", {1, 0}},
77-
{"sstvecd", {1, 0}},
78-
{"ssu64xl", {1, 0}},
79-
{"svade", {1, 0}},
80-
{"svadu", {1, 0}},
81-
{"svbare", {1, 0}},
82-
{"svinval", {1, 0}},
83-
{"svnapot", {1, 0}},
84-
{"svpbmt", {1, 0}},
85-
86-
{"v", {1, 0}},
87-
88-
// vendor-defined ('X') extensions
89-
{"xcvalu", {1, 0}},
90-
{"xcvbi", {1, 0}},
91-
{"xcvbitmanip", {1, 0}},
92-
{"xcvelw", {1, 0}},
93-
{"xcvmac", {1, 0}},
94-
{"xcvmem", {1, 0}},
95-
{"xcvsimd", {1, 0}},
96-
{"xsfcease", {1, 0}},
97-
{"xsfvcp", {1, 0}},
98-
{"xsfvfnrclipxfqf", {1, 0}},
99-
{"xsfvfwmaccqqq", {1, 0}},
100-
{"xsfvqmaccdod", {1, 0}},
101-
{"xsfvqmaccqoq", {1, 0}},
102-
{"xsifivecdiscarddlone", {1, 0}},
103-
{"xsifivecflushdlone", {1, 0}},
104-
{"xtheadba", {1, 0}},
105-
{"xtheadbb", {1, 0}},
106-
{"xtheadbs", {1, 0}},
107-
{"xtheadcmo", {1, 0}},
108-
{"xtheadcondmov", {1, 0}},
109-
{"xtheadfmemidx", {1, 0}},
110-
{"xtheadmac", {1, 0}},
111-
{"xtheadmemidx", {1, 0}},
112-
{"xtheadmempair", {1, 0}},
113-
{"xtheadsync", {1, 0}},
114-
{"xtheadvdot", {1, 0}},
115-
{"xventanacondops", {1, 0}},
116-
117-
{"za128rs", {1, 0}},
118-
{"za64rs", {1, 0}},
119-
{"zacas", {1, 0}},
120-
{"zama16b", {1, 0}},
121-
{"zawrs", {1, 0}},
122-
123-
{"zba", {1, 0}},
124-
{"zbb", {1, 0}},
125-
{"zbc", {1, 0}},
126-
{"zbkb", {1, 0}},
127-
{"zbkc", {1, 0}},
128-
{"zbkx", {1, 0}},
129-
{"zbs", {1, 0}},
130-
131-
{"zca", {1, 0}},
132-
{"zcb", {1, 0}},
133-
{"zcd", {1, 0}},
134-
{"zce", {1, 0}},
135-
{"zcf", {1, 0}},
136-
{"zcmop", {1, 0}},
137-
{"zcmp", {1, 0}},
138-
{"zcmt", {1, 0}},
139-
140-
{"zdinx", {1, 0}},
141-
142-
{"zfa", {1, 0}},
143-
{"zfh", {1, 0}},
144-
{"zfhmin", {1, 0}},
145-
{"zfinx", {1, 0}},
146-
147-
{"zhinx", {1, 0}},
148-
{"zhinxmin", {1, 0}},
149-
150-
{"zic64b", {1, 0}},
151-
{"zicbom", {1, 0}},
152-
{"zicbop", {1, 0}},
153-
{"zicboz", {1, 0}},
154-
{"ziccamoa", {1, 0}},
155-
{"ziccif", {1, 0}},
156-
{"zicclsm", {1, 0}},
157-
{"ziccrse", {1, 0}},
158-
{"zicntr", {2, 0}},
159-
{"zicond", {1, 0}},
160-
{"zicsr", {2, 0}},
161-
{"zifencei", {2, 0}},
162-
{"zihintntl", {1, 0}},
163-
{"zihintpause", {2, 0}},
164-
{"zihpm", {2, 0}},
165-
{"zimop", {1, 0}},
166-
167-
{"zk", {1, 0}},
168-
{"zkn", {1, 0}},
169-
{"zknd", {1, 0}},
170-
{"zkne", {1, 0}},
171-
{"zknh", {1, 0}},
172-
{"zkr", {1, 0}},
173-
{"zks", {1, 0}},
174-
{"zksed", {1, 0}},
175-
{"zksh", {1, 0}},
176-
{"zkt", {1, 0}},
177-
178-
{"zmmul", {1, 0}},
179-
180-
{"zvbb", {1, 0}},
181-
{"zvbc", {1, 0}},
182-
183-
{"zve32f", {1, 0}},
184-
{"zve32x", {1, 0}},
185-
{"zve64d", {1, 0}},
186-
{"zve64f", {1, 0}},
187-
{"zve64x", {1, 0}},
188-
189-
{"zvfh", {1, 0}},
190-
{"zvfhmin", {1, 0}},
191-
192-
// vector crypto
193-
{"zvkb", {1, 0}},
194-
{"zvkg", {1, 0}},
195-
{"zvkn", {1, 0}},
196-
{"zvknc", {1, 0}},
197-
{"zvkned", {1, 0}},
198-
{"zvkng", {1, 0}},
199-
{"zvknha", {1, 0}},
200-
{"zvknhb", {1, 0}},
201-
{"zvks", {1, 0}},
202-
{"zvksc", {1, 0}},
203-
{"zvksed", {1, 0}},
204-
{"zvksg", {1, 0}},
205-
{"zvksh", {1, 0}},
206-
{"zvkt", {1, 0}},
207-
208-
{"zvl1024b", {1, 0}},
209-
{"zvl128b", {1, 0}},
210-
{"zvl16384b", {1, 0}},
211-
{"zvl2048b", {1, 0}},
212-
{"zvl256b", {1, 0}},
213-
{"zvl32768b", {1, 0}},
214-
{"zvl32b", {1, 0}},
215-
{"zvl4096b", {1, 0}},
216-
{"zvl512b", {1, 0}},
217-
{"zvl64b", {1, 0}},
218-
{"zvl65536b", {1, 0}},
219-
{"zvl8192b", {1, 0}},
220-
};
221-
222-
// NOTE: This table should be sorted alphabetically by extension name.
223-
// clang-format off
224-
static const RISCVSupportedExtension SupportedExperimentalExtensions[] = {
225-
{"smmpm", {0, 8}},
226-
{"smnpm", {0, 8}},
227-
{"ssnpm", {0, 8}},
228-
{"sspm", {0, 8}},
229-
{"ssqosid", {1, 0}},
230-
{"supm", {0, 8}},
231-
232-
{"zaamo", {0, 2}},
233-
{"zabha", {1, 0}},
234-
{"zalasr", {0, 1}},
235-
{"zalrsc", {0, 2}},
236-
237-
{"zfbfmin", {1, 0}},
238-
239-
{"zicfilp", {0, 4}},
240-
{"zicfiss", {0, 4}},
241-
242-
{"ztso", {0, 1}},
243-
244-
{"zvfbfmin", {1, 0}},
245-
{"zvfbfwma", {1, 0}},
246-
};
247-
// clang-format on
50+
#define GET_SUPPORTED_EXTENSIONS
51+
#include "llvm/TargetParser//RISCVTargetParserDef.inc"
24852

24953
static constexpr RISCVProfile SupportedProfiles[] = {
25054
{"rvi20u32", "rv32i"},
@@ -1041,66 +845,6 @@ Error RISCVISAInfo::checkDependency() {
1041845
return Error::success();
1042846
}
1043847

1044-
static const char *ImpliedExtsD[] = {"f"};
1045-
static const char *ImpliedExtsF[] = {"zicsr"};
1046-
static const char *ImpliedExtsV[] = {"zvl128b", "zve64d"};
1047-
static const char *ImpliedExtsXSfvcp[] = {"zve32x"};
1048-
static const char *ImpliedExtsXSfvfnrclipxfqf[] = {"zve32f"};
1049-
static const char *ImpliedExtsXSfvfwmaccqqq[] = {"zvfbfmin"};
1050-
static const char *ImpliedExtsXSfvqmaccdod[] = {"zve32x"};
1051-
static const char *ImpliedExtsXSfvqmaccqoq[] = {"zve32x"};
1052-
static const char *ImpliedExtsXTHeadVdot[] = {"v"};
1053-
static const char *ImpliedExtsZcb[] = {"zca"};
1054-
static const char *ImpliedExtsZcd[] = {"d", "zca"};
1055-
static const char *ImpliedExtsZce[] = {"zcb", "zcmp", "zcmt"};
1056-
static const char *ImpliedExtsZcf[] = {"f", "zca"};
1057-
static const char *ImpliedExtsZcmop[] = {"zca"};
1058-
static const char *ImpliedExtsZcmp[] = {"zca"};
1059-
static const char *ImpliedExtsZcmt[] = {"zca", "zicsr"};
1060-
static const char *ImpliedExtsZdinx[] = {"zfinx"};
1061-
static const char *ImpliedExtsZfa[] = {"f"};
1062-
static const char *ImpliedExtsZfbfmin[] = {"f"};
1063-
static const char *ImpliedExtsZfh[] = {"zfhmin"};
1064-
static const char *ImpliedExtsZfhmin[] = {"f"};
1065-
static const char *ImpliedExtsZfinx[] = {"zicsr"};
1066-
static const char *ImpliedExtsZhinx[] = {"zhinxmin"};
1067-
static const char *ImpliedExtsZhinxmin[] = {"zfinx"};
1068-
static const char *ImpliedExtsZicfiss[] = {"zicsr", "zimop"};
1069-
static const char *ImpliedExtsZicntr[] = {"zicsr"};
1070-
static const char *ImpliedExtsZihpm[] = {"zicsr"};
1071-
static const char *ImpliedExtsZk[] = {"zkn", "zkt", "zkr"};
1072-
static const char *ImpliedExtsZkn[] = {"zbkb", "zbkc", "zbkx",
1073-
"zkne", "zknd", "zknh"};
1074-
static const char *ImpliedExtsZks[] = {"zbkb", "zbkc", "zbkx", "zksed", "zksh"};
1075-
static const char *ImpliedExtsZvbb[] = {"zvkb"};
1076-
static const char *ImpliedExtsZve32f[] = {"zve32x", "f"};
1077-
static const char *ImpliedExtsZve32x[] = {"zvl32b", "zicsr"};
1078-
static const char *ImpliedExtsZve64d[] = {"zve64f", "d"};
1079-
static const char *ImpliedExtsZve64f[] = {"zve64x", "zve32f"};
1080-
static const char *ImpliedExtsZve64x[] = {"zve32x", "zvl64b"};
1081-
static const char *ImpliedExtsZvfbfmin[] = {"zve32f"};
1082-
static const char *ImpliedExtsZvfbfwma[] = {"zvfbfmin", "zfbfmin"};
1083-
static const char *ImpliedExtsZvfh[] = {"zvfhmin", "zfhmin"};
1084-
static const char *ImpliedExtsZvfhmin[] = {"zve32f"};
1085-
static const char *ImpliedExtsZvkn[] = {"zvkb", "zvkned", "zvknhb", "zvkt"};
1086-
static const char *ImpliedExtsZvknc[] = {"zvbc", "zvkn"};
1087-
static const char *ImpliedExtsZvkng[] = {"zvkg", "zvkn"};
1088-
static const char *ImpliedExtsZvknhb[] = {"zve64x"};
1089-
static const char *ImpliedExtsZvks[] = {"zvkb", "zvksed", "zvksh", "zvkt"};
1090-
static const char *ImpliedExtsZvksc[] = {"zvbc", "zvks"};
1091-
static const char *ImpliedExtsZvksg[] = {"zvkg", "zvks"};
1092-
static const char *ImpliedExtsZvl1024b[] = {"zvl512b"};
1093-
static const char *ImpliedExtsZvl128b[] = {"zvl64b"};
1094-
static const char *ImpliedExtsZvl16384b[] = {"zvl8192b"};
1095-
static const char *ImpliedExtsZvl2048b[] = {"zvl1024b"};
1096-
static const char *ImpliedExtsZvl256b[] = {"zvl128b"};
1097-
static const char *ImpliedExtsZvl32768b[] = {"zvl16384b"};
1098-
static const char *ImpliedExtsZvl4096b[] = {"zvl2048b"};
1099-
static const char *ImpliedExtsZvl512b[] = {"zvl256b"};
1100-
static const char *ImpliedExtsZvl64b[] = {"zvl32b"};
1101-
static const char *ImpliedExtsZvl65536b[] = {"zvl32768b"};
1102-
static const char *ImpliedExtsZvl8192b[] = {"zvl4096b"};
1103-
1104848
struct ImpliedExtsEntry {
1105849
StringLiteral Name;
1106850
ArrayRef<const char *> Exts;
@@ -1112,67 +856,8 @@ struct ImpliedExtsEntry {
1112856
bool operator<(StringRef Other) const { return Name < Other; }
1113857
};
1114858

1115-
// Note: The table needs to be sorted by name.
1116-
static constexpr ImpliedExtsEntry ImpliedExts[] = {
1117-
{{"d"}, {ImpliedExtsD}},
1118-
{{"f"}, {ImpliedExtsF}},
1119-
{{"v"}, {ImpliedExtsV}},
1120-
{{"xsfvcp"}, {ImpliedExtsXSfvcp}},
1121-
{{"xsfvfnrclipxfqf"}, {ImpliedExtsXSfvfnrclipxfqf}},
1122-
{{"xsfvfwmaccqqq"}, {ImpliedExtsXSfvfwmaccqqq}},
1123-
{{"xsfvqmaccdod"}, {ImpliedExtsXSfvqmaccdod}},
1124-
{{"xsfvqmaccqoq"}, {ImpliedExtsXSfvqmaccqoq}},
1125-
{{"xtheadvdot"}, {ImpliedExtsXTHeadVdot}},
1126-
{{"zcb"}, {ImpliedExtsZcb}},
1127-
{{"zcd"}, {ImpliedExtsZcd}},
1128-
{{"zce"}, {ImpliedExtsZce}},
1129-
{{"zcf"}, {ImpliedExtsZcf}},
1130-
{{"zcmop"}, {ImpliedExtsZcmop}},
1131-
{{"zcmp"}, {ImpliedExtsZcmp}},
1132-
{{"zcmt"}, {ImpliedExtsZcmt}},
1133-
{{"zdinx"}, {ImpliedExtsZdinx}},
1134-
{{"zfa"}, {ImpliedExtsZfa}},
1135-
{{"zfbfmin"}, {ImpliedExtsZfbfmin}},
1136-
{{"zfh"}, {ImpliedExtsZfh}},
1137-
{{"zfhmin"}, {ImpliedExtsZfhmin}},
1138-
{{"zfinx"}, {ImpliedExtsZfinx}},
1139-
{{"zhinx"}, {ImpliedExtsZhinx}},
1140-
{{"zhinxmin"}, {ImpliedExtsZhinxmin}},
1141-
{{"zicfiss"}, {ImpliedExtsZicfiss}},
1142-
{{"zicntr"}, {ImpliedExtsZicntr}},
1143-
{{"zihpm"}, {ImpliedExtsZihpm}},
1144-
{{"zk"}, {ImpliedExtsZk}},
1145-
{{"zkn"}, {ImpliedExtsZkn}},
1146-
{{"zks"}, {ImpliedExtsZks}},
1147-
{{"zvbb"}, {ImpliedExtsZvbb}},
1148-
{{"zve32f"}, {ImpliedExtsZve32f}},
1149-
{{"zve32x"}, {ImpliedExtsZve32x}},
1150-
{{"zve64d"}, {ImpliedExtsZve64d}},
1151-
{{"zve64f"}, {ImpliedExtsZve64f}},
1152-
{{"zve64x"}, {ImpliedExtsZve64x}},
1153-
{{"zvfbfmin"}, {ImpliedExtsZvfbfmin}},
1154-
{{"zvfbfwma"}, {ImpliedExtsZvfbfwma}},
1155-
{{"zvfh"}, {ImpliedExtsZvfh}},
1156-
{{"zvfhmin"}, {ImpliedExtsZvfhmin}},
1157-
{{"zvkn"}, {ImpliedExtsZvkn}},
1158-
{{"zvknc"}, {ImpliedExtsZvknc}},
1159-
{{"zvkng"}, {ImpliedExtsZvkng}},
1160-
{{"zvknhb"}, {ImpliedExtsZvknhb}},
1161-
{{"zvks"}, {ImpliedExtsZvks}},
1162-
{{"zvksc"}, {ImpliedExtsZvksc}},
1163-
{{"zvksg"}, {ImpliedExtsZvksg}},
1164-
{{"zvl1024b"}, {ImpliedExtsZvl1024b}},
1165-
{{"zvl128b"}, {ImpliedExtsZvl128b}},
1166-
{{"zvl16384b"}, {ImpliedExtsZvl16384b}},
1167-
{{"zvl2048b"}, {ImpliedExtsZvl2048b}},
1168-
{{"zvl256b"}, {ImpliedExtsZvl256b}},
1169-
{{"zvl32768b"}, {ImpliedExtsZvl32768b}},
1170-
{{"zvl4096b"}, {ImpliedExtsZvl4096b}},
1171-
{{"zvl512b"}, {ImpliedExtsZvl512b}},
1172-
{{"zvl64b"}, {ImpliedExtsZvl64b}},
1173-
{{"zvl65536b"}, {ImpliedExtsZvl65536b}},
1174-
{{"zvl8192b"}, {ImpliedExtsZvl8192b}},
1175-
};
859+
#define GET_IMPLIED_EXTENSIONS
860+
#include "llvm/TargetParser/RISCVTargetParserDef.inc"
1176861

1177862
void RISCVISAInfo::updateImplication() {
1178863
bool HasE = Exts.count("e") != 0;

0 commit comments

Comments
 (0)