]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: intrinsify runtime.getcallerpc on all link register architectures
authorWei Xiao <Wei.Xiao@arm.com>
Wed, 2 May 2018 06:25:00 +0000 (14:25 +0800)
committerCherry Zhang <cherryyz@google.com>
Wed, 2 May 2018 16:59:27 +0000 (16:59 +0000)
Add a compiler intrinsic for getcallerpc on following architectures:
  arm
  mips mipsle mips64 mips64le
  ppc64 ppc64le
  s390x

Change-Id: I758f3d4742fc214b206bcd07d90408622c17dbef
Reviewed-on: https://go-review.googlesource.com/110835
Run-TryBot: Wei Xiao <Wei.Xiao@arm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
31 files changed:
src/cmd/compile/internal/arm/ssa.go
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/mips/ssa.go
src/cmd/compile/internal/mips64/ssa.go
src/cmd/compile/internal/ppc64/ssa.go
src/cmd/compile/internal/s390x/ssa.go
src/cmd/compile/internal/ssa/gen/ARM.rules
src/cmd/compile/internal/ssa/gen/ARMOps.go
src/cmd/compile/internal/ssa/gen/MIPS.rules
src/cmd/compile/internal/ssa/gen/MIPS64.rules
src/cmd/compile/internal/ssa/gen/MIPS64Ops.go
src/cmd/compile/internal/ssa/gen/MIPSOps.go
src/cmd/compile/internal/ssa/gen/PPC64.rules
src/cmd/compile/internal/ssa/gen/PPC64Ops.go
src/cmd/compile/internal/ssa/gen/S390X.rules
src/cmd/compile/internal/ssa/gen/S390XOps.go
src/cmd/compile/internal/ssa/opGen.go
src/cmd/compile/internal/ssa/rewriteARM.go
src/cmd/compile/internal/ssa/rewriteMIPS.go
src/cmd/compile/internal/ssa/rewriteMIPS64.go
src/cmd/compile/internal/ssa/rewritePPC64.go
src/cmd/compile/internal/ssa/rewriteS390X.go
src/cmd/internal/obj/arm/obj5.go
src/cmd/internal/obj/mips/obj0.go
src/cmd/internal/obj/ppc64/obj9.go
src/cmd/internal/obj/s390x/objz.go
src/runtime/asm_arm.s
src/runtime/asm_mips64x.s
src/runtime/asm_mipsx.s
src/runtime/asm_ppc64x.s
src/runtime/asm_s390x.s

index 4c8358f5957384ff104ad6aad97853650cdc3920..98627344b8c4acca0a1ee4d706a169e13cba8c07 100644 (file)
@@ -797,6 +797,10 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
                p.From.Name = obj.NAME_PARAM
                p.To.Type = obj.TYPE_REG
                p.To.Reg = v.Reg()
+       case ssa.OpARMLoweredGetCallerPC:
+               p := s.Prog(obj.AGETCALLERPC)
+               p.To.Type = obj.TYPE_REG
+               p.To.Reg = v.Reg()
        case ssa.OpARMFlagEQ,
                ssa.OpARMFlagLT_ULT,
                ssa.OpARMFlagLT_UGT,
index 7d2cd7e847ffd954653d969782a46d4901c19f96..62dafcb4dcaf03929bb62772d344d916863fb951 100644 (file)
@@ -2830,10 +2830,11 @@ func init() {
                },
                all...)
 
