source: tests/bitmanip2.cfa @ 6a490b2

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 6a490b2 was da36d25, checked in by Peter A. Buhr <pabuhr@…>, 5 years ago

first complete draft of bitmanip, performance problems with polymorphic functions

  • Property mode set to 100644
File size: 10.0 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2020 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// bitmanip2.cfa --
8//
9// Author           : Peter A. Buhr
10// Created On       : Tue Apr  7 21:21:20 2020
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Tue Apr  7 21:21:40 2020
13// Update Count     : 1
14//
15
16#include <fstream.hfa>
17#include <bitmanip.hfa>
18
19int main() {
20        signed char sc;
21        unsigned char usc;
22        short int si;
23        unsigned short int usi;
24        int i;
25        unsigned int ui;
26        long int li;
27        unsigned long int uli;
28        long long int lli;
29        unsigned long long int ulli;
30
31        //============================================================
32#if 1
33        sout | nl | "low0" | nl | nl;
34
35        sout | "signed char";
36        sc = -1;
37        sout | wd(__bitsizeof(sc)+2, pad0(bin(sc))) | low0( sc );
38        for ( sc <<= 1; sc != -1hh; sc = (sc << 1) | 1 ) {
39                sout | wd(__bitsizeof(sc)+2, pad0(bin(sc))) | low0( sc );
40        } // for
41        sout | nl;
42        sout | "unsigned char";
43        usc = -1;
44        sout | wd(__bitsizeof(usc)+2, pad0(bin(usc))) | low0( usc );
45        for ( usc <<= 1; usc != -1hh; usc = (usc << 1) | 1 ) {
46                sout | wd(__bitsizeof(usc)+2, pad0(bin(usc))) | low0( usc );
47        } // for
48        sout | nl;
49
50        sout | "short int";
51        si = -1;
52        sout | wd(__bitsizeof(si)+2, pad0(bin(si))) | low0( si );
53        for ( si <<= 1; si != -1h; si = (si << 1) | 1 ) {
54                sout | wd(__bitsizeof(si)+2, pad0(bin(si))) | low0( si );
55        } // for
56        sout | nl;
57        sout | "unsigned short int";
58        usi = -1;
59        sout | wd(__bitsizeof(usi)+2, pad0(bin(usi))) | low0( usi );
60        for ( usi <<= 1; usi != -1h; usi = (usi << 1) | 1 ) {
61                sout | wd(__bitsizeof(usi)+2, pad0(bin(usi))) | low0( usi );
62        } // for
63        sout | nl;
64
65        sout | "int";
66        i = -1;
67        sout | wd(__bitsizeof(i)+2, pad0(bin(i))) | low0( i );
68        for ( i <<= 1; i != -1; i = (i << 1) | 1 ) {
69                sout | wd(__bitsizeof(i)+2, pad0(bin(i))) | low0( i );
70        } // for
71        sout | nl;
72        sout | "unsigned int";
73        ui = -1;
74        sout | wd(__bitsizeof(ui)+2, pad0(bin(ui))) | low0( ui );
75        for ( ui <<= 1; ui != -1; ui = (ui << 1) | 1 ) {
76                sout | wd(__bitsizeof(ui)+2, pad0(bin(ui))) | low0( ui );
77        } // for
78        sout | nl;
79
80        sout | "long int";
81        li = -1;
82        sout | wd(__bitsizeof(li)+2, pad0(bin(li))) | low0( li );
83        for ( li <<= 1; li != -1; li = (li << 1) | 1 ) {
84                sout | wd(__bitsizeof(li)+2, pad0(bin(li))) | low0( li );
85        } // for
86        sout | nl;
87        sout | "unsigned long int";
88        uli = -1;
89        sout | wd(__bitsizeof(uli)+2, pad0(bin(uli))) | low0( uli );
90        for ( uli <<= 1; uli != -1; uli = (uli << 1) | 1 ) {
91                sout | wd(__bitsizeof(uli)+2, pad0(bin(uli))) | low0( uli );
92        } // for
93        sout | nl;
94
95        sout | "long long int";
96        lli = -1;
97        sout | wd(__bitsizeof(lli)+2, pad0(bin(lli))) | low0( lli );
98        for ( lli <<= 1; lli != -1; lli = (lli << 1) | 1 ) {
99                sout | wd(__bitsizeof(lli)+2, pad0(bin(lli))) | low0( lli );
100        } // for
101        sout | nl;
102        sout | "unsigned long long int";
103        ulli = -1;
104        sout | wd(__bitsizeof(ulli)+2, pad0(bin(ulli))) | low0( ulli );
105        for ( ulli <<= 1; ulli != -1; ulli = (ulli << 1) | 1 ) {
106                sout | wd(__bitsizeof(ulli)+2, pad0(bin(ulli))) | low0( ulli );
107        } // for
108        sout | nl;
109#endif // 0
110        //============================================================
111#if 1
112        sout | nl | "low1" | nl | nl;
113
114        sout | "signed char";
115        sc = 0;
116        sout | wd(__bitsizeof(sc)+2, pad0(bin(sc))) | low1( sc );
117        for ( sc = 1; sc != 0; sc <<= 1 ) {
118                sout | wd(__bitsizeof(sc)+2, pad0(bin(sc))) | low1( sc );
119        } // for
120        sout | nl;
121        sout | "unsigned char";
122        usc = 0;
123        sout | wd(__bitsizeof(usc)+2, pad0(bin(usc))) | low1( usc );
124        for ( usc = 1; usc != 0; usc <<= 1 ) {
125                sout | wd(__bitsizeof(usc)+2, pad0(bin(usc))) | low1( usc );
126        } // for
127        sout | nl;
128
129        sout | "short int";
130        si = 0;
131        sout | wd(__bitsizeof(si)+2, pad0(bin(si))) | low1( si );
132        for ( si = 1; si != 0; si <<= 1 ) {
133                sout | wd(__bitsizeof(si)+2, pad0(bin(si))) | low1( si );
134        } // for
135        sout | nl;
136        sout | "unsigned short int";
137        usi = 0;
138        sout | wd(__bitsizeof(usi)+2, pad0(bin(usi))) | low1( usi );
139        for ( usi = 1; usi != 0; usi <<= 1 ) {
140                sout | wd(__bitsizeof(usi)+2, pad0(bin(usi))) | low1( usi );
141        } // for
142        sout | nl;
143
144        sout | "int";
145        i = 0;
146        sout | wd(__bitsizeof(i)+2, pad0(bin(i))) | low1( i );
147        for ( i = 1; i != 0; i <<= 1 ) {
148                sout | wd(__bitsizeof(i)+2, pad0(bin(i))) | low1( i );
149        } // for
150        sout | nl;
151        sout | "unsigned int";
152        ui = 0;
153        sout | wd(__bitsizeof(ui)+2, pad0(bin(ui))) | low1( ui );
154        for ( ui = 1; ui != 0; ui <<= 1 ) {
155                sout | wd(__bitsizeof(ui)+2, pad0(bin(ui))) | low1( ui );
156        } // for
157        sout | nl;
158
159        sout | "long int";
160        li = 0;
161        sout | wd(__bitsizeof(li)+2, pad0(bin(i))) | low1( li );
162        for ( li = 1; li != 0; li <<= 1 ) {
163                sout | wd(__bitsizeof(li)+2, pad0(bin(li))) | low1( li );
164        } // for
165        sout | nl;
166        sout | "unsigned long int";
167        uli = 0;
168        sout | wd(__bitsizeof(uli)+2, pad0(bin(uli))) | low1( uli );
169        for ( uli = 1; uli != 0; uli <<= 1 ) {
170                sout | wd(__bitsizeof(uli)+2, pad0(bin(i))) | low1( uli );
171        } // for
172        sout | nl;
173
174        sout | "long long int";
175        lli = 0;
176        sout | wd(__bitsizeof(lli)+2, pad0(bin(i))) | low1( lli );
177        for ( lli = 1; lli != 0; lli <<= 1 ) {
178                sout | wd(__bitsizeof(lli)+2, pad0(bin(lli))) | low1( lli );
179        } // for
180        sout | nl;
181        sout | "unsigned long long int";
182        ulli = 0;
183        sout | wd(__bitsizeof(ulli)+2, pad0(bin(ulli))) | low1( ulli );
184        for ( ulli = 1; ulli != 0; ulli <<= 1 ) {
185                sout | wd(__bitsizeof(ulli)+2, pad0(bin(ulli))) | low1( ulli );
186        } // for
187        sout | nl;
188#endif // 0
189        //============================================================
190#if 1
191        sout | nl | "high0" | nl | nl;
192
193        sout | "signed char";
194        sc = -1;
195        sout | wd(__bitsizeof(sc)+2, pad0(bin(sc))) | high0( sc );
196        for ( sc <<= 1; sc != -1hh; sc = (sc << 1) | 1 ) {
197                sout | wd(__bitsizeof(sc)+2, pad0(bin(sc))) | high0( sc );
198        } // for
199        sout | nl;
200        sout | "unsigned char";
201        usc = -1;
202        sout | wd(__bitsizeof(usc)+2, pad0(bin(usc))) | high0( usc );
203        for ( usc <<= 1; usc != -1hh; usc = (usc << 1) | 1 ) {
204                sout | wd(__bitsizeof(usc)+2, pad0(bin(usc))) | high0( usc );
205        } // for
206        sout | nl;
207
208        sout | "short int";
209        si = -1;
210        sout | wd(__bitsizeof(si)+2, pad0(bin(si))) | high0( si );
211        for ( si <<= 1; si != -1h; si = (si << 1) | 1 ) {
212                sout | wd(__bitsizeof(si)+2, pad0(bin(si))) | high0( si );
213        } // for
214        sout | nl;
215        sout | "unsigned short int";
216        usi = -1;
217        sout | wd(__bitsizeof(usi)+2, pad0(bin(usi))) | high0( usi );
218        for ( usi <<= 1; usi != -1h; usi = (usi << 1) | 1 ) {
219                sout | wd(__bitsizeof(usi)+2, pad0(bin(usi))) | high0( usi );
220        } // for
221        sout | nl;
222
223        sout | "int";
224        i = -1;
225        sout | wd(__bitsizeof(i)+2, pad0(bin(i))) | high0( i );
226        for ( i <<= 1; i != -1; i = (i << 1) | 1 ) {
227                sout | wd(__bitsizeof(i)+2, pad0(bin(i))) | high0( i );
228        } // for
229        sout | nl;
230        sout | "unsigned int";
231        ui = -1;
232        sout | wd(__bitsizeof(ui)+2, pad0(bin(ui))) | high0( ui );
233        for ( i <<= 1; i != -1; i = (i << 1) | 1 ) {
234                sout | wd(__bitsizeof(ui)+2, pad0(bin(i))) | high0( ui );
235        } // for
236        sout | nl;
237
238        sout | "long int";
239        li = -1;
240        sout | wd(__bitsizeof(li)+2, pad0(bin(li))) | high0( li );
241        for ( li <<= 1; li != -1; li = (li << 1) | 1 ) {
242                sout | wd(__bitsizeof(li)+2, pad0(bin(li))) | high0( li );
243        } // for
244        sout | nl;
245        sout | "unsigned long int";
246        uli = -1;
247        sout | wd(__bitsizeof(uli)+2, pad0(bin(uli))) | high0( uli );
248        for ( uli <<= 1; uli != -1; uli = (uli << 1) | 1 ) {
249                sout | wd(__bitsizeof(uli)+2, pad0(bin(uli))) | high0( uli );
250        } // for
251        sout | nl;
252
253        sout | "long long int";
254        lli = -1;
255        sout | wd(__bitsizeof(lli)+2, pad0(bin(lli))) | high0( lli );
256        for ( lli <<= 1; lli != -1; lli = (lli << 1) | 1 ) {
257                sout | wd(__bitsizeof(lli)+2, pad0(bin(lli))) | high0( lli );
258        } // for
259        sout | nl;
260        sout | "unsigned long long int";
261        ulli = -1;
262        sout | wd(__bitsizeof(ulli)+2, pad0(bin(ulli))) | high0( ulli );
263        for ( ulli <<= 1; ulli != -1; ulli = (ulli << 1) | 1 ) {
264                sout | wd(__bitsizeof(ulli)+2, pad0(bin(ulli))) | high0( ulli );
265        } // for
266        sout | nl;
267#endif // 0
268        //============================================================
269#if 1
270        sout | nl | "high1" | nl | nl;
271
272        sout | "signed char";
273        sc = 0;
274        sout | wd(__bitsizeof(sc)+2, pad0(bin(sc))) | high1( sc );
275        for ( sc = 1; sc != 0; sc <<= 1 ) {
276                sout | wd(__bitsizeof(sc)+2, pad0(bin(sc))) | high1( sc );
277        } // for
278        sout | nl;
279        sout | "unsigned char";
280        usc = 0;
281        sout | wd(__bitsizeof(usc)+2, pad0(bin(usc))) | high1( usc );
282        for ( usc = 1; usc != 0; usc <<= 1 ) {
283                sout | wd(__bitsizeof(usc)+2, pad0(bin(usc))) | high1( usc );
284        } // for
285        sout | nl;
286
287        sout | "short int";
288        si = 0;
289        sout | wd(__bitsizeof(si)+2, pad0(bin(si))) | high1( si );
290        for ( si = 1; si != 0; si <<= 1 ) {
291                sout | wd(__bitsizeof(si)+2, pad0(bin(si))) | high1( si );
292        } // for
293        sout | nl;
294        sout | "unsigned short int";
295        usi = 0;
296        sout | wd(__bitsizeof(usi)+2, pad0(bin(usi))) | high1( usi );
297        for ( usi = 1; usi != 0; usi <<= 1 ) {
298                sout | wd(__bitsizeof(usi)+2, pad0(bin(usi))) | high1( usi );
299        } // for
300        sout | nl;
301
302        sout | "int";
303        i = 0;
304        sout | wd(__bitsizeof(i)+2, pad0(bin(i))) | high1( i );
305        for ( i = 1; i != 0; i <<= 1 ) {
306                sout | wd(__bitsizeof(i)+2, pad0(bin(i))) | high1( i );
307        } // for
308        sout | nl;
309        sout | "unsigned int";
310        ui = 0;
311        sout | wd(__bitsizeof(ui)+2, pad0(bin(ui))) | high1( ui );
312        for ( ui = 1; ui != 0; ui <<= 1 ) {
313                sout | wd(__bitsizeof(ui)+2, pad0(bin(ui))) | high1( ui );
314        } // for
315        sout | nl;
316
317        sout | "long int";
318        li = 0;
319        sout | wd(__bitsizeof(li)+2, pad0(bin(li))) | high1( li );
320        for ( li = 1; li != 0; li <<= 1 ) {
321                sout | wd(__bitsizeof(li)+2, pad0(bin(li))) | high1( li );
322        } // for
323        sout | nl;
324        sout | "unsigned long int";
325        uli = 0;
326        sout | wd(__bitsizeof(uli)+2, pad0(bin(uli))) | high1( uli );
327        for ( uli = 1; uli != 0; uli <<= 1 ) {
328                sout | wd(__bitsizeof(uli)+2, pad0(bin(uli))) | high1( uli );
329        } // for
330        sout | nl;
331
332        sout | "long long int";
333        lli = 0;
334        sout | wd(__bitsizeof(lli)+2, pad0(bin(lli))) | high1( lli );
335        for ( lli = 1; lli != 0; lli <<= 1 ) {
336                sout | wd(__bitsizeof(lli)+2, pad0(bin(lli))) | high1( lli );
337        } // for
338        sout | nl;
339        sout | "unsigned long long int";
340        ulli = 0;
341        sout | wd(__bitsizeof(ulli)+2, pad0(bin(ulli))) | high1( ulli );
342        for ( ulli = 1; ulli != 0; ulli <<= 1 ) {
343                sout | wd(__bitsizeof(ulli)+2, pad0(bin(ulli))) | high1( ulli );
344        } // for
345        sout | nl;
346#endif // 0
347} // main
348
349// Local Variables: //
350// tab-width: 4 //
351// compile-command: "cfa bitmanip2.cfa" //
352// End: //
Note: See TracBrowser for help on using the repository browser.