Compare commits
No commits in common. "1cf99a6499909ac1bddcd769d554d94cc23d29e5" and "b24246354864de7895fd0d183e11c0923343acc7" have entirely different histories.
1cf99a6499
...
b242463548
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -521,7 +521,6 @@ dependencies = [
|
|||||||
"inkwell",
|
"inkwell",
|
||||||
"insta",
|
"insta",
|
||||||
"itertools",
|
"itertools",
|
||||||
"lazy_static",
|
|
||||||
"nac3parser",
|
"nac3parser",
|
||||||
"parking_lot 0.11.2",
|
"parking_lot 0.11.2",
|
||||||
"rayon",
|
"rayon",
|
||||||
|
@ -10,7 +10,6 @@ crossbeam = "0.8.1"
|
|||||||
parking_lot = "0.11.1"
|
parking_lot = "0.11.1"
|
||||||
rayon = "1.5.1"
|
rayon = "1.5.1"
|
||||||
nac3parser = { path = "../nac3parser" }
|
nac3parser = { path = "../nac3parser" }
|
||||||
lazy_static = "1.4.0"
|
|
||||||
|
|
||||||
[dependencies.inkwell]
|
[dependencies.inkwell]
|
||||||
git = "https://github.com/TheDan64/inkwell.git"
|
git = "https://github.com/TheDan64/inkwell.git"
|
||||||
|
@ -52,10 +52,6 @@ pub struct StaticValueStore {
|
|||||||
|
|
||||||
pub type VarValue<'ctx> = (PointerValue<'ctx>, Option<Arc<dyn StaticValue + Send + Sync>>, i64);
|
pub type VarValue<'ctx> = (PointerValue<'ctx>, Option<Arc<dyn StaticValue + Send + Sync>>, i64);
|
||||||
|
|
||||||
lazy_static!(
|
|
||||||
static ref PASSES_INIT_LOCK: Mutex<AtomicBool> = Mutex::new(AtomicBool::new(true));
|
|
||||||
);
|
|
||||||
|
|
||||||
pub struct CodeGenContext<'ctx, 'a> {
|
pub struct CodeGenContext<'ctx, 'a> {
|
||||||
pub ctx: &'ctx Context,
|
pub ctx: &'ctx Context,
|
||||||
pub builder: Builder<'ctx>,
|
pub builder: Builder<'ctx>,
|
||||||
@ -148,16 +144,13 @@ impl WorkerRegistry {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let mut handles = Vec::new();
|
let mut handles = Vec::new();
|
||||||
|
|
||||||
for mut generator in generators.into_iter() {
|
for mut generator in generators.into_iter() {
|
||||||
let registry = registry.clone();
|
let registry = registry.clone();
|
||||||
let registry2 = registry.clone();
|
let registry2 = registry.clone();
|
||||||
let f = f.clone();
|
let f = f.clone();
|
||||||
|
|
||||||
let handle = thread::spawn(move || {
|
let handle = thread::spawn(move || {
|
||||||
registry.worker_thread(generator.as_mut(), f);
|
registry.worker_thread(generator.as_mut(), f);
|
||||||
});
|
});
|
||||||
|
|
||||||
let handle = thread::spawn(move || {
|
let handle = thread::spawn(move || {
|
||||||
if let Err(e) = handle.join() {
|
if let Err(e) = handle.join() {
|
||||||
if let Some(e) = e.downcast_ref::<&'static str>() {
|
if let Some(e) = e.downcast_ref::<&'static str>() {
|
||||||
@ -169,7 +162,6 @@ impl WorkerRegistry {
|
|||||||
registry2.wait_condvar.notify_all();
|
registry2.wait_condvar.notify_all();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
handles.push(handle);
|
handles.push(handle);
|
||||||
}
|
}
|
||||||
(registry, handles)
|
(registry, handles)
|
||||||
@ -210,13 +202,11 @@ impl WorkerRegistry {
|
|||||||
self.sender.send(Some(task)).unwrap();
|
self.sender.send(Some(task)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn worker_thread<G: CodeGenerator>(
|
fn worker_thread<G: CodeGenerator>(&self, generator: &mut G, f: Arc<WithCall>) {
|
||||||
&self, generator:
|
|
||||||
&mut G, f: Arc<WithCall>
|
|
||||||
) {
|
|
||||||
let context = Context::create();
|
let context = Context::create();
|
||||||
let mut builder = context.create_builder();
|
let mut builder = context.create_builder();
|
||||||
let module = context.create_module(generator.get_name());
|
let module = context.create_module(generator.get_name());
|
||||||
|
|
||||||
module.add_basic_value_flag(
|
module.add_basic_value_flag(
|
||||||
"Debug Info Version",
|
"Debug Info Version",
|
||||||
inkwell::module::FlagBehavior::Warning,
|
inkwell::module::FlagBehavior::Warning,
|
||||||
@ -228,14 +218,10 @@ impl WorkerRegistry {
|
|||||||
context.i32_type().const_int(4, false),
|
context.i32_type().const_int(4, false),
|
||||||
);
|
);
|
||||||
|
|
||||||
let passes = PassManager::create(&module);
|
|
||||||
|
|
||||||
{
|
|
||||||
let _data = PASSES_INIT_LOCK.lock();
|
|
||||||
let pass_builder = PassManagerBuilder::create();
|
let pass_builder = PassManagerBuilder::create();
|
||||||
pass_builder.set_optimization_level(OptimizationLevel::Default);
|
pass_builder.set_optimization_level(OptimizationLevel::Default);
|
||||||
|
let passes = PassManager::create(&module);
|
||||||
pass_builder.populate_function_pass_manager(&passes);
|
pass_builder.populate_function_pass_manager(&passes);
|
||||||
}
|
|
||||||
|
|
||||||
let mut errors = HashSet::new();
|
let mut errors = HashSet::new();
|
||||||
while let Some(task) = self.receiver.recv().unwrap() {
|
while let Some(task) = self.receiver.recv().unwrap() {
|
||||||
@ -257,6 +243,7 @@ impl WorkerRegistry {
|
|||||||
if !errors.is_empty() {
|
if !errors.is_empty() {
|
||||||
panic!("Codegen error: {}", errors.into_iter().sorted().join("\n----------\n"));
|
panic!("Codegen error: {}", errors.into_iter().sorted().join("\n----------\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = module.verify();
|
let result = module.verify();
|
||||||
if let Err(err) = result {
|
if let Err(err) = result {
|
||||||
println!("{}", module.print_to_string().to_str().unwrap());
|
println!("{}", module.print_to_string().to_str().unwrap());
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
#![warn(clippy::all)]
|
#![warn(clippy::all)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate lazy_static;
|
|
||||||
|
|
||||||
pub mod codegen;
|
pub mod codegen;
|
||||||
pub mod symbol_resolver;
|
pub mod symbol_resolver;
|
||||||
pub mod toplevel;
|
pub mod toplevel;
|
||||||
|
Loading…
Reference in New Issue
Block a user