kusano 2b45e8
/*********************************************************************/
kusano 2b45e8
/* Copyright 2009, 2010 The University of Texas at Austin.           */
kusano 2b45e8
/* All rights reserved.                                              */
kusano 2b45e8
/*                                                                   */
kusano 2b45e8
/* Redistribution and use in source and binary forms, with or        */
kusano 2b45e8
/* without modification, are permitted provided that the following   */
kusano 2b45e8
/* conditions are met:                                               */
kusano 2b45e8
/*                                                                   */
kusano 2b45e8
/*   1. Redistributions of source code must retain the above         */
kusano 2b45e8
/*      copyright notice, this list of conditions and the following  */
kusano 2b45e8
/*      disclaimer.                                                  */
kusano 2b45e8
/*                                                                   */
kusano 2b45e8
/*   2. Redistributions in binary form must reproduce the above      */
kusano 2b45e8
/*      copyright notice, this list of conditions and the following  */
kusano 2b45e8
/*      disclaimer in the documentation and/or other materials       */
kusano 2b45e8
/*      provided with the distribution.                              */
kusano 2b45e8
/*                                                                   */
kusano 2b45e8
/*    THIS  SOFTWARE IS PROVIDED  BY THE  UNIVERSITY OF  TEXAS AT    */
kusano 2b45e8
/*    AUSTIN  ``AS IS''  AND ANY  EXPRESS OR  IMPLIED WARRANTIES,    */
kusano 2b45e8
/*    INCLUDING, BUT  NOT LIMITED  TO, THE IMPLIED  WARRANTIES OF    */
kusano 2b45e8
/*    MERCHANTABILITY  AND FITNESS FOR  A PARTICULAR  PURPOSE ARE    */
kusano 2b45e8
/*    DISCLAIMED.  IN  NO EVENT SHALL THE UNIVERSITY  OF TEXAS AT    */
kusano 2b45e8
/*    AUSTIN OR CONTRIBUTORS BE  LIABLE FOR ANY DIRECT, INDIRECT,    */
kusano 2b45e8
/*    INCIDENTAL,  SPECIAL, EXEMPLARY,  OR  CONSEQUENTIAL DAMAGES    */
kusano 2b45e8
/*    (INCLUDING, BUT  NOT LIMITED TO,  PROCUREMENT OF SUBSTITUTE    */
kusano 2b45e8
/*    GOODS  OR  SERVICES; LOSS  OF  USE,  DATA,  OR PROFITS;  OR    */
kusano 2b45e8
/*    BUSINESS INTERRUPTION) HOWEVER CAUSED  AND ON ANY THEORY OF    */
kusano 2b45e8
/*    LIABILITY, WHETHER  IN CONTRACT, STRICT  LIABILITY, OR TORT    */
kusano 2b45e8
/*    (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING IN ANY WAY OUT    */
kusano 2b45e8
/*    OF  THE  USE OF  THIS  SOFTWARE,  EVEN  IF ADVISED  OF  THE    */
kusano 2b45e8
/*    POSSIBILITY OF SUCH DAMAGE.                                    */
kusano 2b45e8
/*                                                                   */
kusano 2b45e8
/* The views and conclusions contained in the software and           */
kusano 2b45e8
/* documentation are those of the authors and should not be          */
kusano 2b45e8
/* interpreted as representing official policies, either expressed   */
kusano 2b45e8
/* or implied, of The University of Texas at Austin.                 */
kusano 2b45e8
/*********************************************************************/
kusano 2b45e8
kusano 2b45e8
#ifndef COMMON_POWER
kusano 2b45e8
#define COMMON_POWER
kusano 2b45e8
kusano 2b45e8
#define MB		__asm__ __volatile__ ("sync")
kusano 2b45e8
#define WMB		__asm__ __volatile__ ("sync")
kusano 2b45e8
kusano 2b45e8
#define INLINE inline
kusano 2b45e8
kusano 2b45e8
#ifdef PPC440
kusano 2b45e8
#define STDERR stdout
kusano 2b45e8
#define QNONCACHE 0x1
kusano 2b45e8
#define QCOMMS    0x2
kusano 2b45e8
#define QFAST     0x4
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifndef ASSEMBLER
kusano 2b45e8
kusano 2b45e8
void *qalloc(int flags, size_t bytes);
kusano 2b45e8
kusano 2b45e8
static void INLINE blas_lock(volatile unsigned long *address){
kusano 2b45e8
kusano 2b45e8
  long int ret, val = 1;
kusano 2b45e8
kusano 2b45e8
  do {
kusano 2b45e8
    while (*address) {YIELDING;};
kusano 2b45e8
kusano 2b45e8
#if defined(OS_LINUX) || defined(OS_DARWIN)
kusano 2b45e8
  __asm__ __volatile__ (
kusano 2b45e8
	   "0:	lwarx %0, 0, %1\n"
kusano 2b45e8
	   "	cmpwi %0, 0\n"
kusano 2b45e8
	   "	bne- 1f\n"
kusano 2b45e8
	   "	stwcx. %2,0, %1\n"
kusano 2b45e8
	   "	bne- 0b\n"
kusano 2b45e8
	   "1:    "
kusano 2b45e8
	: "=&r"(ret)
kusano 2b45e8
	: "r"(address), "r" (val)
kusano 2b45e8
	: "cr0", "memory");
kusano 2b45e8
#else
kusano 2b45e8
  __asm__ __volatile__ (
kusano 2b45e8
	   ".machine \"any\"\n"
kusano 2b45e8
	   "	lwarx %0, 0, %1\n"
kusano 2b45e8
	   "	cmpwi  %0, 0\n"
kusano 2b45e8
	   "	bne-  $+12\n"
kusano 2b45e8
	   "	stwcx. %2,0, %1\n"
kusano 2b45e8
	   "	bne-  $-16\n"
kusano 2b45e8
	: "=&r"(ret)
kusano 2b45e8
	: "r"(address), "r" (val)
kusano 2b45e8
	: "cr0", "memory");
kusano 2b45e8
#endif
kusano 2b45e8
  } while (ret);
kusano 2b45e8
}
kusano 2b45e8
kusano 2b45e8
static inline unsigned long rpcc(void){
kusano 2b45e8
  unsigned long ret;
kusano 2b45e8
kusano 2b45e8
#ifdef OS_AIX
kusano 2b45e8
  __asm__ __volatile__(".machine \"any\" ;");
kusano 2b45e8
#endif
kusano 2b45e8
  __asm__ __volatile__ ("mftb %0" : "=r" (ret) : );
kusano 2b45e8
kusano 2b45e8
#if defined(POWER5) || defined(PPC970)
kusano 2b45e8
  return (ret << 6);
kusano 2b45e8
#else
kusano 2b45e8
  return (ret << 3);
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
}
kusano 2b45e8
kusano 2b45e8
#ifdef __64BIT__
kusano 2b45e8
#define RPCC64BIT
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
static inline unsigned long getstackaddr(void){
kusano 2b45e8
  unsigned long addr;
kusano 2b45e8
kusano 2b45e8
  __asm__ __volatile__ ("mr %0, 1"
kusano 2b45e8
			 : "=r"(addr) : : "memory");
kusano 2b45e8
kusano 2b45e8
  return addr;  
kusano 2b45e8
};
kusano 2b45e8
kusano 2b45e8
#if defined(OS_LINUX) || defined(OS_AIX)
kusano 2b45e8
#define GET_IMAGE(res)  __asm__ __volatile__("fmr %0, 2" : "=f"(res)  : : "memory")
kusano 2b45e8
#else
kusano 2b45e8
#define GET_IMAGE(res)  __asm__ __volatile__("fmr %0, f2" : "=f"(res)  : : "memory")
kusano 2b45e8
kusano 2b45e8
#define GET_IMAGE_CANCEL
kusano 2b45e8
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef SMP
kusano 2b45e8
static inline int blas_quickdivide(blasint x, blasint y){
kusano 2b45e8
  return x / y;
kusano 2b45e8
}
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
kusano 2b45e8
#ifdef ASSEMBLER
kusano 2b45e8
kusano 2b45e8
#ifdef DOUBLE
kusano 2b45e8
#define LFD	lfd
kusano 2b45e8
#define LFDX	lfdx
kusano 2b45e8
#define LFPDX	lfpdx
kusano 2b45e8
#define LFSDX	lfsdx
kusano 2b45e8
#define LFXDX	lfxdx
kusano 2b45e8
#define LFDU	lfdu
kusano 2b45e8
#define LFDUX	lfdux
kusano 2b45e8
#define LFPDUX	lfpdux
kusano 2b45e8
#define LFSDUX	lfsdux
kusano 2b45e8
#define LFXDUX	lfxdux
kusano 2b45e8
#define STFD	stfd
kusano 2b45e8
#define STFDX	stfdx
kusano 2b45e8
#define STFPDX	stfpdx
kusano 2b45e8
#define STFSDX	stfsdx
kusano 2b45e8
#define STFXDX	stfxdx
kusano 2b45e8
#define STFDU	stfdu
kusano 2b45e8
#define STFDUX	stfdux
kusano 2b45e8
#define STFPDUX	stfpdux
kusano 2b45e8
#define STFSDUX	stfsdux
kusano 2b45e8
#define STFXDUX	stfxdux
kusano 2b45e8
#define FMADD	fmadd
kusano 2b45e8
#define FMSUB	fmsub
kusano 2b45e8
#define FNMADD	fnmadd
kusano 2b45e8
#define FNMSUB	fnmsub
kusano 2b45e8
#define FMUL	fmul
kusano 2b45e8
#define FADD	fadd
kusano 2b45e8
#define FSUB	fsub
kusano 2b45e8
#else
kusano 2b45e8
#define LFD	lfs
kusano 2b45e8
#define LFDX	lfsx
kusano 2b45e8
#define LFPDX	lfpsx
kusano 2b45e8
#define LFSDX	lfssx
kusano 2b45e8
#define LFXDX	lfxsx
kusano 2b45e8
#define LFDU	lfsu
kusano 2b45e8
#define LFDUX	lfsux
kusano 2b45e8
#define LFPDUX	lfpsux
kusano 2b45e8
#define LFSDUX	lfssux
kusano 2b45e8
#define LFXDUX	lfxsux
kusano 2b45e8
#define STFD	stfs
kusano 2b45e8
#define STFDX	stfsx
kusano 2b45e8
#define STFPDX	stfpsx
kusano 2b45e8
#define STFSDX	stfssx
kusano 2b45e8
#define STFXDX	stfxsx
kusano 2b45e8
#define STFDU	stfsu
kusano 2b45e8
#define STFDUX	stfsux
kusano 2b45e8
#define STFPDUX	stfpsux
kusano 2b45e8
#define STFSDUX	stfssux
kusano 2b45e8
#define STFXDUX	stfxsux
kusano 2b45e8
#define FMADD	fmadds
kusano 2b45e8
#define FMSUB	fmsubs
kusano 2b45e8
#define FNMADD	fnmadds
kusano 2b45e8
#define FNMSUB	fnmsubs
kusano 2b45e8
#define FMUL	fmuls
kusano 2b45e8
#define FADD	fadds
kusano 2b45e8
#define FSUB	fsubs
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef __64BIT__
kusano 2b45e8
#define LDLONG	ld
kusano 2b45e8
#else
kusano 2b45e8
#define LDLONG	lwz
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef OS_DARWIN
kusano 2b45e8
#define LL(x)	L##x
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef OS_LINUX
kusano 2b45e8
#define LL(x)	.L##x
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifndef LL
kusano 2b45e8
#define LL(x)	__L##x
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
kusano 2b45e8
#if   defined(__64BIT__) &&  defined(USE64BITINT)
kusano 2b45e8
#define LDINT	ld
kusano 2b45e8
#elif defined(__64BIT__) && !defined(USE64BITINT)
kusano 2b45e8
#define LDINT	lwa
kusano 2b45e8
#else
kusano 2b45e8
#define LDINT	lwz
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
/*
kusano 2b45e8
#define DCBT(REGA, REGB, NUM) .long (0x7c00022c | (REGA << 16) | (REGB << 11) | ((NUM) << 21))
kusano 2b45e8
#define DCBTST(REGA, REGB, NUM) .long (0x7c0001ec | (REGA << 16) | (REGB << 11) | ((NUM) << 21))
kusano 2b45e8
*/
kusano 2b45e8
kusano 2b45e8
#define DSTATTR_H(SIZE, COUNT, STRIDE) ((SIZE << 8) | (COUNT))
kusano 2b45e8
#define DSTATTR_L(SIZE, COUNT, STRIDE) (STRIDE)
kusano 2b45e8
kusano 2b45e8
#if defined(PPC970) || defined(POWER3) || defined(POWER4) || defined(POWER5) || defined(PPCG4)
kusano 2b45e8
#define HAVE_PREFETCH
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#if defined(POWER3) || defined(POWER6) || defined(PPCG4) || defined(CELL)
kusano 2b45e8
#define DCBT_ARG	0
kusano 2b45e8
#else
kusano 2b45e8
#define DCBT_ARG	8
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef CELL
kusano 2b45e8
#define L1_DUALFETCH
kusano 2b45e8
#define L1_PREFETCHSIZE (64 + 128 * 13)
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#if defined(POWER3) || defined(POWER4) || defined(POWER5)
kusano 2b45e8
#define L1_DUALFETCH
kusano 2b45e8
#define L1_PREFETCHSIZE (96 + 128 * 12)
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#if defined(POWER6)
kusano 2b45e8
#define L1_DUALFETCH
kusano 2b45e8
#define L1_PREFETCHSIZE (16 + 128 * 100)
kusano 2b45e8
#define L1_PREFETCH	dcbtst
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifndef L1_PREFETCH
kusano 2b45e8
#define L1_PREFETCH	dcbt
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifndef L1_PREFETCHW
kusano 2b45e8
#define L1_PREFETCHW	dcbtst
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#if DCBT_ARG == 0
kusano 2b45e8
#define DCBT(REGA, REGB)	L1_PREFETCH	REGB, REGA
kusano 2b45e8
#define DCBTST(REGA, REGB)	L1_PREFETCHW	REGB, REGA
kusano 2b45e8
#else
kusano 2b45e8
#define DCBT(REGA, REGB)	L1_PREFETCH	DCBT_ARG, REGB, REGA
kusano 2b45e8
#define DCBTST(REGA, REGB)	L1_PREFETCHW	DCBT_ARG, REGB, REGA
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
kusano 2b45e8
#ifndef L1_PREFETCHSIZE
kusano 2b45e8
#define L1_PREFETCHSIZE (96 + 128 * 12)
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#if !defined(OS_DARWIN) || defined(NEEDPARAM)
kusano 2b45e8
#define f0	0
kusano 2b45e8
#define f1	1
kusano 2b45e8
#define f2	2
kusano 2b45e8
#define f3	3
kusano 2b45e8
#define f4	4
kusano 2b45e8
#define f5	5
kusano 2b45e8
#define f6	6
kusano 2b45e8
#define f7	7
kusano 2b45e8
#define f8	8
kusano 2b45e8
#define f9	9
kusano 2b45e8
#define f10	10
kusano 2b45e8
#define f11	11
kusano 2b45e8
#define f12	12
kusano 2b45e8
#define f13	13
kusano 2b45e8
#define f14	14
kusano 2b45e8
#define f15	15
kusano 2b45e8
#define f16	16
kusano 2b45e8
#define f17	17
kusano 2b45e8
#define f18	18
kusano 2b45e8
#define f19	19
kusano 2b45e8
#define f20	20
kusano 2b45e8
#define f21	21
kusano 2b45e8
#define f22	22
kusano 2b45e8
#define f23	23
kusano 2b45e8
#define f24	24
kusano 2b45e8
#define f25	25
kusano 2b45e8
#define f26	26
kusano 2b45e8
#define f27	27
kusano 2b45e8
#define f28	28
kusano 2b45e8
#define f29	29
kusano 2b45e8
#define f30	30
kusano 2b45e8
#define f31	31
kusano 2b45e8
kusano 2b45e8
#define r0	0
kusano 2b45e8
#define r1	1
kusano 2b45e8
#define r2	2
kusano 2b45e8
#define r3	3
kusano 2b45e8
#define r4	4
kusano 2b45e8
#define r5	5
kusano 2b45e8
#define r6	6
kusano 2b45e8
#define r7	7
kusano 2b45e8
#define r8	8
kusano 2b45e8
#define r9	9
kusano 2b45e8
#define r10	10
kusano 2b45e8
#define r11	11
kusano 2b45e8
#define r12	12
kusano 2b45e8
#define r13	13
kusano 2b45e8
#define r14	14
kusano 2b45e8
#define r15	15
kusano 2b45e8
#define r16	16
kusano 2b45e8
#define r17	17
kusano 2b45e8
#define r18	18
kusano 2b45e8
#define r19	19
kusano 2b45e8
#define r20	20
kusano 2b45e8
#define r21	21
kusano 2b45e8
#define r22	22
kusano 2b45e8
#define r23	23
kusano 2b45e8
#define r24	24
kusano 2b45e8
#define r25	25
kusano 2b45e8
#define r26	26
kusano 2b45e8
#define r27	27
kusano 2b45e8
#define r28	28
kusano 2b45e8
#define r29	29
kusano 2b45e8
#define r30	30
kusano 2b45e8
#define r31	31
kusano 2b45e8
kusano 2b45e8
#define v0	0
kusano 2b45e8
#define v1	1
kusano 2b45e8
#define v2	2
kusano 2b45e8
#define v3	3
kusano 2b45e8
#define v4	4
kusano 2b45e8
#define v5	5
kusano 2b45e8
#define v6	6
kusano 2b45e8
#define v7	7
kusano 2b45e8
#define v8	8
kusano 2b45e8
#define v9	9
kusano 2b45e8
#define v10	10
kusano 2b45e8
#define v11	11
kusano 2b45e8
#define v12	12
kusano 2b45e8
#define v13	13
kusano 2b45e8
#define v14	14
kusano 2b45e8
#define v15	15
kusano 2b45e8
#define v16	16
kusano 2b45e8
#define v17	17
kusano 2b45e8
#define v18	18
kusano 2b45e8
#define v19	19
kusano 2b45e8
#define v20	20
kusano 2b45e8
#define v21	21
kusano 2b45e8
#define v22	22
kusano 2b45e8
#define v23	23
kusano 2b45e8
#define v24	24
kusano 2b45e8
#define v25	25
kusano 2b45e8
#define v26	26
kusano 2b45e8
#define v27	27
kusano 2b45e8
#define v28	28
kusano 2b45e8
#define v29	29
kusano 2b45e8
#define v30	30
kusano 2b45e8
#define v31	31
kusano 2b45e8
kusano 2b45e8
#define BO_dCTR_NZERO_AND_NOT	0
kusano 2b45e8
#define BO_dCTR_NZERO_AND_NOT_1	1
kusano 2b45e8
#define BO_dCTR_ZERO_AND_NOT	2
kusano 2b45e8
#define BO_dCTR_ZERO_AND_NOT_1	3
kusano 2b45e8
#define BO_IF_NOT	4
kusano 2b45e8
#define BO_IF_NOT_1	5
kusano 2b45e8
#define BO_IF_NOT_2	6
kusano 2b45e8
#define BO_IF_NOT_3	7
kusano 2b45e8
#define BO_dCTR_NZERO_AND	8
kusano 2b45e8
#define BO_dCTR_NZERO_AND_1	9
kusano 2b45e8
#define BO_dCTR_ZERO_AND	10
kusano 2b45e8
#define BO_dCTR_ZERO_AND_1	11
kusano 2b45e8
#define BO_IF	12
kusano 2b45e8
#define BO_IF_1	13
kusano 2b45e8
#define BO_IF_2	14
kusano 2b45e8
#define BO_IF_3	15
kusano 2b45e8
#define BO_dCTR_NZERO	16
kusano 2b45e8
#define BO_dCTR_NZERO_1	17
kusano 2b45e8
#define BO_dCTR_ZERO	18
kusano 2b45e8
#define BO_dCTR_ZERO_1	19
kusano 2b45e8
#define BO_ALWAYS	20
kusano 2b45e8
#define BO_ALWAYS_1	21
kusano 2b45e8
#define BO_ALWAYS_2	22
kusano 2b45e8
#define BO_ALWAYS_3	23
kusano 2b45e8
#define BO_dCTR_NZERO_8	24
kusano 2b45e8
#define BO_dCTR_NZERO_9	25
kusano 2b45e8
#define BO_dCTR_ZERO_8	26
kusano 2b45e8
#define BO_dCTR_ZERO_9	27
kusano 2b45e8
#define BO_ALWAYS_8	28
kusano 2b45e8
#define BO_ALWAYS_9	29
kusano 2b45e8
#define BO_ALWAYS_10	30
kusano 2b45e8
#define BO_ALWAYS_11	31
kusano 2b45e8
kusano 2b45e8
#define CR0_LT	0
kusano 2b45e8
#define CR0_GT	1
kusano 2b45e8
#define CR0_EQ	2
kusano 2b45e8
#define CR0_SO	3
kusano 2b45e8
#define CR1_FX	4
kusano 2b45e8
#define CR1_FEX	5
kusano 2b45e8
#define CR1_VX	6
kusano 2b45e8
#define CR1_OX	7
kusano 2b45e8
#define CR2_LT	8
kusano 2b45e8
#define CR2_GT	9
kusano 2b45e8
#define CR2_EQ	10
kusano 2b45e8
#define CR2_SO	11
kusano 2b45e8
#define CR3_LT	12
kusano 2b45e8
#define CR3_GT	13
kusano 2b45e8
#define CR3_EQ	14
kusano 2b45e8
#define CR3_SO	15
kusano 2b45e8
#define CR4_LT	16
kusano 2b45e8
#define CR4_GT	17
kusano 2b45e8
#define CR4_EQ	18
kusano 2b45e8
#define CR4_SO	19
kusano 2b45e8
#define CR5_LT	20
kusano 2b45e8
#define CR5_GT	21
kusano 2b45e8
#define CR5_EQ	22
kusano 2b45e8
#define CR5_SO	23
kusano 2b45e8
#define CR6_LT	24
kusano 2b45e8
#define CR6_GT	25
kusano 2b45e8
#define CR6_EQ	26
kusano 2b45e8
#define CR6_SO	27
kusano 2b45e8
#define CR7_LT	28
kusano 2b45e8
#define CR7_GT	29
kusano 2b45e8
#define CR7_EQ	30
kusano 2b45e8
#define CR7_SO	31
kusano 2b45e8
#define TO_LT	16
kusano 2b45e8
#define TO_GT	8
kusano 2b45e8
#define TO_EQ	4
kusano 2b45e8
#define TO_LLT	2
kusano 2b45e8
#define TO_LGT	1
kusano 2b45e8
#define CR0	 0
kusano 2b45e8
#define CR1	 1
kusano 2b45e8
#define CR2	 2
kusano 2b45e8
#define CR3	 3
kusano 2b45e8
#define CR4	 4
kusano 2b45e8
#define CR5	 5
kusano 2b45e8
#define CR6	 6
kusano 2b45e8
#define CR7	 7
kusano 2b45e8
#define cr0	 0
kusano 2b45e8
#define cr1	 1
kusano 2b45e8
#define cr2	 2
kusano 2b45e8
#define cr3	 3
kusano 2b45e8
#define cr4	 4
kusano 2b45e8
#define cr5	 5
kusano 2b45e8
#define cr6	 6
kusano 2b45e8
#define cr7	 7
kusano 2b45e8
#define VRsave	256
kusano 2b45e8
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#define CTR 9
kusano 2b45e8
#define SP r1
kusano 2b45e8
kusano 2b45e8
#ifdef __64BIT__
kusano 2b45e8
#define	slwi	sldi
kusano 2b45e8
#define cmpwi	cmpdi
kusano 2b45e8
#define srawi	sradi
kusano 2b45e8
#define mullw	mulld
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifndef F_INTERFACE
kusano 2b45e8
#define REALNAME ASMNAME
kusano 2b45e8
#else
kusano 2b45e8
#define REALNAME ASMFNAME
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#if defined(ASSEMBLER) && !defined(NEEDPARAM)
kusano 2b45e8
kusano 2b45e8
#ifdef OS_LINUX
kusano 2b45e8
#ifndef __64BIT__
kusano 2b45e8
#define PROLOGUE \
kusano 2b45e8
	.section .text;\
