1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-18 01:30:27 +02:00

logsub is intrinsic

* libguile/intrinsics.h:
* libguile/intrinsics.c (logsub): New intrinsic.
  (scm_bootstrap_intrinsics): Init new intrinsic.
* libguile/vm-engine.c (logsub): Disable.
* module/language/cps/reify-primitives.scm (compute-known-primitives):
  Add logsub.
* module/system/vm/assembler.scm: Update logsub intrinsic assembler.
This commit is contained in:
Andy Wingo 2018-04-12 17:10:35 +02:00
parent b2c01e5b58
commit 25a0fe8839
5 changed files with 22 additions and 6 deletions

View file

@ -80,6 +80,22 @@ scm_to_uint64_truncate (SCM x)
return scm_to_uint64 (scm_logand (x, scm_from_uint64 ((scm_t_uint64) -1)));
}
static SCM
logsub (SCM x, SCM y)
{
if (SCM_I_INUMP (x) && SCM_I_INUMP (y))
{
scm_t_signed_bits a, b;
a = SCM_I_INUM (x);
b = SCM_I_INUM (y);
return SCM_I_MAKINUM (a & ~b);
}
return scm_logand (x, scm_lognot (y));
}
void
scm_bootstrap_intrinsics (void)
{
@ -106,6 +122,7 @@ scm_bootstrap_intrinsics (void)
scm_vm_intrinsics.scm_to_s64 = scm_to_int64;
scm_vm_intrinsics.u64_to_scm = scm_from_uint64;
scm_vm_intrinsics.s64_to_scm = scm_from_int64;
scm_vm_intrinsics.logsub = logsub;
scm_c_register_extension ("libguile-" SCM_EFFECTIVE_VERSION,
"scm_init_intrinsics",

View file

@ -57,6 +57,7 @@ typedef SCM (*scm_t_scm_from_s64_intrinsic) (scm_t_int64);
M(s64_from_scm, scm_to_s64, "scm->s64", SCM_TO_S64) \
M(scm_from_u64, u64_to_scm, "u64->scm", U64_TO_SCM) \
M(scm_from_s64, s64_to_scm, "s64->scm", S64_TO_SCM) \
M(scm_from_scm_scm, logsub, "logsub", LOGSUB) \
/* Add new intrinsics here; also update scm_bootstrap_intrinsics. */
enum scm_vm_intrinsic

View file

@ -2564,11 +2564,7 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
NEXT (1);
}
/* logsub dst:8 a:8 b:8
*
* Place the bitwise AND of A and the bitwise NOT of B into DST.
*/
VM_DEFINE_OP (161, logsub, "logsub", OP1 (X8_S8_S8_S8) | OP_DST)
VM_DEFINE_OP (161, unused_161, NULL, NOP)
{
ARGS2 (x, y);