mirror of
https://github.com/golang/go.git
synced 2025-05-16 04:44:39 +00: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:
parent
4b8895e2dd
commit
ad4efedc6c
@ -13,6 +13,7 @@ import (
|
|||||||
"cmd/asm/internal/flags"
|
"cmd/asm/internal/flags"
|
||||||
"cmd/asm/internal/lex"
|
"cmd/asm/internal/lex"
|
||||||
"cmd/internal/obj"
|
"cmd/internal/obj"
|
||||||
|
"cmd/internal/src"
|
||||||
"cmd/internal/sys"
|
"cmd/internal/sys"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -163,7 +164,7 @@ func (p *Parser) asmText(word string, operands [][]lex.Token) {
|
|||||||
prog := &obj.Prog{
|
prog := &obj.Prog{
|
||||||
Ctxt: p.ctxt,
|
Ctxt: p.ctxt,
|
||||||
As: obj.ATEXT,
|
As: obj.ATEXT,
|
||||||
Lineno: p.histLineNum,
|
Lineno: src.MakePos(p.histLineNum),
|
||||||
From: nameAddr,
|
From: nameAddr,
|
||||||
From3: &obj.Addr{
|
From3: &obj.Addr{
|
||||||
Type: obj.TYPE_CONST,
|
Type: obj.TYPE_CONST,
|
||||||
@ -296,7 +297,7 @@ func (p *Parser) asmPCData(word string, operands [][]lex.Token) {
|
|||||||
prog := &obj.Prog{
|
prog := &obj.Prog{
|
||||||
Ctxt: p.ctxt,
|
Ctxt: p.ctxt,
|
||||||
As: obj.APCDATA,
|
As: obj.APCDATA,
|
||||||
Lineno: p.histLineNum,
|
Lineno: src.MakePos(p.histLineNum),
|
||||||
From: key,
|
From: key,
|
||||||
To: value,
|
To: value,
|
||||||
}
|
}
|
||||||
@ -326,7 +327,7 @@ func (p *Parser) asmFuncData(word string, operands [][]lex.Token) {
|
|||||||
prog := &obj.Prog{
|
prog := &obj.Prog{
|
||||||
Ctxt: p.ctxt,
|
Ctxt: p.ctxt,
|
||||||
As: obj.AFUNCDATA,
|
As: obj.AFUNCDATA,
|
||||||
Lineno: p.histLineNum,
|
Lineno: src.MakePos(p.histLineNum),
|
||||||
From: valueAddr,
|
From: valueAddr,
|
||||||
To: nameAddr,
|
To: nameAddr,
|
||||||
}
|
}
|
||||||
@ -341,7 +342,7 @@ func (p *Parser) asmJump(op obj.As, cond string, a []obj.Addr) {
|
|||||||
var target *obj.Addr
|
var target *obj.Addr
|
||||||
prog := &obj.Prog{
|
prog := &obj.Prog{
|
||||||
Ctxt: p.ctxt,
|
Ctxt: p.ctxt,
|
||||||
Lineno: p.histLineNum,
|
Lineno: src.MakePos(p.histLineNum),
|
||||||
As: op,
|
As: op,
|
||||||
}
|
}
|
||||||
switch len(a) {
|
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)
|
// fmt.Printf("%s %+v\n", op, a)
|
||||||
prog := &obj.Prog{
|
prog := &obj.Prog{
|
||||||
Ctxt: p.ctxt,
|
Ctxt: p.ctxt,
|
||||||
Lineno: p.histLineNum,
|
Lineno: src.MakePos(p.histLineNum),
|
||||||
As: op,
|
As: op,
|
||||||
}
|
}
|
||||||
switch len(a) {
|
switch len(a) {
|
||||||
|
@ -45,7 +45,7 @@ func Prog(as obj.As) *obj.Prog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
p.As = as
|
p.As = as
|
||||||
p.Lineno = int32(lineno.Line()) // TODO(gri) fix this
|
p.Lineno = lineno
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ package gc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"cmd/internal/obj"
|
"cmd/internal/obj"
|
||||||
"cmd/internal/src"
|
|
||||||
"cmd/internal/sys"
|
"cmd/internal/sys"
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -1254,7 +1253,7 @@ func livenessepilogue(lv *Liveness) {
|
|||||||
if !n.Name.Needzero {
|
if !n.Name.Needzero {
|
||||||
n.Name.Needzero = true
|
n.Name.Needzero = true
|
||||||
if debuglive >= 1 {
|
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]
|
n := lv.vars[j]
|
||||||
if n.Class != PPARAM {
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ package obj
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"cmd/internal/src"
|
||||||
"cmd/internal/sys"
|
"cmd/internal/sys"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
@ -238,7 +239,7 @@ type Prog struct {
|
|||||||
Forwd *Prog // for x86 back end
|
Forwd *Prog // for x86 back end
|
||||||
Rel *Prog // for x86, arm back ends
|
Rel *Prog // for x86, arm back ends
|
||||||
Pc int64 // for back ends or assembler: virtual or actual program counter, depending on phase
|
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)
|
Spadj int32 // effect of instruction on stack pointer (increment or decrement amount)
|
||||||
As As // assembler opcode
|
As As // assembler opcode
|
||||||
Reg int16 // 2nd source operand
|
Reg int16 // 2nd source operand
|
||||||
|
@ -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)
|
// Because p->lineno applies to p, phase == 0 (before p)
|
||||||
// takes care of the update.
|
// takes care of the update.
|
||||||
func pctofileline(ctxt *Link, sym *LSym, oldval int32, p *Prog, phase int32, arg interface{}) int32 {
|
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
|
return oldval
|
||||||
}
|
}
|
||||||
f, l := linkgetline(ctxt, p.Lineno)
|
f, l := linkgetline(ctxt, p.Lineno.Line())
|
||||||
if f == nil {
|
if f == nil {
|
||||||
// print("getline failed for %s %v\n", ctxt->cursym->name, p);
|
// print("getline failed for %s %v\n", ctxt->cursym->name, p);
|
||||||
return oldval
|
return oldval
|
||||||
|
@ -59,7 +59,7 @@ func Getgoextlinkenabled() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *Prog) Line() 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{
|
var armCondCode = []string{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user