[LLVMdev] TableGen related question for the Hexagon backend

Jyotsna Verma jverma at codeaurora.org
Fri Aug 17 10:02:03 PDT 2012


Hi Jacob,

Thanks for the suggestions. I have a few questions here.

> 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.

Are you saying that the mechanism is already present which allows us to
relate instructions with each other? What do you mean by a proper query
language?

> 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.

We do have different type of relationships between instructions. I define
multiple IFormat objects one per relationship which finally translates into
a unique column into the mapping table.

def Format_rr : IFormat<1>;
def Format_ri : IFormat<2>;
def Format_predt : IFormat<3>;
def Format_predf : IFormat<4>;

Addrr : { Addrr, Addri, Addrr_pt, Addrr_pf, .. , ..}
Addri : { Addrr, Addri, Addri_pt, Addri_pf,..

> 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"]]; };

Can you please elaborate it more? It seems interesting but I coundn't
understand it completely. 
Also, how do I get the table from the definition above? For the table, I
need to know the name of the predicated-true and false instructions.

> 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.

I didn't want to modify the tablegen parser either. But, I couldn't think of
a way around it. Once instructions are expended by the TableGen parser,
there is no way to relate them. Since I wanted to encode this formation
within the instruction itself while they are being expanded, parser appeared
to be the only place to do it. 

Thanks,
Jyotsna




More information about the llvm-dev mailing list