]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/obj/arm64: simplify buildop
authorJoel Sing <joel@sing.id.au>
Wed, 3 May 2023 08:19:30 +0000 (18:19 +1000)
committerJoel Sing <joel@sing.id.au>
Wed, 26 Jul 2023 12:38:37 +0000 (12:38 +0000)
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 <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>

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

index 2ee7b0f6c62bee070e3d1fd199d477be281270bb..d5f3f20410c6cdc4581057de35a0647011a45845 100644 (file)
@@ -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.
@@ -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")