Skip to content

Commit 1c80d32

Browse files
authored
[WebAssembly] Sort target features (NFC) (#90777)
1 parent 941eab1 commit 1c80d32

File tree

7 files changed

+241
-239
lines changed

7 files changed

+241
-239
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4895,34 +4895,34 @@ def mharden_sls_EQ : Joined<["-"], "mharden-sls=">, Group<m_Group>,
48954895
" blr(ARM/AArch64), comdat(ARM/AArch64), nocomdat(ARM/AArch64),"
48964896
" return(X86), indirect-jmp(X86)">;
48974897

4898-
def msimd128 : Flag<["-"], "msimd128">, Group<m_wasm_Features_Group>;
4899-
def mno_simd128 : Flag<["-"], "mno-simd128">, Group<m_wasm_Features_Group>;
4900-
def mrelaxed_simd : Flag<["-"], "mrelaxed-simd">, Group<m_wasm_Features_Group>;
4901-
def mno_relaxed_simd : Flag<["-"], "mno-relaxed-simd">, Group<m_wasm_Features_Group>;
4902-
def mhalf_precision : Flag<["-"], "mhalf-precision">, Group<m_wasm_Features_Group>;
4903-
def mno_half_precision : Flag<["-"], "mno-half-precision">, Group<m_wasm_Features_Group>;
4904-
def mnontrapping_fptoint : Flag<["-"], "mnontrapping-fptoint">, Group<m_wasm_Features_Group>;
4905-
def mno_nontrapping_fptoint : Flag<["-"], "mno-nontrapping-fptoint">, Group<m_wasm_Features_Group>;
4906-
def msign_ext : Flag<["-"], "msign-ext">, Group<m_wasm_Features_Group>;
4907-
def mno_sign_ext : Flag<["-"], "mno-sign-ext">, Group<m_wasm_Features_Group>;
4908-
def mexception_handing : Flag<["-"], "mexception-handling">, Group<m_wasm_Features_Group>;
4909-
def mno_exception_handing : Flag<["-"], "mno-exception-handling">, Group<m_wasm_Features_Group>;
49104898
def matomics : Flag<["-"], "matomics">, Group<m_wasm_Features_Group>;
49114899
def mno_atomics : Flag<["-"], "mno-atomics">, Group<m_wasm_Features_Group>;
49124900
def mbulk_memory : Flag<["-"], "mbulk-memory">, Group<m_wasm_Features_Group>;
49134901
def mno_bulk_memory : Flag<["-"], "mno-bulk-memory">, Group<m_wasm_Features_Group>;
4914-
def mmutable_globals : Flag<["-"], "mmutable-globals">, Group<m_wasm_Features_Group>;
4915-
def mno_mutable_globals : Flag<["-"], "mno-mutable-globals">, Group<m_wasm_Features_Group>;
4916-
def mmultivalue : Flag<["-"], "mmultivalue">, Group<m_wasm_Features_Group>;
4917-
def mno_multivalue : Flag<["-"], "mno-multivalue">, Group<m_wasm_Features_Group>;
4918-
def mtail_call : Flag<["-"], "mtail-call">, Group<m_wasm_Features_Group>;
4919-
def mno_tail_call : Flag<["-"], "mno-tail-call">, Group<m_wasm_Features_Group>;
4920-
def mreference_types : Flag<["-"], "mreference-types">, Group<m_wasm_Features_Group>;
4921-
def mno_reference_types : Flag<["-"], "mno-reference-types">, Group<m_wasm_Features_Group>;
4902+
def mexception_handing : Flag<["-"], "mexception-handling">, Group<m_wasm_Features_Group>;
4903+
def mno_exception_handing : Flag<["-"], "mno-exception-handling">, Group<m_wasm_Features_Group>;
49224904
def mextended_const : Flag<["-"], "mextended-const">, Group<m_wasm_Features_Group>;
49234905
def mno_extended_const : Flag<["-"], "mno-extended-const">, Group<m_wasm_Features_Group>;
4906+
def mhalf_precision : Flag<["-"], "mhalf-precision">, Group<m_wasm_Features_Group>;
4907+
def mno_half_precision : Flag<["-"], "mno-half-precision">, Group<m_wasm_Features_Group>;
49244908
def mmultimemory : Flag<["-"], "mmultimemory">, Group<m_wasm_Features_Group>;
49254909
def mno_multimemory : Flag<["-"], "mno-multimemory">, Group<m_wasm_Features_Group>;
4910+
def mmultivalue : Flag<["-"], "mmultivalue">, Group<m_wasm_Features_Group>;
4911+
def mno_multivalue : Flag<["-"], "mno-multivalue">, Group<m_wasm_Features_Group>;
4912+
def mmutable_globals : Flag<["-"], "mmutable-globals">, Group<m_wasm_Features_Group>;
4913+
def mno_mutable_globals : Flag<["-"], "mno-mutable-globals">, Group<m_wasm_Features_Group>;
4914+
def mnontrapping_fptoint : Flag<["-"], "mnontrapping-fptoint">, Group<m_wasm_Features_Group>;
4915+
def mno_nontrapping_fptoint : Flag<["-"], "mno-nontrapping-fptoint">, Group<m_wasm_Features_Group>;
4916+
def mreference_types : Flag<["-"], "mreference-types">, Group<m_wasm_Features_Group>;
4917+
def mno_reference_types : Flag<["-"], "mno-reference-types">, Group<m_wasm_Features_Group>;
4918+
def mrelaxed_simd : Flag<["-"], "mrelaxed-simd">, Group<m_wasm_Features_Group>;
4919+
def mno_relaxed_simd : Flag<["-"], "mno-relaxed-simd">, Group<m_wasm_Features_Group>;
4920+
def msign_ext : Flag<["-"], "msign-ext">, Group<m_wasm_Features_Group>;
4921+
def mno_sign_ext : Flag<["-"], "mno-sign-ext">, Group<m_wasm_Features_Group>;
4922+
def msimd128 : Flag<["-"], "msimd128">, Group<m_wasm_Features_Group>;
4923+
def mno_simd128 : Flag<["-"], "mno-simd128">, Group<m_wasm_Features_Group>;
4924+
def mtail_call : Flag<["-"], "mtail-call">, Group<m_wasm_Features_Group>;
4925+
def mno_tail_call : Flag<["-"], "mno-tail-call">, Group<m_wasm_Features_Group>;
49264926
def mexec_model_EQ : Joined<["-"], "mexec-model=">, Group<m_wasm_Features_Driver_Group>,
49274927
Values<"command,reactor">,
49284928
HelpText<"Execution model (WebAssembly only)">,

clang/lib/Basic/Targets/WebAssembly.cpp

Lines changed: 83 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,20 @@ bool WebAssemblyTargetInfo::setABI(const std::string &Name) {
4545

4646
bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) const {
4747
return llvm::StringSwitch<bool>(Feature)
48-
.Case("simd128", SIMDLevel >= SIMD128)
49-
.Case("relaxed-simd", SIMDLevel >= RelaxedSIMD)
48+
.Case("atomics", HasAtomics)
49+
.Case("bulk-memory", HasBulkMemory)
50+
.Case("exception-handling", HasExceptionHandling)
51+
.Case("extended-const", HasExtendedConst)
5052
.Case("half-precision", HasHalfPrecision)
53+
.Case("multimemory", HasMultiMemory)
54+
.Case("multivalue", HasMultivalue)
55+
.Case("mutable-globals", HasMutableGlobals)
5156
.Case("nontrapping-fptoint", HasNontrappingFPToInt)
57+
.Case("reference-types", HasReferenceTypes)
58+
.Case("relaxed-simd", SIMDLevel >= RelaxedSIMD)
5259
.Case("sign-ext", HasSignExt)
53-
.Case("exception-handling", HasExceptionHandling)
54-
.Case("bulk-memory", HasBulkMemory)
55-
.Case("atomics", HasAtomics)
56-
.Case("mutable-globals", HasMutableGlobals)
57-
.Case("multivalue", HasMultivalue)
60+
.Case("simd128", SIMDLevel >= SIMD128)
5861
.Case("tail-call", HasTailCall)
59-
.Case("reference-types", HasReferenceTypes)
60-
.Case("extended-const", HasExtendedConst)
61-
.Case("multimemory", HasMultiMemory)
6262
.Default(false);
6363
}
6464

@@ -74,34 +74,34 @@ void WebAssemblyTargetInfo::fillValidCPUList(
7474
void WebAssemblyTargetInfo::getTargetDefines(const LangOptions &Opts,
7575
MacroBuilder &Builder) const {
7676
defineCPUMacros(Builder, "wasm", /*Tuning=*/false);
77-
if (SIMDLevel >= SIMD128)
78-
Builder.defineMacro("__wasm_simd128__");
79-
if (SIMDLevel >= RelaxedSIMD)
80-
Builder.defineMacro("__wasm_relaxed_simd__");
81-
if (HasNontrappingFPToInt)
82-
Builder.defineMacro("__wasm_nontrapping_fptoint__");
83-
if (HasSignExt)
84-
Builder.defineMacro("__wasm_sign_ext__");
85-
if (HasExceptionHandling)
86-
Builder.defineMacro("__wasm_exception_handling__");
87-
if (HasBulkMemory)
88-
Builder.defineMacro("__wasm_bulk_memory__");
8977
if (HasAtomics)
9078
Builder.defineMacro("__wasm_atomics__");
91-
if (HasMutableGlobals)
92-
Builder.defineMacro("__wasm_mutable_globals__");
93-
if (HasMultivalue)
94-
Builder.defineMacro("__wasm_multivalue__");
95-
if (HasTailCall)
96-
Builder.defineMacro("__wasm_tail_call__");
97-
if (HasReferenceTypes)
98-
Builder.defineMacro("__wasm_reference_types__");
79+
if (HasBulkMemory)
80+
Builder.defineMacro("__wasm_bulk_memory__");
81+
if (HasExceptionHandling)
82+
Builder.defineMacro("__wasm_exception_handling__");
9983
if (HasExtendedConst)
10084
Builder.defineMacro("__wasm_extended_const__");
10185
if (HasMultiMemory)
10286
Builder.defineMacro("__wasm_multimemory__");
10387
if (HasHalfPrecision)
10488
Builder.defineMacro("__wasm_half_precision__");
89+
if (HasMultivalue)
90+
Builder.defineMacro("__wasm_multivalue__");
91+
if (HasMutableGlobals)
92+
Builder.defineMacro("__wasm_mutable_globals__");
93+
if (HasNontrappingFPToInt)
94+
Builder.defineMacro("__wasm_nontrapping_fptoint__");
95+
if (HasReferenceTypes)
96+
Builder.defineMacro("__wasm_reference_types__");
97+
if (SIMDLevel >= RelaxedSIMD)
98+
Builder.defineMacro("__wasm_relaxed_simd__");
99+
if (HasSignExt)
100+
Builder.defineMacro("__wasm_sign_ext__");
101+
if (SIMDLevel >= SIMD128)
102+
Builder.defineMacro("__wasm_simd128__");
103+
if (HasTailCall)
104+
Builder.defineMacro("__wasm_tail_call__");
105105

106106
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
107107
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
@@ -159,11 +159,11 @@ bool WebAssemblyTargetInfo::initFeatureMap(
159159
addGenericFeatures();
160160
Features["atomics"] = true;
161161
Features["bulk-memory"] = true;
162+
Features["half-precision"] = true;
162163
Features["multimemory"] = true;
163164
Features["nontrapping-fptoint"] = true;
164165
Features["reference-types"] = true;
165166
Features["tail-call"] = true;
166-
Features["half-precision"] = true;
167167
setSIMDLevel(Features, SIMD128, true);
168168
};
169169
if (CPU == "generic") {
@@ -178,36 +178,20 @@ bool WebAssemblyTargetInfo::initFeatureMap(
178178
bool WebAssemblyTargetInfo::handleTargetFeatures(
179179
std::vector<std::string> &Features, DiagnosticsEngine &Diags) {
180180
for (const auto &Feature : Features) {
181-
if (Feature == "+simd128") {
182-
SIMDLevel = std::max(SIMDLevel, SIMD128);
183-
continue;
184-
}
185-
if (Feature == "-simd128") {
186-
SIMDLevel = std::min(SIMDLevel, SIMDEnum(SIMD128 - 1));
187-
continue;
188-
}
189-
if (Feature == "+relaxed-simd") {
190-
SIMDLevel = std::max(SIMDLevel, RelaxedSIMD);
191-
continue;
192-
}
193-
if (Feature == "-relaxed-simd") {
194-
SIMDLevel = std::min(SIMDLevel, SIMDEnum(RelaxedSIMD - 1));
195-
continue;
196-
}
197-
if (Feature == "+nontrapping-fptoint") {
198-
HasNontrappingFPToInt = true;
181+
if (Feature == "+atomics") {
182+
HasAtomics = true;
199183
continue;
200184
}
201-
if (Feature == "-nontrapping-fptoint") {
202-
HasNontrappingFPToInt = false;
185+
if (Feature == "-atomics") {
186+
HasAtomics = false;
203187
continue;
204188
}
205-
if (Feature == "+sign-ext") {
206-
HasSignExt = true;
189+
if (Feature == "+bulk-memory") {
190+
HasBulkMemory = true;
207191
continue;
208192
}
209-
if (Feature == "-sign-ext") {
210-
HasSignExt = false;
193+
if (Feature == "-bulk-memory") {
194+
HasBulkMemory = false;
211195
continue;
212196
}
213197
if (Feature == "+exception-handling") {
@@ -218,12 +202,12 @@ bool WebAssemblyTargetInfo::handleTargetFeatures(
218202
HasExceptionHandling = false;
219203
continue;
220204
}
221-
if (Feature == "+bulk-memory") {
222-
HasBulkMemory = true;
205+
if (Feature == "+extended-const") {
206+
HasExtendedConst = true;
223207
continue;
224208
}
225-
if (Feature == "-bulk-memory") {
226-
HasBulkMemory = false;
209+
if (Feature == "-extended-const") {
210+
HasExtendedConst = false;
227211
continue;
228212
}
229213
if (Feature == "+half-precision") {
@@ -235,20 +219,12 @@ bool WebAssemblyTargetInfo::handleTargetFeatures(
235219
HasHalfPrecision = false;
236220
continue;
237221
}
238-
if (Feature == "+atomics") {
239-
HasAtomics = true;
240-
continue;
241-
}
242-
if (Feature == "-atomics") {
243-
HasAtomics = false;
244-
continue;
245-
}
246-
if (Feature == "+mutable-globals") {
247-
HasMutableGlobals = true;
222+
if (Feature == "+multimemory") {
223+
HasMultiMemory = true;
248224
continue;
249225
}
250-
if (Feature == "-mutable-globals") {
251-
HasMutableGlobals = false;
226+
if (Feature == "-multimemory") {
227+
HasMultiMemory = false;
252228
continue;
253229
}
254230
if (Feature == "+multivalue") {
@@ -259,12 +235,20 @@ bool WebAssemblyTargetInfo::handleTargetFeatures(
259235
HasMultivalue = false;
260236
continue;
261237
}
262-
if (Feature == "+tail-call") {
263-
HasTailCall = true;
238+
if (Feature == "+mutable-globals") {
239+
HasMutableGlobals = true;
264240
continue;
265241
}
266-
if (Feature == "-tail-call") {
267-
HasTailCall = false;
242+
if (Feature == "-mutable-globals") {
243+
HasMutableGlobals = false;
244+
continue;
245+
}
246+
if (Feature == "+nontrapping-fptoint") {
247+
HasNontrappingFPToInt = true;
248+
continue;
249+
}
250+
if (Feature == "-nontrapping-fptoint") {
251+
HasNontrappingFPToInt = false;
268252
continue;
269253
}
270254
if (Feature == "+reference-types") {
@@ -275,20 +259,36 @@ bool WebAssemblyTargetInfo::handleTargetFeatures(
275259
HasReferenceTypes = false;
276260
continue;
277261
}
278-
if (Feature == "+extended-const") {
279-
HasExtendedConst = true;
262+
if (Feature == "+relaxed-simd") {
263+
SIMDLevel = std::max(SIMDLevel, RelaxedSIMD);
280264
continue;
281265
}
282-
if (Feature == "-extended-const") {
283-
HasExtendedConst = false;
266+
if (Feature == "-relaxed-simd") {
267+
SIMDLevel = std::min(SIMDLevel, SIMDEnum(RelaxedSIMD - 1));
284268
continue;
285269
}
286-
if (Feature == "+multimemory") {
287-
HasMultiMemory = true;
270+
if (Feature == "+sign-ext") {
271+
HasSignExt = true;
288272
continue;
289273
}
290-
if (Feature == "-multimemory") {
291-
HasMultiMemory = false;
274+
if (Feature == "-sign-ext") {
275+
HasSignExt = false;
276+
continue;
277+
}
278+
if (Feature == "+simd128") {
279+
SIMDLevel = std::max(SIMDLevel, SIMD128);
280+
continue;
281+
}
282+
if (Feature == "-simd128") {
283+
SIMDLevel = std::min(SIMDLevel, SIMDEnum(SIMD128 - 1));
284+
continue;
285+
}
286+
if (Feature == "+tail-call") {
287+
HasTailCall = true;
288+
continue;
289+
}
290+
if (Feature == "-tail-call") {
291+
HasTailCall = false;
292292
continue;
293293
}
294294

clang/lib/Basic/Targets/WebAssembly.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,18 @@ class LLVM_LIBRARY_VISIBILITY WebAssemblyTargetInfo : public TargetInfo {
5353
RelaxedSIMD,
5454
} SIMDLevel = NoSIMD;
5555

56-
bool HasNontrappingFPToInt = false;
57-
bool HasSignExt = false;
58-
bool HasExceptionHandling = false;
59-
bool HasBulkMemory = false;
6056
bool HasAtomics = false;
61-
bool HasMutableGlobals = false;
62-
bool HasMultivalue = false;
63-
bool HasTailCall = false;
64-
bool HasReferenceTypes = false;
57+
bool HasBulkMemory = false;
58+
bool HasExceptionHandling = false;
6559
bool HasExtendedConst = false;
66-
bool HasMultiMemory = false;
6760
bool HasHalfPrecision = false;
61+
bool HasMultiMemory = false;
62+
bool HasMultivalue = false;
63+
bool HasMutableGlobals = false;
64+
bool HasNontrappingFPToInt = false;
65+
bool HasReferenceTypes = false;
66+
bool HasSignExt = false;
67+
bool HasTailCall = false;
6868

6969
std::string ABI;
7070

0 commit comments

Comments
 (0)