Home | History | Annotate | Download | only in arch
      1 // Do not edit. Bootstrap copy of /usr/local/google/buildbot/src/android/build-tools/out/obj/go/src/cmd/asm/internal/arch/ppc64.go
      2 
      3 //line /usr/local/google/buildbot/src/android/build-tools/out/obj/go/src/cmd/asm/internal/arch/ppc64.go:1
      4 // Copyright 2015 The Go Authors. All rights reserved.
      5 // Use of this source code is governed by a BSD-style
      6 // license that can be found in the LICENSE file.
      7 
      8 // This file encapsulates some of the odd characteristics of the
      9 // 64-bit PowerPC (PPC64) instruction set, to minimize its interaction
     10 // with the core of the assembler.
     11 
     12 package arch
     13 
     14 import "bootstrap/internal/obj/ppc64"
     15 
     16 func jumpPPC64(word string) bool {
     17 	switch word {
     18 	case "BC", "BCL", "BEQ", "BGE", "BGT", "BL", "BLE", "BLT", "BNE", "BR", "BVC", "BVS", "CALL", "JMP":
     19 		return true
     20 	}
     21 	return false
     22 }
     23 
     24 // IsPPC64RLD reports whether the op (as defined by an ppc64.A* constant) is
     25 // one of the RLD-like instructions that require special handling.
     26 // The FMADD-like instructions behave similarly.
     27 func IsPPC64RLD(op int) bool {
     28 	switch op {
     29 	case ppc64.ARLDC, ppc64.ARLDCCC, ppc64.ARLDCL, ppc64.ARLDCLCC,
     30 		ppc64.ARLDCR, ppc64.ARLDCRCC, ppc64.ARLDMI, ppc64.ARLDMICC,
     31 		ppc64.ARLWMI, ppc64.ARLWMICC, ppc64.ARLWNM, ppc64.ARLWNMCC:
     32 		return true
     33 	case ppc64.AFMADD, ppc64.AFMADDCC, ppc64.AFMADDS, ppc64.AFMADDSCC,
     34 		ppc64.AFMSUB, ppc64.AFMSUBCC, ppc64.AFMSUBS, ppc64.AFMSUBSCC,
     35 		ppc64.AFNMADD, ppc64.AFNMADDCC, ppc64.AFNMADDS, ppc64.AFNMADDSCC,
     36 		ppc64.AFNMSUB, ppc64.AFNMSUBCC, ppc64.AFNMSUBS, ppc64.AFNMSUBSCC:
     37 		return true
     38 	}
     39 	return false
     40 }
     41 
     42 // IsPPC64CMP reports whether the op (as defined by an ppc64.A* constant) is
     43 // one of the CMP instructions that require special handling.
     44 func IsPPC64CMP(op int) bool {
     45 	switch op {
     46 	case ppc64.ACMP, ppc64.ACMPU, ppc64.ACMPW, ppc64.ACMPWU:
     47 		return true
     48 	}
     49 	return false
     50 }
     51 
     52 // IsPPC64NEG reports whether the op (as defined by an ppc64.A* constant) is
     53 // one of the NEG-like instructions that require special handling.
     54 func IsPPC64NEG(op int) bool {
     55 	switch op {
     56 	case ppc64.AADDMECC, ppc64.AADDMEVCC, ppc64.AADDMEV, ppc64.AADDME,
     57 		ppc64.AADDZECC, ppc64.AADDZEVCC, ppc64.AADDZEV, ppc64.AADDZE,
     58 		ppc64.ACNTLZDCC, ppc64.ACNTLZD, ppc64.ACNTLZWCC, ppc64.ACNTLZW,
     59 		ppc64.AEXTSBCC, ppc64.AEXTSB, ppc64.AEXTSHCC, ppc64.AEXTSH,
     60 		ppc64.AEXTSWCC, ppc64.AEXTSW, ppc64.ANEGCC, ppc64.ANEGVCC,
     61 		ppc64.ANEGV, ppc64.ANEG, ppc64.ASLBMFEE, ppc64.ASLBMFEV,
     62 		ppc64.ASLBMTE, ppc64.ASUBMECC, ppc64.ASUBMEVCC, ppc64.ASUBMEV,
     63 		ppc64.ASUBME, ppc64.ASUBZECC, ppc64.ASUBZEVCC, ppc64.ASUBZEV,
     64 		ppc64.ASUBZE:
     65 		return true
     66 	}
     67 	return false
     68 }
     69 
     70 func ppc64RegisterNumber(name string, n int16) (int16, bool) {
     71 	switch name {
     72 	case "CR":
     73 		if 0 <= n && n <= 7 {
     74 			return ppc64.REG_CR0 + n, true
     75 		}
     76 	case "F":
     77 		if 0 <= n && n <= 31 {
     78 			return ppc64.REG_F0 + n, true
     79 		}
     80 	case "R":
     81 		if 0 <= n && n <= 31 {
     82 			return ppc64.REG_R0 + n, true
     83 		}
     84 	case "SPR":
     85 		if 0 <= n && n <= 1024 {
     86 			return ppc64.REG_SPR0 + n, true
     87 		}
     88 	}
     89 	return 0, false
     90 }
     91