Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
CohenArthur committed Jul 30, 2024
1 parent 56d835b commit 4cc35d2
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 21 deletions.
6 changes: 2 additions & 4 deletions compiler/plc_driver/src/pipelines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ impl<T: SourceContainer + Sync> AnnotatedProject<T> {
unit,
dependencies,
literals,
todo!("give GOT layout for singlemodules?"),
todo!("give GOT layout for single modules?"),
)
})
.reduce(|a, b| {
Expand Down Expand Up @@ -390,7 +390,7 @@ impl<T: SourceContainer + Sync> AnnotatedProject<T> {
let got_layout = compile_options
.got_layout_file
.as_ref()
.map(|path| read_got_layout(&path, ConfigFormat::JSON))
.map(|path| read_got_layout(path, ConfigFormat::JSON))
.transpose()?;

let got_layout = Mutex::new(got_layout);
Expand Down Expand Up @@ -437,8 +437,6 @@ impl<T: SourceContainer + Sync> AnnotatedProject<T> {
&got_layout,
)?;

dbg!(module.persist_to_string());

module
.persist(
Some(&compile_directory),
Expand Down
11 changes: 0 additions & 11 deletions src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
use std::{
cell::RefCell,
collections::HashMap,
fs,
ops::Deref,
path::{Path, PathBuf},
sync::Mutex,
Expand Down Expand Up @@ -144,8 +143,6 @@ impl<'ink> CodeGen<'ink> {
acc.push(format!("{}_instance", p.get_name()));
acc
});
let test: Vec<_> =
program_globals.clone().into_iter().map(|s| crate::index::get_initializer_name(&s)).collect();

let functions = global_index.get_pous().values().filter_map(|p| match p {
PouIndexEntry::Function { name, linkage: LinkageType::Internal, is_generated: false, .. }
Expand All @@ -169,10 +166,7 @@ impl<'ink> CodeGen<'ink> {
acc
});

// let all_names: Vec<_> = all_names.collect();

if let Some(got_entries) = &mut *got_layout.lock().unwrap() {
// let got_entries = read_got_layout(location.as_str(), *format)?;
let mut new_symbols = Vec::new();
let mut new_got_entries = HashMap::new();
let mut new_got = HashMap::new();
Expand All @@ -198,18 +192,13 @@ impl<'ink> CodeGen<'ink> {
new_got.insert(idx, name.to_string());
}

// FIXME: Remove - moved out of there
// Now we can write new_got_entries back out to a file.
// write_got_layout(new_got_entries, location.as_str(), *format)?;

// Construct our GOT as a new global array. We initialise this array in the loader code.
let got_size: u32 = new_got
.keys()
.max()
.map_or(0, |m| *m + 1)
.try_into()
.expect("the computed custom GOT size is too large");
eprintln!("creating __custom_got array");

let ptr_ty = llvm.context.i8_type().ptr_type(AddressSpace::default());
let empty_got = ptr_ty
Expand Down
1 change: 0 additions & 1 deletion src/codegen/generators/variable_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::{
index::{get_initializer_name, Index, PouIndexEntry, VariableIndexEntry},
resolver::{AnnotationMap, AstAnnotations, Dependency},
};
use indexmap::IndexSet;
use inkwell::{module::Module, values::GlobalValue};
use plc_ast::ast::LinkageType;
use plc_diagnostics::diagnostics::Diagnostic;
Expand Down
5 changes: 0 additions & 5 deletions src/codegen/llvm_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use plc_diagnostics::diagnostics::Diagnostic;
use plc_source::source_location::SourceLocation;
use plc_util::convention::qualified_name;
use rustc_hash::FxHashMap;
use std::collections::HashMap;

/// Index view containing declared values for the current context
/// Parent Index is the a fallback lookup index for values not declared locally
Expand Down Expand Up @@ -57,8 +56,6 @@ impl<'ink> LlvmTypedIndex<'ink> {
}
for (name, index) in other.got_indices.drain() {
self.got_indices.insert(name, index);

dbg!(&self.got_indices);
}
for (name, assocication) in other.initial_value_associations.drain() {
self.initial_value_associations.insert(name, assocication);
Expand Down Expand Up @@ -178,8 +175,6 @@ impl<'ink> LlvmTypedIndex<'ink> {
}

pub fn insert_new_got_index(&mut self, variable_name: &str) -> Result<(), Diagnostic> {
eprintln!("llvm_index: inserting {variable_name}");
// FIXME: Does that start at 0 or 1?
let idx = self.got_indices.values().max().copied().unwrap_or(0);

self.got_indices.insert(variable_name.to_lowercase(), idx);
Expand Down

0 comments on commit 4cc35d2

Please sign in to comment.