[WebAssembly] Add gc target feature to addBleedingEdgeFeatures (#151294)
Also alphebetize feature list, add `-mgc` and `-mno-gc` flags, and add some missing feature tests. Reland of #151107. https://github.com/llvm/llvm-project/pull/150201#discussion_r2237982637
This commit is contained in:
parent
90aed4dbdf
commit
8dd91996f0
9 changed files with 44 additions and 22 deletions
|
|
@ -5312,6 +5312,8 @@ def mextended_const : Flag<["-"], "mextended-const">, Group<m_wasm_Features_Grou
|
|||
def mno_extended_const : Flag<["-"], "mno-extended-const">, Group<m_wasm_Features_Group>;
|
||||
def mfp16 : Flag<["-"], "mfp16">, Group<m_wasm_Features_Group>;
|
||||
def mno_fp16 : Flag<["-"], "mno-fp16">, Group<m_wasm_Features_Group>;
|
||||
def mgc : Flag<["-"], "mgc">, Group<m_wasm_Features_Group>;
|
||||
def mno_gc : Flag<["-"], "mno-gc">, Group<m_wasm_Features_Group>;
|
||||
def mmultimemory : Flag<["-"], "mmultimemory">, Group<m_wasm_Features_Group>;
|
||||
def mno_multimemory : Flag<["-"], "mno-multimemory">, Group<m_wasm_Features_Group>;
|
||||
def mmultivalue : Flag<["-"], "mmultivalue">, Group<m_wasm_Features_Group>;
|
||||
|
|
|
|||
|
|
@ -59,12 +59,12 @@ bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) const {
|
|||
.Case("exception-handling", HasExceptionHandling)
|
||||
.Case("extended-const", HasExtendedConst)
|
||||
.Case("fp16", HasFP16)
|
||||
.Case("gc", HasGC)
|
||||
.Case("multimemory", HasMultiMemory)
|
||||
.Case("multivalue", HasMultivalue)
|
||||
.Case("mutable-globals", HasMutableGlobals)
|
||||
.Case("nontrapping-fptoint", HasNontrappingFPToInt)
|
||||
.Case("reference-types", HasReferenceTypes)
|
||||
.Case("gc", HasGC)
|
||||
.Case("relaxed-simd", SIMDLevel >= RelaxedSIMD)
|
||||
.Case("sign-ext", HasSignExt)
|
||||
.Case("simd128", SIMDLevel >= SIMD128)
|
||||
|
|
@ -99,6 +99,8 @@ void WebAssemblyTargetInfo::getTargetDefines(const LangOptions &Opts,
|
|||
Builder.defineMacro("__wasm_multimemory__");
|
||||
if (HasFP16)
|
||||
Builder.defineMacro("__wasm_fp16__");
|
||||
if (HasGC)
|
||||
Builder.defineMacro("__wasm_gc__");
|
||||
if (HasMultivalue)
|
||||
Builder.defineMacro("__wasm_multivalue__");
|
||||
if (HasMutableGlobals)
|
||||
|
|
@ -107,8 +109,6 @@ void WebAssemblyTargetInfo::getTargetDefines(const LangOptions &Opts,
|
|||
Builder.defineMacro("__wasm_nontrapping_fptoint__");
|
||||
if (HasReferenceTypes)
|
||||
Builder.defineMacro("__wasm_reference_types__");
|
||||
if (HasGC)
|
||||
Builder.defineMacro("__wasm_gc__");
|
||||
if (SIMDLevel >= RelaxedSIMD)
|
||||
Builder.defineMacro("__wasm_relaxed_simd__");
|
||||
if (HasSignExt)
|
||||
|
|
@ -194,6 +194,7 @@ bool WebAssemblyTargetInfo::initFeatureMap(
|
|||
Features["exception-handling"] = true;
|
||||
Features["extended-const"] = true;
|
||||
Features["fp16"] = true;
|
||||
Features["gc"] = true;
|
||||
Features["multimemory"] = true;
|
||||
Features["tail-call"] = true;
|
||||
Features["wide-arithmetic"] = true;
|
||||
|
|
@ -270,6 +271,14 @@ bool WebAssemblyTargetInfo::handleTargetFeatures(
|
|||
HasFP16 = false;
|
||||
continue;
|
||||
}
|
||||
if (Feature == "+gc") {
|
||||
HasGC = true;
|
||||
continue;
|
||||
}
|
||||
if (Feature == "-gc") {
|
||||
HasGC = false;
|
||||
continue;
|
||||
}
|
||||
if (Feature == "+multimemory") {
|
||||
HasMultiMemory = true;
|
||||
continue;
|
||||
|
|
@ -310,14 +319,6 @@ bool WebAssemblyTargetInfo::handleTargetFeatures(
|
|||
HasReferenceTypes = false;
|
||||
continue;
|
||||
}
|
||||
if (Feature == "+gc") {
|
||||
HasGC = true;
|
||||
continue;
|
||||
}
|
||||
if (Feature == "-gc") {
|
||||
HasGC = false;
|
||||
continue;
|
||||
}
|
||||
if (Feature == "+relaxed-simd") {
|
||||
SIMDLevel = std::max(SIMDLevel, RelaxedSIMD);
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -64,12 +64,12 @@ class LLVM_LIBRARY_VISIBILITY WebAssemblyTargetInfo : public TargetInfo {
|
|||
bool HasExceptionHandling = false;
|
||||
bool HasExtendedConst = false;
|
||||
bool HasFP16 = false;
|
||||
bool HasGC = false;
|
||||
bool HasMultiMemory = false;
|
||||
bool HasMultivalue = false;
|
||||
bool HasMutableGlobals = false;
|
||||
bool HasNontrappingFPToInt = false;
|
||||
bool HasReferenceTypes = false;
|
||||
bool HasGC = false;
|
||||
bool HasSignExt = false;
|
||||
bool HasTailCall = false;
|
||||
bool HasWideArithmetic = false;
|
||||
|
|
|
|||
|
|
@ -41,6 +41,12 @@
|
|||
// HALF-PRECISION: "-target-feature" "+fp16"
|
||||
// NO-HALF-PRECISION: "-target-feature" "-fp16"
|
||||
|
||||
// RUN: %clang --target=wasm32-unknown-unknown -### %s -mgc 2>&1 | FileCheck %s -check-prefix=GC
|
||||
// RUN: %clang --target=wasm32-unknown-unknown -### %s -mno-gc 2>&1 | FileCheck %s -check-prefix=NO-GC
|
||||
|
||||
// GC: "-target-feature" "+gc"
|
||||
// NO-GC: "-target-feature" "-gc"
|
||||
|
||||
// RUN: %clang --target=wasm32-unknown-unknown -### %s -mmultimemory 2>&1 | FileCheck %s -check-prefix=MULTIMEMORY
|
||||
// RUN: %clang --target=wasm32-unknown-unknown -### %s -mno-multimemory 2>&1 | FileCheck %s -check-prefix=NO-MULTIMEMORY
|
||||
|
||||
|
|
|
|||
|
|
@ -52,6 +52,15 @@
|
|||
//
|
||||
// FP16: #define __wasm_fp16__ 1{{$}}
|
||||
|
||||
// RUN: %clang -E -dM %s -o - 2>&1 \
|
||||
// RUN: -target wasm32-unknown-unknown -mgc \
|
||||
// RUN: | FileCheck %s -check-prefix=GC
|
||||
// RUN: %clang -E -dM %s -o - 2>&1 \
|
||||
// RUN: -target wasm64-unknown-unknown -mgc \
|
||||
// RUN: | FileCheck %s -check-prefix=GC
|
||||
//
|
||||
// GC: #define __wasm_gc__ 1{{$}}
|
||||
|
||||
// RUN: %clang -E -dM %s -o - 2>&1 \
|
||||
// RUN: -target wasm32-unknown-unknown -mmultimemory \
|
||||
// RUN: | FileCheck %s -check-prefix=MULTIMEMORY
|
||||
|
|
@ -145,6 +154,7 @@
|
|||
// MVP-NOT: #define __wasm_exception_handling__ 1{{$}}
|
||||
// MVP-NOT: #define __wasm_extended_const__ 1{{$}}
|
||||
// MVP-NOT: #define __wasm_fp16__ 1{{$}}
|
||||
// MVP-NOT: #define __wasm_gc__ 1{{$}}
|
||||
// MVP-NOT: #define __wasm_multimemory__ 1{{$}}
|
||||
// MVP-NOT: #define __wasm_multivalue__ 1{{$}}
|
||||
// MVP-NOT: #define __wasm_mutable_globals__ 1{{$}}
|
||||
|
|
@ -181,6 +191,7 @@
|
|||
// GENERIC-NOT: #define __wasm_exception_handling__ 1{{$}}
|
||||
// GENERIC-NOT: #define __wasm_extended_const__ 1{{$}}
|
||||
// GENERIC-NOT: #define __wasm__fp16__ 1{{$}}
|
||||
// GENERIC-NOT: #define __wasm_gc__ 1{{$}}
|
||||
// GENERIC-NOT: #define __wasm_multimemory__ 1{{$}}
|
||||
// GENERIC-NOT: #define __wasm_relaxed_simd__ 1{{$}}
|
||||
// GENERIC-NOT: #define __wasm_simd128__ 1{{$}}
|
||||
|
|
@ -199,6 +210,7 @@
|
|||
// BLEEDING-EDGE-INCLUDE-DAG: #define __wasm_exception_handling__ 1{{$}}
|
||||
// BLEEDING-EDGE-INCLUDE-DAG: #define __wasm_extended_const__ 1{{$}}
|
||||
// BLEEDING-EDGE-INCLUDE-DAG: #define __wasm_fp16__ 1{{$}}
|
||||
// BLEEDING-EDGE-INCLUDE-DAG: #define __wasm_gc__ 1{{$}}
|
||||
// BLEEDING-EDGE-INCLUDE-DAG: #define __wasm_multimemory__ 1{{$}}
|
||||
// BLEEDING-EDGE-INCLUDE-DAG: #define __wasm_multivalue__ 1{{$}}
|
||||
// BLEEDING-EDGE-INCLUDE-DAG: #define __wasm_mutable_globals__ 1{{$}}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ def FeatureFP16 :
|
|||
SubtargetFeature<"fp16", "HasFP16", "true",
|
||||
"Enable FP16 instructions">;
|
||||
|
||||
def FeatureGC : SubtargetFeature<"gc", "HasGC", "true", "Enable wasm gc">;
|
||||
|
||||
def FeatureMultiMemory :
|
||||
SubtargetFeature<"multimemory", "HasMultiMemory", "true",
|
||||
"Enable multiple memories">;
|
||||
|
|
@ -71,7 +73,6 @@ def FeatureReferenceTypes :
|
|||
SubtargetFeature<"reference-types", "HasReferenceTypes", "true",
|
||||
"Enable reference types">;
|
||||
|
||||
def FeatureGC : SubtargetFeature<"gc", "HasGC", "true", "Enable wasm gc">;
|
||||
def FeatureRelaxedSIMD :
|
||||
SubtargetFeature<"relaxed-simd", "SIMDLevel", "RelaxedSIMD",
|
||||
"Enable relaxed-simd instructions">;
|
||||
|
|
@ -139,10 +140,10 @@ def : ProcessorModel<"lime1", NoSchedModel,
|
|||
def : ProcessorModel<"bleeding-edge", NoSchedModel,
|
||||
[FeatureAtomics, FeatureBulkMemory, FeatureBulkMemoryOpt,
|
||||
FeatureCallIndirectOverlong, FeatureExceptionHandling,
|
||||
FeatureExtendedConst, FeatureFP16, FeatureMultiMemory,
|
||||
FeatureMultivalue, FeatureMutableGlobals,
|
||||
FeatureExtendedConst, FeatureFP16, FeatureGC,
|
||||
FeatureMultiMemory, FeatureMultivalue, FeatureMutableGlobals,
|
||||
FeatureNontrappingFPToInt, FeatureRelaxedSIMD,
|
||||
FeatureReferenceTypes, FeatureGC, FeatureSIMD128,
|
||||
FeatureReferenceTypes, FeatureSIMD128,
|
||||
FeatureSignExt, FeatureTailCall]>;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
|||
|
|
@ -50,6 +50,9 @@ def HasFP16 :
|
|||
Predicate<"Subtarget->hasFP16()">,
|
||||
AssemblerPredicate<(all_of FeatureFP16), "fp16">;
|
||||
|
||||
def HasGC : Predicate<"Subtarget->hasGC()">,
|
||||
AssemblerPredicate<(all_of FeatureGC), "gc">;
|
||||
|
||||
def HasMultiMemory :
|
||||
Predicate<"Subtarget->hasMultiMemory()">,
|
||||
AssemblerPredicate<(all_of FeatureMultiMemory), "multimemory">;
|
||||
|
|
@ -76,9 +79,6 @@ def HasReferenceTypes :
|
|||
Predicate<"Subtarget->hasReferenceTypes()">,
|
||||
AssemblerPredicate<(all_of FeatureReferenceTypes), "reference-types">;
|
||||
|
||||
def HasGC : Predicate<"Subtarget->hasGC()">,
|
||||
AssemblerPredicate<(all_of FeatureGC), "gc">;
|
||||
|
||||
def HasRelaxedSIMD :
|
||||
Predicate<"Subtarget->hasRelaxedSIMD()">,
|
||||
AssemblerPredicate<(all_of FeatureRelaxedSIMD), "relaxed-simd">;
|
||||
|
|
|
|||
|
|
@ -46,12 +46,12 @@ class WebAssemblySubtarget final : public WebAssemblyGenSubtargetInfo {
|
|||
bool HasExceptionHandling = false;
|
||||
bool HasExtendedConst = false;
|
||||
bool HasFP16 = false;
|
||||
bool HasGC = false;
|
||||
bool HasMultiMemory = false;
|
||||
bool HasMultivalue = false;
|
||||
bool HasMutableGlobals = false;
|
||||
bool HasNontrappingFPToInt = false;
|
||||
bool HasReferenceTypes = false;
|
||||
bool HasGC = false;
|
||||
bool HasSignExt = false;
|
||||
bool HasTailCall = false;
|
||||
bool HasWideArithmetic = false;
|
||||
|
|
|
|||
|
|
@ -68,9 +68,9 @@ target triple = "wasm32-unknown-unknown"
|
|||
|
||||
; bleeding-edge: +atomics, +bulk-memory, +bulk-memory-opt,
|
||||
; +call-indirect-overlong, +exception-handling,
|
||||
; +extended-const, +fp16, +multimemory, +multivalue,
|
||||
; +extended-const, +fp16, +gc, +multimemory, +multivalue,
|
||||
; +mutable-globals, +nontrapping-fptoint, +relaxed-simd,
|
||||
; +reference-types, +simd128, +sign-ext, +tail-call, +gc
|
||||
; +reference-types, +simd128, +sign-ext, +tail-call
|
||||
; BLEEDING-EDGE-LABEL: .section .custom_section.target_features,"",@
|
||||
; BLEEDING-EDGE-NEXT: .int8 17
|
||||
; BLEEDING-EDGE-NEXT: .int8 43
|
||||
|
|
|
|||
Loading…
Reference in a new issue