Skip to content

Commit

Permalink
fixup! fixup! [SandboxIR][Doc] Add a Doc file for Sandbox IR
Browse files Browse the repository at this point in the history
  • Loading branch information
vporpo committed Jul 13, 2024
1 parent 1ee7c00 commit b931be8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions llvm/docs/SandboxIR.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Sandbox IR: A transactional layer over LLVM IR

Sandbox IR is an IR layer on top of LLVM IR that allow you to save/restore its state.
Sandbox IR is an IR layer on top of LLVM IR that allows you to save/restore its state.

# API
The Sandbox IR API is designed to feel like LLVM, replicating many common API classes and functions to mirror the LLVM API.
Expand All @@ -21,7 +21,8 @@ namespace sandboxir {

## Sandbox IR Value <-> LLVM IR Value Mapping
Each LLVM IR Value maps to a single Sandbox IR Value.
The reverse is also true in most cases, except for multi-Instruction Sandbox IR Instructions that may be defined in extensions the Sandbox IR.
The reverse is also true in most cases, except for Sandbox IR Instructions that map to more than one LLVM IR Instruction.
Such instructions can be defined in extensions of the base Sandbox IR.


- Forward mapping: Sandbox IR Value -> LLVM IR Value
Expand All @@ -33,7 +34,7 @@ This mapping is stored in `sandboxir::Context::LLVMValueToValue`.
For example `sandboxir::User::getOperand(OpIdx)` for a `sandboxir::User *U` works as follows:
- First we find the LLVM User: `llvm::User * LLVMU = U->Val`.
- Next we get the LLVM Value operand: `llvm::Value *LLVMOp = LLVMU->getOperand(OpIdx)`
- Finally we get the Sandbox IR operand that corresponds to `LLVMOp` by querying the map in the SandboxIR context: `retrun Ctx.getValue(LLVMOp)`.
- Finally we get the Sandbox IR operand that corresponds to `LLVMOp` by querying the map in the Sandbox IR context: `retrun Ctx.getValue(LLVMOp)`.

## Sandbox IR is Write-Through
Sandbox IR is designed to rely on LLVM IR for its state.
Expand Down

0 comments on commit b931be8

Please sign in to comment.