Skip to content

string representations of special FP values work with DoubleType, but not FloatType or HalfType #833

Open
@jvesely

Description

@jvesely

simple reproducer:

from llvmlite import ir

fp = ir.DoubleType()
#fp = ir.FloatType()
#fp = ir.HalfType()
fnty = ir.FunctionType(fp, ())

module = ir.Module(name=__file__)
func = ir.Function(module, fnty, name="fpadd")
block = func.append_basic_block(name="entry")
builder = ir.IRBuilder(block)
x = fp("Inf")
builder.ret(x)

print(module)

The above only works with DoubleType. Both FloatType and HalfType produce the following error:

    return struct.unpack('f', struct.pack('f', value))[0]
struct.error: required argument is not a float

Using float("Inf") instead of just "Inf" works around the problem:

target triple = "unknown-unknown-unknown"
target datalayout = ""

define float @"fpadd"() 
{
entry:
  ret float 0x7ff0000000000000
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needtriageNeeds to be triaged further

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions