提交 1bcb4df1 编写于 作者: D Denis Merigoux 提交者: Eduard-Mihai Burtescu

Generalized OperandBundleDef in BuilderMethods

上级 bc86624c
......@@ -191,7 +191,7 @@ fn invoke(&self,
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 @@ fn invoke(&self,
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 @@ 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<&traits::OperandBundleDef<'ll, &'ll Value>>) -> &'ll Value {
self.count_insn("call");
debug!("Call {:?} with args ({:?})",
......@@ -1199,7 +1199,7 @@ fn call(&self, llfn: &'ll Value, args: &[&'ll Value],
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 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 @@ pub fn cleanuppad(&self) -> &'ll Value {
self.cleanuppad
}
pub fn bundle(&self) -> &OperandBundleDef<'ll> {
pub fn bundle(&self) -> &OperandBundleDef<'ll, &'ll Value> {
&self.operand
}
}
......
......@@ -28,6 +28,7 @@
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 @@ pub fn new(name: &str, vals: &[&'a Value]) -> Self {
};
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::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 @@ fn invoke(
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 @@ fn check_call<'b>(
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;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册