[llvm] r364689 - [WebAssembly] Assembler: support .int16/32/64 directives.
Wouter van Oortmerssen via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 28 15:20:33 PDT 2019
Author: aardappel
Date: Fri Jun 28 15:20:33 2019
New Revision: 364689
URL: http://llvm.org/viewvc/llvm-project?rev=364689&view=rev
Log:
[WebAssembly] Assembler: support .int16/32/64 directives.
Reviewers: sbc100
Subscribers: dschuff, jgravelle-google, aheejin, sunfish, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D63959
Modified:
llvm/trunk/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
llvm/trunk/test/MC/WebAssembly/basic-assembly.s
Modified: llvm/trunk/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp?rev=364689&r1=364688&r2=364689&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp Fri Jun 28 15:20:33 2019
@@ -665,13 +665,18 @@ public:
return expect(AsmToken::EndOfStatement, "EOL");
}
- if (DirectiveID.getString() == ".int8") {
+ if (DirectiveID.getString() == ".int8" ||
+ DirectiveID.getString() == ".int16" ||
+ DirectiveID.getString() == ".int32" ||
+ DirectiveID.getString() == ".int64") {
if (CheckDataSection()) return true;
- int64_t V;
- if (Parser.parseAbsoluteExpression(V))
- return error("Cannot parse int8 constant: ", Lexer.getTok());
- // TODO: error if value doesn't fit?
- Out.EmitIntValue(static_cast<uint64_t>(V), 1);
+ const MCExpr *Val;
+ SMLoc End;
+ if (Parser.parseExpression(Val, End))
+ return error("Cannot parse .int expression: ", Lexer.getTok());
+ size_t NumBits = 0;
+ DirectiveID.getString().drop_front(4).getAsInteger(10, NumBits);
+ Out.EmitValue(Val, NumBits / 8, End);
return expect(AsmToken::EndOfStatement, "EOL");
}
Modified: llvm/trunk/test/MC/WebAssembly/basic-assembly.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/basic-assembly.s?rev=364689&r1=364688&r2=364689&view=diff
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/basic-assembly.s (original)
+++ llvm/trunk/test/MC/WebAssembly/basic-assembly.s Fri Jun 28 15:20:33 2019
@@ -95,7 +95,10 @@ test0:
.L.str:
.int8 'H'
.asciz "ello, World!"
- .size .L.str, 14
+ .int16 1234
+ .int64 5000000000
+ .int32 2000000000
+ .size .L.str, 28
.ident "clang version 9.0.0 (trunk 364502) (llvm/trunk 364571)"
.globaltype __stack_pointer, i32
@@ -185,5 +188,8 @@ test0:
# CHECK-NEXT: .L.str:
# CHECK-NEXT: .int8 72
# CHECK-NEXT: .asciz "ello, World!"
+# CHECK-NEXT: .int16 1234
+# CHECK-NEXT: .int64 5000000000
+# CHECK-NEXT: .int32 2000000000
# CHECK: .globaltype __stack_pointer, i32
More information about the llvm-commits
mailing list