mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-01 04:10:18 +02:00
Remove add1 and sub1
* libguile/vm-engine.c: Remove add1 and sub1 instructions. Will replace with add/immediate and sub/immediate. * module/language/tree-il/peval.scm (peval): If we reify a new <primcall>, expand it. Removes 1- and similar primcalls. * module/language/tree-il/primitives.scm: Don't specialize (+ x 1) to 1+. (expand-primcall): New export, does a single primcall expansion. (expand-primitives): Use the new helper. * module/language/cps/effects-analysis.scm: * module/language/cps/primitives.scm: * module/language/cps/types.scm: * module/system/vm/assembler.scm: Remove support for add1 and sub1 CPS primitives. * test-suite/tests/peval.test ("partial evaluation"): Adapt tests that expect 1+/1- to expect +/-.
This commit is contained in:
parent
e003466039
commit
8f18b71b7a
8 changed files with 30 additions and 88 deletions
|
@ -2382,29 +2382,7 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
|
|||
BINARY_INTEGER_OP (+, scm_sum);
|
||||
}
|
||||
|
||||
/* add1 dst:12 src:12
|
||||
*
|
||||
* Add 1 to the value in SRC, and place the result in DST.
|
||||
*/
|
||||
VM_DEFINE_OP (87, add1, "add1", OP1 (X8_S12_S12) | OP_DST)
|
||||
{
|
||||
ARGS1 (x);
|
||||
|
||||
/* Check for overflow. We must avoid overflow in the signed
|
||||
addition below, even if X is not an inum. */
|
||||
if (SCM_LIKELY ((scm_t_signed_bits) SCM_UNPACK (x) <= INUM_MAX - INUM_STEP))
|
||||
{
|
||||
SCM result;
|
||||
|
||||
/* Add 1 to the integer without untagging. */
|
||||
result = SCM_PACK ((scm_t_signed_bits) SCM_UNPACK (x) + INUM_STEP);
|
||||
|
||||
if (SCM_LIKELY (SCM_I_INUMP (result)))
|
||||
RETURN (result);
|
||||
}
|
||||
|
||||
RETURN_EXP (scm_sum (x, SCM_I_MAKINUM (1)));
|
||||
}
|
||||
VM_DEFINE_OP (87, unused_87, NULL, NOP)
|
||||
|
||||
/* sub dst:8 a:8 b:8
|
||||
*
|
||||
|
@ -2415,29 +2393,7 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
|
|||
BINARY_INTEGER_OP (-, scm_difference);
|
||||
}
|
||||
|
||||
/* sub1 dst:12 src:12
|
||||
*
|
||||
* Subtract 1 from SRC, and place the result in DST.
|
||||
*/
|
||||
VM_DEFINE_OP (89, sub1, "sub1", OP1 (X8_S12_S12) | OP_DST)
|
||||
{
|
||||
ARGS1 (x);
|
||||
|
||||
/* Check for overflow. We must avoid overflow in the signed
|
||||
subtraction below, even if X is not an inum. */
|
||||
if (SCM_LIKELY ((scm_t_signed_bits) SCM_UNPACK (x) >= INUM_MIN + INUM_STEP))
|
||||
{
|
||||
SCM result;
|
||||
|
||||
/* Substract 1 from the integer without untagging. */
|
||||
result = SCM_PACK ((scm_t_signed_bits) SCM_UNPACK (x) - INUM_STEP);
|
||||
|
||||
if (SCM_LIKELY (SCM_I_INUMP (result)))
|
||||
RETURN (result);
|
||||
}
|
||||
|
||||
RETURN_EXP (scm_difference (x, SCM_I_MAKINUM (1)));
|
||||
}
|
||||
VM_DEFINE_OP (89, unused_89, NULL, NOP)
|
||||
|
||||
/* mul dst:8 a:8 b:8
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue