summaryrefslogtreecommitdiff
path: root/lib/AsmParser/Parser.cpp
diff options
context:
space:
mode:
authorQuentin Colombet <qcolombet@apple.com>2016-03-07 22:09:05 +0000
committerQuentin Colombet <qcolombet@apple.com>2016-03-07 22:09:05 +0000
commit2ba0323edd1a49c7a78404e1814dcd00818f65c0 (patch)
tree42c32aedcae2fd7465122a8d776c62964d8b8349 /lib/AsmParser/Parser.cpp
parent6266be011998881771fe20db92250d00f66e0a79 (diff)
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@262868 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AsmParser/Parser.cpp')
-rw-r--r--lib/AsmParser/Parser.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/AsmParser/Parser.cpp b/lib/AsmParser/Parser.cpp
index 4e55e62ecf5..9b635982477 100644
--- a/lib/AsmParser/Parser.cpp
+++ b/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<MemoryBuffer> Buf = MemoryBuffer::getMemBuffer(Asm);
+ SM.AddNewSourceBuffer(std::move(Buf), SMLoc());
+ Type *Ty;
+ if (LLParser(Asm, SM, Err, const_cast<Module *>(&M))
+ .parseStandaloneType(Ty, Slots))
+ return nullptr;
+ return Ty;
+}