Compare commits

..

No commits in common. "abbaa506adabcbe8de9fa88c66138c81907333a8" and "5a34551905f1cf029eefd600511b2ff948205996" have entirely different histories.

7 changed files with 34 additions and 25 deletions

View File

@ -8,17 +8,17 @@ repos:
hooks: hooks:
- id: nac3-cargo-fmt - id: nac3-cargo-fmt
name: nac3 cargo format name: nac3 cargo format
entry: nix entry: cargo
language: system language: system
types: [file, rust] types: [file, rust]
pass_filenames: false pass_filenames: false
description: Runs cargo fmt on the codebase. description: Runs cargo fmt on the codebase.
args: [develop, -c, cargo, fmt, --all] args: [fmt]
- id: nac3-cargo-clippy - id: nac3-cargo-clippy
name: nac3 cargo clippy name: nac3 cargo clippy
entry: nix entry: cargo
language: system language: system
types: [file, rust] types: [file, rust]
pass_filenames: false pass_filenames: false
description: Runs cargo clippy on the codebase. description: Runs cargo clippy on the codebase.
args: [develop, -c, cargo, clippy, --tests] args: [clippy, --tests]

View File

@ -32,8 +32,8 @@ use pyo3::{
use crate::{symbol_resolver::InnerResolver, timeline::TimeFns}; use crate::{symbol_resolver::InnerResolver, timeline::TimeFns};
use itertools::Itertools;
use nac3core::inkwell::values::IntValue; use nac3core::inkwell::values::IntValue;
use itertools::Itertools;
use std::{ use std::{
collections::{hash_map::DefaultHasher, HashMap}, collections::{hash_map::DefaultHasher, HashMap},
hash::{Hash, Hasher}, hash::{Hash, Hasher},

View File

@ -23,8 +23,6 @@ use std::process::Command;
use std::rc::Rc; use std::rc::Rc;
use std::sync::Arc; use std::sync::Arc;
use itertools::Itertools;
use nac3core::codegen::{gen_func_impl, CodeGenLLVMOptions, CodeGenTargetMachineOptions};
use nac3core::inkwell::{ use nac3core::inkwell::{
context::Context, context::Context,
memory_buffer::MemoryBuffer, memory_buffer::MemoryBuffer,
@ -34,12 +32,14 @@ use nac3core::inkwell::{
targets::*, targets::*,
OptimizationLevel, OptimizationLevel,
}; };
use itertools::Itertools;
use nac3core::codegen::{gen_func_impl, CodeGenLLVMOptions, CodeGenTargetMachineOptions};
use nac3core::toplevel::builtins::get_exn_constructor;
use nac3core::typecheck::typedef::{into_var_map, TypeEnum, Unifier, VarMap};
use nac3core::nac3parser::{ use nac3core::nac3parser::{
ast::{ExprKind, Stmt, StmtKind, StrRef}, ast::{ExprKind, Stmt, StmtKind, StrRef},
parser::parse_program, parser::parse_program,
}; };
use nac3core::toplevel::builtins::get_exn_constructor;
use nac3core::typecheck::typedef::{into_var_map, TypeEnum, Unifier, VarMap};
use pyo3::create_exception; use pyo3::create_exception;
use pyo3::prelude::*; use pyo3::prelude::*;
use pyo3::{exceptions, types::PyBytes, types::PyDict, types::PySet}; use pyo3::{exceptions, types::PyBytes, types::PyDict, types::PySet};

View File

@ -1,12 +1,11 @@
use crate::PrimitivePythonId; use crate::PrimitivePythonId;
use itertools::Itertools;
use nac3core::inkwell::{ use nac3core::inkwell::{
module::Linkage, module::Linkage,
types::{BasicType, BasicTypeEnum}, types::{BasicType, BasicTypeEnum},
values::BasicValueEnum, values::BasicValueEnum,
AddressSpace, AddressSpace,
}; };
use nac3core::nac3parser::ast::{self, StrRef}; use itertools::Itertools;
use nac3core::{ use nac3core::{
codegen::{ codegen::{
classes::{NDArrayType, ProxyType}, classes::{NDArrayType, ProxyType},
@ -23,6 +22,7 @@ use nac3core::{
typedef::{into_var_map, iter_type_vars, Type, TypeEnum, TypeVar, Unifier, VarMap}, typedef::{into_var_map, iter_type_vars, Type, TypeEnum, TypeVar, Unifier, VarMap},
}, },
}; };
use nac3core::nac3parser::ast::{self, StrRef};
use parking_lot::RwLock; use parking_lot::RwLock;
use pyo3::{ use pyo3::{
types::{PyDict, PyTuple}, types::{PyDict, PyTuple},

View File

@ -1,9 +1,9 @@
use itertools::Either;
use nac3core::codegen::CodeGenContext;
use nac3core::inkwell::{ use nac3core::inkwell::{
values::{BasicValueEnum, CallSiteValue}, values::{BasicValueEnum, CallSiteValue},
AddressSpace, AtomicOrdering, AddressSpace, AtomicOrdering,
}; };
use itertools::Either;
use nac3core::codegen::CodeGenContext;
/// Functions for manipulating the timeline. /// Functions for manipulating the timeline.
pub trait TimeFns { pub trait TimeFns {

View File

@ -1,4 +1,3 @@
use nac3core::nac3parser::ast::{self, StrRef};
use nac3core::{ use nac3core::{
codegen::CodeGenContext, codegen::CodeGenContext,
symbol_resolver::{SymbolResolver, SymbolValue, ValueEnum}, symbol_resolver::{SymbolResolver, SymbolValue, ValueEnum},
@ -8,6 +7,7 @@ use nac3core::{
typedef::{Type, Unifier}, typedef::{Type, Unifier},
}, },
}; };
use nac3core::nac3parser::ast::{self, StrRef};
use parking_lot::{Mutex, RwLock}; use parking_lot::{Mutex, RwLock};
use std::collections::HashSet; use std::collections::HashSet;
use std::{collections::HashMap, sync::Arc}; use std::{collections::HashMap, sync::Arc};

View File

@ -10,12 +10,8 @@
use clap::Parser; use clap::Parser;
use nac3core::inkwell::{ use nac3core::inkwell::{
memory_buffer::MemoryBuffer, module::Linkage, passes::PassBuilderOptions, memory_buffer::MemoryBuffer, passes::PassBuilderOptions, support::is_multithreaded, targets::*,
support::is_multithreaded, targets::*, OptimizationLevel, OptimizationLevel, module::Linkage
};
use nac3core::nac3parser::{
ast::{Constant, Expr, ExprKind, StmtKind, StrRef},
parser,
}; };
use nac3core::{ use nac3core::{
codegen::{ codegen::{
@ -34,6 +30,10 @@ use nac3core::{
typedef::{FunSignature, Type, Unifier, VarMap}, typedef::{FunSignature, Type, Unifier, VarMap},
}, },
}; };
use nac3core::nac3parser::{
ast::{Constant, Expr, ExprKind, StmtKind, StrRef},
parser,
};
use parking_lot::{Mutex, RwLock}; use parking_lot::{Mutex, RwLock};
use std::collections::HashSet; use std::collections::HashSet;
use std::num::NonZeroUsize; use std::num::NonZeroUsize;
@ -279,14 +279,18 @@ fn main() {
reloc_mode: RelocMode::PIC, reloc_mode: RelocMode::PIC,
..host_target_machine ..host_target_machine
}; };
let target_machine = target_machine_options
.create_target_machine(opt_level)
.expect("couldn't create target machine");
let context = nac3core::inkwell::context::Context::create(); let context = nac3core::inkwell::context::Context::create();
let size_t = let size_t = context
context.ptr_sized_int_type(&target_machine.get_target_data(), None).get_bit_width(); .ptr_sized_int_type(
&target_machine_options
.create_target_machine(opt_level)
.map(|tm| tm.get_target_data())
.unwrap(),
None,
)
.get_bit_width();
let program = match fs::read_to_string(file_name.clone()) { let program = match fs::read_to_string(file_name.clone()) {
Ok(program) => program, Ok(program) => program,
@ -454,6 +458,11 @@ fn main() {
} }
// Optimize `main` // Optimize `main`
let target_machine = llvm_options
.target
.create_target_machine(llvm_options.opt_level)
.expect("couldn't create target machine");
let pass_options = PassBuilderOptions::create(); let pass_options = PassBuilderOptions::create();
pass_options.set_merge_functions(true); pass_options.set_merge_functions(true);
let passes = format!("default<O{}>", opt_level as u32); let passes = format!("default<O{}>", opt_level as u32);