Skip to content

Commit 3160644

Browse files
committed
More fixes.
1 parent 8d49258 commit 3160644

File tree

5 files changed

+33
-11
lines changed

5 files changed

+33
-11
lines changed

clang/lib/Basic/Targets/WebAssembly.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) const {
4848
.Case("atomics", HasAtomics)
4949
.Case("bulk-memory", HasBulkMemory)
5050
.Case("bulk-memory-opt", HasBulkMemoryOpt)
51+
.Case("call-indirect-overlong", HasCallIndirectOverlong)
5152
.Case("exception-handling", HasExceptionHandling)
5253
.Case("extended-const", HasExtendedConst)
5354
.Case("fp16", HasFP16)
@@ -56,7 +57,6 @@ bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) const {
5657
.Case("mutable-globals", HasMutableGlobals)
5758
.Case("nontrapping-fptoint", HasNontrappingFPToInt)
5859
.Case("reference-types", HasReferenceTypes)
59-
.Case("call-indirect-overlong", HasCallIndirectOverlong)
6060
.Case("relaxed-simd", SIMDLevel >= RelaxedSIMD)
6161
.Case("sign-ext", HasSignExt)
6262
.Case("simd128", SIMDLevel >= SIMD128)
@@ -160,6 +160,7 @@ bool WebAssemblyTargetInfo::initFeatureMap(
160160
auto addGenericFeatures = [&]() {
161161
Features["bulk-memory"] = true;
162162
Features["bulk-memory-opt"] = true;
163+
Features["call-indirect-overlong"] = true;
163164
Features["multivalue"] = true;
164165
Features["mutable-globals"] = true;
165166
Features["nontrapping-fptoint"] = true;

llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,18 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
277277
: MCTargetAsmParser(Options, STI, MII), Parser(Parser),
278278
Lexer(Parser.getLexer()), Is64(STI.getTargetTriple().isArch64Bit()),
279279
TC(Parser, MII, Is64), SkipTypeCheck(Options.MCNoTypeCheck) {
280-
setAvailableFeatures(ComputeAvailableFeatures(STI.getFeatureBits()));
280+
FeatureBitset FBS = ComputeAvailableFeatures(STI.getFeatureBits());
281+
282+
// bulk-memory implies bulk-memory-opt
283+
if (FBS.test(WebAssembly::FeatureBulkMemory)) {
284+
FBS.set(WebAssembly::FeatureBulkMemoryOpt);
285+
}
286+
// reference-types implies call-indirect-overlong
287+
if (FBS.test(WebAssembly::FeatureReferenceTypes)) {
288+
FBS.set(WebAssembly::FeatureCallIndirectOverlong);
289+
}
290+
291+
setAvailableFeatures(FBS);
281292
// Don't type check if this is inline asm, since that is a naked sequence of
282293
// instructions without a function/locals decl.
283294
auto &SM = Parser.getSourceManager();

llvm/test/CodeGen/WebAssembly/call-indirect.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
; RUN: llc < %s -asm-verbose=false -mattr=-reference-types -O2 | FileCheck --check-prefixes=CHECK,NOREF %s
2-
; RUN: llc < %s -asm-verbose=false -mattr=+reference-types -O2 | FileCheck --check-prefixes=CHECK,REF %s
1+
; RUN: llc < %s -asm-verbose=false -mattr=-reference-types,call-indirect-overlong -O2 | FileCheck --check-prefixes=CHECK,NOREF %s
2+
; RUN: llc < %s -asm-verbose=false -mattr=+call-indirect-overlong -O2 | FileCheck --check-prefixes=CHECK,REF %s
33
; RUN: llc < %s -asm-verbose=false -O2 --filetype=obj | obj2yaml | FileCheck --check-prefix=OBJ %s
44

55
; Test that compilation units with call_indirect but without any

llvm/test/CodeGen/WebAssembly/function-pointer64.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
; RUN: llc < %s -asm-verbose=false -mattr=-reference-types -O2 | FileCheck %s
1+
; RUN: llc < %s -asm-verbose=false -mattr=-reference-types,-call-indirect-overlong -O2 | FileCheck %s
22
; RUN: llc < %s -asm-verbose=false -mattr=+reference-types -O2 | FileCheck --check-prefix=REF %s
3-
; RUN: llc < %s -asm-verbose=false -mattr=-reference-types -O2 --filetype=obj | obj2yaml | FileCheck --check-prefix=YAML %s
3+
; RUN: llc < %s -asm-verbose=false -mattr=-reference-types,-call-indirect-overlong -O2 --filetype=obj | obj2yaml | FileCheck --check-prefix=YAML %s
44

55
; This tests pointer features that may codegen differently in wasm64.
66

llvm/test/CodeGen/WebAssembly/target-features-cpus.ll

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@ target triple = "wasm32-unknown-unknown"
1212
; mvp: should not contain the target features section
1313
; MVP-NOT: .custom_section.target_features,"",@
1414

15-
; generic: +multivalue, +mutable-globals, +reference-types, +sign-ext
15+
; generic: +call-indirect-overlong, +multivalue, +mutable-globals, +reference-types, +sign-ext
1616
; GENERIC-LABEL: .custom_section.target_features,"",@
1717
; GENERIC-NEXT: .int8 6
1818
; GENERIC-NEXT: .int8 43
1919
; GENERIC-NEXT: .int8 11
2020
; GENERIC-NEXT: .ascii "bulk-memory"
2121
; GENERIC-NEXT: .int8 43
22+
; GENERIC-NEXT: .int8 22
23+
; GENERIC-NEXT: .ascii "call-indirect-overlong"
24+
; GENERIC-NEXT: .int8 43
2225
; GENERIC-NEXT: .int8 10
2326
; GENERIC-NEXT: .ascii "multivalue"
2427
; GENERIC-NEXT: .int8 43
@@ -59,10 +62,11 @@ target triple = "wasm32-unknown-unknown"
5962
; TRAIL1-NEXT: .int8 8
6063
; TRAIL1-NEXT: .ascii "sign-ext"
6164

62-
; bleeding-edge: +atomics, +bulk-memory, +exception-handling, +extended-const,
63-
; +fp16, +multimemory, +multivalue, +mutable-globals,
64-
; +nontrapping-fptoint, +relaxed-simd, +reference-types,
65-
; +simd128, +sign-ext, +tail-call
65+
; bleeding-edge: +atomics, +bulk-memory, +bulk-memory-opt,
66+
; +call-indirect-overlong, +exception-handling,
67+
; +extended-const, +fp16, +multimemory, +multivalue,
68+
; +mutable-globals, +nontrapping-fptoint, +relaxed-simd,
69+
; +reference-types, +simd128, +sign-ext, +tail-call
6670
; BLEEDING-EDGE-LABEL: .section .custom_section.target_features,"",@
6771
; BLEEDING-EDGE-NEXT: .int8 14
6872
; BLEEDING-EDGE-NEXT: .int8 43
@@ -72,6 +76,12 @@ target triple = "wasm32-unknown-unknown"
7276
; BLEEDING-EDGE-NEXT: .int8 11
7377
; BLEEDING-EDGE-NEXT: .ascii "bulk-memory"
7478
; BLEEDING-EDGE-NEXT: .int8 43
79+
; BLEEDING-EDGE-NEXT: .int8 15
80+
; BLEEDING-EDGE-NEXT: .ascii "bulk-memory-opt"
81+
; BLEEDING-EDGE-NEXT: .int8 43
82+
; BLEEDING-EDGE-NEXT: .int8 22
83+
; BLEEDING-EDGE-NEXT: .ascii "call-indirect-overlong"
84+
; BLEEDING-EDGE-NEXT: .int8 43
7585
; BLEEDING-EDGE-NEXT: .int8 18
7686
; BLEEDING-EDGE-NEXT: .ascii "exception-handling"
7787
; BLEEDING-EDGE-NEXT: .int8 43

0 commit comments

Comments
 (0)