(% . number))
"Alist used for type propagation.")
-(defconst comp-limple-assignments '(set setimm set-par-to-local)
+(defconst comp-limple-assignments '(set
+ setimm
+ set-par-to-local
+ set-args-to-local
+ set-rest-args-to-local)
"Limple operators used to assign to mvars.")
(defconst comp-mostly-pure-funcs
(df (make-hash-table) :type hash-table
:documentation "Dominance frontier set. Block-name -> block")
(post-num nil :type number
- :documentation "Post order number."))
+ :documentation "Post order number.")
+ (final-frame nil :type vector
+ :documentation "This is a copy of the frame when leaving the block.
+Is in use to help the SSA rename pass."))
(cl-defstruct (comp-edge (:copier nil) (:constructor make--comp-edge))
"An edge connecting two basic blocks."
"Emit the prologue for a narg function."
(cl-loop for i below minarg
do (progn
- (comp-emit `(set-args-to-local ,i))
+ (comp-emit `(set-args-to-local ,(comp-slot-n i)))
(comp-emit '(inc-args))))
(cl-loop for i from minarg below nonrest
for bb = (intern (format "entry_%s" i))
(comp-emit `(cond-jump-narg-leq ,i ,bb ,fallback))
(comp-mark-block-closed)
(comp-emit-block bb)
- (comp-emit `(set-args-to-local ,i))
+ (comp-emit `(set-args-to-local ,(comp-slot-n i)))
(comp-emit '(inc-args)))
finally (comp-emit-jump 'entry_rest_args))
(cl-loop for i from minarg below nonrest
(comp-emit-block (intern (format "entry_fallback_%s" i)))
(comp-emit-set-const nil)))
(comp-emit-block 'entry_rest_args)
- (comp-emit `(set-rest-args-to-local ,nonrest)))
+ (comp-emit `(set-rest-args-to-local ,(comp-slot-n nonrest))))
(defun comp-limplify-finalize-function (func)
"Reverse insns into all basic blocks of FUNC."
(cl-loop for i from 0 below (comp-func-frame-size comp-func)
;; List of blocks with a definition of mvar i
- with defs-v = (cl-loop with blocks = (comp-func-blocks comp-func)
+ for defs-v = (cl-loop with blocks = (comp-func-blocks comp-func)
for b being each hash-value of blocks
when (slot-assigned-p i b)
collect b)
;; Set of basic blocks where phi is added.
- with f = ()
+ for f = ()
;; Worklist, set of basic blocks that contain definitions of v.
- with w = defs-v
+ for w = defs-v
do
(while w
(let ((x (pop w)))
(puthash bb t visited)
(cl-loop for insn in (comp-block-insns bb)
do (comp-ssa-rename-insn insn in-frame))
+ (setf (comp-block-final-frame bb)
+ (copy-sequence in-frame))
(when-let ((out-edges (comp-block-out-edges bb)))
(cl-loop for ed in out-edges
for child = (comp-edge-dst ed)
n);
emit_cond_jump (test, target2, target1);
}
+ else if (EQ (op, Qphi))
+ {
+ /* Nothing to do for phis into the backend. */
+ }
else if (EQ (op, Qpush_handler))
{
EMACS_UINT clobber_slot = XFIXNUM (FUNCALL1 (comp-mvar-slot, arg0));
else if (EQ (op, Qset_args_to_local))
{
/*
- Limple: (set-args-to-local 1)
+ Limple: (set-args-to-local #s(comp-mvar 1 6 nil nil nil nil))
C: local[1] = *args;
*/
gcc_jit_rvalue *gcc_args =
gcc_jit_rvalue *res =
gcc_jit_lvalue_as_rvalue (gcc_jit_rvalue_dereference (gcc_args, NULL));
- EMACS_UINT slot_n = XFIXNUM (arg0);
+ EMACS_UINT slot_n = XFIXNUM (FUNCALL1 (comp-mvar-slot, arg0));
gcc_jit_block_add_assignment (comp.block,
NULL,
comp.frame[slot_n],
else if (EQ (op, Qset_rest_args_to_local))
{
/*
- Limple: (set-rest-args-to-local 3)
- C: local[3] = list (nargs - 3, args);
+ Limple: (set-rest-args-to-local #s(comp-mvar 2 9 nil nil nil nil))
+ C: local[2] = list (nargs - 2, args);
*/
+
+ EMACS_UINT slot_n = XFIXNUM (FUNCALL1 (comp-mvar-slot, arg0));
gcc_jit_rvalue *n =
gcc_jit_context_new_rvalue_from_int (comp.ctxt,
comp.ptrdiff_type,
- XFIXNUM (arg0));
+ slot_n);
gcc_jit_lvalue *nargs =
gcc_jit_param_as_lvalue (gcc_jit_function_get_param (comp.func, 0));
gcc_jit_lvalue *args =
gcc_jit_block_add_assignment (comp.block,
NULL,
- comp.frame[XFIXNUM (arg0)],
+ comp.frame[slot_n],
res);
}
else if (EQ (op, Qinc_args))
DEFSYM (Qreturn, "return");
DEFSYM (Qcomp_mvar, "comp-mvar");
DEFSYM (Qcond_jump, "cond-jump");
+ DEFSYM (Qphi, "phi");
/* In use for prologue emission. */
DEFSYM (Qset_par_to_local, "set-par-to-local");
DEFSYM (Qset_args_to_local, "set-args-to-local");