Add LLVM intrinsic funtions#43
Open
alperenunal wants to merge 2 commits intotinygo-org:mainfrom
Open
Conversation
aykevl
reviewed
Jan 11, 2023
Member
aykevl
left a comment
There was a problem hiding this comment.
Thank you for the contribution!
Please don't look too much at the existing code for code style inspiration. It's really a mess that was inherited from LLVM. Instead:
- Please add a newline between functions.
- Please add a bit of documentation to the functions. Even if it is simply a copy of the C/C++ API documentation.
In addition, I think it would be nice to define an Intrinsic type with methods, instead of using a bare uint. Something like:
type Intrinsic C.unsigned
func (in Intrinsic) IsOverloaded() bool { ... }Also, note that unsigned in C is not the same as Go uint. Go uint on a 64-bit system is usually uint64, while C unsigned is usually 32 bits. (It probably doesn't matter in practice though).
| t.C = C.LLVMIntrinsicGetType(c.C, C.unsigned(id), llvmTypeRefPtr(¶mTypes[0]), C.size_t(len(paramTypes))) | ||
| return | ||
| } | ||
| func (c Module) InsertIntrinsic(id uint, paramTypes []Type) (v Value) { |
Member
There was a problem hiding this comment.
I'd suggest GetIntrinsic to match the C name and because it really is a kind of getter.
Author
|
Your welcome! |
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added few functions to manage intrinsic functions. I'm not sure about where to put them in source and also don't know if they fit your naming convention.