# jbezoz/slva architecture

> Architecture diagram of the GitHub repository jbezoz/slva, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jbezoz/slva
- Repository: https://github.com/jbezoz/slva

## Overview

#### Purpose and Entry Points
SLVA implements Strong Live Variable Analysis over a custom intermediate representation, with LLVM-like `.ll` inputs and a sample consumer. The top-level execution entry is `run.sh`; the analysis/library build is centered on `slim-ir/CMakeLists.txt`, while the executable driver is in `slim-use/main.cpp`.

#### Analysis IR Layer
The custom SLIM IR defines the program model used by the analysis:
- IR/container structures: `slim-ir/include/IR.h`, `slim-ir/IR.cpp`
- Instruction hierarchy: `slim-ir/include/Instructions.h`, `slim-ir/Instructions.cpp`
- Operand/value representation: `slim-ir/include/Operand.h`, `slim-ir/Operand.cpp`

This separation establishes the key boundary between parsed/source-level input and analysis-ready control-flow/instruction data.

#### Instruction and Operand Semantics
`Instructions` and `Operand` encode use/definition behavior needed for live-variable propagation. Instruction-specific handling belongs in `slim-ir/Instructions.cpp`; operand identity and categorization belong in `slim-ir/Operand.cpp`. The analysis should consume these abstractions rather than depend directly on textual LLVM IR.

#### Driver and Integration Layer
`slim-use/main.cpp` is the primary application-level entry point that exercises the IR library and runs the analysis workflow. `slim-use/CMakeLists.txt` links/builds this consumer separately from the IR library, making `slim-ir` a reusable analysis substrate and `slim-use` the executable integration boundary.

#### Input Pipeline and Artifacts
The repository includes C source, LLVM IR, and SLIM-oriented IR examples:
- Source input: `slim-use/testcases/test.c`
- LLVM-style input: `slim-use/testcases/test.ll`
- SLIM IR artifact: `slim-use/testcases/test.slim.ll`

The expected flow is source/LLVM-like input → SLIM IR representation → instruction/operand use-def interpretation → strong live-variable results. The exact parsing or translation mechanism is not explicit in the visible tree.

#### Build and Runtime Environment
The core runtime is native C++ built with CMake:
- Library build definition: `slim-ir/CMakeLists.txt`
- Consumer build definition: `slim-use/CMakeLists.txt`
- Library runner: `slim-ir/run_ir_lib.sh`
- Consumer runners: `slim-use/run.sh`, `slim-use/run2.sh`

Ruby appears to support experimentation or reference logic rather than the main runtime: `pseudo_code.rb`, `slim-use/temp.rb`, and `slim-use/temp2.rb`. No network services, databases, web framework, or deployed infrastructure are indicated.

#### Key Architectural Boundaries
1. **Build orchestration vs. analysis code:** `run.sh` and CMake files invoke/build components; they should not contain analysis semantics.
2. **Reusable IR library vs. executable use case:** `slim-ir/` owns IR abstractions; `slim-use/` owns demonstration/input execution.
3. **Textual test fixtures vs. internal model:** `.c`/`.ll` files are external artifacts, while `IR`, `Instructions`, and `Operand` are the stable in-memory analysis contract.

