Ignore:
Timestamp:
Feb 21, 2008, 5:06:20 PM (13 years ago)
Author:
rme
Message:

Make compiler use CISC-y get/set/test bit instructions when
referencing/setting bits in a bit vector.

In order to avoid minor bootstrapping problems, define a few new
bit referencing and bit testing vinsns with an "n" prefix, leaving
the old ones around for now.

The x86 BT/BTS/BTR instructions take two operands: a bit base and
bit offset. When the bit base is a memory location, the bit offset
(in a register) is a signed 16/32/64 bit quantity (depending on
operand size). There's no need to limit the bit offset to
(1- TARGET::NBITS-IN-WORD).

This is shorter and removes the need to use a register for a word index.
(The register saving is no big deal on x86-64, but it matters a lot on
32-bit x86.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/compiler/X86/x862.lisp

    r8461 r8549  
    16001600             (if (and index-known-fixnum (<= index-known-fixnum (arch::target-max-1-bit-constant-index arch)))
    16011601               (! misc-ref-c-bit-fixnum target src index-known-fixnum)
    1602                (with-imm-temps
    1603                    () (word-index bitnum)
    1604                  (if index-known-fixnum
    1605                    (progn
    1606                      (x862-lri seg word-index (+ (arch::target-misc-data-offset arch) (ash index-known-fixnum -6)))
    1607                      (x862-lri seg bitnum (logand index-known-fixnum #x63)))
    1608                    (! word-index-and-bitnum-from-index word-index bitnum unscaled-idx))
    1609                  (! ref-bit-vector-fixnum target bitnum src word-index))))))))
     1602               (with-imm-target () bitnum
     1603                 (if index-known-fixnum
     1604                   (x862-lri seg bitnum index-known-fixnum)
     1605                   (! scale-1bit-misc-index bitnum unscaled-idx))
     1606                 (! nref-bit-vector-fixnum target bitnum src))))))))
    16101607    (^)))
    16111608
     
    22652262                      (progn
    22662263                        (! set-constant-bit-to-variable-value src index-known-fixnum val-reg)))
    2267                     (with-imm-temps () (word-index bit-number)
    2268                       (if index-known-fixnum
    2269                         (progn
    2270                           (x862-lri seg word-index (+ (arch::target-misc-data-offset arch) (ash index-known-fixnum -6)))
    2271                           (x862-lri seg bit-number (logand index-known-fixnum #x63)))
    2272                         (! word-index-and-bitnum-from-index word-index bit-number unscaled-idx))
    2273                       (if constval
    2274                         (if (zerop constval)
    2275                           (! set-variable-bit-to-zero src word-index bit-number)
    2276                           (! set-variable-bit-to-one src word-index bit-number))
    2277                         (progn
    2278                           (! set-variable-bit-to-variable-value src word-index bit-number val-reg))))))))))
     2264                    (progn
     2265                      (if index-known-fixnum
     2266                        (x862-lri seg scaled-idx index-known-fixnum)
     2267                        (! scale-1bit-misc-index scaled-idx unscaled-idx))
     2268                      (if constval
     2269                        (if (zerop constval)
     2270                          (! nset-variable-bit-to-zero src scaled-idx)
     2271                          (! nset-variable-bit-to-one src scaled-idx))
     2272                        (progn
     2273                          (! nset-variable-bit-to-variable-value src scaled-idx val-reg))))))))))
    22792274      (when (and vreg val-reg) (<- val-reg))
    22802275      (^))))
Note: See TracChangeset for help on using the changeset viewer.