[LLVMdev] Tablegen binary literals

Pete Cooper peter_cooper at apple.com
Wed Jul 30 19:05:39 PDT 2014


Hi all

Currently tablegen parses binary literals such as 0b011 and immediately turns them in to integers internally.  Due to this, 0b011 is a 2-bit value because tablegen will happily drop leading zeroes on integers.

I propose that we change this, and store binary literals with a size.  I think this is much more natural, as when the user writes a value with 3 bits, I think they expect to get a value with 3 bits, and not a 2-bit value which is silently truncated and later silently zero extended.

Given this, I would then like to extend bits initializers to accept these new sized binary literals.  For example, I would like to be able to write

bits<2> opc;
bits<8> x = { opc, 0b1100, rd{1}, rs{0} }

This would let us write some encodings much more concisely, instead of having to put each initializer on its own line.

I do have patches, which I’m happy to present for review, but I’d like some feedback on the general idea before we get to the low level details.

Thanks,
Pete



More information about the llvm-dev mailing list