))
)
-
; Compute population counts for each bit. Return it as a vector indexed by bit number.
; Rather than computing raw popularity, attempt to compute "disinguishing value" or
; inverse-entropy for each bit. The idea is that the larger the number for any particular
; bit slot, the more instructions it can be used to distinguish. Raw mask popularity
; is not enough -- popular masks may include useless "reserved" fields whose values
; don't change, and thus are useless in distinguishing.
+
(define (-distinguishing-bit-population masks mask-lens values lsb0?)
(let* ((max-length (apply max mask-lens))
(0-population (make-vector max-length 0))
(vector->list 0-population) (vector->list 1-population))))
)
-
; Return a list (0 ... limit-1)
+
(define (-range limit)
(let loop ((i 0)
(indices (list)))
)
; Return a list (base ... base+size-1)
+
(define (-range2 base size)
(let loop ((i base)
(indices (list)))
(if (= i (+ base size)) (reverse indices) (loop (+ i 1) (cons i indices))))
)
+; Return a copy of given vector, with all entries with given indices set
+; to `value'
-; Return a copy of given vector, with all entries with given indices set to `value'
(define (-vector-copy-set-all vector indices value)
(let ((new-vector (make-vector (vector-length vector))))
(for-each (lambda (index)
new-vector)
)
-
-; Return a list of indices whose counts in the given vector exceed the given threshold.
+; Return a list of indices whose counts in the given vector exceed the given
+; threshold.
; Sort them in decreasing order of populatority.
+
(define (-population-above-threshold population threshold)
(let* ((unsorted
(find (lambda (index) (if (vector-ref population index)
sorted)
)
-
; Return the top few most popular indices in the population vector,
; ignoring any that are already used (marked by #f). Don't exceed
; `size' unless the clustering is just too good to pass up.
+
(define (-population-top-few population size)
(let loop ((old-picks (list))
(remaining-population population)
(* 0.75 count-threshold))))))
)
-
-
; Given list of insns, return list of bit numbers of constant bits in opcode
; that they all share (or mostly share), up to MAX elements.
; ALREADY-USED is a list of bitnums we can't use.
sorted-indices)
)
-
(define (OLDdecode-get-best-bits insn-list already-used startbit max decode-bitsize lsb0?)
(let ((masks (map insn-base-mask insn-list))
; ??? We assume mask lengths are repeatedly used for insns longer
; build the first decode table. If nil, we compute 8 bits of it (FIXME)
; ourselves.
; LSB0? is non-#f if bit number 0 is the least significant bit.
-; FIXME: Need to be perfect for every subtable, or allow target more control.
-; Leave for later (and don't give target more control until oodles of effort
-; have been spent trying to be perfect! ... or close enough).
(define (-gen-decode-fn insn-list initial-bitnums lsb0?)
(assert (with-scache?))
; 0 is passed for the start bit (it is independent of lsb0?)
(if (null? initial-bitnums)
(set! initial-bitnums
- (if (= 0 (length insn-list)) (list 0) ; dummy value
+ (if (= 0 (length insn-list))
+ (list 0) ; dummy value
(decode-get-best-bits insn-list nil
0 ; startbit
8 ; max
; build the first decode table. If nil, we compute 8 bits of it (FIXME)
; ourselves.
; LSB0? is non-#f if bit number 0 is the least significant bit.
-; FIXME: Need to be perfect for every subtable, or allow target more control.
-; Leave for later (and don't give target more control until oodles of effort
-; have been spent trying to be perfect! ... or close enough).
(define (-gen-decode-fn insn-list initial-bitnums lsb0?)