Skip to content
Snippets Groups Projects
Commit 12a8db0e authored by Russel Arbore's avatar Russel Arbore
Browse files

Just emit the used array constants

parent f8689077
No related branches found
No related tags found
1 merge request!25Misc. improvements
This commit is part of merge request !25. Comments created here will be created in the context of that merge request.
...@@ -185,6 +185,12 @@ impl<'a> FunctionContext<'a> { ...@@ -185,6 +185,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.
......
...@@ -57,6 +57,8 @@ pub struct FunctionManifest { ...@@ -57,6 +57,8 @@ pub struct FunctionManifest {
// Types of all of the nodes in this function. Used for figuring out the // Types of all of the nodes in this function. Used for figuring out the
// type of partition data inputs and outputs. // type of partition data inputs and outputs.
pub typing: Vec<TypeID>, pub typing: Vec<TypeID>,
// IDs of constants that are actually used in this function.
pub used_constants: Vec<ConstantID>,
// Number of dynamic constant parameters that need to provided. // Number of dynamic constant parameters that need to provided.
pub num_dynamic_constant_parameters: u32, pub num_dynamic_constant_parameters: u32,
// Manifests for constituent partitions. // Manifests for constituent partitions.
......
...@@ -215,9 +215,13 @@ fn codegen(manifest: &ModuleManifest, elf: &[u8]) -> Result<String, anyhow::Erro ...@@ -215,9 +215,13 @@ fn codegen(manifest: &ModuleManifest, elf: &[u8]) -> Result<String, anyhow::Erro
// Declare all of the array constant memories. We declare them as Vecs // Declare all of the array constant memories. We declare them as Vecs
// to allocate the memories. We emit multiplications of the dynamic // to allocate the memories. We emit multiplications of the dynamic
// constant dimensions to allocate the whole memory as one contiguous // constant dimensions to allocate the whole memory as one contiguous
// range. TODO: emit only the array constants actually used in this // range.
// function. for (arr_cons_num, arr_cons_id) in manifest
for (arr_cons_num, arr_cons_id) in manifest.array_cons_ids.iter().enumerate() { .array_cons_ids
.iter()
.filter(|id| function.used_constants.contains(id))
.enumerate()
{
let arr_ty_id = manifest let arr_ty_id = manifest
.constant_types .constant_types
.iter() .iter()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment