1 /** shifts of bit-precise integers.
3 width: 7, 8, 9, 16, 24, 32, 33, 40, 48, 63, 64
4 count: 1, 4, 5, 7, 8, 9, 16, 20, 33, 40, 47, 48
5 varstorage: auto, static
6 countstorage: auto, static
12 // clang 11 supports bit-precise types, but deviates a bit from C23.
13 #if __clang_major__ == 11
14 #define __SDCC_BITINT_MAXWIDTH 128
15 #define _BitInt _ExtInt
18 #if __SDCC_BITINT_MAXWIDTH >= {width} // TODO: When we can regression-test in --std-c23 mode, use the standard macro from limits.h instead!
19 typedef unsigned _BitInt({width
}) bitinttype
;
20 typedef unsigned _BitInt(8) counttype
;
23 typedef unsigned int bitinttype
;
25 typedef unsigned long bitinttype
;
27 typedef unsigned char counttype
;
30 #define OPERAND0 ((bitinttype)0xa5b6c7d8e9fa)
31 #define OPERAND1 ((bitinttype)0x08192a3b4c5d6e7f)
33 // Lack of memory on pdk and mcs51
34 #if defined (__SDCC_pdk14) || defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)
36 #elif defined (__SDCC_pdk15)
38 #elif defined (__SDCC_mcs51) && defined(__SDCC_MODEL_SMALL)
44 bitinttype
setoperand0(void)
46 volatile bitinttype tmp
= OPERAND0
;
50 bitinttype
setoperand1(void)
52 volatile bitinttype tmp
= OPERAND1
;
56 counttype
setcount(void)
58 volatile counttype tmp
= {count
};
62 void testleftshift(void)
64 #if {width} <= MAXWIDTH && {count} < {width} && {direction} == 0
65 {varstorage
} bitinttype operand
, result
;
66 {countstorage
} counttype count
;
70 operand
= setoperand0();
71 result
= operand
<< count
;
72 ASSERT (result
== (OPERAND0
<< {count
}));
74 operand
= setoperand1();
75 result
= operand
<< count
;
76 ASSERT (result
== (OPERAND1
<< {count
}));
80 void testrightshift(void)
82 #if {width} <= MAXWIDTH && {count} < {width} && {direction} == 1
83 {varstorage
} bitinttype operand
, result
;
84 {countstorage
} counttype count
;
88 operand
= setoperand0();
89 result
= operand
>> count
;
90 ASSERT (result
== (OPERAND0
>> {count
}));
92 operand
= setoperand1();
93 result
= operand
>> count
;
94 ASSERT (result
== (OPERAND1
>> {count
}));