Skip to content

Commit

Permalink
adding CI 33
Browse files Browse the repository at this point in the history
  • Loading branch information
moste00 committed Aug 30, 2024
1 parent 4742079 commit 4a24e60
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 5 deletions.
36 changes: 32 additions & 4 deletions .github/workflows/end2end-smoke-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ jobs:
- name: Fetching the generator sources
uses: actions/checkout@v4

- name: Getting the hash of the riscv sail model to fetch
id: sail-riscv-model-get-hash
run: echo "h=$(cat sail.hash.txt)" >> "$GITHUB_OUTPUT"

- name: Fetching the riscv sail model
uses: actions/checkout@v4
with:
repository: riscv/sail-riscv
ref: ${{ steps.sail-riscv-model-get-hash.outputs.h }}
path: ../sail-riscv/
sparse-checkout: model

- name: Running the generator
run: |
source ~/.bash_profile
Expand All @@ -23,7 +35,23 @@ jobs:
opam install . --deps-only
opam install sail=0.17.1
ls ~/.opam/default/share/sail
ls ~/.opam/default/share/sail/lib
rm *.gen.inc
dune exec --profile release -- riscv_disasm_from_sail -f bin/sail.filepaths.txt
mv riscv_ast.gen.inc old_riscv_ast.gen.inc
mv riscv_decode.gen.inc old_riscv_decode.gen.inc
dune exec --profile release -- riscv_disasm_from_sail -f sail.filepaths.txt
echo '#include "riscv_decode.gen.inc" \n void main() {}' > test_main.c
gcc test_main.c || echo "Failure: Trying to compile the tool-generated C code failed."
if diff -q riscv_ast.gen.inc old_riscv_ast.gen.inc > /dev/null 2>&1; then
if diff -q riscv_decode.gen.inc old_riscv_decode.gen.inc > /dev/null 2>&1; then
echo "Success: The tool generates compiling C code that is identical to the files committed."
else
echo "Failure: The tool-generated decoding logic differ from that committed in the repo."
exit 1
fi
else
echo "Failure: The tool-generated ast definition differ from the one committed in the repo."
exit 1
fi
15 changes: 14 additions & 1 deletion riscv_ast.gen.inc
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,9 @@ struct ast {
FVFMTYPE,
RIVVTYPE,
RMVVTYPE,
RFVVTYPE
RFVVTYPE,
RISCV_ZICBOM,
RISCV_ZICBOZ
} ast_node_type;

union {
Expand Down Expand Up @@ -2690,6 +2692,17 @@ struct ast {
uint8_t vd /* bits : 5 */;
} rfvvtype;

struct {
enum cbop_zicbom {
CBO_CLEAN,
CBO_FLUSH,
CBO_INVAL
} cbop;

uint8_t rs1 /* bits : 5 */;
} riscv_zicbom;

uint8_t riscv_zicboz /* bits : 5 */;
} ast_node;

} ;
28 changes: 28 additions & 0 deletions riscv_decode.gen.inc
Original file line number Diff line number Diff line change
Expand Up @@ -7017,6 +7017,34 @@ void decode(struct ast *tree, uint64_t binary_stream) {
tree->ast_node.rfvvtype.vd = vd;
return ;
}
}
if ((binary_stream & 0x000000000000007F == 0x0F) && ((binary_stream & 0x0000000000000F80)>>7 == 0x00) && ((binary_stream & 0x0000000000007000)>>12 == 0x2)) {
uint64_t cbop = 0xFFFFFFFFFFFFFFFF ;
switch ((binary_stream & 0x00000000FFF00000)>>20) {
case 0x000:
cbop = CBO_INVAL ;
break;
case 0x002:
cbop = CBO_FLUSH ;
break;
case 0x001:
cbop = CBO_CLEAN ;
break;

}
if (cbop != 0xFFFFFFFFFFFFFFFF) {
uint64_t rs1 = (binary_stream & 0x00000000000F8000)>>15 ;
tree->ast_node_type = RISCV_ZICBOM ;
tree->ast_node.riscv_zicbom.cbop = cbop;
tree->ast_node.riscv_zicbom.rs1 = rs1;
return ;
}
}
if ((binary_stream & 0x000000000000007F == 0x0F) && ((binary_stream & 0x0000000000000F80)>>7 == 0x00) && ((binary_stream & 0x0000000000007000)>>12 == 0x2) && ((binary_stream & 0x00000000FFF00000)>>20 == 0x004)) {
uint64_t rs1 = (binary_stream & 0x00000000000F8000)>>15 ;
tree->ast_node_type = RISCV_ZICBOZ ;
tree->ast_node.riscv_zicboz = rs1;
return ;
}
uint64_t s = binary_stream & 0x00000000FFFFFFFF ;
tree->ast_node_type = ILLEGAL ;
Expand Down
2 changes: 2 additions & 0 deletions bin/sail.filepaths.txt → sail.filepaths.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
../sail-riscv/model/riscv_insts_vext_fp_vm.sail
../sail-riscv/model/riscv_insts_vext_red.sail
../sail-riscv/model/riscv_insts_vext_fp_red.sail
../sail-riscv/model/riscv_insts_zicbom.sail
../sail-riscv/model/riscv_insts_zicboz.sail
../sail-riscv/model/riscv_jalr_seq.sail
../sail-riscv/model/riscv_insts_end.sail
../sail-riscv/model/riscv_step_common.sail
Expand Down
1 change: 1 addition & 0 deletions sail.hash.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e199a2e0dcdc5d2d5705b717538bb7a1b3060725
27 changes: 27 additions & 0 deletions tools/riscv-ls.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh

if [ $# -eq 0 ]; then
echo "No sail model path given, must be given."
exit
elif [ $# -eq 1 ]; then
SAIL_RISCV_ROOT=$1
echo "Path to sail model given as $1"
else
echo "Unrecognized arguments. Usage: riscv-ls [path to riscv sail model repo]"
echo "If no path to sail model was given, it's automatically searched for using find"
exit
fi

MKFILE="$SAIL_RISCV_ROOT/Makefile"

# add instrumentation to the makefile in order to be able to print any variables
echo 'print-% : ; @echo $* = $($*)' >> "$MKFILE"

TOOL_ROOT=$PWD
(
cd $SAIL_RISCV_ROOT
make print-SAIL_SRCS | xargs -n 1 | grep ".sail" | xargs -I {} echo "$SAIL_RISCV_ROOT"{} > "$TOOL_ROOT/sail.filepaths.txt"
)

# remove instrumentation from the makefile again to avoid version control headache
sed -i '$d' $MKFILE

0 comments on commit 4a24e60

Please sign in to comment.