llvm.org GIT mirror llvm / be7b514
[X86][inline asm] support even directive The .even directive aligns content to an evan-numbered address. In at&t syntax .even In Microsoft syntax even (without the dot). Differential Revision: http://reviews.llvm.org/D15413 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255462 91177308-0d34-0410-b5e6-96231b3b80d8 Michael Zuckerman 4 years ago
4 changed file(s) with 76 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
2929 enum AsmRewriteKind {
3030 AOK_Delete = 0, // Rewrite should be ignored.
3131 AOK_Align, // Rewrite align as .align.
32 AOK_EVEN, // Rewrite even as .even.
3233 AOK_DotOperator, // Rewrite a dot operator expression as an immediate.
3334 // E.g., [eax].foo.bar -> [eax].8
3435 AOK_Emit, // Rewrite _emit as .byte.
4445 const char AsmRewritePrecedence [] = {
4546 0, // AOK_Delete
4647 2, // AOK_Align
48 2, // AOK_EVEN
4749 2, // AOK_DotOperator
4850 2, // AOK_Emit
4951 4, // AOK_Imm
17131713 if (ParsingInlineAsm && (IDVal == "align" || IDVal == "ALIGN"))
17141714 return parseDirectiveMSAlign(IDLoc, Info);
17151715
1716 if (ParsingInlineAsm && (IDVal == "even"))
1717 Info.AsmRewrites->emplace_back(AOK_EVEN, IDLoc, 4);
17161718 checkForValidSection();
17171719
17181720 // Canonicalize the opcode to lower case.
48624864 AdditionalSkip = (Val < 4) ? 2 : Val < 7 ? 3 : 4;
48634865 break;
48644866 }
4867 case AOK_EVEN:
4868 OS << ".even";
4869 break;
48654870 case AOK_DotOperator:
48664871 // Insert the dot if the user omitted it.
48674872 OS.flush();
2525 #include "llvm/MC/MCParser/MCAsmParser.h"
2626 #include "llvm/MC/MCParser/MCParsedAsmOperand.h"
2727 #include "llvm/MC/MCRegisterInfo.h"
28 #include "llvm/MC/MCSection.h"
2829 #include "llvm/MC/MCStreamer.h"
2930 #include "llvm/MC/MCSubtargetInfo.h"
3031 #include "llvm/MC/MCSymbol.h"
713714 SMLoc End, unsigned Size, StringRef Identifier,
714715 InlineAsmIdentifierInfo &Info);
715716
717 bool parseDirectiveEven(SMLoc L);
716718 bool ParseDirectiveWord(unsigned Size, SMLoc L);
717719 bool ParseDirectiveCode(StringRef IDVal, SMLoc L);
718720
28432845 "a '%' prefix in .intel_syntax");
28442846 }
28452847 return false;
2846 }
2848 } else if (IDVal == ".even")
2849 return parseDirectiveEven(DirectiveID.getLoc());
28472850 return true;
28482851 }
28492852
2853 /// parseDirectiveEven
2854 /// ::= .even
2855 bool X86AsmParser::parseDirectiveEven(SMLoc L) {
2856 const MCSection *Section = getStreamer().getCurrentSection().first;
2857 if (getLexer().isNot(AsmToken::EndOfStatement)) {
2858 TokError("unexpected token in directive");
2859 return false;
2860 }
2861 if (!Section) {
2862 getStreamer().InitSections(false);
2863 Section = getStreamer().getCurrentSection().first;
2864 }
2865 if (Section->UseCodeAlign())
2866 getStreamer().EmitCodeAlignment(2, 0);
2867 else
2868 getStreamer().EmitValueToAlignment(2, 0, 1, 0);
2869 return false;
2870 }
28502871 /// ParseDirectiveWord
28512872 /// ::= .word [ expression (, expression)* ]
28522873 bool X86AsmParser::ParseDirectiveWord(unsigned Size, SMLoc L) {
0 # RUN: llvm-mc -filetype obj -o - %s | llvm-readobj -s -sd \
1 # RUN: | FileCheck %s
2
3 .text
4 even_check:
5 .byte 0x00
6 .byte 0x01
7 .byte 0x02
8 .byte 0x03
9 .byte 0x04
10 .byte 0x05
11 .byte 0x06
12 .byte 0x07
13 .byte 0x08
14 .byte 0x09
15 .byte 0x10
16 .even
17 .byte 0x11
18 .byte 0x12
19 .even
20 .byte 0x13
21 .even
22 .byte 0x00
23 .byte 0x01
24 .byte 0x02
25 .byte 0x03
26 .byte 0x04
27 .byte 0x05
28 .byte 0x06
29 .byte 0x07
30 .byte 0x08
31 .byte 0x09
32 .byte 0x10
33 .byte 0x11
34 .byte 0x12
35 .byte 0x13
36 .byte 0x14
37 .byte 0x15
38
39 # CHECK: Section {
40 # CHECK: Name: .text
41 # CHECK: SectionData (
42 # CHECK: 0000: 00010203 04050607 08091090 11121390
43 # CHECK: 0010: 00010203 04050607 08091011 12131415
44 # CHECK: )
45 # CHECK: }
46