From 92748db384ca663703136c540372b2917515519a Mon Sep 17 00:00:00 2001 From: ram <ram> Date: Thu, 8 Feb 1990 09:21:28 +0000 Subject: [PATCH] Added source transforms for REALPART, IMAGPART, NUMERATOR and DENOMIATOR which call the appropriate subprimitive only if the number is a COMPLEX/RATIO. This simplifies the primitives and allows the type check to be squeezed out in cases where we know the type at compile time. --- compiler/srctran.lisp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/compiler/srctran.lisp b/compiler/srctran.lisp index ea6963d22..019788dd0 100644 --- a/compiler/srctran.lisp +++ b/compiler/srctran.lisp @@ -158,6 +158,28 @@ (def-source-transform ldb-test (bytespec integer) `(not (zerop (ldb ,bytespec ,integer)))) + +;;; With the ratio and complex accessors, we pick off the "identity" case, and +;;; use a primitive to handle the cell access case. +;;; +(macrolet ((frob (fun) + `(def-source-transform ,fun (num) + (once-only ((n-num `(the rational ,num))) + `(if (ratiop ,n-num) + (%primitive ,',fun ,n-num) + ,n-num))))) + (frob numerator) + (frob denominator)) + +(macrolet ((frob (fun) + `(def-source-transform ,fun (num) + (once-only ((n-num num)) + `(if (complexp ,n-num) + (%primitive ,',fun ,n-num) + ,n-num))))) + (frob realpart) + (frob imagpart)) + ;;;; Numeric Derive-Type methods: -- GitLab