Skip to content

Commit 2fa3ef0

Browse files
committed
More fixes.
1 parent 1f77f5e commit 2fa3ef0

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)
@@ -175,6 +175,7 @@ bool WebAssemblyTargetInfo::initFeatureMap(
175175
Features["atomics"] = true;
176176
Features["bulk-memory"] = true;
177177
Features["bulk-memory-opt"] = true;
178+
Features["call-indirect-overlong"] = true;
178179
Features["exception-handling"] = true;
179180
Features["extended-const"] = true;
180181
Features["fp16"] = 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,10 +12,13 @@ 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 4
1818
; GENERIC-NEXT: .int8 43
19+
; GENERIC-NEXT: .int8 22
20+
; GENERIC-NEXT: .ascii "call-indirect-overlong"
21+
; GENERIC-NEXT: .int8 43
1922
; GENERIC-NEXT: .int8 10
2023
; GENERIC-NEXT: .ascii "multivalue"
2124
; GENERIC-NEXT: .int8 43
@@ -53,10 +56,11 @@ target triple = "wasm32-unknown-unknown"
5356
; TRAIL1-NEXT: .int8 8
5457
; TRAIL1-NEXT: .ascii "sign-ext"
5558

56-
; bleeding-edge: +atomics, +bulk-memory, +exception-handling, +extended-const,
57-
; +fp16, +multimemory, +multivalue, +mutable-globals,
58-
; +nontrapping-fptoint, +relaxed-simd, +reference-types,
59-
; +simd128, +sign-ext, +tail-call
59+
; bleeding-edge: +atomics, +bulk-memory, +bulk-memory-opt,
60+
; +call-indirect-overlong, +exception-handling,
61+
; +extended-const, +fp16, +multimemory, +multivalue,
62+
; +mutable-globals, +nontrapping-fptoint, +relaxed-simd,
63+
; +reference-types, +simd128, +sign-ext, +tail-call
6064
; BLEEDING-EDGE-LABEL: .section .custom_section.target_features,"",@
6165
; BLEEDING-EDGE-NEXT: .int8 14
6266
; BLEEDING-EDGE-NEXT: .int8 43
@@ -66,6 +70,12 @@ target triple = "wasm32-unknown-unknown"
6670
; BLEEDING-EDGE-NEXT: .int8 11
6771
; BLEEDING-EDGE-NEXT: .ascii "bulk-memory"
6872
; BLEEDING-EDGE-NEXT: .int8 43
73+
; BLEEDING-EDGE-NEXT: .int8 15
74+
; BLEEDING-EDGE-NEXT: .ascii "bulk-memory-opt"
75+
; BLEEDING-EDGE-NEXT: .int8 43
76+
; BLEEDING-EDGE-NEXT: .int8 22
77+
; BLEEDING-EDGE-NEXT: .ascii "call-indirect-overlong"
78+
; BLEEDING-EDGE-NEXT: .int8 43
6979
; BLEEDING-EDGE-NEXT: .int8 18
7080
; BLEEDING-EDGE-NEXT: .ascii "exception-handling"
7181
; BLEEDING-EDGE-NEXT: .int8 43

0 commit comments

Comments
 (0)