-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
remove the type parameter from builtins that support vectors #6835
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
Comments
Yup, that would be neat. |
Yes, partially. |
As they're defined right now it'd be a problem to extend them to vectors.
If this logic is extended to vectors |
The same proposal for |
AIR: * `array_elem_val` is now allowed to be used with a vector as the array type. * New instructions: splat, vector_init AstGen: * The splat ZIR instruction uses coerced_ty for the ResultLoc, avoiding an unnecessary `as` instruction, since the coercion will be performed in Sema. * Builtins that accept vectors now ignore the type parameter. Comment from this commit reproduced here: The accepted proposal #6835 tells us to remove the type parameter from these builtins. To stay source-compatible with stage1, we still observe the parameter here, but we do not encode it into the ZIR. To implement this proposal in stage2, only AstGen code will need to be changed. Sema: * `clz` and `ctz` ZIR instructions are now handled by the same function which accept AIR tag and comptime eval function pointer to differentiate. * `@typeInfo` for vectors is implemented. * `@splat` is implemented. It takes advantage of `Value.Tag.repeated` 😎 * `elemValue` is implemented for vectors, when the index is a scalar. Handling a vector index is still TODO. * Element-wise coercion is implemented for vectors. It could probably be optimized a bit, but it is at least complete & correct. * `Type.intInfo` supports vectors, returning int info for the element. * `Value.ctz` initial implementation. Needs work. * `Value.eql` is implemented for arrays and vectors. LLVM backend: * Implement vector support when lowering `array_elem_val`. * Implement vector support when lowering `ctz` and `clz`. * Implement `splat` and `vector_init`.
These are covered by #10248. |
AIR: * `array_elem_val` is now allowed to be used with a vector as the array type. * New instructions: splat, vector_init AstGen: * The splat ZIR instruction uses coerced_ty for the ResultLoc, avoiding an unnecessary `as` instruction, since the coercion will be performed in Sema. * Builtins that accept vectors now ignore the type parameter. Comment from this commit reproduced here: The accepted proposal ziglang#6835 tells us to remove the type parameter from these builtins. To stay source-compatible with stage1, we still observe the parameter here, but we do not encode it into the ZIR. To implement this proposal in stage2, only AstGen code will need to be changed. Sema: * `clz` and `ctz` ZIR instructions are now handled by the same function which accept AIR tag and comptime eval function pointer to differentiate. * `@typeInfo` for vectors is implemented. * `@splat` is implemented. It takes advantage of `Value.Tag.repeated` 😎 * `elemValue` is implemented for vectors, when the index is a scalar. Handling a vector index is still TODO. * Element-wise coercion is implemented for vectors. It could probably be optimized a bit, but it is at least complete & correct. * `Type.intInfo` supports vectors, returning int info for the element. * `Value.ctz` initial implementation. Needs work. * `Value.eql` is implemented for arrays and vectors. LLVM backend: * Implement vector support when lowering `array_elem_val`. * Implement vector support when lowering `ctz` and `clz`. * Implement `splat` and `vector_init`.
Closes ziglang#12529 Closes ziglang#12511 Closes ziglang#6835
Closes ziglang#12529 Closes ziglang#12511 Closes ziglang#6835
Closes ziglang#12529 Closes ziglang#12511 Closes ziglang#6835
As described in LLVM's docs:
@bitReverse(comptime T: type, integer: T) T
uses llvm-bitreverse-intrinsics@clz(comptime T: type, integer: T)
uses llvm-ctlz-intrinsic@ctz(comptime T: type, integer: T)
uses llvm-cttz-intrinsic@popCount(comptime T: type, integer: T)
uses llvm-ctpop-intrinsicProposal: remove first parameter (like
@cos
,@sin
, etc. builtins):@bitReverse(value: anytype) @TypeOf(value)
@clz(value: anytype) T
@ctz(value: anytype) T
@popCount(value: anytype) T
Where
T
iscomptime_int
ifvalue
is known at comptime. Otherwise,T
isusize
.Related #903 as always.
The text was updated successfully, but these errors were encountered: