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 class Module;
23 namespace orc {
24 
25 /// A layer that applies a transform to emitted modules.
26 /// The transform function is responsible for locking the ThreadSafeContext
27 /// before operating on the module.
28 class IRTransformLayer : public IRLayer {
29 public:
32 
35 
36  void setTransform(TransformFunction Transform) {
37  this->Transform = std::move(Transform);
38  }
39 
40  void emit(std::unique_ptr<MaterializationResponsibility> R,
41  ThreadSafeModule TSM) override;
42 
45  return TSM;
46  }
47 
48 private:
49  IRLayer &BaseLayer;
50  TransformFunction Transform;
51 };
52 
53 } // end namespace orc
54 } // end namespace llvm
55 
56 #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:43
llvm::orc::IRTransformLayer::TransformFunction
unique_function< Expected< ThreadSafeModule >(ThreadSafeModule, MaterializationResponsibility &R)> TransformFunction
Definition: IRTransformLayer.h:31
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:36
llvm::orc::IRTransformLayer::emit
void emit(std::unique_ptr< MaterializationResponsibility > R, ThreadSafeModule TSM) override
Emit should materialize the given IR.
Definition: IRTransformLayer.cpp:20
Module
Machine Check Debug Module
Definition: MachineCheckDebugify.cpp:122
llvm::orc::ExecutionSession
An ExecutionSession represents a running JIT program.
Definition: Core.h:1346
llvm::orc::IRTransformLayer
A layer that applies a transform to emitted modules.
Definition: IRTransformLayer.h:28
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:68