Skip to content

Commit

Permalink
cmd/internal/obj/arm64: simplify buildop
Browse files Browse the repository at this point in the history
This code stems from the original 7l C code, where one way to determine
the end of a table is to put a sentinel entry, then scan for it. This is
now Go code and the length of an array is readily available.

Remove the sentinel and sentinel scan, then adjust the remaining code to
work accordingly.

Change-Id: I8964c787f5149f3548fa78bf8923aa7a93f9482e
Reviewed-on: https://go-review.googlesource.com/c/go/+/512536
Reviewed-by: Cherry Mui <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Matthew Dempsky <[email protected]>
Run-TryBot: Joel Sing <[email protected]>
  • Loading branch information
4a6f656c committed Jul 26, 2023
1 parent a3c1836 commit 2a1ba6e
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions src/cmd/internal/obj/arm64/asm7.go
Original file line number Diff line number Diff line change
Expand Up @@ -853,8 +853,6 @@ var optab = []Optab{
{obj.ADUFFZERO, C_NONE, C_NONE, C_NONE, C_SBRA, 5, 4, 0, 0, 0}, // same as AB/ABL
{obj.ADUFFCOPY, C_NONE, C_NONE, C_NONE, C_SBRA, 5, 4, 0, 0, 0}, // same as AB/ABL
{obj.APCALIGN, C_LCON, C_NONE, C_NONE, C_NONE, 0, 0, 0, 0, 0}, // align code

{obj.AXXX, C_NONE, C_NONE, C_NONE, C_NONE, 0, 4, 0, 0, 0},
}

// Valid pstate field values, and value to use in instruction.
Expand Down Expand Up @@ -2596,29 +2594,27 @@ func buildop(ctxt *obj.Link) {
return
}

var n int
for i := 0; i < C_GOK; i++ {
for n = 0; n < C_GOK; n++ {
if cmp(n, i) {
xcmp[i][n] = true
for j := 0; j < C_GOK; j++ {
if cmp(j, i) {
xcmp[i][j] = true
}
}
}
for n = 0; optab[n].as != obj.AXXX; n++ {
}
sort.Sort(ocmp(optab[:n]))
for i := 0; i < n; i++ {
r := optab[i].as
start := i
for optab[i].as == r {
i++

sort.Sort(ocmp(optab))
for i := 0; i < len(optab); i++ {
as, start := optab[i].as, i
for ; i < len(optab)-1; i++ {
if optab[i+1].as != as {
break
}
}
t := optab[start:i]
i--
oprangeset(r, t)
switch r {
t := optab[start : i+1]
oprangeset(as, t)
switch as {
default:
ctxt.Diag("unknown op in build: %v", r)
ctxt.Diag("unknown op in build: %v", as)
ctxt.DiagFlush()
log.Fatalf("bad code")

Expand Down

0 comments on commit 2a1ba6e

Please sign in to comment.