Skip to content
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

Add LLVM intrinsic funtions #43

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

alperenunal
Copy link

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.

Copy link
Member

@aykevl aykevl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

ir.go Outdated
t.C = C.LLVMIntrinsicGetType(c.C, C.unsigned(id), llvmTypeRefPtr(&paramTypes[0]), C.size_t(len(paramTypes)))
return
}
func (c Module) InsertIntrinsic(id uint, paramTypes []Type) (v Value) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest GetIntrinsic to match the C name and because it really is a kind of getter.

@alperenunal
Copy link
Author

Your welcome!
Committed new changes. Waiting for your review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants