github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/internal/obj/s390x/condition_code.go (about)

     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  
     5  package s390x
     6  
     7  // CCMask represents a 4-bit condition code mask. Bits that
     8  // are not part of the mask should be 0.
     9  //
    10  // Condition code masks represent the 4 possible values of
    11  // the 2-bit condition code as individual bits. Since IBM Z
    12  // is a big-endian platform bits are numbered from left to
    13  // right. The lowest value, 0, is represented by 8 (0b1000)
    14  // and the highest value, 3, is represented by 1 (0b0001).
    15  //
    16  // Note that condition code values have different semantics
    17  // depending on the instruction that set the condition code.
    18  // The names given here assume that the condition code was
    19  // set by an integer or floating point comparison. Other
    20  // instructions may use these same codes to indicate
    21  // different results such as a carry or overflow.
    22  type CCMask uint8
    23  
    24  const (
    25  	Never CCMask = 0
    26  
    27  	// 1-bit masks
    28  	Equal     CCMask = 1 << 3
    29  	Less      CCMask = 1 << 2
    30  	Greater   CCMask = 1 << 1
    31  	Unordered CCMask = 1 << 0
    32  
    33  	// 2-bit masks
    34  	EqualOrUnordered   CCMask = Equal | Unordered
    35  	LessOrEqual        CCMask = Less | Equal
    36  	LessOrGreater      CCMask = Less | Greater
    37  	LessOrUnordered    CCMask = Less | Unordered
    38  	GreaterOrEqual     CCMask = Greater | Equal
    39  	GreaterOrUnordered CCMask = Greater | Unordered
    40  
    41  	// 3-bit masks
    42  	NotEqual     CCMask = Always ^ Equal
    43  	NotLess      CCMask = Always ^ Less
    44  	NotGreater   CCMask = Always ^ Greater
    45  	NotUnordered CCMask = Always ^ Unordered
    46  
    47  	// 4-bit mask
    48  	Always CCMask = Equal | Less | Greater | Unordered
    49  
    50  	// useful aliases
    51  	Carry    CCMask = GreaterOrUnordered
    52  	NoCarry  CCMask = LessOrEqual
    53  	Borrow   CCMask = NoCarry
    54  	NoBorrow CCMask = Carry
    55  )
    56  
    57  // Inverse returns the complement of the condition code mask.
    58  func (c CCMask) Inverse() CCMask
    59  
    60  // ReverseComparison swaps the bits at 0b0100 and 0b0010 in the mask,
    61  // reversing the behavior of greater than and less than conditions.
    62  func (c CCMask) ReverseComparison() CCMask
    63  
    64  func (c CCMask) String() string
    65  
    66  func (CCMask) CanBeAnSSAAux()