cornell-zhang/hcl-dialect

printing hex value prints random values

jcasas00 opened this issue · 2 comments

    def kernel():
        stype = hcl.Struct({"x": hcl.UInt(8), "y": hcl.UInt(8)})
        xy = hcl.scalar(0x1234, "foo", dtype=stype).v
        hcl.print((xy.x, xy.y), "dec: %d %d\n")
        hcl.print((xy.x, xy.y), "hex: %x %x\n")

generates:

match 0: 52 18
match 0: 0 598f4740

The "hex" print actually prints random values (number changes every run).

%x format string hasn't been supported in the LLVM backend, let me add that

llvm.mlir.printf only support f64 input type. Currently we are casting integers to float first and use .0f as a replacement for %d. We should implement our own print utility function that supports %x and %X format string