diff --git a/Makefile b/Makefile index 52078e9..a333167 100644 --- a/Makefile +++ b/Makefile @@ -32,6 +32,9 @@ INTEGER = 0## ##Set to [1] if you don't want float tests (i.e. for Zve32x or Zve64x) ## + FLOAT16 = 1## + ##Set to [0] if you don't want float16 (Zvfh) tests + ## PATTERN = '.*'## ##Set to a valid regex to generate the tests of your interests (e.g. PATTERN='^v[ls].+\.v$' to generate only load/store tests) ## @@ -112,7 +115,7 @@ unittest: generate-stage1: clean-out build @mkdir -p ${OUTPUT_STAGE1} - build/generator -VLEN ${VLEN} -XLEN ${XLEN} -split=${SPLIT} -integer=${INTEGER} -pattern='${PATTERN}' -testfloat3level='${TESTFLOAT3LEVEL}' -repeat='${REPEAT}' -stage1output ${OUTPUT_STAGE1} -configs ${CONFIGS} + build/generator -VLEN ${VLEN} -XLEN ${XLEN} -split=${SPLIT} -integer=${INTEGER} -float16=${FLOAT16} -pattern='${PATTERN}' -testfloat3level='${TESTFLOAT3LEVEL}' -repeat='${REPEAT}' -stage1output ${OUTPUT_STAGE1} -configs ${CONFIGS} include Makefrag diff --git a/generator/insn.go b/generator/insn.go index bbf2d5c..2eb5161 100644 --- a/generator/insn.go +++ b/generator/insn.go @@ -19,6 +19,7 @@ type Option struct { VLEN VLEN XLEN XLEN Repeat int + Float16 bool } const minStride = -1 // Must be negative diff --git a/generator/insn_fdvs2.go b/generator/insn_fdvs2.go index 4eabb97..e3f1dda 100644 --- a/generator/insn_fdvs2.go +++ b/generator/insn_fdvs2.go @@ -6,7 +6,7 @@ import ( ) func (i *Insn) genCodeFdVs2(pos int) []string { - combinations := i.combinations([]LMUL{1}, floatSEWs, []bool{false}, i.vxrms()) + combinations := i.combinations([]LMUL{1}, i.floatSEWs(), []bool{false}, i.vxrms()) res := make([]string, 0, len(combinations)) for _, c := range combinations[pos:] { diff --git a/generator/insn_util.go b/generator/insn_util.go index 628a030..9a1ac8d 100644 --- a/generator/insn_util.go +++ b/generator/insn_util.go @@ -29,7 +29,13 @@ type VXSAT bool type SEW int var allSEWs = []SEW{8, 16, 32, 64} -var floatSEWs = []SEW{16, 32, 64} +func (i *Insn) floatSEWs() []SEW { + if (i.Option.Float16) { + return []SEW{16,32,64} + } else { + return []SEW{32,64} + } +} var validSEWs = map[SEW]struct{}{ allSEWs[0]: {}, allSEWs[1]: {}, diff --git a/generator/insn_vdfs1.go b/generator/insn_vdfs1.go index 97c1447..de06c7d 100644 --- a/generator/insn_vdfs1.go +++ b/generator/insn_vdfs1.go @@ -7,7 +7,7 @@ import ( func (i *Insn) genCodeVdFs1(pos int) []string { lmuls := iff(strings.HasSuffix(i.Name, ".s.f"), []LMUL{1}, allLMULs) - combinations := i.combinations(lmuls, floatSEWs, []bool{false}, i.vxrms()) + combinations := i.combinations(lmuls, i.floatSEWs(), []bool{false}, i.vxrms()) res := make([]string, 0, len(combinations)) for _, c := range combinations[pos:] { diff --git a/generator/insn_vdfs1vs2vm.go b/generator/insn_vdfs1vs2vm.go index 7f63d6d..d0ba53b 100644 --- a/generator/insn_vdfs1vs2vm.go +++ b/generator/insn_vdfs1vs2vm.go @@ -10,7 +10,7 @@ func (i *Insn) genCodeVdFs1Vs2Vm(pos int) []string { vdWidening := strings.HasPrefix(i.Name, "vfw") vdSize := iff(vdWidening, 2, 1) - sews := iff(vdWidening, floatSEWs[:len(floatSEWs)-1], floatSEWs) + sews := iff(vdWidening, i.floatSEWs()[:len(i.floatSEWs())-1], i.floatSEWs()) combinations := i.combinations( iff(vdWidening, wideningMULs, allLMULs), sews, diff --git a/generator/insn_vdvs1vs2vm.go b/generator/insn_vdvs1vs2vm.go index 479fdb8..dd521fa 100644 --- a/generator/insn_vdvs1vs2vm.go +++ b/generator/insn_vdvs1vs2vm.go @@ -12,7 +12,7 @@ func (i *Insn) genCodeVdVs1Vs2Vm(pos int) []string { vdSize := iff(vdWidening, 2, 1) vs1Size := 1 - sews := iff(float, floatSEWs, allSEWs) + sews := iff(float, i.floatSEWs(), allSEWs) sews = iff(vdWidening, sews[:len(sews)-1], sews) combinations := i.combinations( iff(vdWidening, wideningMULs, allLMULs), diff --git a/generator/insn_vdvs2fs1v0.go b/generator/insn_vdvs2fs1v0.go index 8b96476..18d7a23 100644 --- a/generator/insn_vdvs2fs1v0.go +++ b/generator/insn_vdvs2fs1v0.go @@ -6,7 +6,7 @@ import ( ) func (i *Insn) genCodeVdVs2Fs1V0(pos int) []string { - combinations := i.combinations(allLMULs, floatSEWs, []bool{false}, i.vxrms()) + combinations := i.combinations(allLMULs, i.floatSEWs(), []bool{false}, i.vxrms()) res := make([]string, 0, len(combinations)) for _, c := range combinations[pos:] { diff --git a/generator/insn_vdvs2fs1vm.go b/generator/insn_vdvs2fs1vm.go index e957632..134b68b 100644 --- a/generator/insn_vdvs2fs1vm.go +++ b/generator/insn_vdvs2fs1vm.go @@ -12,7 +12,7 @@ func (i *Insn) genCodeVdVs2Fs1Vm(pos int) []string { vdSize := iff(vdWidening, 2, 1) vs2Size := iff(vs2Widening, 2, 1) - sews := iff(vdWidening || vs2Widening, floatSEWs[:len(floatSEWs)-1], floatSEWs) + sews := iff(vdWidening || vs2Widening, i.floatSEWs()[:len(i.floatSEWs())-1], i.floatSEWs()) combinations := i.combinations( iff(vdWidening || vs2Widening, wideningMULs, allLMULs), sews, diff --git a/generator/insn_vdvs2vm.go b/generator/insn_vdvs2vm.go index d85df6f..b681c91 100644 --- a/generator/insn_vdvs2vm.go +++ b/generator/insn_vdvs2vm.go @@ -14,7 +14,7 @@ func (i *Insn) genCodeVdVs2Vm(pos int) []string { vs2Size := iff(vdNarrowing, 2, 1) lmuls := iff(vdWidening || vdNarrowing, wideningMULs, allLMULs) - sews := iff(vdWidening || vdNarrowing, floatSEWs[:len(floatSEWs)-1], floatSEWs) + sews := iff(vdWidening || vdNarrowing, i.floatSEWs()[:len(i.floatSEWs())-1], i.floatSEWs()) combinations := i.combinations(lmuls, sews, []bool{false, true}, i.vxrms()) res := make([]string, 0, len(combinations)) diff --git a/generator/insn_vdvs2vs1vm.go b/generator/insn_vdvs2vs1vm.go index 5f65162..0070742 100644 --- a/generator/insn_vdvs2vs1vm.go +++ b/generator/insn_vdvs2vs1vm.go @@ -13,7 +13,7 @@ func (i *Insn) genCodeVdVs2Vs1Vm(pos int) []string { vdSize := iff(vdWidening, 2, 1) vs2Size := iff(vs2Widening, 2, 1) - sews := iff(float, floatSEWs, allSEWs) + sews := iff(float, i.floatSEWs(), allSEWs) sews = iff(vdWidening || vs2Widening, sews[:len(sews)-1], sews) combinations := i.combinations( iff(vdWidening || vs2Widening, wideningMULs, allLMULs), diff --git a/main.go b/main.go index 6c9cef6..96a3307 100644 --- a/main.go +++ b/main.go @@ -28,6 +28,7 @@ var vlenF = flag.Int("VLEN", 256, "") 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 float16F = flag.Bool("float16", true, "generate float16 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.") @@ -94,6 +95,7 @@ func main() { VLEN: generator.VLEN(*vlenF), XLEN: generator.XLEN(*xlenF), Repeat: *repeatF, + Float16: *float16F, } if (!strings.HasPrefix(file.Name(), "vf") && !strings.HasPrefix(file.Name(), "vmf")) || strings.HasPrefix(file.Name(), "vfirst") { option.Repeat = 1 diff --git a/single/single.go b/single/single.go index 65ff270..31584f4 100644 --- a/single/single.go +++ b/single/single.go @@ -23,6 +23,7 @@ func fatalIf(err error) { var vlenF = flag.Int("VLEN", 256, "") var xlenF = flag.Int("XLEN", 64, "") +var float16F = flag.Bool("float16", true, "") var outputFileF = flag.String("outputfile", "", "output file name.") var configFileF = flag.String("configfile", "", "config file path.") var testfloat3LevelF = flag.Int("testfloat3level", 2, "testfloat3 testing level (1 or 2).") @@ -52,6 +53,7 @@ func main() { VLEN: generator.VLEN(*vlenF), XLEN: generator.XLEN(*xlenF), Repeat: *repeatF, + Float16: *float16F, } fp := *configFileF