[llvm-commits] [SignlessTypes] CVS: llvm/include/llvm/Constants.h
Changes in directory llvm/include/llvm: Constants.h updated: 1.88.2.8 -> 1.88.2.9 --- Log message: --- Diffs of the changes: (+1 -1) Constants.h |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/include/llvm/Constants.h diff -u llvm/include/llvm/Constants.h:1.88.2.8 llvm/include/llvm/Constants.h:1.88.2.9 --- llvm/include/llvm/Constants.h:1.88.2.8 Mon Oct 23 13:13:26 2006 +++ llvm/include/llvm/Constants.h Sun Oct 29 01:35:48 2006 @@ -547,7 +547,6 @@ static Constant *getUDiv(Constant *C1, Constant *C2); static Constant *getSDiv(Constant *C1, Constant *C2); static Constant *getFDiv(Constant *C1, Constant *C2); - static Constant *getFRem(Constant *C1, Constant *C2); static Constant *getAnd(Constant *C1, Constant *C2); static Constant *getOr(Constant *C1, Constant *C2); static Constant *getXor(Constant *C1, Constant *C2); @@ -564,6 +563,7 @@ static Constant *getSShr(Constant *C1, Constant *C2); // signed shr static Constant *getURem(Constant *C1, Constant *C2); // unsgied rem static Constant *getSRem(Constant *C1, Constant *C2); // signed rem + static Constant *getFRem(Constant *C1, Constant *C2); /// Getelementptr form. std::vector is only accepted for convenience: /// all elements must be Constant's. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [SignlessTypes] CVS: llvm/lib/VMCore/ConstantFolding.cpp Constants.cpp Instruction.cpp
Changes in directory llvm/lib/VMCore: ConstantFolding.cpp updated: 1.93.2.9 -> 1.93.2.10 Constants.cpp updated: 1.163.2.10 -> 1.163.2.11 Instruction.cpp updated: 1.53.2.5 -> 1.53.2.6 --- Log message: --- Diffs of the changes: (+15 -15) ConstantFolding.cpp | 20 ++-- Constants.cpp |6 +++--- Instruction.cpp |4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) Index: llvm/lib/VMCore/ConstantFolding.cpp diff -u llvm/lib/VMCore/ConstantFolding.cpp:1.93.2.9 llvm/lib/VMCore/ConstantFolding.cpp:1.93.2.10 --- llvm/lib/VMCore/ConstantFolding.cpp:1.93.2.9Wed Oct 25 20:58:05 2006 +++ llvm/lib/VMCore/ConstantFolding.cpp Sun Oct 29 01:35:49 2006 @@ -116,15 +116,15 @@ 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 *urem(const Constant *V1, const Constant *V2) const { return SubClassName::URem((const ArgType *)V1, (const ArgType *)V2); } virtual Constant *srem(const Constant *V1, const Constant *V2) const { return SubClassName::SRem((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 *frem(const Constant *V1, const Constant *V2) const { return SubClassName::FRem((const ArgType *)V1, (const ArgType *)V2); } @@ -199,6 +199,7 @@ static Constant *Mul(const ArgType *V1, const ArgType *V2) { return 0; } static Constant *URem(const ArgType *V1, const ArgType *V2) { return 0; } static Constant *SRem(const ArgType *V1, const ArgType *V2) { return 0; } + static Constant *FRem(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; } @@ -207,7 +208,6 @@ 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 *FRem(const ArgType *V1, const ArgType *V2) { return 0; } static Constant *LessThan(const ArgType *V1, const ArgType *V2) { return 0; } @@ -399,15 +399,15 @@ static Constant *SDiv(const ConstantPacked *V1, const ConstantPacked *V2) { return EvalVectorOp(V1, V2, ConstantExpr::getSDiv); } + static Constant *FDiv(const ConstantPacked *V1, const ConstantPacked *V2) { +return EvalVectorOp(V1, V2, ConstantExpr::getFDiv); + } static Constant *URem(const ConstantPacked *V1, const ConstantPacked *V2) { return EvalVectorOp(V1, V2, ConstantExpr::getURem); } static Constant *SRem(const ConstantPacked *V1, const ConstantPacked *V2) { return EvalVectorOp(V1, V2, ConstantExpr::getSRem); } - static Constant *FDiv(const ConstantPacked *V1, const ConstantPacked *V2) { -return EvalVectorOp(V1, V2, ConstantExpr::getFDiv); - } static Constant *FRem(const ConstantPacked *V1, const ConstantPacked *V2) { return EvalVectorOp(V1, V2, ConstantExpr::getFRem); } @@ -1277,10 +1277,10 @@ case Instruction::Mul: C = ConstRules::get(V1, V2).mul(V1, V2); break; case Instruction::URem:C = ConstRules::get(V1, V2).urem(V1, V2); break; case Instruction::SRem:C = ConstRules::get(V1, V2).srem(V1, V2); break; + case Instruction::FRem:C = ConstRules::get(V1, V2).frem(V1, V2); break; case Instruction::UDiv:C = ConstRules::get(V1, V2).udiv(V1, V2); break; case Instruction::SDiv:C = ConstRules::get(V1, V2).sdiv(V1, V2); break; case Instruction::FDiv:C = ConstRules::get(V1, V2).fdiv(V1, V2); break; - case Instruction::FRem:C = ConstRules::get(V1, V2).frem(V1, V2); break; case Instruction::And: C = ConstRules::get(V1, V2).op_and(V1, V2); break; case Instruction::Or: C = ConstRules::get(V1, V2).op_or (V1, V2); break; case Instruction::Xor: C = ConstRules::get(V1, V2).op_xor(V1, V2); break; @@ -1364,10 +1364,10 @@ return Constant::getNullValue(V1->getType()); case Instruction::URem: case Instruction::SRem: +case Instruction::FRem: case Instruction::UDiv: case Instruction::SDiv: case Instruction::FDiv: -case Instruction::FRem: if (!isa(V2)) // undef/X -> 0 return Constant::getNullValue(V1->getType()); return const_cast(V2);// X/undef -> undef @@ -1482,10 +1482,10 @@ case Instruction::Sub: case Instruction::URem: case Instruction::SRem: +case Instruction::FRem: case Instruction::SDiv: cas
[llvm-commits] [SignlessTypes] CVS: llvm/include/llvm/Support/PatternMatch.h
Changes in directory llvm/include/llvm/Support: PatternMatch.h updated: 1.9.2.3 -> 1.9.2.4 --- Log message: --- Diffs of the changes: (+6 -5) PatternMatch.h | 11 ++- 1 files changed, 6 insertions(+), 5 deletions(-) Index: llvm/include/llvm/Support/PatternMatch.h diff -u llvm/include/llvm/Support/PatternMatch.h:1.9.2.3 llvm/include/llvm/Support/PatternMatch.h:1.9.2.4 --- llvm/include/llvm/Support/PatternMatch.h:1.9.2.3Mon Oct 23 13:13:26 2006 +++ llvm/include/llvm/Support/PatternMatch.hSun Oct 29 01:35:49 2006 @@ -123,6 +123,12 @@ return BinaryOp_match(L, R); } +template +inline BinaryOp_match m_FDiv(const LHS &L, +const RHS &R) { + return BinaryOp_match(L, R); +} + // SignlessType Revision: here we replace m_Rem with m_URem and add m_SRem // for SRem which is signed Rem. template @@ -136,11 +142,6 @@ const RHS &R) { return BinaryOp_match(L, R); } -template -inline BinaryOp_match m_FDiv(const LHS &L, -const RHS &R) { - return BinaryOp_match(L, R); -} template inline BinaryOp_match m_FRem(const LHS &L, ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [SignlessTypes] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
Changes in directory llvm/lib/ExecutionEngine/Interpreter: Execution.cpp updated: 1.139.6.5 -> 1.139.6.6 --- Log message: --- Diffs of the changes: (+51 -14) Execution.cpp | 65 +- 1 files changed, 51 insertions(+), 14 deletions(-) Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.139.6.5 llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.139.6.6 --- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.139.6.5Wed Oct 25 20:58:05 2006 +++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp Sun Oct 29 01:35:49 2006 @@ -40,7 +40,11 @@ const Type *Ty); static GenericValue executeMulInst(GenericValue Src1, GenericValue Src2, const Type *Ty); -static GenericValue executeRemInst(GenericValue Src1, GenericValue Src2, +static GenericValue executeURemInst(GenericValue Src1, GenericValue Src2, + const Type *Ty); +static GenericValue executeSRemInst(GenericValue Src1, GenericValue Src2, + const Type *Ty); +static GenericValue executeFRemInst(GenericValue Src1, GenericValue Src2, const Type *Ty); static GenericValue executeUDivInst(GenericValue Src1, GenericValue Src2, const Type *Ty); @@ -106,10 +110,17 @@ getOperandValue(CE->getOperand(1), SF), CE->getOperand(0)->getType()); case Instruction::URem: +return executeURemInst(getOperandValue(CE->getOperand(0), SF), + getOperandValue(CE->getOperand(1), SF), + CE->getOperand(0)->getType()); case Instruction::SRem: -return executeRemInst(getOperandValue(CE->getOperand(0), SF), - getOperandValue(CE->getOperand(1), SF), - CE->getOperand(0)->getType()); +return executeSRemInst(getOperandValue(CE->getOperand(0), SF), + getOperandValue(CE->getOperand(1), SF), + CE->getOperand(0)->getType()); + case Instruction::FRem: +return executeFRemInst(getOperandValue(CE->getOperand(0), SF), + getOperandValue(CE->getOperand(1), SF), + CE->getOperand(0)->getType()); case Instruction::And: return executeAndInst(getOperandValue(CE->getOperand(0), SF), getOperandValue(CE->getOperand(1), SF), @@ -296,24 +307,50 @@ IMPLEMENT_BINARY_OPERATOR(/, Float); IMPLEMENT_BINARY_OPERATOR(/, Double); default: -std::cout << "Unhandled type for Div instruction: " << *Ty << "\n"; +std::cout << "Unhandled type for FDiv instruction: " << *Ty << "\n"; abort(); } return Dest; } -static GenericValue executeRemInst(GenericValue Src1, GenericValue Src2, - const Type *Ty) { +static GenericValue executeURemInst(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 URem instruction: " << *Ty << "\n"; +abort(); + } + return Dest; +} + +static GenericValue executeSRemInst(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 SRem instruction: " << *Ty << "\n"; +abort(); + } + return Dest; +} + +static GenericValue executeFRemInst(GenericValue Src1, GenericValue Src2, +const Type *Ty) { + GenericValue Dest; + switch (Ty->getTypeID()) { case Type::FloatTyID: Dest.FloatVal = fmod(Src1.FloatVal, Src2.FloatVal); break; @@ -321,7 +358,7 @@ Dest.DoubleVal = fmod(Src1.DoubleVal, Src2.DoubleVal); break; default: -std::cout << "Unhandled type for Rem instruction: " << *Ty << "\n"; +std::cout << "Unhandled type for FRem instruction: " << *Ty << "\n"; abort(); } return Dest; @@ -543,9 +580,9 @@ case Instruction::Add: R = executeAddInst (Src1, Src2, Ty); break; case Instruction::Sub: R = executeSubInst (Src1, Src2, Ty); break; case Instruction::Mul
[llvm-commits] [SignlessTypes] CVS: llvm/lib/Target/CBackend/Writer.cpp
Changes in directory llvm/lib/Target/CBackend: Writer.cpp updated: 1.272.2.7 -> 1.272.2.8 --- Log message: --- Diffs of the changes: (+13 -5) Writer.cpp | 18 +- 1 files changed, 13 insertions(+), 5 deletions(-) Index: llvm/lib/Target/CBackend/Writer.cpp diff -u llvm/lib/Target/CBackend/Writer.cpp:1.272.2.7 llvm/lib/Target/CBackend/Writer.cpp:1.272.2.8 --- llvm/lib/Target/CBackend/Writer.cpp:1.272.2.7 Wed Oct 25 20:58:05 2006 +++ llvm/lib/Target/CBackend/Writer.cpp Sun Oct 29 01:35:49 2006 @@ -592,10 +592,10 @@ case Instruction::Mul: case Instruction::URem: case Instruction::SRem: +case Instruction::FRem: case Instruction::SDiv: case Instruction::UDiv: case Instruction::FDiv: -case Instruction::FRem: case Instruction::And: case Instruction::Or: case Instruction::Xor: @@ -607,6 +607,7 @@ case Instruction::SetGE: case Instruction::Shl: case Instruction::Shr: +{ Out << '('; bool NeedsClosingParens = printConstExprCast(CE); printConstantWithCast(CE->getOperand(0), CE->getOpcode()); @@ -638,6 +639,7 @@ Out << "))"; Out << ')'; return; +} default: std::cerr << "CWriter Error: Unhandled constant expression: " @@ -827,7 +829,9 @@ bool Result = false; const Type* Ty = CE->getOperand(0)->getType(); switch (CE->getOpcode()) { + case Instruction::URem: case Instruction::UDiv: Result = Ty->isSigned(); break; + case Instruction::SRem: case Instruction::SDiv: Result = Ty->isUnsigned(); break; default: break; } @@ -857,6 +861,7 @@ default: // for most instructions, it doesn't matter break; +case Instruction::URem: case Instruction::UDiv: // For UDiv to have unsigned operands if (OpTy->isSigned()) { @@ -864,6 +869,7 @@ shouldCast = true; } break; +case Instruction::SRem: case Instruction::SDiv: if (OpTy->isUnsigned()) { OpTy = OpTy->getSignedVersion(); @@ -921,7 +927,9 @@ bool Result = false; const Type* Ty = I.getOperand(0)->getType(); switch (I.getOpcode()) { + case Instruction::URem: case Instruction::UDiv: Result = Ty->isSigned(); break; + case Instruction::SRem: case Instruction::SDiv: Result = Ty->isUnsigned(); break; default: break; } @@ -951,6 +959,7 @@ default: // for most instructions, it doesn't matter break; +case Instruction::URem: case Instruction::UDiv: // For UDiv to have unsigned operands if (OpTy->isSigned()) { @@ -958,6 +967,7 @@ shouldCast = true; } break; +case Instruction::SRem: case Instruction::SDiv: if (OpTy->isUnsigned()) { OpTy = OpTy->getSignedVersion(); @@ -1776,8 +1786,7 @@ Out << "-("; writeOperand(BinaryOperator::getNegArgument(cast(&I))); Out << ")"; - } else if ((I.getOpcode() == Instruction::URem || - I.getOpcode() == Instruction::SRem) && + } else if (I.getOpcode() == Instruction::FRem && I.getType()->isFloatingPoint()) { // Output a call to fmod/fmodf instead of emitting a%b if (I.getType() == Type::FloatTy) @@ -1804,8 +1813,7 @@ case Instruction::Sub: Out << " - "; break; case Instruction::Mul: Out << '*'; break; case Instruction::URem: -case Instruction::SRem: -case Instruction::FRem: Out << '%'; break; +case Instruction::SRem:Out << '%'; break; case Instruction::UDiv: case Instruction::SDiv: case Instruction::FDiv: Out << '/'; break; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [SignlessTypes] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
Changes in directory llvm/lib/CodeGen/SelectionDAG: SelectionDAGISel.cpp updated: 1.289.2.7 -> 1.289.2.8 --- Log message: --- Diffs of the changes: (+1 -1) SelectionDAGISel.cpp |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.289.2.7 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.289.2.8 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.289.2.7Wed Oct 25 20:58:05 2006 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Sun Oct 29 01:35:49 2006 @@ -517,10 +517,10 @@ } void visitURem(User &I) { visitIntBinary(I, ISD::UREM, 0); } void visitSRem(User &I) { visitIntBinary(I, ISD::SREM, 0); } + void visitFRem(User &I) { visitFPBinary(I, ISD::FREM, 0); } 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 visitFRem(User &I) { visitFPBinary(I, ISD::FREM, 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); } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [SignlessTypes] CVS: llvm/test/Regression/CodeGen/X86/compare_folding.llx
Changes in directory llvm/test/Regression/CodeGen/X86: compare_folding.llx updated: 1.3 -> 1.3.2.1 --- Log message: --- Diffs of the changes: (+4 -4) compare_folding.llx |8 1 files changed, 4 insertions(+), 4 deletions(-) Index: llvm/test/Regression/CodeGen/X86/compare_folding.llx diff -u llvm/test/Regression/CodeGen/X86/compare_folding.llx:1.3 llvm/test/Regression/CodeGen/X86/compare_folding.llx:1.3.2.1 --- llvm/test/Regression/CodeGen/X86/compare_folding.llx:1.3Wed Oct 11 20:42:03 2006 +++ llvm/test/Regression/CodeGen/X86/compare_folding.llxSun Oct 29 01:49:36 2006 @@ -1,8 +1,8 @@ -; RUN: llvm-as < %s | llc -march=x86 | grep movsd | wc -l | grep 1 && -; RUN: llvm-as < %s | llc -march=x86 | grep ucomisd -declare bool %llvm.isunordered(double,double) +; RUN: llvm-as < %s | llc -march=x86 -mcpu=yonah | grep movsd | wc -l | grep 1 && +; RUN: llvm-as < %s | llc -march=x86 -mcpu=yonah | grep ucomisd +declare bool %llvm.isunordered.f64(double,double) bool %test1(double %X, double %Y) { ;; Returns isunordered(X,Y) - %COM = call bool %llvm.isunordered(double %X, double %Y) + %COM = call bool %llvm.isunordered.f64(double %X, double %Y) ret bool %COM } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Support/FoldingSet.cpp
Changes in directory llvm/lib/Support: FoldingSet.cpp updated: 1.6 -> 1.7 --- Log message: Not handling zero length strings. --- Diffs of the changes: (+2 -2) FoldingSet.cpp |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/lib/Support/FoldingSet.cpp diff -u llvm/lib/Support/FoldingSet.cpp:1.6 llvm/lib/Support/FoldingSet.cpp:1.7 --- llvm/lib/Support/FoldingSet.cpp:1.6 Fri Oct 27 14:38:32 2006 +++ llvm/lib/Support/FoldingSet.cpp Sun Oct 29 02:27:07 2006 @@ -61,7 +61,7 @@ Pos = Units * sizeof(unsigned); } else { // Otherwise do it the hard way. -for ( Pos += 4; Pos < Size; Pos += 4) { +for ( Pos += 4; Pos <= Size; Pos += 4) { unsigned V = ((unsigned char)String[Pos - 4] << 24) | ((unsigned char)String[Pos - 3] << 16) | ((unsigned char)String[Pos - 2] << 8) | @@ -77,7 +77,7 @@ case 1: V = (V << 8) | (unsigned char)String[Size - 3]; // Fall thru. case 2: V = (V << 8) | (unsigned char)String[Size - 2]; // Fall thru. case 3: V = (V << 8) | (unsigned char)String[Size - 1]; break; - case 0: return; // Nothing left. + default: return; // Nothing left. } Bits.push_back(V); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Support/FoldingSet.cpp
Changes in directory llvm/lib/Support: FoldingSet.cpp updated: 1.7 -> 1.8 --- Log message: Try again. --- Diffs of the changes: (+4 -1) FoldingSet.cpp |5 - 1 files changed, 4 insertions(+), 1 deletion(-) Index: llvm/lib/Support/FoldingSet.cpp diff -u llvm/lib/Support/FoldingSet.cpp:1.7 llvm/lib/Support/FoldingSet.cpp:1.8 --- llvm/lib/Support/FoldingSet.cpp:1.7 Sun Oct 29 02:27:07 2006 +++ llvm/lib/Support/FoldingSet.cpp Sun Oct 29 03:19:59 2006 @@ -51,6 +51,9 @@ } void FoldingSetImpl::NodeID::AddString(const std::string &String) { unsigned Size = String.size(); + Bits.push_back(Size); + if (!Size) return; + unsigned Units = Size / 4; unsigned Pos = 0; const unsigned *Base = (const unsigned *)String.data(); @@ -58,7 +61,7 @@ // If the string is aligned do a bulk transfer. if (!((intptr_t)Base & 3)) { Bits.append(Base, Base + Units); -Pos = Units * sizeof(unsigned); +Pos = (Units + 1) * 4; } else { // Otherwise do it the hard way. for ( Pos += 4; Pos <= Size; Pos += 4) { ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] llvm-gcc patch
I just committed Anton's patch for PR973. This should greatly improve static ctor/dtor handling on linux. -Chris Index: crtstuff.c === --- crtstuff.c (revision 119298) +++ crtstuff.c (working copy) @@ -51,9 +51,6 @@ This file must be compiled with gcc. */ -/* APPLE LOCAL begin LLVM */ -#ifndef __llvm__ /* FIXME: add inline asm support */ - /* It is incorrect to include config.h here, because this file is being compiled for the target, and hence definitions concerning only the host do not apply. */ @@ -69,6 +66,13 @@ #include "tm.h" #include "unwind-dw2-fde.h" +/* APPLE LOCAL begin LLVM */ +#ifdef __llvm__ + /* FIXME: Remove when external weak linkage will be alive. */ + #undef JCR_SECTION_NAME +#endif +/* APPLE LOCAL end LLVM */ + #ifndef FORCE_CODE_SECTION_ALIGN # define FORCE_CODE_SECTION_ALIGN #endif @@ -177,11 +181,25 @@ static func_ptr force_to_data[1] __attribute__ ((__unused__)) = { }; asm (CTORS_SECTION_ASM_OP); STATIC func_ptr __CTOR_LIST__[1] +/* APPLE LOCAL begin LLVM */ +#ifdef __llvm__ +/* FIXME: Remove when external weak linkage will be alive. */ + __attribute__ ((__used__, aligned(sizeof(func_ptr +#else __attribute__ ((__unused__, aligned(sizeof(func_ptr +#endif +/* APPLE LOCAL end LLVM */ = { (func_ptr) (-1) }; #else STATIC func_ptr __CTOR_LIST__[1] - __attribute__ ((__unused__, section(".ctors"), aligned(sizeof (func_ptr +/* APPLE LOCAL begin LLVM */ +#ifdef __llvm__ +/* FIXME: Remove when external weak linkage will be alive. */ + __attribute__ ((__used__, section(".ctors"), aligned(sizeof (func_ptr +#else + __attribute__ ((__unused__, section(".ctors"), aligned(sizeof (func_ptr +#endif +/* APPLE LOCAL end LLVM */ = { (func_ptr) (-1) }; #endif /* __CTOR_LIST__ alternatives */ @@ -449,11 +467,25 @@ #elif defined(DTORS_SECTION_ASM_OP) asm (DTORS_SECTION_ASM_OP); STATIC func_ptr __DTOR_END__[1] +/* APPLE LOCAL begin LLVM */ +#ifdef __llvm__ +/* FIXME: Remove when external weak linkage will be alive. */ +__attribute__ ((__used__, aligned(sizeof(func_ptr +#else __attribute__ ((unused, aligned(sizeof(func_ptr +#endif +/* APPLE LOCAL end LLVM */ = { (func_ptr) 0 }; #else STATIC func_ptr __DTOR_END__[1] - __attribute__((unused, section(".dtors"), aligned(sizeof(func_ptr +/* APPLE LOCAL begin LLVM */ +#ifdef __llvm__ +/* FIXME: Remove when external weak linkage will be alive. */ + __attribute__((__used__, section(".dtors"), aligned(sizeof (func_ptr +#else + __attribute__((unused, section(".dtors"), aligned(sizeof(func_ptr +#endif +/* APPLE LOCAL end LLVM */ = { (func_ptr) 0 }; #endif @@ -558,5 +590,3 @@ #error "One of CRT_BEGIN or CRT_END must be defined." #endif -#endif -/* APPLE LOCAL end LLVM */ ___ 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.305 -> 1.306 --- Log message: Fix a load folding issue that Evan noticed: there is no need to export values used by comparisons in the main block. --- Diffs of the changes: (+17 -7) SelectionDAGISel.cpp | 24 +--- 1 files changed, 17 insertions(+), 7 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.305 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.306 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.305Sat Oct 28 14:22:10 2006 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Sun Oct 29 12:23:37 2006 @@ -841,12 +841,11 @@ // caseblock. if (BOp && isa(BOp) && // The operands of the setcc have to be in this block. We don't know -// how to export them from some other block. -isExportableFromCurrentBlock(BOp->getOperand(0), BB) && -isExportableFromCurrentBlock(BOp->getOperand(1), BB)) { - ExportFromCurrentBlock(BOp->getOperand(0)); - ExportFromCurrentBlock(BOp->getOperand(1)); - +// how to export them from some other block. If this is the first block +// of the sequence, no exporting is needed. +(CurBB == CurMBB || + (isExportableFromCurrentBlock(BOp->getOperand(0), BB) && + isExportableFromCurrentBlock(BOp->getOperand(1), BB { ISD::CondCode SignCond, UnsCond, FPCond, Condition; switch (BOp->getOpcode()) { default: assert(0 && "Unknown setcc opcode!"); @@ -903,7 +902,6 @@ SelectionDAGISel::CaseBlock CB(ISD::SETEQ, Cond, ConstantBool::getTrue(), TBB, FBB, CurBB); SwitchCases.push_back(CB); -ExportFromCurrentBlock(Cond); return; } @@ -993,6 +991,18 @@ (BOp->getOpcode() == Instruction::And || BOp->getOpcode() == Instruction::Or)) { FindMergedConditions(BOp, Succ0MBB, Succ1MBB, CurMBB, BOp->getOpcode()); + + // If the compares in later blocks need to use values not currently + // exported from this block, export them now. This block should always be + // the first entry. + assert(SwitchCases[0].ThisBB == CurMBB && "Unexpected lowering!"); + + for (unsigned i = 1, e = SwitchCases.size(); i != e; ++i) { +ExportFromCurrentBlock(SwitchCases[i].CmpLHS); +ExportFromCurrentBlock(SwitchCases[i].CmpRHS); + } + + // Emit the branch for this block. visitSwitchCase(SwitchCases[0]); SwitchCases.erase(SwitchCases.begin()); return; ___ 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/Generic/2006-10-29-Crash.ll
Changes in directory llvm/test/Regression/CodeGen/Generic: 2006-10-29-Crash.ll added (r1.1) --- Log message: new testcase --- Diffs of the changes: (+21 -0) 2006-10-29-Crash.ll | 21 + 1 files changed, 21 insertions(+) Index: llvm/test/Regression/CodeGen/Generic/2006-10-29-Crash.ll diff -c /dev/null llvm/test/Regression/CodeGen/Generic/2006-10-29-Crash.ll:1.1 *** /dev/null Sun Oct 29 15:01:05 2006 --- llvm/test/Regression/CodeGen/Generic/2006-10-29-Crash.llSun Oct 29 15:00:55 2006 *** *** 0 --- 1,21 + ; RUN: llvm-as < %s | llc + + void %form_component_prediction(int %dy) { + entry: + %tmp7 = and int %dy, 1 ; [#uses=1] + %tmp27 = seteq int %tmp7, 0 ; [#uses=1] + br bool false, label %cond_next30, label %bb115 + + cond_next30: ; preds = %entry + ret void + + bb115:; preds = %entry + %bothcond1 = or bool %tmp27, false ; [#uses=1] + br bool %bothcond1, label %bb228, label %cond_next125 + + cond_next125: ; preds = %bb115 + ret void + + bb228:; preds = %bb115 + ret void + } ___ 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.306 -> 1.307 --- Log message: fix Generic/2006-10-29-Crash.ll --- Diffs of the changes: (+9 -1) SelectionDAGISel.cpp | 10 +- 1 files changed, 9 insertions(+), 1 deletion(-) Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.306 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.307 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.306Sun Oct 29 12:23:37 2006 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Sun Oct 29 15:01:20 2006 @@ -824,6 +824,12 @@ return true; } +static bool InBlock(const Value *V, const BasicBlock *BB) { + if (const Instruction *I = dyn_cast(V)) +return I->getParent() == BB; + return true; +} + /// FindMergedConditions - If Cond is an expression like void SelectionDAGLowering::FindMergedConditions(Value *Cond, MachineBasicBlock *TBB, @@ -834,7 +840,9 @@ BinaryOperator *BOp = dyn_cast(Cond); if (!BOp || (unsigned)BOp->getOpcode() != Opc || !BOp->hasOneUse() || - BOp->getParent() != CurBB->getBasicBlock()) { + BOp->getParent() != CurBB->getBasicBlock() || + !InBlock(BOp->getOperand(0), CurBB->getBasicBlock()) || + !InBlock(BOp->getOperand(1), CurBB->getBasicBlock())) { const BasicBlock *BB = CurBB->getBasicBlock(); // If the leaf of the tree is a setcond inst, merge the condition into the ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/CodeGen/BranchFolding.cpp
Changes in directory llvm/lib/CodeGen: BranchFolding.cpp updated: 1.26 -> 1.27 --- Log message: Make CanFallThrough more intelligent (so it can handle blocks with (e.g.) no successors), and make island block movement more general. This compiles CodeGen/X86/2006-04-27-ISelFoldingBug.ll to: _loadAndRLEsource_no_exit_2E_1_label_2E_0: subl $8, %esp movl %esi, 4(%esp) movl %ebx, (%esp) movl 16(%esp), %eax movl 12(%esp), %ecx LBB1_3: #label.0 movl _last, %edx movl %edx, %esi incl %esi movl %esi, _last movl %ecx, %ebx # TRUNCATE movb %bl, %bl movl _block, %esi movb %bl, 1(%esi,%edx) cmpl %eax, _last jge LBB1_2 #codeRepl5.exitStub LBB1_4: #label.0 cmpl $257, %ecx je LBB1_2 #codeRepl5.exitStub LBB1_1: #label.0.no_exit.1_crit_edge.exitStub movl $1, %eax movl (%esp), %ebx movl 4(%esp), %esi addl $8, %esp ret LBB1_2: #codeRepl5.exitStub xorl %eax, %eax movl (%esp), %ebx movl 4(%esp), %esi addl $8, %esp ret instead of: _loadAndRLEsource_no_exit_2E_1_label_2E_0: subl $8, %esp movl %esi, 4(%esp) movl %ebx, (%esp) movl 16(%esp), %eax movl 12(%esp), %ecx jmp LBB1_3 #label.0 LBB1_1: #label.0.no_exit.1_crit_edge.exitStub movl $1, %eax movl (%esp), %ebx movl 4(%esp), %esi addl $8, %esp ret LBB1_2: #codeRepl5.exitStub xorl %eax, %eax movl (%esp), %ebx movl 4(%esp), %esi addl $8, %esp ret LBB1_3: #label.0 movl _last, %edx movl %edx, %esi incl %esi movl %esi, _last movl %ecx, %ebx # TRUNCATE movb %bl, %bl movl _block, %esi movb %bl, 1(%esi,%edx) cmpl %eax, _last jge LBB1_2 #codeRepl5.exitStub LBB1_4: #label.0 cmpl $257, %ecx jne LBB1_1 #label.0.no_exit.1_crit_edge.exitStub jmp LBB1_2 #codeRepl5.exitStub ... which is much better layout :) --- Diffs of the changes: (+94 -62) BranchFolding.cpp | 156 -- 1 files changed, 94 insertions(+), 62 deletions(-) Index: llvm/lib/CodeGen/BranchFolding.cpp diff -u llvm/lib/CodeGen/BranchFolding.cpp:1.26 llvm/lib/CodeGen/BranchFolding.cpp:1.27 --- llvm/lib/CodeGen/BranchFolding.cpp:1.26 Sat Oct 28 13:34:47 2006 +++ llvm/lib/CodeGen/BranchFolding.cpp Sun Oct 29 15:05:41 2006 @@ -48,6 +48,11 @@ bool OptimizeBranches(MachineFunction &MF); void OptimizeBlock(MachineBasicBlock *MBB); void RemoveDeadBlock(MachineBasicBlock *MBB); + +bool CanFallThrough(MachineBasicBlock *CurBB); +bool CanFallThrough(MachineBasicBlock *CurBB, bool BranchUnAnalyzable, +MachineBasicBlock *TBB, MachineBasicBlock *FBB, +const std::vector &Cond); }; } @@ -443,19 +448,37 @@ } } -/// CanFallThrough - Return true of the specified branch condition can transfer -/// control to FallthroughBlock, the block immediately after the branch. -static bool CanFallThrough(MachineBasicBlock *TBB, - MachineBasicBlock *FBB, - const std::vector &Cond, - MachineFunction::iterator FallthroughBlock) { +/// CanFallThrough - Return true if the specified block (with the specified +/// branch condition) can implicitly transfer control to the block after it by +/// falling off the end of it. This should return false if it can reach the +/// block after it, but it uses an explicit branch to do so (e.g. a table jump). +/// +/// True is a conservative answer. +/// +bool BranchFolder::CanFallThrough(MachineBasicBlock *CurBB, + bool BranchUnAnalyzable, + MachineBasicBlock *TBB, MachineBasicBlock *FBB, + const std::vector &Cond) { + MachineFunction::iterator Fallthrough = CurBB; + ++Fallthrough; + // If FallthroughBlock is off the end of the function, it can't fall through. + if (Fallthrough == CurBB->getParent()->end()) +return false; + + // If FallthroughBlock isn't a successor of CurBB, no fallthrough is possible. + if (!CurBB->isSuccessor(Fallthrough)) +return false; + + // If we couldn't analyze the branch, assume it could fall through. + if (BranchUnAnalyzable) return true; + // If there is no branch, control always falls through. if (TBB == 0) return true; // If there is some explicit branch to the fallthrough block, it can obviously // reach, even though the branch should get folded to fall through implicitly. - if (MachineFunction::iterator(TBB) == FallthroughBlock || - MachineFunction::iterator(FBB) == FallthroughBlock) + if (MachineFunction::iterator(TBB) == Fallthrough || + MachineFunct
[llvm-commits] CVS: llvm/test/Regression/Transforms/SimplifyCFG/2006-10-29-InvokeCrash.ll
Changes in directory llvm/test/Regression/Transforms/SimplifyCFG: 2006-10-29-InvokeCrash.ll added (r1.1) --- Log message: new testcase --- Diffs of the changes: (+652 -0) 2006-10-29-InvokeCrash.ll | 652 ++ 1 files changed, 652 insertions(+) Index: llvm/test/Regression/Transforms/SimplifyCFG/2006-10-29-InvokeCrash.ll diff -c /dev/null llvm/test/Regression/Transforms/SimplifyCFG/2006-10-29-InvokeCrash.ll:1.1 *** /dev/null Sun Oct 29 15:21:06 2006 --- llvm/test/Regression/Transforms/SimplifyCFG/2006-10-29-InvokeCrash.ll Sun Oct 29 15:20:56 2006 *** *** 0 --- 1,652 + ; RUN: llvm-as < %s | opt -simplifycfg -disable-output + + %struct..4._102 = type { %struct.QVectorData* } + %struct..5._125 = type { %struct.QMapData* } + %struct.QAbstractTextDocumentLayout = type { %struct.QObject } + %struct.QBasicAtomic = type { int } + %struct.QFont = type { %struct.QFontPrivate*, uint } + %struct.QFontMetrics = type { %struct.QFontPrivate* } + %struct.QFontPrivate = type opaque + "struct.QFragmentMap" = type { %struct.QFragmentMapData } + %struct.QFragmentMapData = type { "struct.QFragmentMapData::._154", int } + "struct.QFragmentMapData::._154" = type { "struct.QFragmentMapData::Header"* } + "struct.QFragmentMapData::Header" = type { uint, uint, uint, uint, uint, uint, uint, uint } + "struct.QHash" = type { "struct.QHash::._152" } + "struct.QHash::._152" = type { %struct.QHashData* } + %struct.QHashData = type { "struct.QHashData::Node"*, "struct.QHashData::Node"**, %struct.QBasicAtomic, int, int, short, short, int, ubyte } + "struct.QHashData::Node" = type { "struct.QHashData::Node"*, uint } + "struct.QList::._92" = type { %struct.QListData } + "struct.QList >" = type { "struct.QList::._92" } + %struct.QListData = type { "struct.QListData::Data"* } + "struct.QListData::Data" = type { %struct.QBasicAtomic, int, int, int, ubyte, [1 x sbyte*] } + "struct.QMap" = type { %struct..5._125 } + %struct.QMapData = type { "struct.QMapData::Node"*, [12 x "struct.QMapData::Node"*], %struct.QBasicAtomic, int, int, uint, ubyte } + "struct.QMapData::Node" = type { "struct.QMapData::Node"*, [1 x "struct.QMapData::Node"*] } + %struct.QObject = type { int (...)**, %struct.QObjectData* } + %struct.QObjectData = type { int (...)**, %struct.QObject*, %struct.QObject*, "struct.QList >", ubyte, [3 x ubyte], int, int } + %struct.QObjectPrivate = type { %struct.QObjectData, int, %struct.QObject*, "struct.QList >", "struct.QVector", %struct.QString } + %struct.QPaintDevice = type { int (...)**, ushort } + %struct.QPainter = type { %struct.QPainterPrivate* } + %struct.QPainterPrivate = type opaque + %struct.QPointF = type { double, double } + %struct.QPrinter = type { %struct.QPaintDevice, %struct.QPrinterPrivate* } + %struct.QPrinterPrivate = type opaque + %struct.QRectF = type { double, double, double, double } + "struct.QSet" = type { "struct.QHash" } + "struct.QSharedDataPointer" = type { %struct.QTextFormatPrivate* } + %struct.QString = type { "struct.QString::Data"* } + "struct.QString::Data" = type { %struct.QBasicAtomic, int, int, ushort*, ubyte, ubyte, [1 x ushort] } + %struct.QTextBlockFormat = type { %struct.QTextFormat } + %struct.QTextBlockGroup = type { %struct.QAbstractTextDocumentLayout } + %struct.QTextDocumentConfig = type { %struct.QString } + %struct.QTextDocumentPrivate = type { %struct.QObjectPrivate, %struct.QString, "struct.QVector", bool, int, int, bool, int, int, int, int, bool, %struct.QTextFormatCollection, %struct.QTextBlockGroup*, %struct.QAbstractTextDocumentLayout*, "struct.QFragmentMap", "struct.QFragmentMap", int, "struct.QList >", "struct.QList >", "struct.QMap", "struct.QMap", "struct.QMap", %struct.QTextDocumentConfig, bool, bool, %struct.QPointF } + %struct.QTextFormat = type { "struct.QSharedDataPointer", int } + %struct.QTextFormatCollection = type { "struct.QVector", "struct.QVector", "struct.QSet", %struct.QFont } + %struct.QTextFormatPrivate = type opaque + "struct.QVector" = type { %struct..4._102 } + %struct.QVectorData = type { %struct.QBasicAtomic, int, int, ubyte } + + implementation ; Functions: + + void %_ZNK13QTextDocument5printEP8QPrinter(%struct.QAbstractTextDocumentLayout* %this, %struct.QPrinter* %printer) { + entry: + %tmp = alloca %struct.QPointF, align 16 ; <%struct.QPointF*> [#uses=2] + %tmp = alloca %struct.QRectF, align 16 ; <%struct.QRectF*> [#uses=5] + %tmp2 = alloca %struct.QPointF, align 16; <%struct.QPointF*> [#uses=3] + %tmp = alloca %struct.QFontMetrics, align 16; <%struct.QFontMetrics*> [#uses=4] + %tmp = alloca %
[llvm-commits] CVS: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
Changes in directory llvm/lib/Transforms/Utils: SimplifyCFG.cpp updated: 1.101 -> 1.102 --- Log message: Fix SimplifyCFG/2006-10-29-InvokeCrash.ll, a crash compiling QT. --- Diffs of the changes: (+1 -1) SimplifyCFG.cpp |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp diff -u llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.101 llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.102 --- llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.101 Fri Oct 20 02:07:24 2006 +++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp Sun Oct 29 15:21:20 2006 @@ -853,7 +853,7 @@ Instruction *I1 = BB1->begin(), *I2 = BB2->begin(); if (I1->getOpcode() != I2->getOpcode() || !I1->isIdenticalTo(I2) || - isa(I1)) + isa(I1) || isa(I1)) return false; // If we get here, we can hoist at least one instruction. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Support/Allocator.cpp
Changes in directory llvm/lib/Support: Allocator.cpp added (r1.1) --- Log message: Add a new llvm::Allocator abstraction, which will be used by a container I'm about to add. This is similar to, but necessarily different than, the STL allocator class. --- Diffs of the changes: (+106 -0) Allocator.cpp | 106 ++ 1 files changed, 106 insertions(+) Index: llvm/lib/Support/Allocator.cpp diff -c /dev/null llvm/lib/Support/Allocator.cpp:1.1 *** /dev/null Sun Oct 29 16:08:13 2006 --- llvm/lib/Support/Allocator.cpp Sun Oct 29 16:08:03 2006 *** *** 0 --- 1,106 + //===--- Allocator.cpp - Simple memory allocation abstraction -===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by Chris Lattner and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===--===// + // + // This file implements the BumpPtrAllocator interface. + // + //===--===// + + #include "llvm/Support/Allocator.h" + #include + using namespace llvm; + + //===--===// + // MemRegion class implementation + //===--===// + + namespace { + /// MemRegion - This is one chunk of the BumpPtrAllocator. + class MemRegion { + unsigned RegionSize; + MemRegion *Next; + char *NextPtr; + public: + void Init(unsigned size, unsigned Alignment, MemRegion *next) { + RegionSize = size; + Next = next; + NextPtr = (char*)(this+1); + + // Align NextPtr. + NextPtr = (char*)((intptr_t)(NextPtr+Alignment-1) & + ~(intptr_t)(Alignment-1)); + } + + const MemRegion *getNext() const { return Next; } + unsigned getNumBytesAllocated() const { + return NextPtr-(const char*)this; + } + + /// Allocate - Allocate and return at least the specified number of bytes. + /// + void *Allocate(unsigned AllocSize, unsigned Alignment, MemRegion **RegPtr) { + // Round size up to an even multiple of the alignment. + AllocSize = (AllocSize+Alignment-1) & ~(Alignment-1); + + // If there is space in this region, return it. + if (unsigned(NextPtr+AllocSize-(char*)this) <= RegionSize) { + void *Result = NextPtr; + NextPtr += AllocSize; + return Result; + } + + // Otherwise, we have to allocate a new chunk. Create one twice as big as + // this one. + MemRegion *NewRegion = (MemRegion *)malloc(RegionSize*2); + NewRegion->Init(RegionSize*2, Alignment, this); + + // Update the current "first region" pointer to point to the new region. + *RegPtr = NewRegion; + + // Try allocating from it now. + return NewRegion->Allocate(AllocSize, Alignment, RegPtr); + } + + /// Deallocate - Release all memory for this region to the system. + /// + void Deallocate() { + MemRegion *next = Next; + free(this); + if (next) + next->Deallocate(); + } + }; + } + + //===--===// + // BumpPtrAllocator class implementation + //===--===// + + BumpPtrAllocator::BumpPtrAllocator() { + TheMemory = malloc(4096); + ((MemRegion*)TheMemory)->Init(4096, 1, 0); + } + + BumpPtrAllocator::~BumpPtrAllocator() { + ((MemRegion*)TheMemory)->Deallocate(); + } + + void *BumpPtrAllocator::Allocate(unsigned Size, unsigned Align) { + return ((MemRegion*)TheMemory)->Allocate(Size, Align,(MemRegion**)&TheMemory); + } + + void BumpPtrAllocator::PrintStats() const { + unsigned BytesUsed = 0; + unsigned NumRegions = 0; + const MemRegion *R = (MemRegion*)TheMemory; + for (; R; R = R->getNext(), ++NumRegions) + BytesUsed += R->getNumBytesAllocated(); + + std::cerr << "\nNumber of memory regions: " << NumRegions << "\n"; + std::cerr << "Bytes allocated: " << BytesUsed << "\n"; + } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/Support/Allocator.h
Changes in directory llvm/include/llvm/Support: Allocator.h added (r1.1) --- Log message: Add a new llvm::Allocator abstraction, which will be used by a container I'm about to add. This is similar to, but necessarily different than, the STL allocator class. --- Diffs of the changes: (+48 -0) Allocator.h | 48 1 files changed, 48 insertions(+) Index: llvm/include/llvm/Support/Allocator.h diff -c /dev/null llvm/include/llvm/Support/Allocator.h:1.1 *** /dev/null Sun Oct 29 16:08:13 2006 --- llvm/include/llvm/Support/Allocator.h Sun Oct 29 16:08:03 2006 *** *** 0 --- 1,48 + //===--- Allocator.h - Simple memory allocation abstraction -*- C++ -*-===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by Chris Lattner and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===--===// + // + // This file defines the MallocAllocator and BumpPtrAllocator interfaces. + // + //===--===// + + #ifndef LLVM_SUPPORT_ALLOCATOR_H + #define LLVM_SUPPORT_ALLOCATOR_H + + #include + + namespace llvm { + + class MallocAllocator { + public: + MallocAllocator() {} + ~MallocAllocator() {} + + void *Allocate(unsigned Size, unsigned Alignment) { return malloc(Size); } + void Deallocate(void *Ptr) { free(Ptr); } + void PrintStats() const {} + }; + + /// BumpPtrAllocator - This allocator is useful for containers that need very + /// simple memory allocation strategies. In particular, this just keeps + /// allocating memory, and never deletes it until the entire block is dead. This + /// makes allocation speedy, but must only be used when the trade-off is ok. + class BumpPtrAllocator { + void *TheMemory; + public: + BumpPtrAllocator(); + ~BumpPtrAllocator(); + + void *Allocate(unsigned Size, unsigned Alignment); + void Deallocate(void *Ptr) {} + void PrintStats() const; + }; + + } // end namespace clang + + #endif ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/ADT/CStringMap.h
Changes in directory llvm/include/llvm/ADT: CStringMap.h added (r1.1) --- Log message: add a highly efficient hash table that is specialized for mapping C strings to some other type. --- Diffs of the changes: (+144 -0) CStringMap.h | 144 +++ 1 files changed, 144 insertions(+) Index: llvm/include/llvm/ADT/CStringMap.h diff -c /dev/null llvm/include/llvm/ADT/CStringMap.h:1.1 *** /dev/null Sun Oct 29 17:42:13 2006 --- llvm/include/llvm/ADT/CStringMap.h Sun Oct 29 17:42:03 2006 *** *** 0 --- 1,144 + //===--- CStringMap.h - CString Hash table map interface *- C++ -*-===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by Chris Lattner and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===--===// + // + // This file defines the CStringMap class. + // + //===--===// + + #ifndef LLVM_ADT_CSTRINGMAP_H + #define LLVM_ADT_CSTRINGMAP_H + + #include "llvm/Support/Allocator.h" + #include + + namespace llvm { + + /// CStringMapVisitor - Subclasses of this class may be implemented to walk all + /// of the items in a CStringMap. + class CStringMapVisitor { + public: + virtual ~CStringMapVisitor(); + virtual void Visit(const char *Key, void *Value) const = 0; + }; + + /// CStringMapImpl - This is the base class of CStringMap that is shared among + /// all of its instantiations. + class CStringMapImpl { + protected: + /// ItemBucket - The hash table consists of an array of these. If Item is + /// non-null, this is an extant entry, otherwise, it is a hole. + struct ItemBucket { + /// FullHashValue - This remembers the full hash value of the key for + /// easy scanning. + unsigned FullHashValue; + + /// Item - This is a pointer to the actual item object. + void *Item; + }; + + ItemBucket *TheTable; + unsigned NumBuckets; + unsigned NumItems; + unsigned ItemSize; + protected: + CStringMapImpl(unsigned InitSize, unsigned ItemSize); + void RehashTable(); + + /// LookupBucketFor - Look up the bucket that the specified string should end + /// up in. If it already exists as a key in the map, the Item pointer for the + /// specified bucket will be non-null. Otherwise, it will be null. In either + /// case, the FullHashValue field of the bucket will be set to the hash value + /// of the string. + unsigned LookupBucketFor(const char *KeyStart, const char *KeyEnd); + + public: + unsigned getNumBuckets() const { return NumBuckets; } + unsigned getNumItems() const { return NumItems; } + + void VisitEntries(const CStringMapVisitor &Visitor) const; + }; + + + /// CStringMap - This is an unconventional map that is specialized for handling + /// keys that are "C strings", that is, null-terminated strings. This does some + /// funky memory allocation and hashing things to make it extremely efficient, + /// storing the string data *after* the value in the map. + template + class CStringMap : public CStringMapImpl { + AllocatorTy Allocator; + public: + CStringMap(unsigned InitialSize = 0) + : CStringMapImpl(InitialSize, sizeof(ValueTy)) {} + + AllocatorTy &getAllocator() { return Allocator; } + const AllocatorTy &getAllocator() const { return Allocator; } + + /// FindValue - Look up the specified key in the map. If it exists, return a + /// pointer to the element, otherwise return null. + ValueTy *FindValue(const char *KeyStart, const char *KeyEnd) { + unsigned BucketNo = LookupBucketFor(KeyStart, KeyEnd); + return static_cast(TheTable[BucketNo].Item); + } + + /// GetOrCreateValue - Look up the specified key in the table. If a value + /// exists, return it. Otherwise, default construct a value, insert it, and + /// return. + ValueTy &GetOrCreateValue(const char *KeyStart, const char *KeyEnd) { + unsigned BucketNo = LookupBucketFor(KeyStart, KeyEnd); + ItemBucket &Bucket = TheTable[BucketNo]; + if (Bucket.Item) + return *static_cast(Bucket.Item); + + unsigned KeyLength = KeyEnd-KeyStart; + + // Okay, the item doesn't already exist, and Bucket is the bucket to fill + // in. Allocate a new item with space for the null-terminated string at the + // end. + unsigned AllocSize = sizeof(ValueTy)+KeyLength+1; + + #ifdef __GNUC__ + unsigned Alignment = __alignof__(ValueTy); + #else + // FIXME: ugly. + unsigned Alignment = 8; + #endif + ValueTy *NewItem = (ValueTy*)Allocator.Allocate(AllocSize, Alignment); + new (NewItem) ValueTy(); + ++NumItems; + + // Copy the string information. + char *StrBuffer = (char*)(NewItem+1); + memcpy(StrBuffer, KeyStart, KeyLength); +
[llvm-commits] CVS: llvm/lib/Support/CStringMap.cpp
Changes in directory llvm/lib/Support: CStringMap.cpp added (r1.1) --- Log message: add a highly efficient hash table that is specialized for mapping C strings to some other type. --- Diffs of the changes: (+134 -0) CStringMap.cpp | 134 + 1 files changed, 134 insertions(+) Index: llvm/lib/Support/CStringMap.cpp diff -c /dev/null llvm/lib/Support/CStringMap.cpp:1.1 *** /dev/null Sun Oct 29 17:42:13 2006 --- llvm/lib/Support/CStringMap.cpp Sun Oct 29 17:42:03 2006 *** *** 0 --- 1,134 + //===--- CStringMap.cpp - CString Hash table map implementation ---===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by Chris Lattner and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===--===// + // + // This file implements the CStringMap class. + // + //===--===// + + #include "llvm/ADT/CStringMap.h" + #include + using namespace llvm; + + CStringMapVisitor::~CStringMapVisitor() { + } + + CStringMapImpl::CStringMapImpl(unsigned InitSize, unsigned itemSize) { + assert((InitSize & (InitSize-1)) == 0 && + "Init Size must be a power of 2 or zero!"); + NumBuckets = InitSize ? InitSize : 512; + ItemSize = itemSize; + NumItems = 0; + + TheTable = new ItemBucket[NumBuckets](); + memset(TheTable, 0, NumBuckets*sizeof(ItemBucket)); + } + + + /// HashString - Compute a hash code for the specified string. + /// + static unsigned HashString(const char *Start, const char *End) { + unsigned int Result = 0; + // Perl hash function. + while (Start != End) + Result = Result * 33 + *Start++; + Result = Result + (Result >> 5); + return Result; + } + + /// LookupBucketFor - Look up the bucket that the specified string should end + /// up in. If it already exists as a key in the map, the Item pointer for the + /// specified bucket will be non-null. Otherwise, it will be null. In either + /// case, the FullHashValue field of the bucket will be set to the hash value + /// of the string. + unsigned CStringMapImpl::LookupBucketFor(const char *NameStart, + const char *NameEnd) { + unsigned HTSize = NumBuckets; + unsigned FullHashValue = HashString(NameStart, NameEnd); + unsigned BucketNo = FullHashValue & (HTSize-1); + + unsigned ProbeAmt = 1; + while (1) { + ItemBucket &Bucket = TheTable[BucketNo]; + void *BucketItem = Bucket.Item; + // If we found an empty bucket, this key isn't in the table yet, return it. + if (BucketItem == 0) { + Bucket.FullHashValue = FullHashValue; + return BucketNo; + } + + // If the full hash value matches, check deeply for a match. The common + // case here is that we are only looking at the buckets (for item info + // being non-null and for the full hash value) not at the items. This + // is important for cache locality. + if (Bucket.FullHashValue == FullHashValue) { + // Do the comparison like this because NameStart isn't necessarily + // null-terminated! + char *ItemStr = (char*)BucketItem+ItemSize; + if (strlen(ItemStr) == unsigned(NameEnd-NameStart) && + memcmp(ItemStr, NameStart, (NameEnd-NameStart)) == 0) { + // We found a match! + return BucketNo; + } + } + + // Okay, we didn't find the item. Probe to the next bucket. + BucketNo = (BucketNo+ProbeAmt) & (HTSize-1); + + // Use quadratic probing, it has fewer clumping artifacts than linear + // probing and has good cache behavior in the common case. + ++ProbeAmt; + } + } + + /// RehashTable - Grow the table, redistributing values into the buckets with + /// the appropriate mod-of-hashtable-size. + void CStringMapImpl::RehashTable() { + unsigned NewSize = NumBuckets*2; + ItemBucket *NewTableArray = new ItemBucket[NewSize](); + memset(NewTableArray, 0, NewSize*sizeof(ItemBucket)); + + // Rehash all the items into their new buckets. Luckily :) we already have + // the hash values available, so we don't have to rehash any strings. + for (ItemBucket *IB = TheTable, *E = TheTable+NumBuckets; IB != E; ++IB) { + if (IB->Item) { + // Fast case, bucket available. + unsigned FullHash = IB->FullHashValue; + unsigned NewBucket = FullHash & (NewSize-1); + if (NewTableArray[NewBucket].Item == 0) { + NewTableArray[FullHash & (NewSize-1)].Item = IB->Item; + NewTableArray[FullHash & (NewSize-1)].FullHashValue = FullHash; + continue; + } + + unsigned ProbeSize = 1; + do { + NewBucket = (NewBucket + ProbeSize++) & (NewSize-1); + } while (NewTableArray[NewBucket].Item); +
[llvm-commits] CVS: llvm/include/llvm/ADT/CStringMap.h
Changes in directory llvm/include/llvm/ADT: CStringMap.h updated: 1.1 -> 1.2 --- Log message: add newline at end of file --- Diffs of the changes: (+2 -1) CStringMap.h |3 ++- 1 files changed, 2 insertions(+), 1 deletion(-) Index: llvm/include/llvm/ADT/CStringMap.h diff -u llvm/include/llvm/ADT/CStringMap.h:1.1 llvm/include/llvm/ADT/CStringMap.h:1.2 --- llvm/include/llvm/ADT/CStringMap.h:1.1 Sun Oct 29 17:42:03 2006 +++ llvm/include/llvm/ADT/CStringMap.h Sun Oct 29 17:47:01 2006 @@ -141,4 +141,5 @@ } -#endif \ No newline at end of file +#endif + ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [SignlessTypes] CVS:llvm/test/Regression/CodeGen/X86/compare_folding.llx
Zhou Sheng, could you please try to include some sort of commit message, no matter how brief? "reorder frem" would be fine, though "Moved FREM to be with the other REM instrucions." would be better. Thanks, Nick Lewycky ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [SignlessTypes] CVS: llvm/test/Regression/CodeGen/X86/compare_folding.llx
Sheng, One of the policies for LLVM is that we *never* commit anything with a blank log message. All your recent commits were blank. In the future, please make a detailed summary of your changes. What is needed is some context on the change. For our work, all your commits should start with: For PR950: Then describe the change. This gives other developers a quick way to review the patch or determine that it is not of interest to them. With 100+ commits a day, this is essential for everyone reviewing code. Thanks for your cooperation. Reid. On Sun, 2006-10-29 at 01:49 -0600, Zhou Sheng wrote: > > Changes in directory llvm/test/Regression/CodeGen/X86: > > compare_folding.llx updated: 1.3 -> 1.3.2.1 > --- > Log message: > > > > --- > Diffs of the changes: (+4 -4) > > compare_folding.llx |8 > 1 files changed, 4 insertions(+), 4 deletions(-) > > > Index: llvm/test/Regression/CodeGen/X86/compare_folding.llx > diff -u llvm/test/Regression/CodeGen/X86/compare_folding.llx:1.3 > llvm/test/Regression/CodeGen/X86/compare_folding.llx:1.3.2.1 > --- llvm/test/Regression/CodeGen/X86/compare_folding.llx:1.3 Wed Oct 11 > 20:42:03 2006 > +++ llvm/test/Regression/CodeGen/X86/compare_folding.llx Sun Oct 29 > 01:49:36 2006 > @@ -1,8 +1,8 @@ > -; RUN: llvm-as < %s | llc -march=x86 | grep movsd | wc -l | grep 1 && > -; RUN: llvm-as < %s | llc -march=x86 | grep ucomisd > -declare bool %llvm.isunordered(double,double) > +; RUN: llvm-as < %s | llc -march=x86 -mcpu=yonah | grep movsd | wc -l | grep > 1 && > +; RUN: llvm-as < %s | llc -march=x86 -mcpu=yonah | grep ucomisd > +declare bool %llvm.isunordered.f64(double,double) > > bool %test1(double %X, double %Y) { ;; Returns isunordered(X,Y) > - %COM = call bool %llvm.isunordered(double %X, double %Y) > + %COM = call bool %llvm.isunordered.f64(double %X, double %Y) > ret bool %COM > } > > > > ___ > llvm-commits mailing list > llvm-commits@cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/ADT/CStringMap.h
Changes in directory llvm/include/llvm/ADT: CStringMap.h updated: 1.2 -> 1.3 --- Log message: add a method --- Diffs of the changes: (+8 -0) CStringMap.h |8 1 files changed, 8 insertions(+) Index: llvm/include/llvm/ADT/CStringMap.h diff -u llvm/include/llvm/ADT/CStringMap.h:1.2 llvm/include/llvm/ADT/CStringMap.h:1.3 --- llvm/include/llvm/ADT/CStringMap.h:1.2 Sun Oct 29 17:47:01 2006 +++ llvm/include/llvm/ADT/CStringMap.h Sun Oct 29 21:14:15 2006 @@ -86,6 +86,14 @@ return static_cast(TheTable[BucketNo].Item); } + /// GetKeyForValueInMap - Given a value that is inserted into this map, return + /// the string that corresponds to it. This is an efficient operation that + /// is provided by CStringMap. The string is live as long as the value is in + /// the map. + static const char *GetKeyForValueInMap(const ValueTy &Val) { +return reinterpret_cast(&Val+1); + } + /// GetOrCreateValue - Look up the specified key in the table. If a value /// exists, return it. Otherwise, default construct a value, insert it, and /// return. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/ADT/SmallString.h SmallVector.h
Changes in directory llvm/include/llvm/ADT: SmallString.h added (r1.1) SmallVector.h updated: 1.20 -> 1.21 --- Log message: Add SmallString a (currently) minimal class that adapts SmallVector to be more string-like. --- Diffs of the changes: (+58 -0) SmallString.h | 57 + SmallVector.h |1 + 2 files changed, 58 insertions(+) Index: llvm/include/llvm/ADT/SmallString.h diff -c /dev/null llvm/include/llvm/ADT/SmallString.h:1.1 *** /dev/null Sun Oct 29 21:39:30 2006 --- llvm/include/llvm/ADT/SmallString.h Sun Oct 29 21:39:20 2006 *** *** 0 --- 1,57 + //===- llvm/ADT/SmallString.h - 'Normally small' strings *- C++ -*-===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by Chris Lattner and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===--===// + // + // This file defines the SmallString class. + // + //===--===// + + #ifndef LLVM_ADT_SMALLSTRING_H + #define LLVM_ADT_SMALLSTRING_H + + #include "llvm/ADT/SmallVector.h" + #include + + namespace llvm { + + /// SmallString - A SmallString is just a SmallVector with methods and accessors + /// that make it work better as a string (e.g. operator+ etc). + template + class SmallString : public SmallVector { + public: + // Default ctor - Initialize to empty. + SmallString() {} + + // Initialize with a range. + template + SmallString(ItTy S, ItTy E) : SmallVector(S, E) {} + + // Copy ctor. + SmallString(const SmallString &RHS) : SmallVector(RHS) {} + + + // Extra methods. + const char *c_str() const { + SmallString *This = const_cast(this); + // Ensure that there is a \0 at the end of the string. + This->reserve(this->size()+1); + This->End[0] = 0; + return this->begin(); + } + + // Extra operators. + SmallString &operator+=(const char *RHS) { + this->append(RHS, RHS+strlen(RHS)); + return *this; + } + }; + + + } + + #endif Index: llvm/include/llvm/ADT/SmallVector.h diff -u llvm/include/llvm/ADT/SmallVector.h:1.20 llvm/include/llvm/ADT/SmallVector.h:1.21 --- llvm/include/llvm/ADT/SmallVector.h:1.20Mon Oct 9 14:05:44 2006 +++ llvm/include/llvm/ADT/SmallVector.h Sun Oct 29 21:39:20 2006 @@ -25,6 +25,7 @@ /// template parameter. template class SmallVectorImpl { +protected: T *Begin, *End, *Capacity; // Allocate raw space for N elements of type T. If T has a ctor or dtor, we ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] llvm-gcc patch
Chris, Could you please resend this as an attachment. It is not applying correctly. Thanks, Reid. On Sun, 2006-10-29 at 09:39 -0800, Chris Lattner wrote: > Index: crtstuff.c > === > --- crtstuff.c (revision 119298) > +++ crtstuff.c (working copy) > @@ -51,9 +51,6 @@ > This file must be compiled with gcc. */ > -/* APPLE LOCAL begin LLVM */ > -#ifndef __llvm__ /* FIXME: add inline asm support */ > - > /* It is incorrect to include config.h here, because this file is > being > compiled for the target, and hence definitions concerning only > the host > do not apply. */ > @@ -69,6 +66,13 @@ > #include "tm.h" > #include "unwind-dw2-fde.h" > +/* APPLE LOCAL begin LLVM */ > +#ifdef __llvm__ > + /* FIXME: Remove when external weak linkage will be alive. */ > + #undef JCR_SECTION_NAME > +#endif > +/* APPLE LOCAL end LLVM */ > + > #ifndef FORCE_CODE_SECTION_ALIGN > # define FORCE_CODE_SECTION_ALIGN > #endif > @@ -177,11 +181,25 @@ > static func_ptr force_to_data[1] __attribute__ ((__unused__)) = { }; > asm (CTORS_SECTION_ASM_OP); > STATIC func_ptr __CTOR_LIST__[1] > +/* APPLE LOCAL begin LLVM */ > +#ifdef __llvm__ > +/* FIXME: Remove when external weak linkage will be alive. */ > + __attribute__ ((__used__, aligned(sizeof(func_ptr > +#else > __attribute__ ((__unused__, aligned(sizeof(func_ptr > +#endif > +/* APPLE LOCAL end LLVM */ > = { (func_ptr) (-1) }; > #else > STATIC func_ptr __CTOR_LIST__[1] > - __attribute__ ((__unused__, section(".ctors"), aligned(sizeof > (func_ptr > +/* APPLE LOCAL begin LLVM */ > +#ifdef __llvm__ > +/* FIXME: Remove when external weak linkage will be alive. */ > + __attribute__ ((__used__, section(".ctors"), aligned(sizeof > (func_ptr > +#else > + __attribute__ ((__unused__, section(".ctors"), aligned(sizeof > (func_ptr > +#endif > +/* APPLE LOCAL end LLVM */ > = { (func_ptr) (-1) }; > #endif /* __CTOR_LIST__ alternatives */ > @@ -449,11 +467,25 @@ > #elif defined(DTORS_SECTION_ASM_OP) > asm (DTORS_SECTION_ASM_OP); > STATIC func_ptr __DTOR_END__[1] > +/* APPLE LOCAL begin LLVM */ > +#ifdef __llvm__ > +/* FIXME: Remove when external weak linkage will be alive. */ > +__attribute__ ((__used__, aligned(sizeof(func_ptr > +#else > __attribute__ ((unused, aligned(sizeof(func_ptr > +#endif > +/* APPLE LOCAL end LLVM */ > = { (func_ptr) 0 }; > #else > STATIC func_ptr __DTOR_END__[1] > - __attribute__((unused, section(".dtors"), > aligned(sizeof(func_ptr > +/* APPLE LOCAL begin LLVM */ > +#ifdef __llvm__ > +/* FIXME: Remove when external weak linkage will be alive. */ > + __attribute__((__used__, section(".dtors"), aligned(sizeof > (func_ptr > +#else > + __attribute__((unused, section(".dtors"), > aligned(sizeof(func_ptr > +#endif > +/* APPLE LOCAL end LLVM */ > = { (func_ptr) 0 }; > #endif > @@ -558,5 +590,3 @@ > #error "One of CRT_BEGIN or CRT_END must be defined." > #endif > -#endif > -/* APPLE LOCAL end LLVM */ ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] llvm-gcc patch
http://llvm.org/bugs/attachment.cgi?id=423&action=view -Chris On Oct 29, 2006, at 8:14 PM, Reid Spencer wrote: > Chris, > > Could you please resend this as an attachment. It is not applying > correctly. > > Thanks, > > Reid. > > On Sun, 2006-10-29 at 09:39 -0800, Chris Lattner wrote: >> Index: crtstuff.c >> === >> --- crtstuff.c (revision 119298) >> +++ crtstuff.c (working copy) >> @@ -51,9 +51,6 @@ >> This file must be compiled with gcc. */ >> -/* APPLE LOCAL begin LLVM */ >> -#ifndef __llvm__ /* FIXME: add inline asm support */ >> - >> /* It is incorrect to include config.h here, because this file is >> being >> compiled for the target, and hence definitions concerning only >> the host >> do not apply. */ >> @@ -69,6 +66,13 @@ >> #include "tm.h" >> #include "unwind-dw2-fde.h" >> +/* APPLE LOCAL begin LLVM */ >> +#ifdef __llvm__ >> + /* FIXME: Remove when external weak linkage will be alive. */ >> + #undef JCR_SECTION_NAME >> +#endif >> +/* APPLE LOCAL end LLVM */ >> + >> #ifndef FORCE_CODE_SECTION_ALIGN >> # define FORCE_CODE_SECTION_ALIGN >> #endif >> @@ -177,11 +181,25 @@ >> static func_ptr force_to_data[1] __attribute__ ((__unused__)) = { }; >> asm (CTORS_SECTION_ASM_OP); >> STATIC func_ptr __CTOR_LIST__[1] >> +/* APPLE LOCAL begin LLVM */ >> +#ifdef __llvm__ >> +/* FIXME: Remove when external weak linkage will be alive. */ >> + __attribute__ ((__used__, aligned(sizeof(func_ptr >> +#else >> __attribute__ ((__unused__, aligned(sizeof(func_ptr >> +#endif >> +/* APPLE LOCAL end LLVM */ >> = { (func_ptr) (-1) }; >> #else >> STATIC func_ptr __CTOR_LIST__[1] >> - __attribute__ ((__unused__, section(".ctors"), aligned(sizeof >> (func_ptr >> +/* APPLE LOCAL begin LLVM */ >> +#ifdef __llvm__ >> +/* FIXME: Remove when external weak linkage will be alive. */ >> + __attribute__ ((__used__, section(".ctors"), aligned(sizeof >> (func_ptr >> +#else >> + __attribute__ ((__unused__, section(".ctors"), aligned(sizeof >> (func_ptr >> +#endif >> +/* APPLE LOCAL end LLVM */ >> = { (func_ptr) (-1) }; >> #endif /* __CTOR_LIST__ alternatives */ >> @@ -449,11 +467,25 @@ >> #elif defined(DTORS_SECTION_ASM_OP) >> asm (DTORS_SECTION_ASM_OP); >> STATIC func_ptr __DTOR_END__[1] >> +/* APPLE LOCAL begin LLVM */ >> +#ifdef __llvm__ >> +/* FIXME: Remove when external weak linkage will be alive. */ >> +__attribute__ ((__used__, aligned(sizeof(func_ptr >> +#else >> __attribute__ ((unused, aligned(sizeof(func_ptr >> +#endif >> +/* APPLE LOCAL end LLVM */ >> = { (func_ptr) 0 }; >> #else >> STATIC func_ptr __DTOR_END__[1] >> - __attribute__((unused, section(".dtors"), >> aligned(sizeof(func_ptr >> +/* APPLE LOCAL begin LLVM */ >> +#ifdef __llvm__ >> +/* FIXME: Remove when external weak linkage will be alive. */ >> + __attribute__((__used__, section(".dtors"), aligned(sizeof >> (func_ptr >> +#else >> + __attribute__((unused, section(".dtors"), >> aligned(sizeof(func_ptr >> +#endif >> +/* APPLE LOCAL end LLVM */ >> = { (func_ptr) 0 }; >> #endif >> @@ -558,5 +590,3 @@ >> #error "One of CRT_BEGIN or CRT_END must be defined." >> #endif >> -#endif >> -/* APPLE LOCAL end LLVM */ > ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/ADT/SmallVector.h
Changes in directory llvm/include/llvm/ADT: SmallVector.h updated: 1.21 -> 1.22 --- Log message: add a new form of insert. --- Diffs of the changes: (+48 -1) SmallVector.h | 49 - 1 files changed, 48 insertions(+), 1 deletion(-) Index: llvm/include/llvm/ADT/SmallVector.h diff -u llvm/include/llvm/ADT/SmallVector.h:1.21 llvm/include/llvm/ADT/SmallVector.h:1.22 --- llvm/include/llvm/ADT/SmallVector.h:1.21Sun Oct 29 21:39:20 2006 +++ llvm/include/llvm/ADT/SmallVector.h Sun Oct 29 23:07:51 2006 @@ -207,6 +207,54 @@ goto Retry; } + template + iterator insert(iterator I, ItTy From, ItTy To) { +if (I == End) { // Important special case for empty vector. + append(From, To); + return end()-1; +} + +unsigned NumToInsert = std::distance(From, To); +// Convert iterator to elt# to avoid invalidating iterator when we reserve() +unsigned InsertElt = I-begin(); + +// Ensure there is enough space. +reserve(size() + NumToInsert); + +// Uninvalidate the iterator. +I = begin()+InsertElt; + +// If we already have this many elements in the collection, append the +// dest elements at the end, then copy over the appropriate elements. Since +// we already reserved space, we know that this won't reallocate the vector. +if (size() >= NumToInsert) { + T *OldEnd = End; + append(End-NumToInsert, End); + + // Copy the existing elements that get replaced. + std::copy(I, OldEnd-NumToInsert, I+NumToInsert); + + std::copy(From, To, I); + return I; +} + +// Otherwise, we're inserting more elements than exist already, and we're +// not inserting at the end. + +// Copy over the elements that we're about to overwrite. +T *OldEnd = End; +End += NumToInsert; +unsigned NumOverwritten = OldEnd-I; +std::uninitialized_copy(I, OldEnd, End-NumOverwritten); + +// Replace the overwritten part. +std::copy(From, From+NumOverwritten, I); + +// Insert the non-overwritten middle part. +std::uninitialized_copy(From+NumOverwritten, To, OldEnd); +return I; + } + const SmallVectorImpl &operator=(const SmallVectorImpl &RHS); private: @@ -224,7 +272,6 @@ for (; S != E; ++S) new (S) T(Elt); } - void destroy_range(T *S, T *E) { while (S != E) { ___ 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/X86/2006-08-21-ExtraMovInst.ll
Changes in directory llvm/test/Regression/CodeGen/X86: 2006-08-21-ExtraMovInst.ll updated: 1.1 -> 1.2 --- Log message: fix this regtest --- Diffs of the changes: (+1 -1) 2006-08-21-ExtraMovInst.ll |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/test/Regression/CodeGen/X86/2006-08-21-ExtraMovInst.ll diff -u llvm/test/Regression/CodeGen/X86/2006-08-21-ExtraMovInst.ll:1.1 llvm/test/Regression/CodeGen/X86/2006-08-21-ExtraMovInst.ll:1.2 --- llvm/test/Regression/CodeGen/X86/2006-08-21-ExtraMovInst.ll:1.1 Mon Aug 21 02:33:33 2006 +++ llvm/test/Regression/CodeGen/X86/2006-08-21-ExtraMovInst.ll Sun Oct 29 23:24:03 2006 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -fast -march=x86 -mcpu=i386 | not grep 'movl %eax, %edx' +; RUN: llvm-as < %s | llc -march=x86 -mcpu=i386 | not grep 'movl %eax, %edx' int %foo(int %t, int %C) { entry: ___ 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/SelectionDAGNodes.h
Changes in directory llvm/include/llvm/CodeGen: SelectionDAGNodes.h updated: 1.158 -> 1.159 --- Log message: Added a new SDNode type: BR_JT for jumptable branch. --- Diffs of the changes: (+4 -0) SelectionDAGNodes.h |4 1 files changed, 4 insertions(+) Index: llvm/include/llvm/CodeGen/SelectionDAGNodes.h diff -u llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.158 llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.159 --- llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.158 Fri Oct 27 20:34:21 2006 +++ llvm/include/llvm/CodeGen/SelectionDAGNodes.h Mon Oct 30 01:57:41 2006 @@ -406,6 +406,10 @@ // is the value to branch to, which must be of the same type as the target's // pointer type. BRIND, + +// BR_JT - Jumptable branch. The first operand is the chain, the second +// is the jumptable index, the last one is the jumptable entry index. +BR_JT, // BRCOND - Conditional branch. The first operand is the chain, // the second is the condition, the third is the block to branch ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits