]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: enforce strongly typed rules for ARM (read)
authorConstantin Konstantinidis <constantinkonstantinidis@gmail.com>
Thu, 24 Sep 2020 16:54:58 +0000 (18:54 +0200)
committerAlberto Donizetti <alb.donizetti@gmail.com>
Sat, 24 Oct 2020 13:20:21 +0000 (13:20 +0000)
Add type casting to offset.
L246-L247
L1473-L1475

toolstash-check successful.

Change-Id: I816c7556609ca6dd67bff8007c2d006cab89ee2b
Reviewed-on: https://go-review.googlesource.com/c/go/+/257639
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Alberto Donizetti <alb.donizetti@gmail.com>

src/cmd/compile/internal/ssa/gen/ARM.rules
src/cmd/compile/internal/ssa/rewriteARM.go

index cfedde5d5e8dff117207f48a63693bba15bcadfc..5d948c1975cd13eede7710b0b879464244a29f96 100644 (file)
 (Leq16U x y) => (LessEqualU (CMP (ZeroExt16to32 x) (ZeroExt16to32 y)))
 (Leq32U x y) => (LessEqualU (CMP x y))
 
-(OffPtr [off] ptr:(SP)) -> (MOVWaddr [off] ptr)
-(OffPtr [off] ptr) -> (ADDconst [off] ptr)
+(OffPtr [off] ptr:(SP)) => (MOVWaddr [int32(off)] ptr)
+(OffPtr [off] ptr) => (ADDconst [int32(off)] ptr)
 
 (Addr ...) -> (MOVWaddr ...)
 (LocalAddr {sym} base _) => (MOVWaddr {sym} base)
 (GE (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) && l.Uses==1 => (GE (TEQshiftRLreg x y z) yes no)
 (GE (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) && l.Uses==1 => (GE (TEQshiftRAreg x y z) yes no)
 
-(MOVBUload [off] {sym} (SB) _) && symIsRO(sym) -> (MOVWconst [int64(read8(sym, off))])
-(MOVHUload [off] {sym} (SB) _) && symIsRO(sym) -> (MOVWconst [int64(read16(sym, off, config.ctxt.Arch.ByteOrder))])
-(MOVWload [off] {sym} (SB) _) && symIsRO(sym) -> (MOVWconst [int64(int32(read32(sym, off, config.ctxt.Arch.ByteOrder)))])
+(MOVBUload [off] {sym} (SB) _) && symIsRO(sym) => (MOVWconst [int32(read8(sym, int64(off)))])
+(MOVHUload [off] {sym} (SB) _) && symIsRO(sym) => (MOVWconst [int32(read16(sym, int64(off), config.ctxt.Arch.ByteOrder))])
+(MOVWload [off] {sym} (SB) _) && symIsRO(sym) => (MOVWconst [int32(read32(sym, int64(off), config.ctxt.Arch.ByteOrder))])
index eff01927dfcb2c6f94662632ce78377aaa785353..d92613da0270ff23e76dc949c032802e1acedbb8 100644 (file)
@@ -4600,15 +4600,15 @@ func rewriteValueARM_OpARMMOVBUload(v *Value) bool {
        }
        // match: (MOVBUload [off] {sym} (SB) _)
        // cond: symIsRO(sym)
-       // result: (MOVWconst [int64(read8(sym, off))])
+       // result: (MOVWconst [int32(read8(sym, int64(off)))])
        for {
-               off := v.AuxInt
-               sym := v.Aux
+               off := auxIntToInt32(v.AuxInt)
+               sym := auxToSym(v.Aux)
                if v_0.Op != OpSB || !(symIsRO(sym)) {
                        break
                }
                v.reset(OpARMMOVWconst)
-               v.AuxInt = int64(read8(sym, off))
+               v.AuxInt = int32ToAuxInt(int32(read8(sym, int64(off))))
                return true
        }
        return false
@@ -5513,15 +5513,15 @@ func rewriteValueARM_OpARMMOVHUload(v *Value) bool {
        }
        // match: (MOVHUload [off] {sym} (SB) _)
        // cond: symIsRO(sym)
-       // result: (MOVWconst [int64(read16(sym, off, config.ctxt.Arch.ByteOrder))])
+       // result: (MOVWconst [int32(read16(sym, int64(off), config.ctxt.Arch.ByteOrder))])
        for {
-               off := v.AuxInt
-               sym := v.Aux
+               off := auxIntToInt32(v.AuxInt)
+               sym := auxToSym(v.Aux)
                if v_0.Op != OpSB || !(symIsRO(sym)) {
                        break
                }
                v.reset(OpARMMOVWconst)
-               v.AuxInt = int64(read16(sym, off, config.ctxt.Arch.ByteOrder))
+               v.AuxInt = int32ToAuxInt(int32(read16(sym, int64(off), config.ctxt.Arch.ByteOrder)))
                return true
        }
        return false
@@ -6234,15 +6234,15 @@ func rewriteValueARM_OpARMMOVWload(v *Value) bool {
        }
        // match: (MOVWload [off] {sym} (SB) _)
        // cond: symIsRO(sym)
-       // result: (MOVWconst [int64(int32(read32(sym, off, config.ctxt.Arch.ByteOrder)))])
+       // result: (MOVWconst [int32(read32(sym, int64(off), config.ctxt.Arch.ByteOrder))])
        for {
-               off := v.AuxInt
-               sym := v.Aux
+               off := auxIntToInt32(v.AuxInt)
+               sym := auxToSym(v.Aux)
                if v_0.Op != OpSB || !(symIsRO(sym)) {
                        break
                }
                v.reset(OpARMMOVWconst)
-               v.AuxInt = int64(int32(read32(sym, off, config.ctxt.Arch.ByteOrder)))
+               v.AuxInt = int32ToAuxInt(int32(read32(sym, int64(off), config.ctxt.Arch.ByteOrder)))
                return true
        }
        return false
@@ -14648,25 +14648,25 @@ func rewriteValueARM_OpNot(v *Value) bool {
 func rewriteValueARM_OpOffPtr(v *Value) bool {
        v_0 := v.Args[0]
        // match: (OffPtr [off] ptr:(SP))
-       // result: (MOVWaddr [off] ptr)
+       // result: (MOVWaddr [int32(off)] ptr)
        for {
-               off := v.AuxInt
+               off := auxIntToInt64(v.AuxInt)
                ptr := v_0
                if ptr.Op != OpSP {
                        break
                }
                v.reset(OpARMMOVWaddr)
-               v.AuxInt = off
+               v.AuxInt = int32ToAuxInt(int32(off))
                v.AddArg(ptr)
                return true
        }
        // match: (OffPtr [off] ptr)
-       // result: (ADDconst [off] ptr)
+       // result: (ADDconst [int32(off)] ptr)
        for {
-               off := v.AuxInt
+               off := auxIntToInt64(v.AuxInt)
                ptr := v_0
                v.reset(OpARMADDconst)
-               v.AuxInt = off
+               v.AuxInt = int32ToAuxInt(int32(off))
                v.AddArg(ptr)
                return true
        }