[llvm-commits] [llvm] r59305 - in /llvm/trunk: lib/Target/XCore/XCoreISelLowering.cpp lib/Target/XCore/XCoreISelLowering.h test/CodeGen/XCore/addsub64.ll
Richard Osborne
richard at xmos.com
Fri Nov 14 07:59:35 PST 2008
Author: friedgold
Date: Fri Nov 14 09:59:19 2008
New Revision: 59305
URL: http://llvm.org/viewvc/llvm-project?rev=59305&view=rev
Log:
[XCore] Fix expansion of 64 bit add/sub. Don't custom expand
these operations if ladd/lsub are not available on the current
subtarget.
Added:
llvm/trunk/test/CodeGen/XCore/addsub64.ll
Modified:
llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp
llvm/trunk/lib/Target/XCore/XCoreISelLowering.h
Modified: llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp?rev=59305&r1=59304&r2=59305&view=diff
==============================================================================
--- llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp Fri Nov 14 09:59:19 2008
@@ -88,9 +88,10 @@
setOperationAction(ISD::SELECT_CC, MVT::Other, Expand);
// 64bit
- setOperationAction(ISD::ADD, MVT::i64, Custom);
- setOperationAction(ISD::SUB, MVT::i64, Custom);
-
+ if (!Subtarget.isXS1A()) {
+ setOperationAction(ISD::ADD, MVT::i64, Custom);
+ setOperationAction(ISD::SUB, MVT::i64, Custom);
+ }
if (Subtarget.isXS1A()) {
setOperationAction(ISD::SMUL_LOHI, MVT::i32, Expand);
}
@@ -161,7 +162,6 @@
// FIXME: Remove these when LegalizeDAGTypes lands.
case ISD::ADD:
case ISD::SUB: return SDValue(ExpandADDSUB(Op.getNode(), DAG),0);
-
case ISD::FRAMEADDR: return LowerFRAMEADDR(Op, DAG);
default:
assert(0 && "unimplemented operand");
@@ -169,15 +169,16 @@
}
}
+/// ReplaceNodeResults - Provide custom lowering hooks for nodes with illegal
+/// result types.
SDNode *XCoreTargetLowering::
-ExpandOperationResult(SDNode *N, SelectionDAG &DAG) {
+ReplaceNodeResults(SDNode *N, SelectionDAG &DAG) {
switch (N->getOpcode()) {
- case ISD::SUB:
- case ISD::ADD:
- return ExpandADDSUB(N, DAG);
default:
- assert(0 && "Wasn't expecting to be able to lower this!");
+ assert(0 && "Don't know how to custom expand this!");
return NULL;
+ case ISD::ADD:
+ case ISD::SUB: return ExpandADDSUB(N, DAG);
}
}
@@ -301,6 +302,7 @@
assert(N->getValueType(0) == MVT::i64 &&
(N->getOpcode() == ISD::ADD || N->getOpcode() == ISD::SUB) &&
"Unknown operand to lower!");
+ assert(!Subtarget.isXS1A() && "Cannot custom lower ADD/SUB on xs1a");
// Extract components
SDValue LHSL = DAG.getNode(ISD::EXTRACT_ELEMENT, MVT::i32, N->getOperand(0),
@@ -313,18 +315,6 @@
DAG.getConstant(1, MVT::i32));
// Expand
- if (Subtarget.isXS1A()) {
- SDValue Lo = DAG.getNode(N->getOpcode(), MVT::i32, LHSL, RHSL);
-
- ISD::CondCode CarryCC = (N->getOpcode() == ISD::ADD) ? ISD::SETULT :
- ISD::SETUGT;
- SDValue Carry = DAG.getSetCC(MVT::i32, Lo, LHSL, CarryCC);
-
- SDValue Hi = DAG.getNode(N->getOpcode(), MVT::i32, LHSH, Carry);
- Hi = DAG.getNode(N->getOpcode(), MVT::i32, Hi, RHSH);
- // Merge the pieces
- return DAG.getNode(ISD::BUILD_PAIR, MVT::i64, Lo, Hi).getNode();
- }
unsigned Opcode = (N->getOpcode() == ISD::ADD) ? XCoreISD::LADD :
XCoreISD::LSUB;
SDValue Zero = DAG.getConstant(0, MVT::i32);
Modified: llvm/trunk/lib/Target/XCore/XCoreISelLowering.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreISelLowering.h?rev=59305&r1=59304&r2=59305&view=diff
==============================================================================
--- llvm/trunk/lib/Target/XCore/XCoreISelLowering.h (original)
+++ llvm/trunk/lib/Target/XCore/XCoreISelLowering.h Fri Nov 14 09:59:19 2008
@@ -67,8 +67,8 @@
/// LowerOperation - Provide custom lowering hooks for some operations.
virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG);
-
- virtual SDNode *ExpandOperationResult(SDNode *N, SelectionDAG &DAG);
+
+ virtual SDNode *ReplaceNodeResults(SDNode *N, SelectionDAG &DAG);
/// getTargetNodeName - This method returns the name of a target specific
// DAG node.
Added: llvm/trunk/test/CodeGen/XCore/addsub64.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/XCore/addsub64.ll?rev=59305&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/XCore/addsub64.ll (added)
+++ llvm/trunk/test/CodeGen/XCore/addsub64.ll Fri Nov 14 09:59:19 2008
@@ -0,0 +1,12 @@
+; RUN: llvm-as < %s | llc -march=xcore -mcpu=xs1b-generic > %t1.s
+; RUN: grep ladd %t1.s | count 2
+; RUN: grep lsub %t1.s | count 2
+define i64 @add64(i64 %a, i64 %b) {
+ %result = add i64 %a, %b
+ ret i64 %result
+}
+
+define i64 @sub64(i64 %a, i64 %b) {
+ %result = sub i64 %a, %b
+ ret i64 %result
+}
More information about the llvm-commits
mailing list