[cfe-commits] r161614 - /cfe/trunk/lib/Sema/SemaStmt.cpp
David Blaikie
dblaikie at gmail.com
Thu Aug 9 15:26:16 PDT 2012
This appears to have broken the CMake build (introducing a dependency
on LLVM MC from Clang Sema) - at a glance I haven't found where to
insert the necessary CMake machinery to represent this & I have to run
now, but perhaps you/someone else will find it before I get a chance.
On Thu, Aug 9, 2012 at 1:47 PM, Chad Rosier <mcrosier at apple.com> wrote:
> Author: mcrosier
> Date: Thu Aug 9 15:47:38 2012
> New Revision: 161614
>
> URL: http://llvm.org/viewvc/llvm-project?rev=161614&view=rev
> Log:
> [ms-inline asm] Instantiate the various parts to the AsmParser.
>
> Modified:
> cfe/trunk/lib/Sema/SemaStmt.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=161614&r1=161613&r2=161614&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaStmt.cpp Thu Aug 9 15:47:38 2012
> @@ -32,6 +32,17 @@
> #include "llvm/ADT/SmallPtrSet.h"
> #include "llvm/ADT/SmallString.h"
> #include "llvm/ADT/SmallVector.h"
> +#include "llvm/ADT/Triple.h"
> +#include "llvm/MC/MCAsmInfo.h"
> +#include "llvm/MC/MCContext.h"
> +#include "llvm/MC/MCObjectFileInfo.h"
> +#include "llvm/MC/MCRegisterInfo.h"
> +#include "llvm/MC/MCStreamer.h"
> +#include "llvm/MC/MCSubtargetInfo.h"
> +#include "llvm/MC/MCTargetAsmParser.h"
> +#include "llvm/MC/MCParser/MCAsmParser.h"
> +#include "llvm/Support/SourceMgr.h"
> +#include "llvm/Support/TargetRegistry.h"
> #include "llvm/Support/TargetSelect.h"
> using namespace clang;
> using namespace sema;
> @@ -2884,15 +2895,40 @@
> std::string PatchedAsmString =
> PatchMSAsmString(*this, IsSimple, AsmLoc, AsmToks, Context.getTargetInfo());
>
> - // Silence compiler warnings. Eventually, the PatchedAsmString will be
> - // passed to the AsmParser.
> - (void)PatchedAsmString;
> -
> // Initialize targets and assembly printers/parsers.
> llvm::InitializeAllTargetInfos();
> llvm::InitializeAllTargetMCs();
> llvm::InitializeAllAsmParsers();
>
> + // Get the target specific parser.
> + std::string Error;
> + 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 syntax.
> + Parser->setAssemblerDialect(1);
> + Parser->setTargetParser(*TargetParser.get());
> +
> MSAsmStmt *NS =
> new (Context) MSAsmStmt(Context, AsmLoc, IsSimple, /* IsVolatile */ true,
> AsmToks, LineEnds, AsmString, EndLoc);
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list