diff options
| author | Denis Merigoux <denis.merigoux@gmail.com> | 2018-08-21 17:39:43 +0200 |
|---|---|---|
| committer | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2018-11-16 14:11:09 +0200 |
| commit | 1bcb4df16678a71b484ea9d1b65911f22b381d86 (patch) | |
| tree | 370b780f16b7594c571022d6f6efb4f27f12ab28 /src/librustc_codegen_llvm | |
| parent | bc86624c43a24ed569a08aaeae3bdea7be181bf7 (diff) | |
| download | rust-1bcb4df16678a71b484ea9d1b65911f22b381d86.tar.gz rust-1bcb4df16678a71b484ea9d1b65911f22b381d86.zip | |
Generalized OperandBundleDef in BuilderMethods
Diffstat (limited to 'src/librustc_codegen_llvm')
| -rw-r--r-- | src/librustc_codegen_llvm/builder.rs | 8 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/common.rs | 10 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/llvm/mod.rs | 5 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/traits.rs | 20 |
4 files changed, 31 insertions, 12 deletions
diff --git a/src/librustc_codegen_llvm/builder.rs b/src/librustc_codegen_llvm/builder.rs index b63bd8f4e3d..f8ab6fc4ec2 100644 --- a/src/librustc_codegen_llvm/builder.rs +++ b/src/librustc_codegen_llvm/builder.rs @@ -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( diff --git a/src/librustc_codegen_llvm/common.rs b/src/librustc_codegen_llvm/common.rs index 66f14322fc6..b4b75ddd181 100644 --- a/src/librustc_codegen_llvm/common.rs +++ b/src/librustc_codegen_llvm/common.rs @@ -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 } } diff --git a/src/librustc_codegen_llvm/llvm/mod.rs b/src/librustc_codegen_llvm/llvm/mod.rs index fbd5192a63f..3b5f0b0f7df 100644 --- a/src/librustc_codegen_llvm/llvm/mod.rs +++ b/src/librustc_codegen_llvm/llvm/mod.rs @@ -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> { diff --git a/src/librustc_codegen_llvm/traits.rs b/src/librustc_codegen_llvm/traits.rs index a3a90952958..e23eeac1c29 100644 --- a/src/librustc_codegen_llvm/traits.rs +++ b/src/librustc_codegen_llvm/traits.rs @@ -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; } |
