mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: move Frontend field from ssa.Config to ssa.Func
Suggested by mdempsky in CL 38232. This allows us to use the Frontend field to associate frontend state and information with a function. See the following CL in the series for examples. This is a giant CL, but it is almost entirely routine refactoring. The ssa test API is starting to feel a bit unwieldy. I will clean it up separately, once the dust has settled. Passes toolstash -cmp. Updates #15756 Change-Id: I71c573bd96ff7251935fce1391b06b1f133c3caf Reviewed-on: https://go-review.googlesource.com/38327 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
193510f2f6
commit
2cdb7f118a
51 changed files with 922 additions and 2228 deletions
|
|
@ -19,6 +19,7 @@ import (
|
|||
type Func struct {
|
||||
Config *Config // architecture information
|
||||
Cache *Cache // re-usable cache
|
||||
fe Frontend // frontend state associated with this Func, callbacks into compiler frontend
|
||||
pass *pass // current pass information (name, options, etc.)
|
||||
Name string // e.g. bytes·Compare
|
||||
Type Type // type signature of the function.
|
||||
|
|
@ -63,8 +64,8 @@ type Func struct {
|
|||
|
||||
// NewFunc returns a new, empty function object.
|
||||
// Caller must set f.Config and f.Cache before using f.
|
||||
func NewFunc() *Func {
|
||||
return &Func{NamedValues: make(map[LocalSlot][]*Value)}
|
||||
func NewFunc(fe Frontend) *Func {
|
||||
return &Func{fe: fe, NamedValues: make(map[LocalSlot][]*Value)}
|
||||
}
|
||||
|
||||
// NumBlocks returns an integer larger than the id of any Block in the Func.
|
||||
|
|
@ -165,7 +166,7 @@ func (f *Func) LogStat(key string, args ...interface{}) {
|
|||
if f.pass != nil {
|
||||
n = strings.Replace(f.pass.name, " ", "_", -1)
|
||||
}
|
||||
f.Config.Warnl(f.Entry.Pos, "\t%s\t%s%s\t%s", n, key, value, f.Name)
|
||||
f.Warnl(f.Entry.Pos, "\t%s\t%s%s\t%s", n, key, value, f.Name)
|
||||
}
|
||||
|
||||
// freeValue frees a value. It must no longer be referenced.
|
||||
|
|
@ -482,9 +483,11 @@ func (f *Func) ConstOffPtrSP(pos src.XPos, t Type, c int64, sp *Value) *Value {
|
|||
|
||||
}
|
||||
|
||||
func (f *Func) Logf(msg string, args ...interface{}) { f.Config.Logf(msg, args...) }
|
||||
func (f *Func) Log() bool { return f.Config.Log() }
|
||||
func (f *Func) Fatalf(msg string, args ...interface{}) { f.Config.Fatalf(f.Entry.Pos, msg, args...) }
|
||||
func (f *Func) Frontend() Frontend { return f.fe }
|
||||
func (f *Func) Warnl(pos src.XPos, msg string, args ...interface{}) { f.fe.Warnl(pos, msg, args...) }
|
||||
func (f *Func) Logf(msg string, args ...interface{}) { f.fe.Logf(msg, args...) }
|
||||
func (f *Func) Log() bool { return f.fe.Log() }
|
||||
func (f *Func) Fatalf(msg string, args ...interface{}) { f.fe.Fatalf(f.Entry.Pos, msg, args...) }
|
||||
|
||||
// postorder returns the reachable blocks in f in a postorder traversal.
|
||||
func (f *Func) postorder() []*Block {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue