Skip to content

Commit b0776db

Browse files
committed
Added 'll lifetime parameter to backend
1 parent 7507ff6 commit b0776db

26 files changed

+450
-450
lines changed

src/librustc_codegen_llvm/abi.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ impl<'a, 'll: 'a, 'tcx: 'll> ArgTypeMethods<'a, 'll, 'tcx> for Builder<'a, 'll,
284284
fn store_fn_arg(
285285
&self,
286286
ty: &ArgType<'tcx, Ty<'tcx>>,
287-
idx: &mut usize, dst: PlaceRef<'tcx, <Self::CodegenCx as Backend>::Value>
287+
idx: &mut usize, dst: PlaceRef<'tcx, <Self::CodegenCx as Backend<'ll>>::Value>
288288
) {
289289
ty.store_fn_arg(&self, idx, dst)
290290
}
@@ -824,7 +824,7 @@ impl AbiBuilderMethods<'a, 'll, 'tcx> for Builder<'a, 'll, 'tcx, &'ll Value> {
824824
fn apply_attrs_callsite(
825825
&self,
826826
ty: &FnType<'tcx, Ty<'tcx>>,
827-
callsite: <Self::CodegenCx as Backend>::Value
827+
callsite: <Self::CodegenCx as Backend<'ll>>::Value
828828
) {
829829
ty.apply_attrs_callsite(&self, callsite)
830830
}

