From: Duraid Madina Date: Mon, 2 May 2005 06:41:13 +0000 (+0000) Subject: add support for bools to SELECT, this fixes Prolangs-C/bison from the X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=4bd708d8a6d846e5e917b7f660055b578ba0e093;p=oota-llvm.git add support for bools to SELECT, this fixes Prolangs-C/bison from the testsuite, however 09-vor is still dead (hopefully for other reasons!) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21651 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/IA64/IA64ISelPattern.cpp b/lib/Target/IA64/IA64ISelPattern.cpp index 1fe9026ed0f..5ac5df5c93a 100644 --- a/lib/Target/IA64/IA64ISelPattern.cpp +++ b/lib/Target/IA64/IA64ISelPattern.cpp @@ -1054,19 +1054,48 @@ unsigned ISel::SelectExpr(SDOperand N) { switch (N.getOperand(1).getValueType()) { default: assert(0 && - "ISD::SELECT: 'select'ing something other than i64 or f64!\n"); + "ISD::SELECT: 'select'ing something other than i1, i64 or f64!\n"); + // for i1, we load the condition into an integer register, then + // conditionally copy Tmp2 and Tmp3 to Tmp1 in parallel (only one + // of them will go through, since the integer register will hold + // either 0 or 1) + case MVT::i1: { + bogoResult=MakeReg(MVT::i1); + + // load the condition into an integer register + unsigned condReg=MakeReg(MVT::i64); + unsigned dummy=MakeReg(MVT::i64); + BuildMI(BB, IA64::MOV, 1, dummy).addReg(IA64::r0); + BuildMI(BB, IA64::TPCADDIMM22, 2, condReg).addReg(dummy) + .addImm(1).addReg(Tmp1); + + // initialize Result (bool) to false (hence UNC) and if + // the select condition (condReg) is false (0), copy Tmp3 + BuildMI(BB, IA64::PCMPEQUNC, 3, bogoResult) + .addReg(condReg).addReg(IA64::r0).addReg(Tmp3); + + // now, if the selection condition is true, write 1 to the + // result if Tmp2 is 1 + BuildMI(BB, IA64::TPCMPNE, 3, Result).addReg(bogoResult) + .addReg(condReg).addReg(IA64::r0).addReg(Tmp2); + break; + } + // for i64/f64, we just copy Tmp3 and then conditionally overwrite it + // with Tmp2 if Tmp1 is true case MVT::i64: bogoResult=MakeReg(MVT::i64); + BuildMI(BB, IA64::MOV, 1, bogoResult).addReg(Tmp3); + BuildMI(BB, IA64::CMOV, 2, Result).addReg(bogoResult).addReg(Tmp2) + .addReg(Tmp1); break; case MVT::f64: bogoResult=MakeReg(MVT::f64); + BuildMI(BB, IA64::FMOV, 1, bogoResult).addReg(Tmp3); + BuildMI(BB, IA64::CFMOV, 2, Result).addReg(bogoResult).addReg(Tmp2) + .addReg(Tmp1); break; } - - BuildMI(BB, IA64::MOV, 1, bogoResult).addReg(Tmp3); - BuildMI(BB, IA64::CMOV, 2, Result).addReg(bogoResult).addReg(Tmp2) - .addReg(Tmp1); // FIXME: should be FMOV/FCMOV sometimes, - // though this will work for now (no JIT) + return Result; }