Source file src/cmd/asm/internal/arch/s390x.go

Documentation: cmd/asm/internal/arch

     1  // Copyright 2016 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  // This file encapsulates some of the odd characteristics of the
     6  // s390x instruction set, to minimize its interaction
     7  // with the core of the assembler.
     8  
     9  package arch
    10  
    11  import (
    12  	"cmd/internal/obj"
    13  	"cmd/internal/obj/s390x"
    14  )
    15  
    16  func jumpS390x(word string) bool {
    17  	switch word {
    18  	case "BC",
    19  		"BCL",
    20  		"BEQ",
    21  		"BGE",
    22  		"BGT",
    23  		"BL",
    24  		"BLE",
    25  		"BLEU",
    26  		"BLT",
    27  		"BLTU",
    28  		"BNE",
    29  		"BR",
    30  		"BVC",
    31  		"BVS",
    32  		"CMPBEQ",
    33  		"CMPBGE",
    34  		"CMPBGT",
    35  		"CMPBLE",
    36  		"CMPBLT",
    37  		"CMPBNE",
    38  		"CMPUBEQ",
    39  		"CMPUBGE",
    40  		"CMPUBGT",
    41  		"CMPUBLE",
    42  		"CMPUBLT",
    43  		"CMPUBNE",
    44  		"CALL",
    45  		"JMP":
    46  		return true
    47  	}
    48  	return false
    49  }
    50  
    51  // IsS390xCMP reports whether the op (as defined by an s390x.A* constant) is
    52  // one of the CMP instructions that require special handling.
    53  func IsS390xCMP(op obj.As) bool {
    54  	switch op {
    55  	case s390x.ACMP, s390x.ACMPU, s390x.ACMPW, s390x.ACMPWU:
    56  		return true
    57  	}
    58  	return false
    59  }
    60  
    61  // IsS390xNEG reports whether the op (as defined by an s390x.A* constant) is
    62  // one of the NEG-like instructions that require special handling.
    63  func IsS390xNEG(op obj.As) bool {
    64  	switch op {
    65  	case s390x.ANEG, s390x.ANEGW:
    66  		return true
    67  	}
    68  	return false
    69  }
    70  
    71  func s390xRegisterNumber(name string, n int16) (int16, bool) {
    72  	switch name {
    73  	case "AR":
    74  		if 0 <= n && n <= 15 {
    75  			return s390x.REG_AR0 + n, true
    76  		}
    77  	case "F":
    78  		if 0 <= n && n <= 15 {
    79  			return s390x.REG_F0 + n, true
    80  		}
    81  	case "R":
    82  		if 0 <= n && n <= 15 {
    83  			return s390x.REG_R0 + n, true
    84  		}
    85  	case "V":
    86  		if 0 <= n && n <= 31 {
    87  			return s390x.REG_V0 + n, true
    88  		}
    89  	}
    90  	return 0, false
    91  }
    92  

View as plain text