diff options
author | Quentin Colombet <qcolombet@apple.com> | 2016-03-07 22:09:05 +0000 |
---|---|---|
committer | Quentin Colombet <qcolombet@apple.com> | 2016-03-07 22:09:05 +0000 |
commit | 81e72b4d4ea92d9b6ab0721ef062638d2114a621 (patch) | |
tree | 19011b0338d9902da1cb98738df7f389e7026964 /llvm/lib/AsmParser/Parser.cpp | |
parent | 4e14a497a3c0e0855ff37cc3b80d9a7ae88891ad (diff) | |
download | bcm5719-llvm-81e72b4d4ea92d9b6ab0721ef062638d2114a621.tar.gz bcm5719-llvm-81e72b4d4ea92d9b6ab0721ef062638d2114a621.zip |
[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
Diffstat (limited to 'llvm/lib/AsmParser/Parser.cpp')
-rw-r--r-- | llvm/lib/AsmParser/Parser.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
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<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; +} |