Flags
From LLVM
Flag Operands
Basically, flag operands (SDNPInFlag, SDNPOutFlag) are a hack used to handle resources that are not accurately modeled in the scheduler (e.g. condition codes, explicit register assignments, etc). The basic idea of the flag operand is that they require the scheduler to keep the "flagged" nodes stuck together in the output machine instructions.
Flag in the SelectionDAG stuff is so named because it was originally used for condition codes. However, it has since grown to mean "keep these two nodes always together". In the case of return, you want the scheduler to produce code like this (on PPC):
... R3 = outval_virtreg blr
not like this:
... R3 = outval_virtreg ... blr
So the copy and blr are flagged together.
Another case where flags are useful are for things like the X86 variable shift instruction. There the shift amount is required to be in the CL register, so we generate code like this:
CL = shamt_virtreg X = shl Y, CL
We don't want the copy and shift to wander apart from each other (e.g. we don't want another shift to get scheduled in between them), so we flag them together. In practice, these copies usually get coallesced away.
c.f. http://www.nabble.com/-RFC%2C-ARM--expanding-RET-to-CopyToReg-BRIND-to4625955.html#a4632200 http://www.nabble.com/tblgen-multiclasses-to6709894.html#a6727113

