[cfe-commits] r161780 - in /cfe/trunk: lib/Sema/SemaStmt.cpp test/CodeGen/ms-inline-asm.c
Richard Smith
richard at metafoo.co.uk
Thu Aug 16 21:03:29 PDT 2012
On Mon, Aug 13, 2012 at 1:32 PM, Chad Rosier <mcrosier at apple.com> wrote:
> Author: mcrosier
> Date: Mon Aug 13 15:32:07 2012
> New Revision: 161780
>
> URL: http://llvm.org/viewvc/llvm-project?rev=161780&view=rev
> Log:
> [ms-inline asm] Have patchMSAsmStrings() return a vector or AsmStrings.
>
> The AsmParser expects a single asm instruction, but valid ms-style inline
> asm
> statements may contain multiple instructions.
>
> This happens with asm blocks
>
> __asm {
> mov ebx, eax
> mov ecx, ebx
> }
>
> or when multiple asm statements are adjacent to one another
>
> __asm mov ebx, eax
> __asm mov ecx, ebx
>
> and
>
> __asm mov ebx, eax __asm mov ecx, ebx
>
> Currently, asm blocks are not properly handled.
>
> Modified:
> cfe/trunk/lib/Sema/SemaStmt.cpp
> cfe/trunk/test/CodeGen/ms-inline-asm.c
>
> Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=161780&r1=161779&r2=161780&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaStmt.cpp Mon Aug 13 15:32:07 2012
> @@ -2921,29 +2935,32 @@
> const std::string &TT = Context.getTargetInfo().getTriple().getTriple();
> const llvm::Target *TheTarget(llvm::TargetRegistry::lookupTarget(TT,
> Error));
>
> - llvm::SourceMgr SrcMgr;
> - llvm::MemoryBuffer *Buffer =
> - llvm::MemoryBuffer::getMemBuffer(PatchedAsmString, "<inline asm>");
> -
> - // Tell SrcMgr about this buffer, which is what the parser will pick up.
> - SrcMgr.AddNewSourceBuffer(Buffer, llvm::SMLoc());
> -
> OwningPtr<llvm::MCAsmInfo> MAI(TheTarget->createMCAsmInfo(TT));
> OwningPtr<llvm::MCRegisterInfo> MRI(TheTarget->createMCRegInfo(TT));
> OwningPtr<llvm::MCObjectFileInfo> MOFI(new llvm::MCObjectFileInfo());
> - llvm::MCContext Ctx(*MAI, *MRI, MOFI.get(), &SrcMgr);
> OwningPtr<llvm::MCSubtargetInfo>
> STI(TheTarget->createMCSubtargetInfo(TT, "", ""));
>
> - OwningPtr<llvm::MCStreamer> Str;
> - OwningPtr<llvm::MCAsmParser>
> - Parser(createMCAsmParser(SrcMgr, Ctx, *Str.get(), *MAI));
> - OwningPtr<llvm::MCTargetAsmParser>
> - TargetParser(TheTarget->createMCAsmParser(*STI, *Parser));
> -
> - // Change to the Intel dialect.
> - Parser->setAssemblerDialect(1);
> - Parser->setTargetParser(*TargetParser.get());
> + for (unsigned i = 0, e = PatchedAsmStrings.size(); i != e; ++i) {
> + llvm::SourceMgr SrcMgr;
> + llvm::MCContext Ctx(*MAI, *MRI, MOFI.get(), &SrcMgr);
> + llvm::MemoryBuffer *Buffer =
> + llvm::MemoryBuffer::getMemBuffer(PatchedAsmStrings[i], "<inline
> asm>");
> +
> + // Tell SrcMgr about this buffer, which is what the parser will pick
> up.
> + SrcMgr.AddNewSourceBuffer(Buffer, llvm::SMLoc());
> +
> + OwningPtr<llvm::MCStreamer> Str;
> + OwningPtr<llvm::MCAsmParser>
> + Parser(createMCAsmParser(SrcMgr, Ctx, *Str.get(), *MAI));
>
Str.get() is a null pointer here.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120816/ae92cc13/attachment.html>
More information about the cfe-commits
mailing list