[llvm-dev] Memory-to-memory .td example?
Ryan Taylor via llvm-dev
llvm-dev at lists.llvm.org
Wed Oct 5 07:01:06 PDT 2016
Here's an example of how we are doing this, in table gen, of a mem, mem,
mem operation:
def directStore : PatFrag<(ops node:$ptr, node:$val), (store node:$ptr,
node:$val), [{.... we have some conditions here, etc... }]>;
class SetABDIn<string asmstr, DAGOperand srcA, DAGOperand srcB, DAGOperand
dstD, list<dag pattern>
: A_B_D<(outs), (ins srcA:$srcA, srcB:$srcB, dstD:$dstD),
!strconcat(asmstr, "\t$srcA, $srcB, $dstD"), pattern,
IIAlu>
{
let mayStore = 1;
let mayLoad = 1;
// whatever else here
}
multiclass ABD<string asmstr, SDPatternOperator OpNode, RegisterClass
srcAReg, RegisterClass srcBReg,
RegisterClass dstReg, ValueType srcAType,
ValueType srcBType, ValueType dstType,
Operand ImmOd, ImmLeaf imm_type>
{
def MEM_MEM_MEM: SetABDIn<asmstr, memXX, memXX, memXX,
[{directStore (OpNode (srcAType (load
addr:$srcA)), (srcBType (load addr:$srcB)), addr:$dstD)]>;
// there are other combinations here, etc...
}
You obviously won't be able to use this directly but I hope this gives you
an idea, I hope I understood your question correctly, apologies if I did
not.
Thanks,
-Ryan
ps. If your architecture can do mem-mem operations, you will run into
problems because common sub will always want to load the value into a
register if it's being used more than once, we're having to generate a
backend pass to reverse this, just fyi.
On Wed, Oct 5, 2016 at 1:07 AM, Ed Hepler via llvm-dev <
llvm-dev at lists.llvm.org> wrote:
> Hi,
>
> I'm currently doing some research on instruction set architectures and
> have been looking for a a C compiler as a tool to assist in the work.
> I'm new to LLVM, have read through the documentation, and compiled the
> release to run some tests.
>
> I looked over the documentation, and read through the .td files for some
> of the included architectures. All are register-based architectures.
> However, my work is looking at a memory-to-memory architecture, and I'm
> looking for some examples (or more documentation on writing .td files) to
> use as the basis for the .td files I need to write.
>
> Any help (or pointers to examples) is appreciated!
>
> Thanks!
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161005/6c01e05b/attachment.html>
More information about the llvm-dev
mailing list