Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
f5fba2d
[IR] Introduced Standard Operations
uslsteen Jun 4, 2026
746c688
[IR] Introduced LIRA Builder
uslsteen Jun 4, 2026
ca34ae6
[test] Integration test was updated
uslsteen Jun 4, 2026
92e5c6d
[ser] YAML serialization supported
uslsteen Jun 4, 2026
63a8c60
[test] Integration test updated
uslsteen Jun 4, 2026
8830cd5
[IR] Introduced Ruby LIRA lib
uslsteen Jun 6, 2026
e112c92
[test] Integration test added
uslsteen Jun 6, 2026
d04219c
[ser] Ruby serialization updated
uslsteen Jun 6, 2026
327a128
[test] Integration test CLI updated
uslsteen Jun 6, 2026
7178cc5
[lib, python3] IR Operations updated
uslsteen Jun 7, 2026
f305b19
[lib, ruby] IR Operations updated
uslsteen Jun 7, 2026
6a50b70
[infra] Ruby format config added
uslsteen Jun 7, 2026
b954df5
[lib] Register added both
uslsteen Jun 8, 2026
e666ec1
[test] Example was updated with Register
uslsteen Jun 8, 2026
2dc5907
[ruby, lib] Ruby lib updated
uslsteen Jun 17, 2026
91fb9b4
[test, ruby] Integration example updated
uslsteen Jun 17, 2026
989ee08
[lib, ruby] Moved Ruby configs into specific directory
uslsteen Jun 17, 2026
6eca5ac
[tools] Added script to provide cross-library check
uslsteen Jun 17, 2026
2013247
[lib, python3] LIRA Library updated
uslsteen Jun 17, 2026
5f8645d
[lib, ruby] LIRA Library updated
uslsteen Jun 17, 2026
fa3c67a
[lib, rust] LIRA Library updated
uslsteen Jun 17, 2026
88c2e31
[example, python3] Integration test moved into examples/ as simple ex…
uslsteen Jun 17, 2026
d5b22cb
[example, ruby] Integration test moved into examples/ as simple example
uslsteen Jun 17, 2026
f33babf
[example, rust] Integration test moved into examples/ as simple example
uslsteen Jun 17, 2026
77f32cc
[lib, examples] Introduced constant mask into LIRA arch specific library
uslsteen Jun 17, 2026
da2edcb
[tools] Normalization regexpr applied
uslsteen Jun 17, 2026
5b0db3b
[lib, python] LIRA Library updated
uslsteen Jun 17, 2026
3c598d0
[infra] Reference LIRA IR (truncated RV32I) placed into tests
uslsteen Jun 17, 2026
94fca6c
[tests, python] Added initial LIRA Python tests
uslsteen Jun 17, 2026
4f50505
[tests, python] README updated
uslsteen Jun 17, 2026
db818b4
[tests, python] Updated test_ir_ser_txt
uslsteen Jun 17, 2026
d7865be
[infra, ruby] Gemfile updated
uslsteen Jun 17, 2026
23d2d67
[lib, ruby] LIRA Library updated
uslsteen Jun 17, 2026
09f770b
[tests, ruby] Added initial LIRA Ruby tests
uslsteen Jun 17, 2026
c9329c6
[infra, ruby] Gemfile lock added
uslsteen Jun 17, 2026
3cd9861
[lib, rust] LIRA Library updated
uslsteen Jun 17, 2026
11491aa
[tests, rust] Added initial LIRA Rust tests
uslsteen Jun 17, 2026
4564c50
[infra] .gitignore updated
uslsteen Jun 17, 2026
697f6c2
[infra] Initial CI config
uslsteen Jun 17, 2026
6ade95b
[infra] CI updated
uslsteen Jun 17, 2026
719cc0d
[infra] CMake was supported
uslsteen Jun 18, 2026
6488b00
[infra] .gitignore updated
uslsteen Jun 18, 2026
4380d5b
[infra] Python installation infra added
uslsteen Jun 18, 2026
93b8cfd
[infra] Ruby installation infra added
uslsteen Jun 18, 2026
c841475
Installation manual added into README
uslsteen Jun 18, 2026
764288c
Updated README
uslsteen Jun 18, 2026
1560443
[infra] Cross-library tests added
uslsteen Jun 18, 2026
78a0c4f
CI Fix
uslsteen Jun 18, 2026
6bce4ff
[lib,tests,rust] Major changes
uslsteen Jun 19, 2026
0c517d9
[infra] CI Updated
uslsteen Jun 19, 2026
36bbedc
Refactoring
uslsteen Jun 19, 2026
16da1b9
[lib, tests, rust] Code formatter applied
uslsteen Jun 19, 2026
f3fae13
[lib, python] Redundant functionality removed
uslsteen Jun 19, 2026
058587c
[python] Added missed __init__.py in the root
uslsteen Jun 19, 2026
fe0a513
[lib, tests, python] Import path
uslsteen Jun 19, 2026
02f6c1d
[tests,python] Relative import fixed
uslsteen Jun 19, 2026
1043e61
[lib, python] Unused format enum removed
uslsteen Jun 19, 2026
b76a4d1
[lib, ruby] Redundant functionality removed
uslsteen Jun 19, 2026
07c6aee
[lib, ruby] Unused format enum removed
uslsteen Jun 19, 2026
1d915ea
Bug improt was deleted
uslsteen Jun 19, 2026
6667b80
[tests, python] Crosslib test outside the pylib
uslsteen Jun 19, 2026
ac9acb5
[lib, ruby] Concat/Extract/Ensure width is deprecated
uslsteen Jun 19, 2026
279878b
[ir_builder] Cache_op refactoring
uslsteen Jun 19, 2026
cd848b0
[lib, python] Concat/Extract/Ensure width is deprecated
uslsteen Jun 19, 2026
4330633
[tests] Unit tests updated with deprecated methods
uslsteen Jun 19, 2026
a15098d
[infra] Description updated
uslsteen Jun 22, 2026
23d974d
Removed CMake
uslsteen Jun 22, 2026
03e1ea9
[infra] Basic operations description updated
uslsteen Jun 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: LIRA CI

