mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
all: merge dev.inline into master
Change-Id: I7715581a04e513dcda9918e853fa6b1ddc703770
This commit is contained in:
commit
47ce87877b
124 changed files with 6096 additions and 5655 deletions
|
|
@ -5,6 +5,7 @@
|
|||
package ssa
|
||||
|
||||
import (
|
||||
"cmd/internal/src"
|
||||
"fmt"
|
||||
"math"
|
||||
"strings"
|
||||
|
|
@ -80,7 +81,7 @@ func (f *Func) retSparseSet(ss *sparseSet) {
|
|||
}
|
||||
|
||||
// newValue allocates a new Value with the given fields and places it at the end of b.Values.
|
||||
func (f *Func) newValue(op Op, t Type, b *Block, line int32) *Value {
|
||||
func (f *Func) newValue(op Op, t Type, b *Block, pos src.XPos) *Value {
|
||||
var v *Value
|
||||
if f.freeValues != nil {
|
||||
v = f.freeValues
|
||||
|
|
@ -97,7 +98,7 @@ func (f *Func) newValue(op Op, t Type, b *Block, line int32) *Value {
|
|||
v.Op = op
|
||||
v.Type = t
|
||||
v.Block = b
|
||||
v.Line = line
|
||||
v.Pos = pos
|
||||
b.Values = append(b.Values, v)
|
||||
return v
|
||||
}
|
||||
|
|
@ -117,7 +118,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.Line, "\t%s\t%s%s\t%s", n, key, value, f.Name)
|
||||
f.Config.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.
|
||||
|
|
@ -187,30 +188,30 @@ func (f *Func) freeBlock(b *Block) {
|
|||
}
|
||||
|
||||
// NewValue0 returns a new value in the block with no arguments and zero aux values.
|
||||
func (b *Block) NewValue0(line int32, op Op, t Type) *Value {
|
||||
v := b.Func.newValue(op, t, b, line)
|
||||
func (b *Block) NewValue0(pos src.XPos, op Op, t Type) *Value {
|
||||
v := b.Func.newValue(op, t, b, pos)
|
||||
v.AuxInt = 0
|
||||
v.Args = v.argstorage[:0]
|
||||
return v
|
||||
}
|
||||
|
||||
// NewValue returns a new value in the block with no arguments and an auxint value.
|
||||
func (b *Block) NewValue0I(line int32, op Op, t Type, auxint int64) *Value {
|
||||
v := b.Func.newValue(op, t, b, line)
|
||||
func (b *Block) NewValue0I(pos src.XPos, op Op, t Type, auxint int64) *Value {
|
||||
v := b.Func.newValue(op, t, b, pos)
|
||||
v.AuxInt = auxint
|
||||
v.Args = v.argstorage[:0]
|
||||
return v
|
||||
}
|
||||
|
||||
// NewValue returns a new value in the block with no arguments and an aux value.
|
||||
func (b *Block) NewValue0A(line int32, op Op, t Type, aux interface{}) *Value {
|
||||
func (b *Block) NewValue0A(pos src.XPos, op Op, t Type, aux interface{}) *Value {
|
||||
if _, ok := aux.(int64); ok {
|
||||
// Disallow int64 aux values. They should be in the auxint field instead.
|
||||
// Maybe we want to allow this at some point, but for now we disallow it
|
||||
// to prevent errors like using NewValue1A instead of NewValue1I.
|
||||
b.Fatalf("aux field has int64 type op=%s type=%s aux=%v", op, t, aux)
|
||||
}
|
||||
v := b.Func.newValue(op, t, b, line)
|
||||
v := b.Func.newValue(op, t, b, pos)
|
||||
v.AuxInt = 0
|
||||
v.Aux = aux
|
||||
v.Args = v.argstorage[:0]
|
||||
|
|
@ -218,8 +219,8 @@ func (b *Block) NewValue0A(line int32, op Op, t Type, aux interface{}) *Value {
|
|||
}
|
||||
|
||||
// NewValue returns a new value in the block with no arguments and both an auxint and aux values.
|
||||
func (b *Block) NewValue0IA(line int32, op Op, t Type, auxint int64, aux interface{}) *Value {
|
||||
v := b.Func.newValue(op, t, b, line)
|
||||
func (b *Block) NewValue0IA(pos src.XPos, op Op, t Type, auxint int64, aux interface{}) *Value {
|
||||
v := b.Func.newValue(op, t, b, pos)
|
||||
v.AuxInt = auxint
|
||||
v.Aux = aux
|
||||
v.Args = v.argstorage[:0]
|
||||
|
|
@ -227,8 +228,8 @@ func (b *Block) NewValue0IA(line int32, op Op, t Type, auxint int64, aux interfa
|
|||
}
|
||||
|
||||
// NewValue1 returns a new value in the block with one argument and zero aux values.
|
||||
func (b *Block) NewValue1(line int32, op Op, t Type, arg *Value) *Value {
|
||||
v := b.Func.newValue(op, t, b, line)
|
||||
func (b *Block) NewValue1(pos src.XPos, op Op, t Type, arg *Value) *Value {
|
||||
v := b.Func.newValue(op, t, b, pos)
|
||||
v.AuxInt = 0
|
||||
v.Args = v.argstorage[:1]
|
||||
v.argstorage[0] = arg
|
||||
|
|
@ -237,8 +238,8 @@ func (b *Block) NewValue1(line int32, op Op, t Type, arg *Value) *Value {
|
|||
}
|
||||
|
||||
// NewValue1I returns a new value in the block with one argument and an auxint value.
|
||||
func (b *Block) NewValue1I(line int32, op Op, t Type, auxint int64, arg *Value) *Value {
|
||||
v := b.Func.newValue(op, t, b, line)
|
||||
func (b *Block) NewValue1I(pos src.XPos, op Op, t Type, auxint int64, arg *Value) *Value {
|
||||
v := b.Func.newValue(op, t, b, pos)
|
||||
v.AuxInt = auxint
|
||||
v.Args = v.argstorage[:1]
|
||||
v.argstorage[0] = arg
|
||||
|
|
@ -247,8 +248,8 @@ func (b *Block) NewValue1I(line int32, op Op, t Type, auxint int64, arg *Value)
|
|||
}
|
||||
|
||||
// NewValue1A returns a new value in the block with one argument and an aux value.
|
||||
func (b *Block) NewValue1A(line int32, op Op, t Type, aux interface{}, arg *Value) *Value {
|
||||
v := b.Func.newValue(op, t, b, line)
|
||||
func (b *Block) NewValue1A(pos src.XPos, op Op, t Type, aux interface{}, arg *Value) *Value {
|
||||
v := b.Func.newValue(op, t, b, pos)
|
||||
v.AuxInt = 0
|
||||
v.Aux = aux
|
||||
v.Args = v.argstorage[:1]
|
||||
|
|
@ -258,8 +259,8 @@ func (b *Block) NewValue1A(line int32, op Op, t Type, aux interface{}, arg *Valu
|
|||
}
|
||||
|
||||
// NewValue1IA returns a new value in the block with one argument and both an auxint and aux values.
|
||||
func (b *Block) NewValue1IA(line int32, op Op, t Type, auxint int64, aux interface{}, arg *Value) *Value {
|
||||
v := b.Func.newValue(op, t, b, line)
|
||||
func (b *Block) NewValue1IA(pos src.XPos, op Op, t Type, auxint int64, aux interface{}, arg *Value) *Value {
|
||||
v := b.Func.newValue(op, t, b, pos)
|
||||
v.AuxInt = auxint
|
||||
v.Aux = aux
|
||||
v.Args = v.argstorage[:1]
|
||||
|
|
@ -269,8 +270,8 @@ func (b *Block) NewValue1IA(line int32, op Op, t Type, auxint int64, aux interfa
|
|||
}
|
||||
|
||||
// NewValue2 returns a new value in the block with two arguments and zero aux values.
|
||||
func (b *Block) NewValue2(line int32, op Op, t Type, arg0, arg1 *Value) *Value {
|
||||
v := b.Func.newValue(op, t, b, line)
|
||||
func (b *Block) NewValue2(pos src.XPos, op Op, t Type, arg0, arg1 *Value) *Value {
|
||||
v := b.Func.newValue(op, t, b, pos)
|
||||
v.AuxInt = 0
|
||||
v.Args = v.argstorage[:2]
|
||||
v.argstorage[0] = arg0
|
||||
|
|
@ -281,8 +282,8 @@ func (b *Block) NewValue2(line int32, op Op, t Type, arg0, arg1 *Value) *Value {
|
|||
}
|
||||
|
||||
// NewValue2I returns a new value in the block with two arguments and an auxint value.
|
||||
func (b *Block) NewValue2I(line int32, op Op, t Type, auxint int64, arg0, arg1 *Value) *Value {
|
||||
v := b.Func.newValue(op, t, b, line)
|
||||
func (b *Block) NewValue2I(pos src.XPos, op Op, t Type, auxint int64, arg0, arg1 *Value) *Value {
|
||||
v := b.Func.newValue(op, t, b, pos)
|
||||
v.AuxInt = auxint
|
||||
v.Args = v.argstorage[:2]
|
||||
v.argstorage[0] = arg0
|
||||
|
|
@ -293,8 +294,8 @@ func (b *Block) NewValue2I(line int32, op Op, t Type, auxint int64, arg0, arg1 *
|
|||
}
|
||||
|
||||
// NewValue3 returns a new value in the block with three arguments and zero aux values.
|
||||
func (b *Block) NewValue3(line int32, op Op, t Type, arg0, arg1, arg2 *Value) *Value {
|
||||
v := b.Func.newValue(op, t, b, line)
|
||||
func (b *Block) NewValue3(pos src.XPos, op Op, t Type, arg0, arg1, arg2 *Value) *Value {
|
||||
v := b.Func.newValue(op, t, b, pos)
|
||||
v.AuxInt = 0
|
||||
v.Args = v.argstorage[:3]
|
||||
v.argstorage[0] = arg0
|
||||
|
|
@ -307,8 +308,8 @@ func (b *Block) NewValue3(line int32, op Op, t Type, arg0, arg1, arg2 *Value) *V
|
|||
}
|
||||
|
||||
// NewValue3I returns a new value in the block with three arguments and an auxint value.
|
||||
func (b *Block) NewValue3I(line int32, op Op, t Type, auxint int64, arg0, arg1, arg2 *Value) *Value {
|
||||
v := b.Func.newValue(op, t, b, line)
|
||||
func (b *Block) NewValue3I(pos src.XPos, op Op, t Type, auxint int64, arg0, arg1, arg2 *Value) *Value {
|
||||
v := b.Func.newValue(op, t, b, pos)
|
||||
v.AuxInt = auxint
|
||||
v.Args = v.argstorage[:3]
|
||||
v.argstorage[0] = arg0
|
||||
|
|
@ -321,8 +322,8 @@ func (b *Block) NewValue3I(line int32, op Op, t Type, auxint int64, arg0, arg1,
|
|||
}
|
||||
|
||||
// NewValue4 returns a new value in the block with four arguments and zero aux values.
|
||||
func (b *Block) NewValue4(line int32, op Op, t Type, arg0, arg1, arg2, arg3 *Value) *Value {
|
||||
v := b.Func.newValue(op, t, b, line)
|
||||
func (b *Block) NewValue4(pos src.XPos, op Op, t Type, arg0, arg1, arg2, arg3 *Value) *Value {
|
||||
v := b.Func.newValue(op, t, b, pos)
|
||||
v.AuxInt = 0
|
||||
v.Args = []*Value{arg0, arg1, arg2, arg3}
|
||||
arg0.Uses++
|
||||
|
|
@ -333,7 +334,7 @@ func (b *Block) NewValue4(line int32, op Op, t Type, arg0, arg1, arg2, arg3 *Val
|
|||
}
|
||||
|
||||
// constVal returns a constant value for c.
|
||||
func (f *Func) constVal(line int32, op Op, t Type, c int64, setAux bool) *Value {
|
||||
func (f *Func) constVal(pos src.XPos, op Op, t Type, c int64, setAux bool) *Value {
|
||||
if f.constants == nil {
|
||||
f.constants = make(map[int64][]*Value)
|
||||
}
|
||||
|
|
@ -348,9 +349,9 @@ func (f *Func) constVal(line int32, op Op, t Type, c int64, setAux bool) *Value
|
|||
}
|
||||
var v *Value
|
||||
if setAux {
|
||||
v = f.Entry.NewValue0I(line, op, t, c)
|
||||
v = f.Entry.NewValue0I(pos, op, t, c)
|
||||
} else {
|
||||
v = f.Entry.NewValue0(line, op, t)
|
||||
v = f.Entry.NewValue0(pos, op, t)
|
||||
}
|
||||
f.constants[c] = append(vv, v)
|
||||
return v
|
||||
|
|
@ -368,50 +369,50 @@ const (
|
|||
)
|
||||
|
||||
// ConstInt returns an int constant representing its argument.
|
||||
func (f *Func) ConstBool(line int32, t Type, c bool) *Value {
|
||||
func (f *Func) ConstBool(pos src.XPos, t Type, c bool) *Value {
|
||||
i := int64(0)
|
||||
if c {
|
||||
i = 1
|
||||
}
|
||||
return f.constVal(line, OpConstBool, t, i, true)
|
||||
return f.constVal(pos, OpConstBool, t, i, true)
|
||||
}
|
||||
func (f *Func) ConstInt8(line int32, t Type, c int8) *Value {
|
||||
return f.constVal(line, OpConst8, t, int64(c), true)
|
||||
func (f *Func) ConstInt8(pos src.XPos, t Type, c int8) *Value {
|
||||
return f.constVal(pos, OpConst8, t, int64(c), true)
|
||||
}
|
||||
func (f *Func) ConstInt16(line int32, t Type, c int16) *Value {
|
||||
return f.constVal(line, OpConst16, t, int64(c), true)
|
||||
func (f *Func) ConstInt16(pos src.XPos, t Type, c int16) *Value {
|
||||
return f.constVal(pos, OpConst16, t, int64(c), true)
|
||||
}
|
||||
func (f *Func) ConstInt32(line int32, t Type, c int32) *Value {
|
||||
return f.constVal(line, OpConst32, t, int64(c), true)
|
||||
func (f *Func) ConstInt32(pos src.XPos, t Type, c int32) *Value {
|
||||
return f.constVal(pos, OpConst32, t, int64(c), true)
|
||||
}
|
||||
func (f *Func) ConstInt64(line int32, t Type, c int64) *Value {
|
||||
return f.constVal(line, OpConst64, t, c, true)
|
||||
func (f *Func) ConstInt64(pos src.XPos, t Type, c int64) *Value {
|
||||
return f.constVal(pos, OpConst64, t, c, true)
|
||||
}
|
||||
func (f *Func) ConstFloat32(line int32, t Type, c float64) *Value {
|
||||
return f.constVal(line, OpConst32F, t, int64(math.Float64bits(float64(float32(c)))), true)
|
||||
func (f *Func) ConstFloat32(pos src.XPos, t Type, c float64) *Value {
|
||||
return f.constVal(pos, OpConst32F, t, int64(math.Float64bits(float64(float32(c)))), true)
|
||||
}
|
||||
func (f *Func) ConstFloat64(line int32, t Type, c float64) *Value {
|
||||
return f.constVal(line, OpConst64F, t, int64(math.Float64bits(c)), true)
|
||||
func (f *Func) ConstFloat64(pos src.XPos, t Type, c float64) *Value {
|
||||
return f.constVal(pos, OpConst64F, t, int64(math.Float64bits(c)), true)
|
||||
}
|
||||
|
||||
func (f *Func) ConstSlice(line int32, t Type) *Value {
|
||||
return f.constVal(line, OpConstSlice, t, constSliceMagic, false)
|
||||
func (f *Func) ConstSlice(pos src.XPos, t Type) *Value {
|
||||
return f.constVal(pos, OpConstSlice, t, constSliceMagic, false)
|
||||
}
|
||||
func (f *Func) ConstInterface(line int32, t Type) *Value {
|
||||
return f.constVal(line, OpConstInterface, t, constInterfaceMagic, false)
|
||||
func (f *Func) ConstInterface(pos src.XPos, t Type) *Value {
|
||||
return f.constVal(pos, OpConstInterface, t, constInterfaceMagic, false)
|
||||
}
|
||||
func (f *Func) ConstNil(line int32, t Type) *Value {
|
||||
return f.constVal(line, OpConstNil, t, constNilMagic, false)
|
||||
func (f *Func) ConstNil(pos src.XPos, t Type) *Value {
|
||||
return f.constVal(pos, OpConstNil, t, constNilMagic, false)
|
||||
}
|
||||
func (f *Func) ConstEmptyString(line int32, t Type) *Value {
|
||||
v := f.constVal(line, OpConstString, t, constEmptyStringMagic, false)
|
||||
func (f *Func) ConstEmptyString(pos src.XPos, t Type) *Value {
|
||||
v := f.constVal(pos, OpConstString, t, constEmptyStringMagic, false)
|
||||
v.Aux = ""
|
||||
return v
|
||||
}
|
||||
|
||||
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.Line, msg, args...) }
|
||||
func (f *Func) Fatalf(msg string, args ...interface{}) { f.Config.Fatalf(f.Entry.Pos, msg, args...) }
|
||||
|
||||
func (f *Func) Free() {
|
||||
// Clear cached CFG info.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue