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