Changeset 11636


Ignore:
Timestamp:
02/06/09 23:01:59 (15 years ago)
Author:
ehuelsmann
Message:

Generalize code generation paths for :INT/:LONG representations in P2-MIN/MAX into 1 path.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/compiler-pass2.lisp

    r11634 r11636  
    31943194
    31953195
     3196(defun emit-numeric-comparison (op representation false-LABEL)
     3197  (let* ((pos (position op comparison-ops))
     3198         (ops-table (cdr (assoc representation comparison-ins)))
     3199         (ops (aref ops-table pos)))
     3200    (if (listp ops)
     3201        (progn
     3202          (emit (car ops))
     3203          (emit (cadr ops) false-LABEL))
     3204        (emit ops false-LABEL))))
     3205
    31963206;; Note that /= is not transitive, so we don't handle it here.
    31973207(defknown p2-numeric-comparison (t t t) t)
     
    32213231                          arg1 'stack common-rep
    32223232                          arg2 'stack common-rep)
    3223                   (let* ((pos (position op comparison-ops))
    3224                          (ops-table (cdr (assoc common-rep comparison-ins)))
    3225                          (ops (aref ops-table pos)))
    3226                     (if (listp ops)
    3227                         (progn
    3228                           (emit (car ops))
    3229                           (emit (cadr ops) LABEL1))
    3230                         (emit ops LABEL1)))
     3233                  (emit-numeric-comparison op common-rep LABEL1)
    32313234                  (emit-push-true representation)
    32323235                  (emit 'goto LABEL2)
     
    67576760         (let ((type1 (derive-compiler-type arg1))
    67586761               (type2 (derive-compiler-type arg2)))
    6759            (cond ((and (fixnum-type-p type1) (fixnum-type-p type2))
    6760                   (compile-form arg1 'stack :int)
    6761                   (emit 'dup)
    6762                   (compile-form arg2 'stack :int)
    6763                   (emit 'dup_x1)
    6764                   (let ((LABEL1 (gensym)))
    6765                     (emit (if (eq op 'max) 'if_icmpge 'if_icmple) LABEL1)
    6766                     (emit 'swap)  ;; The lower stack value is greater-or-equal
     6762           (cond ((and (java-long-type-p type1) (java-long-type-p type2))
     6763                  (let ((common-rep (if (and (fixnum-type-p type1)
     6764                                             (fixnum-type-p type2))
     6765                                        :int :long))
     6766                        (LABEL1 (gensym)))
     6767                    (compile-form arg1 'stack common-rep)
     6768                    (emit-dup common-rep)
     6769                    (compile-form arg2 'stack common-rep)
     6770                    (emit (if (eq common-rep :long)
     6771                              'dup2_x2 'dup_x1))
     6772                    (emit-numeric-comparison (if (eq op 'max) '<= '>=)
     6773                                             common-rep LABEL1)
     6774                    (emit-swap common-rep common-rep)
    67676775                    (label LABEL1)
    6768                     (emit 'pop))  ;; Throw away the lower stack value
    6769                   (convert-representation :int representation)
    6770                   (emit-move-from-stack target representation))
    6771                  ((and (java-long-type-p type1) (java-long-type-p type2))
    6772                   (compile-form arg1 'stack :long)
    6773                   (emit 'dup2)
    6774                   (compile-form arg2 'stack :long)
    6775                   (emit 'dup2_x2)
    6776                   (emit 'lcmp)
    6777                   (let ((LABEL1 (gensym)))
    6778                     (emit (if (eq op 'max) 'ifge 'ifle) LABEL1)
    6779                     (emit 'dup2_x2) ;; pour-mans swap2
    6780                     (emit 'pop2)
    6781                     (label LABEL1)
    6782                     (emit 'pop2))
    6783                   (convert-representation :long representation)
    6784                   (emit-move-from-stack target representation))
     6776                    (emit-move-from-stack nil common-rep)
     6777                    (convert-representation common-rep representation)
     6778                    (emit-move-from-stack target representation)))
    67856779                 (t
    67866780                  (compile-form arg1 'stack nil)
Note: See TracChangeset for help on using the changeset viewer.