bb787794b036fb4da85d5164dd6930cb68b512fa
1 /* This file is part of the program psim.
3 Copyright (C) 1994-1996, Andrew Cagney <cagney@highland.com.au>
4 Copyright (C) 1997, Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #error "N must be #defined"
29 /* NOTE: See end of file for #undef */
30 #define unsignedN XCONCAT2(unsigned,N)
31 #define signedN XCONCAT2(signed,N)
32 #define MASKEDn XCONCAT2(MASKED,N)
33 #define MASKn XCONCAT2(MASK,N)
34 #define LSMASKEDn XCONCAT2(LSMASKED,N)
35 #define LSMASKn XCONCAT2(LSMASK,N)
36 #define MSMASKEDn XCONCAT2(MSMASKED,N)
37 #define MSMASKn XCONCAT2(MSMASK,N)
38 #define EXTRACTEDn XCONCAT2(EXTRACTED,N)
39 #define INSERTEDn XCONCAT2(INSERTED,N)
40 #define ROTn XCONCAT2(ROT,N)
41 #define ROTLn XCONCAT2(ROTL,N)
42 #define ROTRn XCONCAT2(ROTR,N)
43 #define SEXTn XCONCAT2(SEXT,N)
48 MASKEDn (unsignedN word
,
52 return (word
& MASKn (start
, stop
));
58 LSMASKEDn (unsignedN word
,
61 return (word
& LSMASKn (nr_bits
));
67 MSMASKEDn (unsignedN word
,
70 return (word
& MSMASKn (nr_bits
));
76 EXTRACTEDn (unsignedN val
,
80 val
<<= _MSB_SHIFT (N
, start
);
81 val
>>= (_MSB_SHIFT (N
, start
) + _LSB_SHIFT (N
, stop
));
88 INSERTEDn (unsignedN val
,
92 val
&= LSMASKn (_MAKE_WIDTH (start
, stop
));
93 val
<<= _LSB_SHIFT (N
, stop
);
104 return ROTRn (val
, shift
);
106 return ROTLn (val
, -shift
);
114 ROTLn (unsignedN val
,
119 result
= (((val
) << (shift
)) | ((val
) >> ((N
)-(shift
))));
126 ROTRn (unsignedN val
,
131 result
= (((val
) >> (shift
)) | ((val
) << ((N
)-(shift
))));
141 /* make the sign-bit most significant and then smear it back into
143 ASSERT (sign_bit
< N
);
144 val
<<= _MSB_SHIFT (N
, sign_bit
);
145 val
>>= _MSB_SHIFT (N
, sign_bit
);
150 /* NOTE: See start of file for #define */
This page took 0.032007 seconds and 4 git commands to generate.