diff options
author | Duraid Madina <duraid@octopus.com.au> | 2005-11-07 03:11:02 +0000 |
---|---|---|
committer | Duraid Madina <duraid@octopus.com.au> | 2005-11-07 03:11:02 +0000 |
commit | d525df3c27d8631c5d46b063e4984d6404875f14 (patch) | |
tree | fffecde22947a83a99a53cfca38424fca92ee422 /lib/Target/IA64/IA64ISelDAGToDAG.cpp | |
parent | cbef8ba5f959b3c4f932005ceef5cf2e0d899f9b (diff) | |
download | external_llvm-d525df3c27d8631c5d46b063e4984d6404875f14.zip external_llvm-d525df3c27d8631c5d46b063e4984d6404875f14.tar.gz external_llvm-d525df3c27d8631c5d46b063e4984d6404875f14.tar.bz2 |
add support for storing and returning bools
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24228 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/IA64/IA64ISelDAGToDAG.cpp')
-rw-r--r-- | lib/Target/IA64/IA64ISelDAGToDAG.cpp | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/lib/Target/IA64/IA64ISelDAGToDAG.cpp b/lib/Target/IA64/IA64ISelDAGToDAG.cpp index 0b228c1..cc136b6 100644 --- a/lib/Target/IA64/IA64ISelDAGToDAG.cpp +++ b/lib/Target/IA64/IA64ISelDAGToDAG.cpp @@ -301,6 +301,16 @@ SDOperand IA64DAGToDAGISel::SelectCALL(SDOperand Op) { switch (N->getValueType(0)) { default: assert(0 && "Unexpected ret value!"); case MVT::Other: break; + case MVT::i1: { + // bools are returned as bytes 0/1 in r8 + SDOperand byteval = CurDAG->getCopyFromReg(Chain, IA64::r8, MVT::i64, + Chain.getValue(1)); + Chain = byteval.getValue(1); + Chain = CurDAG->getTargetNode(IA64::CMPNE, MVT::i1, MVT::Other, + byteval, CurDAG->getRegister(IA64::r0, MVT::i64)).getValue(1); + CallResults.push_back(Chain.getValue(0)); + break; + } case MVT::i64: Chain = CurDAG->getCopyFromReg(Chain, IA64::r8, MVT::i64, Chain.getValue(1)).getValue(1); @@ -422,17 +432,28 @@ SDOperand IA64DAGToDAGISel::Select(SDOperand Op) { case ISD::TRUNCSTORE: case ISD::STORE: { SDOperand Address = Select(N->getOperand(2)); - + SDOperand Chain = Select(N->getOperand(0)); + unsigned Opc; if (N->getOpcode() == ISD::STORE) { switch (N->getOperand(1).getValueType()) { - default: assert(0 && "unknown Type in store"); + default: assert(0 && "unknown type in store"); + case MVT::i1: { // this is a bool + Opc = IA64::ST1; // we store either 0 or 1 as a byte + CurDAG->SelectNodeTo(N, Opc, MVT::Other, Address, + CurDAG->getTargetNode(IA64::PADDS, MVT::i64, + CurDAG->getRegister(IA64::r0, MVT::i64), + CurDAG->getConstant(1, MVT::i64), + Select(N->getOperand(1))), + Chain); + return SDOperand(N, 0); // XXX: early exit + } case MVT::i64: Opc = IA64::ST8; break; case MVT::f64: Opc = IA64::STF8; break; - } + } } else { //ISD::TRUNCSTORE switch(cast<VTSDNode>(N->getOperand(4))->getVT()) { - default: assert(0 && "unknown Type in store"); + default: assert(0 && "unknown type in truncstore"); case MVT::i8: Opc = IA64::ST1; break; case MVT::i16: Opc = IA64::ST2; break; case MVT::i32: Opc = IA64::ST4; break; @@ -441,7 +462,7 @@ SDOperand IA64DAGToDAGISel::Select(SDOperand Op) { } CurDAG->SelectNodeTo(N, Opc, MVT::Other, Select(N->getOperand(2)), - Select(N->getOperand(1)), Select(N->getOperand(0))); + Select(N->getOperand(1)), Chain); return SDOperand(N, 0); } |