[llvm] r179030 - [ms-inline asm] Add support for ImmDisp [ Symbol ] memory operands.
Rafael EspĂndola
rafael.espindola at gmail.com
Mon Apr 8 21:54:51 PDT 2013
testcase?
On 8 April 2013 13:43, Chad Rosier <mcrosier at apple.com> wrote:
> Author: mcrosier
> Date: Mon Apr 8 12:43:47 2013
> New Revision: 179030
>
> URL: http://llvm.org/viewvc/llvm-project?rev=179030&view=rev
> Log:
> [ms-inline asm] Add support for ImmDisp [ Symbol ] memory operands.
> rdar://13521249
>
> Modified:
> llvm/trunk/include/llvm/MC/MCTargetAsmParser.h
> llvm/trunk/lib/MC/MCParser/AsmParser.cpp
> llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
>
> Modified: llvm/trunk/include/llvm/MC/MCTargetAsmParser.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCTargetAsmParser.h?rev=179030&r1=179029&r2=179030&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/MC/MCTargetAsmParser.h (original)
> +++ llvm/trunk/include/llvm/MC/MCTargetAsmParser.h Mon Apr 8 12:43:47 2013
> @@ -22,7 +22,7 @@ class MCInst;
> template <typename T> class SmallVectorImpl;
>
> enum AsmRewriteKind {
> - AOK_Align, // Rewrite align as .align.
> + AOK_Align = 0, // Rewrite align as .align.
> AOK_DotOperator, // Rewrite a dot operator expression as an immediate.
> // E.g., [eax].foo.bar -> [eax].8
> AOK_Emit, // Rewrite _emit as .byte.
> @@ -34,6 +34,18 @@ enum AsmRewriteKind {
> AOK_Skip // Skip emission (e.g., offset/type operators).
> };
>
> +const char AsmRewritePrecedence [] = {
> + 0, // AOK_Align
> + 0, // AOK_DotOperator
> + 0, // AOK_Emit
> + 2, // AOK_Imm
> + 2, // AOK_ImmPrefix
> + 1, // AOK_Input
> + 1, // AOK_Output
> + 3, // AOK_SizeDirective
> + 0 // AOK_Skip
> +};
> +
> struct AsmRewrite {
> AsmRewriteKind Kind;
> SMLoc Loc;
>
> Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=179030&r1=179029&r2=179030&view=diff
> ==============================================================================
> --- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
> +++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Mon Apr 8 12:43:47 2013
> @@ -4046,19 +4046,17 @@ static int RewritesSort(const void *A, c
> if (AsmRewriteB->Loc.getPointer() < AsmRewriteA->Loc.getPointer())
> return 1;
>
> - // It's possible to have a SizeDirective rewrite and an Input/Output rewrite
> - // to the same location. Make sure the SizeDirective rewrite is performed
> - // first. This also ensure the sort algorithm is stable.
> - if (AsmRewriteA->Kind == AOK_SizeDirective) {
> - assert ((AsmRewriteB->Kind == AOK_Input || AsmRewriteB->Kind == AOK_Output) &&
> - "Expected an Input/Output rewrite!");
> + // It's possible to have a SizeDirective, Imm/ImmPrefix and an Input/Output
> + // rewrite to the same location. Make sure the SizeDirective rewrite is
> + // performed first, then the Imm/ImmPrefix and finally the Input/Output. This
> + // ensures the sort algorithm is stable.
> + if (AsmRewritePrecedence [AsmRewriteA->Kind] >
> + AsmRewritePrecedence [AsmRewriteB->Kind])
> return -1;
> - }
> - if (AsmRewriteB->Kind == AOK_SizeDirective) {
> - assert ((AsmRewriteA->Kind == AOK_Input || AsmRewriteA->Kind == AOK_Output) &&
> - "Expected an Input/Output rewrite!");
> +
> + if (AsmRewritePrecedence [AsmRewriteA->Kind] <
> + AsmRewritePrecedence [AsmRewriteB->Kind])
> return 1;
> - }
> llvm_unreachable ("Unstable rewrite sort.");
> }
>
>
> Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp?rev=179030&r1=179029&r2=179030&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp (original)
> +++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Mon Apr 8 12:43:47 2013
> @@ -61,8 +61,8 @@ private:
> X86Operand *ParseIntelOperator(SMLoc StartLoc, unsigned OpKind);
> X86Operand *ParseIntelMemOperand(unsigned SegReg, uint64_t ImmDisp,
> SMLoc StartLoc);
> - X86Operand *ParseIntelBracExpression(unsigned SegReg, uint64_t ImmDisp,
> - unsigned Size);
> + X86Operand *ParseIntelBracExpression(unsigned SegReg, SMLoc SizeDirLoc,
> + uint64_t ImmDisp, unsigned Size);
> X86Operand *ParseIntelVarWithQualifier(const MCExpr *&Disp,
> SMLoc &IdentStart);
> X86Operand *ParseMemOperand(unsigned SegReg, SMLoc StartLoc);
> @@ -1100,6 +1100,7 @@ X86Operand *X86AsmParser::CreateMemForIn
> }
>
> X86Operand *X86AsmParser::ParseIntelBracExpression(unsigned SegReg,
> + SMLoc SizeDirLoc,
> uint64_t ImmDisp,
> unsigned Size) {
> const AsmToken &Tok = Parser.getTok();
> @@ -1126,18 +1127,11 @@ X86Operand *X86AsmParser::ParseIntelBrac
> if (getLexer().isNot(AsmToken::RBrac))
> return ErrorOperand(Parser.getTok().getLoc(), "Expected ']' token!");
>
> - // FIXME: We don't handle 'ImmDisp' '[' 'Symbol' ']'.
> - if (ImmDisp)
> - return ErrorOperand(Start, "Unsupported immediate displacement!");
> -
> // Adjust the EndLoc due to the ']'.
> End = SMLoc::getFromPointer(Parser.getTok().getEndLoc().getPointer()-1);
> Parser.Lex();
> if (!isParsingInlineAsm())
> return X86Operand::CreateMem(Disp, Start, End, Size);
> -
> - // We want the size directive before the '['.
> - SMLoc SizeDirLoc = SMLoc::getFromPointer(Start.getPointer()-1);
> return CreateMemForInlineAsm(Disp, Start, End, SizeDirLoc, Size);
> }
> }
> @@ -1302,11 +1296,11 @@ X86Operand *X86AsmParser::ParseIntelMemO
> Parser.Lex(); // Eat the integer.
> if (getLexer().isNot(AsmToken::LBrac))
> return ErrorOperand(Start, "Expected '[' token!");
> - return ParseIntelBracExpression(SegReg, ImmDisp, Size);
> + return ParseIntelBracExpression(SegReg, Start, ImmDisp, Size);
> }
>
> if (getLexer().is(AsmToken::LBrac))
> - return ParseIntelBracExpression(SegReg, ImmDisp, Size);
> + return ParseIntelBracExpression(SegReg, Start, ImmDisp, Size);
>
> if (!ParseRegister(SegReg, Start, End)) {
> // Handel SegReg : [ ... ]
> @@ -1315,7 +1309,7 @@ X86Operand *X86AsmParser::ParseIntelMemO
> Parser.Lex(); // Eat :
> if (getLexer().isNot(AsmToken::LBrac))
> return ErrorOperand(Start, "Expected '[' token!");
> - return ParseIntelBracExpression(SegReg, ImmDisp, Size);
> + return ParseIntelBracExpression(SegReg, Start, ImmDisp, Size);
> }
>
> const MCExpr *Disp = MCConstantExpr::Create(0, getParser().getContext());
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list