-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rustc: Make trans collect/partition a query
This commit moves the `collect_and_partition_translation_items` function into a query on `TyCtxt` instead of a free function in trans, allowing us to track dependencies and such of the function.
- Loading branch information
1 parent
dba3ddd
commit 132bde7
Showing
12 changed files
with
352 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
use syntax::ast::NodeId; | ||
use syntax::symbol::InternedString; | ||
use ty::Instance; | ||
use util::nodemap::FxHashMap; | ||
|
||
#[derive(PartialEq, Eq, Clone, Copy, Debug, Hash)] | ||
pub enum TransItem<'tcx> { | ||
Fn(Instance<'tcx>), | ||
Static(NodeId), | ||
GlobalAsm(NodeId), | ||
} | ||
|
||
pub struct CodegenUnit<'tcx> { | ||
/// A name for this CGU. Incremental compilation requires that | ||
/// name be unique amongst **all** crates. Therefore, it should | ||
/// contain something unique to this crate (e.g., a module path) | ||
/// as well as the crate name and disambiguator. | ||
name: InternedString, | ||
items: FxHashMap<TransItem<'tcx>, (Linkage, Visibility)>, | ||
} | ||
|
||
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] | ||
pub enum Linkage { | ||
External, | ||
AvailableExternally, | ||
LinkOnceAny, | ||
LinkOnceODR, | ||
WeakAny, | ||
WeakODR, | ||
Appending, | ||
Internal, | ||
Private, | ||
ExternalWeak, | ||
Common, | ||
} | ||
|
||
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] | ||
pub enum Visibility { | ||
Default, | ||
Hidden, | ||
Protected, | ||
} | ||
|
||
impl<'tcx> CodegenUnit<'tcx> { | ||
pub fn new(name: InternedString) -> CodegenUnit<'tcx> { | ||
CodegenUnit { | ||
name: name, | ||
items: FxHashMap(), | ||
} | ||
} | ||
|
||
pub fn name(&self) -> &InternedString { | ||
&self.name | ||
} | ||
|
||
pub fn set_name(&mut self, name: InternedString) { | ||
self.name = name; | ||
} | ||
|
||
pub fn items(&self) -> &FxHashMap<TransItem<'tcx>, (Linkage, Visibility)> { | ||
&self.items | ||
} | ||
|
||
pub fn items_mut(&mut self) | ||
-> &mut FxHashMap<TransItem<'tcx>, (Linkage, Visibility)> | ||
{ | ||
&mut self.items | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.