LLVM  14.0.0git
IRTransformLayer.h
Go to the documentation of this file.
1 //===- IRTransformLayer.h - Run all IR through a functor --------*- C++ -*-===//
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 //
9 // Run all IR passed in through a user supplied functor.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_EXECUTIONENGINE_ORC_IRTRANSFORMLAYER_H
14 #define LLVM_EXECUTIONENGINE_ORC_IRTRANSFORMLAYER_H
15 
19 #include <memory>
20 
21 namespace llvm {
22 namespace orc {
23 
24 /// A layer that applies a transform to emitted modules.
25 /// The transform function is responsible for locking the ThreadSafeContext
26 /// before operating on the module.
27 class IRTransformLayer : public IRLayer {
28 public:
31 
34 
35  void setTransform(TransformFunction Transform) {
36  this->Transform = std::move(Transform);
37  }
38 
39  void emit(std::unique_ptr<MaterializationResponsibility> R,
40  ThreadSafeModule TSM) override;
41 
44  return TSM;
45  }
46 
47 private:
48  IRLayer &BaseLayer;
49  TransformFunction Transform;
50 };
51 
52 } // end namespace orc
53 } // end namespace llvm
54 
55 #endif // LLVM_EXECUTIONENGINE_ORC_IRTRANSFORMLAYER_H
llvm::orc::MaterializationResponsibility
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
Definition: Core.h:520
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
JITSymbol.h
FunctionExtras.h
llvm::unique_function< Expected< ThreadSafeModule >(ThreadSafeModule, MaterializationResponsibility &R)>
Layer.h
llvm::orc::IRTransformLayer::identityTransform
static ThreadSafeModule identityTransform(ThreadSafeModule TSM, MaterializationResponsibility &R)
Definition: IRTransformLayer.h:42
llvm::orc::IRTransformLayer::TransformFunction
unique_function< Expected< ThreadSafeModule >(ThreadSafeModule, MaterializationResponsibility &R)> TransformFunction
Definition: IRTransformLayer.h:30
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
llvm::orc::IRTransformLayer::setTransform
void setTransform(TransformFunction Transform)
Definition: IRTransformLayer.h:35
llvm::orc::IRTransformLayer::emit
void emit(std::unique_ptr< MaterializationResponsibility > R, ThreadSafeModule TSM) override
Emit should materialize the given IR.
Definition: IRTransformLayer.cpp:20
llvm::orc::ExecutionSession
An ExecutionSession represents a running JIT program.
Definition: Core.h:1358
llvm::orc::IRTransformLayer
A layer that applies a transform to emitted modules.
Definition: IRTransformLayer.h:27
llvm::orc::IRTransformLayer::IRTransformLayer
IRTransformLayer(ExecutionSession &ES, IRLayer &BaseLayer, TransformFunction Transform=identityTransform)
Definition: IRTransformLayer.cpp:15
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:67