[PATCH 1/2] TableGen: Generate a function for getting operand indices based on their defined names

Jakob Stoklund Olesen stoklund at 2pi.dk
Fri Jun 7 09:48:55 PDT 2013


On Jun 3, 2013, at 2:23 PM, Tom Stellard <tom at stellard.net> wrote:

> From: Tom Stellard <thomas.stellard at amd.com>
> 
> This patch modifies TableGen to generate a function in
> ${TARGET}GenInstrInfo.inc called getNamedOperandIdx(), which can be used
> to look up indices for operands based on their names.
> 
> For example, if you have an instruction like:
> 
> def ADD : TargetInstr <(outs GPR:$dst), (ins GPR:$src0, GPR:$src1)>;
> 
> You can look up the operand indices using the new function, like this:
> 
> Target::getNamedOperandIdx(Target::ADD, Target::OpName::DST)  => 0
> Target::getNamedOperandIdx(Target::ADD, Target::OpName::SRC0) => 1
> Target::getNamedOperandIdx(Target::ADD, Target::OpName::SRC1) => 2
> 
> The operand names are case insensitive, so $dst is equivalent to $DST.

TableGen is not case insensitive, so won’t this create opportunities for collisions? It doesn’t seem to be necessary.

The function you’re generating looks like it could get really big. Please use some form of table compression to reduce the size.

Thanks,
/jakob





More information about the llvm-commits mailing list