github.com/sean-/go@v0.0.0-20151219100004-97f854cd7bb6/src/cmd/asm/internal/arch/mips64.go (about)

     1  // Copyright 2015 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  // 64-bit MIPS (MIPS64) instruction set, to minimize its interaction
     7  // with the core of the assembler.
     8  
     9  package arch
    10  
    11  import "cmd/internal/obj/mips"
    12  
    13  func jumpMIPS64(word string) bool {
    14  	switch word {
    15  	case "BEQ", "BFPF", "BFPT", "BGEZ", "BGEZAL", "BGTZ", "BLEZ", "BLTZ", "BLTZAL", "BNE", "JMP", "JAL", "CALL":
    16  		return true
    17  	}
    18  	return false
    19  }
    20  
    21  // IsMIPS64CMP reports whether the op (as defined by an mips.A* constant) is
    22  // one of the CMP instructions that require special handling.
    23  func IsMIPS64CMP(op int) bool {
    24  	switch op {
    25  	case mips.ACMPEQF, mips.ACMPEQD, mips.ACMPGEF, mips.ACMPGED,
    26  		mips.ACMPGTF, mips.ACMPGTD:
    27  		return true
    28  	}
    29  	return false
    30  }
    31  
    32  // IsMIPS64MUL reports whether the op (as defined by an mips.A* constant) is
    33  // one of the MUL/DIV/REM instructions that require special handling.
    34  func IsMIPS64MUL(op int) bool {
    35  	switch op {
    36  	case mips.AMUL, mips.AMULU, mips.AMULV, mips.AMULVU,
    37  		mips.ADIV, mips.ADIVU, mips.ADIVV, mips.ADIVVU,
    38  		mips.AREM, mips.AREMU, mips.AREMV, mips.AREMVU:
    39  		return true
    40  	}
    41  	return false
    42  }
    43  
    44  func mipsRegisterNumber(name string, n int16) (int16, bool) {
    45  	switch name {
    46  	case "F":
    47  		if 0 <= n && n <= 31 {
    48  			return mips.REG_F0 + n, true
    49  		}
    50  	case "FCR":
    51  		if 0 <= n && n <= 31 {
    52  			return mips.REG_FCR0 + n, true
    53  		}
    54  	case "M":
    55  		if 0 <= n && n <= 31 {
    56  			return mips.REG_M0 + n, true
    57  		}
    58  	case "R":
    59  		if 0 <= n && n <= 31 {
    60  			return mips.REG_R0 + n, true
    61  		}
    62  	}
    63  	return 0, false
    64  }