aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2008-06-21 17:00:47 +0000
committerDuncan Sands <baldrick@free.fr>2008-06-21 17:00:47 +0000
commita1ace76c70ae5332d6f33fce5c0c1e2fdb8cca11 (patch)
tree58c308504951707b34e5c134a623de7686f7b075
parent4c8c83022b501759d8559e224c84ae2a9921ba41 (diff)
downloadexternal_llvm-a1ace76c70ae5332d6f33fce5c0c1e2fdb8cca11.zip
external_llvm-a1ace76c70ae5332d6f33fce5c0c1e2fdb8cca11.tar.gz
external_llvm-a1ace76c70ae5332d6f33fce5c0c1e2fdb8cca11.tar.bz2
Support for load/store of expanded float types. I
don't know if a truncating store is possible here, but added support for it anyway. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52577 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp62
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp2
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeTypes.h2
-rw-r--r--test/CodeGen/PowerPC/2008-06-21-F128LoadStore.ll10
4 files changed, 75 insertions, 1 deletions
diff --git a/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp b/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
index 2a36ae2..ed1e496 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
@@ -404,6 +404,8 @@ void DAGTypeLegalizer::ExpandFloatResult(SDNode *N, unsigned ResNo) {
case ISD::BIT_CONVERT: ExpandRes_BIT_CONVERT(N, Lo, Hi); break;
case ISD::BUILD_PAIR: ExpandRes_BUILD_PAIR(N, Lo, Hi); break;
case ISD::EXTRACT_VECTOR_ELT: ExpandRes_EXTRACT_VECTOR_ELT(N, Lo, Hi); break;
+
+ case ISD::LOAD: ExpandFloatRes_LOAD(N, Lo, Hi); break;
}
// If Lo/Hi is null, the sub-method took care of registering results etc.
@@ -411,6 +413,38 @@ void DAGTypeLegalizer::ExpandFloatResult(SDNode *N, unsigned ResNo) {
SetExpandedFloat(SDOperand(N, ResNo), Lo, Hi);
}
+void DAGTypeLegalizer::ExpandFloatRes_LOAD(SDNode *N, SDOperand &Lo,
+ SDOperand &Hi) {
+ if (ISD::isNON_EXTLoad(N)) {
+ ExpandRes_NON_EXTLOAD(N, Lo, Hi);
+ return;
+ }
+
+ assert(ISD::isUNINDEXEDLoad(N) && "Indexed load during type legalization!");
+ LoadSDNode *LD = cast<LoadSDNode>(N);
+ SDOperand Chain = LD->getChain();
+ SDOperand Ptr = LD->getBasePtr();
+
+ MVT NVT = TLI.getTypeToTransformTo(LD->getValueType(0));
+ assert(NVT.isByteSized() && "Expanded type not byte sized!");
+ assert(LD->getMemoryVT().bitsLE(NVT) && "Float type not round?");
+
+ Lo = DAG.getExtLoad(LD->getExtensionType(), NVT, Chain, Ptr,
+ LD->getSrcValue(), LD->getSrcValueOffset(),
+ LD->getMemoryVT(),
+ LD->isVolatile(), LD->getAlignment());
+
+ // Remember the chain.
+ Chain = Lo.getValue(1);
+
+ // The high part is undefined.
+ Hi = DAG.getNode(ISD::UNDEF, NVT);
+
+ // Modified the chain - switch anything that used the old chain to use the
+ // new one.
+ ReplaceValueWith(SDOperand(LD, 1), Chain);
+}
+
//===----------------------------------------------------------------------===//
// Float Operand Expansion
@@ -441,6 +475,10 @@ bool DAGTypeLegalizer::ExpandFloatOperand(SDNode *N, unsigned OpNo) {
case ISD::BIT_CONVERT: Res = ExpandOp_BIT_CONVERT(N); break;
case ISD::BUILD_VECTOR: Res = ExpandOp_BUILD_VECTOR(N); break;
case ISD::EXTRACT_ELEMENT: Res = ExpandOp_EXTRACT_ELEMENT(N); break;
+
+ case ISD::STORE:
+ Res = ExpandFloatOp_STORE(cast<StoreSDNode>(N), OpNo);
+ break;
}
}
@@ -462,3 +500,27 @@ bool DAGTypeLegalizer::ExpandFloatOperand(SDNode *N, unsigned OpNo) {
ReplaceValueWith(SDOperand(N, 0), Res);
return false;
}
+
+SDOperand DAGTypeLegalizer::ExpandFloatOp_STORE(SDNode *N, unsigned OpNo) {
+ if (ISD::isNON_TRUNCStore(N))
+ return ExpandOp_NON_TRUNCStore(N, OpNo);
+
+ assert(ISD::isUNINDEXEDStore(N) && "Indexed store during type legalization!");
+ assert(OpNo == 1 && "Can only expand the stored value so far");
+ StoreSDNode *ST = cast<StoreSDNode>(N);
+
+ SDOperand Chain = ST->getChain();
+ SDOperand Ptr = ST->getBasePtr();
+
+ MVT NVT = TLI.getTypeToTransformTo(ST->getValue().getValueType());
+ assert(NVT.isByteSized() && "Expanded type not byte sized!");
+ assert(ST->getMemoryVT().bitsLE(NVT) && "Float type not round?");
+
+ SDOperand Lo, Hi;
+ GetExpandedOp(ST->getValue(), Lo, Hi);
+
+ return DAG.getTruncStore(Chain, Lo, Ptr,
+ ST->getSrcValue(), ST->getSrcValueOffset(),
+ ST->getMemoryVT(),
+ ST->isVolatile(), ST->getAlignment());
+}
diff --git a/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp b/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
index 90b800e..eea97ef 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
@@ -1875,7 +1875,7 @@ SDOperand DAGTypeLegalizer::ExpandIntOp_STORE(StoreSDNode *N, unsigned OpNo) {
bool isVolatile = N->isVolatile();
SDOperand Lo, Hi;
- assert(!(NVT.getSizeInBits() & 7) && "Expanded type not byte sized!");
+ assert(NVT.isByteSized() && "Expanded type not byte sized!");
if (N->getMemoryVT().bitsLE(NVT)) {
GetExpandedInteger(N->getValue(), Lo, Hi);
diff --git a/lib/CodeGen/SelectionDAG/LegalizeTypes.h b/lib/CodeGen/SelectionDAG/LegalizeTypes.h
index 677aef4..b7ca990 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeTypes.h
+++ b/lib/CodeGen/SelectionDAG/LegalizeTypes.h
@@ -347,9 +347,11 @@ private:
// Float Result Expansion.
void ExpandFloatResult(SDNode *N, unsigned ResNo);
+ void ExpandFloatRes_LOAD(SDNode *N, SDOperand &Lo, SDOperand &Hi);
// Float Operand Expansion.
bool ExpandFloatOperand(SDNode *N, unsigned OperandNo);
+ SDOperand ExpandFloatOp_STORE(SDNode *N, unsigned OpNo);
//===--------------------------------------------------------------------===//
// Scalarization Support: LegalizeVectorTypes.cpp
diff --git a/test/CodeGen/PowerPC/2008-06-21-F128LoadStore.ll b/test/CodeGen/PowerPC/2008-06-21-F128LoadStore.ll
new file mode 100644
index 0000000..92b5ca2
--- /dev/null
+++ b/test/CodeGen/PowerPC/2008-06-21-F128LoadStore.ll
@@ -0,0 +1,10 @@
+; RUN: llvm-as < %s | llc -march=ppc32
+
+@g = external global ppc_fp128
+@h = external global ppc_fp128
+
+define void @f() {
+ %tmp = load ppc_fp128* @g
+ store ppc_fp128 %tmp, ppc_fp128* @h
+ ret void
+}