src/librustc_codegen_llvm/base.rs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,12 @@ pub fn bin_op_to_fcmp_predicate(op: hir::BinOpKind) -> RealPredicate {
157157

158158
pub fn compare_simd_types<'a, 'll:'a, 'tcx:'ll, Builder : BuilderMethods<'a, 'll, 'tcx>>(
159159
bx: &Builder,
160-
lhs: <Builder::CodegenCx as Backend>::Value,
161-
rhs: <Builder::CodegenCx as Backend>::Value,
160+
lhs: <Builder::CodegenCx as Backend<'ll>>::Value,
161+
rhs: <Builder::CodegenCx as Backend<'ll>>::Value,
162162
t: Ty<'tcx>,
163-
ret_ty: <Builder::CodegenCx as Backend>::Type,
163+
ret_ty: <Builder::CodegenCx as Backend<'ll>>::Type,
164164
op: hir::BinOpKind
165-
) -> <Builder::CodegenCx as Backend>::Value {
165+
) -> <Builder::CodegenCx as Backend<'ll>>::Value {
166166
let signed = match t.sty {
167167
ty::Float(_) => {
168168
let cmp = bin_op_to_fcmp_predicate(op);
@@ -219,10 +219,10 @@ pub fn unsized_info<'a, 'll: 'a, 'tcx: 'll, Cx: 'a + CodegenMethods<'ll, 'tcx>>(
219219
/// Coerce `src` to `dst_ty`. `src_ty` must be a thin pointer.
220220
pub fn unsize_thin_ptr<'a, 'll: 'a, 'tcx: 'll, Bx: BuilderMethods<'a, 'll, 'tcx>>(
221221
bx: &Bx,
222-
src: <Bx::CodegenCx as Backend>::Value,
222+
src: <Bx::CodegenCx as Backend<'ll>>::Value,
223223
src_ty: Ty<'tcx>,
224224
dst_ty: Ty<'tcx>
225-
) -> (<Bx::CodegenCx as Backend>::Value, <Bx::CodegenCx as Backend>::Value) where
225+
) -> (<Bx::CodegenCx as Backend<'ll>>::Value, <Bx::CodegenCx as Backend<'ll>>::Value) where
226226
&'a Bx::CodegenCx: LayoutOf<Ty = Ty<'tcx>, TyLayout = TyLayout<'tcx>> + HasTyCtxt<'tcx>
227227
{
228228
debug!("unsize_thin_ptr: {:?} => {:?}", src_ty, dst_ty);
@@ -276,8 +276,8 @@ pub fn unsize_thin_ptr<'a, 'll: 'a, 'tcx: 'll, Bx: BuilderMethods<'a, 'll, 'tcx>
276276
/// to a value of type `dst_ty` and store the result in `dst`
277277
pub fn coerce_unsized_into<'a, 'll: 'a, 'tcx: 'll, Bx: BuilderMethods<'a, 'll, 'tcx>>(
278278
bx: &Bx,
279-
src: PlaceRef<'tcx, <Bx::CodegenCx as Backend>::Value>,
280-
dst: PlaceRef<'tcx, <Bx::CodegenCx as Backend>::Value>
279+
src: PlaceRef<'tcx, <Bx::CodegenCx as Backend<'ll>>::Value>,
280+
dst: PlaceRef<'tcx, <Bx::CodegenCx as Backend<'ll>>::Value>
281281
) where &'a Bx::CodegenCx: LayoutOf<Ty = Ty<'tcx>, TyLayout = TyLayout<'tcx>> + HasTyCtxt<'tcx>
282282
{
283283
let src_ty = src.layout.ty;
@@ -337,28 +337,28 @@ pub fn coerce_unsized_into<'a, 'll: 'a, 'tcx: 'll, Bx: BuilderMethods<'a, 'll, '
337337
pub fn cast_shift_expr_rhs<'a, 'll: 'a, 'tcx: 'll, Builder : BuilderMethods<'a, 'll, 'tcx>>(
338338
bx: &Builder,
339339
op: hir::BinOpKind,
340-
lhs: <Builder::CodegenCx as Backend>::Value,
341-
rhs: <Builder::CodegenCx as Backend>::Value
342-
) -> <Builder::CodegenCx as Backend>::Value {
340+
lhs: <Builder::CodegenCx as Backend<'ll>>::Value,
341+
rhs: <Builder::CodegenCx as Backend<'ll>>::Value
342+
) -> <Builder::CodegenCx as Backend<'ll>>::Value {
343343
cast_shift_rhs(bx, op, lhs, rhs, |a, b| bx.trunc(a, b), |a, b| bx.zext(a, b))
344344
}
345345

346346
fn cast_shift_rhs<'a, 'll :'a, 'tcx : 'll, F, G, Builder : BuilderMethods<'a, 'll, 'tcx>>(
347347
bx: &Builder,
348348
op: hir::BinOpKind,
349-
lhs: <Builder::CodegenCx as Backend>::Value,
350-
rhs: <Builder::CodegenCx as Backend>::Value,
349+
lhs: <Builder::CodegenCx as Backend<'ll>>::Value,
350+
rhs: <Builder::CodegenCx as Backend<'ll>>::Value,
351351
trunc: F,
352352
zext: G
353-
) -> <Builder::CodegenCx as Backend>::Value
353+
) -> <Builder::CodegenCx as Backend<'ll>>::Value
354354
where F: FnOnce(
355-
<Builder::CodegenCx as Backend>::Value,
356-
<Builder::CodegenCx as Backend>::Type
357-
) -> <Builder::CodegenCx as Backend>::Value,
355+
<Builder::CodegenCx as Backend<'ll>>::Value,
356+
<Builder::CodegenCx as Backend<'ll>>::Type
357+
) -> <Builder::CodegenCx as Backend<'ll>>::Value,
358358
G: FnOnce(
359-
<Builder::CodegenCx as Backend>::Value,
360-
<Builder::CodegenCx as Backend>::Type
361-
) -> <Builder::CodegenCx as Backend>::Value
359+
<Builder::CodegenCx as Backend<'ll>>::Value,
360+
<Builder::CodegenCx as Backend<'ll>>::Type
361+
) -> <Builder::CodegenCx as Backend<'ll>>::Value
362362
{
363363
// Shifts may have any size int on the rhs
364364
if op.is_shift() {
@@ -397,16 +397,16 @@ pub fn wants_msvc_seh(sess: &Session) -> bool {
397397

398398
pub fn call_assume<'a, 'll: 'a, 'tcx: 'll, Bx : BuilderMethods<'a, 'll ,'tcx>>(
399399
bx: &Bx,
400-
val: <Bx::CodegenCx as Backend>::Value
400+
val: <Bx::CodegenCx as Backend<'ll>>::Value
401401
) {
402402
let assume_intrinsic = bx.cx().get_intrinsic("llvm.assume");
403403
bx.call(assume_intrinsic, &[val], None);
404404
}
405405

406406
pub fn from_immediate<'a, 'll: 'a, 'tcx: 'll, Bx : BuilderMethods<'a, 'll ,'tcx>>(
407407
bx: &Bx,
408-
val: <Bx::CodegenCx as Backend>::Value
409-
) -> <Bx::CodegenCx as Backend>::Value {
408+
val: <Bx::CodegenCx as Backend<'ll>>::Value
409+
) -> <Bx::CodegenCx as Backend<'ll>>::Value {
410410
if bx.cx().val_ty(val) == bx.cx().type_i1() {
411411
bx.zext(val, bx.cx().type_i8())
412412
} else {
@@ -416,9 +416,9 @@ pub fn from_immediate<'a, 'll: 'a, 'tcx: 'll, Bx : BuilderMethods<'a, 'll ,'tcx>
416416

417417
pub fn to_immediate<'a, 'll: 'a, 'tcx: 'll, Builder : BuilderMethods<'a, 'll, 'tcx>>(
418418
bx: &Builder,
419-
val: <Builder::CodegenCx as Backend>::Value,
419+
val: <Builder::CodegenCx as Backend<'ll>>::Value,
420420
layout: layout::TyLayout,
421-
) -> <Builder::CodegenCx as Backend>::Value {
421+
) -> <Builder::CodegenCx as Backend<'ll>>::Value {
422422
if let layout::Abi::Scalar(ref scalar) = layout.abi {
423423
return to_immediate_scalar(bx, val, scalar);
424424
}
@@ -427,9 +427,9 @@ pub fn to_immediate<'a, 'll: 'a, 'tcx: 'll, Builder : BuilderMethods<'a, 'll, 't
427427

428428
pub fn to_immediate_scalar<'a, 'll :'a, 'tcx :'ll, Builder : BuilderMethods<'a, 'll, 'tcx>>(
429429
bx: &Builder,
430-
val: <Builder::CodegenCx as Backend>::Value,
430+
val: <Builder::CodegenCx as Backend<'ll>>::Value,
431431
scalar: &layout::Scalar,
432-
) -> <Builder::CodegenCx as Backend>::Value {
432+
) -> <Builder::CodegenCx as Backend<'ll>>::Value {
433433
if scalar.is_bool() {
434434
return bx.trunc(val, bx.cx().type_i1());
435435
}
@@ -438,8 +438,8 @@ pub fn to_immediate_scalar<'a, 'll :'a, 'tcx :'ll, Builder : BuilderMethods<'a,
438438

439439
pub fn memcpy_ty<'a, 'll: 'a, 'tcx: 'll, Builder : BuilderMethods<'a, 'll, 'tcx>>(
440440
bx: &Builder,
441-
dst: <Builder::CodegenCx as Backend>::Value,
442-
src: <Builder::CodegenCx as Backend>::Value,
441+
dst: <Builder::CodegenCx as Backend<'ll>>::Value,
442+
src: <Builder::CodegenCx as Backend<'ll>>::Value,
443443
layout: TyLayout<'tcx>,
444444
align: Align,
445445
flags: MemFlags,

src/librustc_codegen_llvm/callee.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ pub fn get_fn(
205205
}
206206

207207
pub fn resolve_and_get_fn<'ll, 'tcx: 'll,
208-
Cx : Backend + MiscMethods<'tcx> + TypeMethods<'ll, 'tcx>
208+
Cx : Backend<'ll> + MiscMethods<'ll, 'tcx> + TypeMethods<'ll, 'tcx>
209209
>(
210210
cx: &Cx,
211211
def_id: DefId,

src/librustc_codegen_llvm/common.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,14 @@ impl<'ll, V : CodegenObject> Funclet<'ll, V> {
215215
}
216216
}
217217

218-
impl Backend for CodegenCx<'ll, 'tcx, &'ll Value> {
218+
impl Backend<'ll> for CodegenCx<'ll, 'tcx, &'ll Value> {
219219
type Value = &'ll Value;
220220
type BasicBlock = &'ll BasicBlock;
221221
type Type = &'ll Type;
222222
type Context = &'ll llvm::Context;
223223
}
224224

225-
impl<'ll, 'tcx : 'll> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx, &'ll Value> {
225+
impl<'ll, 'tcx : 'll> ConstMethods<'ll, 'tcx> for CodegenCx<'ll, 'tcx, &'ll Value> {
226226

227227
// LLVM constant constructors.
228228
fn const_null(&self, t: &'ll Type) -> &'ll Value {
@@ -545,9 +545,9 @@ pub fn langcall(tcx: TyCtxt,
545545

546546
pub fn build_unchecked_lshift<'a, 'll: 'a, 'tcx: 'll, Bx: BuilderMethods<'a, 'll, 'tcx>>(
547547
bx: &Bx,
548-
lhs: <Bx::CodegenCx as Backend>::Value,
549-
rhs: <Bx::CodegenCx as Backend>::Value
550-
) -> <Bx::CodegenCx as Backend>::Value {
548+
lhs: <Bx::CodegenCx as Backend<'ll>>::Value,
549+
rhs: <Bx::CodegenCx as Backend<'ll>>::Value
550+
) -> <Bx::CodegenCx as Backend<'ll>>::Value {
551551
let rhs = base::cast_shift_expr_rhs(bx, hir::BinOpKind::Shl, lhs, rhs);
552552
// #1877, #10183: Ensure that input is always valid
553553
let rhs = shift_mask_rhs(bx, rhs);
@@ -557,9 +557,9 @@ pub fn build_unchecked_lshift<'a, 'll: 'a, 'tcx: 'll, Bx: BuilderMethods<'a, 'll
557557
pub fn build_unchecked_rshift<'a, 'll: 'a, 'tcx: 'll, Bx: BuilderMethods<'a, 'll, 'tcx>>(
558558
bx: &Bx,
559559
lhs_t: Ty<'tcx>,
560-
lhs: <Bx::CodegenCx as Backend>::Value,
561-
rhs: <Bx::CodegenCx as Backend>::Value
562-
) -> <Bx::CodegenCx as Backend>::Value {
560+
lhs: <Bx::CodegenCx as Backend<'ll>>::Value,
561+
rhs: <Bx::CodegenCx as Backend<'ll>>::Value
562+
) -> <Bx::CodegenCx as Backend<'ll>>::Value {
563563
let rhs = base::cast_shift_expr_rhs(bx, hir::BinOpKind::Shr, lhs, rhs);
564564
// #1877, #10183: Ensure that input is always valid
565565
let rhs = shift_mask_rhs(bx, rhs);
@@ -573,18 +573,18 @@ pub fn build_unchecked_rshift<'a, 'll: 'a, 'tcx: 'll, Bx: BuilderMethods<'a, 'll
573573

574574
fn shift_mask_rhs<'a, 'll: 'a, 'tcx: 'll, Bx: BuilderMethods<'a, 'll, 'tcx>>(
575575
bx: &Bx,
576-
rhs: <Bx::CodegenCx as Backend>::Value
577-
) -> <Bx::CodegenCx as Backend>::Value {
576+
rhs: <Bx::CodegenCx as Backend<'ll>>::Value
577+
) -> <Bx::CodegenCx as Backend<'ll>>::Value {
578578
let rhs_llty = bx.cx().val_ty(rhs);
579579
bx.and(rhs, shift_mask_val(bx, rhs_llty, rhs_llty, false))
580580
}
581581

582582
pub fn shift_mask_val<'a, 'll: 'a, 'tcx: 'll, Bx: BuilderMethods<'a, 'll, 'tcx>>(
583583
bx: &Bx,
584-
llty: <Bx::CodegenCx as Backend>::Type,
585-
mask_llty: <Bx::CodegenCx as Backend>::Type,
584+
llty: <Bx::CodegenCx as Backend<'ll>>::Type,
585+
mask_llty: <Bx::CodegenCx as Backend<'ll>>::Type,
586586
invert: bool
587-
) -> <Bx::CodegenCx as Backend>::Value {
587+
) -> <Bx::CodegenCx as Backend<'ll>>::Value {
588588
let kind = bx.cx().type_kind(llty);
589589
match kind {
590590
TypeKind::Integer => {

src/librustc_codegen_llvm/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ pub fn ptrcast(val: &'ll Value, ty: &'ll Type) -> &'ll Value {
116116
}
117117
}
118118

119-
impl StaticMethods<'tcx> for CodegenCx<'ll, 'tcx, &'ll Value> {
119+
impl StaticMethods<'ll> for CodegenCx<'ll, 'tcx, &'ll Value> {
120120

121121
fn static_ptrcast(&self, val: &'ll Value, ty: &'ll Type) -> &'ll Value {
122122
ptrcast(val, ty)

src/librustc_codegen_llvm/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ impl<'a, 'tcx, Value : Eq+Hash> CodegenCx<'a, 'tcx, Value> {
316316
}
317317
}
318318

319-
impl MiscMethods<'tcx> for CodegenCx<'ll, 'tcx, &'ll Value> {
319+
impl MiscMethods<'ll, 'tcx> for CodegenCx<'ll, 'tcx, &'ll Value> {
320320
fn vtables(&self) -> &RefCell<FxHashMap<(Ty<'tcx>,
321321
Option<ty::PolyExistentialTraitRef<'tcx>>), &'ll Value>>
322322
{
@@ -422,7 +422,7 @@ impl MiscMethods<'tcx> for CodegenCx<'ll, 'tcx, &'ll Value> {
422422

423423
impl<'ll, 'tcx: 'll> CodegenMethods<'ll, 'tcx> for CodegenCx<'ll, 'tcx, &'ll Value> {}
424424

425-
impl IntrinsicDeclarationMethods for CodegenCx<'b, 'tcx, &'b Value> {
425+
impl IntrinsicDeclarationMethods<'b> for CodegenCx<'b, 'tcx, &'b Value> {
426426
fn get_intrinsic(&self, key: &str) -> &'b Value {
427427
if let Some(v) = self.intrinsics.borrow().get(key).cloned() {
428428
return v;

src/librustc_codegen_llvm/declare.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ fn declare_raw_fn(
9595
llfn
9696
}
9797

98-
impl DeclareMethods<'tcx> for CodegenCx<'ll, 'tcx, &'ll Value> {
98+
impl DeclareMethods<'ll, 'tcx> for CodegenCx<'ll, 'tcx, &'ll Value> {
9999

100100
/// Declare a global value.
101101
///

src/librustc_codegen_llvm/glue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ pub fn size_and_align_of_dst<'a, 'll: 'a, 'tcx: 'll,
2525
>(
2626
bx: &Bx,
2727
t: Ty<'tcx>,
28-
info: Option<<Bx::CodegenCx as Backend>::Value>
29-
) -> (<Bx::CodegenCx as Backend>::Value, <Bx::CodegenCx as Backend>::Value) where
28+
info: Option<<Bx::CodegenCx as Backend<'ll>>::Value>
29+
) -> (<Bx::CodegenCx as Backend<'ll>>::Value, <Bx::CodegenCx as Backend<'ll>>::Value) where
3030
&'a Bx::CodegenCx: LayoutOf<Ty = Ty<'tcx>, TyLayout = TyLayout<'tcx>> + HasTyCtxt<'tcx>
3131
{
3232
debug!("calculate size of DST: {}; with lost info: {:?}",

src/librustc_codegen_llvm/interfaces/abi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ pub trait AbiBuilderMethods<'a, 'll: 'a, 'tcx: 'll> : HasCodegen<'a, 'll, 'tcx>
2727
fn apply_attrs_callsite(
2828
&self,
2929
ty: &FnType<'tcx, Ty<'tcx>>,
30-
callsite: <Self::CodegenCx as Backend>::Value
30+
callsite: <Self::CodegenCx as Backend<'ll>>::Value
3131
);
3232
}

src/librustc_codegen_llvm/interfaces/asm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ pub trait AsmBuilderMethods<'a, 'll: 'a, 'tcx: 'll> : HasCodegen<'a, 'll, 'tcx>{
1717
fn codegen_inline_asm(
1818
&self,
1919
ia: &InlineAsm,
20-
outputs: Vec<PlaceRef<'tcx, <Self::CodegenCx as Backend>::Value>>,
21-
inputs: Vec<<Self::CodegenCx as Backend>::Value>
20+
outputs: Vec<PlaceRef<'tcx, <Self::CodegenCx as Backend<'ll>>::Value>>,
21+
inputs: Vec<<Self::CodegenCx as Backend<'ll>>::Value>
2222
);
2323
}
2424

0 commit comments

Comments
 (0)