Commit a92bd662 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

[dev.ssa] cmd/compile: support zero type for *T

Change-Id: I4c9bcea01e2c4333c2a3592b66f1da9f424747a4
Reviewed-on: https://go-review.googlesource.com/12130Reviewed-by: default avatarKeith Randall <khr@golang.org>
parent 50e59bb9
......@@ -652,7 +652,7 @@ func (s *state) assign(op uint8, left *Node, right *Node) {
switch {
case t.IsString():
val = s.entryNewValue0A(ssa.OpConst, left.Type, "")
case t.IsInteger():
case t.IsInteger() || t.IsPtr():
val = s.entryNewValue0(ssa.OpConst, left.Type)
case t.IsBoolean():
val = s.entryNewValue0A(ssa.OpConst, left.Type, false) // TODO: store bools as 0/1 in AuxInt?
......
......@@ -76,6 +76,7 @@
(OffPtr [off] ptr) -> (ADDQconst [off] ptr)
(Const <t> [val]) && t.IsInteger() -> (MOVQconst [val])
(Const <t>) && t.IsPtr() -> (MOVQconst [0]) // nil is the only const pointer
(Addr {sym} base) -> (LEAQ {sym} base)
......
......@@ -499,6 +499,24 @@ func rewriteValueAMD64(v *Value, config *Config) bool {
goto end4c8bfe9df26fc5aa2bd76b211792732a
end4c8bfe9df26fc5aa2bd76b211792732a:
;
// match: (Const <t>)
// cond: t.IsPtr()
// result: (MOVQconst [0])
{
t := v.Type
if !(t.IsPtr()) {
goto endd23abe8d7061f11c260b162e24eec060
}
v.Op = OpAMD64MOVQconst
v.AuxInt = 0
v.Aux = nil
v.resetArgs()
v.AuxInt = 0
return true
}
goto endd23abe8d7061f11c260b162e24eec060
endd23abe8d7061f11c260b162e24eec060:
;
case OpConvNop:
// match: (ConvNop <t> x)
// cond: t == x.Type
......
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