[llvm] r201988 - ARM IAS: support .align without parameters
Saleem Abdulrasool
compnerd at compnerd.org
Sun Feb 23 09:45:32 PST 2014
Author: compnerd
Date: Sun Feb 23 11:45:32 2014
New Revision: 201988
URL: http://llvm.org/viewvc/llvm-project?rev=201988&view=rev
Log:
ARM IAS: support .align without parameters
.align is handled specially on certain targets. .align without any parameters
on ARM indicates a default alignment (4). Handle the special case in the target
parser, but fall back to the generic parser for the normal version.
Added:
llvm/trunk/test/MC/ARM/directive-align.s
Modified:
llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=201988&r1=201987&r2=201988&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Sun Feb 23 11:45:32 2014
@@ -228,6 +228,7 @@ class ARMAsmParser : public MCTargetAsmP
bool parseDirectiveMovSP(SMLoc L);
bool parseDirectiveObjectArch(SMLoc L);
bool parseDirectiveArchExtension(SMLoc L);
+ bool parseDirectiveAlign(SMLoc L);
StringRef splitMnemonic(StringRef Mnemonic, unsigned &PredicationCode,
bool &CarrySetting, unsigned &ProcessorIMod,
@@ -8022,6 +8023,8 @@ bool ARMAsmParser::ParseDirective(AsmTok
return parseDirectiveObjectArch(DirectiveID.getLoc());
else if (IDVal == ".arch_extension")
return parseDirectiveArchExtension(DirectiveID.getLoc());
+ else if (IDVal == ".align")
+ return parseDirectiveAlign(DirectiveID.getLoc());
return true;
}
@@ -9060,6 +9063,23 @@ bool ARMAsmParser::parseDirectiveObjectA
return false;
}
+
+/// parseDirectiveAlign
+/// ::= .align
+bool ARMAsmParser::parseDirectiveAlign(SMLoc L) {
+ // NOTE: if this is not the end of the statement, fall back to the target
+ // agnostic handling for this directive which will correctly handle this.
+ if (getLexer().isNot(AsmToken::EndOfStatement))
+ return true;
+
+ // '.align' is target specifically handled to mean 2**2 byte alignment.
+ if (getStreamer().getCurrentSection().first->UseCodeAlign())
+ getStreamer().EmitCodeAlignment(4, 0);
+ else
+ getStreamer().EmitValueToAlignment(4, 0, 1, 0);
+
+ return false;
+}
/// Force static initialization.
extern "C" void LLVMInitializeARMAsmParser() {
Added: llvm/trunk/test/MC/ARM/directive-align.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/directive-align.s?rev=201988&view=auto
==============================================================================
--- llvm/trunk/test/MC/ARM/directive-align.s (added)
+++ llvm/trunk/test/MC/ARM/directive-align.s Sun Feb 23 11:45:32 2014
@@ -0,0 +1,28 @@
+@ RUN: llvm-mc -triple armv7-eabi %s | FileCheck %s
+
+ .data
+
+unaligned:
+ .byte 1
+ .align
+
+@ CHECK-LABEL: unaligned
+@ CHECK-NEXT: .byte 1
+@ CHECK-NEXT: .align 2
+
+aligned:
+ .long 0x1d10c1e5
+ .align
+
+@ CHECK-LABEL: aligned
+@ CHECK-NEXT: .long 487637477
+@ CHECK-NEXT: .align 2
+
+trailer:
+ .long 0xd1ab011c
+ .align 2
+
+@ CHECK-LABEL: trailer
+@ CHECK-NEXT: .long 3517645084
+@ CHECK-NEXT: .align 2
+
More information about the llvm-commits
mailing list