Compare commits
6 Commits
8bef0ab8f2
...
fc93fc2f0e
Author | SHA1 | Date |
---|---|---|
David Mak | fc93fc2f0e | |
David Mak | dd42022633 | |
David Mak | 6dfc43c8b0 | |
David Mak | ab2360d7a0 | |
David Mak | ee1ee4ab3b | |
David Mak | 3e430b9b40 |
|
@ -64,7 +64,8 @@ impl<'ctx, 'a> CodeGenContext<'ctx, 'a> {
|
|||
index: &[IntValue<'ctx>],
|
||||
name: Option<&str>,
|
||||
) -> BasicValueEnum<'ctx> {
|
||||
unsafe { self.builder.build_load(self.builder.build_gep(ptr, index, ""), name.unwrap_or_default()) }
|
||||
let gep = unsafe { self.builder.build_gep(ptr, index, "") };
|
||||
self.builder.build_load(gep, name.unwrap_or_default())
|
||||
}
|
||||
|
||||
fn get_subst_key(
|
||||
|
|
|
@ -13,7 +13,10 @@ use crate::{
|
|||
},
|
||||
};
|
||||
use indoc::indoc;
|
||||
use inkwell::OptimizationLevel;
|
||||
use inkwell::{
|
||||
targets::{InitializationConfig, Target},
|
||||
OptimizationLevel
|
||||
};
|
||||
use nac3parser::{
|
||||
ast::{fold::Fold, StrRef},
|
||||
parser::parse_program,
|
||||
|
@ -21,7 +24,6 @@ use nac3parser::{
|
|||
use parking_lot::RwLock;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::sync::Arc;
|
||||
use inkwell::targets::{InitializationConfig, Target};
|
||||
|
||||
struct Resolver {
|
||||
id_to_type: HashMap<StrRef, Type>,
|
||||
|
|
|
@ -1,84 +0,0 @@
|
|||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define min(a, b) \
|
||||
({ \
|
||||
__typeof__(a) _a = (a); \
|
||||
__typeof__(b) _b = (b); \
|
||||
_a < _b ? _a : _b; \
|
||||
})
|
||||
|
||||
#if __SIZEOF_POINTER__ == 8
|
||||
#define usize uint64_t
|
||||
#elif __SIZEOF_POINTER__ == 4
|
||||
#define usize uint32_t
|
||||
#elif __SIZEOF_POINTER__ == 2
|
||||
#define usize uint16_t
|
||||
#endif
|
||||
|
||||
void output_int32(const int32_t x) {
|
||||
printf("%d\n", x);
|
||||
}
|
||||
|
||||
void output_int64(const int64_t x) {
|
||||
printf("%ld\n", x);
|
||||
}
|
||||
|
||||
void output_uint32(const uint32_t x) {
|
||||
printf("%d\n", x);
|
||||
}
|
||||
|
||||
void output_uint64(const uint64_t x) {
|
||||
printf("%ld\n", x);
|
||||
}
|
||||
|
||||
void output_asciiart(const int32_t x) {
|
||||
const char* chars = " .,-:;i+hHM$*#@ ";
|
||||
if (x < 0) {
|
||||
fputc('\n', stdout);
|
||||
} else {
|
||||
fputc(chars[x], stdout);
|
||||
}
|
||||
}
|
||||
|
||||
struct cslice_int32 {
|
||||
const int32_t* data;
|
||||
usize len;
|
||||
};
|
||||
|
||||
void output_int32_list(struct cslice_int32* slice) {
|
||||
fputc('[', stdout);
|
||||
for (usize i = 0; i < slice->len; ++i) {
|
||||
if (i == slice->len - 1) {
|
||||
printf("%d", slice->data[i]);
|
||||
} else {
|
||||
printf("%d, ", slice->data[i]);
|
||||
}
|
||||
}
|
||||
puts("]");
|
||||
}
|
||||
|
||||
uint32_t __nac3_personality(
|
||||
__attribute__((unused)) uint32_t state,
|
||||
__attribute__((unused)) uint32_t exception_object,
|
||||
__attribute__((unused)) uint32_t context) {
|
||||
assert(false && "__nac3_personality not implemented");
|
||||
exit(101);
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
uint32_t __nac3_raise(uint32_t state, uint32_t exception_object, uint32_t context) {
|
||||
printf("__nac3_raise(state: %x, exception_object: %x, context: %x\n", state, exception_object, context);
|
||||
exit(101);
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
extern int32_t run();
|
||||
|
||||
int main() {
|
||||
run();
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "No argument supplied"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -e ../../target/release/nac3standalone ]; then
|
||||
nac3standalone=../../target/release/nac3standalone
|
||||
else
|
||||
# used by Nix builds
|
||||
nac3standalone=../../target/x86_64-unknown-linux-gnu/release/nac3standalone
|
||||
fi
|
||||
|
||||
rm -f *.o *.bc
|
||||
$nac3standalone --emit-llvm "$@"
|
||||
gcc -c -std=c11 -Wall -Wextra -pedantic-errors -Werror=pedantic -O3 -o demo.o demo.c
|
||||
clang -S -Wall -Wextra -O3 -emit-llvm -o irrt.bc ../../nac3core/src/codegen/irrt/irrt.c
|
||||
lli --extra-object demo.o --extra-module irrt.bc main.bc
|
Loading…
Reference in New Issue