Skip to content

Commit

Permalink
[nix] fix codegen compile for zvbb insn
Browse files Browse the repository at this point in the history
Signed-off-by: Avimitin <[email protected]>
  • Loading branch information
Avimitin authored and Lucas-Wye committed Aug 5, 2024
1 parent 82f09ad commit 87154e8
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 35 deletions.
30 changes: 19 additions & 11 deletions tests/builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,25 @@ let

CC = "${stdenv.targetPlatform.config}-cc";

NIX_CFLAGS_COMPILE = [
"-mabi=ilp32f"
"-march=${rtlDesignMetadata.march}"
"-mno-relax"
"-static"
"-mcmodel=medany"
"-fvisibility=hidden"
"-fno-PIC"
"-g"
"-O3"
];
NIX_CFLAGS_COMPILE =
let
march = lib.pipe rtlDesignMetadata.march [
(lib.splitString "_")
(map (ext: if ext == "zvbb" then "zvbb1" else ext))
(lib.concatStringsSep "_")
];
in
[
"-mabi=ilp32f"
"-march=${march}"
"-mno-relax"
"-static"
"-mcmodel=medany"
"-fvisibility=hidden"
"-fno-PIC"
"-g"
"-O3"
] ++ lib.optionals (lib.elem "zvbb" (lib.splitString "_" rtlDesignMetadata.march)) [ "-menable-experimental-extensions" ];

installPhase = ''
runHook preInstall
Expand Down
16 changes: 0 additions & 16 deletions tests/codegen/common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,12 @@ vadd.vx
vand.vi
vand.vv
vand.vx
vandn.vv
vandn.vx
vasub.vv
vasub.vx
vasubu.vv
vasubu.vx
vbrev.v
vbrev8.v
vclz.v
vcompress.vm
vcpop.m
vcpop.v
vctz.v
vdiv.vv
vdiv.vx
vdivu.vv
Expand Down Expand Up @@ -249,16 +242,10 @@ vrem.vv
vrem.vx
vremu.vv
vremu.vx
vrev8.v
vrgather.vi
vrgather.vv
vrgather.vx
vrgatherei16.vv
vrol.vv
vrol.vx
vror.vi
vror.vv
vror.vx
vrsub.vi
vrsub.vx
vs1r.v
Expand Down Expand Up @@ -427,9 +414,6 @@ vwmulu.vv
vwmulu.vx
vwredsum.vs
vwredsumu.vs
vwsll.vi
vwsll.vv
vwsll.vx
vwsub.vv
vwsub.vx
vwsub.wv
Expand Down
5 changes: 2 additions & 3 deletions tests/codegen/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,10 @@ let
commonTests = buildTestsFromFile ./common.txt { featuresRequired = [ ]; };
fpTests = buildTestsFromFile ./fp.txt { featuresRequired = [ "zve32f" ]; };
zvbbTests = buildTestsFromFile ./zvbb.txt { featuresRequired = [ "zvbb" ]; };
hasFeature = feat: lib.any (f: feat == f) currentFeatures;
in
lib.recurseIntoAttrs (
commonTests //
lib.optionalAttrs (hasFeature "zve32f") fpTests //
lib.optionalAttrs (hasFeature "zvbb") zvbbTests
lib.optionalAttrs (lib.elem "zve32f" currentFeatures) fpTests //
lib.optionalAttrs (lib.elem "zvbb" currentFeatures) zvbbTests
)

2 changes: 1 addition & 1 deletion tests/codegen/zvbb.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
vandn.vv
vandn.vx
vbrev.v
vbreav8.v
vbrev8.v
vclz.v
vcpop.v
vctz.v
Expand Down
5 changes: 1 addition & 4 deletions tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,14 @@
}:

let
hasExt = cmp: lib.any (ext: cmp == (lib.toLower ext)) rtlDesignMetadata.extensions;

# Add an extra abstract layer between test case and RTL design, so that we can have clean and organized way
# for developer to specify their required features without the need to parse ISA string themselves.
currentFeatures = [
"vlen:${rtlDesignMetadata.vlen}"
"dlen:${rtlDesignMetadata.dlen}"
"xlen:${if (lib.hasPrefix "rv32" rtlDesignMetadata.march) then "32" else "64"}"
]
++ lib.optionals (hasExt "zve32f") [ "zve32f" ]
++ lib.optionals (hasExt "zvbb") [ "zvbb" ];
++ (lib.splitString "_" rtlDesignMetadata.march);

# isSubSetOf m n: n is subset of m
isSubsetOf = m: n: lib.all (x: lib.elem x m) n;
Expand Down

0 comments on commit 87154e8

Please sign in to comment.