Main entry points: [`slim-ir/CMakeLists.txt`](https://github.com/jbezoz/slva/blob/master/slim-ir/CMakeLists.txt) (IR library build), [`slim-use/main.cpp`](https://github.com/jbezoz/slva/blob/master/slim-use/main.cpp) (SLVA driver), [`slim-ir/Instructions.cpp`](https://github.com/jbezoz/slva/blob/master/slim-ir/Instructions.cpp) (Instruction semantics), [`slim-ir/IR.cpp`](https://github.com/jbezoz/slva/blob/master/slim-ir/IR.cpp) (IR containers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_build["Build &amp; runners"]
  node_root_runner["Top-level runner<br/>shell entry point<br/>[run.sh]"]
  node_ir_cmake["IR library build<br/>CMake target<br/>[CMakeLists.txt]"]
  node_ir_runner["IR library runner<br/>shell runner<br/>[run_ir_lib.sh]"]
  node_consumer_cmake["Consumer build<br/>CMake target<br/>[CMakeLists.txt]"]
  node_consumer_runner["Consumer runners<br/>shell runners<br/>[run.sh]"]
end

subgraph group_ir["SLIM IR library"]
  node_ir_model{{"IR containers<br/>program model<br/>[IR.cpp]"}}
  node_ir_api["IR API<br/>C++ header<br/>[IR.h]"]
  node_instructions{{"Instruction semantics<br/>use-def semantics<br/>[Instructions.cpp]"}}
  node_instruction_api["Instruction API<br/>C++ header<br/>[Instructions.h]"]
  node_operands{{"Operand semantics<br/>value model<br/>[Operand.cpp]"}}
  node_operand_api["Operand API<br/>C++ header<br/>[Operand.h]"]
end

subgraph group_consumer["Analysis consumer"]
  node_driver["SLVA driver<br/>C++ executable<br/>[main.cpp]"]
  node_live_results["Strong live variables<br/>analysis result"]
end

subgraph group_fixtures["Input fixtures"]
  node_c_input["C source fixture<br/>source input<br/>[test.c]"]
  node_llvm_input["LLVM-style fixture<br/>textual IR input<br/>[test.ll]"]
  node_slim_input["SLIM IR fixture<br/>textual IR artifact<br/>[test.slim.ll]"]
end

node_root_runner -->|"invokes"| node_ir_runner
node_root_runner -->|"invokes"| node_consumer_runner
node_ir_runner -->|"builds"| node_ir_cmake
node_consumer_runner -->|"builds"| node_consumer_cmake
node_ir_cmake -->|"compiles"| node_ir_model
node_ir_cmake -->|"compiles"| node_instructions
node_ir_cmake -->|"compiles"| node_operands
node_consumer_cmake -->|"builds"| node_driver
node_consumer_cmake -->|"links library"| node_ir_cmake
node_ir_api -->|"declares"| node_ir_model
node_instruction_api -->|"declares"| node_instructions
node_operand_api -->|"declares"| node_operands
node_ir_model -->|"contains"| node_instructions
node_instructions -->|"interprets use-def"| node_operands
node_c_input -.->|"source counterpart"| node_llvm_input
node_llvm_input -.->|"represented as"| node_slim_input
node_slim_input -->|"analysis input"| node_driver
node_driver -->|"uses"| node_ir_model
node_driver -->|"propagates liveness through"| node_instructions
node_driver -->|"produces"| node_live_results

click node_root_runner "https://github.com/jbezoz/slva/blob/master/run.sh"
click node_ir_cmake "https://github.com/jbezoz/slva/blob/master/slim-ir/CMakeLists.txt"
click node_ir_runner "https://github.com/jbezoz/slva/blob/master/slim-ir/run_ir_lib.sh"
click node_consumer_cmake "https://github.com/jbezoz/slva/blob/master/slim-use/CMakeLists.txt"
click node_consumer_runner "https://github.com/jbezoz/slva/blob/master/slim-use/run.sh"
click node_ir_model "https://github.com/jbezoz/slva/blob/master/slim-ir/IR.cpp"
click node_ir_api "https://github.com/jbezoz/slva/blob/master/slim-ir/include/IR.h"
click node_instructions "https://github.com/jbezoz/slva/blob/master/slim-ir/Instructions.cpp"
click node_instruction_api "https://github.com/jbezoz/slva/blob/master/slim-ir/include/Instructions.h"
click node_operands "https://github.com/jbezoz/slva/blob/master/slim-ir/Operand.cpp"
click node_operand_api "https://github.com/jbezoz/slva/blob/master/slim-ir/include/Operand.h"
click node_driver "https://github.com/jbezoz/slva/blob/master/slim-use/main.cpp"
click node_c_input "https://github.com/jbezoz/slva/blob/master/slim-use/testcases/test.c"
click node_llvm_input "https://github.com/jbezoz/slva/blob/master/slim-use/testcases/test.ll"
click node_slim_input "https://github.com/jbezoz/slva/blob/master/slim-use/testcases/test.slim.ll"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_root_runner,node_ir_cmake,node_ir_runner,node_consumer_cmake,node_consumer_runner toneBlue
class node_ir_model,node_ir_api,node_instructions,node_instruction_api,node_operands,node_operand_api toneAmber
class node_driver,node_live_results toneMint
class node_c_input,node_llvm_input,node_slim_input toneRose
```

## Components

### Build & runners

- [Top-level runner](https://github.com/jbezoz/slva/blob/master/run.sh): shell entry point · `run.sh`
- [IR library build](https://github.com/jbezoz/slva/blob/master/slim-ir/CMakeLists.txt): CMake target · `slim-ir/CMakeLists.txt`
- [IR library runner](https://github.com/jbezoz/slva/blob/master/slim-ir/run_ir_lib.sh): shell runner · `slim-ir/run_ir_lib.sh`
- [Consumer build](https://github.com/jbezoz/slva/blob/master/slim-use/CMakeLists.txt): CMake target · `slim-use/CMakeLists.txt`
- [Consumer runners](https://github.com/jbezoz/slva/blob/master/slim-use/run.sh): shell runners · `slim-use/run.sh`

### SLIM IR library

Reusable in-memory program model and use-def semantics.

- [IR containers](https://github.com/jbezoz/slva/blob/master/slim-ir/IR.cpp): program model · Owns analysis-ready program and control-flow structures. · `slim-ir/IR.cpp`
- [IR API](https://github.com/jbezoz/slva/blob/master/slim-ir/include/IR.h): C++ header · `slim-ir/include/IR.h`
- [Instruction semantics](https://github.com/jbezoz/slva/blob/master/slim-ir/Instructions.cpp): use-def semantics · Instruction-specific use and definition behavior. · `slim-ir/Instructions.cpp`
- [Instruction API](https://github.com/jbezoz/slva/blob/master/slim-ir/include/Instructions.h): C++ header · `slim-ir/include/Instructions.h`
- [Operand semantics](https://github.com/jbezoz/slva/blob/master/slim-ir/Operand.cpp): value model · Defines operand identity and categorization. · `slim-ir/Operand.cpp`
- [Operand API](https://github.com/jbezoz/slva/blob/master/slim-ir/include/Operand.h): C++ header · `slim-ir/include/Operand.h`

### Analysis consumer

- [SLVA driver](https://github.com/jbezoz/slva/blob/master/slim-use/main.cpp): C++ executable · Exercises the IR library and runs strong live-variable analysis. · `slim-use/main.cpp`
- **Strong live variables**: analysis result

### Input fixtures

- [C source fixture](https://github.com/jbezoz/slva/blob/master/slim-use/testcases/test.c): source input · `slim-use/testcases/test.c`
- [LLVM-style fixture](https://github.com/jbezoz/slva/blob/master/slim-use/testcases/test.ll): textual IR input · `slim-use/testcases/test.ll`
- [SLIM IR fixture](https://github.com/jbezoz/slva/blob/master/slim-use/testcases/test.slim.ll): textual IR artifact · `slim-use/testcases/test.slim.ll`

## Connections

- Top-level runner → IR library runner: invokes
- Top-level runner → Consumer runners: invokes
- IR library runner → IR library build: builds
- Consumer runners → Consumer build: builds
- IR library build → IR containers: compiles
- IR library build → Instruction semantics: compiles
- IR library build → Operand semantics: compiles
- Consumer build → SLVA driver: builds
- Consumer build → IR library build: links library
- IR API → IR containers: declares
- Instruction API → Instruction semantics: declares
- Operand API → Operand semantics: declares
- IR containers → Instruction semantics: contains
- Instruction semantics → Operand semantics: interprets use-def
- C source fixture → LLVM-style fixture: source counterpart
- LLVM-style fixture → SLIM IR fixture: represented as · Translation mechanism is not explicit.
- SLIM IR fixture → SLVA driver: analysis input
- SLVA driver → IR containers: uses
- SLVA driver → Instruction semantics: propagates liveness through
- SLVA driver → Strong live variables: produces
