]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: add dedicated ARM64BitField aux type
authorJosh Bleecher Snyder <josharian@gmail.com>
Tue, 18 Feb 2020 01:47:34 +0000 (17:47 -0800)
committerJosh Bleecher Snyder <josharian@gmail.com>
Fri, 28 Feb 2020 14:52:13 +0000 (14:52 +0000)
The goal here is improved AuxInt printing in ssa.html.
Instead of displaying an inscrutable encoded integer,
it displays something like

v25 (28) = UBFX <int> [lsb=4,width=8] v52

which is much nicer for debugging.

Change-Id: I40713ff7f4a857c4557486cdf73c2dff137511ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/221420
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/compile/internal/ssa/check.go
src/cmd/compile/internal/ssa/gen/ARM64Ops.go
src/cmd/compile/internal/ssa/gen/rulegen.go
src/cmd/compile/internal/ssa/op.go
src/cmd/compile/internal/ssa/opGen.go
src/cmd/compile/internal/ssa/value.go

index 4e258fe82b3e384773b8c6fb614ab4fe9f5d76f6..a6746805f7ffff85ee852e50dc0aba0c8c38935a 100644 (file)
@@ -141,7 +141,7 @@ func checkFunc(f *Func) {
                                        f.Fatalf("bad int32 AuxInt value for %v", v)
                                }
                                canHaveAuxInt = true
-                       case auxInt64, auxFloat64:
+                       case auxInt64, auxFloat64, auxARM64BitField:
                                canHaveAuxInt = true
                        case auxInt128:
                                // AuxInt must be zero, so leave canHaveAuxInt set to false.
