[llvm] r198031 - ARM IAS: support .even directive
Saleem Abdulrasool
compnerd at compnerd.org
Wed Dec 25 17:52:28 PST 2013
Author: compnerd
Date: Wed Dec 25 19:52:28 2013
New Revision: 198031
URL: http://llvm.org/viewvc/llvm-project?rev=198031&view=rev
Log:
ARM IAS: support .even directive
The .even directive aligns content to an evan-numbered address. This is an ARM
specific directive applicable to any section.
Added:
llvm/trunk/test/MC/ARM/directive-even.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=198031&r1=198030&r2=198031&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Wed Dec 25 19:52:28 2013
@@ -31,6 +31,7 @@
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstrDesc.h"
#include "llvm/MC/MCInstrInfo.h"
+#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCParser/MCAsmLexer.h"
#include "llvm/MC/MCParser/MCAsmParser.h"
#include "llvm/MC/MCParser/MCParsedAsmOperand.h"
@@ -227,6 +228,7 @@ class ARMAsmParser : public MCTargetAsmP
bool parseDirectiveRegSave(SMLoc L, bool IsVector);
bool parseDirectiveInst(SMLoc L, char Suffix = '\0');
bool parseDirectiveLtorg(SMLoc L);
+ bool parseDirectiveEven(SMLoc L);
StringRef splitMnemonic(StringRef Mnemonic, unsigned &PredicationCode,
bool &CarrySetting, unsigned &ProcessorIMod,
@@ -7912,6 +7914,8 @@ bool ARMAsmParser::ParseDirective(AsmTok
return parseDirectiveInst(DirectiveID.getLoc(), 'w');
else if (IDVal == ".ltorg" || IDVal == ".pool")
return parseDirectiveLtorg(DirectiveID.getLoc());
+ else if (IDVal == ".even")
+ return parseDirectiveEven(DirectiveID.getLoc());
return true;
}
@@ -8476,6 +8480,27 @@ bool ARMAsmParser::parseDirectiveLtorg(S
return false;
}
+bool ARMAsmParser::parseDirectiveEven(SMLoc L) {
+ const MCSection *Section = getStreamer().getCurrentSection().first;
+
+ if (getLexer().isNot(AsmToken::EndOfStatement)) {
+ TokError("unexpected token in directive");
+ return false;
+ }
+
+ if (!Section) {
+ getStreamer().InitToTextSection();
+ Section = getStreamer().getCurrentSection().first;
+ }
+
+ if (Section->UseCodeAlign())
+ getStreamer().EmitCodeAlignment(2, 0);
+ else
+ getStreamer().EmitValueToAlignment(2, 0, 1, 0);
+
+ return false;
+}
+
/// Force static initialization.
extern "C" void LLVMInitializeARMAsmParser() {
RegisterMCAsmParser<ARMAsmParser> X(TheARMTarget);
Added: llvm/trunk/test/MC/ARM/directive-even.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/directive-even.s?rev=198031&view=auto
==============================================================================
--- llvm/trunk/test/MC/ARM/directive-even.s (added)
+++ llvm/trunk/test/MC/ARM/directive-even.s Wed Dec 25 19:52:28 2013
@@ -0,0 +1,70 @@
+@ RUN: llvm-mc -triple armv7-eabi -filetype obj -o - %s | llvm-readobj -s -sd \
+@ RUN: | FileCheck %s
+
+ .syntax unified
+
+ .text
+
+ .even
+
+ .global aligned_function
+ .type aligned_function,%function
+aligned_function:
+ bkpt
+
+ .space 5
+
+ .even
+
+ .global unaligned_function
+ .type unaligned_function,%function
+unaligned_function:
+ bkpt
+
+@ CHECK: Section {
+@ CHECK: Name: .text
+@ CHECK: SectionData (
+@ CHECK: 0000: 700020E1 00000000 00007000 20E1
+@ CHECK: )
+@ CHECK: }
+
+ .data
+
+ .space 15
+
+ .even
+
+ .global classifiable
+ .type classifiable,%object
+classifiable:
+ .byte 0xf1
+ .byte 0x51
+ .byte 0xa5
+ .byte 0xc1
+ .byte 0x00
+ .byte 0x00
+ .byte 0x1e
+ .byte 0xab
+
+ .even
+
+ .global declassified
+ .type declassified,%object
+declassified:
+ .byte 0x51
+ .byte 0xa5
+ .byte 0xc1
+ .byte 0xde
+ .byte 0x00
+ .byte 0x00
+ .byte 0xed
+ .byte 0xf1
+
+@ CHECK: Section {
+@ CHECK: Name: .data
+@ CHECK: SectionData (
+@ CHECK: 0000: 00000000 00000000 00000000 00000000
+@ CHECK: 0010: F151A5C1 00001EAB 51A5C1DE 0000EDF1
+@ CHECK: )
+@ CHECK: }
+
More information about the llvm-commits
mailing list