[tblgen] Allow FixedLenDecoderEmitter to use APInt-like objects as InsnType

Authored by dsanders on Oct 23 2018, 10:23 AM.


[tblgen] Allow FixedLenDecoderEmitter to use APInt-like objects as InsnType

Some targets have very long encodings and uint64_t isn't sufficient. uint128_t
isn't portable so such targets need to use an object instead.

There is one catch with this at the moment, no string of bits extracted
from the encoding may exceeed 64-bits. Fields are still permitted to
exceed 64-bits so long as they aren't one contiguous string of bits. If
this proves to be a problem then we can modify the generation of
fieldFromInstruction() calls to account for it but for now I've added an
assertion for this.

InsnType must either be integral or an APInt-like object that must:

  • Have a static const max_size_in_bits equal to the number of bits in the encoding.
  • be default-constructible and copy-constructible
  • be constructible from a uint64_t (this is the key area the interface deviates from APInt since this constructor does not take the bit width)
  • be constructible from an APInt (this can be private)
  • be convertible to uint64_t
  • Support the ~, &,, ==, !=, and |= operators with other objects of the same type
  • Support shift (<<, >>) with signed and unsigned integers on the RHS
  • Support put (<<) to raw_ostream&

Reviewers: bogner, charukcs

Subscribers: nhaehnle, llvm-commits

Differential Revision: https://reviews.llvm.org/D52100

llvm-svn: 345056