[llvm-commits] CVS: llvm-test/SingleSource/UnitTests/Vector/divides.c
Changes in directory llvm-test/SingleSource/UnitTests/Vector: divides.c added (r1.1) --- Log message: Add a new test case for testing vector divides, both signed and unsigned. --- Diffs of the changes: (+33 -0) divides.c | 33 + 1 files changed, 33 insertions(+) Index: llvm-test/SingleSource/UnitTests/Vector/divides.c diff -c /dev/null llvm-test/SingleSource/UnitTests/Vector/divides.c:1.1 *** /dev/null Thu Oct 26 00:59:35 2006 --- llvm-test/SingleSource/UnitTests/Vector/divides.c Thu Oct 26 00:59:25 2006 *** *** 0 --- 1,33 + #include stdio.h + typedef unsigned uvec __attribute__ ((__vector_size__ (16))); + typedef int svec __attribute__ ((__vector_size__ (16))); + void testuvec(uvec *A, uvec *B, uvec *R) { *R = *A / *B; } + void testsvec(svec *A, svec *B, svec *R) { *R = *A / *B; } + + typedef union { + svec V; + int A[4]; + } SV; + + typedef union { + uvec V; + unsigned A[4]; + } UV; + + int main(int argc, char**argv) { + SV S1, S2, S3; + UV U1, U2, U3; + S1.A[0] = S2.A[0] = 2; + S1.A[1] = S2.A[1] = -3; + S1.A[2] = S2.A[2] = 5; + S1.A[3] = S2.A[3] = -8; + U1.A[0] = U2.A[0] = 2; + U1.A[1] = U2.A[1] = 3; + U1.A[2] = U2.A[2] = 5; + U1.A[3] = U2.A[3] = 8; + testuvec(U1.V, U2.V, U3.V); + testsvec(S1.V, S2.V, S3.V); + + printf(U3.V = %u %u %u %u\n, U3.A[0], U3.A[1], U3.A[2], U3.A[3]); + printf(S3.V = %u %u %u %u\n, S3.A[0], S3.A[1], S3.A[2], S3.A[3]); + } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm-gcc] FINAL DIV-[SUF]Div Changes
All, Attached is the final patch for llvm-gcc4 to make it work with the DIV instruction changes that I just committed to LLVM. You'll need to apply this patch to your llvm-gcc4 if you update LLVM before the patch is applied to the subversion repository. It should be done in 24 hours. Thanks, Reid. Index: gcc/llvm-convert.cpp === --- gcc/llvm-convert.cpp (revision 187) +++ gcc/llvm-convert.cpp (working copy) @@ -544,9 +544,18 @@ case PLUS_EXPR: Result = EmitBinOp(exp, DestLoc, Instruction::Add);break; case MINUS_EXPR: Result = EmitBinOp(exp, DestLoc, Instruction::Sub);break; case MULT_EXPR: Result = EmitBinOp(exp, DestLoc, Instruction::Mul);break; - case TRUNC_DIV_EXPR: Result = EmitBinOp(exp, DestLoc, Instruction::Div);break; - case EXACT_DIV_EXPR: Result = EmitBinOp(exp, DestLoc, Instruction::Div);break; - case RDIV_EXPR: Result = EmitBinOp(exp, DestLoc, Instruction::Div);break; + case TRUNC_DIV_EXPR: +if (TYPE_UNSIGNED(TREE_TYPE(exp))) + Result = EmitBinOp(exp, DestLoc, Instruction::UDiv); +else + Result = EmitBinOp(exp, DestLoc, Instruction::SDiv); +break; + case EXACT_DIV_EXPR: +Result = EmitBinOp(exp, DestLoc, Instruction::UDiv); +break; + case RDIV_EXPR: +Result = EmitBinOp(exp, DestLoc, Instruction::FDiv); +break; case TRUNC_MOD_EXPR: Result = EmitBinOp(exp, DestLoc, Instruction::Rem);break; case BIT_AND_EXPR: Result = EmitBinOp(exp, DestLoc, Instruction::And);break; case BIT_IOR_EXPR: Result = EmitBinOp(exp, DestLoc, Instruction::Or );break; @@ -2263,6 +2272,7 @@ // everything to the result type. LHS = NOOPCastToType(LHS, Ty); RHS = NOOPCastToType(RHS, Ty); + return BinaryOperator::create((Instruction::BinaryOps)Opc, LHS, RHS, tmp, CurBB); } @@ -3584,12 +3594,12 @@ Value *Tmp4 = BinaryOperator::createMul(RHSr, RHSr, tmp, CurBB); // c*c Value *Tmp5 = BinaryOperator::createMul(RHSi, RHSi, tmp, CurBB); // d*d Value *Tmp6 = BinaryOperator::createAdd(Tmp4, Tmp5, tmp, CurBB); // cc+dd -DSTr = BinaryOperator::createDiv(Tmp3, Tmp6, tmp, CurBB); +DSTr = BinaryOperator::createFDiv(Tmp3, Tmp6, tmp, CurBB); Value *Tmp7 = BinaryOperator::createMul(LHSi, RHSr, tmp, CurBB); // b*c Value *Tmp8 = BinaryOperator::createMul(LHSr, RHSi, tmp, CurBB); // a*d Value *Tmp9 = BinaryOperator::createSub(Tmp7, Tmp8, tmp, CurBB); // bc-ad -DSTi = BinaryOperator::createDiv(Tmp9, Tmp6, tmp, CurBB); +DSTi = BinaryOperator::createFDiv(Tmp9, Tmp6, tmp, CurBB); break; } case EQ_EXPR: // (a+ib) == (c+id) = (a == c) (b == d) Index: gcc/config/i386/i386.h === --- gcc/config/i386/i386.h (revision 187) +++ gcc/config/i386/i386.h (working copy) @@ -4195,7 +4195,7 @@ } \ case IX86_BUILTIN_DIVPS:\ case IX86_BUILTIN_DIVPD:\ -RESULT = BinaryOperator::createDiv(OPS[0], OPS[1], tmp, CURBB); \ +RESULT = BinaryOperator::createFDiv(OPS[0], OPS[1], tmp, CURBB); \ return true; \ case IX86_BUILTIN_PAND128: \ RESULT = BinaryOperator::createAnd(OPS[0], OPS[1], tmp, CURBB); \ ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Analysis/ScalarEvolution.cpp
Changes in directory llvm/lib/Analysis: ScalarEvolution.cpp updated: 1.54 - 1.55 --- Log message: For PR950: http://llvm.org/PR950 : Make necessary changes to support DIV - [SUF]Div. This changes llvm to have three division instructions: signed, unsigned, floating point. The bytecode and assembler are bacwards compatible, however. --- Diffs of the changes: (+14 -15) ScalarEvolution.cpp | 29 ++--- 1 files changed, 14 insertions(+), 15 deletions(-) Index: llvm/lib/Analysis/ScalarEvolution.cpp diff -u llvm/lib/Analysis/ScalarEvolution.cpp:1.54 llvm/lib/Analysis/ScalarEvolution.cpp:1.55 --- llvm/lib/Analysis/ScalarEvolution.cpp:1.54 Fri Oct 20 02:07:24 2006 +++ llvm/lib/Analysis/ScalarEvolution.cpp Thu Oct 26 01:15:43 2006 @@ -989,9 +989,9 @@ SCEVHandle SCEVSDivExpr::get(const SCEVHandle LHS, const SCEVHandle RHS) { if (SCEVConstant *RHSC = dyn_castSCEVConstant(RHS)) { if (RHSC-getValue()-equalsInt(1)) - return LHS;// X /s 1 -- x + return LHS;// X sdiv 1 -- x if (RHSC-getValue()-isAllOnesValue()) - return SCEV::getNegativeSCEV(LHS); // X /s -1 -- -x + return SCEV::getNegativeSCEV(LHS); // X sdiv -1 -- -x if (SCEVConstant *LHSC = dyn_castSCEVConstant(LHS)) { Constant *LHSCV = LHSC-getValue(); @@ -1001,7 +1001,7 @@ LHSCV-getType()-getSignedVersion()); if (RHSCV-getType()-isUnsigned()) RHSCV = ConstantExpr::getCast(RHSCV, LHSCV-getType()); - return SCEVUnknown::get(ConstantExpr::getDiv(LHSCV, RHSCV)); + return SCEVUnknown::get(ConstantExpr::getSDiv(LHSCV, RHSCV)); } } @@ -1384,10 +1384,9 @@ case Instruction::Mul: return SCEVMulExpr::get(getSCEV(I-getOperand(0)), getSCEV(I-getOperand(1))); -case Instruction::Div: - if (V-getType()-isInteger() V-getType()-isSigned()) -return SCEVSDivExpr::get(getSCEV(I-getOperand(0)), - getSCEV(I-getOperand(1))); +case Instruction::SDiv: + return SCEVSDivExpr::get(getSCEV(I-getOperand(0)), + getSCEV(I-getOperand(1))); break; case Instruction::Sub: @@ -2058,16 +2057,16 @@ return std::make_pair(CNC, CNC); } - Constant *Two = ConstantInt::get(L-getValue()-getType(), 2); + Constant *C = L-getValue(); + Constant *Two = ConstantInt::get(C-getType(), 2); // Convert from chrec coefficients to polynomial coefficients AX^2+BX+C - Constant *C = L-getValue(); // The B coefficient is M-N/2 Constant *B = ConstantExpr::getSub(M-getValue(), - ConstantExpr::getDiv(N-getValue(), + ConstantExpr::getSDiv(N-getValue(), Two)); // The A coefficient is N/2 - Constant *A = ConstantExpr::getDiv(N-getValue(), Two); + Constant *A = ConstantExpr::getSDiv(N-getValue(), Two); // Compute the B^2-4ac term. Constant *SqrtTerm = @@ -2102,9 +2101,9 @@ SqrtTerm = ConstantExpr::getCast(SqrtTerm, SignedTy); Constant *Solution1 = -ConstantExpr::getDiv(ConstantExpr::getAdd(NegB, SqrtTerm), TwoA); +ConstantExpr::getSDiv(ConstantExpr::getAdd(NegB, SqrtTerm), TwoA); Constant *Solution2 = -ConstantExpr::getDiv(ConstantExpr::getSub(NegB, SqrtTerm), TwoA); +ConstantExpr::getSDiv(ConstantExpr::getSub(NegB, SqrtTerm), TwoA); return std::make_pair(SCEVUnknown::get(Solution1), SCEVUnknown::get(Solution2)); } @@ -2150,7 +2149,7 @@ Constant *StartNegC = ConstantExpr::getNeg(StartCC); Constant *Rem = ConstantExpr::getRem(StartNegC, StepC-getValue()); if (Rem-isNullValue()) { - Constant *Result =ConstantExpr::getDiv(StartNegC,StepC-getValue()); + Constant *Result =ConstantExpr::getSDiv(StartNegC,StepC-getValue()); return SCEVUnknown::get(Result); } } @@ -2352,7 +2351,7 @@ Constant *ExitValue = Upper; if (A != One) { ExitValue = ConstantExpr::getSub(ConstantExpr::getAdd(Upper, A), One); - ExitValue = ConstantExpr::getDiv(ExitValue, A); + ExitValue = ConstantExpr::getSDiv(ExitValue, A); } assert(isaConstantInt(ExitValue) Constant folding of integers not implemented?); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/Constants.h Instruction.def
Changes in directory llvm/include/llvm: Constants.h updated: 1.90 - 1.91 Instruction.def updated: 1.19 - 1.20 --- Log message: For PR950: http://llvm.org/PR950 : Make necessary changes to support DIV - [SUF]Div. This changes llvm to have three division instructions: signed, unsigned, floating point. The bytecode and assembler are bacwards compatible, however. --- Diffs of the changes: (+31 -31) Constants.h |4 ++- Instruction.def | 58 +++- 2 files changed, 31 insertions(+), 31 deletions(-) Index: llvm/include/llvm/Constants.h diff -u llvm/include/llvm/Constants.h:1.90 llvm/include/llvm/Constants.h:1.91 --- llvm/include/llvm/Constants.h:1.90 Fri Oct 20 02:24:55 2006 +++ llvm/include/llvm/Constants.h Thu Oct 26 01:15:43 2006 @@ -543,7 +543,9 @@ static Constant *getAdd(Constant *C1, Constant *C2); static Constant *getSub(Constant *C1, Constant *C2); static Constant *getMul(Constant *C1, Constant *C2); - static Constant *getDiv(Constant *C1, Constant *C2); + static Constant *getUDiv(Constant *C1, Constant *C2); + static Constant *getSDiv(Constant *C1, Constant *C2); + static Constant *getFDiv(Constant *C1, Constant *C2); static Constant *getRem(Constant *C1, Constant *C2); static Constant *getAnd(Constant *C1, Constant *C2); static Constant *getOr(Constant *C1, Constant *C2); Index: llvm/include/llvm/Instruction.def diff -u llvm/include/llvm/Instruction.def:1.19 llvm/include/llvm/Instruction.def:1.20 --- llvm/include/llvm/Instruction.def:1.19 Fri Apr 7 20:15:18 2006 +++ llvm/include/llvm/Instruction.def Thu Oct 26 01:15:43 2006 @@ -93,45 +93,43 @@ HANDLE_BINARY_INST( 7, Add , BinaryOperator) HANDLE_BINARY_INST( 8, Sub , BinaryOperator) HANDLE_BINARY_INST( 9, Mul , BinaryOperator) -HANDLE_BINARY_INST(10, Div , BinaryOperator) -HANDLE_BINARY_INST(11, Rem , BinaryOperator) +HANDLE_BINARY_INST(10, UDiv , BinaryOperator) +HANDLE_BINARY_INST(11, SDiv , BinaryOperator) +HANDLE_BINARY_INST(12, FDiv , BinaryOperator) +HANDLE_BINARY_INST(13, Rem , BinaryOperator) // Logical operators... -HANDLE_BINARY_INST(12, And , BinaryOperator) -HANDLE_BINARY_INST(13, Or, BinaryOperator) -HANDLE_BINARY_INST(14, Xor , BinaryOperator) +HANDLE_BINARY_INST(14, And , BinaryOperator) +HANDLE_BINARY_INST(15, Or, BinaryOperator) +HANDLE_BINARY_INST(16, Xor , BinaryOperator) // Binary comparison operators... -HANDLE_BINARY_INST(15, SetEQ , SetCondInst) -HANDLE_BINARY_INST(16, SetNE , SetCondInst) -HANDLE_BINARY_INST(17, SetLE , SetCondInst) -HANDLE_BINARY_INST(18, SetGE , SetCondInst) -HANDLE_BINARY_INST(19, SetLT , SetCondInst) -HANDLE_BINARY_INST(20, SetGT , SetCondInst) - LAST_BINARY_INST(20) +HANDLE_BINARY_INST(17, SetEQ , SetCondInst) +HANDLE_BINARY_INST(18, SetNE , SetCondInst) +HANDLE_BINARY_INST(19, SetLE , SetCondInst) +HANDLE_BINARY_INST(20, SetGE , SetCondInst) +HANDLE_BINARY_INST(21, SetLT , SetCondInst) +HANDLE_BINARY_INST(22, SetGT , SetCondInst) + LAST_BINARY_INST(22) // Memory operators... - FIRST_MEMORY_INST(21) -HANDLE_MEMORY_INST(21, Malloc, MallocInst) // Heap management instructions -HANDLE_MEMORY_INST(22, Free , FreeInst ) -HANDLE_MEMORY_INST(23, Alloca, AllocaInst) // Stack management -HANDLE_MEMORY_INST(24, Load , LoadInst ) // Memory manipulation instrs -HANDLE_MEMORY_INST(25, Store , StoreInst ) -HANDLE_MEMORY_INST(26, GetElementPtr, GetElementPtrInst) - LAST_MEMORY_INST(26) + FIRST_MEMORY_INST(23) +HANDLE_MEMORY_INST(23, Malloc, MallocInst) // Heap management instructions +HANDLE_MEMORY_INST(24, Free , FreeInst ) +HANDLE_MEMORY_INST(25, Alloca, AllocaInst) // Stack management +HANDLE_MEMORY_INST(26, Load , LoadInst ) // Memory manipulation instrs +HANDLE_MEMORY_INST(27, Store , StoreInst ) +HANDLE_MEMORY_INST(28, GetElementPtr, GetElementPtrInst) + LAST_MEMORY_INST(28) // Other operators... - FIRST_OTHER_INST(27) -HANDLE_OTHER_INST(27, PHI, PHINode) // PHI node instruction -HANDLE_OTHER_INST(28, Cast , CastInst ) // Type cast -HANDLE_OTHER_INST(29, Call , CallInst ) // Call a function - -HANDLE_OTHER_INST(30, Shl, ShiftInst ) // Shift operations -HANDLE_OTHER_INST(31, Shr, ShiftInst ) -// 32 - Empty slot used to be used for vanext in llvm 1.5 and before. -// 33 - Empty slot used to be used for vaarg in llvm 1.5 and before. + FIRST_OTHER_INST(29) +HANDLE_OTHER_INST(29, PHI, PHINode) // PHI node instruction +HANDLE_OTHER_INST(30, Cast , CastInst ) // Type cast +HANDLE_OTHER_INST(31, Call , CallInst ) // Call a function +HANDLE_OTHER_INST(32, Shl, ShiftInst ) // Shift operations +HANDLE_OTHER_INST(33, Shr, ShiftInst ) HANDLE_OTHER_INST(34, Select , SelectInst ) // select instruction - HANDLE_OTHER_INST(35, UserOp1, Instruction) // May be used internally in a pass HANDLE_OTHER_INST(36, UserOp2, Instruction) HANDLE_OTHER_INST(37, VAArg , VAArgInst ) // vaarg instruction
[llvm-commits] CVS: llvm/lib/VMCore/ConstantFolding.cpp Constants.cpp Instruction.cpp Instructions.cpp
Changes in directory llvm/lib/VMCore: ConstantFolding.cpp updated: 1.94 - 1.95 Constants.cpp updated: 1.165 - 1.166 Instruction.cpp updated: 1.53 - 1.54 Instructions.cpp updated: 1.43 - 1.44 --- Log message: For PR950: http://llvm.org/PR950 : Make necessary changes to support DIV - [SUF]Div. This changes llvm to have three division instructions: signed, unsigned, floating point. The bytecode and assembler are bacwards compatible, however. --- Diffs of the changes: (+105 -33) ConstantFolding.cpp | 82 +++- Constants.cpp | 30 --- Instruction.cpp |8 +++-- Instructions.cpp| 18 ++- 4 files changed, 105 insertions(+), 33 deletions(-) Index: llvm/lib/VMCore/ConstantFolding.cpp diff -u llvm/lib/VMCore/ConstantFolding.cpp:1.94 llvm/lib/VMCore/ConstantFolding.cpp:1.95 --- llvm/lib/VMCore/ConstantFolding.cpp:1.94Fri Oct 20 02:07:24 2006 +++ llvm/lib/VMCore/ConstantFolding.cpp Thu Oct 26 01:15:43 2006 @@ -40,7 +40,9 @@ virtual Constant *add(const Constant *V1, const Constant *V2) const = 0; virtual Constant *sub(const Constant *V1, const Constant *V2) const = 0; virtual Constant *mul(const Constant *V1, const Constant *V2) const = 0; -virtual Constant *div(const Constant *V1, const Constant *V2) const = 0; +virtual Constant *udiv(const Constant *V1, const Constant *V2) const = 0; +virtual Constant *sdiv(const Constant *V1, const Constant *V2) const = 0; +virtual Constant *fdiv(const Constant *V1, const Constant *V2) const = 0; virtual Constant *rem(const Constant *V1, const Constant *V2) const = 0; virtual Constant *op_and(const Constant *V1, const Constant *V2) const = 0; virtual Constant *op_or (const Constant *V1, const Constant *V2) const = 0; @@ -106,8 +108,14 @@ virtual Constant *mul(const Constant *V1, const Constant *V2) const { return SubClassName::Mul((const ArgType *)V1, (const ArgType *)V2); } - virtual Constant *div(const Constant *V1, const Constant *V2) const { -return SubClassName::Div((const ArgType *)V1, (const ArgType *)V2); + virtual Constant *udiv(const Constant *V1, const Constant *V2) const { +return SubClassName::UDiv((const ArgType *)V1, (const ArgType *)V2); + } + virtual Constant *sdiv(const Constant *V1, const Constant *V2) const { +return SubClassName::SDiv((const ArgType *)V1, (const ArgType *)V2); + } + virtual Constant *fdiv(const Constant *V1, const Constant *V2) const { +return SubClassName::FDiv((const ArgType *)V1, (const ArgType *)V2); } virtual Constant *rem(const Constant *V1, const Constant *V2) const { return SubClassName::Rem((const ArgType *)V1, (const ArgType *)V2); @@ -178,16 +186,18 @@ // Default noop implementations //======// - static Constant *Add(const ArgType *V1, const ArgType *V2) { return 0; } - static Constant *Sub(const ArgType *V1, const ArgType *V2) { return 0; } - static Constant *Mul(const ArgType *V1, const ArgType *V2) { return 0; } - static Constant *Div(const ArgType *V1, const ArgType *V2) { return 0; } - static Constant *Rem(const ArgType *V1, const ArgType *V2) { return 0; } - static Constant *And(const ArgType *V1, const ArgType *V2) { return 0; } - static Constant *Or (const ArgType *V1, const ArgType *V2) { return 0; } - static Constant *Xor(const ArgType *V1, const ArgType *V2) { return 0; } - static Constant *Shl(const ArgType *V1, const ArgType *V2) { return 0; } - static Constant *Shr(const ArgType *V1, const ArgType *V2) { return 0; } + static Constant *Add (const ArgType *V1, const ArgType *V2) { return 0; } + static Constant *Sub (const ArgType *V1, const ArgType *V2) { return 0; } + static Constant *Mul (const ArgType *V1, const ArgType *V2) { return 0; } + static Constant *SDiv(const ArgType *V1, const ArgType *V2) { return 0; } + static Constant *UDiv(const ArgType *V1, const ArgType *V2) { return 0; } + static Constant *FDiv(const ArgType *V1, const ArgType *V2) { return 0; } + static Constant *Rem (const ArgType *V1, const ArgType *V2) { return 0; } + static Constant *And (const ArgType *V1, const ArgType *V2) { return 0; } + static Constant *Or (const ArgType *V1, const ArgType *V2) { return 0; } + static Constant *Xor (const ArgType *V1, const ArgType *V2) { return 0; } + static Constant *Shl (const ArgType *V1, const ArgType *V2) { return 0; } + static Constant *Shr (const ArgType *V1, const ArgType *V2) { return 0; } static Constant *LessThan(const ArgType *V1, const ArgType *V2) { return 0; } @@ -373,8 +383,14 @@ static Constant *Mul(const ConstantPacked *V1, const ConstantPacked *V2) { return EvalVectorOp(V1, V2, ConstantExpr::getMul); } - static Constant *Div(const ConstantPacked *V1, const ConstantPacked *V2) { -return EvalVectorOp(V1, V2, ConstantExpr::getDiv); + static Constant *UDiv(const
[llvm-commits] CVS: llvm/lib/Target/CBackend/Writer.cpp
Changes in directory llvm/lib/Target/CBackend: Writer.cpp updated: 1.274 - 1.275 --- Log message: For PR950: http://llvm.org/PR950 : Make necessary changes to support DIV - [SUF]Div. This changes llvm to have three division instructions: signed, unsigned, floating point. The bytecode and assembler are bacwards compatible, however. --- Diffs of the changes: (+161 -7) Writer.cpp | 168 ++--- 1 files changed, 161 insertions(+), 7 deletions(-) Index: llvm/lib/Target/CBackend/Writer.cpp diff -u llvm/lib/Target/CBackend/Writer.cpp:1.274 llvm/lib/Target/CBackend/Writer.cpp:1.275 --- llvm/lib/Target/CBackend/Writer.cpp:1.274 Sun Oct 22 04:58:21 2006 +++ llvm/lib/Target/CBackend/Writer.cpp Thu Oct 26 01:15:43 2006 @@ -121,6 +121,8 @@ void writeOperand(Value *Operand); void writeOperandInternal(Value *Operand); +void writeOperandWithCast(Value* Operand, unsigned Opcode); +bool writeInstructionCast(const Instruction I); private : void lowerIntrinsics(Function F); @@ -136,6 +138,8 @@ void printLoop(Loop *L); void printConstant(Constant *CPV); +void printConstantWithCast(Constant *CPV, unsigned Opcode); +bool printConstExprCast(const ConstantExpr *CE); void printConstantArray(ConstantArray *CPA); void printConstantPacked(ConstantPacked *CP); @@ -586,7 +590,9 @@ case Instruction::Add: case Instruction::Sub: case Instruction::Mul: -case Instruction::Div: +case Instruction::SDiv: +case Instruction::UDiv: +case Instruction::FDiv: case Instruction::Rem: case Instruction::And: case Instruction::Or: @@ -600,12 +606,15 @@ case Instruction::Shl: case Instruction::Shr: Out '('; - printConstant(CE-getOperand(0)); + bool NeedsClosingParens = printConstExprCast(CE); + printConstantWithCast(CE-getOperand(0), CE-getOpcode()); switch (CE-getOpcode()) { case Instruction::Add: Out + ; break; case Instruction::Sub: Out - ; break; case Instruction::Mul: Out * ; break; - case Instruction::Div: Out / ; break; + case Instruction::UDiv: + case Instruction::SDiv: + case Instruction::FDiv: Out / ; break; case Instruction::Rem: Out % ; break; case Instruction::And: Out; break; case Instruction::Or: Out | ; break; @@ -620,7 +629,9 @@ case Instruction::Shr: Out; break; default: assert(0 Illegal opcode here!); } - printConstant(CE-getOperand(1)); + printConstantWithCast(CE-getOperand(1), CE-getOpcode()); + if (NeedsClosingParens) +Out )); Out ')'; return; @@ -805,6 +816,71 @@ } } +// Some constant expressions need to be casted back to the original types +// because their operands were casted to the expected type. This function takes +// care of detecting that case and printing the cast for the ConstantExpr. +bool CWriter::printConstExprCast(const ConstantExpr* CE) { + bool Result = false; + const Type* Ty = CE-getOperand(0)-getType(); + switch (CE-getOpcode()) { + case Instruction::UDiv: Result = Ty-isSigned(); break; + case Instruction::SDiv: Result = Ty-isUnsigned(); break; + default: break; + } + if (Result) { +Out ((; +printType(Out, Ty); +Out )(; + } + return Result; +} + +// Print a constant assuming that it is the operand for a given Opcode. The +// opcodes that care about sign need to cast their operands to the expected +// type before the operation proceeds. This function does the casting. +void CWriter::printConstantWithCast(Constant* CPV, unsigned Opcode) { + + // Extract the operand's type, we'll need it. + const Type* OpTy = CPV-getType(); + + // Indicate whether to do the cast or not. + bool shouldCast = false; + + // Based on the Opcode for which this Constant is being written, determine + // the new type to which the operand should be casted by setting the value + // of OpTy. If we change OpTy, also set shouldCast to true. + switch (Opcode) { +default: + // for most instructions, it doesn't matter + break; +case Instruction::UDiv: + // For UDiv to have unsigned operands + if (OpTy-isSigned()) { +OpTy = OpTy-getUnsignedVersion(); +shouldCast = true; + } + break; +case Instruction::SDiv: + if (OpTy-isUnsigned()) { +OpTy = OpTy-getSignedVersion(); +shouldCast = true; + } + break; + } + + // Write out the casted constnat if we should, otherwise just write the + // operand. + if (shouldCast) { +Out ((; +printType(Out, OpTy); +Out ); +printConstant(CPV); +Out ); + } else +writeOperand(CPV); + +} + void CWriter::writeOperandInternal(Value *Operand) { if (Instruction *I = dyn_castInstruction(Operand)) if (isInlinableInst(*I) !isDirectAlloca(I)) { @@ -833,6 +909,72 @@ Out ')'; } +// Some
[llvm-commits] CVS: llvm/test/Regression/Transforms/InstCombine/div.ll
Changes in directory llvm/test/Regression/Transforms/InstCombine: div.ll updated: 1.12 - 1.13 --- Log message: For PR950: http://llvm.org/PR950 : Make necessary changes to support DIV - [SUF]Div. This changes llvm to have three division instructions: signed, unsigned, floating point. The bytecode and assembler are bacwards compatible, however. --- Diffs of the changes: (+5 -6) div.ll | 11 +-- 1 files changed, 5 insertions(+), 6 deletions(-) Index: llvm/test/Regression/Transforms/InstCombine/div.ll diff -u llvm/test/Regression/Transforms/InstCombine/div.ll:1.12 llvm/test/Regression/Transforms/InstCombine/div.ll:1.13 --- llvm/test/Regression/Transforms/InstCombine/div.ll:1.12 Sun Feb 5 01:52:47 2006 +++ llvm/test/Regression/Transforms/InstCombine/div.ll Thu Oct 26 01:15:43 2006 @@ -57,13 +57,12 @@ uint %test10(uint %X, bool %C) { %V = select bool %C, uint 64, uint 8 -%R = div uint %X, %V +%R = udiv uint %X, %V ret uint %R } -uint %test10(uint %X, ubyte %B) { - %Amt = shl uint 32, ubyte %B - %V = div uint %X, %Amt - ret uint %V +int %test11(int %X, bool %C) { +%A = select bool %C, int 1024, int 32 +%B = udiv int %X, %A +ret int %B } - ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Target/CBackend/Writer.cpp
Changes in directory llvm/lib/Target/CBackend: Writer.cpp updated: 1.275 - 1.276 --- Log message: Enclose a case in { and } so that the pickier compilers don't complain. --- Diffs of the changes: (+2 -0) Writer.cpp |2 ++ 1 files changed, 2 insertions(+) Index: llvm/lib/Target/CBackend/Writer.cpp diff -u llvm/lib/Target/CBackend/Writer.cpp:1.275 llvm/lib/Target/CBackend/Writer.cpp:1.276 --- llvm/lib/Target/CBackend/Writer.cpp:1.275 Thu Oct 26 01:15:43 2006 +++ llvm/lib/Target/CBackend/Writer.cpp Thu Oct 26 01:17:40 2006 @@ -605,6 +605,7 @@ case Instruction::SetGE: case Instruction::Shl: case Instruction::Shr: +{ Out '('; bool NeedsClosingParens = printConstExprCast(CE); printConstantWithCast(CE-getOperand(0), CE-getOpcode()); @@ -634,6 +635,7 @@ Out )); Out ')'; return; +} default: std::cerr CWriter Error: Unhandled constant expression: ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/projects/Stacker/lib/compiler/StackerCompiler.cpp
Changes in directory llvm/projects/Stacker/lib/compiler: StackerCompiler.cpp updated: 1.19 - 1.20 --- Log message: For PR950: http://llvm.org/PR950 : Make necessary changes to support DIV - [SUF]Div. This changes llvm to have three division instructions: signed, unsigned, floating point. The bytecode and assembler are bacwards compatible, however. --- Diffs of the changes: (+2 -2) StackerCompiler.cpp |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/projects/Stacker/lib/compiler/StackerCompiler.cpp diff -u llvm/projects/Stacker/lib/compiler/StackerCompiler.cpp:1.19 llvm/projects/Stacker/lib/compiler/StackerCompiler.cpp:1.20 --- llvm/projects/Stacker/lib/compiler/StackerCompiler.cpp:1.19 Fri Oct 20 02:07:24 2006 +++ llvm/projects/Stacker/lib/compiler/StackerCompiler.cpp Thu Oct 26 01:15:43 2006 @@ -1041,7 +1041,7 @@ LoadInst* op1 = castLoadInst(pop_integer(bb)); LoadInst* op2 = castLoadInst(pop_integer(bb)); BinaryOperator* divop = -BinaryOperator::create( Instruction::Div, op1, op2); +BinaryOperator::create( Instruction::SDiv, op1, op2); bb-getInstList().push_back( divop ); push_value( bb, divop ); break; @@ -1072,7 +1072,7 @@ // Divide by the third operand BinaryOperator* divop = -BinaryOperator::create( Instruction::Div, multop, op3); +BinaryOperator::create( Instruction::SDiv, multop, op3); bb-getInstList().push_back( divop ); // Push the result ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp
Changes in directory llvm/lib/Transforms/IPO: SimplifyLibCalls.cpp updated: 1.70 - 1.71 --- Log message: For PR950: http://llvm.org/PR950 : Make necessary changes to support DIV - [SUF]Div. This changes llvm to have three division instructions: signed, unsigned, floating point. The bytecode and assembler are bacwards compatible, however. --- Diffs of the changes: (+1 -1) SimplifyLibCalls.cpp |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp diff -u llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp:1.70 llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp:1.71 --- llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp:1.70 Fri Oct 20 02:07:24 2006 +++ llvm/lib/Transforms/IPO/SimplifyLibCalls.cppThu Oct 26 01:15:43 2006 @@ -1275,7 +1275,7 @@ return true; } else if (Op2V == -1.0) { // pow(x,-1.0)- 1.0/x -BinaryOperator* div_inst= BinaryOperator::createDiv( +BinaryOperator* div_inst= BinaryOperator::createFDiv( ConstantFP::get(Ty,1.0), base, ci-getName()+.pow, ci); ci-replaceAllUsesWith(div_inst); ci-eraseFromParent(); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
Changes in directory llvm/lib/CodeGen/SelectionDAG: SelectionDAGISel.cpp updated: 1.298 - 1.299 --- Log message: For PR950: http://llvm.org/PR950 : Make necessary changes to support DIV - [SUF]Div. This changes llvm to have three division instructions: signed, unsigned, floating point. The bytecode and assembler are bacwards compatible, however. --- Diffs of the changes: (+44 -24) SelectionDAGISel.cpp | 68 +-- 1 files changed, 44 insertions(+), 24 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.298 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.299 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.298Tue Oct 24 13:07:37 2006 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Thu Oct 26 01:15:43 2006 @@ -499,28 +499,35 @@ void visitInvoke(InvokeInst I) { assert(0 TODO); } void visitUnwind(UnwindInst I) { assert(0 TODO); } - void visitBinary(User I, unsigned IntOp, unsigned FPOp, unsigned VecOp); + void visitIntBinary(User I, unsigned IntOp, unsigned VecOp); + void visitFPBinary(User I, unsigned FPOp, unsigned VecOp); void visitShift(User I, unsigned Opcode); void visitAdd(User I) { -visitBinary(I, ISD::ADD, ISD::FADD, ISD::VADD); +if (I.getType()-isFloatingPoint()) + visitFPBinary(I, ISD::FADD, ISD::VADD); +else + visitIntBinary(I, ISD::ADD, ISD::VADD); } void visitSub(User I); - void visitMul(User I) { -visitBinary(I, ISD::MUL, ISD::FMUL, ISD::VMUL); - } - void visitDiv(User I) { -const Type *Ty = I.getType(); -visitBinary(I, -Ty-isSigned() ? ISD::SDIV : ISD::UDIV, ISD::FDIV, -Ty-isSigned() ? ISD::VSDIV : ISD::VUDIV); + void visitMul(User I) { +if (I.getType()-isFloatingPoint()) + visitFPBinary(I, ISD::FMUL, ISD::VMUL); +else + visitIntBinary(I, ISD::MUL, ISD::VMUL); } + void visitUDiv(User I) { visitIntBinary(I, ISD::UDIV, ISD::VUDIV); } + void visitSDiv(User I) { visitIntBinary(I, ISD::SDIV, ISD::VSDIV); } + void visitFDiv(User I) { visitFPBinary(I, ISD::FDIV, ISD::VSDIV); } void visitRem(User I) { const Type *Ty = I.getType(); -visitBinary(I, Ty-isSigned() ? ISD::SREM : ISD::UREM, ISD::FREM, 0); - } - void visitAnd(User I) { visitBinary(I, ISD::AND, 0, ISD::VAND); } - void visitOr (User I) { visitBinary(I, ISD::OR, 0, ISD::VOR); } - void visitXor(User I) { visitBinary(I, ISD::XOR, 0, ISD::VXOR); } +if (Ty-isFloatingPoint()) + visitFPBinary(I, ISD::FREM, 0); +else + visitIntBinary(I, Ty-isSigned() ? ISD::SREM : ISD::UREM, 0); + } + void visitAnd(User I) { visitIntBinary(I, ISD::AND, ISD::VAND); } + void visitOr (User I) { visitIntBinary(I, ISD::OR, ISD::VOR); } + void visitXor(User I) { visitIntBinary(I, ISD::XOR, ISD::VXOR); } void visitShl(User I) { visitShift(I, ISD::SHL); } void visitShr(User I) { visitShift(I, I.getType()-isUnsigned() ? ISD::SRL : ISD::SRA); @@ -1142,25 +1149,38 @@ setValue(I, DAG.getNode(ISD::FNEG, Op2.getValueType(), Op2)); return; } - } - visitBinary(I, ISD::SUB, ISD::FSUB, ISD::VSUB); +visitFPBinary(I, ISD::FSUB, ISD::VSUB); + } else +visitIntBinary(I, ISD::SUB, ISD::VSUB); } -void SelectionDAGLowering::visitBinary(User I, unsigned IntOp, unsigned FPOp, - unsigned VecOp) { +void +SelectionDAGLowering::visitIntBinary(User I, unsigned IntOp, unsigned VecOp) { const Type *Ty = I.getType(); SDOperand Op1 = getValue(I.getOperand(0)); SDOperand Op2 = getValue(I.getOperand(1)); - if (Ty-isIntegral()) { -setValue(I, DAG.getNode(IntOp, Op1.getValueType(), Op1, Op2)); - } else if (Ty-isFloatingPoint()) { -setValue(I, DAG.getNode(FPOp, Op1.getValueType(), Op1, Op2)); + if (const PackedType *PTy = dyn_castPackedType(Ty)) { +SDOperand Num = DAG.getConstant(PTy-getNumElements(), MVT::i32); +SDOperand Typ = DAG.getValueType(TLI.getValueType(PTy-getElementType())); +setValue(I, DAG.getNode(VecOp, MVT::Vector, Op1, Op2, Num, Typ)); } else { -const PackedType *PTy = castPackedType(Ty); +setValue(I, DAG.getNode(IntOp, Op1.getValueType(), Op1, Op2)); + } +} + +void +SelectionDAGLowering::visitFPBinary(User I, unsigned FPOp, unsigned VecOp) { + const Type *Ty = I.getType(); + SDOperand Op1 = getValue(I.getOperand(0)); + SDOperand Op2 = getValue(I.getOperand(1)); + + if (const PackedType *PTy = dyn_castPackedType(Ty)) { SDOperand Num = DAG.getConstant(PTy-getNumElements(), MVT::i32); SDOperand Typ = DAG.getValueType(TLI.getValueType(PTy-getElementType())); setValue(I, DAG.getNode(VecOp, MVT::Vector, Op1, Op2, Num, Typ)); + } else { +setValue(I, DAG.getNode(FPOp, Op1.getValueType(), Op1, Op2)); } } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu
[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp PredicateSimplifier.cpp Reassociate.cpp
Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.527 - 1.528 PredicateSimplifier.cpp updated: 1.29 - 1.30 Reassociate.cpp updated: 1.63 - 1.64 --- Log message: For PR950: http://llvm.org/PR950 : Make necessary changes to support DIV - [SUF]Div. This changes llvm to have three division instructions: signed, unsigned, floating point. The bytecode and assembler are bacwards compatible, however. --- Diffs of the changes: (+254 -133) InstructionCombining.cpp | 379 ++- PredicateSimplifier.cpp |4 Reassociate.cpp |4 3 files changed, 254 insertions(+), 133 deletions(-) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.527 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.528 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.527 Fri Oct 20 13:20:21 2006 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Thu Oct 26 01:15:43 2006 @@ -131,7 +131,11 @@ Instruction *visitAdd(BinaryOperator I); Instruction *visitSub(BinaryOperator I); Instruction *visitMul(BinaryOperator I); -Instruction *visitDiv(BinaryOperator I); +Instruction *commonDivTransforms(BinaryOperator I); +Instruction *commonIDivTransforms(BinaryOperator I); +Instruction *visitUDiv(BinaryOperator I); +Instruction *visitSDiv(BinaryOperator I); +Instruction *visitFDiv(BinaryOperator I); Instruction *visitRem(BinaryOperator I); Instruction *visitAnd(BinaryOperator I); Instruction *visitOr (BinaryOperator I); @@ -1822,7 +1826,9 @@ return R; } - // add (cast *A to intptrtype) B - cast (GEP (cast *A to sbyte*) B) - intptrtype + // add (cast *A to intptrtype) B - + // cast (GEP (cast *A to sbyte*) B) - + // intptrtype { CastInst* CI = dyn_castCastInst(LHS); Value* Other = RHS; @@ -1975,11 +1981,11 @@ } // 0 - (X sdiv C) - (X sdiv -C) - if (Op1I-getOpcode() == Instruction::Div) + if (Op1I-getOpcode() == Instruction::SDiv) if (ConstantInt *CSI = dyn_castConstantInt(Op0)) - if (CSI-getType()-isSigned() CSI-isNullValue()) + if (CSI-isNullValue()) if (Constant *DivRHS = dyn_castConstant(Op1I-getOperand(1))) - return BinaryOperator::createDiv(Op1I-getOperand(0), + return BinaryOperator::createSDiv(Op1I-getOperand(0), ConstantExpr::getNeg(DivRHS)); // X - X*C -- X * (1-C) @@ -2156,64 +2162,28 @@ return Changed ? I : 0; } -Instruction *InstCombiner::visitDiv(BinaryOperator I) { +/// This function implements the transforms on div instructions that work +/// regardless of the kind of div instruction it is (udiv, sdiv, or fdiv). It is +/// used by the visitors to those instructions. +/// @brief Transforms common to all three div instructions +Instruction* InstCombiner::commonDivTransforms(BinaryOperator I) { Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1); - if (isaUndefValue(Op0)) // undef / X - 0 + // undef / X - 0 + if (isaUndefValue(Op0)) return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType())); - if (isaUndefValue(Op1)) -return ReplaceInstUsesWith(I, Op1); // X / undef - undef - - if (ConstantInt *RHS = dyn_castConstantInt(Op1)) { -// div X, 1 == X -if (RHS-equalsInt(1)) - return ReplaceInstUsesWith(I, Op0); - -// div X, -1 == -X -if (RHS-isAllOnesValue()) - return BinaryOperator::createNeg(Op0); - -if (Instruction *LHS = dyn_castInstruction(Op0)) - if (LHS-getOpcode() == Instruction::Div) -if (ConstantInt *LHSRHS = dyn_castConstantInt(LHS-getOperand(1))) { - // (X / C1) / C2 - X / (C1*C2) - return BinaryOperator::createDiv(LHS-getOperand(0), - ConstantExpr::getMul(RHS, LHSRHS)); -} - -// Check to see if this is an unsigned division with an exact power of 2, -// if so, convert to a right shift. -if (ConstantInt *C = dyn_castConstantInt(RHS)) - if (C-getType()-isUnsigned()) -if (uint64_t Val = C-getZExtValue())// Don't break X / 0 - if (isPowerOf2_64(Val)) { -uint64_t C = Log2_64(Val); -return new ShiftInst(Instruction::Shr, Op0, - ConstantInt::get(Type::UByteTy, C)); - } -// -X/C - X/-C -if (RHS-getType()-isSigned()) - if (Value *LHSNeg = dyn_castNegVal(Op0)) -return BinaryOperator::createDiv(LHSNeg, ConstantExpr::getNeg(RHS)); - -if (!RHS-isNullValue()) { - if (SelectInst *SI = dyn_castSelectInst(Op0)) -if (Instruction *R = FoldOpIntoSelect(I, SI, this)) - return R; - if (isaPHINode(Op0)) -if (Instruction *NV = FoldOpIntoPhi(I)) - return NV; -} - } + // X / undef - undef + if
[llvm-commits] CVS: llvm/tools/llvm2cpp/CppWriter.cpp
Changes in directory llvm/tools/llvm2cpp: CppWriter.cpp updated: 1.17 - 1.18 --- Log message: For PR950: http://llvm.org/PR950 : Make necessary changes to support DIV - [SUF]Div. This changes llvm to have three division instructions: signed, unsigned, floating point. The bytecode and assembler are bacwards compatible, however. --- Diffs of the changes: (+9 -3) CppWriter.cpp | 12 +--- 1 files changed, 9 insertions(+), 3 deletions(-) Index: llvm/tools/llvm2cpp/CppWriter.cpp diff -u llvm/tools/llvm2cpp/CppWriter.cpp:1.17 llvm/tools/llvm2cpp/CppWriter.cpp:1.18 --- llvm/tools/llvm2cpp/CppWriter.cpp:1.17 Fri Oct 20 02:07:24 2006 +++ llvm/tools/llvm2cpp/CppWriter.cpp Thu Oct 26 01:15:43 2006 @@ -773,7 +773,9 @@ case Instruction::Add:Out getAdd; break; case Instruction::Sub:Out getSub; break; case Instruction::Mul:Out getMul; break; -case Instruction::Div:Out getDiv; break; +case Instruction::UDiv: Out getUDiv; break; +case Instruction::SDiv: Out getSDiv; break; +case Instruction::FDiv: Out getFDiv; break; case Instruction::Rem:Out getRem; break; case Instruction::And:Out getAnd; break; case Instruction::Or: Out getOr; break; @@ -1021,7 +1023,9 @@ case Instruction::Add: case Instruction::Sub: case Instruction::Mul: -case Instruction::Div: +case Instruction::UDiv: +case Instruction::SDiv: +case Instruction::FDiv: case Instruction::Rem: case Instruction::And: case Instruction::Or: @@ -1033,7 +1037,9 @@ case Instruction::Add: Out Instruction::Add; break; case Instruction::Sub: Out Instruction::Sub; break; case Instruction::Mul: Out Instruction::Mul; break; -case Instruction::Div: Out Instruction::Div; break; +case Instruction::UDiv:Out Instruction::UDiv; break; +case Instruction::SDiv:Out Instruction::SDiv; break; +case Instruction::FDiv:Out Instruction::FDiv; break; case Instruction::Rem: Out Instruction::Rem; break; case Instruction::And: Out Instruction::And; break; case Instruction::Or: Out Instruction::Or; break; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
Changes in directory llvm/lib/ExecutionEngine/Interpreter: Execution.cpp updated: 1.140 - 1.141 --- Log message: For PR950: http://llvm.org/PR950 : Make necessary changes to support DIV - [SUF]Div. This changes llvm to have three division instructions: signed, unsigned, floating point. The bytecode and assembler are bacwards compatible, however. --- Diffs of the changes: (+51 -11) Execution.cpp | 62 +++--- 1 files changed, 51 insertions(+), 11 deletions(-) Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.140 llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.141 --- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.140Fri Oct 20 02:07:24 2006 +++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp Thu Oct 26 01:15:43 2006 @@ -42,8 +42,12 @@ const Type *Ty); static GenericValue executeRemInst(GenericValue Src1, GenericValue Src2, const Type *Ty); -static GenericValue executeDivInst(GenericValue Src1, GenericValue Src2, - const Type *Ty); +static GenericValue executeUDivInst(GenericValue Src1, GenericValue Src2, +const Type *Ty); +static GenericValue executeSDivInst(GenericValue Src1, GenericValue Src2, +const Type *Ty); +static GenericValue executeFDivInst(GenericValue Src1, GenericValue Src2, +const Type *Ty); static GenericValue executeAndInst(GenericValue Src1, GenericValue Src2, const Type *Ty); static GenericValue executeOrInst(GenericValue Src1, GenericValue Src2, @@ -89,10 +93,18 @@ return executeMulInst(getOperandValue(CE-getOperand(0), SF), getOperandValue(CE-getOperand(1), SF), CE-getOperand(0)-getType()); - case Instruction::Div: -return executeDivInst(getOperandValue(CE-getOperand(0), SF), - getOperandValue(CE-getOperand(1), SF), - CE-getOperand(0)-getType()); + case Instruction::SDiv: +return executeSDivInst(getOperandValue(CE-getOperand(0), SF), + getOperandValue(CE-getOperand(1), SF), + CE-getOperand(0)-getType()); + case Instruction::UDiv: +return executeUDivInst(getOperandValue(CE-getOperand(0), SF), + getOperandValue(CE-getOperand(1), SF), + CE-getOperand(0)-getType()); + case Instruction::FDiv: +return executeFDivInst(getOperandValue(CE-getOperand(0), SF), + getOperandValue(CE-getOperand(1), SF), + CE-getOperand(0)-getType()); case Instruction::Rem: return executeRemInst(getOperandValue(CE-getOperand(0), SF), getOperandValue(CE-getOperand(1), SF), @@ -242,18 +254,44 @@ return Dest; } -static GenericValue executeDivInst(GenericValue Src1, GenericValue Src2, +static GenericValue executeUDivInst(GenericValue Src1, GenericValue Src2, const Type *Ty) { GenericValue Dest; + if (Ty-isSigned()) +Ty = Ty-getUnsignedVersion(); switch (Ty-getTypeID()) { IMPLEMENT_BINARY_OPERATOR(/, UByte); -IMPLEMENT_BINARY_OPERATOR(/, SByte); IMPLEMENT_BINARY_OPERATOR(/, UShort); -IMPLEMENT_BINARY_OPERATOR(/, Short); IMPLEMENT_BINARY_OPERATOR(/, UInt); -IMPLEMENT_BINARY_OPERATOR(/, Int); IMPLEMENT_BINARY_OPERATOR(/, ULong); + default: +std::cout Unhandled type for UDiv instruction: *Ty \n; +abort(); + } + return Dest; +} + +static GenericValue executeSDivInst(GenericValue Src1, GenericValue Src2, + const Type *Ty) { + GenericValue Dest; + if (Ty-isUnsigned()) +Ty = Ty-getSignedVersion(); + switch (Ty-getTypeID()) { +IMPLEMENT_BINARY_OPERATOR(/, SByte); +IMPLEMENT_BINARY_OPERATOR(/, Short); +IMPLEMENT_BINARY_OPERATOR(/, Int); IMPLEMENT_BINARY_OPERATOR(/, Long); + default: +std::cout Unhandled type for SDiv instruction: *Ty \n; +abort(); + } + return Dest; +} + +static GenericValue executeFDivInst(GenericValue Src1, GenericValue Src2, + const Type *Ty) { + GenericValue Dest; + switch (Ty-getTypeID()) { IMPLEMENT_BINARY_OPERATOR(/, Float); IMPLEMENT_BINARY_OPERATOR(/, Double); default: @@ -504,7 +542,9 @@ case Instruction::Add: R = executeAddInst (Src1, Src2, Ty); break; case Instruction::Sub: R = executeSubInst (Src1, Src2, Ty); break; case Instruction::Mul: R = executeMulInst (Src1, Src2, Ty); break; - case Instruction::Div: R = executeDivInst (Src1, Src2, Ty); break; + case Instruction::UDiv: R = executeUDivInst (Src1, Src2, Ty); break; + case Instruction::SDiv: R
[llvm-commits] CVS: llvm/include/llvm/Support/PatternMatch.h
Changes in directory llvm/include/llvm/Support: PatternMatch.h updated: 1.9 - 1.10 --- Log message: For PR950: http://llvm.org/PR950 : Make necessary changes to support DIV - [SUF]Div. This changes llvm to have three division instructions: signed, unsigned, floating point. The bytecode and assembler are bacwards compatible, however. --- Diffs of the changes: (+14 -2) PatternMatch.h | 16 ++-- 1 files changed, 14 insertions(+), 2 deletions(-) Index: llvm/include/llvm/Support/PatternMatch.h diff -u llvm/include/llvm/Support/PatternMatch.h:1.9 llvm/include/llvm/Support/PatternMatch.h:1.10 --- llvm/include/llvm/Support/PatternMatch.h:1.9Mon Sep 18 00:17:11 2006 +++ llvm/include/llvm/Support/PatternMatch.hThu Oct 26 01:15:43 2006 @@ -112,9 +112,21 @@ } templatetypename LHS, typename RHS -inline BinaryOp_matchLHS, RHS, Instruction::Div m_Div(const LHS L, +inline BinaryOp_matchLHS, RHS, Instruction::UDiv m_UDiv(const LHS L, const RHS R) { - return BinaryOp_matchLHS, RHS, Instruction::Div(L, R); + return BinaryOp_matchLHS, RHS, Instruction::UDiv(L, R); +} + +templatetypename LHS, typename RHS +inline BinaryOp_matchLHS, RHS, Instruction::SDiv m_SDiv(const LHS L, +const RHS R) { + return BinaryOp_matchLHS, RHS, Instruction::SDiv(L, R); +} + +templatetypename LHS, typename RHS +inline BinaryOp_matchLHS, RHS, Instruction::FDiv m_FDiv(const LHS L, +const RHS R) { + return BinaryOp_matchLHS, RHS, Instruction::FDiv(L, R); } templatetypename LHS, typename RHS ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/Analysis/ScalarEvolutionExpander.h ScalarEvolutionExpressions.h
Changes in directory llvm/include/llvm/Analysis: ScalarEvolutionExpander.h updated: 1.5 - 1.6 ScalarEvolutionExpressions.h updated: 1.7 - 1.8 --- Log message: For PR950: http://llvm.org/PR950 : Make necessary changes to support DIV - [SUF]Div. This changes llvm to have three division instructions: signed, unsigned, floating point. The bytecode and assembler are bacwards compatible, however. --- Diffs of the changes: (+2 -2) ScalarEvolutionExpander.h|2 +- ScalarEvolutionExpressions.h |2 +- 2 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/include/llvm/Analysis/ScalarEvolutionExpander.h diff -u llvm/include/llvm/Analysis/ScalarEvolutionExpander.h:1.5 llvm/include/llvm/Analysis/ScalarEvolutionExpander.h:1.6 --- llvm/include/llvm/Analysis/ScalarEvolutionExpander.h:1.5Fri Mar 31 22:48:52 2006 +++ llvm/include/llvm/Analysis/ScalarEvolutionExpander.hThu Oct 26 01:15:43 2006 @@ -140,7 +140,7 @@ const Type *Ty = S-getType(); Value *LHS = expandInTy(S-getLHS(), Ty); Value *RHS = expandInTy(S-getRHS(), Ty); - return BinaryOperator::createDiv(LHS, RHS, tmp., InsertPt); + return BinaryOperator::createSDiv(LHS, RHS, tmp., InsertPt); } Value *visitAddRecExpr(SCEVAddRecExpr *S); Index: llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h diff -u llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h:1.7 llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h:1.8 --- llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h:1.7 Fri Mar 31 22:48:52 2006 +++ llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h Thu Oct 26 01:15:43 2006 @@ -293,7 +293,7 @@ //======// - /// SCEVSDivExpr - This class represents a binary unsigned division operation. + /// SCEVSDivExpr - This class represents a binary signed division operation. /// class SCEVSDivExpr : public SCEV { SCEVHandle LHS, RHS; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Target/README.txt
Changes in directory llvm/lib/Target: README.txt updated: 1.43 - 1.44 --- Log message: For PR950: http://llvm.org/PR950 : Make necessary changes to support DIV - [SUF]Div. This changes llvm to have three division instructions: signed, unsigned, floating point. The bytecode and assembler are bacwards compatible, however. --- Diffs of the changes: (+13 -0) README.txt | 13 + 1 files changed, 13 insertions(+) Index: llvm/lib/Target/README.txt diff -u llvm/lib/Target/README.txt:1.43 llvm/lib/Target/README.txt:1.44 --- llvm/lib/Target/README.txt:1.43 Tue Oct 24 11:12:47 2006 +++ llvm/lib/Target/README.txt Thu Oct 26 01:15:43 2006 @@ -319,3 +319,16 @@ } //===-===// + +-instcombine should handle this transform: + setcc (sdiv X / C1 ), C2 +when X, C1, and C2 are unsigned. Similarly for udiv and signed operands. + +Currently InstCombine avoids this transform but will do it when the signs of +the operands and the sign of the divide match. See the FIXME in +InstructionCombining.cpp in the visitSetCondInst method after the switch case +for Instruction::UDiv (around line 4447) for more details. + +The SingleSource/Benchmarks/Shootout-C++/hash and hash2 tests have examples of +this construct. +//===-===// ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/docs/LangRef.html
Changes in directory llvm/docs: LangRef.html updated: 1.158 - 1.159 --- Log message: For PR950: http://llvm.org/PR950 : Make necessary changes to support DIV - [SUF]Div. This changes llvm to have three division instructions: signed, unsigned, floating point. The bytecode and assembler are bacwards compatible, however. --- Diffs of the changes: (+59 -13) LangRef.html | 72 --- 1 files changed, 59 insertions(+), 13 deletions(-) Index: llvm/docs/LangRef.html diff -u llvm/docs/LangRef.html:1.158 llvm/docs/LangRef.html:1.159 --- llvm/docs/LangRef.html:1.158Sun Oct 15 15:05:59 2006 +++ llvm/docs/LangRef.html Thu Oct 26 01:15:43 2006 @@ -77,7 +77,9 @@ lia href=#i_add'ttadd/tt' Instruction/a/li lia href=#i_sub'ttsub/tt' Instruction/a/li lia href=#i_mul'ttmul/tt' Instruction/a/li - lia href=#i_div'ttdiv/tt' Instruction/a/li + lia href=#i_udiv'ttudiv/tt' Instruction/a/li + lia href=#i_sdiv'ttsdiv/tt' Instruction/a/li + lia href=#i_fdiv'ttfdiv/tt' Instruction/a/li lia href=#i_rem'ttrem/tt' Instruction/a/li lia href=#i_setcc'ttseticc/i/tt' Instructions/a/li /ol @@ -1630,26 +1632,70 @@ /pre /div !-- ___ -- -div class=doc_subsubsection a name=i_div'ttdiv/tt' +div class=doc_subsubsection a name=i_udiv'ttudiv/tt' Instruction +/a/div +div class=doc_text +h5Syntax:/h5 +pre lt;resultgt; = udiv lt;tygt; lt;var1gt;, lt;var2gt; i; yields {ty}:result/i +/pre +h5Overview:/h5 +pThe 'ttudiv/tt' instruction returns the quotient of its two +operands./p +h5Arguments:/h5 +pThe two arguments to the 'ttudiv/tt' instruction must be +a href=#t_integerinteger/a values. Both arguments must have identical +types. This instruction can also take a href=#t_packedpacked/a versions +of the values in which case the elements must be integers./p +h5Semantics:/h5 +pThe value produced is the unsigned integer quotient of the two operands. This +instruction always performs an unsigned division operation, regardless of +whether the arguments are unsigned or not./p +h5Example:/h5 +pre lt;resultgt; = udiv uint 4, %var i; yields {uint}:result = 4 / %var/i +/pre +/div +!-- ___ -- +div class=doc_subsubsection a name=i_sdiv'ttsdiv/tt' Instruction +/a /div +div class=doc_text +h5Syntax:/h5 +pre lt;resultgt; = sdiv lt;tygt; lt;var1gt;, lt;var2gt; i; yields {ty}:result/i +/pre +h5Overview:/h5 +pThe 'ttsdiv/tt' instruction returns the quotient of its two +operands./p +h5Arguments:/h5 +pThe two arguments to the 'ttsdiv/tt' instruction must be +a href=#t_integerinteger/a values. Both arguments must have identical +types. This instruction can also take a href=#t_packedpacked/a versions +of the values in which case the elements must be integers./p +h5Semantics:/h5 +pThe value produced is the signed integer quotient of the two operands. This +instruction always performs a signed division operation, regardless of whether +the arguments are signed or not./p +h5Example:/h5 +pre lt;resultgt; = sdiv int 4, %var i; yields {int}:result = 4 / %var/i +/pre +/div +!-- ___ -- +div class=doc_subsubsection a name=i_fdiv'ttfdiv/tt' Instruction/a /div div class=doc_text h5Syntax:/h5 -pre lt;resultgt; = div lt;tygt; lt;var1gt;, lt;var2gt; i; yields {ty}:result/i +pre lt;resultgt; = fdiv lt;tygt; lt;var1gt;, lt;var2gt; i; yields {ty}:result/i /pre h5Overview:/h5 -pThe 'ttdiv/tt' instruction returns the quotient of its two +pThe 'ttfdiv/tt' instruction returns the quotient of its two operands./p h5Arguments:/h5 -pThe two arguments to the 'ttdiv/tt' instruction must be either a - href=#t_integerinteger/a or a href=#t_floatingfloating point/a -values. -This instruction can also take a href=#t_packedpacked/a versions of the values. -Both arguments must have identical types./p +pThe two arguments to the 'ttdiv/tt' instruction must be +a href=#t_floatingfloating point/a values. Both arguments must have +identical types. This instruction can also take a href=#t_packedpacked/a +versions of the values in which case the elements must be floating point./p h5Semantics:/h5 -pThe value produced is the integer or floating point quotient of the -two operands./p +pThe value produced is the floating point quotient of the two operands./p h5Example:/h5 -pre lt;resultgt; = div int 4, %var i; yields {int}:result = 4 / %var/i +pre lt;resultgt; = fdiv float 4.0, %var i; yields {float}:result = 4.0 / %var/i /pre /div !-- ___ -- @@ -3910,7 +3956,7 @@ a href=mailto:[EMAIL PROTECTED]Chris Lattner/abr a href=http://llvm.org;The LLVM Compiler Infrastructure/abr - Last
[llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.cpp Reader.h
Changes in directory llvm/lib/Bytecode/Reader: Reader.cpp updated: 1.199 - 1.200 Reader.h updated: 1.34 - 1.35 --- Log message: For PR950: http://llvm.org/PR950 : Make necessary changes to support DIV - [SUF]Div. This changes llvm to have three division instructions: signed, unsigned, floating point. The bytecode and assembler are bacwards compatible, however. --- Diffs of the changes: (+713 -370) Reader.cpp | 1064 +++-- Reader.h | 19 + 2 files changed, 713 insertions(+), 370 deletions(-) Index: llvm/lib/Bytecode/Reader/Reader.cpp diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.199 llvm/lib/Bytecode/Reader/Reader.cpp:1.200 --- llvm/lib/Bytecode/Reader/Reader.cpp:1.199 Fri Oct 20 02:07:24 2006 +++ llvm/lib/Bytecode/Reader/Reader.cpp Thu Oct 26 01:15:43 2006 @@ -562,6 +562,244 @@ insertValue(AI, getTypeSlot(AI-getType()), FunctionValues); } +// Convert previous opcode values into the current value and/or construct +// the instruction. This function handles all *abnormal* cases for instruction +// generation based on obsolete opcode values. The normal cases are handled +// in ParseInstruction below. Generally this function just produces a new +// Opcode value (first argument). In a few cases (VAArg, VANext) the upgrade +// path requies that the instruction (sequence) be generated differently from +// the normal case in order to preserve the original semantics. In these +// cases the result of the function will be a non-zero Instruction pointer. In +// all other cases, zero will be returned indicating that the *normal* +// instruction generation should be used, but with the new Opcode value. +// +Instruction* +BytecodeReader::handleObsoleteOpcodes( + unsigned Opcode, /// The old opcode, possibly updated by this function + std::vectorunsigned Oprnds, /// The operands to the instruction + unsigned iType,/// The type code from the bytecode file + const Type* InstTy, /// The type of the instruction + BasicBlock* BB /// The basic block to insert into, if we need to +) { + + // First, short circuit this if no conversion is required. When signless + // instructions were implemented the entire opcode sequence was revised so + // we key on this first which means that the opcode value read is the one + // we should use. + if (!hasSignlessInstructions) +return 0; // The opcode is fine the way it is. + + // Declare the resulting instruction we might build. In general we just + // change the Opcode argument but in a few cases we need to generate the + // Instruction here because the upgrade case is significantly different from + // the normal case. + Instruction *Result = 0; + + // If this is a bytecode format that did not include the unreachable + // instruction, bump up the opcode number to adjust it. + if (hasNoUnreachableInst) +if (Opcode = Instruction::Unreachable Opcode 62) + ++Opcode; + + // We're dealing with an upgrade situation. For each of the opcode values, + // perform the necessary conversion. + switch (Opcode) { +default: // Error + // This switch statement provides cases for all known opcodes prior to + // version 6 bytecode format. We know we're in an upgrade situation so + // if there isn't a match in this switch, then something is horribly + // wrong. + error(Unknown obsolete opcode encountered.); + break; +case 1: // Ret + Opcode = Instruction::Ret; + break; +case 2: // Br + Opcode = Instruction::Br; + break; +case 3: // Switch + Opcode = Instruction::Switch; + break; +case 4: // Invoke + Opcode = Instruction::Invoke; + break; +case 5: // Unwind + Opcode = Instruction::Unwind; + break; +case 6: // Unreachable + Opcode = Instruction::Unreachable; + break; +case 7: // Add + Opcode = Instruction::Add; + break; +case 8: // Sub + Opcode = Instruction::Sub; + break; +case 9: // Mul + Opcode = Instruction::Mul; + break; +case 10: // Div + // The type of the instruction is based on the operands. We need to select + // fdiv, udiv or sdiv based on that type. The iType values are hardcoded + // to the values used in bytecode version 5 (and prior) because it is + // likely these codes will change in future versions of LLVM. + if (iType == 10 || iType == 11 ) +Opcode = Instruction::FDiv; + else if (iType = 2 iType = 9 iType % 2 != 0) +Opcode = Instruction::SDiv; + else +Opcode = Instruction::UDiv; + break; + +case 11: // Rem +Opcode = Instruction::Rem; + break; +case 12: // And + Opcode = Instruction::And; + break; +case 13: // Or + Opcode = Instruction::Or; + break; +case 14: // Xor + Opcode = Instruction::Xor; + break; +case 15: // SetEQ + Opcode = Instruction::SetEQ; + break; +
[llvm-commits] CVS: llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp ARMRegisterInfo.cpp ARMRegisterInfo.td
Changes in directory llvm/lib/Target/ARM: ARMISelDAGToDAG.cpp updated: 1.79 - 1.80 ARMRegisterInfo.cpp updated: 1.22 - 1.23 ARMRegisterInfo.td updated: 1.5 - 1.6 --- Log message: initial support for frame pointers --- Diffs of the changes: (+44 -5) ARMISelDAGToDAG.cpp |3 +++ ARMRegisterInfo.cpp | 41 + ARMRegisterInfo.td |5 - 3 files changed, 44 insertions(+), 5 deletions(-) Index: llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp diff -u llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp:1.79 llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp:1.80 --- llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp:1.79Tue Oct 24 15:15:21 2006 +++ llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp Thu Oct 26 08:31:25 2006 @@ -91,10 +91,13 @@ setOperationAction(ISD::VASTART, MVT::Other, Custom); setOperationAction(ISD::VACOPY,MVT::Other, Expand); setOperationAction(ISD::VAEND, MVT::Other, Expand); + setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i32, Expand); setOperationAction(ISD::ConstantFP, MVT::f64, Expand); setOperationAction(ISD::ConstantFP, MVT::f32, Expand); + setStackPointerRegisterToSaveRestore(ARM::R13); + setSchedulingPreference(SchedulingForRegPressure); computeRegisterProperties(); } Index: llvm/lib/Target/ARM/ARMRegisterInfo.cpp diff -u llvm/lib/Target/ARM/ARMRegisterInfo.cpp:1.22 llvm/lib/Target/ARM/ARMRegisterInfo.cpp:1.23 --- llvm/lib/Target/ARM/ARMRegisterInfo.cpp:1.22Tue Oct 17 09:34:02 2006 +++ llvm/lib/Target/ARM/ARMRegisterInfo.cpp Thu Oct 26 08:31:25 2006 @@ -19,10 +19,20 @@ #include llvm/CodeGen/MachineFrameInfo.h #include llvm/CodeGen/MachineLocation.h #include llvm/Type.h +#include llvm/Target/TargetOptions.h #include llvm/ADT/STLExtras.h #include iostream using namespace llvm; +// hasFP - Return true if the specified function should have a dedicated frame +// pointer register. This is true if the function has variable sized allocas or +// if frame pointer elimination is disabled. +// +static bool hasFP(const MachineFunction MF) { + const MachineFrameInfo *MFI = MF.getFrameInfo(); + return NoFramePointerElim || MFI-hasVarSizedObjects(); +} + ARMRegisterInfo::ARMRegisterInfo() : ARMGenRegisterInfo(ARM::ADJCALLSTACKDOWN, ARM::ADJCALLSTACKUP) { } @@ -88,6 +98,9 @@ void ARMRegisterInfo:: eliminateCallFramePseudoInstr(MachineFunction MF, MachineBasicBlock MBB, MachineBasicBlock::iterator I) const { + if (hasFP(MF)) { +assert(0); + } MBB.erase(I); } @@ -114,17 +127,18 @@ Offset += StackSize; assert (Offset = 0); + unsigned BaseRegister = hasFP(MF) ? ARM::R11 : ARM::R13; if (Offset 4096) { // Replace the FrameIndex with r13 -MI.getOperand(FrameIdx).ChangeToRegister(ARM::R13, false); +MI.getOperand(FrameIdx).ChangeToRegister(BaseRegister, false); // Replace the ldr offset with Offset MI.getOperand(OffIdx).ChangeToImmediate(Offset); } else { // Insert a set of r12 with the full address // r12 = r13 + offset MachineBasicBlock *MBB2 = MI.getParent(); -BuildMI(*MBB2, II, ARM::ADD, 4, ARM::R12).addReg(ARM::R13).addImm(Offset) - .addImm(0).addImm(ARMShift::LSL); +BuildMI(*MBB2, II, ARM::ADD, 4, ARM::R12).addReg(BaseRegister) + .addImm(Offset).addImm(0).addImm(ARMShift::LSL); // Replace the FrameIndex with r12 MI.getOperand(FrameIdx).ChangeToRegister(ARM::R12, false); @@ -140,6 +154,8 @@ MachineFrameInfo *MFI = MF.getFrameInfo(); int NumBytes = (int) MFI-getStackSize(); + bool HasFP = hasFP(MF); + if (MFI-hasCalls()) { // We reserve argument space for call sites in the function immediately on // entry to the current function. This eliminates the need for add/sub @@ -147,6 +163,10 @@ NumBytes += MFI-getMaxCallFrameSize(); } + if (HasFP) +// Add space for storing the FP +NumBytes += 4; + // Align to 8 bytes NumBytes = ((NumBytes + 7) / 8) * 8; @@ -155,6 +175,13 @@ //sub sp, sp, #NumBytes BuildMI(MBB, MBBI, ARM::SUB, 4, ARM::R13).addReg(ARM::R13).addImm(NumBytes) .addImm(0).addImm(ARMShift::LSL); + + if (HasFP) { +BuildMI(MBB, MBBI, ARM::str, 3) + .addReg(ARM::R11).addImm(0).addReg(ARM::R13); +BuildMI(MBB, MBBI, ARM::MOV, 3, ARM::R11).addReg(ARM::R13).addImm(0). + addImm(ARMShift::LSL); + } } void ARMRegisterInfo::emitEpilogue(MachineFunction MF, @@ -166,6 +193,12 @@ MachineFrameInfo *MFI = MF.getFrameInfo(); int NumBytes = (int) MFI-getStackSize(); + if (hasFP(MF)) { +BuildMI(MBB, MBBI, ARM::MOV, 3, ARM::R13).addReg(ARM::R11).addImm(0). + addImm(ARMShift::LSL); +BuildMI(MBB, MBBI, ARM::ldr, 2, ARM::R11).addImm(0).addReg(ARM::R13); + } + //add sp, sp, #NumBytes BuildMI(MBB, MBBI, ARM::ADD, 4, ARM::R13).addReg(ARM::R13).addImm(NumBytes) .addImm(0).addImm(ARMShift::LSL); @@ -176,7 +209,7 @@ } unsigned
[llvm-commits] CVS: llvm/test/Regression/CodeGen/ARM/alloca.ll
Changes in directory llvm/test/Regression/CodeGen/ARM: alloca.ll added (r1.1) --- Log message: initial support for frame pointers --- Diffs of the changes: (+5 -0) alloca.ll |5 + 1 files changed, 5 insertions(+) Index: llvm/test/Regression/CodeGen/ARM/alloca.ll diff -c /dev/null llvm/test/Regression/CodeGen/ARM/alloca.ll:1.1 *** /dev/null Thu Oct 26 08:31:36 2006 --- llvm/test/Regression/CodeGen/ARM/alloca.ll Thu Oct 26 08:31:26 2006 *** *** 0 --- 1,5 + void %f(uint %a) { + entry: + %tmp1032 = alloca ubyte, uint %a + ret void + } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] Div-[USF]Div Patch, Attempt #2
On Oct 25, 2006, at 9:57 PM, Reid Spencer wrote: This code is a bit simpler as: // (X / C1) / C2 - X / (C1*C2) if (BinaryOperator *LHS = dyn_castBinaryOperator(Op0)) if (LHS-getOpcode() == I.getOpcode()) Didn't apply this because it causes a compiler warning about signed/unsigned comparison. Ok. // udiv X, (Select Cond, C1, C2) -- Select Cond, (shr X, C1), (shr X, C2) // where C1C2 are powers of two. ... X = InsertNewInstBefore( new CastInst(X, X-getType()-getUnsignedVersion ()), I); This (and similar cases) is easier/cleaner with InsertCastBefore. Yes, I agree. I changed the ones in my code but there are actually dozens (hundreds) of instances in the file (not related to my changes). I'm going to commit the DIV patch first, then I'll come back and clean up the others in a separate patch (tested, of course). Ok, sounds good. Thanks for your excellent reviews, Chris. I know it takes a lot of your time and I appreciate that you so willingly give it. I'll apply what I learned from DIV to the REM patch which I'm reviewing for Sheng soon. Hopefully REM will fare better than DIV did. Sounds good, I'm sure it will get more smooth as it goes on. Thanks for the great improvements Reid! -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/Type.h
Changes in directory llvm/include/llvm: Type.h updated: 1.90 - 1.91 --- Log message: Add isFPOrFPVector() method, which indicates if a type is either FP or a vector of FP types. --- Diffs of the changes: (+4 -0) Type.h |4 1 files changed, 4 insertions(+) Index: llvm/include/llvm/Type.h diff -u llvm/include/llvm/Type.h:1.90 llvm/include/llvm/Type.h:1.91 --- llvm/include/llvm/Type.h:1.90 Thu Sep 28 18:38:07 2006 +++ llvm/include/llvm/Type.hThu Oct 26 13:22:45 2006 @@ -185,6 +185,10 @@ /// types bool isFloatingPoint() const { return ID == FloatTyID || ID == DoubleTyID; } + /// isFPOrFPVector - Return true if this is a FP type or a vector of FP types. + /// + bool isFPOrFPVector() const; + /// isAbstract - True if the type is either an Opaque type, or is a derived /// type that includes an opaque type somewhere in it. /// ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/VMCore/Instruction.cpp
Changes in directory llvm/lib/VMCore: Instruction.cpp updated: 1.54 - 1.55 --- Log message: Fix Transforms/InstCombine/2006-10-26-VectorReassoc.ll --- Diffs of the changes: (+6 -5) Instruction.cpp | 11 ++- 1 files changed, 6 insertions(+), 5 deletions(-) Index: llvm/lib/VMCore/Instruction.cpp diff -u llvm/lib/VMCore/Instruction.cpp:1.54 llvm/lib/VMCore/Instruction.cpp:1.55 --- llvm/lib/VMCore/Instruction.cpp:1.54Thu Oct 26 01:15:43 2006 +++ llvm/lib/VMCore/Instruction.cpp Thu Oct 26 13:27:26 2006 @@ -172,11 +172,12 @@ /// applied to floating point types. /// bool Instruction::isAssociative(unsigned Opcode, const Type *Ty) { - if (Opcode == Add || Opcode == Mul || - Opcode == And || Opcode == Or || Opcode == Xor) { -// Floating point operations do not associate! -return !Ty-isFloatingPoint(); - } + if (Opcode == And || Opcode == Or || Opcode == Xor) +return true; + + // Add/Mul reassociate unless they are FP or FP vectors. + if (Opcode == Add || Opcode == Mul) +return !Ty-isFPOrFPVector(); return 0; } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Target/X86/X86AsmPrinter.cpp X86TargetAsmInfo.cpp
Changes in directory llvm/lib/Target/X86: X86AsmPrinter.cpp updated: 1.205 - 1.206 X86TargetAsmInfo.cpp updated: 1.4 - 1.5 --- Log message: Put cstrings in .cstring section when compiling for Mac OS X. --- Diffs of the changes: (+10 -1) X86AsmPrinter.cpp| 10 +- X86TargetAsmInfo.cpp |1 + 2 files changed, 10 insertions(+), 1 deletion(-) Index: llvm/lib/Target/X86/X86AsmPrinter.cpp diff -u llvm/lib/Target/X86/X86AsmPrinter.cpp:1.205 llvm/lib/Target/X86/X86AsmPrinter.cpp:1.206 --- llvm/lib/Target/X86/X86AsmPrinter.cpp:1.205 Tue Oct 24 15:32:14 2006 +++ llvm/lib/Target/X86/X86AsmPrinter.cpp Thu Oct 26 14:18:18 2006 @@ -204,9 +204,17 @@ // If external or appending, declare as a global symbol O \t.globl name \n; // FALL THROUGH - case GlobalValue::InternalLinkage: + case GlobalValue::InternalLinkage: { +if (TAI-getCStringSection()) { + const ConstantArray *CVA = dyn_castConstantArray(C); + if (CVA CVA-isCString()) { +SwitchToDataSection(TAI-getCStringSection(), I); +break; + } +} SwitchToDataSection(TAI-getDataSection(), I); break; + } default: assert(0 Unknown linkage type!); } Index: llvm/lib/Target/X86/X86TargetAsmInfo.cpp diff -u llvm/lib/Target/X86/X86TargetAsmInfo.cpp:1.4 llvm/lib/Target/X86/X86TargetAsmInfo.cpp:1.5 --- llvm/lib/Target/X86/X86TargetAsmInfo.cpp:1.4Wed Oct 4 21:43:52 2006 +++ llvm/lib/Target/X86/X86TargetAsmInfo.cppThu Oct 26 14:18:18 2006 @@ -32,6 +32,7 @@ PrivateGlobalPrefix = L; // Marker for constant pool idxs ConstantPoolSection = \t.const\n; JumpTableDataSection = \t.const\n; +CStringSection = \t.cstring; FourByteConstantSection = \t.literal4\n; EightByteConstantSection = \t.literal8\n; if (Subtarget-is64Bit()) ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.528 - 1.529 --- Log message: Simplify code a bit by changing instances of: InsertNewInstBefore(new CastInst(Val, ValTy, Val-GetName()), I) into: InsertCastBefore(Val, ValTy, I) --- Diffs of the changes: (+27 -47) InstructionCombining.cpp | 74 +-- 1 files changed, 27 insertions(+), 47 deletions(-) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.528 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.529 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.528 Thu Oct 26 01:15:43 2006 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Thu Oct 26 14:19:06 2006 @@ -461,9 +461,7 @@ if (Constant *C = dyn_castConstant(V)) return ConstantExpr::getCast(C, DestTy); - CastInst *CI = new CastInst(V, DestTy, V-getName()); - InsertNewInstBefore(CI, *InsertBefore); - return CI; + return InsertCastBefore(V, DestTy, *InsertBefore); } // SimplifyCommutative - This performs a few simplifications for commutative @@ -1087,13 +1085,11 @@ // convert this into a zero extension. if ((KnownZero InSignBit) || (NewBits ~DemandedMask) == NewBits) { // Convert to unsigned first. -Instruction *NewVal; -NewVal = new CastInst(I-getOperand(0), SrcTy-getUnsignedVersion(), - I-getOperand(0)-getName()); -InsertNewInstBefore(NewVal, *I); +Value *NewVal = + InsertCastBefore(I-getOperand(0), SrcTy-getUnsignedVersion(), *I); // Then cast that to the destination type. NewVal = new CastInst(NewVal, I-getType(), I-getName()); -InsertNewInstBefore(NewVal, *I); +InsertNewInstBefore(castInstruction(NewVal), *I); return UpdateValueUsesWith(I, NewVal); } else if (KnownOne InSignBit) {// Input sign bit known set KnownOne |= NewBits; @@ -1124,17 +1120,15 @@ // the shift amount is = the size of the datatype, which is undefined. if (DemandedMask == 1 I-getType()-isSigned()) { // Convert the input to unsigned. - Instruction *NewVal = new CastInst(I-getOperand(0), - I-getType()-getUnsignedVersion(), - I-getOperand(0)-getName()); - InsertNewInstBefore(NewVal, *I); + Value *NewVal = InsertCastBefore(I-getOperand(0), + I-getType()-getUnsignedVersion(), *I); // Perform the unsigned shift right. NewVal = new ShiftInst(Instruction::Shr, NewVal, I-getOperand(1), I-getName()); - InsertNewInstBefore(NewVal, *I); + InsertNewInstBefore(castInstruction(NewVal), *I); // Then cast that to the destination type. NewVal = new CastInst(NewVal, I-getType(), I-getName()); - InsertNewInstBefore(NewVal, *I); + InsertNewInstBefore(castInstruction(NewVal), *I); return UpdateValueUsesWith(I, NewVal); } @@ -1175,17 +1169,14 @@ // are demanded, turn this into an unsigned shift right. if ((KnownZero SignBit) || (HighBits ~DemandedMask) == HighBits) { // Convert the input to unsigned. - Instruction *NewVal; - NewVal = new CastInst(I-getOperand(0), -I-getType()-getUnsignedVersion(), -I-getOperand(0)-getName()); - InsertNewInstBefore(NewVal, *I); + Value *NewVal = InsertCastBefore(I-getOperand(0), + I-getType()-getUnsignedVersion(), *I); // Perform the unsigned shift right. NewVal = new ShiftInst(Instruction::Shr, NewVal, SA, I-getName()); - InsertNewInstBefore(NewVal, *I); + InsertNewInstBefore(castInstruction(NewVal), *I); // Then cast that to the destination type. NewVal = new CastInst(NewVal, I-getType(), I-getName()); - InsertNewInstBefore(NewVal, *I); + InsertNewInstBefore(castInstruction(NewVal), *I); return UpdateValueUsesWith(I, NewVal); } else if (KnownOne SignBit) { // New bits are known one. KnownOne |= HighBits; @@ -1914,15 +1905,13 @@ SI-getType()-getPrimitiveSizeInBits()-1) { // Ok, the transformation is safe. Insert a cast of the incoming // value, then the new shift, then the new cast. - Instruction *FirstCast = new CastInst(SI-getOperand(0), NewTy, - SI-getOperand(0)-getName()); - Value *InV = InsertNewInstBefore(FirstCast, I); - Instruction *NewShift = new ShiftInst(Instruction::Shr, FirstCast, + Value *InV = InsertCastBefore(SI-getOperand(0), NewTy, I); + Instruction *NewShift = new
[llvm-commits] CVS: llvm/include/llvm/LinkTimeOptimizer.h
Changes in directory llvm/include/llvm: LinkTimeOptimizer.h updated: 1.11 - 1.12 --- Log message: Save temp. bc files when saveTemps flag is true. Use final output file name supplied by linker to construct temp bc file names. Remove tabs. --- Diffs of the changes: (+7 -4) LinkTimeOptimizer.h | 11 +++ 1 files changed, 7 insertions(+), 4 deletions(-) Index: llvm/include/llvm/LinkTimeOptimizer.h diff -u llvm/include/llvm/LinkTimeOptimizer.h:1.11 llvm/include/llvm/LinkTimeOptimizer.h:1.12 --- llvm/include/llvm/LinkTimeOptimizer.h:1.11 Wed Oct 25 13:10:07 2006 +++ llvm/include/llvm/LinkTimeOptimizer.h Thu Oct 26 15:46:22 2006 @@ -91,8 +91,9 @@ NameToSymbolMap , std::setstd::string ) = 0; virtual enum LTOStatus optimizeModules(const std::string , - std::vectorconst char* , - std::string ) = 0; + std::vectorconst char* , + std::string , bool, + const char *) = 0; virtual void getTargetTriple(const std::string , std::string ) = 0; virtual void removeModule (const std::string InputFilename) = 0; virtual ~LinkTimeOptimizer() = 0; @@ -113,8 +114,10 @@ std::setstd::string references); enum LTOStatus optimizeModules(const std::string OutputFilename, std::vectorconst char* exportList, - std::string targetTriple); -void getTargetTriple(const std::string InputFilename, std::string targetTriple); + std::string targetTriple, bool saveTemps, + const char *); +void getTargetTriple(const std::string InputFilename, + std::string targetTriple); void removeModule (const std::string InputFilename); // Constructors and destructors ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/tools/lto/lto.cpp
Changes in directory llvm/tools/lto: lto.cpp updated: 1.24 - 1.25 --- Log message: Save temp. bc files when saveTemps flag is true. Use final output file name supplied by linker to construct temp bc file names. Remove tabs. --- Diffs of the changes: (+24 -11) lto.cpp | 35 --- 1 files changed, 24 insertions(+), 11 deletions(-) Index: llvm/tools/lto/lto.cpp diff -u llvm/tools/lto/lto.cpp:1.24 llvm/tools/lto/lto.cpp:1.25 --- llvm/tools/lto/lto.cpp:1.24 Wed Oct 25 13:10:07 2006 +++ llvm/tools/lto/lto.cpp Thu Oct 26 15:46:22 2006 @@ -129,7 +129,7 @@ /// set corresponding target triplet string. void LTO::getTargetTriple(const std::string InputFilename, - std::string targetTriple) + std::string targetTriple) { Module *m = getModule(InputFilename); if (m) @@ -142,8 +142,8 @@ /// Return LTO_READ_SUCCESS if there is no error. enum LTOStatus LTO::readLLVMObjectFile(const std::string InputFilename, - NameToSymbolMap symbols, - std::setstd::string references) +NameToSymbolMap symbols, +std::setstd::string references) { Module *m = getModule(InputFilename); if (!m) @@ -316,7 +316,7 @@ CodeGenPasses-add(new TargetData(*Target-getTargetData())); Target-addPassesToEmitFile(*CodeGenPasses, Out, TargetMachine::AssemblyFile, -true); + true); // Run our queue of passes all at once now, efficiently. Passes.run(*M); @@ -337,8 +337,10 @@ /// Return appropriate LTOStatus. enum LTOStatus LTO::optimizeModules(const std::string OutputFilename, - std::vectorconst char * exportList, - std::string targetTriple) + std::vectorconst char * exportList, + std::string targetTriple, + bool saveTemps, + const char *FinalOutputFilename) { if (modules.empty()) return LTO_NO_WORK; @@ -352,11 +354,15 @@ if (theLinker.LinkModules(bigOne, modules[i], errMsg)) return LTO_MODULE_MERGE_FAILURE; -#if 0 - // Enable this when -save-temps is used - std::ofstream Out(big.bc, io_mode); - WriteBytecodeToFile(bigOne, Out, true); -#endif + sys::Path FinalOutputPath(FinalOutputFilename); + FinalOutputPath.eraseSuffix(); + + if (saveTemps) { +std::string tempFileName(FinalOutputPath.c_str()); +tempFileName += 0.bc; +std::ofstream Out(tempFileName.c_str(), io_mode); +WriteBytecodeToFile(bigOne, Out, true); + } // Strip leading underscore because it was added to match names // seen by linker. @@ -404,6 +410,13 @@ return status; } + if (saveTemps) { +std::string tempFileName(FinalOutputPath.c_str()); +tempFileName += 1.bc; +std::ofstream Out(tempFileName.c_str(), io_mode); +WriteBytecodeToFile(bigOne, Out, true); + } + targetTriple = bigOne-getTargetTriple(); // Run GCC to assemble and link the program into native code. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp
Changes in directory llvm/lib/VMCore: Constants.cpp updated: 1.167 - 1.168 --- Log message: Speed up isCString() --- Diffs of the changes: (+14 -4) Constants.cpp | 18 ++ 1 files changed, 14 insertions(+), 4 deletions(-) Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.167 llvm/lib/VMCore/Constants.cpp:1.168 --- llvm/lib/VMCore/Constants.cpp:1.167 Thu Oct 26 14:15:05 2006 +++ llvm/lib/VMCore/Constants.cpp Thu Oct 26 16:48:03 2006 @@ -1077,11 +1077,21 @@ /// isString) and it ends in a null byte \0 and does not contains any other /// null bytes except its terminator. bool ConstantArray::isCString() const { - if (!isString()) return false; - // This is safe because a ConstantArray cannot be a zero array. - for (unsigned i = 0, e = getNumOperands()-1; i != e; ++i) -if (castConstantInt(getOperand(i))-getZExtValue() == 0) + // Check the element type for sbyte or ubyte... + if (getType()-getElementType() != Type::UByteTy + getType()-getElementType() != Type::SByteTy) +return false; + Constant *Zero = Constant::getNullValue(getOperand(0)-getType()); + // Last element must be a null. + if (getOperand(getNumOperands()-1) != Zero) +return false; + // Other elements must be non-null integers. + for (unsigned i = 0, e = getNumOperands()-1; i != e; ++i) { +if (!isaConstantInt(getOperand(i))) return false; +if (getOperand(i) == Zero) + return false; + } return true; } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Changes in directory llvm/lib/CodeGen/SelectionDAG: SelectionDAG.cpp updated: 1.355 - 1.356 --- Log message: getPreIndexedLoad - getIndexedLoad. --- Diffs of the changes: (+7 -21) SelectionDAG.cpp | 28 +++- 1 files changed, 7 insertions(+), 21 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.355 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.356 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.355Tue Oct 17 16:47:13 2006 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Thu Oct 26 16:53:40 2006 @@ -1447,28 +1447,14 @@ return SDOperand(N, 0); } -SDOperand SelectionDAG::getPreIndexedLoad(SDOperand OrigLoad, SDOperand Base) { +SDOperand SelectionDAG::getIndexedLoad(SDOperand OrigLoad, SDOperand Base, + SDOperand Offset, ISD::MemOpAddrMode AM){ LoadSDNode *LD = castLoadSDNode(OrigLoad); - SDOperand Ptr = LD-getBasePtr(); - MVT::ValueType PtrVT = Ptr.getValueType(); - unsigned Opc = Ptr.getOpcode(); - SDOperand Offset = LD-getOffset(); - assert(Offset.getOpcode() == ISD::UNDEF); - assert((Opc == ISD::ADD || Opc == ISD::SUB) - Load address must be base +/- offset!); - ISD::MemOpAddrMode AM = (Opc == ISD::ADD) ? ISD::PRE_INC : ISD::PRE_DEC; - if (Ptr.getOperand(0) == Base) { -Offset = Ptr.getOperand(1); -Ptr = Ptr.getOperand(0); - } else { -assert(Ptr.getOperand(1) == Base); -Offset = Ptr.getOperand(0); -Ptr = Ptr.getOperand(1); - } - + assert(LD-getOffset().getOpcode() == ISD::UNDEF + Load is already a indexed load!); MVT::ValueType VT = OrigLoad.getValueType(); - SDVTList VTs = getVTList(VT, PtrVT, MVT::Other); - SelectionDAGCSEMap::NodeID ID(ISD::LOAD, VTs, LD-getChain(), Ptr, Offset); + SDVTList VTs = getVTList(VT, Base.getValueType(), MVT::Other); + SelectionDAGCSEMap::NodeID ID(ISD::LOAD, VTs, LD-getChain(), Base, Offset); ID.AddInteger(AM); ID.AddInteger(LD-getExtensionType()); ID.AddInteger(LD-getLoadedVT()); @@ -1479,7 +1465,7 @@ void *IP = 0; if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP)) return SDOperand(E, 0); - SDNode *N = new LoadSDNode(LD-getChain(), Ptr, Offset, AM, + SDNode *N = new LoadSDNode(LD-getChain(), Base, Offset, AM, LD-getExtensionType(), LD-getLoadedVT(), LD-getSrcValue(), LD-getSrcValueOffset(), LD-getAlignment(), LD-isVolatile()); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/CodeGen/SelectionDAG.h SelectionDAGNodes.h
Changes in directory llvm/include/llvm/CodeGen: SelectionDAG.h updated: 1.139 - 1.140 SelectionDAGNodes.h updated: 1.155 - 1.156 --- Log message: Indexed load / store changes. --- Diffs of the changes: (+18 -18) SelectionDAG.h |3 ++- SelectionDAGNodes.h | 33 - 2 files changed, 18 insertions(+), 18 deletions(-) Index: llvm/include/llvm/CodeGen/SelectionDAG.h diff -u llvm/include/llvm/CodeGen/SelectionDAG.h:1.139 llvm/include/llvm/CodeGen/SelectionDAG.h:1.140 --- llvm/include/llvm/CodeGen/SelectionDAG.h:1.139 Tue Oct 17 16:12:56 2006 +++ llvm/include/llvm/CodeGen/SelectionDAG.hThu Oct 26 16:52:23 2006 @@ -314,7 +314,8 @@ SDOperand getExtLoad(ISD::LoadExtType ExtType, MVT::ValueType VT, SDOperand Chain, SDOperand Ptr, const Value *SV, int SVOffset, MVT::ValueType EVT, bool isVolatile=false); - SDOperand getPreIndexedLoad(SDOperand OrigLoad, SDOperand Base); + SDOperand getIndexedLoad(SDOperand OrigLoad, SDOperand Base, + SDOperand Offset, ISD::MemOpAddrMode AM); SDOperand getVecLoad(unsigned Count, MVT::ValueType VT, SDOperand Chain, SDOperand Ptr, SDOperand SV); Index: llvm/include/llvm/CodeGen/SelectionDAGNodes.h diff -u llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.155 llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.156 --- llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.155 Tue Oct 17 16:12:56 2006 +++ llvm/include/llvm/CodeGen/SelectionDAGNodes.h Thu Oct 26 16:52:24 2006 @@ -370,9 +370,10 @@ // operations. FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, -// Other operators. LOAD and STORE have token chains as their first -// operand, then the same operands as an LLVM load/store instruction, then a -// SRCVALUE node that provides alias analysis information. +// LOAD and STORE have token chains as their first operand, then the same +// operands as an LLVM load/store instruction, then an offset node that +// is added / subtracted from the base pointer to form the address (for +// indexed memory ops). LOAD, STORE, // Abstract vector version of LOAD. VLOAD has a constant element count as @@ -529,8 +530,8 @@ /// load); an unindexed store does not produces a value. /// /// PRE_INC Similar to the unindexed mode where the effective address is - /// PRE_DEC the result of computation of the base pointer. However, it - /// considers the computation as being folded into the load / + /// PRE_DEC the value of the base pointer add / subtract the offset. + /// It considers the computation as being folded into the load / /// store operation (i.e. the load / store does the address /// computation as well as performing the memory transaction). /// The base operand is always undefined. In addition to @@ -540,12 +541,12 @@ /// of the address computation). /// /// POST_INC The effective address is the value of the base pointer. The - /// POST_DEC value of the offset operand is then added to the base after - /// memory transaction. In addition to producing a chain, - /// post-indexed load produces two values (the result of the load - /// and the result of the base + offset computation); a - /// post-indexed store produces one value (the the result of the - /// base + offset computation). + /// POST_DEC value of the offset operand is then added to / subtracted + /// from the base after memory transaction. In addition to + /// producing a chain, post-indexed load produces two values + /// (the result of the load and the result of the base +/- offset + /// computation); a post-indexed store produces one value (the + /// the result of the base +/- offset computation). /// enum MemOpAddrMode { UNINDEXED = 0, @@ -1408,9 +1409,8 @@ : SDNode(ISD::LOAD, Chain, Ptr, Off), AddrMode(AM), ExtType(ETy), LoadedVT(LVT), SrcValue(SV), SVOffset(O), Alignment(Align), IsVolatile(Vol) { -assert((Off.getOpcode() == ISD::UNDEF || -AddrMode == ISD::POST_INC || AddrMode == ISD::POST_DEC) - Only post-indexed load has a non-undef offset operand); +assert((Off.getOpcode() == ISD::UNDEF || AddrMode != ISD::UNINDEXED) + Only indexed load has a non-undef offset operand); } public: @@ -1462,9 +1462,8 @@ : SDNode(ISD::STORE, Chain, Value, Ptr, Off), AddrMode(AM), IsTruncStore(isTrunc), StoredVT(SVT), SrcValue(SV), SVOffset(O), Alignment(Align), IsVolatile(Vol) { -assert((Off.getOpcode() == ISD::UNDEF || -AddrMode == ISD::POST_INC || AddrMode == ISD::POST_DEC) - Only post-indexed store has a non-undef offset
[llvm-commits] patch for cfstrings
This improves support for the darwin-specific -fconstant-cfstrings option: Index: darwin.c === --- darwin.c(revision 119244) +++ darwin.c(working copy) @@ -1379,8 +1379,28 @@ machopic_select_section (tree exp, int r /* APPLE LOCAL begin LLVM */ #ifdef ENABLE_LLVM const char *darwin_objc_llvm_implicit_target_global_var_section(tree decl) { + const char *name; + + if (TREE_CODE(decl) == CONST_DECL) { +extern int flag_next_runtime; +tree typename = TYPE_NAME(TREE_TYPE(decl)); +if (TREE_CODE(typename) == TYPE_DECL) + typename = DECL_NAME(typename); + +if (!strcmp(IDENTIFIER_POINTER(typename), __builtin_ObjCString)) { + if (flag_next_runtime) +return __OBJC,__cstring_object,regular,no_dead_strip; + else +return __OBJC,__string_object,no_dead_strip; +} else if (!strcmp(IDENTIFIER_POINTER(typename), __builtin_CFString)) { + return __DATA,__cfstring; +} else { + return 0; +} + } + /* Get a pointer to the name, past the L_OBJC_ prefix. */ - const char *name = IDENTIFIER_POINTER (DECL_NAME (decl))+7; + name = IDENTIFIER_POINTER (DECL_NAME (decl))+7; if (!strncmp (name, CLASS_METHODS_, 14)) return __OBJC,__cls_meth, regular, no_dead_strip; Index: darwin.h === --- darwin.h(revision 119244) +++ darwin.h(working copy) @@ -1552,11 +1552,12 @@ void add_framework_path (char *); * For darwin, we have to handle all of the funny objc sections here. Note that * doing this by name is very ugly. */ -#define LLVM_IMPLICIT_TARGET_GLOBAL_VAR_SECTION(decl) \ - ((DECL_NAME (decl) \ - TREE_CODE (DECL_NAME (decl)) == IDENTIFIER_NODE\ - IDENTIFIER_POINTER (DECL_NAME (decl)) \ - !strncmp (IDENTIFIER_POINTER (DECL_NAME (decl)), L_OBJC_, 7)) ? \ +#define LLVM_IMPLICIT_TARGET_GLOBAL_VAR_SECTION(decl) \ + (((DECL_NAME (decl) \ +TREE_CODE (DECL_NAME (decl)) == IDENTIFIER_NODE \ +IDENTIFIER_POINTER (DECL_NAME (decl)) \ +!strncmp (IDENTIFIER_POINTER (DECL_NAME (decl)), L_OBJC_, 7)) || \ + TREE_CODE(decl) == CONST_DECL) ? \ darwin_objc_llvm_implicit_target_global_var_section(decl) : 0) const char *darwin_objc_llvm_implicit_target_global_var_section(tree); -Chris___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp PPCTargetAsmInfo.cpp
Changes in directory llvm/lib/Target/PowerPC: PPCAsmPrinter.cpp updated: 1.202 - 1.203 PPCTargetAsmInfo.cpp updated: 1.7 - 1.8 --- Log message: Place cstrings in .cstring section. --- Diffs of the changes: (+9 -0) PPCAsmPrinter.cpp|8 PPCTargetAsmInfo.cpp |1 + 2 files changed, 9 insertions(+) Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.202 llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.203 --- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.202 Tue Oct 24 15:32:14 2006 +++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp Thu Oct 26 16:48:57 2006 @@ -548,6 +548,14 @@ O \t.globl name \n; // FALL THROUGH case GlobalValue::InternalLinkage: +if (TAI-getCStringSection()) { + const ConstantArray *CVA = dyn_castConstantArray(C); + if (CVA CVA-isCString()) { +SwitchToDataSection(TAI-getCStringSection(), I); +break; + } +} + SwitchToDataSection(\t.data, I); break; default: Index: llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp diff -u llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp:1.7 llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp:1.8 --- llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp:1.7Tue Oct 17 06:30:57 2006 +++ llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cppThu Oct 26 16:48:57 2006 @@ -28,6 +28,7 @@ AlignmentIsInBytes = false; ConstantPoolSection = \t.const\t; JumpTableDataSection = .const; + CStringSection = \t.cstring; LCOMMDirective = \t.lcomm\t; StaticCtorsSection = .mod_init_func; StaticDtorsSection = .mod_term_func; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/test/Regression/CodeGen/ARM/alloca.ll
Changes in directory llvm/test/Regression/CodeGen/ARM: alloca.ll updated: 1.1 - 1.2 --- Log message: Add a run line to this test. --- Diffs of the changes: (+1 -0) alloca.ll |1 + 1 files changed, 1 insertion(+) Index: llvm/test/Regression/CodeGen/ARM/alloca.ll diff -u llvm/test/Regression/CodeGen/ARM/alloca.ll:1.1 llvm/test/Regression/CodeGen/ARM/alloca.ll:1.2 --- llvm/test/Regression/CodeGen/ARM/alloca.ll:1.1 Thu Oct 26 08:31:26 2006 +++ llvm/test/Regression/CodeGen/ARM/alloca.ll Fri Oct 27 00:30:23 2006 @@ -1,3 +1,4 @@ +; RUN: llvm-as %s | llc -march=arm void %f(uint %a) { entry: %tmp1032 = alloca ubyte, uint %a ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits