Skip to content

Commit ba2ed26

Browse files
committed
Generalized BasicBlocks in BuilderMethods trait
1 parent bc2897e commit ba2ed26

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::small_c_str::SmallCStr;
7676
use rustc_data_structures::sync::Lrc;
7777

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

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

393394
pub fn from_immediate<'a, 'll: 'a, 'tcx: 'll,
394395
Value : ?Sized,
395-
Builder: BuilderMethods<'a, 'll, 'tcx, Value>>(
396+
Builder: BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock>>(
396397
bx: &Builder,
397398
val: &'ll Value
398399
) -> &'ll Value where Value : ValueTrait {
@@ -427,7 +428,7 @@ pub fn to_immediate_scalar(
427428

428429
pub fn call_memcpy<'a, 'll: 'a, 'tcx: 'll,
429430
Value : ?Sized,
430-
Builder: BuilderMethods<'a, 'll, 'tcx, Value>>(
431+
Builder: BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock>>(
431432
bx: &Builder,
432433
dst: &'ll Value,
433434
src: &'ll Value,
@@ -456,7 +457,7 @@ pub fn call_memcpy<'a, 'll: 'a, 'tcx: 'll,
456457

457458
pub fn memcpy_ty<'a, 'll: 'a, 'tcx: 'll,
458459
Value : ?Sized,
459-
Builder: BuilderMethods<'a, 'll, 'tcx, Value>>(
460+
Builder: BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock>>(
460461
bx: &Builder,
461462
dst: &'ll Value,
462463
src: &'ll Value,

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, &'ll Value> {
58+
impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock>
59+
for Builder<'a, 'll, 'tcx, &'ll Value> {
5960
fn new_block<'b>(
6061
cx: &'a CodegenCx<'ll, 'tcx, &'ll Value>,
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
@@ -23,6 +23,7 @@ use type_::Type;
2323
use glue;
2424

2525
use traits::BuilderMethods;
26+
use llvm::BasicBlock;
2627

2728
use std::fmt;
2829

@@ -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)