Skip to content

Commit 1bcb4df

Browse files
denismerigouxeddyb
authored andcommitted
Generalized OperandBundleDef in BuilderMethods
1 parent bc86624 commit 1bcb4df

File tree

4 files changed

+31
-12
lines changed

4 files changed

+31
-12
lines changed

src/librustc_codegen_llvm/builder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,15 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock>
191191
args: &[&'ll Value],
192192
then: &'ll BasicBlock,
193193
catch: &'ll BasicBlock,
194-
bundle: Option<&OperandBundleDef<'ll>>) -> &'ll Value {
194+
bundle: Option<&traits::OperandBundleDef<'ll, &'ll Value>>) -> &'ll Value {
195195
self.count_insn("invoke");
196196

197197
debug!("Invoke {:?} with args ({:?})",
198198
llfn,
199199
args);
200200

201201
let args = self.check_call("invoke", llfn, args);
202-
let bundle = bundle.map(|b| &*b.raw);
202+
let bundle = bundle.map(|b| &*(OperandBundleDef::from_generic(b)).raw);
203203

204204
unsafe {
205205
llvm::LLVMRustBuildInvoke(self.llbuilder,
@@ -1191,15 +1191,15 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock>
11911191
}
11921192

11931193
fn call(&self, llfn: &'ll Value, args: &[&'ll Value],
1194-
bundle: Option<&OperandBundleDef<'ll>>) -> &'ll Value {
1194+
bundle: Option<&traits::OperandBundleDef<'ll, &'ll Value>>) -> &'ll Value {
11951195
self.count_insn("call");
11961196

11971197
debug!("Call {:?} with args ({:?})",
11981198
llfn,
11991199
args);
12001200

12011201
let args = self.check_call("call", llfn, args);
1202-
let bundle = bundle.map(|b| &*b.raw);
1202+
let bundle = bundle.map(|b| &*(OperandBundleDef::from_generic(b)).raw);
12031203

12041204
unsafe {
12051205
llvm::LLVMRustBuildCall(

src/librustc_codegen_llvm/common.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//! Code that is useful in various codegen modules.
1414
1515
use llvm::{self, TypeKind};
16-
use llvm::{True, False, Bool, OperandBundleDef};
16+
use llvm::{True, False, Bool};
1717
use rustc::hir::def_id::DefId;
1818
use rustc::middle::lang_items::LangItem;
1919
use abi;
@@ -28,7 +28,7 @@ use value::{Value, ValueTrait};
2828
use rustc::ty::{self, Ty, TyCtxt};
2929
use rustc::ty::layout::{HasDataLayout, LayoutOf};
3030
use rustc::hir;
31-
use traits::BuilderMethods;
31+
use traits::{BuilderMethods, OperandBundleDef};
3232

3333
use libc::{c_uint, c_char};
3434

@@ -91,22 +91,22 @@ pub fn type_is_freeze<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bo
9191
/// the `OperandBundleDef` value created for MSVC landing pads.
9292
pub struct Funclet<'ll> {
9393
cleanuppad: &'ll Value,
94-
operand: OperandBundleDef<'ll>,
94+
operand: OperandBundleDef<'ll, &'ll Value>,
9595
}
9696

9797
impl Funclet<'ll> {
9898
pub fn new(cleanuppad: &'ll Value) -> Self {
9999
Funclet {
100100
cleanuppad,
101-
operand: OperandBundleDef::new("funclet", &[cleanuppad]),
101+
operand: OperandBundleDef::new("funclet", cleanuppad),
102102
}
103103
}
104104

105105
pub fn cleanuppad(&self) -> &'ll Value {
106106
self.cleanuppad
107107
}
108108

109-
pub fn bundle(&self) -> &OperandBundleDef<'ll> {
109+
pub fn bundle(&self) -> &OperandBundleDef<'ll, &'ll Value> {
110110
&self.operand
111111
}
112112
}

src/librustc_codegen_llvm/llvm/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use std::ffi::CStr;
2828
use std::cell::RefCell;
2929
use libc::{self, c_uint, c_char, size_t};
3030
use rustc_data_structures::small_c_str::SmallCStr;
31+
use traits;
3132

3233
pub mod archive_ro;
3334
pub mod diagnostic;
@@ -271,6 +272,10 @@ impl OperandBundleDef<'a> {
271272
};
272273
OperandBundleDef { raw: def }
273274
}
275+
276+
pub fn from_generic(bundle : &traits::OperandBundleDef<'a, &'a Value>) -> Self {
277+
Self::new(bundle.name, &[bundle.val])
278+
}
274279
}
275280

276281
impl Drop for OperandBundleDef<'a> {

src/librustc_codegen_llvm/traits.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,32 @@
99
// except according to those terms.
1010

1111
use llvm::{AtomicRmwBinOp, AtomicOrdering, SynchronizationScope, AsmDialect};
12-
use llvm::OperandBundleDef;
1312
use common::*;
1413
use type_::Type;
1514
use libc::c_char;
1615
use rustc::ty::TyCtxt;
1716
use rustc::ty::layout::{Align, Size};
1817
use rustc::session::Session;
1918
use builder::MemFlags;
19+
use value::Value;
2020

2121
use std::borrow::Cow;
2222
use std::ops::Range;
2323

24+
pub struct OperandBundleDef<'a, Value : 'a> {
25+
pub name: &'a str,
26+
pub val: Value
27+
}
28+
29+
impl OperandBundleDef<'ll, &'ll Value> {
30+
pub fn new(name: &'ll str, val: &'ll Value) -> Self {
31+
OperandBundleDef {
32+
name,
33+
val,
34+
}
35+
}
36+
}
37+
2438
pub enum IntPredicate {
2539
IntEQ,
2640
IntNE,
@@ -97,7 +111,7 @@ pub trait BuilderMethods<'a, 'll :'a, 'tcx: 'll,
97111
args: &[&'ll Value],
98112
then: &'ll BasicBlock,
99113
catch: &'ll BasicBlock,
100-
bundle: Option<&OperandBundleDef<'ll>>
114+
bundle: Option<&OperandBundleDef<'ll, &'ll Value>>
101115
) -> &'ll Value;
102116
fn unreachable(&self);
103117
fn add(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value;
@@ -313,6 +327,6 @@ pub trait BuilderMethods<'a, 'll :'a, 'tcx: 'll,
313327
fn call_lifetime_intrinsic(&self, intrinsic: &str, ptr: &'ll Value, size: Size);
314328

315329
fn call(&self, llfn: &'ll Value, args: &[&'ll Value],
316-
bundle: Option<&OperandBundleDef<'ll>>) -> &'ll Value;
330+
bundle: Option<&OperandBundleDef<'ll, &'ll Value>>) -> &'ll Value;
317331
fn zext(&self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value;
318332
}

0 commit comments

Comments
 (0)