Generalized OperandBundleDef in BuilderMethods
This commit is contained in:
parent
bc86624c43
commit
1bcb4df166
4 changed files with 31 additions and 12 deletions
|
@ -191,7 +191,7 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock>
|
|||
args: &[&'ll Value],
|
||||
then: &'ll BasicBlock,
|
||||
catch: &'ll BasicBlock,
|
||||
bundle: Option<&OperandBundleDef<'ll>>) -> &'ll Value {
|
||||
bundle: Option<&traits::OperandBundleDef<'ll, &'ll Value>>) -> &'ll Value {
|
||||
self.count_insn("invoke");
|
||||
|
||||
debug!("Invoke {:?} with args ({:?})",
|
||||
|
@ -199,7 +199,7 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock>
|
|||
args);
|
||||
|
||||
let args = self.check_call("invoke", llfn, args);
|
||||
let bundle = bundle.map(|b| &*b.raw);
|
||||
let bundle = bundle.map(|b| &*(OperandBundleDef::from_generic(b)).raw);
|
||||
|
||||
unsafe {
|
||||
llvm::LLVMRustBuildInvoke(self.llbuilder,
|
||||
|
@ -1191,7 +1191,7 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock>
|
|||
}
|
||||
|
||||
fn call(&self, llfn: &'ll Value, args: &[&'ll Value],
|
||||
bundle: Option<&OperandBundleDef<'ll>>) -> &'ll Value {
|
||||
bundle: Option<&traits::OperandBundleDef<'ll, &'ll Value>>) -> &'ll Value {
|
||||
self.count_insn("call");
|
||||
|
||||
debug!("Call {:?} with args ({:?})",
|
||||
|
@ -1199,7 +1199,7 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock>
|
|||
args);
|
||||
|
||||
let args = self.check_call("call", llfn, args);
|
||||
let bundle = bundle.map(|b| &*b.raw);
|
||||
let bundle = bundle.map(|b| &*(OperandBundleDef::from_generic(b)).raw);
|
||||
|
||||
unsafe {
|
||||
llvm::LLVMRustBuildCall(
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
//! Code that is useful in various codegen modules.
|
||||
|
||||
use llvm::{self, TypeKind};
|
||||
use llvm::{True, False, Bool, OperandBundleDef};
|
||||
use llvm::{True, False, Bool};
|
||||
use rustc::hir::def_id::DefId;
|
||||
use rustc::middle::lang_items::LangItem;
|
||||
use abi;
|
||||
|
@ -28,7 +28,7 @@ use value::{Value, ValueTrait};
|
|||
use rustc::ty::{self, Ty, TyCtxt};
|
||||
use rustc::ty::layout::{HasDataLayout, LayoutOf};
|
||||
use rustc::hir;
|
||||
use traits::BuilderMethods;
|
||||
use traits::{BuilderMethods, OperandBundleDef};
|
||||
|
||||
use libc::{c_uint, c_char};
|
||||
|
||||
|
@ -91,14 +91,14 @@ pub fn type_is_freeze<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bo
|
|||
/// the `OperandBundleDef` value created for MSVC landing pads.
|
||||
pub struct Funclet<'ll> {
|
||||
cleanuppad: &'ll Value,
|
||||
operand: OperandBundleDef<'ll>,
|
||||
operand: OperandBundleDef<'ll, &'ll Value>,
|
||||
}
|
||||
|
||||
impl Funclet<'ll> {
|
||||
pub fn new(cleanuppad: &'ll Value) -> Self {
|
||||
Funclet {
|
||||
cleanuppad,
|
||||
operand: OperandBundleDef::new("funclet", &[cleanuppad]),
|
||||
operand: OperandBundleDef::new("funclet", cleanuppad),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ impl Funclet<'ll> {
|
|||
self.cleanuppad
|
||||
}
|
||||
|
||||
pub fn bundle(&self) -> &OperandBundleDef<'ll> {
|
||||
pub fn bundle(&self) -> &OperandBundleDef<'ll, &'ll Value> {
|
||||
&self.operand
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ use std::ffi::CStr;
|
|||
use std::cell::RefCell;
|
||||
use libc::{self, c_uint, c_char, size_t};
|
||||
use rustc_data_structures::small_c_str::SmallCStr;
|
||||
use traits;
|
||||
|
||||
pub mod archive_ro;
|
||||
pub mod diagnostic;
|
||||
|
@ -271,6 +272,10 @@ impl OperandBundleDef<'a> {
|
|||
};
|
||||
OperandBundleDef { raw: def }
|
||||
}
|
||||
|
||||
pub fn from_generic(bundle : &traits::OperandBundleDef<'a, &'a Value>) -> Self {
|
||||
Self::new(bundle.name, &[bundle.val])
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for OperandBundleDef<'a> {
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
// except according to those terms.
|
||||
|
||||
use llvm::{AtomicRmwBinOp, AtomicOrdering, SynchronizationScope, AsmDialect};
|
||||
use llvm::OperandBundleDef;
|
||||
use common::*;
|
||||
use type_::Type;
|
||||
use libc::c_char;
|
||||
|
@ -17,10 +16,25 @@ use rustc::ty::TyCtxt;
|
|||
use rustc::ty::layout::{Align, Size};
|
||||
use rustc::session::Session;
|
||||
use builder::MemFlags;
|
||||
use value::Value;
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::ops::Range;
|
||||
|
||||
pub struct OperandBundleDef<'a, Value : 'a> {
|
||||
pub name: &'a str,
|
||||
pub val: Value
|
||||
}
|
||||
|
||||
impl OperandBundleDef<'ll, &'ll Value> {
|
||||
pub fn new(name: &'ll str, val: &'ll Value) -> Self {
|
||||
OperandBundleDef {
|
||||
name,
|
||||
val,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub enum IntPredicate {
|
||||
IntEQ,
|
||||
IntNE,
|
||||
|
@ -97,7 +111,7 @@ pub trait BuilderMethods<'a, 'll :'a, 'tcx: 'll,
|
|||
args: &[&'ll Value],
|
||||
then: &'ll BasicBlock,
|
||||
catch: &'ll BasicBlock,
|
||||
bundle: Option<&OperandBundleDef<'ll>>
|
||||
bundle: Option<&OperandBundleDef<'ll, &'ll Value>>
|
||||
) -> &'ll Value;
|
||||
fn unreachable(&self);
|
||||
fn add(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value;
|
||||
|
@ -313,6 +327,6 @@ pub trait BuilderMethods<'a, 'll :'a, 'tcx: 'll,
|
|||
fn call_lifetime_intrinsic(&self, intrinsic: &str, ptr: &'ll Value, size: Size);
|
||||
|
||||
fn call(&self, llfn: &'ll Value, args: &[&'ll Value],
|
||||
bundle: Option<&OperandBundleDef<'ll>>) -> &'ll Value;
|
||||
bundle: Option<&OperandBundleDef<'ll, &'ll Value>>) -> &'ll Value;
|
||||
fn zext(&self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue