Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
ef816db
Add Simtests: snippetbased and C.
egorshamshura Mar 17, 2026
68701cb
Add tests in workflow.
egorshamshura Mar 17, 2026
a35d675
Add interface functions. Small codegen fix.
egorshamshura Mar 17, 2026
b5fe8cb
Add target dependent file to implement interface functions. Add LLVM …
egorshamshura Mar 17, 2026
747bdbc
Remove redundant whitespaces. Add status message.
egorshamshura Mar 17, 2026
3bacbb1
Added --propagate-exit flag.
egorshamshura Mar 23, 2026
9136e8b
Start to use CTest instead of python-scripts. Add test presets in CMa…
egorshamshura Mar 23, 2026
17b66cb
Add new presets.
egorshamshura Mar 24, 2026
138151c
Describe RV32M
egorshamshura Mar 20, 2026
ec4518e
Decoder fix
egorshamshura Mar 20, 2026
3cb7de3
Small fixes.
egorshamshura Mar 27, 2026
980f2b0
Removed on push in workflow.
egorshamshura Mar 27, 2026
e121a8b
Add small improvements
egorshamshura May 7, 2026
05e7d15
Remove xlen field. Small cmake improvement
egorshamshura May 7, 2026
0069758
fix
egorshamshura May 7, 2026
6f63416
fix
egorshamshura May 7, 2026
1780f52
Add some tests for sim
egorshamshura May 9, 2026
a7411da
Clang-format
egorshamshura May 9, 2026
9b0ace4
Add ctests to run by cached-interp sim
egorshamshura May 9, 2026
74a31d2
Update
egorshamshura May 9, 2026
339a8f5
Fix div by zero handling
egorshamshura May 9, 2026
90a9afc
Fix div by zero handling
egorshamshura May 9, 2026
aaace7b
Add more snippet tests
egorshamshura May 12, 2026
c3b5a35
[lib] Memory ifaces dynamic registry supported
uslsteen Jun 7, 2026
d0c9e2f
[lib] Introduced LIRA Ruby Lib
uslsteen Jun 8, 2026
c1a3654
[lib] LIRA Seriazalization Support
uslsteen Jun 8, 2026
fa564e2
[lib] Decode Snippets serialization caching
uslsteen Jun 8, 2026
86c9cff
[ser] Serialization updated
uslsteen Jun 9, 2026
02e3a46
[sim-gen] Introduced LIRA-Driven Sim Gen
uslsteen Jun 9, 2026
4963bec
[sim-lib] Temporary Stack access update
uslsteen Jun 9, 2026
4e8a4e3
[IR] Added LIRA IR temporary
uslsteen Jun 9, 2026
81efae2
[simgen] Debug PC print
uslsteen Jun 11, 2026
172c0ae
[simgen] Instructions w/ empty body supported
uslsteen Jun 11, 2026
1591c0a
[ser] Sign extension fix
uslsteen Jun 11, 2026
6f00359
[sim-gen] PC debug print removed
uslsteen Jun 11, 2026
6196666
[RV32I] Shift (I type) instructions enc upd
uslsteen Jun 11, 2026
b2542ce
[simlib] Stack Pointer set updated
uslsteen Jun 12, 2026
758483e
[ser] LIRA IR serialization shift fix
uslsteen Jun 12, 2026
8eafc97
[simgen] Removed redundant getter
uslsteen Jun 12, 2026
f4c1c11
[simgen] Base Ops codegen was synced w/ LIRA Ops
uslsteen Jun 12, 2026
1c005cf
[ser] Binary Ops serialization refactoring
uslsteen Jun 13, 2026
1b68dbc
[IR] LIRA IR updated
uslsteen Jun 13, 2026
74a65dd
[ADL, ser] Memory Interface names weere committed on ADL side
uslsteen Jun 15, 2026
0d2add4
[simgen] CPU State codegen was unified
uslsteen Jun 15, 2026
d79e58a
[simgen] CPP types gen refactored
uslsteen Jun 15, 2026
b6826e8
[simgen] Lira Exec Engine & Interpreted codegen refactored
uslsteen Jun 15, 2026
f1e271b
[infra] Sim gen targets were configured
uslsteen Jun 15, 2026
8429a78
LIRA IR updated
uslsteen Jun 15, 2026
f075f02
[ser] Major LIRA serizalier refactoring
uslsteen Jun 15, 2026
e65c78a
[simgen] Cpp Codegen major refactoring
uslsteen Jun 15, 2026
b4d18bd
[lib, sim_gen] Operations register & look up was supported
uslsteen Jun 16, 2026
7026ed8
[lira] Operations added
uslsteen Jun 16, 2026
d2e81cd
[ser] Encode & Decode constraints were supported
uslsteen Jun 16, 2026
ce1a2cd
[simgen] Decode constraints were supported in decoder gen
uslsteen Jun 16, 2026
220c588
[ADL] Introduced Operands List & Mapping
uslsteen Jun 16, 2026
28a8c66
[ser] Operand List & Map sections serialization supported
uslsteen Jun 16, 2026
7b3bff6
[simgen] Decode & Constraint snipptets refactoring
uslsteen Jun 16, 2026
bf73668
LIRA IR updated
uslsteen Jun 16, 2026
4c5d2c1
[ser, simgen] Base Ops caching added into lookup instead of deseriali…
uslsteen Jun 16, 2026
b52fa03
Introduced base operations enum instead of strings
uslsteen Jun 16, 2026
645f19b
Refactored
uslsteen Jun 16, 2026
5e1ba95
Aliases support
uslsteen Jun 16, 2026
740ad7d
[simgen] Redundant arch hash was removed
uslsteen Jun 16, 2026
dda6c26
[infra, simgen] cpu_state.cc removed from the build
uslsteen Jun 16, 2026
3a34185
[simgen] Read Reg statement in decoder is prohibited
uslsteen Jun 16, 2026
5f9a56e
[ADL, simgen] Single :map section is deprecated
uslsteen Jun 16, 2026
c7001d4
[ser] Added Field resolve function
uslsteen Jun 16, 2026
41e86df
[simgen] Introduced decode tree
uslsteen Jun 16, 2026
250f1ad
[ADL, Target] Introduced Operand & OperandBuilder
uslsteen Jun 17, 2026
0dd7802
[infra] Build upd
uslsteen Jun 17, 2026
aaf03f5
LIRA IR updated
uslsteen Jun 17, 2026
88e8d71
[lira] LIRA Library updated
uslsteen Jun 24, 2026
cd97bb7
[IR] LIRA IR removed
uslsteen Jun 24, 2026
6562235
[simgen] Simgen sync w/ LIRA lib update
uslsteen Jun 24, 2026
5622f63
[ser] Fix LIRA encode generation
milkicow Jun 25, 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
2 changes: 2 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
BasedOnStyle: LLVM
18 changes: 8 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: CI

