diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-02-16 17:08:55 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-02-16 17:08:55 -0500 |
| commit | b6e7a0dadd86ce401e82ec53d6874e9934826c2d (patch) | |
| tree | 27171640bb593bdc66d47b213f73f2b40ca68df3 /src/analyze.cpp | |
| parent | fc5d47b9b960aa08d65bf0dfe3d6395c811f793b (diff) | |
| download | zig-b6e7a0dadd86ce401e82ec53d6874e9934826c2d.tar.gz zig-b6e7a0dadd86ce401e82ec53d6874e9934826c2d.zip | |
support arithmetic for non byte aligned integer types
see #261
Diffstat (limited to 'src/analyze.cpp')
| -rw-r--r-- | src/analyze.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index 1b248ba128..8ac641ebfc 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -3997,3 +3997,33 @@ bool type_id_eql(TypeId a, TypeId b) { } zig_unreachable(); } + +uint32_t zig_llvm_fn_key_hash(ZigLLVMFnKey x) { + switch (x.id) { + case ZigLLVMFnIdCtz: + return x.data.ctz.bit_count * 810453934; + case ZigLLVMFnIdClz: + return x.data.clz.bit_count * 2428952817; + case ZigLLVMFnIdOverflowArithmetic: + return (x.data.overflow_arithmetic.bit_count * 87135777) + + (x.data.overflow_arithmetic.add_sub_mul * 31640542) + + (x.data.overflow_arithmetic.is_signed ? 1062315172 : 314955820); + } + zig_unreachable(); +} + +bool zig_llvm_fn_key_eql(ZigLLVMFnKey a, ZigLLVMFnKey b) { + if (a.id != b.id) + return false; + switch (a.id) { + case ZigLLVMFnIdCtz: + return a.data.ctz.bit_count == b.data.ctz.bit_count; + case ZigLLVMFnIdClz: + return a.data.clz.bit_count == b.data.clz.bit_count; + case ZigLLVMFnIdOverflowArithmetic: + return (a.data.overflow_arithmetic.bit_count == b.data.overflow_arithmetic.bit_count) && + (a.data.overflow_arithmetic.add_sub_mul == b.data.overflow_arithmetic.add_sub_mul) && + (a.data.overflow_arithmetic.is_signed == b.data.overflow_arithmetic.is_signed); + } + zig_unreachable(); +} |
