aboutsummaryrefslogtreecommitdiffstats
path: root/src/comp.c
diff options
context:
space:
mode:
authorAndrea Corallo2019-05-24 15:43:00 +0200
committerAndrea Corallo2020-01-01 11:33:38 +0100
commitf42b2b0143f5f6e6fd9741b482cd98785feb95da (patch)
tree5c9d65a7ae80a813e22060a8292b213c75dedee9 /src/comp.c
parent17807af213da9eb08507d47dff142a1f8672b4e7 (diff)
downloademacs-f42b2b0143f5f6e6fd9741b482cd98785feb95da.tar.gz
emacs-f42b2b0143f5f6e6fd9741b482cd98785feb95da.zip
introduce CASE_CALL_NARGS macro and add various ops
symbol_function set fset fget fget Bsubstring
Diffstat (limited to 'src/comp.c')
-rw-r--r--src/comp.c94
1 files changed, 30 insertions, 64 deletions
diff --git a/src/comp.c b/src/comp.c
index 33528f98004..07629fa00b7 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -89,6 +89,18 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
89 89
90#define DISCARD(n) (stack -= (n)) 90#define DISCARD(n) (stack -= (n))
91 91
92#define STR(s) #s
93
94/* With most of the ops we need to do the same stuff so this save some
95 typing. */
96
97#define CASE_CALL_NARGS(name, nargs) \
98 case B##name: \
99 POP##nargs; \
100 res = jit_emit_call (STR(F##name), comp.lisp_obj_type, nargs, args); \
101 PUSH (gcc_jit_lvalue_as_rvalue (res)); \
102 break
103
92/* The compiler context */ 104/* The compiler context */
93 105
94typedef struct { 106typedef struct {
@@ -555,35 +567,17 @@ compile_f (const char *f_name, ptrdiff_t bytestr_length,
555 case Blistp: 567 case Blistp:
556 printf("Blistp\n"); 568 printf("Blistp\n");
557 break; 569 break;
558 case Beq: 570
559 POP2; 571 CASE_CALL_NARGS (eq, 2);
560 res = jit_emit_call ("Feq", comp.lisp_obj_type, 2, args); 572 CASE_CALL_NARGS (memq, 1);
561 PUSH (gcc_jit_lvalue_as_rvalue (res)); 573
562 break;
563 case Bmemq:
564 POP1;
565 res = jit_emit_call ("Fmemq", comp.lisp_obj_type, 1, args);
566 PUSH (gcc_jit_lvalue_as_rvalue (res));
567 break;
568 break;
569 case Bnot: 574 case Bnot:
570 printf("Bnot\n"); 575 printf("Bnot\n");
571 break; 576 break;
572 case Bcar: 577
573 POP1; 578 CASE_CALL_NARGS (car, 1);
574 res = jit_emit_call ("Fcar", comp.lisp_obj_type, 1, args); 579 CASE_CALL_NARGS (cdr, 1);
575 PUSH (gcc_jit_lvalue_as_rvalue (res)); 580 CASE_CALL_NARGS (cons, 2);
576 break;
577 case Bcdr:
578 POP1;
579 res = jit_emit_call ("Fcdr", comp.lisp_obj_type, 1, args);
580 PUSH (gcc_jit_lvalue_as_rvalue (res));
581 break;
582 case Bcons:
583 POP2;
584 res = jit_emit_call ("Fcons", comp.lisp_obj_type, 2, args);
585 PUSH (gcc_jit_lvalue_as_rvalue (res));
586 break;
587 581
588 case BlistN: 582 case BlistN:
589 op = FETCH; 583 op = FETCH;
@@ -611,45 +605,17 @@ compile_f (const char *f_name, ptrdiff_t bytestr_length,
611 break; 605 break;
612 } 606 }
613 607
614 case Blength: 608 CASE_CALL_NARGS (length, 1);
615 POP1; 609 CASE_CALL_NARGS (aref, 2);
616 res = jit_emit_call ("Flength", comp.lisp_obj_type, 1, args); 610 CASE_CALL_NARGS (aset, 3);
617 PUSH (gcc_jit_lvalue_as_rvalue (res)); 611 CASE_CALL_NARGS (symbol_value, 1);
618 break; 612 CASE_CALL_NARGS (symbol_function, 1);
619 613 CASE_CALL_NARGS (set, 2);
620 case Baref: 614 CASE_CALL_NARGS (fset, 2);
621 POP2; 615 CASE_CALL_NARGS (fget, 2);
622 res = jit_emit_call ("Faref", comp.lisp_obj_type, 2, args); 616 CASE_CALL_NARGS (fget, 2);
623 PUSH (gcc_jit_lvalue_as_rvalue (res)); 617 CASE_CALL_NARGS (Bsubstring, 3);
624 break;
625
626 case Baset:
627 POP3;
628 res = jit_emit_call ("Faset", comp.lisp_obj_type, 3, args);
629 PUSH (gcc_jit_lvalue_as_rvalue (res));
630 break;
631
632 case Bsymbol_value:
633 POP1;
634 res = jit_emit_call ("Fsymbol_value", comp.lisp_obj_type, 1, args);
635 PUSH (gcc_jit_lvalue_as_rvalue (res));
636 break;
637 618
638 case Bsymbol_function:
639 printf("Bsymbol_function\n");
640 break;
641 case Bset:
642 printf("Bset\n");
643 break;
644 case Bfset:
645 printf("Bfset\n");
646 break;
647 case Bget:
648 printf("Bget\n");
649 break;
650 case Bsubstring:
651 printf("Bsubstring\n");
652 break;
653 case Bconcat2: 619 case Bconcat2:
654 printf("Bconcat2\n"); 620 printf("Bconcat2\n");
655 break; 621 break;