1
0
mirror of https://github.com/golang/go synced 2024-11-24 01:40:12 -07:00

[dev.inline] cmd/internal/obj: use src.Pos in obj.Prog

This will let us use the src.Pos struct to thread inlining
information through to obj.

Change-Id: I96a16d3531167396988df66ae70f0b729049cc82
Reviewed-on: https://go-review.googlesource.com/34195
Run-TryBot: David Lazar <lazard@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
This commit is contained in:
David Lazar 2016-12-09 12:34:01 -05:00
parent 4b8895e2dd
commit ad4efedc6c
6 changed files with 14 additions and 13 deletions

View File

@ -13,6 +13,7 @@ import (
"cmd/asm/internal/flags"
"cmd/asm/internal/lex"
"cmd/internal/obj"
"cmd/internal/src"
"cmd/internal/sys"
)
@ -163,7 +164,7 @@ func (p *Parser) asmText(word string, operands [][]lex.Token) {
prog := &obj.Prog{
Ctxt: p.ctxt,
As: obj.ATEXT,
Lineno: p.histLineNum,
Lineno: src.MakePos(p.histLineNum),
From: nameAddr,
From3: &obj.Addr{
Type: obj.TYPE_CONST,
@ -296,7 +297,7 @@ func (p *Parser) asmPCData(word string, operands [][]lex.Token) {
prog := &obj.Prog{
Ctxt: p.ctxt,
As: obj.APCDATA,
Lineno: p.histLineNum,
Lineno: src.MakePos(p.histLineNum),
From: key,
To: value,
}
@ -326,7 +327,7 @@ func (p *Parser) asmFuncData(word string, operands [][]lex.Token) {
prog := &obj.Prog{
Ctxt: p.ctxt,
As: obj.AFUNCDATA,
Lineno: p.histLineNum,
Lineno: src.MakePos(p.histLineNum),
From: valueAddr,
To: nameAddr,
}
@ -341,7 +342,7 @@ func (p *Parser) asmJump(op obj.As, cond string, a []obj.Addr) {
var target *obj.Addr
prog := &obj.Prog{
Ctxt: p.ctxt,
Lineno: p.histLineNum,
Lineno: src.MakePos(p.histLineNum),
As: op,
}
switch len(a) {
@ -469,7 +470,7 @@ func (p *Parser) asmInstruction(op obj.As, cond string, a []obj.Addr) {
// fmt.Printf("%s %+v\n", op, a)
prog := &obj.Prog{
Ctxt: p.ctxt,
Lineno: p.histLineNum,
Lineno: src.MakePos(p.histLineNum),
As: op,
}
switch len(a) {

View File

@ -45,7 +45,7 @@ func Prog(as obj.As) *obj.Prog {
}
p.As = as
p.Lineno = int32(lineno.Line()) // TODO(gri) fix this
p.Lineno = lineno
return p
}

View File

@ -17,7 +17,6 @@ package gc
import (
"cmd/internal/obj"
"cmd/internal/src"
"cmd/internal/sys"
"crypto/md5"
"fmt"
@ -1254,7 +1253,7 @@ func livenessepilogue(lv *Liveness) {
if !n.Name.Needzero {
n.Name.Needzero = true
if debuglive >= 1 {
Warnl(src.MakePos(p.Lineno), "%v: %L is ambiguously live", Curfn.Func.Nname, n)
Warnl(p.Lineno, "%v: %L is ambiguously live", Curfn.Func.Nname, n)
}
}
}
@ -1345,7 +1344,7 @@ func livenessepilogue(lv *Liveness) {
}
n := lv.vars[j]
if n.Class != PPARAM {
yyerrorl(src.MakePos(p.Lineno), "internal error: %v %L recorded as live on entry, p.Pc=%v", Curfn.Func.Nname, n, p.Pc)
yyerrorl(p.Lineno, "internal error: %v %L recorded as live on entry, p.Pc=%v", Curfn.Func.Nname, n, p.Pc)
}
}
}

View File

@ -32,6 +32,7 @@ package obj
import (
"bufio"
"cmd/internal/src"
"cmd/internal/sys"
"fmt"
)
@ -238,7 +239,7 @@ type Prog struct {
Forwd *Prog // for x86 back end
Rel *Prog // for x86, arm back ends
Pc int64 // for back ends or assembler: virtual or actual program counter, depending on phase
Lineno int32 // line number of this instruction
Lineno src.Pos // line number of this instruction
Spadj int32 // effect of instruction on stack pointer (increment or decrement amount)
As As // assembler opcode
Reg int16 // 2nd source operand

View File

@ -138,10 +138,10 @@ func funcpctab(ctxt *Link, dst *Pcdata, func_ *LSym, desc string, valfunc func(*
// Because p->lineno applies to p, phase == 0 (before p)
// takes care of the update.
func pctofileline(ctxt *Link, sym *LSym, oldval int32, p *Prog, phase int32, arg interface{}) int32 {
if p.As == ATEXT || p.As == ANOP || p.As == AUSEFIELD || p.Lineno == 0 || phase == 1 {
if p.As == ATEXT || p.As == ANOP || p.As == AUSEFIELD || p.Lineno.Line() == 0 || phase == 1 {
return oldval
}
f, l := linkgetline(ctxt, p.Lineno)
f, l := linkgetline(ctxt, p.Lineno.Line())
if f == nil {
// print("getline failed for %s %v\n", ctxt->cursym->name, p);
return oldval

View File

@ -59,7 +59,7 @@ func Getgoextlinkenabled() string {
}
func (p *Prog) Line() string {
return p.Ctxt.LineHist.LineString(int(p.Lineno))
return p.Ctxt.LineHist.LineString(int(p.Lineno.Line()))
}
var armCondCode = []string{