Skip to content

Commit 914e289

Browse files
AFOliveirarootdhower-qc
authored
LLVM verification (#356)
* Add simple Docker environment variable Signed-off-by: Afonso Oliveira <[email protected]> * Fix errors due to incorrect parsing of VM Signed-off-by: Afonso Oliveira <[email protected]> * First Refactor to pytest Signed-off-by: Afonso Oliveira <[email protected]> * Allow 16 bit instructions for C extension Signed-off-by: Afonso Oliveira <[email protected]> * Revert bad parsing Signed-off-by: Afonso Oliveira <[email protected]> * Allow only one value Signed-off-by: Afonso Oliveira <[email protected]> * Use AsmString instead of name Signed-off-by: Afonso Oliveira <[email protected]> * Small Refactor on parsing.py * refactor to do unit tests * refactor to file name * Modify to have seveal Unit tests instead of just one Signed-off-by: Afonso Oliveira <[email protected]> * Clean up and code reorganization Signed-off-by: Afonso Oliveira <[email protected]> * Ensure it is not pseudo Signed-off-by: Afonso Oliveira <[email protected]> * Skip aq/rl instructions Signed-off-by: Afonso Oliveira <[email protected]> * add pytest to requirements Signed-off-by: Afonso Oliveira <[email protected]> * add LLVM path as environment variable Signed-off-by: Afonso Oliveira <[email protected]> * remove and ignor python cache Signed-off-by: Afonso Oliveira <[email protected]> * Add LLVM test to the Rakefile Signed-off-by: Afonso Oliveira <[email protected]> * Optimizations to test logic and modify test order Signed-off-by: Afonso Oliveira <[email protected]> * Add prerequisites syntax Signed-off-by: root <[email protected]> * Fix pre-commit related issues Signed-off-by: root <[email protected]> * Add LLVM tblgen to regress.yaml && change Rakefile for new changes Signed-off-by: Afonso Oliveira <[email protected]> * Fix caching Signed-off-by: Afonso Oliveira <[email protected]> * Fix caching Signed-off-by: Afonso Oliveira <[email protected]> * Fix caching Signed-off-by: Afonso Oliveira <[email protected]> * Add dependencie for smoke test Signed-off-by: Afonso Oliveira <[email protected]> * Change logic for LLVM's path Signed-off-by: Afonso Oliveira <[email protected]> * Change CI logic for LLVM Signed-off-by: Afonso Oliveira <[email protected]> * Add cache and update paths Signed-off-by: Afonso Oliveira <[email protected]> * Add corner case when implementation of LLVM does not need to follow the ISA Spec Signed-off-by: Afonso Oliveira <[email protected]> * Work around for FENCE. ISA and compiler should treat it differently * Set CM instruction length 16 bit instead of 32 * Add LICENSE compliant to UDB native files. Signed-off-by: Afonso Oliveira <[email protected]> --------- Signed-off-by: Afonso Oliveira <[email protected]> Signed-off-by: root <[email protected]> Co-authored-by: root <[email protected]> Co-authored-by: Derek Hower <[email protected]>
1 parent 30a6c41 commit 914e289

File tree

8 files changed

+523
-0
lines changed

8 files changed

+523
-0
lines changed

.github/workflows/regress.yml

100644100755
+60
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,24 @@ jobs:
1717
- uses: actions/setup-python@v5
1818
- uses: pre-commit/[email protected]
1919
regress-smoke:
20+
needs: build-llvm
2021
runs-on: ubuntu-latest
2122
env:
2223
SINGULARITY: 1
2324
steps:
2425
- name: Clone Github Repo Action
2526
uses: actions/checkout@v4
27+
- name: Get current LLVM submodule commit SHA
28+
id: get-llvm-sha
29+
run: echo "LLVM_SHA=$(git ls-tree HEAD ext/llvm-project | awk '{print $3}')" >> $GITHUB_ENV
30+
- name: Restore cache RISC-V JSON
31+
id: cache-riscv
32+
uses: actions/cache@v4
33+
with:
34+
path: ext/llvm-project/riscv.json
35+
key: ${{ runner.os }}-riscv-json-${{ env.LLVM_SHA }}
36+
restore-keys: |
37+
${{ runner.os }}-riscv-json-
2638
- name: singularity setup
2739
uses: ./.github/actions/singularity-setup
2840
- name: Run smoke
@@ -98,6 +110,54 @@ jobs:
98110
uses: ./.github/actions/singularity-setup
99111
- name: Generate extension PDF
100112
run: ./do gen:profile_release_pdf[Mock]
113+
build-llvm:
114+
runs-on: ubuntu-latest
115+
steps:
116+
- name: Check out repository (no submodules, shallow fetch)
117+
uses: actions/checkout@v4
118+
with:
119+
submodules: false
120+
fetch-depth: 1
121+
- name: Get current LLVM submodule commit SHA
122+
id: get-llvm-sha
123+
run: echo "LLVM_SHA=$(git ls-tree HEAD ext/llvm-project | awk '{print $3}')" >> $GITHUB_ENV
124+
- name: Cache RISC-V JSON
125+
id: cache-riscv
126+
uses: actions/cache@v4
127+
with:
128+
path: ext/llvm-project/riscv.json
129+
key: ${{ runner.os }}-riscv-json-${{ env.LLVM_SHA }}
130+
restore-keys: |
131+
${{ runner.os }}-riscv-json-
132+
- name: Initialize LLVM submodule (shallow + sparse)
133+
if: ${{ steps.cache-riscv.outputs.cache-hit != 'true' }}
134+
run: |
135+
git submodule sync --recursive
136+
git submodule update --init --recursive --depth=1 ext/llvm-project
137+
138+
- name: Check for required directories and files
139+
if: ${{ steps.cache-riscv.outputs.cache-hit != 'true' }}
140+
run: |
141+
ls -l ext/llvm-project/llvm/include
142+
ls -l ext/llvm-project/llvm/lib/Target/RISCV
143+
ls -l ext/llvm-project/llvm/lib/Target/RISCV/RISCV.td
144+
- name: Configure and build llvm-tblgen
145+
if: ${{ steps.cache-riscv.outputs.cache-hit != 'true' }}
146+
run: |
147+
cmake -S ext/llvm-project/llvm -B ext/llvm-project/build -DCMAKE_BUILD_TYPE=Release
148+
cmake --build ext/llvm-project/build --target llvm-tblgen
149+
- name: Generate RISC-V JSON
150+
if: ${{ steps.cache-riscv.outputs.cache-hit != 'true' }}
151+
run: |
152+
chmod +x ./ext/llvm-project/build/bin/llvm-tblgen
153+
./ext/llvm-project/build/bin/llvm-tblgen \
154+
-I ext/llvm-project/llvm/include \
155+
-I ext/llvm-project/llvm/lib/Target/RISCV \
156+
ext/llvm-project/llvm/lib/Target/RISCV/RISCV.td \
157+
--dump-json \
158+
-o ext/llvm-project/riscv.json
159+
- name: Show riscv.json output
160+
run: ls -l ext/llvm-project/riscv.json
101161
regress-gen-go:
102162
runs-on: ubuntu-latest
103163
env:

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,8 @@ gen
1616
node_modules
1717
_site
1818
images
19+
__pycache__/
20+
*.pyc
21+
.pytest_cache/
1922
*.bak
2023
*.log

.gitmodules

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
[submodule "ext/riscv-isa-manual"]
88
path = ext/riscv-isa-manual
99
url = https://github.com/riscv/riscv-isa-manual
10+
[submodule "ext/llvm-project"]
11+
path = ext/llvm-project
12+
url = https://github.com/llvm/llvm-project.git
13+
branch = main
1014
[submodule "ext/riscv-tests"]
1115
path = ext/riscv-tests
1216
url = https://github.com/riscv-software-src/riscv-tests.git

Rakefile

+11
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,15 @@ namespace :serve do
157157
end
158158

159159
namespace :test do
160+
161+
# "Run the cross-validation against LLVM"
162+
task :llvm do
163+
begin
164+
sh "#{$root}/.home/.venv/bin/python3 -m pytest ext/auto-inst/test_parsing.py -v"
165+
rescue => e
166+
raise unless e.message.include?("status (5)") # don't fail on skipped tests
167+
end
168+
end
160169
# "Run the IDL compiler test suite"
161170
task :idl_compiler do
162171
t = Minitest::TestTask.new(:lib_test)
@@ -430,6 +439,8 @@ namespace :test do
430439
Rake::Task["test:idl"].invoke
431440
puts "UPDATE: Running test:inst_encodings"
432441
Rake::Task["test:inst_encodings"].invoke
442+
puts "UPDATE: Running test:llvm"
443+
Rake::Task["test:llvm"].invoke
433444
puts "UPDATE: Done test:smoke"
434445
end
435446

0 commit comments

Comments
 (0)