1
Fork 0

Generalized BasicBlocks in BuilderMethods trait

This commit is contained in:
Denis Merigoux 2018-08-20 17:44:18 +02:00 committed by Eduard-Mihai Burtescu
parent 34c5dc045f
commit 14798d6937
4 changed files with 16 additions and 8 deletions

View file

@ -76,6 +76,7 @@ use rustc_data_structures::sync::Lrc;
use rustc_data_structures::indexed_vec::Idx; use rustc_data_structures::indexed_vec::Idx;
use traits::BuilderMethods; use traits::BuilderMethods;
use llvm::BasicBlock;
use std::any::Any; use std::any::Any;
use std::cmp; use std::cmp;
@ -391,7 +392,7 @@ pub fn call_assume(bx: &Builder<'_, 'll, '_>, val: &'ll Value) {
pub fn from_immediate<'a, 'll: 'a, 'tcx: 'll, pub fn from_immediate<'a, 'll: 'a, 'tcx: 'll,
Value : ?Sized, Value : ?Sized,
Builder: BuilderMethods<'a, 'll, 'tcx, Value>>( Builder: BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock>>(
bx: &Builder, bx: &Builder,
val: &'ll Value val: &'ll Value
) -> &'ll Value where Value : ValueTrait { ) -> &'ll Value where Value : ValueTrait {
@ -426,7 +427,7 @@ pub fn to_immediate_scalar(
pub fn call_memcpy<'a, 'll: 'a, 'tcx: 'll, pub fn call_memcpy<'a, 'll: 'a, 'tcx: 'll,
Value : ?Sized, Value : ?Sized,
Builder: BuilderMethods<'a, 'll, 'tcx, Value>>( Builder: BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock>>(
bx: &Builder, bx: &Builder,
dst: &'ll Value, dst: &'ll Value,
dst_align: Align, dst_align: Align,
@ -452,7 +453,7 @@ pub fn call_memcpy<'a, 'll: 'a, 'tcx: 'll,
pub fn memcpy_ty<'a, 'll: 'a, 'tcx: 'll, pub fn memcpy_ty<'a, 'll: 'a, 'tcx: 'll,
Value : ?Sized, Value : ?Sized,
Builder: BuilderMethods<'a, 'll, 'tcx, Value>>( Builder: BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock>>(
bx: &Builder, bx: &Builder,
dst: &'ll Value, dst: &'ll Value,
dst_align: Align, dst_align: Align,

View file

@ -55,7 +55,8 @@ bitflags! {
} }
} }
impl BuilderMethods<'a, 'll, 'tcx, Value> for Builder<'a, 'll, 'tcx> { impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock>
for Builder<'a, 'll, 'tcx> {
fn new_block<'b>( fn new_block<'b>(
cx: &'a CodegenCx<'ll, 'tcx>, cx: &'a CodegenCx<'ll, 'tcx>,
llfn: &'ll Value, llfn: &'ll Value,

View file

@ -22,6 +22,7 @@ use type_::Type;
use glue; use glue;
use traits::BuilderMethods; use traits::BuilderMethods;
use llvm::BasicBlock;
use std::fmt; use std::fmt;
@ -281,7 +282,8 @@ impl OperandValue<&'ll Value> {
impl<'a, 'll: 'a, 'tcx: 'll, Value : ?Sized> OperandValue<&'ll Value> where impl<'a, 'll: 'a, 'tcx: 'll, Value : ?Sized> OperandValue<&'ll Value> where
Value : ValueTrait, Value : ValueTrait,
Builder<'a, 'll, 'tcx, &'ll Value>: BuilderMethods<'a, 'll, 'tcx, Value> Builder<'a, 'll, 'tcx, &'ll Value>:
BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock>
{ {
pub fn nontemporal_store( pub fn nontemporal_store(
self, self,
@ -291,7 +293,7 @@ impl<'a, 'll: 'a, 'tcx: 'll, Value : ?Sized> OperandValue<&'ll Value> where
self.store_with_flags(bx, dest, MemFlags::NONTEMPORAL); self.store_with_flags(bx, dest, MemFlags::NONTEMPORAL);
} }
fn store_with_flags<Builder: BuilderMethods<'a, 'll, 'tcx, Value>>( fn store_with_flags<Builder: BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock>>(
self, self,
bx: &Builder, bx: &Builder,
dest: PlaceRef<'tcx, &'ll Value>, dest: PlaceRef<'tcx, &'ll Value>,

View file

@ -10,7 +10,7 @@
use llvm::{AtomicRmwBinOp, AtomicOrdering, SynchronizationScope, AsmDialect}; use llvm::{AtomicRmwBinOp, AtomicOrdering, SynchronizationScope, AsmDialect};
use llvm::{IntPredicate, RealPredicate, OperandBundleDef}; use llvm::{IntPredicate, RealPredicate, OperandBundleDef};
use llvm::{self, BasicBlock}; use llvm;
use common::*; use common::*;
use type_::Type; use type_::Type;
use libc::c_char; use libc::c_char;
@ -23,7 +23,11 @@ use std::borrow::Cow;
use std::ops::Range; use std::ops::Range;
pub trait BuilderMethods<'a, 'll :'a, 'tcx: 'll, Value : ?Sized> { pub trait BuilderMethods<'a, 'll :'a, 'tcx: 'll,
Value : ?Sized,
BasicBlock: ?Sized
> {
fn new_block<'b>( fn new_block<'b>(
cx: &'a CodegenCx<'ll, 'tcx, &'ll Value>, cx: &'a CodegenCx<'ll, 'tcx, &'ll Value>,
llfn: &'ll Value, llfn: &'ll Value,