[llvm-commits] [PATCH] TableGen backend support to express relations between instruction

Jakob Stoklund Olesen stoklund at 2pi.dk
Mon Oct 1 09:34:59 PDT 2012


On Sep 30, 2012, at 9:16 PM, "Jyotsna Verma" <jverma at codeaurora.org> wrote:

>>> 4) For each key instructions, we form a small group of instructions
>>> which have the same values as the key instruction for all the fields
>>> listed in RowFields.
>> 
>> OK, please avoid using a quadratic algorithm to do that.
> 
> I have tried to come up with an alternative algorithm but I couldn't think
> of any. If you have any ideas, I would like to hear them.

Sure.

Make one scan over the instructions, using the column fields to determine which column the instruction belongs to, if any. Build a map that is keyed by the values of the row fields, and with values that are vectors of Records:

 Map (RowVal1, RowVal2, …) --> [KeyCol, Val1Col, Val2Col, …]

While doing this, you can collect the KeyCol records, like you are doing now.

One the second pass over the KeyCol records, you can look up the corresponding records in the map.

> I wanted to abstract all the functionality required for Instruction Mapping
> at one place. You are right about the class having very little state.
> However, since the dataset I'm operating on is changing for each iteration,
> it didn't make sense to store it inside the class.

Instead of having effectively a singleton class, create a new instance for each table you're building. Then you can have all the context variables as members.

/jakob





More information about the llvm-commits mailing list