[LLVMdev] The meaning of SDNPHasChain

Evan Cheng evan.cheng at apple.com
Thu Oct 5 18:36:57 CDT 2006


On Oct 5, 2006, at 4:08 PM, Roman Levenstein wrote:

> Hi,
>
> What does it mean if a custom Node in the instructions description  
> file
> is declared to have a Chain?
> Looking at different backends, I have the impression that it describes
> some sort of side effect and usually used for nodes affecting the
> control flow. But I'm not quite sure. Can someone describe the
> semantics of this property and also what is a typical usage of it?

Right, llvm models control flow dep. as chain operands. We use it to  
model relative ordering of memory operations. SDNPHasChain is defined  
in TargetSelectionDAG.td as a node property. It tells tblegen that  
specific node read / write chains so tblgen can emit the correct  
selection code for patterns that use these SDNode's.

>
> In particular, I have found that CMP nodes for different targets are
> described differently with regard to this property. ARM backend  
> defines
> armcmp without this property. PCC defines PCCvcmp and PCCvcmp_o also
> without this property. In Sparc backend SPcmpicc is also not using it.
> But X86cmp does for some reason. I'm trying to understand if I need it
> for my backend or not.

X86ISD::CMP is a X86 specific target node. Other targets have similar  
nodes but there are subtle differences. Initially X86ISD::CMP was not  
defined to have a chain. It was added later as an "optimization" to  
force ordering between a load operand, cmp, and its CMOV or BRCOND  
use to allow load folding. X86 cmp / test can fold load, but it may  
cause cycles in the DAG if the instruction selector is not careful. I  
doubt any other current targets needs this.


>
> It would be also interesting to get some information about other  
> SDNP-*
> SelectionDAG node properties, e.g. SDNPOutFlag, SDNPInFlag,
> SDNPOptInFlag and their purpose.

TargetSelectionDAG.td describes them briefly. Basically a "flag" is a  
way to glue two nodes together. That is, the node which produces a  
flag and its use has to be scheduled together. So SDNPOutFlag means  
the node produces a flag, SDNPInFlag means it reads a flag, and  
SDNPOptInFlag has an optional flag operand (which always comes last).

Evan

>
> -Roman
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev



More information about the LLVMdev mailing list