Skip to content

Commit

Permalink
test/codegen: updated multiple tests to verify on ppc64,ppc64le
Browse files Browse the repository at this point in the history
Updated multiple tests in test/codegen: math.go, mathbits.go, shift.go
and slices.go to verify on ppc64/ppc64le as well

Change-Id: Id88dd41569b7097819fb4d451b615f69cf7f7a94
Reviewed-on: https://go-review.googlesource.com/c/go/+/412115
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Archana Ravindar <aravind5@in.ibm.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Paul Murphy <murp@ibm.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
  • Loading branch information
Archana R authored and laboger committed Aug 17, 2022
1 parent 2c46cc8 commit d09c6ac
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/codegen/math.go
Expand Up @@ -60,6 +60,8 @@ func sqrt(x float64) float64 {
// mips/hardfloat:"SQRTD" mips/softfloat:-"SQRTD"
// mips64/hardfloat:"SQRTD" mips64/softfloat:-"SQRTD"
// wasm:"F64Sqrt"
// ppc64le:"FSQRT"
// ppc64:"FSQRT"
return math.Sqrt(x)
}

Expand All @@ -71,6 +73,8 @@ func sqrt32(x float32) float32 {
// mips/hardfloat:"SQRTF" mips/softfloat:-"SQRTF"
// mips64/hardfloat:"SQRTF" mips64/softfloat:-"SQRTF"
// wasm:"F32Sqrt"
// ppc64le:"FSQRTS"
// ppc64:"FSQRTS"
return float32(math.Sqrt(float64(x)))
}

Expand Down
16 changes: 16 additions & 0 deletions test/codegen/mathbits.go
Expand Up @@ -19,6 +19,8 @@ func LeadingZeros(n uint) int {
// arm:"CLZ" arm64:"CLZ"
// mips:"CLZ"
// wasm:"I64Clz"
// ppc64le:"CNTLZD"
// ppc64:"CNTLZD"
return bits.LeadingZeros(n)
}

Expand All @@ -29,6 +31,8 @@ func LeadingZeros64(n uint64) int {
// arm:"CLZ" arm64:"CLZ"
// mips:"CLZ"
// wasm:"I64Clz"
// ppc64le:"CNTLZD"
// ppc64:"CNTLZD"
return bits.LeadingZeros64(n)
}

Expand All @@ -39,6 +43,8 @@ func LeadingZeros32(n uint32) int {
// arm:"CLZ" arm64:"CLZW"
// mips:"CLZ"
// wasm:"I64Clz"
// ppc64le:"CNTLZW"
// ppc64:"CNTLZW"
return bits.LeadingZeros32(n)
}

Expand All @@ -49,6 +55,8 @@ func LeadingZeros16(n uint16) int {
// arm:"CLZ" arm64:"CLZ"
// mips:"CLZ"
// wasm:"I64Clz"
// ppc64le:"CNTLZD"
// ppc64:"CNTLZD"
return bits.LeadingZeros16(n)
}

Expand All @@ -59,6 +67,8 @@ func LeadingZeros8(n uint8) int {
// arm:"CLZ" arm64:"CLZ"
// mips:"CLZ"
// wasm:"I64Clz"
// ppc64le:"CNTLZD"
// ppc64:"CNTLZD"
return bits.LeadingZeros8(n)
}

Expand All @@ -73,6 +83,8 @@ func Len(n uint) int {
// arm:"CLZ" arm64:"CLZ"
// mips:"CLZ"
// wasm:"I64Clz"
// ppc64le:"SUBC","CNTLZD"
// ppc64:"SUBC","CNTLZD"
return bits.Len(n)
}

Expand Down Expand Up @@ -113,6 +125,8 @@ func Len16(n uint16) int {
// arm:"CLZ" arm64:"CLZ"
// mips:"CLZ"
// wasm:"I64Clz"
// ppc64le:"SUBC","CNTLZD"
// ppc64:"SUBC","CNTLZD"
return bits.Len16(n)
}

Expand All @@ -123,6 +137,8 @@ func Len8(n uint8) int {
// arm:"CLZ" arm64:"CLZ"
// mips:"CLZ"
// wasm:"I64Clz"
// ppc64le:"SUBC","CNTLZD"
// ppc64:"SUBC","CNTLZD"
return bits.Len8(n)
}

Expand Down
18 changes: 18 additions & 0 deletions test/codegen/shift.go
Expand Up @@ -12,46 +12,64 @@ package codegen

func lshConst64x64(v int64) int64 {
// riscv64:"SLLI",-"AND",-"SLTIU"
// ppc64le:"SLD"
// ppc64:"SLD"
return v << uint64(33)
}

func rshConst64Ux64(v uint64) uint64 {
// riscv64:"SRLI",-"AND",-"SLTIU"
// ppc64le:"SRD"
// ppc64:"SRD"
return v >> uint64(33)
}

func rshConst64x64(v int64) int64 {
// riscv64:"SRAI",-"OR",-"SLTIU"
// ppc64le:"SRAD"
// ppc64:"SRAD"
return v >> uint64(33)
}

func lshConst32x64(v int32) int32 {
// riscv64:"SLLI",-"AND",-"SLTIU"
// ppc64le:"SLW"
// ppc64:"SLW"
return v << uint64(29)
}

func rshConst32Ux64(v uint32) uint32 {
// riscv64:"SRLI",-"AND",-"SLTIU"
// ppc64le:"SRW"
// ppc64:"SRW"
return v >> uint64(29)
}

func rshConst32x64(v int32) int32 {
// riscv64:"SRAI",-"OR",-"SLTIU"
// ppc64le:"SRAW"
// ppc64:"SRAW"
return v >> uint64(29)
}

func lshConst64x32(v int64) int64 {
// riscv64:"SLLI",-"AND",-"SLTIU"
// ppc64le:"SLD"
// ppc64:"SLD"
return v << uint32(33)
}

func rshConst64Ux32(v uint64) uint64 {
// riscv64:"SRLI",-"AND",-"SLTIU"
// ppc64le:"SRD"
// ppc64:"SRD"
return v >> uint32(33)
}

func rshConst64x32(v int64) int64 {
// riscv64:"SRAI",-"OR",-"SLTIU"
// ppc64le:"SRAD"
// ppc64:"SRAD"
return v >> uint32(33)
}

Expand Down
48 changes: 48 additions & 0 deletions test/codegen/slices.go
Expand Up @@ -19,6 +19,8 @@ import "unsafe"

func SliceClear(s []int) []int {
// amd64:`.*memclrNoHeapPointers`
// ppc64le:`.*memclrNoHeapPointers`
// ppc64:`.*memclrNoHeapPointers`
for i := range s {
s[i] = 0
}
Expand All @@ -27,6 +29,8 @@ func SliceClear(s []int) []int {

func SliceClearPointers(s []*int) []*int {
// amd64:`.*memclrHasPointers`
// ppc64le:`.*memclrHasPointers`
// ppc64:`.*memclrHasPointers`
for i := range s {
s[i] = nil
}
Expand All @@ -43,39 +47,71 @@ func SliceExtensionConst(s []int) []int {
// amd64:`.*runtime\.memclrNoHeapPointers`
// amd64:-`.*runtime\.makeslice`
// amd64:-`.*runtime\.panicmakeslicelen`
// ppc64le:`.*runtime\.memclrNoHeapPointers`
// ppc64le:-`.*runtime\.makeslice`
// ppc64le:-`.*runtime\.panicmakeslicelen`
// ppc64:`.*runtime\.memclrNoHeapPointers`
// ppc64:-`.*runtime\.makeslice`
// ppc64:-`.*runtime\.panicmakeslicelen`
return append(s, make([]int, 1<<2)...)
}

func SliceExtensionConstInt64(s []int) []int {
// amd64:`.*runtime\.memclrNoHeapPointers`
// amd64:-`.*runtime\.makeslice`
// amd64:-`.*runtime\.panicmakeslicelen`
// ppc64le:`.*runtime\.memclrNoHeapPointers`
// ppc64le:-`.*runtime\.makeslice`
// ppc64le:-`.*runtime\.panicmakeslicelen`
// ppc64:`.*runtime\.memclrNoHeapPointers`
// ppc64:-`.*runtime\.makeslice`
// ppc64:-`.*runtime\.panicmakeslicelen`
return append(s, make([]int, int64(1<<2))...)
}

func SliceExtensionConstUint64(s []int) []int {
// amd64:`.*runtime\.memclrNoHeapPointers`
// amd64:-`.*runtime\.makeslice`
// amd64:-`.*runtime\.panicmakeslicelen`
// ppc64le:`.*runtime\.memclrNoHeapPointers`
// ppc64le:-`.*runtime\.makeslice`
// ppc64le:-`.*runtime\.panicmakeslicelen`
// ppc64:`.*runtime\.memclrNoHeapPointers`
// ppc64:-`.*runtime\.makeslice`
// ppc64:-`.*runtime\.panicmakeslicelen`
return append(s, make([]int, uint64(1<<2))...)
}

func SliceExtensionConstUint(s []int) []int {
// amd64:`.*runtime\.memclrNoHeapPointers`
// amd64:-`.*runtime\.makeslice`
// amd64:-`.*runtime\.panicmakeslicelen`
// ppc64le:`.*runtime\.memclrNoHeapPointers`
// ppc64le:-`.*runtime\.makeslice`
// ppc64le:-`.*runtime\.panicmakeslicelen`
// ppc64:`.*runtime\.memclrNoHeapPointers`
// ppc64:-`.*runtime\.makeslice`
// ppc64:-`.*runtime\.panicmakeslicelen`
return append(s, make([]int, uint(1<<2))...)
}

func SliceExtensionPointer(s []*int, l int) []*int {
// amd64:`.*runtime\.memclrHasPointers`
// amd64:-`.*runtime\.makeslice`
// ppc64le:`.*runtime\.memclrHasPointers`
// ppc64le:-`.*runtime\.makeslice`
// ppc64:`.*runtime\.memclrHasPointers`
// ppc64:-`.*runtime\.makeslice`
return append(s, make([]*int, l)...)
}

func SliceExtensionVar(s []byte, l int) []byte {
// amd64:`.*runtime\.memclrNoHeapPointers`
// amd64:-`.*runtime\.makeslice`
// ppc64le:`.*runtime\.memclrNoHeapPointers`
// ppc64le:-`.*runtime\.makeslice`
// ppc64:`.*runtime\.memclrNoHeapPointers`
// ppc64:-`.*runtime\.makeslice`
return append(s, make([]byte, l)...)
}

Expand Down Expand Up @@ -116,6 +152,12 @@ func SliceMakeCopyLen(s []int) []int {
// amd64:`.*runtime\.mallocgc`
// amd64:`.*runtime\.memmove`
// amd64:-`.*runtime\.makeslice`
// ppc64le:`.*runtime\.mallocgc`
// ppc64le:`.*runtime\.memmove`
// ppc64le:-`.*runtime\.makeslice`
// ppc64:`.*runtime\.mallocgc`
// ppc64:`.*runtime\.memmove`
// ppc64:-`.*runtime\.makeslice`
a := make([]int, len(s))
copy(a, s)
return a
Expand All @@ -125,6 +167,12 @@ func SliceMakeCopyLenPtr(s []*int) []*int {
// amd64:`.*runtime\.makeslicecopy`
// amd64:-`.*runtime\.makeslice\(`
// amd64:-`.*runtime\.typedslicecopy
// ppc64le:`.*runtime\.makeslicecopy`
// ppc64le:-`.*runtime\.makeslice\(`
// ppc64le:-`.*runtime\.typedslicecopy
// ppc64:`.*runtime\.makeslicecopy`
// ppc64:-`.*runtime\.makeslice\(`
// ppc64:-`.*runtime\.typedslicecopy
a := make([]*int, len(s))
copy(a, s)
return a
Expand Down

0 comments on commit d09c6ac

Please sign in to comment.