@@ -11,83 +11,6 @@ pub fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>(
11
11
12
12
let mir = tcx. instance_mir ( instance. def ) ;
13
13
14
- // Check fn sig for u128 and i128 and replace those functions with a trap.
15
- {
16
- // FIXME implement u128 and i128 support
17
-
18
- // Check sig for u128 and i128
19
- let fn_sig = tcx. normalize_erasing_late_bound_regions ( ParamEnv :: reveal_all ( ) , & instance. fn_sig ( tcx) ) ;
20
-
21
- struct UI128Visitor < ' tcx > ( TyCtxt < ' tcx > , bool ) ;
22
-
23
- impl < ' tcx > rustc:: ty:: fold:: TypeVisitor < ' tcx > for UI128Visitor < ' tcx > {
24
- fn visit_ty ( & mut self , t : Ty < ' tcx > ) -> bool {
25
- if t. sty == self . 0 . types . u128 . sty || t. sty == self . 0 . types . i128 . sty {
26
- self . 1 = true ;
27
- return false ; // stop visiting
28
- }
29
-
30
- t. super_visit_with ( self )
31
- }
32
- }
33
-
34
- let mut visitor = UI128Visitor ( tcx, false ) ;
35
- fn_sig. visit_with ( & mut visitor) ;
36
-
37
- //If found replace function with a trap.
38
- if visitor. 1 {
39
- tcx. sess . warn ( "u128 and i128 are not yet supported. \
40
- Functions using these as args will be replaced with a trap.") ;
41
-
42
- // Declare function with fake signature
43
- let sig = Signature {
44
- params : vec ! [ AbiParam :: new( types:: INVALID ) ] ,
45
- returns : vec ! [ ] ,
46
- call_conv : CallConv :: Fast ,
47
- } ;
48
- let name = tcx. symbol_name ( instance) . as_str ( ) ;
49
- let func_id = cx. module . declare_function ( & * name, linkage, & sig) . unwrap ( ) ;
50
-
51
- // Create trapping function
52
- let mut func = Function :: with_name_signature ( ExternalName :: user ( 0 , 0 ) , sig) ;
53
- let mut func_ctx = FunctionBuilderContext :: new ( ) ;
54
- let mut bcx = FunctionBuilder :: new ( & mut func, & mut func_ctx) ;
55
- let start_ebb = bcx. create_ebb ( ) ;
56
- bcx. append_ebb_params_for_function_params ( start_ebb) ;
57
- bcx. switch_to_block ( start_ebb) ;
58
-
59
- let mut fx = FunctionCx {
60
- tcx,
61
- module : cx. module ,
62
- pointer_type : pointer_ty ( tcx) ,
63
-
64
- instance,
65
- mir,
66
-
67
- bcx,
68
- ebb_map : HashMap :: new ( ) ,
69
- local_map : HashMap :: new ( ) ,
70
-
71
- clif_comments : crate :: pretty_clif:: CommentWriter :: new ( tcx, instance) ,
72
- constants : & mut cx. ccx ,
73
- caches : & mut cx. caches ,
74
- source_info_set : indexmap:: IndexSet :: new ( ) ,
75
- } ;
76
-
77
- crate :: trap:: trap_unreachable ( & mut fx, "[unimplemented] Called function with u128 or i128 as argument." ) ;
78
- fx. bcx . seal_all_blocks ( ) ;
79
- fx. bcx . finalize ( ) ;
80
-
81
- // Define function
82
- cx. caches . context . func = func;
83
- cx. module
84
- . define_function ( func_id, & mut cx. caches . context )
85
- . unwrap ( ) ;
86
- cx. caches . context . clear ( ) ;
87
- return ;
88
- }
89
- }
90
-
91
14
// Declare function
92
15
let ( name, sig) = get_function_name_and_sig ( tcx, instance, false ) ;
93
16
let func_id = cx. module . declare_function ( & name, linkage, & sig) . unwrap ( ) ;
@@ -391,7 +314,7 @@ fn trans_stmt<'a, 'tcx: 'a>(
391
314
let rhs = trans_operand ( fx, rhs) ;
392
315
393
316
let res = match ty. sty {
394
- ty:: Bool => trans_bool_binop ( fx, * bin_op, lhs, rhs, lval . layout ( ) . ty ) ,
317
+ ty:: Bool => trans_bool_binop ( fx, * bin_op, lhs, rhs) ,
395
318
ty:: Uint ( _) => {
396
319
trans_int_binop ( fx, * bin_op, lhs, rhs, lval. layout ( ) . ty , false )
397
320
}
@@ -656,7 +579,9 @@ fn trans_stmt<'a, 'tcx: 'a>(
656
579
| StatementKind :: Retag { .. }
657
580
| StatementKind :: AscribeUserType ( ..) => { }
658
581
659
- StatementKind :: InlineAsm { .. } => unimpl ! ( "Inline assembly is not supported" ) ,
582
+ StatementKind :: InlineAsm { .. } => {
583
+ crate :: trap:: trap_panic ( fx, "Inline assembly is not supported" ) ;
584
+ }
660
585
}
661
586
}
662
587
@@ -805,10 +730,9 @@ fn trans_bool_binop<'a, 'tcx: 'a>(
805
730
bin_op : BinOp ,
806
731
lhs : CValue < ' tcx > ,
807
732
rhs : CValue < ' tcx > ,
808
- ty : Ty < ' tcx > ,
809
733
) -> CValue < ' tcx > {
810
734
let res = binop_match ! {
811
- fx, bin_op, false , lhs, rhs, ty , "bool" ;
735
+ fx, bin_op, false , lhs, rhs, fx . tcx . types . bool , "bool" ;
812
736
Add ( _) bug;
813
737
Sub ( _) bug;
814
738
Mul ( _) bug;
@@ -849,7 +773,7 @@ pub fn trans_int_binop<'a, 'tcx: 'a>(
849
773
) ;
850
774
}
851
775
852
- if out_ty == fx. tcx . types . u128 || out_ty == fx. tcx . types . i128 {
776
+ if lhs . layout ( ) . ty == fx. tcx . types . u128 || lhs . layout ( ) . ty == fx. tcx . types . i128 {
853
777
return match ( bin_op, signed) {
854
778
_ => {
855
779
let layout = fx. layout_of ( out_ty) ;
0 commit comments