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

Tim Northover Tim.Northover at arm.com
Wed Jan 9 05:50:35 PST 2013


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?

Cheers.

Tim.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tblgen-mangle.diff
Type: text/x-patch
Size: 2634 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130109/59b25e4d/attachment.bin>


More information about the llvm-commits mailing list