-       addF("runtime", "getcallerpc",
+       add("runtime", "getcallerpc",
                func(s *state, n *Node, args []*ssa.Value) *ssa.Value {
                        return s.newValue0(ssa.OpGetCallerPC, s.f.Config.Types.Uintptr)
-               }, sys.AMD64, sys.I386, sys.ARM64)
+               },
+               all...)
 
        add("runtime", "getcallersp",
                func(s *state, n *Node, args []*ssa.Value) *ssa.Value {
index 7a81ce911ba4ed4754be0026f18e15c1c201bd6f..2bf17dc4151d1fc59095f350165c63b1d969850d 100644 (file)
@@ -768,6 +768,10 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
                p.From.Name = obj.NAME_PARAM
                p.To.Type = obj.TYPE_REG
                p.To.Reg = v.Reg()
+       case ssa.OpMIPSLoweredGetCallerPC:
+               p := s.Prog(obj.AGETCALLERPC)
+               p.To.Type = obj.TYPE_REG
+               p.To.Reg = v.Reg()
        case ssa.OpClobber:
                // TODO: implement for clobberdead experiment. Nop is ok for now.
        default:
index 33b3152e189f95ad282ac07d3c32e149ee00ba3d..bf2076f5fb380d475e0bca93a0df9fc66e6a5318 100644 (file)
@@ -739,6 +739,10 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
                p.From.Name = obj.NAME_PARAM
                p.To.Type = obj.TYPE_REG
                p.To.Reg = v.Reg()
+       case ssa.OpMIPS64LoweredGetCallerPC:
+               p := s.Prog(obj.AGETCALLERPC)
+               p.To.Type = obj.TYPE_REG
+               p.To.Reg = v.Reg()
        case ssa.OpClobber:
                // TODO: implement for clobberdead experiment. Nop is ok for now.
        default:
index 4c91a04a03a38650339cdf3f4ee8135c5b9dfef4..9f6febd903723bde5da52e604f4f6cffac99570f 100644 (file)
@@ -431,6 +431,11 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
                p.To.Type = obj.TYPE_REG
                p.To.Reg = v.Reg()
 
+       case ssa.OpPPC64LoweredGetCallerPC:
+               p := s.Prog(obj.AGETCALLERPC)
+               p.To.Type = obj.TYPE_REG
+               p.To.Reg = v.Reg()
+
        case ssa.OpPPC64LoweredRound32F, ssa.OpPPC64LoweredRound64F:
                // input is already rounded
 
index eb7474e7fde7a4f51daea9b85d2c207ccd3c4b3f..6b8d8ab4b3d19081074995087153236c9c5b9429 100644 (file)
@@ -509,6 +509,10 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
                p.From.Name = obj.NAME_PARAM
                p.To.Type = obj.TYPE_REG
                p.To.Reg = v.Reg()
+       case ssa.OpS390XLoweredGetCallerPC:
+               p := s.Prog(obj.AGETCALLERPC)
+               p.To.Type = obj.TYPE_REG
+               p.To.Reg = v.Reg()
        case ssa.OpS390XCALLstatic, ssa.OpS390XCALLclosure, ssa.OpS390XCALLinter:
                s.Call(v)
        case ssa.OpS390XLoweredWB:
index 912539cb5b82be942e7badf9a55d0705d1f6b884..4714becd7326381de592f7b998a2e272d599cb51 100644 (file)
 // pseudo-ops
 (GetClosurePtr) -> (LoweredGetClosurePtr)
 (GetCallerSP) -> (LoweredGetCallerSP)
+(GetCallerPC) -> (LoweredGetCallerPC)
 
 // Absorb pseudo-ops into blocks.
 (If (Equal cc) yes no) -> (EQ cc yes no)
index 3b916e29aefa4c997de3228cd2b022ece72a630d..2df9003247267e6b2a3c6bf4dfc6c80363bf5aa5 100644 (file)
@@ -519,6 +519,12 @@ func init() {
                // LoweredGetCallerSP returns the SP of the caller of the current function.
                {name: "LoweredGetCallerSP", reg: gp01, rematerializeable: true},
 
+               // LoweredGetCallerPC evaluates to the PC to which its "caller" will return.
+               // I.e., if f calls g "calls" getcallerpc,
+               // the result should be the PC within f that g will return to.
+               // See runtime/stubs.go for a more detailed discussion.
+               {name: "LoweredGetCallerPC", reg: gp01, rematerializeable: true},
+
                // Constant flag values. For any comparison, there are 5 possible
                // outcomes: the three from the signed total order (<,==,>) and the
                // three from the unsigned total order. The == cases overlap.
index f097d93689fb0099fbb08faa1a9d16ce314f85e0..50fdf29b04fa87b68c95815987fc2214334b3f0e 100644 (file)
 // pseudo-ops
 (GetClosurePtr) -> (LoweredGetClosurePtr)
 (GetCallerSP) -> (LoweredGetCallerSP)
+(GetCallerPC) -> (LoweredGetCallerPC)
 
 (If cond yes no) -> (NE cond yes no)
 
index 61705678707a7db5ea2c74e9714b693b1e9ee094..f5e78ec2944a9721f55aa77dbdd7dd3420aacc7c 100644 (file)
 // pseudo-ops
 (GetClosurePtr) -> (LoweredGetClosurePtr)
 (GetCallerSP) -> (LoweredGetCallerSP)
+(GetCallerPC) -> (LoweredGetCallerPC)
 
 (If cond yes no) -> (NE cond yes no)
 
index 55f860f0536d6735569eb5de087fefd63fbf5cbc..5235930ccc5858df28c3749433667df8b332a03e 100644 (file)
@@ -409,6 +409,12 @@ func init() {
                // LoweredGetCallerSP returns the SP of the caller of the current function.
                {name: "LoweredGetCallerSP", reg: gp01, rematerializeable: true},
 
+               // LoweredGetCallerPC evaluates to the PC to which its "caller" will return.
+               // I.e., if f calls g "calls" getcallerpc,
+               // the result should be the PC within f that g will return to.
+               // See runtime/stubs.go for a more detailed discussion.
+               {name: "LoweredGetCallerPC", reg: gp01, rematerializeable: true},
+
                // LoweredWB invokes runtime.gcWriteBarrier. arg0=destptr, arg1=srcptr, arg2=mem, aux=runtime.gcWriteBarrier
                // It saves all GP registers if necessary,
                // but clobbers R31 (LR) because it's a call
index e07ad745b3d3f24b54b77b15e35dfcd9e8595d01..2605b60650bdb689bcf9f104129e9d4a6dc56668 100644 (file)
@@ -379,6 +379,12 @@ func init() {
                // LoweredGetCallerSP returns the SP of the caller of the current function.
                {name: "LoweredGetCallerSP", reg: gp01, rematerializeable: true},
 
+               // LoweredGetCallerPC evaluates to the PC to which its "caller" will return.
+               // I.e., if f calls g "calls" getcallerpc,
+               // the result should be the PC within f that g will return to.
+               // See runtime/stubs.go for a more detailed discussion.
+               {name: "LoweredGetCallerPC", reg: gp01, rematerializeable: true},
+
                // LoweredWB invokes runtime.gcWriteBarrier. arg0=destptr, arg1=srcptr, arg2=mem, aux=runtime.gcWriteBarrier
                // It saves all GP registers if necessary,
                // but clobbers R31 (LR) because it's a call
index 8f6929f9595c90934049529d2cc3e83e64ffd9fd..c97bbe2963c6d35d01a24dde926117726331357a 100644 (file)
 // Miscellaneous
 (GetClosurePtr) -> (LoweredGetClosurePtr)
 (GetCallerSP) -> (LoweredGetCallerSP)
+(GetCallerPC) -> (LoweredGetCallerPC)
 (IsNonNil ptr) -> (NotEqual (CMPconst [0] ptr))
 (IsInBounds idx len) -> (LessThan (CMPU idx len))
 (IsSliceInBounds idx len) -> (LessEqual (CMPU idx len))
index ad68794de0080e7afa9ecbc8cc11dd5836d1d1ad..fde88056d35cf6a5b08cf0bd18810bcb140720d8 100644 (file)
@@ -322,6 +322,12 @@ func init() {
                // LoweredGetCallerSP returns the SP of the caller of the current function.
                {name: "LoweredGetCallerSP", reg: gp01, rematerializeable: true},
 
+               // LoweredGetCallerPC evaluates to the PC to which its "caller" will return.
+               // I.e., if f calls g "calls" getcallerpc,
+               // the result should be the PC within f that g will return to.
+               // See runtime/stubs.go for a more detailed discussion.
+               {name: "LoweredGetCallerPC", reg: gp01, rematerializeable: true},
+
                //arg0=ptr,arg1=mem, returns void.  Faults if ptr is nil.
                {name: "LoweredNilCheck", argLength: 2, reg: regInfo{inputs: []regMask{gp | sp | sb}, clobbers: tmp}, clobberFlags: true, nilCheck: true, faultOnNilArg0: true},
                // Round ops to block fused-multiply-add extraction.
index 9debb25759d7b29995d1de11e7ae7c300d8b0975..ba0891c18728eeb867511c0a5ab7b782f1f2cbb0 100644 (file)
 (GetG mem) -> (LoweredGetG mem)
 (GetClosurePtr) -> (LoweredGetClosurePtr)
 (GetCallerSP) -> (LoweredGetCallerSP)
+(GetCallerPC) -> (LoweredGetCallerPC)
 (Addr {sym} base) -> (MOVDaddr {sym} base)
 (ITab (Load ptr mem)) -> (MOVDload ptr mem)
 
index 459148fc2aa43b283adbfeba26d882880b1a8b42..7a751a644c548f6985b4eb40c72d36f9d610ce9f 100644 (file)
@@ -451,6 +451,11 @@ func init() {
                // arg0=ptr,arg1=mem, returns void.  Faults if ptr is nil.
                // LoweredGetCallerSP returns the SP of the caller of the current function.
                {name: "LoweredGetCallerSP", reg: gp01, rematerializeable: true},
+               // LoweredGetCallerPC evaluates to the PC to which its "caller" will return.
+               // I.e., if f calls g "calls" getcallerpc,
+               // the result should be the PC within f that g will return to.
+               // See runtime/stubs.go for a more detailed discussion.
+               {name: "LoweredGetCallerPC", reg: gp01, rematerializeable: true},
                {name: "LoweredNilCheck", argLength: 2, reg: regInfo{inputs: []regMask{ptrsp}}, clobberFlags: true, nilCheck: true, faultOnNilArg0: true},
                // Round ops to block fused-multiply-add extraction.
                {name: "LoweredRound32F", argLength: 1, reg: fp11, resultInArg0: true, zeroWidth: true},
index 0bac31266a12d3c465901d9859ea5175fc559fb4..c78b8b663b0cc259067329a86dbbf181db916a90 100644 (file)
@@ -1019,6 +1019,7 @@ const (
        OpARMLoweredMove
        OpARMLoweredGetClosurePtr
        OpARMLoweredGetCallerSP
+       OpARMLoweredGetCallerPC
        OpARMFlagEQ
        OpARMFlagLT_ULT
        OpARMFlagLT_UGT
@@ -1374,6 +1375,7 @@ const (
        OpMIPSFPFlagFalse
        OpMIPSLoweredGetClosurePtr
        OpMIPSLoweredGetCallerSP
+       OpMIPSLoweredGetCallerPC
        OpMIPSLoweredWB
 
        OpMIPS64ADDV
@@ -1486,6 +1488,7 @@ const (
        OpMIPS64FPFlagFalse
        OpMIPS64LoweredGetClosurePtr
        OpMIPS64LoweredGetCallerSP
+       OpMIPS64LoweredGetCallerPC
        OpMIPS64LoweredWB
 
        OpPPC64ADD
@@ -1614,6 +1617,7 @@ const (
        OpPPC64FGreaterEqual
        OpPPC64LoweredGetClosurePtr
        OpPPC64LoweredGetCallerSP
+       OpPPC64LoweredGetCallerPC
        OpPPC64LoweredNilCheck
        OpPPC64LoweredRound32F
        OpPPC64LoweredRound64F
@@ -1826,6 +1830,7 @@ const (
        OpS390XLoweredGetG
        OpS390XLoweredGetClosurePtr
        OpS390XLoweredGetCallerSP
+       OpS390XLoweredGetCallerPC
        OpS390XLoweredNilCheck
        OpS390XLoweredRound32F
        OpS390XLoweredRound64F
@@ -13314,6 +13319,16 @@ var opcodeTable = [...]opInfo{
                        },
                },
        },
+       {
+               name:              "LoweredGetCallerPC",
+               argLen:            0,
+               rematerializeable: true,
+               reg: regInfo{
+                       outputs: []outputInfo{
+                               {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14
+                       },
+               },
+       },
        {
                name:   "FlagEQ",
                argLen: 0,
@@ -17995,6 +18010,16 @@ var opcodeTable = [...]opInfo{
                        },
                },
        },
+       {
+               name:              "LoweredGetCallerPC",
+               argLen:            0,
+               rematerializeable: true,
+               reg: regInfo{
+                       outputs: []outputInfo{
+                               {0, 335544318}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R28 R31
+                       },
+               },
+       },
        {
                name:         "LoweredWB",
                auxType:      auxSym,
@@ -19515,6 +19540,16 @@ var opcodeTable = [...]opInfo{
                        },
                },
        },
+       {
+               name:              "LoweredGetCallerPC",
+               argLen:            0,
+               rematerializeable: true,
+               reg: regInfo{
+                       outputs: []outputInfo{
+                               {0, 167772158}, // R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31
+                       },
+               },
+       },
        {
                name:         "LoweredWB",
                auxType:      auxSym,
@@ -21203,6 +21238,16 @@ var opcodeTable = [...]opInfo{
                        },
                },
        },
+       {
+               name:              "LoweredGetCallerPC",
+               argLen:            0,
+               rematerializeable: true,
+               reg: regInfo{
+                       outputs: []outputInfo{
+                               {0, 1073733624}, // R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R14 R15 R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29
+                       },
+               },
+       },
        {
                name:           "LoweredNilCheck",
                argLen:         2,
@@ -24309,6 +24354,16 @@ var opcodeTable = [...]opInfo{
                        },
                },
        },
+       {
+               name:              "LoweredGetCallerPC",
+               argLen:            0,
+               rematerializeable: true,
+               reg: regInfo{
+                       outputs: []outputInfo{
+                               {0, 21503}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14
+                       },
+               },
+       },
        {
                name:           "LoweredNilCheck",
                argLen:         2,
index 6d3ab83ce55c0376fed723ac464bf6999074c1d5..2622913eae8dca2e8bed1746c8a5aeeb587c506f 100644 (file)
@@ -551,6 +551,8 @@ func rewriteValueARM(v *Value) bool {
                return rewriteValueARM_OpGeq8_0(v)
        case OpGeq8U:
                return rewriteValueARM_OpGeq8U_0(v)
+       case OpGetCallerPC:
+               return rewriteValueARM_OpGetCallerPC_0(v)
        case OpGetCallerSP:
                return rewriteValueARM_OpGetCallerSP_0(v)
        case OpGetClosurePtr:
@@ -18584,6 +18586,15 @@ func rewriteValueARM_OpGeq8U_0(v *Value) bool {
                return true
        }
 }
+func rewriteValueARM_OpGetCallerPC_0(v *Value) bool {
+       // match: (GetCallerPC)
+       // cond:
+       // result: (LoweredGetCallerPC)
+       for {
+               v.reset(OpARMLoweredGetCallerPC)
+               return true
+       }
+}
 func rewriteValueARM_OpGetCallerSP_0(v *Value) bool {
        // match: (GetCallerSP)
        // cond:
index b33afcc73d9e1b103b882c47c344067ca2a57ddd..c101e91636fdde510dfa83bcb94e5dc697827408 100644 (file)
@@ -145,6 +145,8 @@ func rewriteValueMIPS(v *Value) bool {
                return rewriteValueMIPS_OpGeq8_0(v)
        case OpGeq8U:
                return rewriteValueMIPS_OpGeq8U_0(v)
+       case OpGetCallerPC:
+               return rewriteValueMIPS_OpGetCallerPC_0(v)
        case OpGetCallerSP:
                return rewriteValueMIPS_OpGetCallerSP_0(v)
        case OpGetClosurePtr:
@@ -1760,6 +1762,15 @@ func rewriteValueMIPS_OpGeq8U_0(v *Value) bool {
                return true
        }
 }
+func rewriteValueMIPS_OpGetCallerPC_0(v *Value) bool {
+       // match: (GetCallerPC)
+       // cond:
+       // result: (LoweredGetCallerPC)
+       for {
+               v.reset(OpMIPSLoweredGetCallerPC)
+               return true
+       }
+}
 func rewriteValueMIPS_OpGetCallerSP_0(v *Value) bool {
        // match: (GetCallerSP)
        // cond:
index 77573d784ab7fbc7a9e021cb9628feb4ac1f8b60..084463a10fba14a75065a1e486a68201ef19ae08 100644 (file)
@@ -169,6 +169,8 @@ func rewriteValueMIPS64(v *Value) bool {
                return rewriteValueMIPS64_OpGeq8_0(v)
        case OpGeq8U:
                return rewriteValueMIPS64_OpGeq8U_0(v)
+       case OpGetCallerPC:
+               return rewriteValueMIPS64_OpGetCallerPC_0(v)
        case OpGetCallerSP:
                return rewriteValueMIPS64_OpGetCallerSP_0(v)
        case OpGetClosurePtr:
@@ -1931,6 +1933,15 @@ func rewriteValueMIPS64_OpGeq8U_0(v *Value) bool {
                return true
        }
 }
+func rewriteValueMIPS64_OpGetCallerPC_0(v *Value) bool {
+       // match: (GetCallerPC)
+       // cond:
+       // result: (LoweredGetCallerPC)
+       for {
+               v.reset(OpMIPS64LoweredGetCallerPC)
+               return true
+       }
+}
 func rewriteValueMIPS64_OpGetCallerSP_0(v *Value) bool {
        // match: (GetCallerSP)
        // cond:
index 5c4d81da8002c3001ac3e31c7eb66990d3e7cc33..8f2c16cd6bd311b8f9927ba4505e92141c02c7b3 100644 (file)
@@ -191,6 +191,8 @@ func rewriteValuePPC64(v *Value) bool {
                return rewriteValuePPC64_OpGeq8_0(v)
        case OpGeq8U:
                return rewriteValuePPC64_OpGeq8U_0(v)
+       case OpGetCallerPC:
+               return rewriteValuePPC64_OpGetCallerPC_0(v)
        case OpGetCallerSP:
                return rewriteValuePPC64_OpGetCallerSP_0(v)
        case OpGetClosurePtr:
@@ -2110,6 +2112,15 @@ func rewriteValuePPC64_OpGeq8U_0(v *Value) bool {
                return true
        }
 }
+func rewriteValuePPC64_OpGetCallerPC_0(v *Value) bool {
+       // match: (GetCallerPC)
+       // cond:
+       // result: (LoweredGetCallerPC)
+       for {
+               v.reset(OpPPC64LoweredGetCallerPC)
+               return true
+       }
+}
 func rewriteValuePPC64_OpGetCallerSP_0(v *Value) bool {
        // match: (GetCallerSP)
        // cond:
index 6ad6d300433252cefaf2b3d162cc9882afa2b0d8..959ed2b4444cb27be5cfa693e22feeca51695912 100644 (file)
@@ -187,6 +187,8 @@ func rewriteValueS390X(v *Value) bool {
                return rewriteValueS390X_OpGeq8_0(v)
        case OpGeq8U:
                return rewriteValueS390X_OpGeq8U_0(v)
+       case OpGetCallerPC:
+               return rewriteValueS390X_OpGetCallerPC_0(v)
        case OpGetCallerSP:
                return rewriteValueS390X_OpGetCallerSP_0(v)
        case OpGetClosurePtr:
@@ -2277,6 +2279,15 @@ func rewriteValueS390X_OpGeq8U_0(v *Value) bool {
                return true
        }
 }
+func rewriteValueS390X_OpGetCallerPC_0(v *Value) bool {
+       // match: (GetCallerPC)
+       // cond:
+       // result: (LoweredGetCallerPC)
+       for {
+               v.reset(OpS390XLoweredGetCallerPC)
+               return true
+       }
+}
 func rewriteValueS390X_OpGetCallerSP_0(v *Value) bool {
        // match: (GetCallerSP)
        // cond:
index ddafa9cec6736432f98f39b306af522a29801324..a177e5f75fd37a42e904851252e1d30867fea3c1 100644 (file)
@@ -643,6 +643,19 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
                        if p.From.Type == obj.TYPE_ADDR && p.From.Reg == REGSP && p.To.Type == obj.TYPE_REG && p.To.Reg == REGSP {
                                p.Spadj = int32(-p.From.Offset)
                        }
+
+               case obj.AGETCALLERPC:
+                       if cursym.Leaf() {
+                               /* MOVW LR, Rd */
+                               p.As = AMOVW
+                               p.From.Type = obj.TYPE_REG
+                               p.From.Reg = REGLINK
+                       } else {
+                               /* MOVW (RSP), Rd */
+                               p.As = AMOVW
+                               p.From.Type = obj.TYPE_MEM
+                               p.From.Reg = REGSP
+                       }
                }
        }
 }
index 697b2b7acb668dc94cac8c4fa860b79fbea7770d..5bbc4ce638d7b6684569e069af506d3cab79e753 100644 (file)
@@ -536,6 +536,19 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
                        if p.To.Type == obj.TYPE_REG && p.To.Reg == REGSP && p.From.Type == obj.TYPE_CONST {
                                p.Spadj = int32(-p.From.Offset)
                        }
+
+               case obj.AGETCALLERPC:
+                       if cursym.Leaf() {
+                               /* MOV LR, Rd */
+                               p.As = mov
+                               p.From.Type = obj.TYPE_REG
+                               p.From.Reg = REGLINK
+                       } else {
+                               /* MOV (RSP), Rd */
+                               p.As = mov
+                               p.From.Type = obj.TYPE_MEM
+                               p.From.Reg = REGSP
+                       }
                }
        }
 
index 4982a85fdbbebd6677fdd1fbf90c955130f3d8d0..c3a9443228483aba56039924345c0ecc1b44afa2 100644 (file)
@@ -781,6 +781,18 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
                        if p.To.Type == obj.TYPE_REG && p.To.Reg == REGSP && p.From.Type == obj.TYPE_CONST {
                                p.Spadj = int32(-p.From.Offset)
                        }
+               case obj.AGETCALLERPC:
+                       if cursym.Leaf() {
+                               /* MOVD LR, Rd */
+                               p.As = AMOVD
+                               p.From.Type = obj.TYPE_REG
+                               p.From.Reg = REG_LR
+                       } else {
+                               /* MOVD (RSP), Rd */
+                               p.As = AMOVD
+                               p.From.Type = obj.TYPE_MEM
+                               p.From.Reg = REGSP
+                       }
                }
        }
 }
index 05d31d1ffd09c4d0a912f51abfc59b9dc3d7551f..2408af82596a44cf89365f877ab4e97f86571514 100644 (file)
@@ -524,6 +524,19 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
                        if p.To.Type == obj.TYPE_REG && p.To.Reg == REGSP && p.From.Type == obj.TYPE_CONST {
                                p.Spadj = int32(-p.From.Offset)
                        }
+
+               case obj.AGETCALLERPC:
+                       if cursym.Leaf() {
+                               /* MOVD LR, Rd */
+                               p.As = AMOVD
+                               p.From.Type = obj.TYPE_REG
+                               p.From.Reg = REG_LR
+                       } else {
+                               /* MOVD (RSP), Rd */
+                               p.As = AMOVD
+                               p.From.Type = obj.TYPE_MEM
+                               p.From.Reg = REGSP
+                       }
                }
        }
        if wasSplit {
index 74b1001fc3510b8e0fc6a477797defeb4ccd4284..a65be1cef29ab8af57a0c6f4cf6a105081a37455 100644 (file)
@@ -760,11 +760,6 @@ TEXT setg<>(SB),NOSPLIT|NOFRAME,$0-0
        MOVW    g, R0
        RET
 
-TEXT runtime·getcallerpc(SB),NOSPLIT|NOFRAME,$0-4
-       MOVW    0(R13), R0              // LR saved by caller
-       MOVW    R0, ret+0(FP)
-       RET
-
 TEXT runtime·emptyfunc(SB),0,$0-0
        RET
 
index e4a5a32ad0f99f8a859ada04a53b658d18f7ccc6..4b842ff0f221ec3703710f6f2ddf7d5ef4f638cb 100644 (file)
@@ -608,11 +608,6 @@ TEXT setg_gcc<>(SB),NOSPLIT,$0-0
        JAL     runtime·save_g(SB)
        RET
 
-TEXT runtime·getcallerpc(SB),NOSPLIT|NOFRAME,$0-8
-       MOVV    0(R29), R1              // LR saved by caller
-       MOVV    R1, ret+0(FP)
-       RET
-
 TEXT runtime·abort(SB),NOSPLIT|NOFRAME,$0-0
        MOVW    (R0), R0
        UNDEF
index ef63f4128927d0ee6fda4ef151b4a4de4c66459f..654eb6572c5bf8dfe68fc60806851adc826727bb 100644 (file)
@@ -611,11 +611,6 @@ TEXT setg_gcc<>(SB),NOSPLIT,$0
        JAL     runtime·save_g(SB)
        RET
 
-TEXT runtime·getcallerpc(SB),NOSPLIT|NOFRAME,$0-4
-       MOVW    0(R29), R1      // LR saved by caller
-       MOVW    R1, ret+0(FP)
-       RET
-
 TEXT runtime·abort(SB),NOSPLIT,$0-0
        UNDEF
 
index b565a1370a613aed3cb48b0079ef3b4c2c02149d..93f9110cc07e1543145605ad1ea68aa9d2c8e009 100644 (file)
@@ -705,11 +705,6 @@ TEXT setg_gcc<>(SB),NOSPLIT|NOFRAME,$0-0
        MOVD    R4, LR
        RET
 
-TEXT runtime·getcallerpc(SB),NOSPLIT|NOFRAME,$0-8
-       MOVD    0(R1), R3               // LR saved by caller
-       MOVD    R3, ret+0(FP)
-       RET
-
 TEXT runtime·abort(SB),NOSPLIT|NOFRAME,$0-0
        MOVW    (R0), R0
        UNDEF
index b569d8b421431fc6d8295264893dc468a5ce79eb..9ef1b8a4c8dce33416d9f70a4fd788d3168d8327 100644 (file)
@@ -725,11 +725,6 @@ TEXT setg_gcc<>(SB),NOSPLIT|NOFRAME,$0-0
        MOVD    R1, LR
        RET
 
-TEXT runtime·getcallerpc(SB),NOSPLIT|NOFRAME,$0-8
-       MOVD    0(R15), R3              // LR saved by caller
-       MOVD    R3, ret+0(FP)
-       RET
-
 TEXT runtime·abort(SB),NOSPLIT|NOFRAME,$0-0
        MOVW    (R0), R0
        UNDEF