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/X8664/x8664-vinsns.lisp

    r8396 r8549  
    5050  (shrq (:$ub 3) (:%q dest)))
    5151
     52;;; same as above, but looks better in bit vector contexts
     53(define-x8664-vinsn scale-1bit-misc-index (((dest :u64))
     54                                            ((idx :imm) ; A fixnum
     55                                             )
     56                                            ())
     57  (movq (:%q idx) (:%q dest))
     58  (shrq (:$ub 3) (:%q dest)))
    5259
    5360(define-x8664-vinsn misc-ref-u64  (((dest :u64))
     
    21422149  (andl (:$l x8664::fixnumone) (:%l bitnum))
    21432150  (movl (:%l bitnum) (:%l dest)))
    2144                                            
     2151
     2152(define-x8664-vinsn nref-bit-vector-fixnum (((dest :imm)
     2153                                             (bitnum :s64))
     2154                                            ((bitnum :s64)
     2155                                             (bitvector :lisp))
     2156                                            ())
     2157  (btq (:%q bitnum) (:@ x8664::misc-data-offset (:%q bitvector)))
     2158  (setb (:%b bitnum))
     2159  (negb (:%b bitnum))
     2160  (andl (:$l x8664::fixnumone) (:%l bitnum))
     2161  (movl (:%l bitnum) (:%l dest)))                                       
    21452162                                                     
    21462163(define-x8664-vinsn misc-ref-c-bit-fixnum (((dest :imm))
     
    27402757                                               (bitnum :u8)))
    27412758  (btsq (:%q bitnum) (:@ x8664::misc-data-offset (:%q vec) (:%q word-index) 8)))
     2759
     2760;;; In safe code, something else has ensured that the value is of type
     2761;;; BIT.
     2762(define-x8664-vinsn nset-variable-bit-to-variable-value (()
     2763                                                        ((vec :lisp)
     2764                                                         (index :s64)
     2765                                                         (value :lisp)))
     2766  (testb (:%b value) (:%b value))
     2767  (je :clr)
     2768  (btsq (:%q index) (:@ x8664::misc-data-offset (:%q vec)))
     2769  (jmp :done)
     2770  :clr
     2771  (btrq (:%q index) (:@ x8664::misc-data-offset (:%q vec)))
     2772  :done)
     2773
     2774(define-x8664-vinsn nset-variable-bit-to-zero (()
     2775                                              ((vec :lisp)
     2776                                               (index :s64)))
     2777  (btrq (:%q index) (:@ x8664::misc-data-offset (:%q vec))))
     2778
     2779(define-x8664-vinsn nset-variable-bit-to-one (()
     2780                                              ((vec :lisp)
     2781                                               (index :s64)))
     2782  (btsq (:%q index) (:@ x8664::misc-data-offset (:%q vec))))
    27422783
    27432784(define-x8664-vinsn set-constant-bit-to-zero (()
Note: See TracChangeset for help on using the changeset viewer.