diff options
| author | gingerBill <bill@gingerbill.org> | 2024-02-22 18:15:13 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-02-22 18:15:13 +0000 |
| commit | 5f001f6d5138d61fbb4900c951e2ccb12894d5ed (patch) | |
| tree | 829a51ce3f0cdf40ecab46c885b7a48f8ae71602 /src/llvm_backend_expr.cpp | |
| parent | fc07211772e37865c928a12ab01663baa940cf28 (diff) | |
Allow casting between a `bit_field` and its backing type
Diffstat (limited to 'src/llvm_backend_expr.cpp')
| -rw-r--r-- | src/llvm_backend_expr.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/llvm_backend_expr.cpp b/src/llvm_backend_expr.cpp index 6bef21822..7b31ca989 100644 --- a/src/llvm_backend_expr.cpp +++ b/src/llvm_backend_expr.cpp @@ -1946,6 +1946,24 @@ gb_internal lbValue lb_emit_conv(lbProcedure *p, lbValue value, Type *t) { } } + // bit_field <-> backing type + if (is_type_bit_field(src)) { + if (are_types_identical(src->BitField.backing_type, dst)) { + lbValue res = {}; + res.type = t; + res.value = value.value; + return res; + } + } + if (is_type_bit_field(dst)) { + if (are_types_identical(src, dst->BitField.backing_type)) { + lbValue res = {}; + res.type = t; + res.value = value.value; + return res; + } + } + // Pointer <-> uintptr if (is_type_pointer(src) && is_type_uintptr(dst)) { |