kusano 2b45e8
	.align 6;\
kusano 2b45e8
	.globl	REALNAME;\
kusano 2b45e8
	.type	REALNAME, @function;\
kusano 2b45e8
REALNAME:
kusano 2b45e8
#define EPILOGUE	.size	REALNAME, .-REALNAME
kusano 2b45e8
#else
kusano 2b45e8
#define PROLOGUE \
kusano 2b45e8
	.section .text;\
kusano 2b45e8
	.align 5;\
kusano 2b45e8
	.globl REALNAME;\
kusano 2b45e8
	.section	".opd","aw";\
kusano 2b45e8
	.align 3;\
kusano 2b45e8
REALNAME:;\
kusano 2b45e8
	.quad	.REALNAME, .TOC.@tocbase, 0;\
kusano 2b45e8
	.previous;\
kusano 2b45e8
	.size	REALNAME, 24;\
kusano 2b45e8
	.type	.REALNAME, @function;\
kusano 2b45e8
	.globl	.REALNAME;\
kusano 2b45e8
.REALNAME:
kusano 2b45e8
#define EPILOGUE \
kusano 2b45e8
	.long 0 ; \
kusano 2b45e8
	.byte 0,0,0,1,128,0,0,0 ; \
kusano 2b45e8
	.size	.REALNAME, .-.REALNAME; \
