diff options
| author | gingerBill <bill@gingerbill.org> | 2025-02-24 15:33:35 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2025-02-24 15:33:35 +0000 |
| commit | de70e6faa04444a1ea6e8f5f72e7b6ce00dcec7e (patch) | |
| tree | 6649c24c638d13a94764d1eca541a08fd79ba663 /src | |
| parent | 83f1c879ecce5ca586f99c89d9d6b89c22555921 (diff) | |
Use more type hashes where possible
Diffstat (limited to 'src')
| -rw-r--r-- | src/llvm_backend.hpp | 14 | ||||
| -rw-r--r-- | src/name_canonicalization.hpp | 17 |
2 files changed, 24 insertions, 7 deletions
diff --git a/src/llvm_backend.hpp b/src/llvm_backend.hpp index 3617c267f..d0f68b73e 100644 --- a/src/llvm_backend.hpp +++ b/src/llvm_backend.hpp @@ -160,11 +160,11 @@ struct lbModule { AstFile *file; // possibly associated char const *module_name; - PtrMap<Type *, LLVMTypeRef> types; // mutex: types_mutex + PtrMap<u64, LLVMTypeRef> types; // mutex: types_mutex PtrMap<void *, lbStructFieldRemapping> struct_field_remapping; // Key: LLVMTypeRef or Type *, mutex: types_mutex - PtrMap<Type *, LLVMTypeRef> func_raw_types; // mutex: func_raw_types_mutex - RecursiveMutex types_mutex; - RecursiveMutex func_raw_types_mutex; + PtrMap<u64, LLVMTypeRef> func_raw_types; // mutex: func_raw_types_mutex + RecursiveMutex types_mutex; + RecursiveMutex func_raw_types_mutex; i32 internal_type_level; RwMutex values_mutex; @@ -178,7 +178,7 @@ struct lbModule { StringMap<LLVMValueRef> const_strings; - PtrMap<Type *, struct lbFunctionType *> function_type_map; + PtrMap<u64, struct lbFunctionType *> function_type_map; StringMap<lbProcedure *> gen_procs; // key is the canonicalized name @@ -201,8 +201,8 @@ struct lbModule { StringMap<lbObjcRef> objc_classes; StringMap<lbObjcRef> objc_selectors; - PtrMap<Type *, lbAddr> map_cell_info_map; // address of runtime.Map_Info - PtrMap<Type *, lbAddr> map_info_map; // address of runtime.Map_Cell_Info + PtrMap<u64, lbAddr> map_cell_info_map; // address of runtime.Map_Info + PtrMap<u64, lbAddr> map_info_map; // address of runtime.Map_Cell_Info PtrMap<Ast *, lbAddr> exact_value_compound_literal_addr_map; // Key: Ast_CompoundLit diff --git a/src/name_canonicalization.hpp b/src/name_canonicalization.hpp index e289ed5b2..304aff42e 100644 --- a/src/name_canonicalization.hpp +++ b/src/name_canonicalization.hpp @@ -109,3 +109,20 @@ gb_internal TypeInfoPair *type_set_retrieve(TypeSet *s, Type *ptr); gb_internal TypeSetIterator begin(TypeSet &set) noexcept; gb_internal TypeSetIterator end(TypeSet &set) noexcept; + + +template <typename V> +gb_internal gb_inline V *map_get(PtrMap<u64, V> *h, Type *key) { + return map_get(h, type_hash_canonical_type(key)); +} +template <typename V> +gb_internal gb_inline void map_set(PtrMap<u64, V> *h, Type *key, V const &value) { + map_set(h, type_hash_canonical_type(key), value); +} + +template <typename V> +gb_internal gb_inline V &map_must_get(PtrMap<u64, V> *h, Type *key) { + V *ptr = map_get(h, type_hash_canonical_type(key)); + GB_ASSERT(ptr != nullptr); + return *ptr; +}
\ No newline at end of file |