Alex Lorenz | 2bdb4e1 | 2015-05-27 18:02:19 +0000 | [diff] [blame] | 1 | //===- MIRParser.cpp - MIR serialization format parser implementation -----===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements the class that parses the optional LLVM IR and machine |
| 11 | // functions that are stored in MIR files. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #include "llvm/CodeGen/MIRParser/MIRParser.h" |
Alex Lorenz | 8e0a1b4 | 2015-06-22 17:02:30 +0000 | [diff] [blame^] | 16 | #include "MIParser.h" |
Alex Lorenz | 2bdb4e1 | 2015-05-27 18:02:19 +0000 | [diff] [blame] | 17 | #include "llvm/ADT/StringRef.h" |
Alex Lorenz | 735c47e | 2015-06-15 20:30:22 +0000 | [diff] [blame] | 18 | #include "llvm/ADT/StringMap.h" |
Alex Lorenz | 2bdb4e1 | 2015-05-27 18:02:19 +0000 | [diff] [blame] | 19 | #include "llvm/ADT/STLExtras.h" |
| 20 | #include "llvm/AsmParser/Parser.h" |
Alex Lorenz | 735c47e | 2015-06-15 20:30:22 +0000 | [diff] [blame] | 21 | #include "llvm/CodeGen/MachineFunction.h" |
Alex Lorenz | 78d7831 | 2015-05-28 22:41:12 +0000 | [diff] [blame] | 22 | #include "llvm/CodeGen/MIRYamlMapping.h" |
Alex Lorenz | 4f093bf | 2015-06-19 17:43:07 +0000 | [diff] [blame] | 23 | #include "llvm/IR/BasicBlock.h" |
Alex Lorenz | 735c47e | 2015-06-15 20:30:22 +0000 | [diff] [blame] | 24 | #include "llvm/IR/DiagnosticInfo.h" |
Alex Lorenz | 8e7a58d7 | 2015-06-15 23:07:38 +0000 | [diff] [blame] | 25 | #include "llvm/IR/Instructions.h" |
Alex Lorenz | 735c47e | 2015-06-15 20:30:22 +0000 | [diff] [blame] | 26 | #include "llvm/IR/LLVMContext.h" |
Alex Lorenz | 2bdb4e1 | 2015-05-27 18:02:19 +0000 | [diff] [blame] | 27 | #include "llvm/IR/Module.h" |
Alex Lorenz | 4f093bf | 2015-06-19 17:43:07 +0000 | [diff] [blame] | 28 | #include "llvm/IR/ValueSymbolTable.h" |
Alex Lorenz | 09b832c | 2015-05-29 17:05:41 +0000 | [diff] [blame] | 29 | #include "llvm/Support/LineIterator.h" |
Alex Lorenz | 2bdb4e1 | 2015-05-27 18:02:19 +0000 | [diff] [blame] | 30 | #include "llvm/Support/SMLoc.h" |
| 31 | #include "llvm/Support/SourceMgr.h" |
| 32 | #include "llvm/Support/MemoryBuffer.h" |
| 33 | #include "llvm/Support/YAMLTraits.h" |
| 34 | #include <memory> |
| 35 | |
| 36 | using namespace llvm; |
| 37 | |
Alex Lorenz | 735c47e | 2015-06-15 20:30:22 +0000 | [diff] [blame] | 38 | namespace llvm { |
Alex Lorenz | 2bdb4e1 | 2015-05-27 18:02:19 +0000 | [diff] [blame] | 39 | |
| 40 | /// This class implements the parsing of LLVM IR that's embedded inside a MIR |
| 41 | /// file. |
| 42 | class MIRParserImpl { |
| 43 | SourceMgr SM; |
| 44 | StringRef Filename; |
| 45 | LLVMContext &Context; |
Alex Lorenz | 735c47e | 2015-06-15 20:30:22 +0000 | [diff] [blame] | 46 | StringMap<std::unique_ptr<yaml::MachineFunction>> Functions; |
Alex Lorenz | 2bdb4e1 | 2015-05-27 18:02:19 +0000 | [diff] [blame] | 47 | |
| 48 | public: |
| 49 | MIRParserImpl(std::unique_ptr<MemoryBuffer> Contents, StringRef Filename, |
| 50 | LLVMContext &Context); |
| 51 | |
Alex Lorenz | 735c47e | 2015-06-15 20:30:22 +0000 | [diff] [blame] | 52 | void reportDiagnostic(const SMDiagnostic &Diag); |
| 53 | |
| 54 | /// Report an error with the given message at unknown location. |
| 55 | /// |
| 56 | /// Always returns true. |
| 57 | bool error(const Twine &Message); |
| 58 | |
Alex Lorenz | 78d7831 | 2015-05-28 22:41:12 +0000 | [diff] [blame] | 59 | /// Try to parse the optional LLVM module and the machine functions in the MIR |
| 60 | /// file. |
Alex Lorenz | 2bdb4e1 | 2015-05-27 18:02:19 +0000 | [diff] [blame] | 61 | /// |
Alex Lorenz | 78d7831 | 2015-05-28 22:41:12 +0000 | [diff] [blame] | 62 | /// Return null if an error occurred. |
Alex Lorenz | 735c47e | 2015-06-15 20:30:22 +0000 | [diff] [blame] | 63 | std::unique_ptr<Module> parse(); |
Alex Lorenz | 78d7831 | 2015-05-28 22:41:12 +0000 | [diff] [blame] | 64 | |
| 65 | /// Parse the machine function in the current YAML document. |
| 66 | /// |
Alex Lorenz | 8e7a58d7 | 2015-06-15 23:07:38 +0000 | [diff] [blame] | 67 | /// \param NoLLVMIR - set to true when the MIR file doesn't have LLVM IR. |
| 68 | /// A dummy IR function is created and inserted into the given module when |
| 69 | /// this parameter is true. |
| 70 | /// |
Alex Lorenz | 78d7831 | 2015-05-28 22:41:12 +0000 | [diff] [blame] | 71 | /// Return true if an error occurred. |
Alex Lorenz | 8e7a58d7 | 2015-06-15 23:07:38 +0000 | [diff] [blame] | 72 | bool parseMachineFunction(yaml::Input &In, Module &M, bool NoLLVMIR); |
Alex Lorenz | 09b832c | 2015-05-29 17:05:41 +0000 | [diff] [blame] | 73 | |
Alex Lorenz | 735c47e | 2015-06-15 20:30:22 +0000 | [diff] [blame] | 74 | /// Initialize the machine function to the state that's described in the MIR |
| 75 | /// file. |
| 76 | /// |
| 77 | /// Return true if error occurred. |
| 78 | bool initializeMachineFunction(MachineFunction &MF); |
| 79 | |
Alex Lorenz | 4f093bf | 2015-06-19 17:43:07 +0000 | [diff] [blame] | 80 | /// Initialize the machine basic block using it's YAML representation. |
| 81 | /// |
| 82 | /// Return true if an error occurred. |
Alex Lorenz | 8e0a1b4 | 2015-06-22 17:02:30 +0000 | [diff] [blame^] | 83 | bool initializeMachineBasicBlock(MachineFunction &MF, MachineBasicBlock &MBB, |
Alex Lorenz | 4f093bf | 2015-06-19 17:43:07 +0000 | [diff] [blame] | 84 | const yaml::MachineBasicBlock &YamlMBB); |
| 85 | |
Alex Lorenz | 09b832c | 2015-05-29 17:05:41 +0000 | [diff] [blame] | 86 | private: |
| 87 | /// Return a MIR diagnostic converted from an LLVM assembly diagnostic. |
| 88 | SMDiagnostic diagFromLLVMAssemblyDiag(const SMDiagnostic &Error, |
| 89 | SMRange SourceRange); |
Alex Lorenz | 8e7a58d7 | 2015-06-15 23:07:38 +0000 | [diff] [blame] | 90 | |
| 91 | /// Create an empty function with the given name. |
| 92 | void createDummyFunction(StringRef Name, Module &M); |
Alex Lorenz | 2bdb4e1 | 2015-05-27 18:02:19 +0000 | [diff] [blame] | 93 | }; |
| 94 | |
Alex Lorenz | 735c47e | 2015-06-15 20:30:22 +0000 | [diff] [blame] | 95 | } // end namespace llvm |
Alex Lorenz | 2bdb4e1 | 2015-05-27 18:02:19 +0000 | [diff] [blame] | 96 | |
| 97 | MIRParserImpl::MIRParserImpl(std::unique_ptr<MemoryBuffer> Contents, |
| 98 | StringRef Filename, LLVMContext &Context) |
| 99 | : SM(), Filename(Filename), Context(Context) { |
| 100 | SM.AddNewSourceBuffer(std::move(Contents), SMLoc()); |
| 101 | } |
| 102 | |
Alex Lorenz | 735c47e | 2015-06-15 20:30:22 +0000 | [diff] [blame] | 103 | bool MIRParserImpl::error(const Twine &Message) { |
| 104 | Context.diagnose(DiagnosticInfoMIRParser( |
| 105 | DS_Error, SMDiagnostic(Filename, SourceMgr::DK_Error, Message.str()))); |
| 106 | return true; |
Alex Lorenz | 78d7831 | 2015-05-28 22:41:12 +0000 | [diff] [blame] | 107 | } |
Alex Lorenz | 2bdb4e1 | 2015-05-27 18:02:19 +0000 | [diff] [blame] | 108 | |
Alex Lorenz | 735c47e | 2015-06-15 20:30:22 +0000 | [diff] [blame] | 109 | void MIRParserImpl::reportDiagnostic(const SMDiagnostic &Diag) { |
| 110 | DiagnosticSeverity Kind; |
| 111 | switch (Diag.getKind()) { |
| 112 | case SourceMgr::DK_Error: |
| 113 | Kind = DS_Error; |
| 114 | break; |
| 115 | case SourceMgr::DK_Warning: |
| 116 | Kind = DS_Warning; |
| 117 | break; |
| 118 | case SourceMgr::DK_Note: |
| 119 | Kind = DS_Note; |
| 120 | break; |
| 121 | } |
| 122 | Context.diagnose(DiagnosticInfoMIRParser(Kind, Diag)); |
| 123 | } |
| 124 | |
| 125 | static void handleYAMLDiag(const SMDiagnostic &Diag, void *Context) { |
| 126 | reinterpret_cast<MIRParserImpl *>(Context)->reportDiagnostic(Diag); |
| 127 | } |
| 128 | |
| 129 | std::unique_ptr<Module> MIRParserImpl::parse() { |
Alex Lorenz | 78d7831 | 2015-05-28 22:41:12 +0000 | [diff] [blame] | 130 | yaml::Input In(SM.getMemoryBuffer(SM.getMainFileID())->getBuffer(), |
Alex Lorenz | 735c47e | 2015-06-15 20:30:22 +0000 | [diff] [blame] | 131 | /*Ctxt=*/nullptr, handleYAMLDiag, this); |
Alex Lorenz | 78d7831 | 2015-05-28 22:41:12 +0000 | [diff] [blame] | 132 | |
| 133 | if (!In.setCurrentDocument()) { |
Alex Lorenz | 735c47e | 2015-06-15 20:30:22 +0000 | [diff] [blame] | 134 | if (In.error()) |
Alex Lorenz | 78d7831 | 2015-05-28 22:41:12 +0000 | [diff] [blame] | 135 | return nullptr; |
| 136 | // Create an empty module when the MIR file is empty. |
| 137 | return llvm::make_unique<Module>(Filename, Context); |
Alex Lorenz | 2bdb4e1 | 2015-05-27 18:02:19 +0000 | [diff] [blame] | 138 | } |
| 139 | |
Alex Lorenz | 78d7831 | 2015-05-28 22:41:12 +0000 | [diff] [blame] | 140 | std::unique_ptr<Module> M; |
Alex Lorenz | 8e7a58d7 | 2015-06-15 23:07:38 +0000 | [diff] [blame] | 141 | bool NoLLVMIR = false; |
Alex Lorenz | 78d7831 | 2015-05-28 22:41:12 +0000 | [diff] [blame] | 142 | // Parse the block scalar manually so that we can return unique pointer |
| 143 | // without having to go trough YAML traits. |
| 144 | if (const auto *BSN = |
| 145 | dyn_cast_or_null<yaml::BlockScalarNode>(In.getCurrentNode())) { |
Alex Lorenz | 735c47e | 2015-06-15 20:30:22 +0000 | [diff] [blame] | 146 | SMDiagnostic Error; |
Alex Lorenz | 78d7831 | 2015-05-28 22:41:12 +0000 | [diff] [blame] | 147 | M = parseAssembly(MemoryBufferRef(BSN->getValue(), Filename), Error, |
| 148 | Context); |
Alex Lorenz | 09b832c | 2015-05-29 17:05:41 +0000 | [diff] [blame] | 149 | if (!M) { |
Alex Lorenz | 735c47e | 2015-06-15 20:30:22 +0000 | [diff] [blame] | 150 | reportDiagnostic(diagFromLLVMAssemblyDiag(Error, BSN->getSourceRange())); |
Alex Lorenz | 78d7831 | 2015-05-28 22:41:12 +0000 | [diff] [blame] | 151 | return M; |
Alex Lorenz | 09b832c | 2015-05-29 17:05:41 +0000 | [diff] [blame] | 152 | } |
Alex Lorenz | 78d7831 | 2015-05-28 22:41:12 +0000 | [diff] [blame] | 153 | In.nextDocument(); |
| 154 | if (!In.setCurrentDocument()) |
| 155 | return M; |
| 156 | } else { |
| 157 | // Create an new, empty module. |
| 158 | M = llvm::make_unique<Module>(Filename, Context); |
Alex Lorenz | 8e7a58d7 | 2015-06-15 23:07:38 +0000 | [diff] [blame] | 159 | NoLLVMIR = true; |
Alex Lorenz | 78d7831 | 2015-05-28 22:41:12 +0000 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | // Parse the machine functions. |
| 163 | do { |
Alex Lorenz | 8e7a58d7 | 2015-06-15 23:07:38 +0000 | [diff] [blame] | 164 | if (parseMachineFunction(In, *M, NoLLVMIR)) |
Alex Lorenz | 78d7831 | 2015-05-28 22:41:12 +0000 | [diff] [blame] | 165 | return nullptr; |
| 166 | In.nextDocument(); |
| 167 | } while (In.setCurrentDocument()); |
| 168 | |
| 169 | return M; |
| 170 | } |
| 171 | |
Alex Lorenz | 8e7a58d7 | 2015-06-15 23:07:38 +0000 | [diff] [blame] | 172 | bool MIRParserImpl::parseMachineFunction(yaml::Input &In, Module &M, |
| 173 | bool NoLLVMIR) { |
Alex Lorenz | 735c47e | 2015-06-15 20:30:22 +0000 | [diff] [blame] | 174 | auto MF = llvm::make_unique<yaml::MachineFunction>(); |
| 175 | yaml::yamlize(In, *MF, false); |
Alex Lorenz | 78d7831 | 2015-05-28 22:41:12 +0000 | [diff] [blame] | 176 | if (In.error()) |
| 177 | return true; |
Alex Lorenz | 735c47e | 2015-06-15 20:30:22 +0000 | [diff] [blame] | 178 | auto FunctionName = MF->Name; |
Alex Lorenz | fe2aa97 | 2015-06-15 22:23:23 +0000 | [diff] [blame] | 179 | if (Functions.find(FunctionName) != Functions.end()) |
| 180 | return error(Twine("redefinition of machine function '") + FunctionName + |
| 181 | "'"); |
Alex Lorenz | 735c47e | 2015-06-15 20:30:22 +0000 | [diff] [blame] | 182 | Functions.insert(std::make_pair(FunctionName, std::move(MF))); |
Alex Lorenz | 8e7a58d7 | 2015-06-15 23:07:38 +0000 | [diff] [blame] | 183 | if (NoLLVMIR) |
| 184 | createDummyFunction(FunctionName, M); |
Alex Lorenz | 5ef16b8 | 2015-06-16 17:06:29 +0000 | [diff] [blame] | 185 | else if (!M.getFunction(FunctionName)) |
| 186 | return error(Twine("function '") + FunctionName + |
| 187 | "' isn't defined in the provided LLVM IR"); |
Alex Lorenz | 735c47e | 2015-06-15 20:30:22 +0000 | [diff] [blame] | 188 | return false; |
| 189 | } |
| 190 | |
Alex Lorenz | 8e7a58d7 | 2015-06-15 23:07:38 +0000 | [diff] [blame] | 191 | void MIRParserImpl::createDummyFunction(StringRef Name, Module &M) { |
| 192 | auto &Context = M.getContext(); |
| 193 | Function *F = cast<Function>(M.getOrInsertFunction( |
| 194 | Name, FunctionType::get(Type::getVoidTy(Context), false))); |
| 195 | BasicBlock *BB = BasicBlock::Create(Context, "entry", F); |
| 196 | new UnreachableInst(Context, BB); |
| 197 | } |
| 198 | |
Alex Lorenz | 735c47e | 2015-06-15 20:30:22 +0000 | [diff] [blame] | 199 | bool MIRParserImpl::initializeMachineFunction(MachineFunction &MF) { |
| 200 | auto It = Functions.find(MF.getName()); |
| 201 | if (It == Functions.end()) |
| 202 | return error(Twine("no machine function information for function '") + |
| 203 | MF.getName() + "' in the MIR file"); |
| 204 | // TODO: Recreate the machine function. |
Alex Lorenz | 5b5f975 | 2015-06-16 00:10:47 +0000 | [diff] [blame] | 205 | const yaml::MachineFunction &YamlMF = *It->getValue(); |
| 206 | if (YamlMF.Alignment) |
| 207 | MF.setAlignment(YamlMF.Alignment); |
| 208 | MF.setExposesReturnsTwice(YamlMF.ExposesReturnsTwice); |
| 209 | MF.setHasInlineAsm(YamlMF.HasInlineAsm); |
Alex Lorenz | 4f093bf | 2015-06-19 17:43:07 +0000 | [diff] [blame] | 210 | const auto &F = *MF.getFunction(); |
| 211 | for (const auto &YamlMBB : YamlMF.BasicBlocks) { |
| 212 | const BasicBlock *BB = nullptr; |
| 213 | if (!YamlMBB.Name.empty()) { |
| 214 | BB = dyn_cast_or_null<BasicBlock>( |
| 215 | F.getValueSymbolTable().lookup(YamlMBB.Name)); |
Alex Lorenz | 00302df | 2015-06-19 20:12:03 +0000 | [diff] [blame] | 216 | if (!BB) |
| 217 | return error(Twine("basic block '") + YamlMBB.Name + |
| 218 | "' is not defined in the function '" + MF.getName() + "'"); |
Alex Lorenz | 4f093bf | 2015-06-19 17:43:07 +0000 | [diff] [blame] | 219 | } |
| 220 | auto *MBB = MF.CreateMachineBasicBlock(BB); |
| 221 | MF.insert(MF.end(), MBB); |
Alex Lorenz | 8e0a1b4 | 2015-06-22 17:02:30 +0000 | [diff] [blame^] | 222 | if (initializeMachineBasicBlock(MF, *MBB, YamlMBB)) |
Alex Lorenz | 4f093bf | 2015-06-19 17:43:07 +0000 | [diff] [blame] | 223 | return true; |
| 224 | } |
| 225 | return false; |
| 226 | } |
| 227 | |
| 228 | bool MIRParserImpl::initializeMachineBasicBlock( |
Alex Lorenz | 8e0a1b4 | 2015-06-22 17:02:30 +0000 | [diff] [blame^] | 229 | MachineFunction &MF, MachineBasicBlock &MBB, |
| 230 | const yaml::MachineBasicBlock &YamlMBB) { |
Alex Lorenz | 4f093bf | 2015-06-19 17:43:07 +0000 | [diff] [blame] | 231 | MBB.setAlignment(YamlMBB.Alignment); |
| 232 | if (YamlMBB.AddressTaken) |
| 233 | MBB.setHasAddressTaken(); |
| 234 | MBB.setIsLandingPad(YamlMBB.IsLandingPad); |
Alex Lorenz | 8e0a1b4 | 2015-06-22 17:02:30 +0000 | [diff] [blame^] | 235 | // Parse the instructions. |
| 236 | for (const auto &MISource : YamlMBB.Instructions) { |
| 237 | SMDiagnostic Error; |
| 238 | if (auto *MI = parseMachineInstr(SM, MF, MISource, Error)) { |
| 239 | MBB.insert(MBB.end(), MI); |
| 240 | continue; |
| 241 | } |
| 242 | reportDiagnostic(Error); |
| 243 | return true; |
| 244 | } |
Alex Lorenz | 78d7831 | 2015-05-28 22:41:12 +0000 | [diff] [blame] | 245 | return false; |
Alex Lorenz | 2bdb4e1 | 2015-05-27 18:02:19 +0000 | [diff] [blame] | 246 | } |
| 247 | |
Alex Lorenz | 09b832c | 2015-05-29 17:05:41 +0000 | [diff] [blame] | 248 | SMDiagnostic MIRParserImpl::diagFromLLVMAssemblyDiag(const SMDiagnostic &Error, |
| 249 | SMRange SourceRange) { |
| 250 | assert(SourceRange.isValid()); |
| 251 | |
| 252 | // Translate the location of the error from the location in the llvm IR string |
| 253 | // to the corresponding location in the MIR file. |
| 254 | auto LineAndColumn = SM.getLineAndColumn(SourceRange.Start); |
| 255 | unsigned Line = LineAndColumn.first + Error.getLineNo() - 1; |
| 256 | unsigned Column = Error.getColumnNo(); |
| 257 | StringRef LineStr = Error.getLineContents(); |
| 258 | SMLoc Loc = Error.getLoc(); |
| 259 | |
| 260 | // Get the full line and adjust the column number by taking the indentation of |
| 261 | // LLVM IR into account. |
| 262 | for (line_iterator L(*SM.getMemoryBuffer(SM.getMainFileID()), false), E; |
| 263 | L != E; ++L) { |
| 264 | if (L.line_number() == Line) { |
| 265 | LineStr = *L; |
| 266 | Loc = SMLoc::getFromPointer(LineStr.data()); |
| 267 | auto Indent = LineStr.find(Error.getLineContents()); |
| 268 | if (Indent != StringRef::npos) |
| 269 | Column += Indent; |
| 270 | break; |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | return SMDiagnostic(SM, Loc, Filename, Line, Column, Error.getKind(), |
| 275 | Error.getMessage(), LineStr, Error.getRanges(), |
| 276 | Error.getFixIts()); |
| 277 | } |
| 278 | |
Alex Lorenz | 735c47e | 2015-06-15 20:30:22 +0000 | [diff] [blame] | 279 | MIRParser::MIRParser(std::unique_ptr<MIRParserImpl> Impl) |
| 280 | : Impl(std::move(Impl)) {} |
| 281 | |
| 282 | MIRParser::~MIRParser() {} |
| 283 | |
| 284 | std::unique_ptr<Module> MIRParser::parseLLVMModule() { return Impl->parse(); } |
| 285 | |
| 286 | bool MIRParser::initializeMachineFunction(MachineFunction &MF) { |
| 287 | return Impl->initializeMachineFunction(MF); |
| 288 | } |
| 289 | |
| 290 | std::unique_ptr<MIRParser> llvm::createMIRParserFromFile(StringRef Filename, |
| 291 | SMDiagnostic &Error, |
| 292 | LLVMContext &Context) { |
Alex Lorenz | 2bdb4e1 | 2015-05-27 18:02:19 +0000 | [diff] [blame] | 293 | auto FileOrErr = MemoryBuffer::getFile(Filename); |
| 294 | if (std::error_code EC = FileOrErr.getError()) { |
| 295 | Error = SMDiagnostic(Filename, SourceMgr::DK_Error, |
| 296 | "Could not open input file: " + EC.message()); |
Alex Lorenz | 735c47e | 2015-06-15 20:30:22 +0000 | [diff] [blame] | 297 | return nullptr; |
Alex Lorenz | 2bdb4e1 | 2015-05-27 18:02:19 +0000 | [diff] [blame] | 298 | } |
Alex Lorenz | 735c47e | 2015-06-15 20:30:22 +0000 | [diff] [blame] | 299 | return createMIRParser(std::move(FileOrErr.get()), Context); |
Alex Lorenz | 2bdb4e1 | 2015-05-27 18:02:19 +0000 | [diff] [blame] | 300 | } |
| 301 | |
Alex Lorenz | 735c47e | 2015-06-15 20:30:22 +0000 | [diff] [blame] | 302 | std::unique_ptr<MIRParser> |
| 303 | llvm::createMIRParser(std::unique_ptr<MemoryBuffer> Contents, |
| 304 | LLVMContext &Context) { |
Alex Lorenz | 2bdb4e1 | 2015-05-27 18:02:19 +0000 | [diff] [blame] | 305 | auto Filename = Contents->getBufferIdentifier(); |
Alex Lorenz | 735c47e | 2015-06-15 20:30:22 +0000 | [diff] [blame] | 306 | return llvm::make_unique<MIRParser>( |
| 307 | llvm::make_unique<MIRParserImpl>(std::move(Contents), Filename, Context)); |
Alex Lorenz | 2bdb4e1 | 2015-05-27 18:02:19 +0000 | [diff] [blame] | 308 | } |