kusano 2b45e8
	.section	.note.GNU-stack,"",@progbits
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef PROFILE
kusano 2b45e8
#ifndef __64BIT__
kusano 2b45e8
#define PROFCODE ;\
kusano 2b45e8
	.section	".data";\
kusano 2b45e8
	.align 2;\
kusano 2b45e8
.LP3:;\
kusano 2b45e8
	.long	0;\
kusano 2b45e8
	.section	".text";\
kusano 2b45e8
	mflr	r0;\
kusano 2b45e8
	stw	r0,   4(SP);\
kusano 2b45e8
	lis	r12, .LP3@ha;\
kusano 2b45e8
	la	r0, .LP3@l(r12);\
kusano 2b45e8
	bl	_mcount;\
kusano 2b45e8
	lwz	r0,   4(SP);\
kusano 2b45e8
	mtlr	r0
kusano 2b45e8
#else
kusano 2b45e8
#define PROFCODE \
kusano 2b45e8
	.globl	 _mcount; \
kusano 2b45e8
	mflr	r0; \
kusano 2b45e8
	std	r0,    16(SP); \
kusano 2b45e8
	mr	r11, SP; \
kusano 2b45e8
	addi	SP, SP, -256; \
kusano 2b45e8
	std	r11,    0(SP); \
