Skip constant-folding MD primitives when cross-compiling.
authorTaylor R Campbell <campbell@mumble.net>
Wed, 12 Dec 2018 20:18:39 +0000 (20:18 +0000)
committerTaylor R Campbell <campbell@mumble.net>
Wed, 12 Dec 2018 22:06:31 +0000 (22:06 +0000)
src/compiler/base/utils.scm

index 7239f9600f2a04ddecefada946cc8972c131c3f0..1fb10147f84849f32a1ee262b41ee46349a5269d 100644 (file)
@@ -469,6 +469,19 @@ USA.
        (ucode-primitive weak-car 1)
        (ucode-primitive weak-cdr 1)))
 \f
+;; These primitives vary from machine to machine in the microcode.  We
+;; could emulate them based on the system characteristics, but for now
+;; it will be easier to just avoid constant-folding them.
+;;
+;; XXX If we ever transition to a system where flonums are not IEEE 754
+;; binary64 floating-point, we'll have to list all the flonum
+;; primitives here too.
+
+(define machine-dependent-primitives
+  (list (ucode-primitive primitive-object-ref 2)
+       (ucode-primitive system-vector-ref 2)
+       (ucode-primitive system-vector-size 1)))
+\f
 ;;;; "Foldable" and side-effect-free operators
 
 (define boolean-valued-function-variables)
@@ -521,8 +534,10 @@ USA.
 (define-integrable (boolean-valued-function-primitive? operator)
   (memq operator boolean-valued-function-primitives))
 
-(define-integrable (constant-foldable-primitive? operator)
-  (memq operator function-primitives))
+(define (constant-foldable-primitive? operator)
+  (and (memq operator function-primitives)
+       (or (not compiler:cross-compiling?))
+       (not (memq operator machine-dependent-primitives))))
 
 (define-integrable (side-effect-free-primitive? operator)
   (memq operator side-effect-free-primitives))