mirror of
https://github.com/golang/go
synced 2024-11-23 13:00:07 -07:00
cmd/compile: fold most repetitive operations to simplify riscv64 rules
Most of repetitive rules in riscv64 are simple, so that we can simplify and fold it with | without losting rules readability. No change in the actual compiler code after running rulegen. Change-Id: Id0bbfd93e63b49b7f66ecb62eb9440b4900c7938 Reviewed-on: https://go-review.googlesource.com/c/go/+/498455 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: M Zhuo <mzh@golangcn.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: M Zhuo <mzh@golangcn.org>
This commit is contained in:
parent
d9f7e1dc73
commit
ada5f8a46d
@ -3,21 +3,11 @@
|
|||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// Lowering arithmetic
|
// Lowering arithmetic
|
||||||
(Add64 ...) => (ADD ...)
|
(Add(Ptr|64|32|16|8) ...) => (ADD ...)
|
||||||
(AddPtr ...) => (ADD ...)
|
(Add(64|32)F ...) => (FADD(D|S) ...)
|
||||||
(Add32 ...) => (ADD ...)
|
|
||||||
(Add16 ...) => (ADD ...)
|
|
||||||
(Add8 ...) => (ADD ...)
|
|
||||||
(Add32F ...) => (FADDS ...)
|
|
||||||
(Add64F ...) => (FADDD ...)
|
|
||||||
|
|
||||||
(Sub64 ...) => (SUB ...)
|
(Sub(Ptr|64|32|16|8) ...) => (SUB ...)
|
||||||
(SubPtr ...) => (SUB ...)
|
(Sub(64|32)F ...) => (FSUB(D|S) ...)
|
||||||
(Sub32 ...) => (SUB ...)
|
|
||||||
(Sub16 ...) => (SUB ...)
|
|
||||||
(Sub8 ...) => (SUB ...)
|
|
||||||
(Sub32F ...) => (FSUBS ...)
|
|
||||||
(Sub64F ...) => (FSUBD ...)
|
|
||||||
|
|
||||||
(Mul64 ...) => (MUL ...)
|
(Mul64 ...) => (MUL ...)
|
||||||
(Mul64uhilo ...) => (LoweredMuluhilo ...)
|
(Mul64uhilo ...) => (LoweredMuluhilo ...)
|
||||||
@ -25,11 +15,9 @@
|
|||||||
(Mul32 ...) => (MULW ...)
|
(Mul32 ...) => (MULW ...)
|
||||||
(Mul16 x y) => (MULW (SignExt16to32 x) (SignExt16to32 y))
|
(Mul16 x y) => (MULW (SignExt16to32 x) (SignExt16to32 y))
|
||||||
(Mul8 x y) => (MULW (SignExt8to32 x) (SignExt8to32 y))
|
(Mul8 x y) => (MULW (SignExt8to32 x) (SignExt8to32 y))
|
||||||
(Mul32F ...) => (FMULS ...)
|
(Mul(64|32)F ...) => (FMUL(D|S) ...)
|
||||||
(Mul64F ...) => (FMULD ...)
|
|
||||||
|
|
||||||
(Div32F ...) => (FDIVS ...)
|
(Div(64|32)F ...) => (FDIV(D|S) ...)
|
||||||
(Div64F ...) => (FDIVD ...)
|
|
||||||
|
|
||||||
(Div64 x y [false]) => (DIV x y)
|
(Div64 x y [false]) => (DIV x y)
|
||||||
(Div64u ...) => (DIVU ...)
|
(Div64u ...) => (DIVU ...)
|
||||||
@ -65,32 +53,15 @@
|
|||||||
(Mod8 x y) => (REMW (SignExt8to32 x) (SignExt8to32 y))
|
(Mod8 x y) => (REMW (SignExt8to32 x) (SignExt8to32 y))
|
||||||
(Mod8u x y) => (REMUW (ZeroExt8to32 x) (ZeroExt8to32 y))
|
(Mod8u x y) => (REMUW (ZeroExt8to32 x) (ZeroExt8to32 y))
|
||||||
|
|
||||||
(And64 ...) => (AND ...)
|
(And(64|32|16|8) ...) => (AND ...)
|
||||||
(And32 ...) => (AND ...)
|
(Or(64|32|16|8) ...) => (OR ...)
|
||||||
(And16 ...) => (AND ...)
|
(Xor(64|32|16|8) ...) => (XOR ...)
|
||||||
(And8 ...) => (AND ...)
|
|
||||||
|
|
||||||
(Or64 ...) => (OR ...)
|
(Neg(64|32|16|8) ...) => (NEG ...)
|
||||||
(Or32 ...) => (OR ...)
|
(Neg(64|32)F ...) => (FNEG(D|S) ...)
|
||||||
(Or16 ...) => (OR ...)
|
|
||||||
(Or8 ...) => (OR ...)
|
|
||||||
|
|
||||||
(Xor64 ...) => (XOR ...)
|
(Com(64|32|16|8) ...) => (NOT ...)
|
||||||
(Xor32 ...) => (XOR ...)
|
|
||||||
(Xor16 ...) => (XOR ...)
|
|
||||||
(Xor8 ...) => (XOR ...)
|
|
||||||
|
|
||||||
(Neg64 ...) => (NEG ...)
|
|
||||||
(Neg32 ...) => (NEG ...)
|
|
||||||
(Neg16 ...) => (NEG ...)
|
|
||||||
(Neg8 ...) => (NEG ...)
|
|
||||||
(Neg32F ...) => (FNEGS ...)
|
|
||||||
(Neg64F ...) => (FNEGD ...)
|
|
||||||
|
|
||||||
(Com64 ...) => (NOT ...)
|
|
||||||
(Com32 ...) => (NOT ...)
|
|
||||||
(Com16 ...) => (NOT ...)
|
|
||||||
(Com8 ...) => (NOT ...)
|
|
||||||
|
|
||||||
(Sqrt ...) => (FSQRTD ...)
|
(Sqrt ...) => (FSQRTD ...)
|
||||||
(Sqrt32 ...) => (FSQRTS ...)
|
(Sqrt32 ...) => (FSQRTS ...)
|
||||||
@ -132,8 +103,7 @@
|
|||||||
|
|
||||||
(CvtBoolToUint8 ...) => (Copy ...)
|
(CvtBoolToUint8 ...) => (Copy ...)
|
||||||
|
|
||||||
(Round32F ...) => (Copy ...)
|
(Round(64|32)F ...) => (Copy ...)
|
||||||
(Round64F ...) => (Copy ...)
|
|
||||||
|
|
||||||
(Slicemask <t> x) => (SRAI [63] (NEG <t> x))
|
(Slicemask <t> x) => (SRAI [63] (NEG <t> x))
|
||||||
|
|
||||||
@ -250,36 +220,26 @@
|
|||||||
(Less32U x y) => (SLTU (ZeroExt32to64 x) (ZeroExt32to64 y))
|
(Less32U x y) => (SLTU (ZeroExt32to64 x) (ZeroExt32to64 y))
|
||||||
(Less16U x y) => (SLTU (ZeroExt16to64 x) (ZeroExt16to64 y))
|
(Less16U x y) => (SLTU (ZeroExt16to64 x) (ZeroExt16to64 y))
|
||||||
(Less8U x y) => (SLTU (ZeroExt8to64 x) (ZeroExt8to64 y))
|
(Less8U x y) => (SLTU (ZeroExt8to64 x) (ZeroExt8to64 y))
|
||||||
(Less64F ...) => (FLTD ...)
|
(Less(64|32)F ...) => (FLT(D|S) ...)
|
||||||
(Less32F ...) => (FLTS ...)
|
|
||||||
|
|
||||||
// Convert x <= y to !(y > x).
|
// Convert x <= y to !(y > x).
|
||||||
(Leq64 x y) => (Not (Less64 y x))
|
(Leq(64|32|16|8) x y) => (Not (Less(64|32|16|8) y x))
|
||||||
(Leq32 x y) => (Not (Less32 y x))
|
(Leq(64|32|16|8)U x y) => (Not (Less(64|32|16|8)U y x))
|
||||||
(Leq16 x y) => (Not (Less16 y x))
|
(Leq(64|32)F ...) => (FLE(D|S) ...)
|
||||||
(Leq8 x y) => (Not (Less8 y x))
|
|
||||||
(Leq64U x y) => (Not (Less64U y x))
|
|
||||||
(Leq32U x y) => (Not (Less32U y x))
|
|
||||||
(Leq16U x y) => (Not (Less16U y x))
|
|
||||||
(Leq8U x y) => (Not (Less8U y x))
|
|
||||||
(Leq64F ...) => (FLED ...)
|
|
||||||
(Leq32F ...) => (FLES ...)
|
|
||||||
|
|
||||||
(EqPtr x y) => (SEQZ (SUB <typ.Uintptr> x y))
|
(EqPtr x y) => (SEQZ (SUB <typ.Uintptr> x y))
|
||||||
(Eq64 x y) => (SEQZ (SUB <x.Type> x y))
|
(Eq64 x y) => (SEQZ (SUB <x.Type> x y))
|
||||||
(Eq32 x y) => (SEQZ (SUB <x.Type> (ZeroExt32to64 x) (ZeroExt32to64 y)))
|
(Eq32 x y) => (SEQZ (SUB <x.Type> (ZeroExt32to64 x) (ZeroExt32to64 y)))
|
||||||
(Eq16 x y) => (SEQZ (SUB <x.Type> (ZeroExt16to64 x) (ZeroExt16to64 y)))
|
(Eq16 x y) => (SEQZ (SUB <x.Type> (ZeroExt16to64 x) (ZeroExt16to64 y)))
|
||||||
(Eq8 x y) => (SEQZ (SUB <x.Type> (ZeroExt8to64 x) (ZeroExt8to64 y)))
|
(Eq8 x y) => (SEQZ (SUB <x.Type> (ZeroExt8to64 x) (ZeroExt8to64 y)))
|
||||||
(Eq64F ...) => (FEQD ...)
|
(Eq(64|32)F ...) => (FEQ(D|S) ...)
|
||||||
(Eq32F ...) => (FEQS ...)
|
|
||||||
|
|
||||||
(NeqPtr x y) => (SNEZ (SUB <typ.Uintptr> x y))
|
(NeqPtr x y) => (SNEZ (SUB <typ.Uintptr> x y))
|
||||||
(Neq64 x y) => (SNEZ (SUB <x.Type> x y))
|
(Neq64 x y) => (SNEZ (SUB <x.Type> x y))
|
||||||
(Neq32 x y) => (SNEZ (SUB <x.Type> (ZeroExt32to64 x) (ZeroExt32to64 y)))
|
(Neq32 x y) => (SNEZ (SUB <x.Type> (ZeroExt32to64 x) (ZeroExt32to64 y)))
|
||||||
(Neq16 x y) => (SNEZ (SUB <x.Type> (ZeroExt16to64 x) (ZeroExt16to64 y)))
|
(Neq16 x y) => (SNEZ (SUB <x.Type> (ZeroExt16to64 x) (ZeroExt16to64 y)))
|
||||||
(Neq8 x y) => (SNEZ (SUB <x.Type> (ZeroExt8to64 x) (ZeroExt8to64 y)))
|
(Neq8 x y) => (SNEZ (SUB <x.Type> (ZeroExt8to64 x) (ZeroExt8to64 y)))
|
||||||
(Neq64F ...) => (FNED ...)
|
(Neq(64|32)F ...) => (FNE(D|S) ...)
|
||||||
(Neq32F ...) => (FNES ...)
|
|
||||||
|
|
||||||
// Loads
|
// Loads
|
||||||
(Load <t> ptr mem) && t.IsBoolean() => (MOVBUload ptr mem)
|
(Load <t> ptr mem) && t.IsBoolean() => (MOVBUload ptr mem)
|
||||||
@ -537,10 +497,7 @@
|
|||||||
(OffPtr [off] ptr) && is32Bit(off) => (ADDI [off] ptr)
|
(OffPtr [off] ptr) && is32Bit(off) => (ADDI [off] ptr)
|
||||||
(OffPtr [off] ptr) => (ADD (MOVDconst [off]) ptr)
|
(OffPtr [off] ptr) => (ADD (MOVDconst [off]) ptr)
|
||||||
|
|
||||||
(Const8 [val]) => (MOVDconst [int64(val)])
|
(Const(64|32|16|8) [val]) => (MOVDconst [int64(val)])
|
||||||
(Const16 [val]) => (MOVDconst [int64(val)])
|
|
||||||
(Const32 [val]) => (MOVDconst [int64(val)])
|
|
||||||
(Const64 [val]) => (MOVDconst [int64(val)])
|
|
||||||
(Const32F [val]) => (FMVSX (MOVDconst [int64(math.Float32bits(val))]))
|
(Const32F [val]) => (FMVSX (MOVDconst [int64(math.Float32bits(val))]))
|
||||||
(Const64F [val]) => (FMVDX (MOVDconst [int64(math.Float64bits(val))]))
|
(Const64F [val]) => (FMVDX (MOVDconst [int64(math.Float64bits(val))]))
|
||||||
(ConstNil) => (MOVDconst [0])
|
(ConstNil) => (MOVDconst [0])
|
||||||
@ -557,18 +514,9 @@
|
|||||||
(TailCall ...) => (CALLtail ...)
|
(TailCall ...) => (CALLtail ...)
|
||||||
|
|
||||||
// Atomic Intrinsics
|
// Atomic Intrinsics
|
||||||
(AtomicLoad8 ...) => (LoweredAtomicLoad8 ...)
|
(AtomicLoad(Ptr|64|32|8) ...) => (LoweredAtomicLoad(64|64|32|8) ...)
|
||||||
(AtomicLoad32 ...) => (LoweredAtomicLoad32 ...)
|
(AtomicStore(PtrNoWB|64|32|8) ...) => (LoweredAtomicStore(64|64|32|8) ...)
|
||||||
(AtomicLoad64 ...) => (LoweredAtomicLoad64 ...)
|
(AtomicAdd(64|32) ...) => (LoweredAtomicAdd(64|32) ...)
|
||||||
(AtomicLoadPtr ...) => (LoweredAtomicLoad64 ...)
|
|
||||||
|
|
||||||
(AtomicStore8 ...) => (LoweredAtomicStore8 ...)
|
|
||||||
(AtomicStore32 ...) => (LoweredAtomicStore32 ...)
|
|
||||||
(AtomicStore64 ...) => (LoweredAtomicStore64 ...)
|
|
||||||
(AtomicStorePtrNoWB ...) => (LoweredAtomicStore64 ...)
|
|
||||||
|
|
||||||
(AtomicAdd32 ...) => (LoweredAtomicAdd32 ...)
|
|
||||||
(AtomicAdd64 ...) => (LoweredAtomicAdd64 ...)
|
|
||||||
|
|
||||||
// AtomicAnd8(ptr,val) => LoweredAtomicAnd32(ptr&^3, ^((uint8(val) ^ 0xff) << ((ptr & 3) * 8)))
|
// AtomicAnd8(ptr,val) => LoweredAtomicAnd32(ptr&^3, ^((uint8(val) ^ 0xff) << ((ptr & 3) * 8)))
|
||||||
(AtomicAnd8 ptr val mem) =>
|
(AtomicAnd8 ptr val mem) =>
|
||||||
@ -581,8 +529,7 @@
|
|||||||
(AtomicCompareAndSwap32 ptr old new mem) => (LoweredAtomicCas32 ptr (SignExt32to64 old) new mem)
|
(AtomicCompareAndSwap32 ptr old new mem) => (LoweredAtomicCas32 ptr (SignExt32to64 old) new mem)
|
||||||
(AtomicCompareAndSwap64 ...) => (LoweredAtomicCas64 ...)
|
(AtomicCompareAndSwap64 ...) => (LoweredAtomicCas64 ...)
|
||||||
|
|
||||||
(AtomicExchange32 ...) => (LoweredAtomicExchange32 ...)
|
(AtomicExchange(64|32) ...) => (LoweredAtomicExchange(64|32) ...)
|
||||||
(AtomicExchange64 ...) => (LoweredAtomicExchange64 ...)
|
|
||||||
|
|
||||||
// AtomicOr8(ptr,val) => LoweredAtomicOr32(ptr&^3, uint32(val)<<((ptr&3)*8))
|
// AtomicOr8(ptr,val) => LoweredAtomicOr32(ptr&^3, uint32(val)<<((ptr&3)*8))
|
||||||
(AtomicOr8 ptr val mem) =>
|
(AtomicOr8 ptr val mem) =>
|
||||||
|
Loading…
Reference in New Issue
Block a user