kusano 2b45e8
	std	r3,   128(SP); \
kusano 2b45e8
	std	r4,   136(SP); \
kusano 2b45e8
	std	r5,   144(SP); \
kusano 2b45e8
	std	r6,   152(SP); \
kusano 2b45e8
	std	r7,   160(SP); \
kusano 2b45e8
	std	r8,   168(SP); \
kusano 2b45e8
	std	r9,   176(SP); \
kusano 2b45e8
	std	r10,  184(SP); \
kusano 2b45e8
	stfd	f3,   192(SP); \
kusano 2b45e8
	stfd	f4,   200(SP); \
kusano 2b45e8
	bl	._mcount; \
kusano 2b45e8
	nop; \
kusano 2b45e8
	ld	r3,   128(SP);\
kusano 2b45e8
	ld	r4,   136(SP);\
kusano 2b45e8
	ld	r5,   144(SP);\
kusano 2b45e8
	ld	r6,   152(SP);\
kusano 2b45e8
	ld	r7,   160(SP);\
kusano 2b45e8
	ld	r8,   168(SP);\
kusano 2b45e8
	ld	r9,   176(SP);\
kusano 2b45e8
	ld	r10,  184(SP);\
kusano 2b45e8
	lfd	f3,   192(SP);\
kusano 2b45e8
	lfd	f4,   200(SP);\