on:
push:
pull_request:

jobs:
Expand All @@ -24,13 +23,15 @@ jobs:
- name: Run clang-format style check
uses: jidicula/clang-format-action@v4.14.0
with:
clang-format-version: '19'
clang-format-version: '20'
check-path: '.'

build:
test:
needs: formatting-check
name: Build
name: Test
runs-on: ubuntu-22.04
container:
image: ghcr.io/egorshamshura/protea-build:latest
strategy:
fail-fast: false
matrix:
Expand All @@ -44,11 +45,8 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.4.8'
bundler-cache: true

- name: Build
run: ci-extra/build.sh "$CMAKE_PRESET"

- name: Run tests
run: ci-extra/test.sh "$CMAKE_PRESET"
17 changes: 16 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,34 @@ cmake_minimum_required(VERSION 3.22 FATAL_ERROR)

project(protea)

set(TARGET_NAME RISCV)

option(PROTEA_BUILD_TESTS
"Enable tests build (requires riscv gnu toolchain)" OFF)

if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set_property(CACHE CMAKE_INSTALL_PREFIX
PROPERTY VALUE "${CMAKE_BINARY_DIR}/install")
endif()

find_package(Ruby 3.4.8 EXACT REQUIRED)
find_package(Ruby 4.0.1 EXACT REQUIRED)
find_package(Python3 3.10 EXACT REQUIRED COMPONENTS Interpreter)
message("Python found: ${Python3_EXECUTABLE}")

