Commit c04813e1 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/internal/obj: combine Pcrel and Comefrom

They're each architecture-specific.
Let them share.

Reduces Prog size to 288, which is the
next smaller malloc class.

Reduces inuse_space while compiling the
rotate tests by ~3.2%.

Change-Id: Ica8ec90e466c97b569745fffff0e5acd364e55fa
Reviewed-on: https://go-review.googlesource.com/10514Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 4ed7d06a
...@@ -900,7 +900,7 @@ func addpool(ctxt *obj.Link, p *obj.Prog, a *obj.Addr) { ...@@ -900,7 +900,7 @@ func addpool(ctxt *obj.Link, p *obj.Prog, a *obj.Addr) {
t.To.Name = a.Name t.To.Name = a.Name
if ctxt.Flag_shared != 0 && t.To.Sym != nil { if ctxt.Flag_shared != 0 && t.To.Sym != nil {
t.Pcrel = p t.Rel = p
} }
case C_SROREG, case C_SROREG,
...@@ -917,9 +917,9 @@ func addpool(ctxt *obj.Link, p *obj.Prog, a *obj.Addr) { ...@@ -917,9 +917,9 @@ func addpool(ctxt *obj.Link, p *obj.Prog, a *obj.Addr) {
t.To.Offset = ctxt.Instoffset t.To.Offset = ctxt.Instoffset
} }
if t.Pcrel == nil { if t.Rel == nil {
for q := ctxt.Blitrl; q != nil; q = q.Link { /* could hash on t.t0.offset */ for q := ctxt.Blitrl; q != nil; q = q.Link { /* could hash on t.t0.offset */
if q.Pcrel == nil && q.To == t.To { if q.Rel == nil && q.To == t.To {
p.Pcond = q p.Pcond = q
return return
} }
...@@ -1671,11 +1671,11 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -1671,11 +1671,11 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
if rel.Sym == ctxt.Tlsg && ctxt.Tlsg.Type == 0 { if rel.Sym == ctxt.Tlsg && ctxt.Tlsg.Type == 0 {
rel.Type = obj.R_TLS rel.Type = obj.R_TLS
if ctxt.Flag_shared != 0 { if ctxt.Flag_shared != 0 {
rel.Add += ctxt.Pc - p.Pcrel.Pc - 8 - int64(rel.Siz) rel.Add += ctxt.Pc - p.Rel.Pc - 8 - int64(rel.Siz)
} }
} else if ctxt.Flag_shared != 0 { } else if ctxt.Flag_shared != 0 {
rel.Type = obj.R_PCREL rel.Type = obj.R_PCREL
rel.Add += ctxt.Pc - p.Pcrel.Pc - 8 rel.Add += ctxt.Pc - p.Rel.Pc - 8
} else { } else {
rel.Type = obj.R_ADDR rel.Type = obj.R_ADDR
} }
...@@ -2062,7 +2062,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { ...@@ -2062,7 +2062,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
if o.flag&LPCREL != 0 { if o.flag&LPCREL != 0 {
rel.Type = obj.R_PCREL rel.Type = obj.R_PCREL
rel.Add += ctxt.Pc - p.Pcrel.Pc - 16 + int64(rel.Siz) rel.Add += ctxt.Pc - p.Rel.Pc - 16 + int64(rel.Siz)
} else { } else {
rel.Type = obj.R_ADDR rel.Type = obj.R_ADDR
} }
......
...@@ -160,7 +160,7 @@ func linkcase(casep *obj.Prog) { ...@@ -160,7 +160,7 @@ func linkcase(casep *obj.Prog) {
for p := casep; p != nil; p = p.Link { for p := casep; p != nil; p = p.Link {
if p.As == ABCASE { if p.As == ABCASE {
for ; p != nil && p.As == ABCASE; p = p.Link { for ; p != nil && p.As == ABCASE; p = p.Link {
p.Pcrel = casep p.Rel = casep
} }
break break
} }
......
...@@ -200,30 +200,29 @@ const ( ...@@ -200,30 +200,29 @@ const (
// TODO(rsc): Describe prog. // TODO(rsc): Describe prog.
// TODO(rsc): Describe TEXT/GLOBL flag in from3, DATA width in from3. // TODO(rsc): Describe TEXT/GLOBL flag in from3, DATA width in from3.
type Prog struct { type Prog struct {
Ctxt *Link Ctxt *Link
Link *Prog Link *Prog
From Addr From Addr
From3 *Addr // optional From3 *Addr // optional
To Addr To Addr
Opt interface{} Opt interface{}
Forwd *Prog Forwd *Prog
Pcond *Prog Pcond *Prog
Comefrom *Prog Rel *Prog // Source of forward jumps on x86; pcrel on arm
Pcrel *Prog Pc int64
Pc int64 Lineno int32
Lineno int32 Spadj int32
Spadj int32 As int16
As int16 Reg int16
Reg int16 RegTo2 int16 // 2nd register output operand
RegTo2 int16 // 2nd register output operand Mark uint16
Mark uint16 Optab uint16
Optab uint16 Scond uint8
Scond uint8 Back uint8
Back uint8 Ft uint8
Ft uint8 Tt uint8
Tt uint8 Isize uint8
Isize uint8 Mode int8
Mode int8
Info ProgInfo Info ProgInfo
} }
......
...@@ -1690,7 +1690,7 @@ func span6(ctxt *obj.Link, s *obj.LSym) { ...@@ -1690,7 +1690,7 @@ func span6(ctxt *obj.Link, s *obj.LSym) {
p.Pc = int64(c) p.Pc = int64(c)
// process forward jumps to p // process forward jumps to p
for q = p.Comefrom; q != nil; q = q.Forwd { for q = p.Rel; q != nil; q = q.Forwd {
v = int32(p.Pc - (q.Pc + int64(q.Mark))) v = int32(p.Pc - (q.Pc + int64(q.Mark)))
if q.Back&2 != 0 { // short if q.Back&2 != 0 { // short
if v > 127 { if v > 127 {
...@@ -1715,7 +1715,7 @@ func span6(ctxt *obj.Link, s *obj.LSym) { ...@@ -1715,7 +1715,7 @@ func span6(ctxt *obj.Link, s *obj.LSym) {
} }
} }
p.Comefrom = nil p.Rel = nil
p.Pc = int64(c) p.Pc = int64(c)
asmins(ctxt, p) asmins(ctxt, p)
...@@ -3547,9 +3547,9 @@ func doasm(ctxt *obj.Link, p *obj.Prog) { ...@@ -3547,9 +3547,9 @@ func doasm(ctxt *obj.Link, p *obj.Prog) {
} }
// Annotate target; will fill in later. // Annotate target; will fill in later.
p.Forwd = q.Comefrom p.Forwd = q.Rel
q.Comefrom = p q.Rel = p
if p.Back&2 != 0 { // short if p.Back&2 != 0 { // short
if p.As == AJCXZL { if p.As == AJCXZL {
ctxt.Andptr[0] = 0x67 ctxt.Andptr[0] = 0x67
......
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