Skip to content

Commit 2a1ba6e

Browse files
committed
cmd/internal/obj/arm64: simplify buildop
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]>
1 parent a3c1836 commit 2a1ba6e

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

src/cmd/internal/obj/arm64/asm7.go

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -853,8 +853,6 @@ var optab = []Optab{
853853
{obj.ADUFFZERO, C_NONE, C_NONE, C_NONE, C_SBRA, 5, 4, 0, 0, 0}, // same as AB/ABL
854854
{obj.ADUFFCOPY, C_NONE, C_NONE, C_NONE, C_SBRA, 5, 4, 0, 0, 0}, // same as AB/ABL
855855
{obj.APCALIGN, C_LCON, C_NONE, C_NONE, C_NONE, 0, 0, 0, 0, 0}, // align code
856-
857-
{obj.AXXX, C_NONE, C_NONE, C_NONE, C_NONE, 0, 4, 0, 0, 0},
858856
}
859857

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

2599-
var n int
26002597
for i := 0; i < C_GOK; i++ {
2601-
for n = 0; n < C_GOK; n++ {
2602-
if cmp(n, i) {
2603-
xcmp[i][n] = true
2598+
for j := 0; j < C_GOK; j++ {
2599+
if cmp(j, i) {
2600+
xcmp[i][j] = true
26042601
}
26052602
}
26062603
}
2607-
for n = 0; optab[n].as != obj.AXXX; n++ {
2608-
}
2609-
sort.Sort(ocmp(optab[:n]))
2610-
for i := 0; i < n; i++ {
2611-
r := optab[i].as
2612-
start := i
2613-
for optab[i].as == r {
2614-
i++
2604+
2605+
sort.Sort(ocmp(optab))
2606+
for i := 0; i < len(optab); i++ {
2607+
as, start := optab[i].as, i
2608+
for ; i < len(optab)-1; i++ {
2609+
if optab[i+1].as != as {
2610+
break
2611+
}
26152612
}
2616-
t := optab[start:i]
2617-
i--
2618-
oprangeset(r, t)
2619-
switch r {
2613+
t := optab[start : i+1]
2614+
oprangeset(as, t)
2615+
switch as {
26202616
default:
2621-
ctxt.Diag("unknown op in build: %v", r)
2617+
ctxt.Diag("unknown op in build: %v", as)
26222618
ctxt.DiagFlush()
26232619
log.Fatalf("bad code")
26242620

0 commit comments

Comments
 (0)