index 51a610fc76a9a81f2e25e4defef797810e06fa51..4e18fb0f765fad96b43fad51313e44798067552d 100644 (file)
@@ -338,17 +338,17 @@ func init() {
                // bitfield ops
                // for all bitfield ops lsb is auxInt>>8, width is auxInt&0xff
                // insert low width bits of arg1 into the result starting at bit lsb, copy other bits from arg0
-               {name: "BFI", argLength: 2, reg: gp21nog, asm: "BFI", aux: "Int64", resultInArg0: true},
+               {name: "BFI", argLength: 2, reg: gp21nog, asm: "BFI", aux: "ARM64BitField", resultInArg0: true},
                // extract width bits of arg1 starting at bit lsb and insert at low end of result, copy other bits from arg0
-               {name: "BFXIL", argLength: 2, reg: gp21nog, asm: "BFXIL", aux: "Int64", resultInArg0: true},
+               {name: "BFXIL", argLength: 2, reg: gp21nog, asm: "BFXIL", aux: "ARM64BitField", resultInArg0: true},
                // insert low width bits of arg0 into the result starting at bit lsb, bits to the left of the inserted bit field are set to the high/sign bit of the inserted bit field, bits to the right are zeroed
-               {name: "SBFIZ", argLength: 1, reg: gp11, asm: "SBFIZ", aux: "Int64"},
+               {name: "SBFIZ", argLength: 1, reg: gp11, asm: "SBFIZ", aux: "ARM64BitField"},
                // extract width bits of arg0 starting at bit lsb and insert at low end of result, remaining high bits are set to the high/sign bit of the extracted bitfield
-               {name: "SBFX", argLength: 1, reg: gp11, asm: "SBFX", aux: "Int64"},
+               {name: "SBFX", argLength: 1, reg: gp11, asm: "SBFX", aux: "ARM64BitField"},
                // insert low width bits of arg0 into the result starting at bit lsb, bits to the left and right of the inserted bit field are zeroed
-               {name: "UBFIZ", argLength: 1, reg: gp11, asm: "UBFIZ", aux: "Int64"},
+               {name: "UBFIZ", argLength: 1, reg: gp11, asm: "UBFIZ", aux: "ARM64BitField"},
                // extract width bits of arg0 starting at bit lsb and insert at low end of result, remaining high bits are zeroed
-               {name: "UBFX", argLength: 1, reg: gp11, asm: "UBFX", aux: "Int64"},
+               {name: "UBFX", argLength: 1, reg: gp11, asm: "UBFX", aux: "ARM64BitField"},
 
                // moves
                {name: "MOVDconst", argLength: 0, reg: gp01, aux: "Int64", asm: "MOVD", typ: "UInt64", rematerializeable: true},      // 32 low bits of auxint
index 4f404af8e7c883530913ebf16bdfdc3fe76539f1..2a10f2fa2513ba33accc2fe2d3f81f295bee00f6 100644 (file)
@@ -1298,7 +1298,7 @@ func parseValue(val string, arch arch, loc string) (op opData, oparch, typ, auxi
 
 func opHasAuxInt(op opData) bool {
        switch op.aux {
-       case "Bool", "Int8", "Int16", "Int32", "Int64", "Int128", "Float32", "Float64", "SymOff", "SymValAndOff", "TypSize":
+       case "Bool", "Int8", "Int16", "Int32", "Int64", "Int128", "Float32", "Float64", "SymOff", "SymValAndOff", "TypSize", "ARM64BitField":
                return true
        }
        return false
index ec9e7863a0cfaa413a045c7fcd8791df8bd550e0..c32f5c730ec1612823d9ed7c3efbde73da479e3c 100644 (file)
@@ -68,23 +68,24 @@ type regInfo struct {
 type auxType int8
 
 const (
-       auxNone         auxType = iota
-       auxBool                 // auxInt is 0/1 for false/true
-       auxInt8                 // auxInt is an 8-bit integer
-       auxInt16                // auxInt is a 16-bit integer
-       auxInt32                // auxInt is a 32-bit integer
-       auxInt64                // auxInt is a 64-bit integer
-       auxInt128               // auxInt represents a 128-bit integer.  Always 0.
-       auxFloat32              // auxInt is a float32 (encoded with math.Float64bits)
-       auxFloat64              // auxInt is a float64 (encoded with math.Float64bits)
-       auxString               // aux is a string
-       auxSym                  // aux is a symbol (a *gc.Node for locals or an *obj.LSym for globals)
-       auxSymOff               // aux is a symbol, auxInt is an offset
-       auxSymValAndOff         // aux is a symbol, auxInt is a ValAndOff
-       auxTyp                  // aux is a type
-       auxTypSize              // aux is a type, auxInt is a size, must have Aux.(Type).Size() == AuxInt
-       auxCCop                 // aux is a ssa.Op that represents a flags-to-bool conversion (e.g. LessThan)
-       auxArchSpecific         // aux type is specific to a particular backend (see the relevant op for the actual type)
+       auxNone          auxType = iota
+       auxBool                  // auxInt is 0/1 for false/true
+       auxInt8                  // auxInt is an 8-bit integer
+       auxInt16                 // auxInt is a 16-bit integer
+       auxInt32                 // auxInt is a 32-bit integer
+       auxInt64                 // auxInt is a 64-bit integer
+       auxInt128                // auxInt represents a 128-bit integer.  Always 0.
+       auxFloat32               // auxInt is a float32 (encoded with math.Float64bits)
+       auxFloat64               // auxInt is a float64 (encoded with math.Float64bits)
+       auxString                // aux is a string
+       auxSym                   // aux is a symbol (a *gc.Node for locals or an *obj.LSym for globals)
+       auxSymOff                // aux is a symbol, auxInt is an offset
+       auxSymValAndOff          // aux is a symbol, auxInt is a ValAndOff
+       auxTyp                   // aux is a type
+       auxTypSize               // aux is a type, auxInt is a size, must have Aux.(Type).Size() == AuxInt
+       auxCCop                  // aux is a ssa.Op that represents a flags-to-bool conversion (e.g. LessThan)
+       auxARM64BitField         // aux is an arm64 bitfield lsb and width packed into auxint
+       auxArchSpecific          // aux type is specific to a particular backend (see the relevant op for the actual type)
 )
 
 // A SymEffect describes the effect that an SSA Value has on the variable
index b951065e7c4f207ff8542e7cdac2c48a2a85e623..1111316d9b35f58ca95273c2e254a14bac377270 100644 (file)
@@ -17359,7 +17359,7 @@ var opcodeTable = [...]opInfo{
        },
        {
                name:         "BFI",
-               auxType:      auxInt64,
+               auxType:      auxARM64BitField,
                argLen:       2,
                resultInArg0: true,
                asm:          arm64.ABFI,
@@ -17375,7 +17375,7 @@ var opcodeTable = [...]opInfo{
        },
        {
                name:         "BFXIL",
-               auxType:      auxInt64,
+               auxType:      auxARM64BitField,
                argLen:       2,
                resultInArg0: true,
                asm:          arm64.ABFXIL,
@@ -17391,7 +17391,7 @@ var opcodeTable = [...]opInfo{
        },
        {
                name:    "SBFIZ",
-               auxType: auxInt64,
+               auxType: auxARM64BitField,
                argLen:  1,
                asm:     arm64.ASBFIZ,
                reg: regInfo{
@@ -17405,7 +17405,7 @@ var opcodeTable = [...]opInfo{
        },
        {
                name:    "SBFX",
-               auxType: auxInt64,
+               auxType: auxARM64BitField,
                argLen:  1,
                asm:     arm64.ASBFX,
                reg: regInfo{
@@ -17419,7 +17419,7 @@ var opcodeTable = [...]opInfo{
        },
        {
                name:    "UBFIZ",
-               auxType: auxInt64,
+               auxType: auxARM64BitField,
                argLen:  1,
                asm:     arm64.AUBFIZ,
                reg: regInfo{
@@ -17433,7 +17433,7 @@ var opcodeTable = [...]opInfo{
        },
        {
                name:    "UBFX",
-               auxType: auxInt64,
+               auxType: auxARM64BitField,
                argLen:  1,
                asm:     arm64.AUBFX,
                reg: regInfo{
index c08eba3d4467aa919809899668666b9f316a73eb..b877220211287aacf4a99e0aef1dad96f2756a7b 100644 (file)
@@ -175,6 +175,10 @@ func (v *Value) auxString() string {
                return fmt.Sprintf(" [%d]", v.AuxInt32())
        case auxInt64, auxInt128:
                return fmt.Sprintf(" [%d]", v.AuxInt)
+       case auxARM64BitField:
+               lsb := getARM64BFlsb(v.AuxInt)
+               width := getARM64BFwidth(v.AuxInt)
+               return fmt.Sprintf(" [lsb=%d,width=%d]", lsb, width)
        case auxFloat32, auxFloat64:
                return fmt.Sprintf(" [%g]", v.AuxFloat())
        case auxString: