mirror of
https://github.com/golang/go
synced 2025-04-29 02:27:46 +00:00
.github
api
doc
lib
misc
src
test
abi
alias3.dir
arenas
asmhdr.dir
chan
closure3.dir
closure5.dir
codegen
README
addrcalc.go
alloc.go
arithmetic.go
atomics.go
bitfield.go
bits.go
bmi.go
bool.go
clobberdead.go
clobberdeadreg.go
compare_and_branch.go
comparisons.go
condmove.go
constants.go
copy.go
floats.go
fuse.go
ifaces.go
issue22703.go
issue25378.go
issue31618.go
issue33580.go
issue38554.go
issue42610.go
issue48054.go
issue52635.go
issue54467.go
issue56440.go
issue58166.go
issue60324.go
issue60673.go
issue61356.go
issue63332.go
issue66585.go
logic.go
mapaccess.go
maps.go
math.go
mathbits.go
memcombine.go
memops.go
memops_bigoffset.go
noextend.go
race.go
regabi_regalloc.go
retpoline.go
rotate.go
select.go
shift.go
shortcircuit.go
slices.go
smallintiface.go
spectre.go
stack.go
strings.go
structs.go
switch.go
writebarrier.go
zerosize.go
ddd2.dir
dwarf
fixedbugs
import2.dir
import4.dir
interface
intrinsic.dir
ken
linkname.dir
linknameasm.dir
method4.dir
retjmp.dir
runtime
stress
syntax
typeparam
uintptrescapes.dir
235.go
64bit.go
README.md
alg.go
alias.go
alias1.go
alias2.go
alias3.go
align.go
append.go
append1.go
args.go
armimm.go
asmhdr.go
assign.go
assign1.go
atomicload.go
bigalg.go
bigmap.go
blank.go
blank1.go
bom.go
bombad.go
bounds.go
cannotassign.go
chancap.go
chanlinear.go
char_lit.go
char_lit1.go
checkbce.go
clear.go
clearfat.go
closedchan.go
closure.go
closure1.go
closure2.go
closure3.go
closure4.go
closure5.go
closure6.go
closure7.go
cmp.go
cmp6.go
cmplx.go
cmplxdivide.c
cmplxdivide.go
cmplxdivide1.go
complit.go
complit1.go
compos.go
const.go
const1.go
const2.go
const3.go
const4.go
const5.go
const6.go
const7.go
const8.go
convT2X.go
convert.go
convert1.go
convert2.go
convert3.go
convert4.go
convinline.go
convlit.go
convlit1.go
copy.go
copy1.go
crlf.go
ddd.go
ddd1.go
ddd2.go
decl.go
declbad.go
defer.go
defererrcheck.go
deferfin.go
defernil.go
deferprint.go
deferprint.out
devirt.go
directive.go
directive2.go
divide.go
divmod.go
embedfunc.go
embedvers.go
empty.go
env.go
eof.go
eof1.go
escape.go
escape2.go
escape2n.go
escape3.go
escape4.go
escape5.go
escape_array.go
escape_calls.go
escape_closure.go
escape_field.go
escape_goto.go
escape_hash_maphash.go
escape_iface.go
escape_indir.go
escape_level.go
escape_map.go
escape_mutations.go
escape_param.go
escape_reflect.go
escape_runtime_atomic.go
escape_selfassign.go
escape_slice.go
escape_struct_param1.go
escape_struct_param2.go
escape_struct_return.go
escape_sync_atomic.go
escape_unsafe.go
fibo.go
finprofiled.go
float_lit.go
float_lit2.go
float_lit3.go
floatcmp.go
for.go
func.go
func1.go
func2.go
func3.go
func4.go
func5.go
func6.go
func7.go
func8.go
funcdup.go
funcdup2.go
fuse.go
gc.go
gc1.go
gc2.go
gcgort.go
gcstring.go
goprint.go
goprint.out
goto.go
heapsampling.go
helloworld.go
helloworld.out
if.go
import.go
import1.go
import2.go
import4.go
import5.go
import6.go
index.go
index0.go
index1.go
index2.go
indirect.go
indirect1.go
init.go
init1.go
initcomma.go
initexp.go
initialize.go
initializerr.go
initloop.go
inline.go
inline_big.go
inline_caller.go
inline_callers.go
inline_endian.go
inline_literal.go
inline_math_bits_rotate.go
inline_sync.go
inline_variadic.go
int_lit.go
intcvt.go
intrinsic.go
intrinsic_atomic.go
iota.go
label.go
label1.go
linkmain.go
linkmain_run.go
linkname.go
linkname3.go
linknameasm.go
linkobj.go
linkx.go
linkx_run.go
literal.go
literal2.go
live.go
live1.go
live2.go
live_regabi.go
live_uintptrkeepalive.go
loopbce.go
mainsig.go
makechan.go
makemap.go
makenew.go
makeslice.go
mallocfin.go
map.go
map1.go
mapclear.go
maplinear.go
maymorestack.go
mergemul.go
method.go
method1.go
method2.go
method3.go
method4.go
method5.go
method6.go
method7.go
named.go
named1.go
newinline.go
nil.go
nilcheck.go
nilptr.go
nilptr2.go
nilptr3.go
nilptr4.go
nilptr5.go
nilptr5_aix.go
nilptr5_wasm.go
nilptr_aix.go
noinit.go
nosplit.go
nowritebarrier.go
nul1.go
opt_branchlikely.go
parentype.go
peano.go
phiopt.go
print.go
print.out
printbig.go
printbig.out
prove.go
prove_constant_folding.go
prove_invert_loop_with_unused_iterators.go
range.go
range2.go
range3.go
range4.go
rangegen.go
recover.go
recover1.go
recover2.go
recover3.go
recover4.go
recover5.go
reflectmethod1.go
reflectmethod2.go
reflectmethod3.go
reflectmethod4.go
reflectmethod5.go
reflectmethod6.go
reflectmethod7.go
reflectmethod8.go
rename.go
rename1.go
reorder.go
reorder2.go
retjmp.go
return.go
rotate.go
rotate0.go
rotate1.go
rotate2.go
rotate3.go
rune.go
runtime.go
shift1.go
shift2.go
shift3.go
sieve.go
sigchld.go
sigchld.out
simassign.go
sizeof.go
slice3.go
slice3err.go
slicecap.go
sliceopt.go
solitaire.go
stack.go
stackobj.go
stackobj2.go
stackobj3.go
strcopy.go
strength.go
string_lit.go
stringrange.go
struct0.go
switch.go
switch2.go
switch3.go
switch4.go
switch5.go
switch6.go
switch7.go
tighten.go
tinyfin.go
torture.go
turing.go
typecheck.go
typecheckloop.go
typeswitch.go
typeswitch1.go
typeswitch2.go
typeswitch2b.go
typeswitch3.go
uintptrescapes.go
uintptrescapes2.go
uintptrescapes3.go
uintptrkeepalive.go
undef.go
unsafe_slice_data.go
unsafe_string.go
unsafe_string_data.go
unsafebuiltins.go
used.go
utf.go
varerr.go
varinit.go
winbatch.go
writebarrier.go
zerodivide.go
zerosize.go
.gitattributes
.gitignore
CONTRIBUTING.md
LICENSE
PATENTS
README.md
SECURITY.md
VERSION
codereview.cfg
go.env
Previously we convert $0 to the ZR register for some reasons, which causes two problems: 1. Confusion, the special case of the ZR register needs to be considered when dealing with constants. For encoding, some places we encode ZR, and some places we encode $0, although we have converted $0 to ZR. 2. Unexpected instruction format. All instructions that support ZR register operands can be replaced by $0. This patch removes this conversion. Note that this patch may cause previously unintendedly supported instruction formats to no longer be supported. Change-Id: I3d8d2c06711b7614a38191397da7776417f1861c Reviewed-on: https://go-review.googlesource.com/c/go/+/404316 Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Eric Fang <eric.fang@arm.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
369 lines
9.6 KiB
Go
369 lines
9.6 KiB
Go
// asmcheck
|
|
|
|
// Copyright 2018 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package codegen
|
|
|
|
// This file contains codegen tests related to bit field
|
|
// insertion/extraction simplifications/optimizations.
|
|
|
|
func extr1(x, x2 uint64) uint64 {
|
|
return x<<7 + x2>>57 // arm64:"EXTR\t[$]57,"
|
|
}
|
|
|
|
func extr2(x, x2 uint64) uint64 {
|
|
return x<<7 | x2>>57 // arm64:"EXTR\t[$]57,"
|
|
}
|
|
|
|
func extr3(x, x2 uint64) uint64 {
|
|
return x<<7 ^ x2>>57 // arm64:"EXTR\t[$]57,"
|
|
}
|
|
|
|
func extr4(x, x2 uint32) uint32 {
|
|
return x<<7 + x2>>25 // arm64:"EXTRW\t[$]25,"
|
|
}
|
|
|
|
func extr5(x, x2 uint32) uint32 {
|
|
return x<<7 | x2>>25 // arm64:"EXTRW\t[$]25,"
|
|
}
|
|
|
|
func extr6(x, x2 uint32) uint32 {
|
|
return x<<7 ^ x2>>25 // arm64:"EXTRW\t[$]25,"
|
|
}
|
|
|
|
// check 32-bit shift masking
|
|
func mask32(x uint32) uint32 {
|
|
return (x << 29) >> 29 // arm64:"AND\t[$]7, R[0-9]+",-"LSR",-"LSL"
|
|
}
|
|
|
|
// check 16-bit shift masking
|
|
func mask16(x uint16) uint16 {
|
|
return (x << 14) >> 14 // arm64:"AND\t[$]3, R[0-9]+",-"LSR",-"LSL"
|
|
}
|
|
|
|
// check 8-bit shift masking
|
|
func mask8(x uint8) uint8 {
|
|
return (x << 7) >> 7 // arm64:"AND\t[$]1, R[0-9]+",-"LSR",-"LSL"
|
|
}
|
|
|
|
func maskshift(x uint64) uint64 {
|
|
// arm64:"AND\t[$]4095, R[0-9]+",-"LSL",-"LSR",-"UBFIZ",-"UBFX"
|
|
return ((x << 5) & (0xfff << 5)) >> 5
|
|
}
|
|
|
|
// bitfield ops
|
|
// bfi
|
|
func bfi1(x, y uint64) uint64 {
|
|
// arm64:"BFI\t[$]4, R[0-9]+, [$]12",-"LSL",-"LSR",-"AND"
|
|
return ((x & 0xfff) << 4) | (y & 0xffffffffffff000f)
|
|
}
|
|
|
|
func bfi2(x, y uint64) uint64 {
|
|
// arm64:"BFI\t[$]12, R[0-9]+, [$]40",-"LSL",-"LSR",-"AND"
|
|
return (x << 24 >> 12) | (y & 0xfff0000000000fff)
|
|
}
|
|
|
|
// bfxil
|
|
func bfxil1(x, y uint64) uint64 {
|
|
// arm64:"BFXIL\t[$]5, R[0-9]+, [$]12",-"LSL",-"LSR",-"AND"
|
|
return ((x >> 5) & 0xfff) | (y & 0xfffffffffffff000)
|
|
}
|
|
|
|
func bfxil2(x, y uint64) uint64 {
|
|
// arm64:"BFXIL\t[$]12, R[0-9]+, [$]40",-"LSL",-"LSR",-"AND"
|
|
return (x << 12 >> 24) | (y & 0xffffff0000000000)
|
|
}
|
|
|
|
// sbfiz
|
|
// merge shifts into sbfiz: (x << lc) >> rc && lc > rc.
|
|
func sbfiz1(x int64) int64 {
|
|
// arm64:"SBFIZ\t[$]1, R[0-9]+, [$]60",-"LSL",-"ASR"
|
|
return (x << 4) >> 3
|
|
}
|
|
|
|
// merge shift and sign-extension into sbfiz.
|
|
func sbfiz2(x int32) int64 {
|
|
return int64(x << 3) // arm64:"SBFIZ\t[$]3, R[0-9]+, [$]29",-"LSL"
|
|
}
|
|
|
|
func sbfiz3(x int16) int64 {
|
|
return int64(x << 3) // arm64:"SBFIZ\t[$]3, R[0-9]+, [$]13",-"LSL"
|
|
}
|
|
|
|
func sbfiz4(x int8) int64 {
|
|
return int64(x << 3) // arm64:"SBFIZ\t[$]3, R[0-9]+, [$]5",-"LSL"
|
|
}
|
|
|
|
// sbfiz combinations.
|
|
// merge shift with sbfiz into sbfiz.
|
|
func sbfiz5(x int32) int32 {
|
|
// arm64:"SBFIZ\t[$]1, R[0-9]+, [$]28",-"LSL",-"ASR"
|
|
return (x << 4) >> 3
|
|
}
|
|
|
|
func sbfiz6(x int16) int64 {
|
|
return int64(x+1) << 3 // arm64:"SBFIZ\t[$]3, R[0-9]+, [$]16",-"LSL"
|
|
}
|
|
|
|
func sbfiz7(x int8) int64 {
|
|
return int64(x+1) << 62 // arm64:"SBFIZ\t[$]62, R[0-9]+, [$]2",-"LSL"
|
|
}
|
|
|
|
func sbfiz8(x int32) int64 {
|
|
return int64(x+1) << 40 // arm64:"SBFIZ\t[$]40, R[0-9]+, [$]24",-"LSL"
|
|
}
|
|
|
|
// sbfx
|
|
// merge shifts into sbfx: (x << lc) >> rc && lc <= rc.
|
|
func sbfx1(x int64) int64 {
|
|
return (x << 3) >> 4 // arm64:"SBFX\t[$]1, R[0-9]+, [$]60",-"LSL",-"ASR"
|
|
}
|
|
|
|
func sbfx2(x int64) int64 {
|
|
return (x << 60) >> 60 // arm64:"SBFX\t[$]0, R[0-9]+, [$]4",-"LSL",-"ASR"
|
|
}
|
|
|
|
// merge shift and sign-extension into sbfx.
|
|
func sbfx3(x int32) int64 {
|
|
return int64(x) >> 3 // arm64:"SBFX\t[$]3, R[0-9]+, [$]29",-"ASR"
|
|
}
|
|
|
|
func sbfx4(x int16) int64 {
|
|
return int64(x) >> 3 // arm64:"SBFX\t[$]3, R[0-9]+, [$]13",-"ASR"
|
|
}
|
|
|
|
func sbfx5(x int8) int64 {
|
|
return int64(x) >> 3 // arm64:"SBFX\t[$]3, R[0-9]+, [$]5",-"ASR"
|
|
}
|
|
|
|
func sbfx6(x int32) int64 {
|
|
return int64(x >> 30) // arm64:"SBFX\t[$]30, R[0-9]+, [$]2"
|
|
}
|
|
|
|
func sbfx7(x int16) int64 {
|
|
return int64(x >> 10) // arm64:"SBFX\t[$]10, R[0-9]+, [$]6"
|
|
}
|
|
|
|
func sbfx8(x int8) int64 {
|
|
return int64(x >> 5) // arm64:"SBFX\t[$]5, R[0-9]+, [$]3"
|
|
}
|
|
|
|
// sbfx combinations.
|
|
// merge shifts with sbfiz into sbfx.
|
|
func sbfx9(x int32) int32 {
|
|
return (x << 3) >> 4 // arm64:"SBFX\t[$]1, R[0-9]+, [$]28",-"LSL",-"ASR"
|
|
}
|
|
|
|
// merge sbfx and sign-extension into sbfx.
|
|
func sbfx10(x int32) int64 {
|
|
c := x + 5
|
|
return int64(c >> 20) // arm64"SBFX\t[$]20, R[0-9]+, [$]12",-"MOVW\tR[0-9]+, R[0-9]+"
|
|
}
|
|
|
|
// ubfiz
|
|
// merge shifts into ubfiz: (x<<lc)>>rc && lc>rc
|
|
func ubfiz1(x uint64) uint64 {
|
|
// arm64:"UBFIZ\t[$]1, R[0-9]+, [$]60",-"LSL",-"LSR"
|
|
// s390x:"RISBGZ\t[$]3, [$]62, [$]1, ",-"SLD",-"SRD"
|
|
return (x << 4) >> 3
|
|
}
|
|
|
|
// merge shift and zero-extension into ubfiz.
|
|
func ubfiz2(x uint32) uint64 {
|
|
return uint64(x+1) << 3 // arm64:"UBFIZ\t[$]3, R[0-9]+, [$]32",-"LSL"
|
|
}
|
|
|
|
func ubfiz3(x uint16) uint64 {
|
|
return uint64(x+1) << 3 // arm64:"UBFIZ\t[$]3, R[0-9]+, [$]16",-"LSL"
|
|
}
|
|
|
|
func ubfiz4(x uint8) uint64 {
|
|
return uint64(x+1) << 3 // arm64:"UBFIZ\t[$]3, R[0-9]+, [$]8",-"LSL"
|
|
}
|
|
|
|
func ubfiz5(x uint8) uint64 {
|
|
return uint64(x) << 60 // arm64:"UBFIZ\t[$]60, R[0-9]+, [$]4",-"LSL"
|
|
}
|
|
|
|
func ubfiz6(x uint32) uint64 {
|
|
return uint64(x << 30) // arm64:"UBFIZ\t[$]30, R[0-9]+, [$]2",
|
|
}
|
|
|
|
func ubfiz7(x uint16) uint64 {
|
|
return uint64(x << 10) // arm64:"UBFIZ\t[$]10, R[0-9]+, [$]6",
|
|
}
|
|
|
|
func ubfiz8(x uint8) uint64 {
|
|
return uint64(x << 7) // arm64:"UBFIZ\t[$]7, R[0-9]+, [$]1",
|
|
}
|
|
|
|
// merge ANDconst into ubfiz.
|
|
func ubfiz9(x uint64) uint64 {
|
|
// arm64:"UBFIZ\t[$]3, R[0-9]+, [$]12",-"LSL",-"AND"
|
|
// s390x:"RISBGZ\t[$]49, [$]60, [$]3,",-"SLD",-"AND"
|
|
return (x & 0xfff) << 3
|
|
}
|
|
|
|
func ubfiz10(x uint64) uint64 {
|
|
// arm64:"UBFIZ\t[$]4, R[0-9]+, [$]12",-"LSL",-"AND"
|
|
// s390x:"RISBGZ\t[$]48, [$]59, [$]4,",-"SLD",-"AND"
|
|
return (x << 4) & 0xfff0
|
|
}
|
|
|
|
// ubfiz combinations
|
|
func ubfiz11(x uint32) uint32 {
|
|
// arm64:"UBFIZ\t[$]1, R[0-9]+, [$]28",-"LSL",-"LSR"
|
|
return (x << 4) >> 3
|
|
}
|
|
|
|
func ubfiz12(x uint64) uint64 {
|
|
// arm64:"UBFIZ\t[$]1, R[0-9]+, [$]20",-"LSL",-"LSR"
|
|
// s390x:"RISBGZ\t[$]43, [$]62, [$]1, ",-"SLD",-"SRD",-"AND"
|
|
return ((x & 0xfffff) << 4) >> 3
|
|
}
|
|
|
|
func ubfiz13(x uint64) uint64 {
|
|
// arm64:"UBFIZ\t[$]5, R[0-9]+, [$]13",-"LSL",-"LSR",-"AND"
|
|
return ((x << 3) & 0xffff) << 2
|
|
}
|
|
|
|
func ubfiz14(x uint64) uint64 {
|
|
// arm64:"UBFIZ\t[$]7, R[0-9]+, [$]12",-"LSL",-"LSR",-"AND"
|
|
// s390x:"RISBGZ\t[$]45, [$]56, [$]7, ",-"SLD",-"SRD",-"AND"
|
|
return ((x << 5) & (0xfff << 5)) << 2
|
|
}
|
|
|
|
// ubfx
|
|
// merge shifts into ubfx: (x<<lc)>>rc && lc<rc
|
|
func ubfx1(x uint64) uint64 {
|
|
// arm64:"UBFX\t[$]1, R[0-9]+, [$]62",-"LSL",-"LSR"
|
|
// s390x:"RISBGZ\t[$]2, [$]63, [$]63,",-"SLD",-"SRD"
|
|
return (x << 1) >> 2
|
|
}
|
|
|
|
// merge shift and zero-extension into ubfx.
|
|
func ubfx2(x uint32) uint64 {
|
|
return uint64(x >> 15) // arm64:"UBFX\t[$]15, R[0-9]+, [$]17",-"LSR"
|
|
}
|
|
|
|
func ubfx3(x uint16) uint64 {
|
|
return uint64(x >> 9) // arm64:"UBFX\t[$]9, R[0-9]+, [$]7",-"LSR"
|
|
}
|
|
|
|
func ubfx4(x uint8) uint64 {
|
|
return uint64(x >> 3) // arm64:"UBFX\t[$]3, R[0-9]+, [$]5",-"LSR"
|
|
}
|
|
|
|
func ubfx5(x uint32) uint64 {
|
|
return uint64(x) >> 30 // arm64:"UBFX\t[$]30, R[0-9]+, [$]2"
|
|
}
|
|
|
|
func ubfx6(x uint16) uint64 {
|
|
return uint64(x) >> 10 // arm64:"UBFX\t[$]10, R[0-9]+, [$]6"
|
|
}
|
|
|
|
func ubfx7(x uint8) uint64 {
|
|
return uint64(x) >> 3 // arm64:"UBFX\t[$]3, R[0-9]+, [$]5"
|
|
}
|
|
|
|
// merge ANDconst into ubfx.
|
|
func ubfx8(x uint64) uint64 {
|
|
// arm64:"UBFX\t[$]25, R[0-9]+, [$]10",-"LSR",-"AND"
|
|
// s390x:"RISBGZ\t[$]54, [$]63, [$]39, ",-"SRD",-"AND"
|
|
return (x >> 25) & 1023
|
|
}
|
|
|
|
func ubfx9(x uint64) uint64 {
|
|
// arm64:"UBFX\t[$]4, R[0-9]+, [$]8",-"LSR",-"AND"
|
|
// s390x:"RISBGZ\t[$]56, [$]63, [$]60, ",-"SRD",-"AND"
|
|
return (x & 0x0ff0) >> 4
|
|
}
|
|
|
|
// ubfx combinations.
|
|
func ubfx10(x uint32) uint32 {
|
|
// arm64:"UBFX\t[$]1, R[0-9]+, [$]30",-"LSL",-"LSR"
|
|
return (x << 1) >> 2
|
|
}
|
|
|
|
func ubfx11(x uint64) uint64 {
|
|
// arm64:"UBFX\t[$]1, R[0-9]+, [$]12",-"LSL",-"LSR",-"AND"
|
|
// s390x:"RISBGZ\t[$]52, [$]63, [$]63,",-"SLD",-"SRD",-"AND"
|
|
return ((x << 1) >> 2) & 0xfff
|
|
}
|
|
|
|
func ubfx12(x uint64) uint64 {
|
|
// arm64:"UBFX\t[$]4, R[0-9]+, [$]11",-"LSL",-"LSR",-"AND"
|
|
// s390x:"RISBGZ\t[$]53, [$]63, [$]60, ",-"SLD",-"SRD",-"AND"
|
|
return ((x >> 3) & 0xfff) >> 1
|
|
}
|
|
|
|
func ubfx13(x uint64) uint64 {
|
|
// arm64:"UBFX\t[$]5, R[0-9]+, [$]56",-"LSL",-"LSR"
|
|
// s390x:"RISBGZ\t[$]8, [$]63, [$]59, ",-"SLD",-"SRD"
|
|
return ((x >> 2) << 5) >> 8
|
|
}
|
|
|
|
func ubfx14(x uint64) uint64 {
|
|
// arm64:"UBFX\t[$]1, R[0-9]+, [$]19",-"LSL",-"LSR"
|
|
// s390x:"RISBGZ\t[$]45, [$]63, [$]63, ",-"SLD",-"SRD",-"AND"
|
|
return ((x & 0xfffff) << 3) >> 4
|
|
}
|
|
|
|
// merge ubfx and zero-extension into ubfx.
|
|
func ubfx15(x uint64) bool {
|
|
midr := x + 10
|
|
part_num := uint16((midr >> 4) & 0xfff)
|
|
if part_num == 0xd0c { // arm64:"UBFX\t[$]4, R[0-9]+, [$]12",-"MOVHU\tR[0-9]+, R[0-9]+"
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
// merge ANDconst and ubfx into ubfx
|
|
func ubfx16(x uint64) uint64 {
|
|
// arm64:"UBFX\t[$]4, R[0-9]+, [$]6",-"AND\t[$]63"
|
|
return ((x >> 3) & 0xfff) >> 1 & 0x3f
|
|
}
|
|
|
|
// Check that we don't emit comparisons for constant shifts.
|
|
//
|
|
//go:nosplit
|
|
func shift_no_cmp(x int) int {
|
|
// arm64:`LSL\t[$]17`,-`CMP`
|
|
// mips64:`SLLV\t[$]17`,-`SGT`
|
|
return x << 17
|
|
}
|
|
|
|
func rev16(c uint64) (uint64, uint64, uint64) {
|
|
// arm64:`REV16`,-`AND`,-`LSR`,-`AND`,-`ORR\tR[0-9]+<<8`
|
|
b1 := ((c & 0xff00ff00ff00ff00) >> 8) | ((c & 0x00ff00ff00ff00ff) << 8)
|
|
// arm64:-`ADD\tR[0-9]+<<8`
|
|
b2 := ((c & 0xff00ff00ff00ff00) >> 8) + ((c & 0x00ff00ff00ff00ff) << 8)
|
|
// arm64:-`EOR\tR[0-9]+<<8`
|
|
b3 := ((c & 0xff00ff00ff00ff00) >> 8) ^ ((c & 0x00ff00ff00ff00ff) << 8)
|
|
return b1, b2, b3
|
|
}
|
|
|
|
func rev16w(c uint32) (uint32, uint32, uint32) {
|
|
// arm64:`REV16W`,-`AND`,-`UBFX`,-`AND`,-`ORR\tR[0-9]+<<8`
|
|
b1 := ((c & 0xff00ff00) >> 8) | ((c & 0x00ff00ff) << 8)
|
|
// arm64:-`ADD\tR[0-9]+<<8`
|
|
b2 := ((c & 0xff00ff00) >> 8) + ((c & 0x00ff00ff) << 8)
|
|
// arm64:-`EOR\tR[0-9]+<<8`
|
|
b3 := ((c & 0xff00ff00) >> 8) ^ ((c & 0x00ff00ff) << 8)
|
|
return b1, b2, b3
|
|
}
|
|
|
|
func shift(x uint32, y uint16, z uint8) uint64 {
|
|
// arm64:-`MOVWU`,-`LSR\t[$]32`
|
|
a := uint64(x) >> 32
|
|
// arm64:-`MOVHU
|
|
b := uint64(y) >> 16
|
|
// arm64:-`MOVBU`
|
|
c := uint64(z) >> 8
|
|
// arm64:`MOVD\tZR`,-`ADD\tR[0-9]+>>16`,-`ADD\tR[0-9]+>>8`,
|
|
return a + b + c
|
|
}
|