[LLVMdev] TableGen backend support to express relations between instruction
Jyotsna Verma
jverma at codeaurora.org
Tue Aug 28 12:11:36 PDT 2012
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
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum.
-----Original Message-----
From: Hal Finkel [mailto:hfinkel at anl.gov]
Sent: Tuesday, August 28, 2012 1:27 PM
To: Jyotsna Verma
Cc: 'Jakob Stoklund Olesen'; llvmdev at cs.uiuc.edu
Subject: Re: [LLVMdev] TableGen backend support to express relations between
instruction
Jyotsna,
I hadn't been following this, so I apologize if this has already been
provided, but can you give a quick example of how this functionality is
used?
Thanks in advance,
Hal
On Tue, 28 Aug 2012 13:01:17 -0500
"Jyotsna Verma" <jverma at codeaurora.org> wrote:
> Hi Jakob,
>
> Here is the first draft of the patch to add TableGen backend support
> for the instruction mapping tables. Please take a look and let me know
> your suggestions. As of now, I create one mapping table per relation
> which results into a long .inc file. So, I'm planning to combine
> everything into a single table and will include APIs (one per
> relation) to query from this table.
>
> Thanks,
> Jyotsna
> --
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum.
>
>
> -----Original Message-----
> From: llvmdev-bounces at cs.uiuc.edu
> [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Jyotsna Verma
> Sent: Tuesday, August 21, 2012 12:42 PM
> To: 'Jakob Stoklund Olesen'
> Cc: llvmdev at cs.uiuc.edu
> Subject: Re: [LLVMdev] TableGen related question for the Hexagon
> backend
>
> Sounds good. I've started adding TableGen backend support to emit
> relationship table into a .inc file. Hoping to finish it soon.
>
> Thanks for all your help.
>
> -Jyotsna
> --
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum.
>
>
> -----Original Message-----
> From: Jakob Stoklund Olesen [mailto:stoklund at 2pi.dk]
> Sent: Tuesday, August 21, 2012 11:28 AM
> To: Jyotsna Verma
> Cc: llvmdev at cs.uiuc.edu
> Subject: Re: [LLVMdev] TableGen related question for the Hexagon
> backend
>
>
> On Aug 20, 2012, at 9:22 PM, Jyotsna Verma <jverma at codeaurora.org>
> wrote:
>
> > Jakob,
> >
> > One more question. You had suggested 'ValueCols' as of type
> > list<list<string> >. Does the TableGen know how to extract it? It
> > appears to me that we may have to add support for that.
>
> You just start from getValueAsListInit() and go from there.
>
> /jakob
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
--
Hal Finkel
Postdoctoral Appointee
Leadership Computing Facility
Argonne National Laboratory
More information about the llvm-dev
mailing list