kusano 2b45e8
	addi	SP, SP,  256;\
kusano 2b45e8
	ld	r0,    16(SP);\
kusano 2b45e8
	mtlr	r0
kusano 2b45e8
#endif
kusano 2b45e8
#else
kusano 2b45e8
#define PROFCODE
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#if OS_AIX
kusano 2b45e8
#ifndef __64BIT__
kusano 2b45e8
#define PROLOGUE \
kusano 2b45e8
	.machine "any";\
kusano 2b45e8
	.globl .REALNAME;\
kusano 2b45e8
	.csect .text[PR],5;\
kusano 2b45e8
.REALNAME:;
kusano 2b45e8
kusano 2b45e8
#define EPILOGUE \
kusano 2b45e8
_section_.text:;\
kusano 2b45e8
	.csect .data[RW],4;\
kusano 2b45e8
	.long _section_.text;
kusano 2b45e8
kusano 2b45e8
#else
kusano 2b45e8
kusano 2b45e8
#define PROLOGUE \
kusano 2b45e8
	.machine "any";\
kusano 2b45e8
	.globl .REALNAME;\
kusano 2b45e8
	.csect .text[PR], 5;\
kusano 2b45e8
.REALNAME:;
kusano 2b45e8
kusano 2b45e8
#define EPILOGUE \
kusano 2b45e8
_section_.text:;\
kusano 2b45e8
	.csect .data[RW],4;\
