summaryrefslogtreecommitdiffstats
path: root/llvm/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
commit81e72b4d4ea92d9b6ab0721ef062638d2114a621 (patch)
tree19011b0338d9902da1cb98738df7f389e7026964 /llvm/lib/AsmParser/Parser.cpp
parent4e14a497a3c0e0855ff37cc3b80d9a7ae88891ad (diff)
downloadbcm5719-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.cpp12
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;
+}
OpenPOWER on IntegriCloud