Hi Hal,
I will try to explain the functionality using a simple example. Let's say
that we have three formats for 'ADD' instruction and we want to relate them.
ADD - non-predicated form
ADD_pt : predicate true
ADD_pf : predicate false
We can define the relationship between the non-predicated instructions and
their predicate formats as follows:
def getPredOpcode : InstrMapping { // InstrMapping is a new class defined in
Target.td
// Used to filter instructions that have this kind of relationship
let FilterClass = "PredRel";
// Instructions with the same BaseOpcode value 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 PredSense=true and PredSense=false
let ValueCols = [["true"], ["false"]];
}
Instructions need to set some fields in order for the TableGen to relate
them using the information provided in 'getPredOpcode'.
Def ADD: PredRel {
let BaseOpcode = "ADD";
let PredSense = "nopred";
}
Def ADD_pt: PredRel {
let BaseOpcode = "ADD";
let PredSense = "true";
}
Def ADD_pf: PredRel {
let BaseOpcode = "ADD";
let PredSense = "false";
}
Here, BaseOpcode and PredSense are the new fields added to the (Hexagon)
Instructions. Other targets can define their own relations and add new
fields if necessary. TableGen will output relations as a table which can be
queried using a function
getPredOpcode(Opcode, predsense) {
If (predsense == true)
return getPredOpcodeTable[Opcode][0]
if (predsense == false)
return getPredOpcodeTable[Opcode][1]
}
Let me know if something is not clear and I will try to explain it further.
Thanks,
Jyotsna