I got this library working with printing String literals, but I can't seem to get it to print floating point numbers. Delimiting them with %f leads to 0.000000 no matter the contents of the actual constant, and %d just gives me jibberish nothing close to the actual value.
This is the code that I have
val EXIT_CODE_OK = 0
val STRING_TYPE = Pointer(I8Type)
val module = ModuleBuilder()
val mainFunction = module.createMainFunction()
module.addDeclaration(FunctionDeclaration("printf", I32Type, listOf(STRING_TYPE), varargs = true))
val okBlock = mainFunction.entryBlock()
val num = 2.0
val numConst = FloatConst(num, FloatType)
okBlock.addInstruction(Printf(mainFunction.stringConstForContent("%f\n").reference(), numConst))
okBlock.addInstruction(ReturnInt(EXIT_CODE_OK))
println(module.IRCode())
I got this library working with printing String literals, but I can't seem to get it to print floating point numbers. Delimiting them with %f leads to 0.000000 no matter the contents of the actual constant, and %d just gives me jibberish nothing close to the actual value.
This is the code that I have