Skip to content
Snippets Groups Projects

Minimal runtime for simple examples

Merged rarbore2 requested to merge proc_macro_rt into main
18 files
+ 711
1249
Compare changes
  • Side-by-side
  • Inline
Files
18
+ 12
11
extern crate hercules_ir;
extern crate hercules_ir;
extern crate hercules_rt;
use std::collections::HashMap;
use std::collections::HashMap;
use self::hercules_ir::*;
use self::hercules_ir::*;
use self::hercules_rt::manifest::*;
/*
/*
* Pretty much all of the codegen functions need to take in some large subset of
* Pretty much all of the codegen functions need to take in some large subset of
@@ -188,10 +186,10 @@ impl<'a> FunctionContext<'a> {
@@ -188,10 +186,10 @@ impl<'a> FunctionContext<'a> {
pub(crate) fn partition_control_successors(
pub(crate) fn partition_control_successors(
&self,
&self,
partition_id: PartitionID,
partition_id: PartitionID,
) -> Vec<PartitionID> {
) -> Vec<(PartitionID, NodeID)> {
let partition = &self.partitions_inverted_map[partition_id.idx()];
let partition = &self.partitions_inverted_map[partition_id.idx()];
let mut partitions: Vec<PartitionID> = partition
partition
.iter()
.iter()
// Only consider nodes in other partitions that are successors of
// Only consider nodes in other partitions that are successors of
// control nodes. These are necessarily other control nodes.
// control nodes. These are necessarily other control nodes.
@@ -205,14 +203,11 @@ impl<'a> FunctionContext<'a> {
@@ -205,14 +203,11 @@ impl<'a> FunctionContext<'a> {
.into_iter()
.into_iter()
.map(|id| self.plan.partitions[id.idx()])
.map(|id| self.plan.partitions[id.idx()])
.filter(|id| *id != partition_id)
.filter(|id| *id != partition_id)
 
.map(move |part_id| (part_id, *id))
})
})
// We want a flat list of all such partitions.
// We want a flat list of all such partitions.
.flatten()
.flatten()
.collect();
.collect()
// We only want one copy of the ID per partition.
partitions.dedup();
partitions
}
}
/*
/*
@@ -376,6 +371,12 @@ impl<'a> PartitionContext<'a> {
@@ -376,6 +371,12 @@ impl<'a> PartitionContext<'a> {
manifest.outputs.push(PartitionOutput::ControlIndicator);
manifest.outputs.push(PartitionOutput::ControlIndicator);
}
}
 
// Store the successor partitions.
 
manifest.successor_partitions = control_successors
 
.into_iter()
 
.map(|(part_id, control_id)| (control_id.idx() as u32, part_id.idx() as u32))
 
.collect();
 
PartitionContext {
PartitionContext {
function,
function,
partition_id,
partition_id,
@@ -438,7 +439,7 @@ pub(crate) fn generate_type_strings(module: &Module) -> Vec<String> {
@@ -438,7 +439,7 @@ pub(crate) fn generate_type_strings(module: &Module) -> Vec<String> {
// since a type may reference a type ID ahead of it in the vector. Instead,
// since a type may reference a type ID ahead of it in the vector. Instead,
// iterate types in a bottom up order with respect to the type intern DAGs.
// iterate types in a bottom up order with respect to the type intern DAGs.
let mut llvm_types = vec!["".to_string(); module.types.len()];
let mut llvm_types = vec!["".to_string(); module.types.len()];
for id in module.types_bottom_up() {
for id in types_bottom_up(&module.types) {
llvm_types[id.idx()] = generate_type_string(&module.types[id.idx()], &llvm_types);
llvm_types[id.idx()] = generate_type_string(&module.types[id.idx()], &llvm_types);
}
}
@@ -497,7 +498,7 @@ pub(crate) fn generate_constant_strings(module: &Module) -> Vec<String> {
@@ -497,7 +498,7 @@ pub(crate) fn generate_constant_strings(module: &Module) -> Vec<String> {
// Render constants into LLVM IR. This is done in a very similar manner as
// Render constants into LLVM IR. This is done in a very similar manner as
// types.
// types.
let mut llvm_constants = vec!["".to_string(); module.constants.len()];
let mut llvm_constants = vec!["".to_string(); module.constants.len()];
for id in module.constants_bottom_up() {
for id in constants_bottom_up(&module.constants) {
llvm_constants[id.idx()] = generate_constant_string(
llvm_constants[id.idx()] = generate_constant_string(
id,
id,
&module.constants[id.idx()],
&module.constants[id.idx()],
Loading