on:
push:
branches: [master]
pull_request:

jobs:
python-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- run: pip install ruamel.yaml pytest pytest-cov
- name: Unit tests
run: pytest python/tests/unit/ -v
- name: Unit coverage
Comment thread
uslsteen marked this conversation as resolved.
run: pytest --cov=python/lira python/tests/unit/ --cov-report=term
- name: Integration tests
run: pytest python/tests/integration/ -v
- name: Diff integration output vs reference
run: diff python/tests/integration/integration.yaml tests/integration/reference.yaml

ruby-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- run: pip install ruamel.yaml
- run: gem install minitest simplecov
- name: Unit tests
run: |
ruby -I ruby -I ruby/lib ruby/tests/unit/test_ir_ser_txt.rb
ruby -I ruby -I ruby/lib ruby/tests/unit/test_arch_ser_yaml.rb
ruby -I ruby -I ruby/lib ruby/tests/unit/test_ir_builder.rb
- name: Unit coverage
run: |
ruby -r simplecov -I ruby -I ruby/lib -e 'SimpleCov.start; Dir["ruby/tests/unit/*.rb"].each { |f| require_relative f }'
- name: Integration tests
run: ruby -I ruby -I ruby/lib ruby/tests/integration/test_integration.rb
- name: Diff integration output vs reference
run: diff ruby/tests/integration/integration.yaml tests/integration/reference.yaml

rust-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- run: pip install ruamel.yaml
Comment thread
uslsteen marked this conversation as resolved.
- name: Integration tests
run: cd rust && cargo test -p lira-tests --test integration
- name: Diff integration output vs reference
run: diff rust/tests/integration/integration.yaml tests/integration/reference.yaml

cross-language:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
- uses: dtolnay/rust-toolchain@stable
- run: pip install ruamel.yaml pytest
- run: gem install minitest

- name: Python writes native YAML
run: pytest tests/cross_language/test_cross.py -k "write" -v
- name: Ruby writes native YAML
run: ruby -I ruby -I ruby/lib tests/cross_language/test_cross.rb --name test_ruby_write_and_self_read
- name: Rust writes native YAML
run: cd rust && cargo test -p lira-tests --test cross_language test_rust_write_and_self_read

- name: Python reads Ruby and Rust
run: pytest tests/cross_language/test_cross.py -k "reads" -v
- name: Ruby reads Python and Rust
run: ruby -I ruby -I ruby/lib tests/cross_language/test_cross.rb --name '/test_ruby_reads/'
- name: Rust reads Python and Ruby
run: cd rust && cargo test -p lira-tests --test cross_language test_rust_reads
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
__pycache__
target

*coverage

build/
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# LIRA

