From 0c09a411e0c763d69aaefa2321c2ae8daabc80e4 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 18 Aug 2005 17:16:52 +0000 Subject: [PATCH] replace switch stmt with an assert, generate li 0 instead of lis 0 for 0, to make the code follow people's expectations better. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22861 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/PowerPC/PPCISelPattern.cpp | 33 ++++++++++++--------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/lib/Target/PowerPC/PPCISelPattern.cpp b/lib/Target/PowerPC/PPCISelPattern.cpp index 2f09a639593..6eddcc48f1e 100644 --- a/lib/Target/PowerPC/PPCISelPattern.cpp +++ b/lib/Target/PowerPC/PPCISelPattern.cpp @@ -1732,26 +1732,23 @@ unsigned ISel::SelectExpr(SDOperand N, bool Recording) { return Result; } - case ISD::Constant: - switch (N.getValueType()) { - default: assert(0 && "Cannot use constants of this type!"); - case MVT::i32: - { - int v = (int)cast(N)->getSignExtended(); - unsigned Hi = Hi16(v); - unsigned Lo = Lo16(v); - if (Hi && Lo) { - Tmp1 = MakeIntReg(); - BuildMI(BB, PPC::LIS, 1, Tmp1).addSImm(Hi); - BuildMI(BB, PPC::ORI, 2, Result).addReg(Tmp1).addImm(Lo); - } else if (Lo) { - BuildMI(BB, PPC::LI, 1, Result).addSImm(Lo); - } else { - BuildMI(BB, PPC::LIS, 1, Result).addSImm(Hi); - } - } + case ISD::Constant: { + assert(N.getValueType() == MVT::i32 && + "Only i32 constants are legal on this target!"); + int v = (int)cast(N)->getValue(); + unsigned Hi = Hi16(v); + unsigned Lo = Lo16(v); + if (Hi && Lo) { + Tmp1 = MakeIntReg(); + BuildMI(BB, PPC::LIS, 1, Tmp1).addSImm(Hi); + BuildMI(BB, PPC::ORI, 2, Result).addReg(Tmp1).addImm(Lo); + } else if (Hi) { + BuildMI(BB, PPC::LIS, 1, Result).addSImm(Hi); + } else { + BuildMI(BB, PPC::LI, 1, Result).addSImm(Lo); } return Result; + } case ISD::ConstantFP: { ConstantFPSDNode *CN = cast(N);