File tree 1 file changed +35
-0
lines changed 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 2
2
3
3
Sandbox IR is an IR layer on top of LLVM IR that allows you to save/restore its state.
4
4
5
+ # Quick Start Notes
6
+
7
+ Within your LLVM pass:
8
+
9
+ ```
10
+ // 1. Include the necessary Sandbox IR header files.
11
+ #include "llvm/SandboxIR/Context.h
12
+ #include "llvm/SandboxIR/Function.h
13
+
14
+ // 2. Create a sandboxir::Context using LLVMContext `LLVMCtx`.
15
+ sandboxir::Context Ctx(LLVMCtx);
16
+
17
+ // 3. Create a sandboxir::Function using LLVM IR Function `LLVMF`.
18
+ auto *F = Ctx.createFunction(LLVMF);
19
+
20
+ // ... Use Sandbox IR in `F` as usual, e.g., iterating, modifying it etc. ...
21
+
22
+ // 4. Save state when needed.
23
+ Ctx.save();
24
+
25
+ // ... Modify Sandbox IR ...
26
+
27
+ // 5. Revert to the saved state.
28
+ Ctx.revert();
29
+ ```
30
+
31
+ Make sure you link against ` SandboxIR ` in ` CMakeLists.txt ` :
32
+
33
+ ```
34
+ LINK_COMPONENTS
35
+ ...
36
+ SandboxIR
37
+ ...
38
+ ```
39
+
5
40
# API
6
41
The Sandbox IR API is designed to feel like LLVM, replicating many common API classes and functions to mirror the LLVM API.
7
42
The class hierarchy is similar (but in the ` llvm::sandboxir ` namespace).
You can’t perform that action at this time.
0 commit comments