kusano 2b45e8
	.llong _section_.text;
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#define PROFCODE
kusano 2b45e8
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef OS_DARWIN
kusano 2b45e8
#ifndef __64BIT__
kusano 2b45e8
	.macro PROLOGUE
kusano 2b45e8
	.section __TEXT,__text,regular,pure_instructions
kusano 2b45e8
	.section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
kusano 2b45e8
	.machine ppc
kusano 2b45e8
	.text
kusano 2b45e8
	.align 4
kusano 2b45e8
	.globl REALNAME
kusano 2b45e8
REALNAME:
kusano 2b45e8
	.endmacro
kusano 2b45e8
#else
kusano 2b45e8
	.macro PROLOGUE
kusano 2b45e8
	.section __TEXT,__text,regular,pure_instructions
kusano 2b45e8
	.section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
kusano 2b45e8
	.machine ppc64
kusano 2b45e8
	.text
kusano 2b45e8
	.align 4
kusano 2b45e8
	.globl REALNAME
kusano 2b45e8
REALNAME:
kusano 2b45e8
	.endmacro
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifndef PROFILE
kusano 2b45e8
#define PROFCODE
kusano 2b45e8
#define EPILOGUE	.subsections_via_symbols
kusano 2b45e8
#else
kusano 2b45e8
#ifndef __64BIT__
kusano 2b45e8
kusano 2b45e8
	.macro PROFCODE
