LegalizeDAG.cpp
SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
case ISD::RET:
Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the chain.
switch (Node->getNumOperands()) {
case 2: // ret val
[skipped]
case 1: // ret void
[skipped]
default: { // ret <values>
[skipped]
Does it imply that a ret instruction may return more than one values?
ret uint 1, uint 2, ubyte 3, uint 4
But at most one return value is allowed, according to
http://llvm.cs.uiuc.edu/docs/LangRef.html#i_ret
Syntax:
ret <type> <value> ; Return a value from a non-void function
ret void ; Return from void function
How to define a function with multiple return values? The code:
uint, uint, ubyte, uint %main() {
ret uint 1, uint 2, ubyte 3, uint 4
}
cannot be correctly assembled by llvm-as.
LegalizeDAG.cpp
SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
case ISD::RET:
Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the chain.
switch (Node->getNumOperands()) {
case 2: // ret val
[skipped]
case 1: // ret void
[skipped]
default: { // ret <values>
[skipped]
Does it imply that a ret instruction may return more than one values?
ret uint 1, uint 2, ubyte 3, uint 4
No. This code is used when a target must return a value in multiple registers. For example, on the i386, a 64-bit integer is returned in EAX and EDX.
But at most one return value is allowed, according to
http://llvm.cs.uiuc.edu/docs/LangRef.html#i_ret
Correct.
How to define a function with multiple return values? The code:
uint, uint, ubyte, uint %main() {
ret uint 1, uint 2, ubyte 3, uint 4
}
cannot be correctly assembled by llvm-as.
LLVM does not currently support this. I would like to add this extension in the future, but we do not have it yet. If you're interested, here are my personal notes on the topic:
http://nondot.org/sabre/LLVMNotes/MultipleReturnValues.txt
In the meantime, multiple values must be returned with by-reference parameters.
-Chris