[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

llvm-svn: 364689
This commit is contained in:
Wouter van Oortmerssen 2019-06-28 22:20:33 +00:00
parent 35bcba4fae
commit 319c87d94f
2 changed files with 18 additions and 7 deletions

View File

@ -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");
}

View File

@ -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