include(ExternalProject)
include(cmake/Bundler.cmake)
include(cmake/QEMU.cmake)
include(cmake/CompilerOptions.cmake)
include(cmake/CPM.cmake)
include(cmake/dependencies.cmake)
include(cmake/CompilerConfig.cmake)

if(PROTEA_BUILD_TESTS)
enable_testing()
endif()

add_subdirectory(lib)
add_subdirectory(sim_lib)
add_subdirectory(sim_gen)
add_subdirectory(sim_gen_lira)
add_subdirectory(test)
92 changes: 87 additions & 5 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,119 @@
"configurePresets": [
{
"name": "Base",
"description": "General preset that applies to all configurations",
"hidden": true,
"binaryDir": "${sourceDir}/build/${presetName}"
},
{
"name": "Default-Release",
"description": "Release build",
"inherits": "Base",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "Default-Debug",
"description": "Debug build",
"inherits": "Base",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "Default-RelWithDebInfo",
"inherits": "Base",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "Default-Sanitized",
"inherits": "Base",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"SANITIZED": "ON"
}
},
{
"name": "Default-SanitizedDebug",
"inherits": "Base",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"SANITIZED": "ON"
}
}
],
"buildPresets": [
{
"name": "Default-Release",
"description": "Build Release configuration",
"configurePreset": "Default-Release"
},
{
"name": "Default-Debug",
"description": "Build Debug configuration",
"configurePreset": "Default-Debug"
},
{
"name": "Default-RelWithDebInfo",
"configurePreset": "Default-RelWithDebInfo"
},
{
"name": "Default-Sanitized",
"configurePreset": "Default-Sanitized"
},
{
"name": "Default-SanitizedDebug",
"configurePreset": "Default-SanitizedDebug"
}
],
"testPresets": [
{
"name": "Default-Release",
"configurePreset": "Default-Release",
"execution": {
"jobs": 16
},
"output": {
"outputOnFailure": true
}
},
{
"name": "Default-Debug",
"configurePreset": "Default-Debug",
"execution": {
"jobs": 16
},
"output": {
"outputOnFailure": true
}
},
{
"name": "Default-RelWithDebInfo",
"configurePreset": "Default-RelWithDebInfo",
"execution": {
"jobs": 16
},
"output": {
"outputOnFailure": true
}
},
{
"name": "Default-Sanitized",
"configurePreset": "Default-Sanitized",
"execution": {
"jobs": 16
},
"output": {
"outputOnFailure": true
}
},
{
"name": "Default-SanitizedDebug",
"configurePreset": "Default-SanitizedDebug",
"execution": {
"jobs": 16
},
"output": {
"outputOnFailure": true
}
}
]
}
22 changes: 6 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,13 @@ Protea (named after Proteus, the Greek sea god known for his ability to change s

ProteaIR (Protea Intermediate Representation) doesn't have canonical textual or binary representation. Instead, it is possible to serialize and deserialize it using JSON, YAML, or any other format.

Usage
Building Protea
-----
It is a monorepo managed by [Bundler](https://bundler.io/). To install dependencies, run:

```bash
bundle install
```

So every ruby tool or script can be run using `bundle exec`, for example:

```bash
bundle exec ruby tools/some_tool.rb
cmake -S . -B build -G <generator> [options]
```



Tests
-----


Some common options:
1) -DPROTEA_BUILD_TESTS=BOOL - An option to enable tests. Tests can be run using ctests
2) -DTARGET_NAME_TOOLCHAIN_DIR="..." - A path to target's toolchain dir
3) -DQEMU_PATH="..." - A path to qemu executable
11 changes: 11 additions & 0 deletions ci-extra/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
PRESET_NAME=$1

