Skip to content

Commit 14798d6

Browse files
denismerigouxeddyb
authored andcommitted
Generalized BasicBlocks in BuilderMethods trait
1 parent 34c5dc0 commit 14798d6

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

src/librustc_codegen_llvm/base.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ use rustc_data_structures::sync::Lrc;
7676
use rustc_data_structures::indexed_vec::Idx;
7777

7878
use traits::BuilderMethods;
79+
use llvm::BasicBlock;
7980

8081
use std::any::Any;
8182
use std::cmp;
@@ -391,7 +392,7 @@ pub fn call_assume(bx: &Builder<'_, 'll, '_>, val: &'ll Value) {
391392

392393
pub fn from_immediate<'a, 'll: 'a, 'tcx: 'll,
393394
Value : ?Sized,
394-
Builder: BuilderMethods<'a, 'll, 'tcx, Value>>(
395+
Builder: BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock>>(
395396
bx: &Builder,
396397
val: &'ll Value
397398
) -> &'ll Value where Value : ValueTrait {
@@ -426,7 +427,7 @@ pub fn to_immediate_scalar(
426427

427428
pub fn call_memcpy<'a, 'll: 'a, 'tcx: 'll,
428429
Value : ?Sized,
429-
Builder: BuilderMethods<'a, 'll, 'tcx, Value>>(
430+
Builder: BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock>>(
430431
bx: &Builder,
431432
dst: &'ll Value,
432433
dst_align: Align,
@@ -452,7 +453,7 @@ pub fn call_memcpy<'a, 'll: 'a, 'tcx: 'll,
452453

453454
pub fn memcpy_ty<'a, 'll: 'a, 'tcx: 'll,
454455
Value : ?Sized,
455-
Builder: BuilderMethods<'a, 'll, 'tcx, Value>>(
456+
Builder: BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock>>(
456457
bx: &Builder,
457458
dst: &'ll Value,
458459
dst_align: Align,

src/librustc_codegen_llvm/builder.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ bitflags! {
5555
}
5656
}
5757

58-
impl BuilderMethods<'a, 'll, 'tcx, Value> for Builder<'a, 'll, 'tcx> {
58+
impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock>
59+
for Builder<'a, 'll, 'tcx> {
5960
fn new_block<'b>(
6061
cx: &'a CodegenCx<'ll, 'tcx>,
6162
llfn: &'ll Value,

src/librustc_codegen_llvm/mir/operand.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use type_::Type;
2222
use glue;
2323

2424
use traits::BuilderMethods;
25+
use llvm::BasicBlock;
2526

2627
use std::fmt;
2728

@@ -281,7 +282,8 @@ impl OperandValue<&'ll Value> {
281282

282283
impl<'a, 'll: 'a, 'tcx: 'll, Value : ?Sized> OperandValue<&'ll Value> where
283284
Value : ValueTrait,
284-
Builder<'a, 'll, 'tcx, &'ll Value>: BuilderMethods<'a, 'll, 'tcx, Value>
285+
Builder<'a, 'll, 'tcx, &'ll Value>:
286+
BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock>
285287
{
286288
pub fn nontemporal_store(
287289
self,
@@ -291,7 +293,7 @@ impl<'a, 'll: 'a, 'tcx: 'll, Value : ?Sized> OperandValue<&'ll Value> where
291293
self.store_with_flags(bx, dest, MemFlags::NONTEMPORAL);
292294
}
293295

294-
fn store_with_flags<Builder: BuilderMethods<'a, 'll, 'tcx, Value>>(
296+
fn store_with_flags<Builder: BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock>>(
295297
self,
296298
bx: &Builder,
297299
dest: PlaceRef<'tcx, &'ll Value>,

src/librustc_codegen_llvm/traits.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use llvm::{AtomicRmwBinOp, AtomicOrdering, SynchronizationScope, AsmDialect};
1212
use llvm::{IntPredicate, RealPredicate, OperandBundleDef};
13-
use llvm::{self, BasicBlock};
13+
use llvm;
1414
use common::*;
1515
use type_::Type;
1616
use libc::c_char;
@@ -23,7 +23,11 @@ use std::borrow::Cow;
2323
use std::ops::Range;
2424

2525

26-
pub trait BuilderMethods<'a, 'll :'a, 'tcx: 'll, Value : ?Sized> {
26+
pub trait BuilderMethods<'a, 'll :'a, 'tcx: 'll,
27+
Value : ?Sized,
28+
BasicBlock: ?Sized
29+
> {
30+
2731
fn new_block<'b>(
2832
cx: &'a CodegenCx<'ll, 'tcx, &'ll Value>,
2933
llfn: &'ll Value,

0 commit comments

Comments
 (0)