Otherwise, just copying the aux and auxint fields doesn't make much sense.
(Although there's no bug - it just means it isn't typechecked correctly.)
Change-Id: I4e21ac67f0c7bfd04ed5af1713cd24bca08af092
Reviewed-on: https://go-review.googlesource.com/c/go/+/227962
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
(REPSTOSQ destptr (MOVQconst [s/8]) (MOVQconst [0]) mem)
// Lowering constants
-(Const8 ...) -> (MOVLconst ...)
-(Const16 ...) -> (MOVLconst ...)
-(Const32 ...) -> (MOVLconst ...)
-(Const64 ...) -> (MOVQconst ...)
-(Const32F ...) -> (MOVSSconst ...)
-(Const64F ...) -> (MOVSDconst ...)
-(ConstNil ...) -> (MOVQconst ...)
-(ConstBool ...) -> (MOVLconst ...)
+(Const8 [c]) => (MOVLconst [int32(c)])
+(Const16 [c]) => (MOVLconst [int32(c)])
+(Const32 ...) => (MOVLconst ...)
+(Const64 ...) => (MOVQconst ...)
+(Const32F ...) => (MOVSSconst ...)
+(Const64F ...) => (MOVSDconst ...)
+(ConstNil ) => (MOVQconst [0])
+(ConstBool [c]) => (MOVLconst [int32(b2i(c))])
// Lowering calls
(StaticCall ...) -> (CALLstatic ...)
(MOVDconst <t> [c]) && !is32Bit(c) && int32(c) < 0 -> (ADD (SLLI <t> [32] (MOVDconst [c>>32+1])) (MOVDconst [int64(int32(c))]))
(MOVDconst <t> [c]) && !is32Bit(c) && int32(c) >= 0 -> (ADD (SLLI <t> [32] (MOVDconst [c>>32+0])) (MOVDconst [int64(int32(c))]))
-(Addr ...) -> (MOVaddr ...)
+(Addr {sym} base) => (MOVaddr {sym} [0] base)
(LocalAddr {sym} base _) -> (MOVaddr {sym} base)
// Conditional branches
(GetClosurePtr ...) -> (LoweredGetClosurePtr ...)
(GetCallerPC ...) -> (LoweredGetCallerPC ...)
(GetCallerSP ...) -> (LoweredGetCallerSP ...)
-(Addr ...) -> (LoweredAddr ...)
+(Addr {sym} base) => (LoweredAddr {sym} [0] base)
(LocalAddr {sym} base _) -> (LoweredAddr {sym} base)
// Write barrier.
for _, op := range ops {
eop, ok := parseEllipsisRules(oprules[op], arch)
if ok {
+ if strings.Contains(oprules[op][0].rule, "=>") && opByName(arch, op).aux != opByName(arch, eop).aux {
+ panic(fmt.Sprintf("can't use ... for ops that have different aux types: %s and %s", op, eop))
+ }
swc := &Case{expr: exprf(op)}
swc.add(stmtf("v.Op = %s", eop))
swc.add(stmtf("return true"))
var auxint2, aux2 string
var args2 []string
var usingCopy string
+ var eop opData
if result[0] != '(' {
// Check for (Foo x) -> x, which can be converted to (Foo ...) -> (Copy ...).
args2 = []string{result}
usingCopy = " using Copy"
} else {
- _, _, _, auxint2, aux2, args2 = parseValue(result, arch, rule.loc)
+ eop, _, _, auxint2, aux2, args2 = parseValue(result, arch, rule.loc)
}
// Check that all restrictions in match are reproduced exactly in result.
if aux != aux2 || auxint != auxint2 || len(args) != len(args2) {
return
}
+ if strings.Contains(rule.rule, "=>") && op.aux != eop.aux {
+ return
+ }
for i := range args {
if args[i] != args2[i] {
return
case OpCondSelect:
return rewriteValueAMD64_OpCondSelect(v)
case OpConst16:
- v.Op = OpAMD64MOVLconst
- return true
+ return rewriteValueAMD64_OpConst16(v)
case OpConst32:
v.Op = OpAMD64MOVLconst
return true
v.Op = OpAMD64MOVSDconst
return true
case OpConst8:
- v.Op = OpAMD64MOVLconst
- return true
+ return rewriteValueAMD64_OpConst8(v)
case OpConstBool:
- v.Op = OpAMD64MOVLconst
- return true
+ return rewriteValueAMD64_OpConstBool(v)
case OpConstNil:
- v.Op = OpAMD64MOVQconst
- return true
+ return rewriteValueAMD64_OpConstNil(v)
case OpCtz16:
return rewriteValueAMD64_OpCtz16(v)
case OpCtz16NonZero:
}
return false
}
+func rewriteValueAMD64_OpConst16(v *Value) bool {
+ // match: (Const16 [c])
+ // result: (MOVLconst [int32(c)])
+ for {
+ c := auxIntToInt16(v.AuxInt)
+ v.reset(OpAMD64MOVLconst)
+ v.AuxInt = int32ToAuxInt(int32(c))
+ return true
+ }
+}
+func rewriteValueAMD64_OpConst8(v *Value) bool {
+ // match: (Const8 [c])
+ // result: (MOVLconst [int32(c)])
+ for {
+ c := auxIntToInt8(v.AuxInt)
+ v.reset(OpAMD64MOVLconst)
+ v.AuxInt = int32ToAuxInt(int32(c))
+ return true
+ }
+}
+func rewriteValueAMD64_OpConstBool(v *Value) bool {
+ // match: (ConstBool [c])
+ // result: (MOVLconst [int32(b2i(c))])
+ for {
+ c := auxIntToBool(v.AuxInt)
+ v.reset(OpAMD64MOVLconst)
+ v.AuxInt = int32ToAuxInt(int32(b2i(c)))
+ return true
+ }
+}
+func rewriteValueAMD64_OpConstNil(v *Value) bool {
+ // match: (ConstNil )
+ // result: (MOVQconst [0])
+ for {
+ v.reset(OpAMD64MOVQconst)
+ v.AuxInt = int64ToAuxInt(0)
+ return true
+ }
+}
func rewriteValueAMD64_OpCtz16(v *Value) bool {
v_0 := v.Args[0]
b := v.Block
v.Op = OpRISCV64ADD
return true
case OpAddr:
- v.Op = OpRISCV64MOVaddr
- return true
+ return rewriteValueRISCV64_OpAddr(v)
case OpAnd16:
v.Op = OpRISCV64AND
return true
}
return false
}
+func rewriteValueRISCV64_OpAddr(v *Value) bool {
+ v_0 := v.Args[0]
+ // match: (Addr {sym} base)
+ // result: (MOVaddr {sym} [0] base)
+ for {
+ sym := auxToSym(v.Aux)
+ base := v_0
+ v.reset(OpRISCV64MOVaddr)
+ v.AuxInt = int32ToAuxInt(0)
+ v.Aux = symToAux(sym)
+ v.AddArg(base)
+ return true
+ }
+}
func rewriteValueRISCV64_OpAvg64u(v *Value) bool {
v_1 := v.Args[1]
v_0 := v.Args[0]
v.Op = OpWasmI64Add
return true
case OpAddr:
- v.Op = OpWasmLoweredAddr
- return true
+ return rewriteValueWasm_OpAddr(v)
case OpAnd16:
v.Op = OpWasmI64And
return true
}
return false
}
+func rewriteValueWasm_OpAddr(v *Value) bool {
+ v_0 := v.Args[0]
+ // match: (Addr {sym} base)
+ // result: (LoweredAddr {sym} [0] base)
+ for {
+ sym := auxToSym(v.Aux)
+ base := v_0
+ v.reset(OpWasmLoweredAddr)
+ v.AuxInt = int32ToAuxInt(0)
+ v.Aux = symToAux(sym)
+ v.AddArg(base)
+ return true
+ }
+}
func rewriteValueWasm_OpBitLen64(v *Value) bool {
v_0 := v.Args[0]
b := v.Block