-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
make @clz() @ctz() @popCount() @byteSwap() @bitReverse() all take types #2240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
shawnl
commented
Apr 10, 2019
08b0f10 to
7986208
Compare
…ake types Closes: ziglang#2119 breaking: @bitreverse -> @bitreverse, @bswap -> @bswap Closes: ziglang#2120 Comes with tests
src/analyze.cpp
Outdated
| } | ||
|
|
||
| //Equivilent to math.Log2Int. ceil log2int | ||
| ZigType *get_shift_type(CodeGen *g, uint64_t x) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can use the existing functions get_smallest_unsigned_int_type and bits_needed_for_unsigned. See ir_analyze_bit_shift which has to do the same thing as @clz.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't. There are differn't. I added a comment explaining why.
doc/langref.html.in
Outdated
|
|
||
| {#header_open|@bswap#} | ||
| <pre>{#syntax#}@bswap(comptime T: type, value: T) T{#endsyntax#}</pre> | ||
| {#header_open|@bSwap#} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we go straight from bswap (which matches gcc builtin) to byteSwap (more verbose, zig-style name)?
std/special/compiler_rt.zig
Outdated
|
|
||
| if (!is_test) { | ||
| // only create these aliases when not testing | ||
| // Why don't we need these when testing? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember, to be honest. You can delete my unhelpful comment (apologies for that). I don't think changing it to a question helps anything though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured it out. These are aliases, not the canonical names...I will update this comment
src/ir.cpp
Outdated
| IrInstruction *result = ir_build_clz(&ira->new_irb, | ||
| clz_instruction->base.scope, clz_instruction->base.source_node, value); | ||
| result->value.type = return_type; | ||
| if (op->value.type->id == ZigTypeIdComptimeInt) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it does implicitly cast, but yes this check should be removed too. (ever occurrence)
|
1 sec, bugs |
|
needs some more tests. |
|
still working on this? |
The Zig error when trying to do things with a function pointer is not very good....
|
Merged in e09c05f |