summaryrefslogtreecommitdiffstats
path: root/llvm/lib/AsmParser/Parser.cpp
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2015-06-23 17:10:10 +0000
committerAlex Lorenz <arphaman@gmail.com>2015-06-23 17:10:10 +0000
commit8955f7d7046779668232f79984e9b3ab43bb8b10 (patch)
tree5f3af0a58f5514f601ab93094739e20c6e48478e /llvm/lib/AsmParser/Parser.cpp
parent82a56b01aef8d71e822fcda90146df72d4ca1e08 (diff)
downloadbcm5719-llvm-8955f7d7046779668232f79984e9b3ab43bb8b10.tar.gz
bcm5719-llvm-8955f7d7046779668232f79984e9b3ab43bb8b10.zip
AsmParser: Extend the API to make the global value and metadata node slot mappings publicly accessible.
This commit creates a new structure called 'SlotMapping' in the AsmParser library. This structure can be passed into the public parsing APIs from the AsmParser library in order to extract the data structures that map from slot numbers to unnamed global values and metadata nodes. This change is useful for MIR Serialization, as the MIR Parser has to lookup the unnamed global values and metadata nodes by their slot numbers. Reviewers: Duncan P. N. Exon Smith Differential Revision: http://reviews.llvm.org/D10551 llvm-svn: 240427
Diffstat (limited to 'llvm/lib/AsmParser/Parser.cpp')
-rw-r--r--llvm/lib/AsmParser/Parser.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/llvm/lib/AsmParser/Parser.cpp b/llvm/lib/AsmParser/Parser.cpp
index c55a6a1e243..9145a54f2a7 100644
--- a/llvm/lib/AsmParser/Parser.cpp
+++ b/llvm/lib/AsmParser/Parser.cpp
@@ -22,21 +22,23 @@
#include <system_error>
using namespace llvm;
-bool llvm::parseAssemblyInto(MemoryBufferRef F, Module &M, SMDiagnostic &Err) {
+bool llvm::parseAssemblyInto(MemoryBufferRef F, Module &M, SMDiagnostic &Err,
+ SlotMapping *Slots) {
SourceMgr SM;
std::unique_ptr<MemoryBuffer> Buf = MemoryBuffer::getMemBuffer(F);
SM.AddNewSourceBuffer(std::move(Buf), SMLoc());
- return LLParser(F.getBuffer(), SM, Err, &M).Run();
+ return LLParser(F.getBuffer(), SM, Err, &M, Slots).Run();
}
std::unique_ptr<Module> llvm::parseAssembly(MemoryBufferRef F,
SMDiagnostic &Err,
- LLVMContext &Context) {
+ LLVMContext &Context,
+ SlotMapping *Slots) {
std::unique_ptr<Module> M =
make_unique<Module>(F.getBufferIdentifier(), Context);
- if (parseAssemblyInto(F, *M, Err))
+ if (parseAssemblyInto(F, *M, Err, Slots))
return nullptr;
return M;
@@ -44,7 +46,8 @@ std::unique_ptr<Module> llvm::parseAssembly(MemoryBufferRef F,
std::unique_ptr<Module> llvm::parseAssemblyFile(StringRef Filename,
SMDiagnostic &Err,
- LLVMContext &Context) {
+ LLVMContext &Context,
+ SlotMapping *Slots) {
ErrorOr<std::unique_ptr<MemoryBuffer>> FileOrErr =
MemoryBuffer::getFileOrSTDIN(Filename);
if (std::error_code EC = FileOrErr.getError()) {
@@ -53,12 +56,13 @@ std::unique_ptr<Module> llvm::parseAssemblyFile(StringRef Filename,
return nullptr;
}
- return parseAssembly(FileOrErr.get()->getMemBufferRef(), Err, Context);
+ return parseAssembly(FileOrErr.get()->getMemBufferRef(), Err, Context, Slots);
}
std::unique_ptr<Module> llvm::parseAssemblyString(StringRef AsmString,
SMDiagnostic &Err,
- LLVMContext &Context) {
+ LLVMContext &Context,
+ SlotMapping *Slots) {
MemoryBufferRef F(AsmString, "<string>");
- return parseAssembly(F, Err, Context);
+ return parseAssembly(F, Err, Context, Slots);
}
OpenPOWER on IntegriCloud