aboutsummaryrefslogtreecommitdiff
path: root/src/analyze.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-05-06 23:13:12 -0400
committerAndrew Kelley <superjoe30@gmail.com>2017-05-06 23:13:12 -0400
commit157af4332a7b78672ff8ad76a00120455547e2fd (patch)
tree0e75d0d9bb111f8e778587a2fb547b74a17c5aa1 /src/analyze.cpp
parent866c841dd8770bcc12af0aaf946c80819f5e0092 (diff)
downloadzig-157af4332a7b78672ff8ad76a00120455547e2fd.tar.gz
zig-157af4332a7b78672ff8ad76a00120455547e2fd.zip
builtin functions for division and remainder division
* add `@divTrunc` and `@divFloor` functions * add `@rem` and `@mod` functions * add compile error for `/` and `%` with signed integers * add `.bit_count` for float primitive types closes #217
Diffstat (limited to 'src/analyze.cpp')
-rw-r--r--src/analyze.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp
index 2b2c303ea8..e1d8ca2869 100644
--- a/src/analyze.cpp
+++ b/src/analyze.cpp
@@ -4228,6 +4228,10 @@ uint32_t zig_llvm_fn_key_hash(ZigLLVMFnKey x) {
return (uint32_t)(x.data.ctz.bit_count) * (uint32_t)810453934;
case ZigLLVMFnIdClz:
return (uint32_t)(x.data.clz.bit_count) * (uint32_t)2428952817;
+ case ZigLLVMFnIdFloor:
+ return (uint32_t)(x.data.floor_ceil.bit_count) * (uint32_t)1899859168;
+ case ZigLLVMFnIdCeil:
+ return (uint32_t)(x.data.floor_ceil.bit_count) * (uint32_t)1953839089;
case ZigLLVMFnIdOverflowArithmetic:
return ((uint32_t)(x.data.overflow_arithmetic.bit_count) * 87135777) +
((uint32_t)(x.data.overflow_arithmetic.add_sub_mul) * 31640542) +
@@ -4244,6 +4248,9 @@ bool zig_llvm_fn_key_eql(ZigLLVMFnKey a, ZigLLVMFnKey b) {
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 ZigLLVMFnIdFloor:
+ case ZigLLVMFnIdCeil:
+ return a.data.floor_ceil.bit_count == b.data.floor_ceil.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) &&