[llvm-commits] [patch] TableGen mangling for enums (AArch64 generic change)

Jakob Stoklund Olesen stoklund at 2pi.dk
Wed Jan 9 10:04:39 PST 2013


On Jan 9, 2013, at 5:50 AM, Tim Northover <Tim.Northover at arm.com> wrote:

> Hi all,
> 
> This patch changes how TableGen's AsmMatcherEmitter names some of its enum 
> entries slightly to enable a particular pattern I've been using on AArch64.
> 
> The problem is that when defining Operands in TableGen, I'd like to be able to 
> write something like:
> 
> def uimm8_operand : Operand<i32> {
>  let PredicateMethod = "isUImm<8>";
>  [...]
> }
> 
> which calls the method:
> 
> template<int width> bool AArch64Operand::isUImm() const;
> 
> This saves duplicating the handling of operands which behave in essentially 
> the same manner. 
> 
> This all worked fine until half-way through last year when TableGen started 
> adding the PredicateMethod strings to an enum. Obviously, "isUImm<8>" is not 
> an appropriate enum tag, so this doesn't work.
> 
> This patch applies a very simple mangling scheme to names that are going to be 
> inserted into the enum: replace any nasty characters by "_". It's not 
> flawless: if someone has an actual predicatemethod called "isUImm_8_" then it 
> will break. However, it will break noisily (compile-time failure) and I 
> believe the trade-off to be acceptable (similar breakage could happen in the 
> existing code).
> 
> Can I commit this?

Looks good, although I would prefer not using isalnum() which has locale-dependent behaviour. It doesn't seem like a big deal here, though, since other parts will complain about PredicateMethod = "isMööse".

/jakob





More information about the llvm-commits mailing list