aboutsummaryrefslogtreecommitdiffstats
path: root/src/comp.c
diff options
context:
space:
mode:
authorAndrea Corallo2020-04-05 15:40:01 +0100
committerAndrea Corallo2020-04-05 21:11:02 +0100
commit7009e8af055afcef85c30d8a3866689bd4e49a4a (patch)
tree2edd9f9631e4732298ac8af2dc36c3d661089eba /src/comp.c
parente3dff709b75c83c3939727538aa0bd072c268687 (diff)
downloademacs-7009e8af055afcef85c30d8a3866689bd4e49a4a.tar.gz
emacs-7009e8af055afcef85c30d8a3866689bd4e49a4a.zip
* src/comp.c (emit_binary_op): New function.
Wrap gcc_jit_context_new_binary_op within emit_binary_op to make sure input type are coherent and save a slew of code.
Diffstat (limited to 'src/comp.c')
-rw-r--r--src/comp.c395
1 files changed, 166 insertions, 229 deletions
diff --git a/src/comp.c b/src/comp.c
index 75a2534b2ee..b56d0afaa3a 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -635,6 +635,18 @@ emit_coerce (gcc_jit_type *new_type, gcc_jit_rvalue *obj)
635 dest_field); 635 dest_field);
636} 636}
637 637
638static gcc_jit_rvalue *
639emit_binary_op (enum gcc_jit_binary_op op,
640 gcc_jit_type *result_type,
641 gcc_jit_rvalue *a, gcc_jit_rvalue *b)
642{
643 /* FIXME Check here for possible UB. */
644 return gcc_jit_context_new_binary_op (comp.ctxt, NULL,
645 op,
646 result_type,
647 emit_coerce (result_type, a),
648 emit_coerce (result_type, b));
649}
638 650
639/* Should come with libgccjit. */ 651/* Should come with libgccjit. */
640 652
@@ -673,20 +685,16 @@ emit_rvalue_from_long_long (long long n)
673 685
674 return 686 return
675 emit_coerce (comp.long_long_type, 687 emit_coerce (comp.long_long_type,
676 gcc_jit_context_new_binary_op ( 688 emit_binary_op (
677 comp.ctxt,
678 NULL,
679 GCC_JIT_BINARY_OP_BITWISE_OR, 689 GCC_JIT_BINARY_OP_BITWISE_OR,
680 comp.unsigned_long_long_type, 690 comp.unsigned_long_long_type,
681 gcc_jit_context_new_binary_op ( 691 emit_binary_op (
682 comp.ctxt, 692 GCC_JIT_BINARY_OP_LSHIFT,
683 NULL, 693 comp.unsigned_long_long_type,
684 GCC_JIT_BINARY_OP_LSHIFT, 694 high,
685 comp.unsigned_long_long_type, 695 gcc_jit_context_new_rvalue_from_int (comp.ctxt,
686 high, 696 comp.unsigned_long_long_type,
687 gcc_jit_context_new_rvalue_from_int (comp.ctxt, 697 32)),
688 comp.unsigned_long_long_type,
689 32)),
690 low)); 698 low));
691} 699}
692 700
@@ -726,25 +734,21 @@ emit_ptr_arithmetic (gcc_jit_rvalue *ptr, gcc_jit_type *ptr_type,
726 emit_comment ("ptr_arithmetic"); 734 emit_comment ("ptr_arithmetic");
727 735
728 gcc_jit_rvalue *offset = 736 gcc_jit_rvalue *offset =
729 gcc_jit_context_new_binary_op ( 737 emit_binary_op (
730 comp.ctxt,
731 NULL,
732 GCC_JIT_BINARY_OP_MULT, 738 GCC_JIT_BINARY_OP_MULT,
733 comp.uintptr_type, 739 comp.uintptr_type,
734 gcc_jit_context_new_rvalue_from_int (comp.ctxt, 740 gcc_jit_context_new_rvalue_from_int (comp.ctxt,
735 comp.uintptr_type, 741 comp.uintptr_type,
736 size_of_ptr_ref), 742 size_of_ptr_ref),
737 emit_coerce (comp.uintptr_type, i)); 743 i);
738 744
739 return 745 return
740 emit_coerce ( 746 emit_coerce (
741 ptr_type, 747 ptr_type,
742 gcc_jit_context_new_binary_op ( 748 emit_binary_op (
743 comp.ctxt,
744 NULL,
745 GCC_JIT_BINARY_OP_PLUS, 749 GCC_JIT_BINARY_OP_PLUS,
746 comp.uintptr_type, 750 comp.uintptr_type,
747 emit_coerce (comp.uintptr_type, ptr), 751 ptr,
748 offset)); 752 offset));
749} 753}
750 754
@@ -792,9 +796,7 @@ emit_XUNTAG (gcc_jit_rvalue *a, gcc_jit_type *type, long long lisp_word_tag)
792#ifndef WIDE_EMACS_INT 796#ifndef WIDE_EMACS_INT
793 return emit_coerce ( 797 return emit_coerce (
794 gcc_jit_type_get_pointer (type), 798 gcc_jit_type_get_pointer (type),
795 gcc_jit_context_new_binary_op ( 799 emit_binary_op (
796 comp.ctxt,
797 NULL,
798 GCC_JIT_BINARY_OP_MINUS, 800 GCC_JIT_BINARY_OP_MINUS,
799 comp.emacs_int_type, 801 comp.emacs_int_type,
800 emit_XLI (a), 802 emit_XLI (a),
@@ -805,15 +807,12 @@ emit_XUNTAG (gcc_jit_rvalue *a, gcc_jit_type *type, long long lisp_word_tag)
805#else 807#else
806 return emit_coerce ( 808 return emit_coerce (
807 gcc_jit_type_get_pointer (type), 809 gcc_jit_type_get_pointer (type),
808 gcc_jit_context_new_binary_op ( 810 emit_binary_op (
809 comp.ctxt, 811 GCC_JIT_BINARY_OP_MINUS,
810 NULL, 812 comp.unsigned_long_long_type,
811 GCC_JIT_BINARY_OP_MINUS, 813 /* FIXME Should be XLP. */
812 comp.unsigned_long_long_type, 814 emit_XLI (a),
813 /* FIXME Should be XLP. */ 815 emit_rvalue_from_long_long (lisp_word_tag)));
814 emit_coerce (comp.unsigned_long_long_type, emit_XLI (a)),
815 emit_coerce (comp.unsigned_long_long_type,
816 emit_rvalue_from_long_long (lisp_word_tag))));
817#endif 816#endif
818} 817}
819 818
@@ -849,9 +848,7 @@ emit_TAGGEDP (gcc_jit_rvalue *obj, ptrdiff_t tag)
849 emit_comment ("TAGGEDP"); 848 emit_comment ("TAGGEDP");
850 849
851 gcc_jit_rvalue *sh_res = 850 gcc_jit_rvalue *sh_res =
852 gcc_jit_context_new_binary_op ( 851 emit_binary_op (
853 comp.ctxt,
854 NULL,
855 GCC_JIT_BINARY_OP_RSHIFT, 852 GCC_JIT_BINARY_OP_RSHIFT,
856 comp.emacs_int_type, 853 comp.emacs_int_type,
857 emit_XLI (obj), 854 emit_XLI (obj),
@@ -860,15 +857,14 @@ emit_TAGGEDP (gcc_jit_rvalue *obj, ptrdiff_t tag)
860 (USE_LSB_TAG ? 0 : VALBITS))); 857 (USE_LSB_TAG ? 0 : VALBITS)));
861 858
862 gcc_jit_rvalue *minus_res = 859 gcc_jit_rvalue *minus_res =
863 gcc_jit_context_new_binary_op (comp.ctxt, 860 emit_binary_op (
864 NULL, 861 GCC_JIT_BINARY_OP_MINUS,
865 GCC_JIT_BINARY_OP_MINUS, 862 comp.unsigned_type,
866 comp.unsigned_type, 863 sh_res,
867 emit_coerce (comp.unsigned_type, sh_res), 864 gcc_jit_context_new_rvalue_from_int (
868 gcc_jit_context_new_rvalue_from_int ( 865 comp.ctxt,
869 comp.ctxt, 866 comp.unsigned_type,
870 comp.unsigned_type, 867 tag));
871 tag));
872 868
873 gcc_jit_rvalue *res = 869 gcc_jit_rvalue *res =
874 gcc_jit_context_new_unary_op ( 870 gcc_jit_context_new_unary_op (
@@ -876,15 +872,14 @@ emit_TAGGEDP (gcc_jit_rvalue *obj, ptrdiff_t tag)
876 NULL, 872 NULL,
877 GCC_JIT_UNARY_OP_LOGICAL_NEGATE, 873 GCC_JIT_UNARY_OP_LOGICAL_NEGATE,
878 comp.int_type, 874 comp.int_type,
879 gcc_jit_context_new_binary_op (comp.ctxt, 875 emit_binary_op (
880 NULL, 876 GCC_JIT_BINARY_OP_BITWISE_AND,
881 GCC_JIT_BINARY_OP_BITWISE_AND, 877 comp.unsigned_type,
882 comp.unsigned_type, 878 minus_res,
883 minus_res, 879 gcc_jit_context_new_rvalue_from_int (
884 gcc_jit_context_new_rvalue_from_int ( 880 comp.ctxt,
885 comp.ctxt, 881 comp.unsigned_type,
886 comp.unsigned_type, 882 ((1 << GCTYPEBITS) - 1))));
887 ((1 << GCTYPEBITS) - 1))));
888 883
889 return res; 884 return res;
890} 885}
@@ -941,9 +936,7 @@ emit_FIXNUMP (gcc_jit_rvalue *obj)
941 emit_comment ("FIXNUMP"); 936 emit_comment ("FIXNUMP");
942 937
943 gcc_jit_rvalue *sh_res = 938 gcc_jit_rvalue *sh_res =
944 gcc_jit_context_new_binary_op ( 939 emit_binary_op (
945 comp.ctxt,
946 NULL,
947 GCC_JIT_BINARY_OP_RSHIFT, 940 GCC_JIT_BINARY_OP_RSHIFT,
948 comp.emacs_int_type, 941 comp.emacs_int_type,
949 emit_XLI (obj), 942 emit_XLI (obj),
@@ -952,15 +945,14 @@ emit_FIXNUMP (gcc_jit_rvalue *obj)
952 (USE_LSB_TAG ? 0 : FIXNUM_BITS))); 945 (USE_LSB_TAG ? 0 : FIXNUM_BITS)));
953 946
954 gcc_jit_rvalue *minus_res = 947 gcc_jit_rvalue *minus_res =
955 gcc_jit_context_new_binary_op (comp.ctxt, 948 emit_binary_op (
956 NULL, 949 GCC_JIT_BINARY_OP_MINUS,
957 GCC_JIT_BINARY_OP_MINUS, 950 comp.unsigned_type,
958 comp.unsigned_type, 951 sh_res,
959 emit_coerce (comp.unsigned_type, sh_res), 952 gcc_jit_context_new_rvalue_from_int (
960 gcc_jit_context_new_rvalue_from_int ( 953 comp.ctxt,
961 comp.ctxt, 954 comp.unsigned_type,
962 comp.unsigned_type, 955 (Lisp_Int0 >> !USE_LSB_TAG)));
963 (Lisp_Int0 >> !USE_LSB_TAG)));
964 956
965 gcc_jit_rvalue *res = 957 gcc_jit_rvalue *res =
966 gcc_jit_context_new_unary_op ( 958 gcc_jit_context_new_unary_op (
@@ -968,15 +960,14 @@ emit_FIXNUMP (gcc_jit_rvalue *obj)
968 NULL, 960 NULL,
969 GCC_JIT_UNARY_OP_LOGICAL_NEGATE, 961 GCC_JIT_UNARY_OP_LOGICAL_NEGATE,
970 comp.int_type, 962 comp.int_type,
971 gcc_jit_context_new_binary_op (comp.ctxt, 963 emit_binary_op (
972 NULL, 964 GCC_JIT_BINARY_OP_BITWISE_AND,
973 GCC_JIT_BINARY_OP_BITWISE_AND, 965 comp.unsigned_type,
974 comp.unsigned_type, 966 minus_res,
975 minus_res, 967 gcc_jit_context_new_rvalue_from_int (
976 gcc_jit_context_new_rvalue_from_int ( 968 comp.ctxt,
977 comp.ctxt, 969 comp.unsigned_type,
978 comp.unsigned_type, 970 ((1 << INTTYPEBITS) - 1))));
979 ((1 << INTTYPEBITS) - 1))));
980 971
981 return res; 972 return res;
982} 973}
@@ -989,27 +980,21 @@ emit_XFIXNUM (gcc_jit_rvalue *obj)
989 980
990 if (!USE_LSB_TAG) 981 if (!USE_LSB_TAG)
991 { 982 {
992 i = gcc_jit_context_new_binary_op (comp.ctxt, 983 i = emit_binary_op (GCC_JIT_BINARY_OP_LSHIFT,
993 NULL, 984 comp.emacs_uint_type,
994 GCC_JIT_BINARY_OP_LSHIFT, 985 i,
995 comp.emacs_uint_type, 986 comp.inttypebits);
996 emit_coerce (comp.emacs_uint_type, i),
997 comp.inttypebits);
998 987
999 return gcc_jit_context_new_binary_op (comp.ctxt, 988 return emit_binary_op (GCC_JIT_BINARY_OP_RSHIFT,
1000 NULL, 989 comp.emacs_int_type,
1001 GCC_JIT_BINARY_OP_RSHIFT, 990 i,
1002 comp.emacs_int_type, 991 comp.inttypebits);
1003 i,
1004 comp.inttypebits);
1005 } 992 }
1006 else 993 else
1007 return gcc_jit_context_new_binary_op (comp.ctxt, 994 return emit_binary_op (GCC_JIT_BINARY_OP_LSHIFT,
1008 NULL, 995 comp.emacs_int_type,
1009 GCC_JIT_BINARY_OP_LSHIFT, 996 i,
1010 comp.emacs_int_type, 997 comp.inttypebits);
1011 i,
1012 comp.inttypebits);
1013} 998}
1014 999
1015static gcc_jit_rvalue * 1000static gcc_jit_rvalue *
@@ -1017,13 +1002,10 @@ emit_INTEGERP (gcc_jit_rvalue *obj)
1017{ 1002{
1018 emit_comment ("INTEGERP"); 1003 emit_comment ("INTEGERP");
1019 1004
1020 return gcc_jit_context_new_binary_op (comp.ctxt, 1005 return emit_binary_op (GCC_JIT_BINARY_OP_LOGICAL_OR,
1021 NULL, 1006 comp.bool_type,
1022 GCC_JIT_BINARY_OP_LOGICAL_OR, 1007 emit_FIXNUMP (obj),
1023 comp.bool_type, 1008 emit_BIGNUMP (obj));
1024 emit_coerce (comp.bool_type,
1025 emit_FIXNUMP (obj)),
1026 emit_BIGNUMP (obj));
1027} 1009}
1028 1010
1029static gcc_jit_rvalue * 1011static gcc_jit_rvalue *
@@ -1031,13 +1013,10 @@ emit_NUMBERP (gcc_jit_rvalue *obj)
1031{ 1013{
1032 emit_comment ("NUMBERP"); 1014 emit_comment ("NUMBERP");
1033 1015
1034 return gcc_jit_context_new_binary_op (comp.ctxt, 1016 return emit_binary_op (GCC_JIT_BINARY_OP_LOGICAL_OR,
1035 NULL, 1017 comp.bool_type,
1036 GCC_JIT_BINARY_OP_LOGICAL_OR, 1018 emit_INTEGERP (obj),
1037 comp.bool_type, 1019 emit_FLOATP (obj));
1038 emit_INTEGERP (obj),
1039 emit_coerce (comp.bool_type,
1040 emit_FLOATP (obj)));
1041} 1020}
1042 1021
1043static gcc_jit_rvalue * 1022static gcc_jit_rvalue *
@@ -1050,19 +1029,13 @@ emit_make_fixnum_LSB_TAG (gcc_jit_rvalue *n)
1050 */ 1029 */
1051 1030
1052 gcc_jit_rvalue *tmp = 1031 gcc_jit_rvalue *tmp =
1053 gcc_jit_context_new_binary_op (comp.ctxt, 1032 emit_binary_op (GCC_JIT_BINARY_OP_LSHIFT,
1054 NULL, 1033 comp.emacs_int_type,
1055 GCC_JIT_BINARY_OP_LSHIFT, 1034 n, comp.inttypebits);
1056 comp.emacs_int_type,
1057 emit_coerce (comp.emacs_uint_type, n),
1058 comp.inttypebits);
1059 1035
1060 tmp = gcc_jit_context_new_binary_op (comp.ctxt, 1036 tmp = emit_binary_op (GCC_JIT_BINARY_OP_PLUS,
1061 NULL, 1037 comp.emacs_int_type,
1062 GCC_JIT_BINARY_OP_PLUS, 1038 tmp, comp.lisp_int0);
1063 comp.emacs_int_type,
1064 tmp,
1065 comp.lisp_int0);
1066 1039
1067 gcc_jit_lvalue *res = gcc_jit_function_new_local (comp.func, 1040 gcc_jit_lvalue *res = gcc_jit_function_new_local (comp.func,
1068 NULL, 1041 NULL,
@@ -1090,29 +1063,21 @@ emit_make_fixnum_MSB_TAG (gcc_jit_rvalue *n)
1090 emit_coerce (comp.emacs_uint_type, 1063 emit_coerce (comp.emacs_uint_type,
1091 emit_rvalue_from_long_long ((EMACS_INT_MAX 1064 emit_rvalue_from_long_long ((EMACS_INT_MAX
1092 >> (INTTYPEBITS - 1)))); 1065 >> (INTTYPEBITS - 1))));
1093 n = gcc_jit_context_new_binary_op ( 1066 n = emit_binary_op (GCC_JIT_BINARY_OP_BITWISE_AND,
1094 comp.ctxt, 1067 comp.emacs_uint_type,
1095 NULL, 1068 intmask, n);
1096 GCC_JIT_BINARY_OP_BITWISE_AND,
1097 comp.emacs_uint_type,
1098 intmask,
1099 emit_coerce (comp.emacs_uint_type, n));
1100 1069
1101 n = gcc_jit_context_new_binary_op ( 1070 n =
1102 comp.ctxt, 1071 emit_binary_op (GCC_JIT_BINARY_OP_PLUS,
1103 NULL, 1072 comp.emacs_uint_type,
1104 GCC_JIT_BINARY_OP_PLUS, 1073 emit_binary_op (GCC_JIT_BINARY_OP_LSHIFT,
1105 comp.emacs_uint_type, 1074 comp.emacs_uint_type,
1106 gcc_jit_context_new_binary_op ( 1075 comp.lisp_int0,
1107 comp.ctxt, 1076 gcc_jit_context_new_rvalue_from_int (
1108 NULL, 1077 comp.ctxt,
1109 GCC_JIT_BINARY_OP_LSHIFT, 1078 comp.emacs_uint_type,
1110 comp.emacs_uint_type, 1079 VALBITS)),
1111 emit_coerce (comp.emacs_uint_type, comp.lisp_int0), 1080 n);
1112 gcc_jit_context_new_rvalue_from_int (comp.ctxt,
1113 comp.emacs_uint_type,
1114 VALBITS)),
1115 n);
1116 return emit_XLI (emit_coerce (comp.emacs_int_type, n)); 1081 return emit_XLI (emit_coerce (comp.emacs_int_type, n));
1117} 1082}
1118 1083
@@ -1321,15 +1286,12 @@ emit_PURE_P (gcc_jit_rvalue *ptr)
1321 comp.ctxt, 1286 comp.ctxt,
1322 NULL, 1287 NULL,
1323 GCC_JIT_COMPARISON_LE, 1288 GCC_JIT_COMPARISON_LE,
1324 gcc_jit_context_new_binary_op ( 1289 emit_binary_op (
1325 comp.ctxt,
1326 NULL,
1327 GCC_JIT_BINARY_OP_MINUS, 1290 GCC_JIT_BINARY_OP_MINUS,
1328 comp.uintptr_type, 1291 comp.uintptr_type,
1329 emit_coerce (comp.uintptr_type, ptr), 1292 ptr,
1330 emit_coerce (comp.uintptr_type, 1293 gcc_jit_lvalue_as_rvalue (
1331 gcc_jit_lvalue_as_rvalue ( 1294 gcc_jit_rvalue_dereference (comp.pure_ref, NULL))),
1332 gcc_jit_rvalue_dereference (comp.pure_ref, NULL)))),
1333 gcc_jit_context_new_rvalue_from_int (comp.ctxt, 1295 gcc_jit_context_new_rvalue_from_int (comp.ctxt,
1334 comp.uintptr_type, 1296 comp.uintptr_type,
1335 PURESIZE)); 1297 PURESIZE));
@@ -1611,7 +1573,7 @@ emit_limple_insn (Lisp_Object insn)
1611 */ 1573 */
1612 gcc_jit_lvalue *m_handlerlist = 1574 gcc_jit_lvalue *m_handlerlist =
1613 gcc_jit_rvalue_dereference_field ( 1575 gcc_jit_rvalue_dereference_field (
1614 gcc_jit_lvalue_as_rvalue ( 1576 gcc_jit_lvalue_as_rvalue (
1615 gcc_jit_rvalue_dereference (comp.current_thread_ref, NULL)), 1577 gcc_jit_rvalue_dereference (comp.current_thread_ref, NULL)),
1616 NULL, 1578 NULL,
1617 comp.m_handlerlist); 1579 comp.m_handlerlist);
@@ -1630,7 +1592,7 @@ emit_limple_insn (Lisp_Object insn)
1630 else if (EQ (op, Qfetch_handler)) 1592 else if (EQ (op, Qfetch_handler))
1631 { 1593 {
1632 gcc_jit_lvalue *m_handlerlist = 1594 gcc_jit_lvalue *m_handlerlist =
1633 gcc_jit_rvalue_dereference_field ( 1595 gcc_jit_rvalue_dereference_field (
1634 gcc_jit_lvalue_as_rvalue ( 1596 gcc_jit_lvalue_as_rvalue (
1635 gcc_jit_rvalue_dereference (comp.current_thread_ref, NULL)), 1597 gcc_jit_rvalue_dereference (comp.current_thread_ref, NULL)),
1636 NULL, 1598 NULL,
@@ -1641,18 +1603,18 @@ emit_limple_insn (Lisp_Object insn)
1641 gcc_jit_lvalue_as_rvalue (m_handlerlist)); 1603 gcc_jit_lvalue_as_rvalue (m_handlerlist));
1642 1604
1643 gcc_jit_block_add_assignment ( 1605 gcc_jit_block_add_assignment (
1644 comp.block, 1606 comp.block,
1645 NULL, 1607 NULL,
1646 m_handlerlist, 1608 m_handlerlist,
1647 gcc_jit_lvalue_as_rvalue ( 1609 gcc_jit_lvalue_as_rvalue (
1648 gcc_jit_rvalue_dereference_field ( 1610 gcc_jit_rvalue_dereference_field (
1649 gcc_jit_lvalue_as_rvalue (comp.loc_handler), 1611 gcc_jit_lvalue_as_rvalue (comp.loc_handler),
1650 NULL, 1612 NULL,
1651 comp.handler_next_field))); 1613 comp.handler_next_field)));
1652 emit_frame_assignment ( 1614 emit_frame_assignment (
1653 arg[0], 1615 arg[0],
1654 gcc_jit_lvalue_as_rvalue ( 1616 gcc_jit_lvalue_as_rvalue (
1655 gcc_jit_rvalue_dereference_field ( 1617 gcc_jit_rvalue_dereference_field (
1656 gcc_jit_lvalue_as_rvalue (comp.loc_handler), 1618 gcc_jit_lvalue_as_rvalue (comp.loc_handler),
1657 NULL, 1619 NULL,
1658 comp.handler_val_field))); 1620 comp.handler_val_field)));
@@ -1745,12 +1707,10 @@ emit_limple_insn (Lisp_Object insn)
1745 gcc_jit_param_as_lvalue (gcc_jit_function_get_param (comp.func, 1)); 1707 gcc_jit_param_as_lvalue (gcc_jit_function_get_param (comp.func, 1));
1746 1708
1747 gcc_jit_rvalue *list_args[] = 1709 gcc_jit_rvalue *list_args[] =
1748 { gcc_jit_context_new_binary_op (comp.ctxt, 1710 { emit_binary_op (GCC_JIT_BINARY_OP_MINUS,
1749 NULL, 1711 comp.ptrdiff_type,
1750 GCC_JIT_BINARY_OP_MINUS, 1712 gcc_jit_lvalue_as_rvalue (nargs),
1751 comp.ptrdiff_type, 1713 n),
1752 gcc_jit_lvalue_as_rvalue (nargs),
1753 n),
1754 gcc_jit_lvalue_as_rvalue (args) }; 1714 gcc_jit_lvalue_as_rvalue (args) };
1755 1715
1756 res = emit_call (Qlist, comp.lisp_obj_type, 2, 1716 res = emit_call (Qlist, comp.lisp_obj_type, 2,
@@ -2124,31 +2084,31 @@ emit_ctxt_code (void)
2124 comp.current_thread_ref = 2084 comp.current_thread_ref =
2125 gcc_jit_lvalue_as_rvalue ( 2085 gcc_jit_lvalue_as_rvalue (
2126 gcc_jit_context_new_global ( 2086 gcc_jit_context_new_global (
2127 comp.ctxt, 2087 comp.ctxt,
2128 NULL, 2088 NULL,
2129 GCC_JIT_GLOBAL_EXPORTED, 2089 GCC_JIT_GLOBAL_EXPORTED,
2130 gcc_jit_type_get_pointer (comp.thread_state_ptr_type), 2090 gcc_jit_type_get_pointer (comp.thread_state_ptr_type),
2131 CURRENT_THREAD_RELOC_SYM)); 2091 CURRENT_THREAD_RELOC_SYM));
2132 2092
2133 comp.pure_ref = 2093 comp.pure_ref =
2134 gcc_jit_lvalue_as_rvalue ( 2094 gcc_jit_lvalue_as_rvalue (
2135 gcc_jit_context_new_global ( 2095 gcc_jit_context_new_global (
2136 comp.ctxt, 2096 comp.ctxt,
2137 NULL, 2097 NULL,
2138 GCC_JIT_GLOBAL_EXPORTED, 2098 GCC_JIT_GLOBAL_EXPORTED,
2139 gcc_jit_type_get_pointer (comp.void_ptr_type), 2099 gcc_jit_type_get_pointer (comp.void_ptr_type),
2140 PURE_RELOC_SYM)); 2100 PURE_RELOC_SYM));
2141 2101
2142 gcc_jit_context_new_global ( 2102 gcc_jit_context_new_global (
2143 comp.ctxt, 2103 comp.ctxt,
2144 NULL, 2104 NULL,
2145 GCC_JIT_GLOBAL_EXPORTED, 2105 GCC_JIT_GLOBAL_EXPORTED,
2146 gcc_jit_type_get_pointer (comp.lisp_obj_ptr_type), 2106 gcc_jit_type_get_pointer (comp.lisp_obj_ptr_type),
2147 COMP_UNIT_SYM); 2107 COMP_UNIT_SYM);
2148 2108
2149 declare_imported_data (); 2109 declare_imported_data ();
2150 2110
2151 /* Functions imported from Lisp code. */ 2111 /* Functions imported from Lisp code. */
2152 freloc_check_fill (); 2112 freloc_check_fill ();
2153 gcc_jit_field **fields = xmalloc (freloc.size * sizeof (*fields)); 2113 gcc_jit_field **fields = xmalloc (freloc.size * sizeof (*fields));
2154 ptrdiff_t n_frelocs = 0; 2114 ptrdiff_t n_frelocs = 0;
@@ -2621,16 +2581,12 @@ define_CAR_CDR (void)
2621 DECL_BLOCK (not_a_cons_b, func[i]); 2581 DECL_BLOCK (not_a_cons_b, func[i]);
2622 comp.block = entry_block; 2582 comp.block = entry_block;
2623 comp.func = func[i]; 2583 comp.func = func[i];
2624 emit_cond_jump ( 2584 emit_cond_jump (emit_binary_op (GCC_JIT_BINARY_OP_LOGICAL_OR,
2625 gcc_jit_context_new_binary_op (comp.ctxt, 2585 comp.bool_type,
2626 NULL, 2586 gcc_jit_param_as_rvalue (param[1]),
2627 GCC_JIT_BINARY_OP_LOGICAL_OR, 2587 emit_CONSP (c)),
2628 comp.bool_type, 2588 is_cons_b,
2629 gcc_jit_param_as_rvalue (param[1]), 2589 not_a_cons_b);
2630 emit_coerce (comp.bool_type,
2631 emit_CONSP (c))),
2632 is_cons_b,
2633 not_a_cons_b);
2634 comp.block = is_cons_b; 2590 comp.block = is_cons_b;
2635 if (i == 0) 2591 if (i == 0)
2636 gcc_jit_block_end_with_return (comp.block, NULL, emit_XCAR (c)); 2592 gcc_jit_block_end_with_return (comp.block, NULL, emit_XCAR (c));
@@ -2780,19 +2736,12 @@ define_add1_sub1 (void)
2780 gcc_jit_rvalue *n = gcc_jit_param_as_rvalue (param[0]); 2736 gcc_jit_rvalue *n = gcc_jit_param_as_rvalue (param[0]);
2781 gcc_jit_rvalue *n_fixnum = emit_XFIXNUM (n); 2737 gcc_jit_rvalue *n_fixnum = emit_XFIXNUM (n);
2782 gcc_jit_rvalue *sure_fixnum = 2738 gcc_jit_rvalue *sure_fixnum =
2783 gcc_jit_context_new_binary_op ( 2739 emit_binary_op (GCC_JIT_BINARY_OP_LOGICAL_OR,
2784 comp.ctxt, 2740 comp.bool_type,
2785 NULL, 2741 gcc_jit_param_as_rvalue (param[1]),
2786 GCC_JIT_BINARY_OP_LOGICAL_OR, 2742 emit_FIXNUMP (n));
2787 comp.bool_type,
2788 gcc_jit_param_as_rvalue (param[1]),
2789 emit_coerce (comp.bool_type,
2790 emit_FIXNUMP (n)));
2791
2792 emit_cond_jump ( 2743 emit_cond_jump (
2793 gcc_jit_context_new_binary_op ( 2744 emit_binary_op (
2794 comp.ctxt,
2795 NULL,
2796 GCC_JIT_BINARY_OP_LOGICAL_AND, 2745 GCC_JIT_BINARY_OP_LOGICAL_AND,
2797 comp.bool_type, 2746 comp.bool_type,
2798 sure_fixnum, 2747 sure_fixnum,
@@ -2808,12 +2757,7 @@ define_add1_sub1 (void)
2808 2757
2809 comp.block = inline_block; 2758 comp.block = inline_block;
2810 gcc_jit_rvalue *inline_res = 2759 gcc_jit_rvalue *inline_res =
2811 gcc_jit_context_new_binary_op (comp.ctxt, 2760 emit_binary_op (op[i], comp.emacs_int_type, n_fixnum, comp.one);
2812 NULL,
2813 op[i],
2814 comp.emacs_int_type,
2815 n_fixnum,
2816 comp.one);
2817 2761
2818 gcc_jit_block_end_with_return (inline_block, 2762 gcc_jit_block_end_with_return (inline_block,
2819 NULL, 2763 NULL,
@@ -2864,29 +2808,22 @@ define_negate (void)
2864 gcc_jit_lvalue *n = gcc_jit_param_as_lvalue (param[0]); 2808 gcc_jit_lvalue *n = gcc_jit_param_as_lvalue (param[0]);
2865 gcc_jit_rvalue *n_fixnum = emit_XFIXNUM (gcc_jit_lvalue_as_rvalue (n)); 2809 gcc_jit_rvalue *n_fixnum = emit_XFIXNUM (gcc_jit_lvalue_as_rvalue (n));
2866 gcc_jit_rvalue *sure_fixnum = 2810 gcc_jit_rvalue *sure_fixnum =
2867 gcc_jit_context_new_binary_op ( 2811 emit_binary_op (GCC_JIT_BINARY_OP_LOGICAL_OR,
2868 comp.ctxt, 2812 comp.bool_type,
2869 NULL, 2813 gcc_jit_param_as_rvalue (param[1]),
2870 GCC_JIT_BINARY_OP_LOGICAL_OR, 2814 emit_FIXNUMP (gcc_jit_lvalue_as_rvalue (n)));
2871 comp.bool_type,
2872 gcc_jit_param_as_rvalue (param[1]),
2873 emit_coerce (comp.bool_type,
2874 emit_FIXNUMP (gcc_jit_lvalue_as_rvalue (n))));
2875 2815
2876 emit_cond_jump ( 2816 emit_cond_jump (emit_binary_op (GCC_JIT_BINARY_OP_LOGICAL_AND,
2877 gcc_jit_context_new_binary_op ( 2817 comp.bool_type,
2878 comp.ctxt, 2818 sure_fixnum,
2879 NULL, 2819 gcc_jit_context_new_comparison (
2880 GCC_JIT_BINARY_OP_LOGICAL_AND, 2820 comp.ctxt,
2881 comp.bool_type, 2821 NULL,
2882 sure_fixnum, 2822 GCC_JIT_COMPARISON_NE,
2883 gcc_jit_context_new_comparison (comp.ctxt, 2823 n_fixnum,
2884 NULL, 2824 emit_most_negative_fixnum ())),
2885 GCC_JIT_COMPARISON_NE, 2825 inline_block,
2886 n_fixnum, 2826 fcall_block);
2887 emit_most_negative_fixnum ())),
2888 inline_block,
2889 fcall_block);
2890 2827
2891 comp.block = inline_block; 2828 comp.block = inline_block;
2892 gcc_jit_rvalue *inline_res = 2829 gcc_jit_rvalue *inline_res =