-
Notifications
You must be signed in to change notification settings - Fork 56
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
Initial support for RISC-V 32 I M #781
Open
clebreto
wants to merge
121
commits into
main
Choose a base branch
from
risc-v
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
121 commits
Select commit
Hold shift + click to select a range
0be66c6
Add dependencies to build vscoq-language-server (temp fix).
rtetley edd3b75
Provides RISCV initial architecture description and first instruction…
clebreto bfafb60
Adds SUB, AND, MV
eponier 881bfc8
Adds LOAD and STORE
eponier 121aad6
Refactor cond
eponier 65371a0
Add XOR and OR to compiler/riscv_instr_decl.v (#747)
zeri42 35faf94
Adds the very minimal bits for dummy compilation.
clebreto 602bee6
WIP : bug-499.
clebreto 8055c6d
Adds li to implement more functionalities.
clebreto 254fd06
Merge pull request #754 from jasmin-lang/riscv-compiler-skeleton
eponier 218dc38
Merge branch 'main' into risc-v
eponier b0b4453
Adds XOR lowering.
clebreto 3a80c10
Fix adressing assembly syntax.
clebreto f9fc5db
Intrepret "subi" as ADDI.
clebreto 9778be6
Factorize instructions by encodings.
clebreto 7a00b90
Adds swap and subi as extra ops.
clebreto 84b5d1b
Condition lowering implementation.
clebreto 12e88bc
Provides JAL instruction to match calling convention
clebreto 9309743
Provides tests for branching conditions.
clebreto 2f9c8c8
Hack to compare with imm.
clebreto ff7977e
X1 -> X2
eponier 33f5b14
X1 -> X2 again
eponier 50e48b8
Push and pop ok
eponier 6f1cc0e
assemble_cond: correctly detects 0
eponier 6d84586
Fixes program crash
eponier 8e2aa91
Allows to execute at least once each test.
clebreto 922c98c
Merge branch 'main' into risc-v
eponier ff82fa2
Check execution of tests.
clebreto 7de90ac
Adds MUL MULH instructions declaration.
clebreto 51d9f0b
Fix typo.
clebreto 1ccb0de
Continues to add multiplication ops.
clebreto dd28d82
Lower multiplication.
clebreto 4e65069
Polishing
eponier 9d82cc5
The cheatsheet is lying!
eponier 542c92c
Proofs skeleton with Admitted.
rtetley e39523e
Change condt_not signature for proofs.
clebreto 5fd0df7
Finalize previous commit.
clebreto 263e6ce
WIP on params_proof
rtetley 16fed13
Correctly zeroing the 2 lest significant bits.
clebreto b23ec40
Adapt printing of functions enclosed in namespaces.
clebreto 19104e8
Merge branch 'main' into risc-v
eponier d53c71c
Escape globals and push (really needed ?).
clebreto fdeadb3
WIP params_proof
rtetley e5702f8
WIP riscv_params_proof
rtetley 548ebde
Provides SLL and SLI.
clebreto 3b5d937
Prove assemble_extra_op.
rtetley aff3b23
Adds NOT and NEG pseudo ops.
clebreto 14428bb
Proove params_core_proof
rtetley 37df6af
Proove params common proof
rtetley 7f1799d
Adds support for signed / unsigned load.
clebreto 5763849
Add srl, srli, and a first compiling risc-v version of gimli
sopmacF 4f07a3d
WIP lowering proofs.
clebreto 2ed57bc
WIP Proof lowering.
rtetley ec1f95d
Renames commonly used registers.
clebreto 54ccb4f
Provides stack zeroization.
clebreto 86f3f92
Advance on stackzero proof.
clebreto 7f75d53
Advance again on stackzero.
clebreto a8d17b5
WIP proof lowering
rtetley 729e5a7
Don't use callee saved register.
clebreto 6b6561d
Admit remaining stack zero proofs.
clebreto ed2bf10
Fix shift declaration and proof.
clebreto fabe78d
Lowering proof done.
rtetley b5de339
Stack zeroization proof.
rtetley a06b9d9
Cleaning
eponier e249081
Gimli: fix and move to examples
eponier 505b4c2
Lowering: factorize reasoning on op2
eponier 538c494
Lowering: accept more left shifts
eponier 846b1a5
assemble_cond: cleaning & more compact proof
eponier b466cd5
Merge branch 'main' into risc-v
eponier 9464d24
Merge remote-tracking branch 'upstream/main' into risc-v
eponier 8df3761
Merge remote-tracking branch 'upstream/main' into risc-v
eponier 3371cb3
Merge remote-tracking branch 'upstream/main' into risc-v
eponier 59b3b1d
Merge branch 'main' into risc-v
clebreto c11b63d
doit hack
clebreto 7ecbdeb
Merge branch 'main' into risc-v
eponier 79879e7
Merge branch 'main' into risc-v
eponier 5017d5f
Proper asm "call" for syscalls
eponier 3a85822
Adds some tests.
clebreto 082668b
Fix sub test ...
clebreto 427a733
Prove decide_op_reg_imm.
clebreto 6dbfd66
Use is_arith_small_neg for sub
clebreto 8e87601
Fixing and polishing
eponier 28da830
Removes unused variable.
clebreto 44640b4
Adds some Omul and lower_mulu tests.
clebreto e2b99d0
Fix load printing.
clebreto eee54f8
Better error message
clebreto df758a9
WIP large stack
clebreto 02174a6
printing
eponier cca80c3
multiple fixes
eponier f0667d0
Adds load and fix test.
clebreto 6313772
Adds sra instruction and associated proof.
clebreto c20b1a9
FIX typo.
clebreto 4545b4a
Adds shift basic tests.
clebreto 914d965
Template test files must be .jinc (again)
eponier 7ce49f6
Use an env var for assembly checker on risc-v
eponier 26fe70b
Prove riscv_lower_addressing
eponier 03dab30
Fix macos / linux assembly checker option handling
clebreto 11d9268
Use jasmin shift semantic properly.
clebreto 013919d
Introduce smart_addi to stack alloc as done
clebreto a2473d9
Moves subi from ext op to lowering.
clebreto df36861
End of the proofs
eponier 31cd7b2
Merge pull request #868 from jasmin-lang/789-risc-v-test-every-instru…
clebreto 72d4742
Clear out unused Lemma.
clebreto 7212a26
FIXME -> TODO.
clebreto 1b6f96f
x28 x29 are FP temporaries -> OK
clebreto 2296f15
FIXME -> Comment
clebreto 9ddd343
Fix typo.
clebreto 9008aad
Remove comment
clebreto eba00c4
move write_lval_eq to psem_facts.
clebreto 582b3ca
Call pass LowerAddressing also in OCaml
eponier 7a14e76
Add RA to the list of callee_saved registers.
clebreto b74ebeb
Merge branch 'main' into risc-v
bgregoir f286134
adapte 4fc6626e82abf81afe315e1f7344889678f48a00 to risc-v
bgregoir c1036d6
Merge branch 'main' into risc-v
eponier 3a2c8bc
Risc v constants if while (#934)
bgregoir fd5e550
Revert "Add RA to the list of callee_saved registers."
eponier d03e378
RISC-V: proper management of the return address
eponier 14e0e9a
Provides SLT, SLTI, SLTU, SLTIU for RISC-V.
clebreto 3af7bbd
Provides extraction to EC.
clebreto f668724
Merge branch 'main' into risc-v
bgregoir 984590c
Merge branch 'risc-v' of github.com:jasmin-lang/jasmin into risc-v
bgregoir 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 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,83 @@ | ||
param int N_ROUND = 24; | ||
param int N_COLUMN = 4; | ||
param int ROUND_CONSTANT = 0x9e377900; | ||
|
||
inline | ||
fn swap(reg ptr u32[12] state, inline int i, inline int j) -> reg ptr u32[12] { | ||
reg u32 x y; | ||
|
||
x = state[i]; | ||
y = state[j]; | ||
state[i] = y; | ||
state[j] = x; | ||
|
||
return state; | ||
} | ||
|
||
inline fn ror32(reg u32 in, inline int cnt) -> reg u32 { | ||
reg u32 u l ret; | ||
u = in << cnt; | ||
l = in >> (32 - cnt); | ||
ret = u | l; | ||
return ret; | ||
} | ||
|
||
export | ||
fn gimli(reg ptr u32[12] state) -> reg ptr u32[12] { | ||
inline int round, column; | ||
reg u32 x, y, z; | ||
reg u32 a, b; | ||
reg u32 rc; | ||
reg u32 tmp; | ||
|
||
rc = ROUND_CONSTANT; | ||
|
||
for round = N_ROUND downto 0 { | ||
for column = 0 to N_COLUMN { | ||
x = state[0 + column]; | ||
/* x <<r= 24; */ | ||
x = ror32(x,24); | ||
y = state[4 + column]; | ||
/* y <<r= 9; */ | ||
y = ror32(y,9); | ||
z = state[8 + column]; | ||
|
||
tmp = z << 1; | ||
a = x ^ tmp; | ||
b = y & z; | ||
tmp = b << 2; | ||
a = a ^ tmp; | ||
state[8 + column] = a; | ||
|
||
a = y ^ x; | ||
b = x | z; | ||
tmp = b << 1; | ||
a = a ^ tmp; | ||
state[4 + column] = a; | ||
|
||
a = z ^ y; | ||
b = x & y; | ||
tmp = b << 3; | ||
a = a ^ tmp; | ||
state[0 + column] = a; | ||
} | ||
|
||
if (round % 4 == 0) { | ||
state = swap(state, 0, 1); | ||
state = swap(state, 2, 3); | ||
} | ||
|
||
if (round % 4 == 2) { | ||
state = swap(state, 0, 2); | ||
state = swap(state, 1, 3); | ||
} | ||
|
||
if (round % 4 == 0) { | ||
a = state[0]; | ||
b = rc + round; | ||
a ^= b; | ||
state[0] = a; | ||
} | ||
} | ||
return state; | ||
} |
This file contains 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,36 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
DIR=$(mktemp -d jasminXXXXXX) | ||
ASM=${DIR}/jasmin.s | ||
OBJ=${DIR}/jasmin.o | ||
|
||
trap "rm -r ${DIR}" EXIT | ||
|
||
set -x | ||
|
||
$(dirname $0)/../jasminc -g -arch risc-v -o ${ASM} "$@" | ||
|
||
# Set default ASSEMBLY_CHECKER | ||
ASSEMBLY_CHECKER=${ASSEMBLY_CHECKER:-llvm-mc} | ||
ASSEMBLY_CHECKER_OPTIONS=${ASSEMBLY_CHECKER_OPTIONS:---triple=riscv32 --mcpu=generic-rv32 -mattr=+m --filetype=obj} | ||
# Detect operating system | ||
UNAME_S=$(uname -s) | ||
|
||
# Conditionally set ASSEMBLY_CHECKER for Darwin (macOS) | ||
if [ "$UNAME_S" == "Darwin" ]; then | ||
ASSEMBLY_CHECKER="riscv64-unknown-elf-as" | ||
ASSEMBLY_CHECKER_OPTIONS="" | ||
elif [ "$UNAME_S" == "Linux" ]; then | ||
ASSEMBLY_CHECKER="llvm-mc" | ||
ASSEMBLY_CHECKER_OPTIONS="--triple=riscv32 --mcpu=generic-rv32 -mattr=+m --filetype=obj" | ||
fi | ||
|
||
# Check if the assembly checker binary exists and is executable | ||
if ! command -v "$ASSEMBLY_CHECKER" &> /dev/null; then | ||
echo "Error: $ASSEMBLY_CHECKER is not installed or not found in PATH." | ||
exit 1 | ||
fi | ||
|
||
${ASSEMBLY_CHECKER} ${ASSEMBLY_CHECKER_OPTIONS} -o ${OBJ} ${ASM} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is surprising: does it mean that it is now possible to write
MOVSX_s16
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any updates on this issue?