]> git.eshelyaron.com Git - emacs.git/commitdiff
introduce CASE_CALL_NARGS macro and add various ops
authorAndrea Corallo <andrea_corallo@yahoo.it>
Fri, 24 May 2019 13:43:00 +0000 (15:43 +0200)
committerAndrea Corallo <akrl@sdf.org>
Wed, 1 Jan 2020 10:33:38 +0000 (11:33 +0100)
symbol_function set fset fget fget Bsubstring

src/comp.c

index 33528f98004e67b0ea3321171bb6d96c34c461c8..07629fa00b742467fa22f212722be8c8a15af0c9 100644 (file)
@@ -89,6 +89,18 @@ along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
 
 #define DISCARD(n) (stack -= (n))
 
+#define STR(s) #s
+
+/* With most of the ops we need to do the same stuff so this save some
+   typing.  */
+
+#define CASE_CALL_NARGS(name, nargs)                                   \
+  case B##name:                                                                \
+  POP##nargs;                                                          \
+  res = jit_emit_call (STR(F##name), comp.lisp_obj_type, nargs, args); \
+  PUSH (gcc_jit_lvalue_as_rvalue (res));                               \
+  break
+
 /* The compiler context  */
 
 typedef struct {
@@ -555,35 +567,17 @@ compile_f (const char *f_name, ptrdiff_t bytestr_length,
        case Blistp:
          printf("Blistp\n");
          break;
-       case Beq:
-         POP2;
-         res = jit_emit_call ("Feq", comp.lisp_obj_type, 2, args);
-         PUSH (gcc_jit_lvalue_as_rvalue (res));
-         break;
-       case Bmemq:
-         POP1;
-         res = jit_emit_call ("Fmemq", comp.lisp_obj_type, 1, args);
-         PUSH (gcc_jit_lvalue_as_rvalue (res));
-         break;
-         break;
+
+       CASE_CALL_NARGS (eq, 2);
+       CASE_CALL_NARGS (memq, 1);
+
        case Bnot:
          printf("Bnot\n");
          break;
-       case Bcar:
-         POP1;
-         res = jit_emit_call ("Fcar", comp.lisp_obj_type, 1, args);
-         PUSH (gcc_jit_lvalue_as_rvalue (res));
-         break;
-       case Bcdr:
-         POP1;
-         res = jit_emit_call ("Fcdr", comp.lisp_obj_type, 1, args);
-         PUSH (gcc_jit_lvalue_as_rvalue (res));
-         break;
-       case Bcons:
-         POP2;
-         res = jit_emit_call ("Fcons", comp.lisp_obj_type, 2, args);
-         PUSH (gcc_jit_lvalue_as_rvalue (res));
-         break;
+
+       CASE_CALL_NARGS (car, 1);
+       CASE_CALL_NARGS (cdr, 1);
+       CASE_CALL_NARGS (cons, 2);
 
        case BlistN:
          op = FETCH;
@@ -611,45 +605,17 @@ compile_f (const char *f_name, ptrdiff_t bytestr_length,
            break;
          }
 
-       case Blength:
-         POP1;
-         res = jit_emit_call ("Flength", comp.lisp_obj_type, 1, args);
-         PUSH (gcc_jit_lvalue_as_rvalue (res));
-         break;
-
-       case Baref:
-         POP2;
-         res = jit_emit_call ("Faref", comp.lisp_obj_type, 2, args);
-         PUSH (gcc_jit_lvalue_as_rvalue (res));
-         break;
-
-       case Baset:
-         POP3;
-         res = jit_emit_call ("Faset", comp.lisp_obj_type, 3, args);
-         PUSH (gcc_jit_lvalue_as_rvalue (res));
-         break;
-
-       case Bsymbol_value:
-         POP1;
-         res = jit_emit_call ("Fsymbol_value", comp.lisp_obj_type, 1, args);
-         PUSH (gcc_jit_lvalue_as_rvalue (res));
-         break;
+       CASE_CALL_NARGS (length, 1);
+       CASE_CALL_NARGS (aref, 2);
+       CASE_CALL_NARGS (aset, 3);
+       CASE_CALL_NARGS (symbol_value, 1);
+       CASE_CALL_NARGS (symbol_function, 1);
+       CASE_CALL_NARGS (set, 2);
+       CASE_CALL_NARGS (fset, 2);
+       CASE_CALL_NARGS (fget, 2);
+       CASE_CALL_NARGS (fget, 2);
+       CASE_CALL_NARGS (Bsubstring, 3);
 
-       case Bsymbol_function:
-         printf("Bsymbol_function\n");
-         break;
-       case Bset:
-         printf("Bset\n");
-         break;
-       case Bfset:
-         printf("Bfset\n");
-         break;
-       case Bget:
-         printf("Bget\n");
-         break;
-       case Bsubstring:
-         printf("Bsubstring\n");
-         break;
        case Bconcat2:
          printf("Bconcat2\n");
          break;