xref: /openbmc/linux/arch/parisc/math-emu/fpbits.h (revision c4f7ac64)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Linux/PA-RISC Project (http://www.parisc-linux.org/)
4  *
5  * Floating-point emulation code
6  *  Copyright (C) 2001 Hewlett-Packard (Paul Bame) <bame@debian.org>
7  */
8 
9 #ifdef __NO_PA_HDRS
10     PA header file -- do not include this header file for non-PA builds.
11 #endif
12 
13 
14 /*
15  *  These macros are designed to be portable to all machines that have
16  *  a wordsize greater than or equal to 32 bits that support the portable
17  *  C compiler and the standard C preprocessor.  Wordsize (default 32)
18  *  and bitfield assignment (default left-to-right,  unlike VAX, PDP-11)
19  *  should be predefined using the constants HOSTWDSZ and BITFRL and
20  *  the C compiler "-D" flag (e.g., -DHOSTWDSZ=36 -DBITFLR for the DEC-20).
21  *  Note that the macro arguments assume that the integer being referenced
22  *  is a 32-bit integer (right-justified on the 20) and that bit 0 is the
23  *  most significant bit.
24  */
25 
26 #ifndef HOSTWDSZ
27 #define	HOSTWDSZ	32
28 #endif
29 
30 
31 /*###########################  Macros  ######################################*/
32 
33 /*-------------------------------------------------------------------------
34  * NewDeclareBitField_Reference - Declare a structure similar to the simulator
35  * function "DeclBitfR" except its use is restricted to occur within a larger
36  * enclosing structure or union definition.  This declaration is an unnamed
37  * structure with the argument, name, as the member name and the argument,
38  * uname, as the element name.
39  *----------------------------------------------------------------------- */
40 #define Bitfield_extract(start, length, object) 	\
41     ((object) >> (HOSTWDSZ - (start) - (length)) & 	\
42     ((unsigned)-1 >> (HOSTWDSZ - (length))))
43 
44 #define Bitfield_signed_extract(start, length, object) \
45     ((int)((object) << start) >> (HOSTWDSZ - (length)))
46 
47 #define Bitfield_mask(start, len, object)		\
48     ((object) & (((unsigned)-1 >> (HOSTWDSZ-len)) << (HOSTWDSZ-start-len)))
49 
50 #define Bitfield_deposit(value,start,len,object)  object = \
51     ((object) & ~(((unsigned)-1 >> (HOSTWDSZ-len)) << (HOSTWDSZ-start-len))) | \
52     (((value) & ((unsigned)-1 >> (HOSTWDSZ-len))) << (HOSTWDSZ-start-len))
53