@@ -410,7 +410,14 @@ my class MASTCompilerInstance {
410
410
$ grow . result_reg);
411
411
$ il := $ grow . instructions;
412
412
push_ilist($ il , $ box );
413
- $ * REGALLOC . release_register($ grow . result_reg, $ MVM_reg_num64 );
413
+ $ reg := $ box . result_reg;
414
+ }
415
+ elsif $ got == $ MVM_reg_int32 || $ got == $ MVM_reg_int16 || $ got == $ MVM_reg_int8 {
416
+ my $ grow := self . coercion($ res , $ MVM_reg_int64 );
417
+ my $ box := QAST ::MASTOperations. box(self , $ ! hll , $ MVM_reg_int64 ,
418
+ $ grow . result_reg);
419
+ $ il := $ grow . instructions;
420
+ push_ilist($ il , $ box );
414
421
$ reg := $ box . result_reg;
415
422
}
416
423
else {
@@ -429,6 +436,13 @@ my class MASTCompilerInstance {
429
436
push_ilist($ il , $ shrink );
430
437
$ reg := $ shrink . result_reg;
431
438
}
439
+ elsif $ desired == $ MVM_reg_int32 || $ desired == $ MVM_reg_int16 || $ desired == $ MVM_reg_int8 {
440
+ my $ unbox := QAST ::MASTOperations. unbox(self , $ ! hll , $ MVM_reg_int64 , $ reg );
441
+ my $ shrink := self . coercion($ unbox , $ desired );
442
+ $ il := $ unbox . instructions;
443
+ push_ilist($ il , $ shrink );
444
+ $ reg := $ shrink . result_reg;
445
+ }
432
446
else {
433
447
nqp ::die(" Unknown unboxing case; desired: " ~ $ desired );
434
448
}
@@ -445,6 +459,15 @@ my class MASTCompilerInstance {
445
459
elsif $ got == $ MVM_reg_void {
446
460
push_op($ il , ' const_i64' , $ res_reg , MAST::IVal. new ( : value(0 ) ));
447
461
}
462
+ elsif $ got == $ MVM_reg_int32 {
463
+ push_op($ il , ' extend_i32' , $ res_reg , $ reg );
464
+ }
465
+ elsif $ got == $ MVM_reg_int16 {
466
+ push_op($ il , ' extend_i16' , $ res_reg , $ reg );
467
+ }
468
+ elsif $ got == $ MVM_reg_int8 {
469
+ push_op($ il , ' extend_i8' , $ res_reg , $ reg );
470
+ }
448
471
else {
449
472
nqp ::die(" Unknown coercion case for int; got: " ~ $ got );
450
473
}
@@ -488,6 +511,30 @@ my class MASTCompilerInstance {
488
511
nqp ::die(" Unknown coercion case for num32; got: " ~ $ got );
489
512
}
490
513
}
514
+ elsif $ desired == $ MVM_reg_int32 {
515
+ if $ got == $ MVM_reg_int64 {
516
+ push_op($ il , ' trunc_i32' , $ res_reg , $ reg );
517
+ }
518
+ else {
519
+ nqp ::die(" Unknown coercion case for int32; got: " ~ $ got );
520
+ }
521
+ }
522
+ elsif $ desired == $ MVM_reg_int16 {
523
+ if $ got == $ MVM_reg_int64 {
524
+ push_op($ il , ' trunc_i16' , $ res_reg , $ reg );
525
+ }
526
+ else {
527
+ nqp ::die(" Unknown coercion case for int16; got: " ~ $ got );
528
+ }
529
+ }
530
+ elsif $ desired == $ MVM_reg_int8 {
531
+ if $ got == $ MVM_reg_int64 {
532
+ push_op($ il , ' trunc_i8' , $ res_reg , $ reg );
533
+ }
534
+ else {
535
+ nqp ::die(" Unknown coercion case for int8; got: " ~ $ got );
536
+ }
537
+ }
491
538
else {
492
539
nqp ::die(" Coercion from type '$ got ' to '$ desired ' NYI" );
493
540
}
0 commit comments