Skip to content
Snippets Groups Projects

Misc. improvements

Merged rarbore2 requested to merge misc into main
Files
7
+ 17
9
@@ -29,6 +29,15 @@ pub fn codegen<W: Write>(
@@ -29,6 +29,15 @@ pub fn codegen<W: Write>(
let llvm_types = generate_type_strings(module);
let llvm_types = generate_type_strings(module);
let llvm_constants = generate_constant_strings(module);
let llvm_constants = generate_constant_strings(module);
let llvm_dynamic_constants = generate_dynamic_constant_strings(module);
let llvm_dynamic_constants = generate_dynamic_constant_strings(module);
 
let type_sizes_aligns = (0..module.types.len())
 
.map(|idx| {
 
if module.types[idx].is_control() {
 
(None, 0)
 
} else {
 
type_size_and_alignment(module, TypeID::new(idx))
 
}
 
})
 
.collect();
// Generate a dummy uninitialized global - this is needed so that there'll
// Generate a dummy uninitialized global - this is needed so that there'll
// be a non-empty .bss section in the ELF object file.
// be a non-empty .bss section in the ELF object file.
@@ -55,6 +64,7 @@ pub fn codegen<W: Write>(
@@ -55,6 +64,7 @@ pub fn codegen<W: Write>(
llvm_types: &llvm_types,
llvm_types: &llvm_types,
llvm_constants: &llvm_constants,
llvm_constants: &llvm_constants,
llvm_dynamic_constants: &llvm_dynamic_constants,
llvm_dynamic_constants: &llvm_dynamic_constants,
 
type_sizes_aligns: &type_sizes_aligns,
partitions_inverted_map: plans[function_idx].invert_partition_map(),
partitions_inverted_map: plans[function_idx].invert_partition_map(),
};
};
@@ -65,15 +75,7 @@ pub fn codegen<W: Write>(
@@ -65,15 +75,7 @@ pub fn codegen<W: Write>(
Ok(ModuleManifest {
Ok(ModuleManifest {
functions: manifests,
functions: manifests,
types: module.types.clone(),
types: module.types.clone(),
type_sizes_aligns: (0..module.types.len())
type_sizes_aligns,
.map(|idx| {
if module.types[idx].is_control() {
(None, 0)
} else {
type_size_and_alignment(module, TypeID::new(idx))
}
})
.collect(),
dynamic_constants: module.dynamic_constants.clone(),
dynamic_constants: module.dynamic_constants.clone(),
// Get the types of all of the constants. This requires collecting over
// Get the types of all of the constants. This requires collecting over
// all of the functions, since the calculated types of constants may be
// all of the functions, since the calculated types of constants may be
@@ -185,6 +187,12 @@ impl<'a> FunctionContext<'a> {
@@ -185,6 +187,12 @@ impl<'a> FunctionContext<'a> {
param_types: self.function.param_types.clone(),
param_types: self.function.param_types.clone(),
return_type: self.function.return_type,
return_type: self.function.return_type,
typing: self.typing.clone(),
typing: self.typing.clone(),
 
used_constants: self
 
.function
 
.nodes
 
.iter()
 
.filter_map(|node| node.try_constant())
 
.collect(),
num_dynamic_constant_parameters: self.function.num_dynamic_constants,
num_dynamic_constant_parameters: self.function.num_dynamic_constants,
partitions: manifests,
partitions: manifests,
// TODO: populate dynamic constant rules.
// TODO: populate dynamic constant rules.
Loading