-
Notifications
You must be signed in to change notification settings - Fork 239
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
Support vector types in math operations #45
Comments
Thanks for opening an issue! If I understand correctly, for example, Assuming I'm understanding your feature request, I propose to do the following:
How does that sound to you? I think that 1) will allow your feature request to be implemented in its most basic form and 2) allow the feature to acquire further compile time guarantees as inkwell is able to provide them |
Hey! Thanks for the response :) I don't think you're able to add a number to a vector - the LLVM language reference manual says "both arguments must have identical types" - which possibly complicates the first proposal... Maybe we can use a generic parameter there? i.e something like Those other proposals sound good... It might also be worth considering in the future an extra const generic parameter on |
Yes, generically constraining the lhs and rhs is definitely the way to go to ensure they're the same type then. Sounds good, I look forward to your PR! In the mean time I will create another issue to make sure to follow up on 2) & 3). And good point on the vector size. |
Is your feature request related to a problem? Please describe.
Yep -- in LLVM IR it is entirely valid to use mathematical operations on vector values, provided the two vectors have the same lengths and element type (and the element type is numeric, of course). However, all of Inkwell's math builder functions take and return
IntValue
orFloatValue
values, meaning vectors can't easily be passed in without converting to aBasicValueEnum
then back or using transmute.Describe the solution you'd like
I'm not too sure what a solution would look like - a simple but messy solution might be to add functions like
build_float_vec_add
andbuild_int_vec_add
, but you do lose the benefit of the typed parameters (although there's probably no way around that until #8 is resolved...)I'm happy to make a pull request with the solution outlined above, although it's probably worth some discussion on a better alternative first?
The text was updated successfully, but these errors were encountered: