-
Notifications
You must be signed in to change notification settings - Fork 0
Lira Integration #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
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 746c688
[IR] Introduced LIRA Builder
uslsteen ca34ae6
[test] Integration test was updated
uslsteen 92e5c6d
[ser] YAML serialization supported
uslsteen 63a8c60
[test] Integration test updated
uslsteen 8830cd5
[IR] Introduced Ruby LIRA lib
uslsteen e112c92
[test] Integration test added
uslsteen d04219c
[ser] Ruby serialization updated
uslsteen 327a128
[test] Integration test CLI updated
uslsteen 7178cc5
[lib, python3] IR Operations updated
uslsteen f305b19
[lib, ruby] IR Operations updated
uslsteen 6a50b70
[infra] Ruby format config added
uslsteen b954df5
[lib] Register added both
uslsteen e666ec1
[test] Example was updated with Register
uslsteen 2dc5907
[ruby, lib] Ruby lib updated
uslsteen 91fb9b4
[test, ruby] Integration example updated
uslsteen 989ee08
[lib, ruby] Moved Ruby configs into specific directory
uslsteen 6eca5ac
[tools] Added script to provide cross-library check
uslsteen 2013247
[lib, python3] LIRA Library updated
uslsteen 5f8645d
[lib, ruby] LIRA Library updated
uslsteen fa3c67a
[lib, rust] LIRA Library updated
uslsteen 88c2e31
[example, python3] Integration test moved into examples/ as simple ex…
uslsteen d5b22cb
[example, ruby] Integration test moved into examples/ as simple example
uslsteen f33babf
[example, rust] Integration test moved into examples/ as simple example
uslsteen 77f32cc
[lib, examples] Introduced constant mask into LIRA arch specific library
uslsteen da2edcb
[tools] Normalization regexpr applied
uslsteen 5b0db3b
[lib, python] LIRA Library updated
uslsteen 3c598d0
[infra] Reference LIRA IR (truncated RV32I) placed into tests
uslsteen 94fca6c
[tests, python] Added initial LIRA Python tests
uslsteen 4f50505
[tests, python] README updated
uslsteen db818b4
[tests, python] Updated test_ir_ser_txt
uslsteen d7865be
[infra, ruby] Gemfile updated
uslsteen 23d2d67
[lib, ruby] LIRA Library updated
uslsteen 09f770b
[tests, ruby] Added initial LIRA Ruby tests
uslsteen c9329c6
[infra, ruby] Gemfile lock added
uslsteen 3cd9861
[lib, rust] LIRA Library updated
uslsteen 11491aa
[tests, rust] Added initial LIRA Rust tests
uslsteen 4564c50
[infra] .gitignore updated
uslsteen 697f6c2
[infra] Initial CI config
uslsteen 6ade95b
[infra] CI updated
uslsteen 719cc0d
[infra] CMake was supported
uslsteen 6488b00
[infra] .gitignore updated
uslsteen 4380d5b
[infra] Python installation infra added
uslsteen 93b8cfd
[infra] Ruby installation infra added
uslsteen c841475
Installation manual added into README
uslsteen 764288c
Updated README
uslsteen 1560443
[infra] Cross-library tests added
uslsteen 78a0c4f
CI Fix
uslsteen 6bce4ff
[lib,tests,rust] Major changes
uslsteen 0c517d9
[infra] CI Updated
uslsteen 36bbedc
Refactoring
uslsteen 16da1b9
[lib, tests, rust] Code formatter applied
uslsteen f3fae13
[lib, python] Redundant functionality removed
uslsteen 058587c
[python] Added missed __init__.py in the root
uslsteen fe0a513
[lib, tests, python] Import path
uslsteen 02f6c1d
[tests,python] Relative import fixed
uslsteen 1043e61
[lib, python] Unused format enum removed
uslsteen b76a4d1
[lib, ruby] Redundant functionality removed
uslsteen 07c6aee
[lib, ruby] Unused format enum removed
uslsteen 1d915ea
Bug improt was deleted
uslsteen 6667b80
[tests, python] Crosslib test outside the pylib
uslsteen ac9acb5
[lib, ruby] Concat/Extract/Ensure width is deprecated
uslsteen 279878b
[ir_builder] Cache_op refactoring
uslsteen cd848b0
[lib, python] Concat/Extract/Ensure width is deprecated
uslsteen 4330633
[tests] Unit tests updated with deprecated methods
uslsteen a15098d
[infra] Description updated
uslsteen 23d974d
Removed CMake
uslsteen 03e1ea9
[infra] Basic operations description updated
uslsteen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| 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 | ||
|
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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,6 @@ | ||
| __pycache__ | ||
| target | ||
|
|
||
| *coverage | ||
|
|
||
| build/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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))` |
This file was deleted.
Oops, something went wrong.
Empty file.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.