LLVM  14.0.0git
IRCompileLayer.cpp
Go to the documentation of this file.
1 //===--------------- IRCompileLayer.cpp - IR Compiling Layer --------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
10 
11 namespace llvm {
12 namespace orc {
13 
15 
17  std::unique_ptr<IRCompiler> Compile)
18  : IRLayer(ES, ManglingOpts), BaseLayer(BaseLayer),
19  Compile(std::move(Compile)) {
20  ManglingOpts = &this->Compile->getManglingOptions();
21 }
22 
24  std::lock_guard<std::mutex> Lock(IRLayerMutex);
25  this->NotifyCompiled = std::move(NotifyCompiled);
26 }
27 
28 void IRCompileLayer::emit(std::unique_ptr<MaterializationResponsibility> R,
29  ThreadSafeModule TSM) {
30  assert(TSM && "Module must not be null");
31 
32  if (auto Obj = TSM.withModuleDo(*Compile)) {
33  {
34  std::lock_guard<std::mutex> Lock(IRLayerMutex);
35  if (NotifyCompiled)
36  NotifyCompiled(*R, std::move(TSM));
37  else
38  TSM = ThreadSafeModule();
39  }
40  BaseLayer.emit(std::move(R), std::move(*Obj));
41  } else {
42  R->failMaterialization();
43  getExecutionSession().reportError(Obj.takeError());
44  }
45 }
46 
47 } // End namespace orc.
48 } // End namespace llvm.
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
llvm::orc::ExecutionSession::reportError
void reportError(Error Err)
Report a error for this execution session.
Definition: Core.h:1375
llvm::orc::IRCompileLayer::emit
void emit(std::unique_ptr< MaterializationResponsibility > R, ThreadSafeModule TSM) override
Emit should materialize the given IR.
Definition: IRCompileLayer.cpp:28
llvm::Lock
static sys::Mutex Lock
Definition: NVPTXUtilities.cpp:39
llvm::orc::IRCompileLayer::IRCompileLayer
IRCompileLayer(ExecutionSession &ES, ObjectLayer &BaseLayer, std::unique_ptr< IRCompiler > Compile)
Definition: IRCompileLayer.cpp:16
llvm::orc::IRCompileLayer::IRCompiler::~IRCompiler
virtual ~IRCompiler()
Definition: IRCompileLayer.cpp:14
llvm::orc::IRCompileLayer::NotifyCompiledFunction
std::function< void(MaterializationResponsibility &R, ThreadSafeModule TSM)> NotifyCompiledFunction
Definition: IRCompileLayer.h:50
llvm::orc::ObjectLayer
Interface for Layers that accept object files.
Definition: Layer.h:134
IRCompileLayer.h
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1639
llvm::orc::IRLayer::getExecutionSession
ExecutionSession & getExecutionSession()
Returns the ExecutionSession for this layer.
Definition: Layer.h:76
llvm::orc::ThreadSafeModule::withModuleDo
decltype(auto) withModuleDo(Func &&F)
Locks the associated ThreadSafeContext and calls the given function on the contained Module.
Definition: ThreadSafeModule.h:133
llvm::orc::ObjectLayer::emit
virtual void emit(std::unique_ptr< MaterializationResponsibility > R, std::unique_ptr< MemoryBuffer > O)=0
Emit should materialize the given IR.
std
Definition: BitVector.h:838
llvm::orc::ExecutionSession
An ExecutionSession represents a running JIT program.
Definition: Core.h:1271
llvm::orc::IRCompileLayer::setNotifyCompiled
void setNotifyCompiled(NotifyCompiledFunction NotifyCompiled)
Definition: IRCompileLayer.cpp:23
llvm::orc::ThreadSafeModule
An LLVM Module together with a shared ThreadSafeContext.
Definition: ThreadSafeModule.h:77
llvm::orc::IRLayer
Interface for layers that accept LLVM IR.
Definition: Layer.h:68