Compare commits

..

No commits in common. "f1581299fcca037eae5522d51cbdc6557bce5397" and "2a922c74800d1da934f722a61aa3af4ff783ea05" have entirely different histories.

3 changed files with 23 additions and 27 deletions

View File

@ -552,9 +552,9 @@ pub fn call_j0<'ctx>(
/// ///
/// * `num_dims` - An [IntValue] containing the number of dimensions. /// * `num_dims` - An [IntValue] containing the number of dimensions.
/// * `dims` - A [PointerValue] to an array containing the size of each dimensions. /// * `dims` - A [PointerValue] to an array containing the size of each dimensions.
pub fn call_ndarray_calc_size<'ctx>( pub fn call_ndarray_calc_size<'ctx, 'a>(
generator: &dyn CodeGenerator, generator: &mut dyn CodeGenerator,
ctx: &mut CodeGenContext<'ctx, '_>, ctx: &mut CodeGenContext<'ctx, 'a>,
num_dims: IntValue<'ctx>, num_dims: IntValue<'ctx>,
dims: PointerValue<'ctx>, dims: PointerValue<'ctx>,
) -> IntValue<'ctx> { ) -> IntValue<'ctx> {
@ -563,7 +563,7 @@ pub fn call_ndarray_calc_size<'ctx>(
let llvm_pi64 = llvm_i64.ptr_type(AddressSpace::default()); let llvm_pi64 = llvm_i64.ptr_type(AddressSpace::default());
let ndarray_calc_size_fn_name = match llvm_usize.get_bit_width() { let ndarray_calc_size_fn_name = match generator.get_size_type(ctx.ctx).get_bit_width() {
32 => "__nac3_ndarray_calc_size", 32 => "__nac3_ndarray_calc_size",
64 => "__nac3_ndarray_calc_size64", 64 => "__nac3_ndarray_calc_size64",
bw => unreachable!("Unsupported size type bit width: {}", bw) bw => unreachable!("Unsupported size type bit width: {}", bw)
@ -600,9 +600,9 @@ pub fn call_ndarray_calc_size<'ctx>(
/// `NDArray`. /// `NDArray`.
/// * `shape` - LLVM pointer to the `shape` of the NDArray. This value must be the LLVM /// * `shape` - LLVM pointer to the `shape` of the NDArray. This value must be the LLVM
/// representation of a `list`. /// representation of a `list`.
pub fn call_ndarray_init_dims<'ctx>( pub fn call_ndarray_init_dims<'ctx, 'a>(
generator: &dyn CodeGenerator, generator: &mut dyn CodeGenerator,
ctx: &mut CodeGenContext<'ctx, '_>, ctx: &mut CodeGenContext<'ctx, 'a>,
ndarray: PointerValue<'ctx>, ndarray: PointerValue<'ctx>,
shape: PointerValue<'ctx>, shape: PointerValue<'ctx>,
) { ) {
@ -616,7 +616,7 @@ pub fn call_ndarray_init_dims<'ctx>(
let llvm_pi32 = llvm_i32.ptr_type(AddressSpace::default()); let llvm_pi32 = llvm_i32.ptr_type(AddressSpace::default());
let llvm_pusize = llvm_usize.ptr_type(AddressSpace::default()); let llvm_pusize = llvm_usize.ptr_type(AddressSpace::default());
let ndarray_init_dims_fn_name = match llvm_usize.get_bit_width() { let ndarray_init_dims_fn_name = match generator.get_size_type(ctx.ctx).get_bit_width() {
32 => "__nac3_ndarray_init_dims", 32 => "__nac3_ndarray_init_dims",
64 => "__nac3_ndarray_init_dims64", 64 => "__nac3_ndarray_init_dims64",
bw => unreachable!("Unsupported size type bit width: {}", bw) bw => unreachable!("Unsupported size type bit width: {}", bw)
@ -661,14 +661,9 @@ pub fn call_ndarray_init_dims<'ctx>(
); );
} }
/// Generates a call to `__nac3_ndarray_calc_nd_indices`. pub fn call_ndarray_calc_nd_indices<'ctx, 'a>(
/// generator: &mut dyn CodeGenerator,
/// * `index` - The index to compute the multidimensional index for. ctx: &mut CodeGenContext<'ctx, 'a>,
/// * `ndarray` - LLVM pointer to the NDArray. This value must be the LLVM representation of an
/// `NDArray`.
pub fn call_ndarray_calc_nd_indices<'ctx>(
generator: &dyn CodeGenerator,
ctx: &mut CodeGenContext<'ctx, '_>,
index: IntValue<'ctx>, index: IntValue<'ctx>,
ndarray: PointerValue<'ctx>, ndarray: PointerValue<'ctx>,
) -> Result<PointerValue<'ctx>, String> { ) -> Result<PointerValue<'ctx>, String> {
@ -680,12 +675,12 @@ pub fn call_ndarray_calc_nd_indices<'ctx>(
let llvm_pusize = llvm_usize.ptr_type(AddressSpace::default()); let llvm_pusize = llvm_usize.ptr_type(AddressSpace::default());
let ndarray_calc_nd_indices_fn_name = match llvm_usize.get_bit_width() { let ndarray_calc_nd_indices_dn_name = match generator.get_size_type(ctx.ctx).get_bit_width() {
32 => "__nac3_ndarray_calc_nd_indices", 32 => "__nac3_ndarray_calc_nd_indices",
64 => "__nac3_ndarray_calc_nd_indices64", 64 => "__nac3_ndarray_calc_nd_indices64",
bw => unreachable!("Unsupported size type bit width: {}", bw) bw => unreachable!("Unsupported size type bit width: {}", bw)
}; };
let ndarray_calc_nd_indices_fn = ctx.module.get_function(ndarray_calc_nd_indices_fn_name).unwrap_or_else(|| { let ndarray_calc_nd_indices_fn = ctx.module.get_function(ndarray_calc_nd_indices_dn_name).unwrap_or_else(|| {
let fn_type = llvm_void.fn_type( let fn_type = llvm_void.fn_type(
&[ &[
llvm_usize.into(), llvm_usize.into(),
@ -696,7 +691,7 @@ pub fn call_ndarray_calc_nd_indices<'ctx>(
false, false,
); );
ctx.module.add_function(ndarray_calc_nd_indices_fn_name, fn_type, None) ctx.module.add_function(ndarray_calc_nd_indices_dn_name, fn_type, None)
}); });
let ndarray_num_dims = ctx.build_gep_and_load( let ndarray_num_dims = ctx.build_gep_and_load(

View File

@ -1,12 +1,18 @@
#include <inttypes.h>
#include <math.h> #include <math.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <inttypes.h>
#define usize size_t #if __SIZEOF_POINTER__ == 8
#define usize uint64_t
#elif __SIZEOF_POINTER__ == 4
#define usize uint32_t
#else
#error "Unsupported platform - Platform is not 32-bit or 64-bit"
#endif
double dbl_nan(void) { double dbl_nan(void) {
return NAN; return NAN;

View File

@ -17,9 +17,6 @@ while [ $# -ge 1 ]; do
--lli) --lli)
use_lli=1 use_lli=1
;; ;;
--debug)
debug=1
;;
*) *)
nac3args+=("$1") nac3args+=("$1")
;; ;;
@ -27,9 +24,7 @@ while [ $# -ge 1 ]; do
shift shift
done done
if [ -n "$debug" ] && [ -e ../../target/debug/nac3standalone ]; then if [ -e ../../target/release/nac3standalone ]; then
nac3standalone=../../target/debug/nac3standalone
elif [ -e ../../target/release/nac3standalone ]; then
nac3standalone=../../target/release/nac3standalone nac3standalone=../../target/release/nac3standalone
else else
# used by Nix builds # used by Nix builds