@@ -72,14 +72,18 @@ use mir::operand::OperandValue;
72
72
use std:: marker:: PhantomData ;
73
73
74
74
75
- pub struct StatRecorder < ' a , ' ll : ' a , ' tcx : ' ll , Cx : ' a + CodegenMethods < ' ll , ' tcx > > {
75
+ pub struct StatRecorder < ' a , ' ll : ' a , ' tcx : ' ll , Cx : ' a + CodegenMethods < ' a , ' ll , ' tcx > >
76
+ where & ' a Cx : LayoutOf < Ty = Ty < ' tcx > , TyLayout = TyLayout < ' tcx > > + HasTyCtxt < ' tcx >
77
+ {
76
78
cx : & ' a Cx ,
77
79
name : Option < String > ,
78
80
istart : usize ,
79
81
phantom : PhantomData < ( & ' ll ( ) , & ' tcx ( ) ) >
80
82
}
81
83
82
- impl < ' a , ' ll : ' a , ' tcx : ' ll , Cx : ' a + CodegenMethods < ' ll , ' tcx > > StatRecorder < ' a , ' ll , ' tcx , Cx > {
84
+ impl < ' a , ' ll : ' a , ' tcx : ' ll , Cx : ' a + CodegenMethods < ' a , ' ll , ' tcx > > StatRecorder < ' a , ' ll , ' tcx , Cx >
85
+ where & ' a Cx : LayoutOf < Ty = Ty < ' tcx > , TyLayout = TyLayout < ' tcx > > + HasTyCtxt < ' tcx >
86
+ {
83
87
pub fn new ( cx : & ' a Cx , name : String ) -> Self {
84
88
let istart = cx. stats ( ) . borrow ( ) . n_llvm_insns ;
85
89
StatRecorder {
@@ -91,8 +95,9 @@ impl<'a, 'll: 'a, 'tcx: 'll, Cx: 'a + CodegenMethods<'ll, 'tcx>> StatRecorder<'a
91
95
}
92
96
}
93
97
94
- impl < ' a , ' ll : ' a , ' tcx : ' ll , Cx : ' a + CodegenMethods < ' ll , ' tcx > > Drop for
98
+ impl < ' a , ' ll : ' a , ' tcx : ' ll , Cx : ' a + CodegenMethods < ' a , ' ll , ' tcx > > Drop for
95
99
StatRecorder < ' a , ' ll , ' tcx , Cx >
100
+ where & ' a Cx : LayoutOf < Ty = Ty < ' tcx > , TyLayout = TyLayout < ' tcx > > + HasTyCtxt < ' tcx >
96
101
{
97
102
fn drop ( & mut self ) {
98
103
if self . cx . sess ( ) . codegen_stats ( ) {
@@ -147,7 +152,9 @@ pub fn compare_simd_types<'a, 'll:'a, 'tcx:'ll, Bx : BuilderMethods<'a, 'll, 'tc
147
152
t : Ty < ' tcx > ,
148
153
ret_ty : <Bx :: CodegenCx as Backend < ' ll > >:: Type ,
149
154
op : hir:: BinOpKind
150
- ) -> <Bx :: CodegenCx as Backend < ' ll > >:: Value {
155
+ ) -> <Bx :: CodegenCx as Backend < ' ll > >:: Value
156
+ where & ' a Bx :: CodegenCx : LayoutOf < Ty = Ty < ' tcx > , TyLayout = TyLayout < ' tcx > > + HasTyCtxt < ' tcx >
157
+ {
151
158
let signed = match t. sty {
152
159
ty:: Float ( _) => {
153
160
let cmp = bin_op_to_fcmp_predicate ( op) ;
@@ -174,7 +181,7 @@ pub fn compare_simd_types<'a, 'll:'a, 'tcx:'ll, Bx : BuilderMethods<'a, 'll, 'tc
174
181
/// The `old_info` argument is a bit funny. It is intended for use
175
182
/// in an upcast, where the new vtable for an object will be derived
176
183
/// from the old one.
177
- pub fn unsized_info < ' a , ' ll : ' a , ' tcx : ' ll , Cx : ' a + CodegenMethods < ' ll , ' tcx > > (
184
+ pub fn unsized_info < ' a , ' ll : ' a , ' tcx : ' ll , Cx : ' a + CodegenMethods < ' a , ' ll , ' tcx > > (
178
185
cx : & ' a Cx ,
179
186
source : Ty < ' tcx > ,
180
187
target : Ty < ' tcx > ,
@@ -326,7 +333,9 @@ pub fn cast_shift_expr_rhs<'a, 'll: 'a, 'tcx: 'll, Bx : BuilderMethods<'a, 'll,
326
333
op : hir:: BinOpKind ,
327
334
lhs : <Bx :: CodegenCx as Backend < ' ll > >:: Value ,
328
335
rhs : <Bx :: CodegenCx as Backend < ' ll > >:: Value
329
- ) -> <Bx :: CodegenCx as Backend < ' ll > >:: Value {
336
+ ) -> <Bx :: CodegenCx as Backend < ' ll > >:: Value
337
+ where & ' a Bx :: CodegenCx : LayoutOf < Ty = Ty < ' tcx > , TyLayout = TyLayout < ' tcx > > + HasTyCtxt < ' tcx >
338
+ {
330
339
cast_shift_rhs ( bx, op, lhs, rhs)
331
340
}
332
341
@@ -335,7 +344,9 @@ fn cast_shift_rhs<'a, 'll :'a, 'tcx : 'll, Bx : BuilderMethods<'a, 'll, 'tcx>>(
335
344
op : hir:: BinOpKind ,
336
345
lhs : <Bx :: CodegenCx as Backend < ' ll > >:: Value ,
337
346
rhs : <Bx :: CodegenCx as Backend < ' ll > >:: Value ,
338
- ) -> <Bx :: CodegenCx as Backend < ' ll > >:: Value {
347
+ ) -> <Bx :: CodegenCx as Backend < ' ll > >:: Value
348
+ where & ' a Bx :: CodegenCx : LayoutOf < Ty = Ty < ' tcx > , TyLayout = TyLayout < ' tcx > > + HasTyCtxt < ' tcx >
349
+ {
339
350
// Shifts may have any size int on the rhs
340
351
if op. is_shift ( ) {
341
352
let mut rhs_llty = bx. cx ( ) . val_ty ( rhs) ;
@@ -374,15 +385,19 @@ pub fn wants_msvc_seh(sess: &Session) -> bool {
374
385
pub fn call_assume < ' a , ' ll : ' a , ' tcx : ' ll , Bx : BuilderMethods < ' a , ' ll , ' tcx > > (
375
386
bx : & mut Bx ,
376
387
val : <Bx :: CodegenCx as Backend < ' ll > >:: Value
377
- ) {
388
+ )
389
+ where & ' a Bx :: CodegenCx : LayoutOf < Ty = Ty < ' tcx > , TyLayout = TyLayout < ' tcx > > + HasTyCtxt < ' tcx >
390
+ {
378
391
let assume_intrinsic = bx. cx ( ) . get_intrinsic ( "llvm.assume" ) ;
379
392
bx. call ( assume_intrinsic, & [ val] , None ) ;
380
393
}
381
394
382
395
pub fn from_immediate < ' a , ' ll : ' a , ' tcx : ' ll , Bx : BuilderMethods < ' a , ' ll , ' tcx > > (
383
396
bx : & mut Bx ,
384
397
val : <Bx :: CodegenCx as Backend < ' ll > >:: Value
385
- ) -> <Bx :: CodegenCx as Backend < ' ll > >:: Value {
398
+ ) -> <Bx :: CodegenCx as Backend < ' ll > >:: Value
399
+ where & ' a Bx :: CodegenCx : LayoutOf < Ty = Ty < ' tcx > , TyLayout = TyLayout < ' tcx > > + HasTyCtxt < ' tcx >
400
+ {
386
401
if bx. cx ( ) . val_ty ( val) == bx. cx ( ) . type_i1 ( ) {
387
402
bx. zext ( val, bx. cx ( ) . type_i8 ( ) )
388
403
} else {
@@ -394,7 +409,9 @@ pub fn to_immediate<'a, 'll: 'a, 'tcx: 'll, Bx : BuilderMethods<'a, 'll, 'tcx>>(
394
409
bx : & mut Bx ,
395
410
val : <Bx :: CodegenCx as Backend < ' ll > >:: Value ,
396
411
layout : layout:: TyLayout ,
397
- ) -> <Bx :: CodegenCx as Backend < ' ll > >:: Value {
412
+ ) -> <Bx :: CodegenCx as Backend < ' ll > >:: Value
413
+ where & ' a Bx :: CodegenCx : LayoutOf < Ty = Ty < ' tcx > , TyLayout = TyLayout < ' tcx > > + HasTyCtxt < ' tcx >
414
+ {
398
415
if let layout:: Abi :: Scalar ( ref scalar) = layout. abi {
399
416
return to_immediate_scalar ( bx, val, scalar) ;
400
417
}
@@ -405,7 +422,9 @@ pub fn to_immediate_scalar<'a, 'll :'a, 'tcx :'ll, Bx : BuilderMethods<'a, 'll,
405
422
bx : & mut Bx ,
406
423
val : <Bx :: CodegenCx as Backend < ' ll > >:: Value ,
407
424
scalar : & layout:: Scalar ,
408
- ) -> <Bx :: CodegenCx as Backend < ' ll > >:: Value {
425
+ ) -> <Bx :: CodegenCx as Backend < ' ll > >:: Value
426
+ where & ' a Bx :: CodegenCx : LayoutOf < Ty = Ty < ' tcx > , TyLayout = TyLayout < ' tcx > > + HasTyCtxt < ' tcx >
427
+ {
409
428
if scalar. is_bool ( ) {
410
429
return bx. trunc ( val, bx. cx ( ) . type_i1 ( ) ) ;
411
430
}
@@ -419,7 +438,9 @@ pub fn memcpy_ty<'a, 'll: 'a, 'tcx: 'll, Bx : BuilderMethods<'a, 'll, 'tcx>>(
419
438
layout : TyLayout < ' tcx > ,
420
439
align : Align ,
421
440
flags : MemFlags ,
422
- ) {
441
+ )
442
+ where & ' a Bx :: CodegenCx : LayoutOf < Ty = Ty < ' tcx > , TyLayout = TyLayout < ' tcx > > + HasTyCtxt < ' tcx >
443
+ {
423
444
let size = layout. size . bytes ( ) ;
424
445
if size == 0 {
425
446
return ;
@@ -467,7 +488,9 @@ pub fn codegen_instance<'a, 'll: 'a, 'tcx: 'll, Bx: BuilderMethods<'a, 'll, 'tcx
467
488
/// users main function.
468
489
pub fn maybe_create_entry_wrapper < ' a , ' ll : ' a , ' tcx : ' ll , Bx : BuilderMethods < ' a , ' ll , ' tcx > > (
469
490
cx : & ' a Bx :: CodegenCx
470
- ) {
491
+ )
492
+ where & ' a Bx :: CodegenCx : LayoutOf < Ty = Ty < ' tcx > , TyLayout = TyLayout < ' tcx > > + HasTyCtxt < ' tcx >
493
+ {
471
494
let ( main_def_id, span) = match * cx. sess ( ) . entry_fn . borrow ( ) {
472
495
Some ( ( id, span, _) ) => {
473
496
( cx. tcx ( ) . hir . local_def_id ( id) , span)
@@ -498,7 +521,10 @@ pub fn maybe_create_entry_wrapper<'a, 'll: 'a, 'tcx: 'll, Bx: BuilderMethods<'a,
498
521
rust_main : <Bx :: CodegenCx as Backend < ' ll > >:: Value ,
499
522
rust_main_def_id : DefId ,
500
523
use_start_lang_item : bool ,
501
- ) {
524
+ )
525
+ where & ' a Bx :: CodegenCx :
526
+ LayoutOf < Ty = Ty < ' tcx > , TyLayout = TyLayout < ' tcx > > + HasTyCtxt < ' tcx >
527
+ {
502
528
let llfty =
503
529
cx. type_func ( & [ cx. type_int ( ) , cx. type_ptr_to ( cx. type_i8p ( ) ) ] , cx. type_int ( ) ) ;
504
530
@@ -551,7 +577,7 @@ pub fn maybe_create_entry_wrapper<'a, 'll: 'a, 'tcx: 'll, Bx: BuilderMethods<'a,
551
577
} ;
552
578
553
579
let result = bx. call ( start_fn, & args, None ) ;
554
- let cast = bx. intcast ( result, cx. type_int ( ) , true ) ;
580
+ let cast = bx. intcast ( result, cx. type_int ( ) , true ) ;
555
581
bx. ret ( cast) ;
556
582
}
557
583
}
0 commit comments