[LLVMdev] TableGen related question for the Hexagon backend

Jakob Stoklund Olesen stoklund at 2pi.dk
Thu Aug 16 17:21:15 PDT 2012


On Aug 16, 2012, at 1:39 PM, Jyotsna Verma <jverma at codeaurora.org> wrote:

> Hi Everyone,
> 
> After some more thoughts to the Jacob's suggestion of using multiclasses for
> Opcode mapping, this is what I have come up with. Please take a look at the
> design below and let me know if you have any suggestions/questions.

Hi Jyotsna,

You are on to something here, but you don't need to define a 'Relations' class on top of the tablegen records. They are already relations, you just need the proper query language to match the instructions you want.

You simply use the existing fields in your instructions, or add new ones as needed. You don't want to be limited to a single 'IFormat' as a column identifier, there can be many different types of relationships  between instructions.

Do something like this:

def getPredicatedOpcode : InstrMapping {

  // Only include instructions form the PredRel class.
  let FilterClass = "PredRel";

  // Instructions with the same BaseOpcode field form a row.
  let RowFields = ["BaseOpcode"];

  // Instructions with the same predicate sense form a column.
  let ColFields = ["PredSense"];

  // The key column is the unpredicated instructions.
  let KeyCol = ["nopred"];

  // Value columns are predicate=true and predicate=false
  let ValueCols = [["true"], ["false"]];
};

That should be enough to generate a table:

 // key , PredSense=true, PredSense=false
 {  ADD , ADDtrue,        ADDfalse,       // BaseOpcode="ADD"
 {  SUB , SUBtrue,        SUBfalse,       // BaseOpcode="SUB"
…

> 5) We need some changes in the TGParser.cpp so that it can use the
> information specified 
> through the RelationMap and populate relevant fields in the RelHexagon
> class. 

The tablegen parser is definitely not the right place to implement this.

/jakob





More information about the llvm-dev mailing list