MichaReiser / llvm-node

LLVM 9.0+ Node Bindings

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

StoreInst type problem (ConstantFP)

atlx opened this issue · comments

commented

I'm trying to create a store instruction that will store a float on a float allocation (logical).

However, I'm running into the problem that when I access ConstantFP.get(), I have no way of specifying the type I want for the value. So ConstantFP.get() accepts LLVMContext and a number in that order.

But in the LLVM documentation this is possible:

image

Has this method not been implemented? The other way I tried was changing the type property of the returned value manually, but it shouldn't be like this... (have not verified working).

This is what is generated from my current code:

define void @main() {
  %pi = alloca float
  store double 3.140000e+00, float* %pi
  ret void
}

from:

...
const myFloat = parseFloat( ... )
ConstantFP.get(<context>, myFloat); // I want a float, creates a double instead.
...

The ConstantInt class' get() method looks more flexible, as it allows to specify the size, etc.

@cloudrex You're right. This wasn't yet supported. I only implemented the APIs that I needed once I worked with LLVM. The majority of LLVM is still not covered.

I created a PR adding support for constantFP #81