dotnet / LLVMSharp

LLVM bindings for .NET Standard written in C# using ClangSharp
MIT License
838 stars 95 forks source link

How can I create a ConstantFP with the managed API? #216

Closed PrettyFlower closed 1 year ago

PrettyFlower commented 1 year ago

It looks like there’s a newer managed API in here that the tutorials don’t use, and it has some nice helper methods like IRBuilder.CreateFAdd() which more closely follows the c++ api. I’m trying to figure out how to do chapter 3 of the kaleidoscope tutorial but can’t figure out how to make a ConstantFP or APFloat value like they use in the NumberExprAST.

tannergooding commented 1 year ago

The managed API surface isn't "complete" today and there are still many APIs that could be exposed which don't exist yet. I've been adding these when I have time/availability to do so, but am more than open to interested parties helping out here if they have time as well.

In this case, we're missing an API like static Constant Get(Type Ty, double V) and/or some wrapper for the APFloat concept so we can expose static Constant Get(Type Ty, APFloat V)

PrettyFlower commented 1 year ago

Thanks for getting back to me. I’m only just getting started with LLVM so I’m not sure I understand it well enough to work on the managed wrapper yet. I’ll use the unmanaged one for now.