Changeset 14336
- Timestamp:
- Oct 7, 2010, 10:49:35 AM (14 years ago)
- File:
-
- 1 edited
-
trunk/source/compiler/nx2.lisp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/compiler/nx2.lisp
r13249 r14336 272 272 (64 (arch::target-max-64-bit-constant-index arch))))))) 273 273 (and limit (< idx limit))))) 274 275 (defun backend-use-operator (op seg vreg xfer &rest forms) 276 (declare (dynamic-extent forms)) 277 (apply (svref (backend-p2-dispatch *target-backend*) 278 (%ilogand op operator-id-mask)) 279 seg vreg xfer forms)) 280 281 ;;; Return non-nil iff we can do something better than a subprim call 282 ;;; to .SPbuiltin-ash. 283 (defun acode-optimize-ash (seg vreg xfer num amt trust-decls &optional (result-type 'integer)) 284 (let* ((unsigned-natural-type (target-word-size-case 285 (32 '(unsigned-byte 32)) 286 (64 '(unsigned-byte 64)))) 287 (target-fixnum-type (target-word-size-case 288 (32 '(signed-byte 30)) 289 (64 '(signed-byte 61)))) 290 (max (target-word-size-case (32 32) (64 64))) 291 (maxbits (target-word-size-case 292 (32 29) 293 (64 60))) 294 (const-num (acode-integer-form-p num)) 295 (const-amt (acode-integer-form-p amt)) 296 (shifted (and const-num const-amt (ash const-num const-amt)))) 297 (cond (shifted 298 (if (nx1-target-fixnump shifted) 299 (backend-use-operator (%nx1-operator fixnum) seg vreg xfer shifted) 300 (backend-use-operator (%nx1-operator immediate) seg vreg xfer shifted)) 301 t) 302 ((eql const-amt 0) 303 (backend-use-operator (%nx1-operator require-integer) seg vreg xfer num) 304 t) 305 ((and (fixnump const-amt) (< const-amt 0)) 306 (if (acode-form-typep num target-fixnum-type trust-decls) 307 (progn 308 (backend-use-operator (%nx1-operator %iasr) 309 seg 310 vreg 311 xfer 312 (make-acode (%nx1-operator fixnum) 313 (- const-amt)) 314 num) 315 t) 316 (if (acode-form-typep num unsigned-natural-type trust-decls) 317 (progn 318 (if (< (- const-amt) max) 319 (backend-use-operator (%nx1-operator natural-shift-right) 320 seg 321 vreg 322 xfer 323 num 324 (make-acode (%nx1-operator fixnum) 325 (- const-amt))) 326 (progn 327 (backend-use-operator (%nx1-operator require-fixnum) 328 seg 329 nil 330 nil 331 num) 332 (backend-use-operator (%nx1-operator fixnum) 333 seg 334 vreg 335 xfer 336 0))) 337 t)))) 338 ((and (fixnump const-amt) 339 (<= 0 const-amt maxbits) 340 (or (acode-form-typep num `(signed-byte ,(- (1+ maxbits) const-amt)) trust-decls) 341 (and (acode-form-typep num 'fixnum trust-decls) 342 trust-decls 343 (subtypep result-type 'fixnum)))) 344 (progn 345 (backend-use-operator (%nx1-operator %ilsl) 346 seg 347 vreg 348 xfer 349 (make-acode (%nx1-operator fixnum) 350 const-amt) 351 num) 352 t)) 353 ((and (fixnump const-amt) 354 (< 0 const-amt max) 355 (acode-form-typep num unsigned-natural-type trust-decls) 356 trust-decls 357 (subtypep result-type unsigned-natural-type)) 358 (backend-use-operator (%nx1-operator natural-shift-left) 359 seg 360 vreg 361 xfer 362 num 363 amt) 364 t) 365 ((typep const-num target-fixnum-type) 366 (let* ((field-width (1+ (integer-length const-num))) 367 ;; num fits in a `(signed-byte ,field-width) 368 (max-shift (- (1+ maxbits) field-width))) 369 (when (acode-form-typep amt `(mod ,(1+ max-shift)) trust-decls) 370 (backend-use-operator (%nx1-operator %ilsl) 371 seg 372 vreg 373 xfer 374 amt 375 (make-acode (%nx1-operator fixnum) 376 const-num)) 377 t))) 378 (t nil)))) 379 380 381 382
Note:
See TracChangeset
for help on using the changeset viewer.
