[LLVMdev] to lower "write to argument pointer"
kewuzhang
kewu.zhang at amd.com
Tue Jul 29 10:35:55 PDT 2014
Thanks Tom!
On Jul 29, 2014, at 10:09 AM, Tom Stellard <tom at stellard.net> wrote:
> On Tue, Jul 29, 2014 at 12:25:55AM -0400, kewuzhang wrote:
>> Drear there:
>>
>> The problem I have is to lower an intrinsic function like this
>> ”
>> float @llvm.write.arg(flaot %src, float* %dst)
>> “
>> I am lowering it with INTRINSIC_W_CHAIN, so the return value and the value to write to dst are generated with some operations using src:
>>
>> "
>> // it is the frame index node corresponding to input pointer
>> SDvalue frindex = Op.getoperand(3);
>> …
>> SDValue returnValue = DAG.getNode(myNode1, DL, VT….);
>>
>> SDValue dstValue = DAG.getNode(myNode2, DL, VT….);
>>
>> // to save the value to dst pointer, I think I need some call like
>> SDValue dstOut = DAG.getStore(chain, DL, dstValue, FrameIndex, MachinePointerInfo(), false, false, 0);
>>
>> “
>> I have two questions here:
>> (1) should I return some merges values( returnValue, DstValue) ? or only return returnValue is right? ( the dag dumped out looks better if I return the merged values)
>
> Since INTRINSIC_W_CHAIN has two values, whatever you lower it to should
> have two: The result and the chain. You canuse MERGE_VALUES for that.
I mean , since the dstValue is wrote to the pointer of dst via " SDValue dstOut = DAG.getStore(chain, DL, dstValue, FrameIndex, MachinePointerInfo(), false, false, 0);”,
Should I only return the "SDValue returnValue = DAG.getNode(myNode1, DL, VT….);” And the chain is only used by the dstOut to write out to pointer?
>
>> (2) How the FrameIndex should be computed? I use DAG.getFrameIndex((dyn_cast<FrameIndexSDnode>( frindex.getNode()))->getIndex(), i32), not confident it is correct, any good examples to understand to this?
>>
>
> Is the FrameIndex one of the inputs to the intrinsic, or are you trying
> to create a new FrameIndex?
>
I think the FrameIndexSDNode is generated by DAGBuilder when it sees the input dst pointer in call " float @llvm.write.arg(flaot %src, float* %dst)”. should be the one you mentioned “frameIndex one of the inputs to the intrinsic”.
I don’t think I need to create new Frameindex.
Best
Kevin
More information about the llvm-dev
mailing list