1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

chasing GNU style

This commit is contained in:
Andrea Corallo 2019-11-11 17:46:34 +01:00
parent 7c9a3556e3
commit 009089f0d6
2 changed files with 38 additions and 37 deletions

View file

@ -1428,7 +1428,7 @@ PRE-LAMBDA and POST-LAMBDA are called in pre or post-order if non nil."
for e in (comp-block-in-edges b) for e in (comp-block-in-edges b)
for b = (comp-edge-src e) for b = (comp-edge-src e)
for in-frame = (comp-block-final-frame b) for in-frame = (comp-block-final-frame b)
collect (aref in-frame slot-n))) )) collect (aref in-frame slot-n)))))
(cl-loop for b being each hash-value of (comp-func-blocks comp-func) (cl-loop for b being each hash-value of (comp-func-blocks comp-func)
do (cl-loop for (op . args) in (comp-block-insns b) do (cl-loop for (op . args) in (comp-block-insns b)

View file

@ -57,11 +57,11 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
/* Like call1 but stringify and intern. */ /* Like call1 but stringify and intern. */
#define CALL1I(fun, arg) \ #define CALL1I(fun, arg) \
CALLN (Ffuncall, intern_c_string (STR(fun)), arg) CALLN (Ffuncall, intern_c_string (STR (fun)), arg)
#define DECL_BLOCK(name, func) \ #define DECL_BLOCK(name, func) \
gcc_jit_block *(name) = \ gcc_jit_block *(name) = \
gcc_jit_function_new_block ((func), STR(name)) gcc_jit_function_new_block ((func), STR (name))
#ifdef HAVE__SETJMP #ifdef HAVE__SETJMP
#define SETJMP _setjmp #define SETJMP _setjmp
@ -72,11 +72,11 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#define ICE_IF(test, msg) \ #define ICE_IF(test, msg) \
do { \ do { \
if (test) \ if (test) \
ice (msg); \ ice (msg); \
} while (0) } while (0)
/* C side of the compiler context. */ /* C side of the compiler context. */
typedef struct { typedef struct {
gcc_jit_context *ctxt; gcc_jit_context *ctxt;
@ -340,10 +340,10 @@ declare_imported_func (Lisp_Object subr_sym, gcc_jit_type *ret_type,
types[i] = comp.lisp_obj_type; types[i] = comp.lisp_obj_type;
} }
/* String containing the function ptr name. */ /* String containing the function ptr name. */
Lisp_Object f_ptr_name = Lisp_Object f_ptr_name =
CALLN (Ffuncall, intern_c_string (STR (comp-c-func-name)), CALLN (Ffuncall, intern_c_string (STR (comp-c-func-name)),
subr_sym, make_string("R", 1)); subr_sym, make_string ("R", 1));
gcc_jit_type *f_ptr_type = gcc_jit_type *f_ptr_type =
gcc_jit_context_new_function_ptr_type (comp.ctxt, gcc_jit_context_new_function_ptr_type (comp.ctxt,
@ -381,7 +381,8 @@ emit_call (Lisp_Object subr_sym, gcc_jit_type *ret_type, unsigned nargs,
xmint_pointer (func), xmint_pointer (func),
nargs, nargs,
args); args);
} else { }
else {
gcc_jit_lvalue *f_ptr = gcc_jit_lvalue *f_ptr =
gcc_jit_lvalue_access_field (comp.func_relocs, gcc_jit_lvalue_access_field (comp.func_relocs,
NULL, NULL,
@ -402,9 +403,9 @@ emit_call_ref (Lisp_Object subr_sym, unsigned nargs,
gcc_jit_lvalue *base_arg, bool direct) gcc_jit_lvalue *base_arg, bool direct)
{ {
gcc_jit_rvalue *args[] = gcc_jit_rvalue *args[] =
{ gcc_jit_context_new_rvalue_from_int(comp.ctxt, { gcc_jit_context_new_rvalue_from_int (comp.ctxt,
comp.ptrdiff_type, comp.ptrdiff_type,
nargs), nargs),
gcc_jit_lvalue_get_address (base_arg, NULL) }; gcc_jit_lvalue_get_address (base_arg, NULL) };
return emit_call (subr_sym, comp.lisp_obj_type, 2, args, direct); return emit_call (subr_sym, comp.lisp_obj_type, 2, args, direct);
} }
@ -757,7 +758,7 @@ emit_NUMBERP (gcc_jit_rvalue *obj)
NULL, NULL,
GCC_JIT_BINARY_OP_LOGICAL_OR, GCC_JIT_BINARY_OP_LOGICAL_OR,
comp.bool_type, comp.bool_type,
emit_INTEGERP(obj), emit_INTEGERP (obj),
emit_cast (comp.bool_type, emit_cast (comp.bool_type,
emit_FLOATP (obj))); emit_FLOATP (obj)));
} }
@ -962,7 +963,7 @@ emit_XSETCAR (gcc_jit_rvalue *c, gcc_jit_rvalue *n)
{ {
emit_comment ("XSETCAR"); emit_comment ("XSETCAR");
gcc_jit_block_add_assignment( gcc_jit_block_add_assignment (
comp.block, comp.block,
NULL, NULL,
gcc_jit_rvalue_dereference ( gcc_jit_rvalue_dereference (
@ -976,7 +977,7 @@ emit_XSETCDR (gcc_jit_rvalue *c, gcc_jit_rvalue *n)
{ {
emit_comment ("XSETCDR"); emit_comment ("XSETCDR");
gcc_jit_block_add_assignment( gcc_jit_block_add_assignment (
comp.block, comp.block,
NULL, NULL,
gcc_jit_rvalue_dereference ( gcc_jit_rvalue_dereference (
@ -1033,9 +1034,9 @@ emit_mvar_val (Lisp_Object mvar)
(read fixnums). */ (read fixnums). */
emit_comment (SSDATA (Fprin1_to_string (constant, Qnil))); emit_comment (SSDATA (Fprin1_to_string (constant, Qnil)));
gcc_jit_rvalue *word = gcc_jit_rvalue *word =
gcc_jit_context_new_rvalue_from_ptr(comp.ctxt, gcc_jit_context_new_rvalue_from_ptr (comp.ctxt,
comp.void_ptr_type, comp.void_ptr_type,
constant); constant);
return emit_cast (comp.lisp_obj_type, word); return emit_cast (comp.lisp_obj_type, word);
} }
/* Other const objects are fetched from the reloc array. */ /* Other const objects are fetched from the reloc array. */
@ -1079,7 +1080,7 @@ emit_set_internal (Lisp_Object args)
gcc_args, false); gcc_args, false);
} }
/* This is for a regular function with arguments as m-var. */ /* This is for a regular function with arguments as m-var. */
static gcc_jit_rvalue * static gcc_jit_rvalue *
emit_simple_limple_call (Lisp_Object args, gcc_jit_type *ret_type, bool direct) emit_simple_limple_call (Lisp_Object args, gcc_jit_type *ret_type, bool direct)
@ -1192,7 +1193,7 @@ emit_limple_insn (Lisp_Object insn)
if (EQ (op, Qjump)) if (EQ (op, Qjump))
{ {
/* Unconditional branch. */ /* Unconditional branch. */
gcc_jit_block *target = retrive_block (arg[0]); gcc_jit_block *target = retrive_block (arg[0]);
gcc_jit_block_end_with_jump (comp.block, NULL, target); gcc_jit_block_end_with_jump (comp.block, NULL, target);
} }
@ -1230,7 +1231,7 @@ emit_limple_insn (Lisp_Object insn)
} }
else if (EQ (op, Qphi)) else if (EQ (op, Qphi))
{ {
/* Nothing to do for phis into the backend. */ /* Nothing to do for phis into the backend. */
} }
else if (EQ (op, Qpush_handler)) else if (EQ (op, Qpush_handler))
{ {
@ -1266,7 +1267,7 @@ emit_limple_insn (Lisp_Object insn)
NULL, NULL,
comp.m_handlerlist); comp.m_handlerlist);
gcc_jit_block_add_assignment( gcc_jit_block_add_assignment (
comp.block, comp.block,
NULL, NULL,
m_handlerlist, m_handlerlist,
@ -1294,14 +1295,14 @@ emit_limple_insn (Lisp_Object insn)
comp.block, comp.block,
NULL, NULL,
m_handlerlist, m_handlerlist,
gcc_jit_lvalue_as_rvalue( gcc_jit_lvalue_as_rvalue (
gcc_jit_rvalue_dereference_field ( gcc_jit_rvalue_dereference_field (
gcc_jit_lvalue_as_rvalue (comp.loc_handler), gcc_jit_lvalue_as_rvalue (comp.loc_handler),
NULL, NULL,
comp.handler_next_field))); comp.handler_next_field)));
emit_frame_assignment ( emit_frame_assignment (
arg[0], arg[0],
gcc_jit_lvalue_as_rvalue( gcc_jit_lvalue_as_rvalue (
gcc_jit_rvalue_dereference_field ( gcc_jit_rvalue_dereference_field (
gcc_jit_lvalue_as_rvalue (comp.loc_handler), gcc_jit_lvalue_as_rvalue (comp.loc_handler),
NULL, NULL,
@ -1667,7 +1668,7 @@ static Lisp_Object
declare_runtime_imported_funcs (void) declare_runtime_imported_funcs (void)
{ {
/* For subr imported by the runtime we rely on the standard mechanism in place /* For subr imported by the runtime we rely on the standard mechanism in place
for functions imported by lisp code. */ for functions imported by lisp code. */
CALL1I (comp-add-subr-to-relocs, intern_c_string ("1+")); CALL1I (comp-add-subr-to-relocs, intern_c_string ("1+"));
CALL1I (comp-add-subr-to-relocs, intern_c_string ("1-")); CALL1I (comp-add-subr-to-relocs, intern_c_string ("1-"));
CALL1I (comp-add-subr-to-relocs, Qplus); CALL1I (comp-add-subr-to-relocs, Qplus);
@ -1760,7 +1761,7 @@ emit_ctxt_code (void)
d_reloc = Fvconcat (1, &d_reloc); d_reloc = Fvconcat (1, &d_reloc);
comp.data_relocs = comp.data_relocs =
gcc_jit_lvalue_as_rvalue( gcc_jit_lvalue_as_rvalue (
gcc_jit_context_new_global ( gcc_jit_context_new_global (
comp.ctxt, comp.ctxt,
NULL, NULL,
@ -1777,7 +1778,7 @@ emit_ctxt_code (void)
Lisp_Object f_runtime = declare_runtime_imported_funcs (); Lisp_Object f_runtime = declare_runtime_imported_funcs ();
EMACS_INT f_reloc_len = XFIXNUM (Flength (f_runtime)); EMACS_INT f_reloc_len = XFIXNUM (Flength (f_runtime));
/* Imported subrs. */ /* Imported subrs. */
Lisp_Object f_subr = CALL1I (comp-ctxt-func-relocs-l, Vcomp_ctxt); Lisp_Object f_subr = CALL1I (comp-ctxt-func-relocs-l, Vcomp_ctxt);
f_reloc_len += XFIXNUM (Flength (f_subr)); f_reloc_len += XFIXNUM (Flength (f_subr));
@ -1805,7 +1806,7 @@ emit_ctxt_code (void)
FIXNUMP (maxarg) ? XFIXNUM (maxarg) : FIXNUMP (maxarg) ? XFIXNUM (maxarg) :
EQ (maxarg, Qmany) ? MANY : UNEVALLED, EQ (maxarg, Qmany) ? MANY : UNEVALLED,
NULL); NULL);
fields [n_frelocs++] = field; fields[n_frelocs++] = field;
f_reloc_list = Fcons (subr_sym, f_reloc_list); f_reloc_list = Fcons (subr_sym, f_reloc_list);
} }
} }
@ -2261,7 +2262,7 @@ define_CAR_CDR (void)
gcc_jit_context_new_function (comp.ctxt, NULL, gcc_jit_context_new_function (comp.ctxt, NULL,
GCC_JIT_FUNCTION_INTERNAL, GCC_JIT_FUNCTION_INTERNAL,
comp.lisp_obj_type, comp.lisp_obj_type,
f_name [i], f_name[i],
2, param, 0); 2, param, 0);
gcc_jit_rvalue *c = gcc_jit_param_as_rvalue (param[0]); gcc_jit_rvalue *c = gcc_jit_param_as_rvalue (param[0]);
@ -2865,7 +2866,7 @@ DEFUN ("comp--init-ctxt", Fcomp__init_ctxt, Scomp__init_ctxt,
if (NILP (comp.emitter_dispatcher)) if (NILP (comp.emitter_dispatcher))
{ {
/* Move this into syms_of_comp the day will be dumpable. */ /* Move this into syms_of_comp the day will be dumpable. */
comp.emitter_dispatcher = CALLN (Fmake_hash_table); comp.emitter_dispatcher = CALLN (Fmake_hash_table);
register_emitter (Qset_internal, emit_set_internal); register_emitter (Qset_internal, emit_set_internal);
register_emitter (Qhelper_unbind_n, emit_simple_limple_call_lisp_ret); register_emitter (Qhelper_unbind_n, emit_simple_limple_call_lisp_ret);
@ -2890,7 +2891,7 @@ DEFUN ("comp--init-ctxt", Fcomp__init_ctxt, Scomp__init_ctxt,
register_emitter (Qintegerp, emit_integerp); register_emitter (Qintegerp, emit_integerp);
} }
comp.ctxt = gcc_jit_context_acquire(); comp.ctxt = gcc_jit_context_acquire ();
if (COMP_DEBUG) if (COMP_DEBUG)
{ {
@ -3016,7 +3017,7 @@ DEFUN ("comp--release-ctxt", Fcomp__release_ctxt, Scomp__release_ctxt,
(void) (void)
{ {
if (comp.ctxt) if (comp.ctxt)
gcc_jit_context_release(comp.ctxt); gcc_jit_context_release (comp.ctxt);
if (logfile) if (logfile)
fclose (logfile); fclose (logfile);
@ -3049,7 +3050,7 @@ DEFUN ("comp--compile-ctxt-to-file", Fcomp__compile_ctxt_to_file,
emit_ctxt_code (); emit_ctxt_code ();
/* Define inline functions. */ /* Define inline functions. */
define_CAR_CDR(); define_CAR_CDR ();
define_PSEUDOVECTORP (); define_PSEUDOVECTORP ();
define_CHECK_TYPE (); define_CHECK_TYPE ();
define_CHECK_IMPURE (); define_CHECK_IMPURE ();
@ -3165,7 +3166,7 @@ load_static_obj (dynlib_handle_ptr handle, const char *name)
{ {
static_obj_t *(*f)(void) = dynlib_sym (handle, name); static_obj_t *(*f)(void) = dynlib_sym (handle, name);
eassert (f); eassert (f);
static_obj_t *res = f(); static_obj_t *res = f ();
return Fread (make_string (res->data, res->len)); return Fread (make_string (res->data, res->len));
} }
@ -3284,12 +3285,12 @@ DEFUN ("comp--register-subr", Fcomp__register_subr,
x->s.max_args = FIXNUMP (maxarg) ? XFIXNUM (maxarg) : MANY; x->s.max_args = FIXNUMP (maxarg) ? XFIXNUM (maxarg) : MANY;
x->s.symbol_name = SSDATA (Fsymbol_name (name)); x->s.symbol_name = SSDATA (Fsymbol_name (name));
x->s.native_elisp = true; x->s.native_elisp = true;
defsubr(x); defsubr (x);
return Qnil; return Qnil;
} }
/* Load related routines. */ /* Load related routines. */
DEFUN ("native-elisp-load", Fnative_elisp_load, Snative_elisp_load, 1, 1, 0, DEFUN ("native-elisp-load", Fnative_elisp_load, Snative_elisp_load, 1, 1, 0,
doc: /* Load native elisp code FILE. */) doc: /* Load native elisp code FILE. */)
(Lisp_Object file) (Lisp_Object file)
@ -3382,7 +3383,7 @@ syms_of_comp (void)
DEFVAR_LISP ("comp-ctxt", Vcomp_ctxt, DEFVAR_LISP ("comp-ctxt", Vcomp_ctxt,
doc: /* doc: /*
The compiler context. */); The compiler context. */);
Vcomp_ctxt = Qnil; Vcomp_ctxt = Qnil;
/* Load mechanism. */ /* Load mechanism. */