Make the size and expr arguments of .fill directive optional.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191318 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Roman Divacky 2013-09-24 17:44:41 +00:00
parent d44f9f2ff8
commit 9c60710c80
2 changed files with 37 additions and 16 deletions

View File

@ -2353,7 +2353,7 @@ bool AsmParser::parseDirectiveZero() {
} }
/// parseDirectiveFill /// parseDirectiveFill
/// ::= .fill expression , expression , expression /// ::= .fill expression [ , expression [ , expression ] ]
bool AsmParser::parseDirectiveFill() { bool AsmParser::parseDirectiveFill() {
checkForValidSection(); checkForValidSection();
@ -2361,26 +2361,31 @@ bool AsmParser::parseDirectiveFill() {
if (parseAbsoluteExpression(NumValues)) if (parseAbsoluteExpression(NumValues))
return true; return true;
if (getLexer().isNot(AsmToken::Comma)) int64_t FillSize = 1;
return TokError("unexpected token in '.fill' directive"); int64_t FillExpr = 0;
Lex();
int64_t FillSize; if (getLexer().isNot(AsmToken::EndOfStatement)) {
if (parseAbsoluteExpression(FillSize)) if (getLexer().isNot(AsmToken::Comma))
return true; return TokError("unexpected token in '.fill' directive");
Lex();
if (getLexer().isNot(AsmToken::Comma)) if (parseAbsoluteExpression(FillSize))
return TokError("unexpected token in '.fill' directive"); return true;
Lex();
int64_t FillExpr; if (getLexer().isNot(AsmToken::EndOfStatement)) {
if (parseAbsoluteExpression(FillExpr)) if (getLexer().isNot(AsmToken::Comma))
return true; return TokError("unexpected token in '.fill' directive");
Lex();
if (getLexer().isNot(AsmToken::EndOfStatement)) if (parseAbsoluteExpression(FillExpr))
return TokError("unexpected token in '.fill' directive"); return true;
Lex(); if (getLexer().isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in '.fill' directive");
Lex();
}
}
if (FillSize != 1 && FillSize != 2 && FillSize != 4 && FillSize != 8) if (FillSize != 1 && FillSize != 2 && FillSize != 4 && FillSize != 8)
return TokError("invalid '.fill' size, expected 1, 2, 4, or 8"); return TokError("invalid '.fill' size, expected 1, 2, 4, or 8");

View File

@ -15,3 +15,19 @@ TEST1:
# CHECK: .quad 4 # CHECK: .quad 4
TEST2: TEST2:
.fill 1, 8, 4 .fill 1, 8, 4
# CHECK: TEST3
# CHECK: .byte 0
# CHECK: .byte 0
# CHECK: .byte 0
# CHECK: .byte 0
TEST3:
.fill 4
# CHECK: TEST4
# CHECK: .short 0
# CHECK: .short 0
# CHECK: .short 0
# CHECK: .short 0
TEST4:
.fill 4, 2