diff --git a/generator/insn.go b/generator/insn.go index 2af6c8e..86e7d74 100644 --- a/generator/insn.go +++ b/generator/insn.go @@ -16,9 +16,9 @@ import ( type insnFormat string type Option struct { - VLEN VLEN - XLEN XLEN - Repeat int + VLEN VLEN + XLEN XLEN + Repeat int Float16 bool } @@ -411,7 +411,7 @@ func (i *Insn) testCases(float bool, sew SEW) [][]any { } break } - for _, c := range i.Tests.SEW16 { + for _, c := range i.Tests.SEW16 { l := make([]any, len(c)) for b, op := range c { l[b] = op diff --git a/generator/insn_util.go b/generator/insn_util.go index 2634d4a..e662c26 100644 --- a/generator/insn_util.go +++ b/generator/insn_util.go @@ -29,13 +29,15 @@ type VXSAT bool type SEW int var allSEWs = []SEW{8, 16, 32, 64} + func (i *Insn) floatSEWs() []SEW { - if (i.Option.Float16) { - return []SEW{16,32,64} + if i.Option.Float16 { + return []SEW{16, 32, 64} } else { - return []SEW{32,64} + return []SEW{32, 64} } } + var validSEWs = map[SEW]struct{}{ allSEWs[0]: {}, allSEWs[1]: {}, @@ -161,7 +163,6 @@ func ma(mask bool) string { return "mu" } - func hash(s string) uint32 { h := fnv.New32a() h.Write([]byte(s)) @@ -185,4 +186,4 @@ func getVRegs(lmul1 LMUL, v0 bool, seed string) (int, int, int) { }) return availableOptions[0], availableOptions[1], availableOptions[2] -} \ No newline at end of file +} diff --git a/generator/insn_vdvs2.go b/generator/insn_vdvs2.go index 398115d..3e7e437 100644 --- a/generator/insn_vdvs2.go +++ b/generator/insn_vdvs2.go @@ -26,18 +26,18 @@ func (i *Insn) genCodeVdVs2(pos int) []string { res := make([]string, 0, len(combinations)) for _, c := range combinations[pos:] { - if sew32OnlyInsn && c.Vl % 4 != 0 { - c.Vl = (c.Vl + 3) / 4 * 4 + if sew32OnlyInsn && c.Vl%4 != 0 { + c.Vl = (c.Vl + 3) / 4 * 4 } builder := strings.Builder{} builder.WriteString(c.initialize()) - + var vd, vs2 int - if (sew32OnlyInsn){ + if sew32OnlyInsn { vd = int(c.LMUL1) vs2 = 3 * int(c.LMUL1) - }else{ + } else { vd, vs2, _ = getVRegs(c.LMUL, true, i.Name) } diff --git a/generator/insn_vdvs2uimm.go b/generator/insn_vdvs2uimm.go index 716ea19..5bf0dc9 100644 --- a/generator/insn_vdvs2uimm.go +++ b/generator/insn_vdvs2uimm.go @@ -14,7 +14,7 @@ func (i *Insn) genCodeVdVs2Uimm(pos int) []string { vdSize := 1 combinations := i.combinations( - iff(vsm3Insn, []LMUL {1, 2, 4, 8}, allLMULs), + iff(vsm3Insn, []LMUL{1, 2, 4, 8}, allLMULs), sews, []bool{false, true}, i.vxrms(), @@ -22,7 +22,7 @@ func (i *Insn) genCodeVdVs2Uimm(pos int) []string { res := make([]string, 0, len(combinations)) for _, c := range combinations[pos:] { - if sew32OnlyInsn && c.Vl % 4 != 0 { + if sew32OnlyInsn && c.Vl%4 != 0 { c.Vl = (c.Vl + 3) &^ 3 } if vsm3Insn { @@ -59,16 +59,16 @@ func (i *Insn) genCodeVdVs2Uimm(pos int) []string { switch c.SEW { case 8: builder.WriteString(fmt.Sprintf("%s v%d, v%d, %d\n", - i.Name, vd, vs2, convNum[uint8](cases[a][0]) % 32)) + i.Name, vd, vs2, convNum[uint8](cases[a][0])%32)) case 16: builder.WriteString(fmt.Sprintf("%s v%d, v%d, %d\n", - i.Name, vd, vs2, convNum[uint16](cases[a][0]) % 32)) + i.Name, vd, vs2, convNum[uint16](cases[a][0])%32)) case 32: builder.WriteString(fmt.Sprintf("%s v%d, v%d, %d\n", - i.Name, vd, vs2, convNum[uint32](cases[a][0]) % 32)) + i.Name, vd, vs2, convNum[uint32](cases[a][0])%32)) case 64: builder.WriteString(fmt.Sprintf("%s v%d, v%d, %d\n", - i.Name, vd, vs2, convNum[uint64](cases[a][0]) % 32)) + i.Name, vd, vs2, convNum[uint64](cases[a][0])%32)) } builder.WriteString("# -------------- TEST END --------------\n") diff --git a/generator/insn_vdvs2vs1.go b/generator/insn_vdvs2vs1.go index 5d08106..f633c34 100644 --- a/generator/insn_vdvs2vs1.go +++ b/generator/insn_vdvs2vs1.go @@ -6,22 +6,22 @@ import ( ) func (i *Insn) genCodeVdVs2Vs1(pos int) []string { - vsm3Insn := strings.HasPrefix(i.Name, "vsm3") + vsm3Insn := strings.HasPrefix(i.Name, "vsm3") sew32OnlyInsn := strings.HasPrefix(i.Name, "vg") || strings.HasPrefix(i.Name, "vsha") sews := iff(sew32OnlyInsn || vsm3Insn, []SEW{32}, allSEWs) combinations := i.combinations( - iff(vsm3Insn, []LMUL {1, 2, 4, 8}, allLMULs), + iff(vsm3Insn, []LMUL{1, 2, 4, 8}, allLMULs), sews, []bool{false}, i.vxrms(), ) res := make([]string, 0, len(combinations)) for _, c := range combinations[pos:] { - if sew32OnlyInsn && c.Vl % 4 != 0 { + if sew32OnlyInsn && c.Vl%4 != 0 { c.Vl = (c.Vl + 3) &^ 3 } if vsm3Insn { - c.Vl = (c.Vl + 7) &^ 7 + c.Vl = (c.Vl + 7) &^ 7 } builder := strings.Builder{} builder.WriteString(c.initialize()) diff --git a/generator/insn_vsetvl.go b/generator/insn_vsetvl.go index caf7892..c6e117b 100644 --- a/generator/insn_vsetvl.go +++ b/generator/insn_vsetvl.go @@ -114,7 +114,7 @@ func (i *Insn) genCodevsetvl(pos int) []string { case 0: curvl = t[2] case 1: - if t[1] == 1 << (i.Option.XLEN - 1) { // vill + if t[1] == 1<<(i.Option.XLEN-1) { // vill curvl = t[2] } else { curvl = int64(getVlmax(curvtype, int(i.Option.VLEN))) diff --git a/generator/tests.go b/generator/tests.go index 56f75a0..9d8e4fd 100644 --- a/generator/tests.go +++ b/generator/tests.go @@ -158,7 +158,7 @@ type tests struct { SEW64_ []testCase[string] `toml:"sew64"` SEW64 []testCase[uint64] `toml:"-"` - FSEW16_ []testCase[string] `toml:"fsew16"` + FSEW16_ []testCase[string] `toml:"fsew16"` FSEW16 []testCase[uint16] `toml:"-"` FSEW32_ []testCase[string] `toml:"fsew32"`