diff --git a/Makefile b/Makefile index 3a59b04..989281c 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ VLEN = 256 XLEN = 64 SPLIT = 10000 INTEGER = 0 +PATTERN = '.*' SPIKE_INSTALL = $(RISCV) OUTPUT = out/v$(VLEN)x$(XLEN)$(MODE) OUTPUT_STAGE1 = $(OUTPUT)/tests/stage1/ @@ -62,7 +63,7 @@ unittest: generate-stage1: clean-out build @mkdir -p ${OUTPUT_STAGE1} - build/generator -VLEN ${VLEN} -XLEN ${XLEN} -split=${SPLIT} -integer=${INTEGER} -stage1output ${OUTPUT_STAGE1} -configs ${CONFIGS} + build/generator -VLEN ${VLEN} -XLEN ${XLEN} -split=${SPLIT} -integer=${INTEGER} -pattern='${PATTERN}' -stage1output ${OUTPUT_STAGE1} -configs ${CONFIGS} include Makefrag diff --git a/README.md b/README.md index 98dc53d..8d838a2 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ Options: - `XLEN`, default is 64, we do not support specifying ELEN yet, ELEN is consistent with XLEN - `MODE`, default is `machine`, can be `machine`, `virtual` or `user` - `INTEGER`, default is 0, set to 1 if you don't want float tests (i.e. for Zve32x or Zve64x) +- `PATTERN`, default is `.*`, set to a valid regex to generate the tests of your interests (e.g. `PATTERN='^v[ls].+\.v$'` to generate load/store tests) For example, to generate `isa=rv32gcv varch=vlen:128,elen:32 mode=machine` tests, use `make -e VLEN=128 XLEN=32 MODE=machine -j$(nproc)`. diff --git a/main.go b/main.go index 8904b46..d7e3e83 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,7 @@ import ( "github.com/ksco/riscv-vector-tests/generator" "os" "path/filepath" + "regexp" "sort" "strconv" "strings" @@ -22,15 +23,19 @@ func fatalIf(err error) { } var vlenF = flag.Int("VLEN", 256, "") -var xlenF = flag.Int("XLEN", 64, "") -var splitF = flag.Int("split", 10000, "") -var integer = flag.Bool("integer", false, "") +var xlenF = flag.Int("XLEN", 64, "we do not support specifying ELEN yet, ELEN is consistent with XLEN.") +var splitF = flag.Int("split", 10000, "split per lines.") +var integerF = flag.Bool("integer", false, "only generate integer tests.") +var patternF = flag.String("pattern", ".*", "regex to filter out tests.") var stage1OutputDirF = flag.String("stage1output", "", "stage1 output directory.") var configsDirF = flag.String("configs", "configs/", "config files directory.") func main() { flag.Parse() + pattern, err := regexp.Compile(*patternF) + fatalIf(err) + if stage1OutputDirF == nil || *stage1OutputDirF == "" { fatalIf(errors.New("-stage1output is required")) } @@ -49,7 +54,11 @@ func main() { lk := sync.Mutex{} wg := sync.WaitGroup{} for _, file := range files { - if *integer && strings.HasPrefix(file.Name(), "vf") { + if *integerF && strings.HasPrefix(file.Name(), "vf") { + continue + } + + if !pattern.MatchString(strings.TrimSuffix(file.Name(), ".toml")) { continue }