fpu_reg.h revision 298830
159243Sobrien/*- 259243Sobrien * Copyright (c) 2002 by Thomas Moestl <tmm@FreeBSD.org>. 359243Sobrien * All rights reserved. 459243Sobrien * 559243Sobrien * Redistribution and use in source and binary forms, with or without 659243Sobrien * modification, are permitted provided that the following conditions 759243Sobrien * are met: 859243Sobrien * 1. Redistributions of source code must retain the above copyright 959243Sobrien * notice, this list of conditions and the following disclaimer. 1059243Sobrien * 2. Redistributions in binary form must reproduce the above copyright 1159243Sobrien * notice, this list of conditions and the following disclaimer in the 1259243Sobrien * documentation and/or other materials provided with the distribution. 1359243Sobrien * 1459243Sobrien * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1559243Sobrien * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1659243Sobrien * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1759243Sobrien * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 1859243Sobrien * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 1959243Sobrien * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 2059243Sobrien * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 2159243Sobrien * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 2259243Sobrien * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 2359243Sobrien * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2459243Sobrien * 2559243Sobrien * $FreeBSD: head/lib/libc/sparc64/fpu/fpu_reg.h 298830 2016-04-30 01:24:24Z pfg $ 2659243Sobrien */ 2759243Sobrien 2859243Sobrien#ifndef _LIBC_SPARC64_FPU_FPU_REG_H_ 2959243Sobrien#define _LIBC_SPARC64_FPU_FPU_REG_H_ 3059243Sobrien 3159243Sobrien/* 3259243Sobrien * These are not really of type char[]. They are are arrays of functions defined 3359243Sobrien * in fpu_reg.S; each array member loads/stores a certain fpu register of the 3459243Sobrien * given size. 35 */ 36extern char __fpu_ld32[]; 37extern char __fpu_st32[]; 38extern char __fpu_ld64[]; 39extern char __fpu_st64[]; 40 41/* Size of the functions in the arrays. */ 42#define FPU_LD32_SZ 8 43#define FPU_ST32_SZ 8 44#define FPU_LD64_SZ 8 45#define FPU_ST64_SZ 8 46 47/* Typedefs for convenient casts in the functions below. */ 48typedef void (fp_ldst32_fn)(u_int32_t *); 49typedef void (fp_ldst64_fn)(u_int64_t *); 50 51/* 52 * These are the functions that are actually used in the fpu emulation code to 53 * access the fp registers. They are usually not used more than once, so 54 * caching needs not be done here. 55 */ 56static __inline u_int32_t 57__fpu_getreg(int r) 58{ 59 u_int32_t rv; 60 61 ((fp_ldst32_fn *)&__fpu_st32[r * FPU_ST32_SZ])(&rv); 62 return (rv); 63} 64 65static __inline u_int64_t 66__fpu_getreg64(int r) 67{ 68 u_int64_t rv; 69 70 ((fp_ldst64_fn *)&__fpu_st64[(r >> 1) * FPU_ST64_SZ])(&rv); 71 return (rv); 72} 73 74static __inline void 75__fpu_setreg(int r, u_int32_t v) 76{ 77 78 ((fp_ldst32_fn *)&__fpu_ld32[r * FPU_LD32_SZ])(&v); 79} 80 81static __inline void 82__fpu_setreg64(int r, u_int64_t v) 83{ 84 85 ((fp_ldst64_fn *)&__fpu_ld64[(r >> 1) * FPU_LD64_SZ])(&v); 86} 87 88#endif /* _LIBC_SPARC64_FPU_FPU_REG_H_ */ 89