[llvm] d657c68 - [WebAssembly] Allow .data shorthand for .section .data, "", @
Wouter van Oortmerssen via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 22 10:27:14 PST 2022
Author: Wouter van Oortmerssen
Date: 2022-02-22T10:26:36-08:00
New Revision: d657c6893f9b987f23ddbb1eddf62cc3add77e28
URL: https://github.com/llvm/llvm-project/commit/d657c6893f9b987f23ddbb1eddf62cc3add77e28
DIFF: https://github.com/llvm/llvm-project/commit/d657c6893f9b987f23ddbb1eddf62cc3add77e28.diff
LOG: [WebAssembly] Allow .data shorthand for .section .data,"",@
Added:
Modified:
llvm/lib/MC/MCParser/WasmAsmParser.cpp
llvm/test/MC/WebAssembly/basic-assembly.s
Removed:
################################################################################
diff --git a/llvm/lib/MC/MCParser/WasmAsmParser.cpp b/llvm/lib/MC/MCParser/WasmAsmParser.cpp
index 7fe2711efcd91..ea93af7c99cbc 100644
--- a/llvm/lib/MC/MCParser/WasmAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/WasmAsmParser.cpp
@@ -21,6 +21,7 @@
#include "llvm/MC/MCParser/MCAsmLexer.h"
#include "llvm/MC/MCParser/MCAsmParser.h"
#include "llvm/MC/MCParser/MCAsmParserExtension.h"
+#include "llvm/MC/MCObjectFileInfo.h"
#include "llvm/MC/MCSectionWasm.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSymbolWasm.h"
@@ -52,6 +53,7 @@ class WasmAsmParser : public MCAsmParserExtension {
this->MCAsmParserExtension::Initialize(*Parser);
addDirectiveHandler<&WasmAsmParser::parseSectionDirectiveText>(".text");
+ addDirectiveHandler<&WasmAsmParser::parseSectionDirectiveData>(".data");
addDirectiveHandler<&WasmAsmParser::parseSectionDirective>(".section");
addDirectiveHandler<&WasmAsmParser::parseDirectiveSize>(".size");
addDirectiveHandler<&WasmAsmParser::parseDirectiveType>(".type");
@@ -89,6 +91,12 @@ class WasmAsmParser : public MCAsmParserExtension {
return false;
}
+ bool parseSectionDirectiveData(StringRef, SMLoc) {
+ auto *S = getContext().getObjectFileInfo()->getDataSection();
+ getStreamer().SwitchSection(S);
+ return false;
+ }
+
uint32_t parseSectionFlags(StringRef FlagStr, bool &Passive, bool &Group) {
uint32_t flags = 0;
for (char C : FlagStr) {
diff --git a/llvm/test/MC/WebAssembly/basic-assembly.s b/llvm/test/MC/WebAssembly/basic-assembly.s
index b86172ba9e24c..769cd7edfa8a3 100644
--- a/llvm/test/MC/WebAssembly/basic-assembly.s
+++ b/llvm/test/MC/WebAssembly/basic-assembly.s
@@ -137,6 +137,9 @@ test0:
.int32 2000000000
.size .L.str, 28
+ .data
+ .int8 73
+
.section .init_array.42,"",@
.p2align 2
.int32 test0
@@ -272,6 +275,10 @@ empty_fref_table:
# CHECK-NEXT: .int32 2000000000
# CHECK-NEXT: .size .L.str, 28
+# CHECK: .data
+# CHECK-EMPTY:
+# CHECK-NEXT: .int8 73
+
# CHECK: .section .init_array.42,"",@
# CHECK-NEXT: .p2align 2
# CHECK-NEXT: .int32 test0
More information about the llvm-commits
mailing list