aboutsummaryrefslogtreecommitdiff
path: root/scripts/wrapper/spike/riscv64-unknown-linux-gnu-run
diff options
context:
space:
mode:
authorPan Li <pan2.li@intel.com>2023-11-21 08:13:28 +0800
committerPan Li <pan2.li@intel.com>2023-11-21 08:22:14 +0800
commit1749dfbf18c2f60602ec43753d7f502770b8098f (patch)
treef16fdd68fb74c2d4021af46486ff73a952c73dd3 /scripts/wrapper/spike/riscv64-unknown-linux-gnu-run
parent82c3d6550a26f03c3b4acb6cbefe5c5e98855ddb (diff)
downloadriscv-gnu-toolchain-1749dfbf18c2f60602ec43753d7f502770b8098f.zip
riscv-gnu-toolchain-1749dfbf18c2f60602ec43753d7f502770b8098f.tar.gz
riscv-gnu-toolchain-1749dfbf18c2f60602ec43753d7f502770b8098f.tar.bz2
Inject CPU options to spike run test from elf file
* Refactor CPU options for exacting common part between qemu and spike. * Inject CPU options to spike run command line. The below common CPU options are extracted to common part. * xlen * vlen * extensions The above CPU options will be leveraged to build the run arguments for both the qemu and spike, for example. QEMU: qemu-riscv64 -cpu rv64,v=true,vlen=1024,elen=64,vext_spec=v1.0 SPIKE: spike --isa=rv64imafdcv_zicsr_zifencei_zmmul --varch=vlen:1024,elen:64 Signed-off-by: Pan Li <pan2.li@intel.com>
Diffstat (limited to 'scripts/wrapper/spike/riscv64-unknown-linux-gnu-run')
-rwxr-xr-xscripts/wrapper/spike/riscv64-unknown-linux-gnu-run13
1 files changed, 7 insertions, 6 deletions
diff --git a/scripts/wrapper/spike/riscv64-unknown-linux-gnu-run b/scripts/wrapper/spike/riscv64-unknown-linux-gnu-run
index 6f5ba83..819ac7a 100755
--- a/scripts/wrapper/spike/riscv64-unknown-linux-gnu-run
+++ b/scripts/wrapper/spike/riscv64-unknown-linux-gnu-run
@@ -1,7 +1,8 @@
-#!/bin/sh
+#!/bin/bash
-xlen="$(readelf -h $1 | grep 'Class' | cut -d: -f 2 | xargs echo | sed 's/^ELF//')"
-arch="${ARCH_STR#*=}"
-spike \
- --isa=${arch} \
- ${PK_PATH}/pk${xlen} "$@"
+xlen="$(march-to-cpu-opt --elf-file-path $1 --print-xlen)"
+isa="$(march-to-cpu-opt --elf-file-path $1 --print-spike-isa)"
+varch="$(march-to-cpu-opt --elf-file-path $1 --print-spike-varch)"
+
+[[ -z ${varch} ]] && spike --isa=${isa} ${PK_PATH}/pk${xlen} "$@"
+[[ ! -z ${varch} ]] && spike --isa=${isa} --varch=${varch} ${PK_PATH}/pk${xlen} "$@"