Skip to content

Commit

Permalink
cmd/compile: funnel SSA Prog creation through SSAGenState
Browse files Browse the repository at this point in the history
Step one in eliminating Prog-related globals.

Passes toolstash-check -all.

Updates golang#15756

Change-Id: I3b777fb5a7716f2d9da3067fbd94c28ca894a465
Reviewed-on: https://go-review.googlesource.com/38450
Run-TryBot: Josh Bleecher Snyder <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Matthew Dempsky <[email protected]>
  • Loading branch information
josharian committed Mar 22, 2017
1 parent 3b39f52 commit 0a94daa
Show file tree
Hide file tree
Showing 10 changed files with 721 additions and 717 deletions.
204 changes: 102 additions & 102 deletions src/cmd/compile/internal/amd64/ssa.go

Large diffs are not rendered by default.

174 changes: 87 additions & 87 deletions src/cmd/compile/internal/arm/ssa.go

Large diffs are not rendered by default.

134 changes: 67 additions & 67 deletions src/cmd/compile/internal/arm64/ssa.go

Large diffs are not rendered by default.

30 changes: 17 additions & 13 deletions src/cmd/compile/internal/gc/ssa.go
Original file line number Diff line number Diff line change
Expand Up @@ -4253,6 +4253,11 @@ type SSAGenState struct {
stackMapIndex map[*ssa.Value]int
}

// Prog appends a new Prog.
func (s *SSAGenState) Prog(as obj.As) *obj.Prog {
return Prog(as)
}

// Pc returns the current Prog.
func (s *SSAGenState) Pc() *obj.Prog {
return pc
Expand Down Expand Up @@ -4411,11 +4416,11 @@ type FloatingEQNEJump struct {
Index int
}

func oneFPJump(b *ssa.Block, jumps *FloatingEQNEJump, likely ssa.BranchPrediction, branches []Branch) []Branch {
p := Prog(jumps.Jump)
func (s *SSAGenState) oneFPJump(b *ssa.Block, jumps *FloatingEQNEJump, likely ssa.BranchPrediction) {
p := s.Prog(jumps.Jump)
p.To.Type = obj.TYPE_BRANCH
to := jumps.Index
branches = append(branches, Branch{p, b.Succs[to].Block()})
s.Branches = append(s.Branches, Branch{p, b.Succs[to].Block()})
if to == 1 {
likely = -likely
}
Expand All @@ -4431,22 +4436,21 @@ func oneFPJump(b *ssa.Block, jumps *FloatingEQNEJump, likely ssa.BranchPredictio
p.From.Type = obj.TYPE_CONST
p.From.Offset = 1
}
return branches
}

func SSAGenFPJump(s *SSAGenState, b, next *ssa.Block, jumps *[2][2]FloatingEQNEJump) {
likely := b.Likely
switch next {
case b.Succs[0].Block():
s.Branches = oneFPJump(b, &jumps[0][0], likely, s.Branches)
s.Branches = oneFPJump(b, &jumps[0][1], likely, s.Branches)
s.oneFPJump(b, &jumps[0][0], likely)
s.oneFPJump(b, &jumps[0][1], likely)
case b.Succs[1].Block():
s.Branches = oneFPJump(b, &jumps[1][0], likely, s.Branches)
s.Branches = oneFPJump(b, &jumps[1][1], likely, s.Branches)
s.oneFPJump(b, &jumps[1][0], likely)
s.oneFPJump(b, &jumps[1][1], likely)
default:
s.Branches = oneFPJump(b, &jumps[1][0], likely, s.Branches)
s.Branches = oneFPJump(b, &jumps[1][1], likely, s.Branches)
q := Prog(obj.AJMP)
s.oneFPJump(b, &jumps[1][0], likely)
s.oneFPJump(b, &jumps[1][1], likely)
q := s.Prog(obj.AJMP)
q.To.Type = obj.TYPE_BRANCH
s.Branches = append(s.Branches, Branch{q, b.Succs[1].Block()})
}
Expand Down Expand Up @@ -4621,7 +4625,7 @@ func (s *SSAGenState) Call(v *ssa.Value) *obj.Prog {
if !ok {
Fatalf("missing stack map index for %v", v.LongString())
}
p := Prog(obj.APCDATA)
p := s.Prog(obj.APCDATA)
Addrconst(&p.From, obj.PCDATA_StackMapIndex)
Addrconst(&p.To, int64(idx))

Expand All @@ -4637,7 +4641,7 @@ func (s *SSAGenState) Call(v *ssa.Value) *obj.Prog {
thearch.Ginsnop()
}

p = Prog(obj.ACALL)
p = s.Prog(obj.ACALL)
if sym, ok := v.Aux.(*obj.LSym); ok {
p.To.Type = obj.TYPE_MEM
p.To.Name = obj.NAME_EXTERN
Expand Down
Loading

0 comments on commit 0a94daa

Please sign in to comment.