diff options
| author | Nate Begeman <natebegeman@mac.com> | 2005-03-29 22:24:51 +0000 |
|---|---|---|
| committer | Nate Begeman <natebegeman@mac.com> | 2005-03-29 22:24:51 +0000 |
| commit | 28145edd30ae5fe5bd82b126cfa739b6146628a5 (patch) | |
| tree | c4075d9384ebb5e7cfa4169ece865d74ed7de762 /llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp | |
| parent | 28c5ac9ff4198d40d1184687ff89bbf7bf5e5d8b (diff) | |
| download | bcm5719-llvm-28145edd30ae5fe5bd82b126cfa739b6146628a5.tar.gz bcm5719-llvm-28145edd30ae5fe5bd82b126cfa739b6146628a5.zip | |
Implement integer select and i1 sign extend
llvm-svn: 20934
Diffstat (limited to 'llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp')
| -rw-r--r-- | llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp | 51 |
1 files changed, 49 insertions, 2 deletions
diff --git a/llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp b/llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp index f1b6020670d..c778021749b 100644 --- a/llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp +++ b/llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp @@ -853,6 +853,9 @@ unsigned ISel::SelectExpr(SDOperand N) { case MVT::i8: BuildMI(BB, PPC::EXTSB, 1, Result).addReg(Tmp1); break; + case MVT::i1: + BuildMI(BB, PPC::SUBFIC, 2, Result).addReg(Tmp1).addSImm(0); + break; } return Result; @@ -1097,8 +1100,52 @@ unsigned ISel::SelectExpr(SDOperand N) { assert(0 && "Is this legal?"); return 0; - case ISD::SELECT: - abort(); + case ISD::SELECT: { + Tmp1 = SelectExpr(N.getOperand(0)); //Cond + + // Create an iterator with which to insert the MBB for copying the false + // value and the MBB to hold the PHI instruction for this SetCC. + MachineBasicBlock *thisMBB = BB; + const BasicBlock *LLVM_BB = BB->getBasicBlock(); + ilist<MachineBasicBlock>::iterator It = BB; + ++It; + + // thisMBB: + // ... + // TrueVal = ... + // cmpTY cr0, r1, r2 + // bCC copy1MBB + // fallthrough --> copy0MBB + BuildMI(BB, PPC::CMPLWI, 2, PPC::CR0).addReg(Tmp1).addImm(0); + MachineBasicBlock *copy0MBB = new MachineBasicBlock(LLVM_BB); + MachineBasicBlock *sinkMBB = new MachineBasicBlock(LLVM_BB); + unsigned TrueValue = SelectExpr(N.getOperand(1)); //Use if TRUE + BuildMI(BB, PPC::BNE, 2).addReg(PPC::CR0).addMBB(sinkMBB); + MachineFunction *F = BB->getParent(); + F->getBasicBlockList().insert(It, copy0MBB); + F->getBasicBlockList().insert(It, sinkMBB); + // Update machine-CFG edges + BB->addSuccessor(copy0MBB); + BB->addSuccessor(sinkMBB); + + // copy0MBB: + // %FalseValue = ... + // # fallthrough to sinkMBB + BB = copy0MBB; + unsigned FalseValue = SelectExpr(N.getOperand(2)); //Use if FALSE + // Update machine-CFG edges + BB->addSuccessor(sinkMBB); + + // sinkMBB: + // %Result = phi [ %FalseValue, copy0MBB ], [ %TrueValue, thisMBB ] + // ... + BB = sinkMBB; + BuildMI(BB, PPC::PHI, 4, Result).addReg(FalseValue) + .addMBB(copy0MBB).addReg(TrueValue).addMBB(thisMBB); + + // FIXME: Select i64? + return Result; + } case ISD::Constant: switch (N.getValueType()) { |

