Mercurial > hg > CbC > old > device
comparison mc-inline.c @ 464:d88f08d81bba
inline continue....
const type
lvar offset for inline local will be add
author | kono |
---|---|
date | Tue, 07 Dec 2004 12:30:18 +0900 |
parents | 50a59dfb4606 |
children | 0a4ca939f403 |
comparison
equal
deleted
inserted
replaced
463:50a59dfb4606 | 464:d88f08d81bba |
---|---|
4 #include <stdio.h> | 4 #include <stdio.h> |
5 #include "mc.h" | 5 #include "mc.h" |
6 #include "mc-parse.h" | 6 #include "mc-parse.h" |
7 #include "mc-codegen.h" | 7 #include "mc-codegen.h" |
8 #include "mc-switch.h" | 8 #include "mc-switch.h" |
9 #include "mc-code.h" | |
10 #include "mc-inline.h" | |
9 | 11 |
10 static int pvartable; | 12 static int pvartable; |
11 static int pdisp; | 13 static int pdisp; |
12 | 14 |
13 /* | 15 /* |
390 */ | 392 */ |
391 | 393 |
392 static int | 394 static int |
393 p_vartable(int e,int adisp,int ldisp) | 395 p_vartable(int e,int adisp,int ldisp) |
394 { | 396 { |
395 int i,e1,e3; | 397 int i; |
396 pvartable = getfree(adisp+ldisp); | 398 pvartable = getfree(adisp+ldisp); |
397 pdisp = pvartable+adisp; | 399 pdisp = pvartable+adisp; |
398 for(i=adisp+ldisp;i>=0;i--) { | 400 for(i=adisp+ldisp;i>=0;i--) { |
399 pvartable = 0; | 401 pvartable = 0; |
400 } | 402 } |
406 { | 408 { |
407 int sz = is_memory(e1); | 409 int sz = is_memory(e1); |
408 int d = cadr(e1); | 410 int d = cadr(e1); |
409 int d1; | 411 int d1; |
410 if ((d1=(heap[pdisp+e1]))) return d1; | 412 if ((d1=(heap[pdisp+e1]))) return d1; |
411 return (heap[pdisp+narg]=new_lvar(sz)); | 413 return (heap[pdisp+d]=new_lvar(sz)); |
412 } | 414 } |
413 | 415 |
414 static int | 416 static int |
415 pfunction(int e) | 417 pfunction(int e) |
416 { | 418 { |
417 | 419 return e; |
418 } | 420 } |
419 | 421 |
420 static int | 422 static int |
421 prindirect(int e) | 423 prindirect(int e) |
422 { | 424 { |
423 | 425 return e; |
424 } | 426 } |
425 | 427 |
426 static int | 428 static int |
427 paddress(int e) | 429 paddress(int e) |
428 { | 430 { |
429 | 431 return e; |
430 } | 432 } |
431 | 433 |
432 static int | 434 static int |
433 p_conv(int e) | 435 p_conv(int e1,int e2) |
434 { | 436 { |
435 | 437 return e1; |
436 } | 438 } |
437 | 439 |
438 static int | 440 static int |
439 pbinop(int e) | 441 pbinop(int op,int e1,int e2) |
440 { | 442 { |
441 | 443 return e1; |
442 } | 444 } |
443 | 445 |
444 static int | 446 static int |
445 psassign(int e) | 447 psassign(int e) |
446 { | 448 { |
447 | 449 return e; |
448 } | 450 } |
449 | 451 |
450 static int | 452 static int |
451 passign(int e) | 453 passign(int e) |
452 { | 454 { |
453 | 455 return e; |
454 } | 456 } |
455 | 457 |
456 static int | 458 static int |
457 passop(int e) | 459 passop(int e) |
458 { | 460 { |
459 | 461 return e; |
460 } | 462 } |
461 | 463 |
462 static int | 464 static int |
463 pdassign(int e) | 465 pdassign(int e) |
464 { | 466 { |
465 | 467 return e; |
466 } | 468 } |
467 | 469 |
468 static int | 470 static int |
469 pdassop(int e) | 471 pdassop(int e) |
470 { | 472 { |
471 | 473 return e; |
472 } | 474 } |
473 | 475 |
474 static int | 476 static int |
475 plassign(int e) | 477 plassign(int e) |
476 { | 478 { |
477 | 479 return e; |
478 } | 480 } |
479 | 481 |
480 static int | 482 static int |
481 plassop(int e) | 483 plassop(int e) |
482 { | 484 { |
483 | 485 return e; |
484 } | 486 } |
485 | 487 |
486 static int | 488 static int |
487 palloc(int e) | 489 palloc(int e) |
488 { | 490 { |
489 | 491 return e; |
490 } | 492 } |
491 | 493 |
492 static int | 494 static int |
493 pcomma(int e) | 495 pcomma(int e1,int e2) |
494 { | 496 { |
495 | 497 return e1; |
496 } | 498 } |
497 | 499 |
498 static int | 500 static int |
499 prbit_field(int e) | 501 prbit_field(int e) |
500 { | 502 { |
501 | 503 return e; |
502 } | 504 } |
503 | 505 |
504 static int | 506 static int |
505 pbassign(int e) | 507 pbassign(int e) |
506 { | 508 { |
507 | 509 return e; |
508 } | 510 } |
509 | 511 |
510 static int | 512 static int |
511 pbassop(int e) | 513 pbassop(int e) |
512 { | 514 { |
513 | 515 return e; |
514 } | 516 } |
515 | 517 |
516 static int | 518 static int |
517 p_decl(int e) | 519 p_decl(int e) |
518 { | 520 { |
547 } | 549 } |
548 | 550 |
549 static int | 551 static int |
550 p_if(int e) | 552 p_if(int e) |
551 { | 553 { |
552 | 554 return e; |
553 } | 555 } |
554 | 556 |
555 static int | 557 static int |
556 p_do(int e) | 558 p_do(int e) |
557 { | 559 { |
558 | 560 return e; |
559 } | 561 } |
560 | 562 |
561 static int | 563 static int |
562 p_while(int e) | 564 p_while(int e) |
563 { | 565 { |
564 | 566 return e; |
565 } | 567 } |
566 | 568 |
567 static int | 569 static int |
568 p_for(int e) | 570 p_for(int e) |
569 { | 571 { |
570 | 572 return e; |
571 } | 573 } |
572 | 574 |
573 static int | 575 static int |
574 p_switch(int e) | 576 p_switch(int e) |
575 { | 577 { |
576 | 578 return e; |
577 } | 579 } |
578 | 580 |
579 static int | 581 static int |
580 p_comp(int e) | 582 p_comp(int e) |
581 { | 583 { |
582 | 584 return e; |
583 } | 585 } |
584 | 586 |
585 static int | 587 static int |
586 p_break(int e) | 588 p_break(int e) |
587 { | 589 { |
588 | 590 return e; |
589 } | 591 } |
590 | 592 |
591 static int | 593 static int |
592 p_continue(int e) | 594 p_continue(int e) |
593 { | 595 { |
594 | 596 return e; |
595 } | 597 } |
596 | 598 |
597 static int | 599 static int |
598 p_case(int e) | 600 p_case(int e) |
599 { | 601 { |
600 | 602 return e; |
601 } | 603 } |
602 | 604 |
603 static int | 605 static int |
604 p_default(int e) | 606 p_default(int e) |
605 { | 607 { |
606 | 608 return e; |
607 } | 609 } |
608 | 610 |
609 static int | 611 static int |
610 p_return(int e) | 612 p_return(int e) |
611 { | 613 { |
612 | 614 return e; |
613 } | 615 } |
614 | 616 |
615 static int | 617 static int |
616 p_goto(int e) | 618 p_goto(int e) |
617 { | 619 { |
618 | 620 return e; |
619 } | 621 } |
620 | 622 |
621 static int | 623 static int |
622 p_asm(int e) | 624 p_asm(int e) |
623 { | 625 { |
624 | 626 return e; |
625 } | 627 } |
626 | 628 |
627 static int | 629 static int |
628 p_label(int e) | 630 p_label(int e) |
629 { | 631 { |
630 | 632 return e; |
631 } | 633 } |
632 | 634 |
633 static int | 635 static int |
634 p_bool(int e) | 636 p_bool(int e) |
635 { | 637 { |
636 | 638 return e; |
639 } | |
640 | |
641 static int | |
642 p_comment(int e) | |
643 { | |
644 return e; | |
637 } | 645 } |
638 | 646 |
639 extern int | 647 extern int |
640 pexpr(int e1) | 648 pexpr(int e1) |
641 { | 649 { |
642 int e2,e3; | 650 int e2,e3; |
643 NMTBL *n; | |
644 | 651 |
645 // if (inmode) error(-1); | 652 // if (inmode) error(-1); |
646 e2 = cadr(e1); | 653 e2 = cadr(e1); |
647 switch (car(e1)){ | 654 switch (car(e1)){ |
648 case GVAR: case RGVAR: case CRGVAR: case CURGVAR: case SRGVAR: | 655 case GVAR: case RGVAR: case CRGVAR: case CURGVAR: case SRGVAR: |
872 int narg,arg; | 879 int narg,arg; |
873 NMTBL *n = (NMTBL*)cadr(cadr(e)); | 880 NMTBL *n = (NMTBL*)cadr(cadr(e)); |
874 int e1 = attr_value(n,INLINE); | 881 int e1 = attr_value(n,INLINE); |
875 int parse = car(e1); | 882 int parse = car(e1); |
876 int arg_disp = cadr(e1); | 883 int arg_disp = cadr(e1); |
884 int e3,t; | |
877 | 885 |
878 pvartable = p_vartable(e,pdisp=arg_disp,caddr(e1)); | 886 pvartable = p_vartable(e,pdisp=arg_disp,caddr(e1)); |
879 /* inline function arguments */ | 887 /* inline function arguments */ |
880 narg = 0; | 888 narg = 0; |
881 for (e3 = e1 = reverse0(caddr(e)); e3; e3 = cadr(e3)) { | 889 for (e3 = e1 = reverse0(caddr(e)); e3; e3 = cadr(e3)) { |
882 t=caddr(e3); | 890 t=caddr(e3); |
883 if (is_const(e3)||(is_memory(e3)&&is_readonly(e3))) { | 891 if (is_const(e3) /* ||(is_memory(e3)&&is_readonly(e3)) */ ) { |
884 heap[pdisp+narg]=e3; | 892 heap[pdisp+narg]=e3; |
885 } else { | 893 } else { |
886 arg = heap[pdisp+narg]=new_lvar(size(t)); | 894 arg = heap[pdisp+narg]=new_lvar(size(t)); |
887 g_expr_u(assign_expr0(arg,e3,t,t)); | 895 g_expr_u(assign_expr0(arg,e3,t,t)); |
888 } | 896 } |
889 narg += (size(t)+3)/4; | 897 narg += (size(t)+3)/4; |
890 } | 898 } |
891 e = pexpr(parse); | 899 e = pexpr(parse); |
892 convlvar = sconvlvar; | |
893 pdisp = sdisp; | 900 pdisp = sdisp; |
901 pvartable = svartable; | |
894 return e; | 902 return e; |
895 } | 903 } |
896 | 904 |
897 /* end */ | 905 /* end */ |