Skip to content

Commit b8e7061

Browse files
committed
Moved Funclet
1 parent 4a2f7c7 commit b8e7061

File tree

6 files changed

+56
-42
lines changed

6 files changed

+56
-42
lines changed

src/librustc_codegen_llvm/common.rs

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ 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::{OperandBundleDef, TypeKind};
33+
use rustc_codegen_utils::common::TypeKind;
3434

3535
use libc::{c_uint, c_char};
3636
use std::iter;
@@ -68,42 +68,6 @@ pub use context::CodegenCx;
6868
*
6969
*/
7070

71-
/// A structure representing an active landing pad for the duration of a basic
72-
/// block.
73-
///
74-
/// Each `Block` may contain an instance of this, indicating whether the block
75-
/// is part of a landing pad or not. This is used to make decision about whether
76-
/// to emit `invoke` instructions (e.g. in a landing pad we don't continue to
77-
/// use `invoke`) and also about various function call metadata.
78-
///
79-
/// For GNU exceptions (`landingpad` + `resume` instructions) this structure is
80-
/// just a bunch of `None` instances (not too interesting), but for MSVC
81-
/// exceptions (`cleanuppad` + `cleanupret` instructions) this contains data.
82-
/// When inside of a landing pad, each function call in LLVM IR needs to be
83-
/// annotated with which landing pad it's a part of. This is accomplished via
84-
/// the `OperandBundleDef` value created for MSVC landing pads.
85-
pub struct Funclet<'ll, V> {
86-
cleanuppad: V,
87-
operand: OperandBundleDef<'ll, V>,
88-
}
89-
90-
impl<'ll, V : CodegenObject> Funclet<'ll, V> {
91-
pub fn new(cleanuppad: V) -> Self {
92-
Funclet {
93-
cleanuppad,
94-
operand: OperandBundleDef::new("funclet", cleanuppad),
95-
}
96-
}
97-
98-
pub fn cleanuppad(&self) -> V {
99-
self.cleanuppad
100-
}
101-
102-
pub fn bundle(&self) -> &OperandBundleDef<'ll, V> {
103-
&self.operand
104-
}
105-
}
106-
10771
impl Backend<'ll> for CodegenCx<'ll, 'tcx, &'ll Value> {
10872
type Value = &'ll Value;
10973
type BasicBlock = &'ll BasicBlock;

src/librustc_codegen_llvm/interfaces/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,10 @@ pub use self::debuginfo::{DebugInfoMethods, DebugInfoBuilderMethods};
3232
pub use self::abi::{AbiMethods, AbiBuilderMethods};
3333
pub use self::declare::{DeclareMethods, PreDefineMethods};
3434
pub use self::asm::{AsmMethods, AsmBuilderMethods};
35-
36-
use std::fmt;
35+
pub use rustc_codegen_utils::interfaces::CodegenObject;
3736

3837
pub trait CodegenMethods<'ll, 'tcx: 'll> :
3938
Backend<'ll> + TypeMethods<'ll, 'tcx> + MiscMethods<'ll, 'tcx> + ConstMethods<'ll, 'tcx> +
4039
StaticMethods<'ll> + DebugInfoMethods<'ll, 'tcx> + AbiMethods<'tcx> +
4140
IntrinsicDeclarationMethods<'ll> + DeclareMethods<'ll, 'tcx> + AsmMethods +
4241
PreDefineMethods<'ll, 'tcx> {}
43-
44-
pub trait CodegenObject : Copy + PartialEq + fmt::Debug {}

src/librustc_codegen_llvm/mir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rustc::mir::{self, Mir};
1616
use rustc::ty::subst::Substs;
1717
use rustc::session::config::DebugInfo;
1818
use base;
19-
use common::Funclet;
19+
use rustc_codegen_utils::common::Funclet;
2020
use debuginfo::{self, VariableAccess, VariableKind, FunctionDebugContext};
2121
use monomorphize::Instance;
2222
use abi::{FnType, PassMode};

src/librustc_codegen_utils/common.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use rustc::ty::{self, Ty, TyCtxt};
1313
use syntax_pos::DUMMY_SP;
14+
use interfaces::CodegenObject;
1415

1516

1617
pub fn type_needs_drop<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bool {
@@ -39,6 +40,44 @@ impl<'a, V> OperandBundleDef<'a, V> {
3940
}
4041
}
4142

43+
44+
45+
/// A structure representing an active landing pad for the duration of a basic
46+
/// block.
47+
///
48+
/// Each `Block` may contain an instance of this, indicating whether the block
49+
/// is part of a landing pad or not. This is used to make decision about whether
50+
/// to emit `invoke` instructions (e.g. in a landing pad we don't continue to
51+
/// use `invoke`) and also about various function call metadata.
52+
///
53+
/// For GNU exceptions (`landingpad` + `resume` instructions) this structure is
54+
/// just a bunch of `None` instances (not too interesting), but for MSVC
55+
/// exceptions (`cleanuppad` + `cleanupret` instructions) this contains data.
56+
/// When inside of a landing pad, each function call in LLVM IR needs to be
57+
/// annotated with which landing pad it's a part of. This is accomplished via
58+
/// the `OperandBundleDef` value created for MSVC landing pads.
59+
pub struct Funclet<'ll, V> {
60+
cleanuppad: V,
61+
operand: OperandBundleDef<'ll, V>,
62+
}
63+
64+
impl<'ll, V : CodegenObject> Funclet<'ll, V> {
65+
pub fn new(cleanuppad: V) -> Self {
66+
Funclet {
67+
cleanuppad,
68+
operand: OperandBundleDef::new("funclet", cleanuppad),
69+
}
70+
}
71+
72+
pub fn cleanuppad(&self) -> V {
73+
self.cleanuppad
74+
}
75+
76+
pub fn bundle(&self) -> &OperandBundleDef<'ll, V> {
77+
&self.operand
78+
}
79+
}
80+
4281
pub enum IntPredicate {
4382
IntEQ,
4483
IntNE,
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use std::fmt;
12+
13+
pub trait CodegenObject : Copy + PartialEq + fmt::Debug {}

src/librustc_codegen_utils/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ pub mod codegen_backend;
4747
pub mod symbol_names;
4848
pub mod symbol_names_test;
4949
pub mod common;
50+
pub mod interfaces;
5051

5152
/// check for the #[rustc_error] annotation, which forces an
5253
/// error in codegen. This is used to write compile-fail tests

0 commit comments

Comments
 (0)