[llvm-dev] Gluing arbitrary nodes together

Dylan McKay via llvm-dev llvm-dev at lists.llvm.org
Thu Jun 9 00:52:55 PDT 2016


Ping

On Sat, Jun 4, 2016 at 4:15 PM, Dylan McKay <dylanmckay34 at gmail.com> wrote:

> Hello all,
>
> I am working on adding atomics support to the AVR backend.
>
> Because the target can only have one core, it is sufficient to:
>
>    - Save the status register
>    - Disable interrupts
>    - Do the nonatomic LOAD/STORE/SWAP/ADD
>    - Restore the status register
>
> I’d really like to be able to do this at the IR level. What I want to do
> is write a custom lowering hook to convert ISD::ATOMIC_LOAD into a
> standard ISD::LOAD with the save/restore/interrupt nodes glued to it.
>
> Here’s what I have so far:
>
>   // Store `SREG`
>   auto Save = DAG.getCopyFromReg(DAG.getEntryNode(), DL, AVR::SREG, MVT::i8);
>
>   // Disable interrupts (`clr` is equivalent to `bclr 7`).
>   auto ClearInterrupts = DAG.getNode(AVRISD::BCLR, DL, MVT::Glue, DAG.getConstant(7, DL, MVT::i8));
>
>   // Perform the nonatomic load.
>   auto *Node = cast<AtomicSDNode>(AtomicOp.getNode());
>   SDValue Load =  DAG.getExtLoad(ISD::EXTLOAD, SDLoc(AtomicOp), AtomicOp.getValueType(),
>                                  Node->getChain(), Node->getBasePtr(),
>                                  Node->getMemoryVT(), Node->getMemOperand());
>
>   auto Restore = DAG.getCopyToReg(DAG.getEntryNode(), DL, AVR::SREG, Save);
>
>   return Load;
>
> I can’t figure out how I can glue all these nodes together and return the
> nonatomic load.
>
> How can I do this?
>
> Cheers,
> Dylan
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160609/6422dc9f/attachment.html>


More information about the llvm-dev mailing list