cmake -S . \
--preset "${PRESET_NAME}" \
-DPROTEA_BUILD_TESTS=true \
-DQEMU_PATH=qemu-riscv32 \
-G Ninja

cmake --build --preset "${PRESET_NAME}" --target simtests --parallel 12

ctest --preset "${PRESET_NAME}"
60 changes: 60 additions & 0 deletions cmake/CompilerConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
option(HARDENED "Should the standard library be hardened" OFF)
option(SANITIZED "Should the build be sanitized" OFF)

function(configure_compiler)
set(isGCC OFF)
set(isClang OFF)

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(isGCC ON)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(isClang ON)
endif()

set(compilerOptions "")
set(compilerDefinitions "")
set(linkerOptions "")

if(isClang)
list(APPEND compilerOptions -stdlib=libc++)
list(APPEND linkerOptions -stdlib=libc++)
message(STATUS "Using libc++ as a standard library")
endif()

if(HARDENED)
if(isGCC)
list(APPEND compilerDefinitions _GLIBCXX_DEBUG)
message(STATUS "Enabled debug mode for libstdc++")
elseif(isClang)
list(APPEND compilerDefinitions _LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG)
message(STATUS "Enabled hardening mode for libc++")
else()
message(STATUS "Hardening is not supported for CXX compiler: '${CMAKE_CXX_COMPILER_ID}'")
endif()
endif()

if(SANITIZED)
if(isGCC OR isClang)
list(APPEND compilerOptions
-fsanitize=undefined,address
-fno-sanitize-recover=all
-fno-optimize-sibling-calls
-fno-omit-frame-pointer
)
list(APPEND linkerOptions
-fsanitize=undefined,address
)
message(STATUS "Enabled UBSan and ASan")
else()
message(WARNING "Sanitized builds are not supported for CXX compiler: '${CMAKE_CXX_COMPILER_ID}'")
endif()
endif()

message(STATUS "Setting global compiler options: ${compilerOptions}")
message(STATUS "Setting global compiler definitions: ${compilerDefinitions}")
message(STATUS "Setting global linker options: ${linkerOptions}")

add_compile_options(${compilerOptions})
add_compile_definitions(${compilerDefinitions})
add_link_options(${linkerOptions})
endfunction()
5 changes: 5 additions & 0 deletions cmake/QEMU.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if (NOT DEFINED QEMU_PATH)
set(QEMU_PATH "qemu")
endif()

message(STATUS "Using QEMU: ${QEMU_PATH}")
28 changes: 28 additions & 0 deletions cmake/discover_generated_tests.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
if(NOT EXISTS "@OUTPUT_TESTS_DIR@")
message(STATUS "Test directory does not exist yet: @OUTPUT_TESTS_DIR@")
return()
endif()

file(GLOB discovered_tests "@OUTPUT_TESTS_DIR@/*")

if(NOT discovered_tests)
message(STATUS "No generated tests found in @OUTPUT_TESTS_DIR@")
endif()

foreach(test_file IN LISTS discovered_tests)
if(IS_DIRECTORY "${test_file}")
continue()
endif()

get_filename_component(test_name "${test_file}" NAME)

add_test(
"@PROJECT_NAME@.${test_name}"
"@GENERATED_SIM_BIN_PATH@" --propagate-exit "${test_file}"
)

add_test(
"@PROJECT_NAME@.cached-interp.${test_name}"
"@GENERATED_SIM_BIN_PATH@" --jit cached-interp --propagate-exit "${test_file}"
)
endforeach()
Loading
Loading