kusano 2b45e8
	mflr	r0
kusano 2b45e8
	stw	r0,     8(SP)
kusano 2b45e8
	addi	SP, SP, -64
kusano 2b45e8
	stw	SP,     0(SP)
kusano 2b45e8
	stw	r3,    12(SP)
kusano 2b45e8
	stw	r4,    16(SP)
kusano 2b45e8
	stw	r5,    20(SP)
kusano 2b45e8
	stw	r6,    24(SP)
kusano 2b45e8
	stw	r7,    28(SP)
kusano 2b45e8
	stw	r8,    32(SP)
kusano 2b45e8
	stw	r9,    36(SP)
kusano 2b45e8
	stw	r10,   40(SP)
kusano 2b45e8
	stfd	f1,    48(SP)
kusano 2b45e8
	stfd	f2,    56(SP)
kusano 2b45e8
	mr	r3, r0
kusano 2b45e8
	bl	Lmcount$stub
kusano 2b45e8
	nop
kusano 2b45e8
	lwz	r3,    12(SP)
kusano 2b45e8
	lwz	r4,    16(SP)
kusano 2b45e8
	lwz	r5,    20(SP)
kusano 2b45e8
	lwz	r6,    24(SP)
kusano 2b45e8
	lwz	r7,    28(SP)
kusano 2b45e8
	lwz	r8,    32(SP)
kusano 2b45e8
	lwz	r9,    36(SP)
kusano 2b45e8
	lwz	r10,   40(SP)
kusano 2b45e8
	lfd	f1,    48(SP)
kusano 2b45e8
	lfd	f2,    56(SP)
kusano 2b45e8
	addi	SP, SP,  64
kusano 2b45e8
	lwz	r0,     8(SP)
kusano 2b45e8
	mtlr	r0
kusano 2b45e8
	.endmacro
kusano 2b45e8
kusano 2b45e8
	.macro EPILOGUE
kusano 2b45e8
	.section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
kusano 2b45e8
	.align 5
kusano 2b45e8
Lmcount$stub:
kusano 2b45e8
	.indirect_symbol mcount
kusano 2b45e8
	mflr r0
kusano 2b45e8
	bcl 20,31,L00000000001$spb
kusano 2b45e8
L00000000001$spb:
kusano 2b45e8
	mflr r11
kusano 2b45e8
	addis r11,r11,ha16(Lmcount$lazy_ptr-L00000000001$spb)
kusano 2b45e8
	mtlr r0
kusano 2b45e8
	lwzu r12,lo16(Lmcount$lazy_ptr-L00000000001$spb)(r11)
kusano 2b45e8
	mtctr r12
kusano 2b45e8
	bctr
kusano 2b45e8
	.lazy_symbol_pointer
kusano 2b45e8
Lmcount$lazy_ptr:
kusano 2b45e8
	.indirect_symbol mcount
kusano 2b45e8
	.long	dyld_stub_binding_helper
kusano 2b45e8
	.subsections_via_symbols
kusano 2b45e8
	.endmacro
kusano 2b45e8
kusano 2b45e8
#else
kusano 2b45e8
	.macro PROFCODE
kusano 2b45e8
	mflr	r0
kusano 2b45e8
	std	r0,    16(SP)
