From 5097765b59a010eca01dd99a91320a5f88537160 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Sun, 29 Jan 2023 11:44:22 +0000 Subject: [PATCH] Remove unused support code for old code generator --- src/jit/jit-exits.c | 352 +------------------------------------------- src/jit/jit-exits.h | 7 +- src/jit/jit-llvm.c | 2 +- src/jit/jit-priv.h | 2 +- src/jit/jit-x86.c | 4 +- src/rt/model.c | 50 +++---- src/rt/structs.h | 10 +- src/symbols.txt | 47 +----- 8 files changed, 35 insertions(+), 439 deletions(-) diff --git a/src/jit/jit-exits.c b/src/jit/jit-exits.c index a2b89070..bfc7b18d 100644 --- a/src/jit/jit-exits.c +++ b/src/jit/jit-exits.c @@ -620,7 +620,7 @@ void __nvc_do_exit(jit_exit_t which, jit_anchor_t *anchor, jit_scalar_t *args, int32_t nlits = args[4].integer; int32_t flags = args[5].integer; - x_resolve_signal2(shared, handle, context, ileft, nlits, flags); + x_resolve_signal(shared, handle, context, ileft, nlits, flags); } break; @@ -1091,244 +1091,12 @@ void __nvc_do_fficall(jit_foreign_t *ff, jit_anchor_t *anchor, //////////////////////////////////////////////////////////////////////////////// // Entry points from AOT compiled code -// Helper macro for passing debug loci from LLVM -#define DEBUG_LOCUS(name) \ - const char *name##_unit, uint32_t name##_offset - -static inline tree_t locus_to_tree(const char *unit, unsigned offset) -{ - if (unit == NULL) - return NULL; - else - return tree_from_locus(ident_new(unit), offset, lib_get_qualified); -} - -DLLEXPORT -void _file_open(int8_t *status, void **_fp, uint8_t *name_bytes, - int32_t name_len, int8_t mode, DEBUG_LOCUS(locus)) -{ - tree_t where = locus_to_tree(locus_unit, locus_offset); - - x_file_open(status, _fp, name_bytes, name_len, mode, where); -} - -DLLEXPORT -void _file_write(void **_fp, uint8_t *data, int32_t len) -{ - x_file_write(_fp, data, len); -} - -DLLEXPORT -void _file_read(void **_fp, uint8_t *data, int32_t size, int32_t count, - int32_t *out) -{ - x_file_read(_fp, data, size, count, out); -} - -DLLEXPORT -void _file_close(void **_fp) -{ - x_file_close(_fp); -} - -DLLEXPORT -int8_t _endfile(void *_f) -{ - return x_endfile(_f); -} - DLLEXPORT void __nvc_flush(FILE *f) { x_file_flush(f); } -DLLEXPORT -void __nvc_index_fail(int32_t value, int32_t left, int32_t right, int8_t dir, - DEBUG_LOCUS(locus), DEBUG_LOCUS(hint)) -{ - tree_t where = locus_to_tree(locus_unit, locus_offset); - tree_t hint = locus_to_tree(hint_unit, hint_offset); - - x_index_fail(value, left, right, dir, where, hint); -} - -DLLEXPORT -void __nvc_length_fail(int32_t left, int32_t right, int32_t dim, - DEBUG_LOCUS(locus)) -{ - tree_t where = locus_to_tree(locus_unit, locus_offset); - - x_length_fail(left, right, dim, where); -} - -DLLEXPORT -void __nvc_range_fail(int64_t value, int64_t left, int64_t right, int8_t dir, - DEBUG_LOCUS(locus), DEBUG_LOCUS(hint)) -{ - tree_t where = locus_to_tree(locus_unit, locus_offset); - tree_t hint = locus_to_tree(hint_unit, hint_offset); - - x_range_fail(value, left, right, dir, where, hint); -} - -DLLEXPORT -void __nvc_exponent_fail(int32_t value, DEBUG_LOCUS(locus)) -{ - tree_t where = locus_to_tree(locus_unit, locus_offset); - - x_exponent_fail(value, where); -} - -DLLEXPORT -void __nvc_overflow(int64_t lhs, int64_t rhs, DEBUG_LOCUS(locus)) -{ - tree_t where = locus_to_tree(locus_unit, locus_offset); - - x_overflow(lhs, rhs, where); -} - -DLLEXPORT -void __nvc_null_deref(DEBUG_LOCUS(locus)) -{ - tree_t where = locus_to_tree(locus_unit, locus_offset); - - x_null_deref(where); -} - -DLLEXPORT -void __nvc_div_zero(DEBUG_LOCUS(locus)) -{ - tree_t where = locus_to_tree(locus_unit, locus_offset); - - x_div_zero(where); -} - -DLLEXPORT -int64_t _string_to_int(const uint8_t *raw_str, int32_t str_len, int32_t *used) -{ - return x_string_to_int(raw_str, str_len, used); -} - -DLLEXPORT -double _string_to_real(const uint8_t *raw_str, int32_t str_len) -{ - return x_string_to_real(raw_str, str_len); -} - -DLLEXPORT -void _canon_value(const uint8_t *raw_str, int32_t str_len, ffi_uarray_t *u) -{ - char *buf = rt_tlab_alloc(str_len); - *u = x_canon_value(raw_str, str_len, buf); -} - -DLLEXPORT -void _int_to_string(int64_t value, ffi_uarray_t *u) -{ - char *buf = rt_tlab_alloc(28); - *u = x_int_to_string(value, buf, 28); -} - -DLLEXPORT -void _real_to_string(double value, ffi_uarray_t *u) -{ - char *buf = rt_tlab_alloc(32); - *u = x_real_to_string(value, buf, 32); -} - -DLLEXPORT -sig_shared_t *_init_signal(uint32_t count, uint32_t size, const uint8_t *values, - int32_t flags, DEBUG_LOCUS(locus), int32_t offset) -{ - tree_t where = locus_to_tree(locus_unit, locus_offset); - return x_init_signal(count, size, values, flags, where, offset); -} - -DLLEXPORT -void __nvc_drive_signal(sig_shared_t *ss, uint32_t offset, int32_t count) -{ - x_drive_signal(ss, offset, count); -} - -DLLEXPORT -void _sched_process(int64_t delay) -{ - x_sched_process(delay); -} - -DLLEXPORT -void _sched_waveform_s(sig_shared_t *ss, uint32_t offset, uint64_t scalar, - int64_t after, int64_t reject) -{ - x_sched_waveform_s(ss, offset, scalar, after, reject); -} - -DLLEXPORT -void _sched_waveform(sig_shared_t *ss, uint32_t offset, void *values, - int32_t count, int64_t after, int64_t reject) -{ - x_sched_waveform(ss, offset, values, count, after, reject); -} - -DLLEXPORT -void _sched_event(sig_shared_t *ss, uint32_t offset, int32_t count, - bool oneshot, sig_shared_t *wake_ss) -{ - x_sched_event(ss, offset, count, oneshot, wake_ss); -} - -DLLEXPORT -void __nvc_alias_signal(sig_shared_t *ss, DEBUG_LOCUS(locus)) -{ - tree_t where = locus_to_tree(locus_unit, locus_offset); - x_alias_signal(ss, where); -} - -DLLEXPORT -void __nvc_assert_fail(const uint8_t *msg, int32_t msg_len, int8_t severity, - int64_t hint_left, int64_t hint_right, int8_t hint_valid, - DEBUG_LOCUS(locus)) -{ - tree_t where = locus_to_tree(locus_unit, locus_offset); - - x_assert_fail(msg, msg_len, severity, hint_left, hint_right, - hint_valid, where); -} - -DLLEXPORT -void __nvc_report(const uint8_t *msg, int32_t msg_len, int8_t severity, - DEBUG_LOCUS(locus)) -{ - tree_t where = locus_to_tree(locus_unit, locus_offset); - - x_report(msg, msg_len, severity, where); -} - -DLLEXPORT -int64_t _last_event(sig_shared_t *ss, uint32_t offset, int32_t count) -{ - return x_last_event(ss, offset, count); -} - -DLLEXPORT -int64_t _last_active(sig_shared_t *ss, uint32_t offset, int32_t count) -{ - return x_last_active(ss, offset, count); -} - -DLLEXPORT -int32_t _test_net_active(sig_shared_t *ss, uint32_t offset, int32_t count) -{ - return x_test_net_active(ss, offset, count); -} - -DLLEXPORT -int32_t _test_net_event(sig_shared_t *ss, uint32_t offset, int32_t count) -{ - return x_test_net_event(ss, offset, count); -} - DLLEXPORT void _debug_out(intptr_t val, int32_t reg) { @@ -1352,103 +1120,7 @@ void _debug_dump(const uint8_t *ptr, int32_t len) } DLLEXPORT -void __nvc_map_signal(sig_shared_t *src_ss, uint32_t src_offset, - sig_shared_t *dst_ss, uint32_t dst_offset, - uint32_t src_count, uint32_t dst_count, - ffi_closure_t *closure) -{ - x_map_signal(src_ss, src_offset, dst_ss, dst_offset, src_count, - dst_count, closure); -} - -DLLEXPORT -void __nvc_map_const(sig_shared_t *ss, uint32_t offset, - const uint8_t *values, uint32_t count) -{ - x_map_const(ss, offset, values, count); -} - -DLLEXPORT -void __nvc_push_scope(DEBUG_LOCUS(locus), int32_t size) -{ - tree_t where = locus_to_tree(locus_unit, locus_offset); - x_push_scope(where, size); -} - -DLLEXPORT -void __nvc_pop_scope(void) -{ - x_pop_scope(); -} - -DLLEXPORT -bool _driving(sig_shared_t *ss, uint32_t offset, int32_t count) -{ - return x_driving(ss, offset, count); -} - -DLLEXPORT -void *_driving_value(sig_shared_t *ss, uint32_t offset, int32_t count) -{ - return x_driving_value(ss, offset, count); -} - -DLLEXPORT -sig_shared_t *_implicit_signal(uint32_t count, uint32_t size, - DEBUG_LOCUS(locus), uint32_t kind, - ffi_closure_t *closure) -{ - tree_t where = locus_to_tree(locus_unit, locus_offset); - return x_implicit_signal(count, size, where, kind, closure); -} - -DLLEXPORT -void _disconnect(sig_shared_t *ss, uint32_t offset, int32_t count, - int64_t after, int64_t reject) -{ - x_disconnect(ss, offset, count, after, reject); -} - -DLLEXPORT -void __nvc_force(sig_shared_t *ss, uint32_t offset, int32_t count, void *values) -{ - x_force(ss, offset, count, values); -} - -DLLEXPORT -void __nvc_release(sig_shared_t *ss, uint32_t offset, int32_t count) -{ - x_release(ss, offset, count); -} - -DLLEXPORT -void __nvc_resolve_signal(sig_shared_t *ss, rt_resolution_t *resolution) -{ - x_resolve_signal(ss, resolution); -} - -DLLEXPORT -void __nvc_elab_order_fail(DEBUG_LOCUS(locus)) -{ - tree_t where = locus_to_tree(locus_unit, locus_offset); - x_elab_order_fail(where); -} - -DLLEXPORT -void __nvc_unreachable(DEBUG_LOCUS(locus)) -{ - tree_t where = locus_to_tree(locus_unit, locus_offset); - x_unreachable(where); -} - -DLLEXPORT -void *__nvc_mspace_alloc(uint32_t size, uint32_t nelems) -{ - return x_mspace_alloc(size, nelems); -} - -DLLEXPORT -void *__nvc_mspace_alloc2(uintptr_t size, jit_anchor_t *anchor) +void *__nvc_mspace_alloc(uintptr_t size, jit_anchor_t *anchor) { jit_thread_local_t *thread = jit_thread_local(); thread->anchor = anchor; @@ -1460,18 +1132,10 @@ void *__nvc_mspace_alloc2(uintptr_t size, jit_anchor_t *anchor) } DLLEXPORT -jit_handle_t __nvc_get_handle(const char *func, ffi_spec_t spec) +void *__nvc_mspace_alloc2(uintptr_t size, jit_anchor_t *anchor) { - jit_t *j = jit_thread_local()->jit; - - jit_handle_t handle = jit_lazy_compile(j, ident_new(func)); - if (handle == JIT_HANDLE_INVALID) - fatal_trace("missing function %s", func); - - if (spec != ~UINT64_C(0)) - jit_get_func(j, handle)->spec = spec; // XXXX: delete me - - return handle; + // TODO: remove after 1.9 release + return __nvc_mspace_alloc(size, anchor); } DLLEXPORT @@ -1483,12 +1147,6 @@ void __nvc_putpriv(jit_handle_t handle, void *data) store_release(jit_get_privdata_ptr(j, f), data); } -DLLEXPORT -void __nvc_setup_toggle_cb(sig_shared_t *ss, int32_t* toggle_mask) -{ - x_cover_setup_toggle_cb(ss, toggle_mask); -} - DLLEXPORT object_t *__nvc_get_object(const char *unit, ptrdiff_t offset) { diff --git a/src/jit/jit-exits.h b/src/jit/jit-exits.h index 307822df..f8f11df4 100644 --- a/src/jit/jit-exits.h +++ b/src/jit/jit-exits.h @@ -1,5 +1,5 @@ // -// Copyright (C) 2022 Nick Gasson +// Copyright (C) 2022-2023 Nick Gasson // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -87,9 +87,8 @@ void x_disconnect(sig_shared_t *ss, uint32_t offset, int32_t count, int64_t after, int64_t reject); void x_force(sig_shared_t *ss, uint32_t offset, int32_t count, void *values); void x_release(sig_shared_t *ss, uint32_t offset, int32_t count); -void x_resolve_signal(sig_shared_t *ss, rt_resolution_t *resolution); -void x_resolve_signal2(sig_shared_t *ss, jit_handle_t handle, void *context, - int32_t ileft, int32_t nlits, int32_t flags); +void x_resolve_signal(sig_shared_t *ss, jit_handle_t handle, void *context, + int32_t ileft, int32_t nlits, int32_t flags); void x_elab_order_fail(tree_t where); void x_unreachable(tree_t where); void *x_mspace_alloc(size_t size, uint32_t nelems); diff --git a/src/jit/jit-llvm.c b/src/jit/jit-llvm.c index 9dec5a2e..997b413c 100644 --- a/src/jit/jit-llvm.c +++ b/src/jit/jit-llvm.c @@ -734,7 +734,7 @@ static LLVMValueRef llvm_get_fn(llvm_obj_t *obj, llvm_fn_t which) obj->fntypes[which] = LLVMFunctionType(obj->types[LLVM_PTR], args, ARRAY_LEN(args), false); - fn = llvm_add_fn(obj, "__nvc_mspace_alloc2", obj->fntypes[which]); + fn = llvm_add_fn(obj, "__nvc_mspace_alloc", obj->fntypes[which]); } break; diff --git a/src/jit/jit-priv.h b/src/jit/jit-priv.h index 07d4afa3..c22adba8 100644 --- a/src/jit/jit-priv.h +++ b/src/jit/jit-priv.h @@ -377,7 +377,7 @@ void __nvc_do_exit(jit_exit_t which, jit_anchor_t *anchor, jit_scalar_t *args, tlab_t *tlab); void __nvc_do_fficall(jit_foreign_t *ff, jit_anchor_t *anchor, jit_scalar_t *args); -void *__nvc_mspace_alloc2(uintptr_t size, jit_anchor_t *anchor); +void *__nvc_mspace_alloc(uintptr_t size, jit_anchor_t *anchor); void _debug_out(intptr_t val, int32_t reg); #endif // _JIT_PRIV_H diff --git a/src/jit/jit-x86.c b/src/jit/jit-x86.c index 8ed90074..7a180d34 100644 --- a/src/jit/jit-x86.c +++ b/src/jit/jit-x86.c @@ -1832,7 +1832,7 @@ static void jit_x86_gen_alloc_stub(jit_x86_state_t *state) MOV(CARG0_REG, __EAX, __DWORD); MOV(CARG1_REG, ANCHOR_REG, __QWORD); - MOV(__EAX, PTR(__nvc_mspace_alloc2), __QWORD); + MOV(__EAX, PTR(__nvc_mspace_alloc), __QWORD); CALL(__EAX); jit_x86_pop_call_clobbered(blob); @@ -1876,7 +1876,7 @@ static void jit_x86_gen_tlab_stub(jit_x86_state_t *state) MOV(CARG0_REG, __EAX, __DWORD); MOV(CARG1_REG, ANCHOR_REG, __QWORD); - MOV(__EAX, PTR(__nvc_mspace_alloc2), __QWORD); + MOV(__EAX, PTR(__nvc_mspace_alloc), __QWORD); CALL(__EAX); jit_x86_pop_call_clobbered(blob); diff --git a/src/rt/model.c b/src/rt/model.c index 4ae4020d..f5bcc51b 100644 --- a/src/rt/model.c +++ b/src/rt/model.c @@ -903,22 +903,23 @@ static void reset_scope(rt_model_t *m, rt_scope_t *s) } static res_memo_t *memo_resolution_fn(rt_model_t *m, rt_signal_t *signal, - rt_resolution_t *resolution) + ffi_closure_t closure, int32_t ileft, + int32_t nlits, res_flags_t flags) { // Optimise some common resolution functions by memoising them - res_memo_t *memo = ihash_get(m->res_memo, resolution->closure.handle); + res_memo_t *memo = ihash_get(m->res_memo, closure.handle); if (memo != NULL) return memo; memo = static_alloc(m, sizeof(res_memo_t)); - memo->closure = resolution->closure; - memo->flags = resolution->flags; - memo->ileft = resolution->ileft; + memo->closure = closure; + memo->flags = flags; + memo->ileft = ileft; ihash_put(m->res_memo, memo->closure.handle, memo); - if (resolution->nlits == 0 || resolution->nlits > 16) + if (nlits == 0 || nlits > 16) return memo; const vhdl_severity_t old_severity = get_exit_severity(); @@ -928,13 +929,13 @@ static res_memo_t *memo_resolution_fn(rt_model_t *m, rt_signal_t *signal, // Memoise the function for all two value cases - for (int i = 0; i < resolution->nlits; i++) { - for (int j = 0; j < resolution->nlits; j++) { + for (int i = 0; i < nlits; i++) { + for (int j = 0; j < nlits; j++) { int8_t args[2] = { i, j }; jit_scalar_t result; if (jit_try_call(m->jit, memo->closure.handle, &result, memo->closure.context, args, memo->ileft, 2)) { - assert(result.integer < resolution->nlits && result.integer >= 0); + assert(result.integer < nlits && result.integer >= 0); memo->tab2[i][j] = result.integer; } } @@ -944,7 +945,7 @@ static res_memo_t *memo_resolution_fn(rt_model_t *m, rt_signal_t *signal, // function behaves like the identity function bool identity = true; - for (int i = 0; i < resolution->nlits; i++) { + for (int i = 0; i < nlits; i++) { int8_t args[1] = { i }; jit_scalar_t result; if (jit_try_call(m->jit, memo->closure.handle, &result, @@ -961,7 +962,7 @@ static res_memo_t *memo_resolution_fn(rt_model_t *m, rt_signal_t *signal, } TRACE("memoised resolution function %s for type %s", - istr(jit_get_name(m->jit, resolution->closure.handle)), + istr(jit_get_name(m->jit, closure.handle)), type_pp(tree_type(signal->where))); jit_set_silent(m->jit, false); @@ -3503,13 +3504,20 @@ void x_release(sig_shared_t *ss, uint32_t offset, int32_t count) } } -void x_resolve_signal(sig_shared_t *ss, rt_resolution_t *resolution) +void x_resolve_signal(sig_shared_t *ss, jit_handle_t handle, void *context, + int32_t ileft, int32_t nlits, int32_t flags) { rt_signal_t *s = container_of(ss, rt_signal_t, shared); TRACE("resolve signal %s", istr(tree_ident(s->where))); - s->resolution = memo_resolution_fn(get_model(), s, resolution); + ffi_closure_t closure = { + .handle = handle, + .context = context + }; + + rt_model_t *m = get_model(); + s->resolution = memo_resolution_fn(m, s, closure, ileft, nlits, flags); // Copy R_IDENT into the nexus flags to avoid rt_resolve_nexus_fast // having to dereference the resolution pointer in the common case @@ -3521,19 +3529,3 @@ void x_resolve_signal(sig_shared_t *ss, rt_resolution_t *resolution) n->flags |= NET_F_R_IDENT; } } - -void x_resolve_signal2(sig_shared_t *ss, jit_handle_t handle, void *context, - int32_t ileft, int32_t nlits, int32_t flags) -{ - rt_resolution_t resolution = { - .closure = { - .handle = handle, - .context = context, - }, - .ileft = ileft, - .nlits = nlits, - .flags = flags, - }; - - x_resolve_signal(ss, &resolution); -} diff --git a/src/rt/structs.h b/src/rt/structs.h index 79aac693..baa012e1 100644 --- a/src/rt/structs.h +++ b/src/rt/structs.h @@ -66,7 +66,7 @@ struct waveform { rt_value_t value; }; -STATIC_ASSERT(sizeof(rt_value_t) <= 24); +STATIC_ASSERT(sizeof(waveform_t) <= 24); typedef struct { rt_wakeable_t *wake; @@ -126,14 +126,6 @@ typedef struct _rt_source { STATIC_ASSERT(sizeof(rt_source_t) <= 64); -// The code generator knows the layout of this struct -typedef struct _rt_resolution { - ffi_closure_t closure; - uint32_t flags; - int32_t ileft; - int32_t nlits; -} rt_resolution_t; - typedef struct { ffi_closure_t closure; res_flags_t flags; diff --git a/src/symbols.txt b/src/symbols.txt index edf90a05..b874db9a 100644 --- a/src/symbols.txt +++ b/src/symbols.txt @@ -30,60 +30,15 @@ _nvc_ieee_warnings; # Exported from src/jit/jit-exits.c - __nvc_alias_signal; - __nvc_assert_fail; - __nvc_div_zero; __nvc_do_exit; __nvc_do_fficall; - __nvc_drive_signal; - __nvc_elab_order_fail; - __nvc_exponent_fail; __nvc_flush; - __nvc_force; - __nvc_get_handle; __nvc_get_object; - __nvc_index_fail; - __nvc_length_fail; - __nvc_map_const; - __nvc_map_signal; __nvc_mspace_alloc; - __nvc_mspace_alloc2; - __nvc_null_deref; - __nvc_overflow; - __nvc_pop_scope; - __nvc_push_scope; + __nvc_mspace_alloc2; # DEAD __nvc_putpriv; - __nvc_range_fail; - __nvc_release; - __nvc_report; - __nvc_resolve_signal; - __nvc_setup_toggle_cb; - __nvc_unreachable; - _canon_value; _debug_dump; _debug_out; - _disconnect; - _driving; - _driving_value; - _endfile; - _file_close; - _file_open; - _file_read; - _file_write; - _implicit_signal; - _init_signal; - _int_to_string; - _last_active; - _last_event; - _real_to_string; - _sched_event; - _sched_process; - _sched_waveform; - _sched_waveform_s; - _string_to_int; - _string_to_real; - _test_net_active; - _test_net_event; # Exported by VHPI vhpiFS; -- 2.39.2