@@ -38,6 +38,11 @@ class Intrinsifier {
3838 '<=' : (b) => b.i64_le_s (),
3939 '>' : (b) => b.i64_gt_s (),
4040 '>=' : (b) => b.i64_ge_s (),
41+ '_div_s' : (b) => b.i64_div_s (),
42+ '_shl' : (b) => b.i64_shl (),
43+ '_shr_s' : (b) => b.i64_shr_s (),
44+ '_shr_u' : (b) => b.i64_shr_u (),
45+ '_lt_u' : (b) => b.i64_lt_u (),
4146 }
4247 },
4348 doubleType: {
@@ -81,13 +86,17 @@ class Intrinsifier {
8186 'truncateToDouble' : (b) {
8287 b.f64_trunc ();
8388 },
89+ '_toInt' : (b) {
90+ b.i64_trunc_sat_f64_s ();
91+ },
8492 },
8593 };
8694 static final Map <String , w.ValueType > unaryResultMap = {
8795 'toDouble' : w.NumType .f64,
8896 'floorToDouble' : w.NumType .f64,
8997 'ceilToDouble' : w.NumType .f64,
9098 'truncateToDouble' : w.NumType .f64,
99+ '_toInt' : w.NumType .i64,
91100 };
92101
93102 Translator get translator => codeGen.translator;
@@ -100,7 +109,7 @@ class Intrinsifier {
100109 }
101110
102111 static bool isComparison (String op) =>
103- op == '<' || op == '<=' || op == '>' || op == '>=' ;
112+ op == '<' || op == '<=' || op == '>' || op == '>=' || op == '_lt_u' ;
104113
105114 Intrinsifier (this .codeGen);
106115
@@ -715,58 +724,6 @@ class Intrinsifier {
715724 codeGen.wrap (typeArguments, translator.types.typeListExpectedType);
716725 b.struct_new (info.struct);
717726 return info.nonNullableType;
718- case "_div_s" :
719- assert (cls == translator.boxedIntClass);
720- assert (node.arguments.positional.length == 2 );
721- Expression first = node.arguments.positional[0 ];
722- Expression second = node.arguments.positional[1 ];
723- codeGen.wrap (first, w.NumType .i64);
724- codeGen.wrap (second, w.NumType .i64);
725- b.i64_div_s ();
726- return w.NumType .i64;
727- case "_shl" :
728- assert (cls == translator.boxedIntClass);
729- assert (node.arguments.positional.length == 2 );
730- Expression first = node.arguments.positional[0 ];
731- Expression second = node.arguments.positional[1 ];
732- codeGen.wrap (first, w.NumType .i64);
733- codeGen.wrap (second, w.NumType .i64);
734- b.i64_shl ();
735- return w.NumType .i64;
736- case "_shr_s" :
737- assert (cls == translator.boxedIntClass);
738- assert (node.arguments.positional.length == 2 );
739- Expression first = node.arguments.positional[0 ];
740- Expression second = node.arguments.positional[1 ];
741- codeGen.wrap (first, w.NumType .i64);
742- codeGen.wrap (second, w.NumType .i64);
743- b.i64_shr_s ();
744- return w.NumType .i64;
745- case "_shr_u" :
746- assert (cls == translator.boxedIntClass);
747- assert (node.arguments.positional.length == 2 );
748- Expression first = node.arguments.positional[0 ];
749- Expression second = node.arguments.positional[1 ];
750- codeGen.wrap (first, w.NumType .i64);
751- codeGen.wrap (second, w.NumType .i64);
752- b.i64_shr_u ();
753- return w.NumType .i64;
754- case "_lt_u" :
755- assert (cls == translator.boxedIntClass);
756- assert (node.arguments.positional.length == 2 );
757- Expression first = node.arguments.positional[0 ];
758- Expression second = node.arguments.positional[1 ];
759- codeGen.wrap (first, w.NumType .i64);
760- codeGen.wrap (second, w.NumType .i64);
761- b.i64_lt_u ();
762- return w.NumType .i32; // bool
763- case "_toInt" :
764- assert (cls == translator.boxedDoubleClass);
765- assert (node.arguments.positional.length == 1 );
766- Expression arg = node.arguments.positional[0 ];
767- codeGen.wrap (arg, w.NumType .f64);
768- b.i64_trunc_sat_f64_s ();
769- return w.NumType .i64;
770727 }
771728 }
772729
0 commit comments