From 81e72b4d4ea92d9b6ab0721ef062638d2114a621 Mon Sep 17 00:00:00 2001 From: Quentin Colombet Date: Mon, 7 Mar 2016 22:09:05 +0000 Subject: [AsmParser] Add a function to parse a standalone type. This is useful for MIR serialization. Indeed generic machine instructions must have a type and we don't want to duplicate the logic in the MIParser. llvm-svn: 262868 --- llvm/lib/AsmParser/Parser.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'llvm/lib/AsmParser/Parser.cpp') diff --git a/llvm/lib/AsmParser/Parser.cpp b/llvm/lib/AsmParser/Parser.cpp index 4e55e62ecf5..9b635982477 100644 --- a/llvm/lib/AsmParser/Parser.cpp +++ b/llvm/lib/AsmParser/Parser.cpp @@ -78,3 +78,15 @@ Constant *llvm::parseConstantValue(StringRef Asm, SMDiagnostic &Err, return nullptr; return C; } + +Type *llvm::parseType(StringRef Asm, SMDiagnostic &Err, const Module &M, + const SlotMapping *Slots) { + SourceMgr SM; + std::unique_ptr Buf = MemoryBuffer::getMemBuffer(Asm); + SM.AddNewSourceBuffer(std::move(Buf), SMLoc()); + Type *Ty; + if (LLParser(Asm, SM, Err, const_cast(&M)) + .parseStandaloneType(Ty, Slots)) + return nullptr; + return Ty; +} -- cgit v1.2.3