LIRA is a framework that provides a data-flow Intermediate Representation.

**Libraries:**
- [python/lira](python/lira) — Python 3 library
- [ruby/lira](ruby/lira) — Ruby library
- [rust/lira](rust/lira) — Rust library

## Install

- Python (pip):
```bash
pip install -e python/
```

- Ruby (gem)
```bash
gem build ruby/lira.gemspec && gem install lira-*.gem
# or via Gemfile:
# gem "lira", path: "ruby"
```
- Rust (Cargo)
```bash
cargo add --path rust/lira
```

## Examples

- [Python 3 examples](python/examples)
- [Ruby examples](ruby/examples)
- [Rust examples](rust/examples)
113 changes: 113 additions & 0 deletions docs/ir_ops.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Basic operations

All basic LIRA operations are inherited from the standard operation from the lira/arch module.

Below is an implementation of a standard operation in [python](../python/lira/arch.py):

```python3
@dataclass
class Operation(Component):
inputs: list[int]
outputs: list[int]
semantic_base: Optional[str] = None
semantic_func: Optional[str] = None
semantic_func_128: Optional[str] = None
semantic_table: Optional[str] = None
```

# Types

In general, base operations work on bit-vector (BV) values.

Note: `BV<1>` is used instead of `Bool`.

# Name Conventions

Operations are grouped by operand signature.
The `name` field follows the specific pattern.

## Unary

`BV<n> -> BV<n>` - `<semnatic_base>_<n>`

| Operation | Description |
|-----------|-------------|
| `not` | bitwise NOT |
| `neg` | two's complement negation |
| `popcnt` | population count (number of set bits) |
| `ctz` | count trailing zeros |
| `clz` | count leading zeros |
| `reverse` | reverse bit order |

## Binary

`BV<n> BV<n> -> BV<n>` – `<semnatic_base>_<n>`

| Operation | Description |
|-----------|-------------|
| `add` | addition |
| `sub` | subtraction |
| `mul` | multiplication |
| `and` | bitwise AND |
| `orr` | bitwise OR |
| `xor` | bitwise XOR |
| `lsl` | logical shift left |
| `lsr` | logical shift right |
| `asr` | arithmetic shift right |
| `rem_u` | unsigned remainder (`rem(a,0)=a`) |
| `rem_s` | signed remainder (`rem(a,0)=a`) |
| `ror` | rotate right |
| `rol` | rotate left |

## Comparison

`BV<n> BV<n> -> BV<1>` - `<semnatic_base>_<n>`

| Operation | Description |
|-----------|-------------|
| `eq` | equality |x
| `ne` | not equal |
| `slt` | signed less than |
| `sle` | signed less or equal |
| `sgt` | signed greater than |
| `sge` | signed greater or equal |
| `ult` | unsigned less than |
| `ule` | unsigned less or equal |
| `ugt` | unsigned greater than |
| `uge` | unsigned greater or equal |
| `add_overflow` | signed addition overflow |
| `sub_overflow` | signed subtraction overflow |

## Ternary

`BV<n> BV<n> BV<n> -> BV<n>` - `<semnatic_base>_<n>`

| Operation | Description |
|-----------|-------------|
| `div_u` | unsigned division: `div(a,b,c) = b != 0 ? a/b : c` |
| `div_s` | signed division: `div(a,b,c) = b != 0 ? a/b : c` |

## Select

`BV<1> BV<n> BV<n> -> BV<n>` - `<semnatic_base>_<n>`

| Operation | Description |
|-----------|-------------|
| `select` | multiplexer: `select(cond, true, false)` |

## Cast

`BV<in> -> BV<out>` - `<semnatic_base>_<in>_to_<out>`

| Operation | Description |
|-----------|-------------|
| `extract_low` | extract low bits (`out` <= `in`) |
| `extend_sign` | sign-extend (`out` > `in`) |
| `extend_zero` | zero-extend (`out` > `in`) |

## Derivatives

Some compound operations are derived from the standard set and need semantic definitions in the LIRA architecture:

- `extract(v, start, width)` = `extract_low(lsr(v, start), width)`
- `concat(low, high)` = `orr(extend_zero(low, high_bits + low_bits), lsl(extend_zero(high, high_bits + low_bits), low_bits))`
61 changes: 0 additions & 61 deletions docs/ops_std.md

This file was deleted.

Empty file added python/__init__.py
Empty file.
Loading
Loading