github.com/peggyl/go@v0.0.0-20151008231540-ae315999c2d5/src/cmd/asm/internal/arch/ppc64.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 PowerPC (PPC64) instruction set, to minimize its interaction 7 // with the core of the assembler. 8 9 package arch 10 11 import "cmd/internal/obj/ppc64" 12 13 func jumpPPC64(word string) bool { 14 switch word { 15 case "BC", "BCL", "BEQ", "BGE", "BGT", "BL", "BLE", "BLT", "BNE", "BR", "BVC", "BVS", "CALL", "JMP": 16 return true 17 } 18 return false 19 } 20 21 // IsPPC64RLD reports whether the op (as defined by an ppc64.A* constant) is 22 // one of the RLD-like instructions that require special handling. 23 // The FMADD-like instructions behave similarly. 24 func IsPPC64RLD(op int) bool { 25 switch op { 26 case ppc64.ARLDC, ppc64.ARLDCCC, ppc64.ARLDCL, ppc64.ARLDCLCC, 27 ppc64.ARLDCR, ppc64.ARLDCRCC, ppc64.ARLDMI, ppc64.ARLDMICC, 28 ppc64.ARLWMI, ppc64.ARLWMICC, ppc64.ARLWNM, ppc64.ARLWNMCC: 29 return true 30 case ppc64.AFMADD, ppc64.AFMADDCC, ppc64.AFMADDS, ppc64.AFMADDSCC, 31 ppc64.AFMSUB, ppc64.AFMSUBCC, ppc64.AFMSUBS, ppc64.AFMSUBSCC, 32 ppc64.AFNMADD, ppc64.AFNMADDCC, ppc64.AFNMADDS, ppc64.AFNMADDSCC, 33 ppc64.AFNMSUB, ppc64.AFNMSUBCC, ppc64.AFNMSUBS, ppc64.AFNMSUBSCC: 34 return true 35 } 36 return false 37 } 38 39 // IsPPC64CMP reports whether the op (as defined by an ppc64.A* constant) is 40 // one of the CMP instructions that require special handling. 41 func IsPPC64CMP(op int) bool { 42 switch op { 43 case ppc64.ACMP, ppc64.ACMPU, ppc64.ACMPW, ppc64.ACMPWU: 44 return true 45 } 46 return false 47 } 48 49 // IsPPC64NEG reports whether the op (as defined by an ppc64.A* constant) is 50 // one of the NEG-like instructions that require special handling. 51 func IsPPC64NEG(op int) bool { 52 switch op { 53 case ppc64.AADDMECC, ppc64.AADDMEVCC, ppc64.AADDMEV, ppc64.AADDME, 54 ppc64.AADDZECC, ppc64.AADDZEVCC, ppc64.AADDZEV, ppc64.AADDZE, 55 ppc64.ACNTLZDCC, ppc64.ACNTLZD, ppc64.ACNTLZWCC, ppc64.ACNTLZW, 56 ppc64.AEXTSBCC, ppc64.AEXTSB, ppc64.AEXTSHCC, ppc64.AEXTSH, 57 ppc64.AEXTSWCC, ppc64.AEXTSW, ppc64.ANEGCC, ppc64.ANEGVCC, 58 ppc64.ANEGV, ppc64.ANEG, ppc64.ASLBMFEE, ppc64.ASLBMFEV, 59 ppc64.ASLBMTE, ppc64.ASUBMECC, ppc64.ASUBMEVCC, ppc64.ASUBMEV, 60 ppc64.ASUBME, ppc64.ASUBZECC, ppc64.ASUBZEVCC, ppc64.ASUBZEV, 61 ppc64.ASUBZE: 62 return true 63 } 64 return false 65 } 66 67 func ppc64RegisterNumber(name string, n int16) (int16, bool) { 68 switch name { 69 case "CR": 70 if 0 <= n && n <= 7 { 71 return ppc64.REG_CR0 + n, true 72 } 73 case "F": 74 if 0 <= n && n <= 31 { 75 return ppc64.REG_F0 + n, true 76 } 77 case "R": 78 if 0 <= n && n <= 31 { 79 return ppc64.REG_R0 + n, true 80 } 81 case "SPR": 82 if 0 <= n && n <= 1024 { 83 return ppc64.REG_SPR0 + n, true 84 } 85 } 86 return 0, false 87 }