Skip to content

Commit

Permalink
Reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
ksco committed Sep 24, 2024
1 parent 42e1a32 commit 6b1f1f2
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 26 deletions.
8 changes: 4 additions & 4 deletions generator/insn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions generator/insn_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]: {},
Expand Down Expand Up @@ -161,7 +163,6 @@ func ma(mask bool) string {
return "mu"
}


func hash(s string) uint32 {
h := fnv.New32a()
h.Write([]byte(s))
Expand All @@ -185,4 +186,4 @@ func getVRegs(lmul1 LMUL, v0 bool, seed string) (int, int, int) {
})

return availableOptions[0], availableOptions[1], availableOptions[2]
}
}
10 changes: 5 additions & 5 deletions generator/insn_vdvs2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
12 changes: 6 additions & 6 deletions generator/insn_vdvs2uimm.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ 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(),
)
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 {
Expand Down Expand Up @@ -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")

Expand Down
8 changes: 4 additions & 4 deletions generator/insn_vdvs2vs1.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion generator/insn_vsetvl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
2 changes: 1 addition & 1 deletion generator/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down

0 comments on commit 6b1f1f2

Please sign in to comment.