|
223 | 223 | (rule (lower (has_type $I32 (imul a b))) (pulley_xmul32 a b))
|
224 | 224 | (rule (lower (has_type $I64 (imul a b))) (pulley_xmul64 a b))
|
225 | 225 |
|
| 226 | +(rule 1 (lower (has_type (ty_int (fits_in_32 _)) (imul a (i32_from_iconst b)))) |
| 227 | + (pulley_xmul32_s32 a b)) |
| 228 | +(rule 2 (lower (has_type $I64 (imul a (i32_from_iconst b)))) |
| 229 | + (pulley_xmul64_s32 a b)) |
| 230 | +(rule 3 (lower (has_type (ty_int (fits_in_32 _)) (imul a (i8_from_iconst b)))) |
| 231 | + (pulley_xmul32_s8 a b)) |
| 232 | +(rule 4 (lower (has_type $I64 (imul a (i8_from_iconst b)))) |
| 233 | + (pulley_xmul64_s8 a b)) |
| 234 | + |
226 | 235 | (rule (lower (has_type $I8X16 (imul a b))) (pulley_vmuli8x16 a b))
|
227 | 236 | (rule (lower (has_type $I16X8 (imul a b))) (pulley_vmuli16x8 a b))
|
228 | 237 | (rule (lower (has_type $I32X4 (imul a b))) (pulley_vmuli32x4 a b))
|
|
294 | 303 | (rule (lower (has_type $I64 (ishl a b)))
|
295 | 304 | (pulley_xshl64 a b))
|
296 | 305 |
|
| 306 | +;; Special-case constant shift amounts. |
| 307 | +(rule 1 (lower (has_type $I32 (ishl a b))) |
| 308 | + (if-let n (u6_shift_from_iconst b)) |
| 309 | + (pulley_xshl32_u6 a n)) |
| 310 | +(rule 1 (lower (has_type $I64 (ishl a b))) |
| 311 | + (if-let n (u6_shift_from_iconst b)) |
| 312 | + (pulley_xshl64_u6 a n)) |
| 313 | + |
| 314 | +;; vector shifts |
| 315 | + |
297 | 316 | (rule (lower (has_type $I8X16 (ishl a b))) (pulley_vshli8x16 a b))
|
298 | 317 | (rule (lower (has_type $I16X8 (ishl a b))) (pulley_vshli16x8 a b))
|
299 | 318 | (rule (lower (has_type $I32X4 (ishl a b))) (pulley_vshli32x4 a b))
|
300 | 319 | (rule (lower (has_type $I64X2 (ishl a b))) (pulley_vshli64x2 a b))
|
301 | 320 |
|
| 321 | +;; Helper to extract a constant from `Value`, mask it to 6 bits, and then make a |
| 322 | +;; `U6`. |
| 323 | +(decl pure partial u6_shift_from_iconst (Value) U6) |
| 324 | +(rule (u6_shift_from_iconst (u64_from_iconst val)) |
| 325 | + (if-let (u6_from_u8 x) (u64_as_u8 (u64_and val 0x3f))) |
| 326 | + x) |
| 327 | + |
| 328 | +(decl u6_from_u8 (U6) u8) |
| 329 | +(extern extractor u6_from_u8 u6_from_u8) |
| 330 | + |
302 | 331 | ;;;; Rules for `ushr` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
303 | 332 |
|
304 | 333 | (rule (lower (has_type $I8 (ushr a b)))
|
|
313 | 342 | (rule (lower (has_type $I64 (ushr a b)))
|
314 | 343 | (pulley_xshr64_u a b))
|
315 | 344 |
|
| 345 | +;; Special-case constant shift amounts. |
| 346 | +(rule 1 (lower (has_type $I32 (ushr a b))) |
| 347 | + (if-let n (u6_shift_from_iconst b)) |
| 348 | + (pulley_xshr32_u_u6 a n)) |
| 349 | +(rule 1 (lower (has_type $I64 (ushr a b))) |
| 350 | + (if-let n (u6_shift_from_iconst b)) |
| 351 | + (pulley_xshr64_u_u6 a n)) |
| 352 | + |
| 353 | +;; vector shifts |
| 354 | + |
316 | 355 | (rule (lower (has_type $I8X16 (ushr a b))) (pulley_vshri8x16_u a b))
|
317 | 356 | (rule (lower (has_type $I16X8 (ushr a b))) (pulley_vshri16x8_u a b))
|
318 | 357 | (rule (lower (has_type $I32X4 (ushr a b))) (pulley_vshri32x4_u a b))
|
|
332 | 371 | (rule (lower (has_type $I64 (sshr a b)))
|
333 | 372 | (pulley_xshr64_s a b))
|
334 | 373 |
|
| 374 | +;; Special-case constant shift amounts. |
| 375 | +(rule 1 (lower (has_type $I32 (sshr a b))) |
| 376 | + (if-let n (u6_shift_from_iconst b)) |
| 377 | + (pulley_xshr32_s_u6 a n)) |
| 378 | +(rule 1 (lower (has_type $I64 (sshr a b))) |
| 379 | + (if-let n (u6_shift_from_iconst b)) |
| 380 | + (pulley_xshr64_s_u6 a n)) |
| 381 | + |
| 382 | +;; vector shifts |
| 383 | + |
335 | 384 | (rule (lower (has_type $I8X16 (sshr a b))) (pulley_vshri8x16_s a b))
|
336 | 385 | (rule (lower (has_type $I16X8 (sshr a b))) (pulley_vshri16x8_s a b))
|
337 | 386 | (rule (lower (has_type $I32X4 (sshr a b))) (pulley_vshri32x4_s a b))
|
338 | 387 | (rule (lower (has_type $I64X2 (sshr a b))) (pulley_vshri64x2_s a b))
|
339 | 388 |
|
340 | 389 | ;;;; Rules for `band` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
341 | 390 |
|
342 |
| -(rule 0 (lower (has_type (fits_in_32 _) (band a b))) |
343 |
| - (pulley_xband32 a b)) |
| 391 | +(rule 0 (lower (has_type (fits_in_32 _) (band a b))) (pulley_xband32 a b)) |
| 392 | +(rule 1 (lower (has_type $I64 (band a b))) (pulley_xband64 a b)) |
344 | 393 |
|
345 |
| -(rule 1 (lower (has_type $I64 (band a b))) |
346 |
| - (pulley_xband64 a b)) |
| 394 | +(rule 3 (lower (has_type (ty_int (fits_in_32 _)) (band a (i32_from_iconst b)))) |
| 395 | + (pulley_xband32_s32 a b)) |
| 396 | +(rule 4 (lower (has_type $I64 (band a (i32_from_iconst b)))) |
| 397 | + (pulley_xband64_s32 a b)) |
| 398 | +(rule 5 (lower (has_type (ty_int (fits_in_32 _)) (band a (i8_from_iconst b)))) |
| 399 | + (pulley_xband32_s8 a b)) |
| 400 | +(rule 6 (lower (has_type $I64 (band a (i8_from_iconst b)))) |
| 401 | + (pulley_xband64_s8 a b)) |
347 | 402 |
|
348 | 403 | (rule 2 (lower (has_type (ty_vec128 _) (band a b)))
|
349 | 404 | (pulley_vband128 a b))
|
350 | 405 |
|
351 | 406 | ;;;; Rules for `bor` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
352 | 407 |
|
353 |
| -(rule 0 (lower (has_type (fits_in_32 _) (bor a b))) |
354 |
| - (pulley_xbor32 a b)) |
| 408 | +(rule 0 (lower (has_type (fits_in_32 _) (bor a b))) (pulley_xbor32 a b)) |
| 409 | +(rule 1 (lower (has_type $I64 (bor a b))) (pulley_xbor64 a b)) |
355 | 410 |
|
356 |
| -(rule 1 (lower (has_type $I64 (bor a b))) |
357 |
| - (pulley_xbor64 a b)) |
| 411 | +(rule 3 (lower (has_type (ty_int (fits_in_32 _)) (bor a (i32_from_iconst b)))) |
| 412 | + (pulley_xbor32_s32 a b)) |
| 413 | +(rule 4 (lower (has_type $I64 (bor a (i32_from_iconst b)))) |
| 414 | + (pulley_xbor64_s32 a b)) |
| 415 | +(rule 5 (lower (has_type (ty_int (fits_in_32 _)) (bor a (i8_from_iconst b)))) |
| 416 | + (pulley_xbor32_s8 a b)) |
| 417 | +(rule 6 (lower (has_type $I64 (bor a (i8_from_iconst b)))) |
| 418 | + (pulley_xbor64_s8 a b)) |
358 | 419 |
|
359 | 420 | (rule 2 (lower (has_type (ty_vec128 _) (bor a b)))
|
360 | 421 | (pulley_vbor128 a b))
|
361 | 422 |
|
362 | 423 | ;;;; Rules for `bxor` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
363 | 424 |
|
364 |
| -(rule 0 (lower (has_type (fits_in_32 _) (bxor a b))) |
365 |
| - (pulley_xbxor32 a b)) |
366 |
| - |
367 |
| -(rule 1 (lower (has_type $I64 (bxor a b))) |
368 |
| - (pulley_xbxor64 a b)) |
| 425 | +(rule 0 (lower (has_type (fits_in_32 _) (bxor a b))) (pulley_xbxor32 a b)) |
| 426 | +(rule 1 (lower (has_type $I64 (bxor a b))) (pulley_xbxor64 a b)) |
| 427 | + |
| 428 | +(rule 3 (lower (has_type (ty_int (fits_in_32 _)) (bxor a (i32_from_iconst b)))) |
| 429 | + (pulley_xbxor32_s32 a b)) |
| 430 | +(rule 4 (lower (has_type $I64 (bxor a (i32_from_iconst b)))) |
| 431 | + (pulley_xbxor64_s32 a b)) |
| 432 | +(rule 5 (lower (has_type (ty_int (fits_in_32 _)) (bxor a (i8_from_iconst b)))) |
| 433 | + (pulley_xbxor32_s8 a b)) |
| 434 | +(rule 6 (lower (has_type $I64 (bxor a (i8_from_iconst b)))) |
| 435 | + (pulley_xbxor64_s8 a b)) |
369 | 436 |
|
370 | 437 | (rule 2 (lower (has_type (ty_vec128 _) (bxor a b)))
|
371 | 438 | (pulley_vbxor128 a b))
|
|
0 commit comments