comparison test/bitfield.c @ 338:7fe7ce0a791f bit-field-done

bit-field done for IA32, PowerPC, MIPS. bit-field assop. No bit-field global init.
author kono
date Fri, 25 Jun 2004 14:30:43 +0900
parents d488b72254fb
children 5ac17fa9d7e0
comparison
equal deleted inserted replaced
337:694cdf15c5bd 338:7fe7ce0a791f
15 unsigned long i:1; 15 unsigned long i:1;
16 unsigned long m:1; 16 unsigned long m:1;
17 unsigned long g:1; 17 unsigned long g:1;
18 unsigned long :1; 18 unsigned long :1;
19 unsigned long pp:2; 19 unsigned long pp:2;
20 long long lpn:40;
20 } pte; 21 } pte;
21 struct { 22 struct {
22 unsigned char v:1; 23 unsigned char v:1;
23 signed long vsid:24; 24 signed long vsid:24;
24 unsigned long h:1; 25 unsigned long h:1;
186 g = a; 187 g = a;
187 188
188 printf("%d %d %d\n",a.pte.pp,g.pte.pp,p->pte.pp); 189 printf("%d %d %d\n",a.pte.pp,g.pte.pp,p->pte.pp);
189 main2(); 190 main2();
190 main5(); 191 main5();
192 main3();
193 main4();
191 return 0; 194 return 0;
192 } 195 }
193 196
194 main2() 197 main2()
195 { 198 {
324 // int :12 bit-field cannot be a return value; 327 // int :12 bit-field cannot be a return value;
325 // main3( int a:8 ) bit-field cannot be an argument; 328 // main3( int a:8 ) bit-field cannot be an argument;
326 main3( int a ) 329 main3( int a )
327 { 330 {
328 // int b:9; // nor local variable 331 // int b:9; // nor local variable
329 int b; 332 int b,i;
330 333 i = 7;
331 334
332 g.pte.rpn--; 335
333 g.pte.rpn++; 336 b = g.pte.rpn = -333;
334 --g.pte.rpn; 337 printf("main3-0: %d\n",b);
335 ++g.pte.rpn; 338 b = g.pte.rpn--;
336 g.pte.rpn += 3; 339 printf("main3-1: %d\n",b);
337 g.pte.rpn -= 3; 340 b = g.pte.rpn++;
338 g.pte.rpn *= 3; 341 printf("main3-2: %d\n",b);
339 g.pte.rpn /= 3; 342 b = --g.pte.rpn;
340 g.pte.rpn %= 3; 343 printf("main3-3: %d\n",b);
341 g.pte.rpn |= 3; 344 b = ++g.pte.rpn;
342 g.pte.rpn &= 3; 345 printf("main3-4: %d\n",b);
343 g.pte.rpn ^= 3; 346 b = (g.pte.rpn += 3);
347 printf("main3-5: %d\n",b);
348 b = (g.pte.rpn -= 3);
349 printf("main3-6: %d\n",b);
350 b = (g.pte.rpn *= 3);
351 printf("main3-7: %d\n",b);
352 b = (g.pte.rpn /= 3);
353 printf("main3-8: %d\n",b);
354 b = (g.pte.rpn %= 3);
355 printf("main3-9: %d\n",b);
356 b = (g.pte.rpn |= 3);
357 printf("main3-10: %d\n",b);
358 b = (g.pte.rpn &= 3);
359 printf("main3-12: %d\n",b);
360 b = (g.pte.rpn ^= 3);
361 printf("main3-13: %d\n",b);
362 b = (g.pte.rpn <<= 3);
363 printf("main3-14: %d\n",b);
364 b = (g.pte.rpn >>= 3);
365 printf("main3-15: %d\n",b);
366
367 g.pte.rpn = -333;
368 printf("main3-16: %d\n",b);
369 b = g.pte.rpn--;
370 printf("main3-17: %d\n",b);
371 b = g.pte.rpn++;
372 printf("main3-18: %d\n",b);
373 b = --g.pte.rpn;
374 printf("main3-19: %d\n",b);
375 b = ++g.pte.rpn;
376 printf("main3-20: %d\n",b);
377 b = (g.pte.rpn += i);
378 printf("main3-21: %d\n",b);
379 b = (g.pte.rpn -= i);
380 printf("main3-22: %d\n",b);
381 b = (g.pte.rpn *= i);
382 printf("main3-23: %d\n",b);
383 b = (g.pte.rpn /= i);
384 printf("main3-24: %d\n",b);
385 b = (g.pte.rpn %= i);
386 printf("main3-25: %d\n",b);
387 b = (g.pte.rpn |= i);
388 printf("main3-26: %d\n",b);
389 b = (g.pte.rpn &= i);
390 printf("main3-27: %d\n",b);
391 b = (g.pte.rpn ^= i);
392 printf("main3-28: %d\n",b);
393 b = (g.pte.rpn <<= i);
394 printf("main3-29: %d\n",b);
395 b = (g.pte.rpn >>= i);
396 printf("main3-30: %d\n",b);
344 397
345 return --b; 398 return --b;
346 } 399 }
400
401 main4( int a )
402 {
403 // int b:9; // nor local variable
404 int b,i;
405 PTE *pg = &g;
406
407 i = 7;
408
409
410 pg->pte.rpn = -333;
411 printf("main4-0: %d\n",b);
412 b = pg->pte.rpn--;
413 printf("main4-1: %d\n",b);
414 b = pg->pte.rpn++;
415 printf("main4-2: %d\n",b);
416 b = --pg->pte.rpn;
417 printf("main4-3: %d\n",b);
418 b = ++pg->pte.rpn;
419 printf("main4-4: %d\n",b);
420 b = (pg->pte.rpn += 3);
421 printf("main4-5: %d\n",b);
422 b = (pg->pte.rpn -= 3);
423 printf("main4-6: %d\n",b);
424 b = (pg->pte.rpn *= 3);
425 printf("main4-7: %d\n",b);
426 b = (pg->pte.rpn /= 3);
427 printf("main4-8: %d\n",b);
428 b = (pg->pte.rpn %= 3);
429 printf("main4-9: %d\n",b);
430 b = (pg->pte.rpn |= 3);
431 printf("main4-10: %d\n",b);
432 b = (pg->pte.rpn &= 3);
433 printf("main4-12: %d\n",b);
434 b = (pg->pte.rpn ^= 3);
435 printf("main4-13: %d\n",b);
436 b = (pg->pte.rpn <<= 3);
437 printf("main4-14: %d\n",b);
438 b = (pg->pte.rpn >>= 3);
439 printf("main4-15: %d\n",b);
440
441 pg->pte.rpn = -333;
442 printf("main4-16: %d\n",b);
443 b = pg->pte.rpn--;
444 printf("main4-17: %d\n",b);
445 b = pg->pte.rpn++;
446 printf("main4-18: %d\n",b);
447 b = --pg->pte.rpn;
448 printf("main4-19: %d\n",b);
449 b = ++pg->pte.rpn;
450 printf("main4-20: %d\n",b);
451 b = (pg->pte.rpn += i);
452 printf("main4-21: %d\n",b);
453 b = (pg->pte.rpn -= i);
454 printf("main4-22: %d\n",b);
455 b = (pg->pte.rpn *= i);
456 printf("main4-23: %d\n",b);
457 b = (pg->pte.rpn /= i);
458 printf("main4-24: %d\n",b);
459 b = (pg->pte.rpn %= i);
460 printf("main4-25: %d\n",b);
461 b = (pg->pte.rpn |= i);
462 printf("main4-26: %d\n",b);
463 b = (pg->pte.rpn &= i);
464 printf("main4-27: %d\n",b);
465 b = (pg->pte.rpn ^= i);
466 printf("main4-28: %d\n",b);
467 b = (pg->pte.rpn <<= i);
468 printf("main4-29: %d\n",b);
469 b = (pg->pte.rpn >>= i);
470 printf("main4-30: %d\n",b);
471
472 return --b;
473 }
474
347 475
348 476
349 477
350 478
351 union ll1 { 479 union ll1 {
535 printf("6:%08x\n",ii.a); 663 printf("6:%08x\n",ii.a);
536 printf("5:%d %d\n",ii.b.a,ii.b.d); 664 printf("5:%d %d\n",ii.b.a,ii.b.d);
537 } 665 }
538 666
539 667
668 main3l( int a )
669 {
670 // int b:9; // nor local variable
671 long long b,i;
672 i = 7;
673
674
675 g.pte.lpn = -333;
676 printf("main3l-0: %d\n",b);
677 b = g.pte.lpn--;
678 printf("main3l-1: %d\n",b);
679 b = g.pte.lpn++;
680 printf("main3l-2: %d\n",b);
681 b = --g.pte.lpn;
682 printf("main3l-3: %d\n",b);
683 b = ++g.pte.lpn;
684 printf("main3l-4: %d\n",b);
685 b = (g.pte.lpn += 3);
686 printf("main3l-5: %d\n",b);
687 b = (g.pte.lpn -= 3);
688 printf("main3l-6: %d\n",b);
689 b = (g.pte.lpn *= 3);
690 printf("main3l-7: %d\n",b);
691 b = (g.pte.lpn /= 3);
692 printf("main3l-8: %d\n",b);
693 b = (g.pte.lpn %= 3);
694 printf("main3l-9: %d\n",b);
695 b = (g.pte.lpn |= 3);
696 printf("main3l-10: %d\n",b);
697 b = (g.pte.lpn &= 3);
698 printf("main3l-12: %d\n",b);
699 b = (g.pte.lpn ^= 3);
700 printf("main3l-13: %d\n",b);
701 b = (g.pte.lpn <<= 3);
702 printf("main3l-14: %d\n",b);
703 b = (g.pte.lpn >>= 3);
704 printf("main3l-15: %d\n",b);
705
706 g.pte.lpn = -333;
707 printf("main3l-16: %d\n",b);
708 b = g.pte.lpn--;
709 printf("main3l-17: %d\n",b);
710 b = g.pte.lpn++;
711 printf("main3l-18: %d\n",b);
712 b = --g.pte.lpn;
713 printf("main3l-19: %d\n",b);
714 b = ++g.pte.lpn;
715 printf("main3l-20: %d\n",b);
716 b = (g.pte.lpn += i);
717 printf("main3l-21: %d\n",b);
718 b = (g.pte.lpn -= i);
719 printf("main3l-22: %d\n",b);
720 b = (g.pte.lpn *= i);
721 printf("main3l-23: %d\n",b);
722 b = (g.pte.lpn /= i);
723 printf("main3l-24: %d\n",b);
724 b = (g.pte.lpn %= i);
725 printf("main3l-25: %d\n",b);
726 b = (g.pte.lpn |= i);
727 printf("main3l-26: %d\n",b);
728 b = (g.pte.lpn &= i);
729 printf("main3l-27: %d\n",b);
730 b = (g.pte.lpn ^= i);
731 printf("main3l-28: %d\n",b);
732 b = (g.pte.lpn <<= i);
733 printf("main3l-29: %d\n",b);
734 b = (g.pte.lpn >>= i);
735 printf("main3l-30: %d\n",b);
736
737 return --b;
738 }
739