[llvm-commits] [llvm] r47172 - in /llvm/trunk/lib/CodeGen/SelectionDAG: LegalizeTypes.h LegalizeTypesPromote.cpp
Duncan Sands
baldrick at free.fr
Fri Feb 15 11:34:17 PST 2008
Author: baldrick
Date: Fri Feb 15 13:34:17 2008
New Revision: 47172
URL: http://llvm.org/viewvc/llvm-project?rev=47172&view=rev
Log:
Teach LegalizeTypes how to promote the flags
in a ret node. These are created as i32 constants
but on some platforms i32 is not legal. This
fixes 26 "make check" failures, for example
Alpha/2005-07-12-TwoMallocCalls.ll.
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h
llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesPromote.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h?rev=47172&r1=47171&r2=47172&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h Fri Feb 15 13:34:17 2008
@@ -182,18 +182,19 @@
// Operand Promotion.
bool PromoteOperand(SDNode *N, unsigned OperandNo);
SDOperand PromoteOperand_ANY_EXTEND(SDNode *N);
- SDOperand PromoteOperand_ZERO_EXTEND(SDNode *N);
- SDOperand PromoteOperand_SIGN_EXTEND(SDNode *N);
- SDOperand PromoteOperand_TRUNCATE(SDNode *N);
+ SDOperand PromoteOperand_BR_CC(SDNode *N, unsigned OpNo);
+ SDOperand PromoteOperand_BRCOND(SDNode *N, unsigned OpNo);
SDOperand PromoteOperand_FP_EXTEND(SDNode *N);
SDOperand PromoteOperand_FP_ROUND(SDNode *N);
SDOperand PromoteOperand_INT_TO_FP(SDNode *N);
+ SDOperand PromoteOperand_RET(SDNode *N, unsigned OpNo);
SDOperand PromoteOperand_SELECT(SDNode *N, unsigned OpNo);
- SDOperand PromoteOperand_BRCOND(SDNode *N, unsigned OpNo);
- SDOperand PromoteOperand_BR_CC(SDNode *N, unsigned OpNo);
SDOperand PromoteOperand_SETCC(SDNode *N, unsigned OpNo);
+ SDOperand PromoteOperand_SIGN_EXTEND(SDNode *N);
SDOperand PromoteOperand_STORE(StoreSDNode *N, unsigned OpNo);
-
+ SDOperand PromoteOperand_TRUNCATE(SDNode *N);
+ SDOperand PromoteOperand_ZERO_EXTEND(SDNode *N);
+
void PromoteSetCCOperands(SDOperand &LHS,SDOperand &RHS, ISD::CondCode Code);
//===--------------------------------------------------------------------===//
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesPromote.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesPromote.cpp?rev=47172&r1=47171&r2=47172&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesPromote.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesPromote.cpp Fri Feb 15 13:34:17 2008
@@ -340,8 +340,10 @@
case ISD::MEMSET:
case ISD::MEMCPY:
case ISD::MEMMOVE: Res = HandleMemIntrinsic(N); break;
+
+ case ISD::RET: Res = PromoteOperand_RET(N, OpNo); break;
}
-
+
// If the result is null, the sub-method took care of registering results etc.
if (!Res.Val) return false;
// If the result is N, the sub-method updated N in place.
@@ -524,3 +526,27 @@
SVOffset, N->getMemoryVT(),
isVolatile, Alignment);
}
+
+SDOperand DAGTypeLegalizer::PromoteOperand_RET(SDNode *N, unsigned OpNo) {
+ assert(!(OpNo & 1) && "Return values should be legally typed!");
+ assert((N->getNumOperands() & 1) && "Wrong number of operands!");
+
+ // It's a flag. Promote all the flags in one hit, as an optimization.
+ SmallVector<SDOperand, 8> NewValues(N->getNumOperands());
+ NewValues[0] = N->getOperand(0); // The chain
+ for (unsigned i = 1, e = N->getNumOperands(); i < e; i += 2) {
+ // The return value.
+ NewValues[i] = N->getOperand(i);
+
+ // The flag.
+ SDOperand Flag = N->getOperand(i + 1);
+ if (getTypeAction(Flag.getValueType()) == Promote)
+ // The promoted value may have rubbish in the new bits, but that
+ // doesn't matter because those bits aren't queried anyway.
+ Flag = GetPromotedOp(Flag);
+ NewValues[i + 1] = Flag;
+ }
+
+ return DAG.UpdateNodeOperands(SDOperand (N, 0),
+ &NewValues[0], NewValues.size());
+}
More information about the llvm-commits
mailing list