Skip to content

Commit e59420d

Browse files
committed
Moved OperandBundleDef
1 parent 0466dcd commit e59420d

File tree

6 files changed

+55
-45
lines changed

6 files changed

+55
-45
lines changed

src/librustc_codegen_llvm/builder.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
use llvm::{AtomicRmwBinOp, AtomicOrdering, SynchronizationScope, AsmDialect};
1212
use llvm::{self, False, OperandBundleDef, BasicBlock};
13-
use common;
1413
use rustc_codegen_utils::common::{IntPredicate, TypeKind, RealPredicate};
1514
use rustc_codegen_utils;
1615
use context::CodegenCx;
@@ -193,12 +192,14 @@ impl BuilderMethods<'a, 'll, 'tcx>
193192
}
194193
}
195194

196-
fn invoke(&self,
197-
llfn: &'ll Value,
198-
args: &[&'ll Value],
199-
then: &'ll BasicBlock,
200-
catch: &'ll BasicBlock,
201-
bundle: Option<&common::OperandBundleDef<'ll, &'ll Value>>) -> &'ll Value {
195+
fn invoke(
196+
&self,
197+
llfn: &'ll Value,
198+
args: &[&'ll Value],
199+
then: &'ll BasicBlock,
200+
catch: &'ll BasicBlock,
201+
bundle: Option<&rustc_codegen_utils::common::OperandBundleDef<'ll, &'ll Value>>
202+
) -> &'ll Value {
202203
self.count_insn("invoke");
203204

204205
debug!("Invoke {:?} with args ({:?})",
@@ -1320,8 +1321,12 @@ impl BuilderMethods<'a, 'll, 'tcx>
13201321
self.call(lifetime_intrinsic, &[self.cx.const_u64(size), ptr], None);
13211322
}
13221323

1323-
fn call(&self, llfn: &'ll Value, args: &[&'ll Value],
1324-
bundle: Option<&common::OperandBundleDef<'ll, &'ll Value>>) -> &'ll Value {
1324+
fn call(
1325+
&self,
1326+
llfn: &'ll Value,
1327+
args: &[&'ll Value],
1328+
bundle: Option<&rustc_codegen_utils::common::OperandBundleDef<'ll, &'ll Value>>
1329+
) -> &'ll Value {
13251330
self.count_insn("call");
13261331

13271332
debug!("Call {:?} with args ({:?})",

src/librustc_codegen_llvm/common.rs

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -30,42 +30,16 @@ use rustc::hir;
3030
use interfaces::BuilderMethods;
3131
use mir::constant::const_alloc_to_llvm;
3232
use mir::place::PlaceRef;
33-
use rustc_codegen_utils::common::TypeKind;
33+
use rustc_codegen_utils::common::{OperandBundleDef, TypeKind};
3434

3535
use libc::{c_uint, c_char};
3636

3737
use syntax::symbol::LocalInternedString;
3838
use syntax::ast::Mutability;
39-
use syntax_pos::{Span, DUMMY_SP};
39+
use syntax_pos::Span;
4040

4141
pub use context::CodegenCx;
4242

43-
pub fn type_needs_drop<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bool {
44-
ty.needs_drop(tcx, ty::ParamEnv::reveal_all())
45-
}
46-
47-
pub fn type_is_sized<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bool {
48-
ty.is_sized(tcx.at(DUMMY_SP), ty::ParamEnv::reveal_all())
49-
}
50-
51-
pub fn type_is_freeze<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bool {
52-
ty.is_freeze(tcx, ty::ParamEnv::reveal_all(), DUMMY_SP)
53-
}
54-
55-
pub struct OperandBundleDef<'a, V> {
56-
pub name: &'a str,
57-
pub val: V
58-
}
59-
60-
impl<V> OperandBundleDef<'ll, V> {
61-
pub fn new(name: &'ll str, val: V) -> Self {
62-
OperandBundleDef {
63-
name,
64-
val
65-
}
66-
}
67-
}
68-
6943
/*
7044
* A note on nomenclature of linking: "extern", "foreign", and "upcall".
7145
*

src/librustc_codegen_llvm/interfaces/builder.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use common::*;
12-
use rustc_codegen_utils::common::{IntPredicate, RealPredicate, AtomicOrdering, SynchronizationScope, AtomicRmwBinOp};
11+
use rustc_codegen_utils::common::{IntPredicate, RealPredicate, AtomicOrdering, SynchronizationScope, AtomicRmwBinOp, OperandBundleDef};
1312
use libc::c_char;
1413
use rustc::ty::TyCtxt;
1514
use rustc::ty::layout::{Align, Size};

src/librustc_codegen_llvm/llvm/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +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 common;
31+
use rustc_codegen_utils;
3232

3333
pub mod archive_ro;
3434
pub mod diagnostic;
@@ -273,7 +273,9 @@ impl OperandBundleDef<'a> {
273273
OperandBundleDef { raw: def }
274274
}
275275

276-
pub fn from_generic(bundle : &common::OperandBundleDef<'a, &'a Value>) -> Self {
276+
pub fn from_generic(
277+
bundle : &rustc_codegen_utils::common::OperandBundleDef<'a, &'a Value>
278+
) -> Self {
277279
Self::new(bundle.name, &[bundle.val])
278280
}
279281
}

src/librustc_codegen_llvm/type_.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use rustc::ty::layout::TyLayout;
2727
use rustc_target::abi::call::{CastTarget, FnType, Reg};
2828
use rustc_data_structures::small_c_str::SmallCStr;
2929
use common;
30+
use rustc_codegen_utils;
3031
use rustc_codegen_utils::common::TypeKind;
3132
use type_of::LayoutLlvmExt;
3233
use abi::{LlvmType, FnTypeExt};
@@ -373,15 +374,15 @@ impl DerivedTypeMethods<'ll, 'tcx> for CodegenCx<'ll, 'tcx, &'ll Value> {
373374
}
374375

375376
fn type_needs_drop(&self, ty: Ty<'tcx>) -> bool {
376-
common::type_needs_drop(*self.tcx(), ty)
377+
rustc_codegen_utils::common::type_needs_drop(*self.tcx(), ty)
377378
}
378379

379380
fn type_is_sized(&self, ty: Ty<'tcx>) -> bool {
380-
common::type_is_sized(*self.tcx(), ty)
381+
rustc_codegen_utils::common::type_is_sized(*self.tcx(), ty)
381382
}
382383

383384
fn type_is_freeze(&self, ty: Ty<'tcx>) -> bool {
384-
common::type_is_freeze(*self.tcx(), ty)
385+
rustc_codegen_utils::common::type_is_freeze(*self.tcx(), ty)
385386
}
386387

387388
fn type_has_metadata(&self, ty: Ty<'tcx>) -> bool {

src/librustc_codegen_utils/common.rs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,38 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10-
1110
#![allow(non_camel_case_types, non_snake_case)]
1211

12+
use rustc::ty::{self, Ty, TyCtxt};
13+
use syntax_pos::DUMMY_SP;
14+
15+
16+
pub fn type_needs_drop<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bool {
17+
ty.needs_drop(tcx, ty::ParamEnv::reveal_all())
18+
}
19+
20+
pub fn type_is_sized<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bool {
21+
ty.is_sized(tcx.at(DUMMY_SP), ty::ParamEnv::reveal_all())
22+
}
23+
24+
pub fn type_is_freeze<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bool {
25+
ty.is_freeze(tcx, ty::ParamEnv::reveal_all(), DUMMY_SP)
26+
}
27+
28+
pub struct OperandBundleDef<'a, V> {
29+
pub name: &'a str,
30+
pub val: V
31+
}
32+
33+
impl<'a, V> OperandBundleDef<'a, V> {
34+
pub fn new(name: &'a str, val: V) -> Self {
35+
OperandBundleDef {
36+
name,
37+
val
38+
}
39+
}
40+
}
41+
1342
pub enum IntPredicate {
1443
IntEQ,
1544
IntNE,

0 commit comments

Comments
 (0)