kusano 2b45e8
	addi	SP, SP, -128
kusano 2b45e8
	std	SP,     0(SP)
kusano 2b45e8
	std	r3,    24(SP)
kusano 2b45e8
	std	r4,    32(SP)
kusano 2b45e8
	std	r5,    40(SP)
kusano 2b45e8
	std	r6,    48(SP)
kusano 2b45e8
	std	r7,    56(SP)
kusano 2b45e8
	std	r8,    64(SP)
kusano 2b45e8
	std	r9,    72(SP)
kusano 2b45e8
	std	r10,   80(SP)
kusano 2b45e8
	stfd	f1,    88(SP)
kusano 2b45e8
	stfd	f2,    96(SP)
kusano 2b45e8
	mr	r3, r0
kusano 2b45e8
	bl	Lmcount$stub
kusano 2b45e8
	nop
kusano 2b45e8
	ld	r3,    24(SP)
kusano 2b45e8
	ld	r4,    32(SP)
kusano 2b45e8
	ld	r5,    40(SP)
kusano 2b45e8
	ld	r6,    48(SP)
kusano 2b45e8
	ld	r7,    56(SP)
kusano 2b45e8
	ld	r8,    64(SP)
kusano 2b45e8
	ld	r9,    72(SP)
kusano 2b45e8
	ld	r10,   80(SP)
kusano 2b45e8
	lfd	f1,    88(SP)
kusano 2b45e8
	lfd	f2,    86(SP)
kusano 2b45e8
	addi	SP, SP,  128
kusano 2b45e8
	ld	r0,    16(SP)
kusano 2b45e8
	mtlr	r0
kusano 2b45e8
	.endmacro
kusano 2b45e8
kusano 2b45e8
	.macro EPILOGUE
kusano 2b45e8
	.data
kusano 2b45e8
	.section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
kusano 2b45e8
	.align 5
kusano 2b45e8
Lmcount$stub:
kusano 2b45e8
	.indirect_symbol mcount
kusano 2b45e8
	mflr r0
kusano 2b45e8
	bcl 20,31,L00000000001$spb
kusano 2b45e8
L00000000001$spb:
kusano 2b45e8
	mflr r11
kusano 2b45e8
	addis r11,r11,ha16(Lmcount$lazy_ptr-L00000000001$spb)
kusano 2b45e8
	mtlr r0
kusano 2b45e8
	ld r12,lo16(Lmcount$lazy_ptr-L00000000001$spb)(r11)
kusano 2b45e8
	mtctr r12
kusano 2b45e8
	bctr
kusano 2b45e8
	.lazy_symbol_pointer
kusano 2b45e8
Lmcount$lazy_ptr:
kusano 2b45e8
	.indirect_symbol mcount
kusano 2b45e8
	.quad	dyld_stub_binding_helper
kusano 2b45e8
	.subsections_via_symbols
kusano 2b45e8
	.endmacro
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#endif
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#define HALT		mfspr	r0, 1023
kusano 2b45e8
kusano 2b45e8
#ifdef OS_LINUX
kusano 2b45e8
#if defined(PPC440) || defined(PPC440FP2)
kusano 2b45e8
#undef  MAX_CPU_NUMBER
kusano 2b45e8
#define MAX_CPU_NUMBER 1
kusano 2b45e8
#endif
kusano 2b45e8
#if !defined(__64BIT__) && !defined(PROFILE) && !defined(PPC440) && !defined(PPC440FP2)
kusano 2b45e8
#define START_ADDRESS (0x0b000000UL)
kusano 2b45e8
#else
kusano 2b45e8
#define SEEK_ADDRESS
kusano 2b45e8
#endif
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef OS_AIX
kusano 2b45e8
#ifndef __64BIT__
kusano 2b45e8
#define START_ADDRESS (0xf0000000UL)
kusano 2b45e8
#else
kusano 2b45e8
#define SEEK_ADDRESS
kusano 2b45e8
#endif
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef OS_DARWIN
kusano 2b45e8
#define SEEK_ADDRESS
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#if defined(PPC440)
kusano 2b45e8
#define BUFFER_SIZE     (  2 << 20)
kusano 2b45e8
#elif defined(PPC440FP2)
kusano 2b45e8
#define BUFFER_SIZE     ( 16 << 20)
kusano 2b45e8
#else
kusano 2b45e8
#define BUFFER_SIZE     ( 16 << 20)
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifndef PAGESIZE
kusano 2b45e8
#define PAGESIZE	( 4 << 10)
kusano 2b45e8
#endif
kusano 2b45e8
#define HUGE_PAGESIZE	(16 << 20)
kusano 2b45e8
kusano 2b45e8
#define BASE_ADDRESS (START_ADDRESS - BUFFER_SIZE * MAX_CPU_NUMBER)
kusano 2b45e8
kusano 2b45e8
#ifndef MAP_ANONYMOUS
kusano 2b45e8
#define MAP_ANONYMOUS MAP_ANON
kusano 2b45e8
#endif
kusano 2b45e8
#endif