aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2010-09-16 15:03:59 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2010-09-16 15:03:59 +0000
commit2ea2ac798b07855bd950e848d73b8bea6bcdea4b (patch)
tree274922c50afdd4476e242959fb3904a7dd70a32a
parent1cd1b0b283079b5a8c54759983e9e70845971b2c (diff)
Add support for the .zero directive.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114077 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/MC/MCParser/AsmParser.cpp22
-rw-r--r--test/MC/ELF/zero.s15
2 files changed, 37 insertions, 0 deletions
diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp
index b3ffed846d..d101ad2c4b 100644
--- a/lib/MC/MCParser/AsmParser.cpp
+++ b/lib/MC/MCParser/AsmParser.cpp
@@ -180,6 +180,7 @@ private:
bool ParseDirectiveValue(unsigned Size); // ".byte", ".long", ...
bool ParseDirectiveFill(); // ".fill"
bool ParseDirectiveSpace(); // ".space"
+ bool ParseDirectiveZero(); // ".zero"
bool ParseDirectiveSet(); // ".set"
bool ParseDirectiveOrg(); // ".org"
// ".align{,32}", ".p2align{,w,l}"
@@ -871,6 +872,8 @@ bool AsmParser::ParseStatement() {
return ParseDirectiveFill();
if (IDVal == ".space")
return ParseDirectiveSpace();
+ if (IDVal == ".zero")
+ return ParseDirectiveZero();
// Symbol attribute directives
@@ -1353,6 +1356,25 @@ bool AsmParser::ParseDirectiveSpace() {
return false;
}
+/// ParseDirectiveZero
+/// ::= .zero expression
+bool AsmParser::ParseDirectiveZero() {
+ CheckForValidSection();
+
+ int64_t NumBytes;
+ if (ParseAbsoluteExpression(NumBytes))
+ return true;
+
+ if (getLexer().isNot(AsmToken::EndOfStatement))
+ return TokError("unexpected token in '.zero' directive");
+
+ Lex();
+
+ getStreamer().EmitFill(NumBytes, 0, DEFAULT_ADDRSPACE);
+
+ return false;
+}
+
/// ParseDirectiveFill
/// ::= .fill expression , expression , expression
bool AsmParser::ParseDirectiveFill() {
diff --git a/test/MC/ELF/zero.s b/test/MC/ELF/zero.s
new file mode 100644
index 0000000000..2ad21e6081
--- /dev/null
+++ b/test/MC/ELF/zero.s
@@ -0,0 +1,15 @@
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | elf-dump --dump-section-data | FileCheck %s
+
+.zero 4
+
+// CHECK: ('sh_name', 1) # '.text'
+// CHECK: ('sh_type', 1)
+// CHECK: ('sh_flags', 6)
+// CHECK: ('sh_addr', 0)
+// CHECK: ('sh_offset', 64)
+// CHECK: ('sh_size', 4)
+// CHECK: ('sh_link', 0)
+// CHECK: ('sh_info', 0)
+// CHECK: ('sh_addralign', 4)
+// CHECK: ('sh_entsize', 0)
+// CHECK: ('_section_data', '00000000')