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

LLVM calling conventions and parameter attributes #217

Open
mrahhal opened this issue Aug 5, 2023 · 3 comments
Open

LLVM calling conventions and parameter attributes #217

mrahhal opened this issue Aug 5, 2023 · 3 comments

Comments

@mrahhal
Copy link
Contributor

mrahhal commented Aug 5, 2023

Hello. From what I can tell there's currently no way to specify the calling conventions and parameter attributes from LLVMSharp. Documentation for these here:

I don't mind trying to contribute these if they're missing, but I'm having a hard time finding any documentation at all for what libLLVM exposes related to this. (I'm aware that it's not exactly stable or properly documented from what I know)

@mrahhal
Copy link
Contributor Author

mrahhal commented Aug 6, 2023

I believe this is the binding for the function from the LLVM-C lib side for the parameter attributes:

public static extern void AddAttributeAtIndex([NativeTypeName("LLVMValueRef")] LLVMOpaqueValue* F, LLVMAttributeIndex Idx, [NativeTypeName("LLVMAttributeRef")] LLVMOpaqueAttributeRef* A);

But it doesn't have a managed wrapper.

Similarly, for calling conventions:

Which is the managed wrapper, but the type used is uint which is a bit opaque. An enum with the descriptive names from https://llvm.org/docs/LangRef.html#calling-conventions could be used instead.

If you can validate this, I'll try and contribute adding the proper wrappers for these.

@tannergooding
Copy link
Member

But it doesn't have a managed wrapper.

The managed wrapper is very much a WIP and not everything has been exposed yet. Contributions are more than welcome to help get the missing pieces filled in.

Which is the managed wrapper, but the type used is uint which is a bit opaque.

The type is uint because that is what the C API returns: https://llvm.org/doxygen/group__LLVMCCoreValueFunction.html#ga36902516d7b958ce09642cfe8a96c887

The managed wrapper type Function is what would provide this in a more type-safe way via an enum. It would try to follow the general conventions laid out by the C++ API: https://llvm.org/doxygen/classllvm_1_1Function.html#a5f494edc0a569c7fc9ff4181243be1ed

@mrahhal
Copy link
Contributor Author

mrahhal commented Aug 7, 2023

Thanks for confirming. I will try and work on these two as a start.

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

No branches or pull requests

2 participants