Commit 41a7dca2 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

[dev.ssa] cmd/compile: unify and check LoweredGetClosurePtr

The comments were mostly duplicated; unify them.
Add a check that the required invariant holds.

Change-Id: I42fe09dcd1fac76d3c4e191f7a58c591c5ce429b
Reviewed-on: https://go-review.googlesource.com/24719
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: default avatarDavid Chase <drchase@google.com>
parent ad8b8f64
...@@ -720,11 +720,8 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) { ...@@ -720,11 +720,8 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
case ssa.OpArg: case ssa.OpArg:
// input args need no code // input args need no code
case ssa.OpAMD64LoweredGetClosurePtr: case ssa.OpAMD64LoweredGetClosurePtr:
// Output is hardwired to DX only, // Closure pointer is DX.
// and DX contains the closure pointer on gc.CheckLoweredGetClosurePtr(v)
// closure entry, and this "instruction"
// is scheduled to the very beginning
// of the entry block.
case ssa.OpAMD64LoweredGetG: case ssa.OpAMD64LoweredGetG:
r := gc.SSARegNum(v) r := gc.SSARegNum(v)
// See the comments in cmd/internal/obj/x86/obj6.go // See the comments in cmd/internal/obj/x86/obj6.go
......
...@@ -708,12 +708,8 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) { ...@@ -708,12 +708,8 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
ssa.OpARMLoweredSelect1: ssa.OpARMLoweredSelect1:
// nothing to do // nothing to do
case ssa.OpARMLoweredGetClosurePtr: case ssa.OpARMLoweredGetClosurePtr:
// Output is hardwired to R7 (arm.REGCTXT) only, // Closure pointer is R7 (arm.REGCTXT).
// and R7 contains the closure pointer on gc.CheckLoweredGetClosurePtr(v)
// closure entry, and this "instruction"
// is scheduled to the very beginning
// of the entry block.
// nothing to do here.
default: default:
v.Unimplementedf("genValue not implemented: %s", v.LongString()) v.Unimplementedf("genValue not implemented: %s", v.LongString())
} }
......
...@@ -4281,6 +4281,16 @@ func CheckLoweredPhi(v *ssa.Value) { ...@@ -4281,6 +4281,16 @@ func CheckLoweredPhi(v *ssa.Value) {
} }
} }
// CheckLoweredGetClosurePtr checks that v is the first instruction in the function's entry block.
// The output of LoweredGetClosurePtr is generally hardwired to the correct register.
// That register contains the closure pointer on closure entry.
func CheckLoweredGetClosurePtr(v *ssa.Value) {
entry := v.Block.Func.Entry
if entry != v.Block || entry.Values[0] != v {
Fatalf("badly placed LoweredGetClosurePtr: %v %v", v.Block, v)
}
}
// AutoVar returns a *Node and int64 representing the auto variable and offset within it // AutoVar returns a *Node and int64 representing the auto variable and offset within it
// where v should be spilled. // where v should be spilled.
func AutoVar(v *ssa.Value) (*Node, int64) { func AutoVar(v *ssa.Value) (*Node, int64) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment