podman
47 строк · 1.3 Кб
1// Copyright 2019 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5package s390x6
7// RotateParams represents the immediates required for a "rotate
8// then ... selected bits instruction".
9//
10// The Start and End values are the indexes that represent
11// the masked region. They are inclusive and are in big-
12// endian order (bit 0 is the MSB, bit 63 is the LSB). They
13// may wrap around.
14//
15// Some examples:
16//
17// Masked region | Start | End
18// --------------------------+-------+----
19// 0x00_00_00_00_00_00_00_0f | 60 | 63
20// 0xf0_00_00_00_00_00_00_00 | 0 | 3
21// 0xf0_00_00_00_00_00_00_0f | 60 | 3
22//
23// The Amount value represents the amount to rotate the
24// input left by. Note that this rotation is performed
25// before the masked region is used.
26type RotateParams struct {27Start uint8 // big-endian start bit index [0..63]28End uint8 // big-endian end bit index [0..63]29Amount uint8 // amount to rotate left30}
31
32func NewRotateParams(start, end, amount int64) RotateParams {33if start&^63 != 0 {34panic("start out of bounds")35}36if end&^63 != 0 {37panic("end out of bounds")38}39if amount&^63 != 0 {40panic("amount out of bounds")41}42return RotateParams{43Start: uint8(start),44End: uint8(end),45Amount: uint8(amount),46}47}
48