@@ -598,7 +598,25 @@ op_with_overflow_inner (Context *ctx, TyTy::FnType *fntype, tree_code op)
598
598
if (!ctx->get_backend ()->function_set_parameters (fndecl, param_vars))
599
599
return error_mark_node;
600
600
601
- enter_intrinsic_block (ctx, fndecl);
601
+ rust_assert (fntype->get_num_substitutions () == 1 );
602
+ auto ¶m_mapping = fntype->get_substs ().at (0 );
603
+ const TyTy::ParamType *param_tyty = param_mapping.get_param_ty ();
604
+ TyTy::BaseType *resolved_tyty = param_tyty->resolve ();
605
+ tree template_parameter_type
606
+ = TyTyResolveCompile::compile (ctx, resolved_tyty);
607
+
608
+ // this should match y as well or we can take it from the TyTy structure
609
+ tree tmp_stmt = error_mark_node;
610
+ Bvariable *result_variable = ctx->get_backend ()->temporary_variable (
611
+ fndecl, NULL_TREE, template_parameter_type, NULL_TREE,
612
+ true /* address_is_taken*/ , UNDEF_LOCATION, &tmp_stmt);
613
+ Bvariable *bool_variable
614
+ = ctx->get_backend ()->temporary_variable (fndecl, NULL_TREE,
615
+ boolean_type_node, NULL_TREE,
616
+ true /* address_is_taken*/ ,
617
+ UNDEF_LOCATION, &tmp_stmt);
618
+
619
+ enter_intrinsic_block (ctx, fndecl, {result_variable, bool_variable});
602
620
603
621
// BUILTIN op_with_overflow FN BODY BEGIN
604
622
auto x = ctx->get_backend ()->var_expression (x_param, UNDEF_LOCATION);
@@ -628,24 +646,20 @@ op_with_overflow_inner (Context *ctx, TyTy::FnType *fntype, tree_code op)
628
646
}
629
647
rust_assert (overflow_builtin != error_mark_node);
630
648
631
- // this should match y as well or we can take it from the TyTy structure
632
- tree overflow_op_type = TREE_TYPE (x);
633
- tree tmp_stmt = error_mark_node;
634
- Bvariable *bvar
635
- = ctx->get_backend ()->temporary_variable (fndecl, NULL_TREE,
636
- overflow_op_type, NULL_TREE,
637
- true /* address_is_taken*/ ,
638
- UNDEF_LOCATION, &tmp_stmt);
639
- ctx->add_statement (tmp_stmt);
640
-
641
- tree result_decl = bvar->get_tree (UNDEF_LOCATION);
649
+ tree bool_decl = bool_variable->get_tree (BUILTINS_LOCATION);
650
+ tree result_decl = result_variable->get_tree (BUILTINS_LOCATION);
642
651
tree result_ref = build_fold_addr_expr_loc (BUILTINS_LOCATION, result_decl);
643
652
644
- tree did_overflow_node
645
- = build_call_expr_loc (BUILTINS_LOCATION, overflow_builtin, 3 , x, y,
646
- result_ref);
653
+ tree builtin_call = build_call_expr_loc (BUILTINS_LOCATION, overflow_builtin,
654
+ 3 , x, y, result_ref);
655
+
656
+ tree overflow_assignment
657
+ = ctx->get_backend ()->assignment_statement (bool_decl, builtin_call,
658
+ BUILTINS_LOCATION);
659
+
660
+ ctx->add_statement (overflow_assignment);
647
661
648
- std::vector<tree> vals = {result_decl, did_overflow_node };
662
+ std::vector<tree> vals = {result_decl, bool_decl };
649
663
tree tuple_type = TREE_TYPE (DECL_RESULT (fndecl));
650
664
tree result_expr
651
665
= ctx->get_backend ()->constructor_expression (tuple_type, false , vals, -1 ,
0 commit comments