pub struct Module {
pub name: Symbol,
pub triple: Triple,
pub datalayout: DataLayout,
/* private fields */
}Expand description
One translation unit, or after LTO the several that were linked into one.
Fields§
§name: SymbolWhat it is called, which is the source file name for a module from the frontend. It appears in the textual form and in the debug info and nothing branches on it.
triple: TripleThe target it is for.
datalayout: DataLayoutThe layout it was built assuming.
Implementations§
Source§impl Module
impl Module
Sourcepub fn new(name: Symbol, target: &TargetInfo) -> Self
pub fn new(name: Symbol, target: &TargetInfo) -> Self
An empty module for that target.
Sourcepub fn add_func(&mut self, func: Func) -> FuncId
pub fn add_func(&mut self, func: Func) -> FuncId
Adds a function, which is a declaration if it has no blocks.
§Panics
Panics if the module already has a symbol of that name. Merging a declaration with a definition is the frontend’s job and it has the declarations to do it with; by the time something is in the IR a name means one thing.
Sourcepub fn add_global(&mut self, global: Global) -> GlobalId
pub fn add_global(&mut self, global: Global) -> GlobalId
Adds a global variable, which is a declaration if it has no image.
§Panics
Panics if the module already has a symbol of that name.
Sourcepub fn add_alias(&mut self, alias: Alias) -> AliasId
pub fn add_alias(&mut self, alias: Alias) -> AliasId
Adds an alias.
The target is not resolved here, and it need not be in this module: an alias of something in another object is a thing people write.
§Panics
Panics if the module already has a symbol of that name.
Sourcepub fn lookup(&self, name: Symbol) -> Option<SymbolRef>
pub fn lookup(&self, name: Symbol) -> Option<SymbolRef>
What that name refers to, or None if this module does not define or declare it.
Sourcepub fn funcs(&self) -> impl Iterator<Item = FuncId> + use<>
pub fn funcs(&self) -> impl Iterator<Item = FuncId> + use<>
Every function, in the order they were added.
Sourcepub fn globals(&self) -> impl Iterator<Item = GlobalId> + use<>
pub fn globals(&self) -> impl Iterator<Item = GlobalId> + use<>
Every global variable, in the order they were added.
Sourcepub fn aliases(&self) -> impl Iterator<Item = AliasId> + use<>
pub fn aliases(&self) -> impl Iterator<Item = AliasId> + use<>
Every alias, in the order they were added.
Sourcepub fn add_meta(&mut self, node: MetaNode) -> Meta
pub fn add_meta(&mut self, node: MetaNode) -> Meta
Adds a metadata node and gives back the reference an instruction holds.
The nodes live here rather than in a function because a TBAA tree is shared by every memory operation in the module and duplicating it per function would make two accesses to the same type look unrelated.
Sourcepub fn metadata(&self) -> impl Iterator<Item = Meta> + use<>
pub fn metadata(&self) -> impl Iterator<Item = Meta> + use<>
Every metadata node, in the order they were added.
Sourcepub fn push_data(&mut self, data: &[Datum]) -> DataList
pub fn push_data(&mut self, data: &[Datum]) -> DataList
Records a run of data and gives back the list a global holds.
Sourcepub fn push_bytes(&mut self, bytes: &[u8]) -> ByteRange
pub fn push_bytes(&mut self, bytes: &[u8]) -> ByteRange
Records literal bytes and gives back the range a Datum::Bytes holds.
Sourcepub fn add_imm(&mut self, imm: Imm) -> Idx<Imm>
pub fn add_imm(&mut self, imm: Imm) -> Idx<Imm>
Records a scalar value and gives back the index a Datum::Scalar holds.
Sourcepub fn add_reloc(&mut self, reloc: Reloc) -> Idx<Reloc>
pub fn add_reloc(&mut self, reloc: Reloc) -> Idx<Reloc>
Records a relocation and gives back the index a Datum::Addr holds.
Sourcepub fn counts(&self) -> ModuleCounts
pub fn counts(&self) -> ModuleCounts
How much is in it, for the -fstats output and for a test that wants to say a pass
deleted something without saying which.