aboutsummaryrefslogtreecommitdiff
path: root/src/analyze.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-02-20 22:40:41 -0500
committerAndrew Kelley <andrew@ziglang.org>2019-02-20 22:40:41 -0500
commit3ee9d06cbdb6bcaf561e7215c4c103c7ad65a72d (patch)
treec9f612c22c8e2d2e1191a5aab8fc2bfaebf4cfcd /src/analyze.cpp
parent079728752eca4cffbb4f7e8dc06d5e23b81d7627 (diff)
downloadzig-3ee9d06cbdb6bcaf561e7215c4c103c7ad65a72d.tar.gz
zig-3ee9d06cbdb6bcaf561e7215c4c103c7ad65a72d.zip
packed structs support comptime bitcasting
* `type_size_store` is no longer a thing. loading and storing a pointer to a value may dereference up to `@sizeOf(T)` bytes, even for integers such as `u24`. * fix `types_have_same_zig_comptime_repr` to not think that the same `ZigTypeId` means the `ConstExprValue` neccesarily has the same representation. * implement `buf_write_value_bytes` and `buf_read_value_bytes` for `ContainerLayoutPacked` closes #1120
Diffstat (limited to 'src/analyze.cpp')
-rw-r--r--src/analyze.cpp22
1 files changed, 0 insertions, 22 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp
index 9fe656ff77..040483a05e 100644
--- a/src/analyze.cpp
+++ b/src/analyze.cpp
@@ -359,28 +359,6 @@ uint64_t type_size(CodeGen *g, ZigType *type_entry) {
return LLVMABISizeOfType(g->target_data_ref, type_entry->type_ref);
}
-uint64_t type_size_store(CodeGen *g, ZigType *type_entry) {
- assert(type_is_complete(type_entry));
-
- if (!type_has_bits(type_entry))
- return 0;
-
- if (type_entry->id == ZigTypeIdStruct && type_entry->data.structure.layout == ContainerLayoutPacked) {
- uint64_t size_in_bits = type_size_bits(g, type_entry);
- return (size_in_bits + 7) / 8;
- } else if (type_entry->id == ZigTypeIdArray) {
- ZigType *child_type = type_entry->data.array.child_type;
- if (child_type->id == ZigTypeIdStruct &&
- child_type->data.structure.layout == ContainerLayoutPacked)
- {
- uint64_t size_in_bits = type_size_bits(g, type_entry);
- return (size_in_bits + 7) / 8;
- }
- }
-
- return LLVMStoreSizeOfType(g->target_data_ref, type_entry->type_ref);
-}
-
uint64_t type_size_bits(CodeGen *g, ZigType *type_entry) {
assert(type_is_complete(type_entry));