aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
diff options
context:
space:
mode:
authorDan Gohman <dev@sunfishcode.online>2024-12-02 17:08:07 -0800
committerGitHub <noreply@github.com>2024-12-02 17:08:07 -0800
commitc3536b263f253a69fb336fb0617ee33a01a5c5dd (patch)
tree3be2dbe8cdd9338a7a5ee3e7ef60cfea762478fd /llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
parentf71ea4bc1b01fd7e29048db82b3e21fba74e8dab (diff)
downloadllvm-c3536b263f253a69fb336fb0617ee33a01a5c5dd.zip
llvm-c3536b263f253a69fb336fb0617ee33a01a5c5dd.tar.gz
llvm-c3536b263f253a69fb336fb0617ee33a01a5c5dd.tar.bz2
[WebAssembly] Define call-indirect-overlong and bulk-memory-opt features (#117087)
This defines some new target features. These are subsets of existing features that reflect implementation concerns: - "call-indirect-overlong" - implied by "reference-types"; just the overlong encoding for the `call_indirect` immediate, and not the actual reference types. - "bulk-memory-opt" - implied by "bulk-memory": just `memory.copy` and `memory.fill`, and not the other instructions in the bulk-memory proposal. This is split out from https://github.com/llvm/llvm-project/pull/112035. --------- Co-authored-by: Heejin Ahn <aheejin@gmail.com>
Diffstat (limited to 'llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp')
-rw-r--r--llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp28
1 files changed, 21 insertions, 7 deletions
diff --git a/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp b/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
index 1045160..f693ef3 100644
--- a/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
+++ b/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
@@ -276,7 +276,18 @@ public:
: MCTargetAsmParser(Options, STI, MII), Parser(Parser),
Lexer(Parser.getLexer()), Is64(STI.getTargetTriple().isArch64Bit()),
TC(Parser, MII, Is64), SkipTypeCheck(Options.MCNoTypeCheck) {
- setAvailableFeatures(ComputeAvailableFeatures(STI.getFeatureBits()));
+ FeatureBitset FBS = ComputeAvailableFeatures(STI.getFeatureBits());
+
+ // bulk-memory implies bulk-memory-opt
+ if (FBS.test(WebAssembly::FeatureBulkMemory)) {
+ FBS.set(WebAssembly::FeatureBulkMemoryOpt);
+ }
+ // reference-types implies call-indirect-overlong
+ if (FBS.test(WebAssembly::FeatureReferenceTypes)) {
+ FBS.set(WebAssembly::FeatureCallIndirectOverlong);
+ }
+
+ setAvailableFeatures(FBS);
// Don't type check if this is inline asm, since that is a naked sequence of
// instructions without a function/locals decl.
auto &SM = Parser.getSourceManager();
@@ -291,7 +302,8 @@ public:
DefaultFunctionTable = getOrCreateFunctionTableSymbol(
getContext(), "__indirect_function_table", Is64);
- if (!STI->checkFeatures("+reference-types"))
+ if (!STI->checkFeatures("+call-indirect-overlong") &&
+ !STI->checkFeatures("+reference-types"))
DefaultFunctionTable->setOmitFromLinkingSection();
}
@@ -531,11 +543,13 @@ public:
}
bool parseFunctionTableOperand(std::unique_ptr<WebAssemblyOperand> *Op) {
- if (STI->checkFeatures("+reference-types")) {
- // If the reference-types feature is enabled, there is an explicit table
- // operand. To allow the same assembly to be compiled with or without
- // reference types, we allow the operand to be omitted, in which case we
- // default to __indirect_function_table.
+ if (STI->checkFeatures("+call-indirect-overlong") ||
+ STI->checkFeatures("+reference-types")) {
+ // If the call-indirect-overlong feature is enabled, or implied by the
+ // reference-types feature, there is an explicit table operand. To allow
+ // the same assembly to be compiled with or without
+ // call-indirect-overlong, we allow the operand to be omitted, in which
+ // case we default to __indirect_function_table.
auto &Tok = Lexer.getTok();
if (Tok.is(AsmToken::Identifier)) {
auto *Sym =