From 2deb068b06a478f446fdb980628cb2198f1fccfa Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Thu, 9 May 2019 21:57:44 +0000 Subject: [PATCH] Add ".dword" directive Summary: The ".dword" directive is a synonym for ".xword" and is used used by klibc, a minimalistic libc subset for initramfs. Reviewers: t.p.northover, nickdesaulniers Reviewed By: nickdesaulniers Subscribers: nickdesaulniers, javed.absar, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D61719 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360381 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp | 8 +++-- test/MC/AArch64/size-directive.s | 39 +++++++++++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 test/MC/AArch64/size-directive.s diff --git a/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp index 0a1e925fb84..a6cf9f064cb 100644 --- a/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ b/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -241,11 +241,13 @@ public: if (S.getTargetStreamer() == nullptr) new AArch64TargetStreamer(S); - // Alias .hword/.word/xword to the target-independent .2byte/.4byte/.8byte - // directives as they have the same form and semantics: - /// ::= (.hword | .word | .xword ) [ expression (, expression)* ] + // Alias .hword/.word/.[dx]word to the target-independent + // .2byte/.4byte/.8byte directives as they have the same form and + // semantics: + /// ::= (.hword | .word | .dword | .xword ) [ expression (, expression)* ] Parser.addAliasForDirective(".hword", ".2byte"); Parser.addAliasForDirective(".word", ".4byte"); + Parser.addAliasForDirective(".dword", ".8byte"); Parser.addAliasForDirective(".xword", ".8byte"); // Initialize the set of available features. diff --git a/test/MC/AArch64/size-directive.s b/test/MC/AArch64/size-directive.s new file mode 100644 index 00000000000..5c9ac26f17e --- /dev/null +++ b/test/MC/AArch64/size-directive.s @@ -0,0 +1,39 @@ +// RUN: llvm-mc %s -triple=aarch64-none-linux-gnu -filetype=asm -o - \ +// RUN: | FileCheck %s --check-prefix=CHECK-ASM +// RUN: llvm-mc %s -triple=aarch64-none-linux-gnu -filetype=obj -o %t +// RUN: llvm-readobj -S --sd %t | FileCheck %s --check-prefix=CHECK-OBJ +// RUN: llvm-objdump -t %t | FileCheck %s --check-prefix=CHECK-SYMS + + .section .size.aarch64_size + + .p2align 2 + .global aarch64_size + .type aarch64_size,%function +aarch64_size: + .hword half_word + .word full_word + .dword double_word + .xword also_double_word + +// CHECK-ASM: .p2align 2 +// CHECK-ASM: .globl aarch64_size +// CHECK-ASM: .type aarch64_size,@function +// CHECK-ASM: aarch64_size: +// CHECK-ASM: .hword half_word +// CHECK-ASM: .word full_word +// CHECK-ASM: .xword double_word +// CHECK-ASM: .xword also_double_word + +// CHECK-OBJ: Section { +// CHECK-OBJ: Name: .size.aarch64_size +// CHECK-OBJ: SectionData ( +// CHECK-OBJ-NEXT: 0000: 00000000 00000000 00000000 00000000 |................| +// CHECK-OBJ-NEXT: 0010: 00000000 0000 |......| +// CHECK-OBJ-NEXT: ) + +// CHECK-SYMS: 0000000000000000 .size.aarch64_size 00000000 $d.0 +// CHECK-SYMS: 0000000000000000 g F .size.aarch64_size 00000000 aarch64_size +// CHECK-SYMS: 0000000000000000 *UND* 00000000 also_double_word +// CHECK-SYMS: 0000000000000000 *UND* 00000000 double_word +// CHECK-SYMS: 0000000000000000 *UND* 00000000 full_word +// CHECK-SYMS: 0000000000000000 *UND* 00000000 half_word -- 2.11.0