From dpatel at apple.com Mon Apr 28 00:13:08 2008 From: dpatel at apple.com (Devang Patel) Date: Mon, 28 Apr 2008 05:13:08 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50333 - /llvm-gcc-4.2/trunk/build_gcc Message-ID: <200804280513.m3S5D8LD016871@zion.cs.uiuc.edu> Author: dpatel Date: Mon Apr 28 00:13:07 2008 New Revision: 50333 URL: http://llvm.org/viewvc/llvm-project?rev=50333&view=rev Log: Add FIXME note. Modified: llvm-gcc-4.2/trunk/build_gcc Modified: llvm-gcc-4.2/trunk/build_gcc URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/build_gcc?rev=50333&r1=50332&r2=50333&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/build_gcc (original) +++ llvm-gcc-4.2/trunk/build_gcc Mon Apr 28 00:13:07 2008 @@ -410,6 +410,7 @@ done done +# FIXME: What is the motivation here ? for t in $TARGETS ; do cp -p /usr/lib/libstdc++.6.dylib \ .$DEST_ROOT/lib/gcc/$t-apple-darwin$DARWIN_VERS/$VERS/libstdc++.dylib \ From dpatel at apple.com Mon Apr 28 00:37:24 2008 From: dpatel at apple.com (Devang Patel) Date: Sun, 27 Apr 2008 22:37:24 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r50317 - /llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-convert.cpp In-Reply-To: References: <200804270642.m3R6gRUl010174@zion.cs.uiuc.edu> Message-ID: <253385FC-59AD-4348-B047-702BE23AB1B7@apple.com> On Apr 27, 2008, at 2:37 AM, Bill Wendling wrote: > Do you have a testcase for this? This patch increases #of passes from 289 to 621 in compat.exp tests on x86-64 darwin :) > (Applied to mainline.) Thanks! - Devang From sabre at nondot.org Mon Apr 28 01:01:07 2008 From: sabre at nondot.org (Chris Lattner) Date: Mon, 28 Apr 2008 06:01:07 -0000 Subject: [llvm-commits] [llvm] r50334 - /llvm/trunk/include/llvm/ADT/SmallVector.h Message-ID: <200804280601.m3S617KC018224@zion.cs.uiuc.edu> Author: lattner Date: Mon Apr 28 01:01:06 2008 New Revision: 50334 URL: http://llvm.org/viewvc/llvm-project?rev=50334&view=rev Log: generalize SmallVector copy ctor, there is no requirement for the initialization vector to have the same fixed size, just the same element type. Modified: llvm/trunk/include/llvm/ADT/SmallVector.h Modified: llvm/trunk/include/llvm/ADT/SmallVector.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SmallVector.h?rev=50334&r1=50333&r2=50334&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/SmallVector.h (original) +++ llvm/trunk/include/llvm/ADT/SmallVector.h Mon Apr 28 01:01:06 2008 @@ -486,7 +486,8 @@ append(S, E); } - SmallVector(const SmallVector &RHS) : SmallVectorImpl(NumTsAvailable) { + SmallVector(const SmallVectorImpl &RHS) + : SmallVectorImpl(NumTsAvailable) { if (!RHS.empty()) operator=(RHS); } From sabre at nondot.org Mon Apr 28 01:02:19 2008 From: sabre at nondot.org (Chris Lattner) Date: Mon, 28 Apr 2008 06:02:19 -0000 Subject: [llvm-commits] [llvm] r50335 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <200804280602.m3S62Jbn018264@zion.cs.uiuc.edu> Author: lattner Date: Mon Apr 28 01:02:19 2008 New Revision: 50335 URL: http://llvm.org/viewvc/llvm-project?rev=50335&view=rev Log: switch RegsForValue::Regs to be a SmallVector to avoid heap thrash on tiny (usually single-element) vectors. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=50335&r1=50334&r2=50335&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Mon Apr 28 01:02:19 2008 @@ -125,7 +125,7 @@ /// Regs - This list holds the register (for legal and promoted values) /// or register set (for expanded values) that the value should be assigned /// to. - std::vector Regs; + SmallVector Regs; /// RegVTs - The value types of the registers. This is the same size /// as ValueVTs; every register contributing to a given value must @@ -146,11 +146,11 @@ unsigned Reg, MVT::ValueType regvt, MVT::ValueType valuevt) : TLI(&tli), Regs(1, Reg), RegVTs(1, regvt), ValueVTs(1, valuevt) {} RegsForValue(const TargetLowering &tli, - const std::vector ®s, + const SmallVectorImpl ®s, MVT::ValueType regvt, MVT::ValueType valuevt) : TLI(&tli), Regs(regs), RegVTs(1, regvt), ValueVTs(1, valuevt) {} RegsForValue(const TargetLowering &tli, - const std::vector ®s, + const SmallVectorImpl ®s, const SmallVector ®vts, const SmallVector &valuevts) : TLI(&tli), Regs(regs), RegVTs(regvts), ValueVTs(valuevts) {} @@ -3600,7 +3600,7 @@ MachineFunction &MF = DAG.getMachineFunction(); - std::vector Regs; + SmallVector Regs; // If this is a constraint for a single physreg, or a constraint for a // register class, find it. From asl at math.spbu.ru Mon Apr 28 01:12:38 2008 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Mon, 28 Apr 2008 10:12:38 +0400 Subject: [llvm-commits] [PATCH] Add support for response files to the CommandLine library In-Reply-To: <48177.81.172.134.32.1209349445.squirrel@webmail.sophsolutions.com> References: <48177.81.172.134.32.1209349445.squirrel@webmail.sophsolutions.com> Message-ID: <1209363158.5745.24.camel@localhost> Mikhail, > Add support for response files [1] to the CommandLine library. Response > files are enabled by an optional argument to ParseCommandLineOptions and > ParseEnvironmentOptions. Looks ok, please apply. PS: Please turn automatic whitespace cleanup off, otherwise patches are really hard to review. -- With best regards, Anton Korobeynikov. Faculty of Mathematics & Mechanics, Saint Petersburg State University. From dpatel at apple.com Mon Apr 28 01:21:48 2008 From: dpatel at apple.com (Devang Patel) Date: Mon, 28 Apr 2008 06:21:48 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50336 - /llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-function-20.c Message-ID: <200804280621.m3S6Ln0p018771@zion.cs.uiuc.edu> Author: dpatel Date: Mon Apr 28 01:21:48 2008 New Revision: 50336 URL: http://llvm.org/viewvc/llvm-project?rev=50336&view=rev Log: Remove inliner specific warning message check. Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-function-20.c Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-function-20.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-function-20.c?rev=50336&r1=50335&r2=50336&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-function-20.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-function-20.c Mon Apr 28 01:21:48 2008 @@ -7,7 +7,7 @@ inline int numberFive (void); asm int numberFive (void) { /* { dg-warning "can never be inlined" } */ - /* { dg-warning "inlining failed in call" "" { target *-*-* } 9 } */ + /* LLVM LOCAL */ li r3, 1 } From isanbard at gmail.com Mon Apr 28 01:31:33 2008 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 28 Apr 2008 06:31:33 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50337 - /llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-function-20.c Message-ID: <200804280631.m3S6VXNd019038@zion.cs.uiuc.edu> Author: void Date: Mon Apr 28 01:31:33 2008 New Revision: 50337 URL: http://llvm.org/viewvc/llvm-project?rev=50337&view=rev Log: Porting r50336 from Tak. Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-function-20.c Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-function-20.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-function-20.c?rev=50337&r1=50336&r2=50337&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-function-20.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-function-20.c Mon Apr 28 01:31:33 2008 @@ -7,7 +7,7 @@ inline int numberFive (void); asm int numberFive (void) { /* { dg-warning "can never be inlined" } */ - /* { dg-warning "inlining failed in call" "" { target *-*-* } 9 } */ + /* LLVM LOCAL */ li r3, 1 } From sabre at nondot.org Mon Apr 28 01:32:08 2008 From: sabre at nondot.org (Chris Lattner) Date: Mon, 28 Apr 2008 06:32:08 -0000 Subject: [llvm-commits] [llvm] r50338 - /llvm/trunk/include/llvm/ADT/SmallVector.h Message-ID: <200804280632.m3S6W8VA019066@zion.cs.uiuc.edu> Author: lattner Date: Mon Apr 28 01:32:08 2008 New Revision: 50338 URL: http://llvm.org/viewvc/llvm-project?rev=50338&view=rev Log: restore the copy ctor in SmallVector. This fixes serious errors I introduced in my last patch. Modified: llvm/trunk/include/llvm/ADT/SmallVector.h Modified: llvm/trunk/include/llvm/ADT/SmallVector.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SmallVector.h?rev=50338&r1=50337&r2=50338&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/SmallVector.h (original) +++ llvm/trunk/include/llvm/ADT/SmallVector.h Mon Apr 28 01:32:08 2008 @@ -486,6 +486,11 @@ append(S, E); } + SmallVector(const SmallVector &RHS) : SmallVectorImpl(NumTsAvailable) { + if (!RHS.empty()) + operator=(RHS); + } + SmallVector(const SmallVectorImpl &RHS) : SmallVectorImpl(NumTsAvailable) { if (!RHS.empty()) From isanbard at gmail.com Mon Apr 28 01:34:05 2008 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 28 Apr 2008 06:34:05 -0000 Subject: [llvm-commits] [llvm] r50339 - in /llvm/branches/Apple/Tak: lib/Transforms/Utils/SimplifyCFG.cpp test/Transforms/SimplifyCFG/2008-04-27-MultipleReturnCrash.ll Message-ID: <200804280634.m3S6Y5qN019130@zion.cs.uiuc.edu> Author: void Date: Mon Apr 28 01:34:05 2008 New Revision: 50339 URL: http://llvm.org/viewvc/llvm-project?rev=50339&view=rev Log: Porting r50332 to Tak. Added: llvm/branches/Apple/Tak/test/Transforms/SimplifyCFG/2008-04-27-MultipleReturnCrash.ll Modified: llvm/branches/Apple/Tak/lib/Transforms/Utils/SimplifyCFG.cpp Modified: llvm/branches/Apple/Tak/lib/Transforms/Utils/SimplifyCFG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Tak/lib/Transforms/Utils/SimplifyCFG.cpp?rev=50339&r1=50338&r2=50339&view=diff ============================================================================== --- llvm/branches/Apple/Tak/lib/Transforms/Utils/SimplifyCFG.cpp (original) +++ llvm/branches/Apple/Tak/lib/Transforms/Utils/SimplifyCFG.cpp Mon Apr 28 01:34:05 2008 @@ -1367,10 +1367,11 @@ // If the return instruction returns a value, and if the value was a // PHI node in "BB", propagate the right value into the return. - if (NewRet->getNumOperands() == 1) - if (PHINode *PN = dyn_cast(NewRet->getOperand(0))) + for (unsigned i = 0, e = NewRet->getNumOperands(); i != e; ++i) + if (PHINode *PN = dyn_cast(NewRet->getOperand(i))) if (PN->getParent() == BB) - NewRet->setOperand(0, PN->getIncomingValueForBlock(Pred)); + NewRet->setOperand(i, PN->getIncomingValueForBlock(Pred)); + // Update any PHI nodes in the returning block to realize that we no // longer branch to them. BB->removePredecessor(Pred); Added: llvm/branches/Apple/Tak/test/Transforms/SimplifyCFG/2008-04-27-MultipleReturnCrash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Tak/test/Transforms/SimplifyCFG/2008-04-27-MultipleReturnCrash.ll?rev=50339&view=auto ============================================================================== --- llvm/branches/Apple/Tak/test/Transforms/SimplifyCFG/2008-04-27-MultipleReturnCrash.ll (added) +++ llvm/branches/Apple/Tak/test/Transforms/SimplifyCFG/2008-04-27-MultipleReturnCrash.ll Mon Apr 28 01:34:05 2008 @@ -0,0 +1,30 @@ +; RUN: llvm-as < %s | opt -simplifycfg -disable-output +; PR2256 +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" +target triple = "x86_64-mingw32" + +define { x86_fp80, x86_fp80 } @catanl({ x86_fp80, x86_fp80 }* byval %Z, i1 %cond) nounwind { +bb: ; preds = %entry + br i1 %cond, label %bb48, label %bb40 + +bb40: ; preds = %bb + store i32 34, i32* null, align 4 + br label %bb196 + +bb48: ; preds = %bb.bb48_crit_edge, %entry.bb48_crit_edge + %tmp53 = icmp eq i32 0, 1280 ; [#uses=1] + br i1 %tmp53, label %bb56, label %bb174 + +bb56: ; preds = %bb48 + %iftmp.0.0 = select i1 false, x86_fp80 0xK3FFFC90FDAA22168C235, x86_fp80 0xKBFFFC90FDAA22168C235 ; [#uses=0] + br label %bb196 + + +bb174: ; preds = %bb144, %bb114 + %tmp191 = mul x86_fp80 0xK00000000000000000000, 0xK3FFE8000000000000000 ; [#uses=1] + br label %bb196 + +bb196: ; preds = %bb174, %bb56, %bb40 + %Res.1.0 = phi x86_fp80 [ 0xK7FFF8000000000000000, %bb40 ], [ %tmp191, %bb174 ], [ 0xK00000000000000000000, %bb56 ] ; [#uses=1] + ret x86_fp80 0xK00000000000000000000, x86_fp80 %Res.1.0 +} From isanbard at gmail.com Mon Apr 28 01:34:18 2008 From: isanbard at gmail.com (Bill Wendling) Date: Sun, 27 Apr 2008 23:34:18 -0700 Subject: [llvm-commits] [llvm] r50332 - in /llvm/trunk: lib/Transforms/Utils/SimplifyCFG.cpp test/Transforms/SimplifyCFG/2008-04-27-MultipleReturnCrash.ll In-Reply-To: <200804280019.m3S0J7In008978@zion.cs.uiuc.edu> References: <200804280019.m3S0J7In008978@zion.cs.uiuc.edu> Message-ID: On Apr 27, 2008, at 5:19 PM, Chris Lattner wrote: > Author: lattner > Date: Sun Apr 27 19:19:07 2008 > New Revision: 50332 > > URL: http://llvm.org/viewvc/llvm-project?rev=50332&view=rev > Log: > Fix PR2256, yet another miscompilation in simplifycfg of i > multiple return values. > > Bill, please pull this into Tak. Done -bw From isanbard at gmail.com Mon Apr 28 01:35:17 2008 From: isanbard at gmail.com (Bill Wendling) Date: Sun, 27 Apr 2008 23:35:17 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r50333 - /llvm-gcc-4.2/trunk/build_gcc In-Reply-To: <200804280513.m3S5D8LD016871@zion.cs.uiuc.edu> References: <200804280513.m3S5D8LD016871@zion.cs.uiuc.edu> Message-ID: <38CD6817-7FBA-4C3F-9CDB-F99001D52ACD@gmail.com> On Apr 27, 2008, at 10:13 PM, Devang Patel wrote: > Author: dpatel > Date: Mon Apr 28 00:13:07 2008 > New Revision: 50333 > > URL: http://llvm.org/viewvc/llvm-project?rev=50333&view=rev > Log: > Add FIXME note. > > Modified: > llvm-gcc-4.2/trunk/build_gcc > > Modified: llvm-gcc-4.2/trunk/build_gcc > URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/build_gcc?rev=50333&r1=50332&r2=50333&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm-gcc-4.2/trunk/build_gcc (original) > +++ llvm-gcc-4.2/trunk/build_gcc Mon Apr 28 00:13:07 2008 > @@ -410,6 +410,7 @@ > done > done > > +# FIXME: What is the motivation here ? If we do just sym-linking, then will coexistence still work? -bw > for t in $TARGETS ; do > cp -p /usr/lib/libstdc++.6.dylib \ > .$DEST_ROOT/lib/gcc/$t-apple-darwin$DARWIN_VERS/$VERS/libstdc+ > +.dylib \ > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From sabre at nondot.org Mon Apr 28 01:44:42 2008 From: sabre at nondot.org (Chris Lattner) Date: Mon, 28 Apr 2008 06:44:42 -0000 Subject: [llvm-commits] [llvm] r50340 - in /llvm/trunk: include/llvm/ADT/SmallVector.h lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <200804280644.m3S6ig0Y019478@zion.cs.uiuc.edu> Author: lattner Date: Mon Apr 28 01:44:42 2008 New Revision: 50340 URL: http://llvm.org/viewvc/llvm-project?rev=50340&view=rev Log: Remove the SmallVector ctor that converts from a SmallVectorImpl. This conversion open the door for many nasty implicit conversion issues, and can be easily solved by initializing with (V.begin(), V.end()) when needed. This patch includes many small cleanups for sdisel also. Modified: llvm/trunk/include/llvm/ADT/SmallVector.h llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Modified: llvm/trunk/include/llvm/ADT/SmallVector.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SmallVector.h?rev=50340&r1=50339&r2=50340&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/SmallVector.h (original) +++ llvm/trunk/include/llvm/ADT/SmallVector.h Mon Apr 28 01:44:42 2008 @@ -491,16 +491,11 @@ operator=(RHS); } - SmallVector(const SmallVectorImpl &RHS) - : SmallVectorImpl(NumTsAvailable) { - if (!RHS.empty()) - operator=(RHS); - } - const SmallVector &operator=(const SmallVector &RHS) { SmallVectorImpl::operator=(RHS); return *this; } + }; } // End llvm namespace Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=50340&r1=50339&r2=50340&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Mon Apr 28 01:44:42 2008 @@ -146,11 +146,11 @@ unsigned Reg, MVT::ValueType regvt, MVT::ValueType valuevt) : TLI(&tli), Regs(1, Reg), RegVTs(1, regvt), ValueVTs(1, valuevt) {} RegsForValue(const TargetLowering &tli, - const SmallVectorImpl ®s, + const SmallVector ®s, MVT::ValueType regvt, MVT::ValueType valuevt) : TLI(&tli), Regs(regs), RegVTs(1, regvt), ValueVTs(1, valuevt) {} RegsForValue(const TargetLowering &tli, - const SmallVectorImpl ®s, + const SmallVector ®s, const SmallVector ®vts, const SmallVector &valuevts) : TLI(&tli), Regs(regs), RegVTs(regvts), ValueVTs(valuevts) {} @@ -360,16 +360,15 @@ /// the correctly promoted or expanded types. Assign these registers /// consecutive vreg numbers and return the first assigned number. unsigned FunctionLoweringInfo::CreateRegForValue(const Value *V) { - const Type *Ty = V->getType(); SmallVector ValueVTs; - ComputeValueVTs(TLI, Ty, ValueVTs); + ComputeValueVTs(TLI, V->getType(), ValueVTs); unsigned FirstReg = 0; for (unsigned Value = 0; Value != ValueVTs.size(); ++Value) { MVT::ValueType ValueVT = ValueVTs[Value]; - unsigned NumRegs = TLI.getNumRegisters(ValueVT); MVT::ValueType RegisterVT = TLI.getRegisterType(ValueVT); + unsigned NumRegs = TLI.getNumRegisters(ValueVT); for (unsigned i = 0; i != NumRegs; ++i) { unsigned R = MakeReg(RegisterVT); if (!FirstReg) FirstReg = R; @@ -1042,18 +1041,22 @@ if (N.Val) return N; const Type *VTy = V->getType(); - MVT::ValueType VT = TLI.getValueType(VTy, true); if (Constant *C = const_cast(dyn_cast(V))) { - if (ConstantExpr *CE = dyn_cast(C)) { - visit(CE->getOpcode(), *CE); - SDOperand N1 = NodeMap[V]; - assert(N1.Val && "visit didn't populate the ValueMap!"); - return N1; - } else if (GlobalValue *GV = dyn_cast(C)) { + MVT::ValueType VT = TLI.getValueType(VTy, true); + + if (ConstantInt *CI = dyn_cast(C)) + return N = DAG.getConstant(CI->getValue(), VT); + + if (GlobalValue *GV = dyn_cast(C)) return N = DAG.getGlobalAddress(GV, VT); - } else if (isa(C)) { + + if (isa(C)) return N = DAG.getConstant(0, TLI.getPointerTy()); - } else if (isa(C)) { + + if (ConstantFP *CFP = dyn_cast(C)) + return N = DAG.getConstantFP(CFP->getValueAPF(), VT); + + if (isa(C)) { if (!isa(VTy)) return N = DAG.getNode(ISD::UNDEF, VT); @@ -1067,44 +1070,46 @@ // Create a VConstant node with generic Vector type. MVT::ValueType VT = MVT::getVectorType(PVT, NumElements); - return N = DAG.getNode(ISD::BUILD_VECTOR, VT, - &Ops[0], Ops.size()); - } else if (ConstantFP *CFP = dyn_cast(C)) { - return N = DAG.getConstantFP(CFP->getValueAPF(), VT); - } else if (const VectorType *PTy = dyn_cast(VTy)) { - unsigned NumElements = PTy->getNumElements(); - MVT::ValueType PVT = TLI.getValueType(PTy->getElementType()); - - // Now that we know the number and type of the elements, push a - // Constant or ConstantFP node onto the ops list for each element of - // the vector constant. - SmallVector Ops; - if (ConstantVector *CP = dyn_cast(C)) { - for (unsigned i = 0; i != NumElements; ++i) - Ops.push_back(getValue(CP->getOperand(i))); - } else { - assert(isa(C) && "Unknown vector constant!"); - SDOperand Op; - if (MVT::isFloatingPoint(PVT)) - Op = DAG.getConstantFP(0, PVT); - else - Op = DAG.getConstant(0, PVT); - Ops.assign(NumElements, Op); - } - - // Create a BUILD_VECTOR node. - MVT::ValueType VT = MVT::getVectorType(PVT, NumElements); - return NodeMap[V] = DAG.getNode(ISD::BUILD_VECTOR, VT, &Ops[0], - Ops.size()); + return N = DAG.getNode(ISD::BUILD_VECTOR, VT, &Ops[0], Ops.size()); + } + + if (ConstantExpr *CE = dyn_cast(C)) { + visit(CE->getOpcode(), *CE); + SDOperand N1 = NodeMap[V]; + assert(N1.Val && "visit didn't populate the ValueMap!"); + return N1; + } + + const VectorType *VecTy = cast(VTy); + unsigned NumElements = VecTy->getNumElements(); + MVT::ValueType PVT = TLI.getValueType(VecTy->getElementType()); + + // Now that we know the number and type of the elements, push a + // Constant or ConstantFP node onto the ops list for each element of + // the vector constant. + SmallVector Ops; + if (ConstantVector *CP = dyn_cast(C)) { + for (unsigned i = 0; i != NumElements; ++i) + Ops.push_back(getValue(CP->getOperand(i))); } else { - // Canonicalize all constant ints to be unsigned. - return N = DAG.getConstant(cast(C)->getValue(),VT); + assert(isa(C) && "Unknown vector constant!"); + SDOperand Op; + if (MVT::isFloatingPoint(PVT)) + Op = DAG.getConstantFP(0, PVT); + else + Op = DAG.getConstant(0, PVT); + Ops.assign(NumElements, Op); } + + // Create a BUILD_VECTOR node. + return NodeMap[V] = DAG.getNode(ISD::BUILD_VECTOR, VT, &Ops[0], Ops.size()); } + // If this is a static alloca, generate it as the frameindex instead of + // computation. if (const AllocaInst *AI = dyn_cast(V)) { std::map::iterator SI = - FuncInfo.StaticAllocaMap.find(AI); + FuncInfo.StaticAllocaMap.find(AI); if (SI != FuncInfo.StaticAllocaMap.end()) return DAG.getFrameIndex(SI->second, TLI.getPointerTy()); } @@ -1114,7 +1119,6 @@ RegsForValue RFV(TLI, InReg, VTy); SDOperand Chain = DAG.getEntryNode(); - return RFV.getCopyFromRegs(DAG, Chain, NULL); } @@ -1124,6 +1128,7 @@ DAG.setRoot(DAG.getNode(ISD::RET, MVT::Other, getControlRoot())); return; } + SmallVector NewValues; NewValues.push_back(getControlRoot()); for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i) { @@ -3600,7 +3605,7 @@ MachineFunction &MF = DAG.getMachineFunction(); - SmallVector Regs; + SmallVector Regs; // If this is a constraint for a single physreg, or a constraint for a // register class, find it. From dpatel at apple.com Mon Apr 28 01:49:24 2008 From: dpatel at apple.com (Devang Patel) Date: Sun, 27 Apr 2008 23:49:24 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r50333 - /llvm-gcc-4.2/trunk/build_gcc In-Reply-To: <38CD6817-7FBA-4C3F-9CDB-F99001D52ACD@gmail.com> References: <200804280513.m3S5D8LD016871@zion.cs.uiuc.edu> <38CD6817-7FBA-4C3F-9CDB-F99001D52ACD@gmail.com> Message-ID: On Apr 27, 2008, at 11:35 PM, Bill Wendling wrote: > If we do just sym-linking, then will coexistence still work? Yes. - Devang From clattner at apple.com Mon Apr 28 02:13:24 2008 From: clattner at apple.com (Chris Lattner) Date: Mon, 28 Apr 2008 00:13:24 -0700 Subject: [llvm-commits] [llvm] r50279 - in /llvm/trunk: lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp lib/Transforms/Scalar/CodeGenPrepare.cpp test/CodeGen/Generic/multiple-return-values-cross-block-with-invoke.ll In-Reply-To: <200804251827.m3PIRtH4003953@zion.cs.uiuc.edu> References: <200804251827.m3PIRtH4003953@zion.cs.uiuc.edu> Message-ID: On Apr 25, 2008, at 11:27 AM, Dan Gohman wrote: > URL: http://llvm.org/viewvc/llvm-project?rev=50279&view=rev > Log: > Remove the code from CodeGenPrepare that moved getresult instructions > to the block that defines their operands. This doesn't work in the > case that the operand is an invoke, because invoke is a terminator > and must be the last instruction in a block. Nice! Thanks for tackling this. > /// RegsForValue - This struct represents the physical registers > that a > /// particular value is assigned and the type information about > the value. > /// This is needed because values can be promoted into larger > registers and > /// expanded into multiple smaller registers than the value. > struct VISIBILITY_HIDDEN RegsForValue { This should probably explicitly mention how it handles aggregates. Maybe a good general summary up front could help my larger complaint next: ... > + /// RegVTs - The value types of the registers. This is the same > size > + /// as ValueVTs; every register contributing to a given value > must > + /// have the same type. When Regs contains all virtual > registers, the > + /// contents of RegVTs is redundant with TLI's getRegisterType > member > + /// function, however when Regs contains physical registers, it > is > + /// necessary to have a separate record of the types. > /// > + SmallVector RegVTs; > > + /// ValueVTs - The value types of the values, which may be > promoted > + /// or synthesized from one or more registers. > + SmallVector ValueVTs; The descriptions of these fields is not very clear to me. The description of RegVTs forward references ValueVTs, maybe ValueVTs should be moved first? It would be helpful to have an explanatory comment here with an example. For example, on PPC, how is {i8, i64} handled by these two vectors? Maybe 'Regs' should have a comment that indicates it can contain pregs? > > + > + RegsForValue() : TLI(0) {} > + > + RegsForValue(const TargetLowering &tli, > + unsigned Reg, MVT::ValueType regvt, MVT::ValueType > valuevt) > + : TLI(&tli), Regs(1, Reg), RegVTs(1, regvt), ValueVTs(1, > valuevt) {} > + RegsForValue(const TargetLowering &tli, > + const std::vector ®s, > MVT::ValueType regvt, MVT::ValueType valuevt) > + : TLI(&tli), Regs(regs), RegVTs(1, regvt), ValueVTs(1, > valuevt) {} > + RegsForValue(const TargetLowering &tli, > + const std::vector ®s, > + const SmallVector ®vts, > + const SmallVector &valuevts) > + : TLI(&tli), Regs(regs), RegVTs(regvts), ValueVTs(valuevts) {} > + RegsForValue(const TargetLowering &tli, > + unsigned Reg, const Type *Ty) : TLI(&tli) { So many ctors... would it be reasonable to change clients to use one of the more general ones instead of having so many ctors? > > + ComputeValueVTs(tli, Ty, ValueVTs); > + > + for (unsigned Value = 0; Value != ValueVTs.size(); ++Value) { Please add a comment explaining what this loop is doing. Does 'ValueVTs.size()' need to be recomputed on every iteration? > > + MVT::ValueType ValueVT = ValueVTs[Value]; > + unsigned NumRegs = TLI->getNumRegisters(ValueVT); > + MVT::ValueType RegisterVT = TLI->getRegisterType(ValueVT); > + for (unsigned i = 0; i != NumRegs; ++i) > + Regs.push_back(Reg + i); > + RegVTs.push_back(RegisterVT); > + Reg += NumRegs; > + } > } > @@ -310,16 +362,22 @@ > /// the correctly promoted or expanded types. Assign these registers > /// consecutive vreg numbers and return the first assigned number. > unsigned FunctionLoweringInfo::CreateRegForValue(const Value *V) { > + const Type *Ty = V->getType(); > + SmallVector ValueVTs; > + ComputeValueVTs(TLI, Ty, ValueVTs); > + > + unsigned FirstReg = 0; > + for (unsigned Value = 0; Value != ValueVTs.size(); ++Value) { > + MVT::ValueType ValueVT = ValueVTs[Value]; > + unsigned NumRegs = TLI.getNumRegisters(ValueVT); > + MVT::ValueType RegisterVT = TLI.getRegisterType(ValueVT); > > + for (unsigned i = 0; i != NumRegs; ++i) { > + unsigned R = MakeReg(RegisterVT); > + if (!FirstReg) FirstReg = R; > + } > + } > + return FirstReg; > } The comments in this method should be improved to talk about what it is now doing. Please mention aggregates. Could this code change to use RegsForValue to compute the expansion? Maybe it should be a new method on RegsForValue? > @@ -3898,8 +3985,9 @@ > if ((NumOps & 7) == 2 /*REGDEF*/) { > // Add NumOps>>3 registers to MatchedRegs. > RegsForValue MatchedRegs; > - MatchedRegs.ValueVT = InOperandVal.getValueType(); > - MatchedRegs.RegVT = AsmNodeOperands[CurOp > +1].getValueType(); > + MatchedRegs.TLI = &TLI; > + MatchedRegs.ValueVTs.resize(1, > InOperandVal.getValueType()); > + MatchedRegs.RegVTs.resize(1, AsmNodeOperands[CurOp > +1].getValueType()); Please use push_back, instead of resize(1, x) > @@ -4304,21 +4392,14 @@ > } > > // Figure out the result value types. We start by making a list of > + // the potentially illegal return value types. > SmallVector LoweredRetTys; > SmallVector RetTys; > + ComputeValueVTs(*this, RetTy, RetTys); > > + // Then we translate that to a list of legal types. > + for (unsigned I = 0, E = RetTys.size(); I != E; ++I) { > + MVT::ValueType VT = RetTys[I]; > MVT::ValueType RegisterVT = getRegisterType(VT); > unsigned NumRegs = getNumRegisters(VT); > for (unsigned i = 0; i != NumRegs; ++i) This seems like something that should be a method on RegsForValue. > @@ -4441,19 +4522,11 @@ > cast(Op.getOperand(1))->getReg() != Reg) && > "Copy from a reg to the same reg!"); > assert(!TargetRegisterInfo::isPhysicalRegister(Reg) && "Is a > physreg"); > + RegsForValue RFV(TLI, Reg, V->getType()); > + SDOperand Chain = DAG.getEntryNode(); > + RFV.getCopyToRegs(Op, DAG, Chain, 0); > + PendingExports.push_back(Chain); > } I'm not sure if your patch is responsible, but it is very strange to me that RegsForValue::getCopyToRegs takes 'Chain' byref and mutates the input. Should RegsForValue::getCopyToRegs return a new chain instead? Thanks again for doing working on this Dan! -Chris From sabre at nondot.org Mon Apr 28 02:16:35 2008 From: sabre at nondot.org (Chris Lattner) Date: Mon, 28 Apr 2008 07:16:35 -0000 Subject: [llvm-commits] [llvm] r50341 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <200804280716.m3S7GaHR020497@zion.cs.uiuc.edu> Author: lattner Date: Mon Apr 28 02:16:35 2008 New Revision: 50341 URL: http://llvm.org/viewvc/llvm-project?rev=50341&view=rev Log: Another collection of random cleanups. No functionality change. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=50341&r1=50340&r2=50341&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Mon Apr 28 02:16:35 2008 @@ -1040,9 +1040,8 @@ SDOperand &N = NodeMap[V]; if (N.Val) return N; - const Type *VTy = V->getType(); if (Constant *C = const_cast(dyn_cast(V))) { - MVT::ValueType VT = TLI.getValueType(VTy, true); + MVT::ValueType VT = TLI.getValueType(V->getType(), true); if (ConstantInt *CI = dyn_cast(C)) return N = DAG.getConstant(CI->getValue(), VT); @@ -1056,22 +1055,8 @@ if (ConstantFP *CFP = dyn_cast(C)) return N = DAG.getConstantFP(CFP->getValueAPF(), VT); - if (isa(C)) { - if (!isa(VTy)) - return N = DAG.getNode(ISD::UNDEF, VT); - - // Create a BUILD_VECTOR of undef nodes. - const VectorType *PTy = cast(VTy); - unsigned NumElements = PTy->getNumElements(); - MVT::ValueType PVT = TLI.getValueType(PTy->getElementType()); - - SmallVector Ops; - Ops.assign(NumElements, DAG.getNode(ISD::UNDEF, PVT)); - - // Create a VConstant node with generic Vector type. - MVT::ValueType VT = MVT::getVectorType(PVT, NumElements); - return N = DAG.getNode(ISD::BUILD_VECTOR, VT, &Ops[0], Ops.size()); - } + if (isa(C) && !isa(V->getType())) + return N = DAG.getNode(ISD::UNDEF, VT); if (ConstantExpr *CE = dyn_cast(C)) { visit(CE->getOpcode(), *CE); @@ -1080,24 +1065,27 @@ return N1; } - const VectorType *VecTy = cast(VTy); + const VectorType *VecTy = cast(V->getType()); unsigned NumElements = VecTy->getNumElements(); - MVT::ValueType PVT = TLI.getValueType(VecTy->getElementType()); - // Now that we know the number and type of the elements, push a - // Constant or ConstantFP node onto the ops list for each element of - // the vector constant. - SmallVector Ops; + // Now that we know the number and type of the elements, get that number of + // elements into the Ops array based on what kind of constant it is. + SmallVector Ops; if (ConstantVector *CP = dyn_cast(C)) { for (unsigned i = 0; i != NumElements; ++i) Ops.push_back(getValue(CP->getOperand(i))); } else { - assert(isa(C) && "Unknown vector constant!"); + assert((isa(C) || isa(C)) && + "Unknown vector constant!"); + MVT::ValueType EltVT = TLI.getValueType(VecTy->getElementType()); + SDOperand Op; - if (MVT::isFloatingPoint(PVT)) - Op = DAG.getConstantFP(0, PVT); + if (isa(C)) + Op = DAG.getNode(ISD::UNDEF, EltVT); + else if (MVT::isFloatingPoint(EltVT)) + Op = DAG.getConstantFP(0, EltVT); else - Op = DAG.getConstant(0, PVT); + Op = DAG.getConstant(0, EltVT); Ops.assign(NumElements, Op); } @@ -1117,7 +1105,7 @@ unsigned InReg = FuncInfo.ValueMap[V]; assert(InReg && "Value not in map!"); - RegsForValue RFV(TLI, InReg, VTy); + RegsForValue RFV(TLI, InReg, V->getType()); SDOperand Chain = DAG.getEntryNode(); return RFV.getCopyFromRegs(DAG, Chain, NULL); } @@ -3368,17 +3356,17 @@ if (isa(I.getOperand(0))) { SDOperand Undef = DAG.getNode(ISD::UNDEF, TLI.getValueType(I.getType())); setValue(&I, Undef); - } else { - SDOperand Call = getValue(I.getOperand(0)); - - // To add support for individual return values with aggregate types, - // we'd need a way to take a getresult index and determine which - // values of the Call SDNode are associated with it. - assert(TLI.getValueType(I.getType(), true) != MVT::Other && - "Individual return values must not be aggregates!"); - - setValue(&I, SDOperand(Call.Val, I.getIndex())); + return; } + + // To add support for individual return values with aggregate types, + // we'd need a way to take a getresult index and determine which + // values of the Call SDNode are associated with it. + assert(TLI.getValueType(I.getType(), true) != MVT::Other && + "Individual return values must not be aggregates!"); + + SDOperand Call = getValue(I.getOperand(0)); + setValue(&I, SDOperand(Call.Val, I.getIndex())); } @@ -3387,23 +3375,27 @@ /// Chain/Flag as the input and updates them for the output Chain/Flag. /// If the Flag pointer is NULL, no flag is used. SDOperand RegsForValue::getCopyFromRegs(SelectionDAG &DAG, - SDOperand &Chain, SDOperand *Flag)const{ + SDOperand &Chain, + SDOperand *Flag) const { // Assemble the legal parts into the final values. SmallVector Values(ValueVTs.size()); - for (unsigned Value = 0, Part = 0; Value != ValueVTs.size(); ++Value) { + SmallVector Parts; + for (unsigned Value = 0, Part = 0, e = ValueVTs.size(); Value != e; ++Value) { // Copy the legal parts from the registers. MVT::ValueType ValueVT = ValueVTs[Value]; unsigned NumRegs = TLI->getNumRegisters(ValueVT); MVT::ValueType RegisterVT = RegVTs[Value]; - SmallVector Parts(NumRegs); + Parts.resize(NumRegs); for (unsigned i = 0; i != NumRegs; ++i) { - SDOperand P = Flag ? - DAG.getCopyFromReg(Chain, Regs[Part+i], RegisterVT, *Flag) : - DAG.getCopyFromReg(Chain, Regs[Part+i], RegisterVT); - Chain = P.getValue(1); - if (Flag) + SDOperand P; + if (Flag == 0) + P = DAG.getCopyFromReg(Chain, Regs[Part+i], RegisterVT); + else { + P = DAG.getCopyFromReg(Chain, Regs[Part+i], RegisterVT, *Flag); *Flag = P.getValue(2); + } + Chain = P.getValue(1); Parts[Part+i] = P; } @@ -3411,6 +3403,10 @@ ValueVT); Part += NumRegs; } + + if (ValueVTs.size() == 1) + return Values[0]; + return DAG.getNode(ISD::MERGE_VALUES, DAG.getVTList(&ValueVTs[0], ValueVTs.size()), &Values[0], ValueVTs.size()); @@ -3425,7 +3421,7 @@ // Get the list of the values's legal parts. unsigned NumRegs = Regs.size(); SmallVector Parts(NumRegs); - for (unsigned Value = 0, Part = 0; Value != ValueVTs.size(); ++Value) { + for (unsigned Value = 0, Part = 0, e = ValueVTs.size(); Value != e; ++Value) { MVT::ValueType ValueVT = ValueVTs[Value]; unsigned NumParts = TLI->getNumRegisters(ValueVT); MVT::ValueType RegisterVT = RegVTs[Value]; @@ -3438,14 +3434,20 @@ // Copy the parts into the registers. SmallVector Chains(NumRegs); for (unsigned i = 0; i != NumRegs; ++i) { - SDOperand Part = Flag ? - DAG.getCopyToReg(Chain, Regs[i], Parts[i], *Flag) : - DAG.getCopyToReg(Chain, Regs[i], Parts[i]); - Chains[i] = Part.getValue(0); - if (Flag) + SDOperand Part; + if (Flag == 0) + Part = DAG.getCopyToReg(Chain, Regs[i], Parts[i]); + else { + Part = DAG.getCopyToReg(Chain, Regs[i], Parts[i], *Flag); *Flag = Part.getValue(1); + } + Chains[i] = Part.getValue(0); } - Chain = DAG.getNode(ISD::TokenFactor, MVT::Other, &Chains[0], NumRegs); + + if (NumRegs == 1) + Chain = Chains[0]; + else + Chain = DAG.getNode(ISD::TokenFactor, MVT::Other, &Chains[0], NumRegs); } /// AddInlineAsmOperands - Add this value to the specified inlineasm node @@ -3455,15 +3457,11 @@ std::vector &Ops) const { MVT::ValueType IntPtrTy = DAG.getTargetLoweringInfo().getPointerTy(); Ops.push_back(DAG.getTargetConstant(Code | (Regs.size() << 3), IntPtrTy)); - for (unsigned Value = 0, Reg = 0; Value != ValueVTs.size(); ++Value) { - MVT::ValueType ValueVT = ValueVTs[Value]; - unsigned NumRegs = TLI->getNumRegisters(ValueVT); + for (unsigned Value = 0, Reg = 0, e = ValueVTs.size(); Value != e; ++Value) { + unsigned NumRegs = TLI->getNumRegisters(ValueVTs[Value]); MVT::ValueType RegisterVT = RegVTs[Value]; - for (unsigned i = 0; i != NumRegs; ++i) { - SDOperand RegOp = DAG.getRegister(Regs[Reg+i], RegisterVT); - Ops.push_back(RegOp); - } - Reg += NumRegs; + for (unsigned i = 0; i != NumRegs; ++i) + Ops.push_back(DAG.getRegister(Regs[Reg++], RegisterVT)); } } @@ -4524,8 +4522,7 @@ return true; } -void SelectionDAGLowering::CopyValueToVirtualRegister(Value *V, - unsigned Reg) { +void SelectionDAGLowering::CopyValueToVirtualRegister(Value *V, unsigned Reg) { SDOperand Op = getValue(V); assert((Op.getOpcode() != ISD::CopyFromReg || cast(Op.getOperand(1))->getReg() != Reg) && From asl at math.spbu.ru Mon Apr 28 02:40:07 2008 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Mon, 28 Apr 2008 07:40:07 -0000 Subject: [llvm-commits] [llvm] r50342 - /llvm/trunk/lib/Target/X86/X86CallingConv.td Message-ID: <200804280740.m3S7e7MU026455@zion.cs.uiuc.edu> Author: asl Date: Mon Apr 28 02:40:07 2008 New Revision: 50342 URL: http://llvm.org/viewvc/llvm-project?rev=50342&view=rev Log: Fix FP return for Win64 ABI Modified: llvm/trunk/lib/Target/X86/X86CallingConv.td Modified: llvm/trunk/lib/Target/X86/X86CallingConv.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CallingConv.td?rev=50342&r1=50341&r2=50342&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86CallingConv.td (original) +++ llvm/trunk/lib/Target/X86/X86CallingConv.td Mon Apr 28 02:40:07 2008 @@ -83,6 +83,10 @@ // The X86-Win64 calling convention always returns __m64 values in RAX. CCIfType<[v8i8, v4i16, v2i32, v1i64], CCAssignToReg<[RAX]>>, + // And FP in XMM0 only. + CCIfType<[f32], CCAssignToReg<[XMM0]>>, + CCIfType<[f64], CCAssignToReg<[XMM0]>>, + // Otherwise, everything is the same as 'normal' X86-64 C CC. CCDelegateTo ]>; From nicolas.geoffray at lip6.fr Mon Apr 28 03:49:15 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 28 Apr 2008 08:49:15 -0000 Subject: [llvm-commits] [vmkit] r50343 - /vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp Message-ID: <200804280849.m3S8nF0v031239@zion.cs.uiuc.edu> Author: geoffray Date: Mon Apr 28 03:49:14 2008 New Revision: 50343 URL: http://llvm.org/viewvc/llvm-project?rev=50343&view=rev Log: Do no empty used_nodes after a collection: otherwise all objects previously allocated will never be collected. Modified: vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp Modified: vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp?rev=50343&r1=50342&r2=50343&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp (original) +++ vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp Mon Apr 28 03:49:14 2008 @@ -91,7 +91,6 @@ //printf(" !!!! reject %p [%p]\n", cur->chunk()->_2gc(), cur); allocator->reject_chunk(cur); } - used_nodes->alone(); } void GCCollector::collect_unprotect() { From nicolas.geoffray at lip6.fr Mon Apr 28 03:51:16 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 28 Apr 2008 08:51:16 -0000 Subject: [llvm-commits] [vmkit] r50344 - in /vmkit/trunk/lib/JnJVM: Classpath/ClasspathVMRuntime.cpp VMCore/NativeUtil.cpp Message-ID: <200804280851.m3S8pGex031311@zion.cs.uiuc.edu> Author: geoffray Date: Mon Apr 28 03:51:15 2008 New Revision: 50344 URL: http://llvm.org/viewvc/llvm-project?rev=50344&view=rev Log: A service environment shares the native libraries with the bootstrap virtual machine. Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp vmkit/trunk/lib/JnJVM/VMCore/NativeUtil.cpp Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp?rev=50344&r1=50343&r2=50344&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp (original) +++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp Mon Apr 28 03:51:15 2008 @@ -66,7 +66,11 @@ jobject _str, jobject _loader) { JavaString* str = (JavaString*)_str; +#ifndef SERVICE_VM Jnjvm* vm = JavaThread::get()->isolate; +#else + Jnjvm* vm = Jnjvm::bootstrapVM; +#endif char* buf = str->strToAsciiz(); Modified: vmkit/trunk/lib/JnJVM/VMCore/NativeUtil.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/NativeUtil.cpp?rev=50344&r1=50343&r2=50344&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/NativeUtil.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/NativeUtil.cpp Mon Apr 28 03:51:15 2008 @@ -182,7 +182,11 @@ static void* loadName(char* buf, bool& jnjvm) { void* res = dlsym(0, buf); if (!res) { - Jnjvm *vm = JavaThread::get()->isolate; +#ifndef SERVICE_VM + Jnjvm* vm = JavaThread::get()->isolate; +#else + Jnjvm* vm = Jnjvm::bootstrapVM; +#endif for (std::vector::iterator i = vm->nativeLibs.begin(), e = vm->nativeLibs.end(); i!= e; ++i) { res = dlsym((*i), buf); From nicolas.geoffray at lip6.fr Mon Apr 28 04:00:49 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 28 Apr 2008 09:00:49 -0000 Subject: [llvm-commits] [vmkit] r50345 - /vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp Message-ID: <200804280900.m3S90oV3031608@zion.cs.uiuc.edu> Author: geoffray Date: Mon Apr 28 04:00:49 2008 New Revision: 50345 URL: http://llvm.org/viewvc/llvm-project?rev=50345&view=rev Log: A type in a constant pool is allocated on behalf of the class of the constant pool. Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp?rev=50345&r1=50344&r2=50345&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp Mon Apr 28 04:00:49 2008 @@ -343,7 +343,7 @@ } sint32 entry = ctpDef[index]; const UTF8* type = UTF8At(entry & 0xFFFF); - Typedef* sign = JavaThread::get()->isolate->constructType(type); + Typedef* sign = classDef->isolate->constructType(type); ctpRes[index] = sign; return sign; } From nicolas.geoffray at lip6.fr Mon Apr 28 04:01:56 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 28 Apr 2008 09:01:56 -0000 Subject: [llvm-commits] [vmkit] r50346 - /vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp Message-ID: <200804280901.m3S91uud031650@zion.cs.uiuc.edu> Author: geoffray Date: Mon Apr 28 04:01:56 2008 New Revision: 50346 URL: http://llvm.org/viewvc/llvm-project?rev=50346&view=rev Log: At startup of a service environment, allocate a bootstrap service that will bootstrap the JVM. Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp?rev=50346&r1=50345&r2=50346&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp Mon Apr 28 04:01:56 2008 @@ -30,6 +30,10 @@ #include "LockedMap.h" #include "Zip.h" +#ifdef SERVICE_VM +#include "ServiceDomain.h" +#endif + using namespace jnjvm; static void initialiseVT() { @@ -69,6 +73,9 @@ INIT(JavaString); INIT(CacheNode); INIT(Enveloppe); +#ifdef SERVICE_VM + INIT(ServiceDomain); +#endif #undef INIT #define INIT(X) { \ @@ -204,7 +211,6 @@ void handler(int val, siginfo_t* info, void* addr) { printf("Crash in JnJVM at %p\n", addr); - JavaJIT::printBacktrace(); assert(0); } @@ -237,11 +243,16 @@ } extern "C" int start_app(int argc, char** argv) { -#if defined(SERVICE_VM) || !defined(MULTIPLE_VM) +#if !defined(MULTIPLE_VM) JavaIsolate* vm = (JavaIsolate*)JavaIsolate::bootstrapVM; #else +#ifdef SERVICE_VM + ServiceDomain* vm = ServiceDomain::allocateService((JavaIsolate*)Jnjvm::bootstrapVM); + JavaThread::get()->isolate = vm; +#else JavaIsolate* vm = JavaIsolate::allocateIsolate(JavaIsolate::bootstrapVM); #endif +#endif vm->runMain(argc, argv); return 0; } From nicolas.geoffray at lip6.fr Mon Apr 28 04:03:04 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 28 Apr 2008 09:03:04 -0000 Subject: [llvm-commits] [vmkit] r50347 - /vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp Message-ID: <200804280903.m3S934nL032140@zion.cs.uiuc.edu> Author: geoffray Date: Mon Apr 28 04:03:03 2008 New Revision: 50347 URL: http://llvm.org/viewvc/llvm-project?rev=50347&view=rev Log: Classes meta-globalvariable can be emitted even if they are not ready (ie clinited). Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp?rev=50347&r1=50346&r2=50347&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp Mon Apr 28 04:03:03 2008 @@ -1842,7 +1842,7 @@ BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock); currentBlock = ifFalse; Value* clVar = 0; - if (dcl && dcl->isReady()) { + if (dcl) { clVar = new LoadInst(dcl->llvmVar(compilingClass->isolate->module), "", ifFalse); } else { clVar = getResolvedClass(index, false); @@ -1879,7 +1879,7 @@ compilingClass->ctpInfo->getMethodClassIfLoaded(index); Value* clVar = 0; - if (dcl && dcl->isReady()) { + if (dcl) { clVar = new LoadInst(dcl->llvmVar(compilingClass->isolate->module), "", currentBlock); } else { clVar = getResolvedClass(index, false); From nicolas.geoffray at lip6.fr Mon Apr 28 04:21:34 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 28 Apr 2008 09:21:34 -0000 Subject: [llvm-commits] [vmkit] r50348 - in /vmkit/trunk/lib/JnJVM/VMCore: JavaClass.cpp JavaClass.h JavaIsolate.cpp JavaJIT.cpp JavaJIT.h JavaJITInitialise.cpp JavaMetaJIT.cpp JavaRuntimeJIT.cpp Jnjvm.cpp LockedMap.h ServiceDomain.cpp VirtualTables.cpp Message-ID: <200804280921.m3S9LZPd032756@zion.cs.uiuc.edu> Author: geoffray Date: Mon Apr 28 04:21:34 2008 New Revision: 50348 URL: http://llvm.org/viewvc/llvm-project?rev=50348&view=rev Log: Multi-vm improvements: - Correct initialization of classes (JavaState and vm argument) - Static instances of classes loaded by app class loaders are not unique anymore (make room for code sharing between class loaders) - getstatic and putstatic: when the class is not resolved, the runtime callback does not update the global variable and index, just the constant pool. Service-vm improvements: - Check if a call is a service call in the called function, not in the caller (TODO: optimize static calls since we know at compilation time if it's a service call or not). Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp vmkit/trunk/lib/JnJVM/VMCore/LockedMap.h vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp?rev=50348&r1=50347&r2=50348&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp Mon Apr 28 04:21:34 2008 @@ -608,15 +608,10 @@ #ifdef MULTIPLE_VM JavaObject* Class::staticInstance() { - if (isolate == Jnjvm::bootstrapVM) { - Class* cl = this; - std::pair* val = - JavaThread::get()->isolate->statics->lookup(cl); - assert(val); - return val->second; - } else { - return _staticInstance; - } + std::pair* val = + JavaThread::get()->isolate->statics->lookup(this); + assert(val); + return val->second; } void Class::createStaticInstance() { @@ -629,35 +624,28 @@ (*i)->initField(val); } - if (isolate == Jnjvm::bootstrapVM) { - std::pair* v = - new std::pair(0, val); - JavaThread::get()->isolate->statics->hash(this, v); - } else { - _staticInstance = val; - } + + Jnjvm* vm = JavaThread::get()->isolate; + std::pair* p = vm->statics->lookup(this); + assert(p); + assert(!p->second); + p->second = val; } -bool CommonClass::isReady() { - if (isolate == Jnjvm::bootstrapVM && !this->isArray && +JavaState* CommonClass::getStatus() { + if (!this->isArray && !AssessorDesc::bogusClassToPrimitive(this)) { Class* cl = (Class*)this; - std::pair* val = - JavaThread::get()->isolate->statics->lookup(cl); - return val && val->first; - } else { - return status == ready; - } -} - -void CommonClass::setReady() { - if (isolate == Jnjvm::bootstrapVM && !this->isArray && - !AssessorDesc::bogusClassToPrimitive(this)) { - std::pair* val = - JavaThread::get()->isolate->statics->lookup((Class*)this); - val->first = 1; + Jnjvm* vm = JavaThread::get()->isolate; + std::pair* val = vm->statics->lookup(cl); + if (!val) { + val = new std::pair(status, 0); + JavaThread::get()->isolate->statics->hash(cl, val); + } + if (val->first < status) val->first = status; + return (JavaState*)&(val->first); } else { - status = ready; + return &status; } } #endif Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h?rev=50348&r1=50347&r2=50348&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h Mon Apr 28 04:21:34 2008 @@ -35,6 +35,7 @@ class Class; class JavaCtpInfo; class JavaField; +class JavaJIT; class JavaMethod; class JavaObject; class Jnjvm; @@ -73,6 +74,8 @@ }; class CommonClass : public mvm::Object { +public: + JavaObject* classLoader; private: llvm::GlobalVariable* _llvmVar; #ifndef MULTIPLE_VM @@ -93,7 +96,6 @@ std::vector staticMethods; std::vector virtualFields; std::vector staticFields; - JavaObject* classLoader; #ifndef MULTIPLE_VM JavaObject* delegatee; #endif @@ -147,15 +149,17 @@ void resolveClass(bool doClinit); #ifndef MULTIPLE_VM + JavaState* getStatus() { + return &status; + } bool isReady() { return status == ready; } - void setReady() { - status = ready; - } #else - bool isReady(); - void setReady(); + JavaState* getStatus(); + bool isReady() { + return *getStatus() == ready; + } #endif bool isResolved() { return status >= resolved; @@ -171,7 +175,6 @@ unsigned int minor; unsigned int major; ArrayUInt8* bytes; - JavaObject* _staticInstance; JavaObject* virtualInstance; llvm::Function* virtualTracer; llvm::Function* staticTracer; @@ -185,7 +188,7 @@ bool innerOuterResolved; void resolveFields(); - llvm::Value* staticVar(llvm::Module* compilingModule, llvm::BasicBlock* BB); + llvm::Value* staticVar(JavaJIT* jit); uint64 virtualSize; VirtualTable* virtualVT; @@ -200,6 +203,7 @@ JavaObject* operator()(Jnjvm* vm); #ifndef MULTIPLE_VM + JavaObject* _staticInstance; JavaObject* staticInstance() { return _staticInstance; } Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp?rev=50348&r1=50347&r2=50348&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp Mon Apr 28 04:21:34 2008 @@ -29,6 +29,10 @@ #include "LockedMap.h" #include "Zip.h" +#ifdef SERVICE_VM +#include "ServiceDomain.h" +#endif + #define PATH_MANIFEST "META-INF/MANIFEST.MF" #define MAIN_CLASS "Main-Class: " #define PREMAIN_CLASS "Premain-Class: " @@ -382,6 +386,9 @@ argc = argc - pos + 1; loadBootstrap(); +#ifdef SERVICE_VM + (*Classpath::vmdataClassLoader)(appClassLoader, (JavaObject*)this); +#endif if (info.agents.size()) { assert(0 && "implement me"); @@ -397,7 +404,7 @@ for (int i = 2; i < argc; ++i) { args->setAt(i - 2, (JavaObject*)asciizToStr(argv[i])); } - + executeClass(info.className, args); waitForExit(); } Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp?rev=50348&r1=50347&r2=50348&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Mon Apr 28 04:21:34 2008 @@ -98,7 +98,7 @@ uint32 JavaJIT::stackSize() { return stack.size(); } - + void JavaJIT::invokeVirtual(uint16 index) { JavaCtpInfo* ctpInfo = compilingClass->ctpInfo; @@ -109,7 +109,8 @@ if ((cl && isFinal(cl->access)) || (meth && (isFinal(meth->access) || isPrivate(meth->access)))) return invokeSpecial(index); - + + #ifndef WITHOUT_VTABLE Constant* zero = mvm::jit::constantZero; Signdef* signature = ctpInfo->infoOfInterfaceOrVirtualMethod(index); @@ -119,7 +120,7 @@ makeArgs(it, index, args, signature->nbIn + 1); JITVerifyNull(args[0]); - + std::vector indexes; //[3]; indexes.push_back(zero); indexes.push_back(zero); @@ -174,7 +175,9 @@ Value* Func = new LoadInst(FuncPtr, "", currentBlock); Func = new BitCastInst(Func, signature->virtualTypePtr, "", currentBlock); + Value* val = invoke(Func, args, "", currentBlock); + const llvm::Type* retType = signature->virtualType->getReturnType(); if (retType != Type::VoidTy) { push(val, signature->ret->funcs); @@ -182,6 +185,7 @@ push(mvm::jit::constantZero, AssessorDesc::dInt); } } + #else return invokeInterfaceOrVirtual(index); #endif @@ -299,8 +303,7 @@ if (isVirtual(compilingMethod->access)) { argsSync.push_back(llvmFunction->arg_begin()); } else { - Module* M = compilingClass->isolate->module; - Value* arg = compilingClass->staticVar(M, currentBlock); + Value* arg = compilingClass->staticVar(this); argsSync.push_back(arg); } llvm::CallInst::Create(aquireObjectLLVM, argsSync.begin(), argsSync.end(), @@ -312,8 +315,7 @@ if (isVirtual(compilingMethod->access)) { argsSync.push_back(llvmFunction->arg_begin()); } else { - Module* M = compilingClass->isolate->module; - Value* arg = compilingClass->staticVar(M, currentBlock); + Value* arg = compilingClass->staticVar(this); argsSync.push_back(arg); } llvm::CallInst::Create(releaseObjectLLVM, argsSync.begin(), argsSync.end(), "", @@ -349,6 +351,7 @@ const FunctionType *funcType = compilingMethod->llvmType; returnType = funcType->getReturnType(); + endBlock = createBasicBlock("end"); llvmFunction = parentFunction; currentBlock = curBB; @@ -409,13 +412,25 @@ JavaObject* loader = compilingClass->classLoader; ServiceDomain* vm = ServiceDomain::getDomainFromLoader(loader); isolateLocal = new LoadInst(vm->llvmDelegatee(), "", currentBlock); + Value* cmp = new ICmpInst(ICmpInst::ICMP_NE, args[args.size() - 1], + isolateLocal, "", currentBlock); + BasicBlock* ifTrue = createBasicBlock("true service call"); + BasicBlock* endBlock = createBasicBlock("end check service call"); + BranchInst::Create(ifTrue, endBlock, cmp, currentBlock); + currentBlock = ifTrue; + std::vector Args; + Args.push_back(args[args.size()- 1]); + Args.push_back(isolateLocal); + CallInst::Create(ServiceDomain::serviceCallStartLLVM, Args.begin(), + Args.end(), "", currentBlock); + BranchInst::Create(endBlock, currentBlock); + currentBlock = endBlock; } #endif #endif exploreOpcodes(&compilingClass->bytes->elements[start], codeLen); - endBlock = createBasicBlock("end"); if (returnType != Type::VoidTy) { endNode = llvm::PHINode::Create(returnType, "", endBlock); @@ -425,6 +440,25 @@ PRINT_DEBUG(JNJVM_COMPILE, 1, COLOR_NORMAL, "--> end inline compiling %s\n", compilingMethod->printString()); + +#if defined(SERVICE_VM) + if (compilingClass->isolate != Jnjvm::bootstrapVM) { + Value* cmp = new ICmpInst(ICmpInst::ICMP_NE, args[args.size() - 1], + isolateLocal, "", currentBlock); + BasicBlock* ifTrue = createBasicBlock("true service call"); + BasicBlock* newEndBlock = createBasicBlock("end check service call"); + BranchInst::Create(ifTrue, newEndBlock, cmp, currentBlock); + currentBlock = ifTrue; + std::vector Args; + Args.push_back(args[args.size() - 1]); + Args.push_back(isolateLocal); + CallInst::Create(ServiceDomain::serviceCallStopLLVM, Args.begin(), + Args.end(), "", currentBlock); + BranchInst::Create(newEndBlock, currentBlock); + currentBlock = newEndBlock; + endBlock = currentBlock; + } +#endif curBB = endBlock; return endNode; @@ -460,7 +494,7 @@ Function* func = llvmFunction = compilingMethod->llvmFunction; - BasicBlock* startBlock = currentBlock = createBasicBlock("start"); + currentBlock = createBasicBlock("start"); endExceptionBlock = createBasicBlock("endExceptionBlock"); unifiedUnreachable = createBasicBlock("unifiedUnreachable"); @@ -481,9 +515,7 @@ } #endif - unsigned nbe = readExceptionTable(reader); - currentBlock = startBlock; for (int i = 0; i < maxLocals; i++) { intLocals.push_back(new AllocaInst(Type::Int32Ty, "", currentBlock)); @@ -534,10 +566,25 @@ JavaObject* loader = compilingClass->classLoader; ServiceDomain* vm = ServiceDomain::getDomainFromLoader(loader); isolateLocal = new LoadInst(vm->llvmDelegatee(), "", currentBlock); + Value* cmp = new ICmpInst(ICmpInst::ICMP_NE, i, isolateLocal, "", + currentBlock); + BasicBlock* ifTrue = createBasicBlock("true service call"); + BasicBlock* endBlock = createBasicBlock("end check service call"); + BranchInst::Create(ifTrue, endBlock, cmp, currentBlock); + currentBlock = ifTrue; + std::vector Args; + Args.push_back(i); + Args.push_back(isolateLocal); + CallInst::Create(ServiceDomain::serviceCallStartLLVM, Args.begin(), + Args.end(), "", currentBlock); + BranchInst::Create(endBlock, currentBlock); + currentBlock = endBlock; } #endif #endif + unsigned nbe = readExceptionTable(reader); + exploreOpcodes(&compilingClass->bytes->elements[start], codeLen); @@ -567,11 +614,29 @@ currentBlock); } #endif + +#if defined(SERVICE_VM) + if (compilingClass->isolate != Jnjvm::bootstrapVM) { + Value* cmp = new ICmpInst(ICmpInst::ICMP_NE, i, isolateLocal, "", + currentBlock); + BasicBlock* ifTrue = createBasicBlock("true service call"); + BasicBlock* newEndBlock = createBasicBlock("end check service call"); + BranchInst::Create(ifTrue, newEndBlock, cmp, currentBlock); + currentBlock = ifTrue; + std::vector Args; + Args.push_back(i); + Args.push_back(isolateLocal); + CallInst::Create(ServiceDomain::serviceCallStopLLVM, Args.begin(), + Args.end(), "", currentBlock); + BranchInst::Create(newEndBlock, currentBlock); + currentBlock = newEndBlock; + } +#endif if (returnType != Type::VoidTy) - llvm::ReturnInst::Create(endNode, endBlock); + llvm::ReturnInst::Create(endNode, currentBlock); else - llvm::ReturnInst::Create(endBlock); + llvm::ReturnInst::Create(currentBlock); pred_iterator PI = pred_begin(endExceptionBlock); pred_iterator PE = pred_end(endExceptionBlock); @@ -623,6 +688,7 @@ unsigned JavaJIT::readExceptionTable(Reader* reader) { + BasicBlock* temp = currentBlock; uint16 nbe = reader->readU2(); std::vector exceptions; unsigned sync = isSynchro(compilingMethod->access) ? 1 : 0; @@ -634,6 +700,7 @@ } BasicBlock* realEndExceptionBlock = endExceptionBlock; + currentExceptionBlock = endExceptionBlock; if (sync) { BasicBlock* synchronizeExceptionBlock = createBasicBlock("synchronizeExceptionBlock"); @@ -644,8 +711,7 @@ if (isVirtual(compilingMethod->access)) { argsSync.push_back(llvmFunction->arg_begin()); } else { - Value* arg = compilingClass->staticVar(compilingClass->isolate->module, - currentBlock); + Value* arg = compilingClass->staticVar(this); argsSync.push_back(arg); } llvm::CallInst::Create(releaseObjectLLVM, argsSync.begin(), argsSync.end(), @@ -817,7 +883,8 @@ e = exceptions.end(); i!= e; ++i) { delete *i; } - + + currentBlock = temp; return nbe; } @@ -850,9 +917,7 @@ const UTF8* utf8 = ctpInfo->UTF8At(ctpInfo->ctpDef[index]); void* val = 0; GlobalVariable* gv = 0; -#ifdef MULTIPLE_VM - if (compilingClass->isolate != Jnjvm::bootstrapVM) { -#endif +#ifndef MULTIPLE_VM val = compilingClass->isolate->UTF8ToStr(utf8); compilingClass->isolate->protectModule->lock(); gv = @@ -861,8 +926,7 @@ constantJavaObjectNull, "", compilingClass->isolate->module); compilingClass->isolate->protectModule->unlock(); -#ifdef MULTIPLE_VM - } else { +#else val = (void*)utf8; compilingClass->isolate->protectModule->lock(); gv = @@ -871,7 +935,6 @@ constantUTF8Null, "", compilingClass->isolate->module); compilingClass->isolate->protectModule->unlock(); - } #endif // TODO: put an initialiser in here @@ -893,13 +956,12 @@ currentBlock); } #ifdef MULTIPLE_VM - if (compilingClass->isolate == Jnjvm::bootstrapVM) { - CallInst* C = llvm::CallInst::Create(runtimeUTF8ToStrLLVM, toPush, "", - currentBlock); - push(C, AssessorDesc::dRef); - } else -#endif + CallInst* C = llvm::CallInst::Create(runtimeUTF8ToStrLLVM, toPush, "", + currentBlock); + push(C, AssessorDesc::dRef); +#else push(toPush, AssessorDesc::dRef); +#endif } else if (type == JavaCtpInfo::ConstantLong) { mvm::jit::protectConstants();//->lock(); push(ConstantInt::get(Type::Int64Ty, ctpInfo->LongAt(index)), @@ -1285,7 +1347,7 @@ if (!val) { Function* func = ctpInfo->infoOfStaticOrSpecialMethod(index, ACC_VIRTUAL, signature, meth); -#ifdef SERVICE_VM +#if 0//def SERVICE_VM bool serviceCall = false; if (meth && meth->classDef->classLoader != compilingClass->classLoader && meth->classDef->isolate != Jnjvm::bootstrapVM){ @@ -1294,7 +1356,7 @@ serviceCall = true; std::vector Args; Args.push_back(isolateLocal); - Args.push_back(calling->llvmDelegatee()); + Args.push_back(new LoadInst(calling->llvmDelegatee(), "", currentBlock)); CallInst::Create(ServiceDomain::serviceCallStartLLVM, Args.begin(), Args.end(), "", currentBlock); } @@ -1307,14 +1369,14 @@ val = invoke(func, args, "", currentBlock); } -#ifdef SERVICE_VM +#if 0//def SERVICE_VM if (serviceCall) { JavaObject* loader = meth->classDef->classLoader; ServiceDomain* calling = ServiceDomain::getDomainFromLoader(loader); serviceCall = true; std::vector Args; Args.push_back(isolateLocal); - Args.push_back(calling->llvmDelegatee()); + Args.push_back(new LoadInst(calling->llvmDelegatee(), "", currentBlock)); CallInst::Create(ServiceDomain::serviceCallStopLLVM, Args.begin(), Args.end(), "", currentBlock); } @@ -1353,7 +1415,7 @@ Function* func = ctpInfo->infoOfStaticOrSpecialMethod(index, ACC_STATIC, signature, meth); -#ifdef SERVICE_VM +#if 0//def SERVICE_VM bool serviceCall = false; if (meth && meth->classDef->classLoader != compilingClass->classLoader && meth->classDef->isolate != Jnjvm::bootstrapVM){ @@ -1362,7 +1424,7 @@ serviceCall = true; std::vector Args; Args.push_back(isolateLocal); - Args.push_back(calling->llvmDelegatee()); + Args.push_back(new LoadInst(calling->llvmDelegatee(), "", currentBlock)); CallInst::Create(ServiceDomain::serviceCallStartLLVM, Args.begin(), Args.end(), "", currentBlock); } @@ -1375,13 +1437,13 @@ val = invoke(func, args, "", currentBlock); } -#ifdef SERVICE_VM +#if 0//def SERVICE_VM if (serviceCall) { JavaObject* loader = meth->classDef->classLoader; ServiceDomain* calling = ServiceDomain::getDomainFromLoader(loader); std::vector Args; Args.push_back(isolateLocal); - Args.push_back(calling->llvmDelegatee()); + Args.push_back(new LoadInst(calling->llvmDelegatee(), "", currentBlock)); CallInst::Create(ServiceDomain::serviceCallStopLLVM, Args.begin(), Args.end(), "", currentBlock); } @@ -1476,11 +1538,9 @@ Value* load = new LoadInst(cl->llvmVar(compilingClass->isolate->module), "", currentBlock); #ifdef MULTIPLE_VM - if (cl->isolate == Jnjvm::bootstrapVM) { - Module* M = compilingClass->isolate->module; - Value* arg = new LoadInst(cl->llvmVar(M), "", currentBlock); - invoke(initialisationCheckLLVM, arg, "", currentBlock); - } + Module* M = compilingClass->isolate->module; + Value* arg = new LoadInst(cl->llvmVar(M), "", currentBlock); + invoke(initialisationCheckLLVM, arg, "", currentBlock); val = invoke(doNewLLVM, load, isolateLocal, "", currentBlock); #else val = invoke(doNewLLVM, load, "", currentBlock); @@ -1531,16 +1591,9 @@ && field->classDef->isReady() #endif ) { - Module* M = compilingClass->isolate->module; - if (stat) object = field->classDef->staticVar(M, currentBlock); + if (stat) object = field->classDef->staticVar(this); const Type* type = stat ? field->classDef->staticType : field->classDef->virtualType; -#ifdef MULTIPLE_VM - if (stat && field->classDef->isolate == Jnjvm::bootstrapVM) { - Value* arg = new LoadInst(field->classDef->llvmVar(M), "", currentBlock); - invoke(initialisationCheckLLVM, arg, "", currentBlock); - } -#endif return fieldGetter(this, type, object, field->offset); } else { const Type* Pty = mvm::jit::arrayPtrType; @@ -1607,15 +1660,6 @@ llvm::BranchInst::Create(endBlock, currentBlock); currentBlock = endBlock;; -#ifdef MULTIPLE_VM - if (stat) { - std::vector args; - Value* val = new LoadInst(compilingClass->llvmVar(M), "", currentBlock); - args.push_back(val); - args.push_back(CI); - invoke(initialisationCheckCtpLLVM, args, "", currentBlock); - } -#endif return new BitCastInst(node, fieldTypePtr, "", currentBlock); } } Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h?rev=50348&r1=50347&r2=50348&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h Mon Apr 28 04:21:34 2008 @@ -252,7 +252,6 @@ static llvm::Function* doNewUnknownLLVM; #ifdef MULTIPLE_VM static llvm::Function* initialisationCheckLLVM; - static llvm::Function* initialisationCheckCtpLLVM; #endif static llvm::Function* initialiseObjectLLVM; static llvm::Function* newLookupLLVM; Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp?rev=50348&r1=50347&r2=50348&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp Mon Apr 28 04:21:34 2008 @@ -232,20 +232,7 @@ initialisationCheckLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "initialisationCheck", module); - } - - // Create initialisationCheckCtpLLVM - { - std::vector args; - args.push_back(mvm::jit::ptrType); - args.push_back(Type::Int32Ty); - const FunctionType* type = FunctionType::get(Type::VoidTy, args, - false); - - initialisationCheckCtpLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "initialisationCheckCtp", - module); - } + } #endif @@ -518,7 +505,8 @@ // Create getStaticInstanceLLVM { std::vector args; - args.push_back(mvm::jit::ptrType); + args.push_back(mvm::jit::ptrType); // cl + args.push_back(mvm::jit::ptrType); // vm const FunctionType* type = FunctionType::get(JavaObject::llvmType, args, false); getStaticInstanceLLVM = Function::Create(type, GlobalValue::ExternalLinkage, Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp?rev=50348&r1=50347&r2=50348&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp Mon Apr 28 04:21:34 2008 @@ -32,16 +32,12 @@ using namespace jnjvm; using namespace llvm; -Value* Class::staticVar(Module* compilingModule, BasicBlock* currentBlock) { +Value* Class::staticVar(JavaJIT* jit) { +#ifndef MULTIPLE_VM if (!_staticVar) { aquire(); if (!_staticVar) { -#ifdef MULTIPLE_VM - if (isolate == Jnjvm::bootstrapVM) { - _staticVar = llvmVar(compilingModule); - } else { -#endif JavaObject* obj = staticInstance(); mvm::jit::protectConstants();//->lock(); Constant* cons = @@ -55,23 +51,18 @@ cons, "", isolate->module); isolate->protectModule->unlock(); - } -#ifdef MULTIPLE_VM } -#endif release(); } -#ifdef MULTIPLE_VM - if (isolate == Jnjvm::bootstrapVM) { - Value* ld = new LoadInst(_staticVar, "", currentBlock); - return llvm::CallInst::Create(JavaJIT::getStaticInstanceLLVM, ld, "", - currentBlock); - } else { -#endif - return new LoadInst(_staticVar, "", currentBlock); -#ifdef MULTIPLE_VM - } + return new LoadInst(_staticVar, "", jit->currentBlock); + +#else + Value* var = llvmVar(jit->compilingClass->isolate->module); + Value* ld = new LoadInst(var, "", jit->currentBlock); + jit->invoke(JavaJIT::initialisationCheckLLVM, ld, "", jit->currentBlock); + return jit->invoke(JavaJIT::getStaticInstanceLLVM, ld, jit->isolateLocal, + "", jit->currentBlock); #endif } Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp?rev=50348&r1=50347&r2=50348&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp Mon Apr 28 04:21:34 2008 @@ -60,7 +60,6 @@ llvm::Function* JavaJIT::doNewUnknownLLVM = 0; #ifdef MULTIPLE_VM llvm::Function* JavaJIT::initialisationCheckLLVM = 0; -llvm::Function* JavaJIT::initialisationCheckCtpLLVM = 0; #endif llvm::Function* JavaJIT::initialiseObjectLLVM = 0; llvm::Function* JavaJIT::newLookupLLVM = 0; @@ -139,8 +138,10 @@ field->classDef->initialiseClass(); if (stat) obj = field->classDef->staticInstance(); void* ptr = (void*)(field->ptrOffset + (uint64)obj); +#ifndef MULTIPLE_VM if (stat) *ifStatic = ptr; *offset = (uint32)field->ptrOffset; +#endif return ptr; } @@ -157,9 +158,10 @@ void* ptr = (void*)((uint64)obj + field->ptrOffset); ctpInfo->ctpRes[index] = field; - +#ifndef MULTIPLE_VM if (stat) *ifStatic = ptr; *offset = (uint32)field->ptrOffset; +#endif return ptr; } @@ -210,18 +212,17 @@ } #ifdef MULTIPLE_VM -extern "C" JavaObject* getStaticInstance(Class* cl) { - if (cl->isolate == Jnjvm::bootstrapVM) { - Jnjvm* vm = JavaThread::get()->isolate; - std::pair* val = vm->statics->lookup(cl); - if (!val) { - cl->initialiseClass(); - val = vm->statics->lookup(cl); - } - return val->second; - } else { - return cl->_staticInstance; +extern "C" JavaObject* getStaticInstance(Class* cl, Jnjvm* vm) { + std::pair* val = vm->statics->lookup(cl); + if (!val || !(val->second)) { + cl->initialiseClass(); + val = vm->statics->lookup(cl); } + return val->second; +} + +extern "C" void initialisationCheck(CommonClass* cl) { + cl->isolate->initialiseClass(cl); } #endif @@ -270,15 +271,3 @@ } #endif -#ifdef MULTIPLE_VM -extern "C" void initialisationCheck(CommonClass* cl) { - cl->isolate->initialiseClass(cl); -} - -extern "C" void initialisationCheckCtp(Class* caller, uint16 index) { - JavaCtpInfo* ctpInfo = caller->ctpInfo; - JavaField* field = (JavaField*)(ctpInfo->ctpRes[index]); - assert(field && "checking without resolving?"); - field->classDef->isolate->initialiseClass(field->classDef); -} -#endif Modified: vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp?rev=50348&r1=50347&r2=50348&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp Mon Apr 28 04:21:34 2008 @@ -304,22 +304,23 @@ typedef void (*clinit_t)(Jnjvm* vm); void Jnjvm::initialiseClass(CommonClass* cl) { + JavaState* status = cl->getStatus(); if (cl->isArray || AssessorDesc::bogusClassToPrimitive(cl)) { - cl->status = ready; - } else if (!(cl->isReady())) { + *status = ready; + } else if (!(*status == ready)) { cl->aquire(); - int status = cl->status; - if (cl->isReady()) { + JavaState* status = cl->getStatus(); + if (*status == ready) { cl->release(); - } else if (status >= resolved && status != clinitParent && - status != inClinit) { - cl->status = clinitParent; + } else if (*status >= resolved && *status != clinitParent && + *status != inClinit) { + *status = clinitParent; cl->release(); if (cl->super) { cl->super->initialiseClass(); } - cl->status = inClinit; + *status = inClinit; JavaMethod* meth = cl->lookupMethodDontThrow(clinitName, clinitType, true, false); @@ -334,7 +335,7 @@ JavaObject* exc = 0; try{ clinit_t pred = (clinit_t)meth->compiledPtr(); - pred(this); + pred(JavaThread::get()->isolate); } catch(...) { exc = JavaThread::getJavaException(); assert(exc && "no exception?"); @@ -349,14 +350,14 @@ } } - cl->setReady(); + *status = ready; cl->broadcastClass(); - } else if (status < resolved) { + } else if (*status < resolved) { cl->release(); unknownError("try to clinit a not-readed class..."); } else { if (!cl->ownerClass()) { - while (status < ready) cl->waitClass(); + while (*status < ready) cl->waitClass(); cl->release(); initialiseClass(cl); } @@ -713,7 +714,9 @@ cl->name = name; cl->classLoader = 0; cl->bytes = 0; +#ifndef MULTIPLE_VM cl->_staticInstance = 0; +#endif cl->virtualInstance = 0; cl->super = 0; cl->ctpInfo = 0; Modified: vmkit/trunk/lib/JnJVM/VMCore/LockedMap.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/LockedMap.h?rev=50348&r1=50347&r2=50348&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/LockedMap.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/LockedMap.h Mon Apr 28 04:21:34 2008 @@ -264,7 +264,7 @@ }; class StaticInstanceMap : - public LockedMap*, std::less > { + public LockedMap*, std::less > { public: static VirtualTable* VT; Modified: vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp?rev=50348&r1=50347&r2=50348&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp Mon Apr 28 04:21:34 2008 @@ -69,14 +69,18 @@ #ifdef MULTIPLE_GC service->GC = Collector::allocate(); #endif - + + service->classpath = callingVM->classpath; + service->bootClasspathEnv = callingVM->bootClasspathEnv; + service->libClasspathEnv = callingVM->libClasspathEnv; + service->bootClasspath = callingVM->bootClasspath; service->functions = vm_new(service, FunctionMap)(); service->functionDefs = vm_new(service, FunctionDefMap)(); service->module = new llvm::Module("Service Domain"); service->protectModule = mvm::Lock::allocNormal(); - service->TheModuleProvider = new JnjvmModuleProvider(service->module, + service->TheModuleProvider = new JnjvmModuleProvider(service->module, service->functions, - service->functionDefs); + service->functionDefs); #ifdef MULTIPLE_GC mvm::jit::memoryManager->addGCForModule(service->module, service->GC); @@ -86,7 +90,8 @@ service->name = "service"; service->jniEnv = &JNI_JNIEnvTable; service->javavmEnv = &JNI_JavaVMTable; - + service->appClassLoader = callingVM->appClassLoader; + // We copy so that bootstrap utf8 such as "" are unique service->hashUTF8 = vm_new(service, UTF8Map)(); callingVM->hashUTF8->copy(service->hashUTF8); @@ -118,8 +123,8 @@ void ServiceDomain::loadBootstrap() { // load and initialise math since it is responsible for dlopen'ing // libjavalang.so and we are optimizing some math operations - loadName(asciizConstructUTF8("java/lang/Math"), - CommonClass::jnjvmClassLoader, true, true, true); + //loadName(asciizConstructUTF8("java/lang/Math"), + // CommonClass::jnjvmClassLoader, true, true, true); } void ServiceDomain::serviceError(const char* str) { @@ -133,29 +138,38 @@ return vm; } -#ifdef SERVICE_VM -extern "C" void ServiceDomainStart(ServiceDomain* caller, - ServiceDomain* callee) { +extern "C" void serviceCallStart(ServiceDomain* caller, + ServiceDomain* callee) { + assert(caller && "No caller in service stop?"); + assert(callee && "No callee in service stop?"); + assert(caller->getVirtualTable() == ServiceDomain::VT && "Caller not a service domain?"); + assert(callee->getVirtualTable() == ServiceDomain::VT && "Callee not a service domain?"); JavaThread* th = JavaThread::get(); th->isolate = callee; +#ifdef SERVICE_VM time_t t = time(NULL); caller->lock->lock(); caller->executionTime += t - th->executionTime; caller->interactions[callee]++; caller->lock->unlock(); th->executionTime = t; - +#endif } -extern "C" void ServiceDomainStop(ServiceDomain* caller, - ServiceDomain* callee) { +extern "C" void serviceCallStop(ServiceDomain* caller, + ServiceDomain* callee) { + assert(caller && "No caller in service stop?"); + assert(callee && "No callee in service stop?"); + assert(caller->getVirtualTable() == ServiceDomain::VT && "Caller not a service domain?"); + assert(callee->getVirtualTable() == ServiceDomain::VT && "Callee not a service domain?"); JavaThread* th = JavaThread::get(); th->isolate = caller; +#ifdef SERVICE_VM time_t t = time(NULL); callee->lock->lock(); callee->executionTime += t - th->executionTime; callee->lock->unlock(); th->executionTime = t; +#endif } -#endif Modified: vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp?rev=50348&r1=50347&r2=50348&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp Mon Apr 28 04:21:34 2008 @@ -144,7 +144,9 @@ void Class::TRACER { CommonClass::PARENT_TRACER; bytes->MARK_AND_TRACE; +#ifndef MULTIPLE_VM _staticInstance->MARK_AND_TRACE; +#endif virtualInstance->MARK_AND_TRACE; ctpInfo->MARK_AND_TRACE; TRACE_VECTOR(Attribut*, gc_allocator, attributs); From nicolas.geoffray at lip6.fr Mon Apr 28 05:31:20 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 28 Apr 2008 10:31:20 -0000 Subject: [llvm-commits] [vmkit] r50349 - in /vmkit/trunk: configure.ac lib/JnJVM/Classpath/ClasspathVMSystemProperties.cpp lib/JnJVM/README lib/JnJVM/VMCore/Jni.cpp Message-ID: <200804281031.m3SAVL8D002134@zion.cs.uiuc.edu> Author: geoffray Date: Mon Apr 28 05:31:15 2008 New Revision: 50349 URL: http://llvm.org/viewvc/llvm-project?rev=50349&view=rev Log: Move to GNU Classpath 0.97.1, and move Java version of JnJVM to 1.5. Modified: vmkit/trunk/configure.ac vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMSystemProperties.cpp vmkit/trunk/lib/JnJVM/README vmkit/trunk/lib/JnJVM/VMCore/Jni.cpp Modified: vmkit/trunk/configure.ac URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/configure.ac?rev=50349&r1=50348&r2=50349&view=diff ============================================================================== --- vmkit/trunk/configure.ac (original) +++ vmkit/trunk/configure.ac Mon Apr 28 05:31:15 2008 @@ -243,10 +243,10 @@ dnl ************************************************************************** AC_ARG_WITH(gnu-classpath-version, [AS_HELP_STRING(--with-gnu-classpath-version=something, - [GNU CLASSPATH VERSION (default is '0.93')])], + [GNU CLASSPATH VERSION (default is '0.97.1')])], [[gnuclasspathversion=$withval]], - [[ echo Using '0.93' as GNU CLASSPATH version. - gnuclasspathversion=0.93 + [[ echo Using '0.97.1' as GNU CLASSPATH version. + gnuclasspathversion=0.97.1 ]] ) gnuclasspathversionuvm=`echo $gnuclasspathversion | $SED s/\\\./-/` Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMSystemProperties.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMSystemProperties.cpp?rev=50349&r1=50348&r2=50349&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMSystemProperties.cpp (original) +++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMSystemProperties.cpp Mon Apr 28 05:31:15 2008 @@ -61,11 +61,11 @@ setProperty(vm, prop, "java.vm.specification.version", "1.0"); setProperty(vm, prop, "java.vm.specification.vendor", "Sun Microsystems, Inc"); setProperty(vm, prop, "java.vm.specification.name", "Java Virtual Machine Specification"); - setProperty(vm, prop, "java.specification.version", "1.4"); + setProperty(vm, prop, "java.specification.version", "1.5"); setProperty(vm, prop, "java.specification.vendor", "Sun Microsystems, Inc"); setProperty(vm, prop, "java.specification.name", "Java Platform API Specification"); - setProperty(vm, prop, "java.version", "1.4"); - setProperty(vm, prop, "java.runtime.version", "1.4"); + setProperty(vm, prop, "java.version", "1.5"); + setProperty(vm, prop, "java.runtime.version", "1.5"); setProperty(vm, prop, "java.vendor", "VVM Project"); setProperty(vm, prop, "java.vendor.url", "http://vvm.lip6.fr"); @@ -73,14 +73,14 @@ if (!tmp) tmp = ""; setProperty(vm, prop, "java.home", tmp); - setProperty(vm, prop, "java.class.version", "48.0"); + setProperty(vm, prop, "java.class.version", "49.0"); setProperty(vm, prop, "java.class.path", vm->classpath); setProperty(vm, prop, "java.boot.class.path", vm->bootClasspathEnv); setProperty(vm, prop, "sun.boot.class.path", vm->bootClasspathEnv); setProperty(vm, prop, "java.vm.version", "2.0"); setProperty(vm, prop, "java.vm.vendor", "VVM Project"); setProperty(vm, prop, "java.vm.name", "JnJVM"); - setProperty(vm, prop, "java.specification.version", "1.4"); + setProperty(vm, prop, "java.specification.version", "1.5"); setProperty(vm, prop, "java.library.path", vm->libClasspathEnv); setProperty(vm, prop, "java.io.tmpdir", "/tmp"); @@ -114,6 +114,7 @@ //setProperty(vm, prop, "gnu.classpath.nio.charset.provider.iconv", "true") setProperty(vm, prop, "file.encoding", "ISO8859_1"); + setProperty(vm, prop, "gnu.java.util.zoneinfo.dir", "/usr/share/zoneinfo"); } Modified: vmkit/trunk/lib/JnJVM/README URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/README?rev=50349&r1=50348&r2=50349&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/README (original) +++ vmkit/trunk/lib/JnJVM/README Mon Apr 28 05:31:15 2008 @@ -1,11 +1,11 @@ 1 - GNU Classpath -Current version 0.93. Use gcj > 4 or ecj +Current version 0.97.1. Use ecj to compile Classpath. a - unzip classpath - tar -xzf classpath-0.93 + tar -xzf classpath-0.97.1 b - compile classpath - cd classpath-0.93 - ./configure && make + cd classpath-0.97.1 + ./configure --disable-plugin --disable-examples && make IMPORTANT: for local use cd classpath-x.y/lib; Modified: vmkit/trunk/lib/JnJVM/VMCore/Jni.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Jni.cpp?rev=50349&r1=50348&r2=50349&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/Jni.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/Jni.cpp Mon Apr 28 05:31:15 2008 @@ -25,8 +25,8 @@ using namespace jnjvm; -extern "C" const struct JNIInvokeInterface JNI_JavaVMTable; -extern "C" struct JNINativeInterface JNI_JNIEnvTable; +extern "C" const struct JNIInvokeInterface_ JNI_JavaVMTable; +extern "C" struct JNINativeInterface_ JNI_JNIEnvTable; #define BEGIN_EXCEPTION \ JavaObject* excp = 0; \ @@ -249,7 +249,7 @@ jobject NewObjectA(JNIEnv* env, jclass clazz, jmethodID methodID, - jvalue *args) { + const jvalue *args) { assert(0 && "implement me"); return 0; } @@ -339,7 +339,7 @@ jobject CallObjectMethodA(JNIEnv *env, jobject obj, jmethodID methodID, - jvalue * args) { + const jvalue * args) { assert(0 && "implement me"); return 0; } @@ -371,7 +371,7 @@ jboolean CallBooleanMethodA(JNIEnv *env, jobject obj, jmethodID methodID, - jvalue * args) { + const jvalue * args) { assert(0 && "implement me"); return 0; } @@ -390,7 +390,7 @@ jbyte CallByteMethodA(JNIEnv *env, jobject obj, jmethodID methodID, - jvalue *args) { + const jvalue *args) { assert(0 && "implement me"); return 0; } @@ -410,7 +410,7 @@ jchar CallCharMethodA(JNIEnv *env, jobject obj, jmethodID methodID, - jvalue *args) { + const jvalue *args) { assert(0 && "implement me"); return 0; } @@ -430,7 +430,7 @@ jshort CallShortMethodA(JNIEnv *env, jobject obj, jmethodID methodID, - jvalue *args) { + const jvalue *args) { assert(0 && "implement me"); return 0; } @@ -463,7 +463,7 @@ jint CallIntMethodA(JNIEnv *env, jobject obj, jmethodID methodID, - jvalue *args) { + const jvalue *args) { assert(0 && "implement me"); return 0; } @@ -484,7 +484,7 @@ jlong CallLongMethodA(JNIEnv *env, jobject obj, jmethodID methodID, - jvalue *args) { + const jvalue *args) { assert(0 && "implement me"); return 0; } @@ -517,7 +517,7 @@ jfloat CallFloatMethodA(JNIEnv *env, jobject _obj, jmethodID methodID, - jvalue *args) { + const jvalue *args) { assert(0 && "implement me"); return 0; } @@ -559,7 +559,7 @@ jdouble CallDoubleMethodA(JNIEnv *env, jobject _obj, jmethodID methodID, - jvalue *args) { + const jvalue *args) { assert(0 && "implement me"); return 0; } @@ -597,7 +597,7 @@ void CallVoidMethodA(JNIEnv *env, jobject obj, jmethodID methodID, - jvalue *args) { + const jvalue *args) { assert(0 && "implement me"); } @@ -618,7 +618,7 @@ jobject CallNonvirtualObjectMethodA(JNIEnv *env, jobject obj, jclass clazz, - jmethodID methodID, jvalue *args) { + jmethodID methodID, const jvalue *args) { assert(0 && "implement me"); return 0; } @@ -640,7 +640,7 @@ jboolean CallNonvirtualBooleanMethodA(JNIEnv *env, jobject obj, jclass clazz, - jmethodID methodID, jvalue *args) { + jmethodID methodID, const jvalue *args) { assert(0 && "implement me"); return 0; } @@ -661,7 +661,7 @@ jbyte CallNonvirtualByteMethodA(JNIEnv *env, jobject obj, jclass clazz, - jmethodID methodID, jvalue *args) { + jmethodID methodID, const jvalue *args) { assert(0 && "implement me"); return 0; } @@ -683,7 +683,7 @@ jchar CallNonvirtualCharMethodA(JNIEnv *env, jobject obj, jclass clazz, - jmethodID methodID, jvalue *args) { + jmethodID methodID, const jvalue *args) { assert(0 && "implement me"); return 0; } @@ -705,7 +705,7 @@ jshort CallNonvirtualShortMethodA(JNIEnv *env, jobject obj, jclass clazz, - jmethodID methodID, jvalue *args) { + jmethodID methodID, const jvalue *args) { assert(0 && "implement me"); return 0; } @@ -727,7 +727,7 @@ jint CallNonvirtualIntMethodA(JNIEnv *env, jobject obj, jclass clazz, - jmethodID methodID, jvalue *args) { + jmethodID methodID, const jvalue *args) { assert(0 && "implement me"); return 0; } @@ -749,7 +749,7 @@ jlong CallNonvirtualLongMethodA(JNIEnv *env, jobject obj, jclass clazz, - jmethodID methodID, jvalue *args) { + jmethodID methodID, const jvalue *args) { assert(0 && "implement me"); return 0; } @@ -771,7 +771,7 @@ jfloat CallNonvirtualFloatMethodA(JNIEnv *env, jobject obj, jclass clazz, - jmethodID methodID, jvalue *args) { + jmethodID methodID, const jvalue *args) { assert(0 && "implement me"); return 0; } @@ -793,7 +793,7 @@ jdouble CallNonvirtualDoubleMethodA(JNIEnv *env, jobject obj, jclass clazz, - jmethodID methodID, jvalue *args) { + jmethodID methodID, const jvalue *args) { assert(0 && "implement me"); return 0; } @@ -824,7 +824,7 @@ void CallNonvirtualVoidMethodA(JNIEnv *env, jobject obj, jclass clazz, - jmethodID methodID, jvalue * args) { + jmethodID methodID, const jvalue * args) { assert(0 && "implement me"); } @@ -1106,7 +1106,7 @@ jobject CallStaticObjectMethodA(JNIEnv *env, jclass clazz, jmethodID methodID, - jvalue *args) { + const jvalue *args) { assert(0 && "implement me"); return 0; } @@ -1138,7 +1138,7 @@ jboolean CallStaticBooleanMethodA(JNIEnv *env, jclass clazz, jmethodID methodID, - jvalue *args) { + const jvalue *args) { assert(0 && "implement me"); return 0; } @@ -1158,7 +1158,7 @@ jbyte CallStaticByteMethodA(JNIEnv *env, jclass clazz, jmethodID methodID, - jvalue *args) { + const jvalue *args) { assert(0 && "implement me"); return 0; } @@ -1178,7 +1178,7 @@ jchar CallStaticCharMethodA(JNIEnv *env, jclass clazz, jmethodID methodID, - jvalue *args) { + const jvalue *args) { assert(0 && "implement me"); return 0; } @@ -1199,7 +1199,7 @@ jshort CallStaticShortMethodA(JNIEnv *env, jclass clazz, jmethodID methodID, - jvalue *args) { + const jvalue *args) { assert(0 && "implement me"); return 0; } @@ -1219,7 +1219,7 @@ jint CallStaticIntMethodA(JNIEnv *env, jclass clazz, jmethodID methodID, - jvalue *args) { + const jvalue *args) { assert(0 && "implement me"); return 0; } @@ -1239,7 +1239,7 @@ jlong CallStaticLongMethodA(JNIEnv *env, jclass clazz, jmethodID methodID, - jvalue *args) { + const jvalue *args) { assert(0 && "implement me"); return 0; } @@ -1261,7 +1261,7 @@ jfloat CallStaticFloatMethodA(JNIEnv *env, jclass clazz, jmethodID methodID, - jvalue *args) { + const jvalue *args) { assert(0 && "implement me"); return 0; } @@ -1282,7 +1282,7 @@ jdouble CallStaticDoubleMethodA(JNIEnv *env, jclass clazz, jmethodID methodID, - jvalue *args) { + const jvalue *args) { assert(0 && "implement me"); return 0; } @@ -1317,7 +1317,7 @@ void CallStaticVoidMethodA(JNIEnv *env, jclass clazz, jmethodID methodID, - jvalue * args) { + const jvalue * args) { assert(0 && "implement me"); } @@ -1969,49 +1969,49 @@ void SetBooleanArrayRegion(JNIEnv *env, jbooleanArray array, jsize start, - jsize len, jboolean *buf) { + jsize len, const jboolean *buf) { assert(0 && "implement me"); } void SetByteArrayRegion(JNIEnv *env, jbyteArray array, jsize start, jsize len, - jbyte *buf) { + const jbyte *buf) { assert(0 && "implement me"); } void SetCharArrayRegion(JNIEnv *env, jcharArray array, jsize start, jsize len, - jchar *buf) { + const jchar *buf) { assert(0 && "implement me"); } void SetShortArrayRegion(JNIEnv *env, jshortArray array, jsize start, - jsize len, jshort *buf) { + jsize len, const jshort *buf) { assert(0 && "implement me"); } void SetIntArrayRegion(JNIEnv *env, jintArray array, jsize start, jsize len, - jint *buf) { + const jint *buf) { assert(0 && "implement me"); } void SetLongArrayRegion(JNIEnv* env, jlongArray array, jsize start, jsize len, - jlong *buf) { + const jlong *buf) { assert(0 && "implement me"); } void SetFloatArrayRegion(JNIEnv *env, jfloatArray array, jsize start, - jsize len, jfloat *buf) { + jsize len, const jfloat *buf) { assert(0 && "implement me"); } void SetDoubleArrayRegion(JNIEnv *env, jdoubleArray array, jsize start, - jsize len, jdouble *buf) { + jsize len, const jdouble *buf) { assert(0 && "implement me"); } @@ -2168,6 +2168,12 @@ return 0; } +jobjectRefType GetObjectRefType(JNIEnv* env, jobject obj) { + assert(0 && "implement me"); + return (jobjectRefType)0; +} + + jint DestroyJavaVM(JavaVM *vm) { assert(0 && "implement me"); @@ -2213,7 +2219,7 @@ } -const struct JNIInvokeInterface JNI_JavaVMTable = { +const struct JNIInvokeInterface_ JNI_JavaVMTable = { NULL, NULL, NULL, @@ -2226,7 +2232,7 @@ }; -struct JNINativeInterface JNI_JNIEnvTable = { +struct JNINativeInterface_ JNI_JNIEnvTable = { NULL, NULL, NULL, @@ -2493,5 +2499,8 @@ &NewDirectByteBuffer, &GetDirectBufferAddress, - &GetDirectBufferCapacity + &GetDirectBufferCapacity, + + /* ---- JNI 1.6 functions ---- */ + &GetObjectRefType }; From echristo at apple.com Mon Apr 28 10:20:00 2008 From: echristo at apple.com (Eric Christopher) Date: Mon, 28 Apr 2008 08:20:00 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r50333 - /llvm-gcc-4.2/trunk/build_gcc In-Reply-To: <200804280513.m3S5D8LD016871@zion.cs.uiuc.edu> References: <200804280513.m3S5D8LD016871@zion.cs.uiuc.edu> Message-ID: > > > +# FIXME: What is the motivation here ? Just to make sure that the root has all of the actual files it needs FWIW. What's up? -eric From nicolas.geoffray at lip6.fr Mon Apr 28 11:09:13 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 28 Apr 2008 16:09:13 -0000 Subject: [llvm-commits] [vmkit] r50350 - in /vmkit/trunk/lib/Mvm/GCMmap2: gccollector.cpp gccollector.h gcinit.cpp Message-ID: <200804281609.m3SG9D7D011979@zion.cs.uiuc.edu> Author: geoffray Date: Mon Apr 28 11:09:12 2008 New Revision: 50350 URL: http://llvm.org/viewvc/llvm-project?rev=50350&view=rev Log: In a service environment, the only distinction between GCs is the collection frequency. Modified: vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cpp Modified: vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp?rev=50350&r1=50349&r2=50350&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp (original) +++ vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp Mon Apr 28 11:09:12 2008 @@ -11,7 +11,7 @@ using namespace mvm; -#ifndef MULTIPLE_GC +#if !defined(MULTIPLE_GC) || defined(SERVICE_GC) GCAllocator *GCCollector::allocator = 0; #ifdef HAVE_PTHREAD GCThread *GCCollector::threads; @@ -19,13 +19,6 @@ GCCollector::markerFn GCCollector::_marker; -int GCCollector::_collect_freq_auto; -int GCCollector::_collect_freq_maybe; -int GCCollector::_since_last_collection; - -bool GCCollector::_enable_auto; -bool GCCollector::_enable_maybe; -bool GCCollector::_enable_collection; int GCCollector::status; @@ -33,13 +26,24 @@ GCChunkNode *GCCollector::unused_nodes; unsigned int GCCollector::current_mark; -#else +#endif + +#ifdef MULTIPLE_GC GCCollector* GCCollector::bootstrapGC; #endif #ifdef SERVICE_GC GCCollector* GCCollector::collectingGC; -unsigned int GCCollector::current_mark; +#endif + +#if !defined(SERVICE_GC) && !defined(MULTIPLE_GC) +int GCCollector::_collect_freq_auto; +int GCCollector::_collect_freq_maybe; +int GCCollector::_since_last_collection; + +bool GCCollector::_enable_auto; +bool GCCollector::_enable_maybe; +bool GCCollector::_enable_collection; #endif void GCCollector::do_collect() { Modified: vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h?rev=50350&r1=50349&r2=50350&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h (original) +++ vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h Mon Apr 28 11:09:12 2008 @@ -23,30 +23,38 @@ #define STATIC static #endif +#if defined(MULTIPLE_GC) && !defined(SERVICE_GC) +#define STATIC_FIELD +#else +#define STATIC_FIELD static +#endif + +#if defined(MULTIPLE_GC) +#define STATIC_NO_SERVICE +#else +#define STATIC_NO_SERVICE static +#endif + namespace mvm { class GCCollector : public Collector { #ifdef HAVE_PTHREAD friend class GCThread; #endif - STATIC GCAllocator *allocator; /* The allocator */ - + STATIC_FIELD GCAllocator *allocator; /* The allocator */ - STATIC GCChunkNode *used_nodes; /* Used memory nodes */ - STATIC GCChunkNode *unused_nodes; /* Unused memory nodes */ -#ifdef SERVICE_GC - static unsigned int current_mark; -#else - STATIC unsigned int current_mark; -#endif - STATIC int _collect_freq_auto; /* Collection frequency in gcmalloc/gcrealloc */ - STATIC int _collect_freq_maybe; /* Collection frequency in maybeCollect */ - STATIC int _since_last_collection; /* Bytes left since last collection */ - STATIC bool _enable_auto; /* Automatic collection? */ - STATIC bool _enable_maybe; /* Collection in maybeCollect()? */ - STATIC bool _enable_collection; /* collection authorized? */ - STATIC int status; + STATIC_FIELD GCChunkNode *used_nodes; /* Used memory nodes */ + STATIC_FIELD GCChunkNode *unused_nodes; /* Unused memory nodes */ + STATIC_FIELD unsigned int current_mark; + + STATIC_NO_SERVICE int _collect_freq_auto; /* Collection frequency in gcmalloc/gcrealloc */ + STATIC_NO_SERVICE int _collect_freq_maybe; /* Collection frequency in maybeCollect */ + STATIC_NO_SERVICE int _since_last_collection; /* Bytes left since last collection */ + STATIC_NO_SERVICE bool _enable_auto; /* Automatic collection? */ + STATIC_NO_SERVICE bool _enable_maybe; /* Collection in maybeCollect()? */ + STATIC_NO_SERVICE bool _enable_collection; /* collection authorized? */ + STATIC_FIELD int status; enum { stat_collect, stat_finalize, stat_alloc, stat_broken }; @@ -75,14 +83,14 @@ } public: - STATIC Collector::markerFn _marker; /* The function which traces roots */ + STATIC_FIELD Collector::markerFn _marker; /* The function which traces roots */ #ifdef SERVICE_GC static GCCollector* collectingGC; #endif #ifdef MULTIPLE_GC static GCCollector* bootstrapGC; #endif - STATIC GCThread *threads; /* le gestionnaire de thread et de synchro */ + STATIC_FIELD GCThread *threads; /* le gestionnaire de thread et de synchro */ static void (*internMemoryError)(unsigned int); #ifdef HAVE_PTHREAD Modified: vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cpp?rev=50350&r1=50349&r2=50350&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cpp (original) +++ vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cpp Mon Apr 28 11:09:12 2008 @@ -26,19 +26,15 @@ } void GCCollector::initialise(Collector::markerFn marker) { - + +#ifdef SERVICE_GC + if (this == bootstrapGC) { +#endif used_nodes = new GCChunkNode(); unused_nodes = new GCChunkNode(); #ifdef HAVE_PTHREAD -#ifdef SERVICE_GC - if (this != bootstrapGC) - threads = bootstrapGC->threads; - else - threads = new GCThread(); -#else threads = new GCThread(); #endif -#endif struct sigaction sa; sigset_t mask; @@ -60,10 +56,11 @@ used_nodes->alone(); + current_mark = 0; + status = stat_alloc; #ifdef SERVICE_GC - if (this == bootstrapGC) + } #endif - current_mark = 0; _collect_freq_auto = def_collect_freq_auto; _collect_freq_maybe = def_collect_freq_maybe; @@ -74,7 +71,6 @@ _enable_collection = 1; _enable_maybe = 1; - status = stat_alloc; } void GCCollector::destroy() { From nicolas.geoffray at lip6.fr Mon Apr 28 11:10:33 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 28 Apr 2008 16:10:33 -0000 Subject: [llvm-commits] [vmkit] r50351 - /vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Message-ID: <200804281610.m3SGAXLv012087@zion.cs.uiuc.edu> Author: geoffray Date: Mon Apr 28 11:10:33 2008 New Revision: 50351 URL: http://llvm.org/viewvc/llvm-project?rev=50351&view=rev Log: Fix compilation of native synchronized functions. Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp?rev=50351&r1=50350&r2=50351&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Mon Apr 28 11:10:33 2008 @@ -217,10 +217,44 @@ mvm::jit::executionEngine->addGlobalMapping(func, natPtr); return llvmFunction; } - + + currentExceptionBlock = endExceptionBlock = 0; currentBlock = createBasicBlock("start"); BasicBlock* executeBlock = createBasicBlock("execute"); endBlock = createBasicBlock("end block"); + +#if defined(MULTIPLE_VM) + Value* lastArg = 0; + for (Function::arg_iterator i = func->arg_begin(), e = func->arg_end(); + i != e; ++i) { + lastArg = i; + } +#if !defined(SERVICE_VM) + isolateLocal = lastArg; +#else + if (compilingClass->isolate == Jnjvm::bootstrapVM) { + isolateLocal = lastArg; + } else { + JavaObject* loader = compilingClass->classLoader; + ServiceDomain* vm = ServiceDomain::getDomainFromLoader(loader); + isolateLocal = new LoadInst(vm->llvmDelegatee(), "", currentBlock); + Value* cmp = new ICmpInst(ICmpInst::ICMP_NE, lastArg, + isolateLocal, "", currentBlock); + BasicBlock* ifTrue = createBasicBlock("true service call"); + BasicBlock* endBlock = createBasicBlock("end check service call"); + BranchInst::Create(ifTrue, endBlock, cmp, currentBlock); + currentBlock = ifTrue; + std::vector Args; + Args.push_back(lastArg); + Args.push_back(isolateLocal); + CallInst::Create(ServiceDomain::serviceCallStartLLVM, Args.begin(), + Args.end(), "", currentBlock); + BranchInst::Create(endBlock, currentBlock); + currentBlock = endBlock; + } +#endif +#endif + if (funcType->getReturnType() != Type::VoidTy) endNode = llvm::PHINode::Create(funcType->getReturnType(), "", endBlock); From nicolas.geoffray at lip6.fr Mon Apr 28 11:11:55 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 28 Apr 2008 16:11:55 -0000 Subject: [llvm-commits] [vmkit] r50352 - in /vmkit/trunk/lib/JnJVM: Classpath/ClasspathVMThread.cpp VMCore/JavaIsolate.cpp VMCore/JavaThread.h VMCore/ServiceDomain.cpp VMCore/ServiceDomain.h Message-ID: <200804281611.m3SGBu4l012141@zion.cs.uiuc.edu> Author: geoffray Date: Mon Apr 28 11:11:55 2008 New Revision: 50352 URL: http://llvm.org/viewvc/llvm-project?rev=50352&view=rev Log: Code cleanup for service-environments. Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.h Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp?rev=50352&r1=50351&r2=50352&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp (original) +++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp Mon Apr 28 11:11:55 2008 @@ -26,6 +26,10 @@ #include "Jnjvm.h" #include "NativeUtil.h" +#ifdef SERVICE_VM +#include "ServiceDomain.h" +#endif + using namespace jnjvm; extern "C" { @@ -67,7 +71,7 @@ ts->nonDaemonLock->unlock(); } -#ifdef SERVICE_DOMAIN +#ifdef SERVICE_VM ((ServiceDomain*)isolate)->numThreads++; #endif JavaMethod* method = vmthClass->lookupMethod(Jnjvm::runName, Jnjvm::clinitType, ACC_VIRTUAL, true); @@ -82,7 +86,7 @@ ts->nonDaemonLock->unlock(); } -#ifdef SERVICE_DOMAIN +#ifdef SERVICE_VM ((ServiceDomain*)isolate)->numThreads--; #endif Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp?rev=50352&r1=50351&r2=50352&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp Mon Apr 28 11:11:55 2008 @@ -330,9 +330,6 @@ } void JavaIsolate::executeClass(const char* className, ArrayObject* args) { -#ifdef SERVICE_VM - JavaThread::get()->executionTime = time(0); -#endif try { JavaJIT::invokeOnceVoid(this, appClassLoader, className, "main", "([Ljava/lang/String;)V", ACC_STATIC, args); Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h?rev=50352&r1=50351&r2=50352&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h Mon Apr 28 11:11:55 2008 @@ -45,8 +45,6 @@ static const unsigned int StateWaiting; static const unsigned int StateInterrupted; - JavaObject* cacheObject; // cache for allocations patching - virtual void print(mvm::PrintBuffer *buf) const; virtual void TRACER; virtual void destroyer(size_t sz); @@ -62,9 +60,6 @@ static bool compareException(Class*); static JavaObject* getJavaException(); void returnFromNative(); -#ifdef SERVICE_VM - time_t executionTime; -#endif }; } // end namespace jnjvm Modified: vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp?rev=50352&r1=50351&r2=50352&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp Mon Apr 28 11:11:55 2008 @@ -115,18 +115,10 @@ service->gcTriggered = 0; service->numThreads = 0; - service->loadBootstrap(); service->lock = mvm::Lock::allocNormal(); return service; } -void ServiceDomain::loadBootstrap() { - // load and initialise math since it is responsible for dlopen'ing - // libjavalang.so and we are optimizing some math operations - //loadName(asciizConstructUTF8("java/lang/Math"), - // CommonClass::jnjvmClassLoader, true, true, true); -} - void ServiceDomain::serviceError(const char* str) { fprintf(stderr, str); abort(); @@ -140,36 +132,28 @@ extern "C" void serviceCallStart(ServiceDomain* caller, ServiceDomain* callee) { - assert(caller && "No caller in service stop?"); - assert(callee && "No callee in service stop?"); - assert(caller->getVirtualTable() == ServiceDomain::VT && "Caller not a service domain?"); - assert(callee->getVirtualTable() == ServiceDomain::VT && "Callee not a service domain?"); + assert(caller && "No caller in service start?"); + assert(callee && "No callee in service start?"); + assert(caller->getVirtualTable() == ServiceDomain::VT && + "Caller not a service domain?"); + assert(callee->getVirtualTable() == ServiceDomain::VT && + "Callee not a service domain?"); JavaThread* th = JavaThread::get(); th->isolate = callee; -#ifdef SERVICE_VM - time_t t = time(NULL); caller->lock->lock(); - caller->executionTime += t - th->executionTime; caller->interactions[callee]++; caller->lock->unlock(); - th->executionTime = t; -#endif } extern "C" void serviceCallStop(ServiceDomain* caller, ServiceDomain* callee) { assert(caller && "No caller in service stop?"); assert(callee && "No callee in service stop?"); - assert(caller->getVirtualTable() == ServiceDomain::VT && "Caller not a service domain?"); - assert(callee->getVirtualTable() == ServiceDomain::VT && "Callee not a service domain?"); + assert(caller->getVirtualTable() == ServiceDomain::VT && + "Caller not a service domain?"); + assert(callee->getVirtualTable() == ServiceDomain::VT && + "Callee not a service domain?"); JavaThread* th = JavaThread::get(); th->isolate = caller; -#ifdef SERVICE_VM - time_t t = time(NULL); - callee->lock->lock(); - callee->executionTime += t - th->executionTime; - callee->lock->unlock(); - th->executionTime = t; -#endif } Modified: vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.h?rev=50352&r1=50351&r2=50352&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.h Mon Apr 28 11:11:55 2008 @@ -39,14 +39,12 @@ virtual void print(mvm::PrintBuffer* buf) const; virtual void TRACER; virtual void destroyer(size_t sz); - void loadBootstrap(); static ServiceDomain* allocateService(JavaIsolate* callingVM); llvm::GlobalVariable* llvmDelegatee(); void serviceError(const char* str); mvm::Lock* lock; ClassMap* classes; - struct timeval started; uint64 executionTime; uint64 memoryUsed; uint64 gcTriggered; From dpatel at apple.com Mon Apr 28 11:12:32 2008 From: dpatel at apple.com (Devang Patel) Date: Mon, 28 Apr 2008 09:12:32 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r50333 - /llvm-gcc-4.2/trunk/build_gcc In-Reply-To: References: <200804280513.m3S5D8LD016871@zion.cs.uiuc.edu> Message-ID: <514A21BA-18EA-41FA-B144-8B3E112BCBC3@apple.com> On Apr 28, 2008, at 8:20 AM, Eric Christopher wrote: >> >> >> +# FIXME: What is the motivation here ? > > Just to make sure that the root has all of the actual files it needs > FWIW. What's up? Why does root need libstdc++.dylib inside the root? libstdc++.dylib is a system library and compiler should find it at /usr/lib/libstdc+ +.dylib. - Devang From echristo at apple.com Mon Apr 28 11:17:21 2008 From: echristo at apple.com (Eric Christopher) Date: Mon, 28 Apr 2008 09:17:21 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r50333 - /llvm-gcc-4.2/trunk/build_gcc In-Reply-To: <514A21BA-18EA-41FA-B144-8B3E112BCBC3@apple.com> References: <200804280513.m3S5D8LD016871@zion.cs.uiuc.edu> <514A21BA-18EA-41FA-B144-8B3E112BCBC3@apple.com> Message-ID: <11243516-B0B6-49E2-AE7F-D2F3EF93E53F@apple.com> On Apr 28, 2008, at 9:12 AM, Devang Patel wrote: > > On Apr 28, 2008, at 8:20 AM, Eric Christopher wrote: > >>> >>> >>> +# FIXME: What is the motivation here ? >> >> Just to make sure that the root has all of the actual files it >> needs FWIW. What's up? > > Why does root need libstdc++.dylib inside the root? libstdc++.dylib > is a system library and compiler should find it at /usr/lib/libstdc+ > +.dylib. Probably so that you can install a root and get a full build and just have it copy over an existing libstdc++. Can't think of anything else offhand. If you remove the lines and everything still works then go ahead :) -eric From criswell at uiuc.edu Mon Apr 28 11:21:27 2008 From: criswell at uiuc.edu (John Criswell) Date: Mon, 28 Apr 2008 16:21:27 -0000 Subject: [llvm-commits] [poolalloc] r50353 - /poolalloc/trunk/lib/PoolAllocate/PASimple.cpp Message-ID: <200804281621.m3SGLR8R012434@zion.cs.uiuc.edu> Author: criswell Date: Mon Apr 28 11:21:26 2008 New Revision: 50353 URL: http://llvm.org/viewvc/llvm-project?rev=50353&view=rev Log: Support FORTRAN programs converted by NAG's f2c program. Modified: poolalloc/trunk/lib/PoolAllocate/PASimple.cpp Modified: poolalloc/trunk/lib/PoolAllocate/PASimple.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PASimple.cpp?rev=50353&r1=50352&r2=50353&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/PASimple.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/PASimple.cpp Mon Apr 28 11:21:26 2008 @@ -89,7 +89,8 @@ AddPoolPrototypes(&M); // Get the main function to insert the poolinit calls. - Function *MainFunc = M.getFunction("main"); + Function *MainFunc = (M.getFunction("main") ? M.getFunction("main") + : M.getFunction("MAIN__")); if (MainFunc == 0 || MainFunc->isDeclaration()) { std::cerr << "Cannot pool allocate this program: it has global " << "pools but no 'main' function yet!\n"; @@ -104,7 +105,7 @@ // Now that all call targets are available, rewrite the function bodies of the // clones. for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) - if (!I->isDeclaration()) + if (!(I->isDeclaration())) ProcessFunctionBodySimple(*I); return true; } @@ -333,7 +334,8 @@ Constant::getNullValue(getPoolType()), "GlobalPool", &M); - Function *MainFunc = M.getFunction("main"); + Function *MainFunc = (M.getFunction("main") ? M.getFunction("main") + : M.getFunction("MAIN__")); assert(MainFunc && "No main in program??"); BasicBlock::iterator InsertPt; From matthijs at stdin.nl Mon Apr 28 07:09:23 2008 From: matthijs at stdin.nl (Matthijs Kooijman) Date: Mon, 28 Apr 2008 14:09:23 +0200 Subject: [llvm-commits] [llvm] r50265 - in /llvm/trunk: include/llvm/ include/llvm/Analysis/ include/llvm/Bitcode/ include/llvm/Support/ lib/AsmParser/ lib/Bitcode/Reader/ lib/Bitcode/Writer/ lib/Transforms/IPO/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ test/Transforms/Inline/ test/Transforms/PruneEH/ test/Transforms/SimplifyCFG/ tools/llvm-bcanalyzer/ In-Reply-To: <200804251654.m3PGs1Kg032722@zion.cs.uiuc.edu> References: <200804251654.m3PGs1Kg032722@zion.cs.uiuc.edu> Message-ID: <20080428120923.GB31157@katherina.student.utwente.nl> (Message resent with correct From address) Hi, > llvm/trunk/lib/AsmParser/llvmAsmParser.y > llvm/trunk/lib/AsmParser/llvmAsmParser.y.cvs This patch modifies llvmAsmParser.y, but does not update llvmAsmParser.{h,cpp}.cvs accordingly, breaking builds when bison is not available. Please update and commeit these files as well. Assuming that you did actually compile the code, could it be that the build system is broken and does not automatically update the .h.cvs and .cpp.cvs files when the .y file changes? Gr. Matthijs From dpatel at apple.com Mon Apr 28 11:43:10 2008 From: dpatel at apple.com (Devang Patel) Date: Mon, 28 Apr 2008 16:43:10 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50354 - /llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386.cpp Message-ID: <200804281643.m3SGhAZw013026@zion.cs.uiuc.edu> Author: dpatel Date: Mon Apr 28 11:43:09 2008 New Revision: 50354 URL: http://llvm.org/viewvc/llvm-project?rev=50354&view=rev Log: Vectors bigger than 128 are returned using sret. This fixes few failures in compat.exp for x86-64 darwin target. Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386.cpp Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386.cpp?rev=50354&r1=50353&r2=50354&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386.cpp (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386.cpp Mon Apr 28 11:43:09 2008 @@ -898,9 +898,9 @@ if (TREE_INT_CST_LOW(TYPE_SIZE(type))==64 && TYPE_VECTOR_SUBPARTS(type)>1) return true; - if (TREE_INT_CST_LOW(TYPE_SIZE(type))>128) - return true; } + if (TREE_INT_CST_LOW(TYPE_SIZE(type))>128) + return true; return false; } From foldr at codedgers.com Mon Apr 28 11:44:25 2008 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Mon, 28 Apr 2008 16:44:25 -0000 Subject: [llvm-commits] [llvm] r50355 - in /llvm/trunk: docs/CommandLine.html include/llvm/Support/CommandLine.h lib/Support/CommandLine.cpp Message-ID: <200804281644.m3SGiPO2013080@zion.cs.uiuc.edu> Author: foldr Date: Mon Apr 28 11:44:25 2008 New Revision: 50355 URL: http://llvm.org/viewvc/llvm-project?rev=50355&view=rev Log: Add support for response files to the CommandLine library. Modified: llvm/trunk/docs/CommandLine.html llvm/trunk/include/llvm/Support/CommandLine.h llvm/trunk/lib/Support/CommandLine.cpp Modified: llvm/trunk/docs/CommandLine.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandLine.html?rev=50355&r1=50354&r2=50355&view=diff ============================================================================== --- llvm/trunk/docs/CommandLine.html (original) +++ llvm/trunk/docs/CommandLine.html Mon Apr 28 11:44:25 2008 @@ -52,6 +52,7 @@ specified
  • Controlling other formatting options
  • Miscellaneous option modifiers
  • +
  • Response files
  • Top-Level Classes and Functions @@ -1442,6 +1443,29 @@ + + + +
    + +

    Some systems, such as certain variants of Microsoft Windows and +some older Unices have a relatively low limit on command-line +length. It is therefore customary to use the so-called 'response +files' to circumvent this restriction. These files are mentioned on +the command-line (using the "@file") syntax. The program reads these +files and inserts the contents into argv, thereby working around the +command-line length limits. Response files are enabled by an optional +fourth argument to +cl::ParseEnvironmentOptions +and +cl::ParseCommandLineOptions. +

    + +
    + +
    Top-Level Classes and Functions @@ -1475,7 +1499,8 @@

    The cl::ParseCommandLineOptions function requires two parameters (argc and argv), but may also take an optional third parameter which holds additional extra text to emit when the ---help option is invoked.

    +--help option is invoked, and a fourth boolean parameter that enables +response files.

    @@ -1497,11 +1522,13 @@ href="#cl::ParseCommandLineOptions">cl::ParseCommandLineOptions does.

    -

    It takes three parameters: the name of the program (since argv may +

    It takes four parameters: the name of the program (since argv may not be available, it can't just look in argv[0]), the name of the -environment variable to examine, and the optional +environment variable to examine, the optional additional extra text to emit when the ---help option is invoked.

    +--help option is invoked, and the boolean +switch that controls whether reponse files +should be read.

    cl::ParseEnvironmentOptions will break the environment variable's value up into words and then process them using Modified: llvm/trunk/include/llvm/Support/CommandLine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CommandLine.h?rev=50355&r1=50354&r2=50355&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/CommandLine.h (original) +++ llvm/trunk/include/llvm/Support/CommandLine.h Mon Apr 28 11:44:25 2008 @@ -41,14 +41,16 @@ // ParseCommandLineOptions - Command line option processing entry point. // void ParseCommandLineOptions(int argc, char **argv, - const char *Overview = 0); + const char *Overview = 0, + bool ReadResponseFiles = false); //===----------------------------------------------------------------------===// // ParseEnvironmentOptions - Environment variable option processing alternate // entry point. // void ParseEnvironmentOptions(const char *progName, const char *envvar, - const char *Overview = 0); + const char *Overview = 0, + bool ReadResponseFiles = false); ///===---------------------------------------------------------------------===// /// SetVersionPrinter - Override the default (LLVM specific) version printer @@ -146,10 +148,10 @@ virtual enum ValueExpected getValueExpectedFlagDefault() const { return ValueOptional; } - + // Out of line virtual function to provide home for the class. virtual void anchor(); - + int NumOccurrences; // The number of times specified int Flags; // Flags for the argument unsigned Position; // Position of last occurrence of the option @@ -213,7 +215,7 @@ // addArgument - Register this argument with the commandline system. // void addArgument(); - + Option *getNextRegisteredOption() const { return NextRegistered; } // Return the width of the option tag for printing... @@ -225,7 +227,7 @@ virtual void printOptionInfo(unsigned GlobalWidth) const = 0; virtual void getExtraOptionNames(std::vector &OptionNames) {} - + // addOccurrence - Wrapper around handleOccurrence that enforces Flags // bool addOccurrence(unsigned pos, const char *ArgName, @@ -339,7 +341,7 @@ }; template -ValuesClass END_WITH_NULL values(const char *Arg, DataType Val, +ValuesClass END_WITH_NULL values(const char *Arg, DataType Val, const char *Desc, ...) { va_list ValueArgs; va_start(ValueArgs, Desc); @@ -389,7 +391,7 @@ // hasArgStr = O.hasArgStr(); } - + void getExtraOptionNames(std::vector &OptionNames) { // If there has been no argstr specified, that means that we need to add an // argument for every possible option. This ensures that our options are @@ -537,7 +539,7 @@ // getValueName - Do not print = at all. virtual const char *getValueName() const { return 0; } - + // An out-of-line virtual method to provide a 'home' for this class. virtual void anchor(); }; @@ -551,7 +553,7 @@ class parser : public basic_parser { public: // parse - Return true on error. - bool parse(Option &O, const char *ArgName, const std::string &Arg, + bool parse(Option &O, const char *ArgName, const std::string &Arg, boolOrDefault &Val); enum ValueExpected getValueExpectedFlagDefault() const { @@ -560,7 +562,7 @@ // getValueName - Do not print = at all. virtual const char *getValueName() const { return 0; } - + // An out-of-line virtual method to provide a 'home' for this class. virtual void anchor(); }; @@ -965,7 +967,7 @@ virtual void getExtraOptionNames(std::vector &OptionNames) { return Parser.getExtraOptionNames(OptionNames); } - + virtual bool handleOccurrence(unsigned pos, const char *ArgName, const std::string &Arg) { typename ParserClass::parser_data_type Val = @@ -1071,7 +1073,7 @@ template class bits_storage { unsigned *Location; // Where to store the bits... - + template static unsigned Bit(const T &V) { unsigned BitPos = reinterpret_cast(V); @@ -1096,9 +1098,9 @@ "line option with external storage!"); *Location |= Bit(V); } - + unsigned getBits() { return *Location; } - + template bool isSet(const T &V) { return (*Location & Bit(V)) != 0; @@ -1106,13 +1108,13 @@ }; -// Define how to hold bits. Since we can inherit from a class, we do so. +// Define how to hold bits. Since we can inherit from a class, we do so. // This makes us exactly compatible with the bits in all cases that it is used. // template class bits_storage { unsigned Bits; // Where to store the bits... - + template static unsigned Bit(const T &V) { unsigned BitPos = reinterpret_cast(V); @@ -1120,15 +1122,15 @@ "enum exceeds width of bit vector!"); return 1 << BitPos; } - + public: template void addValue(const T &V) { Bits |= Bit(V); } - + unsigned getBits() { return Bits; } - + template bool isSet(const T &V) { return (Bits & Bit(V)) != 0; @@ -1151,7 +1153,7 @@ virtual void getExtraOptionNames(std::vector &OptionNames) { return Parser.getExtraOptionNames(OptionNames); } - + virtual bool handleOccurrence(unsigned pos, const char *ArgName, const std::string &Arg) { typename ParserClass::parser_data_type Val = Modified: llvm/trunk/lib/Support/CommandLine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CommandLine.cpp?rev=50355&r1=50354&r2=50355&view=diff ============================================================================== --- llvm/trunk/lib/Support/CommandLine.cpp (original) +++ llvm/trunk/lib/Support/CommandLine.cpp Mon Apr 28 11:44:25 2008 @@ -17,7 +17,9 @@ //===----------------------------------------------------------------------===// #include "llvm/Config/config.h" +#include "llvm/ADT/OwningPtr.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/Streams.h" #include "llvm/System/Path.h" @@ -87,7 +89,7 @@ void Option::addArgument() { assert(NextRegistered == 0 && "argument multiply registered!"); - + NextRegistered = RegisteredOptionList; RegisteredOptionList = this; MarkOptionsChanged(); @@ -111,7 +113,7 @@ O->getExtraOptionNames(OptionNames); if (O->ArgStr[0]) OptionNames.push_back(O->ArgStr); - + // Handle named options. for (unsigned i = 0, e = OptionNames.size(); i != e; ++i) { // Add argument to the argument map! @@ -121,9 +123,9 @@ << OptionNames[0] << "' defined more than once!\n"; } } - + OptionNames.clear(); - + // Remember information about positional options. if (O->getFormattingFlag() == cl::Positional) PositionalOpts.push_back(O); @@ -135,10 +137,10 @@ CAOpt = O; } } - + if (CAOpt) PositionalOpts.push_back(CAOpt); - + // Make sure that they are in order of registration not backwards. std::reverse(PositionalOpts.begin(), PositionalOpts.end()); } @@ -150,17 +152,17 @@ static Option *LookupOption(const char *&Arg, const char *&Value, std::map &OptionsMap) { while (*Arg == '-') ++Arg; // Eat leading dashes - + const char *ArgEnd = Arg; while (*ArgEnd && *ArgEnd != '=') ++ArgEnd; // Scan till end of argument name. - + if (*ArgEnd == '=') // If we have an equals sign... Value = ArgEnd+1; // Get the value, not the equals - - + + if (*Arg == 0) return 0; - + // Look up the option. std::map::iterator I = OptionsMap.find(std::string(Arg, ArgEnd)); @@ -309,7 +311,7 @@ /// an environment variable (whose name is given in ENVVAR). /// void cl::ParseEnvironmentOptions(const char *progName, const char *envVar, - const char *Overview) { + const char *Overview, bool ReadResponseFiles) { // Check args. assert(progName && "Program name not specified"); assert(envVar && "Environment variable name missing"); @@ -328,7 +330,7 @@ // and hand it off to ParseCommandLineOptions(). ParseCStringVector(newArgv, envValue); int newArgc = newArgv.size(); - ParseCommandLineOptions(newArgc, &newArgv[0], Overview); + ParseCommandLineOptions(newArgc, &newArgv[0], Overview, ReadResponseFiles); // Free all the strdup()ed strings. for (std::vector::iterator i = newArgv.begin(), e = newArgv.end(); @@ -336,32 +338,78 @@ free (*i); } + +/// ExpandResponseFiles - Copy the contents of argv into newArgv, +/// substituting the contents of the response files for the arguments +/// of type @file. +static void ExpandResponseFiles(int argc, char** argv, + std::vector& newArgv) { + for (int i = 1; i != argc; ++i) { + char* arg = argv[i]; + + if (arg[0] == '@') { + + sys::PathWithStatus respFile(++arg); + + // Check that the response file is not empty (mmap'ing empty + // files can be problematic). + const sys::FileStatus *FileStat = respFile.getFileStatus(); + if (!FileStat) + continue; + if (FileStat->getSize() == 0) + continue; + + // Mmap the response file into memory. + OwningPtr + respFilePtr(MemoryBuffer::getFile(respFile.c_str())); + + if (respFilePtr == 0) + continue; + + ParseCStringVector(newArgv, respFilePtr->getBufferStart()); + } + else { + newArgv.push_back(strdup(arg)); + } + } +} + void cl::ParseCommandLineOptions(int argc, char **argv, - const char *Overview) { + const char *Overview, bool ReadResponseFiles) { // Process all registered options. std::vector PositionalOpts; std::vector SinkOpts; std::map Opts; GetOptionInfo(PositionalOpts, SinkOpts, Opts); - + assert((!Opts.empty() || !PositionalOpts.empty()) && "No options specified!"); + + // Expand response files. + std::vector newArgv; + if (ReadResponseFiles) { + newArgv.push_back(strdup(argv[0])); + ExpandResponseFiles(argc, argv, newArgv); + argv = &newArgv[0]; + argc = newArgv.size(); + } + sys::Path progname(argv[0]); // Copy the program name into ProgName, making sure not to overflow it. std::string ProgName = sys::Path(argv[0]).getLast(); if (ProgName.size() > 79) ProgName.resize(79); strcpy(ProgramName, ProgName.c_str()); - + ProgramOverview = Overview; bool ErrorParsing = false; // Check out the positional arguments to collect information about them. unsigned NumPositionalRequired = 0; - + // Determine whether or not there are an unlimited number of positionals bool HasUnlimitedPositionals = false; - + Option *ConsumeAfterOpt = 0; if (!PositionalOpts.empty()) { if (PositionalOpts[0]->getNumOccurrencesFlag() == cl::ConsumeAfter) { @@ -427,7 +475,7 @@ GetOptionInfo(PositionalOpts, SinkOpts, Opts); OptionListChanged = false; } - + // Check to see if this is a positional argument. This argument is // considered to be positional if it doesn't start with '-', if it is "-" // itself, or if we have seen "--" already. @@ -567,7 +615,7 @@ << ": Not enough positional command line arguments specified!\n" << "Must specify at least " << NumPositionalRequired << " positional arguments: See: " << argv[0] << " --help\n"; - + ErrorParsing = true; } else if (!HasUnlimitedPositionals && PositionalVals.size() > PositionalOpts.size()) { @@ -664,6 +712,14 @@ PositionalOpts.clear(); MoreHelp->clear(); + // Free the memory allocated by ExpandResponseFiles. + if (ReadResponseFiles) { + // Free all the strdup()ed strings. + for (std::vector::iterator i = newArgv.begin(), e = newArgv.end(); + i != e; ++i) + free (*i); + } + // If we had an error processing our arguments, don't let the program execute if (ErrorParsing) exit(1); } @@ -678,7 +734,7 @@ cerr << HelpStr; // Be nice for positional arguments else cerr << ProgramName << ": for the -" << ArgName; - + cerr << " option: " << Message << "\n"; return true; } @@ -943,7 +999,7 @@ std::vector SinkOpts; std::map OptMap; GetOptionInfo(PositionalOpts, SinkOpts, OptMap); - + // Copy Options into a vector so we can sort them as we like... std::vector > Opts; copy(OptMap.begin(), OptMap.end(), std::back_inserter(Opts)); @@ -970,7 +1026,7 @@ // Print out the positional options. Option *CAOpt = 0; // The cl::ConsumeAfter option, if it exists... - if (!PositionalOpts.empty() && + if (!PositionalOpts.empty() && PositionalOpts[0]->getNumOccurrencesFlag() == ConsumeAfter) CAOpt = PositionalOpts[0]; From nicolas.geoffray at lip6.fr Mon Apr 28 11:48:02 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 28 Apr 2008 16:48:02 -0000 Subject: [llvm-commits] [vmkit] r50356 - /vmkit/trunk/lib/JnJVM/Classpath/Classpath.cpp Message-ID: <200804281648.m3SGm2Pe013218@zion.cs.uiuc.edu> Author: geoffray Date: Mon Apr 28 11:48:02 2008 New Revision: 50356 URL: http://llvm.org/viewvc/llvm-project?rev=50356&view=rev Log: Implementation of Java_java_util_concurrent_atomic_AtomicLong_VMSupportsCS8. Modified: vmkit/trunk/lib/JnJVM/Classpath/Classpath.cpp Modified: vmkit/trunk/lib/JnJVM/Classpath/Classpath.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/Classpath.cpp?rev=50356&r1=50355&r2=50356&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Classpath/Classpath.cpp (original) +++ vmkit/trunk/lib/JnJVM/Classpath/Classpath.cpp Mon Apr 28 11:48:02 2008 @@ -93,3 +93,14 @@ return false; } } + +extern "C" { +JNIEXPORT bool JNICALL Java_java_util_concurrent_atomic_AtomicLong_VMSupportsCS8( +#ifdef NATIVE_JNI +JNIEnv *env, +jclass clazz, +#endif +) { + return false; +} +} From gohman at apple.com Mon Apr 28 11:58:24 2008 From: gohman at apple.com (Dan Gohman) Date: Mon, 28 Apr 2008 16:58:24 -0000 Subject: [llvm-commits] [llvm] r50357 - /llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Message-ID: <200804281658.m3SGwPBH013528@zion.cs.uiuc.edu> Author: djg Date: Mon Apr 28 11:58:24 2008 New Revision: 50357 URL: http://llvm.org/viewvc/llvm-project?rev=50357&view=rev Log: Teach DAGCombine to convert (sext x) to (zext x) when the sign-bit of x is known to be zero. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=50357&r1=50356&r2=50357&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Mon Apr 28 11:58:24 2008 @@ -2887,6 +2887,10 @@ if (SCC.Val) return SCC; } + // fold (sext x) -> (zext x) if the sign bit is known zero. + if (DAG.SignBitIsZero(N0)) + return DAG.getNode(ISD::ZERO_EXTEND, VT, N0); + return SDOperand(); } From gohman at apple.com Mon Apr 28 12:02:22 2008 From: gohman at apple.com (Dan Gohman) Date: Mon, 28 Apr 2008 17:02:22 -0000 Subject: [llvm-commits] [llvm] r50358 - in /llvm/trunk: lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/sext-misc.ll Message-ID: <200804281702.m3SH2MPF013676@zion.cs.uiuc.edu> Author: djg Date: Mon Apr 28 12:02:21 2008 New Revision: 50358 URL: http://llvm.org/viewvc/llvm-project?rev=50358&view=rev Log: Teach InstCombine's ComputeMaskedBits what SelectionDAG's ComputeMaskedBits knows about cttz, ctlz, and ctpop. Teach SelectionDAG's ComputeMaskedBits what InstCombine's knows about SRem. And teach them both some things about high bits in Mul, UDiv, URem, and Sub. This allows instcombine and dagcombine to eliminate sign-extension operations in several new cases. Added: llvm/trunk/test/Transforms/InstCombine/sext-misc.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=50358&r1=50357&r2=50358&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Mon Apr 28 12:02:21 2008 @@ -1229,6 +1229,50 @@ KnownZero = KnownZeroOut; return; } + case ISD::MUL: { + APInt Mask2 = APInt::getAllOnesValue(BitWidth); + ComputeMaskedBits(Op.getOperand(1), Mask2, KnownZero, KnownOne, Depth+1); + ComputeMaskedBits(Op.getOperand(0), Mask2, KnownZero2, KnownOne2, Depth+1); + assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); + assert((KnownZero2 & KnownOne2) == 0 && "Bits known to be one AND zero?"); + + // If low bits are zero in either operand, output low known-0 bits. + // Also compute a conserative estimate for high known-0 bits. + // More trickiness is possible, but this is sufficient for the + // interesting case of alignment computation. + KnownOne.clear(); + unsigned TrailZ = KnownZero.countTrailingOnes() + + KnownZero2.countTrailingOnes(); + unsigned LeadZ = std::max(KnownZero.countLeadingOnes() + + KnownZero2.countLeadingOnes() + + 1, BitWidth) - BitWidth; + + TrailZ = std::min(TrailZ, BitWidth); + LeadZ = std::min(LeadZ, BitWidth); + KnownZero = APInt::getLowBitsSet(BitWidth, TrailZ) | + APInt::getHighBitsSet(BitWidth, LeadZ); + KnownZero &= Mask; + return; + } + case ISD::UDIV: { + // For the purposes of computing leading zeros we can conservatively + // treat a udiv as a logical right shift by the power of 2 known to + // be greater than the denominator. + APInt AllOnes = APInt::getAllOnesValue(BitWidth); + ComputeMaskedBits(Op.getOperand(0), + AllOnes, KnownZero2, KnownOne2, Depth+1); + unsigned LeadZ = KnownZero2.countLeadingOnes(); + + KnownOne2.clear(); + KnownZero2.clear(); + ComputeMaskedBits(Op.getOperand(1), + AllOnes, KnownZero2, KnownOne2, Depth+1); + LeadZ = std::min(BitWidth, + LeadZ + BitWidth - KnownOne2.countLeadingZeros()); + + KnownZero = APInt::getHighBitsSet(BitWidth, LeadZ) & Mask; + return; + } case ISD::SELECT: ComputeMaskedBits(Op.getOperand(2), Mask, KnownZero, KnownOne, Depth+1); ComputeMaskedBits(Op.getOperand(1), Mask, KnownZero2, KnownOne2, Depth+1); @@ -1469,47 +1513,94 @@ KnownZero = APInt::getHighBitsSet(BitWidth, BitWidth - 1); return; + case ISD::SUB: { + if (ConstantSDNode *CLHS = dyn_cast(Op.getOperand(0))) { + // We know that the top bits of C-X are clear if X contains less bits + // than C (i.e. no wrap-around can happen). For example, 20-X is + // positive if we can prove that X is >= 0 and < 16. + if (CLHS->getAPIntValue().isNonNegative()) { + unsigned NLZ = (CLHS->getAPIntValue()+1).countLeadingZeros(); + // NLZ can't be BitWidth with no sign bit + APInt MaskV = APInt::getHighBitsSet(BitWidth, NLZ+1); + ComputeMaskedBits(Op.getOperand(1), MaskV, KnownZero2, KnownOne2, + Depth+1); + + // If all of the MaskV bits are known to be zero, then we know the + // output top bits are zero, because we now know that the output is + // from [0-C]. + if ((KnownZero2 & MaskV) == MaskV) { + unsigned NLZ2 = CLHS->getAPIntValue().countLeadingZeros(); + // Top bits known zero. + KnownZero = APInt::getHighBitsSet(BitWidth, NLZ2) & Mask; + } + } + } + } + // fall through case ISD::ADD: { - // If either the LHS or the RHS are Zero, the result is zero. - ComputeMaskedBits(Op.getOperand(1), Mask, KnownZero, KnownOne, Depth+1); - ComputeMaskedBits(Op.getOperand(0), Mask, KnownZero2, KnownOne2, Depth+1); - assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); - assert((KnownZero2 & KnownOne2) == 0 && "Bits known to be one AND zero?"); - // Output known-0 bits are known if clear or set in both the low clear bits // common to both LHS & RHS. For example, 8+(X<<3) is known to have the // low 3 bits clear. - unsigned KnownZeroOut = std::min(KnownZero.countTrailingOnes(), - KnownZero2.countTrailingOnes()); - - KnownZero = APInt::getLowBitsSet(BitWidth, KnownZeroOut); - KnownOne = APInt(BitWidth, 0); + APInt Mask2 = APInt::getLowBitsSet(BitWidth, Mask.countTrailingOnes()); + ComputeMaskedBits(Op.getOperand(0), Mask2, KnownZero2, KnownOne2, Depth+1); + assert((KnownZero2 & KnownOne2) == 0 && "Bits known to be one AND zero?"); + unsigned KnownZeroOut = KnownZero2.countTrailingOnes(); + + ComputeMaskedBits(Op.getOperand(1), Mask2, KnownZero2, KnownOne2, Depth+1); + assert((KnownZero2 & KnownOne2) == 0 && "Bits known to be one AND zero?"); + KnownZeroOut = std::min(KnownZeroOut, + KnownZero2.countTrailingOnes()); + + KnownZero |= APInt::getLowBitsSet(BitWidth, KnownZeroOut); return; } - case ISD::SUB: { - ConstantSDNode *CLHS = dyn_cast(Op.getOperand(0)); - if (!CLHS) return; + case ISD::SREM: + if (ConstantSDNode *Rem = dyn_cast(Op.getOperand(1))) { + APInt RA = Rem->getAPIntValue(); + if (RA.isPowerOf2() || (-RA).isPowerOf2()) { + APInt LowBits = RA.isStrictlyPositive() ? ((RA - 1) | RA) : ~RA; + APInt Mask2 = LowBits | APInt::getSignBit(BitWidth); + ComputeMaskedBits(Op.getOperand(0), Mask2,KnownZero2,KnownOne2,Depth+1); + + // The sign of a remainder is equal to the sign of the first + // operand (zero being positive). + if (KnownZero2[BitWidth-1] || ((KnownZero2 & LowBits) == LowBits)) + KnownZero2 |= ~LowBits; + else if (KnownOne2[BitWidth-1]) + KnownOne2 |= ~LowBits; - // We know that the top bits of C-X are clear if X contains less bits - // than C (i.e. no wrap-around can happen). For example, 20-X is - // positive if we can prove that X is >= 0 and < 16. - if (CLHS->getAPIntValue().isNonNegative()) { - unsigned NLZ = (CLHS->getAPIntValue()+1).countLeadingZeros(); - // NLZ can't be BitWidth with no sign bit - APInt MaskV = APInt::getHighBitsSet(BitWidth, NLZ+1); - ComputeMaskedBits(Op.getOperand(1), MaskV, KnownZero, KnownOne, Depth+1); - - // If all of the MaskV bits are known to be zero, then we know the output - // top bits are zero, because we now know that the output is from [0-C]. - if ((KnownZero & MaskV) == MaskV) { - unsigned NLZ2 = CLHS->getAPIntValue().countLeadingZeros(); - // Top bits known zero. - KnownZero = APInt::getHighBitsSet(BitWidth, NLZ2) & Mask; - KnownOne = APInt(BitWidth, 0); // No one bits known. - } else { - KnownZero = KnownOne = APInt(BitWidth, 0); // Otherwise, nothing known. + KnownZero |= KnownZero2 & Mask; + KnownOne |= KnownOne2 & Mask; + + assert((KnownZero & KnownOne) == 0&&"Bits known to be one AND zero?"); + } + } + return; + case ISD::UREM: { + if (ConstantSDNode *Rem = dyn_cast(Op.getOperand(1))) { + APInt RA = Rem->getAPIntValue(); + if (RA.isStrictlyPositive() && RA.isPowerOf2()) { + APInt LowBits = (RA - 1) | RA; + APInt Mask2 = LowBits & Mask; + KnownZero |= ~LowBits & Mask; + ComputeMaskedBits(Op.getOperand(0), Mask2, KnownZero, KnownOne,Depth+1); + assert((KnownZero & KnownOne) == 0&&"Bits known to be one AND zero?"); + break; } } + + // Since the result is less than or equal to either operand, any leading + // zero bits in either operand must also exist in the result. + APInt AllOnes = APInt::getAllOnesValue(BitWidth); + ComputeMaskedBits(Op.getOperand(0), AllOnes, KnownZero, KnownOne, + Depth+1); + ComputeMaskedBits(Op.getOperand(1), AllOnes, KnownZero2, KnownOne2, + Depth+1); + + uint32_t Leaders = std::max(KnownZero.countLeadingOnes(), + KnownZero2.countLeadingOnes()); + KnownOne.clear(); + KnownZero = APInt::getHighBitsSet(BitWidth, Leaders) & Mask; return; } default: Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=50358&r1=50357&r2=50358&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Mon Apr 28 12:02:21 2008 @@ -700,15 +700,15 @@ return; } + KnownZero.clear(); KnownOne.clear(); // Start out not knowing anything. + if (Depth == 6 || Mask == 0) return; // Limit search depth. User *I = dyn_cast(V); if (!I) return; - KnownZero.clear(); KnownOne.clear(); // Don't know anything. APInt KnownZero2(KnownZero), KnownOne2(KnownOne); - switch (getOpcode(I)) { default: break; case Instruction::And: { @@ -759,16 +759,42 @@ assert((KnownZero2 & KnownOne2) == 0 && "Bits known to be one AND zero?"); // If low bits are zero in either operand, output low known-0 bits. + // Also compute a conserative estimate for high known-0 bits. // More trickiness is possible, but this is sufficient for the // interesting case of alignment computation. KnownOne.clear(); unsigned TrailZ = KnownZero.countTrailingOnes() + KnownZero2.countTrailingOnes(); + unsigned LeadZ = std::max(KnownZero.countLeadingOnes() + + KnownZero2.countLeadingOnes() + + 1, BitWidth) - BitWidth; + TrailZ = std::min(TrailZ, BitWidth); - KnownZero = APInt::getLowBitsSet(BitWidth, TrailZ); + LeadZ = std::min(LeadZ, BitWidth); + KnownZero = APInt::getLowBitsSet(BitWidth, TrailZ) | + APInt::getHighBitsSet(BitWidth, LeadZ); KnownZero &= Mask; return; } + case Instruction::UDiv: { + // For the purposes of computing leading zeros we can conservatively + // treat a udiv as a logical right shift by the power of 2 known to + // be greater than the denominator. + APInt AllOnes = APInt::getAllOnesValue(BitWidth); + ComputeMaskedBits(I->getOperand(0), + AllOnes, KnownZero2, KnownOne2, Depth+1); + unsigned LeadZ = KnownZero2.countLeadingOnes(); + + KnownOne2.clear(); + KnownZero2.clear(); + ComputeMaskedBits(I->getOperand(1), + AllOnes, KnownZero2, KnownOne2, Depth+1); + LeadZ = std::min(BitWidth, + LeadZ + BitWidth - KnownOne2.countLeadingZeros()); + + KnownZero = APInt::getHighBitsSet(BitWidth, LeadZ) & Mask; + return; + } case Instruction::Select: ComputeMaskedBits(I->getOperand(2), Mask, KnownZero, KnownOne, Depth+1); ComputeMaskedBits(I->getOperand(1), Mask, KnownZero2, KnownOne2, Depth+1); @@ -900,38 +926,36 @@ unsigned NLZ = (CLHS->getValue()+1).countLeadingZeros(); // NLZ can't be BitWidth with no sign bit APInt MaskV = APInt::getHighBitsSet(BitWidth, NLZ+1); - ComputeMaskedBits(I->getOperand(1), MaskV, KnownZero, KnownOne, Depth+1); + ComputeMaskedBits(I->getOperand(1), MaskV, KnownZero2, KnownOne2, + Depth+1); - // If all of the MaskV bits are known to be zero, then we know the output - // top bits are zero, because we now know that the output is from [0-C]. - if ((KnownZero & MaskV) == MaskV) { + // If all of the MaskV bits are known to be zero, then we know the + // output top bits are zero, because we now know that the output is + // from [0-C]. + if ((KnownZero2 & MaskV) == MaskV) { unsigned NLZ2 = CLHS->getValue().countLeadingZeros(); // Top bits known zero. KnownZero = APInt::getHighBitsSet(BitWidth, NLZ2) & Mask; - KnownOne = APInt(BitWidth, 0); // No one bits known. - } else { - KnownZero = KnownOne = APInt(BitWidth, 0); // Otherwise, nothing known. } - return; } } } // fall through case Instruction::Add: { - // If either the LHS or the RHS are Zero, the result is zero. - ComputeMaskedBits(I->getOperand(1), Mask, KnownZero, KnownOne, Depth+1); - ComputeMaskedBits(I->getOperand(0), Mask, KnownZero2, KnownOne2, Depth+1); - assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); - assert((KnownZero2 & KnownOne2) == 0 && "Bits known to be one AND zero?"); - // Output known-0 bits are known if clear or set in both the low clear bits // common to both LHS & RHS. For example, 8+(X<<3) is known to have the // low 3 bits clear. - unsigned KnownZeroOut = std::min(KnownZero.countTrailingOnes(), - KnownZero2.countTrailingOnes()); - - KnownZero = APInt::getLowBitsSet(BitWidth, KnownZeroOut); - KnownOne = APInt(BitWidth, 0); + APInt Mask2 = APInt::getLowBitsSet(BitWidth, Mask.countTrailingOnes()); + ComputeMaskedBits(I->getOperand(0), Mask2, KnownZero2, KnownOne2, Depth+1); + assert((KnownZero2 & KnownOne2) == 0 && "Bits known to be one AND zero?"); + unsigned KnownZeroOut = KnownZero2.countTrailingOnes(); + + ComputeMaskedBits(I->getOperand(1), Mask2, KnownZero2, KnownOne2, Depth+1); + assert((KnownZero2 & KnownOne2) == 0 && "Bits known to be one AND zero?"); + KnownZeroOut = std::min(KnownZeroOut, + KnownZero2.countTrailingOnes()); + + KnownZero |= APInt::getLowBitsSet(BitWidth, KnownZeroOut); return; } case Instruction::SRem: @@ -956,7 +980,7 @@ } } break; - case Instruction::URem: + case Instruction::URem: { if (ConstantInt *Rem = dyn_cast(I->getOperand(1))) { APInt RA = Rem->getValue(); if (RA.isStrictlyPositive() && RA.isPowerOf2()) { @@ -965,19 +989,24 @@ KnownZero |= ~LowBits & Mask; ComputeMaskedBits(I->getOperand(0), Mask2, KnownZero, KnownOne,Depth+1); assert((KnownZero & KnownOne) == 0&&"Bits known to be one AND zero?"); + break; } - } else { - // Since the result is less than or equal to RHS, any leading zero bits - // in RHS must also exist in the result. - APInt AllOnes = APInt::getAllOnesValue(BitWidth); - ComputeMaskedBits(I->getOperand(1), AllOnes, KnownZero2, KnownOne2, - Depth+1); - - uint32_t Leaders = KnownZero2.countLeadingOnes(); - KnownZero |= APInt::getHighBitsSet(BitWidth, Leaders) & Mask; - assert((KnownZero & KnownOne) == 0&&"Bits known to be one AND zero?"); } + + // Since the result is less than or equal to either operand, any leading + // zero bits in either operand must also exist in the result. + APInt AllOnes = APInt::getAllOnesValue(BitWidth); + ComputeMaskedBits(I->getOperand(0), AllOnes, KnownZero, KnownOne, + Depth+1); + ComputeMaskedBits(I->getOperand(1), AllOnes, KnownZero2, KnownOne2, + Depth+1); + + uint32_t Leaders = std::max(KnownZero.countLeadingOnes(), + KnownZero2.countLeadingOnes()); + KnownOne.clear(); + KnownZero = APInt::getHighBitsSet(BitWidth, Leaders) & Mask; break; + } case Instruction::Alloca: case Instruction::Malloc: { @@ -1088,6 +1117,20 @@ } break; } + case Instruction::Call: + if (IntrinsicInst *II = dyn_cast(I)) { + switch (II->getIntrinsicID()) { + default: break; + case Intrinsic::ctpop: + case Intrinsic::ctlz: + case Intrinsic::cttz: { + unsigned LowBits = Log2_32(BitWidth)+1; + KnownZero = APInt::getHighBitsSet(BitWidth, BitWidth - LowBits); + break; + } + } + } + break; } } @@ -1232,7 +1275,9 @@ APInt LHSKnownZero(BitWidth, 0), LHSKnownOne(BitWidth, 0); APInt &RHSKnownZero = KnownZero, &RHSKnownOne = KnownOne; switch (I->getOpcode()) { - default: break; + default: + ComputeMaskedBits(V, DemandedMask, RHSKnownZero, RHSKnownOne, Depth); + break; case Instruction::And: // If either the LHS or the RHS are Zero, the result is zero. if (SimplifyDemandedBits(I->getOperand(1), DemandedMask, @@ -1578,6 +1623,9 @@ LHSKnownZero, LHSKnownOne, Depth+1)) return true; } + // Otherwise just hand the sub off to ComputeMaskedBits to fill in + // the known zeros and ones. + ComputeMaskedBits(V, DemandedMask, RHSKnownZero, RHSKnownOne, Depth); break; case Instruction::Shl: if (ConstantInt *SA = dyn_cast(I->getOperand(1))) { @@ -1695,10 +1743,10 @@ } } break; - case Instruction::URem: + case Instruction::URem: { if (ConstantInt *Rem = dyn_cast(I->getOperand(1))) { APInt RA = Rem->getValue(); - if (RA.isPowerOf2()) { + if (RA.isStrictlyPositive() && RA.isPowerOf2()) { APInt LowBits = (RA - 1) | RA; APInt Mask2 = LowBits & DemandedMask; KnownZero |= ~LowBits & DemandedMask; @@ -1707,19 +1755,26 @@ return true; assert((KnownZero & KnownOne) == 0&&"Bits known to be one AND zero?"); + break; } - } else { - APInt KnownZero2(BitWidth, 0), KnownOne2(BitWidth, 0); - APInt AllOnes = APInt::getAllOnesValue(BitWidth); - if (SimplifyDemandedBits(I->getOperand(1), AllOnes, - KnownZero2, KnownOne2, Depth+1)) - return true; - - uint32_t Leaders = KnownZero2.countLeadingOnes(); - KnownZero |= APInt::getHighBitsSet(BitWidth, Leaders) & DemandedMask; } + + APInt KnownZero2(BitWidth, 0), KnownOne2(BitWidth, 0); + APInt AllOnes = APInt::getAllOnesValue(BitWidth); + ComputeMaskedBits(I->getOperand(0), AllOnes, + KnownZero2, KnownOne2, Depth+1); + uint32_t Leaders = KnownZero2.countLeadingOnes(); + APInt HighZeros = APInt::getHighBitsSet(BitWidth, Leaders); + if (SimplifyDemandedBits(I->getOperand(1), ~HighZeros, + KnownZero2, KnownOne2, Depth+1)) + return true; + + Leaders = std::max(Leaders, + KnownZero2.countLeadingOnes()); + KnownZero = APInt::getHighBitsSet(BitWidth, Leaders) & DemandedMask; break; } + } // If the client is only demanding bits that we know, return the known // constant. Added: llvm/trunk/test/Transforms/InstCombine/sext-misc.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/sext-misc.ll?rev=50358&view=auto ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/sext-misc.ll (added) +++ llvm/trunk/test/Transforms/InstCombine/sext-misc.ll Mon Apr 28 12:02:21 2008 @@ -0,0 +1,45 @@ +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep sext +; RUN: llvm-as < %s | llc -march=x86-64 | not grep movslq +; RUN: llvm-as < %s | llc -march=x86 | not grep sar + +declare i32 @llvm.ctpop.i32(i32) +declare i32 @llvm.ctlz.i32(i32) +declare i32 @llvm.cttz.i32(i32) + +define i64 @foo(i32 %x) { + %t = call i32 @llvm.ctpop.i32(i32 %x) + %s = sext i32 %t to i64 + ret i64 %s +} +define i64 @boo(i32 %x) { + %t = call i32 @llvm.ctlz.i32(i32 %x) + %s = sext i32 %t to i64 + ret i64 %s +} +define i64 @zoo(i32 %x) { + %t = call i32 @llvm.cttz.i32(i32 %x) + %s = sext i32 %t to i64 + ret i64 %s +} +define i64 @coo(i32 %x) { + %t = udiv i32 %x, 3 + %s = sext i32 %t to i64 + ret i64 %s +} +define i64 @moo(i32 %x) { + %t = urem i32 %x, 30000 + %s = sext i32 %t to i64 + ret i64 %s +} +define i64 @yoo(i32 %x) { + %u = lshr i32 %x, 3 + %t = mul i32 %u, 3 + %s = sext i32 %t to i64 + ret i64 %s +} +define i64 @voo(i32 %x) { + %t = and i32 %x, 511 + %u = sub i32 20000, %t + %s = sext i32 %u to i64 + ret i64 %s +} From gohman at apple.com Mon Apr 28 12:15:20 2008 From: gohman at apple.com (Dan Gohman) Date: Mon, 28 Apr 2008 17:15:20 -0000 Subject: [llvm-commits] [llvm] r50359 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAG.h lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMISelLowering.h lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86ISelLowering.h Message-ID: <200804281715.m3SHFKgD014115@zion.cs.uiuc.edu> Author: djg Date: Mon Apr 28 12:15:20 2008 New Revision: 50359 URL: http://llvm.org/viewvc/llvm-project?rev=50359&view=rev Log: Fix the SVOffset values for loads and stores produced by memcpy/memset expansion. It was a bug for the SVOffset value to be used in the actual address calculations. Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.h llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.h Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAG.h?rev=50359&r1=50358&r2=50359&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAG.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAG.h Mon Apr 28 12:15:20 2008 @@ -326,17 +326,17 @@ SDOperand getMemcpy(SDOperand Chain, SDOperand Dst, SDOperand Src, SDOperand Size, unsigned Align, bool AlwaysInline, - const Value *DstSV, uint64_t DstOff, - const Value *SrcSV, uint64_t SrcOff); + const Value *DstSV, uint64_t DstSVOff, + const Value *SrcSV, uint64_t SrcSVOff); SDOperand getMemmove(SDOperand Chain, SDOperand Dst, SDOperand Src, SDOperand Size, unsigned Align, - const Value *DstSV, uint64_t DstOff, - const Value *SrcSV, uint64_t SrcOff); + const Value *DstSV, uint64_t DstOSVff, + const Value *SrcSV, uint64_t SrcSVOff); SDOperand getMemset(SDOperand Chain, SDOperand Dst, SDOperand Src, SDOperand Size, unsigned Align, - const Value *DstSV, uint64_t DstOff); + const Value *DstSV, uint64_t DstSVOff); /// getSetCC - Helper function to make it easier to build SetCC's if you just /// have an ISD::CondCode instead of an SDOperand. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=50359&r1=50358&r2=50359&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Mon Apr 28 12:15:20 2008 @@ -2590,8 +2590,8 @@ SDOperand Src, uint64_t Size, unsigned Align, bool AlwaysInline, - const Value *DstSV, uint64_t DstOff, - const Value *SrcSV, uint64_t SrcOff) { + const Value *DstSV, uint64_t DstSVOff, + const Value *SrcSV, uint64_t SrcSVOff){ const TargetLowering &TLI = DAG.getTargetLoweringInfo(); // Expand memcpy to a series of store ops if the size operand falls below @@ -2610,6 +2610,7 @@ GlobalAddressSDNode *G = NULL; std::string Str; bool CopyFromStr = false; + uint64_t SrcOff = 0, DstOff = 0; if (Src.getOpcode() == ISD::GlobalAddress) G = cast(Src); @@ -2640,15 +2641,15 @@ Store = DAG.getStore(Chain, Value, getMemBasePlusOffset(Dst, DstOff, DAG), - DstSV, DstOff); + DstSV, DstSVOff + DstOff); } else { Value = DAG.getLoad(VT, Chain, getMemBasePlusOffset(Src, SrcOff, DAG), - SrcSV, SrcOff, false, Align); + SrcSV, SrcSVOff + SrcOff, false, Align); Store = DAG.getStore(Chain, Value, getMemBasePlusOffset(Dst, DstOff, DAG), - DstSV, DstOff, false, Align); + DstSV, DstSVOff + DstOff, false, Align); } OutChains.push_back(Store); SrcOff += VTSize; @@ -2663,7 +2664,7 @@ SDOperand Chain, SDOperand Dst, SDOperand Src, uint64_t Size, unsigned Align, - const Value *DstSV, uint64_t DstOff) { + const Value *DstSV, uint64_t DstSVOff) { const TargetLowering &TLI = DAG.getTargetLoweringInfo(); // Expand memset to a series of load/store ops if the size operand @@ -2674,6 +2675,7 @@ return SDOperand(); SmallVector OutChains; + uint64_t DstOff = 0; unsigned NumMemOps = MemOps.size(); for (unsigned i = 0; i < NumMemOps; i++) { @@ -2682,7 +2684,7 @@ SDOperand Value = getMemsetValue(Src, VT, DAG); SDOperand Store = DAG.getStore(Chain, Value, getMemBasePlusOffset(Dst, DstOff, DAG), - DstSV, DstOff); + DstSV, DstSVOff + DstOff); OutChains.push_back(Store); DstOff += VTSize; } @@ -2694,8 +2696,8 @@ SDOperand SelectionDAG::getMemcpy(SDOperand Chain, SDOperand Dst, SDOperand Src, SDOperand Size, unsigned Align, bool AlwaysInline, - const Value *DstSV, uint64_t DstOff, - const Value *SrcSV, uint64_t SrcOff) { + const Value *DstSV, uint64_t DstSVOff, + const Value *SrcSV, uint64_t SrcSVOff) { // Check to see if we should lower the memcpy to loads and stores first. // For cases within the target-specified limits, this is the best choice. @@ -2707,7 +2709,7 @@ SDOperand Result = getMemcpyLoadsAndStores(*this, Chain, Dst, Src, ConstantSize->getValue(), - Align, false, DstSV, DstOff, SrcSV, SrcOff); + Align, false, DstSV, DstSVOff, SrcSV, SrcSVOff); if (Result.Val) return Result; } @@ -2717,7 +2719,7 @@ SDOperand Result = TLI.EmitTargetCodeForMemcpy(*this, Chain, Dst, Src, Size, Align, AlwaysInline, - DstSV, DstOff, SrcSV, SrcOff); + DstSV, DstSVOff, SrcSV, SrcSVOff); if (Result.Val) return Result; @@ -2727,7 +2729,7 @@ assert(ConstantSize && "AlwaysInline requires a constant size!"); return getMemcpyLoadsAndStores(*this, Chain, Dst, Src, ConstantSize->getValue(), Align, true, - DstSV, DstOff, SrcSV, SrcOff); + DstSV, DstSVOff, SrcSV, SrcSVOff); } // Emit a library call. @@ -2748,8 +2750,8 @@ SDOperand SelectionDAG::getMemmove(SDOperand Chain, SDOperand Dst, SDOperand Src, SDOperand Size, unsigned Align, - const Value *DstSV, uint64_t DstOff, - const Value *SrcSV, uint64_t SrcOff) { + const Value *DstSV, uint64_t DstSVOff, + const Value *SrcSV, uint64_t SrcSVOff) { // TODO: Optimize small memmove cases with simple loads and stores, // ensuring that all loads precede all stores. This can cause severe @@ -2759,7 +2761,7 @@ // code. If the target chooses to do this, this is the next best. SDOperand Result = TLI.EmitTargetCodeForMemmove(*this, Chain, Dst, Src, Size, Align, - DstSV, DstOff, SrcSV, SrcOff); + DstSV, DstSVOff, SrcSV, SrcSVOff); if (Result.Val) return Result; @@ -2781,7 +2783,7 @@ SDOperand SelectionDAG::getMemset(SDOperand Chain, SDOperand Dst, SDOperand Src, SDOperand Size, unsigned Align, - const Value *DstSV, uint64_t DstOff) { + const Value *DstSV, uint64_t DstSVOff) { // Check to see if we should lower the memset to stores first. // For cases within the target-specified limits, this is the best choice. @@ -2793,7 +2795,7 @@ SDOperand Result = getMemsetStores(*this, Chain, Dst, Src, ConstantSize->getValue(), Align, - DstSV, DstOff); + DstSV, DstSVOff); if (Result.Val) return Result; } @@ -2802,7 +2804,7 @@ // code. If the target chooses to do this, this is the next best. SDOperand Result = TLI.EmitTargetCodeForMemset(*this, Chain, Dst, Src, Size, Align, - DstSV, DstOff); + DstSV, DstSVOff); if (Result.Val) return Result; Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=50359&r1=50358&r2=50359&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Mon Apr 28 12:15:20 2008 @@ -1247,8 +1247,8 @@ SDOperand Dst, SDOperand Src, SDOperand Size, unsigned Align, bool AlwaysInline, - const Value *DstSV, uint64_t DstOff, - const Value *SrcSV, uint64_t SrcOff){ + const Value *DstSV, uint64_t DstSVOff, + const Value *SrcSV, uint64_t SrcSVOff){ // Do repeated 4-byte loads and stores. To be improved. // This requires 4-byte alignment. if ((Align & 3) != 0) @@ -1271,6 +1271,7 @@ const unsigned MAX_LOADS_IN_LDM = 6; SDOperand TFOps[MAX_LOADS_IN_LDM]; SDOperand Loads[MAX_LOADS_IN_LDM]; + uint64_t SrcOff = 0, DstOff = 0; // Emit up to MAX_LOADS_IN_LDM loads, then a TokenFactor barrier, then the // same number of stores. The loads and stores will get combined into @@ -1281,7 +1282,7 @@ Loads[i] = DAG.getLoad(VT, Chain, DAG.getNode(ISD::ADD, MVT::i32, Src, DAG.getConstant(SrcOff, MVT::i32)), - SrcSV, SrcOff); + SrcSV, SrcSVOff + SrcOff); TFOps[i] = Loads[i].getValue(1); SrcOff += VTSize; } @@ -1292,7 +1293,7 @@ TFOps[i] = DAG.getStore(Chain, Loads[i], DAG.getNode(ISD::ADD, MVT::i32, Dst, DAG.getConstant(DstOff, MVT::i32)), - DstSV, DstOff); + DstSV, DstSVOff + DstOff); DstOff += VTSize; } Chain = DAG.getNode(ISD::TokenFactor, MVT::Other, &TFOps[0], i); @@ -1318,7 +1319,7 @@ Loads[i] = DAG.getLoad(VT, Chain, DAG.getNode(ISD::ADD, MVT::i32, Src, DAG.getConstant(SrcOff, MVT::i32)), - SrcSV, SrcOff); + SrcSV, SrcSVOff + SrcOff); TFOps[i] = Loads[i].getValue(1); ++i; SrcOff += VTSize; @@ -1340,7 +1341,7 @@ TFOps[i] = DAG.getStore(Chain, Loads[i], DAG.getNode(ISD::ADD, MVT::i32, Dst, DAG.getConstant(DstOff, MVT::i32)), - DstSV, DstOff); + DstSV, DstSVOff + DstOff); ++i; DstOff += VTSize; BytesLeft -= VTSize; Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.h?rev=50359&r1=50358&r2=50359&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.h (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.h Mon Apr 28 12:15:20 2008 @@ -149,8 +149,8 @@ SDOperand Dst, SDOperand Src, SDOperand Size, unsigned Align, bool AlwaysInline, - const Value *DstSV, uint64_t DstOff, - const Value *SrcSV, uint64_t SrcOff); + const Value *DstSV, uint64_t DstSVOff, + const Value *SrcSV, uint64_t SrcSVOff); }; } Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=50359&r1=50358&r2=50359&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Mon Apr 28 12:15:20 2008 @@ -4763,7 +4763,7 @@ SDOperand Chain, SDOperand Dst, SDOperand Src, SDOperand Size, unsigned Align, - const Value *DstSV, uint64_t DstOff) { + const Value *DstSV, uint64_t DstSVOff) { ConstantSDNode *ConstantSize = dyn_cast(Size); /// If not DWORD aligned or size is more than the threshold, call the library. @@ -4890,7 +4890,7 @@ DAG.getConstant(Offset, AddrVT)), Src, DAG.getConstant(BytesLeft, SizeVT), - Align, DstSV, 0); + Align, DstSV, DstSVOff + Offset); } // TODO: Use a Tokenfactor, as in memcpy, instead of a single chain. @@ -4903,8 +4903,8 @@ SDOperand Dst, SDOperand Src, SDOperand Size, unsigned Align, bool AlwaysInline, - const Value *DstSV, uint64_t DstOff, - const Value *SrcSV, uint64_t SrcOff){ + const Value *DstSV, uint64_t DstSVOff, + const Value *SrcSV, uint64_t SrcSVOff){ // This requires the copy size to be a constant, preferrably // within a subtarget-specific limit. @@ -4964,7 +4964,8 @@ DAG.getConstant(Offset, SrcVT)), DAG.getConstant(BytesLeft, SizeVT), Align, AlwaysInline, - DstSV, 0, SrcSV, 0)); + DstSV, DstSVOff + Offset, + SrcSV, SrcSVOff + Offset)); } return DAG.getNode(ISD::TokenFactor, MVT::Other, &Results[0], Results.size()); Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=50359&r1=50358&r2=50359&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Mon Apr 28 12:15:20 2008 @@ -538,14 +538,14 @@ SDOperand Chain, SDOperand Dst, SDOperand Src, SDOperand Size, unsigned Align, - const Value *DstSV, uint64_t DstOff); + const Value *DstSV, uint64_t DstSVOff); SDOperand EmitTargetCodeForMemcpy(SelectionDAG &DAG, SDOperand Chain, SDOperand Dst, SDOperand Src, SDOperand Size, unsigned Align, bool AlwaysInline, - const Value *DstSV, uint64_t DstOff, - const Value *SrcSV, uint64_t SrcOff); + const Value *DstSV, uint64_t DstSVOff, + const Value *SrcSV, uint64_t SrcSVOff); }; } From gohman at apple.com Mon Apr 28 12:27:57 2008 From: gohman at apple.com (Dan Gohman) Date: Mon, 28 Apr 2008 10:27:57 -0700 Subject: [llvm-commits] Speeding up instruction selection (ScheduleDAGRRList) In-Reply-To: References: Message-ID: On Apr 24, 2008, at 6:07 AM, Roman Levenstein wrote: > >> /Users/echeng/LLVM/llvm/Release/bin/llc -f Output/sqlite3.llvm.bc -o >> Output/sqlite3.llc.s >> Assertion failed: (RemovedNum == 1 && "Not in queue!"), function >> remove, file ScheduleDAGRRList.cpp, line 1321. > > Fixed. This was a bug related to the CapturePred function. It was > updating the state of the SUnit before removing it. As a result, the > comparison operators were working incorrectly and this SUnit could not > be removed properly. This is something that could cause subtle oddities in the priority_queue implementation too. Good catch! > > > With this patch, everything compiles without any problems on my > machine. > > The new patch is attached. This looks good; please commit it. I expect we'll be revisiting the use of std::set, but in the testing I've done it doesn't seem to be a big enough factor to hold this up. Dan From gordonhenriksen at mac.com Mon Apr 28 12:37:06 2008 From: gordonhenriksen at mac.com (Gordon Henriksen) Date: Mon, 28 Apr 2008 17:37:06 -0000 Subject: [llvm-commits] [llvm] r50360 - in /llvm/trunk: include/llvm-c/Core.h include/llvm/Argument.h lib/VMCore/Core.cpp lib/VMCore/Function.cpp Message-ID: <200804281737.m3SHb7ME014773@zion.cs.uiuc.edu> Author: gordon Date: Mon Apr 28 12:37:06 2008 New Revision: 50360 URL: http://llvm.org/viewvc/llvm-project?rev=50360&view=rev Log: Expose parameter attributes via C bindings. Patch by Anders Johnsen! Modified: llvm/trunk/include/llvm-c/Core.h llvm/trunk/include/llvm/Argument.h llvm/trunk/lib/VMCore/Core.cpp llvm/trunk/lib/VMCore/Function.cpp Modified: llvm/trunk/include/llvm-c/Core.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=50360&r1=50359&r2=50360&view=diff ============================================================================== --- llvm/trunk/include/llvm-c/Core.h (original) +++ llvm/trunk/include/llvm-c/Core.h Mon Apr 28 12:37:06 2008 @@ -83,6 +83,20 @@ typedef struct LLVMOpaquePassManager *LLVMPassManagerRef; typedef enum { + LLVMZExtParamAttr = 1<<0, + LLVMSExtParamAttr = 1<<1, + LLVMNoReturnParamAttr = 1<<2, + LLVMNoUnwindParamAttr = 1<<3, + LLVMInRegParamAttr = 1<<4, + LLVMNoAliasParamAttr = 1<<5, + LLVMStructRetParamAttr = 1<<6, + LLVMByValParamAttr = 1<<7, + LLVMNestParamAttr = 1<<8, + LLVMReadNoneParamAttr = 1<<9, + LLVMReadOnlyParamAttr = 1<<10 +} LLVMParamAttr; + +typedef enum { LLVMVoidTypeKind, /**< type with no size */ LLVMFloatTypeKind, /**< 32 bit floating point type */ LLVMDoubleTypeKind, /**< 64 bit floating point type */ @@ -413,6 +427,9 @@ LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn); LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg); LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg); +void LLVMAddParamAttr(LLVMValueRef Arg, LLVMParamAttr PA); +void LLVMRemoveParamAttr(LLVMValueRef Arg, LLVMParamAttr PA); +void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align); /* Operations on basic blocks */ LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB); @@ -441,6 +458,11 @@ /* Operations on call sites */ void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC); unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr); +void LLVMAddInstrParamAttr(LLVMValueRef Instr, unsigned index, LLVMParamAttr); +void LLVMRemoveInstrParamAttr(LLVMValueRef Instr, unsigned index, + LLVMParamAttr); +void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index, + unsigned align); /* Operations on phi nodes */ void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues, Modified: llvm/trunk/include/llvm/Argument.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Argument.h?rev=50360&r1=50359&r2=50360&view=diff ============================================================================== --- llvm/trunk/include/llvm/Argument.h (original) +++ llvm/trunk/include/llvm/Argument.h Mon Apr 28 12:37:06 2008 @@ -15,6 +15,7 @@ #define LLVM_ARGUMENT_H #include "llvm/Value.h" +#include "llvm/ParameterAttributes.h" namespace llvm { @@ -60,7 +61,13 @@ /// hasSRetAttr - Return true if this argument has the sret attribute on it in /// its containing function. bool hasStructRetAttr() const; + + /// addAttr - Add a ParamAttr to an argument + void addAttr(ParameterAttributes); + /// removeAttr - Remove a ParamAttr from an argument + void removeAttr(ParameterAttributes); + virtual void print(std::ostream &OS) const; void print(std::ostream *OS) const { if (OS) print(*OS); Modified: llvm/trunk/lib/VMCore/Core.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=50360&r1=50359&r2=50360&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Core.cpp (original) +++ llvm/trunk/lib/VMCore/Core.cpp Mon Apr 28 12:37:06 2008 @@ -20,6 +20,7 @@ #include "llvm/TypeSymbolTable.h" #include "llvm/ModuleProvider.h" #include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/CallSite.h" #include #include #include @@ -798,6 +799,19 @@ return wrap(--I); } +void LLVMAddParamAttr(LLVMValueRef Arg, LLVMParamAttr PA) { + unwrap(Arg)->addAttr(PA); +} + +void LLVMRemoveParamAttr(LLVMValueRef Arg, LLVMParamAttr PA) { + unwrap(Arg)->removeAttr(PA); +} + +void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align) { + unwrap(Arg)->addAttr( + ParamAttr::constructAlignmentFromInt(align)); +} + /*--.. Operations on basic blocks ..........................................--*/ LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB) { @@ -936,6 +950,28 @@ assert(0 && "LLVMSetInstructionCallConv applies only to call and invoke!"); } +void LLVMAddInstrParamAttr(LLVMValueRef Instr, unsigned index, + LLVMParamAttr PA) { + CallSite Call = CallSite(unwrap(Instr)); + Call.setParamAttrs( + Call.getParamAttrs().addAttr(index, PA)); +} + +void LLVMRemoveInstrParamAttr(LLVMValueRef Instr, unsigned index, + LLVMParamAttr PA) { + CallSite Call = CallSite(unwrap(Instr)); + Call.setParamAttrs( + Call.getParamAttrs().removeAttr(index, PA)); +} + +void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index, + unsigned align) { + CallSite Call = CallSite(unwrap(Instr)); + Call.setParamAttrs( + Call.getParamAttrs().addAttr(index, + ParamAttr::constructAlignmentFromInt(align))); +} + /*--.. Operations on phi nodes .............................................--*/ void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues, Modified: llvm/trunk/lib/VMCore/Function.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=50360&r1=50359&r2=50360&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Function.cpp (original) +++ llvm/trunk/lib/VMCore/Function.cpp Mon Apr 28 12:37:06 2008 @@ -110,6 +110,17 @@ return getParent()->paramHasAttr(1, ParamAttr::StructRet); } +/// addAttr - Add a ParamAttr to an argument +void Argument::addAttr(ParameterAttributes attr) { + getParent()->setParamAttrs( + getParent()->getParamAttrs().addAttr(getArgNo() + 1, attr)); +} + +/// removeAttr - Remove a ParamAttr from an argument +void Argument::removeAttr(ParameterAttributes attr) { + getParent()->setParamAttrs( + getParent()->getParamAttrs().removeAttr(getArgNo() + 1, attr)); +} From gohman at apple.com Mon Apr 28 12:42:03 2008 From: gohman at apple.com (Dan Gohman) Date: Mon, 28 Apr 2008 17:42:03 -0000 Subject: [llvm-commits] [llvm] r50361 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <200804281742.m3SHg3YS014897@zion.cs.uiuc.edu> Author: djg Date: Mon Apr 28 12:42:03 2008 New Revision: 50361 URL: http://llvm.org/viewvc/llvm-project?rev=50361&view=rev Log: Don't call size() on each iteration of the loop. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=50361&r1=50360&r2=50361&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Mon Apr 28 12:42:03 2008 @@ -158,7 +158,7 @@ unsigned Reg, const Type *Ty) : TLI(&tli) { ComputeValueVTs(tli, Ty, ValueVTs); - for (unsigned Value = 0; Value != ValueVTs.size(); ++Value) { + for (unsigned Value = 0, e = ValueVTs.size(); Value != e; ++Value) { MVT::ValueType ValueVT = ValueVTs[Value]; unsigned NumRegs = TLI->getNumRegisters(ValueVT); MVT::ValueType RegisterVT = TLI->getRegisterType(ValueVT); @@ -364,7 +364,7 @@ ComputeValueVTs(TLI, V->getType(), ValueVTs); unsigned FirstReg = 0; - for (unsigned Value = 0; Value != ValueVTs.size(); ++Value) { + for (unsigned Value = 0, e = ValueVTs.size(); Value != e; ++Value) { MVT::ValueType ValueVT = ValueVTs[Value]; MVT::ValueType RegisterVT = TLI.getRegisterType(ValueVT); From kremenek at apple.com Mon Apr 28 12:58:07 2008 From: kremenek at apple.com (Ted Kremenek) Date: Mon, 28 Apr 2008 17:58:07 -0000 Subject: [llvm-commits] [llvm] r50362 - /llvm/trunk/lib/Support/Allocator.cpp Message-ID: <200804281758.m3SHw7lm015385@zion.cs.uiuc.edu> Author: kremenek Date: Mon Apr 28 12:58:07 2008 New Revision: 50362 URL: http://llvm.org/viewvc/llvm-project?rev=50362&view=rev Log: Bug fix in BumpPtrAllocator: don't assume that all objects have the same alignment. "Bump" of the pointer for the next allocated object to be of the specified alignment. Modified: llvm/trunk/lib/Support/Allocator.cpp Modified: llvm/trunk/lib/Support/Allocator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Allocator.cpp?rev=50362&r1=50361&r2=50362&view=diff ============================================================================== --- llvm/trunk/lib/Support/Allocator.cpp (original) +++ llvm/trunk/lib/Support/Allocator.cpp Mon Apr 28 12:58:07 2008 @@ -46,13 +46,16 @@ /// 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; + char* Result = (char*) (((uintptr_t) (NextPtr+Alignment-1)) + & ~(Alignment-1)); + + // Speculate the new value of NextPtr. + char* NextPtrTmp = Result + AllocSize; + + // If we are still within the current region, return Result. + if (unsigned (NextPtrTmp - (char*) this) <= RegionSize) { + NextPtr = NextPtrTmp; return Result; } From kremenek at apple.com Mon Apr 28 12:58:20 2008 From: kremenek at apple.com (Ted Kremenek) Date: Mon, 28 Apr 2008 17:58:20 -0000 Subject: [llvm-commits] [llvm] r50363 - /llvm/trunk/include/llvm/Support/AlignOf.h Message-ID: <200804281758.m3SHwKGM015404@zion.cs.uiuc.edu> Author: kremenek Date: Mon Apr 28 12:58:20 2008 New Revision: 50363 URL: http://llvm.org/viewvc/llvm-project?rev=50363&view=rev Log: Add more alignment enums. Modified: llvm/trunk/include/llvm/Support/AlignOf.h Modified: llvm/trunk/include/llvm/Support/AlignOf.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/AlignOf.h?rev=50363&r1=50362&r2=50363&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/AlignOf.h (original) +++ llvm/trunk/include/llvm/Support/AlignOf.h Mon Apr 28 12:58:20 2008 @@ -35,10 +35,17 @@ template struct AlignOf { enum { Alignment = sizeof(AlignmentCalcImpl) - sizeof(T) }; + enum { Alignment_GreaterEqual_2Bytes = Alignment >= 2 ? 1 : 0 }; enum { Alignment_GreaterEqual_4Bytes = Alignment >= 4 ? 1 : 0 }; enum { Alignment_GreaterEqual_8Bytes = Alignment >= 8 ? 1 : 0 }; enum { Alignment_GreaterEqual_16Bytes = Alignment >= 16 ? 1 : 0 }; + + enum { Alignment_LessEqual_2Bytes = Alignment <= 2 ? 1 : 0 }; + enum { Alignment_LessEqual_4Bytes = Alignment <= 4 ? 1 : 0 }; + enum { Alignment_LessEqual_8Bytes = Alignment <= 8 ? 1 : 0 }; + enum { Alignment_LessEqual_16Bytes = Alignment <= 16 ? 1 : 0 }; + }; /// alignof - A templated function that returns the mininum alignment of From gohman at apple.com Mon Apr 28 13:10:41 2008 From: gohman at apple.com (Dan Gohman) Date: Mon, 28 Apr 2008 18:10:41 -0000 Subject: [llvm-commits] [llvm] r50365 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <200804281810.m3SIAfXu015793@zion.cs.uiuc.edu> Author: djg Date: Mon Apr 28 13:10:39 2008 New Revision: 50365 URL: http://llvm.org/viewvc/llvm-project?rev=50365&view=rev Log: Rewrite the comments for RegsForValue and its members, and reorder some of the members for clarity. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=50365&r1=50364&r2=50365&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Mon Apr 28 13:10:39 2008 @@ -114,46 +114,56 @@ } namespace { - /// RegsForValue - This struct represents the physical registers that a - /// particular value is assigned and the type information about the value. - /// This is needed because values can be promoted into larger registers and - /// expanded into multiple smaller registers than the value. + /// RegsForValue - This struct represents the registers (physical or virtual) + /// that a particular set of values is assigned, and the type information about + /// the value. The most common situation is to represent one value at a time, + /// but struct or array values are handled element-wise as multiple values. + /// The splitting of aggregates is performed recursively, so that we never + /// have aggregate-typed registers. The values at this point do not necessarily + /// have legal types, so each value may require one or more registers of some + /// legal type. + /// struct VISIBILITY_HIDDEN RegsForValue { /// TLI - The TargetLowering object. + /// const TargetLowering *TLI; - /// Regs - This list holds the register (for legal and promoted values) - /// or register set (for expanded values) that the value should be assigned - /// to. - SmallVector Regs; + /// ValueVTs - The value types of the values, which may not be legal, and + /// may need be promoted or synthesized from one or more registers. + /// + SmallVector ValueVTs; - /// RegVTs - The value types of the registers. This is the same size - /// as ValueVTs; every register contributing to a given value must - /// have the same type. When Regs contains all virtual registers, the - /// contents of RegVTs is redundant with TLI's getRegisterType member - /// function, however when Regs contains physical registers, it is - /// necessary to have a separate record of the types. + /// RegVTs - The value types of the registers. This is the same size as + /// ValueVTs and it records, for each value, what the type of the assigned + /// register or registers are. (Individual values are never synthesized + /// from more than one type of register.) + /// + /// With virtual registers, the contents of RegVTs is redundant with TLI's + /// getRegisterType member function, however when with physical registers + /// it is necessary to have a separate record of the types. /// SmallVector RegVTs; - /// ValueVTs - The value types of the values, which may be promoted - /// or synthesized from one or more registers. - SmallVector ValueVTs; + /// Regs - This list holds the registers assigned to the values. + /// Each legal or promoted value requires one register, and each + /// expanded value requires multiple registers. + /// + SmallVector Regs; RegsForValue() : TLI(0) {} RegsForValue(const TargetLowering &tli, unsigned Reg, MVT::ValueType regvt, MVT::ValueType valuevt) - : TLI(&tli), Regs(1, Reg), RegVTs(1, regvt), ValueVTs(1, valuevt) {} + : TLI(&tli), ValueVTs(1, valuevt), RegVTs(1, regvt), Regs(1, Reg) {} RegsForValue(const TargetLowering &tli, const SmallVector ®s, MVT::ValueType regvt, MVT::ValueType valuevt) - : TLI(&tli), Regs(regs), RegVTs(1, regvt), ValueVTs(1, valuevt) {} + : TLI(&tli), ValueVTs(1, valuevt), RegVTs(1, regvt), Regs(regs) {} RegsForValue(const TargetLowering &tli, const SmallVector ®s, const SmallVector ®vts, const SmallVector &valuevts) - : TLI(&tli), Regs(regs), RegVTs(regvts), ValueVTs(valuevts) {} + : TLI(&tli), ValueVTs(valuevts), RegVTs(regvts), Regs(regs) {} RegsForValue(const TargetLowering &tli, unsigned Reg, const Type *Ty) : TLI(&tli) { ComputeValueVTs(tli, Ty, ValueVTs); From clattner at apple.com Mon Apr 28 13:14:26 2008 From: clattner at apple.com (Chris Lattner) Date: Mon, 28 Apr 2008 11:14:26 -0700 Subject: [llvm-commits] [llvm] r50358 - in /llvm/trunk: lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/sext-misc.ll In-Reply-To: <200804281702.m3SH2MPF013676@zion.cs.uiuc.edu> References: <200804281702.m3SH2MPF013676@zion.cs.uiuc.edu> Message-ID: On Apr 28, 2008, at 10:02 AM, Dan Gohman wrote: > Log: > Teach InstCombine's ComputeMaskedBits what SelectionDAG's > ComputeMaskedBits knows about cttz, ctlz, and ctpop. Teach > SelectionDAG's ComputeMaskedBits what InstCombine's knows > about SRem. And teach them both some things about high bits > in Mul, UDiv, URem, and Sub. This allows instcombine and > dagcombine to eliminate sign-extension operations in > several new cases. Nice! -Chris From gohman at apple.com Mon Apr 28 13:19:43 2008 From: gohman at apple.com (Dan Gohman) Date: Mon, 28 Apr 2008 18:19:43 -0000 Subject: [llvm-commits] [llvm] r50366 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <200804281819.m3SIJifM016055@zion.cs.uiuc.edu> Author: djg Date: Mon Apr 28 13:19:43 2008 New Revision: 50366 URL: http://llvm.org/viewvc/llvm-project?rev=50366&view=rev Log: Add a comment to CreateRegForValue that clarifies the handling of aggregate types. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=50366&r1=50365&r2=50366&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Mon Apr 28 13:19:43 2008 @@ -369,6 +369,10 @@ /// CreateRegForValue - Allocate the appropriate number of virtual registers of /// the correctly promoted or expanded types. Assign these registers /// consecutive vreg numbers and return the first assigned number. +/// +/// In the case that the given value has struct or array type, this function +/// will assign registers for each member or element. +/// unsigned FunctionLoweringInfo::CreateRegForValue(const Value *V) { SmallVector ValueVTs; ComputeValueVTs(TLI, V->getType(), ValueVTs); From gohman at apple.com Mon Apr 28 13:28:50 2008 From: gohman at apple.com (Dan Gohman) Date: Mon, 28 Apr 2008 18:28:50 -0000 Subject: [llvm-commits] [llvm] r50367 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <200804281828.m3SISoL2016483@zion.cs.uiuc.edu> Author: djg Date: Mon Apr 28 13:28:49 2008 New Revision: 50367 URL: http://llvm.org/viewvc/llvm-project?rev=50367&view=rev Log: Delete an unused constructor. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=50367&r1=50366&r2=50367&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Mon Apr 28 13:28:49 2008 @@ -153,9 +153,6 @@ RegsForValue() : TLI(0) {} RegsForValue(const TargetLowering &tli, - unsigned Reg, MVT::ValueType regvt, MVT::ValueType valuevt) - : TLI(&tli), ValueVTs(1, valuevt), RegVTs(1, regvt), Regs(1, Reg) {} - RegsForValue(const TargetLowering &tli, const SmallVector ®s, MVT::ValueType regvt, MVT::ValueType valuevt) : TLI(&tli), ValueVTs(1, valuevt), RegVTs(1, regvt), Regs(regs) {} From evan.cheng at apple.com Mon Apr 28 13:35:41 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 28 Apr 2008 11:35:41 -0700 Subject: [llvm-commits] [llvm] r50357 - /llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp In-Reply-To: <200804281658.m3SGwPBH013528@zion.cs.uiuc.edu> References: <200804281658.m3SGwPBH013528@zion.cs.uiuc.edu> Message-ID: <1A96CB40-FEB1-4187-B1D0-6BA415CBF1AF@apple.com> Is this always safe? What if zext of the type is not legal? Evan On Apr 28, 2008, at 9:58 AM, Dan Gohman wrote: > Author: djg > Date: Mon Apr 28 11:58:24 2008 > New Revision: 50357 > > URL: http://llvm.org/viewvc/llvm-project?rev=50357&view=rev > Log: > Teach DAGCombine to convert (sext x) to (zext x) when the > sign-bit of x is known to be zero. > > Modified: > llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp > > Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=50357&r1=50356&r2=50357&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original) > +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Mon Apr 28 > 11:58:24 2008 > @@ -2887,6 +2887,10 @@ > if (SCC.Val) return SCC; > } > > + // fold (sext x) -> (zext x) if the sign bit is known zero. > + if (DAG.SignBitIsZero(N0)) > + return DAG.getNode(ISD::ZERO_EXTEND, VT, N0); > + > return SDOperand(); > } > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From gohman at apple.com Mon Apr 28 13:41:28 2008 From: gohman at apple.com (Dan Gohman) Date: Mon, 28 Apr 2008 11:41:28 -0700 Subject: [llvm-commits] [llvm] r50279 - in /llvm/trunk: lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp lib/Transforms/Scalar/CodeGenPrepare.cpp test/CodeGen/Generic/multiple-return-values-cross-block-with-invoke.ll In-Reply-To: References: <200804251827.m3PIRtH4003953@zion.cs.uiuc.edu> Message-ID: <99F2986B-B21C-45EC-84F1-715893122EA2@apple.com> On Apr 28, 2008, at 12:13 AM, Chris Lattner wrote: > On Apr 25, 2008, at 11:27 AM, Dan Gohman wrote: >> >> /// RegsForValue - This struct represents the physical registers >> that a >> /// particular value is assigned and the type information about >> the value. >> /// This is needed because values can be promoted into larger >> registers and >> /// expanded into multiple smaller registers than the value. >> struct VISIBILITY_HIDDEN RegsForValue { > > This should probably explicitly mention how it handles aggregates. > Maybe a good general summary up front could help my larger complaint > next: I rewrote this comment. Let me know if have further questions. > > > > ... > >> + /// RegVTs - The value types of the registers. This is the same >> size >> + /// as ValueVTs; every register contributing to a given value >> must >> + /// have the same type. When Regs contains all virtual >> registers, the >> + /// contents of RegVTs is redundant with TLI's getRegisterType >> member >> + /// function, however when Regs contains physical registers, it >> is >> + /// necessary to have a separate record of the types. >> /// >> + SmallVector RegVTs; >> >> + /// ValueVTs - The value types of the values, which may be >> promoted >> + /// or synthesized from one or more registers. >> + SmallVector ValueVTs; > > The descriptions of these fields is not very clear to me. The > description of RegVTs forward references ValueVTs, maybe ValueVTs > should be moved first? It would be helpful to have an explanatory > comment here with an example. For example, on PPC, how is {i8, i64} > handled by these two vectors? Maybe 'Regs' should have a comment that > indicates it can contain pregs? I rewrote several related comments to be more explanatory. > > >> >> + >> + RegsForValue() : TLI(0) {} >> + >> + RegsForValue(const TargetLowering &tli, >> + unsigned Reg, MVT::ValueType regvt, MVT::ValueType >> valuevt) >> + : TLI(&tli), Regs(1, Reg), RegVTs(1, regvt), ValueVTs(1, >> valuevt) {} >> + RegsForValue(const TargetLowering &tli, >> + const std::vector ®s, >> MVT::ValueType regvt, MVT::ValueType valuevt) >> + : TLI(&tli), Regs(regs), RegVTs(1, regvt), ValueVTs(1, >> valuevt) {} >> + RegsForValue(const TargetLowering &tli, >> + const std::vector ®s, >> + const SmallVector ®vts, >> + const SmallVector &valuevts) >> + : TLI(&tli), Regs(regs), RegVTs(regvts), ValueVTs(valuevts) {} >> + RegsForValue(const TargetLowering &tli, >> + unsigned Reg, const Type *Ty) : TLI(&tli) { > > So many ctors... would it be reasonable to change clients to use one > of the more general ones instead of having so many ctors? One of them was unused; I deleted it. > > >> >> + ComputeValueVTs(tli, Ty, ValueVTs); >> + >> + for (unsigned Value = 0; Value != ValueVTs.size(); ++Value) { > > Please add a comment explaining what this loop is doing. Does > 'ValueVTs.size()' need to be recomputed on every iteration? No, it ought to be inlined :-). I fixed it though. > > >> >> + MVT::ValueType ValueVT = ValueVTs[Value]; >> + unsigned NumRegs = TLI->getNumRegisters(ValueVT); >> + MVT::ValueType RegisterVT = TLI->getRegisterType(ValueVT); >> + for (unsigned i = 0; i != NumRegs; ++i) >> + Regs.push_back(Reg + i); >> + RegVTs.push_back(RegisterVT); >> + Reg += NumRegs; >> + } >> } > > >> @@ -310,16 +362,22 @@ >> /// the correctly promoted or expanded types. Assign these registers >> /// consecutive vreg numbers and return the first assigned number. >> unsigned FunctionLoweringInfo::CreateRegForValue(const Value *V) { >> + const Type *Ty = V->getType(); >> + SmallVector ValueVTs; >> + ComputeValueVTs(TLI, Ty, ValueVTs); >> + >> + unsigned FirstReg = 0; >> + for (unsigned Value = 0; Value != ValueVTs.size(); ++Value) { >> + MVT::ValueType ValueVT = ValueVTs[Value]; >> + unsigned NumRegs = TLI.getNumRegisters(ValueVT); >> + MVT::ValueType RegisterVT = TLI.getRegisterType(ValueVT); >> >> + for (unsigned i = 0; i != NumRegs; ++i) { >> + unsigned R = MakeReg(RegisterVT); >> + if (!FirstReg) FirstReg = R; >> + } >> + } >> + return FirstReg; >> } > > The comments in this method should be improved to talk about what it > is now doing. Please mention aggregates. Could this code change to > use RegsForValue to compute the expansion? Maybe it should be a new > method on RegsForValue? I added a comment that mentions aggregates. This code does use ComputeValueVTs to do most of the work; that's a function I factored out specifically for the purpose of using it in both CreateRegForValue and RegsForValue. > > >> @@ -3898,8 +3985,9 @@ >> if ((NumOps & 7) == 2 /*REGDEF*/) { >> // Add NumOps>>3 registers to MatchedRegs. >> RegsForValue MatchedRegs; >> - MatchedRegs.ValueVT = InOperandVal.getValueType(); >> - MatchedRegs.RegVT = AsmNodeOperands[CurOp >> +1].getValueType(); >> + MatchedRegs.TLI = &TLI; >> + MatchedRegs.ValueVTs.resize(1, >> InOperandVal.getValueType()); >> + MatchedRegs.RegVTs.resize(1, AsmNodeOperands[CurOp >> +1].getValueType()); > > Please use push_back, instead of resize(1, x) I used resize because it's initializing the vector contents with exactly one element. But I'll change it if you insist :-). > > >> @@ -4304,21 +4392,14 @@ >> } >> >> // Figure out the result value types. We start by making a list of >> + // the potentially illegal return value types. >> SmallVector LoweredRetTys; >> SmallVector RetTys; >> + ComputeValueVTs(*this, RetTy, RetTys); >> >> + // Then we translate that to a list of legal types. >> + for (unsigned I = 0, E = RetTys.size(); I != E; ++I) { >> + MVT::ValueType VT = RetTys[I]; >> MVT::ValueType RegisterVT = getRegisterType(VT); >> unsigned NumRegs = getNumRegisters(VT); >> for (unsigned i = 0; i != NumRegs; ++i) > > This seems like something that should be a method on RegsForValue. It isn't trivial to do though. I expect we'll continue to refactor RegsForValue and eventually get this cleaned up. > > >> @@ -4441,19 +4522,11 @@ >> cast(Op.getOperand(1))->getReg() != Reg) && >> "Copy from a reg to the same reg!"); >> assert(!TargetRegisterInfo::isPhysicalRegister(Reg) && "Is a >> physreg"); >> + RegsForValue RFV(TLI, Reg, V->getType()); >> + SDOperand Chain = DAG.getEntryNode(); >> + RFV.getCopyToRegs(Op, DAG, Chain, 0); >> + PendingExports.push_back(Chain); >> } > > I'm not sure if your patch is responsible, but it is very strange to > me that RegsForValue::getCopyToRegs takes 'Chain' byref and mutates > the input. Should RegsForValue::getCopyToRegs return a new chain > instead? Perhaps, but currently the Chain handling is consistent with the optional Flag handling. Dan From gohman at apple.com Mon Apr 28 13:47:17 2008 From: gohman at apple.com (Dan Gohman) Date: Mon, 28 Apr 2008 18:47:17 -0000 Subject: [llvm-commits] [llvm] r50368 - /llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Message-ID: <200804281847.m3SIlHSB017114@zion.cs.uiuc.edu> Author: djg Date: Mon Apr 28 13:47:17 2008 New Revision: 50368 URL: http://llvm.org/viewvc/llvm-project?rev=50368&view=rev Log: Evan pointed out that folding sext to zext may not be correct if the zext is not legal. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=50368&r1=50367&r2=50368&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Mon Apr 28 13:47:17 2008 @@ -2888,7 +2888,8 @@ } // fold (sext x) -> (zext x) if the sign bit is known zero. - if (DAG.SignBitIsZero(N0)) + if ((!AfterLegalize || TLI.isOperationLegal(ISD::ZERO_EXTEND, VT)) && + DAG.SignBitIsZero(N0)) return DAG.getNode(ISD::ZERO_EXTEND, VT, N0); return SDOperand(); From dalej at apple.com Mon Apr 28 14:46:58 2008 From: dalej at apple.com (Dale Johannesen) Date: Mon, 28 Apr 2008 19:46:58 -0000 Subject: [llvm-commits] [llvm] r50369 - /llvm/trunk/include/llvm/Constants.h Message-ID: <200804281946.m3SJkwTW019211@zion.cs.uiuc.edu> Author: johannes Date: Mon Apr 28 14:46:58 2008 New Revision: 50369 URL: http://llvm.org/viewvc/llvm-project?rev=50369&view=rev Log: Don't try to convert PPC long double. Modified: llvm/trunk/include/llvm/Constants.h Modified: llvm/trunk/include/llvm/Constants.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Constants.h?rev=50369&r1=50368&r2=50369&view=diff ============================================================================== --- llvm/trunk/include/llvm/Constants.h (original) +++ llvm/trunk/include/llvm/Constants.h Mon Apr 28 14:46:58 2008 @@ -263,6 +263,9 @@ bool isExactlyValue(const APFloat& V) const; bool isExactlyValue(double V) const { + // convert is not supported on this type + if (&Val.getSemantics() == &APFloat::PPCDoubleDouble) + return false; APFloat FV(V); FV.convert(Val.getSemantics(), APFloat::rmNearestTiesToEven); return isExactlyValue(FV); From gohman at apple.com Mon Apr 28 14:51:27 2008 From: gohman at apple.com (Dan Gohman) Date: Mon, 28 Apr 2008 19:51:27 -0000 Subject: [llvm-commits] [llvm] r50370 - in /llvm/trunk: lib/Transforms/Scalar/DeadStoreElimination.cpp test/Transforms/DeadStoreElimination/volatile-load.ll Message-ID: <200804281951.m3SJpRnh019358@zion.cs.uiuc.edu> Author: djg Date: Mon Apr 28 14:51:27 2008 New Revision: 50370 URL: http://llvm.org/viewvc/llvm-project?rev=50370&view=rev Log: Fix DSE to not eliminate volatile loads with no uses. Added: llvm/trunk/test/Transforms/DeadStoreElimination/volatile-load.ll Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=50370&r1=50369&r2=50370&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Mon Apr 28 14:51:27 2008 @@ -326,9 +326,9 @@ // If we encounter a use of the pointer, it is no longer considered dead if (LoadInst* L = dyn_cast(BBI)) { - // However, if this load is unused, we can go ahead and remove it, and - // not have to worry about it making our pointer undead! - if (L->use_empty()) { + // However, if this load is unused and not volatile, we can go ahead and remove it, + // and not have to worry about it making our pointer undead! + if (L->use_empty() && !L->isVolatile()) { MD.removeInstruction(L); // DCE instructions only used to calculate that load Added: llvm/trunk/test/Transforms/DeadStoreElimination/volatile-load.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DeadStoreElimination/volatile-load.ll?rev=50370&view=auto ============================================================================== --- llvm/trunk/test/Transforms/DeadStoreElimination/volatile-load.ll (added) +++ llvm/trunk/test/Transforms/DeadStoreElimination/volatile-load.ll Mon Apr 28 14:51:27 2008 @@ -0,0 +1,8 @@ +; RUN: llvm-as < %s | opt -dse | llvm-dis | grep {volatile load} + + at g_1 = global i32 0 + +define void @foo() nounwind { + %t = volatile load i32* @g_1 + ret void +} From isanbard at gmail.com Mon Apr 28 14:57:12 2008 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 28 Apr 2008 19:57:12 -0000 Subject: [llvm-commits] [llvm] r50371 - /llvm/branches/Apple/Tak/include/llvm/Constants.h Message-ID: <200804281957.m3SJvCUk019722@zion.cs.uiuc.edu> Author: void Date: Mon Apr 28 14:57:12 2008 New Revision: 50371 URL: http://llvm.org/viewvc/llvm-project?rev=50371&view=rev Log: Porting r50369 to Tak. Modified: llvm/branches/Apple/Tak/include/llvm/Constants.h Modified: llvm/branches/Apple/Tak/include/llvm/Constants.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Tak/include/llvm/Constants.h?rev=50371&r1=50370&r2=50371&view=diff ============================================================================== --- llvm/branches/Apple/Tak/include/llvm/Constants.h (original) +++ llvm/branches/Apple/Tak/include/llvm/Constants.h Mon Apr 28 14:57:12 2008 @@ -263,6 +263,9 @@ bool isExactlyValue(const APFloat& V) const; bool isExactlyValue(double V) const { + // convert is not supported on this type + if (&Val.getSemantics() == &APFloat::PPCDoubleDouble) + return false; APFloat FV(V); FV.convert(Val.getSemantics(), APFloat::rmNearestTiesToEven); return isExactlyValue(FV); From gohman at apple.com Mon Apr 28 15:25:15 2008 From: gohman at apple.com (Dan Gohman) Date: Mon, 28 Apr 2008 20:25:15 -0000 Subject: [llvm-commits] [llvm] r50372 - /llvm/trunk/lib/Support/Allocator.cpp Message-ID: <200804282025.m3SKPF3X020635@zion.cs.uiuc.edu> Author: djg Date: Mon Apr 28 15:25:15 2008 New Revision: 50372 URL: http://llvm.org/viewvc/llvm-project?rev=50372&view=rev Log: Fix a pointer-arithmetic bug that caused 64-bit host pointer values to be truncated to 32 bits. This fixes the recent Benchmarks/McCat/09-vor regression on x86-64, among other things. Modified: llvm/trunk/lib/Support/Allocator.cpp Modified: llvm/trunk/lib/Support/Allocator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Allocator.cpp?rev=50372&r1=50371&r2=50372&view=diff ============================================================================== --- llvm/trunk/lib/Support/Allocator.cpp (original) +++ llvm/trunk/lib/Support/Allocator.cpp Mon Apr 28 15:25:15 2008 @@ -48,7 +48,7 @@ void *Allocate(unsigned AllocSize, unsigned Alignment, MemRegion **RegPtr) { char* Result = (char*) (((uintptr_t) (NextPtr+Alignment-1)) - & ~(Alignment-1)); + & ~((uintptr_t) Alignment-1)); // Speculate the new value of NextPtr. char* NextPtrTmp = Result + AllocSize; From isanbard at gmail.com Mon Apr 28 15:34:54 2008 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 28 Apr 2008 13:34:54 -0700 Subject: [llvm-commits] [llvm] r50372 - /llvm/trunk/lib/Support/Allocator.cpp In-Reply-To: <200804282025.m3SKPF3X020635@zion.cs.uiuc.edu> References: <200804282025.m3SKPF3X020635@zion.cs.uiuc.edu> Message-ID: <16e5fdf90804281334j7bdbd61ep57e03ae7f006213c@mail.gmail.com> Does this go into Tak? On Mon, Apr 28, 2008 at 1:25 PM, Dan Gohman wrote: > Author: djg > Date: Mon Apr 28 15:25:15 2008 > New Revision: 50372 > > URL: http://llvm.org/viewvc/llvm-project?rev=50372&view=rev > Log: > Fix a pointer-arithmetic bug that caused 64-bit host pointer values to > be truncated to 32 bits. This fixes the recent Benchmarks/McCat/09-vor > regression on x86-64, among other things. > > Modified: > llvm/trunk/lib/Support/Allocator.cpp > > Modified: llvm/trunk/lib/Support/Allocator.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Allocator.cpp?rev=50372&r1=50371&r2=50372&view=diff > > ============================================================================== > --- llvm/trunk/lib/Support/Allocator.cpp (original) > +++ llvm/trunk/lib/Support/Allocator.cpp Mon Apr 28 15:25:15 2008 > @@ -48,7 +48,7 @@ > void *Allocate(unsigned AllocSize, unsigned Alignment, MemRegion **RegPtr) { > > char* Result = (char*) (((uintptr_t) (NextPtr+Alignment-1)) > - & ~(Alignment-1)); > + & ~((uintptr_t) Alignment-1)); > > // Speculate the new value of NextPtr. > char* NextPtrTmp = Result + AllocSize; > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From gohman at apple.com Mon Apr 28 16:36:28 2008 From: gohman at apple.com (Dan Gohman) Date: Mon, 28 Apr 2008 21:36:28 -0000 Subject: [llvm-commits] [llvm] r50374 - /llvm/branches/Apple/Tak/lib/Support/Allocator.cpp Message-ID: <200804282136.m3SLaSUn023070@zion.cs.uiuc.edu> Author: djg Date: Mon Apr 28 16:36:28 2008 New Revision: 50374 URL: http://llvm.org/viewvc/llvm-project?rev=50374&view=rev Log: Porting r50362 and r50372 to Tak. Modified: llvm/branches/Apple/Tak/lib/Support/Allocator.cpp Modified: llvm/branches/Apple/Tak/lib/Support/Allocator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Tak/lib/Support/Allocator.cpp?rev=50374&r1=50373&r2=50374&view=diff ============================================================================== --- llvm/branches/Apple/Tak/lib/Support/Allocator.cpp (original) +++ llvm/branches/Apple/Tak/lib/Support/Allocator.cpp Mon Apr 28 16:36:28 2008 @@ -46,13 +46,16 @@ /// 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; + char* Result = (char*) (((uintptr_t) (NextPtr+Alignment-1)) + & ~((uintptr_t) Alignment-1)); + + // Speculate the new value of NextPtr. + char* NextPtrTmp = Result + AllocSize; + + // If we are still within the current region, return Result. + if (unsigned (NextPtrTmp - (char*) this) <= RegionSize) { + NextPtr = NextPtrTmp; return Result; } From asl at math.spbu.ru Mon Apr 28 16:48:04 2008 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Mon, 28 Apr 2008 21:48:04 -0000 Subject: [llvm-commits] [llvm] r50375 - /llvm/trunk/include/llvm-c/Core.h Message-ID: <200804282148.m3SLm4UZ023426@zion.cs.uiuc.edu> Author: asl Date: Mon Apr 28 16:48:04 2008 New Revision: 50375 URL: http://llvm.org/viewvc/llvm-project?rev=50375&view=rev Log: Correct parameter attributes encoding for C bindings. Patch by Anders Johnsen! Modified: llvm/trunk/include/llvm-c/Core.h Modified: llvm/trunk/include/llvm-c/Core.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=50375&r1=50374&r2=50375&view=diff ============================================================================== --- llvm/trunk/include/llvm-c/Core.h (original) +++ llvm/trunk/include/llvm-c/Core.h Mon Apr 28 16:48:04 2008 @@ -86,10 +86,10 @@ LLVMZExtParamAttr = 1<<0, LLVMSExtParamAttr = 1<<1, LLVMNoReturnParamAttr = 1<<2, - LLVMNoUnwindParamAttr = 1<<3, - LLVMInRegParamAttr = 1<<4, - LLVMNoAliasParamAttr = 1<<5, - LLVMStructRetParamAttr = 1<<6, + LLVMInRegParamAttr = 1<<3, + LLVMStructRetParamAttr = 1<<4, + LLVMNoUnwindParamAttr = 1<<5, + LLVMNoAliasParamAttr = 1<<6, LLVMByValParamAttr = 1<<7, LLVMNestParamAttr = 1<<8, LLVMReadNoneParamAttr = 1<<9, From asl at math.spbu.ru Mon Apr 28 15:53:48 2008 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Mon, 28 Apr 2008 20:53:48 -0000 Subject: [llvm-commits] [llvm] r50373 - in /llvm/trunk/tools/bugpoint: ExecutionDriver.cpp ToolRunner.cpp ToolRunner.h Message-ID: <200804282053.m3SKrm90021528@zion.cs.uiuc.edu> Author: asl Date: Mon Apr 28 15:53:48 2008 New Revision: 50373 URL: http://llvm.org/viewvc/llvm-project?rev=50373&view=rev Log: Add possibility of using arbitrary to to execute stuff from bugpoint. Patch by Pekka J??skel?inen! Modified: llvm/trunk/tools/bugpoint/ExecutionDriver.cpp llvm/trunk/tools/bugpoint/ToolRunner.cpp llvm/trunk/tools/bugpoint/ToolRunner.h Modified: llvm/trunk/tools/bugpoint/ExecutionDriver.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/ExecutionDriver.cpp?rev=50373&r1=50372&r2=50373&view=diff ============================================================================== --- llvm/trunk/tools/bugpoint/ExecutionDriver.cpp (original) +++ llvm/trunk/tools/bugpoint/ExecutionDriver.cpp Mon Apr 28 15:53:48 2008 @@ -28,7 +28,7 @@ // for miscompilation. // enum OutputType { - AutoPick, RunLLI, RunJIT, RunLLC, RunCBE, CBE_bug, LLC_Safe + AutoPick, RunLLI, RunJIT, RunLLC, RunCBE, CBE_bug, LLC_Safe, Custom }; cl::opt @@ -48,6 +48,9 @@ clEnumValN(RunCBE, "run-cbe", "Compile with CBE"), clEnumValN(CBE_bug,"cbe-bug", "Find CBE bugs"), clEnumValN(LLC_Safe, "llc-safe", "Use LLC for all"), + clEnumValN(Custom, "run-custom", + "Use -exec-command to define a command to execute " + "the bitcode. Useful for cross-compilation."), clEnumValEnd), cl::init(AutoPick)); @@ -71,8 +74,13 @@ "into executing programs")); cl::list - AdditionalLinkerArgs("Xlinker", + AdditionalLinkerArgs("Xlinker", cl::desc("Additional arguments to pass to the linker")); + + cl::opt + CustomExecCommand("exec-command", cl::init("simulate"), + cl::desc("Command to execute the bitcode (use with -run-custom) " + "(default: simulate)")); } namespace llvm { @@ -148,6 +156,10 @@ Interpreter = AbstractInterpreter::createCBE(getToolName(), Message, &ToolArgv); break; + case Custom: + Interpreter = AbstractInterpreter::createCustom(getToolName(), Message, + CustomExecCommand); + break; default: Message = "Sorry, this back-end is not supported by bugpoint right now!\n"; break; Modified: llvm/trunk/tools/bugpoint/ToolRunner.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/ToolRunner.cpp?rev=50373&r1=50372&r2=50373&view=diff ============================================================================== --- llvm/trunk/tools/bugpoint/ToolRunner.cpp (original) +++ llvm/trunk/tools/bugpoint/ToolRunner.cpp Mon Apr 28 15:53:48 2008 @@ -174,6 +174,110 @@ return 0; } +//===---------------------------------------------------------------------===// +// Custom execution command implementation of AbstractIntepreter interface +// +// Allows using a custom command for executing the bitcode, thus allows, +// for example, to invoke a cross compiler for code generation followed by +// a simulator that executes the generated binary. +namespace { + class CustomExecutor : public AbstractInterpreter { + std::string ExecutionCommand; + std::vector ExecutorArgs; + public: + CustomExecutor( + const std::string &ExecutionCmd, std::vector ExecArgs) : + ExecutionCommand(ExecutionCmd), ExecutorArgs(ExecArgs) {} + + virtual int ExecuteProgram(const std::string &Bitcode, + const std::vector &Args, + const std::string &InputFile, + const std::string &OutputFile, + const std::vector &GCCArgs, + const std::vector &SharedLibs = + std::vector(), + unsigned Timeout = 0, + unsigned MemoryLimit = 0); + }; +} + +int CustomExecutor::ExecuteProgram(const std::string &Bitcode, + const std::vector &Args, + const std::string &InputFile, + const std::string &OutputFile, + const std::vector &GCCArgs, + const std::vector &SharedLibs, + unsigned Timeout, + unsigned MemoryLimit) { + + std::vector ProgramArgs; + ProgramArgs.push_back(ExecutionCommand.c_str()); + + for (std::size_t i = 0; i < ExecutorArgs.size(); ++i) + ProgramArgs.push_back(ExecutorArgs.at(i).c_str()); + ProgramArgs.push_back(Bitcode.c_str()); + ProgramArgs.push_back(0); + + // Add optional parameters to the running program from Argv + for (unsigned i=0, e = Args.size(); i != e; ++i) + ProgramArgs.push_back(Args[i].c_str()); + + return RunProgramWithTimeout( + sys::Path(ExecutionCommand), + &ProgramArgs[0], sys::Path(InputFile), sys::Path(OutputFile), + sys::Path(OutputFile), Timeout, MemoryLimit); +} + +// Custom execution environment create method, takes the execution command +// as arguments +AbstractInterpreter *AbstractInterpreter::createCustom( + const std::string &ProgramPath, + std::string &Message, + const std::string &ExecCommandLine) { + + std::string Command = ""; + std::vector Args; + std::string delimiters = " "; + + // Tokenize the ExecCommandLine to the command and the args to allow + // defining a full command line as the command instead of just the + // executed program. We cannot just pass the whole string after the command + // as a single argument because then program sees only a single + // command line argument (with spaces in it: "foo bar" instead + // of "foo" and "bar"). + + // code borrowed from: + // http://oopweb.com/CPP/Documents/CPPHOWTO/Volume/C++Programming-HOWTO-7.html + std::string::size_type lastPos = + ExecCommandLine.find_first_not_of(delimiters, 0); + std::string::size_type pos = + ExecCommandLine.find_first_of(delimiters, lastPos); + + while (std::string::npos != pos || std::string::npos != lastPos) { + std::string token = ExecCommandLine.substr(lastPos, pos - lastPos); + if (Command == "") + Command = token; + else + Args.push_back(token); + // Skip delimiters. Note the "not_of" + lastPos = ExecCommandLine.find_first_not_of(delimiters, pos); + // Find next "non-delimiter" + pos = ExecCommandLine.find_first_of(delimiters, lastPos); + } + + std::string CmdPath = FindExecutable(Command, ProgramPath).toString(); + if (CmdPath.empty()) { + Message = + std::string("Cannot find '") + Command + + "' in executable directory or PATH!\n"; + return 0; + } + + Message = "Found command in: " + CmdPath + "\n"; + + return new CustomExecutor(CmdPath, Args); +} + //===----------------------------------------------------------------------===// // LLC Implementation of AbstractIntepreter interface // Modified: llvm/trunk/tools/bugpoint/ToolRunner.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/ToolRunner.h?rev=50373&r1=50372&r2=50373&view=diff ============================================================================== --- llvm/trunk/tools/bugpoint/ToolRunner.h (original) +++ llvm/trunk/tools/bugpoint/ToolRunner.h Mon Apr 28 15:53:48 2008 @@ -98,6 +98,10 @@ std::string &Message, const std::vector *Args=0); + static AbstractInterpreter* createCustom(const std::string &ProgramPath, + std::string &Message, + const std::string &ExecCommandLine); + virtual ~AbstractInterpreter() {} From evan.cheng at apple.com Mon Apr 28 17:07:13 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 28 Apr 2008 22:07:13 -0000 Subject: [llvm-commits] [llvm] r50376 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <200804282207.m3SM7EeF024010@zion.cs.uiuc.edu> Author: evancheng Date: Mon Apr 28 17:07:13 2008 New Revision: 50376 URL: http://llvm.org/viewvc/llvm-project?rev=50376&view=rev Log: Fix a bug in RegsForValue::getCopyToRegs() that causes cyclical scheduling units. If it's creating multiple CopyToReg nodes that are "flagged" together, it should not create a TokenFactor for it's chain outputs: c1, f1 = CopyToReg c2, f2 = CopyToReg c3 = TokenFactor c1, c2 ... = user c3, ..., f2 Now that the two CopyToReg's and the user are "flagged" together. They effectively forms a single scheduling unit. The TokenFactor is now both an operand and a successor of the Flagged nodes. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=50376&r1=50375&r2=50376&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Mon Apr 28 17:07:13 2008 @@ -3455,8 +3455,18 @@ Chains[i] = Part.getValue(0); } - if (NumRegs == 1) - Chain = Chains[0]; + if (NumRegs == 1 || Flag) + // If NumRegs > 1 && Flag is used then the use of the last CopyToReg is + // flagged to it. That is the CopyToReg nodes and the user are considered + // a single scheduling unit. If we create a TokenFactor and return it as + // chain, then the TokenFactor is both a predecessor (operand) of the + // user as well as a successor (the TF operands are flagged to the user). + // c1, f1 = CopyToReg + // c2, f2 = CopyToReg + // c3 = TokenFactor c1, c2 + // ... + // = op c3, ..., f2 + Chain = Chains[NumRegs-1]; else Chain = DAG.getNode(ISD::TokenFactor, MVT::Other, &Chains[0], NumRegs); } From evan.cheng at apple.com Mon Apr 28 17:14:35 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 28 Apr 2008 22:14:35 -0000 Subject: [llvm-commits] [llvm] r50377 - /llvm/trunk/test/CodeGen/X86/2008-04-28-CyclicSchedUnit.ll Message-ID: <200804282214.m3SMEZnS024198@zion.cs.uiuc.edu> Author: evancheng Date: Mon Apr 28 17:14:34 2008 New Revision: 50377 URL: http://llvm.org/viewvc/llvm-project?rev=50377&view=rev Log: Test case. Added: llvm/trunk/test/CodeGen/X86/2008-04-28-CyclicSchedUnit.ll Added: llvm/trunk/test/CodeGen/X86/2008-04-28-CyclicSchedUnit.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2008-04-28-CyclicSchedUnit.ll?rev=50377&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/2008-04-28-CyclicSchedUnit.ll (added) +++ llvm/trunk/test/CodeGen/X86/2008-04-28-CyclicSchedUnit.ll Mon Apr 28 17:14:34 2008 @@ -0,0 +1,6 @@ +; RUN: llvm-as < %s | llc + +define i64 @t(i64 %maxIdleDuration) nounwind { + call void asm sideeffect "wrmsr", "{cx},A,~{dirflag},~{fpsr},~{flags}"( i32 416, i64 0 ) nounwind + unreachable +} From gohman at apple.com Mon Apr 28 17:18:31 2008 From: gohman at apple.com (Dan Gohman) Date: Mon, 28 Apr 2008 15:18:31 -0700 Subject: [llvm-commits] [llvm] r50377 - /llvm/trunk/test/CodeGen/X86/2008-04-28-CyclicSchedUnit.ll In-Reply-To: <200804282214.m3SMEZnS024198@zion.cs.uiuc.edu> References: <200804282214.m3SMEZnS024198@zion.cs.uiuc.edu> Message-ID: <2F22391A-A528-414A-BF1C-E65DEC177F9A@apple.com> Thanks Evan. Can you add a -march=x86 to this test; it's significantly less interesting on x86-64 where i64 is legal. Dan On Apr 28, 2008, at 3:14 PM, Evan Cheng wrote: > Author: evancheng > Date: Mon Apr 28 17:14:34 2008 > New Revision: 50377 > > URL: http://llvm.org/viewvc/llvm-project?rev=50377&view=rev > Log: > Test case. > > Added: > llvm/trunk/test/CodeGen/X86/2008-04-28-CyclicSchedUnit.ll > > Added: llvm/trunk/test/CodeGen/X86/2008-04-28-CyclicSchedUnit.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2008-04-28-CyclicSchedUnit.ll?rev=50377&view=auto > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/test/CodeGen/X86/2008-04-28-CyclicSchedUnit.ll (added) > +++ llvm/trunk/test/CodeGen/X86/2008-04-28-CyclicSchedUnit.ll Mon > Apr 28 17:14:34 2008 > @@ -0,0 +1,6 @@ > +; RUN: llvm-as < %s | llc > + > +define i64 @t(i64 %maxIdleDuration) nounwind { > + call void asm sideeffect "wrmsr", > "{cx},A,~{dirflag},~{fpsr},~{flags}"( i32 416, i64 0 ) nounwind > + unreachable > +} > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From lattner at apple.com Mon Apr 28 17:24:56 2008 From: lattner at apple.com (Tanya Lattner) Date: Mon, 28 Apr 2008 15:24:56 -0700 Subject: [llvm-commits] [llvm] r50358 - in /llvm/trunk: lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/sext-misc.ll In-Reply-To: <200804281702.m3SH2MPF013676@zion.cs.uiuc.edu> References: <200804281702.m3SH2MPF013676@zion.cs.uiuc.edu> Message-ID: <61DD658D-2829-4622-B642-AED4EFFF00BF@apple.com> I believe this patch is causing the following failure: llvm/test/CodeGen/CellSPU/and_ops.ll Failed with exit(1) at line 2 while running: grep and and_ops.ll.tmp1.s | count 232 count: expected 232 lines and got 234. child process exited abnormally Please fix or revert. -Tanya On Apr 28, 2008, at 10:02 AM, Dan Gohman wrote: > Author: djg > Date: Mon Apr 28 12:02:21 2008 > New Revision: 50358 > > URL: http://llvm.org/viewvc/llvm-project?rev=50358&view=rev > Log: > Teach InstCombine's ComputeMaskedBits what SelectionDAG's > ComputeMaskedBits knows about cttz, ctlz, and ctpop. Teach > SelectionDAG's ComputeMaskedBits what InstCombine's knows > about SRem. And teach them both some things about high bits > in Mul, UDiv, URem, and Sub. This allows instcombine and > dagcombine to eliminate sign-extension operations in > several new cases. > > Added: > llvm/trunk/test/Transforms/InstCombine/sext-misc.ll > Modified: > llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp > llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp > > Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ > SelectionDAG/SelectionDAG.cpp?rev=50358&r1=50357&r2=50358&view=diff > > ====================================================================== > ======== > --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) > +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Mon Apr 28 > 12:02:21 2008 > @@ -1229,6 +1229,50 @@ > KnownZero = KnownZeroOut; > return; > } > + case ISD::MUL: { > + APInt Mask2 = APInt::getAllOnesValue(BitWidth); > + ComputeMaskedBits(Op.getOperand(1), Mask2, KnownZero, > KnownOne, Depth+1); > + ComputeMaskedBits(Op.getOperand(0), Mask2, KnownZero2, > KnownOne2, Depth+1); > + assert((KnownZero & KnownOne) == 0 && "Bits known to be one > AND zero?"); > + assert((KnownZero2 & KnownOne2) == 0 && "Bits known to be one > AND zero?"); > + > + // If low bits are zero in either operand, output low known-0 > bits. > + // Also compute a conserative estimate for high known-0 bits. > + // More trickiness is possible, but this is sufficient for the > + // interesting case of alignment computation. > + KnownOne.clear(); > + unsigned TrailZ = KnownZero.countTrailingOnes() + > + KnownZero2.countTrailingOnes(); > + unsigned LeadZ = std::max(KnownZero.countLeadingOnes() + > + KnownZero2.countLeadingOnes() + > + 1, BitWidth) - BitWidth; > + > + TrailZ = std::min(TrailZ, BitWidth); > + LeadZ = std::min(LeadZ, BitWidth); > + KnownZero = APInt::getLowBitsSet(BitWidth, TrailZ) | > + APInt::getHighBitsSet(BitWidth, LeadZ); > + KnownZero &= Mask; > + return; > + } > + case ISD::UDIV: { > + // For the purposes of computing leading zeros we can > conservatively > + // treat a udiv as a logical right shift by the power of 2 > known to > + // be greater than the denominator. > + APInt AllOnes = APInt::getAllOnesValue(BitWidth); > + ComputeMaskedBits(Op.getOperand(0), > + AllOnes, KnownZero2, KnownOne2, Depth+1); > + unsigned LeadZ = KnownZero2.countLeadingOnes(); > + > + KnownOne2.clear(); > + KnownZero2.clear(); > + ComputeMaskedBits(Op.getOperand(1), > + AllOnes, KnownZero2, KnownOne2, Depth+1); > + LeadZ = std::min(BitWidth, > + LeadZ + BitWidth - KnownOne2.countLeadingZeros > ()); > + > + KnownZero = APInt::getHighBitsSet(BitWidth, LeadZ) & Mask; > + return; > + } > case ISD::SELECT: > ComputeMaskedBits(Op.getOperand(2), Mask, KnownZero, KnownOne, > Depth+1); > ComputeMaskedBits(Op.getOperand(1), Mask, KnownZero2, > KnownOne2, Depth+1); > @@ -1469,47 +1513,94 @@ > KnownZero = APInt::getHighBitsSet(BitWidth, BitWidth - 1); > return; > > + case ISD::SUB: { > + if (ConstantSDNode *CLHS = dyn_cast > (Op.getOperand(0))) { > + // We know that the top bits of C-X are clear if X contains > less bits > + // than C (i.e. no wrap-around can happen). For example, 20- > X is > + // positive if we can prove that X is >= 0 and < 16. > + if (CLHS->getAPIntValue().isNonNegative()) { > + unsigned NLZ = (CLHS->getAPIntValue()+1).countLeadingZeros(); > + // NLZ can't be BitWidth with no sign bit > + APInt MaskV = APInt::getHighBitsSet(BitWidth, NLZ+1); > + ComputeMaskedBits(Op.getOperand(1), MaskV, KnownZero2, > KnownOne2, > + Depth+1); > + > + // If all of the MaskV bits are known to be zero, then we > know the > + // output top bits are zero, because we now know that the > output is > + // from [0-C]. > + if ((KnownZero2 & MaskV) == MaskV) { > + unsigned NLZ2 = CLHS->getAPIntValue().countLeadingZeros(); > + // Top bits known zero. > + KnownZero = APInt::getHighBitsSet(BitWidth, NLZ2) & Mask; > + } > + } > + } > + } > + // fall through > case ISD::ADD: { > - // If either the LHS or the RHS are Zero, the result is zero. > - ComputeMaskedBits(Op.getOperand(1), Mask, KnownZero, KnownOne, > Depth+1); > - ComputeMaskedBits(Op.getOperand(0), Mask, KnownZero2, > KnownOne2, Depth+1); > - assert((KnownZero & KnownOne) == 0 && "Bits known to be one > AND zero?"); > - assert((KnownZero2 & KnownOne2) == 0 && "Bits known to be one > AND zero?"); > - > // Output known-0 bits are known if clear or set in both the > low clear bits > // common to both LHS & RHS. For example, 8+(X<<3) is known > to have the > // low 3 bits clear. > - unsigned KnownZeroOut = std::min(KnownZero.countTrailingOnes(), > - KnownZero2.countTrailingOnes()); > - > - KnownZero = APInt::getLowBitsSet(BitWidth, KnownZeroOut); > - KnownOne = APInt(BitWidth, 0); > + APInt Mask2 = APInt::getLowBitsSet(BitWidth, > Mask.countTrailingOnes()); > + ComputeMaskedBits(Op.getOperand(0), Mask2, KnownZero2, > KnownOne2, Depth+1); > + assert((KnownZero2 & KnownOne2) == 0 && "Bits known to be one > AND zero?"); > + unsigned KnownZeroOut = KnownZero2.countTrailingOnes(); > + > + ComputeMaskedBits(Op.getOperand(1), Mask2, KnownZero2, > KnownOne2, Depth+1); > + assert((KnownZero2 & KnownOne2) == 0 && "Bits known to be one > AND zero?"); > + KnownZeroOut = std::min(KnownZeroOut, > + KnownZero2.countTrailingOnes()); > + > + KnownZero |= APInt::getLowBitsSet(BitWidth, KnownZeroOut); > return; > } > - case ISD::SUB: { > - ConstantSDNode *CLHS = dyn_cast(Op.getOperand > (0)); > - if (!CLHS) return; > + case ISD::SREM: > + if (ConstantSDNode *Rem = dyn_cast > (Op.getOperand(1))) { > + APInt RA = Rem->getAPIntValue(); > + if (RA.isPowerOf2() || (-RA).isPowerOf2()) { > + APInt LowBits = RA.isStrictlyPositive() ? ((RA - 1) | > RA) : ~RA; > + APInt Mask2 = LowBits | APInt::getSignBit(BitWidth); > + ComputeMaskedBits(Op.getOperand(0), > Mask2,KnownZero2,KnownOne2,Depth+1); > + > + // The sign of a remainder is equal to the sign of the first > + // operand (zero being positive). > + if (KnownZero2[BitWidth-1] || ((KnownZero2 & LowBits) == > LowBits)) > + KnownZero2 |= ~LowBits; > + else if (KnownOne2[BitWidth-1]) > + KnownOne2 |= ~LowBits; > > - // We know that the top bits of C-X are clear if X contains > less bits > - // than C (i.e. no wrap-around can happen). For example, 20-X is > - // positive if we can prove that X is >= 0 and < 16. > - if (CLHS->getAPIntValue().isNonNegative()) { > - unsigned NLZ = (CLHS->getAPIntValue()+1).countLeadingZeros(); > - // NLZ can't be BitWidth with no sign bit > - APInt MaskV = APInt::getHighBitsSet(BitWidth, NLZ+1); > - ComputeMaskedBits(Op.getOperand(1), MaskV, KnownZero, > KnownOne, Depth+1); > - > - // If all of the MaskV bits are known to be zero, then we > know the output > - // top bits are zero, because we now know that the output is > from [0-C]. > - if ((KnownZero & MaskV) == MaskV) { > - unsigned NLZ2 = CLHS->getAPIntValue().countLeadingZeros(); > - // Top bits known zero. > - KnownZero = APInt::getHighBitsSet(BitWidth, NLZ2) & Mask; > - KnownOne = APInt(BitWidth, 0); // No one bits known. > - } else { > - KnownZero = KnownOne = APInt(BitWidth, 0); // Otherwise, > nothing known. > + KnownZero |= KnownZero2 & Mask; > + KnownOne |= KnownOne2 & Mask; > + > + assert((KnownZero & KnownOne) == 0&&"Bits known to be one > AND zero?"); > + } > + } > + return; > + case ISD::UREM: { > + if (ConstantSDNode *Rem = dyn_cast > (Op.getOperand(1))) { > + APInt RA = Rem->getAPIntValue(); > + if (RA.isStrictlyPositive() && RA.isPowerOf2()) { > + APInt LowBits = (RA - 1) | RA; > + APInt Mask2 = LowBits & Mask; > + KnownZero |= ~LowBits & Mask; > + ComputeMaskedBits(Op.getOperand(0), Mask2, KnownZero, > KnownOne,Depth+1); > + assert((KnownZero & KnownOne) == 0&&"Bits known to be one > AND zero?"); > + break; > } > } > + > + // Since the result is less than or equal to either operand, > any leading > + // zero bits in either operand must also exist in the result. > + APInt AllOnes = APInt::getAllOnesValue(BitWidth); > + ComputeMaskedBits(Op.getOperand(0), AllOnes, KnownZero, KnownOne, > + Depth+1); > + ComputeMaskedBits(Op.getOperand(1), AllOnes, KnownZero2, > KnownOne2, > + Depth+1); > + > + uint32_t Leaders = std::max(KnownZero.countLeadingOnes(), > + KnownZero2.countLeadingOnes()); > + KnownOne.clear(); > + KnownZero = APInt::getHighBitsSet(BitWidth, Leaders) & Mask; > return; > } > default: > > Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/ > Scalar/InstructionCombining.cpp?rev=50358&r1=50357&r2=50358&view=diff > > ====================================================================== > ======== > --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp > (original) > +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Mon > Apr 28 12:02:21 2008 > @@ -700,15 +700,15 @@ > return; > } > > + KnownZero.clear(); KnownOne.clear(); // Start out not knowing > anything. > + > if (Depth == 6 || Mask == 0) > return; // Limit search depth. > > User *I = dyn_cast(V); > if (!I) return; > > - KnownZero.clear(); KnownOne.clear(); // Don't know anything. > APInt KnownZero2(KnownZero), KnownOne2(KnownOne); > - > switch (getOpcode(I)) { > default: break; > case Instruction::And: { > @@ -759,16 +759,42 @@ > assert((KnownZero2 & KnownOne2) == 0 && "Bits known to be one > AND zero?"); > > // If low bits are zero in either operand, output low known-0 > bits. > + // Also compute a conserative estimate for high known-0 bits. > // More trickiness is possible, but this is sufficient for the > // interesting case of alignment computation. > KnownOne.clear(); > unsigned TrailZ = KnownZero.countTrailingOnes() + > KnownZero2.countTrailingOnes(); > + unsigned LeadZ = std::max(KnownZero.countLeadingOnes() + > + KnownZero2.countLeadingOnes() + > + 1, BitWidth) - BitWidth; > + > TrailZ = std::min(TrailZ, BitWidth); > - KnownZero = APInt::getLowBitsSet(BitWidth, TrailZ); > + LeadZ = std::min(LeadZ, BitWidth); > + KnownZero = APInt::getLowBitsSet(BitWidth, TrailZ) | > + APInt::getHighBitsSet(BitWidth, LeadZ); > KnownZero &= Mask; > return; > } > + case Instruction::UDiv: { > + // For the purposes of computing leading zeros we can > conservatively > + // treat a udiv as a logical right shift by the power of 2 > known to > + // be greater than the denominator. > + APInt AllOnes = APInt::getAllOnesValue(BitWidth); > + ComputeMaskedBits(I->getOperand(0), > + AllOnes, KnownZero2, KnownOne2, Depth+1); > + unsigned LeadZ = KnownZero2.countLeadingOnes(); > + > + KnownOne2.clear(); > + KnownZero2.clear(); > + ComputeMaskedBits(I->getOperand(1), > + AllOnes, KnownZero2, KnownOne2, Depth+1); > + LeadZ = std::min(BitWidth, > + LeadZ + BitWidth - KnownOne2.countLeadingZeros > ()); > + > + KnownZero = APInt::getHighBitsSet(BitWidth, LeadZ) & Mask; > + return; > + } > case Instruction::Select: > ComputeMaskedBits(I->getOperand(2), Mask, KnownZero, KnownOne, > Depth+1); > ComputeMaskedBits(I->getOperand(1), Mask, KnownZero2, > KnownOne2, Depth+1); > @@ -900,38 +926,36 @@ > unsigned NLZ = (CLHS->getValue()+1).countLeadingZeros(); > // NLZ can't be BitWidth with no sign bit > APInt MaskV = APInt::getHighBitsSet(BitWidth, NLZ+1); > - ComputeMaskedBits(I->getOperand(1), MaskV, KnownZero, > KnownOne, Depth+1); > + ComputeMaskedBits(I->getOperand(1), MaskV, KnownZero2, > KnownOne2, > + Depth+1); > > - // If all of the MaskV bits are known to be zero, then we > know the output > - // top bits are zero, because we now know that the output > is from [0-C]. > - if ((KnownZero & MaskV) == MaskV) { > + // If all of the MaskV bits are known to be zero, then we > know the > + // output top bits are zero, because we now know that the > output is > + // from [0-C]. > + if ((KnownZero2 & MaskV) == MaskV) { > unsigned NLZ2 = CLHS->getValue().countLeadingZeros(); > // Top bits known zero. > KnownZero = APInt::getHighBitsSet(BitWidth, NLZ2) & Mask; > - KnownOne = APInt(BitWidth, 0); // No one bits known. > - } else { > - KnownZero = KnownOne = APInt(BitWidth, 0); // > Otherwise, nothing known. > } > - return; > } > } > } > // fall through > case Instruction::Add: { > - // If either the LHS or the RHS are Zero, the result is zero. > - ComputeMaskedBits(I->getOperand(1), Mask, KnownZero, KnownOne, > Depth+1); > - ComputeMaskedBits(I->getOperand(0), Mask, KnownZero2, > KnownOne2, Depth+1); > - assert((KnownZero & KnownOne) == 0 && "Bits known to be one > AND zero?"); > - assert((KnownZero2 & KnownOne2) == 0 && "Bits known to be one > AND zero?"); > - > // Output known-0 bits are known if clear or set in both the > low clear bits > // common to both LHS & RHS. For example, 8+(X<<3) is known > to have the > // low 3 bits clear. > - unsigned KnownZeroOut = std::min(KnownZero.countTrailingOnes(), > - KnownZero2.countTrailingOnes()); > - > - KnownZero = APInt::getLowBitsSet(BitWidth, KnownZeroOut); > - KnownOne = APInt(BitWidth, 0); > + APInt Mask2 = APInt::getLowBitsSet(BitWidth, > Mask.countTrailingOnes()); > + ComputeMaskedBits(I->getOperand(0), Mask2, KnownZero2, > KnownOne2, Depth+1); > + assert((KnownZero2 & KnownOne2) == 0 && "Bits known to be one > AND zero?"); > + unsigned KnownZeroOut = KnownZero2.countTrailingOnes(); > + > + ComputeMaskedBits(I->getOperand(1), Mask2, KnownZero2, > KnownOne2, Depth+1); > + assert((KnownZero2 & KnownOne2) == 0 && "Bits known to be one > AND zero?"); > + KnownZeroOut = std::min(KnownZeroOut, > + KnownZero2.countTrailingOnes()); > + > + KnownZero |= APInt::getLowBitsSet(BitWidth, KnownZeroOut); > return; > } > case Instruction::SRem: > @@ -956,7 +980,7 @@ > } > } > break; > - case Instruction::URem: > + case Instruction::URem: { > if (ConstantInt *Rem = dyn_cast(I->getOperand(1))) { > APInt RA = Rem->getValue(); > if (RA.isStrictlyPositive() && RA.isPowerOf2()) { > @@ -965,19 +989,24 @@ > KnownZero |= ~LowBits & Mask; > ComputeMaskedBits(I->getOperand(0), Mask2, KnownZero, > KnownOne,Depth+1); > assert((KnownZero & KnownOne) == 0&&"Bits known to be one > AND zero?"); > + break; > } > - } else { > - // Since the result is less than or equal to RHS, any > leading zero bits > - // in RHS must also exist in the result. > - APInt AllOnes = APInt::getAllOnesValue(BitWidth); > - ComputeMaskedBits(I->getOperand(1), AllOnes, KnownZero2, > KnownOne2, > - Depth+1); > - > - uint32_t Leaders = KnownZero2.countLeadingOnes(); > - KnownZero |= APInt::getHighBitsSet(BitWidth, Leaders) & Mask; > - assert((KnownZero & KnownOne) == 0&&"Bits known to be one > AND zero?"); > } > + > + // Since the result is less than or equal to either operand, > any leading > + // zero bits in either operand must also exist in the result. > + APInt AllOnes = APInt::getAllOnesValue(BitWidth); > + ComputeMaskedBits(I->getOperand(0), AllOnes, KnownZero, KnownOne, > + Depth+1); > + ComputeMaskedBits(I->getOperand(1), AllOnes, KnownZero2, > KnownOne2, > + Depth+1); > + > + uint32_t Leaders = std::max(KnownZero.countLeadingOnes(), > + KnownZero2.countLeadingOnes()); > + KnownOne.clear(); > + KnownZero = APInt::getHighBitsSet(BitWidth, Leaders) & Mask; > break; > + } > > case Instruction::Alloca: > case Instruction::Malloc: { > @@ -1088,6 +1117,20 @@ > } > break; > } > + case Instruction::Call: > + if (IntrinsicInst *II = dyn_cast(I)) { > + switch (II->getIntrinsicID()) { > + default: break; > + case Intrinsic::ctpop: > + case Intrinsic::ctlz: > + case Intrinsic::cttz: { > + unsigned LowBits = Log2_32(BitWidth)+1; > + KnownZero = APInt::getHighBitsSet(BitWidth, BitWidth - > LowBits); > + break; > + } > + } > + } > + break; > } > } > > @@ -1232,7 +1275,9 @@ > APInt LHSKnownZero(BitWidth, 0), LHSKnownOne(BitWidth, 0); > APInt &RHSKnownZero = KnownZero, &RHSKnownOne = KnownOne; > switch (I->getOpcode()) { > - default: break; > + default: > + ComputeMaskedBits(V, DemandedMask, RHSKnownZero, RHSKnownOne, > Depth); > + break; > case Instruction::And: > // If either the LHS or the RHS are Zero, the result is zero. > if (SimplifyDemandedBits(I->getOperand(1), DemandedMask, > @@ -1578,6 +1623,9 @@ > LHSKnownZero, LHSKnownOne, Depth+1)) > return true; > } > + // Otherwise just hand the sub off to ComputeMaskedBits to > fill in > + // the known zeros and ones. > + ComputeMaskedBits(V, DemandedMask, RHSKnownZero, RHSKnownOne, > Depth); > break; > case Instruction::Shl: > if (ConstantInt *SA = dyn_cast(I->getOperand(1))) { > @@ -1695,10 +1743,10 @@ > } > } > break; > - case Instruction::URem: > + case Instruction::URem: { > if (ConstantInt *Rem = dyn_cast(I->getOperand(1))) { > APInt RA = Rem->getValue(); > - if (RA.isPowerOf2()) { > + if (RA.isStrictlyPositive() && RA.isPowerOf2()) { > APInt LowBits = (RA - 1) | RA; > APInt Mask2 = LowBits & DemandedMask; > KnownZero |= ~LowBits & DemandedMask; > @@ -1707,19 +1755,26 @@ > return true; > > assert((KnownZero & KnownOne) == 0&&"Bits known to be one > AND zero?"); > + break; > } > - } else { > - APInt KnownZero2(BitWidth, 0), KnownOne2(BitWidth, 0); > - APInt AllOnes = APInt::getAllOnesValue(BitWidth); > - if (SimplifyDemandedBits(I->getOperand(1), AllOnes, > - KnownZero2, KnownOne2, Depth+1)) > - return true; > - > - uint32_t Leaders = KnownZero2.countLeadingOnes(); > - KnownZero |= APInt::getHighBitsSet(BitWidth, Leaders) & > DemandedMask; > } > + > + APInt KnownZero2(BitWidth, 0), KnownOne2(BitWidth, 0); > + APInt AllOnes = APInt::getAllOnesValue(BitWidth); > + ComputeMaskedBits(I->getOperand(0), AllOnes, > + KnownZero2, KnownOne2, Depth+1); > + uint32_t Leaders = KnownZero2.countLeadingOnes(); > + APInt HighZeros = APInt::getHighBitsSet(BitWidth, Leaders); > + if (SimplifyDemandedBits(I->getOperand(1), ~HighZeros, > + KnownZero2, KnownOne2, Depth+1)) > + return true; > + > + Leaders = std::max(Leaders, > + KnownZero2.countLeadingOnes()); > + KnownZero = APInt::getHighBitsSet(BitWidth, Leaders) & > DemandedMask; > break; > } > + } > > // If the client is only demanding bits that we know, return the > known > // constant. > > Added: llvm/trunk/test/Transforms/InstCombine/sext-misc.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ > InstCombine/sext-misc.ll?rev=50358&view=auto > > ====================================================================== > ======== > --- llvm/trunk/test/Transforms/InstCombine/sext-misc.ll (added) > +++ llvm/trunk/test/Transforms/InstCombine/sext-misc.ll Mon Apr 28 > 12:02:21 2008 > @@ -0,0 +1,45 @@ > +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep sext > +; RUN: llvm-as < %s | llc -march=x86-64 | not grep movslq > +; RUN: llvm-as < %s | llc -march=x86 | not grep sar > + > +declare i32 @llvm.ctpop.i32(i32) > +declare i32 @llvm.ctlz.i32(i32) > +declare i32 @llvm.cttz.i32(i32) > + > +define i64 @foo(i32 %x) { > + %t = call i32 @llvm.ctpop.i32(i32 %x) > + %s = sext i32 %t to i64 > + ret i64 %s > +} > +define i64 @boo(i32 %x) { > + %t = call i32 @llvm.ctlz.i32(i32 %x) > + %s = sext i32 %t to i64 > + ret i64 %s > +} > +define i64 @zoo(i32 %x) { > + %t = call i32 @llvm.cttz.i32(i32 %x) > + %s = sext i32 %t to i64 > + ret i64 %s > +} > +define i64 @coo(i32 %x) { > + %t = udiv i32 %x, 3 > + %s = sext i32 %t to i64 > + ret i64 %s > +} > +define i64 @moo(i32 %x) { > + %t = urem i32 %x, 30000 > + %s = sext i32 %t to i64 > + ret i64 %s > +} > +define i64 @yoo(i32 %x) { > + %u = lshr i32 %x, 3 > + %t = mul i32 %u, 3 > + %s = sext i32 %t to i64 > + ret i64 %s > +} > +define i64 @voo(i32 %x) { > + %t = and i32 %x, 511 > + %u = sub i32 20000, %t > + %s = sext i32 %u to i64 > + ret i64 %s > +} > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From dalej at apple.com Mon Apr 28 17:26:52 2008 From: dalej at apple.com (Dale Johannesen) Date: Mon, 28 Apr 2008 22:26:52 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50378 - /llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-backend.cpp Message-ID: <200804282226.m3SMQqpZ024630@zion.cs.uiuc.edu> Author: johannes Date: Mon Apr 28 17:26:52 2008 New Revision: 50378 URL: http://llvm.org/viewvc/llvm-project?rev=50378&view=rev Log: Revert part of 50039 that changed inlining behavior. Fixes 5895098 and 5886557. Note this is not being applied to mainline, only the release branch. Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-backend.cpp Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-backend.cpp?rev=50378&r1=50377&r2=50378&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-backend.cpp Mon Apr 28 17:26:52 2008 @@ -356,10 +356,9 @@ if (flag_unit_at_a_time && flag_exceptions) PM->add(createPruneEHPass()); // Remove dead EH info - if (flag_inline_trees) // respect -fno-inline-functions - PM->add(createFunctionInliningPass()); // Inline small functions - if (optimize > 1) { + if (flag_inline_trees > 1) // respect -fno-inline-functions + PM->add(createFunctionInliningPass()); // Inline small functions if (flag_unit_at_a_time && !lang_hooks.flag_no_builtin()) PM->add(createSimplifyLibCallsPass()); // Library Call Optimizations From clattner at apple.com Mon Apr 28 18:18:55 2008 From: clattner at apple.com (Chris Lattner) Date: Mon, 28 Apr 2008 16:18:55 -0700 Subject: [llvm-commits] [llvm] r50279 - in /llvm/trunk: lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp lib/Transforms/Scalar/CodeGenPrepare.cpp test/CodeGen/Generic/multiple-return-values-cross-block-with-invoke.ll In-Reply-To: <99F2986B-B21C-45EC-84F1-715893122EA2@apple.com> References: <200804251827.m3PIRtH4003953@zion.cs.uiuc.edu> <99F2986B-B21C-45EC-84F1-715893122EA2@apple.com> Message-ID: On Apr 28, 2008, at 11:41 AM, Dan Gohman wrote: >>> /// This is needed because values can be promoted into larger >>> registers and >>> /// expanded into multiple smaller registers than the value. >>> struct VISIBILITY_HIDDEN RegsForValue { >> >> This should probably explicitly mention how it handles aggregates. >> Maybe a good general summary up front could help my larger complaint >> next: > > I rewrote this comment. Let me know if have further questions. Thanks! >>> + for (unsigned i = 0; i != NumRegs; ++i) { >>> + unsigned R = MakeReg(RegisterVT); >>> + if (!FirstReg) FirstReg = R; >>> + } >>> + } >>> + return FirstReg; >>> } >> >> The comments in this method should be improved to talk about what it >> is now doing. Please mention aggregates. Could this code change to >> use RegsForValue to compute the expansion? Maybe it should be a new >> method on RegsForValue? > > I added a comment that mentions aggregates. This code does > use ComputeValueVTs to do most of the work; that's a function > I factored out specifically for the purpose of using it > in both CreateRegForValue and RegsForValue. True: the direction I was trying to go is to make CreateRegForValue a private method in RegsForValue. This might not make sense, but would reduce one concept out of SDISel. >>> @@ -3898,8 +3985,9 @@ >>> if ((NumOps & 7) == 2 /*REGDEF*/) { >>> // Add NumOps>>3 registers to MatchedRegs. >>> RegsForValue MatchedRegs; >>> - MatchedRegs.ValueVT = InOperandVal.getValueType(); >>> - MatchedRegs.RegVT = AsmNodeOperands[CurOp >>> +1].getValueType(); >>> + MatchedRegs.TLI = &TLI; >>> + MatchedRegs.ValueVTs.resize(1, >>> InOperandVal.getValueType()); >>> + MatchedRegs.RegVTs.resize(1, AsmNodeOperands[CurOp >>> +1].getValueType()); >> >> Please use push_back, instead of resize(1, x) > > I used resize because it's initializing the vector contents > with exactly one element. But I'll change it if you insist :-). Please do, it is much more idiomatic to use push_back and the vector was clearly empty before. >>> // Figure out the result value types. We start by making a list of >>> + // the potentially illegal return value types. >>> SmallVector LoweredRetTys; >>> SmallVector RetTys; >>> + ComputeValueVTs(*this, RetTy, RetTys); >>> >>> + // Then we translate that to a list of legal types. >>> + for (unsigned I = 0, E = RetTys.size(); I != E; ++I) { >>> + MVT::ValueType VT = RetTys[I]; >>> MVT::ValueType RegisterVT = getRegisterType(VT); >>> unsigned NumRegs = getNumRegisters(VT); >>> for (unsigned i = 0; i != NumRegs; ++i) >> >> This seems like something that should be a method on RegsForValue. > > It isn't trivial to do though. I expect we'll continue to > refactor RegsForValue and eventually get this cleaned up. Ok. >>> @@ -4441,19 +4522,11 @@ >>> cast(Op.getOperand(1))->getReg() != Reg) && >>> "Copy from a reg to the same reg!"); >>> assert(!TargetRegisterInfo::isPhysicalRegister(Reg) && "Is a >>> physreg"); >>> + RegsForValue RFV(TLI, Reg, V->getType()); >>> + SDOperand Chain = DAG.getEntryNode(); >>> + RFV.getCopyToRegs(Op, DAG, Chain, 0); >>> + PendingExports.push_back(Chain); >>> } >> >> I'm not sure if your patch is responsible, but it is very strange to >> me that RegsForValue::getCopyToRegs takes 'Chain' byref and mutates >> the input. Should RegsForValue::getCopyToRegs return a new chain >> instead? > > Perhaps, but currently the Chain handling is consistent with > the optional Flag handling. Ok. Thanks Dan, -Chris From clattner at apple.com Mon Apr 28 18:20:04 2008 From: clattner at apple.com (Chris Lattner) Date: Mon, 28 Apr 2008 16:20:04 -0700 Subject: [llvm-commits] [llvm] r50372 - /llvm/trunk/lib/Support/Allocator.cpp In-Reply-To: <16e5fdf90804281334j7bdbd61ep57e03ae7f006213c@mail.gmail.com> References: <200804282025.m3SKPF3X020635@zion.cs.uiuc.edu> <16e5fdf90804281334j7bdbd61ep57e03ae7f006213c@mail.gmail.com> Message-ID: <9020DCB8-8823-4594-BF0C-B733514E5166@apple.com> On Apr 28, 2008, at 1:34 PM, Bill Wendling wrote: > Does this go into Tak? No. -Chris > > > On Mon, Apr 28, 2008 at 1:25 PM, Dan Gohman wrote: >> Author: djg >> Date: Mon Apr 28 15:25:15 2008 >> New Revision: 50372 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=50372&view=rev >> Log: >> Fix a pointer-arithmetic bug that caused 64-bit host pointer values >> to >> be truncated to 32 bits. This fixes the recent Benchmarks/McCat/09- >> vor >> regression on x86-64, among other things. >> >> Modified: >> llvm/trunk/lib/Support/Allocator.cpp >> >> Modified: llvm/trunk/lib/Support/Allocator.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Allocator.cpp?rev=50372&r1=50371&r2=50372&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/lib/Support/Allocator.cpp (original) >> +++ llvm/trunk/lib/Support/Allocator.cpp Mon Apr 28 15:25:15 2008 >> @@ -48,7 +48,7 @@ >> void *Allocate(unsigned AllocSize, unsigned Alignment, MemRegion >> **RegPtr) { >> >> char* Result = (char*) (((uintptr_t) (NextPtr+Alignment-1)) >> - & ~(Alignment-1)); >> + & ~((uintptr_t) Alignment-1)); >> >> // Speculate the new value of NextPtr. >> char* NextPtrTmp = Result + AllocSize; >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From gohman at apple.com Mon Apr 28 18:26:22 2008 From: gohman at apple.com (Dan Gohman) Date: Mon, 28 Apr 2008 23:26:22 -0000 Subject: [llvm-commits] [llvm] r50379 - in /llvm/trunk/test/CodeGen/CellSPU: and_ops.ll and_ops_more.ll Message-ID: <200804282326.m3SNQMWE026689@zion.cs.uiuc.edu> Author: djg Date: Mon Apr 28 18:26:22 2008 New Revision: 50379 URL: http://llvm.org/viewvc/llvm-project?rev=50379&view=rev Log: Update and_ops.ll according to the recent dagcombiner changes. Add a new test, and_ops_more.ll, which is XFAIL'd, to record the parts of and_ops.ll that were affected by this change. Added: llvm/trunk/test/CodeGen/CellSPU/and_ops_more.ll Modified: llvm/trunk/test/CodeGen/CellSPU/and_ops.ll Modified: llvm/trunk/test/CodeGen/CellSPU/and_ops.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/CellSPU/and_ops.ll?rev=50379&r1=50378&r2=50379&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/CellSPU/and_ops.ll (original) +++ llvm/trunk/test/CodeGen/CellSPU/and_ops.ll Mon Apr 28 18:26:22 2008 @@ -1,7 +1,7 @@ ; RUN: llvm-as -o - %s | llc -march=cellspu > %t1.s -; RUN: grep and %t1.s | count 232 +; RUN: grep and %t1.s | count 234 ; RUN: grep andc %t1.s | count 85 -; RUN: grep andi %t1.s | count 36 +; RUN: grep andi %t1.s | count 37 ; RUN: grep andhi %t1.s | count 30 ; RUN: grep andbi %t1.s | count 4 Added: llvm/trunk/test/CodeGen/CellSPU/and_ops_more.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/CellSPU/and_ops_more.ll?rev=50379&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/CellSPU/and_ops_more.ll (added) +++ llvm/trunk/test/CodeGen/CellSPU/and_ops_more.ll Mon Apr 28 18:26:22 2008 @@ -0,0 +1,26 @@ +; RUN: llvm-as -o - %s | llc -march=cellspu > %t1.s +; RUN: grep and %t1.s | count 10 +; RUN: not grep andc %t1.s +; RUN: not grep andi %t1.s +; RUN: grep andhi %t1.s | count 5 +; RUN: grep andbi %t1.s | count 1 +; XFAIL: * + +; This testcase is derived from test/CodeGen/CellSPU/and_ops.ll and +; records the changes due to r50358. The and_sext8 function appears +; to be improved by this change, while the andhi_i16 function appears +; to be pessimized. + +target datalayout = "E-p:32:32:128-f64:64:128-f32:32:128-i64:32:128-i32:32:128-i16:16:128-i8:8:128-i1:8:128-a0:0:128-v128:128:128-s0:128:128" +target triple = "spu" + +define i16 @andhi_i16(i16 signext %in) signext { + %tmp38 = and i16 %in, 37 ; [#uses=1] + ret i16 %tmp38 +} + +define i8 @and_sext8(i8 signext %in) signext { + ; ANDBI generated + %tmp38 = and i8 %in, 37 + ret i8 %tmp38 +} From evan.cheng at apple.com Mon Apr 28 18:31:41 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 28 Apr 2008 23:31:41 -0000 Subject: [llvm-commits] [llvm] r50380 - /llvm/trunk/test/CodeGen/X86/2008-04-28-CyclicSchedUnit.ll Message-ID: <200804282331.m3SNVfqX026873@zion.cs.uiuc.edu> Author: evancheng Date: Mon Apr 28 18:31:41 2008 New Revision: 50380 URL: http://llvm.org/viewvc/llvm-project?rev=50380&view=rev Log: Add -march=x86. Modified: llvm/trunk/test/CodeGen/X86/2008-04-28-CyclicSchedUnit.ll Modified: llvm/trunk/test/CodeGen/X86/2008-04-28-CyclicSchedUnit.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2008-04-28-CyclicSchedUnit.ll?rev=50380&r1=50379&r2=50380&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2008-04-28-CyclicSchedUnit.ll (original) +++ llvm/trunk/test/CodeGen/X86/2008-04-28-CyclicSchedUnit.ll Mon Apr 28 18:31:41 2008 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc +; RUN: llvm-as < %s | llc -march=x86 define i64 @t(i64 %maxIdleDuration) nounwind { call void asm sideeffect "wrmsr", "{cx},A,~{dirflag},~{fpsr},~{flags}"( i32 416, i64 0 ) nounwind From dpatel at apple.com Mon Apr 28 19:30:11 2008 From: dpatel at apple.com (Devang Patel) Date: Tue, 29 Apr 2008 00:30:11 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50381 - /llvm-gcc-4.2/branches/Apple/Tak/gcc/objc/objc-act.c Message-ID: <200804290030.m3T0UC4I028623@zion.cs.uiuc.edu> Author: dpatel Date: Mon Apr 28 19:30:11 2008 New Revision: 50381 URL: http://llvm.org/viewvc/llvm-project?rev=50381&view=rev Log: Disable 5812818 fix for now. Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/objc/objc-act.c Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/objc/objc-act.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/objc/objc-act.c?rev=50381&r1=50380&r2=50381&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/objc/objc-act.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/objc/objc-act.c Mon Apr 28 19:30:11 2008 @@ -8622,6 +8622,7 @@ CLASS_TYPE (class) = record; /* APPLE LOCAL llvm begin */ +#if 0 #ifdef ENABLE_LLVM /* Synthesized properties will later be added to this RECORD_DECL as they * are found in @implementations. We don't want the LLVM tree->llvm @@ -8633,6 +8634,7 @@ if (flag_objc_abi == 2) llvm_compute_type(record); #endif +#endif /* APPLE LOCAL llvm end */ } } From resistor at mac.com Mon Apr 28 19:38:35 2008 From: resistor at mac.com (Owen Anderson) Date: Tue, 29 Apr 2008 00:38:35 -0000 Subject: [llvm-commits] [llvm] r50382 - in /llvm/trunk: include/llvm/LinkAllPasses.h include/llvm/Transforms/Scalar.h lib/Transforms/Scalar/DeadLoopElimination.cpp Message-ID: <200804290038.m3T0cZc1028840@zion.cs.uiuc.edu> Author: resistor Date: Mon Apr 28 19:38:34 2008 New Revision: 50382 URL: http://llvm.org/viewvc/llvm-project?rev=50382&view=rev Log: Add dead loop elimination, which removes dead loops for which we can compute the trip count. Added: llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp Modified: llvm/trunk/include/llvm/LinkAllPasses.h llvm/trunk/include/llvm/Transforms/Scalar.h Modified: llvm/trunk/include/llvm/LinkAllPasses.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LinkAllPasses.h?rev=50382&r1=50381&r2=50382&view=diff ============================================================================== --- llvm/trunk/include/llvm/LinkAllPasses.h (original) +++ llvm/trunk/include/llvm/LinkAllPasses.h Mon Apr 28 19:38:34 2008 @@ -114,6 +114,7 @@ (void) llvm::createCodeGenPreparePass(); (void) llvm::createGVNPass(); (void) llvm::createMemCpyOptPass(); + (void) llvm::createDeadLoopEliminationPass(); (void)new llvm::IntervalPartition(); (void)new llvm::FindUsedTypes(); Modified: llvm/trunk/include/llvm/Transforms/Scalar.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Scalar.h?rev=50382&r1=50381&r2=50382&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Scalar.h (original) +++ llvm/trunk/include/llvm/Transforms/Scalar.h Mon Apr 28 19:38:34 2008 @@ -319,6 +319,13 @@ //===----------------------------------------------------------------------===// // +// DeadLoopElimination - This pass performs DCE of non-infinite loops that it +// can prove are dead. +// +LoopPass *createDeadLoopEliminationPass(); + +//===----------------------------------------------------------------------===// +// // CodeGenPrepare - This pass prepares a function for instruction selection. // FunctionPass *createCodeGenPreparePass(const TargetLowering *TLI = 0); Added: llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp?rev=50382&view=auto ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp (added) +++ llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp Mon Apr 28 19:38:34 2008 @@ -0,0 +1,239 @@ +//===- DeadLoopElimination.cpp - Dead Loop Elimination Pass ---------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements the Dead Loop Elimination Pass. +// +//===----------------------------------------------------------------------===// + +#define DEBUG_TYPE "dead-loop" + +#include "llvm/Transforms/Scalar.h" +#include "llvm/Instruction.h" +#include "llvm/Analysis/LoopInfo.h" +#include "llvm/Analysis/LoopPass.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/ADT/SmallVector.h" + +using namespace llvm; + +STATISTIC(NumDeleted, "Number of loops deleted"); + +namespace { + class VISIBILITY_HIDDEN DeadLoopElimination : public LoopPass { + public: + static char ID; // Pass ID, replacement for typeid + DeadLoopElimination() : LoopPass((intptr_t)&ID) { } + + // Possibly eliminate loop L if it is dead. + bool runOnLoop(Loop* L, LPPassManager& LPM); + + bool SingleDominatingExit(Loop* L); + bool IsLoopDead(Loop* L); + bool IsLoopInvariantInst(Instruction *I, Loop* L); + + virtual void getAnalysisUsage(AnalysisUsage& AU) const { + AU.addRequired(); + AU.addRequired(); + AU.addRequiredID(LoopSimplifyID); + AU.addRequiredID(LCSSAID); + + AU.addPreserved(); + AU.addPreserved(); + AU.addPreservedID(LoopSimplifyID); + AU.addPreservedID(LCSSAID); + } + }; + + char DeadLoopElimination::ID = 0; + RegisterPass X ("dead-loop", "Eliminate dead loops"); +} + +LoopPass* llvm::createDeadLoopEliminationPass() { + return new DeadLoopElimination(); +} + +bool DeadLoopElimination::SingleDominatingExit(Loop* L) { + SmallVector exitingBlocks; + L->getExitingBlocks(exitingBlocks); + + if (exitingBlocks.size() != 1) + return 0; + + BasicBlock* latch = L->getLoopLatch(); + if (!latch) + return 0; + + DominatorTree& DT = getAnalysis(); + if (DT.dominates(exitingBlocks[0], latch)) + return exitingBlocks[0]; + else + return 0; +} + +bool DeadLoopElimination::IsLoopInvariantInst(Instruction *I, Loop* L) { + // PHI nodes are not loop invariant if defined in the loop. + if (isa(I) && L->contains(I->getParent())) + return false; + + // The instruction is loop invariant if all of its operands are loop-invariant + for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) + if (!L->isLoopInvariant(I->getOperand(i))) + return false; + + // If we got this far, the instruction is loop invariant! + return true; +} + +bool DeadLoopElimination::IsLoopDead(Loop* L) { + SmallVector exitingBlocks; + L->getExitingBlocks(exitingBlocks); + BasicBlock* exitingBlock = exitingBlocks[0]; + + // Get the set of out-of-loop blocks that the exiting block branches to. + SmallVector exitBlocks; + L->getUniqueExitBlocks(exitBlocks); + if (exitBlocks.size() > 1) + return false; + BasicBlock* exitBlock = exitBlocks[0]; + + // Make sure that all PHI entries coming from the loop are loop invariant. + BasicBlock::iterator BI = exitBlock->begin(); + while (PHINode* P = dyn_cast(BI)) { + Value* incoming = P->getIncomingValueForBlock(exitingBlock); + if (Instruction* I = dyn_cast(incoming)) + if (!IsLoopInvariantInst(I, L)) + return false; + + BI++; + } + + // Make sure that no instructions in the block have potential side-effects. + for (Loop::block_iterator LI = L->block_begin(), LE = L->block_end(); + LI != LE; ++LI) { + for (BasicBlock::iterator BI = (*LI)->begin(), BE = (*LI)->end(); + BI != BE; ++BI) { + if (BI->mayWriteToMemory()) + return false; + } + } + + return true; +} + +bool DeadLoopElimination::runOnLoop(Loop* L, LPPassManager& LPM) { + // Don't remove loops for which we can't solve the trip count. + // They could be infinite, in which case we'd be changing program behavior. + if (L->getTripCount()) + return false; + + // We can only remove the loop if there is a preheader that we can + // branch from after removing it. + BasicBlock* preheader = L->getLoopPreheader(); + if (!preheader) + return false; + + // We can't remove loops that contain subloops. If the subloops were dead, + // they would already have been removed in earlier executions of this pass. + if (L->begin() != L->end()) + return false; + + // Loops with multiple exits or exits that don't dominate the latch + // are too complicated to handle correctly. + if (!SingleDominatingExit(L)) + return false; + + // Finally, we have to check that the loop really is dead. + if (!IsLoopDead(L)) + return false; + + // Now that we know the removal is safe, change the branch from the preheader + // to go to the single exiting block. + SmallVector exitingBlocks; + L->getExitingBlocks(exitingBlocks); + BasicBlock* exitingBlock = exitingBlocks[0]; + + SmallVector exitBlocks; + L->getUniqueExitBlocks(exitBlocks); + BasicBlock* exitBlock = exitBlocks[0]; + + Function* F = L->getLoopLatch()->getParent(); + + for (Loop::block_iterator LI = L->block_begin(), LE = L->block_end(); + LI != LE; ++LI) + for (BasicBlock::iterator BI = (*LI)->begin(), BE = (*LI)->end(); + BI != BE; ) { + Instruction* I = BI++; + if (I->getNumUses() > 0 && IsLoopInvariantInst(I, L)) + I->moveBefore(preheader->getTerminator()); + } + + TerminatorInst* TI = preheader->getTerminator(); + if (BranchInst* BI = dyn_cast(TI)) { + if (BI->isUnconditional()) + BI->setSuccessor(0, exitBlock); + else if (L->contains(BI->getSuccessor(0))) + BI->setSuccessor(0, exitBlock); + else + BI->setSuccessor(1, exitBlock); + } else { + return false; + } + + BasicBlock::iterator BI = exitBlock->begin(); + while (PHINode* P = dyn_cast(BI)) { + unsigned i = P->getBasicBlockIndex(exitingBlock); + P->setIncomingBlock(i, preheader); + BI++; + } + + DominatorTree& DT = getAnalysis(); + for (Loop::block_iterator LI = L->block_begin(), LE = L->block_end(); + LI != LE; ++LI) { + SmallPtrSet childNodes; + childNodes.insert(DT[*LI]->begin(), DT[*LI]->end()); + for (SmallPtrSet::iterator DI = childNodes.begin(), + DE = childNodes.end(); DI != DE; ++DI) + DT.changeImmediateDominator(*DI, DT[preheader]); + + DT.eraseNode(*LI); + + for (BasicBlock::iterator BI = (*LI)->begin(), BE = (*LI)->end(); + BI != BE; ++BI) { + BI->dropAllReferences(); + } + + (*LI)->dropAllReferences(); + } + + unsigned bar = 0; + + for (Loop::block_iterator LI = L->block_begin(), LE = L->block_end(); + LI != LE; ++LI) { + for (BasicBlock::iterator BI = (*LI)->begin(), BE = (*LI)->end(); + BI != BE; ) { + Instruction* I = BI++; + I->eraseFromParent(); + } + + (*LI)->eraseFromParent(); + } + + LoopInfo& loopInfo = getAnalysis(); + SmallPtrSet blocks; + blocks.insert(L->block_begin(), L->block_end()); + for (SmallPtrSet::iterator I = blocks.begin(), + E = blocks.end(); I != E; ++I) + loopInfo.removeBlock(*I); + + LPM.deleteLoopFromQueue(L); + + NumDeleted++; + + return true; +} From resistor at mac.com Mon Apr 28 19:39:24 2008 From: resistor at mac.com (Owen Anderson) Date: Tue, 29 Apr 2008 00:39:24 -0000 Subject: [llvm-commits] [llvm] r50383 - /llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp Message-ID: <200804290039.m3T0dOMb028874@zion.cs.uiuc.edu> Author: resistor Date: Mon Apr 28 19:39:24 2008 New Revision: 50383 URL: http://llvm.org/viewvc/llvm-project?rev=50383&view=rev Log: Remove debugging code. Modified: llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp Modified: llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp?rev=50383&r1=50382&r2=50383&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp Mon Apr 28 19:39:24 2008 @@ -162,8 +162,6 @@ L->getUniqueExitBlocks(exitBlocks); BasicBlock* exitBlock = exitBlocks[0]; - Function* F = L->getLoopLatch()->getParent(); - for (Loop::block_iterator LI = L->block_begin(), LE = L->block_end(); LI != LE; ++LI) for (BasicBlock::iterator BI = (*LI)->begin(), BE = (*LI)->end(); @@ -211,8 +209,6 @@ (*LI)->dropAllReferences(); } - unsigned bar = 0; - for (Loop::block_iterator LI = L->block_begin(), LE = L->block_end(); LI != LE; ++LI) { for (BasicBlock::iterator BI = (*LI)->begin(), BE = (*LI)->end(); From resistor at mac.com Mon Apr 28 19:45:16 2008 From: resistor at mac.com (Owen Anderson) Date: Tue, 29 Apr 2008 00:45:16 -0000 Subject: [llvm-commits] [llvm] r50384 - /llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp Message-ID: <200804290045.m3T0jGko029097@zion.cs.uiuc.edu> Author: resistor Date: Mon Apr 28 19:45:15 2008 New Revision: 50384 URL: http://llvm.org/viewvc/llvm-project?rev=50384&view=rev Log: Add some more comments. Modified: llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp Modified: llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp?rev=50384&r1=50383&r2=50384&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp Mon Apr 28 19:45:15 2008 @@ -162,6 +162,12 @@ L->getUniqueExitBlocks(exitBlocks); BasicBlock* exitBlock = exitBlocks[0]; + // Because we're deleting a large chunk of code at once, the sequence in which + // we remove things is very important to avoid invalidation issues. Don't + // mess with this unless you have good reason and know what you're doing. + + // Move simple loop-invariant expressions out of the loop, since they + // might be needed by the exit phis. for (Loop::block_iterator LI = L->block_begin(), LE = L->block_end(); LI != LE; ++LI) for (BasicBlock::iterator BI = (*LI)->begin(), BE = (*LI)->end(); @@ -171,6 +177,7 @@ I->moveBefore(preheader->getTerminator()); } + // Connect the preheader directly to the exit block. TerminatorInst* TI = preheader->getTerminator(); if (BranchInst* BI = dyn_cast(TI)) { if (BI->isUnconditional()) @@ -180,9 +187,12 @@ else BI->setSuccessor(1, exitBlock); } else { + // FIXME: Support switches return false; } + // Rewrite phis in the exit block to get their inputs from + // the preheader instead of the exiting block. BasicBlock::iterator BI = exitBlock->begin(); while (PHINode* P = dyn_cast(BI)) { unsigned i = P->getBasicBlockIndex(exitingBlock); @@ -190,9 +200,12 @@ BI++; } + // Update lots of internal structures... DominatorTree& DT = getAnalysis(); for (Loop::block_iterator LI = L->block_begin(), LE = L->block_end(); LI != LE; ++LI) { + // Move all of the block's children to be children of the preheader, which + // allows us to remove the domtree entry for the block. SmallPtrSet childNodes; childNodes.insert(DT[*LI]->begin(), DT[*LI]->end()); for (SmallPtrSet::iterator DI = childNodes.begin(), @@ -201,6 +214,8 @@ DT.eraseNode(*LI); + // Drop all references between the instructions and the block so + // that we don't have reference counting problems later. for (BasicBlock::iterator BI = (*LI)->begin(), BE = (*LI)->end(); BI != BE; ++BI) { BI->dropAllReferences(); @@ -209,6 +224,8 @@ (*LI)->dropAllReferences(); } + // Erase the instructions and the blocks without having to worry + // about ordering because we already dropped the references. for (Loop::block_iterator LI = L->block_begin(), LE = L->block_end(); LI != LE; ++LI) { for (BasicBlock::iterator BI = (*LI)->begin(), BE = (*LI)->end(); @@ -220,6 +237,8 @@ (*LI)->eraseFromParent(); } + // Finally, the blocks from loopinfo. This has to happen late because + // otherwise our loop iterators won't work. LoopInfo& loopInfo = getAnalysis(); SmallPtrSet blocks; blocks.insert(L->block_begin(), L->block_end()); @@ -227,6 +246,8 @@ E = blocks.end(); I != E; ++I) loopInfo.removeBlock(*I); + // The last step is to inform the loop pass manager that we've + // eliminated this loop. LPM.deleteLoopFromQueue(L); NumDeleted++; From dalej at apple.com Mon Apr 28 20:11:02 2008 From: dalej at apple.com (Dale Johannesen) Date: Mon, 28 Apr 2008 18:11:02 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r50381 - /llvm-gcc-4.2/branches/Apple/Tak/gcc/objc/objc-act.c In-Reply-To: <200804290030.m3T0UC4I028623@zion.cs.uiuc.edu> References: <200804290030.m3T0UC4I028623@zion.cs.uiuc.edu> Message-ID: <050312FF-6CD8-4D0B-8A1D-5878D461FF34@apple.com> On Apr 28, 2008, at 5:30 PM, Devang Patel wrote: > Author: dpatel > Date: Mon Apr 28 19:30:11 2008 > New Revision: 50381 > > URL: http://llvm.org/viewvc/llvm-project?rev=50381&view=rev > Log: > Disable 5812818 fix for now. Would somebody please reopen 5812818 in that case? That is not as important as the SWB, but it is a compile-time crash on correct code. > Modified: > llvm-gcc-4.2/branches/Apple/Tak/gcc/objc/objc-act.c > > Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/objc/objc-act.c > URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/objc/objc-act.c?rev=50381&r1=50380&r2=50381&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm-gcc-4.2/branches/Apple/Tak/gcc/objc/objc-act.c (original) > +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/objc/objc-act.c Mon Apr 28 > 19:30:11 2008 > @@ -8622,6 +8622,7 @@ > CLASS_TYPE (class) = record; > > /* APPLE LOCAL llvm begin */ > +#if 0 > #ifdef ENABLE_LLVM > /* Synthesized properties will later be added to this > RECORD_DECL as they > * are found in @implementations. We don't want the LLVM tree- > >llvm > @@ -8633,6 +8634,7 @@ > if (flag_objc_abi == 2) > llvm_compute_type(record); > #endif > +#endif > /* APPLE LOCAL llvm end */ > } > } > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From evan.cheng at apple.com Mon Apr 28 20:41:44 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 29 Apr 2008 01:41:44 -0000 Subject: [llvm-commits] [llvm] r50385 - in /llvm/trunk: lib/CodeGen/SimpleRegisterCoalescing.cpp test/CodeGen/X86/2008-04-28-CoalescerBug.ll Message-ID: <200804290141.m3T1fiYu030660@zion.cs.uiuc.edu> Author: evancheng Date: Mon Apr 28 20:41:44 2008 New Revision: 50385 URL: http://llvm.org/viewvc/llvm-project?rev=50385&view=rev Log: Another extract_subreg coalescing bug. e.g. vr1024<2> extract_subreg vr1025, 2 If vr1024 do not have the same register class as vr1025, it's not safe to coalesce this away. For example, vr1024 might be a GPR32 while vr1025 might be a GPR64. Added: llvm/trunk/test/CodeGen/X86/2008-04-28-CoalescerBug.ll Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp?rev=50385&r1=50384&r2=50385&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp (original) +++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Mon Apr 28 20:41:44 2008 @@ -942,9 +942,11 @@ unsigned OldSubIdx = isExtSubReg ? CopyMI->getOperand(0).getSubReg() : CopyMI->getOperand(2).getSubReg(); if (OldSubIdx) { - if (OldSubIdx == SubIdx) + if (OldSubIdx == SubIdx && !differingRegisterClasses(SrcReg, DstReg)) // r1024<2> = EXTRACT_SUBREG r1025, 2. Then r1024 has already been // coalesced to a larger register so the subreg indices cancel out. + // Also check if the other larger register is of the same register + // class as the would be resulting register. SubIdx = 0; else { DOUT << "\t Sub-register indices mismatch.\n"; Added: llvm/trunk/test/CodeGen/X86/2008-04-28-CoalescerBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2008-04-28-CoalescerBug.ll?rev=50385&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/2008-04-28-CoalescerBug.ll (added) +++ llvm/trunk/test/CodeGen/X86/2008-04-28-CoalescerBug.ll Mon Apr 28 20:41:44 2008 @@ -0,0 +1,166 @@ +; RUN: llvm-as < %s | llc -mtriple=x86_64-apple-darwin | grep movl | not grep {r\[abcd\]x} +; RUN: llvm-as < %s | llc -mtriple=x86_64-apple-darwin | grep movl | not grep {r\[ds\]i} +; RUN: llvm-as < %s | llc -mtriple=x86_64-apple-darwin | grep movl | not grep {r\[bs\]p} + + %struct.BITMAP = type { i16, i16, i32, i32, i32, i32, i32, i32, i8*, i8* } + %struct.BltData = type { float, float, float, float } + %struct.BltDepth = type { i32, i8**, i32, %struct.BITMAP* (%struct.BltDepth**, %struct.BITMAP*, i32, i32, float*, float, i32)*, i32 (%struct.BltDepth**, %struct.BltOp*)*, i32 (%struct.BltDepth**, %struct.BltOp*, %struct.BltImg*)*, i32 (%struct.BltDepth**, %struct.BltOp*, %struct.BltSh*)*, [28 x [2 x [2 x i32]]]*, %struct.BltData* } + %struct.BltImg = type { i32, i8, i8, i8, float, float*, float*, i32, i32, float*, i32 (i8*, i8*, i8**, i32*, i8**, i32*)*, i8* } + %struct.BltOp = type { i8, i8, i8, i8, i32, i32, i32, i32, i32, i32, i32, i32, i8*, i8*, i32, i32, i32, i32, i32, i32, i32, i8*, i8*, i32, i32, i32, i32, i32, i32, i32, i8* } + %struct.BltSh = type { i8, i8, i8, i8, float, float*, float*, float*, float*, i32, i32, float*, float*, float* } + +define void @t(%struct.BltDepth* %depth, %struct.BltOp* %bop, i32 %mode) nounwind { +entry: + switch i32 %mode, label %return [ + i32 1, label %bb2898.us + i32 18, label %bb13086.preheader + ] + +bb13086.preheader: ; preds = %entry + %tmp13098 = icmp eq i32 0, 0 ; [#uses=1] + %tmp13238 = icmp eq i32 0, 0 ; [#uses=1] + br label %bb13088 + +bb2898.us: ; preds = %bb2898.us, %entry + br label %bb2898.us + +bb13088: ; preds = %bb13572, %bb13567, %bb13107, %bb13086.preheader + br i1 %tmp13098, label %bb13107, label %bb13101 + +bb13101: ; preds = %bb13088 + br label %bb13107 + +bb13107: ; preds = %bb13101, %bb13088 + %iftmp.684.0 = phi i32 [ 0, %bb13101 ], [ 65535, %bb13088 ] ; [#uses=2] + %tmp13111 = load i64* null, align 8 ; [#uses=3] + %tmp13116 = lshr i64 %tmp13111, 16 ; [#uses=1] + %tmp1311613117 = trunc i64 %tmp13116 to i32 ; [#uses=1] + %tmp13118 = and i32 %tmp1311613117, 65535 ; [#uses=1] + %tmp13120 = lshr i64 %tmp13111, 32 ; [#uses=1] + %tmp1312013121 = trunc i64 %tmp13120 to i32 ; [#uses=1] + %tmp13122 = and i32 %tmp1312013121, 65535 ; [#uses=2] + %tmp13124 = lshr i64 %tmp13111, 48 ; [#uses=1] + %tmp1312413125 = trunc i64 %tmp13124 to i32 ; [#uses=2] + %tmp1314013141not = xor i16 0, -1 ; [#uses=1] + %tmp1314013141not13142 = zext i16 %tmp1314013141not to i32 ; [#uses=3] + %tmp13151 = mul i32 %tmp13122, %tmp1314013141not13142 ; [#uses=1] + %tmp13154 = mul i32 %tmp1312413125, %tmp1314013141not13142 ; [#uses=1] + %tmp13157 = mul i32 %iftmp.684.0, %tmp1314013141not13142 ; [#uses=1] + %tmp13171 = add i32 %tmp13151, 1 ; [#uses=1] + %tmp13172 = add i32 %tmp13171, 0 ; [#uses=1] + %tmp13176 = add i32 %tmp13154, 1 ; [#uses=1] + %tmp13177 = add i32 %tmp13176, 0 ; [#uses=1] + %tmp13181 = add i32 %tmp13157, 1 ; [#uses=1] + %tmp13182 = add i32 %tmp13181, 0 ; [#uses=1] + %tmp13188 = lshr i32 %tmp13172, 16 ; [#uses=1] + %tmp13190 = lshr i32 %tmp13177, 16 ; [#uses=1] + %tmp13192 = lshr i32 %tmp13182, 16 ; [#uses=1] + %tmp13198 = sub i32 %tmp13118, 0 ; [#uses=1] + %tmp13201 = sub i32 %tmp13122, %tmp13188 ; [#uses=1] + %tmp13204 = sub i32 %tmp1312413125, %tmp13190 ; [#uses=1] + %tmp13207 = sub i32 %iftmp.684.0, %tmp13192 ; [#uses=1] + %tmp1320813209 = zext i32 %tmp13204 to i64 ; [#uses=1] + %tmp13211 = shl i64 %tmp1320813209, 48 ; [#uses=1] + %tmp1321213213 = zext i32 %tmp13201 to i64 ; [#uses=1] + %tmp13214 = shl i64 %tmp1321213213, 32 ; [#uses=1] + %tmp13215 = and i64 %tmp13214, 281470681743360 ; [#uses=1] + %tmp1321713218 = zext i32 %tmp13198 to i64 ; [#uses=1] + %tmp13219 = shl i64 %tmp1321713218, 16 ; [#uses=1] + %tmp13220 = and i64 %tmp13219, 4294901760 ; [#uses=1] + %tmp13216 = or i64 %tmp13211, 0 ; [#uses=1] + %tmp13221 = or i64 %tmp13216, %tmp13215 ; [#uses=1] + %tmp13225 = or i64 %tmp13221, %tmp13220 ; [#uses=4] + %tmp1322713228 = trunc i32 %tmp13207 to i16 ; [#uses=4] + %tmp13233 = icmp eq i16 %tmp1322713228, 0 ; [#uses=1] + br i1 %tmp13233, label %bb13088, label %bb13236 + +bb13236: ; preds = %bb13107 + br i1 false, label %bb13567, label %bb13252 + +bb13252: ; preds = %bb13236 + %tmp1329013291 = zext i16 %tmp1322713228 to i64 ; [#uses=8] + %tmp13296 = lshr i64 %tmp13225, 16 ; [#uses=1] + %tmp13297 = and i64 %tmp13296, 65535 ; [#uses=1] + %tmp13299 = lshr i64 %tmp13225, 32 ; [#uses=1] + %tmp13300 = and i64 %tmp13299, 65535 ; [#uses=1] + %tmp13302 = lshr i64 %tmp13225, 48 ; [#uses=1] + %tmp13306 = sub i64 %tmp1329013291, 0 ; [#uses=0] + %tmp13309 = sub i64 %tmp1329013291, %tmp13297 ; [#uses=1] + %tmp13312 = sub i64 %tmp1329013291, %tmp13300 ; [#uses=1] + %tmp13315 = sub i64 %tmp1329013291, %tmp13302 ; [#uses=1] + %tmp13318 = mul i64 %tmp1329013291, %tmp1329013291 ; [#uses=1] + br i1 false, label %bb13339, label %bb13324 + +bb13324: ; preds = %bb13252 + br i1 false, label %bb13339, label %bb13330 + +bb13330: ; preds = %bb13324 + %tmp13337 = sdiv i64 0, 0 ; [#uses=1] + br label %bb13339 + +bb13339: ; preds = %bb13330, %bb13324, %bb13252 + %r0120.0 = phi i64 [ %tmp13337, %bb13330 ], [ 0, %bb13252 ], [ 4294836225, %bb13324 ] ; [#uses=1] + br i1 false, label %bb13360, label %bb13345 + +bb13345: ; preds = %bb13339 + br i1 false, label %bb13360, label %bb13351 + +bb13351: ; preds = %bb13345 + %tmp13354 = mul i64 0, %tmp13318 ; [#uses=1] + %tmp13357 = sub i64 %tmp1329013291, %tmp13309 ; [#uses=1] + %tmp13358 = sdiv i64 %tmp13354, %tmp13357 ; [#uses=1] + br label %bb13360 + +bb13360: ; preds = %bb13351, %bb13345, %bb13339 + %r1121.0 = phi i64 [ %tmp13358, %bb13351 ], [ 0, %bb13339 ], [ 4294836225, %bb13345 ] ; [#uses=1] + br i1 false, label %bb13402, label %bb13387 + +bb13387: ; preds = %bb13360 + br label %bb13402 + +bb13402: ; preds = %bb13387, %bb13360 + %r3123.0 = phi i64 [ 0, %bb13360 ], [ 4294836225, %bb13387 ] ; [#uses=1] + %tmp13404 = icmp eq i16 %tmp1322713228, -1 ; [#uses=1] + br i1 %tmp13404, label %bb13435, label %bb13407 + +bb13407: ; preds = %bb13402 + br label %bb13435 + +bb13435: ; preds = %bb13407, %bb13402 + %r0120.1 = phi i64 [ 0, %bb13407 ], [ %r0120.0, %bb13402 ] ; [#uses=0] + %r1121.1 = phi i64 [ 0, %bb13407 ], [ %r1121.0, %bb13402 ] ; [#uses=0] + %r3123.1 = phi i64 [ 0, %bb13407 ], [ %r3123.0, %bb13402 ] ; [#uses=0] + %tmp13450 = mul i64 0, %tmp13312 ; [#uses=0] + %tmp13455 = mul i64 0, %tmp13315 ; [#uses=0] + %tmp13461 = add i64 0, %tmp1329013291 ; [#uses=1] + %tmp13462 = mul i64 %tmp13461, 65535 ; [#uses=1] + %tmp13466 = sub i64 %tmp13462, 0 ; [#uses=1] + %tmp13526 = add i64 %tmp13466, 1 ; [#uses=1] + %tmp13527 = add i64 %tmp13526, 0 ; [#uses=1] + %tmp13528 = ashr i64 %tmp13527, 16 ; [#uses=4] + %tmp13536 = sub i64 %tmp13528, 0 ; [#uses=1] + %tmp13537 = shl i64 %tmp13536, 32 ; [#uses=1] + %tmp13538 = and i64 %tmp13537, 281470681743360 ; [#uses=1] + %tmp13542 = sub i64 %tmp13528, 0 ; [#uses=1] + %tmp13543 = shl i64 %tmp13542, 16 ; [#uses=1] + %tmp13544 = and i64 %tmp13543, 4294901760 ; [#uses=1] + %tmp13548 = sub i64 %tmp13528, 0 ; [#uses=1] + %tmp13549 = and i64 %tmp13548, 65535 ; [#uses=1] + %tmp13539 = or i64 %tmp13538, 0 ; [#uses=1] + %tmp13545 = or i64 %tmp13539, %tmp13549 ; [#uses=1] + %tmp13550 = or i64 %tmp13545, %tmp13544 ; [#uses=1] + %tmp1355213553 = trunc i64 %tmp13528 to i16 ; [#uses=1] + br label %bb13567 + +bb13567: ; preds = %bb13435, %bb13236 + %tsp1040.0.0 = phi i64 [ %tmp13550, %bb13435 ], [ %tmp13225, %bb13236 ] ; [#uses=0] + %tsp1040.1.0 = phi i16 [ %tmp1355213553, %bb13435 ], [ %tmp1322713228, %bb13236 ] ; [#uses=1] + br i1 %tmp13238, label %bb13088, label %bb13572 + +bb13572: ; preds = %bb13567 + store i16 %tsp1040.1.0, i16* null, align 2 + br label %bb13088 + +return: ; preds = %entry + ret void +} From sabre at nondot.org Mon Apr 28 23:29:55 2008 From: sabre at nondot.org (Chris Lattner) Date: Tue, 29 Apr 2008 04:29:55 -0000 Subject: [llvm-commits] [llvm] r50386 - in /llvm/trunk: lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp test/CodeGen/X86/inline-asm-mrv.ll Message-ID: <200804290429.m3T4TtCd002846@zion.cs.uiuc.edu> Author: lattner Date: Mon Apr 28 23:29:54 2008 New Revision: 50386 URL: http://llvm.org/viewvc/llvm-project?rev=50386&view=rev Log: add support for multiple return values in inline asm. This is a step towards PR2094. It now compiles the attached .ll file to: _sad16_sse2: movslq %ecx, %rax ## InlineAsm Start %ecx %rdx %rax %rax %r8d %rdx %rsi ## InlineAsm End ## InlineAsm Start set %eax ## InlineAsm End ret which is pretty decent for a 3 output, 4 input asm. Added: llvm/trunk/test/CodeGen/X86/inline-asm-mrv.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=50386&r1=50385&r2=50386&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Mon Apr 28 23:29:54 2008 @@ -176,6 +176,15 @@ } } + /// append - Add the specified values to this one. + void append(const RegsForValue &RHS) { + TLI = RHS.TLI; + ValueVTs.append(RHS.ValueVTs.begin(), RHS.ValueVTs.end()); + RegVTs.append(RHS.RegVTs.begin(), RHS.RegVTs.end()); + Regs.append(RHS.Regs.begin(), RHS.Regs.end()); + } + + /// getCopyFromRegs - Emit a series of CopyFromReg nodes that copies from /// this value and returns the result as a ValueVTs value. This uses /// Chain/Flag as the input and updates them for the output Chain/Flag. @@ -3754,7 +3763,6 @@ } // Otherwise, we couldn't allocate enough registers for this. - return; } @@ -3938,7 +3946,7 @@ // Loop over all of the inputs, copying the operand values into the // appropriate registers and processing the output regs. RegsForValue RetValRegs; - + // IndirectStoresToEmit - The set of stores to emit after the inline asm node. std::vector > IndirectStoresToEmit; @@ -3970,15 +3978,16 @@ exit(1); } - if (!OpInfo.isIndirect) { - // This is the result value of the call. - assert(RetValRegs.Regs.empty() && - "Cannot have multiple output constraints yet!"); - assert(CS.getType() != Type::VoidTy && "Bad inline asm!"); - RetValRegs = OpInfo.AssignedRegs; - } else { + // If this is an indirect operand, store through the pointer after the + // asm. + if (OpInfo.isIndirect) { IndirectStoresToEmit.push_back(std::make_pair(OpInfo.AssignedRegs, OpInfo.CallOperandVal)); + } else { + // This is the result value of the call. + assert(CS.getType() != Type::VoidTy && "Bad inline asm!"); + // Concatenate this output onto the outputs list. + RetValRegs.append(OpInfo.AssignedRegs); } // Add information to the INLINEASM node to know that this register is @@ -4115,9 +4124,7 @@ // width/num elts. Make sure to convert it to the right type with // bit_convert. if (MVT::isVector(Val.getValueType())) { - const VectorType *VTy = cast(CS.getType()); - MVT::ValueType DesiredVT = TLI.getValueType(VTy); - + MVT::ValueType DesiredVT = TLI.getValueType(CS.getType()); Val = DAG.getNode(ISD::BIT_CONVERT, DesiredVT, Val); } Added: llvm/trunk/test/CodeGen/X86/inline-asm-mrv.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/inline-asm-mrv.ll?rev=50386&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/inline-asm-mrv.ll (added) +++ llvm/trunk/test/CodeGen/X86/inline-asm-mrv.ll Mon Apr 28 23:29:54 2008 @@ -0,0 +1,17 @@ +; PR2094 +; RUN: llvm-as < %s | llc -march=x86-64 | grep movslq +; RUN: llvm-as < %s | llc -march=x86-64 | not grep movq + +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" +target triple = "x86_64-apple-darwin8" + +define i32 @sad16_sse2(i8* %v, i8* %blk2, i8* %blk1, i32 %stride, i32 %h) nounwind { +entry: + %tmp12 = sext i32 %stride to i64 ; [#uses=1] + %mrv = call {i32, i8*, i8*} asm sideeffect "$0 $1 $2 $3 $4 $5 $6", + "=r,=r,=r,r,r,r,r"( i64 %tmp12, i32 %h, i8* %blk1, i8* %blk2 ) nounwind + %tmp6 = getresult {i32, i8*, i8*} %mrv, 0 + %tmp7 = call i32 asm sideeffect "set $0", + "=r,~{dirflag},~{fpsr},~{flags}"( ) nounwind + ret i32 %tmp7 +} From sabre at nondot.org Mon Apr 28 23:48:56 2008 From: sabre at nondot.org (Chris Lattner) Date: Tue, 29 Apr 2008 04:48:56 -0000 Subject: [llvm-commits] [llvm] r50389 - in /llvm/trunk: lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp test/CodeGen/X86/inline-asm-mrv.ll Message-ID: <200804290448.m3T4mul4003479@zion.cs.uiuc.edu> Author: lattner Date: Mon Apr 28 23:48:56 2008 New Revision: 50389 URL: http://llvm.org/viewvc/llvm-project?rev=50389&view=rev Log: make the vector conversion magic handle multiple results. We now compile test2/test3 to: _test2: ## InlineAsm Start set %xmm0, %xmm1 ## InlineAsm End addps %xmm1, %xmm0 ret _test3: ## InlineAsm Start set %xmm0, %xmm1 ## InlineAsm End paddd %xmm1, %xmm0 ret as expected. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp llvm/trunk/test/CodeGen/X86/inline-asm-mrv.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=50389&r1=50388&r2=50389&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Mon Apr 28 23:48:56 2008 @@ -4119,15 +4119,24 @@ // and set it as the value of the call. if (!RetValRegs.Regs.empty()) { SDOperand Val = RetValRegs.getCopyFromRegs(DAG, Chain, &Flag); - - // If the result of the inline asm is a vector, it may have the wrong - // width/num elts. Make sure to convert it to the right type with + + // If any of the results of the inline asm is a vector, it may have the + // wrong width/num elts. This can happen for register classes that can + // contain multiple different value types. The preg or vreg allocated may + // not have the same VT as was expected. Convert it to the right type with // bit_convert. - if (MVT::isVector(Val.getValueType())) { - MVT::ValueType DesiredVT = TLI.getValueType(CS.getType()); - Val = DAG.getNode(ISD::BIT_CONVERT, DesiredVT, Val); + if (const StructType *ResSTy = dyn_cast(CS.getType())) { + for (unsigned i = 0, e = ResSTy->getNumElements(); i != e; ++i) { + if (MVT::isVector(Val.Val->getValueType(i))) + Val = DAG.getNode(ISD::BIT_CONVERT, + TLI.getValueType(ResSTy->getElementType(i)), Val); + } + } else { + if (MVT::isVector(Val.getValueType())) + Val = DAG.getNode(ISD::BIT_CONVERT, TLI.getValueType(CS.getType()), + Val); } - + setValue(CS.getInstruction(), Val); } Modified: llvm/trunk/test/CodeGen/X86/inline-asm-mrv.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/inline-asm-mrv.ll?rev=50389&r1=50388&r2=50389&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/inline-asm-mrv.ll (original) +++ llvm/trunk/test/CodeGen/X86/inline-asm-mrv.ll Mon Apr 28 23:48:56 2008 @@ -1,12 +1,13 @@ ; PR2094 ; RUN: llvm-as < %s | llc -march=x86-64 | grep movslq +; RUN: llvm-as < %s | llc -march=x86-64 | grep addps +; RUN: llvm-as < %s | llc -march=x86-64 | grep paddd ; RUN: llvm-as < %s | llc -march=x86-64 | not grep movq target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" target triple = "x86_64-apple-darwin8" -define i32 @sad16_sse2(i8* %v, i8* %blk2, i8* %blk1, i32 %stride, i32 %h) nounwind { -entry: +define i32 @test1(i8* %v, i8* %blk2, i8* %blk1, i32 %stride, i32 %h) nounwind { %tmp12 = sext i32 %stride to i64 ; [#uses=1] %mrv = call {i32, i8*, i8*} asm sideeffect "$0 $1 $2 $3 $4 $5 $6", "=r,=r,=r,r,r,r,r"( i64 %tmp12, i32 %h, i8* %blk1, i8* %blk2 ) nounwind @@ -15,3 +16,20 @@ "=r,~{dirflag},~{fpsr},~{flags}"( ) nounwind ret i32 %tmp7 } + +define <4 x float> @test2() nounwind { + %mrv = call {<4 x float>, <4 x float>} asm "set $0, $1", "=x,=x"() + %a = getresult {<4 x float>, <4 x float>} %mrv, 0 + %b = getresult {<4 x float>, <4 x float>} %mrv, 1 + %c = add <4 x float> %a, %b + ret <4 x float> %c +} + +define <4 x i32> @test3() nounwind { + %mrv = call {<4 x i32>, <4 x i32>} asm "set $0, $1", "=x,=x"() + %a = getresult {<4 x i32>, <4 x i32>} %mrv, 0 + %b = getresult {<4 x i32>, <4 x i32>} %mrv, 1 + %c = add <4 x i32> %a, %b + ret <4 x i32> %c +} + From sabre at nondot.org Mon Apr 28 23:58:39 2008 From: sabre at nondot.org (Chris Lattner) Date: Tue, 29 Apr 2008 04:58:39 -0000 Subject: [llvm-commits] [llvm] r50390 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/2008-04-28-VolatileStore.ll Message-ID: <200804290458.m3T4wdep003808@zion.cs.uiuc.edu> Author: lattner Date: Mon Apr 28 23:58:38 2008 New Revision: 50390 URL: http://llvm.org/viewvc/llvm-project?rev=50390&view=rev Log: don't delete the last store to an alloca if the store is volatile. Added: llvm/trunk/test/Transforms/InstCombine/2008-04-28-VolatileStore.ll Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=50390&r1=50389&r2=50390&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Mon Apr 28 23:58:38 2008 @@ -10311,7 +10311,7 @@ // If the RHS is an alloca with a single use, zapify the store, making the // alloca dead. - if (Ptr->hasOneUse()) { + if (Ptr->hasOneUse() && !SI.isVolatile()) { if (isa(Ptr)) { EraseInstFromFunction(SI); ++NumCombined; Added: llvm/trunk/test/Transforms/InstCombine/2008-04-28-VolatileStore.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2008-04-28-VolatileStore.ll?rev=50390&view=auto ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/2008-04-28-VolatileStore.ll (added) +++ llvm/trunk/test/Transforms/InstCombine/2008-04-28-VolatileStore.ll Mon Apr 28 23:58:38 2008 @@ -0,0 +1,8 @@ +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {volatile store} + +define void @test() { + %votf = alloca <4 x float> ; <<4 x float>*> [#uses=1] + volatile store <4 x float> zeroinitializer, <4 x float>* %votf, align 16 + ret void +} + From sabre at nondot.org Tue Apr 29 00:05:22 2008 From: sabre at nondot.org (Chris Lattner) Date: Tue, 29 Apr 2008 05:05:22 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50391 - /llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/i386-bitmask1.c Message-ID: <200804290505.m3T55MDt003991@zion.cs.uiuc.edu> Author: lattner Date: Tue Apr 29 00:05:22 2008 New Revision: 50391 URL: http://llvm.org/viewvc/llvm-project?rev=50391&view=rev Log: Fix this test so we don't delete the whole thing. We compile this loop to amazingly gross code. What is wrong with this picture: entry: %tmp2126 = icmp sgt i32 %count, 0 ; [#uses=1] br i1 %tmp2126, label %bb.preheader, label %return bb.preheader: ; preds = %entry %tmp = icmp slt i32 %count, 1 ; [#uses=1] %smax = select i1 %tmp, i32 1, i32 %count ; [#uses=1] br label %bb .. Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/i386-bitmask1.c Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/i386-bitmask1.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/i386-bitmask1.c?rev=50391&r1=50390&r2=50391&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/i386-bitmask1.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/i386-bitmask1.c Tue Apr 29 00:05:22 2008 @@ -5,11 +5,10 @@ /* { dg-final { scan-assembler "and.*0xffffff00" } } */ unsigned char lut[256]; -void foo( int count ) +void foo( int count, unsigned int *srcptr, unsigned *dstptr ) { int j; - unsigned int *srcptr, *dstptr; for (j = 0; j < count; j++) { unsigned int tmp = *srcptr; unsigned int alpha = (tmp&255); From sabre at nondot.org Tue Apr 29 00:12:08 2008 From: sabre at nondot.org (Chris Lattner) Date: Tue, 29 Apr 2008 05:12:08 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50392 - /llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/i386-bitmask1.c Message-ID: <200804290512.m3T5C8CK004196@zion.cs.uiuc.edu> Author: lattner Date: Tue Apr 29 00:12:08 2008 New Revision: 50392 URL: http://llvm.org/viewvc/llvm-project?rev=50392&view=rev Log: llvm prints in decimal, allow this test to pass. Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/i386-bitmask1.c Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/i386-bitmask1.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/i386-bitmask1.c?rev=50392&r1=50391&r2=50392&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/i386-bitmask1.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/i386-bitmask1.c Tue Apr 29 00:12:08 2008 @@ -2,7 +2,7 @@ /* { dg-do compile { target "i?86-*-*" } } */ /* { dg-options "-O2" } */ /* { dg-skip-if "" { i?86-*-* } { "-m64" } { "" } } */ -/* { dg-final { scan-assembler "and.*0xffffff00" } } */ +/* { dg-final { scan-assembler "and.*(0xffffff00|4294967040)" } } */ unsigned char lut[256]; void foo( int count, unsigned int *srcptr, unsigned *dstptr ) From tonic at nondot.org Tue Apr 29 00:12:45 2008 From: tonic at nondot.org (Tanya Lattner) Date: Tue, 29 Apr 2008 05:12:45 -0000 Subject: [llvm-commits] [nightly-test-server] r50393 - /nightly-test-server/trunk/AcceptTestResults.php Message-ID: <200804290512.m3T5CjCX004226@zion.cs.uiuc.edu> Author: tbrethou Date: Tue Apr 29 00:12:45 2008 New Revision: 50393 URL: http://llvm.org/viewvc/llvm-project?rev=50393&view=rev Log: Fix loc stats and program results. Update comments to reflect new table design. Modified: nightly-test-server/trunk/AcceptTestResults.php Modified: nightly-test-server/trunk/AcceptTestResults.php URL: http://llvm.org/viewvc/llvm-project/nightly-test-server/trunk/AcceptTestResults.php?rev=50393&r1=50392&r2=50393&view=diff ============================================================================== --- nightly-test-server/trunk/AcceptTestResults.php (original) +++ nightly-test-server/trunk/AcceptTestResults.php Tue Apr 29 00:12:45 2008 @@ -45,33 +45,39 @@ /******************************************************************************* * mysql> describe testRunInfo; -* +-------------------+-----------------------------------+------+-----+---------------------+----------------+ -* | Field | Type | Null | Key | Default | Extra | -* +-------------------+-----------------------------------+------+-----+---------------------+----------------+ -* | id | int(11) | | PRI | NULL | auto_increment | -* | runDateTime | datetime | | | 0000-00-00 00:00:00 | | -* | machineId | int(11) | | | 0 | | -* | machineUname | text | YES | | NULL | | -* | gccVersion | text | YES | | NULL | | -* | cvsCpuTime | double | YES | | NULL | | -* | cvsWallTime | double | YES | | NULL | | -* | configureCpuTime | double | YES | | NULL | | -* | configureWallTime | double | YES | | NULL | | -* | buildCpuTime | double | YES | | NULL | | -* | buildWallTime | double | YES | | NULL | | -* | dejagnuCpuTime | double | YES | | NULL | | -* | dejagnuWallTime | double | YES | | NULL | | -* | warnings | mediumtext | YES | | NULL | | -* | warningsAdded | text | YES | | NULL | | -* | warningsRemoved | text | YES | | NULL | | -* | cvsUsersAdd | text | YES | | NULL | | -* | cvsUsersCO | text | YES | | NULL | | -* | cvsFilesAdded | text | YES | | NULL | | -* | cvsFilesRemoved | text | YES | | NULL | | -* | cvsFilesModified | text | YES | | NULL | | -* | buildStatus | tinyint(4) | YES | | NULL | | -* | type | enum('release','debug','unknown') | YES | | unknown | | -* +-------------------+-----------------------------------+------+-----+---------------------+----------------+ +* +-------------------+-------------------------------------+------+-----+---------------------+----------------+ +* | Field | Type | Null | Key | Default | Extra | +* +-------------------+-------------------------------------+------+-----+---------------------+----------------+ +* | id | int(11) | | PRI | NULL | auto_increment | +* | runDateTime | datetime | | MUL | 0000-00-00 00:00:00 | | +* | machineId | int(11) | | MUL | 0 | | +* | machineUname | text | YES | | NULL | | +* | gccVersion | text | YES | | NULL | | +* | cvsCpuTime | double | YES | | NULL | | +* | cvsWallTime | double | YES | | NULL | | +* | configureCpuTime | double | YES | | NULL | | +* | configureWallTime | double | YES | | NULL | | +* | buildCpuTime | double | YES | | NULL | | +* | buildWallTime | double | YES | | NULL | | +* | dejagnuCpuTime | double | YES | | NULL | | +* | dejagnuWallTime | double | YES | | NULL | | +* | warnings | mediumtext | YES | | NULL | | +* | warningsAdded | text | YES | | NULL | | +* | warningsRemoved | text | YES | | NULL | | +* | cvsUsersAdd | text | YES | | NULL | | +* | cvsUsersCO | text | YES | | NULL | | +* | cvsFilesAdded | text | YES | | NULL | | +* | cvsFilesRemoved | text | YES | | NULL | | +* | cvsFilesModified | text | YES | | NULL | | +* | buildStatus | enum('OK','FAIL','Skipped','Other') | YES | | Other | | +* | type | enum('release','debug','unknown') | YES | | unknown | | +* | dejagnuPass | int(11) | YES | | NULL | | +* | dejagnuFail | int(11) | YES | | NULL | | +* | dejagnuXFail | int(11) | YES | | NULL | | +* | dejagnuXPass | int(11) | YES | | NULL | | +* | dateAdded | datetime | YES | | NULL | | +* +-------------------+-------------------------------------+------+-----+---------------------+----------------+ +* * Add a test run configuration to the database for logging test results. * *******************************************************************************/ @@ -205,17 +211,47 @@ $program = $results[0]; $program = $prefix . $program; + $gccasTime = $results[1]; + if($gccasTime == "*") + $gccasTime = NULL; + $byteCodeSize = $results[2]; + if($byteCodeSize == "*") + $byteCodeSize = NULL; + $llcTime = $results[3]; + if($llcTime == "*") + $llcTime = NULL; + $llcBetaTime = $results[4]; + if($llcBetaTime == "*") + $llcBetaTime = NULL; + $jitTime = $results[5]; + if($jitTime == "*") + $jitTime = NULL; + $gccRunTime = $results[6]; + if($gccRunTime = "*") + $gccRunTime = NULL; + $cbeRunTime = $results[7]; + if($cbeRunTime == "*") + $cbeRunTime = NULL; + $llcRunTime = $results[8]; + if($llcRunTime == "*") + $llcRunTime = NULL; + $llcBetaRunTime = $results[9]; + if($llcBetaRunTime == "*") + $llcBetaRunTime = NULL; + $jitRunTime = $results[10]; - + if($jitRunTime == "*") + $jitRunTime = NULL; + // Get id for program name $sqlQuery = "SELECT id FROM programs WHERE name=\"$program\""; $result = mysql_query($sqlQuery) or die(mysql_error()); @@ -239,7 +275,7 @@ \"$llcTime\", \"$llcBetaTime\", \"$jitTime\", \"$gccRunTime\", \"$cbeRunTime\", \"$llcRunTime\", \"$llcBetaRunTime\", \"$jitRunTime\")"; - + mysql_query($query) or die(mysql_error()); } @@ -594,7 +630,7 @@ $loc = $_POST['lines_of_code']; $filesincvs = $_POST['cvs_file_count']; $dirsincvs = $_POST['cvs_dir_count']; -if(strcmp($buildstatus, "OK") == 0) { +if($buildstatus == 1) { // only update loc if successful build updateLLVMStats($runDateTime, $loc, $filesincvs, $dirsincvs, $testRunConfigId); From dpatel at apple.com Tue Apr 29 00:48:18 2008 From: dpatel at apple.com (Devang Patel) Date: Mon, 28 Apr 2008 22:48:18 -0700 Subject: [llvm-commits] [llvm] r50382 - in /llvm/trunk: include/llvm/LinkAllPasses.h include/llvm/Transforms/Scalar.h lib/Transforms/Scalar/DeadLoopElimination.cpp In-Reply-To: <200804290038.m3T0cZc1028840@zion.cs.uiuc.edu> References: <200804290038.m3T0cZc1028840@zion.cs.uiuc.edu> Message-ID: On Apr 28, 2008, at 5:38 PM, Owen Anderson wrote: > + for (Loop::block_iterator LI = L->block_begin(), LE = L- > >block_end(); > + LI != LE; ++LI) { Make sure that you're not incrementing invalid iterator here. - Devang From dpatel at apple.com Tue Apr 29 00:50:35 2008 From: dpatel at apple.com (Devang Patel) Date: Mon, 28 Apr 2008 22:50:35 -0700 Subject: [llvm-commits] [llvm] r50384 - /llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp In-Reply-To: <200804290045.m3T0jGko029097@zion.cs.uiuc.edu> References: <200804290045.m3T0jGko029097@zion.cs.uiuc.edu> Message-ID: On Apr 28, 2008, at 5:45 PM, Owen Anderson wrote: > Author: resistor > Date: Mon Apr 28 19:45:15 2008 > New Revision: 50384 > > URL: http://llvm.org/viewvc/llvm-project?rev=50384&view=rev > Log: > Add some more comments. Thanks!. Please define "Dead Loop" at the beginning to avoid confusion. Some of the function definitions could use comments to describe their behavior. - Devang From sabre at nondot.org Tue Apr 29 00:53:29 2008 From: sabre at nondot.org (Chris Lattner) Date: Tue, 29 Apr 2008 05:53:29 -0000 Subject: [llvm-commits] [llvm] r50397 - /llvm/trunk/test/CFrontend/inline-asm-mrv.c Message-ID: <200804290553.m3T5rTua005540@zion.cs.uiuc.edu> Author: lattner Date: Tue Apr 29 00:53:29 2008 New Revision: 50397 URL: http://llvm.org/viewvc/llvm-project?rev=50397&view=rev Log: new testcase for PR2094. The inline asms should not pin allocas to the stack anymore. Added: llvm/trunk/test/CFrontend/inline-asm-mrv.c Added: llvm/trunk/test/CFrontend/inline-asm-mrv.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CFrontend/inline-asm-mrv.c?rev=50397&view=auto ============================================================================== --- llvm/trunk/test/CFrontend/inline-asm-mrv.c (added) +++ llvm/trunk/test/CFrontend/inline-asm-mrv.c Tue Apr 29 00:53:29 2008 @@ -0,0 +1,12 @@ +// RUN: %llvmgcc -S %s -o - -O | not grep alloca +// PR2094 + +int sad16_sse2(void *v, unsigned char *blk2, unsigned char *blk1, + int stride, int h) { + int ret; + asm volatile( "%0 %1 %2 %3" + : "+r" (h), "+r" (blk1), "+r" (blk2) + : "r" ((long)stride)); + asm volatile("set %0 %1" : "=r"(ret) : "r"(blk1)); + return ret; +} From sabre at nondot.org Tue Apr 29 00:54:46 2008 From: sabre at nondot.org (Chris Lattner) Date: Tue, 29 Apr 2008 05:54:46 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50398 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Message-ID: <200804290554.m3T5skVa005587@zion.cs.uiuc.edu> Author: lattner Date: Tue Apr 29 00:54:45 2008 New Revision: 50398 URL: http://llvm.org/viewvc/llvm-project?rev=50398&view=rev Log: Implement support for turning inline asms with multiple results into a multiple return value call. This fixes the last part of PR2094. Testcase here: llvm/test/CFrontend/inline-asm-mrv.c Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=50398&r1=50397&r2=50398&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Tue Apr 29 00:54:45 2008 @@ -3794,8 +3794,8 @@ std::string ConstraintStr; // StoreCallResultAddr - The pointer to store the result of the call through. - Value *StoreCallResultAddr = 0; - const Type *CallResultType = Type::VoidTy; + SmallVector StoreCallResultAddrs; + SmallVector CallResultTypes; // Process outputs. int ValNum = 0; @@ -3856,13 +3856,11 @@ cast(Dest.Ptr->getType())->getElementType(); assert(!Dest.isBitfield() && "Cannot assign into a bitfield!"); - if (ConstraintStr.empty() && !AllowsMem && // Reg dest and no output yet? - DestValTy->isFirstClassType()) { - assert(StoreCallResultAddr == 0 && "Already have a result val?"); - StoreCallResultAddr = Dest.Ptr; + if (!AllowsMem && DestValTy->isFirstClassType()) { // Reg dest -> asm return + StoreCallResultAddrs.push_back(Dest.Ptr); ConstraintStr += ",="; ConstraintStr += SimplifiedConstraint; - CallResultType = DestValTy; + CallResultTypes.push_back(DestValTy); } else { ConstraintStr += ",=*"; ConstraintStr += SimplifiedConstraint; @@ -3989,6 +3987,17 @@ } } + const Type *CallResultType; + switch (CallResultTypes.size()) { + case 0: CallResultType = Type::VoidTy; break; + case 1: CallResultType = CallResultTypes[0]; break; + default: + std::vector TmpVec(CallResultTypes.begin(), + CallResultTypes.end()); + CallResultType = StructType::get(TmpVec); + break; + } + const FunctionType *FTy = FunctionType::get(CallResultType, CallArgTypes, false); @@ -4005,12 +4014,18 @@ Value *Asm = InlineAsm::get(FTy, NewAsmStr, ConstraintStr, ASM_VOLATILE_P(exp) || !ASM_OUTPUTS(exp)); CallInst *CV = Builder.CreateCall(Asm, CallOps.begin(), CallOps.end(), - StoreCallResultAddr ? "tmp" : ""); + CallResultTypes.empty() ? "" : "asmtmp"); CV->setDoesNotThrow(); // If the call produces a value, store it into the destination. - if (StoreCallResultAddr) - Builder.CreateStore(CV, StoreCallResultAddr); + if (StoreCallResultAddrs.size() == 1) + Builder.CreateStore(CV, StoreCallResultAddrs[0]); + else if (unsigned NumResults = StoreCallResultAddrs.size()) { + for (unsigned i = 0; i != NumResults; ++i) { + Value *ValI = Builder.CreateGetResult(CV, i, "asmresult"); + Builder.CreateStore(ValI, StoreCallResultAddrs[i]); + } + } // Give the backend a chance to upgrade the inline asm to LLVM code. This // handles some common cases that LLVM has intrinsics for, e.g. x86 bswap -> From asl at math.spbu.ru Tue Apr 29 01:20:19 2008 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Tue, 29 Apr 2008 06:20:19 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50399 - /llvm-gcc-4.2/trunk/libstdc++-v3/include/bits/locale_facets.tcc Message-ID: <200804290620.m3T6KKFS006391@zion.cs.uiuc.edu> Author: asl Date: Tue Apr 29 01:20:19 2008 New Revision: 50399 URL: http://llvm.org/viewvc/llvm-project?rev=50399&view=rev Log: Backport from mainline (pre-GPLv3). Fix for sizeof(const void*) > sizeof(unsigned long). Modified: llvm-gcc-4.2/trunk/libstdc++-v3/include/bits/locale_facets.tcc Modified: llvm-gcc-4.2/trunk/libstdc++-v3/include/bits/locale_facets.tcc URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libstdc%2B%2B-v3/include/bits/locale_facets.tcc?rev=50399&r1=50398&r2=50399&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/libstdc++-v3/include/bits/locale_facets.tcc (original) +++ llvm-gcc-4.2/trunk/libstdc++-v3/include/bits/locale_facets.tcc Tue Apr 29 01:20:19 2008 @@ -885,7 +885,13 @@ const fmtflags __fmt = __io.flags(); __io.flags(__fmt & ~ios_base::basefield | ios_base::hex); - unsigned long __ul; + // LLVM LOCAL begin mainline + typedef __gnu_cxx::__conditional_type<(sizeof(void*) + <= sizeof(unsigned long)), + unsigned long, unsigned long long>::__type _UIntPtrType; + + _UIntPtrType __ul; + // LLVM LOCAL end mainline __beg = _M_extract_int(__beg, __end, __io, __err, __ul); // Reset from hex formatted input. @@ -1307,8 +1313,14 @@ | ios_base::internal); __io.flags(__flags & __fmt | (ios_base::hex | ios_base::showbase)); + // LLVM LOCAL begin mainline + typedef __gnu_cxx::__conditional_type<(sizeof(const void*) + <= sizeof(unsigned long)), + unsigned long, unsigned long long>::__type _UIntPtrType; + __s = _M_insert_int(__s, __io, __fill, - reinterpret_cast(__v)); + reinterpret_cast<_UIntPtrType>(__v)); + // LLVM LOCAL end mainline __io.flags(__flags); return __s; } From asl at math.spbu.ru Tue Apr 29 01:21:06 2008 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Tue, 29 Apr 2008 06:21:06 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50400 - in /llvm-gcc-4.2/trunk: gcc/config.gcc gcc/config.host gcc/config/i386/t-cygming libstdc++-v3/configure libtool.m4 Message-ID: <200804290621.m3T6L7qp006433@zion.cs.uiuc.edu> Author: asl Date: Tue Apr 29 01:21:06 2008 New Revision: 50400 URL: http://llvm.org/viewvc/llvm-project?rev=50400&view=rev Log: Backport from mainline. Add win64 as target to llvm-gcc. All win64-related changes were explicitely approved by their author to be backported to llvm-gcc under GPLv2. Modified: llvm-gcc-4.2/trunk/gcc/config.gcc llvm-gcc-4.2/trunk/gcc/config.host llvm-gcc-4.2/trunk/gcc/config/i386/t-cygming llvm-gcc-4.2/trunk/libstdc++-v3/configure llvm-gcc-4.2/trunk/libtool.m4 Modified: llvm-gcc-4.2/trunk/gcc/config.gcc URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config.gcc?rev=50400&r1=50399&r2=50400&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config.gcc (original) +++ llvm-gcc-4.2/trunk/gcc/config.gcc Tue Apr 29 01:21:06 2008 @@ -1325,22 +1325,30 @@ target_gtfiles="\$(srcdir)/config/i386/winnt.c" extra_options="${extra_options} i386/cygming.opt" extra_objs="winnt.o winnt-stubs.o" - c_target_objs=cygwin2.o - cxx_target_objs="cygwin2.o winnt-cxx.o" +# LLVM LOCAL begin mainline + c_target_objs="cygwin2.o msformat-c.o" + cxx_target_objs="cygwin2.o winnt-cxx.o msformat-c.o" +# LLVM LOCAL end mainline extra_gcc_objs=cygwin1.o extra_parts="crtbegin.o crtend.o" if test x$enable_threads = xyes; then thread_file='posix' fi ;; -i[34567]86-*-mingw32*) +# LLVM LOCAL begin mainline +i[34567]86-*-mingw32* | x86_64-*-mingw32*) +# LLVM LOCAL end mainline tm_file="${tm_file} i386/unix.h i386/bsd.h i386/gas.h dbxcoff.h i386/cygming.h i386/mingw32.h" xm_file=i386/xm-mingw32.h tmake_file="i386/t-cygming i386/t-mingw32" target_gtfiles="\$(srcdir)/config/i386/winnt.c" extra_options="${extra_options} i386/cygming.opt" extra_objs="winnt.o winnt-stubs.o" - cxx_target_objs=winnt-cxx.o +# LLVM LOCAL begin mainline + c_target_objs="msformat-c.o" + cxx_target_objs="winnt-cxx.o msformat-c.o" + default_use_cxa_atexit=yes +# LLVM LOCAL end mainline extra_parts="crtbegin.o crtend.o" case ${enable_threads} in "" | yes | win32) Modified: llvm-gcc-4.2/trunk/gcc/config.host URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config.host?rev=50400&r1=50399&r2=50400&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config.host (original) +++ llvm-gcc-4.2/trunk/gcc/config.host Tue Apr 29 01:21:06 2008 @@ -168,7 +168,9 @@ host_xmake_file="${host_xmake_file} i386/x-cygwin" host_exeext=.exe ;; - i[34567]86-*-mingw32*) +# LLVM LOCAL begin mainline + i[34567]86-*-mingw32* | x86_64-*-mingw32*) +# LLVM LOCAL end mainline host_xm_file=i386/xm-mingw32.h host_xmake_file="${host_xmake_file} i386/x-mingw32" host_exeext=.exe Modified: llvm-gcc-4.2/trunk/gcc/config/i386/t-cygming URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/t-cygming?rev=50400&r1=50399&r2=50400&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/t-cygming (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/t-cygming Tue Apr 29 01:21:06 2008 @@ -29,6 +29,14 @@ $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ $(srcdir)/config/i386/winnt-stubs.c +# LLVM LOCAL begin mainline +msformat-c.o: $(srcdir)/config/i386/msformat-c.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ + $(TM_H) $(RTL_H) $(REGS_H) hard-reg-set.h output.h $(TREE_H) flags.h \ + $(TM_P_H) toplev.h $(HASHTAB_H) $(GGC_H) + $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ + $(srcdir)/config/i386/msformat-c.c +# LLVM LOCAL end mainline + STMP_FIXINC=stmp-fixinc # LLVM LOCAL begin mainline 125696 Modified: llvm-gcc-4.2/trunk/libstdc++-v3/configure URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libstdc%2B%2B-v3/configure?rev=50400&r1=50399&r2=50400&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/libstdc++-v3/configure (original) +++ llvm-gcc-4.2/trunk/libstdc++-v3/configure Tue Apr 29 01:21:06 2008 @@ -4207,7 +4207,7 @@ ;; cygwin* | mingw* |pw32*) - lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' + lt_cv_deplibs_check_method='file_magic file format pe*-i386(.*architecture: i386)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; Modified: llvm-gcc-4.2/trunk/libtool.m4 URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libtool.m4?rev=50400&r1=50399&r2=50400&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/libtool.m4 (original) +++ llvm-gcc-4.2/trunk/libtool.m4 Tue Apr 29 01:21:06 2008 @@ -663,7 +663,7 @@ ;; cygwin* | mingw* |pw32*) - lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' + lt_cv_deplibs_check_method='file_magic file format pe*-i386(.*architecture: i386)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; From asl at math.spbu.ru Tue Apr 29 01:21:42 2008 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Tue, 29 Apr 2008 06:21:42 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50401 - in /llvm-gcc-4.2/trunk/libiberty: pex-common.h pex-djgpp.c pex-msdos.c pex-unix.c pex-win32.c Message-ID: <200804290621.m3T6Lhbe006471@zion.cs.uiuc.edu> Author: asl Date: Tue Apr 29 01:21:42 2008 New Revision: 50401 URL: http://llvm.org/viewvc/llvm-project?rev=50401&view=rev Log: Backport from mainline. Win64-related changes to libiberty. Modified: llvm-gcc-4.2/trunk/libiberty/pex-common.h llvm-gcc-4.2/trunk/libiberty/pex-djgpp.c llvm-gcc-4.2/trunk/libiberty/pex-msdos.c llvm-gcc-4.2/trunk/libiberty/pex-unix.c llvm-gcc-4.2/trunk/libiberty/pex-win32.c Modified: llvm-gcc-4.2/trunk/libiberty/pex-common.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libiberty/pex-common.h?rev=50401&r1=50400&r2=50401&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/libiberty/pex-common.h (original) +++ llvm-gcc-4.2/trunk/libiberty/pex-common.h Tue Apr 29 01:21:42 2008 @@ -26,6 +26,14 @@ #include "libiberty.h" #include +/* LLVM LOCAL begin mainline */ +/* pid_t is may defined by config.h or sys/types.h needs to be + included. */ +#if !defined(pid_t) && defined(HAVE_SYS_TYPES_H) +#include +#endif +/* LLVM LOCAL end mainline */ + #define install_error_msg "installation problem, cannot exec `%s'" /* stdin file number. */ @@ -104,7 +112,9 @@ closed in the child process. The function should handle the PEX_STDERR_TO_STDOUT flag. Return >= 0 on success, or -1 on error and set *ERRMSG and *ERR. */ - long (*exec_child) (struct pex_obj *, int /* flags */, +/* LLVM LOCAL begin mainline */ + pid_t (*exec_child) (struct pex_obj *, int /* flags */, +/* LLVM LOCAL end mainline */ const char */* executable */, char * const * /* argv */, char * const * /* env */, int /* in */, int /* out */, int /* errdes */, @@ -116,7 +126,9 @@ and time in *TIME (if it is not null). CHILD is from fork. DONE is 1 if this is called via pex_free. ERRMSG and ERR are as in fork. Return 0 on success, -1 on error. */ - int (*wait) (struct pex_obj *, long /* child */, int * /* status */, +/* LLVM LOCAL begin mainline */ + int (*wait) (struct pex_obj *, pid_t /* child */, int * /* status */, +/* LLVM LOCAL end mainline */ struct pex_time * /* time */, int /* done */, const char ** /* errmsg */, int * /* err */); /* Create a pipe (only called if PEX_USE_PIPES is set) storing two Modified: llvm-gcc-4.2/trunk/libiberty/pex-djgpp.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libiberty/pex-djgpp.c?rev=50401&r1=50400&r2=50401&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/libiberty/pex-djgpp.c (original) +++ llvm-gcc-4.2/trunk/libiberty/pex-djgpp.c Tue Apr 29 01:21:42 2008 @@ -44,12 +44,16 @@ static int pex_djgpp_open_read (struct pex_obj *, const char *, int); static int pex_djgpp_open_write (struct pex_obj *, const char *, int); -static long pex_djgpp_exec_child (struct pex_obj *, int, const char *, +/* LLVM LOCAL begin mainline */ +static pid_t pex_djgpp_exec_child (struct pex_obj *, int, const char *, +/* LLVM LOCAL end mainline */ char * const *, char * const *, int, int, int, int, const char **, int *); static int pex_djgpp_close (struct pex_obj *, int); -static int pex_djgpp_wait (struct pex_obj *, long, int *, struct pex_time *, +/* LLVM LOCAL begin mainline */ +static int pex_djgpp_wait (struct pex_obj *, pid_t, int *, struct pex_time *, +/* LLVM LOCAL end mainline */ int, const char **, int *); /* The list of functions we pass to the common routines. */ @@ -110,7 +114,9 @@ /* Execute a child. */ -static long +/* LLVM LOCAL begin mainline */ +static pid_t +/* LLVM LOCAL end mainline */ pex_djgpp_exec_child (struct pex_obj *obj, int flags, const char *executable, char * const * argv, char * const * env, int in, int out, int errdes, @@ -132,19 +138,25 @@ { *err = errno; *errmsg = "dup"; - return -1; + /* LLVM LOCAL begin mainline */ + return (pid_t) -1; + /* LLVM LOCAL end mainline */ } if (dup2 (in, STDIN_FILE_NO) < 0) { *err = errno; *errmsg = "dup2"; - return -1; + /* LLVM LOCAL begin mainline */ + return (pid_t) -1; + /* LLVM LOCAL end mainline */ } if (close (in) < 0) { *err = errno; *errmsg = "close"; - return -1; + /* LLVM LOCAL begin mainline */ + return (pid_t) -1; + /* LLVM LOCAL end mainline */ } } @@ -155,19 +167,25 @@ { *err = errno; *errmsg = "dup"; - return -1; + /* LLVM LOCAL begin mainline */ + return (pid_t) -1; + /* LLVM LOCAL end mainline */ } if (dup2 (out, STDOUT_FILE_NO) < 0) { *err = errno; *errmsg = "dup2"; - return -1; + /* LLVM LOCAL begin mainline */ + return (pid_t) -1; + /* LLVM LOCAL end mainline */ } if (close (out) < 0) { *err = errno; *errmsg = "close"; - return -1; + /* LLVM LOCAL begin mainline */ + return (pid_t) -1; + /* LLVM LOCAL end mainline */ } } @@ -179,14 +197,18 @@ { *err = errno; *errmsg = "dup"; - return -1; + /* LLVM LOCAL begin mainline */ + return (pid_t) -1; + /* LLVM LOCAL end mainline */ } if (dup2 ((flags & PEX_STDERR_TO_STDOUT) != 0 ? STDOUT_FILE_NO : errdes, STDERR_FILE_NO) < 0) { *err = errno; *errmsg = "dup2"; - return -1; + /* LLVM LOCAL begin mainline */ + return (pid_t) -1; + /* LLVM LOCAL end mainline */ } if (errdes != STDERR_FILE_NO) { @@ -194,7 +216,9 @@ { *err = errno; *errmsg = "close"; - return -1; + /* LLVM LOCAL begin mainline */ + return (pid_t) -1; + /* LLVM LOCAL end mainline */ } } } @@ -218,13 +242,17 @@ { *err = errno; *errmsg = "dup2"; - return -1; + /* LLVM LOCAL begin mainline */ + return (pid_t) -1; + /* LLVM LOCAL end mainline */ } if (close (org_in) < 0) { *err = errno; *errmsg = "close"; - return -1; + /* LLVM LOCAL begin mainline */ + return (pid_t) -1; + /* LLVM LOCAL end mainline */ } } @@ -234,13 +262,17 @@ { *err = errno; *errmsg = "dup2"; - return -1; + /* LLVM LOCAL begin mainline */ + return (pid_t) -1; + /* LLVM LOCAL end mainline */ } if (close (org_out) < 0) { *err = errno; *errmsg = "close"; - return -1; + /* LLVM LOCAL begin mainline */ + return (pid_t) -1; + /* LLVM LOCAL end mainline */ } } @@ -251,13 +283,17 @@ { *err = errno; *errmsg = "dup2"; - return -1; + /* LLVM LOCAL begin mainline */ + return (pid_t) -1; + /* LLVM LOCAL end mainline */ } if (close (org_errdes) < 0) { *err = errno; *errmsg = "close"; - return -1; + /* LLVM LOCAL begin mainline */ + return (pid_t) -1; + /* LLVM LOCAL end mainline */ } } @@ -269,7 +305,9 @@ statuses[obj->count] = status; obj->sysdep = (void *) statuses; - return obj->count; + /* LLVM LOCAL begin mainline */ + return (pid_t) obj->count; + /* LLVM LOCAL end mainline */ } /* Wait for a child process to complete. Actually the child process @@ -277,7 +315,9 @@ status. */ static int -pex_djgpp_wait (struct pex_obj *obj, long pid, int *status, +/* LLVM LOCAL begin mainline */ +pex_djgpp_wait (struct pex_obj *obj, pid_t pid, int *status, +/* LLVM LOCAL end mainline */ struct pex_time *time, int done ATTRIBUTE_UNUSED, const char **errmsg ATTRIBUTE_UNUSED, int *err ATTRIBUTE_UNUSED) Modified: llvm-gcc-4.2/trunk/libiberty/pex-msdos.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libiberty/pex-msdos.c?rev=50401&r1=50400&r2=50401&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/libiberty/pex-msdos.c (original) +++ llvm-gcc-4.2/trunk/libiberty/pex-msdos.c Tue Apr 29 01:21:42 2008 @@ -54,12 +54,16 @@ static int pex_msdos_open (struct pex_obj *, const char *, int); static int pex_msdos_open (struct pex_obj *, const char *, int); static int pex_msdos_fdindex (struct pex_msdos *, int); -static long pex_msdos_exec_child (struct pex_obj *, int, const char *, +/* LLVM LOCAL begin mainline */ +static pid_t pex_msdos_exec_child (struct pex_obj *, int, const char *, +/* LLVM LOCAL end mainline */ char * const *, char * const *, int, int, int, int, int, const char **, int *); static int pex_msdos_close (struct pex_obj *, int); -static int pex_msdos_wait (struct pex_obj *, long, int *, struct pex_time *, +/* LLVM LOCAL begin mainline */ +static int pex_msdos_wait (struct pex_obj *, pid_t, int *, struct pex_time *, +/* LLVM LOCAL end mainline */ int, const char **, int *); static void pex_msdos_cleanup (struct pex_obj *); @@ -152,7 +156,9 @@ /* Execute a child. */ -static long +/* LLVM LOCAL begin mainline */ +static pid_t +/* LLVM LOCAL end mainline */ pex_msdos_exec_child (struct pex_obj *obj, int flags, const char *executable, char * const * argv, char * const * env, int in, int out, int toclose ATTRIBUTE_UNUSED, @@ -235,7 +241,9 @@ free (scmd); free (rf); *errmsg = "cannot open temporary command file"; - return -1; + /* LLVM LOCAL begin mainline */ + return (pid_t) -1; + /* LLVM LOCAL end mainline */ } for (i = 1; argv[i] != NULL; ++i) @@ -262,7 +270,9 @@ free (scmd); free (rf); *errmsg = "system"; - return -1; + /* LLVM LOCAL begin mainline */ + return (pid_t) -1; + /* LLVM LOCAL end mainline */ } remove (rf); @@ -275,7 +285,9 @@ ms->statuses = XRESIZEVEC(int, ms->statuses, obj->count + 1); ms->statuses[obj->count] = status; - return obj->count; + /* LLVM LOCAL begin mainline */ + return (pid_t) obj->count; + /* LLVM LOCAL end mainline */ } /* Wait for a child process to complete. Actually the child process @@ -283,7 +295,9 @@ status. */ static int -pex_msdos_wait (struct pex_obj *obj, long pid, int *status, +/* LLVM LOCAL begin mainline */ +pex_msdos_wait (struct pex_obj *obj, pid_t pid, int *status, +/* LLVM LOCAL end mainline */ struct pex_time *time, int done ATTRIBUTE_UNUSED, const char **errmsg ATTRIBUTE_UNUSED, int *err ATTRIBUTE_UNUSED) Modified: llvm-gcc-4.2/trunk/libiberty/pex-unix.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libiberty/pex-unix.c?rev=50401&r1=50400&r2=50401&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/libiberty/pex-unix.c (original) +++ llvm-gcc-4.2/trunk/libiberty/pex-unix.c Tue Apr 29 01:21:42 2008 @@ -84,15 +84,21 @@ time that it took. This is simple if we have wait4, slightly harder if we have waitpid, and is a pain if we only have wait. */ +/* LLVM LOCAL begin mainline */ static pid_t pex_wait (struct pex_obj *, pid_t, int *, struct pex_time *); +/* LLVM LOCAL end mainline */ #ifdef HAVE_WAIT4 +/* LLVM LOCAL begin mainline */ static pid_t pex_wait (struct pex_obj *obj ATTRIBUTE_UNUSED, pid_t pid, int *status, +/* LLVM LOCAL end mainline */ struct pex_time *time) { + /* LLVM LOCAL begin mainline */ pid_t ret; + /* LLVM LOCAL end mainline */ struct rusage r; #ifdef HAVE_WAITPID @@ -119,8 +125,10 @@ #ifndef HAVE_GETRUSAGE +/* LLVM LOCAL begin mainline */ static pid_t pex_wait (struct pex_obj *obj ATTRIBUTE_UNUSED, pid_t pid, int *status, +/* LLVM LOCAL end mainline */ struct pex_time *time) { if (time != NULL) @@ -130,12 +138,16 @@ #else /* defined (HAVE_GETRUSAGE) */ +/* LLVM LOCAL begin mainline */ static pid_t pex_wait (struct pex_obj *obj ATTRIBUTE_UNUSED, pid_t pid, int *status, +/* LLVM LOCAL end mainline */ struct pex_time *time) { struct rusage r1, r2; + /* LLVM LOCAL begin mainline */ pid_t ret; + /* LLVM LOCAL end mainline */ if (time == NULL) return waitpid (pid, status, 0); @@ -174,13 +186,17 @@ struct status_list { struct status_list *next; + /* LLVM LOCAL begin mainline */ pid_t pid; + /* LLVM LOCAL end mainline */ int status; struct pex_time time; }; +/* LLVM LOCAL begin mainline */ static pid_t pex_wait (struct pex_obj *obj, pid_t pid, int *status, struct pex_time *time) +/* LLVM LOCAL end mainline */ { struct status_list **pp; @@ -204,7 +220,9 @@ while (1) { + /* LLVM LOCAL begin mainline */ pid_t cpid; + /* LLVM LOCAL end mainline */ struct status_list *psl; struct pex_time pt; #ifdef HAVE_GETRUSAGE @@ -269,12 +287,16 @@ ATTRIBUTE_NORETURN; static int pex_unix_open_read (struct pex_obj *, const char *, int); static int pex_unix_open_write (struct pex_obj *, const char *, int); -static long pex_unix_exec_child (struct pex_obj *, int, const char *, +/* LLVM LOCAL begin mainline */ +static pid_t pex_unix_exec_child (struct pex_obj *, int, const char *, +/* LLVM LOCAL end mainline */ char * const *, char * const *, int, int, int, int, const char **, int *); static int pex_unix_close (struct pex_obj *, int); -static int pex_unix_wait (struct pex_obj *, long, int *, struct pex_time *, +/* LLVM LOCAL begin mainline */ +static int pex_unix_wait (struct pex_obj *, pid_t, int *, struct pex_time *, +/* LLVM LOCAL end mainline */ int, const char **, int *); static int pex_unix_pipe (struct pex_obj *, int *, int); static FILE *pex_unix_fdopenr (struct pex_obj *, int, int); @@ -355,13 +377,17 @@ extern char **environ; -static long +/* LLVM LOCAL begin mainline */ +static pid_t pex_unix_exec_child (struct pex_obj *obj, int flags, const char *executable, +/* LLVM LOCAL end mainline */ char * const * argv, char * const * env, int in, int out, int errdes, int toclose, const char **errmsg, int *err) { + /* LLVM LOCAL begin mainline */ pid_t pid; + /* LLVM LOCAL end mainline */ /* We declare these to be volatile to avoid warnings from gcc about them being clobbered by vfork. */ @@ -384,7 +410,9 @@ case -1: *err = errno; *errmsg = VFORK_STRING; - return -1; + /* LLVM LOCAL begin mainline */ + return (pid_t) -1; + /* LLVM LOCAL end mainline */ case 0: /* Child process. */ @@ -435,7 +463,9 @@ } /* NOTREACHED */ - return -1; + /* LLVM LOCAL begin mainline */ + return (pid_t) -1; + /* LLVM LOCAL end mainline */ default: /* Parent process. */ @@ -445,7 +475,9 @@ { *err = errno; *errmsg = "close"; - return -1; + /* LLVM LOCAL begin mainline */ + return (pid_t) -1; + /* LLVM LOCAL end mainline */ } } if (out != STDOUT_FILE_NO) @@ -454,7 +486,9 @@ { *err = errno; *errmsg = "close"; - return -1; + /* LLVM LOCAL begin mainline */ + return (pid_t) -1; + /* LLVM LOCAL end mainline */ } } if (errdes != STDERR_FILE_NO) @@ -463,18 +497,22 @@ { *err = errno; *errmsg = "close"; - return -1; + /* LLVM LOCAL begin mainline */ + return (pid_t) -1; + /* LLVM LOCAL end mainline */ } } - return (long) pid; + return pid; } } /* Wait for a child process to complete. */ static int -pex_unix_wait (struct pex_obj *obj, long pid, int *status, +/* LLVM LOCAL begin mainline */ +pex_unix_wait (struct pex_obj *obj, pid_t pid, int *status, +/* LLVM LOCAL end mainline */ struct pex_time *time, int done, const char **errmsg, int *err) { Modified: llvm-gcc-4.2/trunk/libiberty/pex-win32.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libiberty/pex-win32.c?rev=50401&r1=50400&r2=50401&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/libiberty/pex-win32.c (original) +++ llvm-gcc-4.2/trunk/libiberty/pex-win32.c Tue Apr 29 01:21:42 2008 @@ -79,12 +79,16 @@ static int pex_win32_open_read (struct pex_obj *, const char *, int); static int pex_win32_open_write (struct pex_obj *, const char *, int); -static long pex_win32_exec_child (struct pex_obj *, int, const char *, +/* LLVM LOCAL begin mainline */ +static pid_t pex_win32_exec_child (struct pex_obj *, int, const char *, +/* LLVM LOCAL end mainline */ char * const *, char * const *, int, int, int, int, const char **, int *); static int pex_win32_close (struct pex_obj *, int); -static int pex_win32_wait (struct pex_obj *, long, int *, +/* LLVM LOCAL begin mainline */ +static int pex_win32_wait (struct pex_obj *, pid_t, int *, +/* LLVM LOCAL end mainline */ struct pex_time *, int, const char **, int *); static int pex_win32_pipe (struct pex_obj *, int *, int); static FILE *pex_win32_fdopenr (struct pex_obj *, int, int); @@ -521,7 +525,9 @@ return c1 - c2; } -static long +/* LLVM LOCAL begin mainline */ +static pid_t +/* LLVM LOCAL end mainline */ win32_spawn (const char *executable, BOOL search, char *const *argv, @@ -596,7 +602,9 @@ free (full_executable); - return -1; + /* LLVM LOCAL begin mainline */ + return (pid_t) -1; + /* LLVM LOCAL end mainline */ } /* Clean up. */ @@ -605,7 +613,9 @@ if (env_block) free (env_block); - return (long) pi->hProcess; + /* LLVM LOCAL begin mainline */ + return (pid_t) pi->hProcess; + /* LLVM LOCAL end mainline */ error: if (env_block) @@ -615,17 +625,23 @@ if (full_executable) free (full_executable); - return -1; + /* LLVM LOCAL begin mainline */ + return (pid_t) -1; + /* LLVM LOCAL end mainline */ } -static long +/* LLVM LOCAL begin mainline */ +static pid_t +/* LLVM LOCAL end mainline */ spawn_script (const char *executable, char *const *argv, char* const *env, DWORD dwCreationFlags, LPSTARTUPINFO si, LPPROCESS_INFORMATION pi) { - int pid = -1; + /* LLVM LOCAL begin mainline */ + pid_t pid = (pid_t) -1; + /* LLVM LOCAL end mainline */ int save_errno = errno; int fd = _open (executable, _O_RDONLY); @@ -672,7 +688,7 @@ dwCreationFlags, si, pi); if (executable1 != newex) free ((char *) newex); - if (pid < 0) + if ((long) pid < 0) { newex = msys_rootify (executable1); if (newex != executable1) @@ -688,14 +704,16 @@ } } } - if (pid < 0) + if ((long) pid < 0) errno = save_errno; return pid; } /* Execute a child. */ -static long +/* LLVM LOCAL begin mainline */ +static pid_t +/* LLVM LOCAL end mainline */ pex_win32_exec_child (struct pex_obj *obj ATTRIBUTE_UNUSED, int flags, const char *executable, char * const * argv, char* const* env, @@ -704,7 +722,9 @@ const char **errmsg, int *err) { - long pid; + /* LLVM LOCAL begin mainline */ + pid_t pid; + /* LLVM LOCAL end mainline */ HANDLE stdin_handle; HANDLE stdout_handle; HANDLE stderr_handle; @@ -779,10 +799,14 @@ /* Create the child process. */ pid = win32_spawn (executable, (flags & PEX_SEARCH) != 0, argv, env, dwCreationFlags, &si, &pi); - if (pid == -1) + /* LLVM LOCAL begin mainline */ + if (pid == (pid_t) -1) + /* LLVM LOCAL end mainline */ pid = spawn_script (executable, argv, env, dwCreationFlags, &si, &pi); - if (pid == -1) + /* LLVM LOCAL begin mainline */ + if (pid == (pid_t) -1) + /* LLVM LOCAL end mainline */ { *err = ENOENT; *errmsg = "CreateProcess"; @@ -807,7 +831,9 @@ macros. Note that WIFSIGNALED will never be true under CRTDLL. */ static int -pex_win32_wait (struct pex_obj *obj ATTRIBUTE_UNUSED, long pid, +/* LLVM LOCAL begin mainline */ +pex_win32_wait (struct pex_obj *obj ATTRIBUTE_UNUSED, pid_t pid, +/* LLVM LOCAL end mainline */ int *status, struct pex_time *time, int done ATTRIBUTE_UNUSED, const char **errmsg, int *err) { @@ -882,7 +908,9 @@ char const *errmsg; int err; argv++; - printf ("%ld\n", pex_win32_exec_child (NULL, PEX_SEARCH, argv[0], argv, NULL, 0, 0, 1, 2, &errmsg, &err)); + /* LLVM LOCAL begin mainline */ + printf ("%ld\n", (long) pex_win32_exec_child (NULL, PEX_SEARCH, argv[0], argv, NULL, 0, 0, 1, 2, &errmsg, &err)); + /* LLVM LOCAL end mainline */ exit (0); } #endif From asl at math.spbu.ru Tue Apr 29 01:22:10 2008 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Tue, 29 Apr 2008 06:22:10 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50402 - /llvm-gcc-4.2/trunk/gcc/config/i386/cygwin.asm Message-ID: <200804290622.m3T6MAot006492@zion.cs.uiuc.edu> Author: asl Date: Tue Apr 29 01:22:09 2008 New Revision: 50402 URL: http://llvm.org/viewvc/llvm-project?rev=50402&view=rev Log: Backport from mainline. Provide win64 version of __alloca() Modified: llvm-gcc-4.2/trunk/gcc/config/i386/cygwin.asm Modified: llvm-gcc-4.2/trunk/gcc/config/i386/cygwin.asm URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/cygwin.asm?rev=50402&r1=50401&r2=50402&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/cygwin.asm (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/cygwin.asm Tue Apr 29 01:22:09 2008 @@ -42,27 +42,97 @@ .global ___chkstk .global __alloca +/* LLVM LOCAL begin mainline */ +#ifndef _WIN64 ___chkstk: __alloca: - pushl %ecx /* save temp */ - movl %esp,%ecx /* get sp */ - addl $0x8,%ecx /* and point to return addr */ - -probe: cmpl $0x1000,%eax /* > 4k ?*/ - jb done - - subl $0x1000,%ecx /* yes, move pointer down 4k*/ - orl $0x0,(%ecx) /* probe there */ - subl $0x1000,%eax /* decrement count */ - jmp probe /* and do it again */ - -done: subl %eax,%ecx - orl $0x0,(%ecx) /* less that 4k, just peek here */ - - movl %esp,%eax - movl %ecx,%esp /* decrement stack */ - - movl (%eax),%ecx /* recover saved temp */ - movl 4(%eax),%eax /* get return address */ - jmp *%eax + pushl %ecx /* save temp */ + leal 8(%esp), %ecx /* point past return addr */ + cmpl $0x1000, %eax /* > 4k ?*/ + jb Ldone + +Lprobe: + subl $0x1000, %ecx /* yes, move pointer down 4k*/ + orl $0x0, (%ecx) /* probe there */ + subl $0x1000, %eax /* decrement count */ + cmpl $0x1000, %eax + ja Lprobe /* and do it again */ + +Ldone: + subl %eax, %ecx + orl $0x0, (%ecx) /* less than 4k, just peek here */ + + movl %esp, %eax /* save old stack pointer */ + movl %ecx, %esp /* decrement stack */ + movl (%eax), %ecx /* recover saved temp */ + movl 4(%eax), %eax /* recover return address */ + + /* Push the return value back. Doing this instead of just + jumping to %eax preserves the cached call-return stack + used by most modern processors. */ + pushl %eax + ret +#else +/* __alloca is a normal function call, which uses %rcx as the argument. And stack space + for the argument is saved. */ +__alloca: + movq %rcx, %rax + addq $0x7, %rax + andq $0xfffffffffffffff8, %rax + popq %rcx /* pop return address */ + popq %r10 /* Pop the reserved stack space. */ + movq %rsp, %r10 /* get sp */ + cmpq $0x1000, %rax /* > 4k ?*/ + jb Ldone_alloca + +Lprobe_alloca: + subq $0x1000, %r10 /* yes, move pointer down 4k*/ + orq $0x0, (%r10) /* probe there */ + subq $0x1000, %rax /* decrement count */ + cmpq $0x1000, %rax + ja Lprobe_alloca /* and do it again */ + +Ldone_alloca: + subq %rax, %r10 + orq $0x0, (%r10) /* less than 4k, just peek here */ + movq %r10, %rax + subq $0x8, %r10 /* Reserve argument stack space. */ + movq %r10, %rsp /* decrement stack */ + + /* Push the return value back. Doing this instead of just + jumping to %rcx preserves the cached call-return stack + used by most modern processors. */ + pushq %rcx + ret + +/* ___chkstk is a *special* function call, which uses %rax as the argument. + We avoid clobbering the 4 integer argument registers, %rcx, %rdx, + %r8 and %r9, which leaves us with %rax, %r10, and %r11 to use. */ +___chkstk: + addq $0x7, %rax /* Make sure stack is on alignment of 8. */ + andq $0xfffffffffffffff8, %rax + popq %r11 /* pop return address */ + movq %rsp, %r10 /* get sp */ + cmpq $0x1000, %rax /* > 4k ?*/ + jb Ldone + +Lprobe: + subq $0x1000, %r10 /* yes, move pointer down 4k*/ + orl $0x0, (%r10) /* probe there */ + subq $0x1000, %rax /* decrement count */ + cmpq $0x1000, %rax + ja Lprobe /* and do it again */ + +Ldone: + subq %rax, %r10 + orl $0x0, (%r10) /* less than 4k, just peek here */ + movq %r10, %rsp /* decrement stack */ + + /* Push the return value back. Doing this instead of just + jumping to %r11 preserves the cached call-return stack + used by most modern processors. */ + pushq %r11 + ret +#endif +/* LLVM LOCAL end mainline */ #endif From asl at math.spbu.ru Tue Apr 29 01:22:43 2008 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Tue, 29 Apr 2008 06:22:43 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50403 - in /llvm-gcc-4.2/trunk/gcc: config/i386/gthr-win32.c gthr-win32.h Message-ID: <200804290622.m3T6MhrB006518@zion.cs.uiuc.edu> Author: asl Date: Tue Apr 29 01:22:42 2008 New Revision: 50403 URL: http://llvm.org/viewvc/llvm-project?rev=50403&view=rev Log: Backport from mainline Modified: llvm-gcc-4.2/trunk/gcc/config/i386/gthr-win32.c llvm-gcc-4.2/trunk/gcc/gthr-win32.h Modified: llvm-gcc-4.2/trunk/gcc/config/i386/gthr-win32.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/gthr-win32.c?rev=50403&r1=50402&r2=50403&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/gthr-win32.c (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/gthr-win32.c Tue Apr 29 01:22:42 2008 @@ -102,7 +102,10 @@ C++ EH. Mingw uses a thread-support DLL to work-around this problem. */ int -__gthr_win32_key_create (__gthread_key_t *key, void (*dtor) (void *)) +__gthr_win32_key_create (__gthread_key_t *key, +/* LLVM LOCAL begin mainline */ + void (*dtor) (void *) __attribute__((unused))) +/* LLVM LOCAL end mainline */ { int status = 0; DWORD tls_index = TlsAlloc (); Modified: llvm-gcc-4.2/trunk/gcc/gthr-win32.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/gthr-win32.h?rev=50403&r1=50402&r2=50403&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/gthr-win32.h (original) +++ llvm-gcc-4.2/trunk/gcc/gthr-win32.h Tue Apr 29 01:22:42 2008 @@ -562,7 +562,10 @@ leaks, especially in threaded applications making extensive use of C++ EH. Mingw uses a thread-support DLL to work-around this problem. */ static inline int -__gthread_key_create (__gthread_key_t *key, void (*dtor) (void *)) +__gthread_key_create (__gthread_key_t *key, +/* LLVM LOCAL begin mainline */ + void (*dtor) (void *) __attribute__((unused))) +/* LLVM LOCAL end mainline */ { int status = 0; DWORD tls_index = TlsAlloc (); From asl at math.spbu.ru Tue Apr 29 01:23:26 2008 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Tue, 29 Apr 2008 06:23:26 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50404 - in /llvm-gcc-4.2/trunk/gcc: c-format.c c-format.h config/i386/msformat-c.c doc/extend.texi doc/tm.texi Message-ID: <200804290623.m3T6NRAB006547@zion.cs.uiuc.edu> Author: asl Date: Tue Apr 29 01:23:26 2008 New Revision: 50404 URL: http://llvm.org/viewvc/llvm-project?rev=50404&view=rev Log: Backport from mainine. Use MS-style for format specifiers. Added: llvm-gcc-4.2/trunk/gcc/config/i386/msformat-c.c Modified: llvm-gcc-4.2/trunk/gcc/c-format.c llvm-gcc-4.2/trunk/gcc/c-format.h llvm-gcc-4.2/trunk/gcc/doc/extend.texi llvm-gcc-4.2/trunk/gcc/doc/tm.texi Modified: llvm-gcc-4.2/trunk/gcc/c-format.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/c-format.c?rev=50404&r1=50403&r2=50404&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/c-format.c (original) +++ llvm-gcc-4.2/trunk/gcc/c-format.c Tue Apr 29 01:23:26 2008 @@ -63,13 +63,13 @@ gcc_diag_format_type, gcc_tdiag_format_type, gcc_cdiag_format_type, gcc_cxxdiag_format_type, gcc_gfc_format_type, - scanf_format_type, strftime_format_type, /* APPLE LOCAL begin radar 4985544 */ - strfmon_format_type, nsstring_format_type, - /* APPLE LOCAL radar 5096648 */ - cfstring_format_type, - format_type_error = -1}; + nsstring_format_type, /* APPLE LOCAL end radar 4985544 */ + /* APPLE LOCAL begin radar 5096648 */ + cfstring_format_type, + /* APPLE LOCAL end radar 5096648 */ + format_type_error = -1}; typedef struct function_format_info { @@ -87,6 +87,10 @@ static bool get_constant (tree expr, unsigned HOST_WIDE_INT *value, int validated_p); +/* LLVM LOCAL begin mainline */ +static const char *convert_format_name_to_system_name (const char *attr_name); +static bool cmp_attribs (const char *tattr_name, const char *attr_name); +/* LLVM LOCAL end mainline */ /* Handle a "format_arg" attribute; arguments as in struct attribute_spec.handler. */ @@ -209,6 +213,10 @@ { const char *p = IDENTIFIER_POINTER (format_type_id); + /* LLVM LOCAL begin mainline */ + p = convert_format_name_to_system_name (p); + /* LLVM LOCAL end mainline */ + info->format_type = decode_format_type (p); /* APPLE LOCAL begin radar 4985544 */ @@ -725,7 +733,9 @@ /* This must be in the same order as enum format_type. */ static const format_kind_info format_types_orig[] = { - { "printf", printf_length_specs, print_char_table, " +#0-'I", NULL, + /* LLVM LOCAL begin mainline */ + { "gnu_printf", printf_length_specs, print_char_table, " +#0-'I", NULL, + /* LLVM LOCAL end mainline */ printf_flag_specs, printf_flag_pairs, FMT_FLAG_ARG_CONVERT|FMT_FLAG_DOLLAR_MULTIPLE|FMT_FLAG_USE_DOLLAR|FMT_FLAG_EMPTY_PREC_OK, 'w', 0, 'p', 0, 'L', @@ -767,23 +777,29 @@ 0, 0, 0, 0, 0, NULL, NULL }, - { "scanf", scanf_length_specs, scan_char_table, "*'I", NULL, + /* LLVM LOCAL begin mainline */ + { "gnu_scanf", scanf_length_specs, scan_char_table, "*'I", NULL, + /* LLVM LOCAL end mainline */ scanf_flag_specs, scanf_flag_pairs, FMT_FLAG_ARG_CONVERT|FMT_FLAG_SCANF_A_KLUDGE|FMT_FLAG_USE_DOLLAR|FMT_FLAG_ZERO_WIDTH_BAD|FMT_FLAG_DOLLAR_GAP_POINTER_OK, 'w', 0, 0, '*', 'L', NULL, NULL }, - { "strftime", NULL, time_char_table, "_-0^#", "EO", + /* LLVM LOCAL begin mainline */ + { "gnu_strftime", NULL, time_char_table, "_-0^#", "EO", + /* LLVM LOCAL end mainline */ strftime_flag_specs, strftime_flag_pairs, FMT_FLAG_FANCY_PERCENT_OK, 'w', 0, 0, 0, 0, NULL, NULL }, - { "strfmon", strfmon_length_specs, monetary_char_table, "=^+(!-", NULL, + /* LLVM LOCAL begin mainline */ + { "gnu_strfmon", strfmon_length_specs, monetary_char_table, "=^+(!-", NULL, + /* LLVM LOCAL end mainline */ strfmon_flag_specs, strfmon_flag_pairs, FMT_FLAG_ARG_CONVERT, 'w', '#', 'p', 0, 'L', NULL, NULL -/* APPLE LOCAL begin radar 4985544 */ }, + /* APPLE LOCAL begin radar 4985544 */ { "NSString", NULL, NULL, NULL, NULL, NULL, NULL, FMT_FLAG_ARG_CONVERT, 0, 0, 0, 0, 0, @@ -871,6 +887,10 @@ { int i; int slen; + + /* LLVM LOCAL begin mainline */ + s = convert_format_name_to_system_name (s); + /* LLVM LOCAL end mainline */ slen = strlen (s); for (i = 0; i < n_format_types; i++) { @@ -1805,8 +1825,25 @@ length_chars_std = STD_C89; if (fli) { + /* LLVM LOCAL begin mainline */ while (fli->name != 0 && fli->name[0] != *format_chars) - fli++; + { + if (fli->name[0] == '\0') + { + int si = strlen (fli->name + 1) + 1; + int i = 1; + while (fli->name[i] != 0 && fli->name[i] == format_chars [i - 1]) + ++i; + if (si == i) + { + if (si > 2) + format_chars += si - 2; + break; + } + } + fli++; + } + /* LLVM LOCAL end mainline */ if (fli->name != 0) { format_chars++; @@ -2748,6 +2785,86 @@ extern const format_kind_info TARGET_FORMAT_TYPES[]; #endif +/* LLVM LOCAL begin mainline */ +#ifdef TARGET_OVERRIDES_FORMAT_ATTRIBUTES +extern const target_ovr_attr TARGET_OVERRIDES_FORMAT_ATTRIBUTES[]; +#endif + +/* Attributes such as "printf" are equivalent to those such as + "gnu_printf" unless this is overridden by a target. */ +static const target_ovr_attr gnu_target_overrides_format_attributes[] = +{ + { "gnu_printf", "printf" }, + { "gnu_scanf", "scanf" }, + { "gnu_strftime", "strftime" }, + { "gnu_strfmon", "strfmon" }, + { NULL, NULL } +}; + +/* Translate to unified attribute name. This is used in decode_format_type and + decode_format_attr. In attr_name the user specified argument is passed. It + returns the unified format name from TARGET_OVERRIDES_FORMAT_ATTRIBUTES + or the attr_name passed to this function, if there is no matching entry. */ +static const char * +convert_format_name_to_system_name (const char *attr_name) +{ + int i; + + if (attr_name == NULL || *attr_name == 0 + || strncmp (attr_name, "gcc_", 4) == 0) + return attr_name; + +#ifdef TARGET_OVERRIDES_FORMAT_ATTRIBUTES + /* Check if format attribute is overridden by target. */ + if (TARGET_OVERRIDES_FORMAT_ATTRIBUTES != NULL + && TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT > 0) + { + for (i = 0; i < TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT; ++i) + { + if (cmp_attribs (TARGET_OVERRIDES_FORMAT_ATTRIBUTES[i].named_attr_src, + attr_name)) + return attr_name; + if (cmp_attribs (TARGET_OVERRIDES_FORMAT_ATTRIBUTES[i].named_attr_dst, + attr_name)) + return TARGET_OVERRIDES_FORMAT_ATTRIBUTES[i].named_attr_src; + } + } +#endif + /* Otherwise default to gnu format. */ + for (i = 0; + gnu_target_overrides_format_attributes[i].named_attr_src != NULL; + ++i) + { + if (cmp_attribs (gnu_target_overrides_format_attributes[i].named_attr_src, + attr_name)) + return attr_name; + if (cmp_attribs (gnu_target_overrides_format_attributes[i].named_attr_dst, + attr_name)) + return gnu_target_overrides_format_attributes[i].named_attr_src; + } + + return attr_name; +} + +/* Return true if TATTR_NAME and ATTR_NAME are the same format attribute, + counting "name" and "__name__" as the same, false otherwise. */ +static bool +cmp_attribs (const char *tattr_name, const char *attr_name) +{ + int alen = strlen (attr_name); + int slen = (tattr_name ? strlen (tattr_name) : 0); + if (alen > 4 && attr_name[0] == '_' && attr_name[1] == '_' + && attr_name[alen - 1] == '_' && attr_name[alen - 2] == '_') + { + attr_name += 2; + alen -= 4; + } + if (alen != slen || strncmp (tattr_name, attr_name, alen) != 0) + return false; + return true; +} +/* LLVM LOCAL end mainline */ + /* Handle a "format" attribute; arguments as in struct attribute_spec.handler. */ tree @@ -2822,7 +2939,12 @@ } } - if (info.format_type == strftime_format_type && info.first_arg_num != 0) + /* LLVM LOCAL begin mainline */ + /* Check if this is a strftime variant. Just for this variant + FMT_FLAG_ARG_CONVERT is not set. */ + if ((format_types[info.format_type].flags & (int) FMT_FLAG_ARG_CONVERT) == 0 + && info.first_arg_num != 0) + /* LLVM LOCAL end mainline */ { error ("strftime formats cannot format arguments"); *no_add_attrs = true; Modified: llvm-gcc-4.2/trunk/gcc/c-format.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/c-format.h?rev=50404&r1=50403&r2=50404&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/c-format.h (original) +++ llvm-gcc-4.2/trunk/gcc/c-format.h Tue Apr 29 01:23:26 2008 @@ -81,12 +81,15 @@ of whether length modifiers can occur (length_char_specs). */ }; - /* Structure describing a length modifier supported in format checking, and possibly a doubled version such as "hh". */ typedef struct { - /* Name of the single-character length modifier. */ + /* LLVM LOCAL begin mainline */ + /* Name of the single-character length modifier. If prefixed by + a zero character, it describes a multi character length + modifier, like I64, I32, etc. */ + /* LLVM LOCAL end mainline */ const char *name; /* Index into a format_char_info.types array. */ enum format_lengths index; @@ -305,4 +308,18 @@ #define T_D128 &dfloat128_type_node #define TEX_D128 { STD_EXT, "_Decimal128", T_D128 } +/* LLVM LOCAL begin mainline */ +/* Structure describing how format attributes such as "printf" are + interpreted as "gnu_printf" or "ms_printf" on a particular system. + TARGET_OVERRIDES_FORMAT_ATTRIBUTES is used to specify target-specific + defaults. */ +typedef struct +{ + /* The name of the to be copied format attribute. */ + const char *named_attr_src; + /* The name of the to be overridden format attribute. */ + const char *named_attr_dst; +} target_ovr_attr; +/* LLVM LOCAL end mainline */ + #endif /* GCC_C_FORMAT_H */ Added: llvm-gcc-4.2/trunk/gcc/config/i386/msformat-c.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/msformat-c.c?rev=50404&view=auto ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/msformat-c.c (added) +++ llvm-gcc-4.2/trunk/gcc/config/i386/msformat-c.c Tue Apr 29 01:23:26 2008 @@ -0,0 +1,175 @@ +/* Check calls to formatted I/O functions (-Wformat). + Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, + 2001, 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tm.h" +#include "tree.h" +#include "flags.h" +#include "c-common.h" +#include "toplev.h" +#include "intl.h" +#include "diagnostic.h" +#include "langhooks.h" +#include "c-format.h" +#include "alloc-pool.h" + +/* Mingw specific format attributes ms_printf, ms_scanf, and ms_strftime. */ + +static const format_length_info ms_printf_length_specs[] = +{ + { "h", FMT_LEN_h, STD_C89, NULL, 0, 0 }, + { "l", FMT_LEN_l, STD_C89, NULL, 0, 0 }, + { "I32", FMT_LEN_l, STD_EXT, NULL, 0, 0 }, + { "I64", FMT_LEN_ll, STD_EXT, NULL, 0, 0 }, + { "I", FMT_LEN_L, STD_EXT, NULL, 0, 0 }, + { NULL, 0, 0, NULL, 0, 0 } +}; + +static const format_flag_spec ms_printf_flag_specs[] = +{ + { ' ', 0, 0, N_("' ' flag"), N_("the ' ' printf flag"), STD_C89 }, + { '+', 0, 0, N_("'+' flag"), N_("the '+' printf flag"), STD_C89 }, + { '#', 0, 0, N_("'#' flag"), N_("the '#' printf flag"), STD_C89 }, + { '0', 0, 0, N_("'0' flag"), N_("the '0' printf flag"), STD_C89 }, + { '-', 0, 0, N_("'-' flag"), N_("the '-' printf flag"), STD_C89 }, + { '\'', 0, 0, N_("''' flag"), N_("the ''' printf flag"), STD_EXT }, + { 'w', 0, 0, N_("field width"), N_("field width in printf format"), STD_C89 }, + { 'p', 0, 0, N_("precision"), N_("precision in printf format"), STD_C89 }, + { 'L', 0, 0, N_("length modifier"), N_("length modifier in printf format"), STD_C89 }, + { 0, 0, 0, NULL, NULL, 0 } +}; + +static const format_flag_pair ms_printf_flag_pairs[] = +{ + { ' ', '+', 1, 0 }, + { '0', '-', 1, 0 }, { '0', 'p', 1, 'i' }, + { 0, 0, 0, 0 } +}; + +static const format_flag_spec ms_scanf_flag_specs[] = +{ + { '*', 0, 0, N_("assignment suppression"), N_("the assignment suppression scanf feature"), STD_C89 }, + { 'a', 0, 0, N_("'a' flag"), N_("the 'a' scanf flag"), STD_EXT }, + { 'w', 0, 0, N_("field width"), N_("field width in scanf format"), STD_C89 }, + { 'L', 0, 0, N_("length modifier"), N_("length modifier in scanf format"), STD_C89 }, + { '\'', 0, 0, N_("''' flag"), N_("the ''' scanf flag"), STD_EXT }, + { 0, 0, 0, NULL, NULL, 0 } +}; + +static const format_flag_pair ms_scanf_flag_pairs[] = +{ + { '*', 'L', 0, 0 }, + { 0, 0, 0, 0 } +}; + +static const format_flag_spec ms_strftime_flag_specs[] = +{ + { '#', 0, 0, N_("'#' flag"), N_("the '#' strftime flag"), STD_EXT }, + { 0, 0, 0, NULL, NULL, 0 } +}; + +static const format_flag_pair ms_strftime_flag_pairs[] = +{ + { 0, 0, 0, 0 } +}; + +static const format_char_info ms_print_char_table[] = +{ + /* C89 conversion specifiers. */ + { "di", 0, STD_C89, { T89_I, BADLEN, T89_S, T89_L, T9L_LL, T99_SST, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0 +'", "i", NULL }, + { "oxX", 0, STD_C89, { T89_UI, BADLEN, T89_US, T89_UL, T9L_ULL, T99_ST, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0#", "i", NULL }, + { "u", 0, STD_C89, { T89_UI, BADLEN, T89_US, T89_UL, T9L_ULL, T99_ST, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0'", "i", NULL }, + { "fgG", 0, STD_C89, { T89_D, BADLEN, BADLEN, T99_D, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0 +#'", "", NULL }, + { "eE", 0, STD_C89, { T89_D, BADLEN, BADLEN, T99_D, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0 +#", "", NULL }, + { "c", 0, STD_C89, { T89_I, BADLEN, T89_S, T94_WI, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-w", "", NULL }, + { "s", 1, STD_C89, { T89_C, BADLEN, T89_S, T94_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "cR", NULL }, + { "p", 1, STD_C89, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-w", "c", NULL }, + { "n", 1, STD_C89, { T89_I, BADLEN, T89_S, T89_L, T9L_LL, BADLEN, BADLEN, BADLEN, T99_IM, BADLEN, BADLEN, BADLEN }, "", "W", NULL }, + /* X/Open conversion specifiers. */ + { "C", 0, STD_EXT, { TEX_WI, BADLEN, T89_S, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-w", "", NULL }, + { "S", 1, STD_EXT, { TEX_W, BADLEN, T89_S, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "R", NULL }, + { NULL, 0, 0, NOLENGTHS, NULL, NULL, NULL } +}; + +static const format_char_info ms_scan_char_table[] = +{ + /* C89 conversion specifiers. */ + { "di", 1, STD_C89, { T89_I, BADLEN, T89_S, T89_L, T9L_LL, T99_SST, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w'", "W", NULL }, + { "u", 1, STD_C89, { T89_UI, BADLEN, T89_US, T89_UL, T9L_ULL, T99_ST, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w'", "W", NULL }, + { "oxX", 1, STD_C89, { T89_UI, BADLEN, T89_US, T89_UL, T9L_ULL, T99_ST, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w", "W", NULL }, + { "efgEG", 1, STD_C89, { T89_F, BADLEN, BADLEN, T89_D, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w'", "W", NULL }, + { "c", 1, STD_C89, { T89_C, BADLEN, T89_S, T94_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w", "cW", NULL }, + { "s", 1, STD_C89, { T89_C, BADLEN, T89_S, T94_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*aw", "cW", NULL }, + { "[", 1, STD_C89, { T89_C, BADLEN, BADLEN, T94_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*aw", "cW[", NULL }, + { "p", 2, STD_C89, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w", "W", NULL }, + { "n", 1, STD_C89, { T89_I, BADLEN, T89_S, T89_L, T9L_LL, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "W", NULL }, + /* X/Open conversion specifiers. */ + { "C", 1, STD_EXT, { TEX_W, BADLEN, T89_S, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w", "W", NULL }, + { "S", 1, STD_EXT, { TEX_W, BADLEN, T89_S, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*aw", "W", NULL }, + { NULL, 0, 0, NOLENGTHS, NULL, NULL, NULL } +}; + +static const format_char_info ms_time_char_table[] = +{ + /* C89 conversion specifiers. */ + { "ABZab", 0, STD_C89, NOLENGTHS, "#", "", NULL }, + { "cx", 0, STD_C89, NOLENGTHS, "#", "3", NULL }, + { "HIMSUWdmw", 0, STD_C89, NOLENGTHS, "#", "", NULL }, + { "j", 0, STD_C89, NOLENGTHS, "#", "", NULL }, + { "p", 0, STD_C89, NOLENGTHS, "#", "", NULL }, + { "X", 0, STD_C89, NOLENGTHS, "#", "", NULL }, + { "y", 0, STD_C89, NOLENGTHS, "#", "4", NULL }, + { "Y", 0, STD_C89, NOLENGTHS, "#", "", NULL }, + { "%", 0, STD_C89, NOLENGTHS, "", "", NULL }, + /* C99 conversion specifiers. */ + { "z", 0, STD_C99, NOLENGTHS, "#", "", NULL }, + { NULL, 0, 0, NOLENGTHS, NULL, NULL, NULL } +}; + +const format_kind_info mingw_format_attributes[3] = +{ + { "ms_printf", ms_printf_length_specs, ms_print_char_table, " +#0-'", NULL, + ms_printf_flag_specs, ms_printf_flag_pairs, + FMT_FLAG_ARG_CONVERT|FMT_FLAG_DOLLAR_MULTIPLE|FMT_FLAG_USE_DOLLAR|FMT_FLAG_EMPTY_PREC_OK, + 'w', 0, 'p', 0, 'L', + &integer_type_node, &integer_type_node + }, + { "ms_scanf", ms_printf_length_specs, ms_scan_char_table, "*'", NULL, + ms_scanf_flag_specs, ms_scanf_flag_pairs, + FMT_FLAG_ARG_CONVERT|FMT_FLAG_SCANF_A_KLUDGE|FMT_FLAG_USE_DOLLAR|FMT_FLAG_ZERO_WIDTH_BAD|FMT_FLAG_DOLLAR_GAP_POINTER_OK, + 'w', 0, 0, '*', 'L', + NULL, NULL + }, + { "ms_strftime", NULL, ms_time_char_table, "", "#", + ms_strftime_flag_specs, ms_strftime_flag_pairs, + FMT_FLAG_FANCY_PERCENT_OK, 0, 0, 0, 0, 0, + NULL, NULL + } +}; + +/* Default overrides for printf, scanf and strftime. */ +const target_ovr_attr mingw_format_attribute_overrides[4] = +{ + { "ms_printf", "printf" }, + { "ms_scanf", "scanf" }, + { "ms_strftime", "strftime" } +}; Modified: llvm-gcc-4.2/trunk/gcc/doc/extend.texi URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/doc/extend.texi?rev=50404&r1=50403&r2=50404&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/doc/extend.texi (original) +++ llvm-gcc-4.2/trunk/gcc/doc/extend.texi Tue Apr 29 01:23:26 2008 @@ -1914,20 +1914,31 @@ for consistency with the @code{printf} style format string argument @code{my_format}. + at c LLVM LOCAL begin mainline The parameter @var{archetype} determines how the format string is -interpreted, and should be @code{printf}, @code{scanf}, @code{strftime} -or @code{strfmon}. (You can also use @code{__printf__}, - at code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.) The -parameter @var{string-index} specifies which argument is the format -string argument (starting from 1), while @var{first-to-check} is the -number of the first argument to check against the format string. For -functions where the arguments are not available to be checked (such as +interpreted, and should be @code{printf}, @code{scanf}, @code{strftime}, + at code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or + at code{strfmon}. (You can also use @code{__printf__}, + at code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.) On +MinGW targets, @code{ms_printf}, @code{ms_scanf}, and + at code{ms_strftime} are also present. + at var{archtype} values such as @code{printf} refer to the formats accepted +by the system's C run-time library, while @code{gnu_} values always refer +to the formats accepted by the GNU C Library. On Microsoft Windows +targets, @code{ms_} values refer to the formats accepted by the + at file{msvcrt.dll} library. +The parameter @var{string-index} +specifies which argument is the format string argument (starting +from 1), while @var{first-to-check} is the number of the first +argument to check against the format string. For functions +where the arguments are not available to be checked (such as @code{vprintf}), specify the third parameter as zero. In this case the compiler only checks the format string for consistency. For @code{strftime} formats, the third parameter is required to be zero. Since non-static C++ methods have an implicit @code{this} argument, the arguments of such methods should be counted from two, not one, when giving values for @var{string-index} and @var{first-to-check}. + at c LLVM LOCAL end mainline In the example above, the format string (@code{my_format}) is the second argument of the function @code{my_print}, and the arguments to check Modified: llvm-gcc-4.2/trunk/gcc/doc/tm.texi URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/doc/tm.texi?rev=50404&r1=50403&r2=50404&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/doc/tm.texi (original) +++ llvm-gcc-4.2/trunk/gcc/doc/tm.texi Tue Apr 29 01:23:26 2008 @@ -9944,6 +9944,20 @@ @code{TARGET_FORMAT_TYPES}. @end defmac + at c LLVM LOCAL begin mainline + at defmac TARGET_OVERRIDES_FORMAT_ATTRIBUTES +If defined, this macro is the name of a global variable containing +target-specific format overrides for the @option{-Wformat} option. The +default is to have no target-specific format overrides. If defined, + at code{TARGET_FORMAT_TYPES} must be defined, too. + at end defmac + + at defmac TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT +If defined, this macro specifies the number of entries in + at code{TARGET_OVERRIDES_FORMAT_ATTRIBUTES}. + at end defmac + at c LLVM LOCAL end mainline + @deftypefn {Target Hook} bool TARGET_RELAXED_ORDERING If set to @code{true}, means that the target's memory model does not guarantee that loads which do not depend on one another will access From asl at math.spbu.ru Tue Apr 29 01:24:14 2008 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Tue, 29 Apr 2008 06:24:14 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50405 - in /llvm-gcc-4.2/trunk/gcc/config/i386: cygming.h i386.c i386.h i386elf.h mingw32.h unix.h Message-ID: <200804290624.m3T6OEYg006600@zion.cs.uiuc.edu> Author: asl Date: Tue Apr 29 01:24:14 2008 New Revision: 50405 URL: http://llvm.org/viewvc/llvm-project?rev=50405&view=rev Log: Backport from mainline. Finally add necessary bits for win64 Modified: llvm-gcc-4.2/trunk/gcc/config/i386/cygming.h llvm-gcc-4.2/trunk/gcc/config/i386/i386.c llvm-gcc-4.2/trunk/gcc/config/i386/i386.h llvm-gcc-4.2/trunk/gcc/config/i386/i386elf.h llvm-gcc-4.2/trunk/gcc/config/i386/mingw32.h llvm-gcc-4.2/trunk/gcc/config/i386/unix.h Modified: llvm-gcc-4.2/trunk/gcc/config/i386/cygming.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/cygming.h?rev=50405&r1=50404&r2=50405&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/cygming.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/cygming.h Tue Apr 29 01:24:14 2008 @@ -21,22 +21,43 @@ the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/* LLVM LOCAL begin mainline */ +#if TARGET_64BIT_DEFAULT +#ifndef DWARF2_DEBUGGING_INFO +#define DWARF2_DEBUGGING_INFO 1 +#endif +#ifndef DWARF2_UNWIND_INFO +#define DWARF2_UNWIND_INFO 1 +#endif +#endif +/* LLVM LOCAL end mainline */ + #define DBX_DEBUGGING_INFO 1 #define SDB_DEBUGGING_INFO 1 #undef PREFERRED_DEBUGGING_TYPE +/* LLVM LOCAL begin mainline */ +#if TARGET_64BIT_DEFAULT +#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG +#else #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG +#endif + +#undef TARGET_64BIT_MS_ABI +#define TARGET_64BIT_MS_ABI TARGET_64BIT +/* LLVM LOCAL end mainline */ #ifdef HAVE_GAS_PE_SECREL32_RELOC #define DWARF2_DEBUGGING_INFO 1 -/* LLVM LOCAL begin mainline 125696 */ +/* LLVM LOCAL begin mainline */ /* Map gcc register number to DBX register number. Maintain compatibility with old -gstabs compiled code. */ -/* LLVM LOCAL end mainline 125696 */ #undef DBX_REGISTER_NUMBER -#define DBX_REGISTER_NUMBER(n) (write_symbols == DWARF2_DEBUG \ - ? svr4_dbx_register_map[n] \ - : dbx_register_map[n]) +#define DBX_REGISTER_NUMBER(n) \ + (TARGET_64BIT ? dbx64_register_map[n] \ + : (write_symbols == DWARF2_DEBUG \ + ? svr4_dbx_register_map[n] : dbx_register_map[n])) +/* LLVM LOCAL end mainline */ /* LLVM LOCAL begin mainline 125696 */ /* Map gcc register number to DWARF 2 CFA column number. Always @@ -109,14 +130,37 @@ #undef MATH_LIBRARY #define MATH_LIBRARY "" -#define SIZE_TYPE "unsigned int" -#define PTRDIFF_TYPE "int" +/* LLVM LOCAL begin mainline */ +#define SIZE_TYPE (TARGET_64BIT ? "long long unsigned int" : "unsigned int") +#define PTRDIFF_TYPE (TARGET_64BIT ? "long long int" : "int") + #define WCHAR_TYPE_SIZE 16 #define WCHAR_TYPE "short unsigned int" +/* Windows64 continues to use a 32-bit long type. */ +#undef LONG_TYPE_SIZE +#define LONG_TYPE_SIZE 32 + +#undef REG_PARM_STACK_SPACE +#define REG_PARM_STACK_SPACE(FNDECL) (TARGET_64BIT_MS_ABI ? 32 : 0) + +#undef OUTGOING_REG_PARM_STACK_SPACE +#define OUTGOING_REG_PARM_STACK_SPACE (TARGET_64BIT_MS_ABI ? 1 : 0) + +#undef REGPARM_MAX +#define REGPARM_MAX (TARGET_64BIT_MS_ABI ? 4 : 3) + +#undef SSE_REGPARM_MAX +#define SSE_REGPARM_MAX (TARGET_64BIT_MS_ABI ? 4 : TARGET_SSE ? 3 : 0) +/* LLVM LOCAL end mainline */ + /* Enable parsing of #pragma pack(push,) and #pragma pack(pop). */ #define HANDLE_PRAGMA_PACK_PUSH_POP 1 +/* LLVM LOCAL begin mainline */ +/* Enable push_macro & pop_macro */ +#define HANDLE_PRAGMA_PUSH_POP_MACRO 1 +/* LLVM LOCAL end mainline */ union tree_node; #define TREE union tree_node * @@ -202,14 +246,21 @@ #define CHECK_STACK_LIMIT 4000 +/* LLVM LOCAL begin mainline */ +#undef STACK_BOUNDARY +#define STACK_BOUNDARY (TARGET_64BIT_MS_ABI ? 128 : BITS_PER_WORD) +/* LLVM LOCAL end mainline */ + /* By default, target has a 80387, uses IEEE compatible arithmetic, returns float values in the 387 and needs stack probes. We also align doubles to 64-bits for MSVC default compatibility. */ +/* LLVM LOCAL begin mainline */ #undef TARGET_SUBTARGET_DEFAULT #define TARGET_SUBTARGET_DEFAULT \ - (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_STACK_PROBE \ - | MASK_ALIGN_DOUBLE) + (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS \ + | MASK_STACK_PROBE | MASK_ALIGN_DOUBLE) +/* LLVM LOCAL end mainline */ /* This is how to output an assembler line that says to advance the location counter @@ -393,9 +444,11 @@ #undef TARGET_USE_LOCAL_THUNK_ALIAS_P #define TARGET_USE_LOCAL_THUNK_ALIAS_P(DECL) (!DECL_ONE_ONLY (DECL)) +/* LLVM LOCAL begin mainline */ #define SUBTARGET_ATTRIBUTE_TABLE \ - /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */ \ { "selectany", 0, 0, true, false, false, ix86_handle_selectany_attribute } + /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */ +/* LLVM LOCAL end mainline */ /* mcount() does not need a counter variable. */ #undef NO_PROFILE_COUNTERS Modified: llvm-gcc-4.2/trunk/gcc/config/i386/i386.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/i386.c?rev=50405&r1=50404&r2=50405&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/i386.c (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/i386.c Tue Apr 29 01:24:14 2008 @@ -1443,6 +1443,10 @@ #define TARGET_INTERNAL_ARG_POINTER ix86_internal_arg_pointer #undef TARGET_DWARF_HANDLE_FRAME_UNSPEC #define TARGET_DWARF_HANDLE_FRAME_UNSPEC ix86_dwarf_handle_frame_unspec +/* LLVM LOCAL begin mainline */ +#undef TARGET_STRICT_ARGUMENT_NAMING +#define TARGET_STRICT_ARGUMENT_NAMING hook_bool_CUMULATIVE_ARGS_true +/* LLVM LOCAL end mainline */ #undef TARGET_GIMPLIFY_VA_ARG_EXPR #define TARGET_GIMPLIFY_VA_ARG_EXPR ix86_gimplify_va_arg @@ -1776,9 +1780,18 @@ } else { - ix86_cmodel = CM_32; - if (TARGET_64BIT) + /* LLVM LOCAL begin mainline */ + /* For TARGET_64BIT_MS_ABI, force pic on, in order to enable the + use of rip-relative addressing. This eliminates fixups that + would otherwise be needed if this object is to be placed in a + DLL, and is essentially just as efficient as direct addressing. */ + if (TARGET_64BIT_MS_ABI) + ix86_cmodel = CM_SMALL_PIC, flag_pic = 1; + else if (TARGET_64BIT) ix86_cmodel = flag_pic ? CM_SMALL_PIC : CM_SMALL; + else + ix86_cmodel = CM_32; + /* LLVM LOCAL end mainline */ } if (ix86_asm_string != 0) { @@ -1894,15 +1907,20 @@ /* Validate -mregparm= value. */ if (ix86_regparm_string) { + /* LLVM LOCAL begin mainline */ + if (TARGET_64BIT) + warning (0, "-mregparm is ignored in 64-bit mode"); + /* LLVM LOCAL end mainline */ i = atoi (ix86_regparm_string); if (i < 0 || i > REGPARM_MAX) error ("-mregparm=%d is not between 0 and %d", i, REGPARM_MAX); else ix86_regparm = i; } - else - if (TARGET_64BIT) - ix86_regparm = REGPARM_MAX; + /* LLVM LOCAL begin mainline */ + if (TARGET_64BIT) + ix86_regparm = REGPARM_MAX; + /* LLVM LOCAL end mainline */ /* If the user has provided any of the -malign-* options, warn and use that value only if -falign-* is not set. @@ -1996,8 +2014,6 @@ /* APPLE LOCAL begin mainline */ if (TARGET_64BIT) { - if (TARGET_ALIGN_DOUBLE) - error ("-malign-double makes no sense in the 64bit mode"); if (TARGET_RTD) error ("-mrtd calling convention not supported in the 64bit mode"); /* APPLE LOCAL begin radar 4877693 */ @@ -2697,8 +2713,12 @@ if (TARGET_64BIT) { - warning (OPT_Wattributes, "%qs attribute ignored", - IDENTIFIER_POINTER (name)); + /* LLVM LOCAL begin mainline */ + /* Do not warn when emulating the MS ABI. */ + if (!TARGET_64BIT_MS_ABI) + warning (OPT_Wattributes, "%qs attribute ignored", + IDENTIFIER_POINTER (name)); + /* LLVM LOCAL end mainline */ *no_add_attrs = true; return NULL_TREE; } @@ -4056,23 +4076,44 @@ the argument itself. The pointer is passed in whatever way is appropriate for passing a pointer to that type. */ +/* LLVM LOCAL begin mainline */ static bool ix86_pass_by_reference (CUMULATIVE_ARGS *cum ATTRIBUTE_UNUSED, enum machine_mode mode ATTRIBUTE_UNUSED, tree type, bool named ATTRIBUTE_UNUSED) { - if (!TARGET_64BIT) - return 0; - - if (type && int_size_in_bytes (type) == -1) + /* See Windows x64 Software Convention. */ + if (TARGET_64BIT_MS_ABI) { - if (TARGET_DEBUG_ARG) - fprintf (stderr, "function_arg_pass_by_reference\n"); - return 1; + int msize = (int) GET_MODE_SIZE (mode); + if (type) + { + /* Arrays are passed by reference. */ + if (TREE_CODE (type) == ARRAY_TYPE) + return true; + + if (AGGREGATE_TYPE_P (type)) + { + /* Structs/unions of sizes other than 8, 16, 32, or 64 bits + are passed by reference. */ + msize = int_size_in_bytes (type); + } + } + + /* __m128 is passed by reference. */ + switch (msize) { + case 1: case 2: case 4: case 8: + break; + default: + return true; + } } + else if (TARGET_64BIT && type && int_size_in_bytes (type) == -1) + return 1; return 0; } +/* LLVM LOCAL end mainline */ /* Return true when TYPE should be 128bit aligned for 32bit argument passing ABI. Only called if TARGET_SSE. */ @@ -19708,7 +19749,7 @@ { int tmp_regno = 2 /* ECX */; if (lookup_attribute ("fastcall", - TYPE_ATTRIBUTES (TREE_TYPE (function)))) + TYPE_ATTRIBUTES (TREE_TYPE (function)))) tmp_regno = 0 /* EAX */; tmp = gen_rtx_REG (SImode, tmp_regno); } Modified: llvm-gcc-4.2/trunk/gcc/config/i386/i386.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/i386.h?rev=50405&r1=50404&r2=50405&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/i386.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/i386.h Tue Apr 29 01:24:14 2008 @@ -306,6 +306,12 @@ it's analogous to similar code for Mach-O on PowerPC. darwin.h redefines this to 1. */ #define TARGET_MACHO 0 + +/* LLVM LOCAL begin mainline */ +/* Likewise, for the Windows 64-bit ABI. */ +#define TARGET_64BIT_MS_ABI 0 +/* LLVM LOCAL end mainline */ + /* APPLE LOCAL begin mach-o cleanup */ #define MACHOPIC_INDIRECT 0 #define MACHOPIC_PURE 0 Modified: llvm-gcc-4.2/trunk/gcc/config/i386/i386elf.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/i386elf.h?rev=50405&r1=50404&r2=50405&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/i386elf.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/i386elf.h Tue Apr 29 01:24:14 2008 @@ -27,11 +27,6 @@ #define TARGET_VERSION fprintf (stderr, " (i386 bare ELF target)"); -/* By default, target has a 80387, uses IEEE compatible arithmetic, - and returns float values in the 387. */ - -#define TARGET_SUBTARGET_DEFAULT (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS) - /* The ELF ABI for the i386 says that records and unions are returned in memory. */ Modified: llvm-gcc-4.2/trunk/gcc/config/i386/mingw32.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/mingw32.h?rev=50405&r1=50404&r2=50405&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/mingw32.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/mingw32.h Tue Apr 29 01:24:14 2008 @@ -20,10 +20,18 @@ the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/* LLVM LOCAL begin mainline */ #undef TARGET_VERSION -#define TARGET_VERSION fprintf (stderr, " (x86 MinGW)"); +#if TARGET_64BIT_DEFAULT +#define TARGET_VERSION fprintf (stderr,"(x86_64 MinGW"); +#else +#define TARGET_VERSION fprintf (stderr," (x86 MinGW)"); +#endif +/* LLVM LOCAL end mainline */ -/* See i386/crtdll.h for an alternative definition. */ +/* LLVM LOCAL begin mainline */ +/* See i386/crtdll.h for an alternative definition. _INTEGRAL_MAX_BITS + is for compatibility with native compiler. */ #define EXTRA_OS_CPP_BUILTINS() \ do \ { \ @@ -32,13 +40,28 @@ builtin_define ("_WIN32"); \ builtin_define_std ("WIN32"); \ builtin_define_std ("WINNT"); \ + builtin_define_with_int_value ("_INTEGRAL_MAX_BITS", \ + TYPE_PRECISION (intmax_type_node));\ + if (TARGET_64BIT_MS_ABI) \ + { \ + builtin_define ("__MINGW64__"); \ + builtin_define_std ("WIN64"); \ + builtin_define_std ("_WIN64"); \ + } \ } \ while (0) +/* LLVM LOCAL end mainline */ /* Override the standard choice of /usr/include as the default prefix to try when searching for header files. */ #undef STANDARD_INCLUDE_DIR +/* LLVM LOCAL begin mainline */ +#if TARGET_64BIT_DEFAULT +#define STANDARD_INCLUDE_DIR "/mingw/include64" +#else #define STANDARD_INCLUDE_DIR "/mingw/include" +#endif +/* LLVM LOCAL end mainline */ #undef STANDARD_INCLUDE_COMPONENT #define STANDARD_INCLUDE_COMPONENT "MINGW" @@ -78,8 +101,14 @@ /* Override startfile prefix defaults. */ #ifndef STANDARD_STARTFILE_PREFIX_1 +/* LLVM LOCAL begin mainline */ +#if TARGET_64BIT_DEFAULT +#define STANDARD_STARTFILE_PREFIX_1 "/mingw/lib64/" +#else #define STANDARD_STARTFILE_PREFIX_1 "/mingw/lib/" #endif +/* LLVM LOCAL end mainline */ +#endif #ifndef STANDARD_STARTFILE_PREFIX_2 #define STANDARD_STARTFILE_PREFIX_2 "" #endif @@ -121,10 +150,48 @@ #define GOMP_SELF_SPECS "%{fopenmp: -mthreads}" -/* LLVM LOCAL begin mainline 125696 */ -/* This works on mingw32. */ -#undef TARGET_USE_JCR_SECTION -#define TARGET_USE_JCR_SECTION 1 +/* LLVM LOCAL begin mainline */ +/* Contains a pointer to type target_ovr_attr defining the target specific + overrides of format attributes. See c-format.h for structure + definition. */ +#undef TARGET_OVERRIDES_FORMAT_ATTRIBUTES +#define TARGET_OVERRIDES_FORMAT_ATTRIBUTES mingw_format_attribute_overrides + +/* Specify the count of elements in TARGET_OVERRIDES_ATTRIBUTE. */ +#undef TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT +#define TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT 3 + +/* MS specific format attributes for ms_printf, ms_scanf, ms_strftime. */ +#undef TARGET_FORMAT_TYPES +#define TARGET_FORMAT_TYPES mingw_format_attributes + +#undef TARGET_N_FORMAT_TYPES +#define TARGET_N_FORMAT_TYPES 3 + +#define TARGET_USE_JCR_SECTION 0 + +#undef MINGW_ENABLE_EXECUTE_STACK +#define MINGW_ENABLE_EXECUTE_STACK \ +extern void __enable_execute_stack (void *); \ +void \ +__enable_execute_stack (void *addr) \ +{ \ + MEMORY_BASIC_INFORMATION b; \ + if (!VirtualQuery (addr, &b, sizeof(b))) \ + abort (); \ + VirtualProtect (b.BaseAddress, b.RegionSize, PAGE_EXECUTE_READWRITE, \ + &b.Protect); \ +} + +#undef ENABLE_EXECUTE_STACK +#define ENABLE_EXECUTE_STACK MINGW_ENABLE_EXECUTE_STACK + +#ifdef IN_LIBGCC2 +#include +#endif + +#if !TARGET_64BIT #define MD_UNWIND_SUPPORT "config/i386/w32-unwind.h" -/* LLVM LOCAL end mainline 125696 */ +#endif +/* LLVM LOCAL end mainline */ Modified: llvm-gcc-4.2/trunk/gcc/config/i386/unix.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/unix.h?rev=50405&r1=50404&r2=50405&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/unix.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/unix.h Tue Apr 29 01:24:14 2008 @@ -61,5 +61,12 @@ /* By default, target has a 80387, uses IEEE compatible arithmetic, and returns float values in the 387. */ +/* LLVM LOCAL begin mainline */ +#define TARGET_SUBTARGET_DEFAULT \ + (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS) -#define TARGET_SUBTARGET_DEFAULT (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS) +/* By default, 64-bit mode uses 128-bit long double. */ +#undef TARGET_SUBTARGET64_DEFAULT +#define TARGET_SUBTARGET64_DEFAULT \ + MASK_128BIT_LONG_DOUBLE +/* LLVM LOCAL end mainline */ From resistor at mac.com Tue Apr 29 01:34:56 2008 From: resistor at mac.com (Owen Anderson) Date: Tue, 29 Apr 2008 06:34:56 -0000 Subject: [llvm-commits] [llvm] r50406 - /llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp Message-ID: <200804290634.m3T6YuaF006914@zion.cs.uiuc.edu> Author: resistor Date: Tue Apr 29 01:34:55 2008 New Revision: 50406 URL: http://llvm.org/viewvc/llvm-project?rev=50406&view=rev Log: Clarify what we mean by a dead loop. Modified: llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp Modified: llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp?rev=50406&r1=50405&r2=50406&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp Tue Apr 29 01:34:55 2008 @@ -126,6 +126,10 @@ return true; } +/// runOnLoop - Remove dead loops, by which we mean loops that do not impact the +/// observable behavior of the program other than finite running time. Note +/// we do ensure that this never remove a loop that might be infinite, as doing +/// so could change the halting/non-halting nature of a program. bool DeadLoopElimination::runOnLoop(Loop* L, LPPassManager& LPM) { // Don't remove loops for which we can't solve the trip count. // They could be infinite, in which case we'd be changing program behavior. From evan.cheng at apple.com Tue Apr 29 01:46:11 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 29 Apr 2008 06:46:11 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50407 - /llvm-gcc-4.2/trunk/gcc/objc/objc-act.c Message-ID: <200804290646.m3T6kBOt007200@zion.cs.uiuc.edu> Author: evancheng Date: Tue Apr 29 01:46:11 2008 New Revision: 50407 URL: http://llvm.org/viewvc/llvm-project?rev=50407&view=rev Log: Disable 5812818 fix for now. Modified: llvm-gcc-4.2/trunk/gcc/objc/objc-act.c Modified: llvm-gcc-4.2/trunk/gcc/objc/objc-act.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/objc/objc-act.c?rev=50407&r1=50406&r2=50407&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/objc/objc-act.c (original) +++ llvm-gcc-4.2/trunk/gcc/objc/objc-act.c Tue Apr 29 01:46:11 2008 @@ -8622,6 +8622,7 @@ CLASS_TYPE (class) = record; /* APPLE LOCAL llvm begin */ +#if 0 #ifdef ENABLE_LLVM /* Synthesized properties will later be added to this RECORD_DECL as they * are found in @implementations. We don't want the LLVM tree->llvm @@ -8633,6 +8634,7 @@ if (flag_objc_abi == 2) llvm_compute_type(record); #endif +#endif /* APPLE LOCAL llvm end */ } } From asl at math.spbu.ru Tue Apr 29 01:52:51 2008 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Tue, 29 Apr 2008 10:52:51 +0400 Subject: [llvm-commits] Win64 support to llvm-gcc Message-ID: <1209451971.5745.76.camel@localhost> Hello, Everyone I've just commited some bits ?backported from mainline gcc to llvm-gcc in order to enable win64 suport. The patches were explicitly approved by their author, Kai Tietz, to be backported into llvm-gcc under GPLv2. Please note, that win64 support is really preliminary. It should 'just work', but it wasn't widely tested. Currently there are some bugs in FP stackifier preventing clean build of w64 CRT with llvm-gcc, so some extra workarounds are needed. Surely, patches and test results are highly welcomed! :) -- With best regards, Anton Korobeynikov. Faculty of Mathematics & Mechanics, Saint Petersburg State University. From sabre at nondot.org Tue Apr 29 01:56:02 2008 From: sabre at nondot.org (Chris Lattner) Date: Tue, 29 Apr 2008 06:56:02 -0000 Subject: [llvm-commits] [llvm] r50408 - /llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp Message-ID: <200804290656.m3T6u2EH007519@zion.cs.uiuc.edu> Author: lattner Date: Tue Apr 29 01:56:02 2008 New Revision: 50408 URL: http://llvm.org/viewvc/llvm-project?rev=50408&view=rev Log: Implement more aggressive support for analyzing string length. This generalizes the previous code to handle the case when the string is not an immediate to the strlen call (for example, crazy stuff like strlen(c ? "foo" : "bart"+1) -> 3). This implements gcc.c-torture/execute/builtins/strlen-2.c. I will generalize other cases in simplifylibcalls to use the same routine later. Modified: llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp Modified: llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp?rev=50408&r1=50407&r2=50408&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp Tue Apr 29 01:56:02 2008 @@ -24,6 +24,7 @@ #include "llvm/Intrinsics.h" #include "llvm/Module.h" #include "llvm/Pass.h" +#include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/Statistic.h" #include "llvm/Config/config.h" @@ -398,16 +399,18 @@ return new SimplifyLibCalls(); } +// Forward declare utility functions. +static bool GetConstantStringInfo(Value *V, std::string &Str); +static Value *CastToCStr(Value *V, Instruction *IP); +static uint64_t GetStringLength(Value *V); + + // Classes below here, in the anonymous namespace, are all subclasses of the // LibCallOptimization class, each implementing all optimizations possible for a // single well-known library call. Each has a static singleton instance that // auto registers it into the "optlist" global above. namespace { -// Forward declare utility functions. -static bool GetConstantStringInfo(Value *V, std::string &Str); -static Value *CastToCStr(Value *V, Instruction *IP); - /// This LibCallOptimization will find instances of a call to "exit" that occurs /// within the "main" function and change it to a simple "ret" instruction with /// the same value passed to the exit function. When this is done, it splits the @@ -812,12 +815,10 @@ } // Get the length of the constant string operand - std::string Str; - if (!GetConstantStringInfo(Src, Str)) - return false; - // strlen("xyz") -> 3 (for example) - return ReplaceCallWith(CI, ConstantInt::get(CI->getType(), Str.size())); + if (uint64_t Len = GetStringLength(Src)) + return ReplaceCallWith(CI, ConstantInt::get(CI->getType(), Len-1)); + return false; } } StrLenOptimizer; @@ -1876,6 +1877,7 @@ return false; // opt failed } } NearByIntOptimizer; +} // end anon namespace /// GetConstantStringInfo - This function computes the length of a /// null-terminated constant array of integers. This function can't rely on the @@ -1972,6 +1974,131 @@ return false; // The array isn't null terminated. } +/// GetStringLengthH - If we can compute the length of the string pointed to by +/// the specified pointer, return 'len+1'. If we can't, return 0. +static uint64_t GetStringLengthH(Value *V, SmallPtrSet &PHIs) { + // Look through noop bitcast instructions. + if (BitCastInst *BCI = dyn_cast(V)) + return GetStringLengthH(BCI->getOperand(0), PHIs); + + // If this is a PHI node, there are two cases: either we have already seen it + // or we haven't. + if (PHINode *PN = dyn_cast(V)) { + if (!PHIs.insert(PN)) + return ~0ULL; // already in the set. + + // If it was new, see if all the input strings are the same length. + uint64_t LenSoFar = ~0ULL; + for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { + uint64_t Len = GetStringLengthH(PN->getIncomingValue(i), PHIs); + if (Len == 0) return 0; // Unknown length -> unknown. + + if (Len == ~0ULL) continue; + + if (Len != LenSoFar && LenSoFar != ~0ULL) + return 0; // Disagree -> unknown. + LenSoFar = Len; + } + + // Success, all agree. + return LenSoFar; + } + + // strlen(select(c,x,y)) -> strlen(x) ^ strlen(y) + if (SelectInst *SI = dyn_cast(V)) { + uint64_t Len1 = GetStringLengthH(SI->getTrueValue(), PHIs); + if (Len1 == 0) return 0; + uint64_t Len2 = GetStringLengthH(SI->getFalseValue(), PHIs); + if (Len2 == 0) return 0; + if (Len1 == ~0ULL) return Len2; + if (Len2 == ~0ULL) return Len1; + if (Len1 != Len2) return 0; + return Len1; + } + + // If the value is not a GEP instruction nor a constant expression with a + // GEP instruction, then return unknown. + User *GEP = 0; + if (GetElementPtrInst *GEPI = dyn_cast(V)) { + GEP = GEPI; + } else if (ConstantExpr *CE = dyn_cast(V)) { + if (CE->getOpcode() != Instruction::GetElementPtr) + return 0; + GEP = CE; + } else { + return 0; + } + + // Make sure the GEP has exactly three arguments. + if (GEP->getNumOperands() != 3) + return 0; + + // Check to make sure that the first operand of the GEP is an integer and + // has value 0 so that we are sure we're indexing into the initializer. + if (ConstantInt *Idx = dyn_cast(GEP->getOperand(1))) { + if (!Idx->isZero()) + return 0; + } else + return 0; + + // If the second index isn't a ConstantInt, then this is a variable index + // into the array. If this occurs, we can't say anything meaningful about + // the string. + uint64_t StartIdx = 0; + if (ConstantInt *CI = dyn_cast(GEP->getOperand(2))) + StartIdx = CI->getZExtValue(); + else + return 0; + + // The GEP instruction, constant or instruction, must reference a global + // variable that is a constant and is initialized. The referenced constant + // initializer is the array that we'll use for optimization. + GlobalVariable* GV = dyn_cast(GEP->getOperand(0)); + if (!GV || !GV->isConstant() || !GV->hasInitializer()) + return 0; + Constant *GlobalInit = GV->getInitializer(); + + // Handle the ConstantAggregateZero case, which is a degenerate case. The + // initializer is constant zero so the length of the string must be zero. + if (isa(GlobalInit)) + return 1; // Len = 0 offset by 1. + + // Must be a Constant Array + ConstantArray *Array = dyn_cast(GlobalInit); + if (!Array || Array->getType()->getElementType() != Type::Int8Ty) + return false; + + // Get the number of elements in the array + uint64_t NumElts = Array->getType()->getNumElements(); + + // Traverse the constant array from StartIdx (derived above) which is + // the place the GEP refers to in the array. + for (unsigned i = StartIdx; i != NumElts; ++i) { + Constant *Elt = Array->getOperand(i); + ConstantInt *CI = dyn_cast(Elt); + if (!CI) // This array isn't suitable, non-int initializer. + return 0; + if (CI->isZero()) + return i-StartIdx+1; // We found end of string, success! + } + + return 0; // The array isn't null terminated, conservatively return 'unknown'. +} + +/// GetStringLength - If we can compute the length of the string pointed to by +/// the specified pointer, return 'len+1'. If we can't, return 0. +static uint64_t GetStringLength(Value *V) { + if (!isa(V->getType())) return 0; + + SmallPtrSet PHIs; + uint64_t Len = GetStringLengthH(V, PHIs); + // If Len is ~0ULL, we had an infinite phi cycle: this is dead code, so return + // an empty string as a length. + return Len == ~0ULL ? 1 : Len; +} + + + /// CastToCStr - Return V if it is an sbyte*, otherwise cast it to sbyte*, /// inserting the cast before IP, and return the cast. /// @brief Cast a value to a "C" string. @@ -2082,4 +2209,3 @@ // * trunc(cnst) -> cnst' // // -} From isanbard at gmail.com Tue Apr 29 02:25:52 2008 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 29 Apr 2008 07:25:52 -0000 Subject: [llvm-commits] [llvm] r50409 - /llvm/branches/Apple/Tak/lib/Support/Allocator.cpp Message-ID: <200804290725.m3T7PqiU008361@zion.cs.uiuc.edu> Author: void Date: Tue Apr 29 02:25:52 2008 New Revision: 50409 URL: http://llvm.org/viewvc/llvm-project?rev=50409&view=rev Log: Reverted r50374. It shouldn't have gone into Tak. Modified: llvm/branches/Apple/Tak/lib/Support/Allocator.cpp Modified: llvm/branches/Apple/Tak/lib/Support/Allocator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Tak/lib/Support/Allocator.cpp?rev=50409&r1=50408&r2=50409&view=diff ============================================================================== --- llvm/branches/Apple/Tak/lib/Support/Allocator.cpp (original) +++ llvm/branches/Apple/Tak/lib/Support/Allocator.cpp Tue Apr 29 02:25:52 2008 @@ -46,16 +46,13 @@ /// 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); - char* Result = (char*) (((uintptr_t) (NextPtr+Alignment-1)) - & ~((uintptr_t) Alignment-1)); - - // Speculate the new value of NextPtr. - char* NextPtrTmp = Result + AllocSize; - - // If we are still within the current region, return Result. - if (unsigned (NextPtrTmp - (char*) this) <= RegionSize) { - NextPtr = NextPtrTmp; + // If there is space in this region, return it. + if (unsigned(NextPtr+AllocSize-(char*)this) <= RegionSize) { + void *Result = NextPtr; + NextPtr += AllocSize; return Result; } From isanbard at gmail.com Tue Apr 29 02:28:31 2008 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 29 Apr 2008 07:28:31 -0000 Subject: [llvm-commits] [llvm] r50410 - in /llvm/branches/Apple/Tak: lib/CodeGen/SimpleRegisterCoalescing.cpp test/CodeGen/X86/2008-04-28-CoalescerBug.ll Message-ID: <200804290728.m3T7SWZM008447@zion.cs.uiuc.edu> Author: void Date: Tue Apr 29 02:28:31 2008 New Revision: 50410 URL: http://llvm.org/viewvc/llvm-project?rev=50410&view=rev Log: Porting r50385 to Tak. Added: llvm/branches/Apple/Tak/test/CodeGen/X86/2008-04-28-CoalescerBug.ll Modified: llvm/branches/Apple/Tak/lib/CodeGen/SimpleRegisterCoalescing.cpp Modified: llvm/branches/Apple/Tak/lib/CodeGen/SimpleRegisterCoalescing.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Tak/lib/CodeGen/SimpleRegisterCoalescing.cpp?rev=50410&r1=50409&r2=50410&view=diff ============================================================================== --- llvm/branches/Apple/Tak/lib/CodeGen/SimpleRegisterCoalescing.cpp (original) +++ llvm/branches/Apple/Tak/lib/CodeGen/SimpleRegisterCoalescing.cpp Tue Apr 29 02:28:31 2008 @@ -942,9 +942,11 @@ unsigned OldSubIdx = isExtSubReg ? CopyMI->getOperand(0).getSubReg() : CopyMI->getOperand(2).getSubReg(); if (OldSubIdx) { - if (OldSubIdx == SubIdx) + if (OldSubIdx == SubIdx && !differingRegisterClasses(SrcReg, DstReg)) // r1024<2> = EXTRACT_SUBREG r1025, 2. Then r1024 has already been // coalesced to a larger register so the subreg indices cancel out. + // Also check if the other larger register is of the same register + // class as the would be resulting register. SubIdx = 0; else { DOUT << "\t Sub-register indices mismatch.\n"; Added: llvm/branches/Apple/Tak/test/CodeGen/X86/2008-04-28-CoalescerBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Tak/test/CodeGen/X86/2008-04-28-CoalescerBug.ll?rev=50410&view=auto ============================================================================== --- llvm/branches/Apple/Tak/test/CodeGen/X86/2008-04-28-CoalescerBug.ll (added) +++ llvm/branches/Apple/Tak/test/CodeGen/X86/2008-04-28-CoalescerBug.ll Tue Apr 29 02:28:31 2008 @@ -0,0 +1,166 @@ +; RUN: llvm-as < %s | llc -mtriple=x86_64-apple-darwin | grep movl | not grep {r\[abcd\]x} +; RUN: llvm-as < %s | llc -mtriple=x86_64-apple-darwin | grep movl | not grep {r\[ds\]i} +; RUN: llvm-as < %s | llc -mtriple=x86_64-apple-darwin | grep movl | not grep {r\[bs\]p} + + %struct.BITMAP = type { i16, i16, i32, i32, i32, i32, i32, i32, i8*, i8* } + %struct.BltData = type { float, float, float, float } + %struct.BltDepth = type { i32, i8**, i32, %struct.BITMAP* (%struct.BltDepth**, %struct.BITMAP*, i32, i32, float*, float, i32)*, i32 (%struct.BltDepth**, %struct.BltOp*)*, i32 (%struct.BltDepth**, %struct.BltOp*, %struct.BltImg*)*, i32 (%struct.BltDepth**, %struct.BltOp*, %struct.BltSh*)*, [28 x [2 x [2 x i32]]]*, %struct.BltData* } + %struct.BltImg = type { i32, i8, i8, i8, float, float*, float*, i32, i32, float*, i32 (i8*, i8*, i8**, i32*, i8**, i32*)*, i8* } + %struct.BltOp = type { i8, i8, i8, i8, i32, i32, i32, i32, i32, i32, i32, i32, i8*, i8*, i32, i32, i32, i32, i32, i32, i32, i8*, i8*, i32, i32, i32, i32, i32, i32, i32, i8* } + %struct.BltSh = type { i8, i8, i8, i8, float, float*, float*, float*, float*, i32, i32, float*, float*, float* } + +define void @t(%struct.BltDepth* %depth, %struct.BltOp* %bop, i32 %mode) nounwind { +entry: + switch i32 %mode, label %return [ + i32 1, label %bb2898.us + i32 18, label %bb13086.preheader + ] + +bb13086.preheader: ; preds = %entry + %tmp13098 = icmp eq i32 0, 0 ; [#uses=1] + %tmp13238 = icmp eq i32 0, 0 ; [#uses=1] + br label %bb13088 + +bb2898.us: ; preds = %bb2898.us, %entry + br label %bb2898.us + +bb13088: ; preds = %bb13572, %bb13567, %bb13107, %bb13086.preheader + br i1 %tmp13098, label %bb13107, label %bb13101 + +bb13101: ; preds = %bb13088 + br label %bb13107 + +bb13107: ; preds = %bb13101, %bb13088 + %iftmp.684.0 = phi i32 [ 0, %bb13101 ], [ 65535, %bb13088 ] ; [#uses=2] + %tmp13111 = load i64* null, align 8 ; [#uses=3] + %tmp13116 = lshr i64 %tmp13111, 16 ; [#uses=1] + %tmp1311613117 = trunc i64 %tmp13116 to i32 ; [#uses=1] + %tmp13118 = and i32 %tmp1311613117, 65535 ; [#uses=1] + %tmp13120 = lshr i64 %tmp13111, 32 ; [#uses=1] + %tmp1312013121 = trunc i64 %tmp13120 to i32 ; [#uses=1] + %tmp13122 = and i32 %tmp1312013121, 65535 ; [#uses=2] + %tmp13124 = lshr i64 %tmp13111, 48 ; [#uses=1] + %tmp1312413125 = trunc i64 %tmp13124 to i32 ; [#uses=2] + %tmp1314013141not = xor i16 0, -1 ; [#uses=1] + %tmp1314013141not13142 = zext i16 %tmp1314013141not to i32 ; [#uses=3] + %tmp13151 = mul i32 %tmp13122, %tmp1314013141not13142 ; [#uses=1] + %tmp13154 = mul i32 %tmp1312413125, %tmp1314013141not13142 ; [#uses=1] + %tmp13157 = mul i32 %iftmp.684.0, %tmp1314013141not13142 ; [#uses=1] + %tmp13171 = add i32 %tmp13151, 1 ; [#uses=1] + %tmp13172 = add i32 %tmp13171, 0 ; [#uses=1] + %tmp13176 = add i32 %tmp13154, 1 ; [#uses=1] + %tmp13177 = add i32 %tmp13176, 0 ; [#uses=1] + %tmp13181 = add i32 %tmp13157, 1 ; [#uses=1] + %tmp13182 = add i32 %tmp13181, 0 ; [#uses=1] + %tmp13188 = lshr i32 %tmp13172, 16 ; [#uses=1] + %tmp13190 = lshr i32 %tmp13177, 16 ; [#uses=1] + %tmp13192 = lshr i32 %tmp13182, 16 ; [#uses=1] + %tmp13198 = sub i32 %tmp13118, 0 ; [#uses=1] + %tmp13201 = sub i32 %tmp13122, %tmp13188 ; [#uses=1] + %tmp13204 = sub i32 %tmp1312413125, %tmp13190 ; [#uses=1] + %tmp13207 = sub i32 %iftmp.684.0, %tmp13192 ; [#uses=1] + %tmp1320813209 = zext i32 %tmp13204 to i64 ; [#uses=1] + %tmp13211 = shl i64 %tmp1320813209, 48 ; [#uses=1] + %tmp1321213213 = zext i32 %tmp13201 to i64 ; [#uses=1] + %tmp13214 = shl i64 %tmp1321213213, 32 ; [#uses=1] + %tmp13215 = and i64 %tmp13214, 281470681743360 ; [#uses=1] + %tmp1321713218 = zext i32 %tmp13198 to i64 ; [#uses=1] + %tmp13219 = shl i64 %tmp1321713218, 16 ; [#uses=1] + %tmp13220 = and i64 %tmp13219, 4294901760 ; [#uses=1] + %tmp13216 = or i64 %tmp13211, 0 ; [#uses=1] + %tmp13221 = or i64 %tmp13216, %tmp13215 ; [#uses=1] + %tmp13225 = or i64 %tmp13221, %tmp13220 ; [#uses=4] + %tmp1322713228 = trunc i32 %tmp13207 to i16 ; [#uses=4] + %tmp13233 = icmp eq i16 %tmp1322713228, 0 ; [#uses=1] + br i1 %tmp13233, label %bb13088, label %bb13236 + +bb13236: ; preds = %bb13107 + br i1 false, label %bb13567, label %bb13252 + +bb13252: ; preds = %bb13236 + %tmp1329013291 = zext i16 %tmp1322713228 to i64 ; [#uses=8] + %tmp13296 = lshr i64 %tmp13225, 16 ; [#uses=1] + %tmp13297 = and i64 %tmp13296, 65535 ; [#uses=1] + %tmp13299 = lshr i64 %tmp13225, 32 ; [#uses=1] + %tmp13300 = and i64 %tmp13299, 65535 ; [#uses=1] + %tmp13302 = lshr i64 %tmp13225, 48 ; [#uses=1] + %tmp13306 = sub i64 %tmp1329013291, 0 ; [#uses=0] + %tmp13309 = sub i64 %tmp1329013291, %tmp13297 ; [#uses=1] + %tmp13312 = sub i64 %tmp1329013291, %tmp13300 ; [#uses=1] + %tmp13315 = sub i64 %tmp1329013291, %tmp13302 ; [#uses=1] + %tmp13318 = mul i64 %tmp1329013291, %tmp1329013291 ; [#uses=1] + br i1 false, label %bb13339, label %bb13324 + +bb13324: ; preds = %bb13252 + br i1 false, label %bb13339, label %bb13330 + +bb13330: ; preds = %bb13324 + %tmp13337 = sdiv i64 0, 0 ; [#uses=1] + br label %bb13339 + +bb13339: ; preds = %bb13330, %bb13324, %bb13252 + %r0120.0 = phi i64 [ %tmp13337, %bb13330 ], [ 0, %bb13252 ], [ 4294836225, %bb13324 ] ; [#uses=1] + br i1 false, label %bb13360, label %bb13345 + +bb13345: ; preds = %bb13339 + br i1 false, label %bb13360, label %bb13351 + +bb13351: ; preds = %bb13345 + %tmp13354 = mul i64 0, %tmp13318 ; [#uses=1] + %tmp13357 = sub i64 %tmp1329013291, %tmp13309 ; [#uses=1] + %tmp13358 = sdiv i64 %tmp13354, %tmp13357 ; [#uses=1] + br label %bb13360 + +bb13360: ; preds = %bb13351, %bb13345, %bb13339 + %r1121.0 = phi i64 [ %tmp13358, %bb13351 ], [ 0, %bb13339 ], [ 4294836225, %bb13345 ] ; [#uses=1] + br i1 false, label %bb13402, label %bb13387 + +bb13387: ; preds = %bb13360 + br label %bb13402 + +bb13402: ; preds = %bb13387, %bb13360 + %r3123.0 = phi i64 [ 0, %bb13360 ], [ 4294836225, %bb13387 ] ; [#uses=1] + %tmp13404 = icmp eq i16 %tmp1322713228, -1 ; [#uses=1] + br i1 %tmp13404, label %bb13435, label %bb13407 + +bb13407: ; preds = %bb13402 + br label %bb13435 + +bb13435: ; preds = %bb13407, %bb13402 + %r0120.1 = phi i64 [ 0, %bb13407 ], [ %r0120.0, %bb13402 ] ; [#uses=0] + %r1121.1 = phi i64 [ 0, %bb13407 ], [ %r1121.0, %bb13402 ] ; [#uses=0] + %r3123.1 = phi i64 [ 0, %bb13407 ], [ %r3123.0, %bb13402 ] ; [#uses=0] + %tmp13450 = mul i64 0, %tmp13312 ; [#uses=0] + %tmp13455 = mul i64 0, %tmp13315 ; [#uses=0] + %tmp13461 = add i64 0, %tmp1329013291 ; [#uses=1] + %tmp13462 = mul i64 %tmp13461, 65535 ; [#uses=1] + %tmp13466 = sub i64 %tmp13462, 0 ; [#uses=1] + %tmp13526 = add i64 %tmp13466, 1 ; [#uses=1] + %tmp13527 = add i64 %tmp13526, 0 ; [#uses=1] + %tmp13528 = ashr i64 %tmp13527, 16 ; [#uses=4] + %tmp13536 = sub i64 %tmp13528, 0 ; [#uses=1] + %tmp13537 = shl i64 %tmp13536, 32 ; [#uses=1] + %tmp13538 = and i64 %tmp13537, 281470681743360 ; [#uses=1] + %tmp13542 = sub i64 %tmp13528, 0 ; [#uses=1] + %tmp13543 = shl i64 %tmp13542, 16 ; [#uses=1] + %tmp13544 = and i64 %tmp13543, 4294901760 ; [#uses=1] + %tmp13548 = sub i64 %tmp13528, 0 ; [#uses=1] + %tmp13549 = and i64 %tmp13548, 65535 ; [#uses=1] + %tmp13539 = or i64 %tmp13538, 0 ; [#uses=1] + %tmp13545 = or i64 %tmp13539, %tmp13549 ; [#uses=1] + %tmp13550 = or i64 %tmp13545, %tmp13544 ; [#uses=1] + %tmp1355213553 = trunc i64 %tmp13528 to i16 ; [#uses=1] + br label %bb13567 + +bb13567: ; preds = %bb13435, %bb13236 + %tsp1040.0.0 = phi i64 [ %tmp13550, %bb13435 ], [ %tmp13225, %bb13236 ] ; [#uses=0] + %tsp1040.1.0 = phi i16 [ %tmp1355213553, %bb13435 ], [ %tmp1322713228, %bb13236 ] ; [#uses=1] + br i1 %tmp13238, label %bb13088, label %bb13572 + +bb13572: ; preds = %bb13567 + store i16 %tsp1040.1.0, i16* null, align 2 + br label %bb13088 + +return: ; preds = %entry + ret void +} From nicolas.geoffray at lip6.fr Tue Apr 29 03:51:35 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 29 Apr 2008 08:51:35 -0000 Subject: [llvm-commits] [vmkit] r50411 - /vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMField.cpp Message-ID: <200804290851.m3T8pao9018659@zion.cs.uiuc.edu> Author: geoffray Date: Tue Apr 29 03:51:35 2008 New Revision: 50411 URL: http://llvm.org/viewvc/llvm-project?rev=50411&view=rev Log: Implementation of sun.misc.Unsafe::objectFieldOffset. Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMField.cpp Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMField.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMField.cpp?rev=50411&r1=50410&r2=50411&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMField.cpp (original) +++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMField.cpp Tue Apr 29 03:51:35 2008 @@ -373,6 +373,14 @@ } } - +JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_objectFieldOffset( +#ifdef NATIVE_JNI +JNIEnv *env, +jclass clazz, +#endif +JavaObject* Field) { + JavaField* field = (JavaField*)((*Classpath::fieldSlot)((JavaObject*)Field).IntVal.getZExtValue()); + return (jlong)field->ptrOffset; +} } From romix.llvm at googlemail.com Tue Apr 29 04:08:02 2008 From: romix.llvm at googlemail.com (Roman Levenstein) Date: Tue, 29 Apr 2008 09:08:02 -0000 Subject: [llvm-commits] [llvm] r50412 - in /llvm/trunk: include/llvm/CodeGen/ScheduleDAG.h lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp Message-ID: <200804290908.m3T982vG019570@zion.cs.uiuc.edu> Author: romix Date: Tue Apr 29 04:07:59 2008 New Revision: 50412 URL: http://llvm.org/viewvc/llvm-project?rev=50412&view=rev Log: Use std::set instead of std::priority_queue for the RegReductionPriorityQueue. This removes the existing bottleneck related to the removal of elements from the middle of the queue. Also fixes a subtle bug in ScheduleDAGRRList::CapturePred: It was updating the state of the SUnit before removing it. As a result, the comparison operators were working incorrectly and this SUnit could not be removed from the queue properly. Reviewed by Evan and Dan. Approved by Dan. Modified: llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp Modified: llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h?rev=50412&r1=50411&r2=50412&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h (original) +++ llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h Tue Apr 29 04:07:59 2008 @@ -112,6 +112,7 @@ typedef SmallVector::const_iterator const_succ_iterator; unsigned NodeNum; // Entry # of node in the node vector. + unsigned NodeQueueId; // Queue id of node. unsigned short Latency; // Node latency. short NumPreds; // # of preds. short NumSuccs; // # of sucss. @@ -131,7 +132,7 @@ const TargetRegisterClass *CopySrcRC; SUnit(SDNode *node, unsigned nodenum) - : Node(node), InstanceNo(0), NodeNum(nodenum), Latency(0), + : Node(node), InstanceNo(0), NodeNum(nodenum), NodeQueueId(0), Latency(0), NumPreds(0), NumSuccs(0), NumPredsLeft(0), NumSuccsLeft(0), isTwoAddress(false), isCommutable(false), hasPhysRegDefs(false), isPending(false), isAvailable(false), isScheduled(false), Modified: llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp?rev=50412&r1=50411&r2=50412&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp Tue Apr 29 04:07:59 2008 @@ -27,6 +27,7 @@ #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/Statistic.h" +#include "llvm/ADT/STLExtras.h" #include #include #include "llvm/Support/CommandLine.h" @@ -363,14 +364,14 @@ /// CapturePred - This does the opposite of ReleasePred. Since SU is being /// unscheduled, incrcease the succ left count of its predecessors. Remove /// them from AvailableQueue if necessary. -void ScheduleDAGRRList::CapturePred(SUnit *PredSU, SUnit *SU, bool isChain) { - PredSU->CycleBound = 0; +void ScheduleDAGRRList::CapturePred(SUnit *PredSU, SUnit *SU, bool isChain) { + unsigned CycleBound = 0; for (SUnit::succ_iterator I = PredSU->Succs.begin(), E = PredSU->Succs.end(); I != E; ++I) { if (I->Dep == SU) continue; - PredSU->CycleBound = std::max(PredSU->CycleBound, - I->Dep->Cycle + PredSU->Latency); + CycleBound = std::max(CycleBound, + I->Dep->Cycle + PredSU->Latency); } if (PredSU->isAvailable) { @@ -379,6 +380,7 @@ AvailableQueue->remove(PredSU); } + PredSU->CycleBound = CycleBound; ++PredSU->NumSuccsLeft; } @@ -1268,11 +1270,12 @@ template class VISIBILITY_HIDDEN RegReductionPriorityQueue : public SchedulingPriorityQueue { - std::priority_queue, SF> Queue; + std::set Queue; + unsigned currentQueueId; public: RegReductionPriorityQueue() : - Queue(SF(this)) {} + Queue(SF(this)), currentQueueId(0) {} virtual void initNodes(DenseMap > &sumap, std::vector &sunits) {} @@ -1292,39 +1295,31 @@ bool empty() const { return Queue.empty(); } void push(SUnit *U) { - Queue.push(U); + assert(!U->NodeQueueId && "Node in the queue already"); + U->NodeQueueId = ++currentQueueId; + Queue.insert(U); } + void push_all(const std::vector &Nodes) { for (unsigned i = 0, e = Nodes.size(); i != e; ++i) - Queue.push(Nodes[i]); + push(Nodes[i]); } SUnit *pop() { if (empty()) return NULL; - SUnit *V = Queue.top(); - Queue.pop(); + typename std::set::iterator i = prior(Queue.end()); + SUnit *V = *i; + Queue.erase(i); + V->NodeQueueId = 0; return V; } - /// remove - This is a really inefficient way to remove a node from a - /// priority queue. We should roll our own heap to make this better or - /// something. void remove(SUnit *SU) { - std::vector Temp; - - assert(!Queue.empty() && "Not in queue!"); - while (Queue.top() != SU) { - Temp.push_back(Queue.top()); - Queue.pop(); - assert(!Queue.empty() && "Not in queue!"); - } - - // Remove the node from the PQ. - Queue.pop(); - - // Add all the other nodes back. - for (unsigned i = 0, e = Temp.size(); i != e; ++i) - Queue.push(Temp[i]); + assert(!Queue.empty() && "Queue is empty!"); + size_t RemovedNum = Queue.erase(SU); + assert(RemovedNum > 0 && "Not in queue!"); + assert(RemovedNum == 1 && "Multiple times in the queue!"); + SU->NodeQueueId = 0; } }; @@ -1504,18 +1499,6 @@ // Bottom up bool bu_ls_rr_sort::operator()(const SUnit *left, const SUnit *right) const { - // There used to be a special tie breaker here that looked for - // two-address instructions and preferred the instruction with a - // def&use operand. The special case triggered diagnostics when - // _GLIBCXX_DEBUG was enabled because it broke the strict weak - // ordering that priority_queue requires. It didn't help much anyway - // because AddPseudoTwoAddrDeps already covers many of the cases - // where it would have applied. In addition, it's counter-intuitive - // that a tie breaker would be the first thing attempted. There's a - // "real" tie breaker below that is the operation of last resort. - // The fact that the "special tie breaker" would trigger when there - // wasn't otherwise a tie is what broke the strict weak ordering - // constraint. unsigned LPriority = SPQ->getNodePriority(left); unsigned RPriority = SPQ->getNodePriority(right); @@ -1562,8 +1545,9 @@ if (left->CycleBound != right->CycleBound) return left->CycleBound > right->CycleBound; - // FIXME: No strict ordering. - return false; + assert(left->NodeQueueId && right->NodeQueueId && + "NodeQueueId cannot be zero"); + return (left->NodeQueueId > right->NodeQueueId); } template bool @@ -1792,8 +1776,9 @@ if (left->CycleBound != right->CycleBound) return left->CycleBound > right->CycleBound; - // FIXME: No strict ordering. - return false; + assert(left->NodeQueueId && right->NodeQueueId && + "NodeQueueId cannot be zero"); + return (left->NodeQueueId > right->NodeQueueId); } /// CalcNodeSethiUllmanNumber - Priority is the Sethi Ullman number. From nicolas.geoffray at lip6.fr Tue Apr 29 04:47:51 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 29 Apr 2008 09:47:51 -0000 Subject: [llvm-commits] [vmkit] r50413 - in /vmkit/trunk/lib/Mvm: Allocator/gcchunk.h GCMmap2/MvmGC.h GCMmap2/gc.cpp GCMmap2/gccollector.cpp GCMmap2/gccollector.h GCMmap2/gcinit.cpp Message-ID: <200804290947.m3T9lr2Y020794@zion.cs.uiuc.edu> Author: geoffray Date: Tue Apr 29 04:47:44 2008 New Revision: 50413 URL: http://llvm.org/viewvc/llvm-project?rev=50413&view=rev Log: Improvements for a service environment: - A chunk has to know its allocator. - Statistics are collected when allocating, collecting and destroying - The GC interface exposes new functions to know if an object has been allocated by a specified GC. Modified: vmkit/trunk/lib/Mvm/Allocator/gcchunk.h vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cpp Modified: vmkit/trunk/lib/Mvm/Allocator/gcchunk.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Allocator/gcchunk.h?rev=50413&r1=50412&r2=50413&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Allocator/gcchunk.h (original) +++ vmkit/trunk/lib/Mvm/Allocator/gcchunk.h Tue Apr 29 04:47:44 2008 @@ -24,8 +24,10 @@ uintptr_t _nbb_mark; /* nbb = 0 <=> ce chunk est libre */ /* bit 0-2: la marque */ /* bit 3: est-on collectable */ - public: +#ifdef SERVICE_GC + void* meta; // who allocated me +#endif static const signed int maskCollectable = 8; static const signed int maskNotCollectable = 0; Modified: vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h?rev=50413&r1=50412&r2=50413&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h (original) +++ vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h Tue Apr 29 04:47:44 2008 @@ -13,6 +13,7 @@ #include #include "mvm/GC/GC.h" +#include "types.h" #define gc_allocator std::allocator #define gc_new(Class) __gc_new(Class::VT) Class @@ -63,7 +64,12 @@ class Collector { public: - +#ifdef SERVICE_GC + uint64 memoryUsed; + uint64 gcTriggered; + bool isMyObject(const void* o) { return getCollectorFromObject(o) == this; } + static Collector* getCollectorFromObject(const void*o); +#endif typedef void (*markerFn)(void*); static void initialise(markerFn mark, void *base_sp); Modified: vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp?rev=50413&r1=50412&r2=50413&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp (original) +++ vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp Tue Apr 29 04:47:44 2008 @@ -254,3 +254,9 @@ return GC; } #endif // MULTIPLE_GC + +#ifdef SERVICE_GC +Collector* Collector::getCollectorFromObject(const void* o) { + return (Collector*)GCCollector::o2node((void*)o)->meta; +} +#endif Modified: vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp?rev=50413&r1=50412&r2=50413&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp (original) +++ vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp Tue Apr 29 04:47:44 2008 @@ -87,6 +87,9 @@ GCChunkNode *next; for(cur=finalizable.next(); cur!=&finalizable; cur=next) { +#ifdef SERVICE_GC + ((Collector*)cur->meta)->memoryUsed -= real_nbb(cur); +#endif register gc_header *c = cur->chunk(); next = cur->next(); Modified: vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h?rev=50413&r1=50412&r2=50413&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h (original) +++ vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h Tue Apr 29 04:47:44 2008 @@ -38,6 +38,7 @@ namespace mvm { class GCCollector : public Collector { + friend class Collector; #ifdef HAVE_PTHREAD friend class GCThread; #endif @@ -165,17 +166,23 @@ STATIC inline void *gcmalloc(VirtualTable *vt, size_t n) { lock(); register GCChunkNode *header = allocator->alloc_chunk(n + sizeof(gc_header), 1, current_mark & 1); - +#ifdef SERVICE_GC + header->meta = this; + memoryUsed += n; +#endif header->append(used_nodes); //printf("Allocate %d bytes at %p [%p] %d %d\n", n, header->chunk()->_2gc(), // header, header->nbb(), real_nbb(header)); - register struct gc_header *p = header->chunk(); p->_XXX_vt = vt; _since_last_collection -= n; - if(_enable_auto && (_since_last_collection <= 0)) + if(_enable_auto && (_since_last_collection <= 0)) { +#ifdef SERVICE_GC + ++gcTriggered; +#endif collect_unprotect(); + } unlock(); return p->_2gc(); @@ -192,6 +199,10 @@ size_t old_sz = node->nbb(); GCChunkNode *res = allocator->realloc_chunk(desc, node, n+sizeof(gc_header)); +#ifdef SERVICE_GC + res->meta = this; + memoryUsed += (n - old_sz); +#endif if(res != node) { res->append(used_nodes); @@ -201,8 +212,12 @@ gc_header *obj = res->chunk(); _since_last_collection -= (n - old_sz); - if(_enable_auto && (_since_last_collection <= 0)) + if(_enable_auto && (_since_last_collection <= 0)) { +#ifdef SERVICE_GC + ++gcTriggered; +#endif collect_unprotect(); + } unlock(); return obj->_2gc(); Modified: vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cpp?rev=50413&r1=50412&r2=50413&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cpp (original) +++ vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cpp Tue Apr 29 04:47:44 2008 @@ -28,6 +28,8 @@ void GCCollector::initialise(Collector::markerFn marker) { #ifdef SERVICE_GC + gcTriggered = 0; + memoryUsed = 0; if (this == bootstrapGC) { #endif used_nodes = new GCChunkNode(); From nicolas.geoffray at lip6.fr Tue Apr 29 04:49:03 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 29 Apr 2008 09:49:03 -0000 Subject: [llvm-commits] [vmkit] r50414 - /vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMObject.cpp Message-ID: <200804290949.m3T9n7Ga020839@zion.cs.uiuc.edu> Author: geoffray Date: Tue Apr 29 04:48:58 2008 New Revision: 50414 URL: http://llvm.org/viewvc/llvm-project?rev=50414&view=rev Log: When cloning, allocate the object with the current isolate. Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMObject.cpp Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMObject.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMObject.cpp?rev=50414&r1=50413&r2=50414&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMObject.cpp (original) +++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMObject.cpp Tue Apr 29 04:48:58 2008 @@ -35,7 +35,7 @@ JavaObject* src = (JavaObject*)_src; uint64 size = src->objectSize() + 4; // + VT JavaObject* res = (JavaObject*) - gc::operator new(size, src->getVirtualTable()); + JavaThread::get()->isolate->allocateObject(size, src->getVirtualTable()); memcpy(res, src, size); return (jobject)res; } From nicolas.geoffray at lip6.fr Tue Apr 29 04:51:47 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 29 Apr 2008 09:51:47 -0000 Subject: [llvm-commits] [vmkit] r50415 - in /vmkit/trunk/lib/JnJVM/VMCore: JavaIsolate.cpp JavaJIT.cpp JavaJIT.h JavaJITInitialise.cpp JavaJITOpcodes.cpp JavaObject.cpp JavaRuntimeJIT.cpp ServiceDomain.cpp ServiceDomain.h Message-ID: <200804290951.m3T9pmnk020933@zion.cs.uiuc.edu> Author: geoffray Date: Tue Apr 29 04:51:46 2008 New Revision: 50415 URL: http://llvm.org/viewvc/llvm-project?rev=50415&view=rev Log: In a service environments, locking and unlocking Java objects is allowed when: - the object has been allocated by the current domain - or the method doing the lock is the shared domain, or the framework domain (appClassLoader). Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.h Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp?rev=50415&r1=50414&r2=50415&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp Tue Apr 29 04:51:46 2008 @@ -385,6 +385,7 @@ loadBootstrap(); #ifdef SERVICE_VM (*Classpath::vmdataClassLoader)(appClassLoader, (JavaObject*)this); + Jnjvm::bootstrapVM->appClassLoader = appClassLoader; #endif if (info.agents.size()) { Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp?rev=50415&r1=50414&r2=50415&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Tue Apr 29 04:51:46 2008 @@ -340,6 +340,12 @@ Value* arg = compilingClass->staticVar(this); argsSync.push_back(arg); } +#ifdef SERVICE_VM + if (ServiceDomain::isLockableDomain(compilingClass->isolate)) + llvm::CallInst::Create(aquireObjectInSharedDomainLLVM, argsSync.begin(), + argsSync.end(), "", currentBlock); + else +#endif llvm::CallInst::Create(aquireObjectLLVM, argsSync.begin(), argsSync.end(), "", currentBlock); } @@ -352,6 +358,12 @@ Value* arg = compilingClass->staticVar(this); argsSync.push_back(arg); } +#ifdef SERVICE_VM + if (ServiceDomain::isLockableDomain(compilingClass->isolate)) + llvm::CallInst::Create(releaseObjectInSharedDomainLLVM, argsSync.begin(), + argsSync.end(), "", currentBlock); + else +#endif llvm::CallInst::Create(releaseObjectLLVM, argsSync.begin(), argsSync.end(), "", currentBlock); } Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h?rev=50415&r1=50414&r2=50415&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h Tue Apr 29 04:51:46 2008 @@ -261,6 +261,10 @@ static llvm::Function* instanceOfLLVM; static llvm::Function* aquireObjectLLVM; static llvm::Function* releaseObjectLLVM; +#ifdef SERVICE_VM + static llvm::Function* aquireObjectInSharedDomainLLVM; + static llvm::Function* releaseObjectInSharedDomainLLVM; +#endif static llvm::Function* multiCallNewLLVM; static llvm::Function* runtimeUTF8ToStrLLVM; static llvm::Function* getStaticInstanceLLVM; Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp?rev=50415&r1=50414&r2=50415&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp Tue Apr 29 04:51:46 2008 @@ -546,6 +546,11 @@ aquireObjectLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5jnjvm10JavaObject6aquireEv", module); +#ifdef SERVICE_VM + aquireObjectInSharedDomainLLVM = Function::Create(type, GlobalValue::ExternalLinkage, + "aquireObjectInSharedDomain", + module); +#endif } // Create releaseObjectLLVM @@ -557,6 +562,11 @@ releaseObjectLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5jnjvm10JavaObject6unlockEv", module); +#ifdef SERVICE_VM + releaseObjectInSharedDomainLLVM = Function::Create(type, GlobalValue::ExternalLinkage, + "releaseObjectInSharedDomain", + module); +#endif } Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp?rev=50415&r1=50414&r2=50415&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp Tue Apr 29 04:51:46 2008 @@ -36,9 +36,9 @@ #include "OpcodeNames.def" -#include - - +#ifdef SERVICE_VM +#include "ServiceDomain.h" +#endif using namespace jnjvm; using namespace llvm; @@ -1893,12 +1893,22 @@ case MONITORENTER : { Value* obj = pop(); +#ifdef SERVICE_VM + if (ServiceDomain::isLockableDomain(compilingClass->isolate)) + invoke(aquireObjectInSharedDomainLLVM, obj, "", currentBlock); + else +#endif invoke(aquireObjectLLVM, obj, "", currentBlock); break; } case MONITOREXIT : { Value* obj = pop(); +#ifdef SERVICE_VM + if (ServiceDomain::isLockableDomain(compilingClass->isolate)) + invoke(releaseObjectInSharedDomainLLVM, obj, "", currentBlock); + else +#endif invoke(releaseObjectLLVM, obj, "", currentBlock); break; } Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp?rev=50415&r1=50414&r2=50415&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp Tue Apr 29 04:51:46 2008 @@ -16,6 +16,10 @@ #include "JavaThread.h" #include "Jnjvm.h" +#ifdef SERVICE_VM +#include "ServiceDomain.h" +#endif + using namespace jnjvm; mvm::Lock* JavaObject::globalLock = 0; @@ -113,14 +117,38 @@ } void JavaObject::aquire() { +#ifdef SERVICE_VM + ServiceDomain* vm = (ServiceDomain*)JavaThread::get()->isolate; + if (!(vm->GC->isMyObject(this))) { + vm->serviceError("I'm locking an object I don't own"); + } +#endif myLock(this)->aquire(); } + void JavaObject::unlock() { verifyNull(this); +#ifdef SERVICE_VM + ServiceDomain* vm = (ServiceDomain*)JavaThread::get()->isolate; + if (!(vm->GC->isMyObject(this))) { + vm->serviceError("I'm unlocking an object I don't own"); + } +#endif lockObj->release(); } +#ifdef SERVICE_VM +extern "C" void aquireObjectInSharedDomain(JavaObject* obj) { + myLock(obj)->aquire(); +} + +extern "C" void releaseObjectInSharedDomain(JavaObject* obj) { + verifyNull(obj); + obj->lockObj->release(); +} +#endif + void JavaObject::waitIntern(struct timeval* info, bool timed) { LockObj * l = myLock(this); bool owner = l->owner(); Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp?rev=50415&r1=50414&r2=50415&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp Tue Apr 29 04:51:46 2008 @@ -72,6 +72,11 @@ llvm::Function* JavaJIT::getClassDelegateeLLVM = 0; llvm::Function* JavaJIT::arrayLengthLLVM = 0; +#ifdef SERVICE_VM +llvm::Function* JavaJIT::aquireObjectInSharedDomainLLVM = 0; +llvm::Function* JavaJIT::releaseObjectInSharedDomainLLVM = 0; +#endif + extern "C" JavaString* runtimeUTF8ToStr(const UTF8* val) { Jnjvm* vm = JavaThread::get()->isolate; return vm->UTF8ToStr(val); Modified: vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp?rev=50415&r1=50414&r2=50415&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp Tue Apr 29 04:51:46 2008 @@ -70,6 +70,7 @@ service->GC = Collector::allocate(); #endif + service->classpath = callingVM->classpath; service->bootClasspathEnv = callingVM->bootClasspathEnv; service->libClasspathEnv = callingVM->libClasspathEnv; @@ -81,6 +82,7 @@ service->TheModuleProvider = new JnjvmModuleProvider(service->module, service->functions, service->functionDefs); + #ifdef MULTIPLE_GC mvm::jit::memoryManager->addGCForModule(service->module, service->GC); @@ -111,8 +113,6 @@ service->classes = vm_new(service, ClassMap)(); service->executionTime = 0; - service->memoryUsed = 0; - service->gcTriggered = 0; service->numThreads = 0; service->lock = mvm::Lock::allocNormal(); @@ -121,6 +121,7 @@ void ServiceDomain::serviceError(const char* str) { fprintf(stderr, str); + JavaJIT::printBacktrace(); abort(); } Modified: vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.h?rev=50415&r1=50414&r2=50415&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.h Tue Apr 29 04:51:46 2008 @@ -46,14 +46,17 @@ mvm::Lock* lock; ClassMap* classes; uint64 executionTime; - uint64 memoryUsed; - uint64 gcTriggered; uint64 numThreads; std::map interactions; static ServiceDomain* getDomainFromLoader(JavaObject* loader); static llvm::Function* serviceCallStartLLVM; static llvm::Function* serviceCallStopLLVM; + + static bool isLockableDomain(Jnjvm* vm) { + return (vm == Jnjvm::bootstrapVM || + vm == getDomainFromLoader(Jnjvm::bootstrapVM->appClassLoader)); + } }; } // end namespace jnjvm From nicolas.geoffray at lip6.fr Tue Apr 29 05:33:28 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 29 Apr 2008 10:33:28 -0000 Subject: [llvm-commits] [vmkit] r50416 - in /vmkit/trunk/lib/JnJVM/VMCore: JavaInitialise.cpp NativeUtil.cpp Message-ID: <200804291033.m3TAXV5n022052@zion.cs.uiuc.edu> Author: geoffray Date: Tue Apr 29 05:33:17 2008 New Revision: 50416 URL: http://llvm.org/viewvc/llvm-project?rev=50416&view=rev Log: Output debugging info when crashing. Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp vmkit/trunk/lib/JnJVM/VMCore/NativeUtil.cpp Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp?rev=50416&r1=50415&r2=50416&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp Tue Apr 29 05:33:17 2008 @@ -211,6 +211,7 @@ void handler(int val, siginfo_t* info, void* addr) { printf("Crash in JnJVM at %p\n", addr); + JavaJIT::printBacktrace(); assert(0); } Modified: vmkit/trunk/lib/JnJVM/VMCore/NativeUtil.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/NativeUtil.cpp?rev=50416&r1=50415&r2=50416&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/NativeUtil.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/NativeUtil.cpp Tue Apr 29 05:33:17 2008 @@ -16,6 +16,7 @@ #include "JavaArray.h" #include "JavaClass.h" #include "JavaConstantPool.h" +#include "JavaJIT.h" #include "JavaThread.h" #include "JavaTypes.h" #include "JavaUpcalls.h" @@ -208,7 +209,9 @@ buf = jniConsFromMeth3(cl, meth); res = loadName(buf, jnjvm); if (!res) { - printf("error for %s\n", meth->printString()); + printf("Native function %s not found. Probably " + "not implemented by JnJVM?\n", meth->printString()); + JavaJIT::printBacktrace(); JavaThread::get()->isolate->unknownError("can not find native method %s", meth->printString()); } From nicolas.geoffray at lip6.fr Tue Apr 29 05:34:07 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 29 Apr 2008 10:34:07 -0000 Subject: [llvm-commits] [vmkit] r50417 - /vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp Message-ID: <200804291034.m3TAY8Dr022077@zion.cs.uiuc.edu> Author: geoffray Date: Tue Apr 29 05:34:07 2008 New Revision: 50417 URL: http://llvm.org/viewvc/llvm-project?rev=50417&view=rev Log: Lock the domain when updateing its thread count. Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp?rev=50417&r1=50416&r2=50417&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp (original) +++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp Tue Apr 29 05:34:07 2008 @@ -72,7 +72,10 @@ } #ifdef SERVICE_VM - ((ServiceDomain*)isolate)->numThreads++; + ServiceDomain* vm = (ServiceDomain*)isolate; + vm->lock->lock(); + vm->numThreads++; + vm->lock->unlock(); #endif JavaMethod* method = vmthClass->lookupMethod(Jnjvm::runName, Jnjvm::clinitType, ACC_VIRTUAL, true); method->invokeIntSpecial(isolate, vmThread); @@ -87,7 +90,9 @@ } #ifdef SERVICE_VM - ((ServiceDomain*)isolate)->numThreads--; + vm->lock->lock(); + vm->numThreads--; + vm->lock->unlock(); #endif #ifdef MULTIPLE_GC From nicolas.geoffray at lip6.fr Tue Apr 29 05:34:52 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 29 Apr 2008 10:34:52 -0000 Subject: [llvm-commits] [vmkit] r50418 - /vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMField.cpp Message-ID: <200804291034.m3TAYqxB022111@zion.cs.uiuc.edu> Author: geoffray Date: Tue Apr 29 05:34:52 2008 New Revision: 50418 URL: http://llvm.org/viewvc/llvm-project?rev=50418&view=rev Log: objectFieldOffset is a virtual method, not static. Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMField.cpp Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMField.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMField.cpp?rev=50418&r1=50417&r2=50418&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMField.cpp (original) +++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMField.cpp Tue Apr 29 05:34:52 2008 @@ -376,8 +376,8 @@ JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_objectFieldOffset( #ifdef NATIVE_JNI JNIEnv *env, -jclass clazz, -#endif +#endif +JavaObject* Unsafe, JavaObject* Field) { JavaField* field = (JavaField*)((*Classpath::fieldSlot)((JavaObject*)Field).IntVal.getZExtValue()); return (jlong)field->ptrOffset; From nicolas.geoffray at lip6.fr Tue Apr 29 05:35:33 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 29 Apr 2008 10:35:33 -0000 Subject: [llvm-commits] [vmkit] r50419 - /vmkit/trunk/lib/JnJVM/Classpath/Classpath.cpp Message-ID: <200804291035.m3TAZYQh022139@zion.cs.uiuc.edu> Author: geoffray Date: Tue Apr 29 05:35:32 2008 New Revision: 50419 URL: http://llvm.org/viewvc/llvm-project?rev=50419&view=rev Log: (Unsafe) Implementation of Java_sun_misc_Unsafe_compareAndSwapLong. Modified: vmkit/trunk/lib/JnJVM/Classpath/Classpath.cpp Modified: vmkit/trunk/lib/JnJVM/Classpath/Classpath.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/Classpath.cpp?rev=50419&r1=50418&r2=50419&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Classpath/Classpath.cpp (original) +++ vmkit/trunk/lib/JnJVM/Classpath/Classpath.cpp Tue Apr 29 05:35:32 2008 @@ -92,9 +92,7 @@ else return false; } -} -extern "C" { JNIEXPORT bool JNICALL Java_java_util_concurrent_atomic_AtomicLong_VMSupportsCS8( #ifdef NATIVE_JNI JNIEnv *env, @@ -103,4 +101,27 @@ ) { return false; } + +JNIEXPORT bool JNICALL Java_sun_misc_Unsafe_compareAndSwapLong( +#ifdef NATIVE_JNI + JNIEnv *env, +#endif + JavaObject* unsafe, JavaObject* obj, jlong offset, jlong expect, jlong update) { + + jlong *ptr; + jlong value; + + ptr = (jlong *) (((uint8 *) obj) + offset); + + value = *ptr; + + if (value == expect) { + *ptr = update; + return true; + } else { + return false; + } + +} + } From nicolas.geoffray at lip6.fr Tue Apr 29 09:59:32 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 29 Apr 2008 14:59:32 -0000 Subject: [llvm-commits] [vmkit] r50420 - /vmkit/trunk/lib/Mvm/GCMmap2/gcthread.h Message-ID: <200804291459.m3TExWUw030633@zion.cs.uiuc.edu> Author: geoffray Date: Tue Apr 29 09:59:31 2008 New Revision: 50420 URL: http://llvm.org/viewvc/llvm-project?rev=50420&view=rev Log: In a service environment, all threads contain a meta information, which is the current service it is executing. Modified: vmkit/trunk/lib/Mvm/GCMmap2/gcthread.h Modified: vmkit/trunk/lib/Mvm/GCMmap2/gcthread.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gcthread.h?rev=50420&r1=50419&r2=50420&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/GCMmap2/gcthread.h (original) +++ vmkit/trunk/lib/Mvm/GCMmap2/gcthread.h Tue Apr 29 09:59:31 2008 @@ -25,10 +25,16 @@ int _tid; public: +#ifdef SERVICE_GC + void* meta; +#endif inline GCThreadCollector() {} inline GCThreadCollector(GCThreadCollector *pred, int t, void *p, int m) : CircularBase(pred) { _base_sp = p; _tid = t; +#ifdef SERVICE_GC + meta = 0; +#endif } /* This function is only called in two cases: @@ -71,7 +77,6 @@ }; class GCThread { - GCThreadCollector base; GCLockRecovery _globalLock; /* global lock for gcmalloc */ LockNormal _stackLock; /* stack lock for synchronization */ Cond _stackCond; /* condition for unlocking other tasks (write protect) */ @@ -82,6 +87,7 @@ public: + GCThreadCollector base; Key _loc; GCThread() { _nb_threads = 0; From nicolas.geoffray at lip6.fr Tue Apr 29 10:00:28 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 29 Apr 2008 15:00:28 -0000 Subject: [llvm-commits] [vmkit] r50421 - /vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Message-ID: <200804291500.m3TF0Sh5030673@zion.cs.uiuc.edu> Author: geoffray Date: Tue Apr 29 10:00:28 2008 New Revision: 50421 URL: http://llvm.org/viewvc/llvm-project?rev=50421&view=rev Log: Allow services to invoke "new" between each other. Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp?rev=50421&r1=50420&r2=50421&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Tue Apr 29 10:00:28 2008 @@ -1560,14 +1560,6 @@ ctpInfo->checkInfoOfClass(index); Class* cl = (Class*)(ctpInfo->getMethodClassIfLoaded(index)); -#ifdef SERVICE_VM - if (cl && cl->classLoader != compilingClass->classLoader && - cl->isolate != Jnjvm::bootstrapVM) { - ServiceDomain* vm = (ServiceDomain*)JavaThread::get()->isolate; - assert(vm->getVirtualTable() == ServiceDomain::VT && "vm not a service?"); - vm->serviceError("The service called new on another service"); - } -#endif Value* val = 0; if (!cl || !(cl->isResolved()) #ifndef MULTIPLE_VM From nicolas.geoffray at lip6.fr Tue Apr 29 10:14:19 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 29 Apr 2008 15:14:19 -0000 Subject: [llvm-commits] [vmkit] r50422 - in /vmkit/trunk/lib/JnJVM/VMCore: JavaInitialise.cpp JavaIsolate.cpp JavaObject.cpp ServiceDomain.cpp ServiceDomain.h Message-ID: <200804291514.m3TFEJYD031071@zion.cs.uiuc.edu> Author: geoffray Date: Tue Apr 29 10:14:19 2008 New Revision: 50422 URL: http://llvm.org/viewvc/llvm-project?rev=50422&view=rev Log: For a service environment: - Provide Felix Hooks - Perform thread monitoring - Throw an exception when a service faults Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.h Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp?rev=50422&r1=50421&r2=50422&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp Tue Apr 29 10:14:19 2008 @@ -233,7 +233,7 @@ sa.sa_sigaction = handler; sa.sa_flags |= (SA_RESTART | SA_SIGINFO | SA_NODEFER); sigaction(SIGSEGV, &sa, 0); - + JavaJIT::initialise(); initialiseVT(); initialiseStatics(); @@ -249,7 +249,7 @@ #else #ifdef SERVICE_VM ServiceDomain* vm = ServiceDomain::allocateService((JavaIsolate*)Jnjvm::bootstrapVM); - JavaThread::get()->isolate = vm; + vm->startExecution(); #else JavaIsolate* vm = JavaIsolate::allocateIsolate(JavaIsolate::bootstrapVM); #endif Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp?rev=50422&r1=50421&r2=50422&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp Tue Apr 29 10:14:19 2008 @@ -384,8 +384,7 @@ loadBootstrap(); #ifdef SERVICE_VM - (*Classpath::vmdataClassLoader)(appClassLoader, (JavaObject*)this); - Jnjvm::bootstrapVM->appClassLoader = appClassLoader; + ServiceDomain::initialise((ServiceDomain*)this); #endif if (info.agents.size()) { Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp?rev=50422&r1=50421&r2=50422&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp Tue Apr 29 10:14:19 2008 @@ -120,7 +120,7 @@ #ifdef SERVICE_VM ServiceDomain* vm = (ServiceDomain*)JavaThread::get()->isolate; if (!(vm->GC->isMyObject(this))) { - vm->serviceError("I'm locking an object I don't own"); + vm->serviceError(vm, "I'm locking an object I don't own"); } #endif myLock(this)->aquire(); @@ -132,7 +132,7 @@ #ifdef SERVICE_VM ServiceDomain* vm = (ServiceDomain*)JavaThread::get()->isolate; if (!(vm->GC->isMyObject(this))) { - vm->serviceError("I'm unlocking an object I don't own"); + vm->serviceError(vm, "I'm unlocking an object I don't own"); } #endif lockObj->release(); Modified: vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp?rev=50422&r1=50421&r2=50422&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp Tue Apr 29 10:14:19 2008 @@ -27,6 +27,14 @@ llvm::Function* ServiceDomain::serviceCallStartLLVM; llvm::Function* ServiceDomain::serviceCallStopLLVM; +JavaMethod* ServiceDomain::ServiceErrorInit; +Class* ServiceDomain::ServiceErrorClass; +ServiceDomain* ServiceDomain::bootstrapDomain; + +// OSGi specific fields +JavaField* ServiceDomain::OSGiFramework; +JavaMethod* ServiceDomain::uninstallBundle; + GlobalVariable* ServiceDomain::llvmDelegatee() { if (!_llvmDelegatee) { @@ -116,13 +124,22 @@ service->numThreads = 0; service->lock = mvm::Lock::allocNormal(); + service->state = DomainLoaded; return service; } -void ServiceDomain::serviceError(const char* str) { - fprintf(stderr, str); - JavaJIT::printBacktrace(); - abort(); +void ServiceDomain::serviceError(ServiceDomain* errorDomain, + const char* str) { + if (ServiceErrorClass) { + JavaObject* obj = (*ServiceErrorClass)(bootstrapDomain); + ServiceErrorInit->invokeIntVirtual(bootstrapDomain, + bootstrapDomain->asciizToStr(str), + errorDomain); + JavaThread::throwException(obj); + } else { + fprintf(stderr, str); + abort(); + } } ServiceDomain* ServiceDomain::getDomainFromLoader(JavaObject* loader) { @@ -131,6 +148,9 @@ return vm; } +#include "gccollector.h" +#include "gcthread.h" + extern "C" void serviceCallStart(ServiceDomain* caller, ServiceDomain* callee) { assert(caller && "No caller in service start?"); @@ -139,11 +159,16 @@ "Caller not a service domain?"); assert(callee->getVirtualTable() == ServiceDomain::VT && "Callee not a service domain?"); + if (callee->state != DomainLoaded) { + ServiceDomain::serviceError(callee, "calling a stopped bundle"); + } JavaThread* th = JavaThread::get(); th->isolate = callee; caller->lock->lock(); caller->interactions[callee]++; caller->lock->unlock(); + mvm::GCThreadCollector* cur = mvm::GCCollector::threads->myloc(); + cur->meta = callee; } extern "C" void serviceCallStop(ServiceDomain* caller, @@ -154,7 +179,53 @@ "Caller not a service domain?"); assert(callee->getVirtualTable() == ServiceDomain::VT && "Callee not a service domain?"); + if (caller->state != DomainLoaded) { + ServiceDomain::serviceError(caller, "Returning to a stopped bundle"); + } JavaThread* th = JavaThread::get(); th->isolate = caller; + mvm::GCThreadCollector* cur = mvm::GCCollector::threads->myloc(); + cur->meta = caller; } + +static int updateCPUUsage(void* unused) { + mvm::GCThreadCollector *cur; + while (true) { + sleep(1); + for(cur=(mvm::GCThreadCollector *)mvm::GCCollector::threads->base.next(); + cur!=&(mvm::GCCollector::threads->base); + cur=(mvm::GCThreadCollector *)cur->next()) { + ServiceDomain* executingDomain = (ServiceDomain*)cur->meta; + if (executingDomain) + ++executingDomain->executionTime; + } + } +} + +void ServiceDomain::initialise(ServiceDomain* boot) { + ServiceDomain::bootstrapDomain = boot; + Jnjvm::bootstrapVM->appClassLoader = boot->appClassLoader; + (*Classpath::vmdataClassLoader)(boot->appClassLoader, (JavaObject*)boot); + int tid = 0; + mvm::Thread::start(&tid, (int (*)(void *))updateCPUUsage, 0); + ServiceErrorClass = UPCALL_CLASS(Jnjvm::bootstrapVM, "JnJVMBundleException"); + ServiceErrorInit = UPCALL_METHOD(Jnjvm::bootstrapVM, "JnjvmBundleException", + "", + "(Ljava/lang/String;Ljava/lang/Object;)V", + ACC_VIRTUAL); + Class* MainClass = bootstrapDomain->constructClass(bootstrapDomain->asciizConstructUTF8("Main"), + Jnjvm::bootstrapVM->appClassLoader); + OSGiFramework = bootstrapDomain->constructField(MainClass, bootstrapDomain->asciizConstructUTF8("m_felix"), + bootstrapDomain->asciizConstructUTF8("Lorg/apache/felix/framework/Felix;"), + ACC_STATIC); + uninstallBundle = bootstrapDomain->constructMethod(OSGiFramework->classDef, bootstrapDomain->asciizConstructUTF8("uninstallBundle"), + bootstrapDomain->asciizConstructUTF8("(Lorg/apache/felix/framework/FelixBundle;)V"), + ACC_VIRTUAL); +} + +void ServiceDomain::startExecution() { + JavaThread::get()->isolate = this; + mvm::GCThreadCollector* cur = mvm::GCCollector::threads->myloc(); + cur->meta = this; +} Modified: vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.h?rev=50422&r1=50421&r2=50422&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.h Tue Apr 29 10:14:19 2008 @@ -30,6 +30,10 @@ class ClassMap; +typedef enum DomainState { + DomainLoaded, DomainUnloading, DomainUnloaded +}DomainState; + class ServiceDomain : public JavaIsolate { private: llvm::GlobalVariable* _llvmDelegatee; @@ -41,22 +45,34 @@ virtual void destroyer(size_t sz); static ServiceDomain* allocateService(JavaIsolate* callingVM); llvm::GlobalVariable* llvmDelegatee(); - void serviceError(const char* str); - + static void serviceError(ServiceDomain* error, const char* str); + mvm::Lock* lock; ClassMap* classes; uint64 executionTime; uint64 numThreads; std::map interactions; + DomainState state; static ServiceDomain* getDomainFromLoader(JavaObject* loader); static llvm::Function* serviceCallStartLLVM; static llvm::Function* serviceCallStopLLVM; + static JavaMethod* ServiceErrorInit; + static Class* ServiceErrorClass; + + static ServiceDomain* bootstrapDomain; static bool isLockableDomain(Jnjvm* vm) { - return (vm == Jnjvm::bootstrapVM || - vm == getDomainFromLoader(Jnjvm::bootstrapVM->appClassLoader)); + return (vm == Jnjvm::bootstrapVM || vm == bootstrapDomain); } + + static void initialise(ServiceDomain* boot); + void startExecution(); + + // OSGi specific fields + static JavaField* OSGiFramework; + static JavaMethod* uninstallBundle; + }; } // end namespace jnjvm From kremenek at apple.com Tue Apr 29 10:50:33 2008 From: kremenek at apple.com (Ted Kremenek) Date: Tue, 29 Apr 2008 15:50:33 -0000 Subject: [llvm-commits] [llvm] r50423 - /llvm/tags/checker/checker-15/ Message-ID: <200804291550.m3TFoXRe032243@zion.cs.uiuc.edu> Author: kremenek Date: Tue Apr 29 10:50:33 2008 New Revision: 50423 URL: http://llvm.org/viewvc/llvm-project?rev=50423&view=rev Log: Tagging checker-15. Added: llvm/tags/checker/checker-15/ - copied from r50422, llvm/trunk/ From nicolas.geoffray at lip6.fr Tue Apr 29 10:56:41 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 29 Apr 2008 15:56:41 -0000 Subject: [llvm-commits] [vmkit] r50425 - /vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp Message-ID: <200804291556.m3TFufxP032450@zion.cs.uiuc.edu> Author: geoffray Date: Tue Apr 29 10:56:41 2008 New Revision: 50425 URL: http://llvm.org/viewvc/llvm-project?rev=50425&view=rev Log: In a service environment, when creating a thread, call the ServiceDomain::startExecution. Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp?rev=50425&r1=50424&r2=50425&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp (original) +++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp Tue Apr 29 10:56:41 2008 @@ -73,6 +73,7 @@ #ifdef SERVICE_VM ServiceDomain* vm = (ServiceDomain*)isolate; + vm->startExecution(); vm->lock->lock(); vm->numThreads++; vm->lock->unlock(); From dpatel at apple.com Tue Apr 29 11:12:45 2008 From: dpatel at apple.com (Devang Patel) Date: Tue, 29 Apr 2008 09:12:45 -0700 Subject: [llvm-commits] [llvm] r50406 - /llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp In-Reply-To: <200804290634.m3T6YuaF006914@zion.cs.uiuc.edu> References: <200804290634.m3T6YuaF006914@zion.cs.uiuc.edu> Message-ID: <8DF7489E-A913-4A81-B639-65AAC61A74DD@apple.com> Thanks! On Apr 28, 2008, at 11:34 PM, Owen Anderson wrote: > Author: resistor > Date: Tue Apr 29 01:34:55 2008 > New Revision: 50406 > > URL: http://llvm.org/viewvc/llvm-project?rev=50406&view=rev > Log: > Clarify what we mean by a dead loop. > > Modified: > llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp > > Modified: llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp?rev=50406&r1=50405&r2=50406&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp > (original) > +++ llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp Tue Apr > 29 01:34:55 2008 > @@ -126,6 +126,10 @@ > return true; > } > > +/// runOnLoop - Remove dead loops, by which we mean loops that do > not impact the > +/// observable behavior of the program other than finite running > time. Note > +/// we do ensure that this never remove a loop that might be > infinite, as doing > +/// so could change the halting/non-halting nature of a program. > bool DeadLoopElimination::runOnLoop(Loop* L, LPPassManager& LPM) { > // Don't remove loops for which we can't solve the trip count. > // They could be infinite, in which case we'd be changing program > behavior. > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits - Devang From asl at math.spbu.ru Tue Apr 29 11:42:52 2008 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Tue, 29 Apr 2008 16:42:52 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50427 - in /llvm-gcc-4.2/trunk/gcc: c-format.c c-format.h config.gcc config/i386/msformat-c.c config/i386/t-cygming doc/extend.texi doc/tm.texi Message-ID: <200804291642.m3TGgrB5001816@zion.cs.uiuc.edu> Author: asl Date: Tue Apr 29 11:42:52 2008 New Revision: 50427 URL: http://llvm.org/viewvc/llvm-project?rev=50427&view=rev Log: Temporary revert ms-format patch Removed: llvm-gcc-4.2/trunk/gcc/config/i386/msformat-c.c Modified: llvm-gcc-4.2/trunk/gcc/c-format.c llvm-gcc-4.2/trunk/gcc/c-format.h llvm-gcc-4.2/trunk/gcc/config.gcc llvm-gcc-4.2/trunk/gcc/config/i386/t-cygming llvm-gcc-4.2/trunk/gcc/doc/extend.texi llvm-gcc-4.2/trunk/gcc/doc/tm.texi Modified: llvm-gcc-4.2/trunk/gcc/c-format.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/c-format.c?rev=50427&r1=50426&r2=50427&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/c-format.c (original) +++ llvm-gcc-4.2/trunk/gcc/c-format.c Tue Apr 29 11:42:52 2008 @@ -63,13 +63,13 @@ gcc_diag_format_type, gcc_tdiag_format_type, gcc_cdiag_format_type, gcc_cxxdiag_format_type, gcc_gfc_format_type, + scanf_format_type, strftime_format_type, /* APPLE LOCAL begin radar 4985544 */ - nsstring_format_type, - /* APPLE LOCAL end radar 4985544 */ - /* APPLE LOCAL begin radar 5096648 */ - cfstring_format_type, - /* APPLE LOCAL end radar 5096648 */ + strfmon_format_type, nsstring_format_type, + /* APPLE LOCAL radar 5096648 */ + cfstring_format_type, format_type_error = -1}; + /* APPLE LOCAL end radar 4985544 */ typedef struct function_format_info { @@ -87,10 +87,6 @@ static bool get_constant (tree expr, unsigned HOST_WIDE_INT *value, int validated_p); -/* LLVM LOCAL begin mainline */ -static const char *convert_format_name_to_system_name (const char *attr_name); -static bool cmp_attribs (const char *tattr_name, const char *attr_name); -/* LLVM LOCAL end mainline */ /* Handle a "format_arg" attribute; arguments as in struct attribute_spec.handler. */ @@ -213,10 +209,6 @@ { const char *p = IDENTIFIER_POINTER (format_type_id); - /* LLVM LOCAL begin mainline */ - p = convert_format_name_to_system_name (p); - /* LLVM LOCAL end mainline */ - info->format_type = decode_format_type (p); /* APPLE LOCAL begin radar 4985544 */ @@ -733,9 +725,7 @@ /* This must be in the same order as enum format_type. */ static const format_kind_info format_types_orig[] = { - /* LLVM LOCAL begin mainline */ - { "gnu_printf", printf_length_specs, print_char_table, " +#0-'I", NULL, - /* LLVM LOCAL end mainline */ + { "printf", printf_length_specs, print_char_table, " +#0-'I", NULL, printf_flag_specs, printf_flag_pairs, FMT_FLAG_ARG_CONVERT|FMT_FLAG_DOLLAR_MULTIPLE|FMT_FLAG_USE_DOLLAR|FMT_FLAG_EMPTY_PREC_OK, 'w', 0, 'p', 0, 'L', @@ -777,29 +767,23 @@ 0, 0, 0, 0, 0, NULL, NULL }, - /* LLVM LOCAL begin mainline */ - { "gnu_scanf", scanf_length_specs, scan_char_table, "*'I", NULL, - /* LLVM LOCAL end mainline */ + { "scanf", scanf_length_specs, scan_char_table, "*'I", NULL, scanf_flag_specs, scanf_flag_pairs, FMT_FLAG_ARG_CONVERT|FMT_FLAG_SCANF_A_KLUDGE|FMT_FLAG_USE_DOLLAR|FMT_FLAG_ZERO_WIDTH_BAD|FMT_FLAG_DOLLAR_GAP_POINTER_OK, 'w', 0, 0, '*', 'L', NULL, NULL }, - /* LLVM LOCAL begin mainline */ - { "gnu_strftime", NULL, time_char_table, "_-0^#", "EO", - /* LLVM LOCAL end mainline */ + { "strftime", NULL, time_char_table, "_-0^#", "EO", strftime_flag_specs, strftime_flag_pairs, FMT_FLAG_FANCY_PERCENT_OK, 'w', 0, 0, 0, 0, NULL, NULL }, - /* LLVM LOCAL begin mainline */ - { "gnu_strfmon", strfmon_length_specs, monetary_char_table, "=^+(!-", NULL, - /* LLVM LOCAL end mainline */ + { "strfmon", strfmon_length_specs, monetary_char_table, "=^+(!-", NULL, strfmon_flag_specs, strfmon_flag_pairs, FMT_FLAG_ARG_CONVERT, 'w', '#', 'p', 0, 'L', NULL, NULL +/* APPLE LOCAL begin radar 4985544 */ }, - /* APPLE LOCAL begin radar 4985544 */ { "NSString", NULL, NULL, NULL, NULL, NULL, NULL, FMT_FLAG_ARG_CONVERT, 0, 0, 0, 0, 0, @@ -887,10 +871,6 @@ { int i; int slen; - - /* LLVM LOCAL begin mainline */ - s = convert_format_name_to_system_name (s); - /* LLVM LOCAL end mainline */ slen = strlen (s); for (i = 0; i < n_format_types; i++) { @@ -1825,25 +1805,8 @@ length_chars_std = STD_C89; if (fli) { - /* LLVM LOCAL begin mainline */ while (fli->name != 0 && fli->name[0] != *format_chars) - { - if (fli->name[0] == '\0') - { - int si = strlen (fli->name + 1) + 1; - int i = 1; - while (fli->name[i] != 0 && fli->name[i] == format_chars [i - 1]) - ++i; - if (si == i) - { - if (si > 2) - format_chars += si - 2; - break; - } - } - fli++; - } - /* LLVM LOCAL end mainline */ + fli++; if (fli->name != 0) { format_chars++; @@ -2785,86 +2748,6 @@ extern const format_kind_info TARGET_FORMAT_TYPES[]; #endif -/* LLVM LOCAL begin mainline */ -#ifdef TARGET_OVERRIDES_FORMAT_ATTRIBUTES -extern const target_ovr_attr TARGET_OVERRIDES_FORMAT_ATTRIBUTES[]; -#endif - -/* Attributes such as "printf" are equivalent to those such as - "gnu_printf" unless this is overridden by a target. */ -static const target_ovr_attr gnu_target_overrides_format_attributes[] = -{ - { "gnu_printf", "printf" }, - { "gnu_scanf", "scanf" }, - { "gnu_strftime", "strftime" }, - { "gnu_strfmon", "strfmon" }, - { NULL, NULL } -}; - -/* Translate to unified attribute name. This is used in decode_format_type and - decode_format_attr. In attr_name the user specified argument is passed. It - returns the unified format name from TARGET_OVERRIDES_FORMAT_ATTRIBUTES - or the attr_name passed to this function, if there is no matching entry. */ -static const char * -convert_format_name_to_system_name (const char *attr_name) -{ - int i; - - if (attr_name == NULL || *attr_name == 0 - || strncmp (attr_name, "gcc_", 4) == 0) - return attr_name; - -#ifdef TARGET_OVERRIDES_FORMAT_ATTRIBUTES - /* Check if format attribute is overridden by target. */ - if (TARGET_OVERRIDES_FORMAT_ATTRIBUTES != NULL - && TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT > 0) - { - for (i = 0; i < TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT; ++i) - { - if (cmp_attribs (TARGET_OVERRIDES_FORMAT_ATTRIBUTES[i].named_attr_src, - attr_name)) - return attr_name; - if (cmp_attribs (TARGET_OVERRIDES_FORMAT_ATTRIBUTES[i].named_attr_dst, - attr_name)) - return TARGET_OVERRIDES_FORMAT_ATTRIBUTES[i].named_attr_src; - } - } -#endif - /* Otherwise default to gnu format. */ - for (i = 0; - gnu_target_overrides_format_attributes[i].named_attr_src != NULL; - ++i) - { - if (cmp_attribs (gnu_target_overrides_format_attributes[i].named_attr_src, - attr_name)) - return attr_name; - if (cmp_attribs (gnu_target_overrides_format_attributes[i].named_attr_dst, - attr_name)) - return gnu_target_overrides_format_attributes[i].named_attr_src; - } - - return attr_name; -} - -/* Return true if TATTR_NAME and ATTR_NAME are the same format attribute, - counting "name" and "__name__" as the same, false otherwise. */ -static bool -cmp_attribs (const char *tattr_name, const char *attr_name) -{ - int alen = strlen (attr_name); - int slen = (tattr_name ? strlen (tattr_name) : 0); - if (alen > 4 && attr_name[0] == '_' && attr_name[1] == '_' - && attr_name[alen - 1] == '_' && attr_name[alen - 2] == '_') - { - attr_name += 2; - alen -= 4; - } - if (alen != slen || strncmp (tattr_name, attr_name, alen) != 0) - return false; - return true; -} -/* LLVM LOCAL end mainline */ - /* Handle a "format" attribute; arguments as in struct attribute_spec.handler. */ tree @@ -2939,12 +2822,7 @@ } } - /* LLVM LOCAL begin mainline */ - /* Check if this is a strftime variant. Just for this variant - FMT_FLAG_ARG_CONVERT is not set. */ - if ((format_types[info.format_type].flags & (int) FMT_FLAG_ARG_CONVERT) == 0 - && info.first_arg_num != 0) - /* LLVM LOCAL end mainline */ + if (info.format_type == strftime_format_type && info.first_arg_num != 0) { error ("strftime formats cannot format arguments"); *no_add_attrs = true; Modified: llvm-gcc-4.2/trunk/gcc/c-format.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/c-format.h?rev=50427&r1=50426&r2=50427&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/c-format.h (original) +++ llvm-gcc-4.2/trunk/gcc/c-format.h Tue Apr 29 11:42:52 2008 @@ -81,15 +81,12 @@ of whether length modifiers can occur (length_char_specs). */ }; + /* Structure describing a length modifier supported in format checking, and possibly a doubled version such as "hh". */ typedef struct { - /* LLVM LOCAL begin mainline */ - /* Name of the single-character length modifier. If prefixed by - a zero character, it describes a multi character length - modifier, like I64, I32, etc. */ - /* LLVM LOCAL end mainline */ + /* Name of the single-character length modifier. */ const char *name; /* Index into a format_char_info.types array. */ enum format_lengths index; @@ -308,18 +305,4 @@ #define T_D128 &dfloat128_type_node #define TEX_D128 { STD_EXT, "_Decimal128", T_D128 } -/* LLVM LOCAL begin mainline */ -/* Structure describing how format attributes such as "printf" are - interpreted as "gnu_printf" or "ms_printf" on a particular system. - TARGET_OVERRIDES_FORMAT_ATTRIBUTES is used to specify target-specific - defaults. */ -typedef struct -{ - /* The name of the to be copied format attribute. */ - const char *named_attr_src; - /* The name of the to be overridden format attribute. */ - const char *named_attr_dst; -} target_ovr_attr; -/* LLVM LOCAL end mainline */ - #endif /* GCC_C_FORMAT_H */ Modified: llvm-gcc-4.2/trunk/gcc/config.gcc URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config.gcc?rev=50427&r1=50426&r2=50427&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config.gcc (original) +++ llvm-gcc-4.2/trunk/gcc/config.gcc Tue Apr 29 11:42:52 2008 @@ -1326,8 +1326,8 @@ extra_options="${extra_options} i386/cygming.opt" extra_objs="winnt.o winnt-stubs.o" # LLVM LOCAL begin mainline - c_target_objs="cygwin2.o msformat-c.o" - cxx_target_objs="cygwin2.o winnt-cxx.o msformat-c.o" + c_target_objs="cygwin2.o" + cxx_target_objs="cygwin2.o winnt-cxx.o" # LLVM LOCAL end mainline extra_gcc_objs=cygwin1.o extra_parts="crtbegin.o crtend.o" @@ -1345,8 +1345,7 @@ extra_options="${extra_options} i386/cygming.opt" extra_objs="winnt.o winnt-stubs.o" # LLVM LOCAL begin mainline - c_target_objs="msformat-c.o" - cxx_target_objs="winnt-cxx.o msformat-c.o" + cxx_target_objs="winnt-cxx.o" default_use_cxa_atexit=yes # LLVM LOCAL end mainline extra_parts="crtbegin.o crtend.o" Removed: llvm-gcc-4.2/trunk/gcc/config/i386/msformat-c.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/msformat-c.c?rev=50426&view=auto ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/msformat-c.c (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/msformat-c.c (removed) @@ -1,175 +0,0 @@ -/* Check calls to formatted I/O functions (-Wformat). - Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, - 2001, 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc. - -This file is part of GCC. - -GCC is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 3, or (at your option) any later -version. - -GCC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with GCC; see the file COPYING3. If not see -. */ - -#include "config.h" -#include "system.h" -#include "coretypes.h" -#include "tm.h" -#include "tree.h" -#include "flags.h" -#include "c-common.h" -#include "toplev.h" -#include "intl.h" -#include "diagnostic.h" -#include "langhooks.h" -#include "c-format.h" -#include "alloc-pool.h" - -/* Mingw specific format attributes ms_printf, ms_scanf, and ms_strftime. */ - -static const format_length_info ms_printf_length_specs[] = -{ - { "h", FMT_LEN_h, STD_C89, NULL, 0, 0 }, - { "l", FMT_LEN_l, STD_C89, NULL, 0, 0 }, - { "I32", FMT_LEN_l, STD_EXT, NULL, 0, 0 }, - { "I64", FMT_LEN_ll, STD_EXT, NULL, 0, 0 }, - { "I", FMT_LEN_L, STD_EXT, NULL, 0, 0 }, - { NULL, 0, 0, NULL, 0, 0 } -}; - -static const format_flag_spec ms_printf_flag_specs[] = -{ - { ' ', 0, 0, N_("' ' flag"), N_("the ' ' printf flag"), STD_C89 }, - { '+', 0, 0, N_("'+' flag"), N_("the '+' printf flag"), STD_C89 }, - { '#', 0, 0, N_("'#' flag"), N_("the '#' printf flag"), STD_C89 }, - { '0', 0, 0, N_("'0' flag"), N_("the '0' printf flag"), STD_C89 }, - { '-', 0, 0, N_("'-' flag"), N_("the '-' printf flag"), STD_C89 }, - { '\'', 0, 0, N_("''' flag"), N_("the ''' printf flag"), STD_EXT }, - { 'w', 0, 0, N_("field width"), N_("field width in printf format"), STD_C89 }, - { 'p', 0, 0, N_("precision"), N_("precision in printf format"), STD_C89 }, - { 'L', 0, 0, N_("length modifier"), N_("length modifier in printf format"), STD_C89 }, - { 0, 0, 0, NULL, NULL, 0 } -}; - -static const format_flag_pair ms_printf_flag_pairs[] = -{ - { ' ', '+', 1, 0 }, - { '0', '-', 1, 0 }, { '0', 'p', 1, 'i' }, - { 0, 0, 0, 0 } -}; - -static const format_flag_spec ms_scanf_flag_specs[] = -{ - { '*', 0, 0, N_("assignment suppression"), N_("the assignment suppression scanf feature"), STD_C89 }, - { 'a', 0, 0, N_("'a' flag"), N_("the 'a' scanf flag"), STD_EXT }, - { 'w', 0, 0, N_("field width"), N_("field width in scanf format"), STD_C89 }, - { 'L', 0, 0, N_("length modifier"), N_("length modifier in scanf format"), STD_C89 }, - { '\'', 0, 0, N_("''' flag"), N_("the ''' scanf flag"), STD_EXT }, - { 0, 0, 0, NULL, NULL, 0 } -}; - -static const format_flag_pair ms_scanf_flag_pairs[] = -{ - { '*', 'L', 0, 0 }, - { 0, 0, 0, 0 } -}; - -static const format_flag_spec ms_strftime_flag_specs[] = -{ - { '#', 0, 0, N_("'#' flag"), N_("the '#' strftime flag"), STD_EXT }, - { 0, 0, 0, NULL, NULL, 0 } -}; - -static const format_flag_pair ms_strftime_flag_pairs[] = -{ - { 0, 0, 0, 0 } -}; - -static const format_char_info ms_print_char_table[] = -{ - /* C89 conversion specifiers. */ - { "di", 0, STD_C89, { T89_I, BADLEN, T89_S, T89_L, T9L_LL, T99_SST, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0 +'", "i", NULL }, - { "oxX", 0, STD_C89, { T89_UI, BADLEN, T89_US, T89_UL, T9L_ULL, T99_ST, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0#", "i", NULL }, - { "u", 0, STD_C89, { T89_UI, BADLEN, T89_US, T89_UL, T9L_ULL, T99_ST, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0'", "i", NULL }, - { "fgG", 0, STD_C89, { T89_D, BADLEN, BADLEN, T99_D, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0 +#'", "", NULL }, - { "eE", 0, STD_C89, { T89_D, BADLEN, BADLEN, T99_D, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0 +#", "", NULL }, - { "c", 0, STD_C89, { T89_I, BADLEN, T89_S, T94_WI, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-w", "", NULL }, - { "s", 1, STD_C89, { T89_C, BADLEN, T89_S, T94_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "cR", NULL }, - { "p", 1, STD_C89, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-w", "c", NULL }, - { "n", 1, STD_C89, { T89_I, BADLEN, T89_S, T89_L, T9L_LL, BADLEN, BADLEN, BADLEN, T99_IM, BADLEN, BADLEN, BADLEN }, "", "W", NULL }, - /* X/Open conversion specifiers. */ - { "C", 0, STD_EXT, { TEX_WI, BADLEN, T89_S, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-w", "", NULL }, - { "S", 1, STD_EXT, { TEX_W, BADLEN, T89_S, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "R", NULL }, - { NULL, 0, 0, NOLENGTHS, NULL, NULL, NULL } -}; - -static const format_char_info ms_scan_char_table[] = -{ - /* C89 conversion specifiers. */ - { "di", 1, STD_C89, { T89_I, BADLEN, T89_S, T89_L, T9L_LL, T99_SST, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w'", "W", NULL }, - { "u", 1, STD_C89, { T89_UI, BADLEN, T89_US, T89_UL, T9L_ULL, T99_ST, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w'", "W", NULL }, - { "oxX", 1, STD_C89, { T89_UI, BADLEN, T89_US, T89_UL, T9L_ULL, T99_ST, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w", "W", NULL }, - { "efgEG", 1, STD_C89, { T89_F, BADLEN, BADLEN, T89_D, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w'", "W", NULL }, - { "c", 1, STD_C89, { T89_C, BADLEN, T89_S, T94_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w", "cW", NULL }, - { "s", 1, STD_C89, { T89_C, BADLEN, T89_S, T94_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*aw", "cW", NULL }, - { "[", 1, STD_C89, { T89_C, BADLEN, BADLEN, T94_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*aw", "cW[", NULL }, - { "p", 2, STD_C89, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w", "W", NULL }, - { "n", 1, STD_C89, { T89_I, BADLEN, T89_S, T89_L, T9L_LL, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "W", NULL }, - /* X/Open conversion specifiers. */ - { "C", 1, STD_EXT, { TEX_W, BADLEN, T89_S, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*w", "W", NULL }, - { "S", 1, STD_EXT, { TEX_W, BADLEN, T89_S, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "*aw", "W", NULL }, - { NULL, 0, 0, NOLENGTHS, NULL, NULL, NULL } -}; - -static const format_char_info ms_time_char_table[] = -{ - /* C89 conversion specifiers. */ - { "ABZab", 0, STD_C89, NOLENGTHS, "#", "", NULL }, - { "cx", 0, STD_C89, NOLENGTHS, "#", "3", NULL }, - { "HIMSUWdmw", 0, STD_C89, NOLENGTHS, "#", "", NULL }, - { "j", 0, STD_C89, NOLENGTHS, "#", "", NULL }, - { "p", 0, STD_C89, NOLENGTHS, "#", "", NULL }, - { "X", 0, STD_C89, NOLENGTHS, "#", "", NULL }, - { "y", 0, STD_C89, NOLENGTHS, "#", "4", NULL }, - { "Y", 0, STD_C89, NOLENGTHS, "#", "", NULL }, - { "%", 0, STD_C89, NOLENGTHS, "", "", NULL }, - /* C99 conversion specifiers. */ - { "z", 0, STD_C99, NOLENGTHS, "#", "", NULL }, - { NULL, 0, 0, NOLENGTHS, NULL, NULL, NULL } -}; - -const format_kind_info mingw_format_attributes[3] = -{ - { "ms_printf", ms_printf_length_specs, ms_print_char_table, " +#0-'", NULL, - ms_printf_flag_specs, ms_printf_flag_pairs, - FMT_FLAG_ARG_CONVERT|FMT_FLAG_DOLLAR_MULTIPLE|FMT_FLAG_USE_DOLLAR|FMT_FLAG_EMPTY_PREC_OK, - 'w', 0, 'p', 0, 'L', - &integer_type_node, &integer_type_node - }, - { "ms_scanf", ms_printf_length_specs, ms_scan_char_table, "*'", NULL, - ms_scanf_flag_specs, ms_scanf_flag_pairs, - FMT_FLAG_ARG_CONVERT|FMT_FLAG_SCANF_A_KLUDGE|FMT_FLAG_USE_DOLLAR|FMT_FLAG_ZERO_WIDTH_BAD|FMT_FLAG_DOLLAR_GAP_POINTER_OK, - 'w', 0, 0, '*', 'L', - NULL, NULL - }, - { "ms_strftime", NULL, ms_time_char_table, "", "#", - ms_strftime_flag_specs, ms_strftime_flag_pairs, - FMT_FLAG_FANCY_PERCENT_OK, 0, 0, 0, 0, 0, - NULL, NULL - } -}; - -/* Default overrides for printf, scanf and strftime. */ -const target_ovr_attr mingw_format_attribute_overrides[4] = -{ - { "ms_printf", "printf" }, - { "ms_scanf", "scanf" }, - { "ms_strftime", "strftime" } -}; Modified: llvm-gcc-4.2/trunk/gcc/config/i386/t-cygming URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/t-cygming?rev=50427&r1=50426&r2=50427&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/t-cygming (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/t-cygming Tue Apr 29 11:42:52 2008 @@ -29,14 +29,6 @@ $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ $(srcdir)/config/i386/winnt-stubs.c -# LLVM LOCAL begin mainline -msformat-c.o: $(srcdir)/config/i386/msformat-c.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ - $(TM_H) $(RTL_H) $(REGS_H) hard-reg-set.h output.h $(TREE_H) flags.h \ - $(TM_P_H) toplev.h $(HASHTAB_H) $(GGC_H) - $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ - $(srcdir)/config/i386/msformat-c.c -# LLVM LOCAL end mainline - STMP_FIXINC=stmp-fixinc # LLVM LOCAL begin mainline 125696 Modified: llvm-gcc-4.2/trunk/gcc/doc/extend.texi URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/doc/extend.texi?rev=50427&r1=50426&r2=50427&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/doc/extend.texi (original) +++ llvm-gcc-4.2/trunk/gcc/doc/extend.texi Tue Apr 29 11:42:52 2008 @@ -1914,31 +1914,20 @@ for consistency with the @code{printf} style format string argument @code{my_format}. - at c LLVM LOCAL begin mainline The parameter @var{archetype} determines how the format string is -interpreted, and should be @code{printf}, @code{scanf}, @code{strftime}, - at code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or - at code{strfmon}. (You can also use @code{__printf__}, - at code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.) On -MinGW targets, @code{ms_printf}, @code{ms_scanf}, and - at code{ms_strftime} are also present. - at var{archtype} values such as @code{printf} refer to the formats accepted -by the system's C run-time library, while @code{gnu_} values always refer -to the formats accepted by the GNU C Library. On Microsoft Windows -targets, @code{ms_} values refer to the formats accepted by the - at file{msvcrt.dll} library. -The parameter @var{string-index} -specifies which argument is the format string argument (starting -from 1), while @var{first-to-check} is the number of the first -argument to check against the format string. For functions -where the arguments are not available to be checked (such as +interpreted, and should be @code{printf}, @code{scanf}, @code{strftime} +or @code{strfmon}. (You can also use @code{__printf__}, + at code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.) The +parameter @var{string-index} specifies which argument is the format +string argument (starting from 1), while @var{first-to-check} is the +number of the first argument to check against the format string. For +functions where the arguments are not available to be checked (such as @code{vprintf}), specify the third parameter as zero. In this case the compiler only checks the format string for consistency. For @code{strftime} formats, the third parameter is required to be zero. Since non-static C++ methods have an implicit @code{this} argument, the arguments of such methods should be counted from two, not one, when giving values for @var{string-index} and @var{first-to-check}. - at c LLVM LOCAL end mainline In the example above, the format string (@code{my_format}) is the second argument of the function @code{my_print}, and the arguments to check Modified: llvm-gcc-4.2/trunk/gcc/doc/tm.texi URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/doc/tm.texi?rev=50427&r1=50426&r2=50427&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/doc/tm.texi (original) +++ llvm-gcc-4.2/trunk/gcc/doc/tm.texi Tue Apr 29 11:42:52 2008 @@ -9944,20 +9944,6 @@ @code{TARGET_FORMAT_TYPES}. @end defmac - at c LLVM LOCAL begin mainline - at defmac TARGET_OVERRIDES_FORMAT_ATTRIBUTES -If defined, this macro is the name of a global variable containing -target-specific format overrides for the @option{-Wformat} option. The -default is to have no target-specific format overrides. If defined, - at code{TARGET_FORMAT_TYPES} must be defined, too. - at end defmac - - at defmac TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT -If defined, this macro specifies the number of entries in - at code{TARGET_OVERRIDES_FORMAT_ATTRIBUTES}. - at end defmac - at c LLVM LOCAL end mainline - @deftypefn {Target Hook} bool TARGET_RELAXED_ORDERING If set to @code{true}, means that the target's memory model does not guarantee that loads which do not depend on one another will access From sabre at nondot.org Tue Apr 29 12:13:44 2008 From: sabre at nondot.org (Chris Lattner) Date: Tue, 29 Apr 2008 17:13:44 -0000 Subject: [llvm-commits] [llvm] r50428 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/2008-04-29-VolatileLoadMerge.ll Message-ID: <200804291713.m3THDiAP002792@zion.cs.uiuc.edu> Author: lattner Date: Tue Apr 29 12:13:43 2008 New Revision: 50428 URL: http://llvm.org/viewvc/llvm-project?rev=50428&view=rev Log: fix a subtle volatile handling bug. Added: llvm/trunk/test/Transforms/InstCombine/2008-04-29-VolatileLoadMerge.ll Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=50428&r1=50427&r2=50428&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Tue Apr 29 12:13:43 2008 @@ -9432,16 +9432,21 @@ // Insert and return the new operation. if (CastInst* FirstCI = dyn_cast(FirstInst)) return CastInst::create(FirstCI->getOpcode(), PhiVal, PN.getType()); - else if (isa(FirstInst)) - return new LoadInst(PhiVal, "", isVolatile); - else if (BinaryOperator *BinOp = dyn_cast(FirstInst)) + if (BinaryOperator *BinOp = dyn_cast(FirstInst)) return BinaryOperator::create(BinOp->getOpcode(), PhiVal, ConstantOp); - else if (CmpInst *CIOp = dyn_cast(FirstInst)) + if (CmpInst *CIOp = dyn_cast(FirstInst)) return CmpInst::create(CIOp->getOpcode(), CIOp->getPredicate(), PhiVal, ConstantOp); - else - assert(0 && "Unknown operation"); - return 0; + assert(isa(FirstInst) && "Unknown operation"); + + // If this was a volatile load that we are merging, make sure to loop through + // and mark all the input loads as non-volatile. If we don't do this, we will + // insert a new volatile load and the old ones will not be deletable. + if (isVolatile) + for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i) + cast(PN.getIncomingValue(i))->setVolatile(false); + + return new LoadInst(PhiVal, "", isVolatile); } /// DeadPHICycle - Return true if this PHI node is only used by a PHI node cycle Added: llvm/trunk/test/Transforms/InstCombine/2008-04-29-VolatileLoadMerge.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2008-04-29-VolatileLoadMerge.ll?rev=50428&view=auto ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/2008-04-29-VolatileLoadMerge.ll (added) +++ llvm/trunk/test/Transforms/InstCombine/2008-04-29-VolatileLoadMerge.ll Tue Apr 29 12:13:43 2008 @@ -0,0 +1,30 @@ +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {volatile load} | count 1 +; PR2262 +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" +target triple = "i386-apple-darwin8" + at g_1 = internal global i32 0 ; [#uses=3] + at .str = internal constant [13 x i8] c"checksum = 0\00" ; <[13 x i8]*> [#uses=1] + at llvm.used = appending global [1 x i8*] [ i8* bitcast (i32 ()* @main to i8*) ], section "llvm.metadata" ; <[1 x i8*]*> [#uses=0] + +define i32 @main() nounwind { +entry: + %tmp93 = icmp slt i32 0, 10 ; [#uses=0] + %tmp34 = volatile load i32* @g_1, align 4 ; [#uses=1] + br label %bb + +bb: ; preds = %bb, %entry + %b.0.reg2mem.0 = phi i32 [ 0, %entry ], [ %tmp6, %bb ] ; [#uses=1] + %tmp3.reg2mem.0 = phi i32 [ %tmp34, %entry ], [ %tmp3, %bb ] ; [#uses=1] + %tmp4 = add i32 %tmp3.reg2mem.0, 5 ; [#uses=1] + volatile store i32 %tmp4, i32* @g_1, align 4 + %tmp6 = add i32 %b.0.reg2mem.0, 1 ; [#uses=2] + %tmp9 = icmp slt i32 %tmp6, 10 ; [#uses=1] + %tmp3 = volatile load i32* @g_1, align 4 ; [#uses=1] + br i1 %tmp9, label %bb, label %bb11 + +bb11: ; preds = %bb + %tmp14 = call i32 @puts( i8* getelementptr ([13 x i8]* @.str, i32 0, i32 0) ) nounwind ; [#uses=0] + ret i32 0 +} + +declare i32 @puts(i8*) From sabre at nondot.org Tue Apr 29 12:25:33 2008 From: sabre at nondot.org (Chris Lattner) Date: Tue, 29 Apr 2008 17:25:33 -0000 Subject: [llvm-commits] [llvm] r50429 - /llvm/trunk/test/Transforms/InstCombine/2008-04-29-VolatileLoadMerge.ll Message-ID: <200804291725.m3THPXag003281@zion.cs.uiuc.edu> Author: lattner Date: Tue Apr 29 12:25:32 2008 New Revision: 50429 URL: http://llvm.org/viewvc/llvm-project?rev=50429&view=rev Log: make this test reduced and *valid* Modified: llvm/trunk/test/Transforms/InstCombine/2008-04-29-VolatileLoadMerge.ll Modified: llvm/trunk/test/Transforms/InstCombine/2008-04-29-VolatileLoadMerge.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2008-04-29-VolatileLoadMerge.ll?rev=50429&r1=50428&r2=50429&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/2008-04-29-VolatileLoadMerge.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/2008-04-29-VolatileLoadMerge.ll Tue Apr 29 12:25:32 2008 @@ -3,28 +3,19 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" target triple = "i386-apple-darwin8" @g_1 = internal global i32 0 ; [#uses=3] - at .str = internal constant [13 x i8] c"checksum = 0\00" ; <[13 x i8]*> [#uses=1] - at llvm.used = appending global [1 x i8*] [ i8* bitcast (i32 ()* @main to i8*) ], section "llvm.metadata" ; <[1 x i8*]*> [#uses=0] -define i32 @main() nounwind { +define i32 @main(i32 %i) nounwind { entry: - %tmp93 = icmp slt i32 0, 10 ; [#uses=0] + %tmp93 = icmp slt i32 %i, 10 ; [#uses=0] %tmp34 = volatile load i32* @g_1, align 4 ; [#uses=1] - br label %bb + br i1 %tmp93, label %bb11, label %bb bb: ; preds = %bb, %entry - %b.0.reg2mem.0 = phi i32 [ 0, %entry ], [ %tmp6, %bb ] ; [#uses=1] - %tmp3.reg2mem.0 = phi i32 [ %tmp34, %entry ], [ %tmp3, %bb ] ; [#uses=1] - %tmp4 = add i32 %tmp3.reg2mem.0, 5 ; [#uses=1] - volatile store i32 %tmp4, i32* @g_1, align 4 - %tmp6 = add i32 %b.0.reg2mem.0, 1 ; [#uses=2] - %tmp9 = icmp slt i32 %tmp6, 10 ; [#uses=1] %tmp3 = volatile load i32* @g_1, align 4 ; [#uses=1] - br i1 %tmp9, label %bb, label %bb11 + br label %bb11 bb11: ; preds = %bb - %tmp14 = call i32 @puts( i8* getelementptr ([13 x i8]* @.str, i32 0, i32 0) ) nounwind ; [#uses=0] - ret i32 0 + %tmp4 = phi i32 [ %tmp34, %entry ], [ %tmp3, %bb ] ; [#uses=1] + ret i32 %tmp4 } -declare i32 @puts(i8*) From sabre at nondot.org Tue Apr 29 12:28:23 2008 From: sabre at nondot.org (Chris Lattner) Date: Tue, 29 Apr 2008 17:28:23 -0000 Subject: [llvm-commits] [llvm] r50430 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/2008-04-29-VolatileLoadDontMerge.ll Message-ID: <200804291728.m3THSNEL003381@zion.cs.uiuc.edu> Author: lattner Date: Tue Apr 29 12:28:22 2008 New Revision: 50430 URL: http://llvm.org/viewvc/llvm-project?rev=50430&view=rev Log: don't eliminate load from volatile value on paths where the load is dead. This fixes the second half of PR2262 Added: llvm/trunk/test/Transforms/InstCombine/2008-04-29-VolatileLoadDontMerge.ll Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=50430&r1=50429&r2=50430&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Tue Apr 29 12:28:22 2008 @@ -9396,6 +9396,15 @@ LI->getParent() != PN.getIncomingBlock(i) || !isSafeToSinkLoad(LI)) return 0; + + // If the PHI is volatile and its block has multiple successors, sinking + // it would remove a load of the volatile value from the path through the + // other successor. + if (isVolatile && + LI->getParent()->getTerminator()->getNumSuccessors() != 1) + return 0; + + } else if (I->getOperand(1) != ConstantOp) { return 0; } Added: llvm/trunk/test/Transforms/InstCombine/2008-04-29-VolatileLoadDontMerge.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2008-04-29-VolatileLoadDontMerge.ll?rev=50430&view=auto ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/2008-04-29-VolatileLoadDontMerge.ll (added) +++ llvm/trunk/test/Transforms/InstCombine/2008-04-29-VolatileLoadDontMerge.ll Tue Apr 29 12:28:22 2008 @@ -0,0 +1,25 @@ +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {volatile load} | count 2 +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" +target triple = "i386-apple-darwin8" + at g_1 = internal global i32 0 ; [#uses=3] + +define i32 @main() nounwind { +entry: + %tmp93 = icmp slt i32 0, 10 ; [#uses=0] + %tmp34 = volatile load i32* @g_1, align 4 ; [#uses=1] + br label %bb + +bb: ; preds = %bb, %entry + %b.0.reg2mem.0 = phi i32 [ 0, %entry ], [ %tmp6, %bb ] ; [#uses=1] + %tmp3.reg2mem.0 = phi i32 [ %tmp34, %entry ], [ %tmp3, %bb ] ; [#uses=1] + %tmp4 = add i32 %tmp3.reg2mem.0, 5 ; [#uses=1] + volatile store i32 %tmp4, i32* @g_1, align 4 + %tmp6 = add i32 %b.0.reg2mem.0, 1 ; [#uses=2] + %tmp9 = icmp slt i32 %tmp6, 10 ; [#uses=1] + %tmp3 = volatile load i32* @g_1, align 4 ; [#uses=1] + br i1 %tmp9, label %bb, label %bb11 + +bb11: ; preds = %bb + ret i32 0 +} + From dpatel at apple.com Tue Apr 29 12:35:01 2008 From: dpatel at apple.com (Devang Patel) Date: Tue, 29 Apr 2008 17:35:01 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50431 - /llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/i386.c Message-ID: <200804291735.m3THZ2B8003614@zion.cs.uiuc.edu> Author: dpatel Date: Tue Apr 29 12:35:01 2008 New Revision: 50431 URL: http://llvm.org/viewvc/llvm-project?rev=50431&view=rev Log: This is no long necessary. Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/i386.c Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/i386.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/i386.c?rev=50431&r1=50430&r2=50431&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/i386.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/i386.c Tue Apr 29 12:35:01 2008 @@ -4261,14 +4261,6 @@ int needed_intregs, needed_sseregs, size; enum machine_mode mode = type_natural_mode (type); - /* LLVM LOCAL begin strcut return check */ - /* FIXME without this, 64-bit _Complex long double crashes if not returned in - memory. With it, we just produce incorrect code. */ - if (TARGET_64BIT && TREE_CODE(type) == COMPLEX_TYPE && - TREE_INT_CST_LOW(TYPE_SIZE_UNIT(type)) > 8) - return 1; - /* LLVM LOCAL end strcut return check */ - if (TARGET_64BIT) return !examine_argument (mode, type, 1, &needed_intregs, &needed_sseregs); From isanbard at gmail.com Tue Apr 29 12:53:49 2008 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 29 Apr 2008 17:53:49 -0000 Subject: [llvm-commits] [llvm] r50432 - in /llvm/branches/Apple/Tak: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/2008-04-28-VolatileStore.ll Message-ID: <200804291753.m3THrnF7004267@zion.cs.uiuc.edu> Author: void Date: Tue Apr 29 12:53:49 2008 New Revision: 50432 URL: http://llvm.org/viewvc/llvm-project?rev=50432&view=rev Log: Ported r50390 to Tak. Added: llvm/branches/Apple/Tak/test/Transforms/InstCombine/2008-04-28-VolatileStore.ll Modified: llvm/branches/Apple/Tak/lib/Transforms/Scalar/InstructionCombining.cpp Modified: llvm/branches/Apple/Tak/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Tak/lib/Transforms/Scalar/InstructionCombining.cpp?rev=50432&r1=50431&r2=50432&view=diff ============================================================================== --- llvm/branches/Apple/Tak/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/branches/Apple/Tak/lib/Transforms/Scalar/InstructionCombining.cpp Tue Apr 29 12:53:49 2008 @@ -10256,7 +10256,7 @@ // If the RHS is an alloca with a single use, zapify the store, making the // alloca dead. - if (Ptr->hasOneUse()) { + if (Ptr->hasOneUse() && !SI.isVolatile()) { if (isa(Ptr)) { EraseInstFromFunction(SI); ++NumCombined; Added: llvm/branches/Apple/Tak/test/Transforms/InstCombine/2008-04-28-VolatileStore.ll URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Tak/test/Transforms/InstCombine/2008-04-28-VolatileStore.ll?rev=50432&view=auto ============================================================================== --- llvm/branches/Apple/Tak/test/Transforms/InstCombine/2008-04-28-VolatileStore.ll (added) +++ llvm/branches/Apple/Tak/test/Transforms/InstCombine/2008-04-28-VolatileStore.ll Tue Apr 29 12:53:49 2008 @@ -0,0 +1,8 @@ +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {volatile store} + +define void @test() { + %votf = alloca <4 x float> ; <<4 x float>*> [#uses=1] + volatile store <4 x float> zeroinitializer, <4 x float>* %votf, align 16 + ret void +} + From isanbard at gmail.com Tue Apr 29 13:04:55 2008 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 29 Apr 2008 11:04:55 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r50431 - /llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/i386.c In-Reply-To: <200804291735.m3THZ2B8003614@zion.cs.uiuc.edu> References: <200804291735.m3THZ2B8003614@zion.cs.uiuc.edu> Message-ID: <16e5fdf90804291104h60fe7cc2t5cb6e0cc5339b663@mail.gmail.com> Does this also go into Mainline? -bw On Tue, Apr 29, 2008 at 10:35 AM, Devang Patel wrote: > Author: dpatel > Date: Tue Apr 29 12:35:01 2008 > New Revision: 50431 > > URL: http://llvm.org/viewvc/llvm-project?rev=50431&view=rev > Log: > This is no long necessary. > > Modified: > llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/i386.c > > Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/i386.c > URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/i386.c?rev=50431&r1=50430&r2=50431&view=diff > > ============================================================================== > --- llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/i386.c (original) > +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/i386.c Tue Apr 29 12:35:01 2008 > @@ -4261,14 +4261,6 @@ > int needed_intregs, needed_sseregs, size; > enum machine_mode mode = type_natural_mode (type); > > - /* LLVM LOCAL begin strcut return check */ > - /* FIXME without this, 64-bit _Complex long double crashes if not returned in > - memory. With it, we just produce incorrect code. */ > - if (TARGET_64BIT && TREE_CODE(type) == COMPLEX_TYPE && > - TREE_INT_CST_LOW(TYPE_SIZE_UNIT(type)) > 8) > - return 1; > - /* LLVM LOCAL end strcut return check */ > - > if (TARGET_64BIT) > return !examine_argument (mode, type, 1, &needed_intregs, &needed_sseregs); > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From asl at math.spbu.ru Tue Apr 29 13:16:22 2008 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Tue, 29 Apr 2008 18:16:22 -0000 Subject: [llvm-commits] [llvm] r50433 - /llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp Message-ID: <200804291816.m3TIGMgu005036@zion.cs.uiuc.edu> Author: asl Date: Tue Apr 29 13:16:22 2008 New Revision: 50433 URL: http://llvm.org/viewvc/llvm-project?rev=50433&view=rev Log: Don't do stupid things: doInitialization(Module&) is not applicable to ModulePass :) Modified: llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp Modified: llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp?rev=50433&r1=50432&r2=50433&view=diff ============================================================================== --- llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp (original) +++ llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp Tue Apr 29 13:16:22 2008 @@ -101,28 +101,13 @@ public: static char ID; - explicit CppWriter(std::ostream &o) : ModulePass((intptr_t)&ID), Out(o) {} + explicit CppWriter(std::ostream &o) : + ModulePass((intptr_t)&ID), Out(o), uniqueNum(0), is_inline(false) {} virtual const char *getPassName() const { return "C++ backend"; } bool runOnModule(Module &M); - bool doInitialization(Module &M) { - uniqueNum = 0; - is_inline = false; - - TypeNames.clear(); - ValueNames.clear(); - UnresolvedTypes.clear(); - TypeStack.clear(); - UsedNames.clear(); - DefinedTypes.clear(); - DefinedValues.clear(); - ForwardRefs.clear(); - - return false; - } - void printProgram(const std::string& fname, const std::string& modName ); void printModule(const std::string& fname, const std::string& modName ); void printContents(const std::string& fname, const std::string& modName ); From evan.cheng at apple.com Tue Apr 29 13:29:14 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 29 Apr 2008 18:29:14 -0000 Subject: [llvm-commits] [llvm] r50434 - /llvm/branches/Apple/Tak/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <200804291829.m3TITEa0005520@zion.cs.uiuc.edu> Author: evancheng Date: Tue Apr 29 13:29:14 2008 New Revision: 50434 URL: http://llvm.org/viewvc/llvm-project?rev=50434&view=rev Log: Ported 50376 to Tak. Modified: llvm/branches/Apple/Tak/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Modified: llvm/branches/Apple/Tak/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Tak/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=50434&r1=50433&r2=50434&view=diff ============================================================================== --- llvm/branches/Apple/Tak/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/branches/Apple/Tak/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Tue Apr 29 13:29:14 2008 @@ -3442,7 +3442,20 @@ if (Flag) *Flag = Part.getValue(1); } - Chain = DAG.getNode(ISD::TokenFactor, MVT::Other, &Chains[0], NumRegs); + if (NumRegs == 1 || Flag) + // If NumRegs > 1 && Flag is used then the use of the last CopyToReg is + // flagged to it. That is the CopyToReg nodes and the user are considered + // a single scheduling unit. If we create a TokenFactor and return it as + // chain, then the TokenFactor is both a predecessor (operand) of the + // user as well as a successor (the TF operands are flagged to the user). + // c1, f1 = CopyToReg + // c2, f2 = CopyToReg + // c3 = TokenFactor c1, c2 + // ... + // = op c3, ..., f2 + Chain = Chains[NumRegs-1]; + else + Chain = DAG.getNode(ISD::TokenFactor, MVT::Other, &Chains[0], NumRegs); } /// AddInlineAsmOperands - Add this value to the specified inlineasm node From clattner at apple.com Tue Apr 29 13:36:06 2008 From: clattner at apple.com (Chris Lattner) Date: Tue, 29 Apr 2008 11:36:06 -0700 Subject: [llvm-commits] [llvm] r50382 - in /llvm/trunk: include/llvm/LinkAllPasses.h include/llvm/Transforms/Scalar.h lib/Transforms/Scalar/DeadLoopElimination.cpp In-Reply-To: <200804290038.m3T0cZc1028840@zion.cs.uiuc.edu> References: <200804290038.m3T0cZc1028840@zion.cs.uiuc.edu> Message-ID: <88D86245-7BE6-45DD-9F76-F7EE9371980F@apple.com> On Apr 28, 2008, at 5:38 PM, Owen Anderson wrote: > URL: http://llvm.org/viewvc/llvm-project?rev=50382&view=rev > Log: > Add dead loop elimination, which removes dead loops for which we can > compute > the trip count. Nice! > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp (added) > +++ llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp Mon Apr > 28 19:38:34 2008 > @@ -0,0 +1,239 @@ > +//===- DeadLoopElimination.cpp - Dead Loop Elimination Pass > ---------------===// All the other loop passes start with "Loop" is there some way to rename this to Loop*? Maybe LoopDeletion? > +#define DEBUG_TYPE "dead-loop" Likewise all the options are -loop-xxx, it would be nice to be consistent. > > + > +#include "llvm/Transforms/Scalar.h" > +#include "llvm/Instruction.h" > +#include "llvm/Analysis/LoopInfo.h" > +#include "llvm/Analysis/LoopPass.h" You don't need LoopInfo.h or Instruction.h > +using namespace llvm; > + > +STATISTIC(NumDeleted, "Number of loops deleted"); > + > +namespace { > + class VISIBILITY_HIDDEN DeadLoopElimination : public LoopPass { Please add a nice big doxygen comment above this pass talking about what it does. The key thing to talk about is that it deletes loops with no side effects that have a computable non-infinite iteration count. > +bool DeadLoopElimination::SingleDominatingExit(Loop* L) { Please add comments for every method, explaining what the method does and what invariants it expects from its input, like other passes in Transforms/Scalar. > +bool DeadLoopElimination::IsLoopInvariantInst(Instruction *I, Loop* > L) { Can Loop::isLoopInvariant be used for this? > +bool DeadLoopElimination::IsLoopDead(Loop* L) { > + SmallVector exitingBlocks; > + L->getExitingBlocks(exitingBlocks); > + BasicBlock* exitingBlock = exitingBlocks[0]; > + > + // Get the set of out-of-loop blocks that the exiting block > branches to. > + SmallVector exitBlocks; > + L->getUniqueExitBlocks(exitBlocks); > + if (exitBlocks.size() > 1) > + return false; > + BasicBlock* exitBlock = exitBlocks[0]; It seems that the property you really want is whether *any* exit from a loop that dominates the latch block has a computable trip count. Exits that don't dominate the latch block or that are not computable are fine, they just don't help prove finiteness. ... actually, I just realized that this isn't true. You need much better comments explaining *why* you can't handle this case. > + // Make sure that all PHI entries coming from the loop are loop > invariant. > + BasicBlock::iterator BI = exitBlock->begin(); > + while (PHINode* P = dyn_cast(BI)) { > + Value* incoming = P->getIncomingValueForBlock(exitingBlock); > + if (Instruction* I = dyn_cast(incoming)) > + if (!IsLoopInvariantInst(I, L)) L->isLoopInvariant handles the non-instruction case fwiw. > +bool DeadLoopElimination::runOnLoop(Loop* L, LPPassManager& LPM) { > + // Don't remove loops for which we can't solve the trip count. > + // They could be infinite, in which case we'd be changing program > behavior. > + if (L->getTripCount()) > + return false; You should move this check lower, it is more expensive to compute than whether there is a preheader or subloops. > + // We can only remove the loop if there is a preheader that we can > + // branch from after removing it. > + BasicBlock* preheader = L->getLoopPreheader(); > + if (!preheader) > + return false; > + > + // We can't remove loops that contain subloops. If the subloops > were dead, > + // they would already have been removed in earlier executions of > this pass. > + if (L->begin() != L->end()) > + return false; > + > + // Loops with multiple exits or exits that don't dominate the latch > + // are too complicated to handle correctly. > + if (!SingleDominatingExit(L)) > + return false; Why? > > + > + // Finally, we have to check that the loop really is dead. > + if (!IsLoopDead(L)) > + return false; > + > + // Now that we know the removal is safe, change the branch from > the preheader > + // to go to the single exiting block. > + SmallVector exitingBlocks; > + L->getExitingBlocks(exitingBlocks); > + BasicBlock* exitingBlock = exitingBlocks[0]; You get the single exiting block 3 times for each loop. Just get it once and pass it to methods that need it. The comments you added to DeadLoopElimination::runOnLoop are very nice, thanks! // Connect the preheader directly to the exit block. TerminatorInst* TI = preheader->getTerminator(); if (BranchInst* BI = dyn_cast(TI)) { if (BI->isUnconditional()) BI->setSuccessor(0, exitBlock); else if (L->contains(BI->getSuccessor(0))) BI->setSuccessor(0, exitBlock); else BI->setSuccessor(1, exitBlock); } else { // FIXME: Support switches return false; } Your FIXME is not sufficient. At this point you've already significantly hacked the function. I'd just use TI- >replaceUsesOfWith(oldblock, newblock), which should handle any terminator unless I'm missing something. If I'm missing something, you have insufficient comments. > + BasicBlock::iterator BI = exitBlock->begin(); > + while (PHINode* P = dyn_cast(BI)) { > + unsigned i = P->getBasicBlockIndex(exitingBlock); > + P->setIncomingBlock(i, preheader); How about P->replaceUsesOfWith(oldblock, newblock) > > + BI++; > + } // Update lots of internal structures... DominatorTree& DT = getAnalysis(); for (Loop::block_iterator LI = L->block_begin(), LE = L->block_end(); Which internal structures? This is not a very useful comment. SmallPtrSet childNodes; Please declare childNodes outside the loop so it doesn't get reconstructed on every iteration. It should be named 'ChildNodes'. > + for (Loop::block_iterator LI = L->block_begin(), LE = L- > >block_end(); > + LI != LE; ++LI) { > + for (BasicBlock::iterator BI = (*LI)->begin(), BE = (*LI)->end(); > + BI != BE; ) { > + Instruction* I = BI++; > + I->eraseFromParent(); > + } > + > + (*LI)->eraseFromParent(); > + } You are incrementing LI after you erase *LI. I don't think there is any need to explicitly erase the instructions in the block here, just nuking the block will delete the contents. -Chris From asl at math.spbu.ru Tue Apr 29 13:53:20 2008 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Tue, 29 Apr 2008 18:53:20 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50435 - in /llvm-gcc-4.2/trunk/gcc: config/i386/mingw32.h libgcc2.c Message-ID: <200804291853.m3TIrK5N006230@zion.cs.uiuc.edu> Author: asl Date: Tue Apr 29 13:53:19 2008 New Revision: 50435 URL: http://llvm.org/viewvc/llvm-project?rev=50435&view=rev Log: Unbreak mingw32 Modified: llvm-gcc-4.2/trunk/gcc/config/i386/mingw32.h llvm-gcc-4.2/trunk/gcc/libgcc2.c Modified: llvm-gcc-4.2/trunk/gcc/config/i386/mingw32.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/mingw32.h?rev=50435&r1=50434&r2=50435&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/mingw32.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/mingw32.h Tue Apr 29 13:53:19 2008 @@ -151,23 +151,6 @@ /* LLVM LOCAL begin mainline */ -/* Contains a pointer to type target_ovr_attr defining the target specific - overrides of format attributes. See c-format.h for structure - definition. */ -#undef TARGET_OVERRIDES_FORMAT_ATTRIBUTES -#define TARGET_OVERRIDES_FORMAT_ATTRIBUTES mingw_format_attribute_overrides - -/* Specify the count of elements in TARGET_OVERRIDES_ATTRIBUTE. */ -#undef TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT -#define TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT 3 - -/* MS specific format attributes for ms_printf, ms_scanf, ms_strftime. */ -#undef TARGET_FORMAT_TYPES -#define TARGET_FORMAT_TYPES mingw_format_attributes - -#undef TARGET_N_FORMAT_TYPES -#define TARGET_N_FORMAT_TYPES 3 - #define TARGET_USE_JCR_SECTION 0 #undef MINGW_ENABLE_EXECUTE_STACK Modified: llvm-gcc-4.2/trunk/gcc/libgcc2.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/libgcc2.c?rev=50435&r1=50434&r2=50435&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/libgcc2.c (original) +++ llvm-gcc-4.2/trunk/gcc/libgcc2.c Tue Apr 29 13:53:19 2008 @@ -2091,10 +2091,6 @@ #endif } -#ifdef __i386__ -extern int VirtualProtect (char *, int, int, int *) __attribute__((stdcall)); -#endif - int mprotect (char *addr, int len, int prot) { From resistor at mac.com Tue Apr 29 14:58:07 2008 From: resistor at mac.com (Owen Anderson) Date: Tue, 29 Apr 2008 19:58:07 -0000 Subject: [llvm-commits] [llvm] r50436 - in /llvm/trunk/lib/Transforms/Scalar: DeadLoopElimination.cpp LoopDeletion.cpp Message-ID: <200804291958.m3TJw7ba008055@zion.cs.uiuc.edu> Author: resistor Date: Tue Apr 29 14:58:07 2008 New Revision: 50436 URL: http://llvm.org/viewvc/llvm-project?rev=50436&view=rev Log: Rename DeadLoopElimination to LoopDeletion, part one. Added: llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp - copied unchanged from r50435, llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp Removed: llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp Removed: llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp?rev=50435&view=auto ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/DeadLoopElimination.cpp (removed) @@ -1,260 +0,0 @@ -//===- DeadLoopElimination.cpp - Dead Loop Elimination Pass ---------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements the Dead Loop Elimination Pass. -// -//===----------------------------------------------------------------------===// - -#define DEBUG_TYPE "dead-loop" - -#include "llvm/Transforms/Scalar.h" -#include "llvm/Instruction.h" -#include "llvm/Analysis/LoopInfo.h" -#include "llvm/Analysis/LoopPass.h" -#include "llvm/ADT/Statistic.h" -#include "llvm/ADT/SmallVector.h" - -using namespace llvm; - -STATISTIC(NumDeleted, "Number of loops deleted"); - -namespace { - class VISIBILITY_HIDDEN DeadLoopElimination : public LoopPass { - public: - static char ID; // Pass ID, replacement for typeid - DeadLoopElimination() : LoopPass((intptr_t)&ID) { } - - // Possibly eliminate loop L if it is dead. - bool runOnLoop(Loop* L, LPPassManager& LPM); - - bool SingleDominatingExit(Loop* L); - bool IsLoopDead(Loop* L); - bool IsLoopInvariantInst(Instruction *I, Loop* L); - - virtual void getAnalysisUsage(AnalysisUsage& AU) const { - AU.addRequired(); - AU.addRequired(); - AU.addRequiredID(LoopSimplifyID); - AU.addRequiredID(LCSSAID); - - AU.addPreserved(); - AU.addPreserved(); - AU.addPreservedID(LoopSimplifyID); - AU.addPreservedID(LCSSAID); - } - }; - - char DeadLoopElimination::ID = 0; - RegisterPass X ("dead-loop", "Eliminate dead loops"); -} - -LoopPass* llvm::createDeadLoopEliminationPass() { - return new DeadLoopElimination(); -} - -bool DeadLoopElimination::SingleDominatingExit(Loop* L) { - SmallVector exitingBlocks; - L->getExitingBlocks(exitingBlocks); - - if (exitingBlocks.size() != 1) - return 0; - - BasicBlock* latch = L->getLoopLatch(); - if (!latch) - return 0; - - DominatorTree& DT = getAnalysis(); - if (DT.dominates(exitingBlocks[0], latch)) - return exitingBlocks[0]; - else - return 0; -} - -bool DeadLoopElimination::IsLoopInvariantInst(Instruction *I, Loop* L) { - // PHI nodes are not loop invariant if defined in the loop. - if (isa(I) && L->contains(I->getParent())) - return false; - - // The instruction is loop invariant if all of its operands are loop-invariant - for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) - if (!L->isLoopInvariant(I->getOperand(i))) - return false; - - // If we got this far, the instruction is loop invariant! - return true; -} - -bool DeadLoopElimination::IsLoopDead(Loop* L) { - SmallVector exitingBlocks; - L->getExitingBlocks(exitingBlocks); - BasicBlock* exitingBlock = exitingBlocks[0]; - - // Get the set of out-of-loop blocks that the exiting block branches to. - SmallVector exitBlocks; - L->getUniqueExitBlocks(exitBlocks); - if (exitBlocks.size() > 1) - return false; - BasicBlock* exitBlock = exitBlocks[0]; - - // Make sure that all PHI entries coming from the loop are loop invariant. - BasicBlock::iterator BI = exitBlock->begin(); - while (PHINode* P = dyn_cast(BI)) { - Value* incoming = P->getIncomingValueForBlock(exitingBlock); - if (Instruction* I = dyn_cast(incoming)) - if (!IsLoopInvariantInst(I, L)) - return false; - - BI++; - } - - // Make sure that no instructions in the block have potential side-effects. - for (Loop::block_iterator LI = L->block_begin(), LE = L->block_end(); - LI != LE; ++LI) { - for (BasicBlock::iterator BI = (*LI)->begin(), BE = (*LI)->end(); - BI != BE; ++BI) { - if (BI->mayWriteToMemory()) - return false; - } - } - - return true; -} - -/// runOnLoop - Remove dead loops, by which we mean loops that do not impact the -/// observable behavior of the program other than finite running time. Note -/// we do ensure that this never remove a loop that might be infinite, as doing -/// so could change the halting/non-halting nature of a program. -bool DeadLoopElimination::runOnLoop(Loop* L, LPPassManager& LPM) { - // Don't remove loops for which we can't solve the trip count. - // They could be infinite, in which case we'd be changing program behavior. - if (L->getTripCount()) - return false; - - // We can only remove the loop if there is a preheader that we can - // branch from after removing it. - BasicBlock* preheader = L->getLoopPreheader(); - if (!preheader) - return false; - - // We can't remove loops that contain subloops. If the subloops were dead, - // they would already have been removed in earlier executions of this pass. - if (L->begin() != L->end()) - return false; - - // Loops with multiple exits or exits that don't dominate the latch - // are too complicated to handle correctly. - if (!SingleDominatingExit(L)) - return false; - - // Finally, we have to check that the loop really is dead. - if (!IsLoopDead(L)) - return false; - - // Now that we know the removal is safe, change the branch from the preheader - // to go to the single exiting block. - SmallVector exitingBlocks; - L->getExitingBlocks(exitingBlocks); - BasicBlock* exitingBlock = exitingBlocks[0]; - - SmallVector exitBlocks; - L->getUniqueExitBlocks(exitBlocks); - BasicBlock* exitBlock = exitBlocks[0]; - - // Because we're deleting a large chunk of code at once, the sequence in which - // we remove things is very important to avoid invalidation issues. Don't - // mess with this unless you have good reason and know what you're doing. - - // Move simple loop-invariant expressions out of the loop, since they - // might be needed by the exit phis. - for (Loop::block_iterator LI = L->block_begin(), LE = L->block_end(); - LI != LE; ++LI) - for (BasicBlock::iterator BI = (*LI)->begin(), BE = (*LI)->end(); - BI != BE; ) { - Instruction* I = BI++; - if (I->getNumUses() > 0 && IsLoopInvariantInst(I, L)) - I->moveBefore(preheader->getTerminator()); - } - - // Connect the preheader directly to the exit block. - TerminatorInst* TI = preheader->getTerminator(); - if (BranchInst* BI = dyn_cast(TI)) { - if (BI->isUnconditional()) - BI->setSuccessor(0, exitBlock); - else if (L->contains(BI->getSuccessor(0))) - BI->setSuccessor(0, exitBlock); - else - BI->setSuccessor(1, exitBlock); - } else { - // FIXME: Support switches - return false; - } - - // Rewrite phis in the exit block to get their inputs from - // the preheader instead of the exiting block. - BasicBlock::iterator BI = exitBlock->begin(); - while (PHINode* P = dyn_cast(BI)) { - unsigned i = P->getBasicBlockIndex(exitingBlock); - P->setIncomingBlock(i, preheader); - BI++; - } - - // Update lots of internal structures... - DominatorTree& DT = getAnalysis(); - for (Loop::block_iterator LI = L->block_begin(), LE = L->block_end(); - LI != LE; ++LI) { - // Move all of the block's children to be children of the preheader, which - // allows us to remove the domtree entry for the block. - SmallPtrSet childNodes; - childNodes.insert(DT[*LI]->begin(), DT[*LI]->end()); - for (SmallPtrSet::iterator DI = childNodes.begin(), - DE = childNodes.end(); DI != DE; ++DI) - DT.changeImmediateDominator(*DI, DT[preheader]); - - DT.eraseNode(*LI); - - // Drop all references between the instructions and the block so - // that we don't have reference counting problems later. - for (BasicBlock::iterator BI = (*LI)->begin(), BE = (*LI)->end(); - BI != BE; ++BI) { - BI->dropAllReferences(); - } - - (*LI)->dropAllReferences(); - } - - // Erase the instructions and the blocks without having to worry - // about ordering because we already dropped the references. - for (Loop::block_iterator LI = L->block_begin(), LE = L->block_end(); - LI != LE; ++LI) { - for (BasicBlock::iterator BI = (*LI)->begin(), BE = (*LI)->end(); - BI != BE; ) { - Instruction* I = BI++; - I->eraseFromParent(); - } - - (*LI)->eraseFromParent(); - } - - // Finally, the blocks from loopinfo. This has to happen late because - // otherwise our loop iterators won't work. - LoopInfo& loopInfo = getAnalysis(); - SmallPtrSet blocks; - blocks.insert(L->block_begin(), L->block_end()); - for (SmallPtrSet::iterator I = blocks.begin(), - E = blocks.end(); I != E; ++I) - loopInfo.removeBlock(*I); - - // The last step is to inform the loop pass manager that we've - // eliminated this loop. - LPM.deleteLoopFromQueue(L); - - NumDeleted++; - - return true; -} From resistor at mac.com Tue Apr 29 15:06:54 2008 From: resistor at mac.com (Owen Anderson) Date: Tue, 29 Apr 2008 20:06:54 -0000 Subject: [llvm-commits] [llvm] r50437 - in /llvm/trunk: include/llvm/LinkAllPasses.h include/llvm/Transforms/Scalar.h lib/Transforms/Scalar/LoopDeletion.cpp Message-ID: <200804292006.m3TK6tF5008443@zion.cs.uiuc.edu> Author: resistor Date: Tue Apr 29 15:06:54 2008 New Revision: 50437 URL: http://llvm.org/viewvc/llvm-project?rev=50437&view=rev Log: Rename DeadLoopElimination to LoopDeletion, part 2. Modified: llvm/trunk/include/llvm/LinkAllPasses.h llvm/trunk/include/llvm/Transforms/Scalar.h llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp Modified: llvm/trunk/include/llvm/LinkAllPasses.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LinkAllPasses.h?rev=50437&r1=50436&r2=50437&view=diff ============================================================================== --- llvm/trunk/include/llvm/LinkAllPasses.h (original) +++ llvm/trunk/include/llvm/LinkAllPasses.h Tue Apr 29 15:06:54 2008 @@ -114,7 +114,7 @@ (void) llvm::createCodeGenPreparePass(); (void) llvm::createGVNPass(); (void) llvm::createMemCpyOptPass(); - (void) llvm::createDeadLoopEliminationPass(); + (void) llvm::createLoopDeletionPass(); (void)new llvm::IntervalPartition(); (void)new llvm::FindUsedTypes(); Modified: llvm/trunk/include/llvm/Transforms/Scalar.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Scalar.h?rev=50437&r1=50436&r2=50437&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Scalar.h (original) +++ llvm/trunk/include/llvm/Transforms/Scalar.h Tue Apr 29 15:06:54 2008 @@ -319,10 +319,10 @@ //===----------------------------------------------------------------------===// // -// DeadLoopElimination - This pass performs DCE of non-infinite loops that it +// LoopDeletion - This pass performs DCE of non-infinite loops that it // can prove are dead. // -LoopPass *createDeadLoopEliminationPass(); +LoopPass *createLoopDeletionPass(); //===----------------------------------------------------------------------===// // Modified: llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp?rev=50437&r1=50436&r2=50437&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp Tue Apr 29 15:06:54 2008 @@ -1,4 +1,4 @@ -//===- DeadLoopElimination.cpp - Dead Loop Elimination Pass ---------------===// +//===- LoopDeletion.cpp - Dead Loop Deletion Pass ---------------===// // // The LLVM Compiler Infrastructure // @@ -11,11 +11,9 @@ // //===----------------------------------------------------------------------===// -#define DEBUG_TYPE "dead-loop" +#define DEBUG_TYPE "loop-delete" #include "llvm/Transforms/Scalar.h" -#include "llvm/Instruction.h" -#include "llvm/Analysis/LoopInfo.h" #include "llvm/Analysis/LoopPass.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/SmallVector.h" @@ -25,10 +23,10 @@ STATISTIC(NumDeleted, "Number of loops deleted"); namespace { - class VISIBILITY_HIDDEN DeadLoopElimination : public LoopPass { + class VISIBILITY_HIDDEN LoopDeletion : public LoopPass { public: static char ID; // Pass ID, replacement for typeid - DeadLoopElimination() : LoopPass((intptr_t)&ID) { } + LoopDeletion() : LoopPass((intptr_t)&ID) { } // Possibly eliminate loop L if it is dead. bool runOnLoop(Loop* L, LPPassManager& LPM); @@ -50,15 +48,15 @@ } }; - char DeadLoopElimination::ID = 0; - RegisterPass X ("dead-loop", "Eliminate dead loops"); + char LoopDeletion::ID = 0; + RegisterPass X ("loop-deletion", "Delete dead loops"); } -LoopPass* llvm::createDeadLoopEliminationPass() { - return new DeadLoopElimination(); +LoopPass* llvm::createLoopDeletionPass() { + return new LoopDeletion(); } -bool DeadLoopElimination::SingleDominatingExit(Loop* L) { +bool LoopDeletion::SingleDominatingExit(Loop* L) { SmallVector exitingBlocks; L->getExitingBlocks(exitingBlocks); @@ -76,7 +74,7 @@ return 0; } -bool DeadLoopElimination::IsLoopInvariantInst(Instruction *I, Loop* L) { +bool LoopDeletion::IsLoopInvariantInst(Instruction *I, Loop* L) { // PHI nodes are not loop invariant if defined in the loop. if (isa(I) && L->contains(I->getParent())) return false; @@ -90,7 +88,7 @@ return true; } -bool DeadLoopElimination::IsLoopDead(Loop* L) { +bool LoopDeletion::IsLoopDead(Loop* L) { SmallVector exitingBlocks; L->getExitingBlocks(exitingBlocks); BasicBlock* exitingBlock = exitingBlocks[0]; @@ -130,7 +128,7 @@ /// observable behavior of the program other than finite running time. Note /// we do ensure that this never remove a loop that might be infinite, as doing /// so could change the halting/non-halting nature of a program. -bool DeadLoopElimination::runOnLoop(Loop* L, LPPassManager& LPM) { +bool LoopDeletion::runOnLoop(Loop* L, LPPassManager& LPM) { // Don't remove loops for which we can't solve the trip count. // They could be infinite, in which case we'd be changing program behavior. if (L->getTripCount()) From resistor at mac.com Tue Apr 29 15:09:01 2008 From: resistor at mac.com (Owen Anderson) Date: Tue, 29 Apr 2008 15:09:01 -0500 Subject: [llvm-commits] [llvm] r50382 - in /llvm/trunk: include/llvm/LinkAllPasses.h include/llvm/Transforms/Scalar.h lib/Transforms/Scalar/DeadLoopElimination.cpp In-Reply-To: <88D86245-7BE6-45DD-9F76-F7EE9371980F@apple.com> References: <200804290038.m3T0cZc1028840@zion.cs.uiuc.edu> <88D86245-7BE6-45DD-9F76-F7EE9371980F@apple.com> Message-ID: On Apr 29, 2008, at 1:36 PM, Chris Lattner wrote: >> +bool DeadLoopElimination::IsLoopInvariantInst(Instruction *I, Loop* >> L) { > > Can Loop::isLoopInvariant be used for this? Unfortunately, no. isLoopInvariant never considers an instruction defined within the loop to be invariant. I tried using it initially, and found that i eliminated very few loops. The code I'm using here is the same logic that LICM uses as well. --Owen -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 4260 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20080429/0f7873e6/attachment.bin From resistor at mac.com Tue Apr 29 15:22:59 2008 From: resistor at mac.com (Owen Anderson) Date: Tue, 29 Apr 2008 15:22:59 -0500 Subject: [llvm-commits] [llvm] r50382 - in /llvm/trunk: include/llvm/LinkAllPasses.h include/llvm/Transforms/Scalar.h lib/Transforms/Scalar/DeadLoopElimination.cpp In-Reply-To: <88D86245-7BE6-45DD-9F76-F7EE9371980F@apple.com> References: <200804290038.m3T0cZc1028840@zion.cs.uiuc.edu> <88D86245-7BE6-45DD-9F76-F7EE9371980F@apple.com> Message-ID: <0D4E62A4-F76F-471B-9E9F-E0154D40509B@mac.com> On Apr 29, 2008, at 1:36 PM, Chris Lattner wrote: >> + for (Loop::block_iterator LI = L->block_begin(), LE = L- >>> block_end(); >> + LI != LE; ++LI) { >> + for (BasicBlock::iterator BI = (*LI)->begin(), BE = (*LI)- >> >end(); >> + BI != BE; ) { >> + Instruction* I = BI++; >> + I->eraseFromParent(); >> + } >> + >> + (*LI)->eraseFromParent(); >> + } > > You are incrementing LI after you erase *LI. I'm actually reasonably confident that this is safe. I'm iterating over the loop's block list, not over the function ilist. Erasing *LI doesn't remove LI from the loop's block list, it just makes it a pointer to freed memory. You'll note that the next step is to remove the blocks from LoopInfo, which does remove them from the loop's block list, and from the block lists of any parent loops as well. --Owen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20080429/4eb09e7f/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 4260 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20080429/4eb09e7f/attachment.bin From criswell at uiuc.edu Tue Apr 29 15:45:33 2008 From: criswell at uiuc.edu (John Criswell) Date: Tue, 29 Apr 2008 20:45:33 -0000 Subject: [llvm-commits] [test-suite] r50438 - /test-suite/trunk/RunSafely.sh Message-ID: <200804292045.m3TKjXv1009961@zion.cs.uiuc.edu> Author: criswell Date: Tue Apr 29 15:45:32 2008 New Revision: 50438 URL: http://llvm.org/viewvc/llvm-project?rev=50438&view=rev Log: Wrap text to 80 columns. No functionality changes. Modified: test-suite/trunk/RunSafely.sh Modified: test-suite/trunk/RunSafely.sh URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/RunSafely.sh?rev=50438&r1=50437&r2=50438&view=diff ============================================================================== --- test-suite/trunk/RunSafely.sh (original) +++ test-suite/trunk/RunSafely.sh Tue Apr 29 15:45:32 2008 @@ -67,19 +67,19 @@ CYGWIN*) ;; Darwin*) - # Disable core file emission, the script doesn't find it anyway because it is put - # into /cores. + # Disable core file emission, the script doesn't find it anyway because it + # is put into /cores. ULIMITCMD="$ULIMITCMD ulimit -c 0;" ULIMITCMD="$ULIMITCMD ulimit -t $ULIMIT;" - # To prevent infinite loops which fill up the disk, specify a limit on size of - # files being output by the tests. 10 MB should be enough for anybody. ;) + # To prevent infinite loops which fill up the disk, specify a limit on size + # of files being output by the tests. 10 MB should be enough for anybody. ;) ULIMITCMD="$ULIMITCMD ulimit -f 10485760;" ;; *) ULIMITCMD="$ULIMITCMD ulimit -t $ULIMIT;" ULIMITCMD="$ULIMITCMD ulimit -c unlimited;" - # To prevent infinite loops which fill up the disk, specify a limit on size of - # files being output by the tests. 10 MB should be enough for anybody. ;) + # To prevent infinite loops which fill up the disk, specify a limit on size + # of files being output by the tests. 10 MB should be enough for anybody. ;) ULIMITCMD="$ULIMITCMD ulimit -f 10485760;" # virtual memory: 200 MB should be enough for anybody. ;) From isanbard at gmail.com Tue Apr 29 15:55:24 2008 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 29 Apr 2008 20:55:24 -0000 Subject: [llvm-commits] [llvm] r50439 - /llvm/tags/Apple/llvmCore-2037/ Message-ID: <200804292055.m3TKtO6j010227@zion.cs.uiuc.edu> Author: void Date: Tue Apr 29 15:55:24 2008 New Revision: 50439 URL: http://llvm.org/viewvc/llvm-project?rev=50439&view=rev Log: Creating llvmCore-2037 from Tak Added: llvm/tags/Apple/llvmCore-2037/ - copied from r50434, llvm/branches/Apple/Tak/ From isanbard at gmail.com Tue Apr 29 15:56:14 2008 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 29 Apr 2008 20:56:14 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50440 - /llvm-gcc-4.2/tags/Apple/llvmCore-2037/ Message-ID: <200804292056.m3TKuEkO010255@zion.cs.uiuc.edu> Author: void Date: Tue Apr 29 15:56:14 2008 New Revision: 50440 URL: http://llvm.org/viewvc/llvm-project?rev=50440&view=rev Log: Creating llvmgcc42-2037 from Tak Added: llvm-gcc-4.2/tags/Apple/llvmCore-2037/ - copied from r50434, llvm-gcc-4.2/branches/Apple/Tak/ From resistor at mac.com Tue Apr 29 15:59:34 2008 From: resistor at mac.com (Owen Anderson) Date: Tue, 29 Apr 2008 20:59:34 -0000 Subject: [llvm-commits] [llvm] r50441 - /llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp Message-ID: <200804292059.m3TKxYwD010357@zion.cs.uiuc.edu> Author: resistor Date: Tue Apr 29 15:59:33 2008 New Revision: 50441 URL: http://llvm.org/viewvc/llvm-project?rev=50441&view=rev Log: A lot of cleanups and documentation improvements, as well as a few corner case fixes. Most of this was suggested by Chris. Modified: llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp?rev=50441&r1=50440&r2=50441&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp Tue Apr 29 15:59:33 2008 @@ -7,7 +7,10 @@ // //===----------------------------------------------------------------------===// // -// This file implements the Dead Loop Elimination Pass. +// This file implements the Dead Loop Elimination Pass. This pass is +// responsible for eliminating loops with non-infinite computable trip counts +// that have no side effects or volatile instructions, and do not contribute +// to the computation of the function's return value. // //===----------------------------------------------------------------------===// @@ -31,8 +34,10 @@ // Possibly eliminate loop L if it is dead. bool runOnLoop(Loop* L, LPPassManager& LPM); - bool SingleDominatingExit(Loop* L); - bool IsLoopDead(Loop* L); + bool SingleDominatingExit(Loop* L, + SmallVector& exitingBlocks); + bool IsLoopDead(Loop* L, SmallVector& exitingBlocks, + SmallVector& exitBlocks); bool IsLoopInvariantInst(Instruction *I, Loop* L); virtual void getAnalysisUsage(AnalysisUsage& AU) const { @@ -56,24 +61,34 @@ return new LoopDeletion(); } -bool LoopDeletion::SingleDominatingExit(Loop* L) { - SmallVector exitingBlocks; - L->getExitingBlocks(exitingBlocks); +/// SingleDominatingExit - Checks that there is only a single blocks that +/// branches out of the loop, and that it also dominates the latch block. Loops +/// with multiple or non-latch-dominating exiting blocks could be dead, but we'd +/// have to do more extensive analysis to make sure, for instance, that the +/// control flow logic involves was or could be made loop-invariant. +bool LoopDeletion::SingleDominatingExit(Loop* L, + SmallVector& exitingBlocks) { if (exitingBlocks.size() != 1) - return 0; + return false; BasicBlock* latch = L->getLoopLatch(); if (!latch) - return 0; + return false; DominatorTree& DT = getAnalysis(); if (DT.dominates(exitingBlocks[0], latch)) - return exitingBlocks[0]; + return true; else - return 0; + return false; } +/// IsLoopInvariantInst - Checks if an instruction is invariant with respect to +/// a loop, which is defined as being true if all of its operands are defined +/// outside of the loop. These instructions can be hoisted out of the loop +/// if their results are needed. This could be made more aggressive by +/// recursively checking the operands for invariance, but it's not clear that +/// it's worth it. bool LoopDeletion::IsLoopInvariantInst(Instruction *I, Loop* L) { // PHI nodes are not loop invariant if defined in the loop. if (isa(I) && L->contains(I->getParent())) @@ -88,19 +103,20 @@ return true; } -bool LoopDeletion::IsLoopDead(Loop* L) { - SmallVector exitingBlocks; - L->getExitingBlocks(exitingBlocks); +/// IsLoopDead - Determined if a loop is dead. This assumes that we've already +/// checked for unique exit and exiting blocks, and that the code is in LCSSA +/// form. +bool LoopDeletion::IsLoopDead(Loop* L, + SmallVector& exitingBlocks, + SmallVector& exitBlocks) { BasicBlock* exitingBlock = exitingBlocks[0]; - - // Get the set of out-of-loop blocks that the exiting block branches to. - SmallVector exitBlocks; - L->getUniqueExitBlocks(exitBlocks); - if (exitBlocks.size() > 1) - return false; BasicBlock* exitBlock = exitBlocks[0]; // Make sure that all PHI entries coming from the loop are loop invariant. + // Because the code is in LCSSA form, any values used outside of the loop + // must pass through a PHI in the exit block, meaning that this check is + // sufficient to guarantee that no loop-variant values are used outside + // of the loop. BasicBlock::iterator BI = exitBlock->begin(); while (PHINode* P = dyn_cast(BI)) { Value* incoming = P->getIncomingValueForBlock(exitingBlock); @@ -112,12 +128,18 @@ } // Make sure that no instructions in the block have potential side-effects. + // This includes instructions that could write to memory, and loads that are + // marked volatile. This could be made more aggressive by using aliasing + // information to identify readonly and readnone calls. for (Loop::block_iterator LI = L->block_begin(), LE = L->block_end(); LI != LE; ++LI) { for (BasicBlock::iterator BI = (*LI)->begin(), BE = (*LI)->end(); BI != BE; ++BI) { if (BI->mayWriteToMemory()) return false; + else if (LoadInst* L = dyn_cast(BI)) + if (L->isVolatile()) + return false; } } @@ -128,10 +150,20 @@ /// observable behavior of the program other than finite running time. Note /// we do ensure that this never remove a loop that might be infinite, as doing /// so could change the halting/non-halting nature of a program. +/// NOTE: This entire process relies pretty heavily on LoopSimplify and LCSSA +/// in order to make various safety checks work. bool LoopDeletion::runOnLoop(Loop* L, LPPassManager& LPM) { - // Don't remove loops for which we can't solve the trip count. - // They could be infinite, in which case we'd be changing program behavior. - if (L->getTripCount()) + SmallVector exitingBlocks; + L->getExitingBlocks(exitingBlocks); + + SmallVector exitBlocks; + L->getUniqueExitBlocks(exitBlocks); + + // We require that the loop only have a single exit block. Otherwise, we'd + // be in the situation of needing to be able to solve statically which exit + // block will be branced to, or trying to preserve the branching logic in + // a loop invariant manner. + if (exitBlocks.size() != 1) return false; // We can only remove the loop if there is a preheader that we can @@ -145,23 +177,22 @@ if (L->begin() != L->end()) return false; + // Don't remove loops for which we can't solve the trip count. + // They could be infinite, in which case we'd be changing program behavior. + if (L->getTripCount()) + return false; + // Loops with multiple exits or exits that don't dominate the latch // are too complicated to handle correctly. - if (!SingleDominatingExit(L)) + if (!SingleDominatingExit(L, exitingBlocks)) return false; // Finally, we have to check that the loop really is dead. - if (!IsLoopDead(L)) + if (!IsLoopDead(L, exitingBlocks, exitBlocks)) return false; - // Now that we know the removal is safe, change the branch from the preheader - // to go to the single exiting block. - SmallVector exitingBlocks; - L->getExitingBlocks(exitingBlocks); - BasicBlock* exitingBlock = exitingBlocks[0]; - - SmallVector exitBlocks; - L->getUniqueExitBlocks(exitBlocks); + // Now that we know the removal is safe, remove the loop by changing the + // branch from the preheader to go to the single exiting block. BasicBlock* exitBlock = exitBlocks[0]; // Because we're deleting a large chunk of code at once, the sequence in which @@ -181,39 +212,30 @@ // Connect the preheader directly to the exit block. TerminatorInst* TI = preheader->getTerminator(); - if (BranchInst* BI = dyn_cast(TI)) { - if (BI->isUnconditional()) - BI->setSuccessor(0, exitBlock); - else if (L->contains(BI->getSuccessor(0))) - BI->setSuccessor(0, exitBlock); - else - BI->setSuccessor(1, exitBlock); - } else { - // FIXME: Support switches - return false; - } - + TI->replaceUsesOfWith(L->getHeader(), exitBlock); + // Rewrite phis in the exit block to get their inputs from // the preheader instead of the exiting block. BasicBlock::iterator BI = exitBlock->begin(); while (PHINode* P = dyn_cast(BI)) { - unsigned i = P->getBasicBlockIndex(exitingBlock); - P->setIncomingBlock(i, preheader); + P->replaceUsesOfWith(exitBlock, preheader); BI++; } - // Update lots of internal structures... + // Update the dominator tree and remove the instructions and blocks that will + // be deleted from the reference counting scheme. DominatorTree& DT = getAnalysis(); + SmallPtrSet ChildNodes; for (Loop::block_iterator LI = L->block_begin(), LE = L->block_end(); LI != LE; ++LI) { // Move all of the block's children to be children of the preheader, which // allows us to remove the domtree entry for the block. - SmallPtrSet childNodes; - childNodes.insert(DT[*LI]->begin(), DT[*LI]->end()); - for (SmallPtrSet::iterator DI = childNodes.begin(), - DE = childNodes.end(); DI != DE; ++DI) + ChildNodes.insert(DT[*LI]->begin(), DT[*LI]->end()); + for (SmallPtrSet::iterator DI = ChildNodes.begin(), + DE = ChildNodes.end(); DI != DE; ++DI) DT.changeImmediateDominator(*DI, DT[preheader]); + ChildNodes.clear(); DT.eraseNode(*LI); // Drop all references between the instructions and the block so @@ -228,16 +250,11 @@ // Erase the instructions and the blocks without having to worry // about ordering because we already dropped the references. + // NOTE: This iteration is safe because erasing the block does not remove its + // entry from the loop's block list. We do that in the next section. for (Loop::block_iterator LI = L->block_begin(), LE = L->block_end(); - LI != LE; ++LI) { - for (BasicBlock::iterator BI = (*LI)->begin(), BE = (*LI)->end(); - BI != BE; ) { - Instruction* I = BI++; - I->eraseFromParent(); - } - + LI != LE; ++LI) (*LI)->eraseFromParent(); - } // Finally, the blocks from loopinfo. This has to happen late because // otherwise our loop iterators won't work. From resistor at mac.com Tue Apr 29 16:02:46 2008 From: resistor at mac.com (Owen Anderson) Date: Tue, 29 Apr 2008 21:02:46 -0000 Subject: [llvm-commits] [llvm] r50442 - /llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Message-ID: <200804292102.m3TL2kT5010502@zion.cs.uiuc.edu> Author: resistor Date: Tue Apr 29 16:02:46 2008 New Revision: 50442 URL: http://llvm.org/viewvc/llvm-project?rev=50442&view=rev Log: We should be returning true here since we've changed the function. Modified: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Modified: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp?rev=50442&r1=50441&r2=50442&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Tue Apr 29 16:02:46 2008 @@ -677,7 +677,7 @@ NumMemCpyInstr++; - return false; + return true; } // MemCpyOpt::runOnFunction - This is the main transformation entry point for a From resistor at mac.com Tue Apr 29 16:26:06 2008 From: resistor at mac.com (Owen Anderson) Date: Tue, 29 Apr 2008 21:26:06 -0000 Subject: [llvm-commits] [llvm] r50444 - in /llvm/trunk: lib/Transforms/Scalar/MemCpyOptimizer.cpp test/Transforms/MemCpyOpt/2008-04-29-SRetRemoval.ll Message-ID: <200804292126.m3TLQ617011386@zion.cs.uiuc.edu> Author: resistor Date: Tue Apr 29 16:26:06 2008 New Revision: 50444 URL: http://llvm.org/viewvc/llvm-project?rev=50444&view=rev Log: Fix a bug in memcpyopt where the memcpy-memcpy transform was never being applied because we were checking for it in the wrong order. This caused a miscompilation because the return slot optimization assumes that the call it is dealing with is NOT a memcpy. Added: llvm/trunk/test/Transforms/MemCpyOpt/2008-04-29-SRetRemoval.ll Modified: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Modified: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp?rev=50444&r1=50443&r2=50444&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Tue Apr 29 16:26:06 2008 @@ -615,10 +615,12 @@ if (dep == MemoryDependenceAnalysis::None || dep == MemoryDependenceAnalysis::NonLocal) return false; - else if (CallInst* C = dyn_cast(dep)) - return performCallSlotOptzn(M, C); - else if (!isa(dep)) - return false; + else if (!isa(dep)) { + if (CallInst* C = dyn_cast(dep)) + return performCallSlotOptzn(M, C); + else + return false; + } MemCpyInst* MDep = cast(dep); Added: llvm/trunk/test/Transforms/MemCpyOpt/2008-04-29-SRetRemoval.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/MemCpyOpt/2008-04-29-SRetRemoval.ll?rev=50444&view=auto ============================================================================== --- llvm/trunk/test/Transforms/MemCpyOpt/2008-04-29-SRetRemoval.ll (added) +++ llvm/trunk/test/Transforms/MemCpyOpt/2008-04-29-SRetRemoval.ll Tue Apr 29 16:26:06 2008 @@ -0,0 +1,17 @@ +; RUN: llvm-as < %s | opt -memcpyopt | llvm-dis | grep {call.*memcpy.*agg.result} + +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" +target triple = "i386-apple-darwin8" + at x = external global { x86_fp80, x86_fp80 } ; <{ x86_fp80, x86_fp80 }*> [#uses=1] + +define void @foo({ x86_fp80, x86_fp80 }* noalias sret %agg.result) nounwind { +entry: + %x.0 = alloca { x86_fp80, x86_fp80 } ; <{ x86_fp80, x86_fp80 }*> [#uses=1] + %x.01 = bitcast { x86_fp80, x86_fp80 }* %x.0 to i8* ; [#uses=2] + call void @llvm.memcpy.i32( i8* %x.01, i8* bitcast ({ x86_fp80, x86_fp80 }* @x to i8*), i32 32, i32 16 ) + %agg.result2 = bitcast { x86_fp80, x86_fp80 }* %agg.result to i8* ; [#uses=1] + call void @llvm.memcpy.i32( i8* %agg.result2, i8* %x.01, i32 32, i32 16 ) + ret void +} + +declare void @llvm.memcpy.i32(i8*, i8*, i32, i32) nounwind From isanbard at gmail.com Tue Apr 29 16:40:13 2008 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 29 Apr 2008 21:40:13 -0000 Subject: [llvm-commits] [llvm] r50445 - in /llvm/branches/Apple/Tak: lib/Transforms/Scalar/MemCpyOptimizer.cpp test/Transforms/MemCpyOpt/2008-04-29-SRetRemoval.ll Message-ID: <200804292140.m3TLeD8E011885@zion.cs.uiuc.edu> Author: void Date: Tue Apr 29 16:40:13 2008 New Revision: 50445 URL: http://llvm.org/viewvc/llvm-project?rev=50445&view=rev Log: Porting r50444 into Tak. Added: llvm/branches/Apple/Tak/test/Transforms/MemCpyOpt/2008-04-29-SRetRemoval.ll Modified: llvm/branches/Apple/Tak/lib/Transforms/Scalar/MemCpyOptimizer.cpp Modified: llvm/branches/Apple/Tak/lib/Transforms/Scalar/MemCpyOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Tak/lib/Transforms/Scalar/MemCpyOptimizer.cpp?rev=50445&r1=50444&r2=50445&view=diff ============================================================================== --- llvm/branches/Apple/Tak/lib/Transforms/Scalar/MemCpyOptimizer.cpp (original) +++ llvm/branches/Apple/Tak/lib/Transforms/Scalar/MemCpyOptimizer.cpp Tue Apr 29 16:40:13 2008 @@ -615,10 +615,12 @@ if (dep == MemoryDependenceAnalysis::None || dep == MemoryDependenceAnalysis::NonLocal) return false; - else if (CallInst* C = dyn_cast(dep)) - return performCallSlotOptzn(M, C); - else if (!isa(dep)) - return false; + else if (!isa(dep)) { + if (CallInst* C = dyn_cast(dep)) + return performCallSlotOptzn(M, C); + else + return false; + } MemCpyInst* MDep = cast(dep); Added: llvm/branches/Apple/Tak/test/Transforms/MemCpyOpt/2008-04-29-SRetRemoval.ll URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Tak/test/Transforms/MemCpyOpt/2008-04-29-SRetRemoval.ll?rev=50445&view=auto ============================================================================== --- llvm/branches/Apple/Tak/test/Transforms/MemCpyOpt/2008-04-29-SRetRemoval.ll (added) +++ llvm/branches/Apple/Tak/test/Transforms/MemCpyOpt/2008-04-29-SRetRemoval.ll Tue Apr 29 16:40:13 2008 @@ -0,0 +1,17 @@ +; RUN: llvm-as < %s | opt -memcpyopt | llvm-dis | grep {call.*memcpy.*agg.result} + +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" +target triple = "i386-apple-darwin8" + at x = external global { x86_fp80, x86_fp80 } ; <{ x86_fp80, x86_fp80 }*> [#uses=1] + +define void @foo({ x86_fp80, x86_fp80 }* noalias sret %agg.result) nounwind { +entry: + %x.0 = alloca { x86_fp80, x86_fp80 } ; <{ x86_fp80, x86_fp80 }*> [#uses=1] + %x.01 = bitcast { x86_fp80, x86_fp80 }* %x.0 to i8* ; [#uses=2] + call void @llvm.memcpy.i32( i8* %x.01, i8* bitcast ({ x86_fp80, x86_fp80 }* @x to i8*), i32 32, i32 16 ) + %agg.result2 = bitcast { x86_fp80, x86_fp80 }* %agg.result to i8* ; [#uses=1] + call void @llvm.memcpy.i32( i8* %agg.result2, i8* %x.01, i32 32, i32 16 ) + ret void +} + +declare void @llvm.memcpy.i32(i8*, i8*, i32, i32) nounwind From clattner at apple.com Tue Apr 29 16:40:30 2008 From: clattner at apple.com (Chris Lattner) Date: Tue, 29 Apr 2008 14:40:30 -0700 Subject: [llvm-commits] [llvm] r50382 - in /llvm/trunk: include/llvm/LinkAllPasses.h include/llvm/Transforms/Scalar.h lib/Transforms/Scalar/DeadLoopElimination.cpp In-Reply-To: <0D4E62A4-F76F-471B-9E9F-E0154D40509B@mac.com> References: <200804290038.m3T0cZc1028840@zion.cs.uiuc.edu> <88D86245-7BE6-45DD-9F76-F7EE9371980F@apple.com> <0D4E62A4-F76F-471B-9E9F-E0154D40509B@mac.com> Message-ID: <52B7EBA9-568F-4B10-BBBE-4896184BBDE0@apple.com> On Apr 29, 2008, at 1:22 PM, Owen Anderson wrote: > > On Apr 29, 2008, at 1:36 PM, Chris Lattner wrote: >>> + for (Loop::block_iterator LI = L->block_begin(), LE = L- >>>> block_end(); >>> + LI != LE; ++LI) { >>> + for (BasicBlock::iterator BI = (*LI)->begin(), BE = (*LI)- >>> >end(); >>> + BI != BE; ) { >>> + Instruction* I = BI++; >>> + I->eraseFromParent(); >>> + } >>> + >>> + (*LI)->eraseFromParent(); >>> + } >> >> You are incrementing LI after you erase *LI. > > I'm actually reasonably confident that this is safe. I'm iterating > over the loop's block list, not over the function ilist. Erasing > *LI doesn't remove LI from the loop's block list, it just makes it a > pointer to freed memory. You'll note that the next step is to > remove the blocks from LoopInfo, which does remove them from the > loop's block list, and from the block lists of any parent loops as > well. You're right, thanks! -Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20080429/92ead614/attachment.html From clattner at apple.com Tue Apr 29 16:41:35 2008 From: clattner at apple.com (Chris Lattner) Date: Tue, 29 Apr 2008 14:41:35 -0700 Subject: [llvm-commits] [llvm] r50382 - in /llvm/trunk: include/llvm/LinkAllPasses.h include/llvm/Transforms/Scalar.h lib/Transforms/Scalar/DeadLoopElimination.cpp In-Reply-To: References: <200804290038.m3T0cZc1028840@zion.cs.uiuc.edu> <88D86245-7BE6-45DD-9F76-F7EE9371980F@apple.com> Message-ID: <2208AF0D-661D-4D35-B724-379446473824@apple.com> On Apr 29, 2008, at 1:09 PM, Owen Anderson wrote: > > On Apr 29, 2008, at 1:36 PM, Chris Lattner wrote: >>> +bool DeadLoopElimination::IsLoopInvariantInst(Instruction *I, Loop* >>> L) { >> >> Can Loop::isLoopInvariant be used for this? > > Unfortunately, no. isLoopInvariant never considers an instruction > defined within the loop to be invariant. I tried using it > initially, and found that i eliminated very few loops. The code I'm > using here is the same logic that LICM uses as well. Maybe there should be a new predicate on Loop? -Chris From resistor at mac.com Tue Apr 29 16:47:54 2008 From: resistor at mac.com (Owen Anderson) Date: Tue, 29 Apr 2008 16:47:54 -0500 Subject: [llvm-commits] [llvm] r50382 - in /llvm/trunk: include/llvm/LinkAllPasses.h include/llvm/Transforms/Scalar.h lib/Transforms/Scalar/DeadLoopElimination.cpp In-Reply-To: <2208AF0D-661D-4D35-B724-379446473824@apple.com> References: <200804290038.m3T0cZc1028840@zion.cs.uiuc.edu> <88D86245-7BE6-45DD-9F76-F7EE9371980F@apple.com> <2208AF0D-661D-4D35-B724-379446473824@apple.com> Message-ID: <7D4C7594-582A-49C9-9707-76272CF69DE8@mac.com> On Apr 29, 2008, at 4:41 PM, Chris Lattner wrote: > > On Apr 29, 2008, at 1:09 PM, Owen Anderson wrote: >> >> >> Unfortunately, no. isLoopInvariant never considers an instruction >> defined within the loop to be invariant. I tried using it >> initially, and found that i eliminated very few loops. The code I'm >> using here is the same logic that LICM uses as well. > > Maybe there should be a new predicate on Loop? > I think it's just a difference in assumed meaning. isLoopInvariant() makes the fewest assumptions about the client, whereas IsLoopInvariantInst() assumes that the client is willing and/or able to handle hoisting loop-invariant instructions for themselves. --Owen -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 4260 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20080429/b1582a3c/attachment.bin From resistor at mac.com Tue Apr 29 16:51:00 2008 From: resistor at mac.com (Owen Anderson) Date: Tue, 29 Apr 2008 21:51:00 -0000 Subject: [llvm-commits] [llvm] r50446 - /llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Message-ID: <200804292151.m3TLp0VV012178@zion.cs.uiuc.edu> Author: resistor Date: Tue Apr 29 16:51:00 2008 New Revision: 50446 URL: http://llvm.org/viewvc/llvm-project?rev=50446&view=rev Log: Revert r50441. The original code was correct. Add some more comments so that I don't make the same mistake in the future. Modified: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Modified: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp?rev=50446&r1=50445&r2=50446&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Tue Apr 29 16:51:00 2008 @@ -668,18 +668,24 @@ CallInst* C = CallInst::Create(MemCpyFun, args.begin(), args.end(), "", M); + + // If C and M don't interfere, then this is a valid transformation. If they + // did, this would mean that the two sources overlap, which would be bad. if (MD.getDependency(C) == MDep) { MD.dropInstruction(M); M->eraseFromParent(); + + NumMemCpyInstr++; + return true; } + // Otherwise, there was no point in doing this, so we remove the call we + // inserted and act like nothing happened. MD.removeInstruction(C); C->eraseFromParent(); - NumMemCpyInstr++; - - return true; + return false; } // MemCpyOpt::runOnFunction - This is the main transformation entry point for a From dpatel at apple.com Tue Apr 29 16:57:27 2008 From: dpatel at apple.com (Devang Patel) Date: Tue, 29 Apr 2008 21:57:27 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50447 - in /llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple: asm-block-13.c asm-block-17.c asm-block-18.c asm-block-24.c asm-block-25.c asm-block-28.c asm-block-30.c asm-block-32.c asm-block-33.c asm-block-36.c asm-block-37.c asm-block-38.c asm-block-39.c asm-block-41.c asm-block-45.c asm-block-50.c asm-block-52.c asm-block-54.c asm-block-55.c asm-block-57.c asm-block-59.c asm-block-64.c Message-ID: <200804292157.m3TLvRuI012382@zion.cs.uiuc.edu> Author: dpatel Date: Tue Apr 29 16:57:26 2008 New Revision: 50447 URL: http://llvm.org/viewvc/llvm-project?rev=50447&view=rev Log: Disable asm-block tests for now. Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-13.c llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-17.c llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-18.c llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-24.c llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-25.c llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-28.c llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-30.c llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-32.c llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-33.c llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-36.c llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-37.c llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-38.c llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-39.c llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-41.c llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-45.c llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-50.c llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-52.c llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-54.c llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-55.c llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-57.c llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-59.c llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-64.c Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-13.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-13.c?rev=50447&r1=50446&r2=50447&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-13.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-13.c Tue Apr 29 16:57:26 2008 @@ -1,6 +1,7 @@ /* APPLE LOCAL file CW asm blocks */ /* { dg-do assemble { target i?86*-*-darwin* } } */ -/* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 } } */ /* Radar 4259442 */ Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-17.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-17.c?rev=50447&r1=50446&r2=50447&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-17.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-17.c Tue Apr 29 16:57:26 2008 @@ -1,6 +1,7 @@ /* APPLE LOCAL file CW asm blocks */ /* { dg-do assemble { target i?86*-*-darwin* } } */ -/* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 -O2 } } */ /* Radar */ Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-18.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-18.c?rev=50447&r1=50446&r2=50447&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-18.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-18.c Tue Apr 29 16:57:26 2008 @@ -1,6 +1,7 @@ /* APPLE LOCAL file CW asm blocks */ /* { dg-do assemble { target i?86*-*-darwin* } } */ -/* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 -O2 } } */ /* Radar 4248228 */ Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-24.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-24.c?rev=50447&r1=50446&r2=50447&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-24.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-24.c Tue Apr 29 16:57:26 2008 @@ -1,6 +1,7 @@ /* APPLE LOCAL file CW asm blocks */ /* { dg-do assemble { target i?86*-*-darwin* } } */ -/* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 } } */ /* Radar 4300095 */ Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-25.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-25.c?rev=50447&r1=50446&r2=50447&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-25.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-25.c Tue Apr 29 16:57:26 2008 @@ -1,6 +1,7 @@ /* APPLE LOCAL file CW asm blocks */ /* { dg-do assemble { target i?86*-*-darwin* } } */ -/* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 } } */ /* Radar 4309942 */ Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-28.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-28.c?rev=50447&r1=50446&r2=50447&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-28.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-28.c Tue Apr 29 16:57:26 2008 @@ -1,6 +1,8 @@ /* APPLE LOCAL file CW asm blocks */ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-options { -fasm-blocks -msse3 -O } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4300156 */ int i; Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-30.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-30.c?rev=50447&r1=50446&r2=50447&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-30.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-30.c Tue Apr 29 16:57:26 2008 @@ -1,6 +1,8 @@ /* APPLE LOCAL file CW asm blocks */ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-options { -fasm-blocks -msse3 } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4300108 */ void foo() { Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-32.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-32.c?rev=50447&r1=50446&r2=50447&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-32.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-32.c Tue Apr 29 16:57:26 2008 @@ -2,6 +2,8 @@ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4319887 */ void bar(); Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-33.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-33.c?rev=50447&r1=50446&r2=50447&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-33.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-33.c Tue Apr 29 16:57:26 2008 @@ -2,6 +2,8 @@ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4300193 */ int i, j, k; Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-36.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-36.c?rev=50447&r1=50446&r2=50447&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-36.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-36.c Tue Apr 29 16:57:26 2008 @@ -2,6 +2,8 @@ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4371958 */ #define SourceArray(row, col) (sPtr [(row) * sRowBytes + (col)]) Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-37.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-37.c?rev=50447&r1=50446&r2=50447&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-37.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-37.c Tue Apr 29 16:57:26 2008 @@ -1,6 +1,8 @@ /* APPLE LOCAL file CW asm blocks */ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-options { -fasm-blocks -msse3 -O1 } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4433955 */ void X2_Interpolate2DNoPinFourCol(const char *sPtr, Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-38.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-38.c?rev=50447&r1=50446&r2=50447&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-38.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-38.c Tue Apr 29 16:57:26 2008 @@ -1,6 +1,8 @@ /* APPLE LOCAL file CW asm blocks */ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-options { -fasm-blocks -msse3 } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4433955 */ void X2_Interpolate2DNoPinFourCol(const char *sPtr, Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-39.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-39.c?rev=50447&r1=50446&r2=50447&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-39.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-39.c Tue Apr 29 16:57:26 2008 @@ -1,6 +1,8 @@ /* APPLE LOCAL file CW asm blocks */ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-options { -fasm-blocks -msse3 } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4432782 */ void foo() { Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-41.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-41.c?rev=50447&r1=50446&r2=50447&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-41.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-41.c Tue Apr 29 16:57:26 2008 @@ -2,6 +2,8 @@ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4429851 */ void foo() { Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-45.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-45.c?rev=50447&r1=50446&r2=50447&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-45.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-45.c Tue Apr 29 16:57:26 2008 @@ -2,6 +2,8 @@ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4419735 */ void foo(short* pSrc) { Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-50.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-50.c?rev=50447&r1=50446&r2=50447&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-50.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-50.c Tue Apr 29 16:57:26 2008 @@ -2,6 +2,8 @@ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4505741 */ static int c[5]; Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-52.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-52.c?rev=50447&r1=50446&r2=50447&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-52.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-52.c Tue Apr 29 16:57:26 2008 @@ -1,6 +1,8 @@ /* APPLE LOCAL file CW asm blocks */ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-options { -fasm-blocks -O } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4527214 */ inline int foo(int x, int y) { Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-54.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-54.c?rev=50447&r1=50446&r2=50447&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-54.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-54.c Tue Apr 29 16:57:26 2008 @@ -2,6 +2,8 @@ /* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 } } */ /* { dg-final { scan-assembler "movq -\(16|36\)\\\(%ebp\\\), %mm0" } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4515069 */ void foo() { Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-55.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-55.c?rev=50447&r1=50446&r2=50447&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-55.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-55.c Tue Apr 29 16:57:26 2008 @@ -2,6 +2,8 @@ /* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 -mdynamic-no-pic } } */ /* { dg-final { scan-assembler "movq _packedw1.*, %mm0" } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4515069 */ void foo() { Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-57.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-57.c?rev=50447&r1=50446&r2=50447&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-57.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-57.c Tue Apr 29 16:57:26 2008 @@ -2,6 +2,8 @@ /* { dg-do run { target i?86*-*-darwin* } } */ /* { dg-skip-if "" { i?86*-*-darwin* } { "-m64" } } */ /* { dg-options { -fasm-blocks -msse3 } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4682427 */ void bar() __attribute ((weak)); Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-59.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-59.c?rev=50447&r1=50446&r2=50447&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-59.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-59.c Tue Apr 29 16:57:26 2008 @@ -3,6 +3,8 @@ /* { dg-options { -fasm-blocks -msse3 -O2 } } */ /* { dg-require-effective-target ilp32 } */ /* { dg-final { scan-assembler "-\(40|44\)\\\(%ebp,%edx,2\\\), %ebx" } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4699545 */ void bar() { Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-64.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-64.c?rev=50447&r1=50446&r2=50447&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-64.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/asm-block-64.c Tue Apr 29 16:57:26 2008 @@ -1,5 +1,7 @@ /* { dg-do compile { target i?86*-*-darwin* } } */ /* { dg-options { -fasm-blocks -O2 } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 5315594 */ typedef unsigned char unsigned8; From clattner at apple.com Tue Apr 29 17:09:07 2008 From: clattner at apple.com (Chris Lattner) Date: Tue, 29 Apr 2008 15:09:07 -0700 Subject: [llvm-commits] [llvm] r50382 - in /llvm/trunk: include/llvm/LinkAllPasses.h include/llvm/Transforms/Scalar.h lib/Transforms/Scalar/DeadLoopElimination.cpp In-Reply-To: <7D4C7594-582A-49C9-9707-76272CF69DE8@mac.com> References: <200804290038.m3T0cZc1028840@zion.cs.uiuc.edu> <88D86245-7BE6-45DD-9F76-F7EE9371980F@apple.com> <2208AF0D-661D-4D35-B724-379446473824@apple.com> <7D4C7594-582A-49C9-9707-76272CF69DE8@mac.com> Message-ID: On Apr 29, 2008, at 2:47 PM, Owen Anderson wrote: > > On Apr 29, 2008, at 4:41 PM, Chris Lattner wrote: > >> >> On Apr 29, 2008, at 1:09 PM, Owen Anderson wrote: >>> >>> >>> Unfortunately, no. isLoopInvariant never considers an instruction >>> defined within the loop to be invariant. I tried using it >>> initially, and found that i eliminated very few loops. The code I'm >>> using here is the same logic that LICM uses as well. >> >> Maybe there should be a new predicate on Loop? >> > > I think it's just a difference in assumed meaning. > isLoopInvariant() makes the fewest assumptions about the client, > whereas IsLoopInvariantInst() assumes that the client is willing and/ > or able to handle hoisting loop-invariant instructions for themselves. IsHoistableFromLoop? -Chris From criswell at uiuc.edu Tue Apr 29 17:12:40 2008 From: criswell at uiuc.edu (John Criswell) Date: Tue, 29 Apr 2008 22:12:40 -0000 Subject: [llvm-commits] [llvm] r50448 - /llvm/trunk/docs/SourceLevelDebugging.html Message-ID: <200804292212.m3TMCeXS012872@zion.cs.uiuc.edu> Author: criswell Date: Tue Apr 29 17:12:40 2008 New Revision: 50448 URL: http://llvm.org/viewvc/llvm-project?rev=50448&view=rev Log: Minor spelling and typo fixes. Modified: llvm/trunk/docs/SourceLevelDebugging.html Modified: llvm/trunk/docs/SourceLevelDebugging.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/SourceLevelDebugging.html?rev=50448&r1=50447&r2=50448&view=diff ============================================================================== --- llvm/trunk/docs/SourceLevelDebugging.html (original) +++ llvm/trunk/docs/SourceLevelDebugging.html Tue Apr 29 17:12:40 2008 @@ -130,7 +130,7 @@

    When a program is being debugged, a debugger interacts with the user and turns the stored debug information into source-language specific information. As such, a debugger must be aware of the source-language, and is thus tied to -a specific language of family of languages.

    +a specific language or family of languages.

    @@ -142,7 +142,7 @@

    The role of debug information is to provide meta information normally stripped away during the compilation process. This meta information provides an -llvm user a relationship between generated code and the original program source +LLVM user a relationship between generated code and the original program source code.

    Currently, debug information is consumed by the DwarfWriter to produce dwarf @@ -175,12 +175,12 @@ have been run, and without any modification to the optimizations themselves. However, some optimizations may impact the ability to modify the current state of the program with a debugger, such as setting program variables, or calling -function that have been deleted.

  • +functions that have been deleted.
  • LLVM optimizations gracefully interact with debugging information. If they are not aware of debug information, they are automatically disabled as necessary in the cases that would invalidate the debug info. This retains the LLVM -features making it easy to write new transformations.
  • +features, making it easy to write new transformations.
  • As desired, LLVM optimizations can be upgraded to be aware of the LLVM debugging information, allowing them to update the debugging information as they From dpatel at apple.com Tue Apr 29 17:42:07 2008 From: dpatel at apple.com (Devang Patel) Date: Tue, 29 Apr 2008 22:42:07 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50450 - /llvm-gcc-4.2/trunk/gcc/config/i386/i386.c Message-ID: <200804292242.m3TMg7Nk013787@zion.cs.uiuc.edu> Author: dpatel Date: Tue Apr 29 17:42:07 2008 New Revision: 50450 URL: http://llvm.org/viewvc/llvm-project?rev=50450&view=rev Log: This is no long necessary. Move from Tak to mainline. Modified: llvm-gcc-4.2/trunk/gcc/config/i386/i386.c Modified: llvm-gcc-4.2/trunk/gcc/config/i386/i386.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/i386.c?rev=50450&r1=50449&r2=50450&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/i386.c (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/i386.c Tue Apr 29 17:42:07 2008 @@ -4302,14 +4302,6 @@ int needed_intregs, needed_sseregs, size; enum machine_mode mode = type_natural_mode (type); - /* LLVM LOCAL begin strcut return check */ - /* FIXME without this, 64-bit _Complex long double crashes if not returned in - memory. With it, we just produce incorrect code. */ - if (TARGET_64BIT && TREE_CODE(type) == COMPLEX_TYPE && - TREE_INT_CST_LOW(TYPE_SIZE_UNIT(type)) > 8) - return 1; - /* LLVM LOCAL end strcut return check */ - if (TARGET_64BIT) return !examine_argument (mode, type, 1, &needed_intregs, &needed_sseregs); From dalej at apple.com Tue Apr 29 17:58:20 2008 From: dalej at apple.com (Dale Johannesen) Date: Tue, 29 Apr 2008 22:58:20 -0000 Subject: [llvm-commits] [llvm] r50451 - /llvm/trunk/lib/CodeGen/DwarfWriter.cpp Message-ID: <200804292258.m3TMwKqh014302@zion.cs.uiuc.edu> Author: johannes Date: Tue Apr 29 17:58:20 2008 New Revision: 50451 URL: http://llvm.org/viewvc/llvm-project?rev=50451&view=rev Log: Make eh_frame objects by 8-byte aligned on 64-bit targets. Modified: llvm/trunk/lib/CodeGen/DwarfWriter.cpp Modified: llvm/trunk/lib/CodeGen/DwarfWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/DwarfWriter.cpp?rev=50451&r1=50450&r2=50451&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/DwarfWriter.cpp (original) +++ llvm/trunk/lib/CodeGen/DwarfWriter.cpp Tue Apr 29 17:58:20 2008 @@ -2876,7 +2876,8 @@ RI->getInitialFrameState(Moves); EmitFrameMoves(NULL, 0, Moves, true); - Asm->EmitAlignment(2, 0, 0, false); + Asm->EmitAlignment(TD->getPointerSize() == sizeof(int32_t) ? 2 : 3, + 0, 0, false); EmitLabel("eh_frame_common_end", Index); Asm->EOL(); @@ -2965,7 +2966,8 @@ // frame. EmitFrameMoves("eh_func_begin", EHFrameInfo.Number, EHFrameInfo.Moves, true); - Asm->EmitAlignment(2, 0, 0, false); + Asm->EmitAlignment(TD->getPointerSize() == sizeof(int32_t) ? 2 : 3, + 0, 0, false); EmitLabel("eh_frame_end", EHFrameInfo.Number); // If the function is marked used, this table should be also. We cannot From dpatel at apple.com Tue Apr 29 18:27:28 2008 From: dpatel at apple.com (Devang Patel) Date: Tue, 29 Apr 2008 23:27:28 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50455 - in /llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple: asm-block-13.c asm-block-17.c asm-block-18.c asm-block-24.c asm-block-25.c asm-block-28.c asm-block-30.c asm-block-32.c asm-block-33.c asm-block-36.c asm-block-37.c asm-block-38.c asm-block-39.c asm-block-41.c asm-block-45.c asm-block-50.c asm-block-52.c asm-block-54.c asm-block-55.c asm-block-57.c asm-block-59.c asm-block-64.c Message-ID: <200804292327.m3TNRSfr015119@zion.cs.uiuc.edu> Author: dpatel Date: Tue Apr 29 18:27:27 2008 New Revision: 50455 URL: http://llvm.org/viewvc/llvm-project?rev=50455&view=rev Log: Disable asm-block tests for now. (Tak -> Mainline) Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-13.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-17.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-18.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-24.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-25.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-28.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-30.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-32.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-33.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-36.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-37.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-38.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-39.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-41.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-45.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-50.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-52.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-54.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-55.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-57.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-59.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-64.c Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-13.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-13.c?rev=50455&r1=50454&r2=50455&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-13.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-13.c Tue Apr 29 18:27:27 2008 @@ -1,6 +1,7 @@ /* APPLE LOCAL file CW asm blocks */ /* { dg-do assemble { target i?86*-*-darwin* } } */ -/* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 } } */ /* Radar 4259442 */ Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-17.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-17.c?rev=50455&r1=50454&r2=50455&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-17.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-17.c Tue Apr 29 18:27:27 2008 @@ -1,6 +1,7 @@ /* APPLE LOCAL file CW asm blocks */ /* { dg-do assemble { target i?86*-*-darwin* } } */ -/* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 -O2 } } */ /* Radar */ Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-18.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-18.c?rev=50455&r1=50454&r2=50455&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-18.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-18.c Tue Apr 29 18:27:27 2008 @@ -1,6 +1,7 @@ /* APPLE LOCAL file CW asm blocks */ /* { dg-do assemble { target i?86*-*-darwin* } } */ -/* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 -O2 } } */ /* Radar 4248228 */ Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-24.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-24.c?rev=50455&r1=50454&r2=50455&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-24.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-24.c Tue Apr 29 18:27:27 2008 @@ -1,6 +1,7 @@ /* APPLE LOCAL file CW asm blocks */ /* { dg-do assemble { target i?86*-*-darwin* } } */ -/* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 } } */ /* Radar 4300095 */ Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-25.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-25.c?rev=50455&r1=50454&r2=50455&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-25.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-25.c Tue Apr 29 18:27:27 2008 @@ -1,6 +1,7 @@ /* APPLE LOCAL file CW asm blocks */ /* { dg-do assemble { target i?86*-*-darwin* } } */ -/* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 } } */ /* Radar 4309942 */ Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-28.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-28.c?rev=50455&r1=50454&r2=50455&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-28.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-28.c Tue Apr 29 18:27:27 2008 @@ -1,6 +1,8 @@ /* APPLE LOCAL file CW asm blocks */ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-options { -fasm-blocks -msse3 -O } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4300156 */ int i; Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-30.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-30.c?rev=50455&r1=50454&r2=50455&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-30.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-30.c Tue Apr 29 18:27:27 2008 @@ -1,6 +1,8 @@ /* APPLE LOCAL file CW asm blocks */ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-options { -fasm-blocks -msse3 } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4300108 */ void foo() { Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-32.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-32.c?rev=50455&r1=50454&r2=50455&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-32.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-32.c Tue Apr 29 18:27:27 2008 @@ -2,6 +2,8 @@ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4319887 */ void bar(); Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-33.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-33.c?rev=50455&r1=50454&r2=50455&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-33.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-33.c Tue Apr 29 18:27:27 2008 @@ -2,6 +2,8 @@ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4300193 */ int i, j, k; Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-36.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-36.c?rev=50455&r1=50454&r2=50455&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-36.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-36.c Tue Apr 29 18:27:27 2008 @@ -2,6 +2,8 @@ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4371958 */ #define SourceArray(row, col) (sPtr [(row) * sRowBytes + (col)]) Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-37.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-37.c?rev=50455&r1=50454&r2=50455&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-37.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-37.c Tue Apr 29 18:27:27 2008 @@ -1,6 +1,8 @@ /* APPLE LOCAL file CW asm blocks */ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-options { -fasm-blocks -msse3 -O1 } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4433955 */ void X2_Interpolate2DNoPinFourCol(const char *sPtr, Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-38.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-38.c?rev=50455&r1=50454&r2=50455&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-38.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-38.c Tue Apr 29 18:27:27 2008 @@ -1,6 +1,8 @@ /* APPLE LOCAL file CW asm blocks */ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-options { -fasm-blocks -msse3 } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4433955 */ void X2_Interpolate2DNoPinFourCol(const char *sPtr, Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-39.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-39.c?rev=50455&r1=50454&r2=50455&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-39.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-39.c Tue Apr 29 18:27:27 2008 @@ -1,6 +1,8 @@ /* APPLE LOCAL file CW asm blocks */ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-options { -fasm-blocks -msse3 } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4432782 */ void foo() { Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-41.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-41.c?rev=50455&r1=50454&r2=50455&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-41.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-41.c Tue Apr 29 18:27:27 2008 @@ -2,6 +2,8 @@ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4429851 */ void foo() { Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-45.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-45.c?rev=50455&r1=50454&r2=50455&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-45.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-45.c Tue Apr 29 18:27:27 2008 @@ -2,6 +2,8 @@ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4419735 */ void foo(short* pSrc) { Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-50.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-50.c?rev=50455&r1=50454&r2=50455&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-50.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-50.c Tue Apr 29 18:27:27 2008 @@ -2,6 +2,8 @@ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4505741 */ static int c[5]; Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-52.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-52.c?rev=50455&r1=50454&r2=50455&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-52.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-52.c Tue Apr 29 18:27:27 2008 @@ -1,6 +1,8 @@ /* APPLE LOCAL file CW asm blocks */ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-options { -fasm-blocks -O } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4527214 */ inline int foo(int x, int y) { Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-54.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-54.c?rev=50455&r1=50454&r2=50455&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-54.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-54.c Tue Apr 29 18:27:27 2008 @@ -2,6 +2,8 @@ /* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 } } */ /* { dg-final { scan-assembler "movq -\(16|36\)\\\(%ebp\\\), %mm0" } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4515069 */ void foo() { Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-55.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-55.c?rev=50455&r1=50454&r2=50455&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-55.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-55.c Tue Apr 29 18:27:27 2008 @@ -2,6 +2,8 @@ /* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 -mdynamic-no-pic } } */ /* { dg-final { scan-assembler "movq _packedw1.*, %mm0" } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4515069 */ void foo() { Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-57.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-57.c?rev=50455&r1=50454&r2=50455&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-57.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-57.c Tue Apr 29 18:27:27 2008 @@ -2,6 +2,8 @@ /* { dg-do run { target i?86*-*-darwin* } } */ /* { dg-skip-if "" { i?86*-*-darwin* } { "-m64" } } */ /* { dg-options { -fasm-blocks -msse3 } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4682427 */ void bar() __attribute ((weak)); Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-59.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-59.c?rev=50455&r1=50454&r2=50455&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-59.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-59.c Tue Apr 29 18:27:27 2008 @@ -3,6 +3,8 @@ /* { dg-options { -fasm-blocks -msse3 -O2 } } */ /* { dg-require-effective-target ilp32 } */ /* { dg-final { scan-assembler "-\(40|44\)\\\(%ebp,%edx,2\\\), %ebx" } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4699545 */ void bar() { Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-64.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-64.c?rev=50455&r1=50454&r2=50455&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-64.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-64.c Tue Apr 29 18:27:27 2008 @@ -1,5 +1,7 @@ /* { dg-do compile { target i?86*-*-darwin* } } */ /* { dg-options { -fasm-blocks -O2 } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 5315594 */ typedef unsigned char unsigned8; From isanbard at gmail.com Tue Apr 29 18:42:48 2008 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 29 Apr 2008 23:42:48 -0000 Subject: [llvm-commits] [llvm] r50456 - /llvm/branches/Apple/Tak/lib/CodeGen/DwarfWriter.cpp Message-ID: <200804292342.m3TNgmnD015612@zion.cs.uiuc.edu> Author: void Date: Tue Apr 29 18:42:48 2008 New Revision: 50456 URL: http://llvm.org/viewvc/llvm-project?rev=50456&view=rev Log: Porting r50451 to Tak. Modified: llvm/branches/Apple/Tak/lib/CodeGen/DwarfWriter.cpp Modified: llvm/branches/Apple/Tak/lib/CodeGen/DwarfWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Tak/lib/CodeGen/DwarfWriter.cpp?rev=50456&r1=50455&r2=50456&view=diff ============================================================================== --- llvm/branches/Apple/Tak/lib/CodeGen/DwarfWriter.cpp (original) +++ llvm/branches/Apple/Tak/lib/CodeGen/DwarfWriter.cpp Tue Apr 29 18:42:48 2008 @@ -2876,7 +2876,8 @@ RI->getInitialFrameState(Moves); EmitFrameMoves(NULL, 0, Moves, true); - Asm->EmitAlignment(2, 0, 0, false); + Asm->EmitAlignment(TD->getPointerSize() == sizeof(int32_t) ? 2 : 3, + 0, 0, false); EmitLabel("eh_frame_common_end", Index); Asm->EOL(); @@ -2965,7 +2966,8 @@ // frame. EmitFrameMoves("eh_func_begin", EHFrameInfo.Number, EHFrameInfo.Moves, true); - Asm->EmitAlignment(2, 0, 0, false); + Asm->EmitAlignment(TD->getPointerSize() == sizeof(int32_t) ? 2 : 3, + 0, 0, false); EmitLabel("eh_frame_end", EHFrameInfo.Number); // If the function is marked used, this table should be also. We cannot From clattner at apple.com Tue Apr 29 18:53:14 2008 From: clattner at apple.com (Chris Lattner) Date: Tue, 29 Apr 2008 16:53:14 -0700 Subject: [llvm-commits] [llvm] r50451 - /llvm/trunk/lib/CodeGen/DwarfWriter.cpp In-Reply-To: <200804292258.m3TMwKqh014302@zion.cs.uiuc.edu> References: <200804292258.m3TMwKqh014302@zion.cs.uiuc.edu> Message-ID: <55F786FF-166E-4AC1-A911-1362F9ACC95E@apple.com> On Apr 29, 2008, at 3:58 PM, Dale Johannesen wrote: > Author: johannes > Date: Tue Apr 29 17:58:20 2008 > New Revision: 50451 > > URL: http://llvm.org/viewvc/llvm-project?rev=50451&view=rev > Log: > Make eh_frame objects by 8-byte aligned on 64-bit > targets. Hi Dale, It's not obvious, but this is a correctness issue, please add a comment explaining what is going on here. Thanks for fixing this! -Chris > > > > Modified: > llvm/trunk/lib/CodeGen/DwarfWriter.cpp > > Modified: llvm/trunk/lib/CodeGen/DwarfWriter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/DwarfWriter.cpp?rev=50451&r1=50450&r2=50451&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/CodeGen/DwarfWriter.cpp (original) > +++ llvm/trunk/lib/CodeGen/DwarfWriter.cpp Tue Apr 29 17:58:20 2008 > @@ -2876,7 +2876,8 @@ > RI->getInitialFrameState(Moves); > EmitFrameMoves(NULL, 0, Moves, true); > > - Asm->EmitAlignment(2, 0, 0, false); > + Asm->EmitAlignment(TD->getPointerSize() == sizeof(int32_t) ? > 2 : 3, > + 0, 0, false); > EmitLabel("eh_frame_common_end", Index); > > Asm->EOL(); > @@ -2965,7 +2966,8 @@ > // frame. > EmitFrameMoves("eh_func_begin", EHFrameInfo.Number, > EHFrameInfo.Moves, true); > > - Asm->EmitAlignment(2, 0, 0, false); > + Asm->EmitAlignment(TD->getPointerSize() == sizeof(int32_t) ? > 2 : 3, > + 0, 0, false); > EmitLabel("eh_frame_end", EHFrameInfo.Number); > > // If the function is marked used, this table should be also. > We cannot > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From dpatel at apple.com Tue Apr 29 18:57:32 2008 From: dpatel at apple.com (Devang Patel) Date: Tue, 29 Apr 2008 23:57:32 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50457 - in /llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple: asm-block-13.c asm-block-17.c asm-block-18.c asm-block-24.c asm-block-25.c asm-block-28.c asm-block-30.c asm-block-32.c asm-block-33.c asm-block-36.c asm-block-37.c asm-block-38.c asm-block-39.c asm-block-41.c asm-block-45.c asm-block-50.c asm-block-52.c asm-block-54.c asm-block-55.c asm-block-57.c asm-block-59.c asm-block-64.c Message-ID: <200804292357.m3TNvXeY016031@zion.cs.uiuc.edu> Author: dpatel Date: Tue Apr 29 18:57:32 2008 New Revision: 50457 URL: http://llvm.org/viewvc/llvm-project?rev=50457&view=rev Log: undo Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-13.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-17.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-18.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-24.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-25.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-28.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-30.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-32.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-33.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-36.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-37.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-38.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-39.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-41.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-45.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-50.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-52.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-54.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-55.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-57.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-59.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-64.c Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-13.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-13.c?rev=50457&r1=50456&r2=50457&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-13.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-13.c Tue Apr 29 18:57:32 2008 @@ -1,7 +1,6 @@ /* APPLE LOCAL file CW asm blocks */ /* { dg-do assemble { target i?86*-*-darwin* } } */ -/* LLVM LOCAL disable test */ -/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ +/* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 } } */ /* Radar 4259442 */ Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-17.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-17.c?rev=50457&r1=50456&r2=50457&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-17.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-17.c Tue Apr 29 18:57:32 2008 @@ -1,7 +1,6 @@ /* APPLE LOCAL file CW asm blocks */ /* { dg-do assemble { target i?86*-*-darwin* } } */ -/* LLVM LOCAL disable test */ -/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ +/* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 -O2 } } */ /* Radar */ Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-18.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-18.c?rev=50457&r1=50456&r2=50457&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-18.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-18.c Tue Apr 29 18:57:32 2008 @@ -1,7 +1,6 @@ /* APPLE LOCAL file CW asm blocks */ /* { dg-do assemble { target i?86*-*-darwin* } } */ -/* LLVM LOCAL disable test */ -/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ +/* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 -O2 } } */ /* Radar 4248228 */ Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-24.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-24.c?rev=50457&r1=50456&r2=50457&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-24.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-24.c Tue Apr 29 18:57:32 2008 @@ -1,7 +1,6 @@ /* APPLE LOCAL file CW asm blocks */ /* { dg-do assemble { target i?86*-*-darwin* } } */ -/* LLVM LOCAL disable test */ -/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ +/* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 } } */ /* Radar 4300095 */ Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-25.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-25.c?rev=50457&r1=50456&r2=50457&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-25.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-25.c Tue Apr 29 18:57:32 2008 @@ -1,7 +1,6 @@ /* APPLE LOCAL file CW asm blocks */ /* { dg-do assemble { target i?86*-*-darwin* } } */ -/* LLVM LOCAL disable test */ -/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ +/* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 } } */ /* Radar 4309942 */ Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-28.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-28.c?rev=50457&r1=50456&r2=50457&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-28.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-28.c Tue Apr 29 18:57:32 2008 @@ -1,8 +1,6 @@ /* APPLE LOCAL file CW asm blocks */ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-options { -fasm-blocks -msse3 -O } } */ -/* LLVM LOCAL disable test */ -/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4300156 */ int i; Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-30.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-30.c?rev=50457&r1=50456&r2=50457&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-30.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-30.c Tue Apr 29 18:57:32 2008 @@ -1,8 +1,6 @@ /* APPLE LOCAL file CW asm blocks */ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-options { -fasm-blocks -msse3 } } */ -/* LLVM LOCAL disable test */ -/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4300108 */ void foo() { Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-32.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-32.c?rev=50457&r1=50456&r2=50457&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-32.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-32.c Tue Apr 29 18:57:32 2008 @@ -2,8 +2,6 @@ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 } } */ -/* LLVM LOCAL disable test */ -/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4319887 */ void bar(); Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-33.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-33.c?rev=50457&r1=50456&r2=50457&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-33.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-33.c Tue Apr 29 18:57:32 2008 @@ -2,8 +2,6 @@ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 } } */ -/* LLVM LOCAL disable test */ -/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4300193 */ int i, j, k; Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-36.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-36.c?rev=50457&r1=50456&r2=50457&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-36.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-36.c Tue Apr 29 18:57:32 2008 @@ -2,8 +2,6 @@ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 } } */ -/* LLVM LOCAL disable test */ -/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4371958 */ #define SourceArray(row, col) (sPtr [(row) * sRowBytes + (col)]) Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-37.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-37.c?rev=50457&r1=50456&r2=50457&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-37.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-37.c Tue Apr 29 18:57:32 2008 @@ -1,8 +1,6 @@ /* APPLE LOCAL file CW asm blocks */ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-options { -fasm-blocks -msse3 -O1 } } */ -/* LLVM LOCAL disable test */ -/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4433955 */ void X2_Interpolate2DNoPinFourCol(const char *sPtr, Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-38.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-38.c?rev=50457&r1=50456&r2=50457&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-38.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-38.c Tue Apr 29 18:57:32 2008 @@ -1,8 +1,6 @@ /* APPLE LOCAL file CW asm blocks */ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-options { -fasm-blocks -msse3 } } */ -/* LLVM LOCAL disable test */ -/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4433955 */ void X2_Interpolate2DNoPinFourCol(const char *sPtr, Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-39.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-39.c?rev=50457&r1=50456&r2=50457&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-39.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-39.c Tue Apr 29 18:57:32 2008 @@ -1,8 +1,6 @@ /* APPLE LOCAL file CW asm blocks */ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-options { -fasm-blocks -msse3 } } */ -/* LLVM LOCAL disable test */ -/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4432782 */ void foo() { Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-41.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-41.c?rev=50457&r1=50456&r2=50457&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-41.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-41.c Tue Apr 29 18:57:32 2008 @@ -2,8 +2,6 @@ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 } } */ -/* LLVM LOCAL disable test */ -/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4429851 */ void foo() { Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-45.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-45.c?rev=50457&r1=50456&r2=50457&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-45.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-45.c Tue Apr 29 18:57:32 2008 @@ -2,8 +2,6 @@ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 } } */ -/* LLVM LOCAL disable test */ -/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4419735 */ void foo(short* pSrc) { Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-50.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-50.c?rev=50457&r1=50456&r2=50457&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-50.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-50.c Tue Apr 29 18:57:32 2008 @@ -2,8 +2,6 @@ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 } } */ -/* LLVM LOCAL disable test */ -/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4505741 */ static int c[5]; Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-52.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-52.c?rev=50457&r1=50456&r2=50457&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-52.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-52.c Tue Apr 29 18:57:32 2008 @@ -1,8 +1,6 @@ /* APPLE LOCAL file CW asm blocks */ /* { dg-do assemble { target i?86*-*-darwin* } } */ /* { dg-options { -fasm-blocks -O } } */ -/* LLVM LOCAL disable test */ -/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4527214 */ inline int foo(int x, int y) { Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-54.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-54.c?rev=50457&r1=50456&r2=50457&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-54.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-54.c Tue Apr 29 18:57:32 2008 @@ -2,8 +2,6 @@ /* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 } } */ /* { dg-final { scan-assembler "movq -\(16|36\)\\\(%ebp\\\), %mm0" } } */ -/* LLVM LOCAL disable test */ -/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4515069 */ void foo() { Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-55.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-55.c?rev=50457&r1=50456&r2=50457&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-55.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-55.c Tue Apr 29 18:57:32 2008 @@ -2,8 +2,6 @@ /* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */ /* { dg-options { -fasm-blocks -msse3 -mdynamic-no-pic } } */ /* { dg-final { scan-assembler "movq _packedw1.*, %mm0" } } */ -/* LLVM LOCAL disable test */ -/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4515069 */ void foo() { Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-57.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-57.c?rev=50457&r1=50456&r2=50457&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-57.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-57.c Tue Apr 29 18:57:32 2008 @@ -2,8 +2,6 @@ /* { dg-do run { target i?86*-*-darwin* } } */ /* { dg-skip-if "" { i?86*-*-darwin* } { "-m64" } } */ /* { dg-options { -fasm-blocks -msse3 } } */ -/* LLVM LOCAL disable test */ -/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4682427 */ void bar() __attribute ((weak)); Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-59.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-59.c?rev=50457&r1=50456&r2=50457&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-59.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-59.c Tue Apr 29 18:57:32 2008 @@ -3,8 +3,6 @@ /* { dg-options { -fasm-blocks -msse3 -O2 } } */ /* { dg-require-effective-target ilp32 } */ /* { dg-final { scan-assembler "-\(40|44\)\\\(%ebp,%edx,2\\\), %ebx" } } */ -/* LLVM LOCAL disable test */ -/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 4699545 */ void bar() { Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-64.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-64.c?rev=50457&r1=50456&r2=50457&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-64.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/asm-block-64.c Tue Apr 29 18:57:32 2008 @@ -1,7 +1,5 @@ /* { dg-do compile { target i?86*-*-darwin* } } */ /* { dg-options { -fasm-blocks -O2 } } */ -/* LLVM LOCAL disable test */ -/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Radar 5315594 */ typedef unsigned char unsigned8; From isanbard at gmail.com Tue Apr 29 19:13:15 2008 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 30 Apr 2008 00:13:15 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50459 - /llvm-gcc-4.2/branches/Apple/Tak/gcc/objc/objc-act.c Message-ID: <200804300013.m3U0DFir016471@zion.cs.uiuc.edu> Author: void Date: Tue Apr 29 19:13:15 2008 New Revision: 50459 URL: http://llvm.org/viewvc/llvm-project?rev=50459&view=rev Log: For classlist references, we need to reset the initializer. Otherwise, we get null values. Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/objc/objc-act.c Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/objc/objc-act.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/objc/objc-act.c?rev=50459&r1=50458&r2=50459&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/objc/objc-act.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/objc/objc-act.c Tue Apr 29 19:13:15 2008 @@ -5399,6 +5399,13 @@ expr = convert (objc_class_type, build_fold_addr_expr (expr)); } finish_var_decl (decl, expr); + /* LLVM LOCAL begin - radar 5720120 */ +#ifdef ENABLE_LLVM + /* Reset the initializer for this reference as it most likely changed. */ + if (!optimize) + reset_initializer_llvm(decl); +#endif + /* LLVM LOCAL end - radar 5720120 */ } } From isanbard at gmail.com Tue Apr 29 19:15:25 2008 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 30 Apr 2008 00:15:25 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50460 - /llvm-gcc-4.2/trunk/gcc/objc/objc-act.c Message-ID: <200804300015.m3U0FPSu016558@zion.cs.uiuc.edu> Author: void Date: Tue Apr 29 19:15:25 2008 New Revision: 50460 URL: http://llvm.org/viewvc/llvm-project?rev=50460&view=rev Log: Porting r50459 from Tak to mainline: For classlist references, we need to reset the initializer. Otherwise, we get null values. Modified: llvm-gcc-4.2/trunk/gcc/objc/objc-act.c Modified: llvm-gcc-4.2/trunk/gcc/objc/objc-act.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/objc/objc-act.c?rev=50460&r1=50459&r2=50460&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/objc/objc-act.c (original) +++ llvm-gcc-4.2/trunk/gcc/objc/objc-act.c Tue Apr 29 19:15:25 2008 @@ -5399,6 +5399,13 @@ expr = convert (objc_class_type, build_fold_addr_expr (expr)); } finish_var_decl (decl, expr); + /* LLVM LOCAL begin - radar 5720120 */ +#ifdef ENABLE_LLVM + /* Reset the initializer for this reference as it most likely changed. */ + if (!optimize) + reset_initializer_llvm(decl); +#endif + /* LLVM LOCAL end - radar 5720120 */ } } From scottm at aero.org Tue Apr 29 19:26:38 2008 From: scottm at aero.org (Scott Michel) Date: Wed, 30 Apr 2008 00:26:38 -0000 Subject: [llvm-commits] [llvm] r50461 - /llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Message-ID: <200804300026.m3U0QcjY016910@zion.cs.uiuc.edu> Author: pingbak Date: Tue Apr 29 19:26:38 2008 New Revision: 50461 URL: http://llvm.org/viewvc/llvm-project?rev=50461&view=rev Log: Fix custom target lowering for zero/any/sign_extend: make sure that DAG.UpdateNodeOperands() is called before (not after) the call to TLI.LowerOperation(). Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=50461&r1=50460&r2=50461&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Tue Apr 29 19:26:38 2008 @@ -3874,14 +3874,12 @@ case Expand: assert(0 && "Shouldn't need to expand other operators here!"); case Legal: Tmp1 = LegalizeOp(Node->getOperand(0)); + Result = DAG.UpdateNodeOperands(Result, Tmp1); if (TLI.getOperationAction(Node->getOpcode(), Node->getValueType(0)) == TargetLowering::Custom) { - Tmp2 = TLI.LowerOperation(Result, DAG); - if (Tmp2.Val) { - Tmp1 = Tmp2; - } + Tmp1 = TLI.LowerOperation(Result, DAG); + if (Tmp1.Val) Result = Tmp1; } - Result = DAG.UpdateNodeOperands(Result, Tmp1); break; case Promote: switch (Node->getOpcode()) { From scottm at aero.org Tue Apr 29 19:30:08 2008 From: scottm at aero.org (Scott Michel) Date: Wed, 30 Apr 2008 00:30:08 -0000 Subject: [llvm-commits] [llvm] r50462 - in /llvm/trunk/lib/Target/CellSPU: SPUFrameInfo.h SPUISelDAGToDAG.cpp SPUISelLowering.cpp SPUISelLowering.h SPUInstrInfo.td SPUNodes.td SPUOperands.td Message-ID: <200804300030.m3U0U95s017017@zion.cs.uiuc.edu> Author: pingbak Date: Tue Apr 29 19:30:08 2008 New Revision: 50462 URL: http://llvm.org/viewvc/llvm-project?rev=50462&view=rev Log: Bug fixes and updates for CellSPU, syncing up with trunk. Most notable fixes are target-specific lowering of frame indices, fix constants generated for the FSMBI instruction, and fixing SPUTargetLowering::computeMaskedBitsFor- TargetNode(). Modified: llvm/trunk/lib/Target/CellSPU/SPUFrameInfo.h llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp llvm/trunk/lib/Target/CellSPU/SPUISelLowering.h llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.td llvm/trunk/lib/Target/CellSPU/SPUNodes.td llvm/trunk/lib/Target/CellSPU/SPUOperands.td Modified: llvm/trunk/lib/Target/CellSPU/SPUFrameInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUFrameInfo.h?rev=50462&r1=50461&r2=50462&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUFrameInfo.h (original) +++ llvm/trunk/lib/Target/CellSPU/SPUFrameInfo.h Tue Apr 29 19:30:08 2008 @@ -57,6 +57,10 @@ static int fullSpillSize() { return (SPURegisterInfo::getNumArgRegs() * stackSlotSize()); } + //! Convert frame index to stack offset + static int FItoStackOffset(int frame_index) { + return frame_index * stackSlotSize(); + } //! Number of instructions required to overcome hint-for-branch latency /*! HBR (hint-for-branch) instructions can be inserted when, for example, Modified: llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp?rev=50462&r1=50461&r2=50462&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp Tue Apr 29 19:30:08 2008 @@ -17,6 +17,7 @@ #include "SPUISelLowering.h" #include "SPUHazardRecognizers.h" #include "SPUFrameInfo.h" +#include "SPURegisterNames.h" #include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineFunction.h" @@ -411,7 +412,10 @@ bool SPUDAGToDAGISel::SelectDForm2Addr(SDOperand Op, SDOperand N, SDOperand &Disp, SDOperand &Base) { - return DFormAddressPredicate(Op, N, Disp, Base, -(1 << 7), (1 << 7) - 1); + const int minDForm2Offset = -(1 << 7); + const int maxDForm2Offset = (1 << 7) - 1; + return DFormAddressPredicate(Op, N, Disp, Base, minDForm2Offset, + maxDForm2Offset); } /*! @@ -443,12 +447,13 @@ if (Opc == ISD::FrameIndex) { // Stack frame index must be less than 512 (divided by 16): - FrameIndexSDNode *FI = dyn_cast(N); + FrameIndexSDNode *FIN = dyn_cast(N); + int FI = int(FIN->getIndex()); DEBUG(cerr << "SelectDFormAddr: ISD::FrameIndex = " - << FI->getIndex() << "\n"); - if (FI->getIndex() < maxOffset) { + << FI << "\n"); + if (SPUFrameInfo::FItoStackOffset(FI) < maxOffset) { Base = CurDAG->getTargetConstant(0, PtrTy); - Index = CurDAG->getTargetFrameIndex(FI->getIndex(), PtrTy); + Index = CurDAG->getTargetFrameIndex(FI, PtrTy); return true; } } else if (Opc == ISD::ADD) { @@ -467,13 +472,14 @@ int32_t offset = int32_t(CN->getSignExtended()); if (Op0.getOpcode() == ISD::FrameIndex) { - FrameIndexSDNode *FI = dyn_cast(Op0); + FrameIndexSDNode *FIN = dyn_cast(Op0); + int FI = int(FIN->getIndex()); DEBUG(cerr << "SelectDFormAddr: ISD::ADD offset = " << offset - << " frame index = " << FI->getIndex() << "\n"); + << " frame index = " << FI << "\n"); - if (FI->getIndex() < maxOffset) { + if (SPUFrameInfo::FItoStackOffset(FI) < maxOffset) { Base = CurDAG->getTargetConstant(offset, PtrTy); - Index = CurDAG->getTargetFrameIndex(FI->getIndex(), PtrTy); + Index = CurDAG->getTargetFrameIndex(FI, PtrTy); return true; } } else if (offset > minOffset && offset < maxOffset) { @@ -487,13 +493,14 @@ int32_t offset = int32_t(CN->getSignExtended()); if (Op1.getOpcode() == ISD::FrameIndex) { - FrameIndexSDNode *FI = dyn_cast(Op1); + FrameIndexSDNode *FIN = dyn_cast(Op1); + int FI = int(FIN->getIndex()); DEBUG(cerr << "SelectDFormAddr: ISD::ADD offset = " << offset - << " frame index = " << FI->getIndex() << "\n"); + << " frame index = " << FI << "\n"); - if (FI->getIndex() < maxOffset) { + if (SPUFrameInfo::FItoStackOffset(FI) < maxOffset) { Base = CurDAG->getTargetConstant(offset, PtrTy); - Index = CurDAG->getTargetFrameIndex(FI->getIndex(), PtrTy); + Index = CurDAG->getTargetFrameIndex(FI, PtrTy); return true; } } else if (offset > minOffset && offset < maxOffset) { @@ -583,17 +590,31 @@ if (Opc >= ISD::BUILTIN_OP_END && Opc < SPUISD::FIRST_NUMBER) { return NULL; // Already selected. } else if (Opc == ISD::FrameIndex) { - // Selects to AIr32 FI, 0 which in turn will become AIr32 SP, imm. - int FI = cast(N)->getIndex(); + // Selects to (add $sp, FI * stackSlotSize) + int FI = + SPUFrameInfo::FItoStackOffset(cast(N)->getIndex()); MVT::ValueType PtrVT = SPUtli.getPointerTy(); - SDOperand Zero = CurDAG->getTargetConstant(0, PtrVT); - SDOperand TFI = CurDAG->getTargetFrameIndex(FI, PtrVT); - DEBUG(cerr << "SPUDAGToDAGISel: Replacing FrameIndex with AI32 , 0\n"); - NewOpc = SPU::AIr32; - Ops[0] = TFI; - Ops[1] = Zero; - n_ops = 2; + // Adjust stack slot to actual offset in frame: + if (isS10Constant(FI)) { + DEBUG(cerr << "SPUDAGToDAGISel: Replacing FrameIndex with AIr32 $sp, " + << FI + << "\n"); + NewOpc = SPU::AIr32; + Ops[0] = CurDAG->getRegister(SPU::R1, PtrVT); + Ops[1] = CurDAG->getTargetConstant(FI, PtrVT); + n_ops = 2; + } else { + DEBUG(cerr << "SPUDAGToDAGISel: Replacing FrameIndex with Ar32 $sp, " + << FI + << "\n"); + NewOpc = SPU::Ar32; + Ops[0] = CurDAG->getRegister(SPU::R1, PtrVT); + Ops[1] = CurDAG->getConstant(FI, PtrVT); + n_ops = 2; + + AddToISelQueue(Ops[1]); + } } else if (Opc == ISD::ZERO_EXTEND) { // (zero_extend:i16 (and:i8 , )) const SDOperand &Op1 = N->getOperand(0); Modified: llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp?rev=50462&r1=50461&r2=50462&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp Tue Apr 29 19:30:08 2008 @@ -14,6 +14,7 @@ #include "SPURegisterNames.h" #include "SPUISelLowering.h" #include "SPUTargetMachine.h" +#include "SPUFrameInfo.h" #include "llvm/ADT/VectorExtras.h" #include "llvm/Analysis/ScalarEvolutionExpressions.h" #include "llvm/CodeGen/CallingConvLower.h" @@ -514,6 +515,12 @@ alignOffs = 0; prefSlotOffs = -vtm->prefslot_byte; } + } else if (basePtr.getOpcode() == ISD::FrameIndex) { + FrameIndexSDNode *FIN = cast(basePtr); + alignOffs = int(FIN->getIndex() * SPUFrameInfo::stackSlotSize()); + prefSlotOffs = (int) (alignOffs & 0xf); + prefSlotOffs -= vtm->prefslot_byte; + basePtr = DAG.getRegister(SPU::R1, VT); } else { alignOffs = 0; prefSlotOffs = -vtm->prefslot_byte; @@ -1912,7 +1919,7 @@ SDOperand FSMBOp = DAG.getCopyToReg(Chain, FSMBIreg, DAG.getNode(SPUISD::FSMBI, MVT::v8i16, - DAG.getConstant(0xcccc, MVT::i32))); + DAG.getConstant(0xcccc, MVT::i16))); SDOperand HHProd = DAG.getCopyToReg(FSMBOp, HiProdReg, @@ -1956,7 +1963,7 @@ DAG.getNode(SPUISD::MPY, MVT::v8i16, rALH, rBLH), c8); SDOperand FSMBmask = DAG.getNode(SPUISD::FSMBI, MVT::v8i16, - DAG.getConstant(0x2222, MVT::i32)); + DAG.getConstant(0x2222, MVT::i16)); SDOperand LoProdParts = DAG.getNode(ISD::BIT_CONVERT, MVT::v4i32, @@ -2271,6 +2278,7 @@ assert(Op0VT == MVT::i32 && "CellSPU: Zero/sign extending something other than i32"); + DEBUG(cerr << "CellSPU: LowerI64Math custom lowering zero/sign/any extend\n"); unsigned NewOpc = (Opc == ISD::SIGN_EXTEND ? SPUISD::ROTBYTES_RIGHT_S @@ -2764,7 +2772,7 @@ } } // Otherwise, return unchanged. -#if 0 +#if 1 if (Result.Val) { DEBUG(cerr << "\nReplace.SPU: "); DEBUG(N->dump(&DAG)); @@ -2833,7 +2841,9 @@ APInt &KnownOne, const SelectionDAG &DAG, unsigned Depth ) const { +#if 0 const uint64_t uint64_sizebits = sizeof(uint64_t) * 8; +#endif switch (Op.getOpcode()) { default: @@ -2849,18 +2859,22 @@ case SPUISD::PROMOTE_SCALAR: { SDOperand Op0 = Op.getOperand(0); - uint64_t InMask = MVT::getIntVTBitMask(Op0.getValueType()); - KnownZero |= APInt(uint64_sizebits, ~InMask, false); - KnownOne |= APInt(uint64_sizebits, InMask, false); + MVT::ValueType Op0VT = Op0.getValueType(); + unsigned Op0VTBits = MVT::getSizeInBits(Op0VT); + uint64_t InMask = MVT::getIntVTBitMask(Op0VT); + KnownZero |= APInt(Op0VTBits, ~InMask, false); + KnownOne |= APInt(Op0VTBits, InMask, false); break; } case SPUISD::LDRESULT: case SPUISD::EXTRACT_ELT0: case SPUISD::EXTRACT_ELT0_CHAINED: { - uint64_t InMask = MVT::getIntVTBitMask(Op.getValueType()); - KnownZero |= APInt(uint64_sizebits, ~InMask, false); - KnownOne |= APInt(uint64_sizebits, InMask, false); + MVT::ValueType OpVT = Op.getValueType(); + unsigned OpVTBits = MVT::getSizeInBits(OpVT); + uint64_t InMask = MVT::getIntVTBitMask(OpVT); + KnownZero |= APInt(OpVTBits, ~InMask, false); + KnownOne |= APInt(OpVTBits, InMask, false); break; } @@ -2873,21 +2887,20 @@ case MPYU: case MPYH: case MPYHH: - case SHLQUAD_L_BITS: - case SHLQUAD_L_BYTES: - case VEC_SHL: - case VEC_SRL: - case VEC_SRA: - case VEC_ROTL: - case VEC_ROTR: - case ROTQUAD_RZ_BYTES: - case ROTQUAD_RZ_BITS: - case ROTBYTES_RIGHT_S: - case ROTBYTES_LEFT: - case ROTBYTES_LEFT_CHAINED: + case SPUISD::SHLQUAD_L_BITS: + case SPUISD::SHLQUAD_L_BYTES: + case SPUISD::VEC_SHL: + case SPUISD::VEC_SRL: + case SPUISD::VEC_SRA: + case SPUISD::VEC_ROTL: + case SPUISD::VEC_ROTR: + case SPUISD::ROTQUAD_RZ_BYTES: + case SPUISD::ROTQUAD_RZ_BITS: + case SPUISD::ROTBYTES_RIGHT_S: + case SPUISD::ROTBYTES_LEFT: + case SPUISD::ROTBYTES_LEFT_CHAINED: case FSMBI: case SELB: - case SFPConstant: case FPInterp: case FPRecipEst: case SEXT32TO64: @@ -2895,6 +2908,16 @@ } } +// LowerAsmOperandForConstraint +void +SPUTargetLowering::LowerAsmOperandForConstraint(SDOperand Op, + char ConstraintLetter, + std::vector &Ops, + SelectionDAG &DAG) const { + // Default, for the time being, to the base class handler + TargetLowering::LowerAsmOperandForConstraint(Op, ConstraintLetter, Ops, DAG); +} + /// isLegalAddressImmediate - Return true if the integer value can be used /// as the offset of the target addressing mode. bool SPUTargetLowering::isLegalAddressImmediate(int64_t V, const Type *Ty) const { Modified: llvm/trunk/lib/Target/CellSPU/SPUISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUISelLowering.h?rev=50462&r1=50461&r2=50462&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUISelLowering.h (original) +++ llvm/trunk/lib/Target/CellSPU/SPUISelLowering.h Tue Apr 29 19:30:08 2008 @@ -125,6 +125,10 @@ getRegForInlineAsmConstraint(const std::string &Constraint, MVT::ValueType VT) const; + void LowerAsmOperandForConstraint(SDOperand Op, char ConstraintLetter, + std::vector &Ops, + SelectionDAG &DAG) const; + /// isLegalAddressImmediate - Return true if the integer value can be used /// as the offset of the target addressing mode. virtual bool isLegalAddressImmediate(int64_t V, const Type *Ty) const; Modified: llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.td?rev=50462&r1=50461&r2=50462&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.td (original) +++ llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.td Tue Apr 29 19:30:08 2008 @@ -22,10 +22,10 @@ //===----------------------------------------------------------------------===// let hasCtrlDep = 1, Defs = [R1], Uses = [R1] in { - def ADJCALLSTACKDOWN : Pseudo<(outs), (ins u16imm:$amt), + def ADJCALLSTACKDOWN : Pseudo<(outs), (ins u16imm_i32:$amt), "${:comment} ADJCALLSTACKDOWN", [(callseq_start imm:$amt)]>; - def ADJCALLSTACKUP : Pseudo<(outs), (ins u16imm:$amt), + def ADJCALLSTACKUP : Pseudo<(outs), (ins u16imm_i32:$amt), "${:comment} ADJCALLSTACKUP", [(callseq_end imm:$amt)]>; } @@ -290,18 +290,34 @@ "cwd\t$rT, $src", ShuffleOp, [(set (v4i32 VECREG:$rT), (SPUvecinsmask dform2_addr:$src))]>; +def CWDf32 : RI7Form<0b01101111100, (outs VECREG:$rT), (ins memri7:$src), + "cwd\t$rT, $src", ShuffleOp, + [(set (v4f32 VECREG:$rT), (SPUvecinsmask dform2_addr:$src))]>; + def CWX : RRForm<0b01101011100, (outs VECREG:$rT), (ins memrr:$src), "cwx\t$rT, $src", ShuffleOp, [(set (v4i32 VECREG:$rT), (SPUvecinsmask xform_addr:$src))]>; +def CWXf32 : RRForm<0b01101011100, (outs VECREG:$rT), (ins memrr:$src), + "cwx\t$rT, $src", ShuffleOp, + [(set (v4f32 VECREG:$rT), (SPUvecinsmask xform_addr:$src))]>; + def CDD : RI7Form<0b11101111100, (outs VECREG:$rT), (ins memri7:$src), "cdd\t$rT, $src", ShuffleOp, [(set (v2i64 VECREG:$rT), (SPUvecinsmask dform2_addr:$src))]>; +def CDDf64 : RI7Form<0b11101111100, (outs VECREG:$rT), (ins memri7:$src), + "cdd\t$rT, $src", ShuffleOp, + [(set (v2f64 VECREG:$rT), (SPUvecinsmask dform2_addr:$src))]>; + def CDX : RRForm<0b11101011100, (outs VECREG:$rT), (ins memrr:$src), "cdx\t$rT, $src", ShuffleOp, [(set (v2i64 VECREG:$rT), (SPUvecinsmask xform_addr:$src))]>; +def CDXf64 : RRForm<0b11101011100, (outs VECREG:$rT), (ins memrr:$src), + "cdx\t$rT, $src", ShuffleOp, + [(set (v2f64 VECREG:$rT), (SPUvecinsmask xform_addr:$src))]>; + //===----------------------------------------------------------------------===// // Constant formation: //===----------------------------------------------------------------------===// @@ -367,10 +383,10 @@ multiclass ImmLoadHalfwordUpper { def v2i64: ILHUVecInst; - def v4i32: ILHUVecInst; + def v4i32: ILHUVecInst; def r64: ILHURegInst; - def r32: ILHURegInst; + def r32: ILHURegInst; // Loads the high portion of an address def hi: ILHURegInst; @@ -436,7 +452,7 @@ multiclass ImmOrHalfwordLower { def v2i64: IOHLVecInst; - def v4i32: IOHLVecInst; + def v4i32: IOHLVecInst; def r32: IOHLRegInst; def f32: IOHLRegInst; @@ -453,7 +469,7 @@ RI16Form<0b101001100, (outs VECREG:$rT), (ins u16imm:$val), "fsmbi\t$rT, $val", SelectOp, - [(set (vectype VECREG:$rT), (SPUfsmbi (i32 immU16:$val)))]>; + [(set (vectype VECREG:$rT), (SPUfsmbi (i16 immU16:$val)))]>; multiclass FormSelectMaskBytesImm { @@ -3873,6 +3889,13 @@ (SPUlo tconstpool:$in, 0)), (IOHLlo (ILHUhi tconstpool:$in), tconstpool:$in)>; +def : Pat<(SPUindirect R32C:$sp, i32ImmSExt10:$imm), + (AIr32 R32C:$sp, i32ImmSExt10:$imm)>; + +def : Pat<(SPUindirect R32C:$sp, imm:$imm), + (Ar32 R32C:$sp, + (IOHLr32 (ILHUr32 (HI16 imm:$imm)), (LO16 imm:$imm)))>; + def : Pat<(add (SPUhi tglobaladdr:$in, 0), (SPUlo tglobaladdr:$in, 0)), (IOHLlo (ILHUhi tglobaladdr:$in), tglobaladdr:$in)>; Modified: llvm/trunk/lib/Target/CellSPU/SPUNodes.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUNodes.td?rev=50462&r1=50461&r2=50462&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUNodes.td (original) +++ llvm/trunk/lib/Target/CellSPU/SPUNodes.td Tue Apr 29 19:30:08 2008 @@ -59,7 +59,8 @@ // FSMBI type constraints: There are several variations for the various // vector types (this avoids having to bit_convert all over the place.) def SPUfsmbi_type: SDTypeProfile<1, 1, [ - /* SDTCisVT<1, i32> */ SDTCisInt<1>]>; + SDTCisInt<1> +]>; // SELB type constraints: def SPUselb_type: SDTypeProfile<1, 3, [ Modified: llvm/trunk/lib/Target/CellSPU/SPUOperands.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUOperands.td?rev=50462&r1=50461&r2=50462&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUOperands.td (original) +++ llvm/trunk/lib/Target/CellSPU/SPUOperands.td Tue Apr 29 19:30:08 2008 @@ -509,7 +509,11 @@ let PrintMethod = "printU16ImmOperand"; } -def u16imm : Operand { +def u16imm_i32 : Operand { + let PrintMethod = "printU16ImmOperand"; +} + +def u16imm : Operand { let PrintMethod = "printU16ImmOperand"; } From dalej at apple.com Tue Apr 29 19:43:29 2008 From: dalej at apple.com (Dale Johannesen) Date: Wed, 30 Apr 2008 00:43:29 -0000 Subject: [llvm-commits] [llvm] r50463 - /llvm/trunk/lib/CodeGen/DwarfWriter.cpp Message-ID: <200804300043.m3U0hTkf017529@zion.cs.uiuc.edu> Author: johannes Date: Tue Apr 29 19:43:29 2008 New Revision: 50463 URL: http://llvm.org/viewvc/llvm-project?rev=50463&view=rev Log: Add comments for previous patch as requested. Modified: llvm/trunk/lib/CodeGen/DwarfWriter.cpp Modified: llvm/trunk/lib/CodeGen/DwarfWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/DwarfWriter.cpp?rev=50463&r1=50462&r2=50463&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/DwarfWriter.cpp (original) +++ llvm/trunk/lib/CodeGen/DwarfWriter.cpp Tue Apr 29 19:43:29 2008 @@ -2876,6 +2876,9 @@ RI->getInitialFrameState(Moves); EmitFrameMoves(NULL, 0, Moves, true); + // On Darwin the linker honors the alignment of eh_frame, which means it + // must be 8-byte on 64-bit targets to match what gcc does. Otherwise + // you get holes which confuse readers of eh_frame. Asm->EmitAlignment(TD->getPointerSize() == sizeof(int32_t) ? 2 : 3, 0, 0, false); EmitLabel("eh_frame_common_end", Index); @@ -2966,6 +2969,9 @@ // frame. EmitFrameMoves("eh_func_begin", EHFrameInfo.Number, EHFrameInfo.Moves, true); + // On Darwin the linker honors the alignment of eh_frame, which means it + // must be 8-byte on 64-bit targets to match what gcc does. Otherwise + // you get holes which confuse readers of eh_frame. Asm->EmitAlignment(TD->getPointerSize() == sizeof(int32_t) ? 2 : 3, 0, 0, false); EmitLabel("eh_frame_end", EHFrameInfo.Number); From wangmp at apple.com Tue Apr 29 20:38:34 2008 From: wangmp at apple.com (Mon P Wang) Date: Tue, 29 Apr 2008 18:38:34 -0700 Subject: [llvm-commits] atomic operator patch Message-ID: <74859BF3-9BE5-4418-8482-7AC4171E565B@apple.com> Currently, llvm support add, swap, and the compare and swap. I want to add support for atomic support for sub, and, or, xor, min and max (the latter two in both signed and unsigned version) in X86 line. The intrinsic names are of the form __sync_fetch_and_[opname] like other sync intrinsics. If you have any issues or concerns, please let me know. -------------- next part -------------- A non-text attachment was scrubbed... Name: atomic_op.patch Type: application/octet-stream Size: 30968 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20080429/2fdddf6d/attachment.obj -------------- next part -------------- From sabre at nondot.org Tue Apr 29 22:07:59 2008 From: sabre at nondot.org (Chris Lattner) Date: Wed, 30 Apr 2008 03:07:59 -0000 Subject: [llvm-commits] [llvm] r50464 - /llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp Message-ID: <200804300308.m3U380QH022404@zion.cs.uiuc.edu> Author: lattner Date: Tue Apr 29 22:07:53 2008 New Revision: 50464 URL: http://llvm.org/viewvc/llvm-project?rev=50464&view=rev Log: use string length computation to generalize several xforms. Modified: llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp Modified: llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp?rev=50464&r1=50463&r2=50464&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp Tue Apr 29 22:07:53 2008 @@ -496,14 +496,13 @@ Value *Dst = CI->getOperand(1); Value *Src = CI->getOperand(2); - // Extract the initializer (while making numerous checks) from the - // source operand of the call to strcat. - std::string SrcStr; - if (!GetConstantStringInfo(Src, SrcStr)) - return false; - + // See if we can get the length of the input string. + uint64_t Len = GetStringLength(Src); + if (Len == 0) return false; + --Len; // Unbias length. + // Handle the simple, do-nothing case - if (SrcStr.empty()) + if (Len == 0) return ReplaceCallWith(CI, Dst); // We need to find the end of the destination string. That's where the @@ -520,7 +519,7 @@ // do the concatenation for us. Value *Vals[] = { Dst, Src, - ConstantInt::get(SLC.getIntPtrType(), SrcStr.size()+1), // copy nul byte. + ConstantInt::get(SLC.getIntPtrType(), Len+1), // copy nul byte. ConstantInt::get(Type::Int32Ty, 1) // alignment }; CallInst::Create(SLC.get_memcpy(), Vals, Vals + 4, "", CI); @@ -549,23 +548,29 @@ /// @brief Perform the strchr optimizations virtual bool OptimizeCall(CallInst *CI, SimplifyLibCalls &SLC) { - // Check that the first argument to strchr is a constant array of sbyte. - std::string Str; - if (!GetConstantStringInfo(CI->getOperand(1), Str)) - return false; - - // If the second operand is not constant, just lower this to memchr since we - // know the length of the input string. + Value *SrcStr = CI->getOperand(1); + // If the second operand is not constant, see if we can compute the length + // and turn this into memchr. ConstantInt *CSI = dyn_cast(CI->getOperand(2)); - if (!CSI) { + if (CSI == 0) { + uint64_t Len = GetStringLength(SrcStr); + if (Len == 0) return false; + Value *Args[3] = { CI->getOperand(1), CI->getOperand(2), - ConstantInt::get(SLC.getIntPtrType(), Str.size()+1) + ConstantInt::get(SLC.getIntPtrType(), Len) // include nul. }; - return ReplaceCallWith(CI, CallInst::Create(SLC.get_memchr(), Args, Args + 3, + return ReplaceCallWith(CI, CallInst::Create(SLC.get_memchr(), + Args, Args + 3, CI->getName(), CI)); } + + // Otherwise, the character is a constant, see if the first argument is + // a string literal. If so, we can constant fold. + std::string Str; + if (!GetConstantStringInfo(SrcStr, Str)) + return false; // strchr can find the nul character. Str += '\0'; @@ -747,14 +752,14 @@ return ReplaceCallWith(CI, Dst); } - // Get the length of the constant string referenced by the Src operand. - std::string SrcStr; - if (!GetConstantStringInfo(Src, SrcStr)) - return false; + // See if we can get the length of the input string. + uint64_t Len = GetStringLength(Src); + if (Len == 0) return false; + --Len; // Unbias length. // If the constant string's length is zero we can optimize this by just - // doing a store of 0 at the first byte of the destination - if (SrcStr.empty()) { + // doing a store of 0 at the first byte of the destination. + if (Len == 0) { new StoreInst(ConstantInt::get(Type::Int8Ty, 0), Dst, CI); return ReplaceCallWith(CI, Dst); } @@ -762,8 +767,8 @@ // We have enough information to now generate the memcpy call to // do the concatenation for us. Value *MemcpyOps[] = { - Dst, Src, // Pass length including nul byte. - ConstantInt::get(SLC.getIntPtrType(), SrcStr.size()+1), + Dst, Src, + ConstantInt::get(SLC.getIntPtrType(), Len+1),// Length including nul byte. ConstantInt::get(Type::Int32Ty, 1) // alignment }; CallInst::Create(SLC.get_memcpy(), MemcpyOps, MemcpyOps + 4, "", CI); @@ -1525,21 +1530,19 @@ if (!CI->use_empty()) return false; - // All the optimizations depend on the length of the first argument and the - // fact that it is a constant string array. Check that now - std::string Str; - if (!GetConstantStringInfo(CI->getOperand(1), Str)) - return false; - + // All the optimizations depend on the length of the first argument. + uint64_t Len = GetStringLength(CI->getOperand(1)); + if (!Len) return false; + const Type *FILETy = CI->getOperand(2)->getType(); - // fputs(s,F) -> fwrite(s,1,len,F) (if s is constant and strlen(s) > 1) - Value *FWriteParms[4] = { + // fputs(s,F) -> fwrite(s,1,strlen(s),F) + Value *Ops[4] = { CI->getOperand(1), - ConstantInt::get(SLC.getIntPtrType(), Str.size()), + ConstantInt::get(SLC.getIntPtrType(), Len-1), ConstantInt::get(SLC.getIntPtrType(), 1), CI->getOperand(2) }; - CallInst::Create(SLC.get_fwrite(FILETy), FWriteParms, FWriteParms + 4, "", CI); + CallInst::Create(SLC.get_fwrite(FILETy), Ops, Ops + 4, "", CI); return ReplaceCallWith(CI, 0); // Known to have no uses (see above). } } FPutsOptimizer; From wangmp at apple.com Tue Apr 29 22:39:59 2008 From: wangmp at apple.com (Mon P Wang) Date: Tue, 29 Apr 2008 20:39:59 -0700 Subject: [llvm-commits] atomic operator patch In-Reply-To: <74859BF3-9BE5-4418-8482-7AC4171E565B@apple.com> References: <74859BF3-9BE5-4418-8482-7AC4171E565B@apple.com> Message-ID: <504C1329-8389-4EEF-8A92-9A4DEE6520A5@apple.com> I have updated the patch because I forgot to delete some obsolete functions as well as removed some unnecessary indentation changes. -------------- next part -------------- A non-text attachment was scrubbed... Name: atomic_op2.patch Type: application/octet-stream Size: 29738 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20080429/cb56b47b/attachment.obj -------------- next part -------------- On Apr 29, 2008, at 6:38 PM, Mon P Wang wrote: > Currently, llvm support add, swap, and the compare and swap. I > want to add support for atomic support for sub, and, or, xor, min > and max (the latter two in both signed and unsigned version) in X86 > line. The intrinsic names are of the form > __sync_fetch_and_[opname] like other sync intrinsics. If you have > any issues or concerns, please let me know. > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From sabre at nondot.org Tue Apr 29 22:55:41 2008 From: sabre at nondot.org (Chris Lattner) Date: Wed, 30 Apr 2008 03:55:41 -0000 Subject: [llvm-commits] [llvm] r50465 - in /llvm/trunk: include/llvm/Value.h lib/VMCore/Value.cpp Message-ID: <200804300355.m3U3tgib023640@zion.cs.uiuc.edu> Author: lattner Date: Tue Apr 29 22:55:40 2008 New Revision: 50465 URL: http://llvm.org/viewvc/llvm-project?rev=50465&view=rev Log: add a method for comparing to see if a value has a specified name. Modified: llvm/trunk/include/llvm/Value.h llvm/trunk/lib/VMCore/Value.cpp Modified: llvm/trunk/include/llvm/Value.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Value.h?rev=50465&r1=50464&r2=50465&view=diff ============================================================================== --- llvm/trunk/include/llvm/Value.h (original) +++ llvm/trunk/include/llvm/Value.h Tue Apr 29 22:55:40 2008 @@ -95,6 +95,10 @@ /// their end. This always returns a non-null pointer. const char *getNameStart() const; + /// isName - Return true if this value has the name specified by the provided + /// nul terminated string. + bool isName(const char *N) const; + /// getNameLen - Return the length of the string, correctly handling nul /// characters embedded into them. unsigned getNameLen() const; Modified: llvm/trunk/lib/VMCore/Value.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Value.cpp?rev=50465&r1=50464&r2=50465&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Value.cpp (original) +++ llvm/trunk/lib/VMCore/Value.cpp Tue Apr 29 22:55:40 2008 @@ -136,6 +136,13 @@ return Name ? Name->getKeyLength() : 0; } +/// isName - Return true if this value has the name specified by the provided +/// nul terminated string. +bool Value::isName(const char *N) const { + unsigned InLen = strlen(N); + return InLen = getNameLen() && memcmp(getNameStart(), N, InLen) == 0; +} + std::string Value::getNameStr() const { if (Name == 0) return ""; From sabre at nondot.org Tue Apr 29 23:56:14 2008 From: sabre at nondot.org (Chris Lattner) Date: Wed, 30 Apr 2008 04:56:14 -0000 Subject: [llvm-commits] [llvm] r50468 - /llvm/trunk/include/llvm/Intrinsics.h Message-ID: <200804300456.m3U4uEBB025398@zion.cs.uiuc.edu> Author: lattner Date: Tue Apr 29 23:56:14 2008 New Revision: 50468 URL: http://llvm.org/viewvc/llvm-project?rev=50468&view=rev Log: add missing #include Modified: llvm/trunk/include/llvm/Intrinsics.h Modified: llvm/trunk/include/llvm/Intrinsics.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Intrinsics.h?rev=50468&r1=50467&r2=50468&view=diff ============================================================================== --- llvm/trunk/include/llvm/Intrinsics.h (original) +++ llvm/trunk/include/llvm/Intrinsics.h Tue Apr 29 23:56:14 2008 @@ -16,6 +16,8 @@ #ifndef LLVM_INTRINSICS_H #define LLVM_INTRINSICS_H +#include + namespace llvm { class Type; From sabre at nondot.org Wed Apr 30 01:06:38 2008 From: sabre at nondot.org (Chris Lattner) Date: Wed, 30 Apr 2008 06:06:38 -0000 Subject: [llvm-commits] [llvm] r50469 - /llvm/trunk/test/Transforms/SimplifyLibCalls/memcmp.ll Message-ID: <200804300606.m3U66cBu027627@zion.cs.uiuc.edu> Author: lattner Date: Wed Apr 30 01:06:37 2008 New Revision: 50469 URL: http://llvm.org/viewvc/llvm-project?rev=50469&view=rev Log: remove redundant check. Modified: llvm/trunk/test/Transforms/SimplifyLibCalls/memcmp.ll Modified: llvm/trunk/test/Transforms/SimplifyLibCalls/memcmp.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyLibCalls/memcmp.ll?rev=50469&r1=50468&r2=50469&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SimplifyLibCalls/memcmp.ll (original) +++ llvm/trunk/test/Transforms/SimplifyLibCalls/memcmp.ll Wed Apr 30 01:06:37 2008 @@ -1,7 +1,5 @@ ; Test that the memcmpOptimizer works correctly -; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | \ -; RUN: not grep {call.*memcmp} -; RUN: llvm-as < %s | opt -simplify-libcalls -disable-output +; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | not grep {call.*memcmp} @h = constant [2 x i8] c"h\00" ; <[2 x i8]*> [#uses=0] @hel = constant [4 x i8] c"hel\00" ; <[4 x i8]*> [#uses=0] From sabre at nondot.org Wed Apr 30 01:12:16 2008 From: sabre at nondot.org (Chris Lattner) Date: Wed, 30 Apr 2008 06:12:16 -0000 Subject: [llvm-commits] [llvm] r50470 - /llvm/trunk/test/Transforms/SimplifyLibCalls/MemCpy.ll Message-ID: <200804300612.m3U6CG6Q027779@zion.cs.uiuc.edu> Author: lattner Date: Wed Apr 30 01:12:15 2008 New Revision: 50470 URL: http://llvm.org/viewvc/llvm-project?rev=50470&view=rev Log: no reason for simplifylibcalls to simplify intrinsics, instcombine does a fine job. Modified: llvm/trunk/test/Transforms/SimplifyLibCalls/MemCpy.ll Modified: llvm/trunk/test/Transforms/SimplifyLibCalls/MemCpy.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyLibCalls/MemCpy.ll?rev=50470&r1=50469&r2=50470&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SimplifyLibCalls/MemCpy.ll (original) +++ llvm/trunk/test/Transforms/SimplifyLibCalls/MemCpy.ll Wed Apr 30 01:12:15 2008 @@ -1,6 +1,4 @@ -; Test that the StrCatOptimizer works correctly -; RUN: llvm-as < %s | opt -constprop -simplify-libcalls | \ -; RUN: llvm-dis | not grep {call.*llvm.memcpy.i32} +; RUN: llvm-as < %s | opt -constprop -instcombine | llvm-dis | not grep {call.*llvm.memcpy.i32} @h = constant [2 x i8] c"h\00" ; <[2 x i8]*> [#uses=1] @hel = constant [4 x i8] c"hel\00" ; <[4 x i8]*> [#uses=1] From ggreif at gmail.com Wed Apr 30 01:15:13 2008 From: ggreif at gmail.com (Gabor Greif) Date: Wed, 30 Apr 2008 06:15:13 -0000 Subject: [llvm-commits] [llvm] r50471 - in /llvm/branches/ggreif/use-diet/include/llvm: Use.h User.h Message-ID: <200804300615.m3U6FDXF027864@zion.cs.uiuc.edu> Author: ggreif Date: Wed Apr 30 01:15:13 2008 New Revision: 50471 URL: http://llvm.org/viewvc/llvm-project?rev=50471&view=rev Log: make some methods protected Modified: llvm/branches/ggreif/use-diet/include/llvm/Use.h llvm/branches/ggreif/use-diet/include/llvm/User.h Modified: llvm/branches/ggreif/use-diet/include/llvm/Use.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Use.h?rev=50471&r1=50470&r2=50471&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/Use.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/Use.h Wed Apr 30 01:15:13 2008 @@ -96,6 +96,14 @@ operator Value*() const { return Val; } Value *get() const { return Val; } User *getUser() const; + inline User *getUserFast() const { + unsigned t = extractTag(Prev); + if (t == fullStopTag) { + if (extractTag(this[1].Val)) + return reinterpret_cast(stripTag(this[1].Val)); + else return (User*)(this + 1); + } else return getUser(); // fallback + } const Use* getImpliedUser() const; static Use *initTags(Use *Start, Use *Stop, ptrdiff_t Done = 0); static void zap(Use *Start, const Use *Stop, bool del = false); @@ -191,8 +199,8 @@ // Retrieve a reference to the current SCC UserTy *operator*() const { - assert(U && "Cannot increment end iterator!"); - return U->getUser(); + assert(U && "Cannot dereference end iterator!"); + return U->getUserFast(); } UserTy *operator->() const { return operator*(); } Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/User.h?rev=50471&r1=50470&r2=50471&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/User.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/User.h Wed Apr 30 01:15:13 2008 @@ -239,6 +239,14 @@ } User(const Type *Ty, unsigned vty, Use *OpList, unsigned NumOps) : Value(Ty, vty), OperandList(OpList), NumOperands(NumOps) {} + Use *allocHungoffUses(unsigned) const; + void dropHungoffUses(Use *U) { + if (OperandList == U) { + OperandList = 0; + NumOperands = 0; + } + Use::zap(U, U->getImpliedUser(), true); + } public: ~User() { Use::zap(OperandList, OperandList + NumOperands); @@ -250,22 +258,12 @@ ? Storage : Usr); } -public: template Use &Op() { return OperandTraits::op_begin(this)[Idx]; } template const Use &Op() const { return OperandTraits::op_begin(const_cast(this))[Idx]; } - Use *allocHungoffUses(unsigned) const; - void dropHungoffUses(Use *U) { - if (OperandList == U) { - OperandList = 0; - NumOperands = 0; - } - Use::zap(U, U->getImpliedUser(), true); - } - Value *getOperand(unsigned i) const { assert(i < NumOperands && "getOperand() out of range!"); return OperandList[i]; From sabre at nondot.org Wed Apr 30 01:39:12 2008 From: sabre at nondot.org (Chris Lattner) Date: Wed, 30 Apr 2008 06:39:12 -0000 Subject: [llvm-commits] [llvm] r50472 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/memset.ll Message-ID: <200804300639.m3U6dCJW028520@zion.cs.uiuc.edu> Author: lattner Date: Wed Apr 30 01:39:11 2008 New Revision: 50472 URL: http://llvm.org/viewvc/llvm-project?rev=50472&view=rev Log: move lowering of llvm.memset -> store from simplify libcalls to instcombine. Added: llvm/trunk/test/Transforms/InstCombine/memset.ll Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=50472&r1=50471&r2=50472&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Wed Apr 30 01:39:11 2008 @@ -370,6 +370,7 @@ Instruction *MatchBSwap(BinaryOperator &I); bool SimplifyStoreAtEndOfBlock(StoreInst &SI); Instruction *SimplifyMemTransfer(MemIntrinsic *MI); + Instruction *SimplifyMemSet(MemSetInst *MI); Value *EvaluateInDifferentType(Value *V, const Type *Ty, bool isSigned); @@ -8491,7 +8492,9 @@ // A single load+store correctly handles overlapping memory in the memmove // case. unsigned Size = MemOpLength->getZExtValue(); - if (Size == 0 || Size > 8 || (Size&(Size-1))) + if (Size == 0) return MI; // Delete this mem transfer. + + if (Size > 8 || (Size&(Size-1))) return 0; // If not 1/2/4/8 bytes, exit. // Use an integer load+store unless we can find something better. @@ -8545,6 +8548,48 @@ return MI; } +Instruction *InstCombiner::SimplifyMemSet(MemSetInst *MI) { + unsigned Alignment = GetOrEnforceKnownAlignment(MI->getDest()); + if (MI->getAlignment()->getZExtValue() < Alignment) { + MI->setAlignment(ConstantInt::get(Type::Int32Ty, Alignment)); + return MI; + } + + // Extract the length and alignment and fill if they are constant. + ConstantInt *LenC = dyn_cast(MI->getLength()); + ConstantInt *FillC = dyn_cast(MI->getValue()); + if (!LenC || !FillC || FillC->getType() != Type::Int8Ty) + return 0; + uint64_t Len = LenC->getZExtValue(); + Alignment = MI->getAlignment()->getZExtValue(); + + // If the length is zero, this is a no-op + if (Len == 0) return MI; // memset(d,c,0,a) -> noop + + // memset(s,c,n) -> store s, c (for n=1,2,4,8) + if (Len <= 8 && isPowerOf2_32((uint32_t)Len)) { + const Type *ITy = IntegerType::get(Len*8); // n=1 -> i8. + + Value *Dest = MI->getDest(); + Dest = InsertBitCastBefore(Dest, PointerType::getUnqual(ITy), *MI); + + // Alignment 0 is identity for alignment 1 for memset, but not store. + if (Alignment == 0) Alignment = 1; + + // Extract the fill value and store. + uint64_t Fill = FillC->getZExtValue()*0x0101010101010101ULL; + InsertNewInstBefore(new StoreInst(ConstantInt::get(ITy, Fill), Dest, false, + Alignment), *MI); + + // Set the size of the copy to 0, it will be deleted on the next iteration. + MI->setLength(Constant::getNullValue(LenC->getType())); + return MI; + } + + return 0; +} + + /// visitCallInst - CallInst simplification. This mostly only handles folding /// of intrinsic instructions. For normal calls, it allows visitCallSite to do /// the heavy lifting. @@ -8592,12 +8637,9 @@ if (isa(MI) || isa(MI)) { if (Instruction *I = SimplifyMemTransfer(MI)) return I; - } else if (isa(MI)) { - unsigned Alignment = GetOrEnforceKnownAlignment(MI->getDest()); - if (MI->getAlignment()->getZExtValue() < Alignment) { - MI->setAlignment(ConstantInt::get(Type::Int32Ty, Alignment)); - Changed = true; - } + } else if (MemSetInst *MSI = dyn_cast(MI)) { + if (Instruction *I = SimplifyMemSet(MSI)) + return I; } if (Changed) return II; Added: llvm/trunk/test/Transforms/InstCombine/memset.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/memset.ll?rev=50472&view=auto ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/memset.ll (added) +++ llvm/trunk/test/Transforms/InstCombine/memset.ll Wed Apr 30 01:39:11 2008 @@ -0,0 +1,15 @@ +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep {call.*llvm.memset} + +declare void @llvm.memset.i32(i8*, i8, i32, i32) + +define i32 @main() { + %target = alloca [1024 x i8] ; <[1024 x i8]*> [#uses=1] + %target_p = getelementptr [1024 x i8]* %target, i32 0, i32 0 ; [#uses=5] + call void @llvm.memset.i32( i8* %target_p, i8 1, i32 0, i32 1 ) + call void @llvm.memset.i32( i8* %target_p, i8 1, i32 1, i32 1 ) + call void @llvm.memset.i32( i8* %target_p, i8 1, i32 2, i32 2 ) + call void @llvm.memset.i32( i8* %target_p, i8 1, i32 4, i32 4 ) + call void @llvm.memset.i32( i8* %target_p, i8 1, i32 8, i32 8 ) + ret i32 0 +} + From resistor at mac.com Wed Apr 30 02:16:33 2008 From: resistor at mac.com (Owen Anderson) Date: Wed, 30 Apr 2008 07:16:33 -0000 Subject: [llvm-commits] [llvm] r50473 - /llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp Message-ID: <200804300716.m3U7GXPb030388@zion.cs.uiuc.edu> Author: resistor Date: Wed Apr 30 02:16:33 2008 New Revision: 50473 URL: http://llvm.org/viewvc/llvm-project?rev=50473&view=rev Log: This condition got inverted accidentally. Modified: llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp?rev=50473&r1=50472&r2=50473&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp Wed Apr 30 02:16:33 2008 @@ -179,7 +179,7 @@ // Don't remove loops for which we can't solve the trip count. // They could be infinite, in which case we'd be changing program behavior. - if (L->getTripCount()) + if (!L->getTripCount()) return false; // Loops with multiple exits or exits that don't dominate the latch From resistor at mac.com Wed Apr 30 02:17:23 2008 From: resistor at mac.com (Owen Anderson) Date: Wed, 30 Apr 2008 07:17:23 -0000 Subject: [llvm-commits] [llvm] r50474 - in /llvm/trunk/test/Transforms: ADCE/2007-07-23-InfiniteLoop.ll LoopDeletion/ LoopDeletion/2007-07-23-InfiniteLoop.ll LoopDeletion/dg.exp Message-ID: <200804300717.m3U7HNfq030427@zion.cs.uiuc.edu> Author: resistor Date: Wed Apr 30 02:17:22 2008 New Revision: 50474 URL: http://llvm.org/viewvc/llvm-project?rev=50474&view=rev Log: Move this test to LoopDeletion, where it now passes. Added: llvm/trunk/test/Transforms/LoopDeletion/ llvm/trunk/test/Transforms/LoopDeletion/2007-07-23-InfiniteLoop.ll - copied, changed from r50443, llvm/trunk/test/Transforms/ADCE/2007-07-23-InfiniteLoop.ll llvm/trunk/test/Transforms/LoopDeletion/dg.exp Removed: llvm/trunk/test/Transforms/ADCE/2007-07-23-InfiniteLoop.ll Removed: llvm/trunk/test/Transforms/ADCE/2007-07-23-InfiniteLoop.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ADCE/2007-07-23-InfiniteLoop.ll?rev=50473&view=auto ============================================================================== --- llvm/trunk/test/Transforms/ADCE/2007-07-23-InfiniteLoop.ll (original) +++ llvm/trunk/test/Transforms/ADCE/2007-07-23-InfiniteLoop.ll (removed) @@ -1,14 +0,0 @@ -; RUN: llvm-as < %s | opt -adce | llvm-dis | grep switch -; PR 1564 -; XFAIL: * - -define fastcc void @out() { - start: - br label %loop - unreachable: - unreachable - loop: - switch i32 0, label %unreachable [ - i32 0, label %loop - ] -} Copied: llvm/trunk/test/Transforms/LoopDeletion/2007-07-23-InfiniteLoop.ll (from r50443, llvm/trunk/test/Transforms/ADCE/2007-07-23-InfiniteLoop.ll) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopDeletion/2007-07-23-InfiniteLoop.ll?p2=llvm/trunk/test/Transforms/LoopDeletion/2007-07-23-InfiniteLoop.ll&p1=llvm/trunk/test/Transforms/ADCE/2007-07-23-InfiniteLoop.ll&r1=50443&r2=50474&rev=50474&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ADCE/2007-07-23-InfiniteLoop.ll (original) +++ llvm/trunk/test/Transforms/LoopDeletion/2007-07-23-InfiniteLoop.ll Wed Apr 30 02:17:22 2008 @@ -1,6 +1,5 @@ -; RUN: llvm-as < %s | opt -adce | llvm-dis | grep switch +; RUN: llvm-as < %s | opt -loop-deletion | llvm-dis | grep switch ; PR 1564 -; XFAIL: * define fastcc void @out() { start: Added: llvm/trunk/test/Transforms/LoopDeletion/dg.exp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopDeletion/dg.exp?rev=50474&view=auto ============================================================================== --- llvm/trunk/test/Transforms/LoopDeletion/dg.exp (added) +++ llvm/trunk/test/Transforms/LoopDeletion/dg.exp Wed Apr 30 02:17:22 2008 @@ -0,0 +1,3 @@ +load_lib llvm.exp + +RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,llx,c,cpp,tr}]] From ggreif at gmail.com Wed Apr 30 03:53:22 2008 From: ggreif at gmail.com (Gabor Greif) Date: Wed, 30 Apr 2008 08:53:22 -0000 Subject: [llvm-commits] [llvm] r50475 - /llvm/trunk/lib/Support/MemoryBuffer.cpp Message-ID: <200804300853.m3U8rMHx009115@zion.cs.uiuc.edu> Author: ggreif Date: Wed Apr 30 03:53:22 2008 New Revision: 50475 URL: http://llvm.org/viewvc/llvm-project?rev=50475&view=rev Log: fcntl.h is pretty standard on unix (without the sys/) Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/MemoryBuffer.cpp?rev=50475&r1=50474&r2=50475&view=diff ============================================================================== --- llvm/trunk/lib/Support/MemoryBuffer.cpp (original) +++ llvm/trunk/lib/Support/MemoryBuffer.cpp Wed Apr 30 03:53:22 2008 @@ -26,11 +26,10 @@ #if !defined(_MSC_VER) && !defined(__MINGW32__) #include #include -#include #else #include -#include #endif +#include using namespace llvm; //===----------------------------------------------------------------------===// From ggreif at gmail.com Wed Apr 30 03:59:22 2008 From: ggreif at gmail.com (Gabor Greif) Date: Wed, 30 Apr 2008 08:59:22 -0000 Subject: [llvm-commits] [llvm] r50476 - /llvm/trunk/lib/Target/CppBackend/ Message-ID: <200804300859.m3U8xNSo009275@zion.cs.uiuc.edu> Author: ggreif Date: Wed Apr 30 03:59:22 2008 New Revision: 50476 URL: http://llvm.org/viewvc/llvm-project?rev=50476&view=rev Log: set ignore property Modified: llvm/trunk/lib/Target/CppBackend/ (props changed) Propchange: llvm/trunk/lib/Target/CppBackend/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Wed Apr 30 03:59:22 2008 @@ -0,0 +1,3 @@ +Release +Debug + From arnold.schwaighofer at gmail.com Wed Apr 30 04:16:34 2008 From: arnold.schwaighofer at gmail.com (Arnold Schwaighofer) Date: Wed, 30 Apr 2008 09:16:34 -0000 Subject: [llvm-commits] [llvm] r50477 - in /llvm/trunk: include/llvm/Target/ lib/CodeGen/SelectionDAG/ lib/Target/PowerPC/ lib/Target/X86/ test/CodeGen/PowerPC/ Message-ID: <200804300916.m3U9GZT3010459@zion.cs.uiuc.edu> Author: arnolds Date: Wed Apr 30 04:16:33 2008 New Revision: 50477 URL: http://llvm.org/viewvc/llvm-project?rev=50477&view=rev Log: Tail call optimization improvements: Move platform independent code (lowering of possibly overwritten arguments, check for tail call optimization eligibility) from target X86ISelectionLowering.cpp to TargetLowering.h and SelectionDAGISel.cpp. Initial PowerPC tail call implementation: Support ppc32 implemented and tested (passes my tests and test-suite llvm-test). Support ppc64 implemented and half tested (passes my tests). On ppc tail call optimization is performed if caller and callee are fastcc call is a tail call (in tail call position, call followed by ret) no variable argument lists or byval arguments option -tailcallopt is enabled Supported: * non pic tail calls on linux/darwin * module-local tail calls on linux(PIC/GOT)/darwin(PIC) * inter-module tail calls on darwin(PIC) If constraints are not met a normal call will be emitted. A test checking the argument lowering behaviour on x86-64 was added. Added: llvm/trunk/test/CodeGen/PowerPC/tailcall1-64.ll llvm/trunk/test/CodeGen/PowerPC/tailcall1.ll llvm/trunk/test/CodeGen/PowerPC/tailcallpic1.ll Modified: llvm/trunk/include/llvm/Target/TargetLowering.h llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp llvm/trunk/lib/Target/PowerPC/PPCCodeEmitter.cpp llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h llvm/trunk/lib/Target/PowerPC/PPCInstr64Bit.td llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.td llvm/trunk/lib/Target/PowerPC/PPCMachineFunctionInfo.h llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.td llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.h llvm/trunk/lib/Target/X86/X86InstrInfo.td Modified: llvm/trunk/include/llvm/Target/TargetLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=50477&r1=50476&r2=50477&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLowering.h (original) +++ llvm/trunk/include/llvm/Target/TargetLowering.h Wed Apr 30 04:16:33 2008 @@ -1033,6 +1033,36 @@ return false; } + /// CheckTailCallReturnConstraints - Check whether CALL node immediatly + /// preceeds the RET node and whether the return uses the result of the node + /// or is a void return. This function can be used by the target to determine + /// eligiblity of tail call optimization. + static bool CheckTailCallReturnConstraints(SDOperand Call, SDOperand Ret) { + unsigned NumOps = Ret.getNumOperands(); + if ((NumOps == 1 && + (Ret.getOperand(0) == SDOperand(Call.Val,1) || + Ret.getOperand(0) == SDOperand(Call.Val,0))) || + (NumOps > 1 && + Ret.getOperand(0) == SDOperand(Call.Val,Call.Val->getNumValues()-1) && + Ret.getOperand(1) == SDOperand(Call.Val,0))) + return true; + return false; + } + + /// GetPossiblePreceedingTailCall - Get preceeding TailCallNodeOpCode node if + /// it exists skip possible ISD:TokenFactor. + static SDOperand GetPossiblePreceedingTailCall(SDOperand Chain, + unsigned TailCallNodeOpCode) { + if (Chain.getOpcode() == TailCallNodeOpCode) { + return Chain; + } else if (Chain.getOpcode() == ISD::TokenFactor) { + if (Chain.getNumOperands() && + Chain.getOperand(0).getOpcode() == TailCallNodeOpCode) + return Chain.getOperand(0); + } + return Chain; + } + /// CustomPromoteOperation - This callback is invoked for operations that are /// unsupported by the target, are registered to use 'custom' lowering, and /// whose type needs to be promoted. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=50477&r1=50476&r2=50477&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Wed Apr 30 04:16:33 2008 @@ -4612,6 +4612,40 @@ } } +/// IsFixedFrameObjectWithPosOffset - Check if object is a fixed frame object and +/// whether object offset >= 0. +static bool +IsFixedFrameObjectWithPosOffset(MachineFrameInfo * MFI, SDOperand Op) { + if (!isa(Op)) return false; + + FrameIndexSDNode * FrameIdxNode = dyn_cast(Op); + int FrameIdx = FrameIdxNode->getIndex(); + return MFI->isFixedObjectIndex(FrameIdx) && + MFI->getObjectOffset(FrameIdx) >= 0; +} + +/// IsPossiblyOverwrittenArgumentOfTailCall - Check if the operand could +/// possibly be overwritten when lowering the outgoing arguments in a tail +/// call. Currently the implementation of this call is very conservative and +/// assumes all arguments sourcing from FORMAL_ARGUMENTS or a CopyFromReg with +/// virtual registers would be overwritten by direct lowering. +static bool IsPossiblyOverwrittenArgumentOfTailCall(SDOperand Op, + MachineFrameInfo * MFI) { + RegisterSDNode * OpReg = NULL; + if (Op.getOpcode() == ISD::FORMAL_ARGUMENTS || + (Op.getOpcode()== ISD::CopyFromReg && + (OpReg = dyn_cast(Op.getOperand(1))) && + (OpReg->getReg() >= TargetRegisterInfo::FirstVirtualRegister)) || + (Op.getOpcode() == ISD::LOAD && + IsFixedFrameObjectWithPosOffset(MFI, Op.getOperand(1))) || + (Op.getOpcode() == ISD::MERGE_VALUES && + Op.getOperand(Op.ResNo).getOpcode() == ISD::LOAD && + IsFixedFrameObjectWithPosOffset(MFI, Op.getOperand(Op.ResNo). + getOperand(1)))) + return true; + return false; +} + /// CheckDAGForTailCallsAndFixThem - This Function looks for CALL nodes in the /// DAG and fixes their tailcall attribute operand. static void CheckDAGForTailCallsAndFixThem(SelectionDAG &DAG, @@ -4636,19 +4670,51 @@ // eligible (no RET or the target rejects) the attribute is fixed to // false. The TargetLowering::IsEligibleForTailCallOptimization function // must correctly identify tail call optimizable calls. - if (isMarkedTailCall && - (Ret==NULL || - !TLI.IsEligibleForTailCallOptimization(OpCall, OpRet, DAG))) { + if (!isMarkedTailCall) continue; + if (Ret==NULL || + !TLI.IsEligibleForTailCallOptimization(OpCall, OpRet, DAG)) { + // Not eligible. Mark CALL node as non tail call. SmallVector Ops; unsigned idx=0; - for(SDNode::op_iterator I =OpCall.Val->op_begin(), - E=OpCall.Val->op_end(); I!=E; I++, idx++) { + for(SDNode::op_iterator I =OpCall.Val->op_begin(), + E = OpCall.Val->op_end(); I != E; I++, idx++) { if (idx!=3) Ops.push_back(*I); - else + else Ops.push_back(DAG.getConstant(false, TLI.getPointerTy())); } DAG.UpdateNodeOperands(OpCall, Ops.begin(), Ops.size()); + } else { + // Look for tail call clobbered arguments. Emit a series of + // copyto/copyfrom virtual register nodes to protect them. + SmallVector Ops; + SDOperand Chain = OpCall.getOperand(0), InFlag; + unsigned idx=0; + for(SDNode::op_iterator I = OpCall.Val->op_begin(), + E = OpCall.Val->op_end(); I != E; I++, idx++) { + SDOperand Arg = *I; + if (idx > 4 && (idx % 2)) { + bool isByVal = cast(OpCall.getOperand(idx+1))-> + getArgFlags().isByVal(); + MachineFunction &MF = DAG.getMachineFunction(); + MachineFrameInfo *MFI = MF.getFrameInfo(); + if (!isByVal && + IsPossiblyOverwrittenArgumentOfTailCall(Arg, MFI)) { + MVT::ValueType VT = Arg.getValueType(); + unsigned VReg = MF.getRegInfo(). + createVirtualRegister(TLI.getRegClassFor(VT)); + Chain = DAG.getCopyToReg(Chain, VReg, Arg, InFlag); + InFlag = Chain.getValue(1); + Arg = DAG.getCopyFromReg(Chain, VReg, VT, InFlag); + Chain = Arg.getValue(1); + InFlag = Arg.getValue(2); + } + } + Ops.push_back(Arg); + } + // Link in chain of CopyTo/CopyFromReg. + Ops[0] = Chain; + DAG.UpdateNodeOperands(OpCall, Ops.begin(), Ops.size()); } } } Modified: llvm/trunk/lib/Target/PowerPC/PPCCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCCodeEmitter.cpp?rev=50477&r1=50476&r2=50477&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCCodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCCodeEmitter.cpp Wed Apr 30 04:16:33 2008 @@ -143,7 +143,8 @@ MO.isConstantPoolIndex() || MO.isJumpTableIndex()) { unsigned Reloc = 0; if (MI.getOpcode() == PPC::BL_Macho || MI.getOpcode() == PPC::BL8_Macho || - MI.getOpcode() == PPC::BL_ELF || MI.getOpcode() == PPC::BL8_ELF) + MI.getOpcode() == PPC::BL_ELF || MI.getOpcode() == PPC::BL8_ELF || + MI.getOpcode() == PPC::TAILB || MI.getOpcode() == PPC::TAILB8) Reloc = PPC::reloc_pcrel_bx; else { if (TM.getRelocationModel() == Reloc::PIC_) { Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=50477&r1=50476&r2=50477&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Wed Apr 30 04:16:33 2008 @@ -26,9 +26,11 @@ #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/PseudoSourceValue.h" #include "llvm/CodeGen/SelectionDAG.h" +#include "llvm/CallingConv.h" #include "llvm/Constants.h" #include "llvm/Function.h" #include "llvm/Intrinsics.h" +#include "llvm/ParameterAttributes.h" #include "llvm/Support/MathExtras.h" #include "llvm/Target/TargetOptions.h" #include "llvm/Support/CommandLine.h" @@ -412,6 +414,8 @@ case PPCISD::MTFSB1: return "PPCISD::MTFSB1"; case PPCISD::FADDRTZ: return "PPCISD::FADDRTZ"; case PPCISD::MTFSF: return "PPCISD::MTFSF"; + case PPCISD::TAILCALL: return "PPCISD::TAILCALL"; + case PPCISD::TC_RETURN: return "PPCISD::TC_RETURN"; } } @@ -1317,6 +1321,20 @@ return FPR; } +/// CalculateStackSlotSize - Calculates the size reserved for this argument on +/// the stack. +static unsigned CalculateStackSlotSize(SDOperand Arg, SDOperand Flag, + bool isVarArg, unsigned PtrByteSize) { + MVT::ValueType ArgVT = Arg.getValueType(); + ISD::ArgFlagsTy Flags = cast(Flag)->getArgFlags(); + unsigned ArgSize =MVT::getSizeInBits(ArgVT)/8; + if (Flags.isByVal()) + ArgSize = Flags.getByValSize(); + ArgSize = ((ArgSize + PtrByteSize - 1)/PtrByteSize) * PtrByteSize; + + return ArgSize; +} + SDOperand PPCTargetLowering::LowerFORMAL_ARGUMENTS(SDOperand Op, SelectionDAG &DAG, @@ -1338,10 +1356,15 @@ bool isPPC64 = PtrVT == MVT::i64; bool isMachoABI = Subtarget.isMachoABI(); bool isELF32_ABI = Subtarget.isELF32_ABI(); + // Potential tail calls could cause overwriting of argument stack slots. + unsigned CC = MF.getFunction()->getCallingConv(); + bool isImmutable = !(PerformTailCallOpt && (CC==CallingConv::Fast)); unsigned PtrByteSize = isPPC64 ? 8 : 4; unsigned ArgOffset = PPCFrameInfo::getLinkageSize(isPPC64, isMachoABI); - + // Area that is at least reserved in caller of this function. + unsigned MinReservedArea = ArgOffset; + static const unsigned GPR_32[] = { // 32-bit registers. PPC::R3, PPC::R4, PPC::R5, PPC::R6, PPC::R7, PPC::R8, PPC::R9, PPC::R10, @@ -1426,7 +1449,7 @@ // even GPR_idx value or to an even ArgOffset value. SmallVector MemOps; - + unsigned nAltivecParamsAtEnd = 0; for (unsigned ArgNo = 0, e = Op.Val->getNumValues()-1; ArgNo != e; ++ArgNo) { SDOperand ArgVal; bool needsLoad = false; @@ -1440,6 +1463,23 @@ unsigned CurArgOffset = ArgOffset; + // Varargs or 64 bit Altivec parameters are padded to a 16 byte boundary. + if (ObjectVT==MVT::v4f32 || ObjectVT==MVT::v4i32 || + ObjectVT==MVT::v8i16 || ObjectVT==MVT::v16i8) { + if (isVarArg || isPPC64) { + MinReservedArea = ((MinReservedArea+15)/16)*16; + MinReservedArea += CalculateStackSlotSize(Op.getValue(ArgNo), + Op.getOperand(ArgNo+3), + isVarArg, + PtrByteSize); + } else nAltivecParamsAtEnd++; + } else + // Calculate min reserved area. + MinReservedArea += CalculateStackSlotSize(Op.getValue(ArgNo), + Op.getOperand(ArgNo+3), + isVarArg, + PtrByteSize); + // FIXME alignment for ELF may not be right // FIXME the codegen can be much improved in some cases. // We do not have to keep everything in memory. @@ -1614,7 +1654,8 @@ // that we ran out of physical registers of the appropriate type. if (needsLoad) { int FI = MFI->CreateFixedObject(ObjSize, - CurArgOffset + (ArgSize - ObjSize)); + CurArgOffset + (ArgSize - ObjSize), + isImmutable); SDOperand FIN = DAG.getFrameIndex(FI, PtrVT); ArgVal = DAG.getLoad(ObjectVT, Root, FIN, NULL, 0); } @@ -1622,6 +1663,25 @@ ArgValues.push_back(ArgVal); } + // Set the size that is at least reserved in caller of this function. Tail + // call optimized function's reserved stack space needs to be aligned so that + // taking the difference between two stack areas will result in an aligned + // stack. + PPCFunctionInfo *FI = MF.getInfo(); + // Add the Altivec parameters at the end, if needed. + if (nAltivecParamsAtEnd) { + MinReservedArea = ((MinReservedArea+15)/16)*16; + MinReservedArea += 16*nAltivecParamsAtEnd; + } + MinReservedArea = + std::max(MinReservedArea, + PPCFrameInfo::getMinCallFrameSize(isPPC64, isMachoABI)); + unsigned TargetAlign = DAG.getMachineFunction().getTarget().getFrameInfo()-> + getStackAlignment(); + unsigned AlignMask = TargetAlign-1; + MinReservedArea = (MinReservedArea + AlignMask) & ~AlignMask; + FI->setMinReservedArea(MinReservedArea); + // If the function takes variable number of arguments, make a frame index for // the start of the first vararg value... for expansion of llvm.va_start. if (isVarArg) { @@ -1720,6 +1780,131 @@ return DAG.getNode(ISD::MERGE_VALUES, RetVT, &ArgValues[0], ArgValues.size()); } +/// CalculateParameterAndLinkageAreaSize - Get the size of the paramter plus +/// linkage area. +static unsigned +CalculateParameterAndLinkageAreaSize(SelectionDAG &DAG, + bool isPPC64, + bool isMachoABI, + bool isVarArg, + unsigned CC, + SDOperand Call, + unsigned &nAltivecParamsAtEnd) { + // Count how many bytes are to be pushed on the stack, including the linkage + // area, and parameter passing area. We start with 24/48 bytes, which is + // prereserved space for [SP][CR][LR][3 x unused]. + unsigned NumBytes = PPCFrameInfo::getLinkageSize(isPPC64, isMachoABI); + unsigned NumOps = (Call.getNumOperands() - 5) / 2; + unsigned PtrByteSize = isPPC64 ? 8 : 4; + + // Add up all the space actually used. + // In 32-bit non-varargs calls, Altivec parameters all go at the end; usually + // they all go in registers, but we must reserve stack space for them for + // possible use by the caller. In varargs or 64-bit calls, parameters are + // assigned stack space in order, with padding so Altivec parameters are + // 16-byte aligned. + nAltivecParamsAtEnd = 0; + for (unsigned i = 0; i != NumOps; ++i) { + SDOperand Arg = Call.getOperand(5+2*i); + SDOperand Flag = Call.getOperand(5+2*i+1); + MVT::ValueType ArgVT = Arg.getValueType(); + // Varargs Altivec parameters are padded to a 16 byte boundary. + if (ArgVT==MVT::v4f32 || ArgVT==MVT::v4i32 || + ArgVT==MVT::v8i16 || ArgVT==MVT::v16i8) { + if (!isVarArg && !isPPC64) { + // Non-varargs Altivec parameters go after all the non-Altivec + // parameters; handle those later so we know how much padding we need. + nAltivecParamsAtEnd++; + continue; + } + // Varargs and 64-bit Altivec parameters are padded to 16 byte boundary. + NumBytes = ((NumBytes+15)/16)*16; + } + NumBytes += CalculateStackSlotSize(Arg, Flag, isVarArg, PtrByteSize); + } + + // Allow for Altivec parameters at the end, if needed. + if (nAltivecParamsAtEnd) { + NumBytes = ((NumBytes+15)/16)*16; + NumBytes += 16*nAltivecParamsAtEnd; + } + + // The prolog code of the callee may store up to 8 GPR argument registers to + // the stack, allowing va_start to index over them in memory if its varargs. + // Because we cannot tell if this is needed on the caller side, we have to + // conservatively assume that it is needed. As such, make sure we have at + // least enough stack space for the caller to store the 8 GPRs. + NumBytes = std::max(NumBytes, + PPCFrameInfo::getMinCallFrameSize(isPPC64, isMachoABI)); + + // Tail call needs the stack to be aligned. + if (CC==CallingConv::Fast && PerformTailCallOpt) { + unsigned TargetAlign = DAG.getMachineFunction().getTarget().getFrameInfo()-> + getStackAlignment(); + unsigned AlignMask = TargetAlign-1; + NumBytes = (NumBytes + AlignMask) & ~AlignMask; + } + + return NumBytes; +} + +/// CalculateTailCallSPDiff - Get the amount the stack pointer has to be +/// adjusted to accomodate the arguments for the tailcall. +static int CalculateTailCallSPDiff(SelectionDAG& DAG, bool IsTailCall, + unsigned ParamSize) { + + if (!IsTailCall) return 0; + + PPCFunctionInfo *FI = DAG.getMachineFunction().getInfo(); + unsigned CallerMinReservedArea = FI->getMinReservedArea(); + int SPDiff = (int)CallerMinReservedArea - (int)ParamSize; + // Remember only if the new adjustement is bigger. + if (SPDiff < FI->getTailCallSPDelta()) + FI->setTailCallSPDelta(SPDiff); + + return SPDiff; +} + +/// IsEligibleForTailCallElimination - Check to see whether the next instruction +/// following the call is a return. A function is eligible if caller/callee +/// calling conventions match, currently only fastcc supports tail calls, and +/// the function CALL is immediatly followed by a RET. +bool +PPCTargetLowering::IsEligibleForTailCallOptimization(SDOperand Call, + SDOperand Ret, + SelectionDAG& DAG) const { + // Variable argument functions are not supported. + if (!PerformTailCallOpt || + cast(Call.getOperand(2))->getValue() != 0) return false; + + if (CheckTailCallReturnConstraints(Call, Ret)) { + MachineFunction &MF = DAG.getMachineFunction(); + unsigned CallerCC = MF.getFunction()->getCallingConv(); + unsigned CalleeCC = cast(Call.getOperand(1))->getValue(); + if (CalleeCC == CallingConv::Fast && CallerCC == CalleeCC) { + // Functions containing by val parameters are not supported. + for (unsigned i = 0; i != ((Call.getNumOperands()-5)/2); i++) { + ISD::ArgFlagsTy Flags = cast(Call.getOperand(5+2*i+1)) + ->getArgFlags(); + if (Flags.isByVal()) return false; + } + + SDOperand Callee = Call.getOperand(4); + // Non PIC/GOT tail calls are supported. + if (getTargetMachine().getRelocationModel() != Reloc::PIC_) + return true; + + // At the moment we can only do local tail calls (in same module, hidden + // or protected) if we are generating PIC. + if (GlobalAddressSDNode *G = dyn_cast(Callee)) + return G->getGlobal()->hasHiddenVisibility() + || G->getGlobal()->hasProtectedVisibility(); + } + } + + return false; +} + /// isCallCompatibleAddress - Return the immediate to use if the specified /// 32-bit value is representable in the immediate field of a BxA instruction. static SDNode *isBLACompatibleAddress(SDOperand Op, SelectionDAG &DAG) { @@ -1735,6 +1920,102 @@ DAG.getTargetLoweringInfo().getPointerTy()).Val; } +struct TailCallArgumentInfo { + SDOperand Arg; + SDOperand FrameIdxOp; + int FrameIdx; + + TailCallArgumentInfo() : FrameIdx(0) {} +}; + +/// StoreTailCallArgumentsToStackSlot - Stores arguments to their stack slot. +static void +StoreTailCallArgumentsToStackSlot(SelectionDAG &DAG, + SDOperand Chain, + const SmallVector &TailCallArgs, + SmallVector &MemOpChains) { + for (unsigned i = 0, e = TailCallArgs.size(); i != e; ++i) { + SDOperand Arg = TailCallArgs[i].Arg; + SDOperand FIN = TailCallArgs[i].FrameIdxOp; + int FI = TailCallArgs[i].FrameIdx; + // Store relative to framepointer. + MemOpChains.push_back(DAG.getStore(Chain, Arg, FIN, + PseudoSourceValue::getFixedStack(), + FI)); + } +} + +/// EmitTailCallStoreFPAndRetAddr - Move the frame pointer and return address to +/// the appropriate stack slot for the tail call optimized function call. +static SDOperand EmitTailCallStoreFPAndRetAddr(SelectionDAG &DAG, + MachineFunction &MF, + SDOperand Chain, + SDOperand OldRetAddr, + SDOperand OldFP, + int SPDiff, + bool isPPC64, + bool isMachoABI) { + if (SPDiff) { + // Calculate the new stack slot for the return address. + int SlotSize = isPPC64 ? 8 : 4; + int NewRetAddrLoc = SPDiff + PPCFrameInfo::getReturnSaveOffset(isPPC64, + isMachoABI); + int NewRetAddr = MF.getFrameInfo()->CreateFixedObject(SlotSize, + NewRetAddrLoc); + int NewFPLoc = SPDiff + PPCFrameInfo::getFramePointerSaveOffset(isPPC64, + isMachoABI); + int NewFPIdx = MF.getFrameInfo()->CreateFixedObject(SlotSize, NewFPLoc); + + MVT::ValueType VT = isPPC64 ? MVT::i64 : MVT::i32; + SDOperand NewRetAddrFrIdx = DAG.getFrameIndex(NewRetAddr, VT); + Chain = DAG.getStore(Chain, OldRetAddr, NewRetAddrFrIdx, + PseudoSourceValue::getFixedStack(), NewRetAddr); + SDOperand NewFramePtrIdx = DAG.getFrameIndex(NewFPIdx, VT); + Chain = DAG.getStore(Chain, OldFP, NewFramePtrIdx, + PseudoSourceValue::getFixedStack(), NewFPIdx); + } + return Chain; +} + +/// CalculateTailCallArgDest - Remember Argument for later processing. Calculate +/// the position of the argument. +static void +CalculateTailCallArgDest(SelectionDAG &DAG, MachineFunction &MF, bool isPPC64, + SDOperand Arg, int SPDiff, unsigned ArgOffset, + SmallVector& TailCallArguments) { + int Offset = ArgOffset + SPDiff; + uint32_t OpSize = (MVT::getSizeInBits(Arg.getValueType())+7)/8; + int FI = MF.getFrameInfo()->CreateFixedObject(OpSize, Offset); + MVT::ValueType VT = isPPC64 ? MVT::i64 : MVT::i32; + SDOperand FIN = DAG.getFrameIndex(FI, VT); + TailCallArgumentInfo Info; + Info.Arg = Arg; + Info.FrameIdxOp = FIN; + Info.FrameIdx = FI; + TailCallArguments.push_back(Info); +} + +/// EmitTCFPAndRetAddrLoad - Emit load from frame pointer and return address +/// stack slot. Returns the chain as result and the loaded frame pointers in +/// LROpOut/FPOpout. Used when tail calling. +SDOperand PPCTargetLowering::EmitTailCallLoadFPAndRetAddr(SelectionDAG & DAG, + int SPDiff, + SDOperand Chain, + SDOperand &LROpOut, + SDOperand &FPOpOut) { + if (SPDiff) { + // Load the LR and FP stack slot for later adjusting. + MVT::ValueType VT = PPCSubTarget.isPPC64() ? MVT::i64 : MVT::i32; + LROpOut = getReturnAddrFrameIndex(DAG); + LROpOut = DAG.getLoad(VT, Chain, LROpOut, NULL, 0); + Chain = SDOperand(LROpOut.Val, 1); + FPOpOut = getFramePointerFrameIndex(DAG); + FPOpOut = DAG.getLoad(VT, Chain, FPOpOut, NULL, 0); + Chain = SDOperand(FPOpOut.Val, 1); + } + return Chain; +} + /// CreateCopyOfByValArgument - Make a copy of an aggregate at address specified /// by "Src" to address "Dst" of size "Size". Alignment information is /// specified by the specific parameter attribute. The copy will be passed as @@ -1750,11 +2031,39 @@ NULL, 0, NULL, 0); } +/// LowerMemOpCallTo - Store the argument to the stack or remember it in case of +/// tail calls. +static void +LowerMemOpCallTo(SelectionDAG &DAG, MachineFunction &MF, SDOperand Chain, + SDOperand Arg, SDOperand PtrOff, int SPDiff, + unsigned ArgOffset, bool isPPC64, bool isTailCall, + bool isVector, SmallVector &MemOpChains, + SmallVector& TailCallArguments) { + MVT::ValueType PtrVT = DAG.getTargetLoweringInfo().getPointerTy(); + if (!isTailCall) { + if (isVector) { + SDOperand StackPtr; + if (isPPC64) + StackPtr = DAG.getRegister(PPC::X1, MVT::i64); + else + StackPtr = DAG.getRegister(PPC::R1, MVT::i32); + PtrOff = DAG.getNode(ISD::ADD, PtrVT, StackPtr, + DAG.getConstant(ArgOffset, PtrVT)); + } + MemOpChains.push_back(DAG.getStore(Chain, Arg, PtrOff, NULL, 0)); + // Calculate and remember argument location. + } else CalculateTailCallArgDest(DAG, MF, isPPC64, Arg, SPDiff, ArgOffset, + TailCallArguments); +} + SDOperand PPCTargetLowering::LowerCALL(SDOperand Op, SelectionDAG &DAG, const PPCSubtarget &Subtarget, TargetMachine &TM) { SDOperand Chain = Op.getOperand(0); bool isVarArg = cast(Op.getOperand(2))->getValue() != 0; + unsigned CC = cast(Op.getOperand(1))->getValue(); + bool isTailCall = cast(Op.getOperand(3))->getValue() != 0 && + CC == CallingConv::Fast && PerformTailCallOpt; SDOperand Callee = Op.getOperand(4); unsigned NumOps = (Op.getNumOperands() - 5) / 2; @@ -1765,58 +2074,32 @@ bool isPPC64 = PtrVT == MVT::i64; unsigned PtrByteSize = isPPC64 ? 8 : 4; + MachineFunction &MF = DAG.getMachineFunction(); + // args_to_use will accumulate outgoing args for the PPCISD::CALL case in // SelectExpr to use to put the arguments in the appropriate registers. std::vector args_to_use; - // Count how many bytes are to be pushed on the stack, including the linkage - // area, and parameter passing area. We start with 24/48 bytes, which is - // prereserved space for [SP][CR][LR][3 x unused]. - unsigned NumBytes = PPCFrameInfo::getLinkageSize(isPPC64, isMachoABI); + // Mark this function as potentially containing a function that contains a + // tail call. As a consequence the frame pointer will be used for dynamicalloc + // and restoring the callers stack pointer in this functions epilog. This is + // done because by tail calling the called function might overwrite the value + // in this function's (MF) stack pointer stack slot 0(SP). + if (PerformTailCallOpt && CC==CallingConv::Fast) + MF.getInfo()->setHasFastCall(); - // Add up all the space actually used. - // In 32-bit non-varargs calls, Altivec parameters all go at the end; usually - // they all go in registers, but we must reserve stack space for them for - // possible use by the caller. In varargs or 64-bit calls, parameters are - // assigned stack space in order, with padding so Altivec parameters are - // 16-byte aligned. unsigned nAltivecParamsAtEnd = 0; - for (unsigned i = 0; i != NumOps; ++i) { - SDOperand Arg = Op.getOperand(5+2*i); - MVT::ValueType ArgVT = Arg.getValueType(); - if (ArgVT==MVT::v4f32 || ArgVT==MVT::v4i32 || - ArgVT==MVT::v8i16 || ArgVT==MVT::v16i8) { - if (!isVarArg && !isPPC64) { - // Non-varargs Altivec parameters go after all the non-Altivec parameters; - // do those last so we know how much padding we need. - nAltivecParamsAtEnd++; - continue; - } else { - // Varargs and 64-bit Altivec parameters are padded to 16 byte boundary. - NumBytes = ((NumBytes+15)/16)*16; - } - } - ISD::ArgFlagsTy Flags = - cast(Op.getOperand(5+2*i+1))->getArgFlags(); - unsigned ArgSize =MVT::getSizeInBits(Op.getOperand(5+2*i).getValueType())/8; - if (Flags.isByVal()) - ArgSize = Flags.getByValSize(); - ArgSize = ((ArgSize + PtrByteSize - 1)/PtrByteSize) * PtrByteSize; - NumBytes += ArgSize; - } - // Allow for Altivec parameters at the end, if needed. - if (nAltivecParamsAtEnd) { - NumBytes = ((NumBytes+15)/16)*16; - NumBytes += 16*nAltivecParamsAtEnd; - } - // The prolog code of the callee may store up to 8 GPR argument registers to - // the stack, allowing va_start to index over them in memory if its varargs. - // Because we cannot tell if this is needed on the caller side, we have to - // conservatively assume that it is needed. As such, make sure we have at - // least enough stack space for the caller to store the 8 GPRs. - NumBytes = std::max(NumBytes, - PPCFrameInfo::getMinCallFrameSize(isPPC64, isMachoABI)); + // Count how many bytes are to be pushed on the stack, including the linkage + // area, and parameter passing area. We start with 24/48 bytes, which is + // prereserved space for [SP][CR][LR][3 x unused]. + unsigned NumBytes = + CalculateParameterAndLinkageAreaSize(DAG, isPPC64, isMachoABI, isVarArg, CC, + Op, nAltivecParamsAtEnd); + + // Calculate by how many bytes the stack has to be adjusted in case of tail + // call optimization. + int SPDiff = CalculateTailCallSPDiff(DAG, isTailCall, NumBytes); // Adjust the stack pointer for the new arguments... // These operations are automatically eliminated by the prolog/epilog pass @@ -1824,6 +2107,11 @@ DAG.getConstant(NumBytes, PtrVT)); SDOperand CallSeqStart = Chain; + // Load the return address and frame pointer so it can be move somewhere else + // later. + SDOperand LROp, FPOp; + Chain = EmitTailCallLoadFPAndRetAddr(DAG, SPDiff, Chain, LROp, FPOp); + // Set up a copy of the stack pointer for use loading and storing any // arguments that may not fit in the registers available for argument // passing. @@ -1861,6 +2149,8 @@ const unsigned *GPR = isPPC64 ? GPR_64 : GPR_32; std::vector > RegsToPass; + SmallVector TailCallArguments; + SmallVector MemOpChains; for (unsigned i = 0; i != NumOps; ++i) { bool inMem = false; @@ -1959,7 +2249,9 @@ if (GPR_idx != NumGPRs) { RegsToPass.push_back(std::make_pair(GPR[GPR_idx++], Arg)); } else { - MemOpChains.push_back(DAG.getStore(Chain, Arg, PtrOff, NULL, 0)); + LowerMemOpCallTo(DAG, MF, Chain, Arg, PtrOff, SPDiff, ArgOffset, + isPPC64, isTailCall, false, MemOpChains, + TailCallArguments); inMem = true; } if (inMem || isMachoABI) { @@ -2007,7 +2299,9 @@ } } } else { - MemOpChains.push_back(DAG.getStore(Chain, Arg, PtrOff, NULL, 0)); + LowerMemOpCallTo(DAG, MF, Chain, Arg, PtrOff, SPDiff, ArgOffset, + isPPC64, isTailCall, false, MemOpChains, + TailCallArguments); inMem = true; } if (inMem || isMachoABI) { @@ -2058,6 +2352,7 @@ } break; } + // Non-varargs Altivec params generally go in registers, but have // stack space allocated at the end. if (VR_idx != NumVRs) { @@ -2065,10 +2360,9 @@ RegsToPass.push_back(std::make_pair(VR[VR_idx++], Arg)); } else if (nAltivecParamsAtEnd==0) { // We are emitting Altivec params in order. - PtrOff = DAG.getNode(ISD::ADD, PtrVT, StackPtr, - DAG.getConstant(ArgOffset, PtrVT)); - SDOperand Store = DAG.getStore(Chain, Arg, PtrOff, NULL, 0); - MemOpChains.push_back(Store); + LowerMemOpCallTo(DAG, MF, Chain, Arg, PtrOff, SPDiff, ArgOffset, + isPPC64, isTailCall, true, MemOpChains, + TailCallArguments); ArgOffset += 16; } break; @@ -2090,10 +2384,11 @@ if (ArgType==MVT::v4f32 || ArgType==MVT::v4i32 || ArgType==MVT::v8i16 || ArgType==MVT::v16i8) { if (++j > NumVRs) { - SDOperand PtrOff = DAG.getNode(ISD::ADD, PtrVT, StackPtr, - DAG.getConstant(ArgOffset, PtrVT)); - SDOperand Store = DAG.getStore(Chain, Arg, PtrOff, NULL, 0); - MemOpChains.push_back(Store); + SDOperand PtrOff; + // We are emitting Altivec params in order. + LowerMemOpCallTo(DAG, MF, Chain, Arg, PtrOff, SPDiff, ArgOffset, + isPPC64, isTailCall, true, MemOpChains, + TailCallArguments); ArgOffset += 16; } } @@ -2120,6 +2415,37 @@ InFlag = Chain.getValue(1); } + // Emit a sequence of copyto/copyfrom virtual registers for arguments that + // might overwrite each other in case of tail call optimization. + if (isTailCall) { + SmallVector MemOpChains2; + // Do not flag preceeding copytoreg stuff together with the following stuff. + InFlag = SDOperand(); + StoreTailCallArgumentsToStackSlot(DAG, Chain, TailCallArguments, + MemOpChains2); + if (!MemOpChains2.empty()) + Chain = DAG.getNode(ISD::TokenFactor, MVT::Other, + &MemOpChains2[0], MemOpChains2.size()); + + // Store the return address to the appropriate stack slot. + Chain = EmitTailCallStoreFPAndRetAddr(DAG, MF, Chain, LROp, FPOp, SPDiff, + isPPC64, isMachoABI); + } + + // Emit callseq_end just before tailcall node. + if (isTailCall) { + SmallVector CallSeqOps; + SDVTList CallSeqNodeTys = DAG.getVTList(MVT::Other, MVT::Flag); + CallSeqOps.push_back(Chain); + CallSeqOps.push_back(DAG.getIntPtrConstant(NumBytes)); + CallSeqOps.push_back(DAG.getIntPtrConstant(0)); + if (InFlag.Val) + CallSeqOps.push_back(InFlag); + Chain = DAG.getNode(ISD::CALLSEQ_END, CallSeqNodeTys, &CallSeqOps[0], + CallSeqOps.size()); + InFlag = Chain.getValue(1); + } + std::vector NodeTys; NodeTys.push_back(MVT::Other); // Returns a chain NodeTys.push_back(MVT::Flag); // Returns a flag for retval copy to use. @@ -2157,6 +2483,9 @@ Ops.push_back(Chain); CallOpc = isMachoABI ? PPCISD::BCTRL_Macho : PPCISD::BCTRL_ELF; Callee.Val = 0; + // Add CTR register as callee so a bctr can be emitted later. + if (isTailCall) + Ops.push_back(DAG.getRegister(PPC::CTR, getPointerTy())); } // If this is a direct call, pass the chain and the callee. @@ -2164,29 +2493,48 @@ Ops.push_back(Chain); Ops.push_back(Callee); } - + // If this is a tail call add stack pointer delta. + if (isTailCall) + Ops.push_back(DAG.getConstant(SPDiff, MVT::i32)); + // Add argument registers to the end of the list so that they are known live // into the call. for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i) Ops.push_back(DAG.getRegister(RegsToPass[i].first, RegsToPass[i].second.getValueType())); - + + // When performing tail call optimization the callee pops its arguments off + // the stack. Account for this here so these bytes can be pushed back on in + // PPCRegisterInfo::eliminateCallFramePseudoInstr. + int BytesCalleePops = + (CC==CallingConv::Fast && PerformTailCallOpt) ? NumBytes : 0; + if (InFlag.Val) Ops.push_back(InFlag); + + // Emit tail call. + if (isTailCall) { + assert(InFlag.Val && + "Flag must be set. Depend on flag being set in LowerRET"); + Chain = DAG.getNode(PPCISD::TAILCALL, + Op.Val->getVTList(), &Ops[0], Ops.size()); + return SDOperand(Chain.Val, Op.ResNo); + } + Chain = DAG.getNode(CallOpc, NodeTys, &Ops[0], Ops.size()); InFlag = Chain.getValue(1); Chain = DAG.getCALLSEQ_END(Chain, DAG.getConstant(NumBytes, PtrVT), - DAG.getConstant(0, PtrVT), + DAG.getConstant(BytesCalleePops, PtrVT), InFlag); if (Op.Val->getValueType(0) != MVT::Other) InFlag = Chain.getValue(1); SmallVector ResultVals; SmallVector RVLocs; - unsigned CC = DAG.getMachineFunction().getFunction()->getCallingConv(); - CCState CCInfo(CC, isVarArg, TM, RVLocs); + unsigned CallerCC = DAG.getMachineFunction().getFunction()->getCallingConv(); + CCState CCInfo(CallerCC, isVarArg, TM, RVLocs); CCInfo.AnalyzeCallResult(Op.Val, RetCC_PPC); // Copy all of the result registers out of their specified physreg. @@ -2226,6 +2574,36 @@ } SDOperand Chain = Op.getOperand(0); + + Chain = GetPossiblePreceedingTailCall(Chain, PPCISD::TAILCALL); + if (Chain.getOpcode() == PPCISD::TAILCALL) { + SDOperand TailCall = Chain; + SDOperand TargetAddress = TailCall.getOperand(1); + SDOperand StackAdjustment = TailCall.getOperand(2); + + assert(((TargetAddress.getOpcode() == ISD::Register && + cast(TargetAddress)->getReg() == PPC::CTR) || + TargetAddress.getOpcode() == ISD::TargetExternalSymbol || + TargetAddress.getOpcode() == ISD::TargetGlobalAddress || + isa(TargetAddress)) && + "Expecting an global address, external symbol, absolute value or register"); + + assert(StackAdjustment.getOpcode() == ISD::Constant && + "Expecting a const value"); + + SmallVector Operands; + Operands.push_back(Chain.getOperand(0)); + Operands.push_back(TargetAddress); + Operands.push_back(StackAdjustment); + // Copy registers used by the call. Last operand is a flag so it is not + // copied. + for (unsigned i=3; i < TailCall.getNumOperands()-1; i++) { + Operands.push_back(Chain.getOperand(i)); + } + return DAG.getNode(PPCISD::TC_RETURN, MVT::Other, &Operands[0], + Operands.size()); + } + SDOperand Flag; // Copy the result values into the output registers. @@ -2268,18 +2646,44 @@ return DAG.getStore(Chain, LoadLinkSP, StackPtr, NULL, 0); } -SDOperand PPCTargetLowering::LowerDYNAMIC_STACKALLOC(SDOperand Op, - SelectionDAG &DAG, - const PPCSubtarget &Subtarget) { + + +SDOperand +PPCTargetLowering::getReturnAddrFrameIndex(SelectionDAG & DAG) const { MachineFunction &MF = DAG.getMachineFunction(); - bool IsPPC64 = Subtarget.isPPC64(); - bool isMachoABI = Subtarget.isMachoABI(); + bool IsPPC64 = PPCSubTarget.isPPC64(); + bool isMachoABI = PPCSubTarget.isMachoABI(); + MVT::ValueType PtrVT = DAG.getTargetLoweringInfo().getPointerTy(); + + // Get current frame pointer save index. The users of this index will be + // primarily DYNALLOC instructions. + PPCFunctionInfo *FI = MF.getInfo(); + int RASI = FI->getReturnAddrSaveIndex(); + + // If the frame pointer save index hasn't been defined yet. + if (!RASI) { + // Find out what the fix offset of the frame pointer save area. + int LROffset = PPCFrameInfo::getReturnSaveOffset(IsPPC64, isMachoABI); + // Allocate the frame index for frame pointer save area. + RASI = MF.getFrameInfo()->CreateFixedObject(IsPPC64? 8 : 4, LROffset); + // Save the result. + FI->setReturnAddrSaveIndex(RASI); + } + return DAG.getFrameIndex(RASI, PtrVT); +} + +SDOperand +PPCTargetLowering::getFramePointerFrameIndex(SelectionDAG & DAG) const { + MachineFunction &MF = DAG.getMachineFunction(); + bool IsPPC64 = PPCSubTarget.isPPC64(); + bool isMachoABI = PPCSubTarget.isMachoABI(); + MVT::ValueType PtrVT = DAG.getTargetLoweringInfo().getPointerTy(); // Get current frame pointer save index. The users of this index will be // primarily DYNALLOC instructions. PPCFunctionInfo *FI = MF.getInfo(); int FPSI = FI->getFramePointerSaveIndex(); - + // If the frame pointer save index hasn't been defined yet. if (!FPSI) { // Find out what the fix offset of the frame pointer save area. @@ -2290,7 +2694,12 @@ // Save the result. FI->setFramePointerSaveIndex(FPSI); } + return DAG.getFrameIndex(FPSI, PtrVT); +} +SDOperand PPCTargetLowering::LowerDYNAMIC_STACKALLOC(SDOperand Op, + SelectionDAG &DAG, + const PPCSubtarget &Subtarget) { // Get the inputs. SDOperand Chain = Op.getOperand(0); SDOperand Size = Op.getOperand(1); @@ -2301,7 +2710,7 @@ SDOperand NegSize = DAG.getNode(ISD::SUB, PtrVT, DAG.getConstant(0, PtrVT), Size); // Construct a node for the frame pointer save index. - SDOperand FPSIdx = DAG.getFrameIndex(FPSI, PtrVT); + SDOperand FPSIdx = getFramePointerFrameIndex(DAG); // Build a DYNALLOC node. SDOperand Ops[3] = { Chain, NegSize, FPSIdx }; SDVTList VTs = DAG.getVTList(PtrVT, MVT::Other); @@ -4099,25 +4508,13 @@ MachineFunction &MF = DAG.getMachineFunction(); PPCFunctionInfo *FuncInfo = MF.getInfo(); - int RAIdx = FuncInfo->getReturnAddrSaveIndex(); - if (RAIdx == 0) { - bool isPPC64 = PPCSubTarget.isPPC64(); - int Offset = - PPCFrameInfo::getReturnSaveOffset(isPPC64, PPCSubTarget.isMachoABI()); - - // Set up a frame object for the return address. - RAIdx = MF.getFrameInfo()->CreateFixedObject(isPPC64 ? 8 : 4, Offset); - - // Remember it for next time. - FuncInfo->setReturnAddrSaveIndex(RAIdx); - - // Make sure the function really does not optimize away the store of the RA - // to the stack. - FuncInfo->setLRStoreRequired(); - } - + // Just load the return address off the stack. - SDOperand RetAddrFI = DAG.getFrameIndex(RAIdx, getPointerTy()); + SDOperand RetAddrFI = getReturnAddrFrameIndex(DAG); + + // Make sure the function really does not optimize away the store of the RA + // to the stack. + FuncInfo->setLRStoreRequired(); return DAG.getLoad(getPointerTy(), DAG.getEntryNode(), RetAddrFI, NULL, 0); } Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h?rev=50477&r1=50476&r2=50477&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h (original) +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h Wed Apr 30 04:16:33 2008 @@ -162,7 +162,16 @@ /// CMP_UNRESERVE = Test for equality and "unreserve" if not true. This /// is used to implement atomic operations. - CMP_UNRESERVE + CMP_UNRESERVE, + + /// TAILCALL - Indicates a tail call should be taken. + TAILCALL, + /// TC_RETURN - A tail call return. + /// operand #0 chain + /// operand #1 callee (register or absolute) + /// operand #2 stack adjustment + /// operand #3 optional in flag + TC_RETURN }; } @@ -308,11 +317,27 @@ /// the offset of the target addressing mode. virtual bool isLegalAddressImmediate(GlobalValue *GV) const; + /// IsEligibleForTailCallOptimization - Check whether the call is eligible + /// for tail call optimization. Target which want to do tail call + /// optimization should implement this function. + virtual bool IsEligibleForTailCallOptimization(SDOperand Call, + SDOperand Ret, + SelectionDAG &DAG) const; + private: /// PPCAtomicLabelIndex - Keep track the number of PPC atomic labels. /// unsigned PPCAtomicLabelIndex; + SDOperand getFramePointerFrameIndex(SelectionDAG & DAG) const; + SDOperand getReturnAddrFrameIndex(SelectionDAG & DAG) const; + + SDOperand EmitTailCallLoadFPAndRetAddr(SelectionDAG & DAG, + int SPDiff, + SDOperand Chain, + SDOperand &LROpOut, + SDOperand &FPOpOut); + SDOperand LowerRETURNADDR(SDOperand Op, SelectionDAG &DAG); SDOperand LowerFRAMEADDR(SDOperand Op, SelectionDAG &DAG); SDOperand LowerConstantPool(SDOperand Op, SelectionDAG &DAG); Modified: llvm/trunk/lib/Target/PowerPC/PPCInstr64Bit.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCInstr64Bit.td?rev=50477&r1=50476&r2=50477&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCInstr64Bit.td (original) +++ llvm/trunk/lib/Target/PowerPC/PPCInstr64Bit.td Wed Apr 30 04:16:33 2008 @@ -116,7 +116,6 @@ def : Pat<(PPCcall_ELF (i64 texternalsym:$dst)), (BL8_ELF texternalsym:$dst)>; - // Atomic operations. def LDARX : Pseudo<(outs G8RC:$rD), (ins memrr:$ptr, i32imm:$label), "\nLa${label}_entry:\n\tldarx $rD, $ptr", @@ -135,6 +134,53 @@ [(PPCcmp_unres G8RC:$rA, immSExt16:$imm, imm:$label)]>; } +let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in +def TCRETURNdi8 :Pseudo< (outs), + (ins calltarget:$dst, i32imm:$offset, variable_ops), + "#TC_RETURNd8 $dst $offset", + []>; + +let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in +def TCRETURNai8 :Pseudo<(outs), (ins aaddr:$func, i32imm:$offset, variable_ops), + "#TC_RETURNa8 $func $offset", + [(PPCtc_return (i64 imm:$func), imm:$offset)]>; + +let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in +def TCRETURNri8 : Pseudo<(outs), (ins CTRRC8:$dst, i32imm:$offset, variable_ops), + "#TC_RETURNr8 $dst $offset", + []>; + + +let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, isBranch = 1, + isIndirectBranch = 1, isCall = 1, isReturn = 1 in +def TAILBCTR8 : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", BrB, []>, + Requires<[In64BitMode]>; + + + +let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7, + isBarrier = 1, isCall = 1, isReturn = 1 in +def TAILB8 : IForm<18, 0, 0, (outs), (ins calltarget:$dst), + "b $dst", BrB, + []>; + + +let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7, + isBarrier = 1, isCall = 1, isReturn = 1 in +def TAILBA8 : IForm<18, 0, 0, (outs), (ins aaddr:$dst), + "ba $dst", BrB, + []>; + +def : Pat<(PPCtc_return (i64 tglobaladdr:$dst), imm:$imm), + (TCRETURNdi8 tglobaladdr:$dst, imm:$imm)>; + +def : Pat<(PPCtc_return (i64 texternalsym:$dst), imm:$imm), + (TCRETURNdi8 texternalsym:$dst, imm:$imm)>; + +def : Pat<(PPCtc_return CTRRC8:$dst, imm:$imm), + (TCRETURNri8 CTRRC8:$dst, imm:$imm)>; + + //===----------------------------------------------------------------------===// // 64-bit SPR manipulation instrs. Modified: llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.td?rev=50477&r1=50476&r2=50477&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.td (original) +++ llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.td Wed Apr 30 04:16:33 2008 @@ -42,6 +42,7 @@ SDTCisVT<0, i32>, SDTCisPtrTy<1>, SDTCisVT<2, OtherVT>, SDTCisVT<3, OtherVT> ]>; + def SDT_PPClarx : SDTypeProfile<1, 2, [ SDTCisInt<0>, SDTCisPtrTy<1>, SDTCisVT<2, i32> ]>; @@ -52,6 +53,10 @@ SDTCisSameAs<0, 1>, SDTCisInt<1>, SDTCisVT<2, i32> ]>; +def SDT_PPCTC_ret : SDTypeProfile<0, 2, [ + SDTCisPtrTy<0>, SDTCisVT<1, i32> +]>; + //===----------------------------------------------------------------------===// // PowerPC specific DAG Nodes. // @@ -121,6 +126,12 @@ def retflag : SDNode<"PPCISD::RET_FLAG", SDTNone, [SDNPHasChain, SDNPOptInFlag]>; +def PPCtc_return : SDNode<"PPCISD::TC_RETURN", SDT_PPCTC_ret, + [SDNPHasChain, SDNPOptInFlag]>; + +def PPCtailcall : SDNode<"PPCISD::TAILCALL", SDT_PPCCall, + [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>; + def PPCvcmp : SDNode<"PPCISD::VCMP" , SDT_PPCvcmp, []>; def PPCvcmp_o : SDNode<"PPCISD::VCMPo", SDT_PPCvcmp, [SDNPOutFlag]>; @@ -453,6 +464,46 @@ [(PPCbctrl_ELF)]>, Requires<[In32BitMode]>; } + +let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in +def TCRETURNdi :Pseudo< (outs), + (ins calltarget:$dst, i32imm:$offset, variable_ops), + "#TC_RETURNd $dst $offset", + []>; + + +let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in +def TCRETURNai :Pseudo<(outs), (ins aaddr:$func, i32imm:$offset, variable_ops), + "#TC_RETURNa $func $offset", + [(PPCtc_return (i32 imm:$func), imm:$offset)]>; + +let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in +def TCRETURNri : Pseudo<(outs), (ins CTRRC:$dst, i32imm:$offset, variable_ops), + "#TC_RETURNr $dst $offset", + []>; + + +let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, isBranch = 1, + isIndirectBranch = 1, isCall = 1, isReturn = 1 in +def TAILBCTR : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", BrB, []>, + Requires<[In32BitMode]>; + + + +let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7, + isBarrier = 1, isCall = 1, isReturn = 1 in +def TAILB : IForm<18, 0, 0, (outs), (ins calltarget:$dst), + "b $dst", BrB, + []>; + + +let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7, + isBarrier = 1, isCall = 1, isReturn = 1 in +def TAILBA : IForm<18, 0, 0, (outs), (ins aaddr:$dst), + "ba $dst", BrB, + []>; + + // DCB* instructions. def DCBA : DCB_Form<758, 0, (outs), (ins memrr:$dst), "dcba $dst", LdStDCBF, [(int_ppc_dcba xoaddr:$dst)]>, @@ -1211,6 +1262,18 @@ def : Pat<(PPCcall_ELF (i32 texternalsym:$dst)), (BL_ELF texternalsym:$dst)>; + +def : Pat<(PPCtc_return (i32 tglobaladdr:$dst), imm:$imm), + (TCRETURNdi tglobaladdr:$dst, imm:$imm)>; + +def : Pat<(PPCtc_return (i32 texternalsym:$dst), imm:$imm), + (TCRETURNdi texternalsym:$dst, imm:$imm)>; + +def : Pat<(PPCtc_return CTRRC:$dst, imm:$imm), + (TCRETURNri CTRRC:$dst, imm:$imm)>; + + + // Hi and Lo for Darwin Global Addresses. def : Pat<(PPChi tglobaladdr:$in, 0), (LIS tglobaladdr:$in)>; def : Pat<(PPClo tglobaladdr:$in, 0), (LI tglobaladdr:$in)>; Modified: llvm/trunk/lib/Target/PowerPC/PPCMachineFunctionInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCMachineFunctionInfo.h?rev=50477&r1=50476&r2=50477&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCMachineFunctionInfo.h (original) +++ llvm/trunk/lib/Target/PowerPC/PPCMachineFunctionInfo.h Wed Apr 30 04:16:33 2008 @@ -43,19 +43,42 @@ /// requires that the code generator produce a store of LR to the stack on /// entry, even though LR may otherwise apparently not be used. bool LRStoreRequired; + + /// MinReservedArea - This is the frame size that is at least reserved in a + /// potential caller (parameter+linkage area). + unsigned MinReservedArea; + + /// TailCallSPDelta - Stack pointer delta used when tail calling. Maximum + /// amount the stack pointer is adjusted to make the frame bigger for tail + /// calls. Used for creating an area before the register spill area. + int TailCallSPDelta; + + /// HasFastCall - Does this function contain a fast call. Used to determine + /// how the caller's stack pointer should be calculated (epilog/dynamicalloc). + bool HasFastCall; + public: PPCFunctionInfo(MachineFunction &MF) : FramePointerSaveIndex(0), ReturnAddrSaveIndex(0), SpillsCR(false), - LRStoreRequired(false) {} + LRStoreRequired(false), + MinReservedArea(0), + TailCallSPDelta(0), + HasFastCall(false) {} int getFramePointerSaveIndex() const { return FramePointerSaveIndex; } void setFramePointerSaveIndex(int Idx) { FramePointerSaveIndex = Idx; } int getReturnAddrSaveIndex() const { return ReturnAddrSaveIndex; } void setReturnAddrSaveIndex(int idx) { ReturnAddrSaveIndex = idx; } - + + unsigned getMinReservedArea() const { return MinReservedArea; } + void setMinReservedArea(unsigned size) { MinReservedArea = size; } + + int getTailCallSPDelta() const { return TailCallSPDelta; } + void setTailCallSPDelta(int size) { TailCallSPDelta = size; } + /// UsesLR - This is set when the prolog/epilog inserter does its initial scan /// of the function, it is true if the LR/LR8 register is ever explicitly /// accessed/clobbered in the machine function (e.g. by calls and movpctolr, @@ -68,6 +91,9 @@ void setLRStoreRequired() { LRStoreRequired = true; } bool isLRStoreRequired() const { return LRStoreRequired; } + + void setHasFastCall() { HasFastCall = true; } + bool hasFastCall() const { return HasFastCall;} }; } // end of namespace llvm Modified: llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp?rev=50477&r1=50476&r2=50477&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp Wed Apr 30 04:16:33 2008 @@ -19,6 +19,7 @@ #include "PPCRegisterInfo.h" #include "PPCFrameInfo.h" #include "PPCSubtarget.h" +#include "llvm/CallingConv.h" #include "llvm/Constants.h" #include "llvm/Function.h" #include "llvm/Type.h" @@ -332,7 +333,8 @@ // static bool needsFP(const MachineFunction &MF) { const MachineFrameInfo *MFI = MF.getFrameInfo(); - return NoFramePointerElim || MFI->hasVarSizedObjects(); + return NoFramePointerElim || MFI->hasVarSizedObjects() || + (PerformTailCallOpt && MF.getInfo()->hasFastCall()); } static bool spillsCR(const MachineFunction &MF) { @@ -399,9 +401,42 @@ MF.getFrameInfo()->hasCalls(); } + + void PPCRegisterInfo:: eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const { + if (PerformTailCallOpt && I->getOpcode() == PPC::ADJCALLSTACKUP) { + // Add (actually substract) back the amount the callee popped on return. + if (int CalleeAmt = I->getOperand(1).getImm()) { + MachineInstr * New = NULL; + bool is64Bit = Subtarget.isPPC64(); + CalleeAmt *= -1; + unsigned StackReg = is64Bit ? PPC::X1 : PPC::R1; + unsigned TmpReg = is64Bit ? PPC::X0 : PPC::R0; + unsigned ADDIInstr = is64Bit ? PPC::ADDI8 : PPC::ADDI; + unsigned ADDInstr = is64Bit ? PPC::ADD8 : PPC::ADD4; + unsigned LISInstr = is64Bit ? PPC::LIS8 : PPC::LIS; + unsigned ORIInstr = is64Bit ? PPC::ORI8 : PPC::ORI; + + if (isInt16(CalleeAmt)) { + New = BuildMI(TII.get(ADDIInstr), StackReg).addReg(StackReg). + addImm(CalleeAmt); + MBB.insert(I, New); + } else { + MachineBasicBlock::iterator MBBI = I; + BuildMI(MBB, MBBI, TII.get(LISInstr), TmpReg) + .addImm(CalleeAmt >> 16); + BuildMI(MBB, MBBI, TII.get(ORIInstr), TmpReg) + .addReg(TmpReg, false, false, true) + .addImm(CalleeAmt & 0xFFFF); + BuildMI(MBB, MBBI, TII.get(ADDInstr)) + .addReg(StackReg) + .addReg(StackReg) + .addReg(TmpReg); + } + } + } // Simply discard ADJCALLSTACKDOWN, ADJCALLSTACKUP instructions. MBB.erase(I); } @@ -924,6 +959,13 @@ FI->setFramePointerSaveIndex(FPSI); } + // Reserve stack space to move the linkage area to in case of a tail call. + int TCSPDelta = 0; + if (PerformTailCallOpt && (TCSPDelta=FI->getTailCallSPDelta()) < 0) { + int AddFPOffsetAmount = IsELF32_ABI ? -4 : 0; + MF.getFrameInfo()->CreateFixedObject( -1 * TCSPDelta, + AddFPOffsetAmount + TCSPDelta); + } // Reserve a slot closest to SP or frame pointer if we have a dynalloc or // a large stack, which will require scavenging a register to materialize a // large offset. @@ -1160,7 +1202,15 @@ void PPCRegisterInfo::emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const { MachineBasicBlock::iterator MBBI = prior(MBB.end()); - assert(MBBI->getOpcode() == PPC::BLR && + unsigned RetOpcode = MBBI->getOpcode(); + + assert( (RetOpcode == PPC::BLR || + RetOpcode == PPC::TCRETURNri || + RetOpcode == PPC::TCRETURNdi || + RetOpcode == PPC::TCRETURNai || + RetOpcode == PPC::TCRETURNri8 || + RetOpcode == PPC::TCRETURNdi8 || + RetOpcode == PPC::TCRETURNai8) && "Can only insert epilog into returning blocks"); // Get alignment info so we know how to restore r1 @@ -1169,7 +1219,7 @@ unsigned MaxAlign = MFI->getMaxAlignment(); // Get the number of bytes allocated from the FrameInfo. - unsigned FrameSize = MFI->getStackSize(); + int FrameSize = MFI->getStackSize(); // Get processor type. bool IsPPC64 = Subtarget.isPPC64(); @@ -1183,19 +1233,75 @@ int LROffset = PPCFrameInfo::getReturnSaveOffset(IsPPC64, IsMachoABI); int FPOffset = PPCFrameInfo::getFramePointerSaveOffset(IsPPC64, IsMachoABI); + bool UsesTCRet = RetOpcode == PPC::TCRETURNri || + RetOpcode == PPC::TCRETURNdi || + RetOpcode == PPC::TCRETURNai || + RetOpcode == PPC::TCRETURNri8 || + RetOpcode == PPC::TCRETURNdi8 || + RetOpcode == PPC::TCRETURNai8; + + PPCFunctionInfo *FI = MF.getInfo(); + + if (UsesTCRet) { + int MaxTCRetDelta = FI->getTailCallSPDelta(); + MachineOperand &StackAdjust = MBBI->getOperand(1); + assert( StackAdjust.isImmediate() && "Expecting immediate value."); + // Adjust stack pointer. + int StackAdj = StackAdjust.getImm(); + int Delta = StackAdj - MaxTCRetDelta; + assert((Delta >= 0) && "Delta must be positive"); + if (MaxTCRetDelta>0) + FrameSize += (StackAdj +Delta); + else + FrameSize += StackAdj; + } + if (FrameSize) { // The loaded (or persistent) stack pointer value is offset by the 'stwu' // on entry to the function. Add this offset back now. - if (!Subtarget.isPPC64()) { - if (isInt16(FrameSize) && (!ALIGN_STACK || TargetAlign >= MaxAlign) && - !MFI->hasVarSizedObjects()) { - BuildMI(MBB, MBBI, TII.get(PPC::ADDI), PPC::R1) - .addReg(PPC::R1).addImm(FrameSize); + if (!IsPPC64) { + // If this function contained a fastcc call and PerformTailCallOpt is + // enabled (=> hasFastCall()==true) the fastcc call might contain a tail + // call which invalidates the stack pointer value in SP(0). So we use the + // value of R31 in this case. + if (FI->hasFastCall() && isInt16(FrameSize)) { + assert(hasFP(MF) && "Expecting a valid the frame pointer."); + BuildMI(MBB, MBBI, TII.get(PPC::ADDI), PPC::R1) + .addReg(PPC::R31).addImm(FrameSize); + } else if(FI->hasFastCall()) { + BuildMI(MBB, MBBI, TII.get(PPC::LIS), PPC::R0) + .addImm(FrameSize >> 16); + BuildMI(MBB, MBBI, TII.get(PPC::ORI), PPC::R0) + .addReg(PPC::R0, false, false, true) + .addImm(FrameSize & 0xFFFF); + BuildMI(MBB, MBBI, TII.get(PPC::ADD4)) + .addReg(PPC::R1) + .addReg(PPC::R31) + .addReg(PPC::R0); + } else if (isInt16(FrameSize) && + (!ALIGN_STACK || TargetAlign >= MaxAlign) && + !MFI->hasVarSizedObjects()) { + BuildMI(MBB, MBBI, TII.get(PPC::ADDI), PPC::R1) + .addReg(PPC::R1).addImm(FrameSize); } else { BuildMI(MBB, MBBI, TII.get(PPC::LWZ),PPC::R1).addImm(0).addReg(PPC::R1); } } else { - if (isInt16(FrameSize) && TargetAlign >= MaxAlign && + if (FI->hasFastCall() && isInt16(FrameSize)) { + assert(hasFP(MF) && "Expecting a valid the frame pointer."); + BuildMI(MBB, MBBI, TII.get(PPC::ADDI8), PPC::X1) + .addReg(PPC::X31).addImm(FrameSize); + } else if(FI->hasFastCall()) { + BuildMI(MBB, MBBI, TII.get(PPC::LIS8), PPC::X0) + .addImm(FrameSize >> 16); + BuildMI(MBB, MBBI, TII.get(PPC::ORI8), PPC::X0) + .addReg(PPC::X0, false, false, true) + .addImm(FrameSize & 0xFFFF); + BuildMI(MBB, MBBI, TII.get(PPC::ADD8)) + .addReg(PPC::X1) + .addReg(PPC::X31) + .addReg(PPC::X0); + } else if (isInt16(FrameSize) && TargetAlign >= MaxAlign && !MFI->hasVarSizedObjects()) { BuildMI(MBB, MBBI, TII.get(PPC::ADDI8), PPC::X1) .addReg(PPC::X1).addImm(FrameSize); @@ -1228,6 +1334,64 @@ if (UsesLR) BuildMI(MBB, MBBI, TII.get(PPC::MTLR)).addReg(PPC::R0); } + + // Callee pop calling convention. Pop parameter/linkage area. Used for tail + // call optimization + if (PerformTailCallOpt && RetOpcode == PPC::BLR && + MF.getFunction()->getCallingConv() == CallingConv::Fast) { + PPCFunctionInfo *FI = MF.getInfo(); + unsigned CallerAllocatedAmt = FI->getMinReservedArea(); + unsigned StackReg = IsPPC64 ? PPC::X1 : PPC::R1; + unsigned FPReg = IsPPC64 ? PPC::X31 : PPC::R31; + unsigned TmpReg = IsPPC64 ? PPC::X0 : PPC::R0; + unsigned ADDIInstr = IsPPC64 ? PPC::ADDI8 : PPC::ADDI; + unsigned ADDInstr = IsPPC64 ? PPC::ADD8 : PPC::ADD4; + unsigned LISInstr = IsPPC64 ? PPC::LIS8 : PPC::LIS; + unsigned ORIInstr = IsPPC64 ? PPC::ORI8 : PPC::ORI; + + if (CallerAllocatedAmt && isInt16(CallerAllocatedAmt)) { + BuildMI(MBB, MBBI, TII.get(ADDIInstr), StackReg) + .addReg(StackReg).addImm(CallerAllocatedAmt); + } else { + BuildMI(MBB, MBBI, TII.get(LISInstr), TmpReg) + .addImm(CallerAllocatedAmt >> 16); + BuildMI(MBB, MBBI, TII.get(ORIInstr), TmpReg) + .addReg(TmpReg, false, false, true) + .addImm(CallerAllocatedAmt & 0xFFFF); + BuildMI(MBB, MBBI, TII.get(ADDInstr)) + .addReg(StackReg) + .addReg(FPReg) + .addReg(TmpReg); + } + } else if (RetOpcode == PPC::TCRETURNdi) { + MBBI = prior(MBB.end()); + MachineOperand &JumpTarget = MBBI->getOperand(0); + BuildMI(MBB, MBBI, TII.get(PPC::TAILB)). + addGlobalAddress(JumpTarget.getGlobal(), JumpTarget.getOffset()); + } else if (RetOpcode == PPC::TCRETURNri) { + MBBI = prior(MBB.end()); + MachineOperand &JumpTarget = MBBI->getOperand(0); + assert(JumpTarget.isReg() && "Expecting register operand."); + BuildMI(MBB, MBBI, TII.get(PPC::TAILBCTR)); + } else if (RetOpcode == PPC::TCRETURNai) { + MBBI = prior(MBB.end()); + MachineOperand &JumpTarget = MBBI->getOperand(0); + BuildMI(MBB, MBBI, TII.get(PPC::TAILBA)).addImm(JumpTarget.getImm()); + } else if (RetOpcode == PPC::TCRETURNdi8) { + MBBI = prior(MBB.end()); + MachineOperand &JumpTarget = MBBI->getOperand(0); + BuildMI(MBB, MBBI, TII.get(PPC::TAILB8)). + addGlobalAddress(JumpTarget.getGlobal(), JumpTarget.getOffset()); + } else if (RetOpcode == PPC::TCRETURNri8) { + MBBI = prior(MBB.end()); + MachineOperand &JumpTarget = MBBI->getOperand(0); + assert(JumpTarget.isReg() && "Expecting register operand."); + BuildMI(MBB, MBBI, TII.get(PPC::TAILBCTR8)); + } else if (RetOpcode == PPC::TCRETURNai8) { + MBBI = prior(MBB.end()); + MachineOperand &JumpTarget = MBBI->getOperand(0); + BuildMI(MBB, MBBI, TII.get(PPC::TAILBA8)).addImm(JumpTarget.getImm()); + } } unsigned PPCRegisterInfo::getRARegister() const { Modified: llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.td?rev=50477&r1=50476&r2=50477&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.td (original) +++ llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.td Wed Apr 30 04:16:33 2008 @@ -346,4 +346,6 @@ let CopyCost = -1; } - + +def CTRRC : RegisterClass<"PPC", [i32], 32, [CTR]>; +def CTRRC8 : RegisterClass<"PPC", [i64], 64, [CTR8]>; Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=50477&r1=50476&r2=50477&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed Apr 30 04:16:33 2008 @@ -788,19 +788,6 @@ #include "X86GenCallingConv.inc" -/// GetPossiblePreceedingTailCall - Get preceeding X86ISD::TAILCALL node if it -/// exists skip possible ISD:TokenFactor. -static SDOperand GetPossiblePreceedingTailCall(SDOperand Chain) { - if (Chain.getOpcode() == X86ISD::TAILCALL) { - return Chain; - } else if (Chain.getOpcode() == ISD::TokenFactor) { - if (Chain.getNumOperands() && - Chain.getOperand(0).getOpcode() == X86ISD::TAILCALL) - return Chain.getOperand(0); - } - return Chain; -} - /// LowerRET - Lower an ISD::RET node. SDOperand X86TargetLowering::LowerRET(SDOperand Op, SelectionDAG &DAG) { assert((Op.getNumOperands() & 1) == 1 && "ISD::RET should have odd # args"); @@ -821,7 +808,7 @@ SDOperand Chain = Op.getOperand(0); // Handle tail call return. - Chain = GetPossiblePreceedingTailCall(Chain); + Chain = GetPossiblePreceedingTailCall(Chain, X86ISD::TAILCALL); if (Chain.getOpcode() == X86ISD::TAILCALL) { SDOperand TailCall = Chain; SDOperand TargetAddress = TailCall.getOperand(1); @@ -1057,27 +1044,6 @@ return None; } -/// IsPossiblyOverwrittenArgumentOfTailCall - Check if the operand could -/// possibly be overwritten when lowering the outgoing arguments in a tail -/// call. Currently the implementation of this call is very conservative and -/// assumes all arguments sourcing from FORMAL_ARGUMENTS or a CopyFromReg with -/// virtual registers would be overwritten by direct lowering. -static bool IsPossiblyOverwrittenArgumentOfTailCall(SDOperand Op, - MachineFrameInfo * MFI) { - RegisterSDNode * OpReg = NULL; - FrameIndexSDNode * FrameIdxNode = NULL; - int FrameIdx = 0; - if (Op.getOpcode() == ISD::FORMAL_ARGUMENTS || - (Op.getOpcode()== ISD::CopyFromReg && - (OpReg = dyn_cast(Op.getOperand(1))) && - (OpReg->getReg() >= TargetRegisterInfo::FirstVirtualRegister)) || - (Op.getOpcode() == ISD::LOAD && - (FrameIdxNode = dyn_cast(Op.getOperand(1))) && - (MFI->isFixedObjectIndex((FrameIdx = FrameIdxNode->getIndex()))) && - (MFI->getObjectOffset(FrameIdx) >= 0))) - return true; - return false; -} /// CallRequiresGOTInRegister - Check whether the call requires the GOT pointer /// in a register before calling. @@ -1087,7 +1053,6 @@ Subtarget->isPICStyleGOT(); } - /// CallRequiresFnAddressInReg - Check whether the call requires the function /// address to be loaded in a register. bool @@ -1097,33 +1062,6 @@ Subtarget->isPICStyleGOT(); } -/// CopyTailCallClobberedArgumentsToVRegs - Create virtual registers for all -/// arguments to force loading and guarantee that arguments sourcing from -/// incomming parameters are not overwriting each other. -static SDOperand -CopyTailCallClobberedArgumentsToVRegs(SDOperand Chain, - SmallVector, 8> &TailCallClobberedVRegs, - SelectionDAG &DAG, - MachineFunction &MF, - const TargetLowering * TL) { - - SDOperand InFlag; - for (unsigned i = 0, e = TailCallClobberedVRegs.size(); i != e; i++) { - SDOperand Arg = TailCallClobberedVRegs[i].second; - unsigned Idx = TailCallClobberedVRegs[i].first; - unsigned VReg = - MF.getRegInfo(). - createVirtualRegister(TL->getRegClassFor(Arg.getValueType())); - Chain = DAG.getCopyToReg(Chain, VReg, Arg, InFlag); - InFlag = Chain.getValue(1); - Arg = DAG.getCopyFromReg(Chain, VReg, Arg.getValueType(), InFlag); - TailCallClobberedVRegs[i] = std::make_pair(Idx, Arg); - Chain = Arg.getValue(1); - InFlag = Arg.getValue(2); - } - return Chain; -} - /// CreateCopyOfByValArgument - Make a copy of an aggregate at address specified /// by "Src" to address "Dst" with size and alignment information specified by /// the specific parameter attribute. The copy will be passed as a byval @@ -1133,8 +1071,7 @@ ISD::ArgFlagsTy Flags, SelectionDAG &DAG) { SDOperand SizeNode = DAG.getConstant(Flags.getByValSize(), MVT::i32); return DAG.getMemcpy(Chain, Dst, Src, SizeNode, Flags.getByValAlign(), - /*AlwaysInline=*/true, - NULL, 0, NULL, 0); + /*AlwaysInline=*/true, NULL, 0, NULL, 0); } SDOperand X86TargetLowering::LowerMemArgument(SDOperand Op, SelectionDAG &DAG, @@ -1463,65 +1400,8 @@ return Chain; } -/// CopyTailCallByValClobberedRegToVirtReg - Copy arguments with register target -/// which might be overwritten by later byval tail call lowering to a virtual -/// register. -bool -X86TargetLowering::CopyTailCallByValClobberedRegToVirtReg(bool containsByValArg, - SmallVector< std::pair, 8> &TailCallByValClobberedVRegs, - SmallVector &TailCallByValClobberedVRegTypes, - std::pair &RegToPass, - SDOperand &OutChain, - SDOperand &OutFlag, - MachineFunction &MF, - SelectionDAG & DAG) { - if (!containsByValArg) return false; - - std::pair ArgRegVReg; - MVT::ValueType VT = RegToPass.second.getValueType(); - - ArgRegVReg.first = RegToPass.first; - ArgRegVReg.second = MF.getRegInfo().createVirtualRegister(getRegClassFor(VT)); - - // Copy Argument to virtual register. - OutChain = DAG.getCopyToReg(OutChain, ArgRegVReg.second, - RegToPass.second, OutFlag); - OutFlag = OutChain.getValue(1); - // Remember virtual register and type. - TailCallByValClobberedVRegs.push_back(ArgRegVReg); - TailCallByValClobberedVRegTypes.push_back(VT); - return true; -} - - -/// RestoreTailCallByValClobberedReg - Restore registers which were saved to -/// virtual registers to prevent tail call byval lowering from overwriting -/// parameter registers. -static SDOperand -RestoreTailCallByValClobberedRegs(SelectionDAG & DAG, SDOperand Chain, - SmallVector< std::pair, 8> &TailCallByValClobberedVRegs, - SmallVector &TailCallByValClobberedVRegTypes) { - if (TailCallByValClobberedVRegs.size()==0) return Chain; - - SmallVector RegOpChains; - for (unsigned i = 0, e=TailCallByValClobberedVRegs.size(); i != e; i++) { - SDOperand InFlag; - unsigned DestReg = TailCallByValClobberedVRegs[i].first; - unsigned VirtReg = TailCallByValClobberedVRegs[i].second; - MVT::ValueType VT = TailCallByValClobberedVRegTypes[i]; - SDOperand Tmp = DAG.getCopyFromReg(Chain, VirtReg, VT, InFlag); - Chain = DAG.getCopyToReg(Chain, DestReg, Tmp, InFlag); - RegOpChains.push_back(Chain); - } - if (!RegOpChains.empty()) - Chain = DAG.getNode(ISD::TokenFactor, MVT::Other, - &RegOpChains[0], RegOpChains.size()); - return Chain; -} - SDOperand X86TargetLowering::LowerCALL(SDOperand Op, SelectionDAG &DAG) { MachineFunction &MF = DAG.getMachineFunction(); - MachineFrameInfo * MFI = MF.getFrameInfo(); SDOperand Chain = Op.getOperand(0); unsigned CC = cast(Op.getOperand(1))->getValue(); bool isVarArg = cast(Op.getOperand(2))->getValue() != 0; @@ -1572,17 +1452,11 @@ FPDiff); SmallVector, 8> RegsToPass; - SmallVector, 8> TailCallClobberedVRegs; - SmallVector MemOpChains; - SDOperand StackPtr; - bool containsTailCallByValArg = false; - SmallVector, 8> TailCallByValClobberedVRegs; - SmallVector TailCallByValClobberedVRegTypes; - // Walk the register/memloc assignments, inserting copies/loads. For tail - // calls, remember all arguments for later special lowering. + // Walk the register/memloc assignments, inserting copies/loads. In the case + // of tail call optimization arguments are handle later. for (unsigned i = 0, e = ArgLocs.size(); i != e; ++i) { CCValAssign &VA = ArgLocs[i]; SDOperand Arg = Op.getOperand(5+2*VA.getValNo()); @@ -1638,10 +1512,6 @@ MemOpChains.push_back(LowerMemOpCallTo(Op, DAG, StackPtr, VA, Chain, Arg)); - // Remember fact that this call contains byval arguments. - containsTailCallByValArg |= IsTailCall && isByVal; - } else if (IsPossiblyOverwrittenArgumentOfTailCall(Arg, MFI)) { - TailCallClobberedVRegs.push_back(std::make_pair(i,Arg)); } } } @@ -1653,21 +1523,14 @@ // Build a sequence of copy-to-reg nodes chained together with token chain // and flag operands which copy the outgoing args into registers. SDOperand InFlag; - for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i) { - // Tail call byval lowering might overwrite argument registers so arguments - // passed to be copied to a virtual register for - // later processing. - if (CopyTailCallByValClobberedRegToVirtReg(containsTailCallByValArg, - TailCallByValClobberedVRegs, - TailCallByValClobberedVRegTypes, - RegsToPass[i], Chain, InFlag, MF, - DAG)) - continue; - - Chain = DAG.getCopyToReg(Chain, RegsToPass[i].first, RegsToPass[i].second, - InFlag); - InFlag = Chain.getValue(1); - } + // Tail call byval lowering might overwrite argument registers so in case of + // tail call optimization the copies to registers are lowered later. + if (!IsTailCall) + for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i) { + Chain = DAG.getCopyToReg(Chain, RegsToPass[i].first, RegsToPass[i].second, + InFlag); + InFlag = Chain.getValue(1); + } // ELF / PIC requires GOT in the EBX register before function calls via PLT // GOT pointer. @@ -1723,10 +1586,6 @@ int FI = 0; // Do not flag preceeding copytoreg stuff together with the following stuff. InFlag = SDOperand(); - - Chain = CopyTailCallClobberedArgumentsToVRegs(Chain, TailCallClobberedVRegs, - DAG, MF, this); - for (unsigned i = 0, e = ArgLocs.size(); i != e; ++i) { CCValAssign &VA = ArgLocs[i]; if (!VA.isRegLoc()) { @@ -1741,17 +1600,6 @@ FI = MF.getFrameInfo()->CreateFixedObject(OpSize, Offset); FIN = DAG.getFrameIndex(FI, getPointerTy()); - // Find virtual register for this argument. - bool Found=false; - for (unsigned idx=0, e= TailCallClobberedVRegs.size(); idx < e; idx++) - if (TailCallClobberedVRegs[idx].first==i) { - Arg = TailCallClobberedVRegs[idx].second; - Found=true; - break; - } - assert(IsPossiblyOverwrittenArgumentOfTailCall(Arg, MFI)==false || - (Found==true && "No corresponding Argument was found")); - if (Flags.isByVal()) { // Copy relative to framepointer. SDOperand Source = DAG.getIntPtrConstant(VA.getLocMemOffset()); @@ -1774,10 +1622,13 @@ Chain = DAG.getNode(ISD::TokenFactor, MVT::Other, &MemOpChains2[0], MemOpChains2.size()); - // Restore byval lowering clobbered registers. - Chain = RestoreTailCallByValClobberedRegs(DAG, Chain, - TailCallByValClobberedVRegs, - TailCallByValClobberedVRegTypes); + // Copy arguments to their registers. + for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i) { + Chain = DAG.getCopyToReg(Chain, RegsToPass[i].first, RegsToPass[i].second, + InFlag); + InFlag = Chain.getValue(1); + } + InFlag =SDOperand(); // Store the return address to the appropriate stack slot. Chain = EmitTailCallStoreRetAddr(DAG, MF, Chain, RetAddrFrIdx, Is64Bit, @@ -1955,15 +1806,7 @@ if (!PerformTailCallOpt) return false; - // Check whether CALL node immediatly preceeds the RET node and whether the - // return uses the result of the node or is a void return. - unsigned NumOps = Ret.getNumOperands(); - if ((NumOps == 1 && - (Ret.getOperand(0) == SDOperand(Call.Val,1) || - Ret.getOperand(0) == SDOperand(Call.Val,0))) || - (NumOps > 1 && - Ret.getOperand(0) == SDOperand(Call.Val,Call.Val->getNumValues()-1) && - Ret.getOperand(1) == SDOperand(Call.Val,0))) { + if (CheckTailCallReturnConstraints(Call, Ret)) { MachineFunction &MF = DAG.getMachineFunction(); unsigned CallerCC = MF.getFunction()->getCallingConv(); unsigned CalleeCC = cast(Call.getOperand(1))->getValue(); Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=50477&r1=50476&r2=50477&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Wed Apr 30 04:16:33 2008 @@ -475,15 +475,6 @@ SDOperand EmitTailCallLoadRetAddr(SelectionDAG &DAG, SDOperand &OutRetAddr, SDOperand Chain, bool IsTailCall, bool Is64Bit, int FPDiff); - - bool CopyTailCallByValClobberedRegToVirtReg(bool containsByValArg, - SmallVector< std::pair,8> &TailCallByValClobberedVRegs, - SmallVector &TailCallByValClobberedVRegTypes, - std::pair &RegToPass, - SDOperand &OutChain, - SDOperand &OutFlag, - MachineFunction &MF, - SelectionDAG & DAG); CCAssignFn *CCAssignFnForNode(SDOperand Op) const; NameDecorationStyle NameDecorationForFORMAL_ARGUMENTS(SDOperand Op); Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=50477&r1=50476&r2=50477&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Wed Apr 30 04:16:33 2008 @@ -391,6 +391,7 @@ []>; let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in + def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL", []>; let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in Added: llvm/trunk/test/CodeGen/PowerPC/tailcall1-64.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/tailcall1-64.ll?rev=50477&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/tailcall1-64.ll (added) +++ llvm/trunk/test/CodeGen/PowerPC/tailcall1-64.ll Wed Apr 30 04:16:33 2008 @@ -0,0 +1,11 @@ +; RUN: llvm-as < %s | llc -march=ppc64 -tailcallopt | grep TC_RETURNd8 +define fastcc i32 @tailcallee(i32 %a1, i32 %a2, i32 %a3, i32 %a4) { +entry: + ret i32 %a3 +} + +define fastcc i32 @tailcaller(i32 %in1, i32 %in2) { +entry: + %tmp11 = tail call fastcc i32 @tailcallee( i32 %in1, i32 %in2, i32 %in1, i32 %in2 ) ; [#uses=1] + ret i32 %tmp11 +} Added: llvm/trunk/test/CodeGen/PowerPC/tailcall1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/tailcall1.ll?rev=50477&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/tailcall1.ll (added) +++ llvm/trunk/test/CodeGen/PowerPC/tailcall1.ll Wed Apr 30 04:16:33 2008 @@ -0,0 +1,11 @@ +; RUN: llvm-as < %s | llc -march=ppc32 -tailcallopt | grep TC_RETURN +define fastcc i32 @tailcallee(i32 %a1, i32 %a2, i32 %a3, i32 %a4) { +entry: + ret i32 %a3 +} + +define fastcc i32 @tailcaller(i32 %in1, i32 %in2) { +entry: + %tmp11 = tail call fastcc i32 @tailcallee( i32 %in1, i32 %in2, i32 %in1, i32 %in2 ) ; [#uses=1] + ret i32 %tmp11 +} Added: llvm/trunk/test/CodeGen/PowerPC/tailcallpic1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/tailcallpic1.ll?rev=50477&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/tailcallpic1.ll (added) +++ llvm/trunk/test/CodeGen/PowerPC/tailcallpic1.ll Wed Apr 30 04:16:33 2008 @@ -0,0 +1,14 @@ +; RUN: llvm-as < %s | llc -tailcallopt -mtriple=powerpc-apple-darwin -relocation-model=pic | grep TC_RETURN + + + +define protected fastcc i32 @tailcallee(i32 %a1, i32 %a2, i32 %a3, i32 %a4) { +entry: + ret i32 %a3 +} + +define fastcc i32 @tailcaller(i32 %in1, i32 %in2) { +entry: + %tmp11 = tail call fastcc i32 @tailcallee( i32 %in1, i32 %in2, i32 %in1, i32 %in2 ) ; [#uses=1] + ret i32 %tmp11 +} From arnold.schwaighofer at gmail.com Wed Apr 30 04:19:48 2008 From: arnold.schwaighofer at gmail.com (Arnold Schwaighofer) Date: Wed, 30 Apr 2008 09:19:48 -0000 Subject: [llvm-commits] [llvm] r50478 - /llvm/trunk/test/CodeGen/X86/tailcallstack64.ll Message-ID: <200804300919.m3U9JmXE010548@zion.cs.uiuc.edu> Author: arnolds Date: Wed Apr 30 04:19:47 2008 New Revision: 50478 URL: http://llvm.org/viewvc/llvm-project?rev=50478&view=rev Log: Really commit the test checking the argument lowering behaviour on x86-64 :). Added: llvm/trunk/test/CodeGen/X86/tailcallstack64.ll Added: llvm/trunk/test/CodeGen/X86/tailcallstack64.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tailcallstack64.ll?rev=50478&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/tailcallstack64.ll (added) +++ llvm/trunk/test/CodeGen/X86/tailcallstack64.ll Wed Apr 30 04:19:47 2008 @@ -0,0 +1,21 @@ +; RUN: llvm-as < %s | llc -tailcallopt -march=x86-64 | grep TAILCALL +; Check that lowered arguments on the stack do not overwrite each other. +; Move param %in1 to temp register (%eax). +; RUN: llvm-as < %s | llc -tailcallopt -march=x86-64 -x86-asm-syntax=att | grep {movl 40(%rsp), %eax} +; Add %in1 %p1 to another temporary register (%r9d). +; RUN: llvm-as < %s | llc -tailcallopt -march=x86-64 -x86-asm-syntax=att | grep {movl %edi, %r9d} +; RUN: llvm-as < %s | llc -tailcallopt -march=x86-64 -x86-asm-syntax=att | grep {addl 32(%rsp), %r9d} +; Move result of addition to stack. +; RUN: llvm-as < %s | llc -tailcallopt -march=x86-64 -x86-asm-syntax=att | grep {movl %r9d, 40(%rsp)} +; Move param %in2 to stack. +; RUN: llvm-as < %s | llc -tailcallopt -march=x86-64 -x86-asm-syntax=att | grep {movl %eax, 32(%rsp)} + +declare fastcc i32 @tailcallee(i32 %p1, i32 %p2, i32 %p3, i32 %p4, i32 %p5, i32 %a, i32 %b) + +define fastcc i32 @tailcaller(i32 %p1, i32 %p2, i32 %p3, i32 %p4, i32 %p5, i32 %in1, i32 %in2) { +entry: + %tmp = add i32 %in1, %p1 + %retval = tail call fastcc i32 @tailcallee(i32 %p1, i32 %p2, i32 %p3, i32 %p4, i32 %p5, i32 %in2,i32 %tmp) + ret i32 %retval +} + From ggreif at gmail.com Wed Apr 30 07:14:15 2008 From: ggreif at gmail.com (Gabor Greif) Date: Wed, 30 Apr 2008 12:14:15 -0000 Subject: [llvm-commits] [llvm] r50479 - in /llvm/branches/ggreif/use-diet: include/llvm/Instructions.h lib/VMCore/Instructions.cpp Message-ID: <200804301214.m3UCEGnv015275@zion.cs.uiuc.edu> Author: ggreif Date: Wed Apr 30 07:14:06 2008 New Revision: 50479 URL: http://llvm.org/viewvc/llvm-project?rev=50479&view=rev Log: remove unneeded destructors Modified: llvm/branches/ggreif/use-diet/include/llvm/Instructions.h llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp Modified: llvm/branches/ggreif/use-diet/include/llvm/Instructions.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Instructions.h?rev=50479&r1=50478&r2=50479&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/Instructions.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/Instructions.h Wed Apr 30 07:14:06 2008 @@ -482,7 +482,6 @@ const std::string &Name, BasicBlock *InsertAtEnd) { return new(2) GetElementPtrInst(Ptr, Idx, Name, InsertAtEnd); } - ~GetElementPtrInst(); virtual GetElementPtrInst *clone() const; @@ -1967,8 +1966,6 @@ Values, Name, InsertAtEnd); } - ~InvokeInst(); - virtual InvokeInst *clone() const; /// Provide fast operand accessors Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp?rev=50479&r1=50478&r2=50479&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp Wed Apr 30 07:14:06 2008 @@ -395,10 +395,6 @@ // InvokeInst Implementation //===----------------------------------------------------------------------===// -InvokeInst::~InvokeInst() { -// delete [] OperandList; -} - void InvokeInst::init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException, Value* const *Args, unsigned NumArgs) { assert(NumOperands == 3+NumArgs && "NumOperands not set up?"); @@ -1021,10 +1017,6 @@ setName(Name); } -GetElementPtrInst::~GetElementPtrInst() { - // delete[] OperandList; -} - // getIndexedType - Returns the type of the element that would be loaded with // a load instruction with the specified parameters. // From ggreif at gmail.com Wed Apr 30 07:35:28 2008 From: ggreif at gmail.com (Gabor Greif) Date: Wed, 30 Apr 2008 12:35:28 -0000 Subject: [llvm-commits] [llvm] r50480 - in /llvm/branches/ggreif/use-diet: include/llvm/Instructions.h lib/Bitcode/Reader/BitcodeReader.cpp lib/Bitcode/Reader/BitcodeReader.h lib/VMCore/Instructions.cpp Message-ID: <200804301235.m3UCZSQT015953@zion.cs.uiuc.edu> Author: ggreif Date: Wed Apr 30 07:35:27 2008 New Revision: 50480 URL: http://llvm.org/viewvc/llvm-project?rev=50480&view=rev Log: some review feedback from Chris Modified: llvm/branches/ggreif/use-diet/include/llvm/Instructions.h llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp Modified: llvm/branches/ggreif/use-diet/include/llvm/Instructions.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Instructions.h?rev=50480&r1=50479&r2=50480&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/Instructions.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/Instructions.h Wed Apr 30 07:35:27 2008 @@ -376,7 +376,7 @@ /// access elements of arrays and structs /// class GetElementPtrInst : public Instruction { - inline GetElementPtrInst(const GetElementPtrInst &GEPI); + GetElementPtrInst(const GetElementPtrInst &GEPI); void init(Value *Ptr, Value* const *Idx, unsigned NumIdx); void init(Value *Ptr, Value *Idx); @@ -472,8 +472,8 @@ return new(Values) GetElementPtrInst(Ptr, IdxBegin, IdxEnd, Values, Name, InsertAtEnd); } - /// Constructors - These two constructors are convenience methods because one - /// and two index getelementptr instructions are so common. + /// Constructors - These two creators are convenience methods because one + /// index getelementptr instructions are so common. static GetElementPtrInst *Create(Value *Ptr, Value *Idx, const std::string &Name = "", Instruction *InsertBefore = 0) { return new(2) GetElementPtrInst(Ptr, Idx, Name, InsertBefore); @@ -558,16 +558,6 @@ struct OperandTraits : VariadicOperandTraits<1> { }; -GetElementPtrInst::GetElementPtrInst(const GetElementPtrInst &GEPI) - : Instruction(reinterpret_cast(GEPI.getType()), GetElementPtr, - OperandTraits::op_end(this) - GEPI.getNumOperands(), - GEPI.getNumOperands()) { - Use *OL = OperandList; - Use *GEPIOL = GEPI.OperandList; - for (unsigned i = 0, E = NumOperands; i != E; ++i) - OL[i].init(GEPIOL[i], this); -} - template GetElementPtrInst::GetElementPtrInst(Value *Ptr, InputIterator IdxBegin, @@ -1099,9 +1089,6 @@ } DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CallInst, Value) -//void CallInst::operator delete(void *it) { -// OperandTraits::op_begin(static_cast(it)); -//} //===----------------------------------------------------------------------===// // SelectInst Class Modified: llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp?rev=50480&r1=50479&r2=50480&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp Wed Apr 30 07:35:27 2008 @@ -147,8 +147,7 @@ } void BitcodeReaderValueList::resize(unsigned Desired) { - if (Desired > Capacity) - { + if (Desired > Capacity) { // Since we expect many values to come from the bitcode file we better // allocate the double amount, so that the array size grows exponentially // at each reallocation. Also, add a small amount of 100 extra elements Modified: llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h?rev=50480&r1=50479&r2=50480&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h (original) +++ llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h Wed Apr 30 07:35:27 2008 @@ -86,7 +86,7 @@ void initVal(unsigned Idx, Value *V) { if (Idx >= size()) { // Insert a bunch of null values. - resize(Idx * 2 + 1); + resize(Idx * 2 + 1); } assert(getOperand(Idx) == 0 && "Cannot init an already init'd Use!"); OperandList[Idx].init(V, this); Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp?rev=50480&r1=50479&r2=50480&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp Wed Apr 30 07:35:27 2008 @@ -995,6 +995,16 @@ OL[1].init(Idx, this); } +GetElementPtrInst::GetElementPtrInst(const GetElementPtrInst &GEPI) + : Instruction(reinterpret_cast(GEPI.getType()), GetElementPtr, + OperandTraits::op_end(this) - GEPI.getNumOperands(), + GEPI.getNumOperands()) { + Use *OL = OperandList; + Use *GEPIOL = GEPI.OperandList; + for (unsigned i = 0, E = NumOperands; i != E; ++i) + OL[i].init(GEPIOL[i], this); +} + GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx, const std::string &Name, Instruction *InBe) : Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(),Idx)), From nicolas.geoffray at lip6.fr Wed Apr 30 08:54:57 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Wed, 30 Apr 2008 13:54:57 -0000 Subject: [llvm-commits] [vmkit] r50481 - /vmkit/trunk/configure.ac Message-ID: <200804301354.m3UDsv5E018199@zion.cs.uiuc.edu> Author: geoffray Date: Wed Apr 30 08:54:57 2008 New Revision: 50481 URL: http://llvm.org/viewvc/llvm-project?rev=50481&view=rev Log: Add the allocator includes for a service build. Modified: vmkit/trunk/configure.ac Modified: vmkit/trunk/configure.ac URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/configure.ac?rev=50481&r1=50480&r2=50481&view=diff ============================================================================== --- vmkit/trunk/configure.ac (original) +++ vmkit/trunk/configure.ac Wed Apr 30 08:54:57 2008 @@ -233,8 +233,8 @@ CXXFLAGS="$CXXFLAGS -DMULTIPLE_VM" else if test "x$vmtype" = "xservice"; then - CFLAGS="$CFLAGS -DMULTIPLE_VM -DSERVICE_GC -DMULTIPLE_GC -DSERVICE_VM" - CXXFLAGS="$CXXFLAGS -DMULTIPLE_VM -DSERVICE_GC -DMULTIPLE_GC -DSERVICE_VM" + CFLAGS="$CFLAGS -DMULTIPLE_VM -DSERVICE_GC -DMULTIPLE_GC -DSERVICE_VM -I$PWD/lib/Mvm/Allocator" + CXXFLAGS="$CXXFLAGS -DMULTIPLE_VM -DSERVICE_GC -DMULTIPLE_GC -DSERVICE_VM -I$PWD/lib/Mvm/Allocator" fi fi From criswell at uiuc.edu Wed Apr 30 09:28:02 2008 From: criswell at uiuc.edu (John Criswell) Date: Wed, 30 Apr 2008 14:28:02 -0000 Subject: [llvm-commits] [poolalloc] r50482 - in /poolalloc/trunk: include/poolalloc/PoolAllocate.h lib/PoolAllocate/PASimple.cpp Message-ID: <200804301428.m3UES2Zp019183@zion.cs.uiuc.edu> Author: criswell Date: Wed Apr 30 09:28:01 2008 New Revision: 50482 URL: http://llvm.org/viewvc/llvm-project?rev=50482&view=rev Log: Made the simple pool allocation pass merge all DSNodes. This is required because all objects will reside in the same pool. Modified: poolalloc/trunk/include/poolalloc/PoolAllocate.h poolalloc/trunk/lib/PoolAllocate/PASimple.cpp Modified: poolalloc/trunk/include/poolalloc/PoolAllocate.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/poolalloc/PoolAllocate.h?rev=50482&r1=50481&r2=50482&view=diff ============================================================================== --- poolalloc/trunk/include/poolalloc/PoolAllocate.h (original) +++ poolalloc/trunk/include/poolalloc/PoolAllocate.h Wed Apr 30 09:28:01 2008 @@ -111,7 +111,7 @@ static char ID; Constant *PoolRegister; - virtual ~PoolAllocateGroup () {} + virtual ~PoolAllocateGroup () {return;} virtual PA::FuncInfo *getFuncInfo(Function &F) { return 0;} virtual PA::FuncInfo *getFuncInfoOrClone(Function &F) {return 0;} virtual Function *getOrigFunctionFromClone(Function *F) const {return 0;} @@ -363,14 +363,27 @@ /// implementation. class PoolAllocateSimple : public PoolAllocate { Value * TheGlobalPool; + DSGraph * CombinedDSGraph; + EquivalenceClasses * GlobalECs; + TargetData * TD; public: static char ID; PoolAllocateSimple() : PoolAllocate(false, (intptr_t)&ID) {} + ~PoolAllocateSimple() {return;} void getAnalysisUsage(AnalysisUsage &AU) const; bool runOnModule(Module &M); GlobalVariable *CreateGlobalPool(unsigned RecSize, unsigned Align, Instruction *IPHint, Module& M); - void ProcessFunctionBodySimple(Function& F); + void ProcessFunctionBodySimple(Function& F, TargetData & TD); + + + virtual DSGraph & getDSGraph (const Function & F) const { + return *CombinedDSGraph; + } + + virtual DSGraph & getGlobalsGraph () const { + return *CombinedDSGraph; + } virtual Value * getGlobalPool (const DSNode * Node) { return TheGlobalPool; Modified: poolalloc/trunk/lib/PoolAllocate/PASimple.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PASimple.cpp?rev=50482&r1=50481&r2=50482&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/PASimple.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/PASimple.cpp Wed Apr 30 09:28:01 2008 @@ -79,11 +79,24 @@ AU.setPreservesAll(); } +static void +MergeNodesInDSGraph (DSGraph & Graph) { + while ((Graph.node_begin() != Graph.node_end()) && + ((++(Graph.node_begin())) != Graph.node_end())) { + DSNodeHandle Node (Graph.node_begin()); + DSNodeHandle Target(++(Graph.node_begin())); + Node.mergeWith (Target); + } + return; +} + bool PoolAllocateSimple::runOnModule(Module &M) { if (M.begin() == M.end()) return false; // Get the Target Data information and the ECGraphs ECGraphs = &getAnalysis(); // folded inlined CBU graphs + assert (ECGraphs && "No ECGraphs pass available!\n"); + TargetData & TD = getAnalysis(); // Add the pool* prototypes to the module AddPoolPrototypes(&M); @@ -98,26 +111,40 @@ } // + // Merge all of the DSNodes in the DSGraphs. + // + GlobalECs = &(ECGraphs->getGlobalECs()); + CombinedDSGraph = new DSGraph (*GlobalECs, TD, &(ECGraphs->getGlobalsGraph())); + //CombinedDSGraph.cloneInto (ECGraphs->getGlobalsGraph()); + for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) { + if (ECGraphs->hasGraph (*I)) + CombinedDSGraph->cloneInto (ECGraphs->getDSGraph(*I)); + } + CombinedDSGraph->cloneInto (ECGraphs->getGlobalsGraph()); + MergeNodesInDSGraph (*CombinedDSGraph); + + // // Create the global pool. // TheGlobalPool = CreateGlobalPool(1, 1, MainFunc->getEntryBlock().begin(), M); + // // Now that all call targets are available, rewrite the function bodies of the // clones. - for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) + for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) { if (!(I->isDeclaration())) - ProcessFunctionBodySimple(*I); + ProcessFunctionBodySimple(*I, TD); + } + return true; } -void PoolAllocateSimple::ProcessFunctionBodySimple(Function& F) { +void +PoolAllocateSimple::ProcessFunctionBodySimple (Function& F, TargetData & TD) { std::vector toDelete; std::vector Returns; std::vector ToFree; - // Get the target data information - TargetData &TD = getAnalysis(); - // // Create a silly Function Info structure for this function. // From sabre at nondot.org Wed Apr 30 10:27:09 2008 From: sabre at nondot.org (Chris Lattner) Date: Wed, 30 Apr 2008 15:27:09 -0000 Subject: [llvm-commits] [llvm] r50483 - /llvm/trunk/lib/VMCore/Value.cpp Message-ID: <200804301527.m3UFR9DN020845@zion.cs.uiuc.edu> Author: lattner Date: Wed Apr 30 10:27:09 2008 New Revision: 50483 URL: http://llvm.org/viewvc/llvm-project?rev=50483&view=rev Log: fix a bug in my previous patch, a classic =/== bug. Modified: llvm/trunk/lib/VMCore/Value.cpp Modified: llvm/trunk/lib/VMCore/Value.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Value.cpp?rev=50483&r1=50482&r2=50483&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Value.cpp (original) +++ llvm/trunk/lib/VMCore/Value.cpp Wed Apr 30 10:27:09 2008 @@ -140,7 +140,7 @@ /// nul terminated string. bool Value::isName(const char *N) const { unsigned InLen = strlen(N); - return InLen = getNameLen() && memcmp(getNameStart(), N, InLen) == 0; + return InLen == getNameLen() && memcmp(getNameStart(), N, InLen) == 0; } From gohman at apple.com Wed Apr 30 10:31:31 2008 From: gohman at apple.com (Dan Gohman) Date: Wed, 30 Apr 2008 08:31:31 -0700 (PDT) Subject: [llvm-commits] atomic operator patch In-Reply-To: <504C1329-8389-4EEF-8A92-9A4DEE6520A5@apple.com> References: <74859BF3-9BE5-4418-8482-7AC4171E565B@apple.com> <504C1329-8389-4EEF-8A92-9A4DEE6520A5@apple.com> Message-ID: <58711.76.126.213.14.1209569491.squirrel@webmail.apple.com> Hi Mon Ping, Thanks for working on the atomic builtins. Below are some review comments. +// Expand atomics bitwise operation +// Op: node to expand, +// BitOpc: ISD::AND, ISD::OR, ISD::XOR +SDNode* X86TargetLowering::ExpandAtomicBitwise(SDNode* Op, SelectionDAG &DAG, + ISD::NodeType BitOpc) { + MVT::ValueType T = cast(Op)->getVT(); + assert (T == MVT::i32 && "Only know how to expand i32 Bitwise op"); + SDOperand ldOp = DAG.getLoad(T, Op->getOperand(0), Op->getOperand(1), + NULL, 0 , false); + SDOperand binOp = DAG.getNode(BitOpc, T, ldOp, Op->getOperand(2)); + return DAG.getAtomic(ISD::ATOMIC_SWAP, Op->getOperand(0), Op->getOperand(1), + binOp, T).Val; + +} This doesn't look atomic. Between the load and the swap another thread could modify the memory. + GCCBuiltin<"__sync_fetch_and_min">; + GCCBuiltin<"__sync_fetch_and_max">; + GCCBuiltin<"__sync_fetch_and_minu">; + GCCBuiltin<"__sync_fetch_and_maxu">; I didn't see these in the GCC 4.3 manual; are these new names? If so, can I suggest umin/umax (and maybe even smin/smax for the signed ones) for the names? It would be more consistent with other similar names in llvm (sdiv/udiv, slt/ult, etc.) + // Defines the capacity of the TargetLowering::OpActions table +#define OpActionsCapacity 173 Could you make this a static const, or an enum? As a macro, it doesn't live in the llvm namespace. + ATOMIC_LSS, + ATOMIC_LANDS, + ATOMIC_LORS, + ATOMIC_LXORS, + ATOMIC_LMINS, + ATOMIC_LMAXS, + ATOMIC_LMINUS, + ATOMIC_LMAXUS, This LS naming convention is getting a bit hairy. LMINUS in particular has the misfortune of looking like the word "minus". How about ATOMIC_LOAD_AND ATOMIC_LOAD_OR and so on? I know this is different from the existing atomics in LLVM, but I wouldn't object to renaming those too :-). Thanks, Dan On Tue, April 29, 2008 8:39 pm, Mon P Wang wrote: > > I have updated the patch because I forgot to delete some obsolete > functions as well as removed some unnecessary indentation changes. > > > > > > > On Apr 29, 2008, at 6:38 PM, Mon P Wang wrote: > >> Currently, llvm support add, swap, and the compare and swap. I >> want to add support for atomic support for sub, and, or, xor, min >> and max (the latter two in both signed and unsigned version) in X86 >> line. The intrinsic names are of the form >> __sync_fetch_and_[opname] like other sync intrinsics. If you have >> any issues or concerns, please let me know. >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From evan.cheng at apple.com Wed Apr 30 11:29:19 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 30 Apr 2008 09:29:19 -0700 Subject: [llvm-commits] atomic operator patch In-Reply-To: <58711.76.126.213.14.1209569491.squirrel@webmail.apple.com> References: <74859BF3-9BE5-4418-8482-7AC4171E565B@apple.com> <504C1329-8389-4EEF-8A92-9A4DEE6520A5@apple.com> <58711.76.126.213.14.1209569491.squirrel@webmail.apple.com> Message-ID: More comments: +SDOperand X86TargetLowering::LowerLSS(SDOperand Op, SelectionDAG &DAG) { + return SDOperand(ExpandATOMIC_LSS(Op.Val, DAG), 0); +} + +SDNode* X86TargetLowering::ExpandATOMIC_LSS(SDNode* Op, SelectionDAG &DAG) { + MVT::ValueType T = cast(Op)->getVT(); + assert (T == MVT::i32 && "Only know how to expand i32 LSS"); + SDOperand negOp = DAG.getNode(ISD::SUB, T, + DAG.getConstant(0, T), Op- >getOperand(2)); + return DAG.getAtomic(ISD::ATOMIC_LAS, Op->getOperand(0), + Op->getOperand(1), negOp, T).Val; +} It seems silly to have a LowerLSS which just call ExpandATOMiC_LSS. Please just mark ATOMIC_LSS as "Exapnd" instead of "Custom". Also, are you going to implement __sync_add_and_fetch, etc.? If so, I've attached a (not fully tested) patch for X86InstrInfo.td. You can incorporate it if you wish. Evan -------------- next part -------------- A non-text attachment was scrubbed... Name: op.atomic-add Type: application/octet-stream Size: 5745 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20080430/7c2b95ed/attachment.obj -------------- next part -------------- On Apr 30, 2008, at 8:31 AM, Dan Gohman wrote: > Hi Mon Ping, > > Thanks for working on the atomic builtins. Below are some > review comments. > > +// Expand atomics bitwise operation > +// Op: node to expand, > +// BitOpc: ISD::AND, ISD::OR, ISD::XOR > +SDNode* X86TargetLowering::ExpandAtomicBitwise(SDNode* Op, > SelectionDAG > &DAG, > + ISD::NodeType > BitOpc) { > + MVT::ValueType T = cast(Op)->getVT(); > + assert (T == MVT::i32 && "Only know how to expand i32 Bitwise op"); > + SDOperand ldOp = DAG.getLoad(T, Op->getOperand(0), Op- > >getOperand(1), > + NULL, 0 , false); > + SDOperand binOp = DAG.getNode(BitOpc, T, ldOp, Op->getOperand(2)); > + return DAG.getAtomic(ISD::ATOMIC_SWAP, Op->getOperand(0), > Op->getOperand(1), > + binOp, T).Val; > + > +} > > This doesn't look atomic. Between the load and the swap another > thread could modify the memory. > > + GCCBuiltin<"__sync_fetch_and_min">; > + GCCBuiltin<"__sync_fetch_and_max">; > + GCCBuiltin<"__sync_fetch_and_minu">; > + GCCBuiltin<"__sync_fetch_and_maxu">; > > I didn't see these in the GCC 4.3 manual; are these new names? > If so, can I suggest umin/umax (and maybe even smin/smax for > the signed ones) for the names? It would be more consistent > with other similar names in llvm (sdiv/udiv, slt/ult, etc.) > > + // Defines the capacity of the TargetLowering::OpActions table > +#define OpActionsCapacity 173 > > Could you make this a static const, or an enum? As a macro, it > doesn't live in the llvm namespace. > > + ATOMIC_LSS, > > + ATOMIC_LANDS, > + ATOMIC_LORS, > + ATOMIC_LXORS, > + ATOMIC_LMINS, > + ATOMIC_LMAXS, > + ATOMIC_LMINUS, > + ATOMIC_LMAXUS, > > This LS naming convention is getting a bit hairy. LMINUS in > particular has the misfortune of looking like the word "minus". > How about > ATOMIC_LOAD_AND > ATOMIC_LOAD_OR > and so on? I know this is different from the existing atomics in > LLVM, but I wouldn't object to renaming those too :-). > > Thanks, > > Dan > > On Tue, April 29, 2008 8:39 pm, Mon P Wang wrote: >> >> I have updated the patch because I forgot to delete some obsolete >> functions as well as removed some unnecessary indentation changes. >> >> >> >> >> >> >> On Apr 29, 2008, at 6:38 PM, Mon P Wang wrote: >> >>> Currently, llvm support add, swap, and the compare and swap. I >>> want to add support for atomic support for sub, and, or, xor, min >>> and max (the latter two in both signed and unsigned version) in X86 >>> line. The intrinsic names are of the form >>> __sync_fetch_and_[opname] like other sync intrinsics. If you have >>> any issues or concerns, please let me know. >>> >>> >>> _______________________________________________ >>> llvm-commits mailing list >>> llvm-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From sabre at nondot.org Wed Apr 30 12:00:56 2008 From: sabre at nondot.org (Chris Lattner) Date: Wed, 30 Apr 2008 17:00:56 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50487 - /llvm-gcc-4.2/trunk/gcc/objc/objc-act.c Message-ID: <200804301700.m3UH0uvX023628@zion.cs.uiuc.edu> Author: lattner Date: Wed Apr 30 12:00:56 2008 New Revision: 50487 URL: http://llvm.org/viewvc/llvm-project?rev=50487&view=rev Log: Fix gcc testsuite failures in objc.dg/objc-gc-1.m, introduced in this patch: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20080421/061374.html Modified: llvm-gcc-4.2/trunk/gcc/objc/objc-act.c Modified: llvm-gcc-4.2/trunk/gcc/objc/objc-act.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/objc/objc-act.c?rev=50487&r1=50486&r2=50487&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/objc/objc-act.c (original) +++ llvm-gcc-4.2/trunk/gcc/objc/objc-act.c Wed Apr 30 12:00:56 2008 @@ -6520,24 +6520,16 @@ In both of this cases, expr is preserved as ARRAY_REF. Normally, gcc would decomponse first example into a pointer arithmetic expression. - So in llvm mode, check expression's field type to ensure that this is really a - array reference or not. */ + So in llvm mode, check expression's field type to ensure that this is really + an array reference or not. */ static int objc_is_really_array_ref(tree expr) { - tree component = NULL_TREE; - tree field = NULL_TREE; + tree base = NULL_TREE; if (TREE_CODE(expr) != ARRAY_REF) return 0; - component = TREE_OPERAND(expr, 0); - if (!component || TREE_CODE(component) != COMPONENT_REF) - return 0; - - field = TREE_OPERAND(component, 1); - if (!field || TREE_CODE(TREE_TYPE(field)) != ARRAY_TYPE) - return 0; - - return 1; + base = TREE_OPERAND(expr, 0); + return base && TREE_CODE(TREE_TYPE(base)) == ARRAY_TYPE; } /* LLVM LOCAL - end pointer arithmetic */ From nicolas.geoffray at lip6.fr Wed Apr 30 12:17:36 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Wed, 30 Apr 2008 17:17:36 -0000 Subject: [llvm-commits] [vmkit] r50488 - in /vmkit/trunk: configure.ac lib/JnJVM/VMCore/Makefile.am Message-ID: <200804301717.m3UHHaoR024302@zion.cs.uiuc.edu> Author: geoffray Date: Wed Apr 30 12:17:36 2008 New Revision: 50488 URL: http://llvm.org/viewvc/llvm-project?rev=50488&view=rev Log: Build fix. Modified: vmkit/trunk/configure.ac vmkit/trunk/lib/JnJVM/VMCore/Makefile.am Modified: vmkit/trunk/configure.ac URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/configure.ac?rev=50488&r1=50487&r2=50488&view=diff ============================================================================== --- vmkit/trunk/configure.ac (original) +++ vmkit/trunk/configure.ac Wed Apr 30 12:17:36 2008 @@ -237,6 +237,8 @@ CXXFLAGS="$CXXFLAGS -DMULTIPLE_VM -DSERVICE_GC -DMULTIPLE_GC -DSERVICE_VM -I$PWD/lib/Mvm/Allocator" fi fi + +AM_CONDITIONAL([SERVICE_BUILD], [test "x$vmtype" = "xservice"]) dnl ************************************************************************** dnl GNU CLASSPATH version Modified: vmkit/trunk/lib/JnJVM/VMCore/Makefile.am URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Makefile.am?rev=50488&r1=50487&r2=50488&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/Makefile.am (original) +++ vmkit/trunk/lib/JnJVM/VMCore/Makefile.am Wed Apr 30 12:17:36 2008 @@ -13,6 +13,10 @@ JavaBacktrace.cpp NativeUtil.h NativeUtil.cpp Jni.cpp \ JavaCache.h JavaCache.cpp JavaUpcalls.h JavaUpcalls.cpp \ JnjvmModuleProvider.h JnjvmModuleProvider.cpp JavaRuntimeJIT.cpp JavaMetaJIT.cpp JavaJITInitialise.cpp \ - LowerArrayLength.cpp ServiceDomain.cpp + LowerArrayLength.cpp + +if SERVICE_BUILD +libJnJVM_la_SOURCES += ServiceDomain.cpp +endif libJnJVM_la_CXXFLAGS =-DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -g -Werror -O2 From monping at apple.com Wed Apr 30 12:11:07 2008 From: monping at apple.com (Mon P Wang) Date: Wed, 30 Apr 2008 10:11:07 -0700 Subject: [llvm-commits] atomic operator patch In-Reply-To: <58711.76.126.213.14.1209569491.squirrel@webmail.apple.com> References: <74859BF3-9BE5-4418-8482-7AC4171E565B@apple.com> <504C1329-8389-4EEF-8A92-9A4DEE6520A5@apple.com> <58711.76.126.213.14.1209569491.squirrel@webmail.apple.com> Message-ID: <0E08691A-3675-4FCF-88DD-50D9F534C1CF@apple.com> Hi Dan, You are right. There is an issue here. When I did it, I was only concern that the memory write is atomic. However as you pointed out, it doesn't prevent another process to read/write the memory location before the write occurs. The min/max don't exist in the GCC manual. Maybe I should avoiding indicating it is a generic gcc builtin. Changing to umin/umax is fine with me and ATOMIC_LOAD_[op] sounds good to me. I'll also change the #define to a const variable. Thanks for the comments, -- Mon Ping On Apr 30, 2008, at 8:31 AM, Dan Gohman wrote: > Hi Mon Ping, > > Thanks for working on the atomic builtins. Below are some > review comments. > > +// Expand atomics bitwise operation > +// Op: node to expand, > +// BitOpc: ISD::AND, ISD::OR, ISD::XOR > +SDNode* X86TargetLowering::ExpandAtomicBitwise(SDNode* Op, > SelectionDAG > &DAG, > + ISD::NodeType > BitOpc) { > + MVT::ValueType T = cast(Op)->getVT(); > + assert (T == MVT::i32 && "Only know how to expand i32 Bitwise op"); > + SDOperand ldOp = DAG.getLoad(T, Op->getOperand(0), Op- > >getOperand(1), > + NULL, 0 , false); > + SDOperand binOp = DAG.getNode(BitOpc, T, ldOp, Op->getOperand(2)); > + return DAG.getAtomic(ISD::ATOMIC_SWAP, Op->getOperand(0), > Op->getOperand(1), > + binOp, T).Val; > + > +} > > This doesn't look atomic. Between the load and the swap another > thread could modify the memory. > > + GCCBuiltin<"__sync_fetch_and_min">; > + GCCBuiltin<"__sync_fetch_and_max">; > + GCCBuiltin<"__sync_fetch_and_minu">; > + GCCBuiltin<"__sync_fetch_and_maxu">; > > I didn't see these in the GCC 4.3 manual; are these new names? > If so, can I suggest umin/umax (and maybe even smin/smax for > the signed ones) for the names? It would be more consistent > with other similar names in llvm (sdiv/udiv, slt/ult, etc.) > > + // Defines the capacity of the TargetLowering::OpActions table > +#define OpActionsCapacity 173 > > Could you make this a static const, or an enum? As a macro, it > doesn't live in the llvm namespace. > > + ATOMIC_LSS, > > + ATOMIC_LANDS, > + ATOMIC_LORS, > + ATOMIC_LXORS, > + ATOMIC_LMINS, > + ATOMIC_LMAXS, > + ATOMIC_LMINUS, > + ATOMIC_LMAXUS, > > This LS naming convention is getting a bit hairy. LMINUS in > particular has the misfortune of looking like the word "minus". > How about > ATOMIC_LOAD_AND > ATOMIC_LOAD_OR > and so on? I know this is different from the existing atomics in > LLVM, but I wouldn't object to renaming those too :-). > > Thanks, > > Dan > > On Tue, April 29, 2008 8:39 pm, Mon P Wang wrote: >> >> I have updated the patch because I forgot to delete some obsolete >> functions as well as removed some unnecessary indentation changes. >> >> >> >> >> >> >> On Apr 29, 2008, at 6:38 PM, Mon P Wang wrote: >> >>> Currently, llvm support add, swap, and the compare and swap. I >>> want to add support for atomic support for sub, and, or, xor, min >>> and max (the latter two in both signed and unsigned version) in X86 >>> line. The intrinsic names are of the form >>> __sync_fetch_and_[opname] like other sync intrinsics. If you have >>> any issues or concerns, please let me know. >>> >>> >>> _______________________________________________ >>> llvm-commits mailing list >>> llvm-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From monping at apple.com Wed Apr 30 12:15:36 2008 From: monping at apple.com (Mon P Wang) Date: Wed, 30 Apr 2008 10:15:36 -0700 Subject: [llvm-commits] atomic operator patch In-Reply-To: References: <74859BF3-9BE5-4418-8482-7AC4171E565B@apple.com> <504C1329-8389-4EEF-8A92-9A4DEE6520A5@apple.com> <58711.76.126.213.14.1209569491.squirrel@webmail.apple.com> Message-ID: <4905FE1F-5CFA-4FD6-909C-D52E5965FC17@apple.com> Hi Evan, I'll mark all the atomic operators that I added to expand. I wasn't planning on it adding the others syncs yet. Thanks, -- Mon Ping On Apr 30, 2008, at 9:29 AM, Evan Cheng wrote: > More comments: > > > +SDOperand X86TargetLowering::LowerLSS(SDOperand Op, SelectionDAG > &DAG) { > + return SDOperand(ExpandATOMIC_LSS(Op.Val, DAG), 0); > +} > + > +SDNode* X86TargetLowering::ExpandATOMIC_LSS(SDNode* Op, > SelectionDAG &DAG) { > + MVT::ValueType T = cast(Op)->getVT(); > + assert (T == MVT::i32 && "Only know how to expand i32 LSS"); > + SDOperand negOp = DAG.getNode(ISD::SUB, T, > + DAG.getConstant(0, T), Op- > >getOperand(2)); > + return DAG.getAtomic(ISD::ATOMIC_LAS, Op->getOperand(0), > + Op->getOperand(1), negOp, T).Val; > +} > > It seems silly to have a LowerLSS which just call ExpandATOMiC_LSS. > Please just mark ATOMIC_LSS as "Exapnd" instead of "Custom". > > Also, are you going to implement __sync_add_and_fetch, etc.? If so, > I've attached a (not fully tested) patch for X86InstrInfo.td. You > can incorporate it if you wish. > > Evan > > > > On Apr 30, 2008, at 8:31 AM, Dan Gohman wrote: > >> Hi Mon Ping, >> >> Thanks for working on the atomic builtins. Below are some >> review comments. >> >> +// Expand atomics bitwise operation >> +// Op: node to expand, >> +// BitOpc: ISD::AND, ISD::OR, ISD::XOR >> +SDNode* X86TargetLowering::ExpandAtomicBitwise(SDNode* Op, >> SelectionDAG >> &DAG, >> + ISD::NodeType >> BitOpc) { >> + MVT::ValueType T = cast(Op)->getVT(); >> + assert (T == MVT::i32 && "Only know how to expand i32 Bitwise >> op"); >> + SDOperand ldOp = DAG.getLoad(T, Op->getOperand(0), Op- >> >getOperand(1), >> + NULL, 0 , false); >> + SDOperand binOp = DAG.getNode(BitOpc, T, ldOp, Op->getOperand(2)); >> + return DAG.getAtomic(ISD::ATOMIC_SWAP, Op->getOperand(0), >> Op->getOperand(1), >> + binOp, T).Val; >> + >> +} >> >> This doesn't look atomic. Between the load and the swap another >> thread could modify the memory. >> >> + GCCBuiltin<"__sync_fetch_and_min">; >> + GCCBuiltin<"__sync_fetch_and_max">; >> + GCCBuiltin<"__sync_fetch_and_minu">; >> + GCCBuiltin<"__sync_fetch_and_maxu">; >> >> I didn't see these in the GCC 4.3 manual; are these new names? >> If so, can I suggest umin/umax (and maybe even smin/smax for >> the signed ones) for the names? It would be more consistent >> with other similar names in llvm (sdiv/udiv, slt/ult, etc.) >> >> + // Defines the capacity of the TargetLowering::OpActions table >> +#define OpActionsCapacity 173 >> >> Could you make this a static const, or an enum? As a macro, it >> doesn't live in the llvm namespace. >> >> + ATOMIC_LSS, >> >> + ATOMIC_LANDS, >> + ATOMIC_LORS, >> + ATOMIC_LXORS, >> + ATOMIC_LMINS, >> + ATOMIC_LMAXS, >> + ATOMIC_LMINUS, >> + ATOMIC_LMAXUS, >> >> This LS naming convention is getting a bit hairy. LMINUS in >> particular has the misfortune of looking like the word "minus". >> How about >> ATOMIC_LOAD_AND >> ATOMIC_LOAD_OR >> and so on? I know this is different from the existing atomics in >> LLVM, but I wouldn't object to renaming those too :-). >> >> Thanks, >> >> Dan >> >> On Tue, April 29, 2008 8:39 pm, Mon P Wang wrote: >>> >>> I have updated the patch because I forgot to delete some obsolete >>> functions as well as removed some unnecessary indentation changes. >>> >>> >>> >>> >>> >>> >>> On Apr 29, 2008, at 6:38 PM, Mon P Wang wrote: >>> >>>> Currently, llvm support add, swap, and the compare and swap. I >>>> want to add support for atomic support for sub, and, or, xor, min >>>> and max (the latter two in both signed and unsigned version) in X86 >>>> line. The intrinsic names are of the form >>>> __sync_fetch_and_[opname] like other sync intrinsics. If you have >>>> any issues or concerns, please let me know. >>>> >>>> >>>> _______________________________________________ >>>> llvm-commits mailing list >>>> llvm-commits at cs.uiuc.edu >>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >>> >>> _______________________________________________ >>> llvm-commits mailing list >>> llvm-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >>> >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From clattner at apple.com Wed Apr 30 12:47:00 2008 From: clattner at apple.com (Chris Lattner) Date: Wed, 30 Apr 2008 10:47:00 -0700 Subject: [llvm-commits] atomic operator patch In-Reply-To: <4905FE1F-5CFA-4FD6-909C-D52E5965FC17@apple.com> References: <74859BF3-9BE5-4418-8482-7AC4171E565B@apple.com> <504C1329-8389-4EEF-8A92-9A4DEE6520A5@apple.com> <58711.76.126.213.14.1209569491.squirrel@webmail.apple.com> <4905FE1F-5CFA-4FD6-909C-D52E5965FC17@apple.com> Message-ID: On Apr 30, 2008, at 10:15 AM, Mon P Wang wrote: > Hi Evan, > > I'll mark all the atomic operators that I added to expand. I wasn't > planning on it adding the others syncs yet. One handy thing you can do is to mark them as expand by default in the TargetLowering ctor. Then specific targets can mark them as legal or custom if they want to do something crazy with them. I don't know if that helps in this case, but it generally means you don't have to touch each target to tell them to expand. -Chris From dpatel at apple.com Wed Apr 30 12:57:25 2008 From: dpatel at apple.com (Devang Patel) Date: Wed, 30 Apr 2008 17:57:25 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50490 - in /llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple: 4474259.c 5490617.c const-cfstring-3.c dwarf-files.c dwarf-inlining.c dwarf-optimized-1.c dwarf-optimized-3.c Message-ID: <200804301757.m3UHvPbC025444@zion.cs.uiuc.edu> Author: dpatel Date: Wed Apr 30 12:57:24 2008 New Revision: 50490 URL: http://llvm.org/viewvc/llvm-project?rev=50490&view=rev Log: testsuite cleanup for LLVM. Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/4474259.c llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/5490617.c llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/const-cfstring-3.c llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/dwarf-files.c llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/dwarf-inlining.c llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/dwarf-optimized-1.c llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/dwarf-optimized-3.c Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/4474259.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/4474259.c?rev=50490&r1=50489&r2=50490&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/4474259.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/4474259.c Wed Apr 30 12:57:24 2008 @@ -1,6 +1,8 @@ /* APPLE LOCAL file 4474259 */ /* { dg-do run { target i*86-*-darwin* } } */ /* { dg-options "-fasm-blocks -O2" } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ /* Insure the compiler output is acceptable to the assembler. */ t1() { Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/5490617.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/5490617.c?rev=50490&r1=50489&r2=50490&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/5490617.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/5490617.c Wed Apr 30 12:57:24 2008 @@ -2,5 +2,5 @@ /* { dg-do compile } */ static char _my_endbss[1]; char *my_endbss_static = _my_endbss; - -/* { dg-final { scan-assembler ".lcomm __my_endbss" } } */ +/* LLVM LOCAL */ +/* { dg-final { scan-assembler ".lcomm\t__my_endbss" } } */ Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/const-cfstring-3.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/const-cfstring-3.c?rev=50490&r1=50489&r2=50490&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/const-cfstring-3.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/const-cfstring-3.c Wed Apr 30 12:57:24 2008 @@ -25,6 +25,7 @@ s0 = s1; } - -/* { dg-final { scan-assembler "\\.long\[ \\t\]+___CFConstantStringClassReference\n\[ \\t\]*\\.long\[ \\t\]+1992\n\[ \\t\]*\\.long\[ \\t\]+LC.*\n\[ \\t\]*\\.long\[ \\t\]+4\n" } } */ -/* { dg-final { scan-assembler "\\.long\[ \\t\]+___CFConstantStringClassReference\n\[ \\t\]*\\.long\[ \\t\]+1992\n\[ \\t\]*\\.long\[ \\t\]+LC.*\n\[ \\t\]*\\.long\[ \\t\]+10\n" } } */ +/* LLVM LOCAL begin */ +/* { dg-final { scan-assembler "\\.long\[ \\t\]+___CFConstantStringClassReference\n\[ \\t\]*\\.long\[ \\t\]+1992\n\[ \\t\]*\\.long\[ \\t\]+_.str1\n\[ \\t\]*\\.long\[ \\t\]+4\n" } } */ +/* { dg-final { scan-assembler "\\.long\[ \\t\]+___CFConstantStringClassReference\n\[ \\t\]*\\.long\[ \\t\]+1992\n\[ \\t\]*\\.long\[ \\t\]+_.str\n\[ \\t\]*\\.long\[ \\t\]+10\n" } } */ +/* LLVM LOCAL end */ Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/dwarf-files.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/dwarf-files.c?rev=50490&r1=50489&r2=50490&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/dwarf-files.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/dwarf-files.c Wed Apr 30 12:57:24 2008 @@ -3,6 +3,8 @@ /* { dg-do compile } */ /* { dg-options "-c -g -fasm-blocks" } */ /* { dg-final { scan-assembler-times "dwarf-files.c" 2 } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ asm(".globl _x\n" "_x:\n" "pushl %ebp\n"); Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/dwarf-inlining.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/dwarf-inlining.c?rev=50490&r1=50489&r2=50490&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/dwarf-inlining.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/dwarf-inlining.c Wed Apr 30 12:57:24 2008 @@ -3,6 +3,8 @@ /* { dg-options "-O3 -gdwarf-2 -dA" } */ /* { dg-skip-if "Unmatchable assembly" { mmix-*-* } { "*" } { "" } } */ /* { dg-final { scan-assembler "\[#@;!/|\]+\[ \t\]+DW_AT_call_line" } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ #include #include Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/dwarf-optimized-1.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/dwarf-optimized-1.c?rev=50490&r1=50489&r2=50490&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/dwarf-optimized-1.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/dwarf-optimized-1.c Wed Apr 30 12:57:24 2008 @@ -3,6 +3,8 @@ /* { dg-options "-O3 -gdwarf-2 -dA" } */ /* { dg-skip-if "Unmatchable assembly" { mmix-*-* } { "*" } { "" } } */ /* { dg-final { scan-assembler "DW_AT_APPLE_optimized" } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ #include #include Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/dwarf-optimized-3.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/dwarf-optimized-3.c?rev=50490&r1=50489&r2=50490&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/dwarf-optimized-3.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/testsuite/gcc.apple/dwarf-optimized-3.c Wed Apr 30 12:57:24 2008 @@ -3,6 +3,8 @@ /* { dg-options "-O0 -gdwarf-2 -dA" } */ /* { dg-skip-if "Unmatchable assembly" { mmix-*-* } { "*" } { "" } } */ /* { dg-final { scan-assembler "DW_AT_APPLE_optimized" } } */ +/* LLVM LOCAL disable test */ +/* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ #include #include From isanbard at gmail.com Wed Apr 30 12:57:34 2008 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 30 Apr 2008 10:57:34 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r50487 - /llvm-gcc-4.2/trunk/gcc/objc/objc-act.c In-Reply-To: <200804301700.m3UH0uvX023628@zion.cs.uiuc.edu> References: <200804301700.m3UH0uvX023628@zion.cs.uiuc.edu> Message-ID: <16e5fdf90804301057r688cfadanab7fd7ae4a83a9f8@mail.gmail.com> On Wed, Apr 30, 2008 at 10:00 AM, Chris Lattner wrote: > Author: lattner > Date: Wed Apr 30 12:00:56 2008 > New Revision: 50487 > > URL: http://llvm.org/viewvc/llvm-project?rev=50487&view=rev > Log: > Fix gcc testsuite failures in objc.dg/objc-gc-1.m, introduced in this patch: > http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20080421/061374.html > Oops. Thanks for fixing this! Sorry about the breakage. -bw From evan.cheng at apple.com Wed Apr 30 14:18:08 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 30 Apr 2008 19:18:08 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50491 - in /llvm-gcc-4.2/trunk/gcc: config/i386/llvm-i386-target.h config/i386/llvm-i386.cpp llvm-abi.h llvm-convert.cpp llvm-types.cpp Message-ID: <200804301918.m3UJI88C027968@zion.cs.uiuc.edu> Author: evancheng Date: Wed Apr 30 14:18:07 2008 New Revision: 50491 URL: http://llvm.org/viewvc/llvm-project?rev=50491&view=rev Log: x86-64 abi specifies small aggregates can be broken up and passed in registers. However, this is only true when there are enough argument registers to pass the whole aggregate in registers. Keep track of the number of scalar parameter registers used so far. If there are only enough registers to "partially" satisfy the requirement, pass the aggregate byval in memory instead. Note, if there are no argument registers left at all, then treat it as if it's being passed in registers and left codegen do the right thing. Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp llvm-gcc-4.2/trunk/gcc/llvm-abi.h llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h?rev=50491&r1=50490&r2=50491&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h Wed Apr 30 14:18:07 2008 @@ -164,10 +164,20 @@ llvm_x86_32_should_pass_aggregate_in_mixed_regs(tree, const Type *Ty, std::vector&); -#define LLVM_SHOULD_PASS_AGGREGATE_IN_MIXED_REGS(T, TY, E) \ - (TARGET_64BIT ? \ - llvm_x86_64_should_pass_aggregate_in_mixed_regs((T), (TY), (E)) : \ +#define LLVM_SHOULD_PASS_AGGREGATE_IN_MIXED_REGS(T, TY, E) \ + (TARGET_64BIT ? \ + llvm_x86_64_should_pass_aggregate_in_mixed_regs((T), (TY), (E)) : \ llvm_x86_32_should_pass_aggregate_in_mixed_regs((T), (TY), (E))) + +extern +bool llvm_x86_64_aggregate_partially_passed_in_regs(std::vector&, + std::vector&); + +#define LLVM_AGGREGATE_PARTIALLY_PASSED_IN_REGS(E, SE) \ + (TARGET_64BIT ? \ + llvm_x86_64_aggregate_partially_passed_in_regs((E), (SE)) : \ + false) + #endif /* LLVM_ABI_H */ /* LLVM LOCAL end (ENTIRE FILE!) */ Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp?rev=50491&r1=50490&r2=50491&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Wed Apr 30 14:18:07 2008 @@ -744,6 +744,82 @@ return llvm_x86_64_should_pass_aggregate_in_memory(TreeType, Mode); } +/* count_num_registers_uses - Return the number of GPRs and XMMs parameter + register used so far. */ +static void count_num_registers_uses(std::vector &ScalarElts, + unsigned &NumGPRs, unsigned &NumXMMs) { + NumGPRs = 0; + NumXMMs = 0; + for (unsigned i = 0, e = ScalarElts.size(); i != e; ++i) { + const Type *Ty = ScalarElts[i]; + if (const VectorType *VTy = dyn_cast(Ty)) { + if (!TARGET_MACHO) + continue; + if (VTy->getNumElements() == 1) + // v1i64 is passed in GPRs on Darwin. + ++NumGPRs; + else + // All other vector scalar values are passed in XMM registers. + ++NumXMMs; + } else if (Ty->isInteger() || isa(Ty)) { + ++NumGPRs; + } else { + // Floating point scalar argument. + assert(Ty->isFloatingPoint() && Ty->isPrimitiveType() && + "Expecting a floating point primitive type!"); + if (Ty->getTypeID() == Type::FloatTyID + || Ty->getTypeID() == Type::DoubleTyID) + ++NumXMMs; + } + } +} + +/* Target hook for llvm-abi.h. This is called when an aggregate is being passed + in registers. If there are only enough available parameter registers to pass + part of the aggregate, return true. That means the aggregate should instead + be passed in memory. */ +bool +llvm_x86_64_aggregate_partially_passed_in_regs(std::vector &Elts, + std::vector &ScalarElts) { + // Counting number of GPRs and XMMs used so far. According to AMD64 ABI + // document: "If there are no registers available for any eightbyte of an + // argument, the whole argument is passed on the stack." X86-64 uses 6 + // integer + // For example, if two GPRs are required but only one is available, then + // both parts will be in memory. + // FIXME: This is a temporary solution. To be removed when llvm has first + // class aggregate values. + unsigned NumGPRs = 0; + unsigned NumXMMs = 0; + count_num_registers_uses(ScalarElts, NumGPRs, NumXMMs); + + unsigned NumGPRsNeeded = 0; + unsigned NumXMMsNeeded = 0; + count_num_registers_uses(Elts, NumGPRsNeeded, NumXMMsNeeded); + + bool GPRsSatisfied = true; + if (NumGPRsNeeded) { + if (NumGPRs < 6) { + if ((NumGPRs + NumGPRsNeeded) > 6) + // Only partially satisfied. + return true; + } else + GPRsSatisfied = false; + } + + bool XMMsSatisfied = true; + if (NumXMMsNeeded) { + if (NumXMMs < 8) { + if ((NumXMMs + NumXMMsNeeded) > 8) + // Only partially satisfied. + return true; + } else + XMMsSatisfied = false; + } + + return !GPRsSatisfied || !XMMsSatisfied; +} + /* Target hook for llvm-abi.h. It returns true if an aggregate of the specified type should be passed in a number of registers of mixed types. It also returns a vector of types that correspond to the registers used @@ -792,17 +868,19 @@ Ty = STy->getElementType(0); if (const VectorType *VTy = dyn_cast(Ty)) { if (VTy->getNumElements() == 2) { - if (VTy->getElementType()->isInteger()) + if (VTy->getElementType()->isInteger()) { Elts.push_back(VectorType::get(Type::Int64Ty, 2)); - else + } else { Elts.push_back(VectorType::get(Type::DoubleTy, 2)); + } Bytes -= 8; } else { assert(VTy->getNumElements() == 4); - if (VTy->getElementType()->isInteger()) + if (VTy->getElementType()->isInteger()) { Elts.push_back(VectorType::get(Type::Int32Ty, 4)); - else + } else { Elts.push_back(VectorType::get(Type::FloatTy, 4)); + } Bytes -= 4; } } else if (llvm_x86_is_all_integer_types(Ty)) { @@ -850,6 +928,7 @@ default: assert(0 && "Unexpected register class!"); } } + return true; } Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi.h?rev=50491&r1=50490&r2=50491&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-abi.h (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-abi.h Wed Apr 30 14:18:07 2008 @@ -247,6 +247,16 @@ false #endif +// LLVM_AGGREGATE_PARTIALLY_PASSED_IN_REGS - Only called if +// LLVM_SHOULD_PASS_AGGREGATE_IN_MIXED_REGS returns true. This returns true if +// there are only enough unused argument passing registers to pass a part of +// the aggregate. Note, this routine should return false if none of the needed +// registers are available. +#ifndef LLVM_AGGREGATE_PARTIALLY_PASSED_IN_REGS +#define LLVM_AGGREGATE_PARTIALLY_PASSED_IN_REGS(E, SE) \ + false +#endif + // LLVM_BYVAL_ALIGNMENT - Returns the alignment of the type in bytes, if known, // in the context of its use as a function parameter. // Note that the alignment in the TYPE node is usually the alignment appropriate @@ -387,23 +397,37 @@ /// argument and invokes methods on the client that indicate how its pieces /// should be handled. This handles things like decimating structures into /// their fields. - void HandleArgument(tree type, ParameterAttributes *Attributes = NULL) { + void HandleArgument(tree type, std::vector &ScalarElts, + ParameterAttributes *Attributes = NULL) { const Type *Ty = ConvertType(type); // Figure out if this field is zero bits wide, e.g. {} or [0 x int]. Do // not include variable sized fields here. std::vector Elts; if (isPassedByInvisibleReference(type)) { // variable size -> by-ref. - C.HandleByInvisibleReferenceArgument(PointerType::getUnqual(Ty), type); + const Type *PtrTy = PointerType::getUnqual(Ty); + C.HandleByInvisibleReferenceArgument(PtrTy, type); + ScalarElts.push_back(PtrTy); } else if (Ty->getTypeID()==Type::VectorTyID) { if (LLVM_SHOULD_PASS_VECTOR_IN_INTEGER_REGS(type)) { - PassInIntegerRegisters(type, Ty); + PassInIntegerRegisters(type, Ty, ScalarElts); } else { C.HandleScalarArgument(Ty, type); + ScalarElts.push_back(Ty); } } else if (Ty->isFirstClassType()) { C.HandleScalarArgument(Ty, type); + ScalarElts.push_back(Ty); } else if (LLVM_SHOULD_PASS_AGGREGATE_IN_MIXED_REGS(type, Ty, Elts)) { - PassInMixedRegisters(type, Ty, Elts); + if (!LLVM_AGGREGATE_PARTIALLY_PASSED_IN_REGS(Elts, ScalarElts)) + PassInMixedRegisters(type, Ty, Elts, ScalarElts); + else { + C.HandleByValArgument(Ty, type); + if (Attributes) { + *Attributes |= ParamAttr::ByVal; + *Attributes |= + ParamAttr::constructAlignmentFromInt(LLVM_BYVAL_ALIGNMENT(type)); + } + } } else if (LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(type, Ty)) { C.HandleByValArgument(Ty, type); if (Attributes) { @@ -412,7 +436,7 @@ ParamAttr::constructAlignmentFromInt(LLVM_BYVAL_ALIGNMENT(type)); } } else if (LLVM_SHOULD_PASS_AGGREGATE_IN_INTEGER_REGS(type)) { - PassInIntegerRegisters(type, Ty); + PassInIntegerRegisters(type, Ty, ScalarElts); } else if (isZeroSizedStructOrUnion(type)) { // Zero sized struct or union, just drop it! ; @@ -423,24 +447,24 @@ assert(FNo != ~0U && "Case not handled yet!"); C.EnterField(FNo, Ty); - HandleArgument(getDeclaredType(Field)); + HandleArgument(getDeclaredType(Field), ScalarElts); C.ExitField(); } } else if (TREE_CODE(type) == COMPLEX_TYPE) { C.EnterField(0, Ty); - HandleArgument(TREE_TYPE(type)); + HandleArgument(TREE_TYPE(type), ScalarElts); C.ExitField(); C.EnterField(1, Ty); - HandleArgument(TREE_TYPE(type)); + HandleArgument(TREE_TYPE(type), ScalarElts); C.ExitField(); } else if ((TREE_CODE(type) == UNION_TYPE) || (TREE_CODE(type) == QUAL_UNION_TYPE)) { - HandleUnion(type); + HandleUnion(type, ScalarElts); } else if (TREE_CODE(type) == ARRAY_TYPE) { const ArrayType *ATy = cast(Ty); for (unsigned i = 0, e = ATy->getNumElements(); i != e; ++i) { C.EnterField(i, Ty); - HandleArgument(TREE_TYPE(type)); + HandleArgument(TREE_TYPE(type), ScalarElts); C.ExitField(); } } else { @@ -451,7 +475,7 @@ /// HandleUnion - Handle a UNION_TYPE or QUAL_UNION_TYPE tree. /// - void HandleUnion(tree type) { + void HandleUnion(tree type, std::vector &ScalarElts) { if (TYPE_TRANSPARENT_UNION(type)) { tree Field = TYPE_FIELDS(type); assert(Field && "Transparent union must have some elements!"); @@ -460,7 +484,7 @@ assert(Field && "Transparent union must have some elements!"); } - HandleArgument(TREE_TYPE(Field)); + HandleArgument(TREE_TYPE(Field), ScalarElts); } else { // Unions pass the largest element. unsigned MaxSize = 0; @@ -487,14 +511,15 @@ } if (MaxElt) - HandleArgument(TREE_TYPE(MaxElt)); + HandleArgument(TREE_TYPE(MaxElt), ScalarElts); } } /// PassInIntegerRegisters - Given an aggregate value that should be passed in /// integer registers, convert it to a structure containing ints and pass all /// of the struct elements in. - void PassInIntegerRegisters(tree type, const Type *Ty) { + void PassInIntegerRegisters(tree type, const Type *Ty, + std::vector &ScalarElts) { unsigned Size = TREE_INT_CST_LOW(TYPE_SIZE(type))/8; // FIXME: We should preserve all aggregate value alignment information. @@ -543,6 +568,7 @@ for (unsigned j = 0; j < ArraySize; ++j) { C.EnterField(j, ATy); C.HandleScalarArgument(ArrayElementType, 0); + ScalarElts.push_back(ArrayElementType); C.ExitField(); } C.ExitField(); @@ -551,6 +577,7 @@ for (unsigned e = Elts.size(); i != e; ++i) { C.EnterField(i, STy); C.HandleScalarArgument(Elts[i], 0); + ScalarElts.push_back(Elts[i]); C.ExitField(); } } @@ -559,11 +586,13 @@ /// mixed integer, floating point, and vector registers, convert it to a /// structure containing the specified struct elements in. void PassInMixedRegisters(tree type, const Type *Ty, - std::vector &Elts) { + std::vector &Elts, + std::vector &ScalarElts) { const StructType *STy = StructType::get(Elts, false); for (unsigned i = 0, e = Elts.size(); i != e; ++i) { C.EnterField(i, STy); C.HandleScalarArgument(Elts[i], 0); + ScalarElts.push_back(Elts[i]); C.ExitField(); } } Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=50491&r1=50490&r2=50491&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Wed Apr 30 14:18:07 2008 @@ -498,7 +498,7 @@ AI->setName(NameStack.back()); ++AI; } - + void HandleByValArgument(const llvm::Type *LLVMTy, tree type) { // Should not get here. abort(); @@ -521,6 +521,22 @@ }; } +// isPassedByVal - Return true if an aggregate of the specified type will be +// passed in memory byval. +static bool isPassedByVal(tree type, const Type *Ty, + std::vector &ScalarArgs) { + if (LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(type, Ty)) + return true; + + std::vector Args; + if (LLVM_SHOULD_PASS_AGGREGATE_IN_MIXED_REGS(type, Ty, Args) && + LLVM_AGGREGATE_PARTIALLY_PASSED_IN_REGS(Args, ScalarArgs)) + // We want to pass the whole aggregate in registers but only some of the + // registers are available. + return true; + return false; +} + void TreeToLLVM::StartFunctionBody() { const char *Name = ""; // Get the name of the function. @@ -668,6 +684,8 @@ // Prepend the static chain (if any) to the list of arguments. tree Args = static_chain ? static_chain : DECL_ARGUMENTS(FnDecl); + // Scalar arguments processed so far. + std::vector ScalarArgs; while (Args) { const char *Name = "unnamed_arg"; if (DECL_NAME(Args)) Name = IDENTIFIER_POINTER(DECL_NAME(Args)); @@ -676,7 +694,7 @@ bool isInvRef = isPassedByInvisibleReference(TREE_TYPE(Args)); if (isInvRef || (!ArgTy->isFirstClassType() && - LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(TREE_TYPE(Args), ArgTy))) { + isPassedByVal(TREE_TYPE(Args), ArgTy, ScalarArgs))) { // If the value is passed by 'invisible reference' or 'byval reference', // the l-value for the argument IS the argument itself. AI->setName(Name); @@ -710,7 +728,7 @@ Client.setName(Name); Client.setLocation(Tmp); - ABIConverter.HandleArgument(TREE_TYPE(Args)); + ABIConverter.HandleArgument(TREE_TYPE(Args), ScalarArgs); Client.clear(); } @@ -2469,7 +2487,7 @@ // Perform any implicit type conversions. if (CallOperands.size() < FTy->getNumParams()) { - const Type *CalledTy = FTy->getParamType(CallOperands.size()); + const Type *CalledTy= FTy->getParamType(CallOperands.size()); if (Loc->getType() != CalledTy) { assert(type && "Inconsistent parameter types?"); bool isSigned = !TYPE_UNSIGNED(type); @@ -2581,6 +2599,7 @@ CallOperands.push_back(Emit(TREE_OPERAND(exp, 2), 0)); // Loop over the arguments, expanding them and adding them to the op list. + std::vector ScalarArgs; for (tree arg = TREE_OPERAND(exp, 1); arg; arg = TREE_CHAIN(arg)) { const Type *ArgTy = ConvertType(TREE_TYPE(TREE_VALUE(arg))); @@ -2596,7 +2615,8 @@ } ParameterAttributes Attributes = ParamAttr::None; - ABIConverter.HandleArgument(TREE_TYPE(TREE_VALUE(arg)), &Attributes); + ABIConverter.HandleArgument(TREE_TYPE(TREE_VALUE(arg)), ScalarArgs, + &Attributes); if (Attributes != ParamAttr::None) PAL = PAL.addAttr(CallOperands.size(), Attributes); Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=50491&r1=50490&r2=50491&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Wed Apr 30 14:18:07 2008 @@ -1068,9 +1068,10 @@ Attrs.push_back(ParamAttrsWithIndex::get(ArgTys.size(), ParamAttr::StructRet | ParamAttr::NoAlias)); + std::vector ScalarArgs; if (static_chain) { // Pass the static chain as the first parameter. - ABIConverter.HandleArgument(TREE_TYPE(static_chain)); + ABIConverter.HandleArgument(TREE_TYPE(static_chain), ScalarArgs); // Mark it as the chain argument. Attrs.push_back(ParamAttrsWithIndex::get(ArgTys.size(), ParamAttr::Nest)); @@ -1082,7 +1083,7 @@ // Determine if there are any attributes for this param. ParameterAttributes Attributes = ParamAttr::None; - ABIConverter.HandleArgument(ArgTy, &Attributes); + ABIConverter.HandleArgument(ArgTy, ScalarArgs, &Attributes); // Compute zext/sext attributes. Attributes |= HandleArgumentExtension(ArgTy); @@ -1165,9 +1166,10 @@ Attrs.push_back(ParamAttrsWithIndex::get(ArgTypes.size(), ParamAttr::StructRet | ParamAttr::NoAlias)); + std::vector ScalarArgs; if (static_chain) { // Pass the static chain as the first parameter. - ABIConverter.HandleArgument(TREE_TYPE(static_chain)); + ABIConverter.HandleArgument(TREE_TYPE(static_chain), ScalarArgs); // Mark it as the chain argument. Attrs.push_back(ParamAttrsWithIndex::get(ArgTypes.size(), ParamAttr::Nest)); @@ -1207,7 +1209,7 @@ // Determine if there are any attributes for this param. ParameterAttributes Attributes = ParamAttr::None; - ABIConverter.HandleArgument(ArgTy, &Attributes); + ABIConverter.HandleArgument(ArgTy, ScalarArgs, &Attributes); // Compute zext/sext attributes. Attributes |= HandleArgumentExtension(ArgTy); From isanbard at gmail.com Wed Apr 30 14:50:27 2008 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 30 Apr 2008 19:50:27 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50492 - in /llvm-gcc-4.2/branches/Apple/Tak/gcc: config/i386/llvm-i386-target.h config/i386/llvm-i386.cpp llvm-abi.h llvm-convert.cpp llvm-types.cpp Message-ID: <200804301950.m3UJoRsb028935@zion.cs.uiuc.edu> Author: void Date: Wed Apr 30 14:50:27 2008 New Revision: 50492 URL: http://llvm.org/viewvc/llvm-project?rev=50492&view=rev Log: Porting r50491 to Tak. Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386-target.h llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386.cpp llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-abi.h llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-convert.cpp llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-types.cpp Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386-target.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386-target.h?rev=50492&r1=50491&r2=50492&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386-target.h (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386-target.h Wed Apr 30 14:50:27 2008 @@ -164,10 +164,20 @@ llvm_x86_32_should_pass_aggregate_in_mixed_regs(tree, const Type *Ty, std::vector&); -#define LLVM_SHOULD_PASS_AGGREGATE_IN_MIXED_REGS(T, TY, E) \ - (TARGET_64BIT ? \ - llvm_x86_64_should_pass_aggregate_in_mixed_regs((T), (TY), (E)) : \ +#define LLVM_SHOULD_PASS_AGGREGATE_IN_MIXED_REGS(T, TY, E) \ + (TARGET_64BIT ? \ + llvm_x86_64_should_pass_aggregate_in_mixed_regs((T), (TY), (E)) : \ llvm_x86_32_should_pass_aggregate_in_mixed_regs((T), (TY), (E))) + +extern +bool llvm_x86_64_aggregate_partially_passed_in_regs(std::vector&, + std::vector&); + +#define LLVM_AGGREGATE_PARTIALLY_PASSED_IN_REGS(E, SE) \ + (TARGET_64BIT ? \ + llvm_x86_64_aggregate_partially_passed_in_regs((E), (SE)) : \ + false) + #endif /* LLVM_ABI_H */ /* LLVM LOCAL end (ENTIRE FILE!) */ Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386.cpp?rev=50492&r1=50491&r2=50492&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386.cpp (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386.cpp Wed Apr 30 14:50:27 2008 @@ -744,6 +744,82 @@ return llvm_x86_64_should_pass_aggregate_in_memory(TreeType, Mode); } +/* count_num_registers_uses - Return the number of GPRs and XMMs parameter + register used so far. */ +static void count_num_registers_uses(std::vector &ScalarElts, + unsigned &NumGPRs, unsigned &NumXMMs) { + NumGPRs = 0; + NumXMMs = 0; + for (unsigned i = 0, e = ScalarElts.size(); i != e; ++i) { + const Type *Ty = ScalarElts[i]; + if (const VectorType *VTy = dyn_cast(Ty)) { + if (!TARGET_MACHO) + continue; + if (VTy->getNumElements() == 1) + // v1i64 is passed in GPRs on Darwin. + ++NumGPRs; + else + // All other vector scalar values are passed in XMM registers. + ++NumXMMs; + } else if (Ty->isInteger() || isa(Ty)) { + ++NumGPRs; + } else { + // Floating point scalar argument. + assert(Ty->isFloatingPoint() && Ty->isPrimitiveType() && + "Expecting a floating point primitive type!"); + if (Ty->getTypeID() == Type::FloatTyID + || Ty->getTypeID() == Type::DoubleTyID) + ++NumXMMs; + } + } +} + +/* Target hook for llvm-abi.h. This is called when an aggregate is being passed + in registers. If there are only enough available parameter registers to pass + part of the aggregate, return true. That means the aggregate should instead + be passed in memory. */ +bool +llvm_x86_64_aggregate_partially_passed_in_regs(std::vector &Elts, + std::vector &ScalarElts) { + // Counting number of GPRs and XMMs used so far. According to AMD64 ABI + // document: "If there are no registers available for any eightbyte of an + // argument, the whole argument is passed on the stack." X86-64 uses 6 + // integer + // For example, if two GPRs are required but only one is available, then + // both parts will be in memory. + // FIXME: This is a temporary solution. To be removed when llvm has first + // class aggregate values. + unsigned NumGPRs = 0; + unsigned NumXMMs = 0; + count_num_registers_uses(ScalarElts, NumGPRs, NumXMMs); + + unsigned NumGPRsNeeded = 0; + unsigned NumXMMsNeeded = 0; + count_num_registers_uses(Elts, NumGPRsNeeded, NumXMMsNeeded); + + bool GPRsSatisfied = true; + if (NumGPRsNeeded) { + if (NumGPRs < 6) { + if ((NumGPRs + NumGPRsNeeded) > 6) + // Only partially satisfied. + return true; + } else + GPRsSatisfied = false; + } + + bool XMMsSatisfied = true; + if (NumXMMsNeeded) { + if (NumXMMs < 8) { + if ((NumXMMs + NumXMMsNeeded) > 8) + // Only partially satisfied. + return true; + } else + XMMsSatisfied = false; + } + + return !GPRsSatisfied || !XMMsSatisfied; +} + /* Target hook for llvm-abi.h. It returns true if an aggregate of the specified type should be passed in a number of registers of mixed types. It also returns a vector of types that correspond to the registers used @@ -792,17 +868,19 @@ Ty = STy->getElementType(0); if (const VectorType *VTy = dyn_cast(Ty)) { if (VTy->getNumElements() == 2) { - if (VTy->getElementType()->isInteger()) + if (VTy->getElementType()->isInteger()) { Elts.push_back(VectorType::get(Type::Int64Ty, 2)); - else + } else { Elts.push_back(VectorType::get(Type::DoubleTy, 2)); + } Bytes -= 8; } else { assert(VTy->getNumElements() == 4); - if (VTy->getElementType()->isInteger()) + if (VTy->getElementType()->isInteger()) { Elts.push_back(VectorType::get(Type::Int32Ty, 4)); - else + } else { Elts.push_back(VectorType::get(Type::FloatTy, 4)); + } Bytes -= 4; } } else if (llvm_x86_is_all_integer_types(Ty)) { @@ -850,6 +928,7 @@ default: assert(0 && "Unexpected register class!"); } } + return true; } Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-abi.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-abi.h?rev=50492&r1=50491&r2=50492&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-abi.h (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-abi.h Wed Apr 30 14:50:27 2008 @@ -247,6 +247,16 @@ false #endif +// LLVM_AGGREGATE_PARTIALLY_PASSED_IN_REGS - Only called if +// LLVM_SHOULD_PASS_AGGREGATE_IN_MIXED_REGS returns true. This returns true if +// there are only enough unused argument passing registers to pass a part of +// the aggregate. Note, this routine should return false if none of the needed +// registers are available. +#ifndef LLVM_AGGREGATE_PARTIALLY_PASSED_IN_REGS +#define LLVM_AGGREGATE_PARTIALLY_PASSED_IN_REGS(E, SE) \ + false +#endif + // LLVM_BYVAL_ALIGNMENT - Returns the alignment of the type in bytes, if known, // in the context of its use as a function parameter. // Note that the alignment in the TYPE node is usually the alignment appropriate @@ -387,23 +397,37 @@ /// argument and invokes methods on the client that indicate how its pieces /// should be handled. This handles things like decimating structures into /// their fields. - void HandleArgument(tree type, ParameterAttributes *Attributes = NULL) { + void HandleArgument(tree type, std::vector &ScalarElts, + ParameterAttributes *Attributes = NULL) { const Type *Ty = ConvertType(type); // Figure out if this field is zero bits wide, e.g. {} or [0 x int]. Do // not include variable sized fields here. std::vector Elts; if (isPassedByInvisibleReference(type)) { // variable size -> by-ref. - C.HandleByInvisibleReferenceArgument(PointerType::getUnqual(Ty), type); + const Type *PtrTy = PointerType::getUnqual(Ty); + C.HandleByInvisibleReferenceArgument(PtrTy, type); + ScalarElts.push_back(PtrTy); } else if (Ty->getTypeID()==Type::VectorTyID) { if (LLVM_SHOULD_PASS_VECTOR_IN_INTEGER_REGS(type)) { - PassInIntegerRegisters(type, Ty); + PassInIntegerRegisters(type, Ty, ScalarElts); } else { C.HandleScalarArgument(Ty, type); + ScalarElts.push_back(Ty); } } else if (Ty->isFirstClassType()) { C.HandleScalarArgument(Ty, type); + ScalarElts.push_back(Ty); } else if (LLVM_SHOULD_PASS_AGGREGATE_IN_MIXED_REGS(type, Ty, Elts)) { - PassInMixedRegisters(type, Ty, Elts); + if (!LLVM_AGGREGATE_PARTIALLY_PASSED_IN_REGS(Elts, ScalarElts)) + PassInMixedRegisters(type, Ty, Elts, ScalarElts); + else { + C.HandleByValArgument(Ty, type); + if (Attributes) { + *Attributes |= ParamAttr::ByVal; + *Attributes |= + ParamAttr::constructAlignmentFromInt(LLVM_BYVAL_ALIGNMENT(type)); + } + } } else if (LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(type, Ty)) { C.HandleByValArgument(Ty, type); if (Attributes) { @@ -412,7 +436,7 @@ ParamAttr::constructAlignmentFromInt(LLVM_BYVAL_ALIGNMENT(type)); } } else if (LLVM_SHOULD_PASS_AGGREGATE_IN_INTEGER_REGS(type)) { - PassInIntegerRegisters(type, Ty); + PassInIntegerRegisters(type, Ty, ScalarElts); } else if (isZeroSizedStructOrUnion(type)) { // Zero sized struct or union, just drop it! ; @@ -423,24 +447,24 @@ assert(FNo != ~0U && "Case not handled yet!"); C.EnterField(FNo, Ty); - HandleArgument(getDeclaredType(Field)); + HandleArgument(getDeclaredType(Field), ScalarElts); C.ExitField(); } } else if (TREE_CODE(type) == COMPLEX_TYPE) { C.EnterField(0, Ty); - HandleArgument(TREE_TYPE(type)); + HandleArgument(TREE_TYPE(type), ScalarElts); C.ExitField(); C.EnterField(1, Ty); - HandleArgument(TREE_TYPE(type)); + HandleArgument(TREE_TYPE(type), ScalarElts); C.ExitField(); } else if ((TREE_CODE(type) == UNION_TYPE) || (TREE_CODE(type) == QUAL_UNION_TYPE)) { - HandleUnion(type); + HandleUnion(type, ScalarElts); } else if (TREE_CODE(type) == ARRAY_TYPE) { const ArrayType *ATy = cast(Ty); for (unsigned i = 0, e = ATy->getNumElements(); i != e; ++i) { C.EnterField(i, Ty); - HandleArgument(TREE_TYPE(type)); + HandleArgument(TREE_TYPE(type), ScalarElts); C.ExitField(); } } else { @@ -451,7 +475,7 @@ /// HandleUnion - Handle a UNION_TYPE or QUAL_UNION_TYPE tree. /// - void HandleUnion(tree type) { + void HandleUnion(tree type, std::vector &ScalarElts) { if (TYPE_TRANSPARENT_UNION(type)) { tree Field = TYPE_FIELDS(type); assert(Field && "Transparent union must have some elements!"); @@ -460,7 +484,7 @@ assert(Field && "Transparent union must have some elements!"); } - HandleArgument(TREE_TYPE(Field)); + HandleArgument(TREE_TYPE(Field), ScalarElts); } else { // Unions pass the largest element. unsigned MaxSize = 0; @@ -487,14 +511,15 @@ } if (MaxElt) - HandleArgument(TREE_TYPE(MaxElt)); + HandleArgument(TREE_TYPE(MaxElt), ScalarElts); } } /// PassInIntegerRegisters - Given an aggregate value that should be passed in /// integer registers, convert it to a structure containing ints and pass all /// of the struct elements in. - void PassInIntegerRegisters(tree type, const Type *Ty) { + void PassInIntegerRegisters(tree type, const Type *Ty, + std::vector &ScalarElts) { unsigned Size = TREE_INT_CST_LOW(TYPE_SIZE(type))/8; // FIXME: We should preserve all aggregate value alignment information. @@ -543,6 +568,7 @@ for (unsigned j = 0; j < ArraySize; ++j) { C.EnterField(j, ATy); C.HandleScalarArgument(ArrayElementType, 0); + ScalarElts.push_back(ArrayElementType); C.ExitField(); } C.ExitField(); @@ -551,6 +577,7 @@ for (unsigned e = Elts.size(); i != e; ++i) { C.EnterField(i, STy); C.HandleScalarArgument(Elts[i], 0); + ScalarElts.push_back(Elts[i]); C.ExitField(); } } @@ -559,11 +586,13 @@ /// mixed integer, floating point, and vector registers, convert it to a /// structure containing the specified struct elements in. void PassInMixedRegisters(tree type, const Type *Ty, - std::vector &Elts) { + std::vector &Elts, + std::vector &ScalarElts) { const StructType *STy = StructType::get(Elts, false); for (unsigned i = 0, e = Elts.size(); i != e; ++i) { C.EnterField(i, STy); C.HandleScalarArgument(Elts[i], 0); + ScalarElts.push_back(Elts[i]); C.ExitField(); } } Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-convert.cpp?rev=50492&r1=50491&r2=50492&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-convert.cpp Wed Apr 30 14:50:27 2008 @@ -498,7 +498,7 @@ AI->setName(NameStack.back()); ++AI; } - + void HandleByValArgument(const llvm::Type *LLVMTy, tree type) { // Should not get here. abort(); @@ -521,6 +521,22 @@ }; } +// isPassedByVal - Return true if an aggregate of the specified type will be +// passed in memory byval. +static bool isPassedByVal(tree type, const Type *Ty, + std::vector &ScalarArgs) { + if (LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(type, Ty)) + return true; + + std::vector Args; + if (LLVM_SHOULD_PASS_AGGREGATE_IN_MIXED_REGS(type, Ty, Args) && + LLVM_AGGREGATE_PARTIALLY_PASSED_IN_REGS(Args, ScalarArgs)) + // We want to pass the whole aggregate in registers but only some of the + // registers are available. + return true; + return false; +} + void TreeToLLVM::StartFunctionBody() { const char *Name = ""; // Get the name of the function. @@ -668,6 +684,8 @@ // Prepend the static chain (if any) to the list of arguments. tree Args = static_chain ? static_chain : DECL_ARGUMENTS(FnDecl); + // Scalar arguments processed so far. + std::vector ScalarArgs; while (Args) { const char *Name = "unnamed_arg"; if (DECL_NAME(Args)) Name = IDENTIFIER_POINTER(DECL_NAME(Args)); @@ -676,7 +694,7 @@ bool isInvRef = isPassedByInvisibleReference(TREE_TYPE(Args)); if (isInvRef || (!ArgTy->isFirstClassType() && - LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(TREE_TYPE(Args), ArgTy))) { + isPassedByVal(TREE_TYPE(Args), ArgTy, ScalarArgs))) { // If the value is passed by 'invisible reference' or 'byval reference', // the l-value for the argument IS the argument itself. AI->setName(Name); @@ -710,7 +728,7 @@ Client.setName(Name); Client.setLocation(Tmp); - ABIConverter.HandleArgument(TREE_TYPE(Args)); + ABIConverter.HandleArgument(TREE_TYPE(Args), ScalarArgs); Client.clear(); } @@ -2469,7 +2487,7 @@ // Perform any implicit type conversions. if (CallOperands.size() < FTy->getNumParams()) { - const Type *CalledTy = FTy->getParamType(CallOperands.size()); + const Type *CalledTy= FTy->getParamType(CallOperands.size()); if (Loc->getType() != CalledTy) { assert(type && "Inconsistent parameter types?"); bool isSigned = !TYPE_UNSIGNED(type); @@ -2581,6 +2599,7 @@ CallOperands.push_back(Emit(TREE_OPERAND(exp, 2), 0)); // Loop over the arguments, expanding them and adding them to the op list. + std::vector ScalarArgs; for (tree arg = TREE_OPERAND(exp, 1); arg; arg = TREE_CHAIN(arg)) { const Type *ArgTy = ConvertType(TREE_TYPE(TREE_VALUE(arg))); @@ -2596,7 +2615,8 @@ } ParameterAttributes Attributes = ParamAttr::None; - ABIConverter.HandleArgument(TREE_TYPE(TREE_VALUE(arg)), &Attributes); + ABIConverter.HandleArgument(TREE_TYPE(TREE_VALUE(arg)), ScalarArgs, + &Attributes); if (Attributes != ParamAttr::None) PAL = PAL.addAttr(CallOperands.size(), Attributes); Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-types.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-types.cpp?rev=50492&r1=50491&r2=50492&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-types.cpp (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-types.cpp Wed Apr 30 14:50:27 2008 @@ -1068,9 +1068,10 @@ Attrs.push_back(ParamAttrsWithIndex::get(ArgTys.size(), ParamAttr::StructRet | ParamAttr::NoAlias)); + std::vector ScalarArgs; if (static_chain) { // Pass the static chain as the first parameter. - ABIConverter.HandleArgument(TREE_TYPE(static_chain)); + ABIConverter.HandleArgument(TREE_TYPE(static_chain), ScalarArgs); // Mark it as the chain argument. Attrs.push_back(ParamAttrsWithIndex::get(ArgTys.size(), ParamAttr::Nest)); @@ -1082,7 +1083,7 @@ // Determine if there are any attributes for this param. ParameterAttributes Attributes = ParamAttr::None; - ABIConverter.HandleArgument(ArgTy, &Attributes); + ABIConverter.HandleArgument(ArgTy, ScalarArgs, &Attributes); // Compute zext/sext attributes. Attributes |= HandleArgumentExtension(ArgTy); @@ -1165,9 +1166,10 @@ Attrs.push_back(ParamAttrsWithIndex::get(ArgTypes.size(), ParamAttr::StructRet | ParamAttr::NoAlias)); + std::vector ScalarArgs; if (static_chain) { // Pass the static chain as the first parameter. - ABIConverter.HandleArgument(TREE_TYPE(static_chain)); + ABIConverter.HandleArgument(TREE_TYPE(static_chain), ScalarArgs); // Mark it as the chain argument. Attrs.push_back(ParamAttrsWithIndex::get(ArgTypes.size(), ParamAttr::Nest)); @@ -1207,7 +1209,7 @@ // Determine if there are any attributes for this param. ParameterAttributes Attributes = ParamAttr::None; - ABIConverter.HandleArgument(ArgTy, &Attributes); + ABIConverter.HandleArgument(ArgTy, ScalarArgs, &Attributes); // Compute zext/sext attributes. Attributes |= HandleArgumentExtension(ArgTy); From kremenek at apple.com Wed Apr 30 15:20:18 2008 From: kremenek at apple.com (Ted Kremenek) Date: Wed, 30 Apr 2008 20:20:18 -0000 Subject: [llvm-commits] [llvm] r50495 - /llvm/tags/checker/checker-16/ Message-ID: <200804302020.m3UKKII8029793@zion.cs.uiuc.edu> Author: kremenek Date: Wed Apr 30 15:20:17 2008 New Revision: 50495 URL: http://llvm.org/viewvc/llvm-project?rev=50495&view=rev Log: Tagging checker-16. Added: llvm/tags/checker/checker-16/ - copied from r50494, llvm/trunk/ From isanbard at gmail.com Wed Apr 30 17:15:04 2008 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 30 Apr 2008 22:15:04 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50501 - /llvm-gcc-4.2/branches/Apple/Tak/gcc/objc/objc-act.c Message-ID: <200804302215.m3UMF4xN000944@zion.cs.uiuc.edu> Author: void Date: Wed Apr 30 17:15:04 2008 New Revision: 50501 URL: http://llvm.org/viewvc/llvm-project?rev=50501&view=rev Log: Porting r50487 to Tak. Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/objc/objc-act.c Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/objc/objc-act.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/objc/objc-act.c?rev=50501&r1=50500&r2=50501&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/objc/objc-act.c (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/objc/objc-act.c Wed Apr 30 17:15:04 2008 @@ -6520,24 +6520,16 @@ In both of this cases, expr is preserved as ARRAY_REF. Normally, gcc would decomponse first example into a pointer arithmetic expression. - So in llvm mode, check expression's field type to ensure that this is really a - array reference or not. */ + So in llvm mode, check expression's field type to ensure that this is really + an array reference or not. */ static int objc_is_really_array_ref(tree expr) { - tree component = NULL_TREE; - tree field = NULL_TREE; + tree base = NULL_TREE; if (TREE_CODE(expr) != ARRAY_REF) return 0; - component = TREE_OPERAND(expr, 0); - if (!component || TREE_CODE(component) != COMPONENT_REF) - return 0; - - field = TREE_OPERAND(component, 1); - if (!field || TREE_CODE(TREE_TYPE(field)) != ARRAY_TYPE) - return 0; - - return 1; + base = TREE_OPERAND(expr, 0); + return base && TREE_CODE(TREE_TYPE(base)) == ARRAY_TYPE; } /* LLVM LOCAL - end pointer arithmetic */ From kremenek at apple.com Wed Apr 30 18:01:34 2008 From: kremenek at apple.com (Ted Kremenek) Date: Wed, 30 Apr 2008 23:01:34 -0000 Subject: [llvm-commits] [llvm] r50504 - /llvm/tags/checker/checker-17/ Message-ID: <200804302301.m3UN1Z9F002200@zion.cs.uiuc.edu> Author: kremenek Date: Wed Apr 30 18:01:34 2008 New Revision: 50504 URL: http://llvm.org/viewvc/llvm-project?rev=50504&view=rev Log: Tagging checker-17. Added: llvm/tags/checker/checker-17/ - copied from r50503, llvm/trunk/ From sabre at nondot.org Wed Apr 30 19:14:28 2008 From: sabre at nondot.org (Chris Lattner) Date: Thu, 01 May 2008 00:14:28 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50509 - /llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Message-ID: <200805010014.m410ESE9004280@zion.cs.uiuc.edu> Author: lattner Date: Wed Apr 30 19:14:27 2008 New Revision: 50509 URL: http://llvm.org/viewvc/llvm-project?rev=50509&view=rev Log: Tweak FixBaseClassField from Dale's patch for PR1746 to only use the cloned tree if the cloned tree is missing something from the input. In some cases in the objc front-end, it is making trees that trigger the 'virtual base class cleanup' code, but doesn't end up making any changes. This avoids the copy. This patch also has a lot of random cleanups, which is basically all noise. The fix here is in FixBaseClassField: if (F == 0) return newTy = oldTy; Dale, please review. This patch should not cause any functionality changes, but is a prerequisite for an ObjC patch I'm working on. Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=50509&r1=50508&r2=50509&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Wed Apr 30 19:14:27 2008 @@ -1643,51 +1643,58 @@ /// This can also occur when a class has an empty base class; the class will /// have size N+4 and the field size N+1. In this case the fields will add /// up to N+4, so we haven't really changed anything. - static tree FixBaseClassField(tree Field) { tree oldTy = TREE_TYPE(Field); tree &newTy = BaseTypesMap[oldTy]; + // If already in table, reuse. - if (!newTy) { - newTy = copy_node(oldTy); - tree F2 = 0, prevF2 = 0; - // Copy the fields up to the TYPE_DECL separator. - // VAR_DECLs can also appear, representing static members. Possibly some - // other junk I haven't hit yet, just skip anything that's not a FIELD:( - for (tree F = TYPE_FIELDS(oldTy); F; prevF2 = F2, F = TREE_CHAIN(F)) { - if (TREE_CODE(F) == TYPE_DECL) - break; - if (TREE_CODE(F) == FIELD_DECL) { - F2 = copy_node(F); - if (prevF2) - TREE_CHAIN(prevF2) = F2; - else - TYPE_FIELDS(newTy) = F2; - TREE_CHAIN(F2) = 0; - } - } - BaseTypesMap[oldTy] = newTy; - BaseTypesMap[newTy] = oldTy; - /* Prevent gcc's garbage collector from destroying newTy. The - GC code doesn't understand DenseMaps:( */ - llvm_note_type_used(newTy); - TYPE_SIZE(newTy) = DECL_SIZE(Field); - TYPE_SIZE_UNIT(newTy) = DECL_SIZE_UNIT(Field); - TYPE_MAIN_VARIANT(newTy) = newTy; - TYPE_STUB_DECL(newTy) = TYPE_STUB_DECL(oldTy); - // Change the name. - if (TYPE_NAME(oldTy)) { - const char *p = "anon"; - if (TREE_CODE(TYPE_NAME(oldTy)) ==IDENTIFIER_NODE) - p = IDENTIFIER_POINTER(TYPE_NAME(oldTy)); - else if (DECL_NAME(TYPE_NAME(oldTy))) - p = IDENTIFIER_POINTER(DECL_NAME(TYPE_NAME(oldTy))); - char *q = (char *)xmalloc(strlen(p)+6); - strcpy(q,p); - strcat(q,".base"); - TYPE_NAME(newTy) = get_identifier(q); - free(q); - } + if (newTy) return newTy; + + newTy = copy_node(oldTy); + tree F2 = 0, prevF2 = 0; + // Copy the fields up to the TYPE_DECL separator. + // VAR_DECLs can also appear, representing static members. Possibly some + // other junk I haven't hit yet, just skip anything that's not a FIELD:( + tree F; + for (F = TYPE_FIELDS(oldTy); F; prevF2 = F2, F = TREE_CHAIN(F)) { + if (TREE_CODE(F) == TYPE_DECL) + break; + + if (TREE_CODE(F) != FIELD_DECL) + continue; + + F2 = copy_node(F); + if (prevF2) + TREE_CHAIN(prevF2) = F2; + else + TYPE_FIELDS(newTy) = F2; + TREE_CHAIN(F2) = 0; + } + + if (F == 0) + return newTy = oldTy; + + BaseTypesMap[oldTy] = newTy; + BaseTypesMap[newTy] = oldTy; + /* Prevent gcc's garbage collector from destroying newTy. The + GC code doesn't understand DenseMaps:( */ + llvm_note_type_used(newTy); + TYPE_SIZE(newTy) = DECL_SIZE(Field); + TYPE_SIZE_UNIT(newTy) = DECL_SIZE_UNIT(Field); + TYPE_MAIN_VARIANT(newTy) = newTy; + TYPE_STUB_DECL(newTy) = TYPE_STUB_DECL(oldTy); + // Change the name. + if (TYPE_NAME(oldTy)) { + const char *p = "anon"; + if (TREE_CODE(TYPE_NAME(oldTy)) ==IDENTIFIER_NODE) + p = IDENTIFIER_POINTER(TYPE_NAME(oldTy)); + else if (DECL_NAME(TYPE_NAME(oldTy))) + p = IDENTIFIER_POINTER(DECL_NAME(TYPE_NAME(oldTy))); + char *q = (char *)xmalloc(strlen(p)+6); + strcpy(q,p); + strcat(q,".base"); + TYPE_NAME(newTy) = get_identifier(q); + free(q); } return newTy; } @@ -1706,8 +1713,6 @@ // node for it, but not when A is a nonvirtual base class. So we can't // use that.) static void FixBaseClassFields(tree type) { - if (TREE_CODE(type)!=RECORD_TYPE) - return; for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) { if (TREE_CODE(Field)==FIELD_DECL && !DECL_BIT_FIELD_TYPE(Field) && @@ -1755,7 +1760,7 @@ // code continues to work (there are pointers stashed away in there). static void RestoreBaseClassFields(tree type) { - if (TREE_CODE(type)!=RECORD_TYPE) + if (TREE_CODE(type) != RECORD_TYPE) return; for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) { if (TREE_CODE(Field) == FIELD_DECL && DECL_FIELD_REPLACED(Field)) { @@ -1770,7 +1775,7 @@ /// DecodeStructFields - This method decodes the specified field, if it is a /// FIELD_DECL, adding or updating the specified StructTypeConversionInfo to -/// reflect it. Return tree if field is decoded correctly. Otherwise return +/// reflect it. Return true if field is decoded correctly. Otherwise return /// false. bool TypeConverter::DecodeStructFields(tree Field, StructTypeConversionInfo &Info) { @@ -1795,7 +1800,8 @@ // then convert to a packed struct and try again. if (TYPE_USER_ALIGN(DECL_BIT_FIELD_TYPE(Field))) { const Type *Ty = ConvertType(getDeclaredType(Field)); - if (TYPE_ALIGN_UNIT(DECL_BIT_FIELD_TYPE(Field)) != Info.getTypeAlignment(Ty)) + if (TYPE_ALIGN_UNIT(DECL_BIT_FIELD_TYPE(Field)) != + Info.getTypeAlignment(Ty)) return false; } } @@ -2005,12 +2011,13 @@ // Alter any fields that appear to represent base classes so their lists // of fields bear some resemblance to reality. - FixBaseClassFields(type); + if (TREE_CODE(type) == RECORD_TYPE) + FixBaseClassFields(type); // Convert over all of the elements of the struct. bool retryAsPackedStruct = false; for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) { - if (DecodeStructFields(Field, *Info) == false) { + if (!DecodeStructFields(Field, *Info)) { retryAsPackedStruct = true; break; } @@ -2020,11 +2027,9 @@ delete Info; Info = new StructTypeConversionInfo(*TheTarget, TYPE_ALIGN_UNIT(type), true); - for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) { - if (DecodeStructFields(Field, *Info) == false) { + for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) + if (DecodeStructFields(Field, *Info) == false) assert(0 && "Unable to decode struct fields."); - } - } } // If the LLVM struct requires explicit tail padding to be the same size as @@ -2038,7 +2043,9 @@ LLVMStructSize = Info->getSizeAsLLVMStruct(); } - if (LLVMStructSize != GCCTypeSize) { + if (LLVMStructSize == GCCTypeSize) { + Info->RemoveExtraBytes(); + } else { assert(LLVMStructSize < GCCTypeSize && "LLVM type size doesn't match GCC type size!"); uint64_t LLVMLastElementEnd = Info->getNewElementByteOffset(1); @@ -2047,7 +2054,7 @@ if (GCCTypeSize-LLVMLastElementEnd == 1) Info->addElement(Type::Int8Ty, 1, 1); else { - if ( ((GCCTypeSize-LLVMStructSize) % 4) == 0) { + if (((GCCTypeSize-LLVMStructSize) % 4) == 0) { // insert array of i32 unsigned Int32ArraySize = (GCCTypeSize-LLVMStructSize)/4; const Type *PadTy = ArrayType::get(Type::Int32Ty, Int32ArraySize); @@ -2063,9 +2070,7 @@ } } } - } else - Info->RemoveExtraBytes(); - + } // Now that the LLVM struct is finalized, figure out a safe place to index to // and set index values for each FieldDecl that doesn't start at a variable From dalej at apple.com Wed Apr 30 19:36:55 2008 From: dalej at apple.com (Dale Johannesen) Date: Wed, 30 Apr 2008 17:36:55 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r50509 - /llvm-gcc-4.2/trunk/gcc/llvm-types.cpp In-Reply-To: <200805010014.m410ESE9004280@zion.cs.uiuc.edu> References: <200805010014.m410ESE9004280@zion.cs.uiuc.edu> Message-ID: On Apr 30, 2008, at 5:14 PM, Chris Lattner wrote: > Author: lattner > Date: Wed Apr 30 19:14:27 2008 > New Revision: 50509 > > URL: http://llvm.org/viewvc/llvm-project?rev=50509&view=rev > Log: > Tweak FixBaseClassField from Dale's patch for PR1746 to only > use the cloned tree if the cloned tree is missing something > from the input. In some cases in the objc front-end, it is > making trees that trigger the 'virtual base class cleanup' > code, but doesn't end up making any changes. This avoids > the copy. > > This patch also has a lot of random cleanups, which is > basically all noise. Right, and not all of them are "cleanups" IMO. I feel strongly that everyone's time is better spent not doing things like this. There's always more than one way to do it. > The fix here is in FixBaseClassField: > > if (F == 0) > return newTy = oldTy; I'm not sure how that would happen, but it wouldn't happen in the base class case I'm looking for, so it should be OK if passes testing. > Dale, please review. This patch should not cause any > functionality changes, but is a prerequisite for an ObjC > patch I'm working on. > > > Modified: > llvm-gcc-4.2/trunk/gcc/llvm-types.cpp > > Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=50509&r1=50508&r2=50509&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original) > +++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Wed Apr 30 19:14:27 2008 > @@ -1643,51 +1643,58 @@ > /// This can also occur when a class has an empty base class; the > class will > /// have size N+4 and the field size N+1. In this case the fields > will add > /// up to N+4, so we haven't really changed anything. > - > static tree FixBaseClassField(tree Field) { > tree oldTy = TREE_TYPE(Field); > tree &newTy = BaseTypesMap[oldTy]; > + > // If already in table, reuse. > - if (!newTy) { > - newTy = copy_node(oldTy); > - tree F2 = 0, prevF2 = 0; > - // Copy the fields up to the TYPE_DECL separator. > - // VAR_DECLs can also appear, representing static members. > Possibly some > - // other junk I haven't hit yet, just skip anything that's not > a FIELD:( > - for (tree F = TYPE_FIELDS(oldTy); F; prevF2 = F2, F = > TREE_CHAIN(F)) { > - if (TREE_CODE(F) == TYPE_DECL) > - break; > - if (TREE_CODE(F) == FIELD_DECL) { > - F2 = copy_node(F); > - if (prevF2) > - TREE_CHAIN(prevF2) = F2; > - else > - TYPE_FIELDS(newTy) = F2; > - TREE_CHAIN(F2) = 0; > - } > - } > - BaseTypesMap[oldTy] = newTy; > - BaseTypesMap[newTy] = oldTy; > - /* Prevent gcc's garbage collector from destroying newTy. The > - GC code doesn't understand DenseMaps:( */ > - llvm_note_type_used(newTy); > - TYPE_SIZE(newTy) = DECL_SIZE(Field); > - TYPE_SIZE_UNIT(newTy) = DECL_SIZE_UNIT(Field); > - TYPE_MAIN_VARIANT(newTy) = newTy; > - TYPE_STUB_DECL(newTy) = TYPE_STUB_DECL(oldTy); > - // Change the name. > - if (TYPE_NAME(oldTy)) { > - const char *p = "anon"; > - if (TREE_CODE(TYPE_NAME(oldTy)) ==IDENTIFIER_NODE) > - p = IDENTIFIER_POINTER(TYPE_NAME(oldTy)); > - else if (DECL_NAME(TYPE_NAME(oldTy))) > - p = IDENTIFIER_POINTER(DECL_NAME(TYPE_NAME(oldTy))); > - char *q = (char *)xmalloc(strlen(p)+6); > - strcpy(q,p); > - strcat(q,".base"); > - TYPE_NAME(newTy) = get_identifier(q); > - free(q); > - } > + if (newTy) return newTy; > + > + newTy = copy_node(oldTy); > + tree F2 = 0, prevF2 = 0; > + // Copy the fields up to the TYPE_DECL separator. > + // VAR_DECLs can also appear, representing static members. > Possibly some > + // other junk I haven't hit yet, just skip anything that's not a > FIELD:( > + tree F; > + for (F = TYPE_FIELDS(oldTy); F; prevF2 = F2, F = TREE_CHAIN(F)) { > + if (TREE_CODE(F) == TYPE_DECL) > + break; > + > + if (TREE_CODE(F) != FIELD_DECL) > + continue; > + > + F2 = copy_node(F); > + if (prevF2) > + TREE_CHAIN(prevF2) = F2; > + else > + TYPE_FIELDS(newTy) = F2; > + TREE_CHAIN(F2) = 0; > + } > + > + if (F == 0) > + return newTy = oldTy; > + > + BaseTypesMap[oldTy] = newTy; > + BaseTypesMap[newTy] = oldTy; > + /* Prevent gcc's garbage collector from destroying newTy. The > + GC code doesn't understand DenseMaps:( */ > + llvm_note_type_used(newTy); > + TYPE_SIZE(newTy) = DECL_SIZE(Field); > + TYPE_SIZE_UNIT(newTy) = DECL_SIZE_UNIT(Field); > + TYPE_MAIN_VARIANT(newTy) = newTy; > + TYPE_STUB_DECL(newTy) = TYPE_STUB_DECL(oldTy); > + // Change the name. > + if (TYPE_NAME(oldTy)) { > + const char *p = "anon"; > + if (TREE_CODE(TYPE_NAME(oldTy)) ==IDENTIFIER_NODE) > + p = IDENTIFIER_POINTER(TYPE_NAME(oldTy)); > + else if (DECL_NAME(TYPE_NAME(oldTy))) > + p = IDENTIFIER_POINTER(DECL_NAME(TYPE_NAME(oldTy))); > + char *q = (char *)xmalloc(strlen(p)+6); > + strcpy(q,p); > + strcat(q,".base"); > + TYPE_NAME(newTy) = get_identifier(q); > + free(q); > } > return newTy; > } > @@ -1706,8 +1713,6 @@ > // node for it, but not when A is a nonvirtual base class. So we > can't > // use that.) > static void FixBaseClassFields(tree type) { > - if (TREE_CODE(type)!=RECORD_TYPE) > - return; > for (tree Field = TYPE_FIELDS(type); Field; Field = > TREE_CHAIN(Field)) { > if (TREE_CODE(Field)==FIELD_DECL && > !DECL_BIT_FIELD_TYPE(Field) && > @@ -1755,7 +1760,7 @@ > // code continues to work (there are pointers stashed away in there). > > static void RestoreBaseClassFields(tree type) { > - if (TREE_CODE(type)!=RECORD_TYPE) > + if (TREE_CODE(type) != RECORD_TYPE) > return; > for (tree Field = TYPE_FIELDS(type); Field; Field = > TREE_CHAIN(Field)) { > if (TREE_CODE(Field) == FIELD_DECL && > DECL_FIELD_REPLACED(Field)) { > @@ -1770,7 +1775,7 @@ > > /// DecodeStructFields - This method decodes the specified field, if > it is a > /// FIELD_DECL, adding or updating the specified > StructTypeConversionInfo to > -/// reflect it. Return tree if field is decoded correctly. > Otherwise return > +/// reflect it. Return true if field is decoded correctly. > Otherwise return > /// false. > bool TypeConverter::DecodeStructFields(tree Field, > StructTypeConversionInfo > &Info) { > @@ -1795,7 +1800,8 @@ > // then convert to a packed struct and try again. > if (TYPE_USER_ALIGN(DECL_BIT_FIELD_TYPE(Field))) { > const Type *Ty = ConvertType(getDeclaredType(Field)); > - if (TYPE_ALIGN_UNIT(DECL_BIT_FIELD_TYPE(Field)) != > Info.getTypeAlignment(Ty)) > + if (TYPE_ALIGN_UNIT(DECL_BIT_FIELD_TYPE(Field)) != > + Info.getTypeAlignment(Ty)) > return false; > } > } > @@ -2005,12 +2011,13 @@ > > // Alter any fields that appear to represent base classes so their > lists > // of fields bear some resemblance to reality. > - FixBaseClassFields(type); > + if (TREE_CODE(type) == RECORD_TYPE) > + FixBaseClassFields(type); > > // Convert over all of the elements of the struct. > bool retryAsPackedStruct = false; > for (tree Field = TYPE_FIELDS(type); Field; Field = > TREE_CHAIN(Field)) { > - if (DecodeStructFields(Field, *Info) == false) { > + if (!DecodeStructFields(Field, *Info)) { > retryAsPackedStruct = true; > break; > } > @@ -2020,11 +2027,9 @@ > delete Info; > Info = new StructTypeConversionInfo(*TheTarget, > TYPE_ALIGN_UNIT(type), > true); > - for (tree Field = TYPE_FIELDS(type); Field; Field = > TREE_CHAIN(Field)) { > - if (DecodeStructFields(Field, *Info) == false) { > + for (tree Field = TYPE_FIELDS(type); Field; Field = > TREE_CHAIN(Field)) > + if (DecodeStructFields(Field, *Info) == false) > assert(0 && "Unable to decode struct fields."); > - } > - } > } > > // If the LLVM struct requires explicit tail padding to be the > same size as > @@ -2038,7 +2043,9 @@ > LLVMStructSize = Info->getSizeAsLLVMStruct(); > } > > - if (LLVMStructSize != GCCTypeSize) { > + if (LLVMStructSize == GCCTypeSize) { > + Info->RemoveExtraBytes(); > + } else { > assert(LLVMStructSize < GCCTypeSize && > "LLVM type size doesn't match GCC type size!"); > uint64_t LLVMLastElementEnd = Info->getNewElementByteOffset(1); > @@ -2047,7 +2054,7 @@ > if (GCCTypeSize-LLVMLastElementEnd == 1) > Info->addElement(Type::Int8Ty, 1, 1); > else { > - if ( ((GCCTypeSize-LLVMStructSize) % 4) == 0) { > + if (((GCCTypeSize-LLVMStructSize) % 4) == 0) { > // insert array of i32 > unsigned Int32ArraySize = (GCCTypeSize-LLVMStructSize)/4; > const Type *PadTy = ArrayType::get(Type::Int32Ty, > Int32ArraySize); > @@ -2063,9 +2070,7 @@ > } > } > } > - } else > - Info->RemoveExtraBytes(); > - > + } > > // Now that the LLVM struct is finalized, figure out a safe place > to index to > // and set index values for each FieldDecl that doesn't start at a > variable > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From sabre at nondot.org Wed Apr 30 20:39:53 2008 From: sabre at nondot.org (Chris Lattner) Date: Thu, 01 May 2008 01:39:53 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50510 - in /llvm-gcc-4.2/trunk/gcc: llvm-types.cpp llvm.h objc/objc-act.c Message-ID: <200805010139.m411drsv006853@zion.cs.uiuc.edu> Author: lattner Date: Wed Apr 30 20:39:53 2008 New Revision: 50510 URL: http://llvm.org/viewvc/llvm-project?rev=50510&view=rev Log: Fully revert r50276 from the tree and fix the objc bug another way: When adding a field decl to a struct, if the LLVM type for the field is larger than the field decl size, try to drop elements from the llvm type to make it fit. This fixes cases where the ObjC frontend is abusing trees, fixing gcc/testsuite/objc.dg/newproperty-retain-3.c There are other cases where the C++ front-end is violating the sanctity of trees (see the FIXME and disabled assert) but this patch should not make those cases any better or worse. Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp llvm-gcc-4.2/trunk/gcc/llvm.h llvm-gcc-4.2/trunk/gcc/objc/objc-act.c Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=50510&r1=50509&r2=50510&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Wed Apr 30 20:39:53 2008 @@ -46,10 +46,6 @@ } #include "llvm-abi.h" -void llvm_compute_type(tree X) { - ConvertType(X); -} - //===----------------------------------------------------------------------===// // Matching LLVM types with GCC trees //===----------------------------------------------------------------------===// @@ -1772,7 +1768,6 @@ } } - /// DecodeStructFields - This method decodes the specified field, if it is a /// FIELD_DECL, adding or updating the specified StructTypeConversionInfo to /// reflect it. Return true if field is decoded correctly. Otherwise return @@ -1817,29 +1812,82 @@ unsigned StartOffsetInBytes = StartOffsetInBits/8; const Type *Ty = ConvertType(getDeclaredType(Field)); - + // If this field is packed then the struct may need padding fields // before this field. if (DECL_PACKED(Field) && !Info.isPacked()) return false; + // Pop any previous elements out of the struct if they overlap with this one. // This can happen when the C++ front-end overlaps fields with tail padding in // C++ classes. - else if (!Info.ResizeLastElementIfOverlapsWith(StartOffsetInBytes, Field, Ty)) { + if (!Info.ResizeLastElementIfOverlapsWith(StartOffsetInBytes, Field, Ty)) { // LLVM disagrees as to where this field should go in the natural field // ordering. Therefore convert to a packed struct and try again. return false; } - else if (TYPE_USER_ALIGN(TREE_TYPE(Field)) - && (unsigned)DECL_ALIGN_UNIT(Field) != Info.getTypeAlignment(Ty) - && !Info.isPacked()) { + + if (TYPE_USER_ALIGN(TREE_TYPE(Field)) && + (unsigned)DECL_ALIGN_UNIT(Field) != Info.getTypeAlignment(Ty) && + !Info.isPacked()) { // If Field has user defined alignment and it does not match Ty alignment // then convert to a packed struct and try again. return false; - } else - // At this point, we know that adding the element will happen at the right - // offset. Add it. - Info.addElement(Ty, StartOffsetInBytes, Info.getTypeSize(Ty)); + } + + // If the converted LLVM type has a different size than the field decl then we + // have a fun case where DECL_SIZE(Field) disagrees with + // TYPE_SIZE(TREE_TYPE(Field)). In a sane world, this would never happen, but + // it can occur in some places in the ObjC front-end for example. The only + // time we support this is when the LLVM type is a struct. In this case, we + // remove entries from the end of the LLVM struct until the size matches what + // the RTL backend expects as the size for the field. + if (DECL_SIZE(Field) && isInt64(DECL_SIZE(Field), true) && + getInt64(DECL_SIZE(Field), true) != Info.getTypeSize(Ty)*8) { + uint64_t LLVMSize = Info.getTypeSize(Ty)*8; + uint64_t GCCFieldSize = getInt64(DECL_SIZE(Field), true); + tree FieldType = TREE_TYPE(Field); + assert(getInt64(TYPE_SIZE(FieldType), true) == LLVMSize && + "LLVM and GCC type layout mismatch?"); + assert(GCCFieldSize < Info.getTypeSize(Ty)*8 && + "GCC FieldDecl size larger than its type's size?"); + const StructType *STy = cast(Ty); + + // Copy over elements that start before the GCC Field Size. + std::vector NewElements; + const StructLayout *Layout = getTargetData().getStructLayout(STy); + + // Copy over all elements from the LLVM structure that start before the end + // of the GCC field decl. + if (GCCFieldSize) { + for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) { + assert(i != STy->getNumElements() && "Didn't find any fields to drop?"); + if (Layout->getElementOffset(i)*8 >= GCCFieldSize) + break; + NewElements.push_back(STy->getElementType(i)); + } + } + + // Make a new LLVM struct out of these fields. + Ty = StructType::get(NewElements, STy->isPacked()); + + // At this point, the size of the GCC and LLVM types must exactly match + // again... except when this is the last field of a C++ struct, in which + // case where are crazy tail padding games we have yet to play. Verify + // that we either exactly match or that this is the last field. + // + // FIXME: Scratch that. There are other crazy cases in the C++ front-end + // that violate this. If we couldn't fix the type size here, we will + // continue on with an unmodified type, which at least won't break anything + // worse than it was before. + // + //assert((Info.getTypeSize(Ty)*8 == GCCFieldSize || isLastFieldDecl(Field)) + // && "Could not make GCC and LLVM field size agree!"); + } + + // At this point, we know that adding the element will happen at the right + // offset. Add it. + Info.addElement(Ty, StartOffsetInBytes, Info.getTypeSize(Ty)); return true; } Modified: llvm-gcc-4.2/trunk/gcc/llvm.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm.h?rev=50510&r1=50509&r2=50510&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm.h (original) +++ llvm-gcc-4.2/trunk/gcc/llvm.h Wed Apr 30 20:39:53 2008 @@ -49,12 +49,6 @@ */ void reset_type_and_initializer_llvm(union tree_node*); -/* llvm_compute_type - Compute the LLVM type for the specified tree type eagerly - * instead of letting it happen lazily. - */ -void llvm_compute_type(union tree_node*); - - /* reset_initializer_llvm - Change the initializer for a global variable. */ void reset_initializer_llvm(union tree_node*); Modified: llvm-gcc-4.2/trunk/gcc/objc/objc-act.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/objc/objc-act.c?rev=50510&r1=50509&r2=50510&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/objc/objc-act.c (original) +++ llvm-gcc-4.2/trunk/gcc/objc/objc-act.c Wed Apr 30 20:39:53 2008 @@ -8619,22 +8619,6 @@ /* APPLE LOCAL begin ObjC new abi */ if (flag_objc_abi == 2) CLASS_TYPE (class) = record; - - /* APPLE LOCAL llvm begin */ -#if 0 -#ifdef ENABLE_LLVM - /* Synthesized properties will later be added to this RECORD_DECL as they - * are found in @implementations. We don't want the LLVM tree->llvm - * converter to see these newly added properties, so we emulate the RTL - * backend and analyze the type eagerly in this case. It would be better - * for the ObjC front-end to not add these properties to the RECORD_DECL - * but that would be a large/invasive change. rdar://5812818 - */ - if (flag_objc_abi == 2) - llvm_compute_type(record); -#endif -#endif - /* APPLE LOCAL llvm end */ } } /* APPLE LOCAL end ObjC new abi */ From sabre at nondot.org Thu May 1 00:11:00 2008 From: sabre at nondot.org (Chris Lattner) Date: Thu, 01 May 2008 05:11:00 -0000 Subject: [llvm-commits] [llvm] r50514 - /llvm/trunk/include/llvm/Support/IRBuilder.h Message-ID: <200805010511.m415B0hK012850@zion.cs.uiuc.edu> Author: lattner Date: Thu May 1 00:11:00 2008 New Revision: 50514 URL: http://llvm.org/viewvc/llvm-project?rev=50514&view=rev Log: Add a spiffy little "CreateCall2" method, which can be used to make a function call that takes two Value*'s as arguments. Modified: llvm/trunk/include/llvm/Support/IRBuilder.h Modified: llvm/trunk/include/llvm/Support/IRBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=50514&r1=50513&r2=50514&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/IRBuilder.h (original) +++ llvm/trunk/include/llvm/Support/IRBuilder.h Thu May 1 00:11:00 2008 @@ -475,15 +475,20 @@ CallInst *CreateCall(Value *Callee, Value *Arg, const char *Name = "") { return Insert(CallInst::Create(Callee, Arg, Name)); } - + CallInst *CreateCall2(Value *Callee, Value *Arg1, Value *Arg2, + const char *Name = "") { + Value *Args[] = { Arg1, Arg2 }; + return Insert(CallInst::Create(Callee, Args, Args+2, Name)); + } + template CallInst *CreateCall(Value *Callee, InputIterator ArgBegin, - InputIterator ArgEnd, const char *Name = "") { + InputIterator ArgEnd, const char *Name = "") { return Insert(CallInst::Create(Callee, ArgBegin, ArgEnd, Name)); } Value *CreateSelect(Value *C, Value *True, Value *False, - const char *Name = "") { + const char *Name = "") { if (Constant *CC = dyn_cast(C)) if (Constant *TC = dyn_cast(True)) if (Constant *FC = dyn_cast(False)) From sabre at nondot.org Thu May 1 00:23:46 2008 From: sabre at nondot.org (Chris Lattner) Date: Thu, 01 May 2008 05:23:46 -0000 Subject: [llvm-commits] [llvm] r50515 - /llvm/trunk/include/llvm/Support/IRBuilder.h Message-ID: <200805010523.m415NkhO013225@zion.cs.uiuc.edu> Author: lattner Date: Thu May 1 00:23:45 2008 New Revision: 50515 URL: http://llvm.org/viewvc/llvm-project?rev=50515&view=rev Log: Add CreateCall3/CreateCall4 at Eric's request. Modified: llvm/trunk/include/llvm/Support/IRBuilder.h Modified: llvm/trunk/include/llvm/Support/IRBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=50515&r1=50514&r2=50515&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/IRBuilder.h (original) +++ llvm/trunk/include/llvm/Support/IRBuilder.h Thu May 1 00:23:45 2008 @@ -480,6 +480,16 @@ Value *Args[] = { Arg1, Arg2 }; return Insert(CallInst::Create(Callee, Args, Args+2, Name)); } + CallInst *CreateCall3(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3, + const char *Name = "") { + Value *Args[] = { Arg1, Arg2, Arg3 }; + return Insert(CallInst::Create(Callee, Args, Args+3, Name)); + } + CallInst *CreateCall4(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3, + Value *Arg4, const char *Name = "") { + Value *Args[] = { Arg1, Arg2, Arg3, Arg4 }; + return Insert(CallInst::Create(Callee, Args, Args+4, Name)); + } template CallInst *CreateCall(Value *Callee, InputIterator ArgBegin, From sabre at nondot.org Thu May 1 01:13:49 2008 From: sabre at nondot.org (Chris Lattner) Date: Thu, 01 May 2008 06:13:49 -0000 Subject: [llvm-commits] [llvm] r50516 - /llvm/trunk/test/Transforms/InstCombine/memmove.ll Message-ID: <200805010613.m416DnVV014693@zion.cs.uiuc.edu> Author: lattner Date: Thu May 1 01:13:48 2008 New Revision: 50516 URL: http://llvm.org/viewvc/llvm-project?rev=50516&view=rev Log: move some tests from libcall optimizer suite. Modified: llvm/trunk/test/Transforms/InstCombine/memmove.ll Modified: llvm/trunk/test/Transforms/InstCombine/memmove.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/memmove.ll?rev=50516&r1=50515&r2=50516&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/memmove.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/memmove.ll Thu May 1 01:13:48 2008 @@ -4,6 +4,10 @@ ; RUN: not grep {call void @llvm.memmove} @S = internal constant [33 x i8] c"panic: restorelist inconsistency\00" ; <[33 x i8]*> [#uses=1] + at h = constant [2 x i8] c"h\00" ; <[2 x i8]*> [#uses=1] + at hel = constant [4 x i8] c"hel\00" ; <[4 x i8]*> [#uses=1] + at hello_u = constant [8 x i8] c"hello_u\00" ; <[8 x i8]*> [#uses=1] + declare void @llvm.memmove.i32(i8*, i8*, i32, i32) @@ -17,3 +21,16 @@ call void @llvm.memmove.i32( i8* %A, i8* getelementptr ([33 x i8]* @S, i32 0, i32 0), i32 %N, i32 1 ) ret void } + +define i32 @test3() { + %h_p = getelementptr [2 x i8]* @h, i32 0, i32 0 ; [#uses=1] + %hel_p = getelementptr [4 x i8]* @hel, i32 0, i32 0 ; [#uses=1] + %hello_u_p = getelementptr [8 x i8]* @hello_u, i32 0, i32 0 ; [#uses=1] + %target = alloca [1024 x i8] ; <[1024 x i8]*> [#uses=1] + %target_p = getelementptr [1024 x i8]* %target, i32 0, i32 0 ; [#uses=3] + call void @llvm.memmove.i32( i8* %target_p, i8* %h_p, i32 2, i32 2 ) + call void @llvm.memmove.i32( i8* %target_p, i8* %hel_p, i32 4, i32 4 ) + call void @llvm.memmove.i32( i8* %target_p, i8* %hello_u_p, i32 8, i32 8 ) + ret i32 0 +} + From sabre at nondot.org Thu May 1 01:14:24 2008 From: sabre at nondot.org (Chris Lattner) Date: Thu, 01 May 2008 06:14:24 -0000 Subject: [llvm-commits] [llvm] r50517 - /llvm/trunk/test/Transforms/SimplifyLibCalls/MemMove.ll Message-ID: <200805010614.m416EOAG014727@zion.cs.uiuc.edu> Author: lattner Date: Thu May 1 01:14:24 2008 New Revision: 50517 URL: http://llvm.org/viewvc/llvm-project?rev=50517&view=rev Log: simplifylibcalls doesn't optimize llvm.memmove, instcombine does. Removed: llvm/trunk/test/Transforms/SimplifyLibCalls/MemMove.ll Removed: llvm/trunk/test/Transforms/SimplifyLibCalls/MemMove.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyLibCalls/MemMove.ll?rev=50516&view=auto ============================================================================== --- llvm/trunk/test/Transforms/SimplifyLibCalls/MemMove.ll (original) +++ llvm/trunk/test/Transforms/SimplifyLibCalls/MemMove.ll (removed) @@ -1,22 +0,0 @@ -; Test that the StrCatOptimizer works correctly -; RUN: llvm-as < %s | opt -constprop -simplify-libcalls | \ -; RUN: llvm-dis | not grep {call.*llvm.memmove.i32} - - at h = constant [2 x i8] c"h\00" ; <[2 x i8]*> [#uses=1] - at hel = constant [4 x i8] c"hel\00" ; <[4 x i8]*> [#uses=1] - at hello_u = constant [8 x i8] c"hello_u\00" ; <[8 x i8]*> [#uses=1] - -declare void @llvm.memmove.i32(i8*, i8*, i32, i32) - -define i32 @main() { - %h_p = getelementptr [2 x i8]* @h, i32 0, i32 0 ; [#uses=1] - %hel_p = getelementptr [4 x i8]* @hel, i32 0, i32 0 ; [#uses=1] - %hello_u_p = getelementptr [8 x i8]* @hello_u, i32 0, i32 0 ; [#uses=1] - %target = alloca [1024 x i8] ; <[1024 x i8]*> [#uses=1] - %target_p = getelementptr [1024 x i8]* %target, i32 0, i32 0 ; [#uses=3] - call void @llvm.memmove.i32( i8* %target_p, i8* %h_p, i32 2, i32 2 ) - call void @llvm.memmove.i32( i8* %target_p, i8* %hel_p, i32 4, i32 4 ) - call void @llvm.memmove.i32( i8* %target_p, i8* %hello_u_p, i32 8, i32 8 ) - ret i32 0 -} - From sabre at nondot.org Thu May 1 01:16:38 2008 From: sabre at nondot.org (Chris Lattner) Date: Thu, 01 May 2008 06:16:38 -0000 Subject: [llvm-commits] [llvm] r50518 - /llvm/trunk/test/Transforms/SimplifyLibCalls/MemSet.ll Message-ID: <200805010616.m416Gc13014794@zion.cs.uiuc.edu> Author: lattner Date: Thu May 1 01:16:38 2008 New Revision: 50518 URL: http://llvm.org/viewvc/llvm-project?rev=50518&view=rev Log: instcombine does memset optzns. Removed: llvm/trunk/test/Transforms/SimplifyLibCalls/MemSet.ll Removed: llvm/trunk/test/Transforms/SimplifyLibCalls/MemSet.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyLibCalls/MemSet.ll?rev=50517&view=auto ============================================================================== --- llvm/trunk/test/Transforms/SimplifyLibCalls/MemSet.ll (original) +++ llvm/trunk/test/Transforms/SimplifyLibCalls/MemSet.ll (removed) @@ -1,18 +0,0 @@ -; Test that the LLVMMemSetOptimizer works correctly -; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | \ -; RUN: not grep {call.*llvm.memset} -; END. - -declare void @llvm.memset.i32(i8*, i8, i32, i32) - -define i32 @main() { - %target = alloca [1024 x i8] ; <[1024 x i8]*> [#uses=1] - %target_p = getelementptr [1024 x i8]* %target, i32 0, i32 0 ; [#uses=5] - call void @llvm.memset.i32( i8* %target_p, i8 1, i32 0, i32 1 ) - call void @llvm.memset.i32( i8* %target_p, i8 1, i32 1, i32 1 ) - call void @llvm.memset.i32( i8* %target_p, i8 1, i32 2, i32 2 ) - call void @llvm.memset.i32( i8* %target_p, i8 1, i32 4, i32 4 ) - call void @llvm.memset.i32( i8* %target_p, i8 1, i32 8, i32 8 ) - ret i32 0 -} - From sabre at nondot.org Thu May 1 01:25:24 2008 From: sabre at nondot.org (Chris Lattner) Date: Thu, 01 May 2008 06:25:24 -0000 Subject: [llvm-commits] [llvm] r50520 - in /llvm/trunk: include/llvm/Transforms/IPO.h include/llvm/Transforms/Scalar.h lib/Transforms/IPO/SimplifyLibCalls.cpp lib/Transforms/Scalar/SimplifyLibCalls.cpp Message-ID: <200805010625.m416POpY015058@zion.cs.uiuc.edu> Author: lattner Date: Thu May 1 01:25:24 2008 New Revision: 50520 URL: http://llvm.org/viewvc/llvm-project?rev=50520&view=rev Log: Delete the IPO simplify-libcalls and completely reimplement it as a FunctionPass. This makes it simpler, fixes dozens of bugs, adds a couple of minor features, and shrinks is considerably: from 2214 to 1437 lines. Added: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Removed: llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp Modified: llvm/trunk/include/llvm/Transforms/IPO.h llvm/trunk/include/llvm/Transforms/Scalar.h Modified: llvm/trunk/include/llvm/Transforms/IPO.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/IPO.h?rev=50520&r1=50519&r2=50520&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/IPO.h (original) +++ llvm/trunk/include/llvm/Transforms/IPO.h Thu May 1 01:25:24 2008 @@ -159,11 +159,6 @@ /// ModulePass *createBlockExtractorPass(const std::vector &BTNE); -/// createOptimizeWellKnownCallsPass - This pass optimizes specific calls to -/// specific well-known (library) functions. -ModulePass *createSimplifyLibCallsPass(); - - /// createIndMemRemPass - This pass removes potential indirect calls of /// malloc and free ModulePass *createIndMemRemPass(); Modified: llvm/trunk/include/llvm/Transforms/Scalar.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Scalar.h?rev=50520&r1=50519&r2=50520&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Scalar.h (original) +++ llvm/trunk/include/llvm/Transforms/Scalar.h Thu May 1 01:25:24 2008 @@ -323,6 +323,12 @@ // can prove are dead. // LoopPass *createLoopDeletionPass(); + +//===----------------------------------------------------------------------===// +// +/// createSimplifyLibCallsPass - This pass optimizes specific calls to +/// specific well-known (library) functions. +FunctionPass *createSimplifyLibCallsPass(); //===----------------------------------------------------------------------===// // Removed: llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp?rev=50519&view=auto ============================================================================== --- llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp (removed) @@ -1,2214 +0,0 @@ -//===- SimplifyLibCalls.cpp - Optimize specific well-known library calls --===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements a module pass that applies a variety of small -// optimizations for calls to specific well-known function calls (e.g. runtime -// library functions). For example, a call to the function "exit(3)" that -// occurs within the main() function can be transformed into a simple "return 3" -// instruction. Any optimization that takes this form (replace call to library -// function with simpler code that provides the same result) belongs in this -// file. -// -//===----------------------------------------------------------------------===// - -#define DEBUG_TYPE "simplify-libcalls" -#include "llvm/Constants.h" -#include "llvm/DerivedTypes.h" -#include "llvm/Instructions.h" -#include "llvm/Intrinsics.h" -#include "llvm/Module.h" -#include "llvm/Pass.h" -#include "llvm/ADT/SmallPtrSet.h" -#include "llvm/ADT/StringMap.h" -#include "llvm/ADT/Statistic.h" -#include "llvm/Config/config.h" -#include "llvm/Support/Compiler.h" -#include "llvm/Support/Debug.h" -#include "llvm/Target/TargetData.h" -#include "llvm/Transforms/IPO.h" -#include -using namespace llvm; - -/// This statistic keeps track of the total number of library calls that have -/// been simplified regardless of which call it is. -STATISTIC(SimplifiedLibCalls, "Number of library calls simplified"); - -namespace { - // Forward declarations - class LibCallOptimization; - class SimplifyLibCalls; - -/// This list is populated by the constructor for LibCallOptimization class. -/// Therefore all subclasses are registered here at static initialization time -/// and this list is what the SimplifyLibCalls pass uses to apply the individual -/// optimizations to the call sites. -/// @brief The list of optimizations deriving from LibCallOptimization -static LibCallOptimization *OptList = 0; - -/// This class is the abstract base class for the set of optimizations that -/// corresponds to one library call. The SimplifyLibCalls pass will call the -/// ValidateCalledFunction method to ask the optimization if a given Function -/// is the kind that the optimization can handle. If the subclass returns true, -/// then SImplifyLibCalls will also call the OptimizeCall method to perform, -/// or attempt to perform, the optimization(s) for the library call. Otherwise, -/// OptimizeCall won't be called. Subclasses are responsible for providing the -/// name of the library call (strlen, strcpy, etc.) to the LibCallOptimization -/// constructor. This is used to efficiently select which call instructions to -/// optimize. The criteria for a "lib call" is "anything with well known -/// semantics", typically a library function that is defined by an international -/// standard. Because the semantics are well known, the optimizations can -/// generally short-circuit actually calling the function if there's a simpler -/// way (e.g. strlen(X) can be reduced to a constant if X is a constant global). -/// @brief Base class for library call optimizations -class VISIBILITY_HIDDEN LibCallOptimization { - LibCallOptimization **Prev, *Next; - const char *FunctionName; ///< Name of the library call we optimize -#ifndef NDEBUG - Statistic occurrences; ///< debug statistic (-debug-only=simplify-libcalls) -#endif -public: - /// The \p fname argument must be the name of the library function being - /// optimized by the subclass. - /// @brief Constructor that registers the optimization. - LibCallOptimization(const char *FName, const char *Description) - : FunctionName(FName) { - -#ifndef NDEBUG - occurrences.construct("simplify-libcalls", Description); -#endif - // Register this optimizer in the list of optimizations. - Next = OptList; - OptList = this; - Prev = &OptList; - if (Next) Next->Prev = &Next; - } - - /// getNext - All libcall optimizations are chained together into a list, - /// return the next one in the list. - LibCallOptimization *getNext() { return Next; } - - /// @brief Deregister from the optlist - virtual ~LibCallOptimization() { - *Prev = Next; - if (Next) Next->Prev = Prev; - } - - /// The implementation of this function in subclasses should determine if - /// \p F is suitable for the optimization. This method is called by - /// SimplifyLibCalls::runOnModule to short circuit visiting all the call - /// sites of such a function if that function is not suitable in the first - /// place. If the called function is suitabe, this method should return true; - /// false, otherwise. This function should also perform any lazy - /// initialization that the LibCallOptimization needs to do, if its to return - /// true. This avoids doing initialization until the optimizer is actually - /// going to be called upon to do some optimization. - /// @brief Determine if the function is suitable for optimization - virtual bool ValidateCalledFunction( - const Function* F, ///< The function that is the target of call sites - SimplifyLibCalls& SLC ///< The pass object invoking us - ) = 0; - - /// The implementations of this function in subclasses is the heart of the - /// SimplifyLibCalls algorithm. Sublcasses of this class implement - /// OptimizeCall to determine if (a) the conditions are right for optimizing - /// the call and (b) to perform the optimization. If an action is taken - /// against ci, the subclass is responsible for returning true and ensuring - /// that ci is erased from its parent. - /// @brief Optimize a call, if possible. - virtual bool OptimizeCall( - CallInst* ci, ///< The call instruction that should be optimized. - SimplifyLibCalls& SLC ///< The pass object invoking us - ) = 0; - - /// @brief Get the name of the library call being optimized - const char *getFunctionName() const { return FunctionName; } - - bool ReplaceCallWith(CallInst *CI, Value *V) { - if (!CI->use_empty()) - CI->replaceAllUsesWith(V); - CI->eraseFromParent(); - return true; - } - - /// @brief Called by SimplifyLibCalls to update the occurrences statistic. - void succeeded() { -#ifndef NDEBUG - DEBUG(++occurrences); -#endif - } -}; - -/// This class is an LLVM Pass that applies each of the LibCallOptimization -/// instances to all the call sites in a module, relatively efficiently. The -/// purpose of this pass is to provide optimizations for calls to well-known -/// functions with well-known semantics, such as those in the c library. The -/// class provides the basic infrastructure for handling runOnModule. Whenever -/// this pass finds a function call, it asks the appropriate optimizer to -/// validate the call (ValidateLibraryCall). If it is validated, then -/// the OptimizeCall method is also called. -/// @brief A ModulePass for optimizing well-known function calls. -class VISIBILITY_HIDDEN SimplifyLibCalls : public ModulePass { -public: - static char ID; // Pass identification, replacement for typeid - SimplifyLibCalls() : ModulePass((intptr_t)&ID) {} - - /// We need some target data for accurate signature details that are - /// target dependent. So we require target data in our AnalysisUsage. - /// @brief Require TargetData from AnalysisUsage. - virtual void getAnalysisUsage(AnalysisUsage& Info) const { - // Ask that the TargetData analysis be performed before us so we can use - // the target data. - Info.addRequired(); - } - - /// For this pass, process all of the function calls in the module, calling - /// ValidateLibraryCall and OptimizeCall as appropriate. - /// @brief Run all the lib call optimizations on a Module. - virtual bool runOnModule(Module &M) { - reset(M); - - bool result = false; - StringMap OptznMap; - for (LibCallOptimization *Optzn = OptList; Optzn; Optzn = Optzn->getNext()) - OptznMap[Optzn->getFunctionName()] = Optzn; - - // The call optimizations can be recursive. That is, the optimization might - // generate a call to another function which can also be optimized. This way - // we make the LibCallOptimization instances very specific to the case they - // handle. It also means we need to keep running over the function calls in - // the module until we don't get any more optimizations possible. - bool found_optimization = false; - do { - found_optimization = false; - for (Module::iterator FI = M.begin(), FE = M.end(); FI != FE; ++FI) { - // All the "well-known" functions are external and have external linkage - // because they live in a runtime library somewhere and were (probably) - // not compiled by LLVM. So, we only act on external functions that - // have external or dllimport linkage and non-empty uses. - if (!FI->isDeclaration() || - !(FI->hasExternalLinkage() || FI->hasDLLImportLinkage()) || - FI->use_empty()) - continue; - - // Get the optimization class that pertains to this function - StringMap::iterator OMI = - OptznMap.find(FI->getName()); - if (OMI == OptznMap.end()) continue; - - LibCallOptimization *CO = OMI->second; - - // Make sure the called function is suitable for the optimization - if (!CO->ValidateCalledFunction(FI, *this)) - continue; - - // Loop over each of the uses of the function - for (Value::use_iterator UI = FI->use_begin(), UE = FI->use_end(); - UI != UE ; ) { - // If the use of the function is a call instruction - if (CallInst* CI = dyn_cast(*UI++)) { - // Do the optimization on the LibCallOptimization. - if (CO->OptimizeCall(CI, *this)) { - ++SimplifiedLibCalls; - found_optimization = result = true; - CO->succeeded(); - } - } - } - } - } while (found_optimization); - - return result; - } - - /// @brief Return the *current* module we're working on. - Module* getModule() const { return M; } - - /// @brief Return the *current* target data for the module we're working on. - TargetData* getTargetData() const { return TD; } - - /// @brief Return the size_t type -- syntactic shortcut - const Type* getIntPtrType() const { return TD->getIntPtrType(); } - - /// @brief Return a Function* for the putchar libcall - Constant *get_putchar() { - if (!putchar_func) - putchar_func = - M->getOrInsertFunction("putchar", Type::Int32Ty, Type::Int32Ty, NULL); - return putchar_func; - } - - /// @brief Return a Function* for the puts libcall - Constant *get_puts() { - if (!puts_func) - puts_func = M->getOrInsertFunction("puts", Type::Int32Ty, - PointerType::getUnqual(Type::Int8Ty), - NULL); - return puts_func; - } - - /// @brief Return a Function* for the fputc libcall - Constant *get_fputc(const Type* FILEptr_type) { - if (!fputc_func) - fputc_func = M->getOrInsertFunction("fputc", Type::Int32Ty, Type::Int32Ty, - FILEptr_type, NULL); - return fputc_func; - } - - /// @brief Return a Function* for the fputs libcall - Constant *get_fputs(const Type* FILEptr_type) { - if (!fputs_func) - fputs_func = M->getOrInsertFunction("fputs", Type::Int32Ty, - PointerType::getUnqual(Type::Int8Ty), - FILEptr_type, NULL); - return fputs_func; - } - - /// @brief Return a Function* for the fwrite libcall - Constant *get_fwrite(const Type* FILEptr_type) { - if (!fwrite_func) - fwrite_func = M->getOrInsertFunction("fwrite", TD->getIntPtrType(), - PointerType::getUnqual(Type::Int8Ty), - TD->getIntPtrType(), - TD->getIntPtrType(), - FILEptr_type, NULL); - return fwrite_func; - } - - /// @brief Return a Function* for the sqrt libcall - Constant *get_sqrt() { - if (!sqrt_func) - sqrt_func = M->getOrInsertFunction("sqrt", Type::DoubleTy, - Type::DoubleTy, NULL); - return sqrt_func; - } - - /// @brief Return a Function* for the strcpy libcall - Constant *get_strcpy() { - if (!strcpy_func) - strcpy_func = M->getOrInsertFunction("strcpy", - PointerType::getUnqual(Type::Int8Ty), - PointerType::getUnqual(Type::Int8Ty), - PointerType::getUnqual(Type::Int8Ty), - NULL); - return strcpy_func; - } - - /// @brief Return a Function* for the strlen libcall - Constant *get_strlen() { - if (!strlen_func) - strlen_func = M->getOrInsertFunction("strlen", TD->getIntPtrType(), - PointerType::getUnqual(Type::Int8Ty), - NULL); - return strlen_func; - } - - /// @brief Return a Function* for the memchr libcall - Constant *get_memchr() { - if (!memchr_func) - memchr_func = M->getOrInsertFunction("memchr", - PointerType::getUnqual(Type::Int8Ty), - PointerType::getUnqual(Type::Int8Ty), - Type::Int32Ty, TD->getIntPtrType(), - NULL); - return memchr_func; - } - - /// @brief Return a Function* for the memcpy libcall - Constant *get_memcpy() { - if (!memcpy_func) { - Intrinsic::ID IID = (TD->getIntPtrType() == Type::Int32Ty) ? - Intrinsic::memcpy_i32 : Intrinsic::memcpy_i64; - memcpy_func = Intrinsic::getDeclaration(M, IID); - } - return memcpy_func; - } - - Constant *getUnaryFloatFunction(const char *BaseName, const Type *T = 0) { - if (T == 0) T = Type::FloatTy; - - char NameBuffer[20]; - const char *Name; - if (T == Type::DoubleTy) - Name = BaseName; // floor - else { - Name = NameBuffer; - unsigned NameLen = strlen(BaseName); - assert(NameLen < sizeof(NameBuffer)-2 && "Buffer too small"); - memcpy(NameBuffer, BaseName, NameLen); - if (T == Type::FloatTy) - NameBuffer[NameLen] = 'f'; // floorf - else - NameBuffer[NameLen] = 'l'; // floorl - NameBuffer[NameLen+1] = 0; - } - - return M->getOrInsertFunction(Name, T, T, NULL); - } - - Constant *get_floorf() { return getUnaryFloatFunction("floor"); } - Constant *get_ceilf() { return getUnaryFloatFunction( "ceil"); } - Constant *get_roundf() { return getUnaryFloatFunction("round"); } - Constant *get_rintf() { return getUnaryFloatFunction( "rint"); } - Constant *get_nearbyintf() { return getUnaryFloatFunction("nearbyint"); } - - - -private: - /// @brief Reset our cached data for a new Module - void reset(Module& mod) { - M = &mod; - TD = &getAnalysis(); - putchar_func = 0; - puts_func = 0; - fputc_func = 0; - fputs_func = 0; - fwrite_func = 0; - memcpy_func = 0; - memchr_func = 0; - sqrt_func = 0; - strcpy_func = 0; - strlen_func = 0; - } - -private: - /// Caches for function pointers. - Constant *putchar_func, *puts_func; - Constant *fputc_func, *fputs_func, *fwrite_func; - Constant *memcpy_func, *memchr_func; - Constant *sqrt_func; - Constant *strcpy_func, *strlen_func; - Module *M; ///< Cached Module - TargetData *TD; ///< Cached TargetData -}; - -char SimplifyLibCalls::ID = 0; -// Register the pass -RegisterPass -X("simplify-libcalls", "Simplify well-known library calls"); - -} // anonymous namespace - -// The only public symbol in this file which just instantiates the pass object -ModulePass *llvm::createSimplifyLibCallsPass() { - return new SimplifyLibCalls(); -} - -// Forward declare utility functions. -static bool GetConstantStringInfo(Value *V, std::string &Str); -static Value *CastToCStr(Value *V, Instruction *IP); -static uint64_t GetStringLength(Value *V); - - -// Classes below here, in the anonymous namespace, are all subclasses of the -// LibCallOptimization class, each implementing all optimizations possible for a -// single well-known library call. Each has a static singleton instance that -// auto registers it into the "optlist" global above. -namespace { - -/// This LibCallOptimization will find instances of a call to "exit" that occurs -/// within the "main" function and change it to a simple "ret" instruction with -/// the same value passed to the exit function. When this is done, it splits the -/// basic block at the exit(3) call and deletes the call instruction. -/// @brief Replace calls to exit in main with a simple return -struct VISIBILITY_HIDDEN ExitInMainOptimization : public LibCallOptimization { - ExitInMainOptimization() : LibCallOptimization("exit", - "Number of 'exit' calls simplified") {} - - // Make sure the called function looks like exit (int argument, int return - // type, external linkage, not varargs). - virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){ - return F->arg_size() >= 1 && F->arg_begin()->getType()->isInteger(); - } - - virtual bool OptimizeCall(CallInst* ci, SimplifyLibCalls& SLC) { - // To be careful, we check that the call to exit is coming from "main", that - // main has external linkage, and the return type of main and the argument - // to exit have the same type. - Function *from = ci->getParent()->getParent(); - if (from->hasExternalLinkage()) - if (from->getReturnType() == ci->getOperand(1)->getType() - && !isa(from->getReturnType())) - if (from->getName() == "main") { - // Okay, time to actually do the optimization. First, get the basic - // block of the call instruction - BasicBlock* bb = ci->getParent(); - - // Create a return instruction that we'll replace the call with. - // Note that the argument of the return is the argument of the call - // instruction. - ReturnInst::Create(ci->getOperand(1), ci); - - // Split the block at the call instruction which places it in a new - // basic block. - bb->splitBasicBlock(ci); - - // The block split caused a branch instruction to be inserted into - // the end of the original block, right after the return instruction - // that we put there. That's not a valid block, so delete the branch - // instruction. - bb->getInstList().pop_back(); - - // Now we can finally get rid of the call instruction which now lives - // in the new basic block. - ci->eraseFromParent(); - - // Optimization succeeded, return true. - return true; - } - // We didn't pass the criteria for this optimization so return false - return false; - } -} ExitInMainOptimizer; - -/// This LibCallOptimization will simplify a call to the strcat library -/// function. The simplification is possible only if the string being -/// concatenated is a constant array or a constant expression that results in -/// a constant string. In this case we can replace it with strlen + llvm.memcpy -/// of the constant string. Both of these calls are further reduced, if possible -/// on subsequent passes. -/// @brief Simplify the strcat library function. -struct VISIBILITY_HIDDEN StrCatOptimization : public LibCallOptimization { -public: - /// @brief Default constructor - StrCatOptimization() : LibCallOptimization("strcat", - "Number of 'strcat' calls simplified") {} - -public: - - /// @brief Make sure that the "strcat" function has the right prototype - virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){ - const FunctionType *FT = F->getFunctionType(); - return FT->getNumParams() == 2 && - FT->getReturnType() == PointerType::getUnqual(Type::Int8Ty) && - FT->getParamType(0) == FT->getReturnType() && - FT->getParamType(1) == FT->getReturnType(); - } - - /// @brief Optimize the strcat library function - virtual bool OptimizeCall(CallInst *CI, SimplifyLibCalls &SLC) { - // Extract some information from the instruction - Value *Dst = CI->getOperand(1); - Value *Src = CI->getOperand(2); - - // See if we can get the length of the input string. - uint64_t Len = GetStringLength(Src); - if (Len == 0) return false; - --Len; // Unbias length. - - // Handle the simple, do-nothing case - if (Len == 0) - return ReplaceCallWith(CI, Dst); - - // We need to find the end of the destination string. That's where the - // memory is to be moved to. We just generate a call to strlen. - CallInst *DstLen = CallInst::Create(SLC.get_strlen(), Dst, - Dst->getName()+".len", CI); - - // Now that we have the destination's length, we must index into the - // destination's pointer to get the actual memcpy destination (end of - // the string .. we're concatenating). - Dst = GetElementPtrInst::Create(Dst, DstLen, Dst->getName()+".indexed", CI); - - // We have enough information to now generate the memcpy call to - // do the concatenation for us. - Value *Vals[] = { - Dst, Src, - ConstantInt::get(SLC.getIntPtrType(), Len+1), // copy nul byte. - ConstantInt::get(Type::Int32Ty, 1) // alignment - }; - CallInst::Create(SLC.get_memcpy(), Vals, Vals + 4, "", CI); - - return ReplaceCallWith(CI, Dst); - } -} StrCatOptimizer; - -/// This LibCallOptimization will simplify a call to the strchr library -/// function. It optimizes out cases where the arguments are both constant -/// and the result can be determined statically. -/// @brief Simplify the strcmp library function. -struct VISIBILITY_HIDDEN StrChrOptimization : public LibCallOptimization { -public: - StrChrOptimization() : LibCallOptimization("strchr", - "Number of 'strchr' calls simplified") {} - - /// @brief Make sure that the "strchr" function has the right prototype - virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){ - const FunctionType *FT = F->getFunctionType(); - return FT->getNumParams() == 2 && - FT->getReturnType() == PointerType::getUnqual(Type::Int8Ty) && - FT->getParamType(0) == FT->getReturnType() && - isa(FT->getParamType(1)); - } - - /// @brief Perform the strchr optimizations - virtual bool OptimizeCall(CallInst *CI, SimplifyLibCalls &SLC) { - Value *SrcStr = CI->getOperand(1); - // If the second operand is not constant, see if we can compute the length - // and turn this into memchr. - ConstantInt *CSI = dyn_cast(CI->getOperand(2)); - if (CSI == 0) { - uint64_t Len = GetStringLength(SrcStr); - if (Len == 0) return false; - - Value *Args[3] = { - CI->getOperand(1), - CI->getOperand(2), - ConstantInt::get(SLC.getIntPtrType(), Len) // include nul. - }; - return ReplaceCallWith(CI, CallInst::Create(SLC.get_memchr(), - Args, Args + 3, - CI->getName(), CI)); - } - - // Otherwise, the character is a constant, see if the first argument is - // a string literal. If so, we can constant fold. - std::string Str; - if (!GetConstantStringInfo(SrcStr, Str)) - return false; - - // strchr can find the nul character. - Str += '\0'; - - // Get the character we're looking for - char CharValue = CSI->getSExtValue(); - - // Compute the offset - uint64_t i = 0; - while (1) { - if (i == Str.size()) // Didn't find the char. strchr returns null. - return ReplaceCallWith(CI, Constant::getNullValue(CI->getType())); - // Did we find our match? - if (Str[i] == CharValue) - break; - ++i; - } - - // strchr(s+n,c) -> gep(s+n+i,c) - // (if c is a constant integer and s is a constant string) - Value *Idx = ConstantInt::get(Type::Int64Ty, i); - Value *GEP = GetElementPtrInst::Create(CI->getOperand(1), Idx, - CI->getOperand(1)->getName() + - ".strchr", CI); - return ReplaceCallWith(CI, GEP); - } -} StrChrOptimizer; - -/// This LibCallOptimization will simplify a call to the strcmp library -/// function. It optimizes out cases where one or both arguments are constant -/// and the result can be determined statically. -/// @brief Simplify the strcmp library function. -struct VISIBILITY_HIDDEN StrCmpOptimization : public LibCallOptimization { -public: - StrCmpOptimization() : LibCallOptimization("strcmp", - "Number of 'strcmp' calls simplified") {} - - /// @brief Make sure that the "strcmp" function has the right prototype - virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){ - const FunctionType *FT = F->getFunctionType(); - return FT->getReturnType() == Type::Int32Ty && FT->getNumParams() == 2 && - FT->getParamType(0) == FT->getParamType(1) && - FT->getParamType(0) == PointerType::getUnqual(Type::Int8Ty); - } - - /// @brief Perform the strcmp optimization - virtual bool OptimizeCall(CallInst *CI, SimplifyLibCalls &SLC) { - // First, check to see if src and destination are the same. If they are, - // then the optimization is to replace the CallInst with a constant 0 - // because the call is a no-op. - Value *Str1P = CI->getOperand(1); - Value *Str2P = CI->getOperand(2); - if (Str1P == Str2P) // strcmp(x,x) -> 0 - return ReplaceCallWith(CI, ConstantInt::get(CI->getType(), 0)); - - std::string Str1; - if (!GetConstantStringInfo(Str1P, Str1)) - return false; - if (Str1.empty()) { - // strcmp("", x) -> *x - Value *V = new LoadInst(Str2P, CI->getName()+".load", CI); - V = new ZExtInst(V, CI->getType(), CI->getName()+".int", CI); - return ReplaceCallWith(CI, V); - } - - std::string Str2; - if (!GetConstantStringInfo(Str2P, Str2)) - return false; - if (Str2.empty()) { - // strcmp(x,"") -> *x - Value *V = new LoadInst(Str1P, CI->getName()+".load", CI); - V = new ZExtInst(V, CI->getType(), CI->getName()+".int", CI); - return ReplaceCallWith(CI, V); - } - - // strcmp(x, y) -> cnst (if both x and y are constant strings) - int R = strcmp(Str1.c_str(), Str2.c_str()); - return ReplaceCallWith(CI, ConstantInt::get(CI->getType(), R)); - } -} StrCmpOptimizer; - -/// This LibCallOptimization will simplify a call to the strncmp library -/// function. It optimizes out cases where one or both arguments are constant -/// and the result can be determined statically. -/// @brief Simplify the strncmp library function. -struct VISIBILITY_HIDDEN StrNCmpOptimization : public LibCallOptimization { -public: - StrNCmpOptimization() : LibCallOptimization("strncmp", - "Number of 'strncmp' calls simplified") {} - - /// @brief Make sure that the "strncmp" function has the right prototype - virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){ - const FunctionType *FT = F->getFunctionType(); - return FT->getReturnType() == Type::Int32Ty && FT->getNumParams() == 3 && - FT->getParamType(0) == FT->getParamType(1) && - FT->getParamType(0) == PointerType::getUnqual(Type::Int8Ty) && - isa(FT->getParamType(2)); - return false; - } - - /// @brief Perform the strncmp optimization - virtual bool OptimizeCall(CallInst *CI, SimplifyLibCalls &SLC) { - // First, check to see if src and destination are the same. If they are, - // then the optimization is to replace the CallInst with a constant 0 - // because the call is a no-op. - Value *Str1P = CI->getOperand(1); - Value *Str2P = CI->getOperand(2); - if (Str1P == Str2P) // strncmp(x,x, n) -> 0 - return ReplaceCallWith(CI, ConstantInt::get(CI->getType(), 0)); - - // Check the length argument, if it is Constant zero then the strings are - // considered equal. - uint64_t Length; - if (ConstantInt *LengthArg = dyn_cast(CI->getOperand(3))) - Length = LengthArg->getZExtValue(); - else - return false; - - if (Length == 0) // strncmp(x,y,0) -> 0 - return ReplaceCallWith(CI, ConstantInt::get(CI->getType(), 0)); - - std::string Str1; - if (!GetConstantStringInfo(Str1P, Str1)) - return false; - if (Str1.empty()) { - // strncmp("", x, n) -> *x - Value *V = new LoadInst(Str2P, CI->getName()+".load", CI); - V = new ZExtInst(V, CI->getType(), CI->getName()+".int", CI); - return ReplaceCallWith(CI, V); - } - - std::string Str2; - if (!GetConstantStringInfo(Str2P, Str2)) - return false; - if (Str2.empty()) { - // strncmp(x, "", n) -> *x - Value *V = new LoadInst(Str1P, CI->getName()+".load", CI); - V = new ZExtInst(V, CI->getType(), CI->getName()+".int", CI); - return ReplaceCallWith(CI, V); - } - - // strncmp(x, y, n) -> cnst (if both x and y are constant strings) - int R = strncmp(Str1.c_str(), Str2.c_str(), Length); - return ReplaceCallWith(CI, ConstantInt::get(CI->getType(), R)); - } -} StrNCmpOptimizer; - -/// This LibCallOptimization will simplify a call to the strcpy library -/// function. Two optimizations are possible: -/// (1) If src and dest are the same and not volatile, just return dest -/// (2) If the src is a constant then we can convert to llvm.memmove -/// @brief Simplify the strcpy library function. -struct VISIBILITY_HIDDEN StrCpyOptimization : public LibCallOptimization { -public: - StrCpyOptimization() : LibCallOptimization("strcpy", - "Number of 'strcpy' calls simplified") {} - - /// @brief Make sure that the "strcpy" function has the right prototype - virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){ - const FunctionType *FT = F->getFunctionType(); - return FT->getNumParams() == 2 && - FT->getParamType(0) == FT->getParamType(1) && - FT->getReturnType() == FT->getParamType(0) && - FT->getParamType(0) == PointerType::getUnqual(Type::Int8Ty); - } - - /// @brief Perform the strcpy optimization - virtual bool OptimizeCall(CallInst *CI, SimplifyLibCalls &SLC) { - // First, check to see if src and destination are the same. If they are, - // then the optimization is to replace the CallInst with the destination - // because the call is a no-op. Note that this corresponds to the - // degenerate strcpy(X,X) case which should have "undefined" results - // according to the C specification. However, it occurs sometimes and - // we optimize it as a no-op. - Value *Dst = CI->getOperand(1); - Value *Src = CI->getOperand(2); - if (Dst == Src) { - // strcpy(x, x) -> x - return ReplaceCallWith(CI, Dst); - } - - // See if we can get the length of the input string. - uint64_t Len = GetStringLength(Src); - if (Len == 0) return false; - --Len; // Unbias length. - - // If the constant string's length is zero we can optimize this by just - // doing a store of 0 at the first byte of the destination. - if (Len == 0) { - new StoreInst(ConstantInt::get(Type::Int8Ty, 0), Dst, CI); - return ReplaceCallWith(CI, Dst); - } - - // We have enough information to now generate the memcpy call to - // do the concatenation for us. - Value *MemcpyOps[] = { - Dst, Src, - ConstantInt::get(SLC.getIntPtrType(), Len+1),// Length including nul byte. - ConstantInt::get(Type::Int32Ty, 1) // alignment - }; - CallInst::Create(SLC.get_memcpy(), MemcpyOps, MemcpyOps + 4, "", CI); - - return ReplaceCallWith(CI, Dst); - } -} StrCpyOptimizer; - -/// This LibCallOptimization will simplify a call to the strlen library -/// function by replacing it with a constant value if the string provided to -/// it is a constant array. -/// @brief Simplify the strlen library function. -struct VISIBILITY_HIDDEN StrLenOptimization : public LibCallOptimization { - StrLenOptimization() : LibCallOptimization("strlen", - "Number of 'strlen' calls simplified") {} - - /// @brief Make sure that the "strlen" function has the right prototype - virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){ - const FunctionType *FT = F->getFunctionType(); - return FT->getNumParams() == 1 && - FT->getParamType(0) == PointerType::getUnqual(Type::Int8Ty) && - isa(FT->getReturnType()); - } - - /// @brief Perform the strlen optimization - virtual bool OptimizeCall(CallInst *CI, SimplifyLibCalls &SLC) { - // Make sure we're dealing with an sbyte* here. - Value *Src = CI->getOperand(1); - - // Does the call to strlen have exactly one use? - if (CI->hasOneUse()) { - // Is that single use a icmp operator? - if (ICmpInst *Cmp = dyn_cast(CI->use_back())) - // Is it compared against a constant integer? - if (ConstantInt *Cst = dyn_cast(Cmp->getOperand(1))) { - // If its compared against length 0 with == or != - if (Cst->getZExtValue() == 0 && Cmp->isEquality()) { - // strlen(x) != 0 -> *x != 0 - // strlen(x) == 0 -> *x == 0 - Value *V = new LoadInst(Src, Src->getName()+".first", CI); - V = new ICmpInst(Cmp->getPredicate(), V, - ConstantInt::get(Type::Int8Ty, 0), - Cmp->getName()+".strlen", CI); - Cmp->replaceAllUsesWith(V); - Cmp->eraseFromParent(); - return ReplaceCallWith(CI, 0); // no uses. - } - } - } - - // Get the length of the constant string operand - // strlen("xyz") -> 3 (for example) - if (uint64_t Len = GetStringLength(Src)) - return ReplaceCallWith(CI, ConstantInt::get(CI->getType(), Len-1)); - return false; - } -} StrLenOptimizer; - -/// IsOnlyUsedInEqualsComparison - Return true if it only matters that the value -/// is equal or not-equal to zero. -static bool IsOnlyUsedInEqualsZeroComparison(Instruction *I) { - for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); - UI != E; ++UI) { - if (ICmpInst *IC = dyn_cast(*UI)) - if (IC->isEquality()) - if (Constant *C = dyn_cast(IC->getOperand(1))) - if (C->isNullValue()) - continue; - // Unknown instruction. - return false; - } - return true; -} - -/// This memcmpOptimization will simplify a call to the memcmp library -/// function. -struct VISIBILITY_HIDDEN memcmpOptimization : public LibCallOptimization { - /// @brief Default Constructor - memcmpOptimization() - : LibCallOptimization("memcmp", "Number of 'memcmp' calls simplified") {} - - /// @brief Make sure that the "memcmp" function has the right prototype - virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &TD) { - Function::const_arg_iterator AI = F->arg_begin(); - if (F->arg_size() != 3 || !isa(AI->getType())) return false; - if (!isa((++AI)->getType())) return false; - if (!(++AI)->getType()->isInteger()) return false; - if (!F->getReturnType()->isInteger()) return false; - return true; - } - - /// Because of alignment and instruction information that we don't have, we - /// leave the bulk of this to the code generators. - /// - /// Note that we could do much more if we could force alignment on otherwise - /// small aligned allocas, or if we could indicate that loads have a small - /// alignment. - virtual bool OptimizeCall(CallInst *CI, SimplifyLibCalls &TD) { - Value *LHS = CI->getOperand(1), *RHS = CI->getOperand(2); - - // If the two operands are the same, return zero. - if (LHS == RHS) { - // memcmp(s,s,x) -> 0 - return ReplaceCallWith(CI, Constant::getNullValue(CI->getType())); - } - - // Make sure we have a constant length. - ConstantInt *LenC = dyn_cast(CI->getOperand(3)); - if (!LenC) return false; - uint64_t Len = LenC->getZExtValue(); - - // If the length is zero, this returns 0. - switch (Len) { - case 0: - // memcmp(s1,s2,0) -> 0 - return ReplaceCallWith(CI, Constant::getNullValue(CI->getType())); - case 1: { - // memcmp(S1,S2,1) -> *(ubyte*)S1 - *(ubyte*)S2 - const Type *UCharPtr = PointerType::getUnqual(Type::Int8Ty); - CastInst *Op1Cast = CastInst::create( - Instruction::BitCast, LHS, UCharPtr, LHS->getName(), CI); - CastInst *Op2Cast = CastInst::create( - Instruction::BitCast, RHS, UCharPtr, RHS->getName(), CI); - Value *S1V = new LoadInst(Op1Cast, LHS->getName()+".val", CI); - Value *S2V = new LoadInst(Op2Cast, RHS->getName()+".val", CI); - Value *RV = BinaryOperator::createSub(S1V, S2V, CI->getName()+".diff",CI); - if (RV->getType() != CI->getType()) - RV = CastInst::createIntegerCast(RV, CI->getType(), false, - RV->getName(), CI); - return ReplaceCallWith(CI, RV); - } - case 2: - if (IsOnlyUsedInEqualsZeroComparison(CI)) { - // TODO: IF both are aligned, use a short load/compare. - - // memcmp(S1,S2,2) -> S1[0]-S2[0] | S1[1]-S2[1] iff only ==/!= 0 matters - const Type *UCharPtr = PointerType::getUnqual(Type::Int8Ty); - CastInst *Op1Cast = CastInst::create( - Instruction::BitCast, LHS, UCharPtr, LHS->getName(), CI); - CastInst *Op2Cast = CastInst::create( - Instruction::BitCast, RHS, UCharPtr, RHS->getName(), CI); - Value *S1V1 = new LoadInst(Op1Cast, LHS->getName()+".val1", CI); - Value *S2V1 = new LoadInst(Op2Cast, RHS->getName()+".val1", CI); - Value *D1 = BinaryOperator::createSub(S1V1, S2V1, - CI->getName()+".d1", CI); - Constant *One = ConstantInt::get(Type::Int32Ty, 1); - Value *G1 = GetElementPtrInst::Create(Op1Cast, One, "next1v", CI); - Value *G2 = GetElementPtrInst::Create(Op2Cast, One, "next2v", CI); - Value *S1V2 = new LoadInst(G1, LHS->getName()+".val2", CI); - Value *S2V2 = new LoadInst(G2, RHS->getName()+".val2", CI); - Value *D2 = BinaryOperator::createSub(S1V2, S2V2, - CI->getName()+".d1", CI); - Value *Or = BinaryOperator::createOr(D1, D2, CI->getName()+".res", CI); - if (Or->getType() != CI->getType()) - Or = CastInst::createIntegerCast(Or, CI->getType(), false /*ZExt*/, - Or->getName(), CI); - return ReplaceCallWith(CI, Or); - } - break; - default: - break; - } - - return false; - } -} memcmpOptimizer; - -/// This LibCallOptimization will simplify a call to the memcpy library -/// function. It simply converts them into calls to llvm.memcpy.*; -/// the resulting call should be optimized later. -/// @brief Simplify the memcpy library function. -struct VISIBILITY_HIDDEN MemCpyOptimization : public LibCallOptimization { -public: - MemCpyOptimization() : LibCallOptimization("memcpy", - "Number of 'memcpy' calls simplified") {} - - /// @brief Make sure that the "memcpy" function has the right prototype - virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){ - const FunctionType *FT = F->getFunctionType(); - const Type* voidPtr = PointerType::getUnqual(Type::Int8Ty); - return FT->getReturnType() == voidPtr && FT->getNumParams() == 3 && - FT->getParamType(0) == voidPtr && - FT->getParamType(1) == voidPtr && - FT->getParamType(2) == SLC.getIntPtrType(); - } - - /// @brief Perform the memcpy optimization - virtual bool OptimizeCall(CallInst *CI, SimplifyLibCalls &SLC) { - Value *MemcpyOps[] = { - CI->getOperand(1), CI->getOperand(2), CI->getOperand(3), - ConstantInt::get(Type::Int32Ty, 1) // align = 1 always. - }; - CallInst::Create(SLC.get_memcpy(), MemcpyOps, MemcpyOps + 4, "", CI); - // memcpy always returns the destination - return ReplaceCallWith(CI, CI->getOperand(1)); - } -} MemCpyOptimizer; - -/// This LibCallOptimization will simplify a call to the memcpy library -/// function by expanding it out to a single store of size 0, 1, 2, 4, or 8 -/// bytes depending on the length of the string and the alignment. Additional -/// optimizations are possible in code generation (sequence of immediate store) -/// @brief Simplify the memcpy library function. -struct VISIBILITY_HIDDEN LLVMMemCpyMoveOptzn : public LibCallOptimization { - LLVMMemCpyMoveOptzn(const char* fname, const char* desc) - : LibCallOptimization(fname, desc) {} - - /// @brief Make sure that the "memcpy" function has the right prototype - virtual bool ValidateCalledFunction(const Function* f, SimplifyLibCalls& TD) { - // Just make sure this has 4 arguments per LLVM spec. - return (f->arg_size() == 4); - } - - /// Because of alignment and instruction information that we don't have, we - /// leave the bulk of this to the code generators. The optimization here just - /// deals with a few degenerate cases where the length of the string and the - /// alignment match the sizes of our intrinsic types so we can do a load and - /// store instead of the memcpy call. - /// @brief Perform the memcpy optimization. - virtual bool OptimizeCall(CallInst* ci, SimplifyLibCalls& TD) { - // Make sure we have constant int values to work with - ConstantInt* LEN = dyn_cast(ci->getOperand(3)); - if (!LEN) - return false; - ConstantInt* ALIGN = dyn_cast(ci->getOperand(4)); - if (!ALIGN) - return false; - - // If the length is larger than the alignment, we can't optimize - uint64_t len = LEN->getZExtValue(); - uint64_t alignment = ALIGN->getZExtValue(); - if (alignment == 0) - alignment = 1; // Alignment 0 is identity for alignment 1 - if (len > alignment) - return false; - - // Get the type we will cast to, based on size of the string - Value* dest = ci->getOperand(1); - Value* src = ci->getOperand(2); - const Type* castType = 0; - switch (len) { - case 0: - // memcpy(d,s,0,a) -> d - return ReplaceCallWith(ci, 0); - case 1: castType = Type::Int8Ty; break; - case 2: castType = Type::Int16Ty; break; - case 4: castType = Type::Int32Ty; break; - case 8: castType = Type::Int64Ty; break; - default: - return false; - } - - // Cast source and dest to the right sized primitive and then load/store - CastInst* SrcCast = CastInst::create(Instruction::BitCast, - src, PointerType::getUnqual(castType), src->getName()+".cast", ci); - CastInst* DestCast = CastInst::create(Instruction::BitCast, - dest, PointerType::getUnqual(castType),dest->getName()+".cast", ci); - LoadInst* LI = new LoadInst(SrcCast,SrcCast->getName()+".val",ci); - new StoreInst(LI, DestCast, ci); - return ReplaceCallWith(ci, 0); - } -}; - -/// This LibCallOptimization will simplify a call to the memcpy/memmove library -/// functions. -LLVMMemCpyMoveOptzn LLVMMemCpyOptimizer32("llvm.memcpy.i32", - "Number of 'llvm.memcpy' calls simplified"); -LLVMMemCpyMoveOptzn LLVMMemCpyOptimizer64("llvm.memcpy.i64", - "Number of 'llvm.memcpy' calls simplified"); -LLVMMemCpyMoveOptzn LLVMMemMoveOptimizer32("llvm.memmove.i32", - "Number of 'llvm.memmove' calls simplified"); -LLVMMemCpyMoveOptzn LLVMMemMoveOptimizer64("llvm.memmove.i64", - "Number of 'llvm.memmove' calls simplified"); - -/// This LibCallOptimization will simplify a call to the memset library -/// function by expanding it out to a single store of size 0, 1, 2, 4, or 8 -/// bytes depending on the length argument. -struct VISIBILITY_HIDDEN LLVMMemSetOptimization : public LibCallOptimization { - /// @brief Default Constructor - LLVMMemSetOptimization(const char *Name) : LibCallOptimization(Name, - "Number of 'llvm.memset' calls simplified") {} - - /// @brief Make sure that the "memset" function has the right prototype - virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &TD) { - // Just make sure this has 3 arguments per LLVM spec. - return F->arg_size() == 4; - } - - /// Because of alignment and instruction information that we don't have, we - /// leave the bulk of this to the code generators. The optimization here just - /// deals with a few degenerate cases where the length parameter is constant - /// and the alignment matches the sizes of our intrinsic types so we can do - /// store instead of the memcpy call. Other calls are transformed into the - /// llvm.memset intrinsic. - /// @brief Perform the memset optimization. - virtual bool OptimizeCall(CallInst *ci, SimplifyLibCalls &TD) { - // Make sure we have constant int values to work with - ConstantInt* LEN = dyn_cast(ci->getOperand(3)); - if (!LEN) - return false; - ConstantInt* ALIGN = dyn_cast(ci->getOperand(4)); - if (!ALIGN) - return false; - - // Extract the length and alignment - uint64_t len = LEN->getZExtValue(); - uint64_t alignment = ALIGN->getZExtValue(); - - // Alignment 0 is identity for alignment 1 - if (alignment == 0) - alignment = 1; - - // If the length is zero, this is a no-op - if (len == 0) { - // memset(d,c,0,a) -> noop - return ReplaceCallWith(ci, 0); - } - - // If the length is larger than the alignment, we can't optimize - if (len > alignment) - return false; - - // Make sure we have a constant ubyte to work with so we can extract - // the value to be filled. - ConstantInt* FILL = dyn_cast(ci->getOperand(2)); - if (!FILL) - return false; - if (FILL->getType() != Type::Int8Ty) - return false; - - // memset(s,c,n) -> store s, c (for n=1,2,4,8) - - // Extract the fill character - uint64_t fill_char = FILL->getZExtValue(); - uint64_t fill_value = fill_char; - - // Get the type we will cast to, based on size of memory area to fill, and - // and the value we will store there. - Value* dest = ci->getOperand(1); - const Type* castType = 0; - switch (len) { - case 1: - castType = Type::Int8Ty; - break; - case 2: - castType = Type::Int16Ty; - fill_value |= fill_char << 8; - break; - case 4: - castType = Type::Int32Ty; - fill_value |= fill_char << 8 | fill_char << 16 | fill_char << 24; - break; - case 8: - castType = Type::Int64Ty; - fill_value |= fill_char << 8 | fill_char << 16 | fill_char << 24; - fill_value |= fill_char << 32 | fill_char << 40 | fill_char << 48; - fill_value |= fill_char << 56; - break; - default: - return false; - } - - // Cast dest to the right sized primitive and then load/store - CastInst* DestCast = new BitCastInst(dest, PointerType::getUnqual(castType), - dest->getName()+".cast", ci); - new StoreInst(ConstantInt::get(castType,fill_value),DestCast, ci); - return ReplaceCallWith(ci, 0); - } -}; - -LLVMMemSetOptimization MemSet32Optimizer("llvm.memset.i32"); -LLVMMemSetOptimization MemSet64Optimizer("llvm.memset.i64"); - - -/// This LibCallOptimization will simplify calls to the "pow" library -/// function. It looks for cases where the result of pow is well known and -/// substitutes the appropriate value. -/// @brief Simplify the pow library function. -struct VISIBILITY_HIDDEN PowOptimization : public LibCallOptimization { -public: - /// @brief Default Constructor - PowOptimization(const char *Name) : LibCallOptimization(Name, - "Number of 'pow' calls simplified") {} - - /// @brief Make sure that the "pow" function has the right prototype - virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){ - // Just make sure this has 2 arguments of the same FP type, which match the - // result type. - const FunctionType *FT = F->getFunctionType(); - return FT->getNumParams() == 2 && - FT->getParamType(0) == FT->getParamType(1) && - FT->getParamType(0) == FT->getReturnType() && - FT->getParamType(0)->isFloatingPoint(); - } - - /// @brief Perform the pow optimization. - virtual bool OptimizeCall(CallInst *CI, SimplifyLibCalls &SLC) { - Value *Op1 = CI->getOperand(1); - Value *Op2 = CI->getOperand(2); - if (ConstantFP *Op1C = dyn_cast(Op1)) { - if (Op1C->isExactlyValue(1.0)) // pow(1.0, x) -> 1.0 - return ReplaceCallWith(CI, Op1C); - if (Op1C->isExactlyValue(2.0)) {// pow(2.0, x) -> exp2(x) - Value *Exp2 = SLC.getUnaryFloatFunction("exp2", CI->getType()); - Value *Res = CallInst::Create(Exp2, Op2, CI->getName()+"exp2", CI); - return ReplaceCallWith(CI, Res); - } - } - - ConstantFP *Op2C = dyn_cast(Op2); - if (Op2C == 0) return false; - - if (Op2C->getValueAPF().isZero()) { - // pow(x, 0.0) -> 1.0 - return ReplaceCallWith(CI, ConstantFP::get(CI->getType(), 1.0)); - } else if (Op2C->isExactlyValue(0.5)) { - // FIXME: This is not safe for -0.0 and -inf. This can only be done when - // 'unsafe' math optimizations are allowed. - // x pow(x, 0.5) sqrt(x) - // --------------------------------------------- - // -0.0 +0.0 -0.0 - // -inf +inf NaN -#if 0 - // pow(x, 0.5) -> sqrt(x) - Value *Sqrt = CallInst::Create(SLC.get_sqrt(), Op1, "sqrt", CI); - return ReplaceCallWith(CI, Sqrt); -#endif - } else if (Op2C->isExactlyValue(1.0)) { - // pow(x, 1.0) -> x - return ReplaceCallWith(CI, Op1); - } else if (Op2C->isExactlyValue(2.0)) { - // pow(x, 2.0) -> x*x - Value *Sq = BinaryOperator::createMul(Op1, Op1, "pow2", CI); - return ReplaceCallWith(CI, Sq); - } else if (Op2C->isExactlyValue(-1.0)) { - // pow(x, -1.0) -> 1.0/x - Value *R = BinaryOperator::createFDiv(ConstantFP::get(CI->getType(), 1.0), - Op1, CI->getName()+".pow", CI); - return ReplaceCallWith(CI, R); - } - return false; // opt failed - } -}; - -PowOptimization PowFOptimizer("powf"); -PowOptimization PowOptimizer("pow"); -PowOptimization PowLOptimizer("powl"); - - -/// This LibCallOptimization will simplify calls to the "printf" library -/// function. It looks for cases where the result of printf is not used and the -/// operation can be reduced to something simpler. -/// @brief Simplify the printf library function. -struct VISIBILITY_HIDDEN PrintfOptimization : public LibCallOptimization { -public: - /// @brief Default Constructor - PrintfOptimization() : LibCallOptimization("printf", - "Number of 'printf' calls simplified") {} - - /// @brief Make sure that the "printf" function has the right prototype - virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){ - // Just make sure this has at least 1 argument and returns an integer or - // void type. - const FunctionType *FT = F->getFunctionType(); - return FT->getNumParams() >= 1 && - (isa(FT->getReturnType()) || - FT->getReturnType() == Type::VoidTy); - } - - /// @brief Perform the printf optimization. - virtual bool OptimizeCall(CallInst *CI, SimplifyLibCalls &SLC) { - // All the optimizations depend on the length of the first argument and the - // fact that it is a constant string array. Check that now - std::string FormatStr; - if (!GetConstantStringInfo(CI->getOperand(1), FormatStr)) - return false; - - // If this is a simple constant string with no format specifiers that ends - // with a \n, turn it into a puts call. - if (FormatStr.empty()) { - // Tolerate printf's declared void. - if (CI->use_empty()) return ReplaceCallWith(CI, 0); - return ReplaceCallWith(CI, ConstantInt::get(CI->getType(), 0)); - } - - if (FormatStr.size() == 1) { - // Turn this into a putchar call, even if it is a %. - Value *V = ConstantInt::get(Type::Int32Ty, FormatStr[0]); - CallInst::Create(SLC.get_putchar(), V, "", CI); - if (CI->use_empty()) return ReplaceCallWith(CI, 0); - return ReplaceCallWith(CI, ConstantInt::get(CI->getType(), 1)); - } - - // Check to see if the format str is something like "foo\n", in which case - // we convert it to a puts call. We don't allow it to contain any format - // characters. - if (FormatStr[FormatStr.size()-1] == '\n' && - FormatStr.find('%') == std::string::npos) { - // Create a string literal with no \n on it. We expect the constant merge - // pass to be run after this pass, to merge duplicate strings. - FormatStr.erase(FormatStr.end()-1); - Constant *Init = ConstantArray::get(FormatStr, true); - Constant *GV = new GlobalVariable(Init->getType(), true, - GlobalVariable::InternalLinkage, - Init, "str", - CI->getParent()->getParent()->getParent()); - // Cast GV to be a pointer to char. - GV = ConstantExpr::getBitCast(GV, PointerType::getUnqual(Type::Int8Ty)); - CallInst::Create(SLC.get_puts(), GV, "", CI); - - if (CI->use_empty()) return ReplaceCallWith(CI, 0); - // The return value from printf includes the \n we just removed, so +1. - return ReplaceCallWith(CI, - ConstantInt::get(CI->getType(), - FormatStr.size()+1)); - } - - - // Only support %c or "%s\n" for now. - if (FormatStr.size() < 2 || FormatStr[0] != '%') - return false; - - // Get the second character and switch on its value - switch (FormatStr[1]) { - default: return false; - case 's': - if (FormatStr != "%s\n" || CI->getNumOperands() < 3 || - // TODO: could insert strlen call to compute string length. - !CI->use_empty()) - return false; - - // printf("%s\n",str) -> puts(str) - CallInst::Create(SLC.get_puts(), CastToCStr(CI->getOperand(2), CI), - CI->getName(), CI); - return ReplaceCallWith(CI, 0); - case 'c': { - // printf("%c",c) -> putchar(c) - if (FormatStr.size() != 2 || CI->getNumOperands() < 3) - return false; - - Value *V = CI->getOperand(2); - if (!isa(V->getType()) || - cast(V->getType())->getBitWidth() > 32) - return false; - - V = CastInst::createZExtOrBitCast(V, Type::Int32Ty, CI->getName()+".int", - CI); - CallInst::Create(SLC.get_putchar(), V, "", CI); - return ReplaceCallWith(CI, ConstantInt::get(CI->getType(), 1)); - } - } - } -} PrintfOptimizer; - -/// This LibCallOptimization will simplify calls to the "fprintf" library -/// function. It looks for cases where the result of fprintf is not used and the -/// operation can be reduced to something simpler. -/// @brief Simplify the fprintf library function. -struct VISIBILITY_HIDDEN FPrintFOptimization : public LibCallOptimization { -public: - /// @brief Default Constructor - FPrintFOptimization() : LibCallOptimization("fprintf", - "Number of 'fprintf' calls simplified") {} - - /// @brief Make sure that the "fprintf" function has the right prototype - virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){ - const FunctionType *FT = F->getFunctionType(); - return FT->getNumParams() == 2 && // two fixed arguments. - FT->getParamType(1) == PointerType::getUnqual(Type::Int8Ty) && - isa(FT->getParamType(0)) && - isa(FT->getReturnType()); - } - - /// @brief Perform the fprintf optimization. - virtual bool OptimizeCall(CallInst *CI, SimplifyLibCalls &SLC) { - // If the call has more than 3 operands, we can't optimize it - if (CI->getNumOperands() != 3 && CI->getNumOperands() != 4) - return false; - - // All the optimizations depend on the format string. - std::string FormatStr; - if (!GetConstantStringInfo(CI->getOperand(2), FormatStr)) - return false; - - // If this is just a format string, turn it into fwrite. - if (CI->getNumOperands() == 3) { - for (unsigned i = 0, e = FormatStr.size(); i != e; ++i) - if (FormatStr[i] == '%') - return false; // we found a format specifier - - // fprintf(file,fmt) -> fwrite(fmt,strlen(fmt),file) - const Type *FILEty = CI->getOperand(1)->getType(); - - Value *FWriteArgs[] = { - CI->getOperand(2), - ConstantInt::get(SLC.getIntPtrType(), FormatStr.size()), - ConstantInt::get(SLC.getIntPtrType(), 1), - CI->getOperand(1) - }; - CallInst::Create(SLC.get_fwrite(FILEty), FWriteArgs, FWriteArgs + 4, CI->getName(), CI); - return ReplaceCallWith(CI, ConstantInt::get(CI->getType(), - FormatStr.size())); - } - - // The remaining optimizations require the format string to be length 2: - // "%s" or "%c". - if (FormatStr.size() != 2 || FormatStr[0] != '%') - return false; - - // Get the second character and switch on its value - switch (FormatStr[1]) { - case 'c': { - // fprintf(file,"%c",c) -> fputc(c,file) - const Type *FILETy = CI->getOperand(1)->getType(); - Value *C = CastInst::createZExtOrBitCast(CI->getOperand(3), Type::Int32Ty, - CI->getName()+".int", CI); - SmallVector Args; - Args.push_back(C); - Args.push_back(CI->getOperand(1)); - CallInst::Create(SLC.get_fputc(FILETy), Args.begin(), Args.end(), "", CI); - return ReplaceCallWith(CI, ConstantInt::get(CI->getType(), 1)); - } - case 's': { - const Type *FILETy = CI->getOperand(1)->getType(); - - // If the result of the fprintf call is used, we can't do this. - // TODO: we should insert a strlen call. - if (!CI->use_empty() || !isa(CI->getOperand(3)->getType())) - return false; - - // fprintf(file,"%s",str) -> fputs(str,file) - SmallVector Args; - Args.push_back(CastToCStr(CI->getOperand(3), CI)); - Args.push_back(CI->getOperand(1)); - CallInst::Create(SLC.get_fputs(FILETy), Args.begin(), - Args.end(), CI->getName(), CI); - return ReplaceCallWith(CI, 0); - } - default: - return false; - } - } -} FPrintFOptimizer; - -/// This LibCallOptimization will simplify calls to the "sprintf" library -/// function. It looks for cases where the result of sprintf is not used and the -/// operation can be reduced to something simpler. -/// @brief Simplify the sprintf library function. -struct VISIBILITY_HIDDEN SPrintFOptimization : public LibCallOptimization { -public: - /// @brief Default Constructor - SPrintFOptimization() : LibCallOptimization("sprintf", - "Number of 'sprintf' calls simplified") {} - - /// @brief Make sure that the "sprintf" function has the right prototype - virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){ - const FunctionType *FT = F->getFunctionType(); - return FT->getNumParams() == 2 && // two fixed arguments. - FT->getParamType(1) == PointerType::getUnqual(Type::Int8Ty) && - FT->getParamType(0) == FT->getParamType(1) && - isa(FT->getReturnType()); - } - - /// @brief Perform the sprintf optimization. - virtual bool OptimizeCall(CallInst *CI, SimplifyLibCalls &SLC) { - // If the call has more than 3 operands, we can't optimize it - if (CI->getNumOperands() != 3 && CI->getNumOperands() != 4) - return false; - - std::string FormatStr; - if (!GetConstantStringInfo(CI->getOperand(2), FormatStr)) - return false; - - if (CI->getNumOperands() == 3) { - // Make sure there's no % in the constant array - for (unsigned i = 0, e = FormatStr.size(); i != e; ++i) - if (FormatStr[i] == '%') - return false; // we found a format specifier - - // sprintf(str,fmt) -> llvm.memcpy(str,fmt,strlen(fmt),1) - Value *MemCpyArgs[] = { - CI->getOperand(1), CI->getOperand(2), - ConstantInt::get(SLC.getIntPtrType(), - FormatStr.size()+1), // Copy the nul byte. - ConstantInt::get(Type::Int32Ty, 1) - }; - CallInst::Create(SLC.get_memcpy(), MemCpyArgs, MemCpyArgs + 4, "", CI); - return ReplaceCallWith(CI, ConstantInt::get(CI->getType(), - FormatStr.size())); - } - - // The remaining optimizations require the format string to be "%s" or "%c". - if (FormatStr.size() != 2 || FormatStr[0] != '%') - return false; - - // Get the second character and switch on its value - switch (FormatStr[1]) { - case 'c': { - // sprintf(dest,"%c",chr) -> store chr, dest - Value *V = CastInst::createTruncOrBitCast(CI->getOperand(3), - Type::Int8Ty, "char", CI); - new StoreInst(V, CI->getOperand(1), CI); - Value *Ptr = GetElementPtrInst::Create(CI->getOperand(1), - ConstantInt::get(Type::Int32Ty, 1), - CI->getOperand(1)->getName()+".end", - CI); - new StoreInst(ConstantInt::get(Type::Int8Ty,0), Ptr, CI); - return ReplaceCallWith(CI, ConstantInt::get(Type::Int32Ty, 1)); - } - case 's': { - // sprintf(dest,"%s",str) -> llvm.memcpy(dest, str, strlen(str)+1, 1) - Value *Len = CallInst::Create(SLC.get_strlen(), - CastToCStr(CI->getOperand(3), CI), - CI->getOperand(3)->getName()+".len", CI); - Value *UnincLen = Len; - Len = BinaryOperator::createAdd(Len, ConstantInt::get(Len->getType(), 1), - Len->getName()+"1", CI); - Value *MemcpyArgs[4] = { - CI->getOperand(1), - CastToCStr(CI->getOperand(3), CI), - Len, - ConstantInt::get(Type::Int32Ty, 1) - }; - CallInst::Create(SLC.get_memcpy(), MemcpyArgs, MemcpyArgs + 4, "", CI); - - // The strlen result is the unincremented number of bytes in the string. - if (!CI->use_empty()) { - if (UnincLen->getType() != CI->getType()) - UnincLen = CastInst::createIntegerCast(UnincLen, CI->getType(), false, - Len->getName(), CI); - CI->replaceAllUsesWith(UnincLen); - } - return ReplaceCallWith(CI, 0); - } - } - return false; - } -} SPrintFOptimizer; - -/// This LibCallOptimization will simplify calls to the "fputs" library -/// function. It looks for cases where the result of fputs is not used and the -/// operation can be reduced to something simpler. -/// @brief Simplify the fputs library function. -struct VISIBILITY_HIDDEN FPutsOptimization : public LibCallOptimization { -public: - /// @brief Default Constructor - FPutsOptimization() : LibCallOptimization("fputs", - "Number of 'fputs' calls simplified") {} - - /// @brief Make sure that the "fputs" function has the right prototype - virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){ - // Just make sure this has 2 arguments - return F->arg_size() == 2; - } - - /// @brief Perform the fputs optimization. - virtual bool OptimizeCall(CallInst *CI, SimplifyLibCalls &SLC) { - // If the result is used, none of these optimizations work. - if (!CI->use_empty()) - return false; - - // All the optimizations depend on the length of the first argument. - uint64_t Len = GetStringLength(CI->getOperand(1)); - if (!Len) return false; - - const Type *FILETy = CI->getOperand(2)->getType(); - // fputs(s,F) -> fwrite(s,1,strlen(s),F) - Value *Ops[4] = { - CI->getOperand(1), - ConstantInt::get(SLC.getIntPtrType(), Len-1), - ConstantInt::get(SLC.getIntPtrType(), 1), - CI->getOperand(2) - }; - CallInst::Create(SLC.get_fwrite(FILETy), Ops, Ops + 4, "", CI); - return ReplaceCallWith(CI, 0); // Known to have no uses (see above). - } -} FPutsOptimizer; - -/// This LibCallOptimization will simplify calls to the "fwrite" function. -struct VISIBILITY_HIDDEN FWriteOptimization : public LibCallOptimization { -public: - /// @brief Default Constructor - FWriteOptimization() : LibCallOptimization("fwrite", - "Number of 'fwrite' calls simplified") {} - - /// @brief Make sure that the "fputs" function has the right prototype - virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){ - const FunctionType *FT = F->getFunctionType(); - return FT->getNumParams() == 4 && - FT->getParamType(0) == PointerType::getUnqual(Type::Int8Ty) && - FT->getParamType(1) == FT->getParamType(2) && - isa(FT->getParamType(1)) && - isa(FT->getParamType(3)) && - isa(FT->getReturnType()); - } - - virtual bool OptimizeCall(CallInst *CI, SimplifyLibCalls &SLC) { - // Get the element size and count. - uint64_t EltSize, EltCount; - if (ConstantInt *C = dyn_cast(CI->getOperand(2))) - EltSize = C->getZExtValue(); - else - return false; - if (ConstantInt *C = dyn_cast(CI->getOperand(3))) - EltCount = C->getZExtValue(); - else - return false; - - // If this is writing zero records, remove the call (it's a noop). - if (EltSize * EltCount == 0) - return ReplaceCallWith(CI, ConstantInt::get(CI->getType(), 0)); - - // If this is writing one byte, turn it into fputc. - if (EltSize == 1 && EltCount == 1) { - SmallVector Args; - // fwrite(s,1,1,F) -> fputc(s[0],F) - Value *Ptr = CI->getOperand(1); - Value *Val = new LoadInst(Ptr, Ptr->getName()+".byte", CI); - Args.push_back(new ZExtInst(Val, Type::Int32Ty, Val->getName()+".int", CI)); - Args.push_back(CI->getOperand(4)); - const Type *FILETy = CI->getOperand(4)->getType(); - CallInst::Create(SLC.get_fputc(FILETy), Args.begin(), Args.end(), "", CI); - return ReplaceCallWith(CI, ConstantInt::get(CI->getType(), 1)); - } - return false; - } -} FWriteOptimizer; - -/// This LibCallOptimization will simplify calls to the "isdigit" library -/// function. It simply does range checks the parameter explicitly. -/// @brief Simplify the isdigit library function. -struct VISIBILITY_HIDDEN isdigitOptimization : public LibCallOptimization { -public: - isdigitOptimization() : LibCallOptimization("isdigit", - "Number of 'isdigit' calls simplified") {} - - /// @brief Make sure that the "isdigit" function has the right prototype - virtual bool ValidateCalledFunction(const Function* f, SimplifyLibCalls& SLC){ - // Just make sure this has 1 argument - return (f->arg_size() == 1); - } - - /// @brief Perform the toascii optimization. - virtual bool OptimizeCall(CallInst *ci, SimplifyLibCalls &SLC) { - if (ConstantInt* CI = dyn_cast(ci->getOperand(1))) { - // isdigit(c) -> 0 or 1, if 'c' is constant - uint64_t val = CI->getZExtValue(); - if (val >= '0' && val <= '9') - return ReplaceCallWith(ci, ConstantInt::get(Type::Int32Ty, 1)); - else - return ReplaceCallWith(ci, ConstantInt::get(Type::Int32Ty, 0)); - } - - // isdigit(c) -> (unsigned)c - '0' <= 9 - CastInst* cast = CastInst::createIntegerCast(ci->getOperand(1), - Type::Int32Ty, false/*ZExt*/, ci->getOperand(1)->getName()+".uint", ci); - BinaryOperator* sub_inst = BinaryOperator::createSub(cast, - ConstantInt::get(Type::Int32Ty,0x30), - ci->getOperand(1)->getName()+".sub",ci); - ICmpInst* setcond_inst = new ICmpInst(ICmpInst::ICMP_ULE,sub_inst, - ConstantInt::get(Type::Int32Ty,9), - ci->getOperand(1)->getName()+".cmp",ci); - CastInst* c2 = new ZExtInst(setcond_inst, Type::Int32Ty, - ci->getOperand(1)->getName()+".isdigit", ci); - return ReplaceCallWith(ci, c2); - } -} isdigitOptimizer; - -struct VISIBILITY_HIDDEN isasciiOptimization : public LibCallOptimization { -public: - isasciiOptimization() - : LibCallOptimization("isascii", "Number of 'isascii' calls simplified") {} - - virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){ - return F->arg_size() == 1 && F->arg_begin()->getType()->isInteger() && - F->getReturnType()->isInteger(); - } - - /// @brief Perform the isascii optimization. - virtual bool OptimizeCall(CallInst *CI, SimplifyLibCalls &SLC) { - // isascii(c) -> (unsigned)c < 128 - Value *V = CI->getOperand(1); - Value *Cmp = new ICmpInst(ICmpInst::ICMP_ULT, V, - ConstantInt::get(V->getType(), 128), - V->getName()+".isascii", CI); - if (Cmp->getType() != CI->getType()) - Cmp = new ZExtInst(Cmp, CI->getType(), Cmp->getName(), CI); - return ReplaceCallWith(CI, Cmp); - } -} isasciiOptimizer; - - -/// This LibCallOptimization will simplify calls to the "toascii" library -/// function. It simply does the corresponding and operation to restrict the -/// range of values to the ASCII character set (0-127). -/// @brief Simplify the toascii library function. -struct VISIBILITY_HIDDEN ToAsciiOptimization : public LibCallOptimization { -public: - /// @brief Default Constructor - ToAsciiOptimization() : LibCallOptimization("toascii", - "Number of 'toascii' calls simplified") {} - - /// @brief Make sure that the "fputs" function has the right prototype - virtual bool ValidateCalledFunction(const Function* f, SimplifyLibCalls& SLC){ - // Just make sure this has 2 arguments - return (f->arg_size() == 1); - } - - /// @brief Perform the toascii optimization. - virtual bool OptimizeCall(CallInst *ci, SimplifyLibCalls &SLC) { - // toascii(c) -> (c & 0x7f) - Value *chr = ci->getOperand(1); - Value *and_inst = BinaryOperator::createAnd(chr, - ConstantInt::get(chr->getType(),0x7F),ci->getName()+".toascii",ci); - return ReplaceCallWith(ci, and_inst); - } -} ToAsciiOptimizer; - -/// This LibCallOptimization will simplify calls to the "ffs" library -/// calls which find the first set bit in an int, long, or long long. The -/// optimization is to compute the result at compile time if the argument is -/// a constant. -/// @brief Simplify the ffs library function. -struct VISIBILITY_HIDDEN FFSOptimization : public LibCallOptimization { -protected: - /// @brief Subclass Constructor - FFSOptimization(const char* funcName, const char* description) - : LibCallOptimization(funcName, description) {} - -public: - /// @brief Default Constructor - FFSOptimization() : LibCallOptimization("ffs", - "Number of 'ffs' calls simplified") {} - - /// @brief Make sure that the "ffs" function has the right prototype - virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){ - // Just make sure this has 2 arguments - return F->arg_size() == 1 && F->getReturnType() == Type::Int32Ty; - } - - /// @brief Perform the ffs optimization. - virtual bool OptimizeCall(CallInst *TheCall, SimplifyLibCalls &SLC) { - if (ConstantInt *CI = dyn_cast(TheCall->getOperand(1))) { - // ffs(cnst) -> bit# - // ffsl(cnst) -> bit# - // ffsll(cnst) -> bit# - uint64_t val = CI->getZExtValue(); - int result = 0; - if (val) { - ++result; - while ((val & 1) == 0) { - ++result; - val >>= 1; - } - } - return ReplaceCallWith(TheCall, ConstantInt::get(Type::Int32Ty, result)); - } - - // ffs(x) -> x == 0 ? 0 : llvm.cttz(x)+1 - // ffsl(x) -> x == 0 ? 0 : llvm.cttz(x)+1 - // ffsll(x) -> x == 0 ? 0 : llvm.cttz(x)+1 - const Type *ArgType = TheCall->getOperand(1)->getType(); - assert(ArgType->getTypeID() == Type::IntegerTyID && - "llvm.cttz argument is not an integer?"); - Constant *F = Intrinsic::getDeclaration(SLC.getModule(), - Intrinsic::cttz, &ArgType, 1); - - Value *V = CastInst::createIntegerCast(TheCall->getOperand(1), ArgType, - false/*ZExt*/, "tmp", TheCall); - Value *V2 = CallInst::Create(F, V, "tmp", TheCall); - V2 = CastInst::createIntegerCast(V2, Type::Int32Ty, false/*ZExt*/, - "tmp", TheCall); - V2 = BinaryOperator::createAdd(V2, ConstantInt::get(Type::Int32Ty, 1), - "tmp", TheCall); - Value *Cond = new ICmpInst(ICmpInst::ICMP_EQ, V, - Constant::getNullValue(V->getType()), "tmp", - TheCall); - V2 = SelectInst::Create(Cond, ConstantInt::get(Type::Int32Ty, 0), V2, - TheCall->getName(), TheCall); - return ReplaceCallWith(TheCall, V2); - } -} FFSOptimizer; - -/// This LibCallOptimization will simplify calls to the "ffsl" library -/// calls. It simply uses FFSOptimization for which the transformation is -/// identical. -/// @brief Simplify the ffsl library function. -struct VISIBILITY_HIDDEN FFSLOptimization : public FFSOptimization { -public: - /// @brief Default Constructor - FFSLOptimization() : FFSOptimization("ffsl", - "Number of 'ffsl' calls simplified") {} - -} FFSLOptimizer; - -/// This LibCallOptimization will simplify calls to the "ffsll" library -/// calls. It simply uses FFSOptimization for which the transformation is -/// identical. -/// @brief Simplify the ffsl library function. -struct VISIBILITY_HIDDEN FFSLLOptimization : public FFSOptimization { -public: - /// @brief Default Constructor - FFSLLOptimization() : FFSOptimization("ffsll", - "Number of 'ffsll' calls simplified") {} - -} FFSLLOptimizer; - -/// This optimizes unary functions that take and return doubles. -struct UnaryDoubleFPOptimizer : public LibCallOptimization { - UnaryDoubleFPOptimizer(const char *Fn, const char *Desc) - : LibCallOptimization(Fn, Desc) {} - - // Make sure that this function has the right prototype - virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){ - return F->arg_size() == 1 && F->arg_begin()->getType() == Type::DoubleTy && - F->getReturnType() == Type::DoubleTy; - } - - /// ShrinkFunctionToFloatVersion - If the input to this function is really a - /// float, strength reduce this to a float version of the function, - /// e.g. floor((double)FLT) -> (double)floorf(FLT). This can only be called - /// when the target supports the destination function and where there can be - /// no precision loss. - static bool ShrinkFunctionToFloatVersion(CallInst *CI, SimplifyLibCalls &SLC, - Constant *(SimplifyLibCalls::*FP)()){ - if (FPExtInst *Cast = dyn_cast(CI->getOperand(1))) - if (Cast->getOperand(0)->getType() == Type::FloatTy) { - Value *New = CallInst::Create((SLC.*FP)(), Cast->getOperand(0), - CI->getName(), CI); - New = new FPExtInst(New, Type::DoubleTy, CI->getName(), CI); - CI->replaceAllUsesWith(New); - CI->eraseFromParent(); - if (Cast->use_empty()) - Cast->eraseFromParent(); - return true; - } - return false; - } -}; - - -struct VISIBILITY_HIDDEN FloorOptimization : public UnaryDoubleFPOptimizer { - FloorOptimization() - : UnaryDoubleFPOptimizer("floor", "Number of 'floor' calls simplified") {} - - virtual bool OptimizeCall(CallInst *CI, SimplifyLibCalls &SLC) { -#ifdef HAVE_FLOORF - // If this is a float argument passed in, convert to floorf. - if (ShrinkFunctionToFloatVersion(CI, SLC, &SimplifyLibCalls::get_floorf)) - return true; -#endif - return false; // opt failed - } -} FloorOptimizer; - -struct VISIBILITY_HIDDEN CeilOptimization : public UnaryDoubleFPOptimizer { - CeilOptimization() - : UnaryDoubleFPOptimizer("ceil", "Number of 'ceil' calls simplified") {} - - virtual bool OptimizeCall(CallInst *CI, SimplifyLibCalls &SLC) { -#ifdef HAVE_CEILF - // If this is a float argument passed in, convert to ceilf. - if (ShrinkFunctionToFloatVersion(CI, SLC, &SimplifyLibCalls::get_ceilf)) - return true; -#endif - return false; // opt failed - } -} CeilOptimizer; - -struct VISIBILITY_HIDDEN RoundOptimization : public UnaryDoubleFPOptimizer { - RoundOptimization() - : UnaryDoubleFPOptimizer("round", "Number of 'round' calls simplified") {} - - virtual bool OptimizeCall(CallInst *CI, SimplifyLibCalls &SLC) { -#ifdef HAVE_ROUNDF - // If this is a float argument passed in, convert to roundf. - if (ShrinkFunctionToFloatVersion(CI, SLC, &SimplifyLibCalls::get_roundf)) - return true; -#endif - return false; // opt failed - } -} RoundOptimizer; - -struct VISIBILITY_HIDDEN RintOptimization : public UnaryDoubleFPOptimizer { - RintOptimization() - : UnaryDoubleFPOptimizer("rint", "Number of 'rint' calls simplified") {} - - virtual bool OptimizeCall(CallInst *CI, SimplifyLibCalls &SLC) { -#ifdef HAVE_RINTF - // If this is a float argument passed in, convert to rintf. - if (ShrinkFunctionToFloatVersion(CI, SLC, &SimplifyLibCalls::get_rintf)) - return true; -#endif - return false; // opt failed - } -} RintOptimizer; - -struct VISIBILITY_HIDDEN NearByIntOptimization : public UnaryDoubleFPOptimizer { - NearByIntOptimization() - : UnaryDoubleFPOptimizer("nearbyint", - "Number of 'nearbyint' calls simplified") {} - - virtual bool OptimizeCall(CallInst *CI, SimplifyLibCalls &SLC) { -#ifdef HAVE_NEARBYINTF - // If this is a float argument passed in, convert to nearbyintf. - if (ShrinkFunctionToFloatVersion(CI, SLC,&SimplifyLibCalls::get_nearbyintf)) - return true; -#endif - return false; // opt failed - } -} NearByIntOptimizer; -} // end anon namespace - -/// GetConstantStringInfo - This function computes the length of a -/// null-terminated constant array of integers. This function can't rely on the -/// size of the constant array because there could be a null terminator in the -/// middle of the array. -/// -/// We also have to bail out if we find a non-integer constant initializer -/// of one of the elements or if there is no null-terminator. The logic -/// below checks each of these conditions and will return true only if all -/// conditions are met. If the conditions aren't met, this returns false. -/// -/// If successful, the \p Array param is set to the constant array being -/// indexed, the \p Length parameter is set to the length of the null-terminated -/// string pointed to by V, the \p StartIdx value is set to the first -/// element of the Array that V points to, and true is returned. -static bool GetConstantStringInfo(Value *V, std::string &Str) { - // Look through noop bitcast instructions. - if (BitCastInst *BCI = dyn_cast(V)) { - if (BCI->getType() == BCI->getOperand(0)->getType()) - return GetConstantStringInfo(BCI->getOperand(0), Str); - return false; - } - - // If the value is not a GEP instruction nor a constant expression with a - // GEP instruction, then return false because ConstantArray can't occur - // any other way - User *GEP = 0; - if (GetElementPtrInst *GEPI = dyn_cast(V)) { - GEP = GEPI; - } else if (ConstantExpr *CE = dyn_cast(V)) { - if (CE->getOpcode() != Instruction::GetElementPtr) - return false; - GEP = CE; - } else { - return false; - } - - // Make sure the GEP has exactly three arguments. - if (GEP->getNumOperands() != 3) - return false; - - // Check to make sure that the first operand of the GEP is an integer and - // has value 0 so that we are sure we're indexing into the initializer. - if (ConstantInt *Idx = dyn_cast(GEP->getOperand(1))) { - if (!Idx->isZero()) - return false; - } else - return false; - - // If the second index isn't a ConstantInt, then this is a variable index - // into the array. If this occurs, we can't say anything meaningful about - // the string. - uint64_t StartIdx = 0; - if (ConstantInt *CI = dyn_cast(GEP->getOperand(2))) - StartIdx = CI->getZExtValue(); - else - return false; - - // The GEP instruction, constant or instruction, must reference a global - // variable that is a constant and is initialized. The referenced constant - // initializer is the array that we'll use for optimization. - GlobalVariable* GV = dyn_cast(GEP->getOperand(0)); - if (!GV || !GV->isConstant() || !GV->hasInitializer()) - return false; - Constant *GlobalInit = GV->getInitializer(); - - // Handle the ConstantAggregateZero case - if (isa(GlobalInit)) { - // This is a degenerate case. The initializer is constant zero so the - // length of the string must be zero. - Str.clear(); - return true; - } - - // Must be a Constant Array - ConstantArray *Array = dyn_cast(GlobalInit); - if (!Array) return false; - - // Get the number of elements in the array - uint64_t NumElts = Array->getType()->getNumElements(); - - // Traverse the constant array from StartIdx (derived above) which is - // the place the GEP refers to in the array. - for (unsigned i = StartIdx; i < NumElts; ++i) { - Constant *Elt = Array->getOperand(i); - ConstantInt *CI = dyn_cast(Elt); - if (!CI) // This array isn't suitable, non-int initializer. - return false; - if (CI->isZero()) - return true; // we found end of string, success! - Str += (char)CI->getZExtValue(); - } - - return false; // The array isn't null terminated. -} - -/// GetStringLengthH - If we can compute the length of the string pointed to by -/// the specified pointer, return 'len+1'. If we can't, return 0. -static uint64_t GetStringLengthH(Value *V, SmallPtrSet &PHIs) { - // Look through noop bitcast instructions. - if (BitCastInst *BCI = dyn_cast(V)) - return GetStringLengthH(BCI->getOperand(0), PHIs); - - // If this is a PHI node, there are two cases: either we have already seen it - // or we haven't. - if (PHINode *PN = dyn_cast(V)) { - if (!PHIs.insert(PN)) - return ~0ULL; // already in the set. - - // If it was new, see if all the input strings are the same length. - uint64_t LenSoFar = ~0ULL; - for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { - uint64_t Len = GetStringLengthH(PN->getIncomingValue(i), PHIs); - if (Len == 0) return 0; // Unknown length -> unknown. - - if (Len == ~0ULL) continue; - - if (Len != LenSoFar && LenSoFar != ~0ULL) - return 0; // Disagree -> unknown. - LenSoFar = Len; - } - - // Success, all agree. - return LenSoFar; - } - - // strlen(select(c,x,y)) -> strlen(x) ^ strlen(y) - if (SelectInst *SI = dyn_cast(V)) { - uint64_t Len1 = GetStringLengthH(SI->getTrueValue(), PHIs); - if (Len1 == 0) return 0; - uint64_t Len2 = GetStringLengthH(SI->getFalseValue(), PHIs); - if (Len2 == 0) return 0; - if (Len1 == ~0ULL) return Len2; - if (Len2 == ~0ULL) return Len1; - if (Len1 != Len2) return 0; - return Len1; - } - - // If the value is not a GEP instruction nor a constant expression with a - // GEP instruction, then return unknown. - User *GEP = 0; - if (GetElementPtrInst *GEPI = dyn_cast(V)) { - GEP = GEPI; - } else if (ConstantExpr *CE = dyn_cast(V)) { - if (CE->getOpcode() != Instruction::GetElementPtr) - return 0; - GEP = CE; - } else { - return 0; - } - - // Make sure the GEP has exactly three arguments. - if (GEP->getNumOperands() != 3) - return 0; - - // Check to make sure that the first operand of the GEP is an integer and - // has value 0 so that we are sure we're indexing into the initializer. - if (ConstantInt *Idx = dyn_cast(GEP->getOperand(1))) { - if (!Idx->isZero()) - return 0; - } else - return 0; - - // If the second index isn't a ConstantInt, then this is a variable index - // into the array. If this occurs, we can't say anything meaningful about - // the string. - uint64_t StartIdx = 0; - if (ConstantInt *CI = dyn_cast(GEP->getOperand(2))) - StartIdx = CI->getZExtValue(); - else - return 0; - - // The GEP instruction, constant or instruction, must reference a global - // variable that is a constant and is initialized. The referenced constant - // initializer is the array that we'll use for optimization. - GlobalVariable* GV = dyn_cast(GEP->getOperand(0)); - if (!GV || !GV->isConstant() || !GV->hasInitializer()) - return 0; - Constant *GlobalInit = GV->getInitializer(); - - // Handle the ConstantAggregateZero case, which is a degenerate case. The - // initializer is constant zero so the length of the string must be zero. - if (isa(GlobalInit)) - return 1; // Len = 0 offset by 1. - - // Must be a Constant Array - ConstantArray *Array = dyn_cast(GlobalInit); - if (!Array || Array->getType()->getElementType() != Type::Int8Ty) - return false; - - // Get the number of elements in the array - uint64_t NumElts = Array->getType()->getNumElements(); - - // Traverse the constant array from StartIdx (derived above) which is - // the place the GEP refers to in the array. - for (unsigned i = StartIdx; i != NumElts; ++i) { - Constant *Elt = Array->getOperand(i); - ConstantInt *CI = dyn_cast(Elt); - if (!CI) // This array isn't suitable, non-int initializer. - return 0; - if (CI->isZero()) - return i-StartIdx+1; // We found end of string, success! - } - - return 0; // The array isn't null terminated, conservatively return 'unknown'. -} - -/// GetStringLength - If we can compute the length of the string pointed to by -/// the specified pointer, return 'len+1'. If we can't, return 0. -static uint64_t GetStringLength(Value *V) { - if (!isa(V->getType())) return 0; - - SmallPtrSet PHIs; - uint64_t Len = GetStringLengthH(V, PHIs); - // If Len is ~0ULL, we had an infinite phi cycle: this is dead code, so return - // an empty string as a length. - return Len == ~0ULL ? 1 : Len; -} - - - -/// CastToCStr - Return V if it is an sbyte*, otherwise cast it to sbyte*, -/// inserting the cast before IP, and return the cast. -/// @brief Cast a value to a "C" string. -static Value *CastToCStr(Value *V, Instruction *IP) { - assert(isa(V->getType()) && - "Can't cast non-pointer type to C string type"); - const Type *SBPTy = PointerType::getUnqual(Type::Int8Ty); - if (V->getType() != SBPTy) - return new BitCastInst(V, SBPTy, V->getName(), IP); - return V; -} - -// TODO: -// Additional cases that we need to add to this file: -// -// cbrt: -// * cbrt(expN(X)) -> expN(x/3) -// * cbrt(sqrt(x)) -> pow(x,1/6) -// * cbrt(sqrt(x)) -> pow(x,1/9) -// -// cos, cosf, cosl: -// * cos(-x) -> cos(x) -// -// exp, expf, expl: -// * exp(log(x)) -> x -// -// log, logf, logl: -// * log(exp(x)) -> x -// * log(x**y) -> y*log(x) -// * log(exp(y)) -> y*log(e) -// * log(exp2(y)) -> y*log(2) -// * log(exp10(y)) -> y*log(10) -// * log(sqrt(x)) -> 0.5*log(x) -// * log(pow(x,y)) -> y*log(x) -// -// lround, lroundf, lroundl: -// * lround(cnst) -> cnst' -// -// memcmp: -// * memcmp(x,y,l) -> cnst -// (if all arguments are constant and strlen(x) <= l and strlen(y) <= l) -// -// memmove: -// * memmove(d,s,l,a) -> memcpy(d,s,l,a) -// (if s is a global constant array) -// -// pow, powf, powl: -// * pow(exp(x),y) -> exp(x*y) -// * pow(sqrt(x),y) -> pow(x,y*0.5) -// * pow(pow(x,y),z)-> pow(x,y*z) -// -// puts: -// * puts("") -> putchar("\n") -// -// round, roundf, roundl: -// * round(cnst) -> cnst' -// -// signbit: -// * signbit(cnst) -> cnst' -// * signbit(nncst) -> 0 (if pstv is a non-negative constant) -// -// sqrt, sqrtf, sqrtl: -// * sqrt(expN(x)) -> expN(x*0.5) -// * sqrt(Nroot(x)) -> pow(x,1/(2*N)) -// * sqrt(pow(x,y)) -> pow(|x|,y*0.5) -// -// stpcpy: -// * stpcpy(str, "literal") -> -// llvm.memcpy(str,"literal",strlen("literal")+1,1) -// strrchr: -// * strrchr(s,c) -> reverse_offset_of_in(c,s) -// (if c is a constant integer and s is a constant string) -// * strrchr(s1,0) -> strchr(s1,0) -// -// strncat: -// * strncat(x,y,0) -> x -// * strncat(x,y,0) -> x (if strlen(y) = 0) -// * strncat(x,y,l) -> strcat(x,y) (if y and l are constants an l > strlen(y)) -// -// strncpy: -// * strncpy(d,s,0) -> d -// * strncpy(d,s,l) -> memcpy(d,s,l,1) -// (if s and l are constants) -// -// strpbrk: -// * strpbrk(s,a) -> offset_in_for(s,a) -// (if s and a are both constant strings) -// * strpbrk(s,"") -> 0 -// * strpbrk(s,a) -> strchr(s,a[0]) (if a is constant string of length 1) -// -// strspn, strcspn: -// * strspn(s,a) -> const_int (if both args are constant) -// * strspn("",a) -> 0 -// * strspn(s,"") -> 0 -// * strcspn(s,a) -> const_int (if both args are constant) -// * strcspn("",a) -> 0 -// * strcspn(s,"") -> strlen(a) -// -// strstr: -// * strstr(x,x) -> x -// * strstr(s1,s2) -> offset_of_s2_in(s1) -// (if s1 and s2 are constant strings) -// -// tan, tanf, tanl: -// * tan(atan(x)) -> x -// -// trunc, truncf, truncl: -// * trunc(cnst) -> cnst' -// -// Added: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=50520&view=auto ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (added) +++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Thu May 1 01:25:24 2008 @@ -0,0 +1,1437 @@ +//===- SimplifyLibCalls.cpp - Optimize specific well-known library calls --===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements a simple pass that applies a variety of small +// optimizations for calls to specific well-known function calls (e.g. runtime +// library functions). For example, a call to the function "exit(3)" that +// occurs within the main() function can be transformed into a simple "return 3" +// instruction. Any optimization that takes this form (replace call to library +// function with simpler code that provides the same result) belongs in this +// file. +// +//===----------------------------------------------------------------------===// + +#define DEBUG_TYPE "simplify-libcalls" +#include "llvm/Transforms/Scalar.h" +#include "llvm/Intrinsics.h" +#include "llvm/Module.h" +#include "llvm/Pass.h" +#include "llvm/Support/IRBuilder.h" +#include "llvm/Target/TargetData.h" +#include "llvm/ADT/SmallPtrSet.h" +#include "llvm/ADT/StringMap.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/Support/Compiler.h" +#include "llvm/Config/config.h" +using namespace llvm; + +STATISTIC(NumSimplified, "Number of library calls simplified"); + +//===----------------------------------------------------------------------===// +// Optimizer Base Class +//===----------------------------------------------------------------------===// + +/// This class is the abstract base class for the set of optimizations that +/// corresponds to one library call. +namespace { +class VISIBILITY_HIDDEN LibCallOptimization { +protected: + Function *Caller; + const TargetData *TD; +public: + LibCallOptimization() { } + virtual ~LibCallOptimization() {} + + /// CallOptimizer - This pure virtual method is implemented by base classes to + /// do various optimizations. If this returns null then no transformation was + /// performed. If it returns CI, then it transformed the call and CI is to be + /// deleted. If it returns something else, replace CI with the new value and + /// delete CI. + virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) =0; + + Value *OptimizeCall(CallInst *CI, const TargetData &TD, IRBuilder &B) { + Caller = CI->getParent()->getParent(); + this->TD = &TD; + return CallOptimizer(CI->getCalledFunction(), CI, B); + } + + /// CastToCStr - Return V if it is an i8*, otherwise cast it to i8*. + Value *CastToCStr(Value *V, IRBuilder &B); + + /// EmitStrLen - Emit a call to the strlen function to the builder, for the + /// specified pointer. Ptr is required to be some pointer type, and the + /// return value has 'intptr_t' type. + Value *EmitStrLen(Value *Ptr, IRBuilder &B); + + /// EmitMemCpy - Emit a call to the memcpy function to the builder. This + /// always expects that the size has type 'intptr_t' and Dst/Src are pointers. + Value *EmitMemCpy(Value *Dst, Value *Src, Value *Len, + unsigned Align, IRBuilder &B); + + /// EmitMemChr - Emit a call to the memchr function. This assumes that Ptr is + /// a pointer, Val is an i32 value, and Len is an 'intptr_t' value. + Value *EmitMemChr(Value *Ptr, Value *Val, Value *Len, IRBuilder &B); + + /// EmitUnaryFloatFnCall - Emit a call to the unary function named 'Name' (e.g. + /// 'floor'). This function is known to take a single of type matching 'Op' + /// and returns one value with the same type. If 'Op' is a long double, 'l' + /// is added as the suffix of name, if 'Op' is a float, we add a 'f' suffix. + Value *EmitUnaryFloatFnCall(Value *Op, const char *Name, IRBuilder &B); + + /// EmitPutChar - Emit a call to the putchar function. This assumes that Char + /// is an integer. + void EmitPutChar(Value *Char, IRBuilder &B); + + /// EmitPutS - Emit a call to the puts function. This assumes that Str is + /// some pointer. + void EmitPutS(Value *Str, IRBuilder &B); + + /// EmitFPutC - Emit a call to the fputc function. This assumes that Char is + /// an i32, and File is a pointer to FILE. + void EmitFPutC(Value *Char, Value *File, IRBuilder &B); + + /// EmitFPutS - Emit a call to the puts function. Str is required to be a + /// pointer and File is a pointer to FILE. + void EmitFPutS(Value *Str, Value *File, IRBuilder &B); + + /// EmitFWrite - Emit a call to the fwrite function. This assumes that Ptr is + /// a pointer, Size is an 'intptr_t', and File is a pointer to FILE. + void EmitFWrite(Value *Ptr, Value *Size, Value *File, IRBuilder &B); + +}; +} // End anonymous namespace. + +/// CastToCStr - Return V if it is an i8*, otherwise cast it to i8*. +Value *LibCallOptimization::CastToCStr(Value *V, IRBuilder &B) { + return B.CreateBitCast(V, PointerType::getUnqual(Type::Int8Ty), "cstr"); +} + +/// EmitStrLen - Emit a call to the strlen function to the builder, for the +/// specified pointer. This always returns an integer value of size intptr_t. +Value *LibCallOptimization::EmitStrLen(Value *Ptr, IRBuilder &B) { + Module *M = Caller->getParent(); + Constant *StrLen =M->getOrInsertFunction("strlen", TD->getIntPtrType(), + PointerType::getUnqual(Type::Int8Ty), + NULL); + return B.CreateCall(StrLen, CastToCStr(Ptr, B), "strlen"); +} + +/// EmitMemCpy - Emit a call to the memcpy function to the builder. This always +/// expects that the size has type 'intptr_t' and Dst/Src are pointers. +Value *LibCallOptimization::EmitMemCpy(Value *Dst, Value *Src, Value *Len, + unsigned Align, IRBuilder &B) { + Module *M = Caller->getParent(); + Intrinsic::ID IID = TD->getIntPtrType() == Type::Int32Ty ? + Intrinsic::memcpy_i32 : Intrinsic::memcpy_i64; + Value *MemCpy = Intrinsic::getDeclaration(M, IID); + return B.CreateCall4(MemCpy, CastToCStr(Dst, B), CastToCStr(Src, B), Len, + ConstantInt::get(Type::Int32Ty, Align)); +} + +/// EmitMemChr - Emit a call to the memchr function. This assumes that Ptr is +/// a pointer, Val is an i32 value, and Len is an 'intptr_t' value. +Value *LibCallOptimization::EmitMemChr(Value *Ptr, Value *Val, + Value *Len, IRBuilder &B) { + Module *M = Caller->getParent(); + Value *MemChr = M->getOrInsertFunction("memchr", + PointerType::getUnqual(Type::Int8Ty), + PointerType::getUnqual(Type::Int8Ty), + Type::Int32Ty, TD->getIntPtrType(), + NULL); + return B.CreateCall3(MemChr, CastToCStr(Ptr, B), Val, Len, "memchr"); +} + +/// EmitUnaryFloatFnCall - Emit a call to the unary function named 'Name' (e.g. +/// 'floor'). This function is known to take a single of type matching 'Op' and +/// returns one value with the same type. If 'Op' is a long double, 'l' is +/// added as the suffix of name, if 'Op' is a float, we add a 'f' suffix. +Value *LibCallOptimization::EmitUnaryFloatFnCall(Value *Op, const char *Name, + IRBuilder &B) { + char NameBuffer[20]; + if (Op->getType() != Type::DoubleTy) { + // If we need to add a suffix, copy into NameBuffer. + unsigned NameLen = strlen(Name); + assert(NameLen < sizeof(NameBuffer)-2); + memcpy(NameBuffer, Name, NameLen); + if (Op->getType() == Type::FloatTy) + NameBuffer[NameLen] = 'f'; // floorf + else + NameBuffer[NameLen] = 'l'; // floorl + NameBuffer[NameLen+1] = 0; + Name = NameBuffer; + } + + Module *M = Caller->getParent(); + Value *Callee = M->getOrInsertFunction(Name, Op->getType(), + Op->getType(), NULL); + return B.CreateCall(Callee, Op, Name); +} + +/// EmitPutChar - Emit a call to the putchar function. This assumes that Char +/// is an integer. +void LibCallOptimization::EmitPutChar(Value *Char, IRBuilder &B) { + Module *M = Caller->getParent(); + Value *F = M->getOrInsertFunction("putchar", Type::Int32Ty, + Type::Int32Ty, NULL); + B.CreateCall(F, B.CreateIntCast(Char, Type::Int32Ty, "chari"), "putchar"); +} + +/// EmitPutS - Emit a call to the puts function. This assumes that Str is +/// some pointer. +void LibCallOptimization::EmitPutS(Value *Str, IRBuilder &B) { + Module *M = Caller->getParent(); + Value *F = M->getOrInsertFunction("puts", Type::Int32Ty, + PointerType::getUnqual(Type::Int8Ty), NULL); + B.CreateCall(F, CastToCStr(Str, B), "puts"); +} + +/// EmitFPutC - Emit a call to the fputc function. This assumes that Char is +/// an integer and File is a pointer to FILE. +void LibCallOptimization::EmitFPutC(Value *Char, Value *File, IRBuilder &B) { + Module *M = Caller->getParent(); + Constant *F = M->getOrInsertFunction("fputc", Type::Int32Ty, Type::Int32Ty, + File->getType(), NULL); + Char = B.CreateIntCast(Char, Type::Int32Ty, "chari"); + B.CreateCall2(F, Char, File, "fputc"); +} + +/// EmitFPutS - Emit a call to the puts function. Str is required to be a +/// pointer and File is a pointer to FILE. +void LibCallOptimization::EmitFPutS(Value *Str, Value *File, IRBuilder &B) { + Module *M = Caller->getParent(); + Constant *F = M->getOrInsertFunction("fputs", Type::Int32Ty, + PointerType::getUnqual(Type::Int8Ty), + File->getType(), NULL); + B.CreateCall2(F, CastToCStr(Str, B), File, "fputs"); +} + +/// EmitFWrite - Emit a call to the fwrite function. This assumes that Ptr is +/// a pointer, Size is an 'intptr_t', and File is a pointer to FILE. +void LibCallOptimization::EmitFWrite(Value *Ptr, Value *Size, Value *File, + IRBuilder &B) { + Module *M = Caller->getParent(); + Constant *F = M->getOrInsertFunction("fwrite", TD->getIntPtrType(), + PointerType::getUnqual(Type::Int8Ty), + TD->getIntPtrType(), TD->getIntPtrType(), + File->getType(), NULL); + B.CreateCall4(F, CastToCStr(Ptr, B), Size, + ConstantInt::get(TD->getIntPtrType(), 1), File); +} + +//===----------------------------------------------------------------------===// +// Helper Functions +//===----------------------------------------------------------------------===// + +/// GetConstantStringInfo - This function computes the length of a +/// null-terminated C string pointed to by V. If successful, it returns true +/// and returns the string in Str. If unsuccessful, it returns false. +static bool GetConstantStringInfo(Value *V, std::string &Str) { + // Look bitcast instructions. + if (BitCastInst *BCI = dyn_cast(V)) + return GetConstantStringInfo(BCI->getOperand(0), Str); + + // If the value is not a GEP instruction nor a constant expression with a + // GEP instruction, then return false because ConstantArray can't occur + // any other way + User *GEP = 0; + if (GetElementPtrInst *GEPI = dyn_cast(V)) { + GEP = GEPI; + } else if (ConstantExpr *CE = dyn_cast(V)) { + if (CE->getOpcode() != Instruction::GetElementPtr) + return false; + GEP = CE; + } else { + return false; + } + + // Make sure the GEP has exactly three arguments. + if (GEP->getNumOperands() != 3) + return false; + + // Check to make sure that the first operand of the GEP is an integer and + // has value 0 so that we are sure we're indexing into the initializer. + if (ConstantInt *Idx = dyn_cast(GEP->getOperand(1))) { + if (!Idx->isZero()) + return false; + } else + return false; + + // If the second index isn't a ConstantInt, then this is a variable index + // into the array. If this occurs, we can't say anything meaningful about + // the string. + uint64_t StartIdx = 0; + if (ConstantInt *CI = dyn_cast(GEP->getOperand(2))) + StartIdx = CI->getZExtValue(); + else + return false; + + // The GEP instruction, constant or instruction, must reference a global + // variable that is a constant and is initialized. The referenced constant + // initializer is the array that we'll use for optimization. + GlobalVariable* GV = dyn_cast(GEP->getOperand(0)); + if (!GV || !GV->isConstant() || !GV->hasInitializer()) + return false; + Constant *GlobalInit = GV->getInitializer(); + + // Handle the ConstantAggregateZero case + if (isa(GlobalInit)) { + // This is a degenerate case. The initializer is constant zero so the + // length of the string must be zero. + Str.clear(); + return true; + } + + // Must be a Constant Array + ConstantArray *Array = dyn_cast(GlobalInit); + if (Array == 0 || Array->getType()->getElementType() != Type::Int8Ty) + return false; + + // Get the number of elements in the array + uint64_t NumElts = Array->getType()->getNumElements(); + + // Traverse the constant array from StartIdx (derived above) which is + // the place the GEP refers to in the array. + for (unsigned i = StartIdx; i < NumElts; ++i) { + Constant *Elt = Array->getOperand(i); + ConstantInt *CI = dyn_cast(Elt); + if (!CI) // This array isn't suitable, non-int initializer. + return false; + if (CI->isZero()) + return true; // we found end of string, success! + Str += (char)CI->getZExtValue(); + } + + return false; // The array isn't null terminated. +} + +/// GetStringLengthH - If we can compute the length of the string pointed to by +/// the specified pointer, return 'len+1'. If we can't, return 0. +static uint64_t GetStringLengthH(Value *V, SmallPtrSet &PHIs) { + // Look through noop bitcast instructions. + if (BitCastInst *BCI = dyn_cast(V)) + return GetStringLengthH(BCI->getOperand(0), PHIs); + + // If this is a PHI node, there are two cases: either we have already seen it + // or we haven't. + if (PHINode *PN = dyn_cast(V)) { + if (!PHIs.insert(PN)) + return ~0ULL; // already in the set. + + // If it was new, see if all the input strings are the same length. + uint64_t LenSoFar = ~0ULL; + for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { + uint64_t Len = GetStringLengthH(PN->getIncomingValue(i), PHIs); + if (Len == 0) return 0; // Unknown length -> unknown. + + if (Len == ~0ULL) continue; + + if (Len != LenSoFar && LenSoFar != ~0ULL) + return 0; // Disagree -> unknown. + LenSoFar = Len; + } + + // Success, all agree. + return LenSoFar; + } + + // strlen(select(c,x,y)) -> strlen(x) ^ strlen(y) + if (SelectInst *SI = dyn_cast(V)) { + uint64_t Len1 = GetStringLengthH(SI->getTrueValue(), PHIs); + if (Len1 == 0) return 0; + uint64_t Len2 = GetStringLengthH(SI->getFalseValue(), PHIs); + if (Len2 == 0) return 0; + if (Len1 == ~0ULL) return Len2; + if (Len2 == ~0ULL) return Len1; + if (Len1 != Len2) return 0; + return Len1; + } + + // If the value is not a GEP instruction nor a constant expression with a + // GEP instruction, then return unknown. + User *GEP = 0; + if (GetElementPtrInst *GEPI = dyn_cast(V)) { + GEP = GEPI; + } else if (ConstantExpr *CE = dyn_cast(V)) { + if (CE->getOpcode() != Instruction::GetElementPtr) + return 0; + GEP = CE; + } else { + return 0; + } + + // Make sure the GEP has exactly three arguments. + if (GEP->getNumOperands() != 3) + return 0; + + // Check to make sure that the first operand of the GEP is an integer and + // has value 0 so that we are sure we're indexing into the initializer. + if (ConstantInt *Idx = dyn_cast(GEP->getOperand(1))) { + if (!Idx->isZero()) + return 0; + } else + return 0; + + // If the second index isn't a ConstantInt, then this is a variable index + // into the array. If this occurs, we can't say anything meaningful about + // the string. + uint64_t StartIdx = 0; + if (ConstantInt *CI = dyn_cast(GEP->getOperand(2))) + StartIdx = CI->getZExtValue(); + else + return 0; + + // The GEP instruction, constant or instruction, must reference a global + // variable that is a constant and is initialized. The referenced constant + // initializer is the array that we'll use for optimization. + GlobalVariable* GV = dyn_cast(GEP->getOperand(0)); + if (!GV || !GV->isConstant() || !GV->hasInitializer()) + return 0; + Constant *GlobalInit = GV->getInitializer(); + + // Handle the ConstantAggregateZero case, which is a degenerate case. The + // initializer is constant zero so the length of the string must be zero. + if (isa(GlobalInit)) + return 1; // Len = 0 offset by 1. + + // Must be a Constant Array + ConstantArray *Array = dyn_cast(GlobalInit); + if (!Array || Array->getType()->getElementType() != Type::Int8Ty) + return false; + + // Get the number of elements in the array + uint64_t NumElts = Array->getType()->getNumElements(); + + // Traverse the constant array from StartIdx (derived above) which is + // the place the GEP refers to in the array. + for (unsigned i = StartIdx; i != NumElts; ++i) { + Constant *Elt = Array->getOperand(i); + ConstantInt *CI = dyn_cast(Elt); + if (!CI) // This array isn't suitable, non-int initializer. + return 0; + if (CI->isZero()) + return i-StartIdx+1; // We found end of string, success! + } + + return 0; // The array isn't null terminated, conservatively return 'unknown'. +} + +/// GetStringLength - If we can compute the length of the string pointed to by +/// the specified pointer, return 'len+1'. If we can't, return 0. +static uint64_t GetStringLength(Value *V) { + if (!isa(V->getType())) return 0; + + SmallPtrSet PHIs; + uint64_t Len = GetStringLengthH(V, PHIs); + // If Len is ~0ULL, we had an infinite phi cycle: this is dead code, so return + // an empty string as a length. + return Len == ~0ULL ? 1 : Len; +} + +/// IsOnlyUsedInZeroEqualityComparison - Return true if it only matters that the +/// value is equal or not-equal to zero. +static bool IsOnlyUsedInZeroEqualityComparison(Value *V) { + for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); + UI != E; ++UI) { + if (ICmpInst *IC = dyn_cast(*UI)) + if (IC->isEquality()) + if (Constant *C = dyn_cast(IC->getOperand(1))) + if (C->isNullValue()) + continue; + // Unknown instruction. + return false; + } + return true; +} + +//===----------------------------------------------------------------------===// +// Miscellaneous LibCall Optimizations +//===----------------------------------------------------------------------===// + +//===---------------------------------------===// +// 'exit' Optimizations + +/// ExitOpt - int main() { exit(4); } --> int main() { return 4; } +struct VISIBILITY_HIDDEN ExitOpt : public LibCallOptimization { + virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) { + // Verify we have a reasonable prototype for exit. + if (Callee->arg_size() == 0 || !CI->use_empty()) + return 0; + + // Verify the caller is main, and that the result type of main matches the + // argument type of exit. + if (!Caller->isName("main") || !Caller->hasExternalLinkage() || + Caller->getReturnType() != CI->getOperand(1)->getType()) + return 0; + + TerminatorInst *OldTI = CI->getParent()->getTerminator(); + + // Create the return after the call. + ReturnInst *RI = B.CreateRet(CI->getOperand(1)); + + // Drop all successor phi node entries. + for (unsigned i = 0, e = OldTI->getNumSuccessors(); i != e; ++i) + OldTI->getSuccessor(i)->removePredecessor(CI->getParent()); + + // Erase all instructions from after our return instruction until the end of + // the block. + BasicBlock::iterator FirstDead = RI; ++FirstDead; + CI->getParent()->getInstList().erase(FirstDead, CI->getParent()->end()); + return CI; + } +}; + +//===----------------------------------------------------------------------===// +// String and Memory LibCall Optimizations +//===----------------------------------------------------------------------===// + +//===---------------------------------------===// +// 'strcat' Optimizations + +struct VISIBILITY_HIDDEN StrCatOpt : public LibCallOptimization { + virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) { + // Verify the "strcat" function prototype. + const FunctionType *FT = Callee->getFunctionType(); + if (FT->getNumParams() != 2 || + FT->getReturnType() != PointerType::getUnqual(Type::Int8Ty) || + FT->getParamType(0) != FT->getReturnType() || + FT->getParamType(1) != FT->getReturnType()) + return 0; + + // Extract some information from the instruction + Value *Dst = CI->getOperand(1); + Value *Src = CI->getOperand(2); + + // See if we can get the length of the input string. + uint64_t Len = GetStringLength(Src); + if (Len == 0) return false; + --Len; // Unbias length. + + // Handle the simple, do-nothing case: strcat(x, "") -> x + if (Len == 0) + return Dst; + + // We need to find the end of the destination string. That's where the + // memory is to be moved to. We just generate a call to strlen. + Value *DstLen = EmitStrLen(Dst, B); + + // Now that we have the destination's length, we must index into the + // destination's pointer to get the actual memcpy destination (end of + // the string .. we're concatenating). + Dst = B.CreateGEP(Dst, DstLen, "endptr"); + + // We have enough information to now generate the memcpy call to do the + // concatenation for us. Make a memcpy to copy the nul byte with align = 1. + EmitMemCpy(Dst, Src, ConstantInt::get(TD->getIntPtrType(), Len+1), 1, B); + return Dst; + } +}; + +//===---------------------------------------===// +// 'strchr' Optimizations + +struct VISIBILITY_HIDDEN StrChrOpt : public LibCallOptimization { + virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) { + // Verify the "strchr" function prototype. + const FunctionType *FT = Callee->getFunctionType(); + if (FT->getNumParams() != 2 || + FT->getReturnType() != PointerType::getUnqual(Type::Int8Ty) || + FT->getParamType(0) != FT->getReturnType()) + return 0; + + Value *SrcStr = CI->getOperand(1); + + // If the second operand is non-constant, see if we can compute the length + // of the input string and turn this into memchr. + ConstantInt *CharC = dyn_cast(CI->getOperand(2)); + if (CharC == 0) { + uint64_t Len = GetStringLength(SrcStr); + if (Len == 0 || FT->getParamType(1) != Type::Int32Ty) // memchr needs i32. + return 0; + + return EmitMemChr(SrcStr, CI->getOperand(2), // include nul. + ConstantInt::get(TD->getIntPtrType(), Len), B); + } + + // Otherwise, the character is a constant, see if the first argument is + // a string literal. If so, we can constant fold. + std::string Str; + if (!GetConstantStringInfo(SrcStr, Str)) + return false; + + // strchr can find the nul character. + Str += '\0'; + char CharValue = CharC->getSExtValue(); + + // Compute the offset. + uint64_t i = 0; + while (1) { + if (i == Str.size()) // Didn't find the char. strchr returns null. + return Constant::getNullValue(CI->getType()); + // Did we find our match? + if (Str[i] == CharValue) + break; + ++i; + } + + // strchr(s+n,c) -> gep(s+n+i,c) + Value *Idx = ConstantInt::get(Type::Int64Ty, i); + return B.CreateGEP(SrcStr, Idx, "strchr"); + } +}; + +//===---------------------------------------===// +// 'strcmp' Optimizations + +struct VISIBILITY_HIDDEN StrCmpOpt : public LibCallOptimization { + virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) { + // Verify the "strcmp" function prototype. + const FunctionType *FT = Callee->getFunctionType(); + if (FT->getNumParams() != 2 || FT->getReturnType() != Type::Int32Ty || + FT->getParamType(0) != FT->getParamType(1) || + FT->getParamType(0) != PointerType::getUnqual(Type::Int8Ty)) + return 0; + + Value *Str1P = CI->getOperand(1), *Str2P = CI->getOperand(2); + if (Str1P == Str2P) // strcmp(x,x) -> 0 + return ConstantInt::get(CI->getType(), 0); + + std::string Str1, Str2; + bool HasStr1 = GetConstantStringInfo(Str1P, Str1); + bool HasStr2 = GetConstantStringInfo(Str2P, Str2); + + if (HasStr1 && Str1.empty()) // strcmp("", x) -> *x + return B.CreateZExt(B.CreateLoad(Str2P, "strcmpload"), CI->getType()); + + if (HasStr2 && Str2.empty()) // strcmp(x,"") -> *x + return B.CreateZExt(B.CreateLoad(Str1P, "strcmpload"), CI->getType()); + + // strcmp(x, y) -> cnst (if both x and y are constant strings) + if (HasStr1 && HasStr2) + return ConstantInt::get(CI->getType(), strcmp(Str1.c_str(),Str2.c_str())); + return 0; + } +}; + +//===---------------------------------------===// +// 'strncmp' Optimizations + +struct VISIBILITY_HIDDEN StrNCmpOpt : public LibCallOptimization { + virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) { + // Verify the "strncmp" function prototype. + const FunctionType *FT = Callee->getFunctionType(); + if (FT->getNumParams() != 3 || FT->getReturnType() != Type::Int32Ty || + FT->getParamType(0) != FT->getParamType(1) || + FT->getParamType(0) != PointerType::getUnqual(Type::Int8Ty) || + !isa(FT->getParamType(2))) + return 0; + + Value *Str1P = CI->getOperand(1), *Str2P = CI->getOperand(2); + if (Str1P == Str2P) // strncmp(x,x,n) -> 0 + return ConstantInt::get(CI->getType(), 0); + + // Get the length argument if it is constant. + uint64_t Length; + if (ConstantInt *LengthArg = dyn_cast(CI->getOperand(3))) + Length = LengthArg->getZExtValue(); + else + return 0; + + if (Length == 0) // strncmp(x,y,0) -> 0 + return ConstantInt::get(CI->getType(), 0); + + std::string Str1, Str2; + bool HasStr1 = GetConstantStringInfo(Str1P, Str1); + bool HasStr2 = GetConstantStringInfo(Str2P, Str2); + + if (HasStr1 && Str1.empty()) // strncmp("", x, n) -> *x + return B.CreateZExt(B.CreateLoad(Str2P, "strcmpload"), CI->getType()); + + if (HasStr2 && Str2.empty()) // strncmp(x, "", n) -> *x + return B.CreateZExt(B.CreateLoad(Str1P, "strcmpload"), CI->getType()); + + // strncmp(x, y) -> cnst (if both x and y are constant strings) + if (HasStr1 && HasStr2) + return ConstantInt::get(CI->getType(), + strncmp(Str1.c_str(), Str2.c_str(), Length)); + return 0; + } +}; + + +//===---------------------------------------===// +// 'strcpy' Optimizations + +struct VISIBILITY_HIDDEN StrCpyOpt : public LibCallOptimization { + virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) { + // Verify the "strcpy" function prototype. + const FunctionType *FT = Callee->getFunctionType(); + if (FT->getNumParams() != 2 || FT->getReturnType() != FT->getParamType(0) || + FT->getParamType(0) != FT->getParamType(1) || + FT->getParamType(0) != PointerType::getUnqual(Type::Int8Ty)) + return 0; + + Value *Dst = CI->getOperand(1), *Src = CI->getOperand(2); + if (Dst == Src) // strcpy(x,x) -> x + return Src; + + // See if we can get the length of the input string. + uint64_t Len = GetStringLength(Src); + if (Len == 0) return false; + + // We have enough information to now generate the memcpy call to do the + // concatenation for us. Make a memcpy to copy the nul byte with align = 1. + EmitMemCpy(Dst, Src, ConstantInt::get(TD->getIntPtrType(), Len), 1, B); + return Dst; + } +}; + + + +//===---------------------------------------===// +// 'strlen' Optimizations + +struct VISIBILITY_HIDDEN StrLenOpt : public LibCallOptimization { + virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) { + const FunctionType *FT = Callee->getFunctionType(); + if (FT->getNumParams() != 1 || + FT->getParamType(0) != PointerType::getUnqual(Type::Int8Ty) || + !isa(FT->getReturnType())) + return 0; + + Value *Src = CI->getOperand(1); + + // Constant folding: strlen("xyz") -> 3 + if (uint64_t Len = GetStringLength(Src)) + return ConstantInt::get(CI->getType(), Len-1); + + // Handle strlen(p) != 0. + if (!IsOnlyUsedInZeroEqualityComparison(CI)) return 0; + + // strlen(x) != 0 --> *x != 0 + // strlen(x) == 0 --> *x == 0 + return B.CreateZExt(B.CreateLoad(Src, "strlenfirst"), CI->getType()); + } +}; + +//===---------------------------------------===// +// 'memcmp' Optimizations + +struct VISIBILITY_HIDDEN MemCmpOpt : public LibCallOptimization { + virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) { + const FunctionType *FT = Callee->getFunctionType(); + if (FT->getNumParams() != 3 || !isa(FT->getParamType(0)) || + !isa(FT->getParamType(1)) || + FT->getReturnType() != Type::Int32Ty) + return 0; + + Value *LHS = CI->getOperand(1), *RHS = CI->getOperand(2); + + if (LHS == RHS) // memcmp(s,s,x) -> 0 + return Constant::getNullValue(CI->getType()); + + // Make sure we have a constant length. + ConstantInt *LenC = dyn_cast(CI->getOperand(3)); + if (!LenC) return false; + uint64_t Len = LenC->getZExtValue(); + + if (Len == 0) // memcmp(s1,s2,0) -> 0 + return Constant::getNullValue(CI->getType()); + + if (Len == 1) { // memcmp(S1,S2,1) -> *LHS - *RHS + Value *LHSV = B.CreateLoad(CastToCStr(LHS, B), "lhsv"); + Value *RHSV = B.CreateLoad(CastToCStr(RHS, B), "rhsv"); + return B.CreateZExt(B.CreateSub(LHSV, RHSV, "chardiff"), CI->getType()); + } + + // memcmp(S1,S2,2) != 0 -> (*(short*)LHS ^ *(short*)RHS) != 0 + // memcmp(S1,S2,4) != 0 -> (*(int*)LHS ^ *(int*)RHS) != 0 + if ((Len == 2 || Len == 4) && IsOnlyUsedInZeroEqualityComparison(CI)) { + LHS = B.CreateBitCast(LHS, PointerType::getUnqual(Type::Int16Ty), "tmp"); + RHS = B.CreateBitCast(RHS, LHS->getType(), "tmp"); + LoadInst *LHSV = B.CreateLoad(LHS, "lhsv"); + LoadInst *RHSV = B.CreateLoad(RHS, "rhsv"); + LHSV->setAlignment(1); RHSV->setAlignment(1); // Unaligned loads. + return B.CreateZExt(B.CreateXor(LHSV, RHSV, "shortdiff"), CI->getType()); + } + + return 0; + } +}; + +//===---------------------------------------===// +// 'memcpy' Optimizations + +struct VISIBILITY_HIDDEN MemCpyOpt : public LibCallOptimization { + virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) { + const FunctionType *FT = Callee->getFunctionType(); + if (FT->getNumParams() != 3 || FT->getReturnType() != FT->getParamType(0) || + !isa(FT->getParamType(0)) || + !isa(FT->getParamType(1)) || + FT->getParamType(2) != TD->getIntPtrType()) + return 0; + + // memcpy(x, y, n) -> llvm.memcpy(x, y, n, 1) + EmitMemCpy(CI->getOperand(1), CI->getOperand(2), CI->getOperand(3), 1, B); + return CI->getOperand(1); + } +}; + +//===----------------------------------------------------------------------===// +// Math Library Optimizations +//===----------------------------------------------------------------------===// + +//===---------------------------------------===// +// 'pow*' Optimizations + +struct VISIBILITY_HIDDEN PowOpt : public LibCallOptimization { + virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) { + const FunctionType *FT = Callee->getFunctionType(); + // Just make sure this has 2 arguments of the same FP type, which match the + // result type. + if (FT->getNumParams() != 2 || FT->getReturnType() != FT->getParamType(0) || + FT->getParamType(0) != FT->getParamType(1) || + !FT->getParamType(0)->isFloatingPoint()) + return 0; + + Value *Op1 = CI->getOperand(1), *Op2 = CI->getOperand(2); + if (ConstantFP *Op1C = dyn_cast(Op1)) { + if (Op1C->isExactlyValue(1.0)) // pow(1.0, x) -> 1.0 + return Op1C; + if (Op1C->isExactlyValue(2.0)) // pow(2.0, x) -> exp2(x) + return EmitUnaryFloatFnCall(Op2, "exp2", B); + } + + ConstantFP *Op2C = dyn_cast(Op2); + if (Op2C == 0) return 0; + + if (Op2C->getValueAPF().isZero()) // pow(x, 0.0) -> 1.0 + return ConstantFP::get(CI->getType(), 1.0); + + if (Op2C->isExactlyValue(0.5)) { + // FIXME: This is not safe for -0.0 and -inf. This can only be done when + // 'unsafe' math optimizations are allowed. + // x pow(x, 0.5) sqrt(x) + // --------------------------------------------- + // -0.0 +0.0 -0.0 + // -inf +inf NaN +#if 0 + // pow(x, 0.5) -> sqrt(x) + return B.CreateCall(get_sqrt(), Op1, "sqrt"); +#endif + } + + if (Op2C->isExactlyValue(1.0)) // pow(x, 1.0) -> x + return Op1; + if (Op2C->isExactlyValue(2.0)) // pow(x, 2.0) -> x*x + return B.CreateMul(Op1, Op1, "pow2"); + if (Op2C->isExactlyValue(-1.0)) // pow(x, -1.0) -> 1.0/x + return B.CreateFDiv(ConstantFP::get(CI->getType(), 1.0), Op1, "powrecip"); + return 0; + } +}; + +//===---------------------------------------===// +// Double -> Float Shrinking Optimizations for Unary Functions like 'floor' + +struct VISIBILITY_HIDDEN UnaryDoubleFPOpt : public LibCallOptimization { + virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) { + const FunctionType *FT = Callee->getFunctionType(); + if (FT->getNumParams() != 1 || FT->getReturnType() != Type::DoubleTy || + FT->getParamType(0) != Type::DoubleTy) + return 0; + + // If this is something like 'floor((double)floatval)', convert to floorf. + FPExtInst *Cast = dyn_cast(CI->getOperand(1)); + if (Cast == 0 || Cast->getOperand(0)->getType() != Type::FloatTy) + return 0; + + // floor((double)floatval) -> (double)floorf(floatval) + Value *V = Cast->getOperand(0); + V = EmitUnaryFloatFnCall(V, Callee->getNameStart(), B); + return B.CreateFPExt(V, Type::DoubleTy); + } +}; + +//===----------------------------------------------------------------------===// +// Integer Optimizations +//===----------------------------------------------------------------------===// + +//===---------------------------------------===// +// 'ffs*' Optimizations + +struct VISIBILITY_HIDDEN FFSOpt : public LibCallOptimization { + virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) { + const FunctionType *FT = Callee->getFunctionType(); + // Just make sure this has 2 arguments of the same FP type, which match the + // result type. + if (FT->getNumParams() != 1 || FT->getReturnType() != Type::Int32Ty || + !isa(FT->getParamType(0))) + return 0; + + Value *Op = CI->getOperand(1); + + // Constant fold. + if (ConstantInt *CI = dyn_cast(Op)) { + if (CI->getValue() == 0) // ffs(0) -> 0. + return Constant::getNullValue(CI->getType()); + return ConstantInt::get(Type::Int32Ty, // ffs(c) -> cttz(c)+1 + CI->getValue().countTrailingZeros()+1); + } + + // ffs(x) -> x != 0 ? (i32)llvm.cttz(x)+1 : 0 + const Type *ArgType = Op->getType(); + Value *F = Intrinsic::getDeclaration(Callee->getParent(), + Intrinsic::cttz, &ArgType, 1); + Value *V = B.CreateCall(F, Op, "cttz"); + V = B.CreateAdd(V, ConstantInt::get(Type::Int32Ty, 1), "tmp"); + V = B.CreateIntCast(V, Type::Int32Ty, false, "tmp"); + + Value *Cond = B.CreateICmpNE(Op, Constant::getNullValue(ArgType), "tmp"); + return B.CreateSelect(Cond, V, ConstantInt::get(Type::Int32Ty, 0)); + } +}; + +//===---------------------------------------===// +// 'isdigit' Optimizations + +struct VISIBILITY_HIDDEN IsDigitOpt : public LibCallOptimization { + virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) { + const FunctionType *FT = Callee->getFunctionType(); + // We require integer(i32) + if (FT->getNumParams() != 1 || !isa(FT->getReturnType()) || + FT->getParamType(0) != Type::Int32Ty) + return 0; + + // isdigit(c) -> (c-'0') getOperand(1); + Op = B.CreateSub(Op, ConstantInt::get(Type::Int32Ty, '0'), "isdigittmp"); + Op = B.CreateICmpULT(Op, ConstantInt::get(Type::Int32Ty, 10), "isdigit"); + return B.CreateZExt(Op, CI->getType()); + } +}; + +//===---------------------------------------===// +// 'isascii' Optimizations + +struct VISIBILITY_HIDDEN IsAsciiOpt : public LibCallOptimization { + virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) { + const FunctionType *FT = Callee->getFunctionType(); + // We require integer(i32) + if (FT->getNumParams() != 1 || !isa(FT->getReturnType()) || + FT->getParamType(0) != Type::Int32Ty) + return 0; + + // isascii(c) -> c getOperand(1); + Op = B.CreateICmpULT(Op, ConstantInt::get(Type::Int32Ty, 128), "isascii"); + return B.CreateZExt(Op, CI->getType()); + } +}; + +//===---------------------------------------===// +// 'toascii' Optimizations + +struct VISIBILITY_HIDDEN ToAsciiOpt : public LibCallOptimization { + virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) { + const FunctionType *FT = Callee->getFunctionType(); + // We require i32(i32) + if (FT->getNumParams() != 1 || FT->getReturnType() != FT->getParamType(0) || + FT->getParamType(0) != Type::Int32Ty) + return 0; + + // isascii(c) -> c & 0x7f + return B.CreateAnd(CI->getOperand(1), ConstantInt::get(CI->getType(),0x7F)); + } +}; + +//===----------------------------------------------------------------------===// +// Formatting and IO Optimizations +//===----------------------------------------------------------------------===// + +//===---------------------------------------===// +// 'printf' Optimizations + +struct VISIBILITY_HIDDEN PrintFOpt : public LibCallOptimization { + virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) { + // Require one fixed pointer argument and an integer/void result. + const FunctionType *FT = Callee->getFunctionType(); + if (FT->getNumParams() < 1 || !isa(FT->getParamType(0)) || + !(isa(FT->getReturnType()) || + FT->getReturnType() == Type::VoidTy)) + return 0; + + // Check for a fixed format string. + std::string FormatStr; + if (!GetConstantStringInfo(CI->getOperand(1), FormatStr)) + return false; + + // Empty format string -> noop. + if (FormatStr.empty()) // Tolerate printf's declared void. + return CI->use_empty() ? (Value*)CI : ConstantInt::get(CI->getType(), 0); + + // printf("x") -> putchar('x'), even for '%'. + if (FormatStr.size() == 1) { + EmitPutChar(ConstantInt::get(Type::Int32Ty, FormatStr[0]), B); + return CI->use_empty() ? (Value*)CI : ConstantInt::get(CI->getType(), 1); + } + + // printf("foo\n") --> puts("foo") + if (FormatStr[FormatStr.size()-1] == '\n' && + FormatStr.find('%') == std::string::npos) { // no format characters. + // Create a string literal with no \n on it. We expect the constant merge + // pass to be run after this pass, to merge duplicate strings. + FormatStr.erase(FormatStr.end()-1); + Constant *C = ConstantArray::get(FormatStr, true); + C = new GlobalVariable(C->getType(), true,GlobalVariable::InternalLinkage, + C, "str", Callee->getParent()); + EmitPutS(C, B); + return CI->use_empty() ? (Value*)CI : + ConstantInt::get(CI->getType(), FormatStr.size()+1); + } + + // Optimize specific format strings. + // printf("%c", chr) --> putchar(*(i8*)dst) + if (FormatStr == "%c" && CI->getNumOperands() > 2 && + isa(CI->getOperand(2)->getType())) { + EmitPutChar(CI->getOperand(2), B); + return CI->use_empty() ? (Value*)CI : ConstantInt::get(CI->getType(), 1); + } + + // printf("%s\n", str) --> puts(str) + if (FormatStr == "%s\n" && CI->getNumOperands() > 2 && + isa(CI->getOperand(2)->getType()) && + CI->use_empty()) { + EmitPutS(CI->getOperand(2), B); + return CI; + } + return 0; + } +}; + +//===---------------------------------------===// +// 'sprintf' Optimizations + +struct VISIBILITY_HIDDEN SPrintFOpt : public LibCallOptimization { + virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) { + // Require two fixed pointer arguments and an integer result. + const FunctionType *FT = Callee->getFunctionType(); + if (FT->getNumParams() != 2 || !isa(FT->getParamType(0)) || + !isa(FT->getParamType(1)) || + !isa(FT->getReturnType())) + return 0; + + // Check for a fixed format string. + std::string FormatStr; + if (!GetConstantStringInfo(CI->getOperand(2), FormatStr)) + return false; + + // If we just have a format string (nothing else crazy) transform it. + if (CI->getNumOperands() == 3) { + // Make sure there's no % in the constant array. We could try to handle + // %% -> % in the future if we cared. + for (unsigned i = 0, e = FormatStr.size(); i != e; ++i) + if (FormatStr[i] == '%') + return 0; // we found a format specifier, bail out. + + // sprintf(str, fmt) -> llvm.memcpy(str, fmt, strlen(fmt)+1, 1) + EmitMemCpy(CI->getOperand(1), CI->getOperand(2), // Copy the nul byte. + ConstantInt::get(TD->getIntPtrType(), FormatStr.size()+1),1,B); + return ConstantInt::get(CI->getType(), FormatStr.size()); + } + + // The remaining optimizations require the format string to be "%s" or "%c" + // and have an extra operand. + if (FormatStr.size() != 2 || FormatStr[0] != '%' || CI->getNumOperands() <4) + return 0; + + // Decode the second character of the format string. + if (FormatStr[1] == 'c') { + // sprintf(dst, "%c", chr) --> *(i8*)dst = chr + if (!isa(CI->getOperand(3)->getType())) return 0; + Value *V = B.CreateTrunc(CI->getOperand(3), Type::Int8Ty, "char"); + B.CreateStore(V, CastToCStr(CI->getOperand(1), B)); + return ConstantInt::get(CI->getType(), 1); + } + + if (FormatStr[1] == 's') { + // sprintf(dest, "%s", str) -> llvm.memcpy(dest, str, strlen(str)+1, 1) + if (!isa(CI->getOperand(3)->getType())) return 0; + + Value *Len = EmitStrLen(CI->getOperand(3), B); + Value *IncLen = B.CreateAdd(Len, ConstantInt::get(Len->getType(), 1), + "leninc"); + EmitMemCpy(CI->getOperand(1), CI->getOperand(3), IncLen, 1, B); + + // The sprintf result is the unincremented number of bytes in the string. + return B.CreateIntCast(Len, CI->getType(), false); + } + return 0; + } +}; + +//===---------------------------------------===// +// 'fwrite' Optimizations + +struct VISIBILITY_HIDDEN FWriteOpt : public LibCallOptimization { + virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) { + // Require a pointer, an integer, an integer, a pointer, returning integer. + const FunctionType *FT = Callee->getFunctionType(); + if (FT->getNumParams() != 4 || !isa(FT->getParamType(0)) || + !isa(FT->getParamType(1)) || + !isa(FT->getParamType(2)) || + !isa(FT->getParamType(3)) || + !isa(FT->getReturnType())) + return 0; + + // Get the element size and count. + ConstantInt *SizeC = dyn_cast(CI->getOperand(2)); + ConstantInt *CountC = dyn_cast(CI->getOperand(3)); + if (!SizeC || !CountC) return 0; + uint64_t Bytes = SizeC->getZExtValue()*CountC->getZExtValue(); + + // If this is writing zero records, remove the call (it's a noop). + if (Bytes == 0) + return ConstantInt::get(CI->getType(), 0); + + // If this is writing one byte, turn it into fputc. + if (Bytes == 1) { // fwrite(S,1,1,F) -> fputc(S[0],F) + Value *Char = B.CreateLoad(CastToCStr(CI->getOperand(1), B), "char"); + EmitFPutC(Char, CI->getOperand(4), B); + return ConstantInt::get(CI->getType(), 1); + } + + return 0; + } +}; + +//===---------------------------------------===// +// 'fputs' Optimizations + +struct VISIBILITY_HIDDEN FPutsOpt : public LibCallOptimization { + virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) { + // Require two pointers. Also, we can't optimize if return value is used. + const FunctionType *FT = Callee->getFunctionType(); + if (FT->getNumParams() != 2 || !isa(FT->getParamType(0)) || + !isa(FT->getParamType(1)) || + !CI->use_empty()) + return 0; + + // fputs(s,F) --> fwrite(s,1,strlen(s),F) + uint64_t Len = GetStringLength(CI->getOperand(1)); + if (!Len) return false; + EmitFWrite(CI->getOperand(1), ConstantInt::get(TD->getIntPtrType(), Len-1), + CI->getOperand(2), B); + return CI; // Known to have no uses (see above). + } +}; + +//===---------------------------------------===// +// 'fprintf' Optimizations + +struct VISIBILITY_HIDDEN FPrintFOpt : public LibCallOptimization { + virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) { + // Require two fixed paramters as pointers and integer result. + const FunctionType *FT = Callee->getFunctionType(); + if (FT->getNumParams() != 2 || !isa(FT->getParamType(0)) || + !isa(FT->getParamType(1)) || + !isa(FT->getReturnType())) + return 0; + + // All the optimizations depend on the format string. + std::string FormatStr; + if (!GetConstantStringInfo(CI->getOperand(2), FormatStr)) + return false; + + // fprintf(F, "foo") --> fwrite("foo", 3, 1, F) + if (CI->getNumOperands() == 3) { + for (unsigned i = 0, e = FormatStr.size(); i != e; ++i) + if (FormatStr[i] == '%') // Could handle %% -> % if we cared. + return false; // We found a format specifier. + + EmitFWrite(CI->getOperand(2), ConstantInt::get(TD->getIntPtrType(), + FormatStr.size()), + CI->getOperand(1), B); + return ConstantInt::get(CI->getType(), FormatStr.size()); + } + + // The remaining optimizations require the format string to be "%s" or "%c" + // and have an extra operand. + if (FormatStr.size() != 2 || FormatStr[0] != '%' || CI->getNumOperands() <4) + return 0; + + // Decode the second character of the format string. + if (FormatStr[1] == 'c') { + // fprintf(F, "%c", chr) --> *(i8*)dst = chr + if (!isa(CI->getOperand(3)->getType())) return 0; + EmitFPutC(CI->getOperand(3), CI->getOperand(1), B); + return ConstantInt::get(CI->getType(), 1); + } + + if (FormatStr[1] == 's') { + // fprintf(F, "%s", str) -> fputs(str, F) + if (!isa(CI->getOperand(3)->getType()) || !CI->use_empty()) + return 0; + EmitFPutS(CI->getOperand(3), CI->getOperand(1), B); + return CI; + } + return 0; + } +}; + + +//===----------------------------------------------------------------------===// +// SimplifyLibCalls Pass Implementation +//===----------------------------------------------------------------------===// + +namespace { + /// This pass optimizes well known library functions from libc and libm. + /// + class VISIBILITY_HIDDEN SimplifyLibCalls : public FunctionPass { + StringMap Optimizations; + // Miscellaneous LibCall Optimizations + ExitOpt Exit; + // String and Memory LibCall Optimizations + StrCatOpt StrCat; StrChrOpt StrChr; StrCmpOpt StrCmp; StrNCmpOpt StrNCmp; + StrCpyOpt StrCpy; StrLenOpt StrLen; MemCmpOpt MemCmp; MemCpyOpt MemCpy; + // Math Library Optimizations + PowOpt Pow; UnaryDoubleFPOpt UnaryDoubleFP; + // Integer Optimizations + FFSOpt FFS; IsDigitOpt IsDigit; IsAsciiOpt IsAscii; ToAsciiOpt ToAscii; + // Formatting and IO Optimizations + SPrintFOpt SPrintF; PrintFOpt PrintF; + FWriteOpt FWrite; FPutsOpt FPuts; FPrintFOpt FPrintF; + public: + static char ID; // Pass identification + SimplifyLibCalls() : FunctionPass((intptr_t)&ID) {} + + void InitOptimizations(); + bool runOnFunction(Function &F); + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(); + } + }; + char SimplifyLibCalls::ID = 0; +} // end anonymous namespace. + +static RegisterPass +X("simplify-libcalls", "Simplify well-known library calls"); + +// Public interface to the Simplify LibCalls pass. +FunctionPass *llvm::createSimplifyLibCallsPass() { + return new SimplifyLibCalls(); +} + +/// Optimizations - Populate the Optimizations map with all the optimizations +/// we know. +void SimplifyLibCalls::InitOptimizations() { + // Miscellaneous LibCall Optimizations + Optimizations["exit"] = &Exit; + + // String and Memory LibCall Optimizations + Optimizations["strcat"] = &StrCat; + Optimizations["strchr"] = &StrChr; + Optimizations["strcmp"] = &StrCmp; + Optimizations["strncmp"] = &StrNCmp; + Optimizations["strcpy"] = &StrCpy; + Optimizations["strlen"] = &StrLen; + Optimizations["memcmp"] = &MemCmp; + Optimizations["memcpy"] = &MemCpy; + + // Math Library Optimizations + Optimizations["powf"] = &Pow; + Optimizations["pow"] = &Pow; + Optimizations["powl"] = &Pow; +#ifdef HAVE_FLOORF + Optimizations["floor"] = &UnaryDoubleFP; +#endif +#ifdef HAVE_CEILF + Optimizations["ceil"] = &UnaryDoubleFP; +#endif +#ifdef HAVE_ROUNDF + Optimizations["round"] = &UnaryDoubleFP; +#endif +#ifdef HAVE_RINTF + Optimizations["rint"] = &UnaryDoubleFP; +#endif +#ifdef HAVE_NEARBYINTF + Optimizations["nearbyint"] = &UnaryDoubleFP; +#endif + + // Integer Optimizations + Optimizations["ffs"] = &FFS; + Optimizations["ffsl"] = &FFS; + Optimizations["ffsll"] = &FFS; + Optimizations["isdigit"] = &IsDigit; + Optimizations["isascii"] = &IsAscii; + Optimizations["toascii"] = &ToAscii; + + // Formatting and IO Optimizations + Optimizations["sprintf"] = &SPrintF; + Optimizations["printf"] = &PrintF; + Optimizations["fwrite"] = &FWrite; + Optimizations["fputs"] = &FPuts; + Optimizations["fprintf"] = &FPrintF; +} + + +/// runOnFunction - Top level algorithm. +/// +bool SimplifyLibCalls::runOnFunction(Function &F) { + if (Optimizations.empty()) + InitOptimizations(); + + const TargetData &TD = getAnalysis(); + + IRBuilder Builder; + + bool Changed = false; + for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) { + for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ) { + // Ignore non-calls. + CallInst *CI = dyn_cast(I++); + if (!CI) continue; + + // Ignore indirect calls and calls to non-external functions. + Function *Callee = CI->getCalledFunction(); + if (Callee == 0 || !Callee->isDeclaration() || + !(Callee->hasExternalLinkage() || Callee->hasDLLImportLinkage())) + continue; + + // Ignore unknown calls. + const char *CalleeName = Callee->getNameStart(); + StringMap::iterator OMI = + Optimizations.find(CalleeName, CalleeName+Callee->getNameLen()); + if (OMI == Optimizations.end()) continue; + + // Set the builder to the instruction after the call. + Builder.SetInsertPoint(BB, I); + + // Try to optimize this call. + Value *Result = OMI->second->OptimizeCall(CI, TD, Builder); + if (Result == 0) continue; + + // Something changed! + Changed = true; + ++NumSimplified; + + // Inspect the instruction after the call (which was potentially just + // added) next. + I = CI; ++I; + + if (CI != Result && !CI->use_empty()) { + CI->replaceAllUsesWith(Result); + if (!Result->hasName()) + Result->takeName(CI); + } + CI->eraseFromParent(); + } + } + return Changed; +} + + +// TODO: +// Additional cases that we need to add to this file: +// +// cbrt: +// * cbrt(expN(X)) -> expN(x/3) +// * cbrt(sqrt(x)) -> pow(x,1/6) +// * cbrt(sqrt(x)) -> pow(x,1/9) +// +// cos, cosf, cosl: +// * cos(-x) -> cos(x) +// +// exp, expf, expl: +// * exp(log(x)) -> x +// +// log, logf, logl: +// * log(exp(x)) -> x +// * log(x**y) -> y*log(x) +// * log(exp(y)) -> y*log(e) +// * log(exp2(y)) -> y*log(2) +// * log(exp10(y)) -> y*log(10) +// * log(sqrt(x)) -> 0.5*log(x) +// * log(pow(x,y)) -> y*log(x) +// +// lround, lroundf, lroundl: +// * lround(cnst) -> cnst' +// +// memcmp: +// * memcmp(x,y,l) -> cnst +// (if all arguments are constant and strlen(x) <= l and strlen(y) <= l) +// +// memmove: +// * memmove(d,s,l,a) -> memcpy(d,s,l,a) +// (if s is a global constant array) +// +// pow, powf, powl: +// * pow(exp(x),y) -> exp(x*y) +// * pow(sqrt(x),y) -> pow(x,y*0.5) +// * pow(pow(x,y),z)-> pow(x,y*z) +// +// puts: +// * puts("") -> putchar("\n") +// +// round, roundf, roundl: +// * round(cnst) -> cnst' +// +// signbit: +// * signbit(cnst) -> cnst' +// * signbit(nncst) -> 0 (if pstv is a non-negative constant) +// +// sqrt, sqrtf, sqrtl: +// * sqrt(expN(x)) -> expN(x*0.5) +// * sqrt(Nroot(x)) -> pow(x,1/(2*N)) +// * sqrt(pow(x,y)) -> pow(|x|,y*0.5) +// +// stpcpy: +// * stpcpy(str, "literal") -> +// llvm.memcpy(str,"literal",strlen("literal")+1,1) +// strrchr: +// * strrchr(s,c) -> reverse_offset_of_in(c,s) +// (if c is a constant integer and s is a constant string) +// * strrchr(s1,0) -> strchr(s1,0) +// +// strncat: +// * strncat(x,y,0) -> x +// * strncat(x,y,0) -> x (if strlen(y) = 0) +// * strncat(x,y,l) -> strcat(x,y) (if y and l are constants an l > strlen(y)) +// +// strncpy: +// * strncpy(d,s,0) -> d +// * strncpy(d,s,l) -> memcpy(d,s,l,1) +// (if s and l are constants) +// +// strpbrk: +// * strpbrk(s,a) -> offset_in_for(s,a) +// (if s and a are both constant strings) +// * strpbrk(s,"") -> 0 +// * strpbrk(s,a) -> strchr(s,a[0]) (if a is constant string of length 1) +// +// strspn, strcspn: +// * strspn(s,a) -> const_int (if both args are constant) +// * strspn("",a) -> 0 +// * strspn(s,"") -> 0 +// * strcspn(s,a) -> const_int (if both args are constant) +// * strcspn("",a) -> 0 +// * strcspn(s,"") -> strlen(a) +// +// strstr: +// * strstr(x,x) -> x +// * strstr(s1,s2) -> offset_of_s2_in(s1) +// (if s1 and s2 are constant strings) +// +// tan, tanf, tanl: +// * tan(atan(x)) -> x +// +// trunc, truncf, truncl: +// * trunc(cnst) -> cnst' +// +// From sabre at nondot.org Thu May 1 01:16:48 2008 From: sabre at nondot.org (Chris Lattner) Date: Thu, 01 May 2008 06:16:48 -0000 Subject: [llvm-commits] [llvm] r50519 - /llvm/trunk/test/Transforms/SimplifyLibCalls/floor.ll Message-ID: <200805010616.m416Gm9C014811@zion.cs.uiuc.edu> Author: lattner Date: Thu May 1 01:16:48 2008 New Revision: 50519 URL: http://llvm.org/viewvc/llvm-project?rev=50519&view=rev Log: fix typo Modified: llvm/trunk/test/Transforms/SimplifyLibCalls/floor.ll Modified: llvm/trunk/test/Transforms/SimplifyLibCalls/floor.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyLibCalls/floor.ll?rev=50519&r1=50518&r2=50519&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SimplifyLibCalls/floor.ll (original) +++ llvm/trunk/test/Transforms/SimplifyLibCalls/floor.ll Thu May 1 01:16:48 2008 @@ -31,7 +31,7 @@ define float @test_nearbyint(float %C) { %D = fpext float %C to double ; [#uses=1] - ; --> floorf + ; --> nearbyintf %E = call double @nearbyint( double %D ) ; [#uses=1] %F = fptrunc double %E to float ; [#uses=1] ret float %F From sabre at nondot.org Thu May 1 01:39:12 2008 From: sabre at nondot.org (Chris Lattner) Date: Thu, 01 May 2008 06:39:12 -0000 Subject: [llvm-commits] [llvm] r50521 - /llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Message-ID: <200805010639.m416dC1Y015412@zion.cs.uiuc.edu> Author: lattner Date: Thu May 1 01:39:12 2008 New Revision: 50521 URL: http://llvm.org/viewvc/llvm-project?rev=50521&view=rev Log: 1) add '-debug' output 2) Return NULL instead of false in several places for tidiness. 3) fix a bug optimizing sprintf(p, "%c", x) Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=50521&r1=50520&r2=50521&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Thu May 1 01:39:12 2008 @@ -28,6 +28,7 @@ #include "llvm/ADT/StringMap.h" #include "llvm/ADT/Statistic.h" #include "llvm/Support/Compiler.h" +#include "llvm/Support/Debug.h" #include "llvm/Config/config.h" using namespace llvm; @@ -509,7 +510,7 @@ // See if we can get the length of the input string. uint64_t Len = GetStringLength(Src); - if (Len == 0) return false; + if (Len == 0) return 0; --Len; // Unbias length. // Handle the simple, do-nothing case: strcat(x, "") -> x @@ -562,7 +563,7 @@ // a string literal. If so, we can constant fold. std::string Str; if (!GetConstantStringInfo(SrcStr, Str)) - return false; + return 0; // strchr can find the nul character. Str += '\0'; @@ -682,7 +683,7 @@ // See if we can get the length of the input string. uint64_t Len = GetStringLength(Src); - if (Len == 0) return false; + if (Len == 0) return 0; // We have enough information to now generate the memcpy call to do the // concatenation for us. Make a memcpy to copy the nul byte with align = 1. @@ -737,7 +738,7 @@ // Make sure we have a constant length. ConstantInt *LenC = dyn_cast(CI->getOperand(3)); - if (!LenC) return false; + if (!LenC) return 0; uint64_t Len = LenC->getZExtValue(); if (Len == 0) // memcmp(s1,s2,0) -> 0 @@ -969,7 +970,7 @@ // Check for a fixed format string. std::string FormatStr; if (!GetConstantStringInfo(CI->getOperand(1), FormatStr)) - return false; + return 0; // Empty format string -> noop. if (FormatStr.empty()) // Tolerate printf's declared void. @@ -1029,7 +1030,7 @@ // Check for a fixed format string. std::string FormatStr; if (!GetConstantStringInfo(CI->getOperand(2), FormatStr)) - return false; + return 0; // If we just have a format string (nothing else crazy) transform it. if (CI->getNumOperands() == 3) { @@ -1052,10 +1053,14 @@ // Decode the second character of the format string. if (FormatStr[1] == 'c') { - // sprintf(dst, "%c", chr) --> *(i8*)dst = chr + // sprintf(dst, "%c", chr) --> *(i8*)dst = chr; *((i8*)dst+1) = 0 if (!isa(CI->getOperand(3)->getType())) return 0; Value *V = B.CreateTrunc(CI->getOperand(3), Type::Int8Ty, "char"); - B.CreateStore(V, CastToCStr(CI->getOperand(1), B)); + Value *Ptr = CastToCStr(CI->getOperand(1), B); + B.CreateStore(V, Ptr); + Ptr = B.CreateGEP(Ptr, ConstantInt::get(Type::Int32Ty, 1), "nul"); + B.CreateStore(Constant::getNullValue(Type::Int8Ty), Ptr); + return ConstantInt::get(CI->getType(), 1); } @@ -1124,7 +1129,7 @@ // fputs(s,F) --> fwrite(s,1,strlen(s),F) uint64_t Len = GetStringLength(CI->getOperand(1)); - if (!Len) return false; + if (!Len) return 0; EmitFWrite(CI->getOperand(1), ConstantInt::get(TD->getIntPtrType(), Len-1), CI->getOperand(2), B); return CI; // Known to have no uses (see above). @@ -1146,13 +1151,13 @@ // All the optimizations depend on the format string. std::string FormatStr; if (!GetConstantStringInfo(CI->getOperand(2), FormatStr)) - return false; + return 0; // fprintf(F, "foo") --> fwrite("foo", 3, 1, F) if (CI->getNumOperands() == 3) { for (unsigned i = 0, e = FormatStr.size(); i != e; ++i) if (FormatStr[i] == '%') // Could handle %% -> % if we cared. - return false; // We found a format specifier. + return 0; // We found a format specifier. EmitFWrite(CI->getOperand(2), ConstantInt::get(TD->getIntPtrType(), FormatStr.size()), @@ -1317,6 +1322,9 @@ Value *Result = OMI->second->OptimizeCall(CI, TD, Builder); if (Result == 0) continue; + DEBUG(DOUT << "SimplifyLibCalls simplified: " << *CI; + DOUT << " into: " << *Result << "\n"); + // Something changed! Changed = true; ++NumSimplified; From evan.cheng at apple.com Thu May 1 01:51:32 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 01 May 2008 06:51:32 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50522 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Message-ID: <200805010651.m416pWgN015789@zion.cs.uiuc.edu> Author: evancheng Date: Thu May 1 01:51:32 2008 New Revision: 50522 URL: http://llvm.org/viewvc/llvm-project?rev=50522&view=rev Log: Disable inlining for optimization level < 3. We'll re-enable it at -O2 with limit turned down. See PR2272 for details. Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=50522&r1=50521&r2=50522&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Thu May 1 01:51:32 2008 @@ -356,10 +356,9 @@ if (flag_unit_at_a_time && flag_exceptions) PM->add(createPruneEHPass()); // Remove dead EH info - if (flag_inline_trees) // respect -fno-inline-functions - PM->add(createFunctionInliningPass()); // Inline small functions - if (optimize > 1) { + if (flag_inline_trees > 1) // respect -fno-inline-functions + PM->add(createFunctionInliningPass()); // Inline small functions if (flag_unit_at_a_time && !lang_hooks.flag_no_builtin()) PM->add(createSimplifyLibCallsPass()); // Library Call Optimizations From sabre at nondot.org Thu May 1 02:26:12 2008 From: sabre at nondot.org (Chris Lattner) Date: Thu, 01 May 2008 07:26:12 -0000 Subject: [llvm-commits] [llvm] r50523 - in /llvm/trunk: lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp test/CodeGen/X86/2008-05-01-InvalidOrdCompare.ll Message-ID: <200805010726.m417QCgp016755@zion.cs.uiuc.edu> Author: lattner Date: Thu May 1 02:26:11 2008 New Revision: 50523 URL: http://llvm.org/viewvc/llvm-project?rev=50523&view=rev Log: don't randomly miscompile seto/setuo just because we are in ffastmath mode. This fixes rdar://5902801, a miscompilation of gcc.dg/builtins-8.c. Bill, please pull this into Tak. Added: llvm/trunk/test/CodeGen/X86/2008-05-01-InvalidOrdCompare.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=50523&r1=50522&r2=50523&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Thu May 1 02:26:11 2008 @@ -1272,8 +1272,8 @@ case FCmpInst::FCMP_OLT: FOC = ISD::SETLT; FPC = ISD::SETOLT; break; case FCmpInst::FCMP_OLE: FOC = ISD::SETLE; FPC = ISD::SETOLE; break; case FCmpInst::FCMP_ONE: FOC = ISD::SETNE; FPC = ISD::SETONE; break; - case FCmpInst::FCMP_ORD: FOC = ISD::SETEQ; FPC = ISD::SETO; break; - case FCmpInst::FCMP_UNO: FOC = ISD::SETNE; FPC = ISD::SETUO; break; + case FCmpInst::FCMP_ORD: FOC = FPC = ISD::SETO; break; + case FCmpInst::FCMP_UNO: FOC = FPC = ISD::SETUO; break; case FCmpInst::FCMP_UEQ: FOC = ISD::SETEQ; FPC = ISD::SETUEQ; break; case FCmpInst::FCMP_UGT: FOC = ISD::SETGT; FPC = ISD::SETUGT; break; case FCmpInst::FCMP_UGE: FOC = ISD::SETGE; FPC = ISD::SETUGE; break; @@ -2317,8 +2317,8 @@ case FCmpInst::FCMP_OLT: FOC = ISD::SETLT; FPC = ISD::SETOLT; break; case FCmpInst::FCMP_OLE: FOC = ISD::SETLE; FPC = ISD::SETOLE; break; case FCmpInst::FCMP_ONE: FOC = ISD::SETNE; FPC = ISD::SETONE; break; - case FCmpInst::FCMP_ORD: FOC = ISD::SETEQ; FPC = ISD::SETO; break; - case FCmpInst::FCMP_UNO: FOC = ISD::SETNE; FPC = ISD::SETUO; break; + case FCmpInst::FCMP_ORD: FOC = ISD::SETO; break; + case FCmpInst::FCMP_UNO: FOC = ISD::SETUO; break; case FCmpInst::FCMP_UEQ: FOC = ISD::SETEQ; FPC = ISD::SETUEQ; break; case FCmpInst::FCMP_UGT: FOC = ISD::SETGT; FPC = ISD::SETUGT; break; case FCmpInst::FCMP_UGE: FOC = ISD::SETGE; FPC = ISD::SETUGE; break; Added: llvm/trunk/test/CodeGen/X86/2008-05-01-InvalidOrdCompare.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2008-05-01-InvalidOrdCompare.ll?rev=50523&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/2008-05-01-InvalidOrdCompare.ll (added) +++ llvm/trunk/test/CodeGen/X86/2008-05-01-InvalidOrdCompare.ll Thu May 1 02:26:11 2008 @@ -0,0 +1,15 @@ +; RUN: llvm-as < %s | llc -enable-unsafe-fp-math | grep jnp +; rdar://5902801 + +declare void @test2() + +define i32 @test(double %p) nounwind { + %tmp5 = fcmp uno double %p, 0.000000e+00 + br i1 %tmp5, label %bb, label %UnifiedReturnBlock +bb: + call void @test2() + ret i32 17 +UnifiedReturnBlock: + ret i32 42 +} + From nicolas.geoffray at lip6.fr Thu May 1 10:00:21 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Thu, 01 May 2008 15:00:21 -0000 Subject: [llvm-commits] [vmkit] r50524 - /vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp Message-ID: <200805011500.m41F0MAU006945@zion.cs.uiuc.edu> Author: geoffray Date: Thu May 1 10:00:21 2008 New Revision: 50524 URL: http://llvm.org/viewvc/llvm-project?rev=50524&view=rev Log: Implement -Xbootclasspath command line option. Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp?rev=50524&r1=50523&r2=50524&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp Thu May 1 10:00:21 2008 @@ -217,6 +217,14 @@ vm->addProperty(key, &value[1]); } } + } else if (!(strncmp(cur, "-Xbootclasspath:", 16))) { + uint32 len = strlen(cur); + if (len == 16) { + printInformation(); + } else { + char* path = &cur[16]; + vm->analyseClasspathEnv(path); + } } else if (!(strcmp(cur, "-enableassertions"))) { nyi(); } else if (!(strcmp(cur, "-ea"))) { From kremenek at apple.com Thu May 1 12:08:00 2008 From: kremenek at apple.com (Ted Kremenek) Date: Thu, 01 May 2008 17:08:00 -0000 Subject: [llvm-commits] [llvm] r50527 - /llvm/trunk/include/llvm/Bitcode/Deserialize.h Message-ID: <200805011708.m41H80Iq010943@zion.cs.uiuc.edu> Author: kremenek Date: Thu May 1 12:08:00 2008 New Revision: 50527 URL: http://llvm.org/viewvc/llvm-project?rev=50527&view=rev Log: Initialize a local variable. Modified: llvm/trunk/include/llvm/Bitcode/Deserialize.h Modified: llvm/trunk/include/llvm/Bitcode/Deserialize.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/Deserialize.h?rev=50527&r1=50526&r2=50527&view=diff ============================================================================== --- llvm/trunk/include/llvm/Bitcode/Deserialize.h (original) +++ llvm/trunk/include/llvm/Bitcode/Deserialize.h Thu May 1 12:08:00 2008 @@ -436,7 +436,7 @@ } template - T* ReadPtr() { T* x; ReadPtr(x,false); return x; } + T* ReadPtr() { T* x = 0; ReadPtr(x,false); return x; } void ReadUIntPtr(uintptr_t& PtrRef, const SerializedPtrID& PtrID, bool AllowBackpatch = true); From nicolas.geoffray at lip6.fr Thu May 1 12:45:31 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Thu, 01 May 2008 17:45:31 -0000 Subject: [llvm-commits] [vmkit] r50529 - /vmkit/trunk/lib/N3/VMCore/VMClass.cpp Message-ID: <200805011745.m41HjVt3012250@zion.cs.uiuc.edu> Author: geoffray Date: Thu May 1 12:45:31 2008 New Revision: 50529 URL: http://llvm.org/viewvc/llvm-project?rev=50529&view=rev Log: Do not get the forwarded type, use the actual type when available. Modified: vmkit/trunk/lib/N3/VMCore/VMClass.cpp Modified: vmkit/trunk/lib/N3/VMCore/VMClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMClass.cpp?rev=50529&r1=50528&r2=50529&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/VMClass.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/VMClass.cpp Thu May 1 12:45:31 2008 @@ -384,16 +384,18 @@ arrayFields.push_back(VMObject::llvmType->getContainedType(0)); arrayFields.push_back(llvm::Type::Int32Ty); arrayFields.push_back(llvm::ArrayType::get(baseClass->naturalType, 0)); - ((llvm::OpaqueType*)naturalType)->refineAbstractTypeTo(llvm::PointerType::getUnqual(llvm::StructType::get(arrayFields, false))); - naturalType = naturalType->getForwardedType(); + const llvm::Type* type = llvm::PointerType::getUnqual(llvm::StructType::get(arrayFields, false)); + ((llvm::OpaqueType*)naturalType)->refineAbstractTypeTo(type); + naturalType = type; virtualType = naturalType; arrayVT = CLIJit::makeArrayVT(this); } void VMClassPointer::makeType() { const llvm::Type* type = (baseClass->naturalType == llvm::Type::VoidTy) ? llvm::Type::Int8Ty : baseClass->naturalType; - ((llvm::OpaqueType*)naturalType)->refineAbstractTypeTo(llvm::PointerType::getUnqual(type)); - naturalType = naturalType->getForwardedType(); + const llvm::Type* pType = llvm::PointerType::getUnqual(type); + ((llvm::OpaqueType*)naturalType)->refineAbstractTypeTo(pType); + naturalType = pType; } void VMCommonClass::resolveType(bool stat, bool clinit) { From isanbard at gmail.com Thu May 1 12:56:09 2008 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 01 May 2008 17:56:09 -0000 Subject: [llvm-commits] [llvm] r50531 - in /llvm/branches/Apple/Tak: lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp test/CodeGen/X86/2008-05-01-InvalidOrdCompare.ll Message-ID: <200805011756.m41Hu9m1012539@zion.cs.uiuc.edu> Author: void Date: Thu May 1 12:56:08 2008 New Revision: 50531 URL: http://llvm.org/viewvc/llvm-project?rev=50531&view=rev Log: Porting r50523 to Tak. Added: llvm/branches/Apple/Tak/test/CodeGen/X86/2008-05-01-InvalidOrdCompare.ll Modified: llvm/branches/Apple/Tak/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Modified: llvm/branches/Apple/Tak/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Tak/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=50531&r1=50530&r2=50531&view=diff ============================================================================== --- llvm/branches/Apple/Tak/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/branches/Apple/Tak/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Thu May 1 12:56:08 2008 @@ -1261,8 +1261,8 @@ case FCmpInst::FCMP_OLT: FOC = ISD::SETLT; FPC = ISD::SETOLT; break; case FCmpInst::FCMP_OLE: FOC = ISD::SETLE; FPC = ISD::SETOLE; break; case FCmpInst::FCMP_ONE: FOC = ISD::SETNE; FPC = ISD::SETONE; break; - case FCmpInst::FCMP_ORD: FOC = ISD::SETEQ; FPC = ISD::SETO; break; - case FCmpInst::FCMP_UNO: FOC = ISD::SETNE; FPC = ISD::SETUO; break; + case FCmpInst::FCMP_ORD: FOC = FPC = ISD::SETO; break; + case FCmpInst::FCMP_UNO: FOC = FPC = ISD::SETUO; break; case FCmpInst::FCMP_UEQ: FOC = ISD::SETEQ; FPC = ISD::SETUEQ; break; case FCmpInst::FCMP_UGT: FOC = ISD::SETGT; FPC = ISD::SETUGT; break; case FCmpInst::FCMP_UGE: FOC = ISD::SETGE; FPC = ISD::SETUGE; break; @@ -2306,8 +2306,8 @@ case FCmpInst::FCMP_OLT: FOC = ISD::SETLT; FPC = ISD::SETOLT; break; case FCmpInst::FCMP_OLE: FOC = ISD::SETLE; FPC = ISD::SETOLE; break; case FCmpInst::FCMP_ONE: FOC = ISD::SETNE; FPC = ISD::SETONE; break; - case FCmpInst::FCMP_ORD: FOC = ISD::SETEQ; FPC = ISD::SETO; break; - case FCmpInst::FCMP_UNO: FOC = ISD::SETNE; FPC = ISD::SETUO; break; + case FCmpInst::FCMP_ORD: FOC = ISD::SETO; break; + case FCmpInst::FCMP_UNO: FOC = ISD::SETUO; break; case FCmpInst::FCMP_UEQ: FOC = ISD::SETEQ; FPC = ISD::SETUEQ; break; case FCmpInst::FCMP_UGT: FOC = ISD::SETGT; FPC = ISD::SETUGT; break; case FCmpInst::FCMP_UGE: FOC = ISD::SETGE; FPC = ISD::SETUGE; break; Added: llvm/branches/Apple/Tak/test/CodeGen/X86/2008-05-01-InvalidOrdCompare.ll URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Tak/test/CodeGen/X86/2008-05-01-InvalidOrdCompare.ll?rev=50531&view=auto ============================================================================== --- llvm/branches/Apple/Tak/test/CodeGen/X86/2008-05-01-InvalidOrdCompare.ll (added) +++ llvm/branches/Apple/Tak/test/CodeGen/X86/2008-05-01-InvalidOrdCompare.ll Thu May 1 12:56:08 2008 @@ -0,0 +1,15 @@ +; RUN: llvm-as < %s | llc -enable-unsafe-fp-math | grep jnp +; rdar://5902801 + +declare void @test2() + +define i32 @test(double %p) nounwind { + %tmp5 = fcmp uno double %p, 0.000000e+00 + br i1 %tmp5, label %bb, label %UnifiedReturnBlock +bb: + call void @test2() + ret i32 17 +UnifiedReturnBlock: + ret i32 42 +} + From isanbard at gmail.com Thu May 1 13:41:09 2008 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 01 May 2008 18:41:09 -0000 Subject: [llvm-commits] [llvm] r50536 - /llvm/trunk/test/CodeGen/PowerPC/2008-05-01-ppc_fp128.ll Message-ID: <200805011841.m41If9Ln014067@zion.cs.uiuc.edu> Author: void Date: Thu May 1 13:41:09 2008 New Revision: 50536 URL: http://llvm.org/viewvc/llvm-project?rev=50536&view=rev Log: Adding testcase. Added: llvm/trunk/test/CodeGen/PowerPC/2008-05-01-ppc_fp128.ll Added: llvm/trunk/test/CodeGen/PowerPC/2008-05-01-ppc_fp128.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/2008-05-01-ppc_fp128.ll?rev=50536&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/2008-05-01-ppc_fp128.ll (added) +++ llvm/trunk/test/CodeGen/PowerPC/2008-05-01-ppc_fp128.ll Thu May 1 13:41:09 2008 @@ -0,0 +1,15 @@ +; RUN: llvm-as < %s | llc -march=ppc32 +target triple = "powerpc-apple-darwin9.2.2" + +define i256 @func(ppc_fp128 %a, ppc_fp128 %b, ppc_fp128 %c, ppc_fp128 %d) nounwind readnone { +entry: + br i1 false, label %bb36, label %bb484 + +bb36: ; preds = %entry + %tmp124 = fcmp ord ppc_fp128 %b, 0xM00000000000000000000000000000000 ; [#uses=1] + %tmp140 = and i1 %tmp124, fcmp une (ppc_fp128 0xM00000000000000000000000000000000, ppc_fp128 0xM00000000000000000000000000000000) ; [#uses=0] + unreachable + +bb484: ; preds = %entry + ret i256 0 +} From gohman at apple.com Thu May 1 14:13:24 2008 From: gohman at apple.com (Dan Gohman) Date: Thu, 01 May 2008 19:13:24 -0000 Subject: [llvm-commits] [llvm] r50537 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/urem-simplify-bug.ll Message-ID: <200805011913.m41JDP60015292@zion.cs.uiuc.edu> Author: djg Date: Thu May 1 14:13:24 2008 New Revision: 50537 URL: http://llvm.org/viewvc/llvm-project?rev=50537&view=rev Log: Fix an overaggressive SimplifyDemandedBits optimization on urem. This fixes the 254.gap regression on x86 and the 403.gcc regression on x86-64. Added: llvm/trunk/test/Transforms/InstCombine/urem-simplify-bug.ll Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=50537&r1=50536&r2=50537&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Thu May 1 14:13:24 2008 @@ -1762,11 +1762,12 @@ APInt KnownZero2(BitWidth, 0), KnownOne2(BitWidth, 0); APInt AllOnes = APInt::getAllOnesValue(BitWidth); - ComputeMaskedBits(I->getOperand(0), AllOnes, - KnownZero2, KnownOne2, Depth+1); + if (SimplifyDemandedBits(I->getOperand(0), AllOnes, + KnownZero2, KnownOne2, Depth+1)) + return true; + uint32_t Leaders = KnownZero2.countLeadingOnes(); - APInt HighZeros = APInt::getHighBitsSet(BitWidth, Leaders); - if (SimplifyDemandedBits(I->getOperand(1), ~HighZeros, + if (SimplifyDemandedBits(I->getOperand(1), AllOnes, KnownZero2, KnownOne2, Depth+1)) return true; Added: llvm/trunk/test/Transforms/InstCombine/urem-simplify-bug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/urem-simplify-bug.ll?rev=50537&view=auto ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/urem-simplify-bug.ll (added) +++ llvm/trunk/test/Transforms/InstCombine/urem-simplify-bug.ll Thu May 1 14:13:24 2008 @@ -0,0 +1,32 @@ +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {= or i32 %x, -5 } + + at .str = internal constant [5 x i8] c"foo\0A\00" ; <[5 x i8]*> [#uses=1] + at .str1 = internal constant [5 x i8] c"bar\0A\00" ; <[5 x i8]*> [#uses=1] + +define i32 @main() nounwind { +entry: + %x = call i32 @func_11( ) nounwind ; [#uses=1] + %tmp3 = or i32 %x, -5 ; [#uses=1] + %tmp5 = urem i32 251, %tmp3 ; [#uses=1] + %tmp6 = icmp ne i32 %tmp5, 0 ; [#uses=1] + %tmp67 = zext i1 %tmp6 to i32 ; [#uses=1] + %tmp9 = urem i32 %tmp67, 95 ; [#uses=1] + %tmp10 = and i32 %tmp9, 1 ; [#uses=1] + %tmp12 = icmp eq i32 %tmp10, 0 ; [#uses=1] + br i1 %tmp12, label %bb14, label %bb + +bb: ; preds = %entry + br label %bb15 + +bb14: ; preds = %entry + br label %bb15 + +bb15: ; preds = %bb14, %bb + %iftmp.0.0 = phi i8* [ getelementptr ([5 x i8]* @.str1, i32 0, i32 0), %bb14 ], [ getelementptr ([5 x i8]* @.str, i32 0, i32 0), %bb ] ; [#uses=1] + %tmp17 = call i32 (i8*, ...)* @printf( i8* %iftmp.0.0 ) nounwind ; [#uses=0] + ret i32 0 +} + +declare i32 @func_11() + +declare i32 @printf(i8*, ...) nounwind From dpatel at apple.com Thu May 1 16:15:57 2008 From: dpatel at apple.com (Devang Patel) Date: Thu, 01 May 2008 21:15:57 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50539 - in /llvm-gcc-4.2/branches/Apple/Tak/gcc: config/i386/llvm-i386-target.h config/i386/llvm-i386.cpp llvm-abi.h llvm-convert.cpp llvm-types.cpp Message-ID: <200805012115.m41LFw3e019500@zion.cs.uiuc.edu> Author: dpatel Date: Thu May 1 16:15:57 2008 New Revision: 50539 URL: http://llvm.org/viewvc/llvm-project?rev=50539&view=rev Log: Do not acess extra bytes when struct is passed in multiple registers. This can happen when a struct does not occupy all bytes, for example 12 byte struct is passed using two i64s. This patch fixes reamining failues in abi-x86_64 tests on darwin target. Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386-target.h llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386.cpp llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-abi.h llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-convert.cpp llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-types.cpp Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386-target.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386-target.h?rev=50539&r1=50538&r2=50539&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386-target.h (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386-target.h Thu May 1 16:15:57 2008 @@ -178,6 +178,24 @@ llvm_x86_64_aggregate_partially_passed_in_regs((E), (SE)) : \ false) +/* llvm_store_scalar_argument - Store scalar argument ARGVAL of type + LLVMTY at location LOC. */ +extern void llvm_x86_store_scalar_argument(Value *Loc, Value *ArgVal, + const llvm::Type *LLVMTy, + unsigned RealSize, + IRBuilder &Builder); +#define LLVM_STORE_SCALAR_ARGUMENT(LOC,ARG,TYPE,SIZE,BUILDER) \ + llvm_x86_store_scalar_argument((LOC),(ARG),(TYPE),(SIZE),(BUILDER)) + + +/* llvm_load_scalar_argument - Load value located at LOC. */ +extern Value *llvm_x86_load_scalar_argument(Value *L, + const llvm::Type *LLVMTy, + unsigned RealSize, + IRBuilder &Builder); +#define LLVM_LOAD_SCALAR_ARGUMENT(LOC,TY,SIZE,BUILDER) \ + llvm_x86_load_scalar_argument((LOC),(TY),(SIZE),(BUILDER)) + #endif /* LLVM_ABI_H */ /* LLVM LOCAL end (ENTIRE FILE!) */ Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386.cpp?rev=50539&r1=50538&r2=50539&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386.cpp (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386.cpp Thu May 1 16:15:57 2008 @@ -1346,4 +1346,52 @@ ++DNO; } } + +/// llvm_store_scalar_argument - Store scalar argument ARGVAL of type +/// LLVMTY at location LOC. +void llvm_x86_store_scalar_argument(Value *Loc, Value *ArgVal, + const llvm::Type *LLVMTy, + unsigned RealSize, + IRBuilder &Builder) { + if (RealSize) { + // Do byte wise store because actaul argument type does not match LLVMTy. + Loc = Builder.CreateBitCast(Loc, + PointerType::getUnqual(llvm::Type::Int8Ty), "bc"); + Value *ShAmt = ConstantInt::get(LLVMTy, 8); + for (unsigned i = 0; i < RealSize; ++i) { + Value *AVT = Builder.CreateTrunc(ArgVal, llvm::Type::Int8Ty, "byte"); + Builder.CreateStore(AVT, Loc); + ArgVal = Builder.CreateLShr(ArgVal, ShAmt, "shft"); + Loc = Builder.CreateGEP(Loc, ConstantInt::get(llvm::Type::Int32Ty, 1), + "Loc"); + } + } else { + // This cast only involves pointers, therefore BitCast. + Loc = Builder.CreateBitCast(Loc, PointerType::getUnqual(LLVMTy), "tmp"); + Builder.CreateStore(ArgVal, Loc); + } +} + +/// llvm_load_scalar_argument - Load value located at LOC. +Value *llvm_x86_load_scalar_argument(Value *L, + const llvm::Type *LLVMTy, + unsigned RealSize, + IRBuilder &Builder) { + Value *Loc = NULL; + L = Builder.CreateBitCast(L, PointerType::getUnqual(llvm::Type::Int8Ty), "bc"); + // Load eacy byte individually. + for (unsigned i = 0; i < RealSize; ++i) { + Value *V = Builder.CreateLoad(L, "val"); + Value *V2 = Builder.CreateZExt(V, LLVMTy); + if (Loc == NULL) + Loc = V2; + else { + Value *ShAmt = ConstantInt::get(LLVMTy, 8*i); + Loc = Builder.CreateOr(Loc, Builder.CreateShl(V2, ShAmt, "shl"), "loc"); + } + L = Builder.CreateGEP(L, ConstantInt::get(llvm::Type::Int32Ty, 1), "gep"); + } + return Loc; +} + /* LLVM LOCAL end (ENTIRE FILE!) */ Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-abi.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-abi.h?rev=50539&r1=50538&r2=50539&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-abi.h (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-abi.h Thu May 1 16:15:57 2008 @@ -79,7 +79,10 @@ /// HandleScalarArgument - This is the primary callback that specifies an /// LLVM argument to pass. It is only used for first class types. - void HandleScalarArgument(const llvm::Type *LLVMTy, tree type) {} + /// If RealSize is non Zero then it specifies number of bytes to access + /// from LLVMTy. + void HandleScalarArgument(const llvm::Type *LLVMTy, tree type, + unsigned RealSize = 0) {} /// HandleByInvisibleReferenceArgument - This callback is invoked if a pointer /// (of type PtrTy) to the argument is passed rather than the argument itself. @@ -589,9 +592,27 @@ std::vector &Elts, std::vector &ScalarElts) { const StructType *STy = StructType::get(Elts, false); + unsigned Size = getTargetData().getABITypeSize(STy); + const StructType *InSTy = dyn_cast(Ty); + unsigned InSize = 0; + // If Ty and STy size does not match then last element is accessing + // extra bits. + unsigned LastEltSizeDiff = 0; + if (InSTy) { + InSize = getTargetData().getABITypeSize(InSTy); + if (InSize < Size) { + unsigned N = STy->getNumElements(); + const llvm::Type *LastEltTy = STy->getElementType(N-1); + LastEltSizeDiff = + getTargetData().getABITypeSize(LastEltTy) - (Size - InSize); + } + } for (unsigned i = 0, e = Elts.size(); i != e; ++i) { C.EnterField(i, STy); - C.HandleScalarArgument(Elts[i], 0); + unsigned RealSize = 0; + if (LastEltSizeDiff && i == (e - 1)) + RealSize = LastEltSizeDiff; + C.HandleScalarArgument(Elts[i], 0, RealSize); ScalarElts.push_back(Elts[i]); C.ExitField(); } Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-convert.cpp?rev=50539&r1=50538&r2=50539&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-convert.cpp Thu May 1 16:15:57 2008 @@ -398,6 +398,24 @@ return NewBB; } +/// llvm_store_scalar_argument - Store scalar argument ARGVAL of type +/// LLVMTY at location LOC. +static void llvm_store_scalar_argument(Value *Loc, Value *ArgVal, + const llvm::Type *LLVMTy, + unsigned RealSize, + IRBuilder &Builder) { + assert (RealSize == 0 && + "The target should handle this argument!"); + // This cast only involves pointers, therefore BitCast. + Loc = Builder.CreateBitCast(Loc, PointerType::getUnqual(LLVMTy), "tmp"); + Builder.CreateStore(ArgVal, Loc); +} + +#ifndef LLVM_STORE_SCALAR_ARGUMENT +#define LLVM_STORE_SCALAR_ARGUMENT(LOC,ARG,TYPE,SIZE,BUILDER) \ + llvm_store_scalar_argument((LOC),(ARG),(TYPE),(SIZE),(BUILDER)) +#endif + namespace { /// FunctionPrologArgumentConversion - This helper class is driven by the ABI /// definition for this target to figure out how to retrieve arguments from @@ -468,7 +486,8 @@ ++AI; } - void HandleScalarArgument(const llvm::Type *LLVMTy, tree type) { + void HandleScalarArgument(const llvm::Type *LLVMTy, tree type, + unsigned RealSize = 0) { Value *ArgVal = AI; if (ArgVal->getType() != LLVMTy) { if (isa(ArgVal->getType()) && isa(LLVMTy)) { @@ -491,10 +510,7 @@ } assert(!LocStack.empty()); Value *Loc = LocStack.back(); - // This cast only involves pointers, therefore BitCast. - Loc = Builder.CreateBitCast(Loc, PointerType::getUnqual(LLVMTy), "tmp"); - - Builder.CreateStore(ArgVal, Loc); + LLVM_STORE_SCALAR_ARGUMENT(Loc,ArgVal,LLVMTy,RealSize,Builder); AI->setName(NameStack.back()); ++AI; } @@ -2319,6 +2335,20 @@ return Result; } +/// llvm_load_scalar_argument - Load value located at LOC. +static Value *llvm_load_scalar_argument(Value *L, + const llvm::Type *LLVMTy, + unsigned RealSize, + IRBuilder &Builder) { + assert (0 && "The target should override this routine!"); + return NULL; +} + +#ifndef LLVM_LOAD_SCALAR_ARGUMENT +#define LLVM_LOAD_SCALAR_ARGUMENT(LOC,TY,SIZE,BUILDER) \ + llvm_load_scalar_argument((LOC),(TY),(SIZE),(BUILDER)) +#endif + namespace { /// FunctionCallArgumentConversion - This helper class is driven by the ABI /// definition for this target to figure out how to pass arguments into the @@ -2482,8 +2512,14 @@ /// HandleScalarArgument - This is the primary callback that specifies an /// LLVM argument to pass. It is only used for first class types. - void HandleScalarArgument(const llvm::Type *LLVMTy, tree type) { - Value *Loc = getValue(LLVMTy); + void HandleScalarArgument(const llvm::Type *LLVMTy, tree type, + unsigned RealSize = 0) { + Value *Loc = NULL; + if (RealSize) { + Value *L = LocStack.back(); + Loc = LLVM_LOAD_SCALAR_ARGUMENT(L,LLVMTy,RealSize,Builder); + } else + Loc = getValue(LLVMTy); // Perform any implicit type conversions. if (CallOperands.size() < FTy->getNumParams()) { Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-types.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-types.cpp?rev=50539&r1=50538&r2=50539&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-types.cpp (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-types.cpp Thu May 1 16:15:57 2008 @@ -994,7 +994,8 @@ HandleShadowArgument(PtrArgTy, RetPtr); } - void HandleScalarArgument(const llvm::Type *LLVMTy, tree type) { + void HandleScalarArgument(const llvm::Type *LLVMTy, tree type, + unsigned RealSize = 0) { if (KNRPromotion) { if (LLVMTy == Type::FloatTy) LLVMTy = Type::DoubleTy; From dpatel at apple.com Thu May 1 17:05:13 2008 From: dpatel at apple.com (Devang Patel) Date: Thu, 01 May 2008 22:05:13 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50543 - /llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-abi.h Message-ID: <200805012205.m41M5DDJ021070@zion.cs.uiuc.edu> Author: dpatel Date: Thu May 1 17:05:13 2008 New Revision: 50543 URL: http://llvm.org/viewvc/llvm-project?rev=50543&view=rev Log: Right now, this is handled only when last element is an integer. Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-abi.h Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-abi.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-abi.h?rev=50543&r1=50542&r2=50543&view=diff ============================================================================== --- llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-abi.h (original) +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-abi.h Thu May 1 17:05:13 2008 @@ -603,8 +603,9 @@ if (InSize < Size) { unsigned N = STy->getNumElements(); const llvm::Type *LastEltTy = STy->getElementType(N-1); - LastEltSizeDiff = - getTargetData().getABITypeSize(LastEltTy) - (Size - InSize); + if (LastEltTy->isInteger()) + LastEltSizeDiff = + getTargetData().getABITypeSize(LastEltTy) - (Size - InSize); } } for (unsigned i = 0, e = Elts.size(); i != e; ++i) { From dalej at apple.com Thu May 1 17:27:44 2008 From: dalej at apple.com (Dale Johannesen) Date: Thu, 01 May 2008 22:27:44 -0000 Subject: [llvm-commits] [llvm] r50545 - /llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp Message-ID: <200805012227.m41MRiJf021931@zion.cs.uiuc.edu> Author: johannes Date: Thu May 1 17:27:44 2008 New Revision: 50545 URL: http://llvm.org/viewvc/llvm-project?rev=50545&view=rev Log: Don't try to create PHIs of struct types. Fallout from x86-64 calling convention work. Modified: llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp?rev=50545&r1=50544&r2=50545&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp Thu May 1 17:27:44 2008 @@ -249,14 +249,37 @@ // create new PHINode for this instruction. Instruction *NewHeaderReplacement = NULL; if (usedOutsideOriginalHeader(In)) { - PHINode *PN = PHINode::Create(In->getType(), In->getName()); - PN->addIncoming(In, OrigHeader); - PN->addIncoming(C, OrigPreHeader); - NewHeader->getInstList().push_front(PN); - NewHeaderReplacement = PN; - } - - // "In" can be replaced by NPH or NH at various places. + const StructType *STy = dyn_cast(In->getType()); + if (STy) { + // Can't create PHI nodes for this type. If there are any getResults + // not defined in this block, move them back to this block. PHI + // nodes will be created for all getResults later. + BasicBlock::iterator InsertPoint; + if (InvokeInst *II = dyn_cast(In)) { + InsertPoint = II->getNormalDest()->begin(); + while (isa(InsertPoint)) + ++InsertPoint; + } else { + InsertPoint = I; // call + InsertPoint++; + } + for (Value::use_iterator UI = In->use_begin(), UE = In->use_end(); + UI != UE; ++UI) { + GetResultInst *InGR = cast(UI); + if (InGR->getParent() != OrigHeader) { + // move InGR to immediately follow call. It will be picked + // up, cloned and PHI'd on the next iteration. + InGR->moveBefore(InsertPoint); + } + } + } else { + PHINode *PN = PHINode::Create(In->getType(), In->getName()); + PN->addIncoming(In, OrigHeader); + PN->addIncoming(C, OrigPreHeader); + NewHeader->getInstList().push_front(PN); + NewHeaderReplacement = PN; + } + } LoopHeaderInfo.push_back(RenameData(In, C, NewHeaderReplacement)); } From tonic at nondot.org Thu May 1 17:31:14 2008 From: tonic at nondot.org (Tanya Lattner) Date: Thu, 1 May 2008 17:31:14 -0500 Subject: [llvm-commits] CVS: llvm-www/devmtg/current/index.html Message-ID: <200805012231.m41MVEn5022072@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg/current: index.html updated: 1.10 -> 1.11 --- Log message: Change to mailing list alias. --- Diffs of the changes: (+4 -4) index.html | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) Index: llvm-www/devmtg/current/index.html diff -u llvm-www/devmtg/current/index.html:1.10 llvm-www/devmtg/current/index.html:1.11 --- llvm-www/devmtg/current/index.html:1.10 Wed Apr 16 11:24:42 2008 +++ llvm-www/devmtg/current/index.html Thu May 1 17:30:40 2008 @@ -21,7 +21,7 @@
    -

    We are in the early stages of planning the second LLVM group meeting. At this point in time, we are asking that anyone interested in attending email the answers to these questions to the person organizing this meeting:

    +

    We are in the early stages of planning the second LLVM group meeting. At this point in time, we are asking that anyone interested in attending email the answers to these questions to the person organizing this meeting:

    • Are you willing to give a talk? on what topic?
    • What topics are your primary interests?
    • @@ -32,7 +32,7 @@
      -

      The meeting is tentatively scheduled between 8:00 AM and 5:00 PM Pacific Time. The schedule of talks has not yet been decided. If you are interested in speaking, please let us know what topic you'd like to present.

      +

      The meeting is tentatively scheduled between 8:00 AM and 5:00 PM Pacific Time. The schedule of talks has not yet been decided. If you are interested in speaking, please let us know what topic you'd like to present.

      @@ -75,7 +75,7 @@ Chuck (Chengyan) ZhaoUniversity of Toronto

      Total unconfirmed: 31

      -

      If your name is misspelled, or organization affiliation isn't correct, please email us, and we'll correct it. +

      If your name is misspelled, or organization affiliation isn't correct, please email us, and we'll correct it.

    - \ No newline at end of file + From isanbard at gmail.com Thu May 1 17:47:27 2008 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 01 May 2008 22:47:27 -0000 Subject: [llvm-commits] [llvm] r50546 - /llvm/branches/Apple/Tak/lib/Transforms/Scalar/LoopRotation.cpp Message-ID: <200805012247.m41MlRak022527@zion.cs.uiuc.edu> Author: void Date: Thu May 1 17:47:26 2008 New Revision: 50546 URL: http://llvm.org/viewvc/llvm-project?rev=50546&view=rev Log: Porting r50545 into Tak. Modified: llvm/branches/Apple/Tak/lib/Transforms/Scalar/LoopRotation.cpp Modified: llvm/branches/Apple/Tak/lib/Transforms/Scalar/LoopRotation.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Tak/lib/Transforms/Scalar/LoopRotation.cpp?rev=50546&r1=50545&r2=50546&view=diff ============================================================================== --- llvm/branches/Apple/Tak/lib/Transforms/Scalar/LoopRotation.cpp (original) +++ llvm/branches/Apple/Tak/lib/Transforms/Scalar/LoopRotation.cpp Thu May 1 17:47:26 2008 @@ -249,14 +249,37 @@ // create new PHINode for this instruction. Instruction *NewHeaderReplacement = NULL; if (usedOutsideOriginalHeader(In)) { - PHINode *PN = PHINode::Create(In->getType(), In->getName()); - PN->addIncoming(In, OrigHeader); - PN->addIncoming(C, OrigPreHeader); - NewHeader->getInstList().push_front(PN); - NewHeaderReplacement = PN; - } - - // "In" can be replaced by NPH or NH at various places. + const StructType *STy = dyn_cast(In->getType()); + if (STy) { + // Can't create PHI nodes for this type. If there are any getResults + // not defined in this block, move them back to this block. PHI + // nodes will be created for all getResults later. + BasicBlock::iterator InsertPoint; + if (InvokeInst *II = dyn_cast(In)) { + InsertPoint = II->getNormalDest()->begin(); + while (isa(InsertPoint)) + ++InsertPoint; + } else { + InsertPoint = I; // call + InsertPoint++; + } + for (Value::use_iterator UI = In->use_begin(), UE = In->use_end(); + UI != UE; ++UI) { + GetResultInst *InGR = cast(UI); + if (InGR->getParent() != OrigHeader) { + // move InGR to immediately follow call. It will be picked + // up, cloned and PHI'd on the next iteration. + InGR->moveBefore(InsertPoint); + } + } + } else { + PHINode *PN = PHINode::Create(In->getType(), In->getName()); + PN->addIncoming(In, OrigHeader); + PN->addIncoming(C, OrigPreHeader); + NewHeader->getInstList().push_front(PN); + NewHeaderReplacement = PN; + } + } LoopHeaderInfo.push_back(RenameData(In, C, NewHeaderReplacement)); } From isanbard at gmail.com Thu May 1 17:49:53 2008 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 01 May 2008 22:49:53 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50547 - in /llvm-gcc-4.2/trunk/gcc: config/i386/llvm-i386-target.h config/i386/llvm-i386.cpp llvm-abi.h llvm-convert.cpp llvm-types.cpp Message-ID: <200805012249.m41Mnr7o022628@zion.cs.uiuc.edu> Author: void Date: Thu May 1 17:49:53 2008 New Revision: 50547 URL: http://llvm.org/viewvc/llvm-project?rev=50547&view=rev Log: Porting r50539 from Tak to mainline. Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp llvm-gcc-4.2/trunk/gcc/llvm-abi.h llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h?rev=50547&r1=50546&r2=50547&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h Thu May 1 17:49:53 2008 @@ -178,6 +178,24 @@ llvm_x86_64_aggregate_partially_passed_in_regs((E), (SE)) : \ false) +/* llvm_store_scalar_argument - Store scalar argument ARGVAL of type + LLVMTY at location LOC. */ +extern void llvm_x86_store_scalar_argument(Value *Loc, Value *ArgVal, + const llvm::Type *LLVMTy, + unsigned RealSize, + IRBuilder &Builder); +#define LLVM_STORE_SCALAR_ARGUMENT(LOC,ARG,TYPE,SIZE,BUILDER) \ + llvm_x86_store_scalar_argument((LOC),(ARG),(TYPE),(SIZE),(BUILDER)) + + +/* llvm_load_scalar_argument - Load value located at LOC. */ +extern Value *llvm_x86_load_scalar_argument(Value *L, + const llvm::Type *LLVMTy, + unsigned RealSize, + IRBuilder &Builder); +#define LLVM_LOAD_SCALAR_ARGUMENT(LOC,TY,SIZE,BUILDER) \ + llvm_x86_load_scalar_argument((LOC),(TY),(SIZE),(BUILDER)) + #endif /* LLVM_ABI_H */ /* LLVM LOCAL end (ENTIRE FILE!) */ Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp?rev=50547&r1=50546&r2=50547&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Thu May 1 17:49:53 2008 @@ -1346,4 +1346,52 @@ ++DNO; } } + +/// llvm_store_scalar_argument - Store scalar argument ARGVAL of type +/// LLVMTY at location LOC. +void llvm_x86_store_scalar_argument(Value *Loc, Value *ArgVal, + const llvm::Type *LLVMTy, + unsigned RealSize, + IRBuilder &Builder) { + if (RealSize) { + // Do byte wise store because actaul argument type does not match LLVMTy. + Loc = Builder.CreateBitCast(Loc, + PointerType::getUnqual(llvm::Type::Int8Ty), "bc"); + Value *ShAmt = ConstantInt::get(LLVMTy, 8); + for (unsigned i = 0; i < RealSize; ++i) { + Value *AVT = Builder.CreateTrunc(ArgVal, llvm::Type::Int8Ty, "byte"); + Builder.CreateStore(AVT, Loc); + ArgVal = Builder.CreateLShr(ArgVal, ShAmt, "shft"); + Loc = Builder.CreateGEP(Loc, ConstantInt::get(llvm::Type::Int32Ty, 1), + "Loc"); + } + } else { + // This cast only involves pointers, therefore BitCast. + Loc = Builder.CreateBitCast(Loc, PointerType::getUnqual(LLVMTy), "tmp"); + Builder.CreateStore(ArgVal, Loc); + } +} + +/// llvm_load_scalar_argument - Load value located at LOC. +Value *llvm_x86_load_scalar_argument(Value *L, + const llvm::Type *LLVMTy, + unsigned RealSize, + IRBuilder &Builder) { + Value *Loc = NULL; + L = Builder.CreateBitCast(L, PointerType::getUnqual(llvm::Type::Int8Ty), "bc"); + // Load eacy byte individually. + for (unsigned i = 0; i < RealSize; ++i) { + Value *V = Builder.CreateLoad(L, "val"); + Value *V2 = Builder.CreateZExt(V, LLVMTy); + if (Loc == NULL) + Loc = V2; + else { + Value *ShAmt = ConstantInt::get(LLVMTy, 8*i); + Loc = Builder.CreateOr(Loc, Builder.CreateShl(V2, ShAmt, "shl"), "loc"); + } + L = Builder.CreateGEP(L, ConstantInt::get(llvm::Type::Int32Ty, 1), "gep"); + } + return Loc; +} + /* LLVM LOCAL end (ENTIRE FILE!) */ Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi.h?rev=50547&r1=50546&r2=50547&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-abi.h (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-abi.h Thu May 1 17:49:53 2008 @@ -79,7 +79,10 @@ /// HandleScalarArgument - This is the primary callback that specifies an /// LLVM argument to pass. It is only used for first class types. - void HandleScalarArgument(const llvm::Type *LLVMTy, tree type) {} + /// If RealSize is non Zero then it specifies number of bytes to access + /// from LLVMTy. + void HandleScalarArgument(const llvm::Type *LLVMTy, tree type, + unsigned RealSize = 0) {} /// HandleByInvisibleReferenceArgument - This callback is invoked if a pointer /// (of type PtrTy) to the argument is passed rather than the argument itself. @@ -589,9 +592,27 @@ std::vector &Elts, std::vector &ScalarElts) { const StructType *STy = StructType::get(Elts, false); + unsigned Size = getTargetData().getABITypeSize(STy); + const StructType *InSTy = dyn_cast(Ty); + unsigned InSize = 0; + // If Ty and STy size does not match then last element is accessing + // extra bits. + unsigned LastEltSizeDiff = 0; + if (InSTy) { + InSize = getTargetData().getABITypeSize(InSTy); + if (InSize < Size) { + unsigned N = STy->getNumElements(); + const llvm::Type *LastEltTy = STy->getElementType(N-1); + LastEltSizeDiff = + getTargetData().getABITypeSize(LastEltTy) - (Size - InSize); + } + } for (unsigned i = 0, e = Elts.size(); i != e; ++i) { C.EnterField(i, STy); - C.HandleScalarArgument(Elts[i], 0); + unsigned RealSize = 0; + if (LastEltSizeDiff && i == (e - 1)) + RealSize = LastEltSizeDiff; + C.HandleScalarArgument(Elts[i], 0, RealSize); ScalarElts.push_back(Elts[i]); C.ExitField(); } Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=50547&r1=50546&r2=50547&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Thu May 1 17:49:53 2008 @@ -398,6 +398,24 @@ return NewBB; } +/// llvm_store_scalar_argument - Store scalar argument ARGVAL of type +/// LLVMTY at location LOC. +static void llvm_store_scalar_argument(Value *Loc, Value *ArgVal, + const llvm::Type *LLVMTy, + unsigned RealSize, + IRBuilder &Builder) { + assert (RealSize == 0 && + "The target should handle this argument!"); + // This cast only involves pointers, therefore BitCast. + Loc = Builder.CreateBitCast(Loc, PointerType::getUnqual(LLVMTy), "tmp"); + Builder.CreateStore(ArgVal, Loc); +} + +#ifndef LLVM_STORE_SCALAR_ARGUMENT +#define LLVM_STORE_SCALAR_ARGUMENT(LOC,ARG,TYPE,SIZE,BUILDER) \ + llvm_store_scalar_argument((LOC),(ARG),(TYPE),(SIZE),(BUILDER)) +#endif + namespace { /// FunctionPrologArgumentConversion - This helper class is driven by the ABI /// definition for this target to figure out how to retrieve arguments from @@ -468,7 +486,8 @@ ++AI; } - void HandleScalarArgument(const llvm::Type *LLVMTy, tree type) { + void HandleScalarArgument(const llvm::Type *LLVMTy, tree type, + unsigned RealSize = 0) { Value *ArgVal = AI; if (ArgVal->getType() != LLVMTy) { if (isa(ArgVal->getType()) && isa(LLVMTy)) { @@ -491,10 +510,7 @@ } assert(!LocStack.empty()); Value *Loc = LocStack.back(); - // This cast only involves pointers, therefore BitCast. - Loc = Builder.CreateBitCast(Loc, PointerType::getUnqual(LLVMTy), "tmp"); - - Builder.CreateStore(ArgVal, Loc); + LLVM_STORE_SCALAR_ARGUMENT(Loc,ArgVal,LLVMTy,RealSize,Builder); AI->setName(NameStack.back()); ++AI; } @@ -2319,6 +2335,20 @@ return Result; } +/// llvm_load_scalar_argument - Load value located at LOC. +static Value *llvm_load_scalar_argument(Value *L, + const llvm::Type *LLVMTy, + unsigned RealSize, + IRBuilder &Builder) { + assert (0 && "The target should override this routine!"); + return NULL; +} + +#ifndef LLVM_LOAD_SCALAR_ARGUMENT +#define LLVM_LOAD_SCALAR_ARGUMENT(LOC,TY,SIZE,BUILDER) \ + llvm_load_scalar_argument((LOC),(TY),(SIZE),(BUILDER)) +#endif + namespace { /// FunctionCallArgumentConversion - This helper class is driven by the ABI /// definition for this target to figure out how to pass arguments into the @@ -2482,8 +2512,14 @@ /// HandleScalarArgument - This is the primary callback that specifies an /// LLVM argument to pass. It is only used for first class types. - void HandleScalarArgument(const llvm::Type *LLVMTy, tree type) { - Value *Loc = getValue(LLVMTy); + void HandleScalarArgument(const llvm::Type *LLVMTy, tree type, + unsigned RealSize = 0) { + Value *Loc = NULL; + if (RealSize) { + Value *L = LocStack.back(); + Loc = LLVM_LOAD_SCALAR_ARGUMENT(L,LLVMTy,RealSize,Builder); + } else + Loc = getValue(LLVMTy); // Perform any implicit type conversions. if (CallOperands.size() < FTy->getNumParams()) { Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=50547&r1=50546&r2=50547&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Thu May 1 17:49:53 2008 @@ -990,7 +990,8 @@ HandleShadowArgument(PtrArgTy, RetPtr); } - void HandleScalarArgument(const llvm::Type *LLVMTy, tree type) { + void HandleScalarArgument(const llvm::Type *LLVMTy, tree type, + unsigned RealSize = 0) { if (KNRPromotion) { if (LLVMTy == Type::FloatTy) LLVMTy = Type::DoubleTy; From isanbard at gmail.com Thu May 1 17:50:07 2008 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 1 May 2008 15:50:07 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r50539 - in /llvm-gcc-4.2/branches/Apple/Tak/gcc: config/i386/llvm-i386-target.h config/i386/llvm-i386.cpp llvm-abi.h llvm-convert.cpp llvm-types.cpp In-Reply-To: <200805012115.m41LFw3e019500@zion.cs.uiuc.edu> References: <200805012115.m41LFw3e019500@zion.cs.uiuc.edu> Message-ID: <16e5fdf90805011550v55cf4a70kd7f84fdd41e863f7@mail.gmail.com> Applied to mainline as r50547. On Thu, May 1, 2008 at 2:15 PM, Devang Patel wrote: > Author: dpatel > Date: Thu May 1 16:15:57 2008 > New Revision: 50539 > > URL: http://llvm.org/viewvc/llvm-project?rev=50539&view=rev > Log: > Do not acess extra bytes when struct is passed in multiple registers. This can happen when a struct does not occupy all bytes, for example 12 byte struct is passed using two i64s. > > This patch fixes reamining failues in abi-x86_64 tests on darwin target. > > Modified: > llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386-target.h > llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386.cpp > llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-abi.h > llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-convert.cpp > llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-types.cpp > > Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386-target.h > URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386-target.h?rev=50539&r1=50538&r2=50539&view=diff > > ============================================================================== > --- llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386-target.h (original) > +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386-target.h Thu May 1 16:15:57 2008 > @@ -178,6 +178,24 @@ > llvm_x86_64_aggregate_partially_passed_in_regs((E), (SE)) : \ > false) > > +/* llvm_store_scalar_argument - Store scalar argument ARGVAL of type > + LLVMTY at location LOC. */ > +extern void llvm_x86_store_scalar_argument(Value *Loc, Value *ArgVal, > + const llvm::Type *LLVMTy, > + unsigned RealSize, > + IRBuilder &Builder); > +#define LLVM_STORE_SCALAR_ARGUMENT(LOC,ARG,TYPE,SIZE,BUILDER) \ > + llvm_x86_store_scalar_argument((LOC),(ARG),(TYPE),(SIZE),(BUILDER)) > + > + > +/* llvm_load_scalar_argument - Load value located at LOC. */ > +extern Value *llvm_x86_load_scalar_argument(Value *L, > + const llvm::Type *LLVMTy, > + unsigned RealSize, > + IRBuilder &Builder); > +#define LLVM_LOAD_SCALAR_ARGUMENT(LOC,TY,SIZE,BUILDER) \ > + llvm_x86_load_scalar_argument((LOC),(TY),(SIZE),(BUILDER)) > + > #endif /* LLVM_ABI_H */ > > /* LLVM LOCAL end (ENTIRE FILE!) */ > > Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386.cpp?rev=50539&r1=50538&r2=50539&view=diff > > ============================================================================== > --- llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386.cpp (original) > +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/config/i386/llvm-i386.cpp Thu May 1 16:15:57 2008 > @@ -1346,4 +1346,52 @@ > ++DNO; > } > } > + > +/// llvm_store_scalar_argument - Store scalar argument ARGVAL of type > +/// LLVMTY at location LOC. > +void llvm_x86_store_scalar_argument(Value *Loc, Value *ArgVal, > + const llvm::Type *LLVMTy, > + unsigned RealSize, > + IRBuilder &Builder) { > + if (RealSize) { > + // Do byte wise store because actaul argument type does not match LLVMTy. > + Loc = Builder.CreateBitCast(Loc, > + PointerType::getUnqual(llvm::Type::Int8Ty), "bc"); > + Value *ShAmt = ConstantInt::get(LLVMTy, 8); > + for (unsigned i = 0; i < RealSize; ++i) { > + Value *AVT = Builder.CreateTrunc(ArgVal, llvm::Type::Int8Ty, "byte"); > + Builder.CreateStore(AVT, Loc); > + ArgVal = Builder.CreateLShr(ArgVal, ShAmt, "shft"); > + Loc = Builder.CreateGEP(Loc, ConstantInt::get(llvm::Type::Int32Ty, 1), > + "Loc"); > + } > + } else { > + // This cast only involves pointers, therefore BitCast. > + Loc = Builder.CreateBitCast(Loc, PointerType::getUnqual(LLVMTy), "tmp"); > + Builder.CreateStore(ArgVal, Loc); > + } > +} > + > +/// llvm_load_scalar_argument - Load value located at LOC. > +Value *llvm_x86_load_scalar_argument(Value *L, > + const llvm::Type *LLVMTy, > + unsigned RealSize, > + IRBuilder &Builder) { > + Value *Loc = NULL; > + L = Builder.CreateBitCast(L, PointerType::getUnqual(llvm::Type::Int8Ty), "bc"); > + // Load eacy byte individually. > + for (unsigned i = 0; i < RealSize; ++i) { > + Value *V = Builder.CreateLoad(L, "val"); > + Value *V2 = Builder.CreateZExt(V, LLVMTy); > + if (Loc == NULL) > + Loc = V2; > + else { > + Value *ShAmt = ConstantInt::get(LLVMTy, 8*i); > + Loc = Builder.CreateOr(Loc, Builder.CreateShl(V2, ShAmt, "shl"), "loc"); > + } > + L = Builder.CreateGEP(L, ConstantInt::get(llvm::Type::Int32Ty, 1), "gep"); > + } > + return Loc; > +} > + > /* LLVM LOCAL end (ENTIRE FILE!) */ > > Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-abi.h > URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-abi.h?rev=50539&r1=50538&r2=50539&view=diff > > ============================================================================== > --- llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-abi.h (original) > +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-abi.h Thu May 1 16:15:57 2008 > @@ -79,7 +79,10 @@ > > /// HandleScalarArgument - This is the primary callback that specifies an > /// LLVM argument to pass. It is only used for first class types. > - void HandleScalarArgument(const llvm::Type *LLVMTy, tree type) {} > + /// If RealSize is non Zero then it specifies number of bytes to access > + /// from LLVMTy. > + void HandleScalarArgument(const llvm::Type *LLVMTy, tree type, > + unsigned RealSize = 0) {} > > /// HandleByInvisibleReferenceArgument - This callback is invoked if a pointer > /// (of type PtrTy) to the argument is passed rather than the argument itself. > @@ -589,9 +592,27 @@ > std::vector &Elts, > std::vector &ScalarElts) { > const StructType *STy = StructType::get(Elts, false); > + unsigned Size = getTargetData().getABITypeSize(STy); > + const StructType *InSTy = dyn_cast(Ty); > + unsigned InSize = 0; > + // If Ty and STy size does not match then last element is accessing > + // extra bits. > + unsigned LastEltSizeDiff = 0; > + if (InSTy) { > + InSize = getTargetData().getABITypeSize(InSTy); > + if (InSize < Size) { > + unsigned N = STy->getNumElements(); > + const llvm::Type *LastEltTy = STy->getElementType(N-1); > + LastEltSizeDiff = > + getTargetData().getABITypeSize(LastEltTy) - (Size - InSize); > + } > + } > for (unsigned i = 0, e = Elts.size(); i != e; ++i) { > C.EnterField(i, STy); > - C.HandleScalarArgument(Elts[i], 0); > + unsigned RealSize = 0; > + if (LastEltSizeDiff && i == (e - 1)) > + RealSize = LastEltSizeDiff; > + C.HandleScalarArgument(Elts[i], 0, RealSize); > ScalarElts.push_back(Elts[i]); > C.ExitField(); > } > > Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-convert.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-convert.cpp?rev=50539&r1=50538&r2=50539&view=diff > > ============================================================================== > --- llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-convert.cpp (original) > +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-convert.cpp Thu May 1 16:15:57 2008 > @@ -398,6 +398,24 @@ > return NewBB; > } > > +/// llvm_store_scalar_argument - Store scalar argument ARGVAL of type > +/// LLVMTY at location LOC. > +static void llvm_store_scalar_argument(Value *Loc, Value *ArgVal, > + const llvm::Type *LLVMTy, > + unsigned RealSize, > + IRBuilder &Builder) { > + assert (RealSize == 0 && > + "The target should handle this argument!"); > + // This cast only involves pointers, therefore BitCast. > + Loc = Builder.CreateBitCast(Loc, PointerType::getUnqual(LLVMTy), "tmp"); > + Builder.CreateStore(ArgVal, Loc); > +} > + > +#ifndef LLVM_STORE_SCALAR_ARGUMENT > +#define LLVM_STORE_SCALAR_ARGUMENT(LOC,ARG,TYPE,SIZE,BUILDER) \ > + llvm_store_scalar_argument((LOC),(ARG),(TYPE),(SIZE),(BUILDER)) > +#endif > + > namespace { > /// FunctionPrologArgumentConversion - This helper class is driven by the ABI > /// definition for this target to figure out how to retrieve arguments from > @@ -468,7 +486,8 @@ > ++AI; > } > > - void HandleScalarArgument(const llvm::Type *LLVMTy, tree type) { > + void HandleScalarArgument(const llvm::Type *LLVMTy, tree type, > + unsigned RealSize = 0) { > Value *ArgVal = AI; > if (ArgVal->getType() != LLVMTy) { > if (isa(ArgVal->getType()) && isa(LLVMTy)) { > @@ -491,10 +510,7 @@ > } > assert(!LocStack.empty()); > Value *Loc = LocStack.back(); > - // This cast only involves pointers, therefore BitCast. > - Loc = Builder.CreateBitCast(Loc, PointerType::getUnqual(LLVMTy), "tmp"); > - > - Builder.CreateStore(ArgVal, Loc); > + LLVM_STORE_SCALAR_ARGUMENT(Loc,ArgVal,LLVMTy,RealSize,Builder); > AI->setName(NameStack.back()); > ++AI; > } > @@ -2319,6 +2335,20 @@ > return Result; > } > > +/// llvm_load_scalar_argument - Load value located at LOC. > +static Value *llvm_load_scalar_argument(Value *L, > + const llvm::Type *LLVMTy, > + unsigned RealSize, > + IRBuilder &Builder) { > + assert (0 && "The target should override this routine!"); > + return NULL; > +} > + > +#ifndef LLVM_LOAD_SCALAR_ARGUMENT > +#define LLVM_LOAD_SCALAR_ARGUMENT(LOC,TY,SIZE,BUILDER) \ > + llvm_load_scalar_argument((LOC),(TY),(SIZE),(BUILDER)) > +#endif > + > namespace { > /// FunctionCallArgumentConversion - This helper class is driven by the ABI > /// definition for this target to figure out how to pass arguments into the > @@ -2482,8 +2512,14 @@ > > /// HandleScalarArgument - This is the primary callback that specifies an > /// LLVM argument to pass. It is only used for first class types. > - void HandleScalarArgument(const llvm::Type *LLVMTy, tree type) { > - Value *Loc = getValue(LLVMTy); > + void HandleScalarArgument(const llvm::Type *LLVMTy, tree type, > + unsigned RealSize = 0) { > + Value *Loc = NULL; > + if (RealSize) { > + Value *L = LocStack.back(); > + Loc = LLVM_LOAD_SCALAR_ARGUMENT(L,LLVMTy,RealSize,Builder); > + } else > + Loc = getValue(LLVMTy); > > // Perform any implicit type conversions. > if (CallOperands.size() < FTy->getNumParams()) { > > Modified: llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-types.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-types.cpp?rev=50539&r1=50538&r2=50539&view=diff > > ============================================================================== > --- llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-types.cpp (original) > +++ llvm-gcc-4.2/branches/Apple/Tak/gcc/llvm-types.cpp Thu May 1 16:15:57 2008 > @@ -994,7 +994,8 @@ > HandleShadowArgument(PtrArgTy, RetPtr); > } > > - void HandleScalarArgument(const llvm::Type *LLVMTy, tree type) { > + void HandleScalarArgument(const llvm::Type *LLVMTy, tree type, > + unsigned RealSize = 0) { > if (KNRPromotion) { > if (LLVMTy == Type::FloatTy) > LLVMTy = Type::DoubleTy; > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From dalej at apple.com Thu May 1 17:50:14 2008 From: dalej at apple.com (Dale Johannesen) Date: Thu, 01 May 2008 22:50:14 -0000 Subject: [llvm-commits] [llvm] r50548 - /llvm/trunk/test/Transforms/LoopRotate/LRCrash-5.ll Message-ID: <200805012250.m41MoEu3022653@zion.cs.uiuc.edu> Author: johannes Date: Thu May 1 17:50:14 2008 New Revision: 50548 URL: http://llvm.org/viewvc/llvm-project?rev=50548&view=rev Log: New test for bug fixed in 50545. Added: llvm/trunk/test/Transforms/LoopRotate/LRCrash-5.ll Added: llvm/trunk/test/Transforms/LoopRotate/LRCrash-5.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopRotate/LRCrash-5.ll?rev=50548&view=auto ============================================================================== --- llvm/trunk/test/Transforms/LoopRotate/LRCrash-5.ll (added) +++ llvm/trunk/test/Transforms/LoopRotate/LRCrash-5.ll Thu May 1 17:50:14 2008 @@ -0,0 +1,26 @@ +; RUN: llvm-as < %s | opt -loop-rotate -disable-output +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" +target triple = "x86_64-apple-darwin9" + %struct.NSArray = type { %struct.NSObject } + %struct.NSObject = type { %struct.objc_class* } + %struct.NSRange = type { i64, i64 } + %struct._message_ref_t = type { %struct.NSObject* (%struct.NSObject*, %struct._message_ref_t*, ...)*, %struct.objc_selector* } + %struct.objc_class = type opaque + %struct.objc_selector = type opaque +@"\01L_OBJC_MESSAGE_REF_26" = external global %struct._message_ref_t ; <%struct._message_ref_t*> [#uses=1] + +define %struct.NSArray* @"-[NSString(DocSetPrivateAddition) _dsa_stringAsPathComponent]"(%struct.NSArray* %self, %struct._message_ref_t* %_cmd) { +entry: + br label %bb116 + +bb116: ; preds = %bb131, %entry + %tmp123 = call %struct.NSRange null( %struct.NSObject* null, %struct._message_ref_t* @"\01L_OBJC_MESSAGE_REF_26", %struct.NSArray* null ) ; <%struct.NSRange> [#uses=1] + br i1 false, label %bb141, label %bb131 + +bb131: ; preds = %bb116 + %mrv_gr125 = getresult %struct.NSRange %tmp123, 1 ; [#uses=0] + br label %bb116 + +bb141: ; preds = %bb116 + ret %struct.NSArray* null +} From isanbard at gmail.com Thu May 1 17:53:26 2008 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 01 May 2008 22:53:26 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50550 - /llvm-gcc-4.2/trunk/gcc/llvm-abi.h Message-ID: <200805012253.m41MrQSp022762@zion.cs.uiuc.edu> Author: void Date: Thu May 1 17:53:26 2008 New Revision: 50550 URL: http://llvm.org/viewvc/llvm-project?rev=50550&view=rev Log: Porting r50543 from Tak to mainline. Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi.h?rev=50550&r1=50549&r2=50550&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-abi.h (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-abi.h Thu May 1 17:53:26 2008 @@ -603,8 +603,9 @@ if (InSize < Size) { unsigned N = STy->getNumElements(); const llvm::Type *LastEltTy = STy->getElementType(N-1); - LastEltSizeDiff = - getTargetData().getABITypeSize(LastEltTy) - (Size - InSize); + if (LastEltTy->isInteger()) + LastEltSizeDiff = + getTargetData().getABITypeSize(LastEltTy) - (Size - InSize); } } for (unsigned i = 0, e = Elts.size(); i != e; ++i) { From nicolas.geoffray at lip6.fr Thu May 1 17:53:48 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Thu, 01 May 2008 22:53:48 -0000 Subject: [llvm-commits] [vmkit] r50551 - in /vmkit/trunk: Makefile.am README configure.ac lib/N3/Makefile.am lib/N3/README lib/N3/VMCore/Makefile.am lib/N3/VMCore/PNetLib.cpp Message-ID: <200805012253.m41MrmJP022785@zion.cs.uiuc.edu> Author: geoffray Date: Thu May 1 17:53:48 2008 New Revision: 50551 URL: http://llvm.org/viewvc/llvm-project?rev=50551&view=rev Log: Port N3 to PNET 0.8.0. N3 does not require to patch pnet anymore. Modified: vmkit/trunk/Makefile.am vmkit/trunk/README vmkit/trunk/configure.ac vmkit/trunk/lib/N3/Makefile.am vmkit/trunk/lib/N3/README vmkit/trunk/lib/N3/VMCore/Makefile.am vmkit/trunk/lib/N3/VMCore/PNetLib.cpp Modified: vmkit/trunk/Makefile.am URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/Makefile.am?rev=50551&r1=50550&r2=50551&view=diff ============================================================================== --- vmkit/trunk/Makefile.am (original) +++ vmkit/trunk/Makefile.am Thu May 1 17:53:48 2008 @@ -1,4 +1,9 @@ -# $Id: Makefile.am,v 1.3 2008/03/21 11:25:06 varth Exp $ -SUBDIRS = lib/Mvm lib/JnJVM lib/N3 -DIST_SUBDIRS = lib/Mvm lib/JnJVM lib/N3 +SUBDIRS = lib/Mvm lib/JnJVM +DIST_SUBDIRS = lib/Mvm lib/JnJVM + +if WITH_N3 +SUBDIRS += lib/N3 +DIST_SUBDIRS += lib/N3 +endif + EXTRA_DIST = Modified: vmkit/trunk/README URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/README?rev=50551&r1=50550&r2=50551&view=diff ============================================================================== --- vmkit/trunk/README (original) +++ vmkit/trunk/README Thu May 1 17:53:48 2008 @@ -16,6 +16,7 @@ There are mainly two options in the ./configure script --with-gnu-classpath-local-prefix: the local build of GNU classpath +--with-pnet-local-prefix: the local build of PNET --with-llvm: the local build of LLVM --with-gc: user either boehm or single-mmap @@ -24,7 +25,7 @@ 2) lib/JnJVM/main: running the JnJVM like any other JVM 3) lib/N3/main: running N3 like CLR -JnJVM and N3 have their own README notes. N3 requires to patch pnet-0.7.4. +JnJVM and N3 have their own README notes. //===---------------------------------------------------------------------===// Modified: vmkit/trunk/configure.ac URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/configure.ac?rev=50551&r1=50550&r2=50551&view=diff ============================================================================== --- vmkit/trunk/configure.ac (original) +++ vmkit/trunk/configure.ac Thu May 1 17:53:48 2008 @@ -292,6 +292,26 @@ AC_SUBST([classpathglibj]) AC_SUBST([classpathlibs]) +dnl ************************************************************************** +dnl Local PNet directory +dnl ************************************************************************** +AC_ARG_WITH(pnet-local-prefix, + [AS_HELP_STRING(--with-pnet-local-prefix=something, + [PNET local prefix (no default)])], + [[pnetlocalprefix=$withval]], + [[ echo Not using PNETlocal prefix. + pnetlocalprefix='' + ]] +) + +AM_CONDITIONAL([WITH_N3], [test "x$pnetlocalprefix" != "x"]) +if test "x$pnetlocalprefix" != x; then + echo Using ${pnetlocalprefix} as PNET local prefix; + AC_DEFINE([WITH_N3], [1], [Compiling N3]) +fi + +AC_SUBST([pnetlocalprefix]) + AC_CONFIG_FILES([ Modified: vmkit/trunk/lib/N3/Makefile.am URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/Makefile.am?rev=50551&r1=50550&r2=50551&view=diff ============================================================================== --- vmkit/trunk/lib/N3/Makefile.am (original) +++ vmkit/trunk/lib/N3/Makefile.am Thu May 1 17:53:48 2008 @@ -6,5 +6,6 @@ main_SOURCES = ../Mvm/Object.cpp ../Mvm/Sigsegv.cpp Main.cpp ../Mvm/MvmMemoryManager.cpp ../Mvm/JIT.cpp ../Mvm/EscapeAnalysis.cpp main_CXXFLAGS = -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -g -Werror -O2 -main_LDADD = VMCore/.libs/libN3.a @GC_LIBS@ @GCTHREAD_LIBS@ @LLVMDYLIB@ +main_LDADD = VMCore/.libs/libN3.a @GC_LIBS@ @GCTHREAD_LIBS@ @LLVMDYLIB@ @pnetlocalprefix@/engine/libILEngine.a @pnetlocalprefix@/image/libILImage.a @pnetlocalprefix@/support/libILSupport.a \ + @pnetlocalprefix@/libffi/.libs/libffi.a @pnetlocalprefix@/dumpasm/libILDumpAsm.a /usr/lib/libtermcap.a main_LDFLAGS = @rdynamic@ Modified: vmkit/trunk/lib/N3/README URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/README?rev=50551&r1=50550&r2=50551&view=diff ============================================================================== --- vmkit/trunk/lib/N3/README (original) +++ vmkit/trunk/lib/N3/README Thu May 1 17:53:48 2008 @@ -1,15 +1,12 @@ -1 - Install pnetlib-0.7.4 +1 - Install pnetlib-0.8.0 -2 - Patch and compile pnet - tar zxvf pnet-0.7.4.tar.gz - patch -p0 < pnet-0.7.4.patch - ./auto_gen.sh +2 - Download pnet 0.8.0 + tar zxvf pnet-0.8.0.tar.gz ./configure make 3 - Compile n3 -3 - Run - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:{dynamic libraries compiled in 2: pnet-0.7.4/engine/.libs:pnet-0.7.4/support/.libs} +4 - Run export MSCORLIB={directory of pnetlib's mscorlib.dll} ./run-n3 HelloWorld.exe Modified: vmkit/trunk/lib/N3/VMCore/Makefile.am URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/Makefile.am?rev=50551&r1=50550&r2=50551&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/Makefile.am (original) +++ vmkit/trunk/lib/N3/VMCore/Makefile.am Thu May 1 17:53:48 2008 @@ -11,4 +11,5 @@ Opcodes.cpp NativeUtil.h NativeUtil.cpp PNetLib.cpp N3ModuleProvider.cpp N3ModuleProvider.h \ PNetLib.h BackTrace.cpp LowerArrayLength.cpp -libN3_la_CXXFLAGS =-DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -g -O2 +libN3_la_CXXFLAGS =-DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -g -O2 -I at pnetlocalprefix@/include \ + -I at pnetlocalprefix@/engine Modified: vmkit/trunk/lib/N3/VMCore/PNetLib.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/PNetLib.cpp?rev=50551&r1=50550&r2=50551&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/PNetLib.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/PNetLib.cpp Thu May 1 17:53:48 2008 @@ -50,32 +50,50 @@ #define METHOD_SEMANTIC_ATTRIBUTES_FIRE 0x20 -typedef uint32 (*uint32_void)(void); -typedef sint32 (*sint32_sint32)(sint32); -typedef char* (*string_void)(void); -typedef sint32 (*sint32_ptr_sint32_ptr_sint32)(uint16*, sint32, uint8*, sint32); -typedef void (*void_ptr_sint32)(void*, sint32); -typedef char (*char_sint32)(sint32); -typedef sint64 (*sint64_ptr)(void*); -typedef uint32 (*uint32_ptr_ptr_uint32)(void*, void*, uint32); -typedef sint32 (*sint32_ptr_ptr_sint32)(void*, void*, sint32); - -static void* pnetLibSupport; -static void* pnetLibStdio; -static void* pnetLibTime; -static uint32_void ILGetCodePage; -static uint32_void ILGetCultureID; -static string_void ILGetCultureName; -static sint32_sint32 ILAnsiGetMaxByteCount; -static sint32_sint32 ILConsoleWriteChar; -static uint32_void ILConsoleGetMode; -static sint32_ptr_sint32_ptr_sint32 ILAnsiGetBytes; -static void_ptr_sint32 StdFlush; -static char_sint32 ILGetUnicodeCategory; -static sint64_ptr ILTimeMethodsGetCurrentTime; -static uint32_ptr_ptr_uint32 ILUnicodeStringToLower; -static sint32_ptr_ptr_sint32 ILUnicodeStringCompareIgnoreCase; -static sint32_ptr_ptr_sint32 ILUnicodeStringCompareNoIgnoreCase; +extern "C" { +extern uint32 ILGetCodePage(void); +extern uint32 ILGetCultureID(void); +extern char* ILGetCultureName(void); +extern sint32 ILAnsiGetMaxByteCount(sint32); +extern sint32 ILConsoleWriteChar(sint32); +extern uint32 ILConsoleGetMode(void); +extern sint32 ILAnsiGetBytes(uint16*, sint32, uint8*, sint32); +extern void _IL_Stdio_StdFlush(void*, sint32); +extern char ILGetUnicodeCategory(sint32); +extern sint64 _IL_TimeMethods_GetCurrentTime(void*); +extern uint32 ILUnicodeStringToLower(void*, void*, uint32); +extern sint32 ILUnicodeStringCompareIgnoreCase(void*, void*, sint32); +extern sint32 ILUnicodeStringCompareNoIgnoreCase(void*, void*, sint32); + +// PNET wants this +void *GC_run_thread(void *(*thread_func)(void *), void *arg){ return 0; } +#ifndef USE_GC_BOEHM +int GC_invoke_finalizers (void) { return 0; } +int GC_should_invoke_finalizers (void) { return 0; } +void GC_register_finalizer_no_order(void) { return; } +void GC_gcollect(void) {} +void GC_malloc_uncollectable(void) {} +void GC_exclude_static_roots(void) {} +void GC_free(void) {} +void GC_malloc_explicitly_typed(void) {} +void GC_get_heap_size(void) {} +void GC_register_disappearing_link(void) {} +void GC_general_register_disappearing_link(void) {} +void GC_pthread_sigmask(void) {} +void GC_pthread_detach(void) {} +void GC_pthread_create(void) {} +void GC_malloc(void) {} +void GC_make_descriptor(void) {} +void GC_unregister_disappearing_link(void) {} +void GC_finalizer_notifier(void) {} +void GC_java_finalization(void) {} +void GC_finalize_on_demand(void) {} +void GC_set_max_heap_size(void) {} +void GC_malloc_atomic(void) {} +#endif +} + + extern "C" void System_Runtime_CompilerServices_RuntimeHelpers_InitializeArray( VMArray* array, VMField* field) { @@ -229,7 +247,7 @@ } extern "C" void Platform_Stdio_StdFlush(sint32 fd) { - StdFlush(0, fd); + _IL_Stdio_StdFlush(0, fd); } extern "C" void System_Array_InternalCopy(VMArray* src, sint32 sstart, @@ -673,7 +691,7 @@ } extern "C" int64_t Platform_TimeMethods_GetCurrentTime() { - return ILTimeMethodsGetCurrentTime(0); + return _IL_TimeMethods_GetCurrentTime(0); } #define ASSEMBLY_VALUE(obj) ((Assembly**)obj)[3] @@ -1153,35 +1171,4 @@ void* p; p = (void*)&System_Runtime_CompilerServices_RuntimeHelpers_InitializeArray; p = (void*)&System_Type_GetTypeFromHandle; - pnetLibSupport = dlopen("libILSupport.so", RTLD_LAZY | RTLD_GLOBAL); - if (!pnetLibSupport) { - printf("error = %s\n", dlerror()); - } - pnetLibStdio = dlopen("libStdio.so", RTLD_LAZY | RTLD_GLOBAL); - pnetLibTime = dlopen("libTime.so", RTLD_LAZY | RTLD_GLOBAL); - ILGetCodePage = (uint32_void)dlsym(pnetLibSupport, "ILGetCodePage"); - assert(ILGetCodePage); - ILGetCultureID = (uint32_void)dlsym(pnetLibSupport, "ILGetCultureID"); - assert(ILGetCultureID); - ILGetCultureName = (string_void)dlsym(pnetLibSupport, "ILGetCultureName"); - assert(ILGetCultureName); - ILAnsiGetMaxByteCount = (sint32_sint32)dlsym(pnetLibSupport, "ILAnsiGetMaxByteCount"); - assert(ILAnsiGetMaxByteCount); - ILConsoleGetMode = (uint32_void)dlsym(pnetLibSupport, "ILConsoleGetMode"); - assert(ILConsoleGetMode); - ILConsoleWriteChar = (sint32_sint32)dlsym(pnetLibSupport, "ILConsoleWriteChar"); - assert(ILConsoleWriteChar); - ILUnicodeStringToLower = (uint32_ptr_ptr_uint32)dlsym(pnetLibSupport, "ILUnicodeStringToLower"); - assert(ILUnicodeStringToLower); - ILAnsiGetBytes = (sint32_ptr_sint32_ptr_sint32)dlsym(pnetLibSupport, "ILAnsiGetBytes"); - assert(ILAnsiGetBytes); - StdFlush = (void_ptr_sint32)dlsym(pnetLibStdio, "_IL_Stdio_StdFlush"); - assert(StdFlush); - ILGetUnicodeCategory = (char_sint32)dlsym(pnetLibSupport, "ILGetUnicodeCategory"); - assert(ILGetUnicodeCategory); - ILTimeMethodsGetCurrentTime = (sint64_ptr)dlsym(pnetLibTime, "_IL_TimeMethods_GetCurrentTime"); - ILUnicodeStringCompareIgnoreCase = (sint32_ptr_ptr_sint32)dlsym(pnetLibSupport, "ILUnicodeStringCompareIgnoreCase"); - ILUnicodeStringCompareNoIgnoreCase = (sint32_ptr_ptr_sint32)dlsym(pnetLibSupport, "ILUnicodeStringCompareNoIgnoreCase"); - assert(ILUnicodeStringCompareIgnoreCase); - assert(ILUnicodeStringCompareNoIgnoreCase); } From sabre at nondot.org Thu May 1 18:09:42 2008 From: sabre at nondot.org (Chris Lattner) Date: Thu, 01 May 2008 23:09:42 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50552 - /llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Message-ID: <200805012309.m41N9gJf023197@zion.cs.uiuc.edu> Author: lattner Date: Thu May 1 18:09:41 2008 New Revision: 50552 URL: http://llvm.org/viewvc/llvm-project?rev=50552&view=rev Log: Use the correct way to size a struct field, this fixes a few GCC C++ regression test failures. Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=50552&r1=50551&r2=50552&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Thu May 1 18:09:41 2008 @@ -1843,9 +1843,9 @@ // time we support this is when the LLVM type is a struct. In this case, we // remove entries from the end of the LLVM struct until the size matches what // the RTL backend expects as the size for the field. + uint64_t LLVMSize = Info.TD.getABITypeSizeInBits(Ty); if (DECL_SIZE(Field) && isInt64(DECL_SIZE(Field), true) && - getInt64(DECL_SIZE(Field), true) != Info.getTypeSize(Ty)*8) { - uint64_t LLVMSize = Info.getTypeSize(Ty)*8; + getInt64(DECL_SIZE(Field), true) != LLVMSize) { uint64_t GCCFieldSize = getInt64(DECL_SIZE(Field), true); tree FieldType = TREE_TYPE(Field); assert(getInt64(TYPE_SIZE(FieldType), true) == LLVMSize && From kremenek at apple.com Thu May 1 18:18:38 2008 From: kremenek at apple.com (Ted Kremenek) Date: Thu, 01 May 2008 23:18:38 -0000 Subject: [llvm-commits] [llvm] r50554 - /llvm/tags/checker/checker-18/ Message-ID: <200805012318.m41NIcDJ023470@zion.cs.uiuc.edu> Author: kremenek Date: Thu May 1 18:18:38 2008 New Revision: 50554 URL: http://llvm.org/viewvc/llvm-project?rev=50554&view=rev Log: Tagging checker-18. Added: llvm/tags/checker/checker-18/ - copied from r50553, llvm/trunk/ From gohman at apple.com Thu May 1 18:40:45 2008 From: gohman at apple.com (Dan Gohman) Date: Thu, 01 May 2008 23:40:45 -0000 Subject: [llvm-commits] [llvm] r50558 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <200805012340.m41NejZ2024075@zion.cs.uiuc.edu> Author: djg Date: Thu May 1 18:40:44 2008 New Revision: 50558 URL: http://llvm.org/viewvc/llvm-project?rev=50558&view=rev Log: Fix uninitialized uses of the FPC variable. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=50558&r1=50557&r2=50558&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Thu May 1 18:40:44 2008 @@ -2317,8 +2317,8 @@ case FCmpInst::FCMP_OLT: FOC = ISD::SETLT; FPC = ISD::SETOLT; break; case FCmpInst::FCMP_OLE: FOC = ISD::SETLE; FPC = ISD::SETOLE; break; case FCmpInst::FCMP_ONE: FOC = ISD::SETNE; FPC = ISD::SETONE; break; - case FCmpInst::FCMP_ORD: FOC = ISD::SETO; break; - case FCmpInst::FCMP_UNO: FOC = ISD::SETUO; break; + case FCmpInst::FCMP_ORD: FOC = FPC = ISD::SETO; break; + case FCmpInst::FCMP_UNO: FOC = FPC = ISD::SETUO; break; case FCmpInst::FCMP_UEQ: FOC = ISD::SETEQ; FPC = ISD::SETUEQ; break; case FCmpInst::FCMP_UGT: FOC = ISD::SETGT; FPC = ISD::SETUGT; break; case FCmpInst::FCMP_UGE: FOC = ISD::SETGE; FPC = ISD::SETUGE; break; From isanbard at gmail.com Thu May 1 18:44:32 2008 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 01 May 2008 23:44:32 -0000 Subject: [llvm-commits] [llvm] r50559 - /llvm/branches/Apple/Tak/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <200805012344.m41NiXgu024191@zion.cs.uiuc.edu> Author: void Date: Thu May 1 18:44:32 2008 New Revision: 50559 URL: http://llvm.org/viewvc/llvm-project?rev=50559&view=rev Log: Porting 50558 to Tak. Modified: llvm/branches/Apple/Tak/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Modified: llvm/branches/Apple/Tak/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Tak/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=50559&r1=50558&r2=50559&view=diff ============================================================================== --- llvm/branches/Apple/Tak/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/branches/Apple/Tak/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Thu May 1 18:44:32 2008 @@ -2306,8 +2306,8 @@ case FCmpInst::FCMP_OLT: FOC = ISD::SETLT; FPC = ISD::SETOLT; break; case FCmpInst::FCMP_OLE: FOC = ISD::SETLE; FPC = ISD::SETOLE; break; case FCmpInst::FCMP_ONE: FOC = ISD::SETNE; FPC = ISD::SETONE; break; - case FCmpInst::FCMP_ORD: FOC = ISD::SETO; break; - case FCmpInst::FCMP_UNO: FOC = ISD::SETUO; break; + case FCmpInst::FCMP_ORD: FOC = FPC = ISD::SETO; break; + case FCmpInst::FCMP_UNO: FOC = FPC = ISD::SETUO; break; case FCmpInst::FCMP_UEQ: FOC = ISD::SETEQ; FPC = ISD::SETUEQ; break; case FCmpInst::FCMP_UGT: FOC = ISD::SETGT; FPC = ISD::SETUGT; break; case FCmpInst::FCMP_UGE: FOC = ISD::SETGE; FPC = ISD::SETUGE; break; From gohman at apple.com Thu May 1 18:50:08 2008 From: gohman at apple.com (Dan Gohman) Date: Thu, 01 May 2008 23:50:08 -0000 Subject: [llvm-commits] [llvm] r50560 - in /llvm/trunk/test: CFrontend/ Linker/ Transforms/ArgumentPromotion/ Transforms/DeadStoreElimination/ Transforms/IndVarsSimplify/ Transforms/Inline/ Transforms/InstCombine/ Transforms/LoopStrengthReduce/ Transforms/SimplifyCFG/ Transforms/SimplifyLibCalls/ Message-ID: <200805012350.m41No8Sb024359@zion.cs.uiuc.edu> Author: djg Date: Thu May 1 18:50:07 2008 New Revision: 50560 URL: http://llvm.org/viewvc/llvm-project?rev=50560&view=rev Log: Update old-style syntax in some "not grep" tests. Modified: llvm/trunk/test/CFrontend/2004-11-27-StaticFunctionRedeclare.c llvm/trunk/test/Linker/2003-05-31-LinkerRename.ll llvm/trunk/test/Transforms/ArgumentPromotion/control-flow.ll llvm/trunk/test/Transforms/DeadStoreElimination/2004-11-28-LiveStoreDeleted.ll llvm/trunk/test/Transforms/IndVarsSimplify/2003-12-21-IndVarSize.ll llvm/trunk/test/Transforms/Inline/inline_dce.ll llvm/trunk/test/Transforms/InstCombine/2004-09-20-BadLoadCombine2.ll llvm/trunk/test/Transforms/InstCombine/bittest.ll llvm/trunk/test/Transforms/InstCombine/setcc-cast-cast.ll llvm/trunk/test/Transforms/LoopStrengthReduce/dont-hoist-simple-loop-constants.ll llvm/trunk/test/Transforms/SimplifyCFG/2003-08-17-BranchFold.ll llvm/trunk/test/Transforms/SimplifyCFG/2003-08-17-BranchFoldOrdering.ll llvm/trunk/test/Transforms/SimplifyCFG/branch-phi-thread.ll llvm/trunk/test/Transforms/SimplifyCFG/switch_thread.ll llvm/trunk/test/Transforms/SimplifyLibCalls/FFS.ll llvm/trunk/test/Transforms/SimplifyLibCalls/StrChr.ll Modified: llvm/trunk/test/CFrontend/2004-11-27-StaticFunctionRedeclare.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CFrontend/2004-11-27-StaticFunctionRedeclare.c?rev=50560&r1=50559&r2=50560&view=diff ============================================================================== --- llvm/trunk/test/CFrontend/2004-11-27-StaticFunctionRedeclare.c (original) +++ llvm/trunk/test/CFrontend/2004-11-27-StaticFunctionRedeclare.c Thu May 1 18:50:07 2008 @@ -1,5 +1,5 @@ // RUN: %llvmgcc -c -emit-llvm %s -o - | \ -// RUN: opt -std-compile-opts | llvm-dis | not grep {declare int.*func} +// RUN: opt -std-compile-opts | llvm-dis | not grep {declare i32.*func} // There should not be an unresolved reference to func here. Believe it or not, // the "expected result" is a function named 'func' which is internal and Modified: llvm/trunk/test/Linker/2003-05-31-LinkerRename.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/2003-05-31-LinkerRename.ll?rev=50560&r1=50559&r2=50560&view=diff ============================================================================== --- llvm/trunk/test/Linker/2003-05-31-LinkerRename.ll (original) +++ llvm/trunk/test/Linker/2003-05-31-LinkerRename.ll Thu May 1 18:50:07 2008 @@ -6,7 +6,7 @@ ; RUN: echo { define internal i32 @foo() \{ ret i32 7 \} } | llvm-as > %t.1.bc ; RUN: llvm-as < %s > %t.2.bc -; RUN: llvm-link %t.1.bc %t.2.bc | llvm-dis | grep internal | not grep %foo( +; RUN: llvm-link %t.1.bc %t.2.bc | llvm-dis | grep internal | not grep @foo( declare i32 @foo() Modified: llvm/trunk/test/Transforms/ArgumentPromotion/control-flow.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ArgumentPromotion/control-flow.ll?rev=50560&r1=50559&r2=50560&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ArgumentPromotion/control-flow.ll (original) +++ llvm/trunk/test/Transforms/ArgumentPromotion/control-flow.ll Thu May 1 18:50:07 2008 @@ -1,5 +1,5 @@ ; RUN: llvm-as < %s | opt -argpromotion | llvm-dis | \ -; RUN: not grep {load int\* null} +; RUN: not grep {load i32\* null} define internal i32 @callee(i1 %C, i32* %P) { br i1 %C, label %T, label %F Modified: llvm/trunk/test/Transforms/DeadStoreElimination/2004-11-28-LiveStoreDeleted.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DeadStoreElimination/2004-11-28-LiveStoreDeleted.ll?rev=50560&r1=50559&r2=50560&view=diff ============================================================================== --- llvm/trunk/test/Transforms/DeadStoreElimination/2004-11-28-LiveStoreDeleted.ll (original) +++ llvm/trunk/test/Transforms/DeadStoreElimination/2004-11-28-LiveStoreDeleted.ll Thu May 1 18:50:07 2008 @@ -1,5 +1,5 @@ ; RUN: llvm-as < %s | opt -dse -scalarrepl -instcombine | \ -; RUN: llvm-dis | not grep {ret int undef} +; RUN: llvm-dis | not grep {ret i32 undef} define i32 @test(double %__x) { %__u = alloca { [3 x i32] } ; <{ [3 x i32] }*> [#uses=2] Modified: llvm/trunk/test/Transforms/IndVarsSimplify/2003-12-21-IndVarSize.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarsSimplify/2003-12-21-IndVarSize.ll?rev=50560&r1=50559&r2=50560&view=diff ============================================================================== --- llvm/trunk/test/Transforms/IndVarsSimplify/2003-12-21-IndVarSize.ll (original) +++ llvm/trunk/test/Transforms/IndVarsSimplify/2003-12-21-IndVarSize.ll Thu May 1 18:50:07 2008 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -indvars | llvm-dis | grep indvar | not grep uint +; RUN: llvm-as < %s | opt -indvars | llvm-dis | grep indvar | not grep i32 @G = global i64 0 ; [#uses=1] Modified: llvm/trunk/test/Transforms/Inline/inline_dce.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Inline/inline_dce.ll?rev=50560&r1=50559&r2=50560&view=diff ============================================================================== --- llvm/trunk/test/Transforms/Inline/inline_dce.ll (original) +++ llvm/trunk/test/Transforms/Inline/inline_dce.ll Thu May 1 18:50:07 2008 @@ -2,7 +2,7 @@ ; inlined into all of their callers. ; RUN: llvm-as < %s | opt -inline | llvm-dis | \ -; RUN: not grep %reallysmall +; RUN: not grep @reallysmall define internal i32 @reallysmall(i32 %A) { ret i32 %A Modified: llvm/trunk/test/Transforms/InstCombine/2004-09-20-BadLoadCombine2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2004-09-20-BadLoadCombine2.ll?rev=50560&r1=50559&r2=50560&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/2004-09-20-BadLoadCombine2.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/2004-09-20-BadLoadCombine2.ll Thu May 1 18:50:07 2008 @@ -1,5 +1,5 @@ ; RUN: llvm-as < %s | opt -instcombine -mem2reg -simplifycfg | \ -; RUN: llvm-dis | grep -v store | not grep {int 1} +; RUN: llvm-dis | grep -v store | not grep {i32 1} ; Test to make sure that instcombine does not accidentally propagate the load ; into the PHI, which would break the program. Modified: llvm/trunk/test/Transforms/InstCombine/bittest.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/bittest.ll?rev=50560&r1=50559&r2=50560&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/bittest.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/bittest.ll Thu May 1 18:50:07 2008 @@ -1,5 +1,5 @@ ; RUN: llvm-as < %s | opt -instcombine -simplifycfg | llvm-dis |\ -; RUN: not grep {call void %abort} +; RUN: not grep {call void @abort} @b_rec.0 = external global i32 ; [#uses=2] Modified: llvm/trunk/test/Transforms/InstCombine/setcc-cast-cast.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/setcc-cast-cast.ll?rev=50560&r1=50559&r2=50560&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/setcc-cast-cast.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/setcc-cast-cast.ll Thu May 1 18:50:07 2008 @@ -2,7 +2,7 @@ ; that folding doesn't happen in case a zext is applied where a sext should have ; been when a setcc is used with two casts. ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \ -; RUN: not grep {br bool false} +; RUN: not grep {br i1 false} ; END. define i32 @bug(i8 %inbuff) { Modified: llvm/trunk/test/Transforms/LoopStrengthReduce/dont-hoist-simple-loop-constants.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/dont-hoist-simple-loop-constants.ll?rev=50560&r1=50559&r2=50560&view=diff ============================================================================== --- llvm/trunk/test/Transforms/LoopStrengthReduce/dont-hoist-simple-loop-constants.ll (original) +++ llvm/trunk/test/Transforms/LoopStrengthReduce/dont-hoist-simple-loop-constants.ll Thu May 1 18:50:07 2008 @@ -1,5 +1,5 @@ ; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | \ -; RUN: not grep {cast uint 1 to uint} +; RUN: not grep {bitcast i32 1 to i32} ; END. ; The setlt wants to use a value that is incremented one more than the dominant ; IV. Don't insert the 1 outside the loop, preventing folding it into the add. Modified: llvm/trunk/test/Transforms/SimplifyCFG/2003-08-17-BranchFold.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/2003-08-17-BranchFold.ll?rev=50560&r1=50559&r2=50560&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SimplifyCFG/2003-08-17-BranchFold.ll (original) +++ llvm/trunk/test/Transforms/SimplifyCFG/2003-08-17-BranchFold.ll Thu May 1 18:50:07 2008 @@ -2,7 +2,7 @@ ; 'br Dest' ; RUN: llvm-as < %s | opt -simplifycfg | llvm-dis | \ -; RUN: not grep {br bool %c2} +; RUN: not grep {br i1 %c2} declare void @noop() Modified: llvm/trunk/test/Transforms/SimplifyCFG/2003-08-17-BranchFoldOrdering.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/2003-08-17-BranchFoldOrdering.ll?rev=50560&r1=50559&r2=50560&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SimplifyCFG/2003-08-17-BranchFoldOrdering.ll (original) +++ llvm/trunk/test/Transforms/SimplifyCFG/2003-08-17-BranchFoldOrdering.ll Thu May 1 18:50:07 2008 @@ -4,7 +4,7 @@ ; the ConstantFoldTerminator function. ; RUN: llvm-as < %s | opt -simplifycfg | llvm-dis | \ -; RUN: not grep {br bool %c2} +; RUN: not grep {br i1 %c2} declare void @noop() Modified: llvm/trunk/test/Transforms/SimplifyCFG/branch-phi-thread.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/branch-phi-thread.ll?rev=50560&r1=50559&r2=50560&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SimplifyCFG/branch-phi-thread.ll (original) +++ llvm/trunk/test/Transforms/SimplifyCFG/branch-phi-thread.ll Thu May 1 18:50:07 2008 @@ -1,5 +1,5 @@ ; RUN: llvm-as < %s | opt -simplifycfg -adce | llvm-dis | \ -; RUN: not grep {call void %f1} +; RUN: not grep {call void @f1} ; END. declare void @f1() Modified: llvm/trunk/test/Transforms/SimplifyCFG/switch_thread.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/switch_thread.ll?rev=50560&r1=50559&r2=50560&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SimplifyCFG/switch_thread.ll (original) +++ llvm/trunk/test/Transforms/SimplifyCFG/switch_thread.ll Thu May 1 18:50:07 2008 @@ -1,5 +1,5 @@ ; RUN: llvm-as < %s | opt -simplifycfg | llvm-dis | \ -; RUN: not grep {call void %DEAD} +; RUN: not grep {call void @DEAD} ; Test that we can thread a simple known condition through switch statements. Modified: llvm/trunk/test/Transforms/SimplifyLibCalls/FFS.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyLibCalls/FFS.ll?rev=50560&r1=50559&r2=50560&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SimplifyLibCalls/FFS.ll (original) +++ llvm/trunk/test/Transforms/SimplifyLibCalls/FFS.ll Thu May 1 18:50:07 2008 @@ -1,6 +1,6 @@ ; Test that the ToAsciiOptimizer works correctly ; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | \ -; RUN: not grep {call.*%ffs} +; RUN: not grep {call.*@ffs} @non_const = external global i32 ; [#uses=1] Modified: llvm/trunk/test/Transforms/SimplifyLibCalls/StrChr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyLibCalls/StrChr.ll?rev=50560&r1=50559&r2=50560&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SimplifyLibCalls/StrChr.ll (original) +++ llvm/trunk/test/Transforms/SimplifyLibCalls/StrChr.ll Thu May 1 18:50:07 2008 @@ -1,6 +1,6 @@ ; Test that the StrChrOptimizer works correctly ; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | \ -; RUN: not grep {call.*%strchr} +; RUN: not grep {call.*@strchr} @hello = constant [14 x i8] c"hello world\5Cn\00" ; <[14 x i8]*> [#uses=1] @null = constant [1 x i8] zeroinitializer ; <[1 x i8]*> [#uses=1] From gohman at apple.com Thu May 1 19:03:54 2008 From: gohman at apple.com (Dan Gohman) Date: Fri, 02 May 2008 00:03:54 -0000 Subject: [llvm-commits] [llvm] r50561 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <200805020003.m4203sxc024722@zion.cs.uiuc.edu> Author: djg Date: Thu May 1 19:03:54 2008 New Revision: 50561 URL: http://llvm.org/viewvc/llvm-project?rev=50561&view=rev Log: Use push_back(...) instead of resize(1, ...), per review feedback. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=50561&r1=50560&r2=50561&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Thu May 1 19:03:54 2008 @@ -4023,8 +4023,8 @@ // Add NumOps>>3 registers to MatchedRegs. RegsForValue MatchedRegs; MatchedRegs.TLI = &TLI; - MatchedRegs.ValueVTs.resize(1, InOperandVal.getValueType()); - MatchedRegs.RegVTs.resize(1, AsmNodeOperands[CurOp+1].getValueType()); + MatchedRegs.ValueVTs.push_back(InOperandVal.getValueType()); + MatchedRegs.RegVTs.push_back(AsmNodeOperands[CurOp+1].getValueType()); for (unsigned i = 0, e = NumOps>>3; i != e; ++i) { unsigned Reg = cast(AsmNodeOperands[++CurOp])->getReg(); From gohman at apple.com Thu May 1 19:05:04 2008 From: gohman at apple.com (Dan Gohman) Date: Fri, 02 May 2008 00:05:04 -0000 Subject: [llvm-commits] [llvm] r50562 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Message-ID: <200805020005.m42054EC024761@zion.cs.uiuc.edu> Author: djg Date: Thu May 1 19:05:03 2008 New Revision: 50562 URL: http://llvm.org/viewvc/llvm-project?rev=50562&view=rev Log: Fix a typo in a comment. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=50562&r1=50561&r2=50562&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Thu May 1 19:05:03 2008 @@ -3409,7 +3409,7 @@ if (SDNode *Existing = FindModifiedNodeSlot(N, Ops, NumOps, InsertPos)) return SDOperand(Existing, InN.ResNo); - // Nope it doesn't. Remove the node from it's current place in the maps. + // Nope it doesn't. Remove the node from its current place in the maps. if (InsertPos) RemoveNodeFromCSEMaps(N); From isanbard at gmail.com Thu May 1 19:41:13 2008 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 02 May 2008 00:41:13 -0000 Subject: [llvm-commits] [llvm] r50563 - /llvm/branches/Apple/Tak/lib/Transforms/Scalar/LoopIndexSplit.cpp Message-ID: <200805020041.m420fDxo025754@zion.cs.uiuc.edu> Author: void Date: Thu May 1 19:41:12 2008 New Revision: 50563 URL: http://llvm.org/viewvc/llvm-project?rev=50563&view=rev Log: Don't split the loop index if it's not "diamond" shaped. The result could be code that's much less efficient and have bugs. Modified: llvm/branches/Apple/Tak/lib/Transforms/Scalar/LoopIndexSplit.cpp Modified: llvm/branches/Apple/Tak/lib/Transforms/Scalar/LoopIndexSplit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Tak/lib/Transforms/Scalar/LoopIndexSplit.cpp?rev=50563&r1=50562&r2=50563&view=diff ============================================================================== --- llvm/branches/Apple/Tak/lib/Transforms/Scalar/LoopIndexSplit.cpp (original) +++ llvm/branches/Apple/Tak/lib/Transforms/Scalar/LoopIndexSplit.cpp Thu May 1 19:41:12 2008 @@ -1124,6 +1124,11 @@ BasicBlock *Succ0 = SplitTerminator->getSuccessor(0); BasicBlock *Succ1 = SplitTerminator->getSuccessor(1); + // If split block does not dominate the latch then this is not a diamond. + // Such loop may not benefit from index split. + if (!DT->dominates(SplitCondBlock, Latch)) + return false; + // Finally this split condition is safe only if merge point for // split condition branch is loop latch. This check along with previous // check, to ensure that exit condition is in either loop latch or header, From isanbard at gmail.com Thu May 1 19:43:20 2008 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 02 May 2008 00:43:20 -0000 Subject: [llvm-commits] [llvm] r50564 - /llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp Message-ID: <200805020043.m420hKqp025809@zion.cs.uiuc.edu> Author: void Date: Thu May 1 19:43:20 2008 New Revision: 50564 URL: http://llvm.org/viewvc/llvm-project?rev=50564&view=rev Log: Porting r50563 from Tak to mainline. Modified: llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp?rev=50564&r1=50563&r2=50564&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp Thu May 1 19:43:20 2008 @@ -1124,6 +1124,11 @@ BasicBlock *Succ0 = SplitTerminator->getSuccessor(0); BasicBlock *Succ1 = SplitTerminator->getSuccessor(1); + // If split block does not dominate the latch then this is not a diamond. + // Such loop may not benefit from index split. + if (!DT->dominates(SplitCondBlock, Latch)) + return false; + // Finally this split condition is safe only if merge point for // split condition branch is loop latch. This check along with previous // check, to ensure that exit condition is in either loop latch or header, From kremenek at apple.com Thu May 1 20:46:53 2008 From: kremenek at apple.com (Ted Kremenek) Date: Fri, 02 May 2008 01:46:53 -0000 Subject: [llvm-commits] [llvm] r50565 - /llvm/tags/checker/checker-19/ Message-ID: <200805020146.m421krI0027584@zion.cs.uiuc.edu> Author: kremenek Date: Thu May 1 20:46:53 2008 New Revision: 50565 URL: http://llvm.org/viewvc/llvm-project?rev=50565&view=rev Log: Tagging checker-19. Added: llvm/tags/checker/checker-19/ - copied from r50564, llvm/trunk/ From isanbard at gmail.com Thu May 1 23:03:44 2008 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 02 May 2008 04:03:44 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50567 - in /llvm-gcc-4.2/tags/Apple: llvmCore-2037/ llvmgcc42-2037/ Message-ID: <200805020403.m4243iW5031425@zion.cs.uiuc.edu> Author: void Date: Thu May 1 23:03:43 2008 New Revision: 50567 URL: http://llvm.org/viewvc/llvm-project?rev=50567&view=rev Log: Rename this tag to its proper name Added: llvm-gcc-4.2/tags/Apple/llvmgcc42-2037/ - copied from r50566, llvm-gcc-4.2/tags/Apple/llvmCore-2037/ Removed: llvm-gcc-4.2/tags/Apple/llvmCore-2037/ From isanbard at gmail.com Thu May 1 23:04:10 2008 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 02 May 2008 04:04:10 -0000 Subject: [llvm-commits] [llvm] r50568 - /llvm/tags/Apple/llvmCore-2038/ Message-ID: <200805020404.m4244A4p031448@zion.cs.uiuc.edu> Author: void Date: Thu May 1 23:04:10 2008 New Revision: 50568 URL: http://llvm.org/viewvc/llvm-project?rev=50568&view=rev Log: Creating llvmCore-2038 branch Added: llvm/tags/Apple/llvmCore-2038/ - copied from r50567, llvm/trunk/ From isanbard at gmail.com Thu May 1 23:04:17 2008 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 02 May 2008 04:04:17 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50569 - /llvm-gcc-4.2/tags/Apple/llvmgcc42-2038/ Message-ID: <200805020404.m4244Hl6031461@zion.cs.uiuc.edu> Author: void Date: Thu May 1 23:04:16 2008 New Revision: 50569 URL: http://llvm.org/viewvc/llvm-project?rev=50569&view=rev Log: Creating llvmgcc42-2038 branch Added: llvm-gcc-4.2/tags/Apple/llvmgcc42-2038/ - copied from r50568, llvm-gcc-4.2/trunk/ From isanbard at gmail.com Thu May 1 23:12:19 2008 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 02 May 2008 04:12:19 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50570 - /llvm-gcc-4.2/tags/Apple/llvmgcc42-2038/ Message-ID: <200805020412.m424CJ3j031665@zion.cs.uiuc.edu> Author: void Date: Thu May 1 23:12:19 2008 New Revision: 50570 URL: http://llvm.org/viewvc/llvm-project?rev=50570&view=rev Log: Copied the wrong branch Removed: llvm-gcc-4.2/tags/Apple/llvmgcc42-2038/ From isanbard at gmail.com Thu May 1 23:12:32 2008 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 02 May 2008 04:12:32 -0000 Subject: [llvm-commits] [llvm] r50571 - /llvm/tags/Apple/llvmCore-2038/ Message-ID: <200805020412.m424CWQA031683@zion.cs.uiuc.edu> Author: void Date: Thu May 1 23:12:32 2008 New Revision: 50571 URL: http://llvm.org/viewvc/llvm-project?rev=50571&view=rev Log: Copied the wrong branch Removed: llvm/tags/Apple/llvmCore-2038/ From isanbard at gmail.com Thu May 1 23:13:30 2008 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 02 May 2008 04:13:30 -0000 Subject: [llvm-commits] [llvm] r50572 - /llvm/tags/Apple/llvmCore-2038/ Message-ID: <200805020413.m424DUvJ031719@zion.cs.uiuc.edu> Author: void Date: Thu May 1 23:13:30 2008 New Revision: 50572 URL: http://llvm.org/viewvc/llvm-project?rev=50572&view=rev Log: Creating llvmCore-2038 from Tak Added: llvm/tags/Apple/llvmCore-2038/ - copied from r50571, llvm/branches/Apple/Tak/ From isanbard at gmail.com Thu May 1 23:14:11 2008 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 02 May 2008 04:14:11 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50573 - /llvm-gcc-4.2/tags/Apple/llvmgcc42-2038/ Message-ID: <200805020414.m424EBGb031750@zion.cs.uiuc.edu> Author: void Date: Thu May 1 23:14:11 2008 New Revision: 50573 URL: http://llvm.org/viewvc/llvm-project?rev=50573&view=rev Log: Creating llvmgcc42-2038 from Tak Added: llvm-gcc-4.2/tags/Apple/llvmgcc42-2038/ - copied from r50572, llvm-gcc-4.2/branches/Apple/Tak/ From evan.cheng at apple.com Fri May 2 02:50:59 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 02 May 2008 07:50:59 -0000 Subject: [llvm-commits] [llvm] r50574 - /llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Message-ID: <200805020750.m427oxZt013501@zion.cs.uiuc.edu> Author: evancheng Date: Fri May 2 02:50:58 2008 New Revision: 50574 URL: http://llvm.org/viewvc/llvm-project?rev=50574&view=rev Log: Not safe folding a load + FsXORPSrr into FsXORPSrm. It's loading a FR64 value but the load folding variant expects a 16-byte aligned address. Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=50574&r1=50573&r2=50574&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Fri May 2 02:50:58 2008 @@ -503,14 +503,6 @@ { X86::DIVPSrr, X86::DIVPSrm }, { X86::DIVSDrr, X86::DIVSDrm }, { X86::DIVSSrr, X86::DIVSSrm }, - { X86::FsANDNPDrr, X86::FsANDNPDrm }, - { X86::FsANDNPSrr, X86::FsANDNPSrm }, - { X86::FsANDPDrr, X86::FsANDPDrm }, - { X86::FsANDPSrr, X86::FsANDPSrm }, - { X86::FsORPDrr, X86::FsORPDrm }, - { X86::FsORPSrr, X86::FsORPSrm }, - { X86::FsXORPDrr, X86::FsXORPDrm }, - { X86::FsXORPSrr, X86::FsXORPSrm }, { X86::HADDPDrr, X86::HADDPDrm }, { X86::HADDPSrr, X86::HADDPSrm }, { X86::HSUBPDrr, X86::HSUBPDrm }, From evan.cheng at apple.com Fri May 2 02:53:33 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 02 May 2008 07:53:33 -0000 Subject: [llvm-commits] [llvm] r50575 - /llvm/trunk/lib/Target/X86/X86InstrSSE.td Message-ID: <200805020753.m427rXx9013579@zion.cs.uiuc.edu> Author: evancheng Date: Fri May 2 02:53:32 2008 New Revision: 50575 URL: http://llvm.org/viewvc/llvm-project?rev=50575&view=rev Log: 80 column violation. Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=50575&r1=50574&r2=50575&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Fri May 2 02:53:32 2008 @@ -1180,26 +1180,32 @@ // Alias bitwise logical operations using SSE logical ops on packed FP values. let Constraints = "$src1 = $dst" in { let isCommutable = 1 in { - def FsANDPDrr : PDI<0x54, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2), + def FsANDPDrr : PDI<0x54, MRMSrcReg, (outs FR64:$dst), + (ins FR64:$src1, FR64:$src2), "andpd\t{$src2, $dst|$dst, $src2}", [(set FR64:$dst, (X86fand FR64:$src1, FR64:$src2))]>; - def FsORPDrr : PDI<0x56, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2), + def FsORPDrr : PDI<0x56, MRMSrcReg, (outs FR64:$dst), + (ins FR64:$src1, FR64:$src2), "orpd\t{$src2, $dst|$dst, $src2}", [(set FR64:$dst, (X86for FR64:$src1, FR64:$src2))]>; - def FsXORPDrr : PDI<0x57, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2), + def FsXORPDrr : PDI<0x57, MRMSrcReg, (outs FR64:$dst), + (ins FR64:$src1, FR64:$src2), "xorpd\t{$src2, $dst|$dst, $src2}", [(set FR64:$dst, (X86fxor FR64:$src1, FR64:$src2))]>; } -def FsANDPDrm : PDI<0x54, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2), +def FsANDPDrm : PDI<0x54, MRMSrcMem, (outs FR64:$dst), + (ins FR64:$src1, f128mem:$src2), "andpd\t{$src2, $dst|$dst, $src2}", [(set FR64:$dst, (X86fand FR64:$src1, (memopfsf64 addr:$src2)))]>; -def FsORPDrm : PDI<0x56, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2), +def FsORPDrm : PDI<0x56, MRMSrcMem, (outs FR64:$dst), + (ins FR64:$src1, f128mem:$src2), "orpd\t{$src2, $dst|$dst, $src2}", [(set FR64:$dst, (X86for FR64:$src1, (memopfsf64 addr:$src2)))]>; -def FsXORPDrm : PDI<0x57, MRMSrcMem, (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2), +def FsXORPDrm : PDI<0x57, MRMSrcMem, (outs FR64:$dst), + (ins FR64:$src1, f128mem:$src2), "xorpd\t{$src2, $dst|$dst, $src2}", [(set FR64:$dst, (X86fxor FR64:$src1, (memopfsf64 addr:$src2)))]>; From sabre at nondot.org Fri May 2 10:11:58 2008 From: sabre at nondot.org (Chris Lattner) Date: Fri, 02 May 2008 15:11:58 -0000 Subject: [llvm-commits] [llvm] r50576 - /llvm/trunk/test/CodeGen/X86/2008-05-01-InvalidOrdCompare.ll Message-ID: <200805021511.m42FBwT3030731@zion.cs.uiuc.edu> Author: lattner Date: Fri May 2 10:11:58 2008 New Revision: 50576 URL: http://llvm.org/viewvc/llvm-project?rev=50576&view=rev Log: specify an arch for non-x86 hosts. Modified: llvm/trunk/test/CodeGen/X86/2008-05-01-InvalidOrdCompare.ll Modified: llvm/trunk/test/CodeGen/X86/2008-05-01-InvalidOrdCompare.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2008-05-01-InvalidOrdCompare.ll?rev=50576&r1=50575&r2=50576&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2008-05-01-InvalidOrdCompare.ll (original) +++ llvm/trunk/test/CodeGen/X86/2008-05-01-InvalidOrdCompare.ll Fri May 2 10:11:58 2008 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -enable-unsafe-fp-math | grep jnp +; RUN: llvm-as < %s | llc -enable-unsafe-fp-math -march=x86 | grep jnp ; rdar://5902801 declare void @test2() From evan.cheng at apple.com Fri May 2 12:01:01 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 02 May 2008 17:01:01 -0000 Subject: [llvm-commits] [llvm] r50578 - /llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Message-ID: <200805021701.m42H11Mi001553@zion.cs.uiuc.edu> Author: evancheng Date: Fri May 2 12:01:01 2008 New Revision: 50578 URL: http://llvm.org/viewvc/llvm-project?rev=50578&view=rev Log: Undo r50574. We are already ensuring the folded load address is 16-byte aligned. Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=50578&r1=50577&r2=50578&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Fri May 2 12:01:01 2008 @@ -503,6 +503,14 @@ { X86::DIVPSrr, X86::DIVPSrm }, { X86::DIVSDrr, X86::DIVSDrm }, { X86::DIVSSrr, X86::DIVSSrm }, + { X86::FsANDNPDrr, X86::FsANDNPDrm }, + { X86::FsANDNPSrr, X86::FsANDNPSrm }, + { X86::FsANDPDrr, X86::FsANDPDrm }, + { X86::FsANDPSrr, X86::FsANDPSrm }, + { X86::FsORPDrr, X86::FsORPDrm }, + { X86::FsORPSrr, X86::FsORPSrm }, + { X86::FsXORPDrr, X86::FsXORPDrm }, + { X86::FsXORPSrr, X86::FsXORPSrm }, { X86::HADDPDrr, X86::HADDPDrm }, { X86::HADDPSrr, X86::HADDPSrm }, { X86::HSUBPDrr, X86::HSUBPDrm }, From sabre at nondot.org Fri May 2 12:18:31 2008 From: sabre at nondot.org (Chris Lattner) Date: Fri, 02 May 2008 17:18:31 -0000 Subject: [llvm-commits] [llvm] r50582 - /llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp Message-ID: <200805021718.m42HIVO9002080@zion.cs.uiuc.edu> Author: lattner Date: Fri May 2 12:18:31 2008 New Revision: 50582 URL: http://llvm.org/viewvc/llvm-project?rev=50582&view=rev Log: add a FIXME so we remember to eventually remove this code. Modified: llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp?rev=50582&r1=50581&r2=50582&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp Fri May 2 12:18:31 2008 @@ -249,8 +249,8 @@ // create new PHINode for this instruction. Instruction *NewHeaderReplacement = NULL; if (usedOutsideOriginalHeader(In)) { - const StructType *STy = dyn_cast(In->getType()); - if (STy) { + // FIXME: remove this when we have first-class aggregates. + if (isa(In->getType())) { // Can't create PHI nodes for this type. If there are any getResults // not defined in this block, move them back to this block. PHI // nodes will be created for all getResults later. @@ -261,14 +261,15 @@ ++InsertPoint; } else { InsertPoint = I; // call - InsertPoint++; + ++InsertPoint; } for (Value::use_iterator UI = In->use_begin(), UE = In->use_end(); UI != UE; ++UI) { GetResultInst *InGR = cast(UI); if (InGR->getParent() != OrigHeader) { - // move InGR to immediately follow call. It will be picked - // up, cloned and PHI'd on the next iteration. + // Move InGR to immediately after the call or in the normal dest of + // the invoke. It will be picked up, cloned and PHI'd on the next + // iteration. InGR->moveBefore(InsertPoint); } } From sabre at nondot.org Fri May 2 13:43:36 2008 From: sabre at nondot.org (Chris Lattner) Date: Fri, 02 May 2008 18:43:36 -0000 Subject: [llvm-commits] [llvm] r50586 - in /llvm/trunk: lib/Transforms/Scalar/SimplifyLibCalls.cpp test/Transforms/SimplifyLibCalls/exp2.ll Message-ID: <200805021843.m42Iha3A004846@zion.cs.uiuc.edu> Author: lattner Date: Fri May 2 13:43:35 2008 New Revision: 50586 URL: http://llvm.org/viewvc/llvm-project?rev=50586&view=rev Log: strength reduce exp2 into ldexp, rdar://5852514 Added: llvm/trunk/test/Transforms/SimplifyLibCalls/exp2.ll Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=50586&r1=50585&r2=50586&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Fri May 2 13:43:35 2008 @@ -838,6 +838,53 @@ }; //===---------------------------------------===// +// 'exp2' Optimizations + +struct VISIBILITY_HIDDEN Exp2Opt : public LibCallOptimization { + virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) { + const FunctionType *FT = Callee->getFunctionType(); + // Just make sure this has 1 argument of FP type, which matches the + // result type. + if (FT->getNumParams() != 1 || FT->getReturnType() != FT->getParamType(0) || + !FT->getParamType(0)->isFloatingPoint()) + return 0; + + Value *Op = CI->getOperand(1); + // Turn exp2(sitofp(x)) -> ldexp(1.0, sext(x)) if sizeof(x) <= 32 + // Turn exp2(uitofp(x)) -> ldexp(1.0, zext(x)) if sizeof(x) < 32 + Value *LdExpArg = 0; + if (SIToFPInst *OpC = dyn_cast(Op)) { + if (OpC->getOperand(0)->getType()->getPrimitiveSizeInBits() <= 32) + LdExpArg = B.CreateSExt(OpC->getOperand(0), Type::Int32Ty, "tmp"); + } else if (UIToFPInst *OpC = dyn_cast(Op)) { + if (OpC->getOperand(0)->getType()->getPrimitiveSizeInBits() < 32) + LdExpArg = B.CreateZExt(OpC->getOperand(0), Type::Int32Ty, "tmp"); + } + + if (LdExpArg) { + const char *Name; + if (Op->getType() == Type::FloatTy) + Name = "ldexpf"; + else if (Op->getType() == Type::DoubleTy) + Name = "ldexp"; + else + Name = "ldexpl"; + + Constant *One = ConstantFP::get(APFloat(1.0f)); + if (Op->getType() != Type::FloatTy) + One = ConstantExpr::getFPExtend(One, Op->getType()); + + Module *M = Caller->getParent(); + Value *Callee = M->getOrInsertFunction(Name, Op->getType(), + Op->getType(), Type::Int32Ty,NULL); + return B.CreateCall2(Callee, One, LdExpArg); + } + return 0; + } +}; + + +//===---------------------------------------===// // Double -> Float Shrinking Optimizations for Unary Functions like 'floor' struct VISIBILITY_HIDDEN UnaryDoubleFPOpt : public LibCallOptimization { @@ -1205,7 +1252,7 @@ StrCatOpt StrCat; StrChrOpt StrChr; StrCmpOpt StrCmp; StrNCmpOpt StrNCmp; StrCpyOpt StrCpy; StrLenOpt StrLen; MemCmpOpt MemCmp; MemCpyOpt MemCpy; // Math Library Optimizations - PowOpt Pow; UnaryDoubleFPOpt UnaryDoubleFP; + PowOpt Pow; Exp2Opt Exp2; UnaryDoubleFPOpt UnaryDoubleFP; // Integer Optimizations FFSOpt FFS; IsDigitOpt IsDigit; IsAsciiOpt IsAscii; ToAsciiOpt ToAscii; // Formatting and IO Optimizations @@ -1253,6 +1300,10 @@ Optimizations["powf"] = &Pow; Optimizations["pow"] = &Pow; Optimizations["powl"] = &Pow; + Optimizations["exp2l"] = &Exp2; + Optimizations["exp2"] = &Exp2; + Optimizations["exp2f"] = &Exp2; + #ifdef HAVE_FLOORF Optimizations["floor"] = &UnaryDoubleFP; #endif Added: llvm/trunk/test/Transforms/SimplifyLibCalls/exp2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyLibCalls/exp2.ll?rev=50586&view=auto ============================================================================== --- llvm/trunk/test/Transforms/SimplifyLibCalls/exp2.ll (added) +++ llvm/trunk/test/Transforms/SimplifyLibCalls/exp2.ll Fri May 2 13:43:35 2008 @@ -0,0 +1,38 @@ +; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | grep {call.*ldexp} | count 4 +; rdar://5852514 + +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" +target triple = "i386-apple-darwin8" + +define double @t1(i32 %x) nounwind { +entry: + %tmp12 = sitofp i32 %x to double ; [#uses=1] + %exp2 = tail call double @exp2( double %tmp12 ) ; [#uses=1] + ret double %exp2 +} + +define float @t4(i8 zeroext %x) nounwind { +entry: + %tmp12 = uitofp i8 %x to float ; [#uses=1] + %tmp3 = tail call float @exp2f( float %tmp12 ) nounwind readonly ; [#uses=1] + ret float %tmp3 +} + +declare float @exp2f(float) nounwind readonly + +define double @t3(i16 zeroext %x) nounwind { +entry: + %tmp12 = uitofp i16 %x to double ; [#uses=1] + %exp2 = tail call double @exp2( double %tmp12 ) ; [#uses=1] + ret double %exp2 +} + +define double @t2(i16 signext %x) nounwind { +entry: + %tmp12 = sitofp i16 %x to double ; [#uses=1] + %exp2 = tail call double @exp2( double %tmp12 ) ; [#uses=1] + ret double %exp2 +} + +declare double @exp2(double) + From monping at apple.com Fri May 2 13:58:03 2008 From: monping at apple.com (Mon P Wang) Date: Fri, 2 May 2008 11:58:03 -0700 Subject: [llvm-commits] atomic operator patch In-Reply-To: <504C1329-8389-4EEF-8A92-9A4DEE6520A5@apple.com> References: <74859BF3-9BE5-4418-8482-7AC4171E565B@apple.com> <504C1329-8389-4EEF-8A92-9A4DEE6520A5@apple.com> Message-ID: Thanks for all the helpful comments. I have fixed and cleanup the code for the atomic operator patch. I have changed the code to use cmpxchg and to loop if the value we read has been altered before the write. Please let me know if you have any further comments. Thanks, -- Mon Ping -------------- next part -------------- A non-text attachment was scrubbed... Name: atomic_op.patch Type: application/octet-stream Size: 37365 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20080502/3f3038eb/attachment.obj -------------- next part -------------- From evan.cheng at apple.com Fri May 2 16:15:08 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 02 May 2008 21:15:08 -0000 Subject: [llvm-commits] [llvm] r50590 - in /llvm/trunk: include/llvm/ADT/APInt.h lib/Support/APFloat.cpp lib/Support/APInt.cpp Message-ID: <200805022115.m42LF9cC009209@zion.cs.uiuc.edu> Author: evancheng Date: Fri May 2 16:15:08 2008 New Revision: 50590 URL: http://llvm.org/viewvc/llvm-project?rev=50590&view=rev Log: Suppress -Wshorten-64-to-32 warnings for 64-bit hosts. Modified: llvm/trunk/include/llvm/ADT/APInt.h llvm/trunk/lib/Support/APFloat.cpp llvm/trunk/lib/Support/APInt.cpp Modified: llvm/trunk/include/llvm/ADT/APInt.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/APInt.h?rev=50590&r1=50589&r2=50590&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/APInt.h (original) +++ llvm/trunk/include/llvm/ADT/APInt.h Fri May 2 16:15:08 2008 @@ -31,7 +31,8 @@ typedef uint64_t integerPart; const unsigned int host_char_bit = 8; - const unsigned int integerPartWidth = host_char_bit * sizeof(integerPart); + const unsigned int integerPartWidth = host_char_bit * + static_cast(sizeof(integerPart)); //===----------------------------------------------------------------------===// // APInt Class @@ -76,8 +77,10 @@ /// This enum is used to hold the constants we needed for APInt. enum { - APINT_BITS_PER_WORD = sizeof(uint64_t) * 8, ///< Bits in a word - APINT_WORD_SIZE = sizeof(uint64_t) ///< Byte size of a word + /// Bits in a word + APINT_BITS_PER_WORD = static_cast(sizeof(uint64_t)) * 8, + /// Byte size of a word + APINT_WORD_SIZE = static_cast(sizeof(uint64_t)) }; /// This constructor is used only internally for speed of construction of Modified: llvm/trunk/lib/Support/APFloat.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APFloat.cpp?rev=50590&r1=50589&r2=50590&view=diff ============================================================================== --- llvm/trunk/lib/Support/APFloat.cpp (original) +++ llvm/trunk/lib/Support/APFloat.cpp Fri May 2 16:15:08 2008 @@ -163,9 +163,9 @@ static int totalExponent(const char *p, int exponentAdjustment) { - integerPart unsignedExponent; + int unsignedExponent; bool negative, overflow; - long exponent; + int exponent; /* Move past the exponent letter and sign to the digits. */ p++; @@ -280,9 +280,10 @@ while (*p == '.'); /* Adjust the exponents for any decimal point. */ - D->exponent += (dot - p) - (dot > p); - D->normalizedExponent = (D->exponent + (p - D->firstSigDigit) - - (dot > D->firstSigDigit && dot < p)); + D->exponent += static_cast((dot - p) - (dot > p)); + D->normalizedExponent = (D->exponent + + static_cast((p - D->firstSigDigit) + - (dot > D->firstSigDigit && dot < p))); } D->lastSigDigit = p; @@ -2002,7 +2003,7 @@ firstSignificantDigit = p; for(;;) { - integerPart hex_value; + unsigned int hex_value; if(*p == '.') { assert(dot == 0); @@ -2043,7 +2044,7 @@ /* Calculate the exponent adjustment implicit in the number of significant digits. */ - expAdjustment = dot - firstSignificantDigit; + expAdjustment = static_cast(dot - firstSignificantDigit); if(expAdjustment < 0) expAdjustment++; expAdjustment = expAdjustment * 4 - 1; @@ -2097,7 +2098,8 @@ decSig.exponent += exp; lostFraction calcLostFraction; - integerPart HUerr, HUdistance, powHUerr; + integerPart HUerr, HUdistance; + unsigned int powHUerr; if (exp >= 0) { /* multiplySignificand leaves the precision-th bit set to 1. */ @@ -2113,7 +2115,7 @@ excessPrecision = calcSemantics.precision; } /* Extra half-ulp lost in reciprocal of exponent. */ - powHUerr = (powStatus == opOK && calcLostFraction == lfExactlyZero) ? 0: 2; + powHUerr = (powStatus == opOK && calcLostFraction == lfExactlyZero) ? 0:2; } /* Both multiplySignificand and divideSignificand return the @@ -2190,7 +2192,7 @@ N-digit decimal integer is N * 196 / 59. Allocate enough space to hold the full significand, and an extra part required by tcMultiplyPart. */ - partCount = (D.lastSigDigit - D.firstSigDigit) + 1; + partCount = static_cast(D.lastSigDigit - D.firstSigDigit) + 1; partCount = partCountForBits(1 + 196 * partCount / 59); decSignificand = new integerPart[partCount + 1]; partCount = 0; @@ -2320,7 +2322,7 @@ *dst = 0; - return dst - p; + return static_cast(dst - p); } /* Does the hard work of outputting the correctly rounded hexadecimal @@ -2443,7 +2445,7 @@ uint32_t hash = sign<<11 | semantics->precision | exponent<<12; const integerPart* p = significandParts(); for (int i=partCount(); i>0; i--, p++) - hash ^= ((uint32_t)*p) ^ (*p)>>32; + hash ^= ((uint32_t)*p) ^ (uint32_t)((*p)>>32); return hash; } } @@ -2483,8 +2485,8 @@ } uint64_t words[2]; - words[0] = (((uint64_t)sign & 1) << 63) | - ((myexponent & 0x7fff) << 48) | + words[0] = ((uint64_t)(sign & 1) << 63) | + ((myexponent & 0x7fffLL) << 48) | ((mysignificand >>16) & 0xffffffffffffLL); words[1] = mysignificand & 0xffff; return APInt(80, 2, words); @@ -2526,10 +2528,10 @@ } uint64_t words[2]; - words[0] = (((uint64_t)sign & 1) << 63) | + words[0] = ((uint64_t)(sign & 1) << 63) | ((myexponent & 0x7ff) << 52) | (mysignificand & 0xfffffffffffffLL); - words[1] = (((uint64_t)sign2 & 1) << 63) | + words[1] = ((uint64_t)(sign2 & 1) << 63) | ((myexponent2 & 0x7ff) << 52) | (mysignificand2 & 0xfffffffffffffLL); return APInt(128, 2, words); @@ -2560,7 +2562,7 @@ mysignificand = *significandParts(); } - return APInt(64, (((((uint64_t)sign & 1) << 63) | + return APInt(64, ((((uint64_t)(sign & 1) << 63) | ((myexponent & 0x7ff) << 52) | (mysignificand & 0xfffffffffffffLL)))); } @@ -2575,7 +2577,7 @@ if (category==fcNormal) { myexponent = exponent+127; //bias - mysignificand = *significandParts(); + mysignificand = (uint32_t)*significandParts(); if (myexponent == 1 && !(mysignificand & 0x800000)) myexponent = 0; // denormal } else if (category==fcZero) { @@ -2587,7 +2589,7 @@ } else { assert(category == fcNaN && "Unknown category!"); myexponent = 0xff; - mysignificand = *significandParts(); + mysignificand = (uint32_t)*significandParts(); } return APInt(32, (((sign&1) << 31) | ((myexponent&0xff) << 23) | @@ -2649,7 +2651,7 @@ initialize(&APFloat::x87DoubleExtended); assert(partCount()==2); - sign = i1>>63; + sign = static_cast(i1>>63); if (myexponent==0 && mysignificand==0) { // exponent, significand meaningless category = fcZero; @@ -2685,8 +2687,8 @@ initialize(&APFloat::PPCDoubleDouble); assert(partCount()==2); - sign = i1>>63; - sign2 = i2>>63; + sign = static_cast(i1>>63); + sign2 = static_cast(i2>>63); if (myexponent==0 && mysignificand==0) { // exponent, significand meaningless // exponent2 and significand2 are required to be 0; we don't check @@ -2732,7 +2734,7 @@ initialize(&APFloat::IEEEdouble); assert(partCount()==1); - sign = i>>63; + sign = static_cast(i>>63); if (myexponent==0 && mysignificand==0) { // exponent, significand meaningless category = fcZero; Modified: llvm/trunk/lib/Support/APInt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APInt.cpp?rev=50590&r1=50589&r2=50590&view=diff ============================================================================== --- llvm/trunk/lib/Support/APInt.cpp (original) +++ llvm/trunk/lib/Support/APInt.cpp Fri May 2 16:15:08 2008 @@ -99,7 +99,7 @@ assert(BitWidth >= MIN_INT_BITS && "bitwidth too small"); assert(BitWidth <= MAX_INT_BITS && "bitwidth too large"); assert(!Val.empty() && "String empty?"); - fromString(numbits, Val.c_str(), Val.size(), radix); + fromString(numbits, Val.c_str(), (uint32_t)Val.size(), radix); } APInt::APInt(const APInt& that) @@ -905,7 +905,7 @@ // Otherwise, we have to shift the mantissa bits up to the right location APInt Tmp(width, mantissa); - Tmp = Tmp.shl(exp - 52); + Tmp = Tmp.shl((uint32_t)exp - 52); return isNeg ? -Tmp : Tmp; } @@ -1086,7 +1086,7 @@ /// Arithmetic right-shift this APInt by shiftAmt. /// @brief Arithmetic right-shift function. APInt APInt::ashr(const APInt &shiftAmt) const { - return ashr(shiftAmt.getLimitedValue(BitWidth)); + return ashr((uint32_t)shiftAmt.getLimitedValue(BitWidth)); } /// Arithmetic right-shift this APInt by shiftAmt. @@ -1175,7 +1175,7 @@ /// Logical right-shift this APInt by shiftAmt. /// @brief Logical right-shift function. APInt APInt::lshr(const APInt &shiftAmt) const { - return lshr(shiftAmt.getLimitedValue(BitWidth)); + return lshr((uint32_t)shiftAmt.getLimitedValue(BitWidth)); } /// Logical right-shift this APInt by shiftAmt. @@ -1244,7 +1244,7 @@ /// @brief Left-shift function. APInt APInt::shl(const APInt &shiftAmt) const { // It's undefined behavior in C to shift by BitWidth or greater, but - return shl(shiftAmt.getLimitedValue(BitWidth)); + return shl((uint32_t)shiftAmt.getLimitedValue(BitWidth)); } /// Left-shift this APInt by shiftAmt. @@ -1307,7 +1307,7 @@ } APInt APInt::rotl(const APInt &rotateAmt) const { - return rotl(rotateAmt.getLimitedValue(BitWidth)); + return rotl((uint32_t)rotateAmt.getLimitedValue(BitWidth)); } APInt APInt::rotl(uint32_t rotateAmt) const { @@ -1322,7 +1322,7 @@ } APInt APInt::rotr(const APInt &rotateAmt) const { - return rotr(rotateAmt.getLimitedValue(BitWidth)); + return rotr((uint32_t)rotateAmt.getLimitedValue(BitWidth)); } APInt APInt::rotr(uint32_t rotateAmt) const { @@ -1517,8 +1517,8 @@ uint64_t result = u_tmp - subtrahend; uint32_t k = j + i; - u[k++] = result & (b-1); // subtract low word - u[k++] = result >> 32; // subtract high word + u[k++] = (uint32_t)(result & (b-1)); // subtract low word + u[k++] = (uint32_t)(result >> 32); // subtract high word while (borrow && k <= m+n) { // deal with borrow to the left borrow = u[k] == 0; u[k]--; @@ -1549,7 +1549,7 @@ // D5. [Test remainder.] Set q[j] = qp. If the result of step D4 was // negative, go to step D6; otherwise go on to step D7. - q[j] = qp; + q[j] = (uint32_t)qp; if (isNeg) { // D6. [Add back]. The probability that this step is necessary is very // small, on the order of only 2/b. Make sure that test data accounts for @@ -1645,8 +1645,8 @@ memset(U, 0, (m+n+1)*sizeof(uint32_t)); for (unsigned i = 0; i < lhsWords; ++i) { uint64_t tmp = (LHS.getNumWords() == 1 ? LHS.VAL : LHS.pVal[i]); - U[i * 2] = tmp & mask; - U[i * 2 + 1] = tmp >> (sizeof(uint32_t)*8); + U[i * 2] = (uint32_t)(tmp & mask); + U[i * 2 + 1] = (uint32_t)(tmp >> (sizeof(uint32_t)*8)); } U[m+n] = 0; // this extra word is for "spill" in the Knuth algorithm. @@ -1654,8 +1654,8 @@ memset(V, 0, (n)*sizeof(uint32_t)); for (unsigned i = 0; i < rhsWords; ++i) { uint64_t tmp = (RHS.getNumWords() == 1 ? RHS.VAL : RHS.pVal[i]); - V[i * 2] = tmp & mask; - V[i * 2 + 1] = tmp >> (sizeof(uint32_t)*8); + V[i * 2] = (uint32_t)(tmp & mask); + V[i * 2 + 1] = (uint32_t)(tmp >> (sizeof(uint32_t)*8)); } // initialize the quotient and remainder @@ -1691,13 +1691,13 @@ remainder = 0; } else if (partial_dividend < divisor) { Q[i] = 0; - remainder = partial_dividend; + remainder = (uint32_t)partial_dividend; } else if (partial_dividend == divisor) { Q[i] = 1; remainder = 0; } else { - Q[i] = partial_dividend / divisor; - remainder = partial_dividend - (Q[i] * divisor); + Q[i] = (uint32_t)(partial_dividend / divisor); + remainder = (uint32_t)(partial_dividend - (Q[i] * divisor)); } } if (R) @@ -1991,7 +1991,7 @@ memset(buf, 0, 65); uint64_t v = VAL; while (bits_used) { - uint32_t bit = v & 1; + uint32_t bit = (uint32_t)v & 1; bits_used--; buf[bits_used] = digits[bit][0]; v >>=1; @@ -2026,7 +2026,8 @@ uint64_t mask = radix - 1; APInt zero(tmp.getBitWidth(), 0); while (tmp.ne(zero)) { - unsigned digit = (tmp.isSingleWord() ? tmp.VAL : tmp.pVal[0]) & mask; + unsigned digit = + (unsigned)((tmp.isSingleWord() ? tmp.VAL : tmp.pVal[0]) & mask); result.insert(insert_at, digits[digit]); tmp = tmp.lshr(shift); } @@ -2054,7 +2055,7 @@ APInt tmp2(tmp.getBitWidth(), 0); divide(tmp, tmp.getNumWords(), divisor, divisor.getNumWords(), &tmp2, &APdigit); - uint32_t digit = APdigit.getZExtValue(); + uint32_t digit = (uint32_t)APdigit.getZExtValue(); assert(digit < radix && "divide failed"); result.insert(insert_at,digits[digit]); tmp = tmp2; From gohman at apple.com Fri May 2 16:30:02 2008 From: gohman at apple.com (Dan Gohman) Date: Fri, 02 May 2008 21:30:02 -0000 Subject: [llvm-commits] [llvm] r50591 - in /llvm/trunk: lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/udiv-simplify-bug-0.ll test/Transforms/InstCombine/udiv-simplify-bug-1.ll Message-ID: <200805022130.m42LU3ve009846@zion.cs.uiuc.edu> Author: djg Date: Fri May 2 16:30:02 2008 New Revision: 50591 URL: http://llvm.org/viewvc/llvm-project?rev=50591&view=rev Log: Fix a mistake in the computation of leading zeros for udiv. Added: llvm/trunk/test/Transforms/InstCombine/udiv-simplify-bug-0.ll llvm/trunk/test/Transforms/InstCombine/udiv-simplify-bug-1.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=50591&r1=50590&r2=50591&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Fri May 2 16:30:02 2008 @@ -1257,7 +1257,7 @@ case ISD::UDIV: { // For the purposes of computing leading zeros we can conservatively // treat a udiv as a logical right shift by the power of 2 known to - // be greater than the denominator. + // be less than the denominator. APInt AllOnes = APInt::getAllOnesValue(BitWidth); ComputeMaskedBits(Op.getOperand(0), AllOnes, KnownZero2, KnownOne2, Depth+1); @@ -1267,8 +1267,10 @@ KnownZero2.clear(); ComputeMaskedBits(Op.getOperand(1), AllOnes, KnownZero2, KnownOne2, Depth+1); - LeadZ = std::min(BitWidth, - LeadZ + BitWidth - KnownOne2.countLeadingZeros()); + unsigned RHSUnknownLeadingOnes = KnownOne2.countLeadingZeros(); + if (RHSUnknownLeadingOnes != BitWidth) + LeadZ = std::min(BitWidth, + LeadZ + BitWidth - RHSUnknownLeadingOnes - 1); KnownZero = APInt::getHighBitsSet(BitWidth, LeadZ) & Mask; return; Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=50591&r1=50590&r2=50591&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Fri May 2 16:30:02 2008 @@ -780,7 +780,7 @@ case Instruction::UDiv: { // For the purposes of computing leading zeros we can conservatively // treat a udiv as a logical right shift by the power of 2 known to - // be greater than the denominator. + // be less than the denominator. APInt AllOnes = APInt::getAllOnesValue(BitWidth); ComputeMaskedBits(I->getOperand(0), AllOnes, KnownZero2, KnownOne2, Depth+1); @@ -790,8 +790,10 @@ KnownZero2.clear(); ComputeMaskedBits(I->getOperand(1), AllOnes, KnownZero2, KnownOne2, Depth+1); - LeadZ = std::min(BitWidth, - LeadZ + BitWidth - KnownOne2.countLeadingZeros()); + unsigned RHSUnknownLeadingOnes = KnownOne2.countLeadingZeros(); + if (RHSUnknownLeadingOnes != BitWidth) + LeadZ = std::min(BitWidth, + LeadZ + BitWidth - RHSUnknownLeadingOnes - 1); KnownZero = APInt::getHighBitsSet(BitWidth, LeadZ) & Mask; return; Added: llvm/trunk/test/Transforms/InstCombine/udiv-simplify-bug-0.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/udiv-simplify-bug-0.ll?rev=50591&view=auto ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/udiv-simplify-bug-0.ll (added) +++ llvm/trunk/test/Transforms/InstCombine/udiv-simplify-bug-0.ll Fri May 2 16:30:02 2008 @@ -0,0 +1,14 @@ +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {ret i64 0} | count 2 + +define i64 @foo(i32 %x) nounwind { + %y = lshr i32 %x, 1 + %r = udiv i32 %y, -1 + %z = sext i32 %r to i64 + ret i64 %z +} +define i64 @bar(i32 %x) nounwind { + %y = lshr i32 %x, 31 + %r = udiv i32 %y, 3 + %z = sext i32 %r to i64 + ret i64 %z +} Added: llvm/trunk/test/Transforms/InstCombine/udiv-simplify-bug-1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/udiv-simplify-bug-1.ll?rev=50591&view=auto ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/udiv-simplify-bug-1.ll (added) +++ llvm/trunk/test/Transforms/InstCombine/udiv-simplify-bug-1.ll Fri May 2 16:30:02 2008 @@ -0,0 +1,25 @@ +; RUN: llvm-as < %s | opt -instcombine | llvm-dis > %t1.ll +; RUN: grep udiv %t1.ll | count 3 +; RUN: grep zext %t1.ll | count 3 +; PR2274 + +; The udiv instructions shouldn't be optimized away, and the +; sext instructions should be optimized to zext. + +define i64 @foo(i32 %x) nounwind { + %r = udiv i32 %x, -1 + %z = sext i32 %r to i64 + ret i64 %z +} +define i64 @bar(i32 %x) nounwind { + %y = lshr i32 %x, 30 + %r = udiv i32 %y, 3 + %z = sext i32 %r to i64 + ret i64 %z +} +define i64 @qux(i32 %x, i32 %v) nounwind { + %y = lshr i32 %x, 31 + %r = udiv i32 %y, %v + %z = sext i32 %r to i64 + ret i64 %z +} From sabre at nondot.org Fri May 2 17:05:07 2008 From: sabre at nondot.org (Chris Lattner) Date: Fri, 02 May 2008 22:05:07 -0000 Subject: [llvm-commits] [llvm] r50593 - /llvm/trunk/tools/opt/opt.cpp Message-ID: <200805022205.m42M57UG010950@zion.cs.uiuc.edu> Author: lattner Date: Fri May 2 17:05:06 2008 New Revision: 50593 URL: http://llvm.org/viewvc/llvm-project?rev=50593&view=rev Log: move libcalls to the same place llvm-gcc has it. Modified: llvm/trunk/tools/opt/opt.cpp Modified: llvm/trunk/tools/opt/opt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=50593&r1=50592&r2=50593&view=diff ============================================================================== --- llvm/trunk/tools/opt/opt.cpp (original) +++ llvm/trunk/tools/opt/opt.cpp Fri May 2 17:05:06 2008 @@ -262,10 +262,10 @@ if (!DisableInline) addPass(PM, createFunctionInliningPass()); // Inline small functions - addPass(PM, createSimplifyLibCallsPass()); // Library Call Optimizations addPass(PM, createArgumentPromotionPass()); // Scalarize uninlined fn args addPass(PM, createTailDuplicationPass()); // Simplify cfg by copying code + addPass(PM, createSimplifyLibCallsPass()); // Library Call Optimizations addPass(PM, createInstructionCombiningPass()); // Cleanup for scalarrepl. addPass(PM, createJumpThreadingPass()); // Thread jumps. addPass(PM, createCFGSimplificationPass()); // Merge & remove BBs From sabre at nondot.org Fri May 2 17:07:35 2008 From: sabre at nondot.org (Chris Lattner) Date: Fri, 02 May 2008 22:07:35 -0000 Subject: [llvm-commits] [llvm] r50594 - /llvm/trunk/test/CFrontend/libcalls.c Message-ID: <200805022207.m42M7ZS3011025@zion.cs.uiuc.edu> Author: lattner Date: Fri May 2 17:07:34 2008 New Revision: 50594 URL: http://llvm.org/viewvc/llvm-project?rev=50594&view=rev Log: verify builtin optimization works like gcc. Added: llvm/trunk/test/CFrontend/libcalls.c Added: llvm/trunk/test/CFrontend/libcalls.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CFrontend/libcalls.c?rev=50594&view=auto ============================================================================== --- llvm/trunk/test/CFrontend/libcalls.c (added) +++ llvm/trunk/test/CFrontend/libcalls.c Fri May 2 17:07:34 2008 @@ -0,0 +1,10 @@ +// llvm-gcc -O1+ should run simplify libcalls, O0 shouldn't +// and -fno-builtins shouldn't. +// RUN: %llvmgcc %s -S -emit-llvm -O0 -o - | grep {call.*exp2f} +// RUN: %llvmgcc %s -S -emit-llvm -O1 -o - | grep {call.*ldexp} +// RUN: %llvmgcc %s -S -emit-llvm -O3 -fno-builtin -o - | grep {call.*exp2f} + +float t4(unsigned char x) { + return exp2f(x); +} + From sabre at nondot.org Fri May 2 17:08:18 2008 From: sabre at nondot.org (Chris Lattner) Date: Fri, 02 May 2008 22:08:18 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50595 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Message-ID: <200805022208.m42M8IhI011052@zion.cs.uiuc.edu> Author: lattner Date: Fri May 2 17:08:18 2008 New Revision: 50595 URL: http://llvm.org/viewvc/llvm-project?rev=50595&view=rev Log: run simplify libcalls later and at -O1 now that it is a functionpass. Testcase here: test/CFrontend/libcalls.c Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=50595&r1=50594&r2=50595&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Fri May 2 17:08:18 2008 @@ -350,8 +350,6 @@ PM->add(createDeadArgEliminationPass()); // Dead argument elimination } PM->add(createInstructionCombiningPass()); // Clean up after IPCP & DAE - // DISABLE PREDSIMPLIFY UNTIL PR967 is fixed. - //PM->add(createPredicateSimplifierPass()); // Canonicalize registers PM->add(createCFGSimplificationPass()); // Clean up after IPCP & DAE if (flag_unit_at_a_time && flag_exceptions) PM->add(createPruneEHPass()); // Remove dead EH info @@ -359,14 +357,13 @@ if (optimize > 1) { if (flag_inline_trees > 1) // respect -fno-inline-functions PM->add(createFunctionInliningPass()); // Inline small functions - if (flag_unit_at_a_time && !lang_hooks.flag_no_builtin()) - PM->add(createSimplifyLibCallsPass()); // Library Call Optimizations - if (optimize > 2) PM->add(createArgumentPromotionPass()); // Scalarize uninlined fn args } PM->add(createTailDuplicationPass()); // Simplify cfg by copying code + if (!lang_hooks.flag_no_builtin()) + PM->add(createSimplifyLibCallsPass()); // Library Call Optimizations PM->add(createInstructionCombiningPass()); // Cleanup for scalarrepl. PM->add(createJumpThreadingPass()); // Thread jumps. PM->add(createCFGSimplificationPass()); // Merge & remove BBs From gohman at apple.com Fri May 2 17:10:02 2008 From: gohman at apple.com (Dan Gohman) Date: Fri, 2 May 2008 15:10:02 -0700 Subject: [llvm-commits] atomic operator patch In-Reply-To: References: <74859BF3-9BE5-4418-8482-7AC4171E565B@apple.com> <504C1329-8389-4EEF-8A92-9A4DEE6520A5@apple.com> Message-ID: Hi Mon Ping, This patch looks good to me. I just have a few minor comments. In lib/Target/X86/X86ISelLowering.cpp: + // Move all successors to thisMBB to nextMBB + for(MachineBasicBlock::succ_iterator iter = thisMBB->succ_begin(), + end = thisMBB->succ_end(); iter != end; ++iter) { + nextMBB->addSuccessor(*iter); + } + + // Update thisMBB to fall through to newMBB + while(!thisMBB->succ_empty()) + thisMBB->removeSuccessor(thisMBB->succ_begin()); Transferring all the successors from one block to another is a fairly common task. Could you add a utility routine to MachineBasicBlock to do this? + // newBB jumps to itself and fall through to next bb + newMBB->addSuccessor(nextMBB); Typo; the comment should say newMBB. Thanks, Dan On May 2, 2008, at 11:58 AM, Mon P Wang wrote: > > Thanks for all the helpful comments. I have fixed and cleanup the > code for the atomic operator patch. I have changed the code to use > cmpxchg and to loop if the value we read has been altered before the > write. Please let me know if you have any further comments. > > Thanks, > -- Mon Ping > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From dpatel at apple.com Fri May 2 17:13:33 2008 From: dpatel at apple.com (Devang Patel) Date: Fri, 02 May 2008 22:13:33 -0000 Subject: [llvm-commits] [llvm] r50596 - /llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp Message-ID: <200805022213.m42MDXxC011251@zion.cs.uiuc.edu> Author: dpatel Date: Fri May 2 17:13:33 2008 New Revision: 50596 URL: http://llvm.org/viewvc/llvm-project?rev=50596&view=rev Log: Add assert. Modified: llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp Modified: llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp?rev=50596&r1=50595&r2=50596&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp (original) +++ llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp Fri May 2 17:13:33 2008 @@ -158,6 +158,7 @@ PMS.top()->getPassManagerType() > PMT_CallGraphPassManager) PMS.pop(); + assert (!PMS.empty() && "Unable to handle Call Graph Pass"); CGPassManager *CGP = dynamic_cast(PMS.top()); // Create new Call Graph SCC Pass Manager if it does not exist. From monping at apple.com Fri May 2 18:03:33 2008 From: monping at apple.com (Mon P Wang) Date: Fri, 2 May 2008 16:03:33 -0700 Subject: [llvm-commits] atomic operator patch In-Reply-To: References: <74859BF3-9BE5-4418-8482-7AC4171E565B@apple.com> <504C1329-8389-4EEF-8A92-9A4DEE6520A5@apple.com> Message-ID: <9418D37E-0350-4CD0-895D-1F7DD167F60A@apple.com> Hi Dan, Adding this utility function sounds like a good idea to me. I'll add it to MachineBasicBlock as transferSuccessors. -- Mon Ping On May 2, 2008, at 3:10 PM, Dan Gohman wrote: > Hi Mon Ping, > > This patch looks good to me. I just have a few minor comments. > > In lib/Target/X86/X86ISelLowering.cpp: > > + // Move all successors to thisMBB to nextMBB > + for(MachineBasicBlock::succ_iterator iter = thisMBB->succ_begin(), > + end = thisMBB->succ_end(); iter != end; ++iter) { > + nextMBB->addSuccessor(*iter); > + } > + > + // Update thisMBB to fall through to newMBB > + while(!thisMBB->succ_empty()) > + thisMBB->removeSuccessor(thisMBB->succ_begin()); > > Transferring all the successors from one block to another is > a fairly common task. Could you add a utility routine to > MachineBasicBlock to do this? > > + // newBB jumps to itself and fall through to next bb > + newMBB->addSuccessor(nextMBB); > > Typo; the comment should say newMBB. > > Thanks, > > Dan > > On May 2, 2008, at 11:58 AM, Mon P Wang wrote: > >> >> Thanks for all the helpful comments. I have fixed and cleanup the >> code for the atomic operator patch. I have changed the code to use >> cmpxchg and to loop if the value we read has been altered before the >> write. Please let me know if you have any further comments. >> >> Thanks, >> -- Mon Ping >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From gabor at mac.com Fri May 2 18:41:47 2008 From: gabor at mac.com (Gabor Greif) Date: Sat, 3 May 2008 01:41:47 +0200 Subject: [llvm-commits] [PATCH] for review: use-diet Message-ID: <63E74B02-F4E7-4E94-B03B-3B0266BE278D@mac.com> Hi all, I am sending this to llvm-commits this time, not wanting to bother everybody with technical details any more. I have worked in most of the comments from and The only thing on my agenda is making the templated function Op() protected, thus removing it from the public interface. Happy reviewing! Gabor -------------- next part -------------- A non-text attachment was scrubbed... Name: use-diet-patch-0205.diff Type: application/octet-stream Size: 137466 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20080503/ab51af59/attachment.obj -------------- next part -------------- From dpatel at apple.com Fri May 2 19:34:18 2008 From: dpatel at apple.com (Devang Patel) Date: Sat, 03 May 2008 00:34:18 -0000 Subject: [llvm-commits] [llvm] r50599 - /llvm/branches/Apple/Tak/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200805030034.m430YIX6015818@zion.cs.uiuc.edu> Author: dpatel Date: Fri May 2 19:34:18 2008 New Revision: 50599 URL: http://llvm.org/viewvc/llvm-project?rev=50599&view=rev Log: Do not sink getresult. Modified: llvm/branches/Apple/Tak/lib/Transforms/Scalar/InstructionCombining.cpp Modified: llvm/branches/Apple/Tak/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Tak/lib/Transforms/Scalar/InstructionCombining.cpp?rev=50599&r1=50598&r2=50599&view=diff ============================================================================== --- llvm/branches/Apple/Tak/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/branches/Apple/Tak/lib/Transforms/Scalar/InstructionCombining.cpp Fri May 2 19:34:18 2008 @@ -11279,7 +11279,9 @@ } // See if we can trivially sink this instruction to a successor basic block. - if (I->hasOneUse()) { + // FIXME: Remove GetREsultInst test when first class support for aggregates is + // implemented. + if (I->hasOneUse() && !isa(I)) { BasicBlock *BB = I->getParent(); BasicBlock *UserParent = cast(I->use_back())->getParent(); if (UserParent != BB) { From dpatel at apple.com Fri May 2 19:36:30 2008 From: dpatel at apple.com (Devang Patel) Date: Sat, 03 May 2008 00:36:30 -0000 Subject: [llvm-commits] [llvm] r50600 - /llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200805030036.m430aUuF015909@zion.cs.uiuc.edu> Author: dpatel Date: Fri May 2 19:36:30 2008 New Revision: 50600 URL: http://llvm.org/viewvc/llvm-project?rev=50600&view=rev Log: Do not sink getresult. Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=50600&r1=50599&r2=50600&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Fri May 2 19:36:30 2008 @@ -11389,7 +11389,9 @@ } // See if we can trivially sink this instruction to a successor basic block. - if (I->hasOneUse()) { + // FIXME: Remove GetREsultInst test when first class support for aggregates is + // implemented. + if (I->hasOneUse() && !isa(I)) { BasicBlock *BB = I->getParent(); BasicBlock *UserParent = cast(I->use_back())->getParent(); if (UserParent != BB) { From evan.cheng at apple.com Fri May 2 19:52:09 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Sat, 03 May 2008 00:52:09 -0000 Subject: [llvm-commits] [llvm] r50601 - in /llvm/trunk: include/llvm/IntrinsicsX86.td lib/Target/X86/X86InstrMMX.td lib/Target/X86/X86InstrSSE.td lib/VMCore/AutoUpgrade.cpp test/CodeGen/X86/mmx-shift.ll Message-ID: <200805030052.m430qAhh016344@zion.cs.uiuc.edu> Author: evancheng Date: Fri May 2 19:52:09 2008 New Revision: 50601 URL: http://llvm.org/viewvc/llvm-project?rev=50601&view=rev Log: Add separate intrinsics for MMX / SSE shifts with i32 integer operands. This allow us to simplify the horribly complicated matching code. Modified: llvm/trunk/include/llvm/IntrinsicsX86.td llvm/trunk/lib/Target/X86/X86InstrMMX.td llvm/trunk/lib/Target/X86/X86InstrSSE.td llvm/trunk/lib/VMCore/AutoUpgrade.cpp llvm/trunk/test/CodeGen/X86/mmx-shift.ll Modified: llvm/trunk/include/llvm/IntrinsicsX86.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicsX86.td?rev=50601&r1=50600&r2=50601&view=diff ============================================================================== --- llvm/trunk/include/llvm/IntrinsicsX86.td (original) +++ llvm/trunk/include/llvm/IntrinsicsX86.td Fri May 2 19:52:09 2008 @@ -324,9 +324,6 @@ def int_x86_sse2_psll_q : GCCBuiltin<"__builtin_ia32_psllq128">, Intrinsic<[llvm_v2i64_ty, llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; - def int_x86_sse2_psll_dq : GCCBuiltin<"__builtin_ia32_pslldqi128">, - Intrinsic<[llvm_v2i64_ty, llvm_v2i64_ty, - llvm_i32_ty], [IntrNoMem]>; def int_x86_sse2_psrl_w : GCCBuiltin<"__builtin_ia32_psrlw128">, Intrinsic<[llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; @@ -336,15 +333,44 @@ def int_x86_sse2_psrl_q : GCCBuiltin<"__builtin_ia32_psrlq128">, Intrinsic<[llvm_v2i64_ty, llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; - def int_x86_sse2_psrl_dq : GCCBuiltin<"__builtin_ia32_psrldqi128">, - Intrinsic<[llvm_v2i64_ty, llvm_v2i64_ty, - llvm_i32_ty], [IntrNoMem]>; def int_x86_sse2_psra_w : GCCBuiltin<"__builtin_ia32_psraw128">, Intrinsic<[llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_x86_sse2_psra_d : GCCBuiltin<"__builtin_ia32_psrad128">, Intrinsic<[llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; + + def int_x86_sse2_pslli_w : GCCBuiltin<"__builtin_ia32_psllwi128">, + Intrinsic<[llvm_v8i16_ty, llvm_v8i16_ty, + llvm_i32_ty], [IntrNoMem]>; + def int_x86_sse2_pslli_d : GCCBuiltin<"__builtin_ia32_pslldi128">, + Intrinsic<[llvm_v4i32_ty, llvm_v4i32_ty, + llvm_i32_ty], [IntrNoMem]>; + def int_x86_sse2_pslli_q : GCCBuiltin<"__builtin_ia32_psllqi128">, + Intrinsic<[llvm_v2i64_ty, llvm_v2i64_ty, + llvm_i32_ty], [IntrNoMem]>; + def int_x86_sse2_psrli_w : GCCBuiltin<"__builtin_ia32_psrlwi128">, + Intrinsic<[llvm_v8i16_ty, llvm_v8i16_ty, + llvm_i32_ty], [IntrNoMem]>; + def int_x86_sse2_psrli_d : GCCBuiltin<"__builtin_ia32_psrldi128">, + Intrinsic<[llvm_v4i32_ty, llvm_v4i32_ty, + llvm_i32_ty], [IntrNoMem]>; + def int_x86_sse2_psrli_q : GCCBuiltin<"__builtin_ia32_psrlqi128">, + Intrinsic<[llvm_v2i64_ty, llvm_v2i64_ty, + llvm_i32_ty], [IntrNoMem]>; + def int_x86_sse2_psrai_w : GCCBuiltin<"__builtin_ia32_psrawi128">, + Intrinsic<[llvm_v8i16_ty, llvm_v8i16_ty, + llvm_i32_ty], [IntrNoMem]>; + def int_x86_sse2_psrai_d : GCCBuiltin<"__builtin_ia32_psradi128">, + Intrinsic<[llvm_v4i32_ty, llvm_v4i32_ty, + llvm_i32_ty], [IntrNoMem]>; + + def int_x86_sse2_psll_dq : GCCBuiltin<"__builtin_ia32_pslldqi128">, + Intrinsic<[llvm_v2i64_ty, llvm_v2i64_ty, + llvm_i32_ty], [IntrNoMem]>; + def int_x86_sse2_psrl_dq : GCCBuiltin<"__builtin_ia32_psrldqi128">, + Intrinsic<[llvm_v2i64_ty, llvm_v2i64_ty, + llvm_i32_ty], [IntrNoMem]>; } // Integer comparison ops @@ -939,6 +965,33 @@ def int_x86_mmx_psra_d : GCCBuiltin<"__builtin_ia32_psrad">, Intrinsic<[llvm_v2i32_ty, llvm_v2i32_ty, llvm_v1i64_ty], [IntrNoMem]>; + + def int_x86_mmx_pslli_w : GCCBuiltin<"__builtin_ia32_psllwi">, + Intrinsic<[llvm_v4i16_ty, llvm_v4i16_ty, + llvm_i32_ty], [IntrNoMem]>; + def int_x86_mmx_pslli_d : GCCBuiltin<"__builtin_ia32_pslldi">, + Intrinsic<[llvm_v2i32_ty, llvm_v2i32_ty, + llvm_i32_ty], [IntrNoMem]>; + def int_x86_mmx_pslli_q : GCCBuiltin<"__builtin_ia32_psllqi">, + Intrinsic<[llvm_v1i64_ty, llvm_v1i64_ty, + llvm_i32_ty], [IntrNoMem]>; + + def int_x86_mmx_psrli_w : GCCBuiltin<"__builtin_ia32_psrlwi">, + Intrinsic<[llvm_v4i16_ty, llvm_v4i16_ty, + llvm_i32_ty], [IntrNoMem]>; + def int_x86_mmx_psrli_d : GCCBuiltin<"__builtin_ia32_psrldi">, + Intrinsic<[llvm_v2i32_ty, llvm_v2i32_ty, + llvm_i32_ty], [IntrNoMem]>; + def int_x86_mmx_psrli_q : GCCBuiltin<"__builtin_ia32_psrlqi">, + Intrinsic<[llvm_v1i64_ty, llvm_v1i64_ty, + llvm_i32_ty], [IntrNoMem]>; + + def int_x86_mmx_psrai_w : GCCBuiltin<"__builtin_ia32_psrawi">, + Intrinsic<[llvm_v4i16_ty, llvm_v4i16_ty, + llvm_i32_ty], [IntrNoMem]>; + def int_x86_mmx_psrai_d : GCCBuiltin<"__builtin_ia32_psradi">, + Intrinsic<[llvm_v2i32_ty, llvm_v2i32_ty, + llvm_i32_ty], [IntrNoMem]>; } // Pack ops. Modified: llvm/trunk/lib/Target/X86/X86InstrMMX.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrMMX.td?rev=50601&r1=50600&r2=50601&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrMMX.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrMMX.td Fri May 2 19:52:09 2008 @@ -118,7 +118,8 @@ } multiclass MMXI_binop_rmi_int opc, bits<8> opc2, Format ImmForm, - string OpcodeStr, Intrinsic IntId> { + string OpcodeStr, Intrinsic IntId, + Intrinsic IntId2> { def rr : MMXI; + [(set VR64:$dst, (IntId2 VR64:$src1, (i32 imm:$src2)))]>; } } @@ -283,23 +280,23 @@ // Shift Instructions defm MMX_PSRLW : MMXI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw", - int_x86_mmx_psrl_w>; + int_x86_mmx_psrl_w, int_x86_mmx_psrli_w>; defm MMX_PSRLD : MMXI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld", - int_x86_mmx_psrl_d>; + int_x86_mmx_psrl_d, int_x86_mmx_psrli_d>; defm MMX_PSRLQ : MMXI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq", - int_x86_mmx_psrl_q>; + int_x86_mmx_psrl_q, int_x86_mmx_psrli_q>; defm MMX_PSLLW : MMXI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw", - int_x86_mmx_psll_w>; + int_x86_mmx_psll_w, int_x86_mmx_pslli_w>; defm MMX_PSLLD : MMXI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld", - int_x86_mmx_psll_d>; + int_x86_mmx_psll_d, int_x86_mmx_pslli_d>; defm MMX_PSLLQ : MMXI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq", - int_x86_mmx_psll_q>; + int_x86_mmx_psll_q, int_x86_mmx_pslli_q>; defm MMX_PSRAW : MMXI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw", - int_x86_mmx_psra_w>; + int_x86_mmx_psra_w, int_x86_mmx_psrai_w>; defm MMX_PSRAD : MMXI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad", - int_x86_mmx_psra_d>; + int_x86_mmx_psra_d, int_x86_mmx_psrai_d>; // Comparison Instructions defm MMX_PCMPEQB : MMXI_binop_rm_int<0x74, "pcmpeqb", int_x86_mmx_pcmpeq_b>; Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=50601&r1=50600&r2=50601&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Fri May 2 19:52:09 2008 @@ -1780,6 +1780,21 @@ (bitconvert (memopv2i64 addr:$src2))))]>; } +multiclass PDI_binop_rmi_int opc, bits<8> opc2, Format ImmForm, + string OpcodeStr, + Intrinsic IntId, Intrinsic IntId2> { + def rr : PDI; + def rm : PDI; + def ri : PDIi8; +} + /// PDI_binop_rm - Simple SSE2 binary operator. multiclass PDI_binop_rm opc, string OpcodeStr, SDNode OpNode, ValueType OpVT, bit Commutable = 0> { @@ -1854,64 +1869,24 @@ defm PSADBW : PDI_binop_rm_int<0xE0, "psadbw", int_x86_sse2_psad_bw, 1>; -defm PSLLW : PDI_binop_rm_int<0xF1, "psllw", int_x86_sse2_psll_w>; -defm PSLLD : PDI_binop_rm_int<0xF2, "pslld", int_x86_sse2_psll_d>; -defm PSLLQ : PDI_binop_rm_int<0xF3, "psllq", int_x86_sse2_psll_q>; - -defm PSRLW : PDI_binop_rm_int<0xD1, "psrlw", int_x86_sse2_psrl_w>; -defm PSRLD : PDI_binop_rm_int<0xD2, "psrld", int_x86_sse2_psrl_d>; -defm PSRLQ : PDI_binop_rm_int<0xD3, "psrlq", int_x86_sse2_psrl_q>; - -defm PSRAW : PDI_binop_rm_int<0xE1, "psraw", int_x86_sse2_psra_w>; -defm PSRAD : PDI_binop_rm_int<0xE2, "psrad", int_x86_sse2_psra_d>; - -// Some immediate variants need to match a bit_convert. -let Constraints = "$src1 = $dst" in { -def PSLLWri : PDIi8<0x71, MRM6r, (outs VR128:$dst), - (ins VR128:$src1, i32i8imm:$src2), - "psllw\t{$src2, $dst|$dst, $src2}", - [(set VR128:$dst, (int_x86_sse2_psll_w VR128:$src1, - (bc_v8i16 (v4i32 (scalar_to_vector (i32 imm:$src2))))))]>; -def PSLLDri : PDIi8<0x72, MRM6r, (outs VR128:$dst), - (ins VR128:$src1, i32i8imm:$src2), - "pslld\t{$src2, $dst|$dst, $src2}", - [(set VR128:$dst, (int_x86_sse2_psll_d VR128:$src1, - (scalar_to_vector (i32 imm:$src2))))]>; -def PSLLQri : PDIi8<0x73, MRM6r, (outs VR128:$dst), - (ins VR128:$src1, i32i8imm:$src2), - "psllq\t{$src2, $dst|$dst, $src2}", - [(set VR128:$dst, (int_x86_sse2_psll_q VR128:$src1, - (bc_v2i64 (v4i32 (scalar_to_vector (i32 imm:$src2))))))]>; - -def PSRLWri : PDIi8<0x71, MRM2r, (outs VR128:$dst), - (ins VR128:$src1, i32i8imm:$src2), - "psrlw\t{$src2, $dst|$dst, $src2}", - [(set VR128:$dst, (int_x86_sse2_psrl_w VR128:$src1, - (bc_v8i16 (v4i32 (scalar_to_vector (i32 imm:$src2))))))]>; -def PSRLDri : PDIi8<0x72, MRM2r, (outs VR128:$dst), - (ins VR128:$src1, i32i8imm:$src2), - "psrld\t{$src2, $dst|$dst, $src2}", - [(set VR128:$dst, (int_x86_sse2_psrl_d VR128:$src1, - (scalar_to_vector (i32 imm:$src2))))]>; -def PSRLQri : PDIi8<0x73, MRM2r, (outs VR128:$dst), - (ins VR128:$src1, i32i8imm:$src2), - "psrlq\t{$src2, $dst|$dst, $src2}", - [(set VR128:$dst, (int_x86_sse2_psrl_q VR128:$src1, - (bc_v2i64 (v4i32 (scalar_to_vector (i32 imm:$src2))))))]>; - -def PSRAWri : PDIi8<0x71, MRM4r, (outs VR128:$dst), - (ins VR128:$src1, i32i8imm:$src2), - "psraw\t{$src2, $dst|$dst, $src2}", - [(set VR128:$dst, (int_x86_sse2_psra_w VR128:$src1, - (bc_v8i16 (v4i32 (scalar_to_vector (i32 imm:$src2))))))]>; -def PSRADri : PDIi8<0x72, MRM4r, (outs VR128:$dst), - (ins VR128:$src1, i32i8imm:$src2), - "psrad\t{$src2, $dst|$dst, $src2}", - [(set VR128:$dst, (int_x86_sse2_psra_d VR128:$src1, - (scalar_to_vector (i32 imm:$src2))))]>; -} - -// PSRAQ doesn't exist in SSE[1-3]. +defm PSLLW : PDI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw", + int_x86_sse2_psll_w, int_x86_sse2_pslli_w>; +defm PSLLD : PDI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld", + int_x86_sse2_psll_d, int_x86_sse2_pslli_d>; +defm PSLLQ : PDI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq", + int_x86_sse2_psll_q, int_x86_sse2_pslli_q>; + +defm PSRLW : PDI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw", + int_x86_sse2_psrl_w, int_x86_sse2_psrli_w>; +defm PSRLD : PDI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld", + int_x86_sse2_psrl_d, int_x86_sse2_psrli_d>; +defm PSRLQ : PDI_binop_rmi_int<0xD3, 0x72, MRM2r, "psrlq", + int_x86_sse2_psrl_q, int_x86_sse2_psrli_q>; + +defm PSRAW : PDI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw", + int_x86_sse2_psra_w, int_x86_sse2_psrai_w>; +defm PSRAD : PDI_binop_rmi_int<0xE2, 0x71, MRM4r, "psrad", + int_x86_sse2_psra_d, int_x86_sse2_psrai_d>; // 128-bit logical shifts. let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in { Modified: llvm/trunk/lib/VMCore/AutoUpgrade.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AutoUpgrade.cpp?rev=50601&r1=50600&r2=50601&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AutoUpgrade.cpp (original) +++ llvm/trunk/lib/VMCore/AutoUpgrade.cpp Fri May 2 19:52:09 2008 @@ -122,7 +122,7 @@ if (Name.compare(5,10,"x86.mmx.ps",10) == 0 && (Name.compare(13,4,"psll", 4) == 0 || Name.compare(13,4,"psra", 4) == 0 || - Name.compare(13,4,"psrl", 4) == 0)) { + Name.compare(13,4,"psrl", 4) == 0) && Name[17] != 'i') { const llvm::Type *VT = VectorType::get(IntegerType::get(64), 1); Modified: llvm/trunk/test/CodeGen/X86/mmx-shift.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/mmx-shift.ll?rev=50601&r1=50600&r2=50601&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/mmx-shift.ll (original) +++ llvm/trunk/test/CodeGen/X86/mmx-shift.ll Fri May 2 19:52:09 2008 @@ -1,14 +1,15 @@ ; RUN: llvm-as < %s | llc -march=x86 -mattr=+mmx | grep psllq | grep 32 +; RUN: llvm-as < %s | llc -march=x86-64 -mattr=+mmx | grep psllq | grep 32 ; RUN: llvm-as < %s | llc -march=x86 -mattr=+mmx | grep psrad define i64 @t1(<1 x i64> %mm1) nounwind { entry: - %tmp6 = tail call <1 x i64> @llvm.x86.mmx.psll.q( <1 x i64> %mm1, <1 x i64> ) ; <<1 x i64>> [#uses=1] + %tmp6 = tail call <1 x i64> @llvm.x86.mmx.pslli.q( <1 x i64> %mm1, i32 32 ) ; <<1 x i64>> [#uses=1] %retval1112 = bitcast <1 x i64> %tmp6 to i64 ; [#uses=1] ret i64 %retval1112 } -declare <1 x i64> @llvm.x86.mmx.psll.q(<1 x i64>, <1 x i64>) nounwind readnone +declare <1 x i64> @llvm.x86.mmx.pslli.q(<1 x i64>, i32) nounwind readnone define i64 @t2(<2 x i32> %mm1, <2 x i32> %mm2) nounwind { entry: From evan.cheng at apple.com Fri May 2 19:53:16 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Sat, 03 May 2008 00:53:16 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50602 - /llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Message-ID: <200805030053.m430rHKi016387@zion.cs.uiuc.edu> Author: evancheng Date: Fri May 2 19:53:16 2008 New Revision: 50602 URL: http://llvm.org/viewvc/llvm-project?rev=50602&view=rev Log: We have separate intrinsics for IX86_BUILTIN_PSRADI, etc. Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp?rev=50602&r1=50601&r2=50602&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Fri May 2 19:53:16 2008 @@ -78,155 +78,6 @@ case IX86_BUILTIN_PMULLW128: Result = Builder.CreateMul(Ops[0], Ops[1], "tmp"); return true; - case IX86_BUILTIN_PSLLWI: { - Function *psllw = - Intrinsic::getDeclaration(TheModule, Intrinsic::x86_mmx_psll_w); - Ops[1] = Builder.CreateZExt(Ops[1], Type::Int64Ty, "zext"); - Ops[1] = BuildVector(Ops[1], NULL); - Result = Builder.CreateCall(psllw, Ops.begin(), Ops.begin()+2, "tmp"); - Result = Builder.CreateBitCast(Result, ResultType, "tmp"); - return true; - } - case IX86_BUILTIN_PSLLWI128: { - Function *psllw = - Intrinsic::getDeclaration(TheModule, Intrinsic::x86_sse2_psll_w); - Value *Undef = UndefValue::get(Type::Int32Ty); - Ops[1] = BuildVector(Ops[1], Undef, Undef, Undef, NULL); - Ops[1] = Builder.CreateBitCast(Ops[1], Ops[0]->getType(), "tmp"); - Result = Builder.CreateCall(psllw, Ops.begin(), Ops.begin()+2, "tmp"); - Result = Builder.CreateBitCast(Result, ResultType, "tmp"); - return true; - } - case IX86_BUILTIN_PSLLDI: { - Function *pslld = - Intrinsic::getDeclaration(TheModule, Intrinsic::x86_mmx_psll_d); - Ops[1] = Builder.CreateZExt(Ops[1], Type::Int64Ty, "zext"); - Ops[1] = BuildVector(Ops[1], NULL); - Result = Builder.CreateCall(pslld, Ops.begin(), Ops.begin()+2, "tmp"); - Result = Builder.CreateBitCast(Result, ResultType, "tmp"); - return true; - } - case IX86_BUILTIN_PSLLDI128: { - Function *pslld - = Intrinsic::getDeclaration(TheModule, Intrinsic::x86_sse2_psll_d); - Value *Undef = UndefValue::get(Type::Int32Ty); - Ops[1] = BuildVector(Ops[1], Undef, Undef, Undef, NULL); - Result = Builder.CreateCall(pslld, Ops.begin(), Ops.begin()+2, "tmp"); - Result = Builder.CreateBitCast(Result, ResultType, "tmp"); - return true; - } - case IX86_BUILTIN_PSLLQI: { - Function *psllq = - Intrinsic::getDeclaration(TheModule, Intrinsic::x86_mmx_psll_q); - Ops[1] = Builder.CreateZExt(Ops[1], Type::Int64Ty, "zext"); - Ops[1] = BuildVector(Ops[1], NULL); - Result = Builder.CreateCall(psllq, Ops.begin(), Ops.begin()+2, "tmp"); - Result = Builder.CreateBitCast(Result, ResultType, "tmp"); - return true; - } - case IX86_BUILTIN_PSLLQI128: { - Function *psllq = - Intrinsic::getDeclaration(TheModule, Intrinsic::x86_sse2_psll_q); - Value *Undef = UndefValue::get(Type::Int32Ty); - Ops[1] = BuildVector(Ops[1], Undef, Undef, Undef, NULL); - Ops[1] = Builder.CreateBitCast(Ops[1], Ops[0]->getType(), "tmp"); - Result = Builder.CreateCall(psllq, Ops.begin(), Ops.begin()+2, "tmp"); - Result = Builder.CreateBitCast(Result, ResultType, "tmp"); - return true; - } - case IX86_BUILTIN_PSRLWI: { - Function *psrlw = - Intrinsic::getDeclaration(TheModule, Intrinsic::x86_mmx_psrl_w); - Ops[1] = Builder.CreateZExt(Ops[1], Type::Int64Ty, "zext"); - Ops[1] = BuildVector(Ops[1], NULL); - Result = Builder.CreateCall(psrlw, Ops.begin(), Ops.begin()+2, "tmp"); - Result = Builder.CreateBitCast(Result, ResultType, "tmp"); - return true; - } - case IX86_BUILTIN_PSRLWI128: { - Function *psrlw = - Intrinsic::getDeclaration(TheModule, Intrinsic::x86_sse2_psrl_w); - Value *Undef = UndefValue::get(Type::Int32Ty); - Ops[1] = BuildVector(Ops[1], Undef, Undef, Undef, NULL); - Ops[1] = Builder.CreateBitCast(Ops[1], Ops[0]->getType(), "tmp"); - Result = Builder.CreateCall(psrlw, Ops.begin(), Ops.begin()+2, "tmp"); - Result = Builder.CreateBitCast(Result, ResultType, "tmp"); - return true; - } - case IX86_BUILTIN_PSRLDI: { - Function *psrld = - Intrinsic::getDeclaration(TheModule, Intrinsic::x86_mmx_psrl_d); - Ops[1] = Builder.CreateZExt(Ops[1], Type::Int64Ty, "zext"); - Ops[1] = BuildVector(Ops[1], NULL); - Result = Builder.CreateCall(psrld, Ops.begin(), Ops.begin()+2, "tmp"); - Result = Builder.CreateBitCast(Result, ResultType, "tmp"); - return true; - } - case IX86_BUILTIN_PSRLDI128: { - Function *psrld = - Intrinsic::getDeclaration(TheModule, Intrinsic::x86_sse2_psrl_d); - Value *Undef = UndefValue::get(Type::Int32Ty); - Ops[1] = BuildVector(Ops[1], Undef, Undef, Undef, NULL); - Result = Builder.CreateCall(psrld, Ops.begin(), Ops.begin()+2, "tmp"); - Result = Builder.CreateBitCast(Result, ResultType, "tmp"); - return true; - } - case IX86_BUILTIN_PSRLQI: { - Function *psrlq = - Intrinsic::getDeclaration(TheModule, Intrinsic::x86_mmx_psrl_q); - Ops[1] = Builder.CreateZExt(Ops[1], Type::Int64Ty, "zext"); - Ops[1] = BuildVector(Ops[1], NULL); - Result = Builder.CreateCall(psrlq, Ops.begin(), Ops.begin()+2, "tmp"); - Result = Builder.CreateBitCast(Result, ResultType, "tmp"); - return true; - } - case IX86_BUILTIN_PSRLQI128: { - Function *psrlq = - Intrinsic::getDeclaration(TheModule, Intrinsic::x86_sse2_psrl_q); - Value *Undef = UndefValue::get(Type::Int32Ty); - Ops[1] = BuildVector(Ops[1], Undef, Undef, Undef, NULL); - Ops[1] = Builder.CreateBitCast(Ops[1], Ops[0]->getType(), "tmp"); - Result = Builder.CreateCall(psrlq, Ops.begin(), Ops.begin()+2, "tmp"); - Result = Builder.CreateBitCast(Result, ResultType, "tmp"); - return true; - } - case IX86_BUILTIN_PSRAWI: { - Function *psraw = - Intrinsic::getDeclaration(TheModule, Intrinsic::x86_mmx_psra_w); - Ops[1] = Builder.CreateZExt(Ops[1], Type::Int64Ty, "zext"); - Ops[1] = BuildVector(Ops[1], NULL); - Result = Builder.CreateCall(psraw, Ops.begin(), Ops.begin()+2, "tmp"); - Result = Builder.CreateBitCast(Result, ResultType, "tmp"); - return true; - } - case IX86_BUILTIN_PSRAWI128: { - Function *psraw = - Intrinsic::getDeclaration(TheModule, Intrinsic::x86_sse2_psra_w); - Value *Undef = UndefValue::get(Type::Int32Ty); - Ops[1] = BuildVector(Ops[1], Undef, Undef, Undef, NULL); - Ops[1] = Builder.CreateBitCast(Ops[1], Ops[0]->getType(), "tmp"); - Result = Builder.CreateCall(psraw, Ops.begin(), Ops.begin()+2, "tmp"); - Result = Builder.CreateBitCast(Result, ResultType, "tmp"); - return true; - } - case IX86_BUILTIN_PSRADI: { - Function *psrad = - Intrinsic::getDeclaration(TheModule, Intrinsic::x86_mmx_psra_d); - Ops[1] = Builder.CreateZExt(Ops[1], Type::Int64Ty, "zext"); - Ops[1] = BuildVector(Ops[1], NULL); - Result = Builder.CreateCall(psrad, Ops.begin(), Ops.begin()+2, "tmp"); - Result = Builder.CreateBitCast(Result, ResultType, "tmp"); - return true; - } - case IX86_BUILTIN_PSRADI128: { - Function *psrad = - Intrinsic::getDeclaration(TheModule, Intrinsic::x86_sse2_psra_d); - Value *Undef = UndefValue::get(Type::Int32Ty); - Ops[1] = BuildVector(Ops[1], Undef, Undef, Undef, NULL); - Result = Builder.CreateCall(psrad, Ops.begin(), Ops.begin()+2, "tmp"); - Result = Builder.CreateBitCast(Result, ResultType, "tmp"); - return true; - } case IX86_BUILTIN_DIVPS: case IX86_BUILTIN_DIVPD: Result = Builder.CreateFDiv(Ops[0], Ops[1], "tmp"); From kremenek at apple.com Fri May 2 20:05:46 2008 From: kremenek at apple.com (Ted Kremenek) Date: Sat, 03 May 2008 01:05:46 -0000 Subject: [llvm-commits] [llvm] r50603 - /llvm/trunk/include/llvm/ADT/ImmutableMap.h Message-ID: <200805030105.m4315kOV016780@zion.cs.uiuc.edu> Author: kremenek Date: Fri May 2 20:05:46 2008 New Revision: 50603 URL: http://llvm.org/viewvc/llvm-project?rev=50603&view=rev Log: Implement operator-> for ImmutableMap iterators. Modified: llvm/trunk/include/llvm/ADT/ImmutableMap.h Modified: llvm/trunk/include/llvm/ADT/ImmutableMap.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/ImmutableMap.h?rev=50603&r1=50602&r2=50603&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/ImmutableMap.h (original) +++ llvm/trunk/include/llvm/ADT/ImmutableMap.h Fri May 2 20:05:46 2008 @@ -176,16 +176,19 @@ friend class ImmutableMap; public: - inline value_type_ref operator*() const { return itr->getValue(); } - inline key_type_ref getKey() const { return itr->getValue().first; } - inline data_type_ref getData() const { return itr->getValue().second; } + value_type_ref operator*() const { return itr->getValue(); } + value_type* operator->() const { return &itr->getValue(); } - inline iterator& operator++() { ++itr; return *this; } - inline iterator operator++(int) { iterator tmp(*this); ++itr; return tmp; } - inline iterator& operator--() { --itr; return *this; } - inline iterator operator--(int) { iterator tmp(*this); --itr; return tmp; } - inline bool operator==(const iterator& RHS) const { return RHS.itr == itr; } - inline bool operator!=(const iterator& RHS) const { return RHS.itr != itr; } + key_type_ref getKey() const { return itr->getValue().first; } + data_type_ref getData() const { return itr->getValue().second; } + + + iterator& operator++() { ++itr; return *this; } + iterator operator++(int) { iterator tmp(*this); ++itr; return tmp; } + iterator& operator--() { --itr; return *this; } + iterator operator--(int) { iterator tmp(*this); --itr; return tmp; } + bool operator==(const iterator& RHS) const { return RHS.itr == itr; } + bool operator!=(const iterator& RHS) const { return RHS.itr != itr; } }; iterator begin() const { return iterator(Root); } From dpatel at apple.com Fri May 2 20:12:15 2008 From: dpatel at apple.com (Devang Patel) Date: Sat, 03 May 2008 01:12:15 -0000 Subject: [llvm-commits] [llvm] r50604 - /llvm/trunk/lib/Transforms/Utils/LCSSA.cpp Message-ID: <200805030112.m431CFbP016982@zion.cs.uiuc.edu> Author: dpatel Date: Fri May 2 20:12:15 2008 New Revision: 50604 URL: http://llvm.org/viewvc/llvm-project?rev=50604&view=rev Log: Handle multiple return values. Modified: llvm/trunk/lib/Transforms/Utils/LCSSA.cpp Modified: llvm/trunk/lib/Transforms/Utils/LCSSA.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LCSSA.cpp?rev=50604&r1=50603&r2=50604&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/LCSSA.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/LCSSA.cpp Fri May 2 20:12:15 2008 @@ -217,7 +217,29 @@ } if (*BB != UserBB && !inLoop(UserBB)) { - AffectedValues.insert(I); + const StructType *STy = dyn_cast(I->getType()); + if (STy) { + // I is a call or an invoke that returns multiple values. + // These values are accessible through getresult only. + // If the getresult value is not in the BB then move it + // immediately here. It will be processed in next iteration. + BasicBlock::iterator InsertPoint; + if (InvokeInst *II = dyn_cast(I)) { + InsertPoint = II->getNormalDest()->begin(); + while (isa(InsertPoint)) + ++InsertPoint; + } else { + InsertPoint = I; + InsertPoint++; + } + for (Value::use_iterator TmpI = I->use_begin(), + TmpE = I->use_end(); TmpI != TmpE; ++TmpI) { + GetResultInst *GR = cast(TmpI); + if (GR->getParent() != *BB) + GR->moveBefore(InsertPoint); + } + } else + AffectedValues.insert(I); break; } } From edwintorok at gmail.com Sat May 3 08:24:23 2008 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Sat, 03 May 2008 16:24:23 +0300 Subject: [llvm-commits] [PATCH] MemCpyOptimizer: fix invalid reads shown by valgrind Message-ID: <481C6787.8030404@gmail.com> Hi, Valgrind has shown that MemCpyOptimizer is accessing freed memory, see relevant portions below. The instruction is freed in processStore using eraseFromParent here: if (StoreInst *SI = dyn_cast(I)) changed_function |= processStore(SI, BI); But dyn_cast<> is accessing the freed instruction here: if (MemCpyInst* M = dyn_cast(I)) { Since StoreInst can never be a MemCpyInst a simple solution is to use 'else'. Attached patch fixes this, ok to commit? Invalid read of size 2 ==17137== at 0x7159F2: llvm::Value::getValueID() const (Value.h:212) [...] ==17137== by 0x877698: (anonymous namespace)::MemCpyOpt::iterateOnFunction(llvm::Function&) (MemCpyOptimizer.cpp:722) [...] ==17137== Address 0x57e9780 is 8 bytes inside a block of size 144 free'd [...] ==17137== by 0x877557: (anonymous namespace)::MemCpyOpt::processStore(llvm::StoreInst*, llvm::ilist_iterator&) (MemCpyOptimizer.cpp:461) --Edwin -------------- next part -------------- A non-text attachment was scrubbed... Name: memcpy.patch Type: text/x-diff Size: 549 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20080503/6fb21f3b/attachment.bin From nicolas.geoffray at lip6.fr Sat May 3 10:16:59 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sat, 03 May 2008 15:16:59 -0000 Subject: [llvm-commits] [vmkit] r50605 - /vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMSystem.cpp Message-ID: <200805031516.m43FGxAP018513@zion.cs.uiuc.edu> Author: geoffray Date: Sat May 3 10:16:58 2008 New Revision: 50605 URL: http://llvm.org/viewvc/llvm-project?rev=50605&view=rev Log: Compare the primitive type of the base classes. If they are not equal, throw an ArrayStoreException. Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMSystem.cpp Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMSystem.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMSystem.cpp?rev=50605&r1=50604&r2=50605&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMSystem.cpp (original) +++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMSystem.cpp Sat May 3 10:16:58 2008 @@ -48,9 +48,11 @@ ClassArray* ts = (ClassArray*)src->classOf; ClassArray* td = (ClassArray*)dst->classOf; - AssessorDesc* srcFuncs = ts->funcs(); - AssessorDesc* dstFuncs = ts->funcs(); CommonClass* dstType = td->baseClass(); + CommonClass* srcType = ts->baseClass(); + AssessorDesc* srcPrim = AssessorDesc::bogusClassToPrimitive(srcType); + AssessorDesc* dstPrim = AssessorDesc::bogusClassToPrimitive(dstType); + AssessorDesc* srcFuncs = ts->funcs(); if (len > src->size) { vm->indexOutOfBounds(src, len); @@ -66,7 +68,7 @@ vm->indexOutOfBounds(src, sstart); } else if (len < 0) { vm->indexOutOfBounds(src, len); - } else if (srcFuncs != dstFuncs) { + } else if (srcPrim != dstPrim) { vm->arrayStoreException(); } From nicolas.geoffray at lip6.fr Sat May 3 10:18:26 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sat, 03 May 2008 15:18:26 -0000 Subject: [llvm-commits] [vmkit] r50606 - /vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Message-ID: <200805031518.m43FIQUi018577@zion.cs.uiuc.edu> Author: geoffray Date: Sat May 3 10:18:26 2008 New Revision: 50606 URL: http://llvm.org/viewvc/llvm-project?rev=50606&view=rev Log: Use the AssessorDesc instead of the LLVM type to assign local variable values. The AssessorDesc knows the sign of the argument, not the LLVM type. Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp?rev=50606&r1=50605&r2=50606&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Sat May 3 10:18:26 2008 @@ -425,23 +425,36 @@ #else uint32 max = args.size(); #endif - for (std::vector::iterator i = args.begin(); - count < max; ++i, ++index, ++count) { + std::vector::iterator type = + compilingMethod->signature->args.begin(); + std::vector::iterator i = args.begin(); + + if (isVirtual(compilingMethod->access)) { + new StoreInst(*i, objectLocals[0], false, currentBlock); + ++i; + ++index; + ++count; + } + + for (;count < max; ++i, ++index, ++count, ++type) { - const Type* cur = (*i)->getType(); + const AssessorDesc* cur = (*type)->funcs; - if (cur == Type::Int64Ty ){ + if (cur == AssessorDesc::dLong){ new StoreInst(*i, longLocals[index], false, currentBlock); ++index; - } else if (cur == Type::Int8Ty || cur == Type::Int16Ty) { + } else if (AssessorDesc::dBool || cur == AssessorDesc::dChar) { new StoreInst(new ZExtInst(*i, Type::Int32Ty, "", currentBlock), intLocals[index], false, currentBlock); - } else if (cur == Type::Int32Ty) { + } else if (AssessorDesc::dByte || cur == AssessorDesc::dShort) { + new StoreInst(new SExtInst(*i, Type::Int32Ty, "", currentBlock), + intLocals[index], false, currentBlock); + } else if (cur == AssessorDesc::dInt) { new StoreInst(*i, intLocals[index], false, currentBlock); - } else if (cur == Type::DoubleTy) { + } else if (cur == AssessorDesc::dDouble) { new StoreInst(*i, doubleLocals[index], false, currentBlock); ++index; - } else if (cur == Type::FloatTy) { + } else if (cur == AssessorDesc::dFloat) { new StoreInst(*i, floatLocals[index], false, currentBlock); } else { new StoreInst(*i, objectLocals[index], false, currentBlock); @@ -580,22 +593,34 @@ uint32 max = func->arg_size(); #endif Function::arg_iterator i = func->arg_begin(); - for (;count < max; ++i, ++index, ++count) { - - const Type* cur = i->getType(); + std::vector::iterator type = + compilingMethod->signature->args.begin(); - if (cur == Type::Int64Ty ){ + if (isVirtual(compilingMethod->access)) { + new StoreInst(i, objectLocals[0], false, currentBlock); + ++i; + ++index; + ++count; + } + + for (;count < max; ++i, ++index, ++count, ++type) { + + const AssessorDesc* cur = (*type)->funcs; + if (cur == AssessorDesc::dLong){ new StoreInst(i, longLocals[index], false, currentBlock); ++index; - } else if (cur == Type::Int8Ty || cur == Type::Int16Ty) { + } else if (cur == AssessorDesc::dBool || cur == AssessorDesc::dChar) { new StoreInst(new ZExtInst(i, Type::Int32Ty, "", currentBlock), intLocals[index], false, currentBlock); - } else if (cur == Type::Int32Ty) { + } else if (cur == AssessorDesc::dByte || cur == AssessorDesc::dShort) { + new StoreInst(new SExtInst(i, Type::Int32Ty, "", currentBlock), + intLocals[index], false, currentBlock); + } else if (cur == AssessorDesc::dInt) { new StoreInst(i, intLocals[index], false, currentBlock); - } else if (cur == Type::DoubleTy) { + } else if (cur == AssessorDesc::dDouble) { new StoreInst(i, doubleLocals[index], false, currentBlock); ++index; - } else if (cur == Type::FloatTy) { + } else if (cur == AssessorDesc::dFloat) { new StoreInst(i, floatLocals[index], false, currentBlock); } else { new StoreInst(i, objectLocals[index], false, currentBlock); From edwintorok at gmail.com Sat May 3 10:56:00 2008 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Sat, 03 May 2008 18:56:00 +0300 Subject: [llvm-commits] [PATCH] PostDominators: avoid memory leak Message-ID: <481C8B10.5010704@gmail.com> Hi, The DT member of PostDominatorTree is never freed, and valgrind reports a leak. No other optimization passess leak, and I like to see as few errors as possible from valgrind, hence this patch. It is only a matter of adding a simple destructor. Can I commit? ==17137== 7,040 (152 direct, 6,888 indirect) bytes in 1 blocks are definitely lost in loss record 29 of 34 ==17137== at 0x4A07809: operator new(unsigned long) (vg_replace_malloc.c:230) ==17137== by 0x9497DE: llvm::PostDominatorTree::PostDominatorTree() (PostDominators.h:29) ==17137== by 0x94981B: llvm::Pass* llvm::callDefaultCtor() (PassSupport.h:165) ==17137== by 0xA0BBD9: llvm::PassInfo::createPass() const (PassSupport.h:101) ==17137== by 0xA069BD: llvm::PMTopLevelManager::schedulePass(llvm::Pass*) (PassManager.cpp:444) ==17137== by 0xA115A5: llvm::PassManagerImpl::add(llvm::Pass*) (PassManager.cpp:274) ==17137== by 0xA06A9E: llvm::PassManager::add(llvm::Pass*) (PassManager.cpp:1347) ==17137== by 0x7224C6: (anonymous namespace)::addPass(llvm::PassManager&, llvm::Pass*) (opt.cpp:236) ==17137== by 0x722818: (anonymous namespace)::AddStandardCompilePasses(llvm::PassManager&) (opt.cpp:299) ==17137== by 0x7234B6: main (opt.cpp:387) --Edwin -------------- next part -------------- A non-text attachment was scrubbed... Name: postdom.patch Type: text/x-diff Size: 962 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20080503/2384532b/attachment.bin From isanbard at gmail.com Sat May 3 15:21:50 2008 From: isanbard at gmail.com (Bill Wendling) Date: Sat, 3 May 2008 13:21:50 -0700 Subject: [llvm-commits] [PATCH] PostDominators: avoid memory leak In-Reply-To: <481C8B10.5010704@gmail.com> References: <481C8B10.5010704@gmail.com> Message-ID: On May 3, 2008, at 8:56 AM, T?r?k Edwin wrote: > Hi, > > The DT member of PostDominatorTree is never freed, and valgrind > reports > a leak. > No other optimization passess leak, and I like to see as few errors as > possible from valgrind, hence this patch. > It is only a matter of adding a simple destructor. > > Can I commit? > Looks good to me. Please commit. -bw > ==17137== 7,040 (152 direct, 6,888 indirect) bytes in 1 blocks are > definitely lost in loss record 29 of 34 > ==17137== at 0x4A07809: operator new(unsigned long) > (vg_replace_malloc.c:230) > ==17137== by 0x9497DE: llvm::PostDominatorTree::PostDominatorTree() > (PostDominators.h:29) > ==17137== by 0x94981B: llvm::Pass* > llvm::callDefaultCtor() (PassSupport.h:165) > ==17137== by 0xA0BBD9: llvm::PassInfo::createPass() const > (PassSupport.h:101) > ==17137== by 0xA069BD: > llvm::PMTopLevelManager::schedulePass(llvm::Pass*) (PassManager.cpp: > 444) > ==17137== by 0xA115A5: llvm::PassManagerImpl::add(llvm::Pass*) > (PassManager.cpp:274) > ==17137== by 0xA06A9E: llvm::PassManager::add(llvm::Pass*) > (PassManager.cpp:1347) > ==17137== by 0x7224C6: (anonymous > namespace)::addPass(llvm::PassManager&, llvm::Pass*) (opt.cpp:236) > ==17137== by 0x722818: (anonymous > namespace)::AddStandardCompilePasses(llvm::PassManager&) (opt.cpp:299) > ==17137== by 0x7234B6: main (opt.cpp:387) > > --Edwin > Index: include/llvm/Analysis/PostDominators.h > =================================================================== > --- include/llvm/Analysis/PostDominators.h (revision 50604) > +++ include/llvm/Analysis/PostDominators.h (working copy) > @@ -29,6 +29,8 @@ > DT = new DominatorTreeBase(true); > } > > + ~PostDominatorTree(); > + > virtual bool runOnFunction(Function &F); > > virtual void getAnalysisUsage(AnalysisUsage &AU) const { > Index: lib/Analysis/PostDominators.cpp > =================================================================== > --- lib/Analysis/PostDominators.cpp (revision 50604) > +++ lib/Analysis/PostDominators.cpp (working copy) > @@ -37,6 +37,11 @@ > return false; > } > > +PostDominatorTree::~PostDominatorTree() > +{ > + delete DT; > +} > + > // > = > = > = > ----------------------------------------------------------------------= > ==// > // PostDominanceFrontier Implementation > // > = > = > = > ----------------------------------------------------------------------= > ==// > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From edwintorok at gmail.com Sat May 3 15:35:47 2008 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Sat, 03 May 2008 23:35:47 +0300 Subject: [llvm-commits] [PATCH] PostDominators: avoid memory leak In-Reply-To: References: <481C8B10.5010704@gmail.com> Message-ID: <481CCCA3.4030507@gmail.com> Bill Wendling wrote: > On May 3, 2008, at 8:56 AM, T?r?k Edwin wrote: > > >> Hi, >> >> The DT member of PostDominatorTree is never freed, and valgrind >> reports >> a leak. >> No other optimization passess leak, and I like to see as few errors as >> possible from valgrind, hence this patch. >> It is only a matter of adding a simple destructor. >> >> Can I commit? >> >> > Looks good to me. Please commit. Thanks commited in r50607. BTW my commit messages never reach this list (I consulted the archives at lists.cs.uiuc.edu), and it is not just this commit. My previous commits don't show up either ... Best regards, --Edwin From clattner at apple.com Sat May 3 18:45:41 2008 From: clattner at apple.com (Chris Lattner) Date: Sat, 3 May 2008 16:45:41 -0700 Subject: [llvm-commits] [PATCH] PostDominators: avoid memory leak In-Reply-To: <481CCCA3.4030507@gmail.com> References: <481C8B10.5010704@gmail.com> <481CCCA3.4030507@gmail.com> Message-ID: On May 3, 2008, at 1:35 PM, T?r?k Edwin wrote: > Bill Wendling wrote: >> On May 3, 2008, at 8:56 AM, T?r?k Edwin wrote: >> >> >>> Hi, >>> >>> The DT member of PostDominatorTree is never freed, and valgrind >>> reports >>> a leak. >>> No other optimization passess leak, and I like to see as few >>> errors as >>> possible from valgrind, hence this patch. >>> It is only a matter of adding a simple destructor. >>> >>> Can I commit? >>> >>> >> Looks good to me. Please commit. > > Thanks commited in r50607. > > BTW my commit messages never reach this list (I consulted the archives > at lists.cs.uiuc.edu), and it is not just this commit. > My previous commits don't show up either ... Try another test commit please. Thanks! -Chris From clattner at apple.com Sat May 3 18:46:46 2008 From: clattner at apple.com (Chris Lattner) Date: Sat, 3 May 2008 16:46:46 -0700 Subject: [llvm-commits] [PATCH] MemCpyOptimizer: fix invalid reads shown by valgrind In-Reply-To: <481C6787.8030404@gmail.com> References: <481C6787.8030404@gmail.com> Message-ID: <222883C7-E925-4DB7-93B9-BAEAC6CC2E0F@apple.com> On May 3, 2008, at 6:24 AM, T?r?k Edwin wrote: > Hi, > > Valgrind has shown that MemCpyOptimizer is accessing freed memory, see > relevant portions below. > The instruction is freed in processStore using eraseFromParent here: > if (StoreInst *SI = dyn_cast(I)) > changed_function |= processStore(SI, BI); > > But dyn_cast<> is accessing the freed instruction here: > if (MemCpyInst* M = dyn_cast(I)) { > > Since StoreInst can never be a MemCpyInst a simple solution is to use > 'else'. > Attached patch fixes this, ok to commit? Looks great, please commit! -Chris > > > --Edwin > Index: lib/Transforms/Scalar/MemCpyOptimizer.cpp > =================================================================== > --- lib/Transforms/Scalar/MemCpyOptimizer.cpp (revision 50604) > +++ lib/Transforms/Scalar/MemCpyOptimizer.cpp (working copy) > @@ -718,8 +718,7 @@ > > if (StoreInst *SI = dyn_cast(I)) > changed_function |= processStore(SI, BI); > - > - if (MemCpyInst* M = dyn_cast(I)) { > + else if (MemCpyInst* M = dyn_cast(I)) { > changed_function |= processMemCpy(M); > } > } > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From isanbard at gmail.com Sun May 4 00:12:40 2008 From: isanbard at gmail.com (Bill Wendling) Date: Sun, 04 May 2008 05:12:40 -0000 Subject: [llvm-commits] [llvm] r50613 - /llvm/branches/Apple/Tak/lib/Transforms/Scalar/MemCpyOptimizer.cpp Message-ID: <200805040512.m445Cem4017647@zion.cs.uiuc.edu> Author: void Date: Sun May 4 00:12:39 2008 New Revision: 50613 URL: http://llvm.org/viewvc/llvm-project?rev=50613&view=rev Log: Pulling Torok's valgrind fix into Tak. Modified: llvm/branches/Apple/Tak/lib/Transforms/Scalar/MemCpyOptimizer.cpp Modified: llvm/branches/Apple/Tak/lib/Transforms/Scalar/MemCpyOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Tak/lib/Transforms/Scalar/MemCpyOptimizer.cpp?rev=50613&r1=50612&r2=50613&view=diff ============================================================================== --- llvm/branches/Apple/Tak/lib/Transforms/Scalar/MemCpyOptimizer.cpp (original) +++ llvm/branches/Apple/Tak/lib/Transforms/Scalar/MemCpyOptimizer.cpp Sun May 4 00:12:39 2008 @@ -712,8 +712,7 @@ if (StoreInst *SI = dyn_cast(I)) changed_function |= processStore(SI, BI); - - if (MemCpyInst* M = dyn_cast(I)) { + else if (MemCpyInst* M = dyn_cast(I)) { changed_function |= processMemCpy(M); } } From asl at math.spbu.ru Sun May 4 01:16:51 2008 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Sun, 04 May 2008 06:16:51 -0000 Subject: [llvm-commits] [llvm] r50614 - in /llvm/trunk: docs/CommandGuide/llvm2cpp.pod tools/llvm2cpp/CppWriter.cpp tools/llvm2cpp/CppWriter.h tools/llvm2cpp/Makefile tools/llvm2cpp/llvm2cpp.cpp Message-ID: <200805040616.m446GqhP019611@zion.cs.uiuc.edu> Author: asl Date: Sun May 4 01:16:50 2008 New Revision: 50614 URL: http://llvm.org/viewvc/llvm-project?rev=50614&view=rev Log: Drop llvm2cpp, it's now a llc target Removed: llvm/trunk/docs/CommandGuide/llvm2cpp.pod llvm/trunk/tools/llvm2cpp/CppWriter.cpp llvm/trunk/tools/llvm2cpp/CppWriter.h llvm/trunk/tools/llvm2cpp/Makefile llvm/trunk/tools/llvm2cpp/llvm2cpp.cpp Removed: llvm/trunk/docs/CommandGuide/llvm2cpp.pod URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/llvm2cpp.pod?rev=50613&view=auto ============================================================================== --- llvm/trunk/docs/CommandGuide/llvm2cpp.pod (original) +++ llvm/trunk/docs/CommandGuide/llvm2cpp.pod (removed) @@ -1,217 +0,0 @@ -=pod - -=head1 NAME - -llvm2xpp - LLVM bitcode to LLVM C++ IR translator - -=head1 SYNOPSIS - -B [I] [I] - -=head1 DESCRIPTION - -B translates from LLVM bitcode (.bc files) to a -corresponding C++ source file that will make calls against the LLVM C++ API to -build the same module as the input. By default, the C++ output is a complete -program that builds the module, verifies it and then emits the module as -LLVM assembly. This technique assists with testing because the input to -B and the output of the generated C++ program should be identical. - -If F is omitted or is C<->, then B reads its input from -standard input. - -If an output file is not specified with the B<-o> option, then -B sends its output to a file or standard output by following -these rules: - -=over - -=item * - -If the input is standard input, then the output is standard output. - -=item * - -If the input is a file that ends with C<.bc>, then the output file is of -the same name, except that the suffix is changed to C<.cpp>. - -=item * - -If the input is a file that does not end with the C<.bc> suffix, then the -output file has the same name as the input file, except that the C<.cpp> -suffix is appended. - -=back - -=head1 OPTIONS - -=over - -=item B<-f> - -Force overwrite. Normally, B will refuse to overwrite an -output file that already exists. With this option, B -will overwrite the output file and replace it with new C++ source code. - -=item B<--help> - -Print a summary of command line options. - -=item B<-f> - -Normally, B will not overwrite an existing output file. With this -option, that default behavior is changed and the program will overwrite existing -output files. - -=item B<-o> F - -Specify the output file name. If F is C<->, then B -sends its output to standard output. - -=item B<-funcname> F - -Specify the name of the function to be generated. The generated code contains a -single function that produces the input module. By default its name is -I. The B<-funcname> option overrides this default and allows -you to control the name of the generated function. This is handy in conjunction -with the B<-fragment> option when you only want B to generate a -single function that produces the module. With both options, such generated code -could be I<#included> into another program. - -=item B<-for> - -Specify the name of the thing for which C++ code should be generated. By default -the entire input module is re-generated. However, use of the various B<-gen-*> -options can restrict what is produced. This option indicates what that -restriction is. - -=item B<-gen-program> - -Specify that the output should be a complete program. Such program will recreate -B's input as an LLVM module, verify that module, and then write out -the module in LLVM assembly format. This is useful for doing identity tests -where the output of the generated program is identical to the input to -B. The LLVM DejaGnu test suite can make use of this fact. This is the -default form of generated output. - -If the B<-for> option is given with this option, it specifies the module -identifier to use for the module created. - -=item B<-gen-module> - -Specify that the output should be a function that regenerates the module. It is -assumed that this output will be #included into another program that has already -arranged for the correct header files to be #included. The function generated -takes no arguments and returns a I. - -If the B<-for> option is given with this option, it specifies the module -identifier to use in creating the module returned by the generated function. - -=item B<-gen-contents> - -Specify that the output should be a function that adds the contents of the input -module to another module. It is assumed that the output will be #included into -another program that has already arranged for the correct header files to be -#included. The function generated takes a single argument of type I and -returns that argument. Note that Module level attributes such as endianess, -pointer size, target triple and inline asm are not passed on from the input -module to the destination module. Only the sub-elements of the module (types, -constants, functions, global variables) will be added to the input module. - -If the B<-for> option is given with this option, it specifies the module -identifier to set in the input module by the generated function. - -=item B<-gen-function> - -Specify that the output should be a function that produces the definitions -necessary for a specific function to be added to a module. It is assumed that -the output will be #included into another program that has already arranged -for the correct header files to be #included. The function generated takes a -single argument of type I and returns the I that it added to -the module. Note that only those things (types, constants, etc.) directly -needed in the definition of the function will be placed in the generated -function. - -The B<-for> option must be given with this option or an error will be produced. -The value of the option must be the name of a function in the input module for -which code should be generated. If the named function does not exist an error -will be produced. - -=item B<-gen-inline> - -This option is very analagous to B<-gen-function> except that the generated -function will not re-produce the target function's definition. Instead, the body -of the target function is inserted into some other function passed as an -argument to the generated function. Similarly any arguments to the function must -be passed to the generated function. The result of the generated function is the -first basic block of the target function. - -The B<-for> option works the same way as it does for B<-gen-function>. - -=item B<-gen-variable> - -Specify that the output should be a function that produces the definitions -necessary for a specific global variable to be added to a module. It is assumed -that the output will be #included into another program that has already arranged -for the correct header files to be #included. The function generated takes a -single argument of type I and returns the I that it -added to the module. Note that only those things (types, constants, etc.) -directly needed in the definition of the global variable will be placed in the -generated function. - -The B<-for> option must be given with this option or an error will be produced. -THe value of the option must be the name of a global variable in the input -module for which code should be generated. If the named global variable does not -exist an error will be produced. - -=item B<-gen-type> - -Specify that the output should be a function that produces the definitions -necessary for specific type to be added to a module. It is assumed that the -otuput will be #included into another program that has already arranged for the -correct header files to be #included. The function generated take a single -argument of type I and returns the I that it added to the -module. Note that the generated function will only add the necessary type -definitions to (possibly recursively) define the requested type. - -The B<-for> option must be given with this option or an error will be produced. -The value of the option must be the name of a global type in the input module -for which code should be generated. If the named type does not exist an error -will be produced. - -=item B<-stats> - -Show pass statistics (not interesting in this program). - -=item B<-time-passes> - -Show pass timing statistics (not interesting in this program). - -=item B<-version> - -Show the version number of this program. - -=back - - -=head1 EXIT STATUS - -If B succeeds, it will exit with 0. Otherwise, if an error -occurs, it will exit with a non-zero value. - -=head1 SEE ALSO - -L L - -=head1 NOTES - -This tool may be removed from a future version of LLVM. Instead, its -functionality may be incorporated into the llc tool. It would then act similarly -to other targets except its output would be C++ source that could be compiled to -construct the input program. - -=head1 AUTHORS - -Written by Reid Spencer (L). - -=cut Removed: llvm/trunk/tools/llvm2cpp/CppWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm2cpp/CppWriter.cpp?rev=50613&view=auto ============================================================================== --- llvm/trunk/tools/llvm2cpp/CppWriter.cpp (original) +++ llvm/trunk/tools/llvm2cpp/CppWriter.cpp (removed) @@ -1,1968 +0,0 @@ -//===-- CppWriter.cpp - Printing LLVM IR as a C++ Source File -------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements the writing of the LLVM IR as a set of C++ calls to the -// LLVM IR interface. The input module is assumed to be verified. -// -//===----------------------------------------------------------------------===// - -#include "llvm/CallingConv.h" -#include "llvm/Constants.h" -#include "llvm/DerivedTypes.h" -#include "llvm/InlineAsm.h" -#include "llvm/Instruction.h" -#include "llvm/Instructions.h" -#include "llvm/Module.h" -#include "llvm/TypeSymbolTable.h" -#include "llvm/ADT/StringExtras.h" -#include "llvm/ADT/STLExtras.h" -#include "llvm/ADT/SmallPtrSet.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/Support/CFG.h" -#include "llvm/Support/ManagedStatic.h" -#include "llvm/Support/MathExtras.h" -#include "llvm/Config/config.h" -#include -#include -#include - -using namespace llvm; - -static cl::opt -FuncName("funcname", cl::desc("Specify the name of the generated function"), - cl::value_desc("function name")); - -enum WhatToGenerate { - GenProgram, - GenModule, - GenContents, - GenFunction, - GenFunctions, - GenInline, - GenVariable, - GenType -}; - -static cl::opt GenerationType(cl::Optional, - cl::desc("Choose what kind of output to generate"), - cl::init(GenProgram), - cl::values( - clEnumValN(GenProgram, "gen-program", "Generate a complete program"), - clEnumValN(GenModule, "gen-module", "Generate a module definition"), - clEnumValN(GenContents, "gen-contents", "Generate contents of a module"), - clEnumValN(GenFunction, "gen-function", "Generate a function definition"), - clEnumValN(GenFunctions,"gen-functions", "Generate all function definitions"), - clEnumValN(GenInline, "gen-inline", "Generate an inline function"), - clEnumValN(GenVariable, "gen-variable", "Generate a variable definition"), - clEnumValN(GenType, "gen-type", "Generate a type definition"), - clEnumValEnd - ) -); - -static cl::opt NameToGenerate("for", cl::Optional, - cl::desc("Specify the name of the thing to generate"), - cl::init("!bad!")); - -namespace { -typedef std::vector TypeList; -typedef std::map TypeMap; -typedef std::map ValueMap; -typedef std::set NameSet; -typedef std::set TypeSet; -typedef std::set ValueSet; -typedef std::map ForwardRefMap; - -class CppWriter { - const char* progname; - std::ostream &Out; - const Module *TheModule; - uint64_t uniqueNum; - TypeMap TypeNames; - ValueMap ValueNames; - TypeMap UnresolvedTypes; - TypeList TypeStack; - NameSet UsedNames; - TypeSet DefinedTypes; - ValueSet DefinedValues; - ForwardRefMap ForwardRefs; - bool is_inline; - -public: - inline CppWriter(std::ostream &o, const Module *M, const char* pn="llvm2cpp") - : progname(pn), Out(o), TheModule(M), uniqueNum(0), TypeNames(), - ValueNames(), UnresolvedTypes(), TypeStack(), is_inline(false) { } - - const Module* getModule() { return TheModule; } - - void printProgram(const std::string& fname, const std::string& modName ); - void printModule(const std::string& fname, const std::string& modName ); - void printContents(const std::string& fname, const std::string& modName ); - void printFunction(const std::string& fname, const std::string& funcName ); - void printFunctions(); - void printInline(const std::string& fname, const std::string& funcName ); - void printVariable(const std::string& fname, const std::string& varName ); - void printType(const std::string& fname, const std::string& typeName ); - - void error(const std::string& msg); - -private: - void printLinkageType(GlobalValue::LinkageTypes LT); - void printVisibilityType(GlobalValue::VisibilityTypes VisTypes); - void printCallingConv(unsigned cc); - void printEscapedString(const std::string& str); - void printCFP(const ConstantFP* CFP); - - std::string getCppName(const Type* val); - inline void printCppName(const Type* val); - - std::string getCppName(const Value* val); - inline void printCppName(const Value* val); - - void printParamAttrs(const PAListPtr &PAL, const std::string &name); - bool printTypeInternal(const Type* Ty); - inline void printType(const Type* Ty); - void printTypes(const Module* M); - - void printConstant(const Constant *CPV); - void printConstants(const Module* M); - - void printVariableUses(const GlobalVariable *GV); - void printVariableHead(const GlobalVariable *GV); - void printVariableBody(const GlobalVariable *GV); - - void printFunctionUses(const Function *F); - void printFunctionHead(const Function *F); - void printFunctionBody(const Function *F); - void printInstruction(const Instruction *I, const std::string& bbname); - std::string getOpName(Value*); - - void printModuleBody(); - -}; - -static unsigned indent_level = 0; -inline std::ostream& nl(std::ostream& Out, int delta = 0) { - Out << "\n"; - if (delta >= 0 || indent_level >= unsigned(-delta)) - indent_level += delta; - for (unsigned i = 0; i < indent_level; ++i) - Out << " "; - return Out; -} - -inline void in() { indent_level++; } -inline void out() { if (indent_level >0) indent_level--; } - -inline void -sanitize(std::string& str) { - for (size_t i = 0; i < str.length(); ++i) - if (!isalnum(str[i]) && str[i] != '_') - str[i] = '_'; -} - -inline std::string -getTypePrefix(const Type* Ty ) { - switch (Ty->getTypeID()) { - case Type::VoidTyID: return "void_"; - case Type::IntegerTyID: - return std::string("int") + utostr(cast(Ty)->getBitWidth()) + - "_"; - case Type::FloatTyID: return "float_"; - case Type::DoubleTyID: return "double_"; - case Type::LabelTyID: return "label_"; - case Type::FunctionTyID: return "func_"; - case Type::StructTyID: return "struct_"; - case Type::ArrayTyID: return "array_"; - case Type::PointerTyID: return "ptr_"; - case Type::VectorTyID: return "packed_"; - case Type::OpaqueTyID: return "opaque_"; - default: return "other_"; - } - return "unknown_"; -} - -// Looks up the type in the symbol table and returns a pointer to its name or -// a null pointer if it wasn't found. Note that this isn't the same as the -// Mode::getTypeName function which will return an empty string, not a null -// pointer if the name is not found. -inline const std::string* -findTypeName(const TypeSymbolTable& ST, const Type* Ty) -{ - TypeSymbolTable::const_iterator TI = ST.begin(); - TypeSymbolTable::const_iterator TE = ST.end(); - for (;TI != TE; ++TI) - if (TI->second == Ty) - return &(TI->first); - return 0; -} - -void -CppWriter::error(const std::string& msg) { - std::cerr << progname << ": " << msg << "\n"; - exit(2); -} - -// printCFP - Print a floating point constant .. very carefully :) -// This makes sure that conversion to/from floating yields the same binary -// result so that we don't lose precision. -void -CppWriter::printCFP(const ConstantFP *CFP) { - APFloat APF = APFloat(CFP->getValueAPF()); // copy - if (CFP->getType() == Type::FloatTy) - APF.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven); - Out << "ConstantFP::get("; - if (CFP->getType() == Type::DoubleTy) - Out << "Type::DoubleTy, "; - else - Out << "Type::FloatTy, "; - Out << "APFloat("; -#if HAVE_PRINTF_A - char Buffer[100]; - sprintf(Buffer, "%A", APF.convertToDouble()); - if ((!strncmp(Buffer, "0x", 2) || - !strncmp(Buffer, "-0x", 3) || - !strncmp(Buffer, "+0x", 3)) && - APF.bitwiseIsEqual(APFloat(atof(Buffer)))) { - if (CFP->getType() == Type::DoubleTy) - Out << "BitsToDouble(" << Buffer << ")"; - else - Out << "BitsToFloat((float)" << Buffer << ")"; - Out << ")"; - } else { -#endif - std::string StrVal = ftostr(CFP->getValueAPF()); - - while (StrVal[0] == ' ') - StrVal.erase(StrVal.begin()); - - // Check to make sure that the stringized number is not some string like - // "Inf" or NaN. Check that the string matches the "[-+]?[0-9]" regex. - if (((StrVal[0] >= '0' && StrVal[0] <= '9') || - ((StrVal[0] == '-' || StrVal[0] == '+') && - (StrVal[1] >= '0' && StrVal[1] <= '9'))) && - (CFP->isExactlyValue(atof(StrVal.c_str())))) { - if (CFP->getType() == Type::DoubleTy) - Out << StrVal; - else - Out << StrVal << "f"; - } - else if (CFP->getType() == Type::DoubleTy) - Out << "BitsToDouble(0x" << std::hex - << CFP->getValueAPF().convertToAPInt().getZExtValue() - << std::dec << "ULL) /* " << StrVal << " */"; - else - Out << "BitsToFloat(0x" << std::hex - << (uint32_t)CFP->getValueAPF().convertToAPInt().getZExtValue() - << std::dec << "U) /* " << StrVal << " */"; - Out << ")"; -#if HAVE_PRINTF_A - } -#endif - Out << ")"; -} - -void -CppWriter::printCallingConv(unsigned cc){ - // Print the calling convention. - switch (cc) { - case CallingConv::C: Out << "CallingConv::C"; break; - case CallingConv::Fast: Out << "CallingConv::Fast"; break; - case CallingConv::Cold: Out << "CallingConv::Cold"; break; - case CallingConv::FirstTargetCC: Out << "CallingConv::FirstTargetCC"; break; - default: Out << cc; break; - } -} - -void -CppWriter::printLinkageType(GlobalValue::LinkageTypes LT) { - switch (LT) { - case GlobalValue::InternalLinkage: - Out << "GlobalValue::InternalLinkage"; break; - case GlobalValue::LinkOnceLinkage: - Out << "GlobalValue::LinkOnceLinkage "; break; - case GlobalValue::WeakLinkage: - Out << "GlobalValue::WeakLinkage"; break; - case GlobalValue::AppendingLinkage: - Out << "GlobalValue::AppendingLinkage"; break; - case GlobalValue::ExternalLinkage: - Out << "GlobalValue::ExternalLinkage"; break; - case GlobalValue::DLLImportLinkage: - Out << "GlobalValue::DLLImportLinkage"; break; - case GlobalValue::DLLExportLinkage: - Out << "GlobalValue::DLLExportLinkage"; break; - case GlobalValue::ExternalWeakLinkage: - Out << "GlobalValue::ExternalWeakLinkage"; break; - case GlobalValue::GhostLinkage: - Out << "GlobalValue::GhostLinkage"; break; - } -} - -void -CppWriter::printVisibilityType(GlobalValue::VisibilityTypes VisType) { - switch (VisType) { - default: assert(0 && "Unknown GVar visibility"); - case GlobalValue::DefaultVisibility: - Out << "GlobalValue::DefaultVisibility"; - break; - case GlobalValue::HiddenVisibility: - Out << "GlobalValue::HiddenVisibility"; - break; - case GlobalValue::ProtectedVisibility: - Out << "GlobalValue::ProtectedVisibility"; - break; - } -} - -// printEscapedString - Print each character of the specified string, escaping -// it if it is not printable or if it is an escape char. -void -CppWriter::printEscapedString(const std::string &Str) { - for (unsigned i = 0, e = Str.size(); i != e; ++i) { - unsigned char C = Str[i]; - if (isprint(C) && C != '"' && C != '\\') { - Out << C; - } else { - Out << "\\x" - << (char) ((C/16 < 10) ? ( C/16 +'0') : ( C/16 -10+'A')) - << (char)(((C&15) < 10) ? ((C&15)+'0') : ((C&15)-10+'A')); - } - } -} - -std::string -CppWriter::getCppName(const Type* Ty) -{ - // First, handle the primitive types .. easy - if (Ty->isPrimitiveType() || Ty->isInteger()) { - switch (Ty->getTypeID()) { - case Type::VoidTyID: return "Type::VoidTy"; - case Type::IntegerTyID: { - unsigned BitWidth = cast(Ty)->getBitWidth(); - return "IntegerType::get(" + utostr(BitWidth) + ")"; - } - case Type::FloatTyID: return "Type::FloatTy"; - case Type::DoubleTyID: return "Type::DoubleTy"; - case Type::LabelTyID: return "Type::LabelTy"; - default: - error("Invalid primitive type"); - break; - } - return "Type::VoidTy"; // shouldn't be returned, but make it sensible - } - - // Now, see if we've seen the type before and return that - TypeMap::iterator I = TypeNames.find(Ty); - if (I != TypeNames.end()) - return I->second; - - // Okay, let's build a new name for this type. Start with a prefix - const char* prefix = 0; - switch (Ty->getTypeID()) { - case Type::FunctionTyID: prefix = "FuncTy_"; break; - case Type::StructTyID: prefix = "StructTy_"; break; - case Type::ArrayTyID: prefix = "ArrayTy_"; break; - case Type::PointerTyID: prefix = "PointerTy_"; break; - case Type::OpaqueTyID: prefix = "OpaqueTy_"; break; - case Type::VectorTyID: prefix = "VectorTy_"; break; - default: prefix = "OtherTy_"; break; // prevent breakage - } - - // See if the type has a name in the symboltable and build accordingly - const std::string* tName = findTypeName(TheModule->getTypeSymbolTable(), Ty); - std::string name; - if (tName) - name = std::string(prefix) + *tName; - else - name = std::string(prefix) + utostr(uniqueNum++); - sanitize(name); - - // Save the name - return TypeNames[Ty] = name; -} - -void -CppWriter::printCppName(const Type* Ty) -{ - printEscapedString(getCppName(Ty)); -} - -std::string -CppWriter::getCppName(const Value* val) { - std::string name; - ValueMap::iterator I = ValueNames.find(val); - if (I != ValueNames.end() && I->first == val) - return I->second; - - if (const GlobalVariable* GV = dyn_cast(val)) { - name = std::string("gvar_") + - getTypePrefix(GV->getType()->getElementType()); - } else if (isa(val)) { - name = std::string("func_"); - } else if (const Constant* C = dyn_cast(val)) { - name = std::string("const_") + getTypePrefix(C->getType()); - } else if (const Argument* Arg = dyn_cast(val)) { - if (is_inline) { - unsigned argNum = std::distance(Arg->getParent()->arg_begin(), - Function::const_arg_iterator(Arg)) + 1; - name = std::string("arg_") + utostr(argNum); - NameSet::iterator NI = UsedNames.find(name); - if (NI != UsedNames.end()) - name += std::string("_") + utostr(uniqueNum++); - UsedNames.insert(name); - return ValueNames[val] = name; - } else { - name = getTypePrefix(val->getType()); - } - } else { - name = getTypePrefix(val->getType()); - } - name += (val->hasName() ? val->getName() : utostr(uniqueNum++)); - sanitize(name); - NameSet::iterator NI = UsedNames.find(name); - if (NI != UsedNames.end()) - name += std::string("_") + utostr(uniqueNum++); - UsedNames.insert(name); - return ValueNames[val] = name; -} - -void -CppWriter::printCppName(const Value* val) { - printEscapedString(getCppName(val)); -} - -void -CppWriter::printParamAttrs(const PAListPtr &PAL, const std::string &name) { - Out << "PAListPtr " << name << "_PAL = 0;"; - nl(Out); - if (!PAL.isEmpty()) { - Out << '{'; in(); nl(Out); - Out << "SmallVector Attrs;"; nl(Out); - Out << "ParamAttrsWithIndex PAWI;"; nl(Out); - for (unsigned i = 0; i < PAL.getNumSlots(); ++i) { - uint16_t index = PAL.getSlot(i).Index; - ParameterAttributes attrs = PAL.getSlot(i).Attrs; - Out << "PAWI.index = " << index << "; PAWI.attrs = 0 "; - if (attrs & ParamAttr::SExt) - Out << " | ParamAttr::SExt"; - if (attrs & ParamAttr::ZExt) - Out << " | ParamAttr::ZExt"; - if (attrs & ParamAttr::StructRet) - Out << " | ParamAttr::StructRet"; - if (attrs & ParamAttr::InReg) - Out << " | ParamAttr::InReg"; - if (attrs & ParamAttr::NoReturn) - Out << " | ParamAttr::NoReturn"; - if (attrs & ParamAttr::NoUnwind) - Out << " | ParamAttr::NoUnwind"; - if (attrs & ParamAttr::ByVal) - Out << " | ParamAttr::ByVal"; - if (attrs & ParamAttr::NoAlias) - Out << " | ParamAttr::NoAlias"; - if (attrs & ParamAttr::Nest) - Out << " | ParamAttr::Nest"; - if (attrs & ParamAttr::ReadNone) - Out << " | ParamAttr::ReadNone"; - if (attrs & ParamAttr::ReadOnly) - Out << " | ParamAttr::ReadOnly"; - Out << ";"; - nl(Out); - Out << "Attrs.push_back(PAWI);"; - nl(Out); - } - Out << name << "_PAL = PAListPtr::get(Attrs.begin(), Attrs.end());"; - nl(Out); - out(); nl(Out); - Out << '}'; nl(Out); - } -} - -bool -CppWriter::printTypeInternal(const Type* Ty) { - // We don't print definitions for primitive types - if (Ty->isPrimitiveType() || Ty->isInteger()) - return false; - - // If we already defined this type, we don't need to define it again. - if (DefinedTypes.find(Ty) != DefinedTypes.end()) - return false; - - // Everything below needs the name for the type so get it now. - std::string typeName(getCppName(Ty)); - - // Search the type stack for recursion. If we find it, then generate this - // as an OpaqueType, but make sure not to do this multiple times because - // the type could appear in multiple places on the stack. Once the opaque - // definition is issued, it must not be re-issued. Consequently we have to - // check the UnresolvedTypes list as well. - TypeList::const_iterator TI = std::find(TypeStack.begin(),TypeStack.end(),Ty); - if (TI != TypeStack.end()) { - TypeMap::const_iterator I = UnresolvedTypes.find(Ty); - if (I == UnresolvedTypes.end()) { - Out << "PATypeHolder " << typeName << "_fwd = OpaqueType::get();"; - nl(Out); - UnresolvedTypes[Ty] = typeName; - } - return true; - } - - // We're going to print a derived type which, by definition, contains other - // types. So, push this one we're printing onto the type stack to assist with - // recursive definitions. - TypeStack.push_back(Ty); - - // Print the type definition - switch (Ty->getTypeID()) { - case Type::FunctionTyID: { - const FunctionType* FT = cast(Ty); - Out << "std::vector" << typeName << "_args;"; - nl(Out); - FunctionType::param_iterator PI = FT->param_begin(); - FunctionType::param_iterator PE = FT->param_end(); - for (; PI != PE; ++PI) { - const Type* argTy = static_cast(*PI); - bool isForward = printTypeInternal(argTy); - std::string argName(getCppName(argTy)); - Out << typeName << "_args.push_back(" << argName; - if (isForward) - Out << "_fwd"; - Out << ");"; - nl(Out); - } - bool isForward = printTypeInternal(FT->getReturnType()); - std::string retTypeName(getCppName(FT->getReturnType())); - Out << "FunctionType* " << typeName << " = FunctionType::get("; - in(); nl(Out) << "/*Result=*/" << retTypeName; - if (isForward) - Out << "_fwd"; - Out << ","; - nl(Out) << "/*Params=*/" << typeName << "_args,"; - nl(Out) << "/*isVarArg=*/" << (FT->isVarArg() ? "true" : "false") << ");"; - out(); - nl(Out); - break; - } - case Type::StructTyID: { - const StructType* ST = cast(Ty); - Out << "std::vector" << typeName << "_fields;"; - nl(Out); - StructType::element_iterator EI = ST->element_begin(); - StructType::element_iterator EE = ST->element_end(); - for (; EI != EE; ++EI) { - const Type* fieldTy = static_cast(*EI); - bool isForward = printTypeInternal(fieldTy); - std::string fieldName(getCppName(fieldTy)); - Out << typeName << "_fields.push_back(" << fieldName; - if (isForward) - Out << "_fwd"; - Out << ");"; - nl(Out); - } - Out << "StructType* " << typeName << " = StructType::get(" - << typeName << "_fields, /*isPacked=*/" - << (ST->isPacked() ? "true" : "false") << ");"; - nl(Out); - break; - } - case Type::ArrayTyID: { - const ArrayType* AT = cast(Ty); - const Type* ET = AT->getElementType(); - bool isForward = printTypeInternal(ET); - std::string elemName(getCppName(ET)); - Out << "ArrayType* " << typeName << " = ArrayType::get(" - << elemName << (isForward ? "_fwd" : "") - << ", " << utostr(AT->getNumElements()) << ");"; - nl(Out); - break; - } - case Type::PointerTyID: { - const PointerType* PT = cast(Ty); - const Type* ET = PT->getElementType(); - bool isForward = printTypeInternal(ET); - std::string elemName(getCppName(ET)); - Out << "PointerType* " << typeName << " = PointerType::get(" - << elemName << (isForward ? "_fwd" : "") - << ", " << utostr(PT->getAddressSpace()) << ");"; - nl(Out); - break; - } - case Type::VectorTyID: { - const VectorType* PT = cast(Ty); - const Type* ET = PT->getElementType(); - bool isForward = printTypeInternal(ET); - std::string elemName(getCppName(ET)); - Out << "VectorType* " << typeName << " = VectorType::get(" - << elemName << (isForward ? "_fwd" : "") - << ", " << utostr(PT->getNumElements()) << ");"; - nl(Out); - break; - } - case Type::OpaqueTyID: { - Out << "OpaqueType* " << typeName << " = OpaqueType::get();"; - nl(Out); - break; - } - default: - error("Invalid TypeID"); - } - - // If the type had a name, make sure we recreate it. - const std::string* progTypeName = - findTypeName(TheModule->getTypeSymbolTable(),Ty); - if (progTypeName) { - Out << "mod->addTypeName(\"" << *progTypeName << "\", " - << typeName << ");"; - nl(Out); - } - - // Pop us off the type stack - TypeStack.pop_back(); - - // Indicate that this type is now defined. - DefinedTypes.insert(Ty); - - // Early resolve as many unresolved types as possible. Search the unresolved - // types map for the type we just printed. Now that its definition is complete - // we can resolve any previous references to it. This prevents a cascade of - // unresolved types. - TypeMap::iterator I = UnresolvedTypes.find(Ty); - if (I != UnresolvedTypes.end()) { - Out << "cast(" << I->second - << "_fwd.get())->refineAbstractTypeTo(" << I->second << ");"; - nl(Out); - Out << I->second << " = cast<"; - switch (Ty->getTypeID()) { - case Type::FunctionTyID: Out << "FunctionType"; break; - case Type::ArrayTyID: Out << "ArrayType"; break; - case Type::StructTyID: Out << "StructType"; break; - case Type::VectorTyID: Out << "VectorType"; break; - case Type::PointerTyID: Out << "PointerType"; break; - case Type::OpaqueTyID: Out << "OpaqueType"; break; - default: Out << "NoSuchDerivedType"; break; - } - Out << ">(" << I->second << "_fwd.get());"; - nl(Out); nl(Out); - UnresolvedTypes.erase(I); - } - - // Finally, separate the type definition from other with a newline. - nl(Out); - - // We weren't a recursive type - return false; -} - -// Prints a type definition. Returns true if it could not resolve all the types -// in the definition but had to use a forward reference. -void -CppWriter::printType(const Type* Ty) { - assert(TypeStack.empty()); - TypeStack.clear(); - printTypeInternal(Ty); - assert(TypeStack.empty()); -} - -void -CppWriter::printTypes(const Module* M) { - - // Walk the symbol table and print out all its types - const TypeSymbolTable& symtab = M->getTypeSymbolTable(); - for (TypeSymbolTable::const_iterator TI = symtab.begin(), TE = symtab.end(); - TI != TE; ++TI) { - - // For primitive types and types already defined, just add a name - TypeMap::const_iterator TNI = TypeNames.find(TI->second); - if (TI->second->isInteger() || TI->second->isPrimitiveType() || - TNI != TypeNames.end()) { - Out << "mod->addTypeName(\""; - printEscapedString(TI->first); - Out << "\", " << getCppName(TI->second) << ");"; - nl(Out); - // For everything else, define the type - } else { - printType(TI->second); - } - } - - // Add all of the global variables to the value table... - for (Module::const_global_iterator I = TheModule->global_begin(), - E = TheModule->global_end(); I != E; ++I) { - if (I->hasInitializer()) - printType(I->getInitializer()->getType()); - printType(I->getType()); - } - - // Add all the functions to the table - for (Module::const_iterator FI = TheModule->begin(), FE = TheModule->end(); - FI != FE; ++FI) { - printType(FI->getReturnType()); - printType(FI->getFunctionType()); - // Add all the function arguments - for(Function::const_arg_iterator AI = FI->arg_begin(), - AE = FI->arg_end(); AI != AE; ++AI) { - printType(AI->getType()); - } - - // Add all of the basic blocks and instructions - for (Function::const_iterator BB = FI->begin(), - E = FI->end(); BB != E; ++BB) { - printType(BB->getType()); - for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E; - ++I) { - printType(I->getType()); - for (unsigned i = 0; i < I->getNumOperands(); ++i) - printType(I->getOperand(i)->getType()); - } - } - } -} - - -// printConstant - Print out a constant pool entry... -void CppWriter::printConstant(const Constant *CV) { - // First, if the constant is actually a GlobalValue (variable or function) or - // its already in the constant list then we've printed it already and we can - // just return. - if (isa(CV) || ValueNames.find(CV) != ValueNames.end()) - return; - - std::string constName(getCppName(CV)); - std::string typeName(getCppName(CV->getType())); - if (CV->isNullValue()) { - Out << "Constant* " << constName << " = Constant::getNullValue(" - << typeName << ");"; - nl(Out); - return; - } - if (isa(CV)) { - // Skip variables and functions, we emit them elsewhere - return; - } - if (const ConstantInt *CI = dyn_cast(CV)) { - Out << "ConstantInt* " << constName << " = ConstantInt::get(APInt(" - << cast(CI->getType())->getBitWidth() << ", " - << " \"" << CI->getValue().toStringSigned(10) << "\", 10));"; - } else if (isa(CV)) { - Out << "ConstantAggregateZero* " << constName - << " = ConstantAggregateZero::get(" << typeName << ");"; - } else if (isa(CV)) { - Out << "ConstantPointerNull* " << constName - << " = ConstanPointerNull::get(" << typeName << ");"; - } else if (const ConstantFP *CFP = dyn_cast(CV)) { - Out << "ConstantFP* " << constName << " = "; - printCFP(CFP); - Out << ";"; - } else if (const ConstantArray *CA = dyn_cast(CV)) { - if (CA->isString() && CA->getType()->getElementType() == Type::Int8Ty) { - Out << "Constant* " << constName << " = ConstantArray::get(\""; - std::string tmp = CA->getAsString(); - bool nullTerminate = false; - if (tmp[tmp.length()-1] == 0) { - tmp.erase(tmp.length()-1); - nullTerminate = true; - } - printEscapedString(tmp); - // Determine if we want null termination or not. - if (nullTerminate) - Out << "\", true"; // Indicate that the null terminator should be added. - else - Out << "\", false";// No null terminator - Out << ");"; - } else { - Out << "std::vector " << constName << "_elems;"; - nl(Out); - unsigned N = CA->getNumOperands(); - for (unsigned i = 0; i < N; ++i) { - printConstant(CA->getOperand(i)); // recurse to print operands - Out << constName << "_elems.push_back(" - << getCppName(CA->getOperand(i)) << ");"; - nl(Out); - } - Out << "Constant* " << constName << " = ConstantArray::get(" - << typeName << ", " << constName << "_elems);"; - } - } else if (const ConstantStruct *CS = dyn_cast(CV)) { - Out << "std::vector " << constName << "_fields;"; - nl(Out); - unsigned N = CS->getNumOperands(); - for (unsigned i = 0; i < N; i++) { - printConstant(CS->getOperand(i)); - Out << constName << "_fields.push_back(" - << getCppName(CS->getOperand(i)) << ");"; - nl(Out); - } - Out << "Constant* " << constName << " = ConstantStruct::get(" - << typeName << ", " << constName << "_fields);"; - } else if (const ConstantVector *CP = dyn_cast(CV)) { - Out << "std::vector " << constName << "_elems;"; - nl(Out); - unsigned N = CP->getNumOperands(); - for (unsigned i = 0; i < N; ++i) { - printConstant(CP->getOperand(i)); - Out << constName << "_elems.push_back(" - << getCppName(CP->getOperand(i)) << ");"; - nl(Out); - } - Out << "Constant* " << constName << " = ConstantVector::get(" - << typeName << ", " << constName << "_elems);"; - } else if (isa(CV)) { - Out << "UndefValue* " << constName << " = UndefValue::get(" - << typeName << ");"; - } else if (const ConstantExpr *CE = dyn_cast(CV)) { - if (CE->getOpcode() == Instruction::GetElementPtr) { - Out << "std::vector " << constName << "_indices;"; - nl(Out); - printConstant(CE->getOperand(0)); - for (unsigned i = 1; i < CE->getNumOperands(); ++i ) { - printConstant(CE->getOperand(i)); - Out << constName << "_indices.push_back(" - << getCppName(CE->getOperand(i)) << ");"; - nl(Out); - } - Out << "Constant* " << constName - << " = ConstantExpr::getGetElementPtr(" - << getCppName(CE->getOperand(0)) << ", " - << "&" << constName << "_indices[0], " - << constName << "_indices.size()" - << " );"; - } else if (CE->isCast()) { - printConstant(CE->getOperand(0)); - Out << "Constant* " << constName << " = ConstantExpr::getCast("; - switch (CE->getOpcode()) { - default: assert(0 && "Invalid cast opcode"); - case Instruction::Trunc: Out << "Instruction::Trunc"; break; - case Instruction::ZExt: Out << "Instruction::ZExt"; break; - case Instruction::SExt: Out << "Instruction::SExt"; break; - case Instruction::FPTrunc: Out << "Instruction::FPTrunc"; break; - case Instruction::FPExt: Out << "Instruction::FPExt"; break; - case Instruction::FPToUI: Out << "Instruction::FPToUI"; break; - case Instruction::FPToSI: Out << "Instruction::FPToSI"; break; - case Instruction::UIToFP: Out << "Instruction::UIToFP"; break; - case Instruction::SIToFP: Out << "Instruction::SIToFP"; break; - case Instruction::PtrToInt: Out << "Instruction::PtrToInt"; break; - case Instruction::IntToPtr: Out << "Instruction::IntToPtr"; break; - case Instruction::BitCast: Out << "Instruction::BitCast"; break; - } - Out << ", " << getCppName(CE->getOperand(0)) << ", " - << getCppName(CE->getType()) << ");"; - } else { - unsigned N = CE->getNumOperands(); - for (unsigned i = 0; i < N; ++i ) { - printConstant(CE->getOperand(i)); - } - Out << "Constant* " << constName << " = ConstantExpr::"; - switch (CE->getOpcode()) { - case Instruction::Add: Out << "getAdd("; break; - case Instruction::Sub: Out << "getSub("; break; - case Instruction::Mul: Out << "getMul("; break; - case Instruction::UDiv: Out << "getUDiv("; break; - case Instruction::SDiv: Out << "getSDiv("; break; - case Instruction::FDiv: Out << "getFDiv("; break; - case Instruction::URem: Out << "getURem("; break; - case Instruction::SRem: Out << "getSRem("; break; - case Instruction::FRem: Out << "getFRem("; break; - case Instruction::And: Out << "getAnd("; break; - case Instruction::Or: Out << "getOr("; break; - case Instruction::Xor: Out << "getXor("; break; - case Instruction::ICmp: - Out << "getICmp(ICmpInst::ICMP_"; - switch (CE->getPredicate()) { - case ICmpInst::ICMP_EQ: Out << "EQ"; break; - case ICmpInst::ICMP_NE: Out << "NE"; break; - case ICmpInst::ICMP_SLT: Out << "SLT"; break; - case ICmpInst::ICMP_ULT: Out << "ULT"; break; - case ICmpInst::ICMP_SGT: Out << "SGT"; break; - case ICmpInst::ICMP_UGT: Out << "UGT"; break; - case ICmpInst::ICMP_SLE: Out << "SLE"; break; - case ICmpInst::ICMP_ULE: Out << "ULE"; break; - case ICmpInst::ICMP_SGE: Out << "SGE"; break; - case ICmpInst::ICMP_UGE: Out << "UGE"; break; - default: error("Invalid ICmp Predicate"); - } - break; - case Instruction::FCmp: - Out << "getFCmp(FCmpInst::FCMP_"; - switch (CE->getPredicate()) { - case FCmpInst::FCMP_FALSE: Out << "FALSE"; break; - case FCmpInst::FCMP_ORD: Out << "ORD"; break; - case FCmpInst::FCMP_UNO: Out << "UNO"; break; - case FCmpInst::FCMP_OEQ: Out << "OEQ"; break; - case FCmpInst::FCMP_UEQ: Out << "UEQ"; break; - case FCmpInst::FCMP_ONE: Out << "ONE"; break; - case FCmpInst::FCMP_UNE: Out << "UNE"; break; - case FCmpInst::FCMP_OLT: Out << "OLT"; break; - case FCmpInst::FCMP_ULT: Out << "ULT"; break; - case FCmpInst::FCMP_OGT: Out << "OGT"; break; - case FCmpInst::FCMP_UGT: Out << "UGT"; break; - case FCmpInst::FCMP_OLE: Out << "OLE"; break; - case FCmpInst::FCMP_ULE: Out << "ULE"; break; - case FCmpInst::FCMP_OGE: Out << "OGE"; break; - case FCmpInst::FCMP_UGE: Out << "UGE"; break; - case FCmpInst::FCMP_TRUE: Out << "TRUE"; break; - default: error("Invalid FCmp Predicate"); - } - break; - case Instruction::Shl: Out << "getShl("; break; - case Instruction::LShr: Out << "getLShr("; break; - case Instruction::AShr: Out << "getAShr("; break; - case Instruction::Select: Out << "getSelect("; break; - case Instruction::ExtractElement: Out << "getExtractElement("; break; - case Instruction::InsertElement: Out << "getInsertElement("; break; - case Instruction::ShuffleVector: Out << "getShuffleVector("; break; - default: - error("Invalid constant expression"); - break; - } - Out << getCppName(CE->getOperand(0)); - for (unsigned i = 1; i < CE->getNumOperands(); ++i) - Out << ", " << getCppName(CE->getOperand(i)); - Out << ");"; - } - } else { - error("Bad Constant"); - Out << "Constant* " << constName << " = 0; "; - } - nl(Out); -} - -void -CppWriter::printConstants(const Module* M) { - // Traverse all the global variables looking for constant initializers - for (Module::const_global_iterator I = TheModule->global_begin(), - E = TheModule->global_end(); I != E; ++I) - if (I->hasInitializer()) - printConstant(I->getInitializer()); - - // Traverse the LLVM functions looking for constants - for (Module::const_iterator FI = TheModule->begin(), FE = TheModule->end(); - FI != FE; ++FI) { - // Add all of the basic blocks and instructions - for (Function::const_iterator BB = FI->begin(), - E = FI->end(); BB != E; ++BB) { - for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E; - ++I) { - for (unsigned i = 0; i < I->getNumOperands(); ++i) { - if (Constant* C = dyn_cast(I->getOperand(i))) { - printConstant(C); - } - } - } - } - } -} - -void CppWriter::printVariableUses(const GlobalVariable *GV) { - nl(Out) << "// Type Definitions"; - nl(Out); - printType(GV->getType()); - if (GV->hasInitializer()) { - Constant* Init = GV->getInitializer(); - printType(Init->getType()); - if (Function* F = dyn_cast(Init)) { - nl(Out)<< "/ Function Declarations"; nl(Out); - printFunctionHead(F); - } else if (GlobalVariable* gv = dyn_cast(Init)) { - nl(Out) << "// Global Variable Declarations"; nl(Out); - printVariableHead(gv); - } else { - nl(Out) << "// Constant Definitions"; nl(Out); - printConstant(gv); - } - if (GlobalVariable* gv = dyn_cast(Init)) { - nl(Out) << "// Global Variable Definitions"; nl(Out); - printVariableBody(gv); - } - } -} - -void CppWriter::printVariableHead(const GlobalVariable *GV) { - nl(Out) << "GlobalVariable* " << getCppName(GV); - if (is_inline) { - Out << " = mod->getGlobalVariable("; - printEscapedString(GV->getName()); - Out << ", " << getCppName(GV->getType()->getElementType()) << ",true)"; - nl(Out) << "if (!" << getCppName(GV) << ") {"; - in(); nl(Out) << getCppName(GV); - } - Out << " = new GlobalVariable("; - nl(Out) << "/*Type=*/"; - printCppName(GV->getType()->getElementType()); - Out << ","; - nl(Out) << "/*isConstant=*/" << (GV->isConstant()?"true":"false"); - Out << ","; - nl(Out) << "/*Linkage=*/"; - printLinkageType(GV->getLinkage()); - Out << ","; - nl(Out) << "/*Initializer=*/0, "; - if (GV->hasInitializer()) { - Out << "// has initializer, specified below"; - } - nl(Out) << "/*Name=*/\""; - printEscapedString(GV->getName()); - Out << "\","; - nl(Out) << "mod);"; - nl(Out); - - if (GV->hasSection()) { - printCppName(GV); - Out << "->setSection(\""; - printEscapedString(GV->getSection()); - Out << "\");"; - nl(Out); - } - if (GV->getAlignment()) { - printCppName(GV); - Out << "->setAlignment(" << utostr(GV->getAlignment()) << ");"; - nl(Out); - }; - if (GV->getVisibility() != GlobalValue::DefaultVisibility) { - printCppName(GV); - Out << "->setVisibility("; - printVisibilityType(GV->getVisibility()); - Out << ");"; - nl(Out); - } - if (is_inline) { - out(); Out << "}"; nl(Out); - } -} - -void -CppWriter::printVariableBody(const GlobalVariable *GV) { - if (GV->hasInitializer()) { - printCppName(GV); - Out << "->setInitializer("; - //if (!isagetInitializer())) - //else - Out << getCppName(GV->getInitializer()) << ");"; - nl(Out); - } -} - -std::string -CppWriter::getOpName(Value* V) { - if (!isa(V) || DefinedValues.find(V) != DefinedValues.end()) - return getCppName(V); - - // See if its alread in the map of forward references, if so just return the - // name we already set up for it - ForwardRefMap::const_iterator I = ForwardRefs.find(V); - if (I != ForwardRefs.end()) - return I->second; - - // This is a new forward reference. Generate a unique name for it - std::string result(std::string("fwdref_") + utostr(uniqueNum++)); - - // Yes, this is a hack. An Argument is the smallest instantiable value that - // we can make as a placeholder for the real value. We'll replace these - // Argument instances later. - Out << "Argument* " << result << " = new Argument(" - << getCppName(V->getType()) << ");"; - nl(Out); - ForwardRefs[V] = result; - return result; -} - -// printInstruction - This member is called for each Instruction in a function. -void -CppWriter::printInstruction(const Instruction *I, const std::string& bbname) { - std::string iName(getCppName(I)); - - // Before we emit this instruction, we need to take care of generating any - // forward references. So, we get the names of all the operands in advance - std::string* opNames = new std::string[I->getNumOperands()]; - for (unsigned i = 0; i < I->getNumOperands(); i++) { - opNames[i] = getOpName(I->getOperand(i)); - } - - switch (I->getOpcode()) { - case Instruction::Ret: { - const ReturnInst* ret = cast(I); - Out << "ReturnInst::Create(" - << (ret->getReturnValue() ? opNames[0] + ", " : "") << bbname << ");"; - break; - } - case Instruction::Br: { - const BranchInst* br = cast(I); - Out << "BranchInst::Create(" ; - if (br->getNumOperands() == 3 ) { - Out << opNames[0] << ", " - << opNames[1] << ", " - << opNames[2] << ", "; - - } else if (br->getNumOperands() == 1) { - Out << opNames[0] << ", "; - } else { - error("Branch with 2 operands?"); - } - Out << bbname << ");"; - break; - } - case Instruction::Switch: { - const SwitchInst* sw = cast(I); - Out << "SwitchInst* " << iName << " = SwitchInst::Create(" - << opNames[0] << ", " - << opNames[1] << ", " - << sw->getNumCases() << ", " << bbname << ");"; - nl(Out); - for (unsigned i = 2; i < sw->getNumOperands(); i += 2 ) { - Out << iName << "->addCase(" - << opNames[i] << ", " - << opNames[i+1] << ");"; - nl(Out); - } - break; - } - case Instruction::Invoke: { - const InvokeInst* inv = cast(I); - Out << "std::vector " << iName << "_params;"; - nl(Out); - for (unsigned i = 3; i < inv->getNumOperands(); ++i) { - Out << iName << "_params.push_back(" - << opNames[i] << ");"; - nl(Out); - } - Out << "InvokeInst *" << iName << " = InvokeInst::Create(" - << opNames[0] << ", " - << opNames[1] << ", " - << opNames[2] << ", " - << iName << "_params.begin(), " << iName << "_params.end(), \""; - printEscapedString(inv->getName()); - Out << "\", " << bbname << ");"; - nl(Out) << iName << "->setCallingConv("; - printCallingConv(inv->getCallingConv()); - Out << ");"; - printParamAttrs(inv->getParamAttrs(), iName); - Out << iName << "->setParamAttrs(" << iName << "_PAL);"; - nl(Out); - break; - } - case Instruction::Unwind: { - Out << "new UnwindInst(" - << bbname << ");"; - break; - } - case Instruction::Unreachable:{ - Out << "new UnreachableInst(" - << bbname << ");"; - break; - } - case Instruction::Add: - case Instruction::Sub: - case Instruction::Mul: - case Instruction::UDiv: - case Instruction::SDiv: - case Instruction::FDiv: - case Instruction::URem: - case Instruction::SRem: - case Instruction::FRem: - case Instruction::And: - case Instruction::Or: - case Instruction::Xor: - case Instruction::Shl: - case Instruction::LShr: - case Instruction::AShr:{ - Out << "BinaryOperator* " << iName << " = BinaryOperator::create("; - switch (I->getOpcode()) { - case Instruction::Add: Out << "Instruction::Add"; break; - case Instruction::Sub: Out << "Instruction::Sub"; break; - case Instruction::Mul: Out << "Instruction::Mul"; break; - case Instruction::UDiv:Out << "Instruction::UDiv"; break; - case Instruction::SDiv:Out << "Instruction::SDiv"; break; - case Instruction::FDiv:Out << "Instruction::FDiv"; break; - case Instruction::URem:Out << "Instruction::URem"; break; - case Instruction::SRem:Out << "Instruction::SRem"; break; - case Instruction::FRem:Out << "Instruction::FRem"; break; - case Instruction::And: Out << "Instruction::And"; break; - case Instruction::Or: Out << "Instruction::Or"; break; - case Instruction::Xor: Out << "Instruction::Xor"; break; - case Instruction::Shl: Out << "Instruction::Shl"; break; - case Instruction::LShr:Out << "Instruction::LShr"; break; - case Instruction::AShr:Out << "Instruction::AShr"; break; - default: Out << "Instruction::BadOpCode"; break; - } - Out << ", " << opNames[0] << ", " << opNames[1] << ", \""; - printEscapedString(I->getName()); - Out << "\", " << bbname << ");"; - break; - } - case Instruction::FCmp: { - Out << "FCmpInst* " << iName << " = new FCmpInst("; - switch (cast(I)->getPredicate()) { - case FCmpInst::FCMP_FALSE: Out << "FCmpInst::FCMP_FALSE"; break; - case FCmpInst::FCMP_OEQ : Out << "FCmpInst::FCMP_OEQ"; break; - case FCmpInst::FCMP_OGT : Out << "FCmpInst::FCMP_OGT"; break; - case FCmpInst::FCMP_OGE : Out << "FCmpInst::FCMP_OGE"; break; - case FCmpInst::FCMP_OLT : Out << "FCmpInst::FCMP_OLT"; break; - case FCmpInst::FCMP_OLE : Out << "FCmpInst::FCMP_OLE"; break; - case FCmpInst::FCMP_ONE : Out << "FCmpInst::FCMP_ONE"; break; - case FCmpInst::FCMP_ORD : Out << "FCmpInst::FCMP_ORD"; break; - case FCmpInst::FCMP_UNO : Out << "FCmpInst::FCMP_UNO"; break; - case FCmpInst::FCMP_UEQ : Out << "FCmpInst::FCMP_UEQ"; break; - case FCmpInst::FCMP_UGT : Out << "FCmpInst::FCMP_UGT"; break; - case FCmpInst::FCMP_UGE : Out << "FCmpInst::FCMP_UGE"; break; - case FCmpInst::FCMP_ULT : Out << "FCmpInst::FCMP_ULT"; break; - case FCmpInst::FCMP_ULE : Out << "FCmpInst::FCMP_ULE"; break; - case FCmpInst::FCMP_UNE : Out << "FCmpInst::FCMP_UNE"; break; - case FCmpInst::FCMP_TRUE : Out << "FCmpInst::FCMP_TRUE"; break; - default: Out << "FCmpInst::BAD_ICMP_PREDICATE"; break; - } - Out << ", " << opNames[0] << ", " << opNames[1] << ", \""; - printEscapedString(I->getName()); - Out << "\", " << bbname << ");"; - break; - } - case Instruction::ICmp: { - Out << "ICmpInst* " << iName << " = new ICmpInst("; - switch (cast(I)->getPredicate()) { - case ICmpInst::ICMP_EQ: Out << "ICmpInst::ICMP_EQ"; break; - case ICmpInst::ICMP_NE: Out << "ICmpInst::ICMP_NE"; break; - case ICmpInst::ICMP_ULE: Out << "ICmpInst::ICMP_ULE"; break; - case ICmpInst::ICMP_SLE: Out << "ICmpInst::ICMP_SLE"; break; - case ICmpInst::ICMP_UGE: Out << "ICmpInst::ICMP_UGE"; break; - case ICmpInst::ICMP_SGE: Out << "ICmpInst::ICMP_SGE"; break; - case ICmpInst::ICMP_ULT: Out << "ICmpInst::ICMP_ULT"; break; - case ICmpInst::ICMP_SLT: Out << "ICmpInst::ICMP_SLT"; break; - case ICmpInst::ICMP_UGT: Out << "ICmpInst::ICMP_UGT"; break; - case ICmpInst::ICMP_SGT: Out << "ICmpInst::ICMP_SGT"; break; - default: Out << "ICmpInst::BAD_ICMP_PREDICATE"; break; - } - Out << ", " << opNames[0] << ", " << opNames[1] << ", \""; - printEscapedString(I->getName()); - Out << "\", " << bbname << ");"; - break; - } - case Instruction::Malloc: { - const MallocInst* mallocI = cast(I); - Out << "MallocInst* " << iName << " = new MallocInst(" - << getCppName(mallocI->getAllocatedType()) << ", "; - if (mallocI->isArrayAllocation()) - Out << opNames[0] << ", " ; - Out << "\""; - printEscapedString(mallocI->getName()); - Out << "\", " << bbname << ");"; - if (mallocI->getAlignment()) - nl(Out) << iName << "->setAlignment(" - << mallocI->getAlignment() << ");"; - break; - } - case Instruction::Free: { - Out << "FreeInst* " << iName << " = new FreeInst(" - << getCppName(I->getOperand(0)) << ", " << bbname << ");"; - break; - } - case Instruction::Alloca: { - const AllocaInst* allocaI = cast(I); - Out << "AllocaInst* " << iName << " = new AllocaInst(" - << getCppName(allocaI->getAllocatedType()) << ", "; - if (allocaI->isArrayAllocation()) - Out << opNames[0] << ", "; - Out << "\""; - printEscapedString(allocaI->getName()); - Out << "\", " << bbname << ");"; - if (allocaI->getAlignment()) - nl(Out) << iName << "->setAlignment(" - << allocaI->getAlignment() << ");"; - break; - } - case Instruction::Load:{ - const LoadInst* load = cast(I); - Out << "LoadInst* " << iName << " = new LoadInst(" - << opNames[0] << ", \""; - printEscapedString(load->getName()); - Out << "\", " << (load->isVolatile() ? "true" : "false" ) - << ", " << bbname << ");"; - break; - } - case Instruction::Store: { - const StoreInst* store = cast(I); - Out << "StoreInst* " << iName << " = new StoreInst(" - << opNames[0] << ", " - << opNames[1] << ", " - << (store->isVolatile() ? "true" : "false") - << ", " << bbname << ");"; - break; - } - case Instruction::GetElementPtr: { - const GetElementPtrInst* gep = cast(I); - if (gep->getNumOperands() <= 2) { - Out << "GetElementPtrInst* " << iName << " = GetElementPtrInst::Create(" - << opNames[0]; - if (gep->getNumOperands() == 2) - Out << ", " << opNames[1]; - } else { - Out << "std::vector " << iName << "_indices;"; - nl(Out); - for (unsigned i = 1; i < gep->getNumOperands(); ++i ) { - Out << iName << "_indices.push_back(" - << opNames[i] << ");"; - nl(Out); - } - Out << "Instruction* " << iName << " = GetElementPtrInst::Create(" - << opNames[0] << ", " << iName << "_indices.begin(), " - << iName << "_indices.end()"; - } - Out << ", \""; - printEscapedString(gep->getName()); - Out << "\", " << bbname << ");"; - break; - } - case Instruction::PHI: { - const PHINode* phi = cast(I); - - Out << "PHINode* " << iName << " = PHINode::Create(" - << getCppName(phi->getType()) << ", \""; - printEscapedString(phi->getName()); - Out << "\", " << bbname << ");"; - nl(Out) << iName << "->reserveOperandSpace(" - << phi->getNumIncomingValues() - << ");"; - nl(Out); - for (unsigned i = 0; i < phi->getNumOperands(); i+=2) { - Out << iName << "->addIncoming(" - << opNames[i] << ", " << opNames[i+1] << ");"; - nl(Out); - } - break; - } - case Instruction::Trunc: - case Instruction::ZExt: - case Instruction::SExt: - case Instruction::FPTrunc: - case Instruction::FPExt: - case Instruction::FPToUI: - case Instruction::FPToSI: - case Instruction::UIToFP: - case Instruction::SIToFP: - case Instruction::PtrToInt: - case Instruction::IntToPtr: - case Instruction::BitCast: { - const CastInst* cst = cast(I); - Out << "CastInst* " << iName << " = new "; - switch (I->getOpcode()) { - case Instruction::Trunc: Out << "TruncInst"; break; - case Instruction::ZExt: Out << "ZExtInst"; break; - case Instruction::SExt: Out << "SExtInst"; break; - case Instruction::FPTrunc: Out << "FPTruncInst"; break; - case Instruction::FPExt: Out << "FPExtInst"; break; - case Instruction::FPToUI: Out << "FPToUIInst"; break; - case Instruction::FPToSI: Out << "FPToSIInst"; break; - case Instruction::UIToFP: Out << "UIToFPInst"; break; - case Instruction::SIToFP: Out << "SIToFPInst"; break; - case Instruction::PtrToInt: Out << "PtrToIntInst"; break; - case Instruction::IntToPtr: Out << "IntToPtrInst"; break; - case Instruction::BitCast: Out << "BitCastInst"; break; - default: assert(!"Unreachable"); break; - } - Out << "(" << opNames[0] << ", " - << getCppName(cst->getType()) << ", \""; - printEscapedString(cst->getName()); - Out << "\", " << bbname << ");"; - break; - } - case Instruction::Call:{ - const CallInst* call = cast(I); - if (InlineAsm* ila = dyn_cast(call->getOperand(0))) { - Out << "InlineAsm* " << getCppName(ila) << " = InlineAsm::get(" - << getCppName(ila->getFunctionType()) << ", \"" - << ila->getAsmString() << "\", \"" - << ila->getConstraintString() << "\"," - << (ila->hasSideEffects() ? "true" : "false") << ");"; - nl(Out); - } - if (call->getNumOperands() > 2) { - Out << "std::vector " << iName << "_params;"; - nl(Out); - for (unsigned i = 1; i < call->getNumOperands(); ++i) { - Out << iName << "_params.push_back(" << opNames[i] << ");"; - nl(Out); - } - Out << "CallInst* " << iName << " = CallInst::Create(" - << opNames[0] << ", " << iName << "_params.begin(), " - << iName << "_params.end(), \""; - } else if (call->getNumOperands() == 2) { - Out << "CallInst* " << iName << " = CallInst::Create(" - << opNames[0] << ", " << opNames[1] << ", \""; - } else { - Out << "CallInst* " << iName << " = CallInst::Create(" << opNames[0] - << ", \""; - } - printEscapedString(call->getName()); - Out << "\", " << bbname << ");"; - nl(Out) << iName << "->setCallingConv("; - printCallingConv(call->getCallingConv()); - Out << ");"; - nl(Out) << iName << "->setTailCall(" - << (call->isTailCall() ? "true":"false"); - Out << ");"; - printParamAttrs(call->getParamAttrs(), iName); - Out << iName << "->setParamAttrs(" << iName << "_PAL);"; - nl(Out); - break; - } - case Instruction::Select: { - const SelectInst* sel = cast(I); - Out << "SelectInst* " << getCppName(sel) << " = SelectInst::Create("; - Out << opNames[0] << ", " << opNames[1] << ", " << opNames[2] << ", \""; - printEscapedString(sel->getName()); - Out << "\", " << bbname << ");"; - break; - } - case Instruction::UserOp1: - /// FALL THROUGH - case Instruction::UserOp2: { - /// FIXME: What should be done here? - break; - } - case Instruction::VAArg: { - const VAArgInst* va = cast(I); - Out << "VAArgInst* " << getCppName(va) << " = new VAArgInst(" - << opNames[0] << ", " << getCppName(va->getType()) << ", \""; - printEscapedString(va->getName()); - Out << "\", " << bbname << ");"; - break; - } - case Instruction::ExtractElement: { - const ExtractElementInst* eei = cast(I); - Out << "ExtractElementInst* " << getCppName(eei) - << " = new ExtractElementInst(" << opNames[0] - << ", " << opNames[1] << ", \""; - printEscapedString(eei->getName()); - Out << "\", " << bbname << ");"; - break; - } - case Instruction::InsertElement: { - const InsertElementInst* iei = cast(I); - Out << "InsertElementInst* " << getCppName(iei) - << " = InsertElementInst::Create(" << opNames[0] - << ", " << opNames[1] << ", " << opNames[2] << ", \""; - printEscapedString(iei->getName()); - Out << "\", " << bbname << ");"; - break; - } - case Instruction::ShuffleVector: { - const ShuffleVectorInst* svi = cast(I); - Out << "ShuffleVectorInst* " << getCppName(svi) - << " = new ShuffleVectorInst(" << opNames[0] - << ", " << opNames[1] << ", " << opNames[2] << ", \""; - printEscapedString(svi->getName()); - Out << "\", " << bbname << ");"; - break; - } - } - DefinedValues.insert(I); - nl(Out); - delete [] opNames; -} - -// Print out the types, constants and declarations needed by one function -void CppWriter::printFunctionUses(const Function* F) { - - nl(Out) << "// Type Definitions"; nl(Out); - if (!is_inline) { - // Print the function's return type - printType(F->getReturnType()); - - // Print the function's function type - printType(F->getFunctionType()); - - // Print the types of each of the function's arguments - for(Function::const_arg_iterator AI = F->arg_begin(), AE = F->arg_end(); - AI != AE; ++AI) { - printType(AI->getType()); - } - } - - // Print type definitions for every type referenced by an instruction and - // make a note of any global values or constants that are referenced - SmallPtrSet gvs; - SmallPtrSet consts; - for (Function::const_iterator BB = F->begin(), BE = F->end(); BB != BE; ++BB){ - for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); - I != E; ++I) { - // Print the type of the instruction itself - printType(I->getType()); - - // Print the type of each of the instruction's operands - for (unsigned i = 0; i < I->getNumOperands(); ++i) { - Value* operand = I->getOperand(i); - printType(operand->getType()); - - // If the operand references a GVal or Constant, make a note of it - if (GlobalValue* GV = dyn_cast(operand)) { - gvs.insert(GV); - if (GlobalVariable *GVar = dyn_cast(GV)) - if (GVar->hasInitializer()) - consts.insert(GVar->getInitializer()); - } else if (Constant* C = dyn_cast(operand)) - consts.insert(C); - } - } - } - - // Print the function declarations for any functions encountered - nl(Out) << "// Function Declarations"; nl(Out); - for (SmallPtrSet::iterator I = gvs.begin(), E = gvs.end(); - I != E; ++I) { - if (Function* Fun = dyn_cast(*I)) { - if (!is_inline || Fun != F) - printFunctionHead(Fun); - } - } - - // Print the global variable declarations for any variables encountered - nl(Out) << "// Global Variable Declarations"; nl(Out); - for (SmallPtrSet::iterator I = gvs.begin(), E = gvs.end(); - I != E; ++I) { - if (GlobalVariable* F = dyn_cast(*I)) - printVariableHead(F); - } - - // Print the constants found - nl(Out) << "// Constant Definitions"; nl(Out); - for (SmallPtrSet::iterator I = consts.begin(), E = consts.end(); - I != E; ++I) { - printConstant(*I); - } - - // Process the global variables definitions now that all the constants have - // been emitted. These definitions just couple the gvars with their constant - // initializers. - nl(Out) << "// Global Variable Definitions"; nl(Out); - for (SmallPtrSet::iterator I = gvs.begin(), E = gvs.end(); - I != E; ++I) { - if (GlobalVariable* GV = dyn_cast(*I)) - printVariableBody(GV); - } -} - -void CppWriter::printFunctionHead(const Function* F) { - nl(Out) << "Function* " << getCppName(F); - if (is_inline) { - Out << " = mod->getFunction(\""; - printEscapedString(F->getName()); - Out << "\", " << getCppName(F->getFunctionType()) << ");"; - nl(Out) << "if (!" << getCppName(F) << ") {"; - nl(Out) << getCppName(F); - } - Out<< " = Function::Create("; - nl(Out,1) << "/*Type=*/" << getCppName(F->getFunctionType()) << ","; - nl(Out) << "/*Linkage=*/"; - printLinkageType(F->getLinkage()); - Out << ","; - nl(Out) << "/*Name=*/\""; - printEscapedString(F->getName()); - Out << "\", mod); " << (F->isDeclaration()? "// (external, no body)" : ""); - nl(Out,-1); - printCppName(F); - Out << "->setCallingConv("; - printCallingConv(F->getCallingConv()); - Out << ");"; - nl(Out); - if (F->hasSection()) { - printCppName(F); - Out << "->setSection(\"" << F->getSection() << "\");"; - nl(Out); - } - if (F->getAlignment()) { - printCppName(F); - Out << "->setAlignment(" << F->getAlignment() << ");"; - nl(Out); - } - if (F->getVisibility() != GlobalValue::DefaultVisibility) { - printCppName(F); - Out << "->setVisibility("; - printVisibilityType(F->getVisibility()); - Out << ");"; - nl(Out); - } - if (F->hasCollector()) { - printCppName(F); - Out << "->setCollector(\"" << F->getCollector() << "\");"; - nl(Out); - } - if (is_inline) { - Out << "}"; - nl(Out); - } - printParamAttrs(F->getParamAttrs(), getCppName(F)); - printCppName(F); - Out << "->setParamAttrs(" << getCppName(F) << "_PAL);"; - nl(Out); -} - -void CppWriter::printFunctionBody(const Function *F) { - if (F->isDeclaration()) - return; // external functions have no bodies. - - // Clear the DefinedValues and ForwardRefs maps because we can't have - // cross-function forward refs - ForwardRefs.clear(); - DefinedValues.clear(); - - // Create all the argument values - if (!is_inline) { - if (!F->arg_empty()) { - Out << "Function::arg_iterator args = " << getCppName(F) - << "->arg_begin();"; - nl(Out); - } - for (Function::const_arg_iterator AI = F->arg_begin(), AE = F->arg_end(); - AI != AE; ++AI) { - Out << "Value* " << getCppName(AI) << " = args++;"; - nl(Out); - if (AI->hasName()) { - Out << getCppName(AI) << "->setName(\"" << AI->getName() << "\");"; - nl(Out); - } - } - } - - // Create all the basic blocks - nl(Out); - for (Function::const_iterator BI = F->begin(), BE = F->end(); - BI != BE; ++BI) { - std::string bbname(getCppName(BI)); - Out << "BasicBlock* " << bbname << " = BasicBlock::Create(\""; - if (BI->hasName()) - printEscapedString(BI->getName()); - Out << "\"," << getCppName(BI->getParent()) << ",0);"; - nl(Out); - } - - // Output all of its basic blocks... for the function - for (Function::const_iterator BI = F->begin(), BE = F->end(); - BI != BE; ++BI) { - std::string bbname(getCppName(BI)); - nl(Out) << "// Block " << BI->getName() << " (" << bbname << ")"; - nl(Out); - - // Output all of the instructions in the basic block... - for (BasicBlock::const_iterator I = BI->begin(), E = BI->end(); - I != E; ++I) { - printInstruction(I,bbname); - } - } - - // Loop over the ForwardRefs and resolve them now that all instructions - // are generated. - if (!ForwardRefs.empty()) { - nl(Out) << "// Resolve Forward References"; - nl(Out); - } - - while (!ForwardRefs.empty()) { - ForwardRefMap::iterator I = ForwardRefs.begin(); - Out << I->second << "->replaceAllUsesWith(" - << getCppName(I->first) << "); delete " << I->second << ";"; - nl(Out); - ForwardRefs.erase(I); - } -} - -void CppWriter::printInline(const std::string& fname, const std::string& func) { - const Function* F = TheModule->getFunction(func); - if (!F) { - error(std::string("Function '") + func + "' not found in input module"); - return; - } - if (F->isDeclaration()) { - error(std::string("Function '") + func + "' is external!"); - return; - } - nl(Out) << "BasicBlock* " << fname << "(Module* mod, Function *" - << getCppName(F); - unsigned arg_count = 1; - for (Function::const_arg_iterator AI = F->arg_begin(), AE = F->arg_end(); - AI != AE; ++AI) { - Out << ", Value* arg_" << arg_count; - } - Out << ") {"; - nl(Out); - is_inline = true; - printFunctionUses(F); - printFunctionBody(F); - is_inline = false; - Out << "return " << getCppName(F->begin()) << ";"; - nl(Out) << "}"; - nl(Out); -} - -void CppWriter::printModuleBody() { - // Print out all the type definitions - nl(Out) << "// Type Definitions"; nl(Out); - printTypes(TheModule); - - // Functions can call each other and global variables can reference them so - // define all the functions first before emitting their function bodies. - nl(Out) << "// Function Declarations"; nl(Out); - for (Module::const_iterator I = TheModule->begin(), E = TheModule->end(); - I != E; ++I) - printFunctionHead(I); - - // Process the global variables declarations. We can't initialze them until - // after the constants are printed so just print a header for each global - nl(Out) << "// Global Variable Declarations\n"; nl(Out); - for (Module::const_global_iterator I = TheModule->global_begin(), - E = TheModule->global_end(); I != E; ++I) { - printVariableHead(I); - } - - // Print out all the constants definitions. Constants don't recurse except - // through GlobalValues. All GlobalValues have been declared at this point - // so we can proceed to generate the constants. - nl(Out) << "// Constant Definitions"; nl(Out); - printConstants(TheModule); - - // Process the global variables definitions now that all the constants have - // been emitted. These definitions just couple the gvars with their constant - // initializers. - nl(Out) << "// Global Variable Definitions"; nl(Out); - for (Module::const_global_iterator I = TheModule->global_begin(), - E = TheModule->global_end(); I != E; ++I) { - printVariableBody(I); - } - - // Finally, we can safely put out all of the function bodies. - nl(Out) << "// Function Definitions"; nl(Out); - for (Module::const_iterator I = TheModule->begin(), E = TheModule->end(); - I != E; ++I) { - if (!I->isDeclaration()) { - nl(Out) << "// Function: " << I->getName() << " (" << getCppName(I) - << ")"; - nl(Out) << "{"; - nl(Out,1); - printFunctionBody(I); - nl(Out,-1) << "}"; - nl(Out); - } - } -} - -void CppWriter::printProgram( - const std::string& fname, - const std::string& mName -) { - Out << "#include \n"; - Out << "#include \n"; - Out << "#include \n"; - Out << "#include \n"; - Out << "#include \n"; - Out << "#include \n"; - Out << "#include \n"; - Out << "#include \n"; - Out << "#include \n"; - Out << "#include \n"; - Out << "#include \n"; - Out << "#include \n"; - Out << "#include \n"; - Out << "#include \n"; - Out << "#include \n"; - Out << "#include \n\n"; - Out << "using namespace llvm;\n\n"; - Out << "Module* " << fname << "();\n\n"; - Out << "int main(int argc, char**argv) {\n"; - Out << " Module* Mod = " << fname << "();\n"; - Out << " verifyModule(*Mod, PrintMessageAction);\n"; - Out << " std::cerr.flush();\n"; - Out << " std::cout.flush();\n"; - Out << " PassManager PM;\n"; - Out << " PM.add(new PrintModulePass(&llvm::cout));\n"; - Out << " PM.run(*Mod);\n"; - Out << " return 0;\n"; - Out << "}\n\n"; - printModule(fname,mName); -} - -void CppWriter::printModule( - const std::string& fname, - const std::string& mName -) { - nl(Out) << "Module* " << fname << "() {"; - nl(Out,1) << "// Module Construction"; - nl(Out) << "Module* mod = new Module(\"" << mName << "\");"; - if (!TheModule->getTargetTriple().empty()) { - nl(Out) << "mod->setDataLayout(\"" << TheModule->getDataLayout() << "\");"; - } - if (!TheModule->getTargetTriple().empty()) { - nl(Out) << "mod->setTargetTriple(\"" << TheModule->getTargetTriple() - << "\");"; - } - - if (!TheModule->getModuleInlineAsm().empty()) { - nl(Out) << "mod->setModuleInlineAsm(\""; - printEscapedString(TheModule->getModuleInlineAsm()); - Out << "\");"; - } - nl(Out); - - // Loop over the dependent libraries and emit them. - Module::lib_iterator LI = TheModule->lib_begin(); - Module::lib_iterator LE = TheModule->lib_end(); - while (LI != LE) { - Out << "mod->addLibrary(\"" << *LI << "\");"; - nl(Out); - ++LI; - } - printModuleBody(); - nl(Out) << "return mod;"; - nl(Out,-1) << "}"; - nl(Out); -} - -void CppWriter::printContents( - const std::string& fname, // Name of generated function - const std::string& mName // Name of module generated module -) { - Out << "\nModule* " << fname << "(Module *mod) {\n"; - Out << "\nmod->setModuleIdentifier(\"" << mName << "\");\n"; - printModuleBody(); - Out << "\nreturn mod;\n"; - Out << "\n}\n"; -} - -void CppWriter::printFunction( - const std::string& fname, // Name of generated function - const std::string& funcName // Name of function to generate -) { - const Function* F = TheModule->getFunction(funcName); - if (!F) { - error(std::string("Function '") + funcName + "' not found in input module"); - return; - } - Out << "\nFunction* " << fname << "(Module *mod) {\n"; - printFunctionUses(F); - printFunctionHead(F); - printFunctionBody(F); - Out << "return " << getCppName(F) << ";\n"; - Out << "}\n"; -} - -void CppWriter::printFunctions() { - const Module::FunctionListType &funcs = TheModule->getFunctionList(); - Module::const_iterator I = funcs.begin(); - Module::const_iterator IE = funcs.end(); - - for (; I != IE; ++I) { - const Function &func = *I; - if (!func.isDeclaration()) { - std::string name("define_"); - name += func.getName(); - printFunction(name, func.getName()); - } - } -} - -void CppWriter::printVariable( - const std::string& fname, /// Name of generated function - const std::string& varName // Name of variable to generate -) { - const GlobalVariable* GV = TheModule->getNamedGlobal(varName); - - if (!GV) { - error(std::string("Variable '") + varName + "' not found in input module"); - return; - } - Out << "\nGlobalVariable* " << fname << "(Module *mod) {\n"; - printVariableUses(GV); - printVariableHead(GV); - printVariableBody(GV); - Out << "return " << getCppName(GV) << ";\n"; - Out << "}\n"; -} - -void CppWriter::printType( - const std::string& fname, /// Name of generated function - const std::string& typeName // Name of type to generate -) { - const Type* Ty = TheModule->getTypeByName(typeName); - if (!Ty) { - error(std::string("Type '") + typeName + "' not found in input module"); - return; - } - Out << "\nType* " << fname << "(Module *mod) {\n"; - printType(Ty); - Out << "return " << getCppName(Ty) << ";\n"; - Out << "}\n"; -} - -} // end anonymous llvm - -namespace llvm { - -void WriteModuleToCppFile(Module* mod, std::ostream& o) { - // Initialize a CppWriter for us to use - CppWriter W(o, mod); - - // Emit a header - o << "// Generated by llvm2cpp - DO NOT MODIFY!\n\n"; - - // Get the name of the function we're supposed to generate - std::string fname = FuncName.getValue(); - - // Get the name of the thing we are to generate - std::string tgtname = NameToGenerate.getValue(); - if (GenerationType == GenModule || - GenerationType == GenContents || - GenerationType == GenProgram || - GenerationType == GenFunctions) { - if (tgtname == "!bad!") { - if (mod->getModuleIdentifier() == "-") - tgtname = ""; - else - tgtname = mod->getModuleIdentifier(); - } - } else if (tgtname == "!bad!") { - W.error("You must use the -for option with -gen-{function,variable,type}"); - } - - switch (WhatToGenerate(GenerationType)) { - case GenProgram: - if (fname.empty()) - fname = "makeLLVMModule"; - W.printProgram(fname,tgtname); - break; - case GenModule: - if (fname.empty()) - fname = "makeLLVMModule"; - W.printModule(fname,tgtname); - break; - case GenContents: - if (fname.empty()) - fname = "makeLLVMModuleContents"; - W.printContents(fname,tgtname); - break; - case GenFunction: - if (fname.empty()) - fname = "makeLLVMFunction"; - W.printFunction(fname,tgtname); - break; - case GenFunctions: - W.printFunctions(); - break; - case GenInline: - if (fname.empty()) - fname = "makeLLVMInline"; - W.printInline(fname,tgtname); - break; - case GenVariable: - if (fname.empty()) - fname = "makeLLVMVariable"; - W.printVariable(fname,tgtname); - break; - case GenType: - if (fname.empty()) - fname = "makeLLVMType"; - W.printType(fname,tgtname); - break; - default: - W.error("Invalid generation option"); - } -} - -} Removed: llvm/trunk/tools/llvm2cpp/CppWriter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm2cpp/CppWriter.h?rev=50613&view=auto ============================================================================== --- llvm/trunk/tools/llvm2cpp/CppWriter.h (original) +++ llvm/trunk/tools/llvm2cpp/CppWriter.h (removed) @@ -1,18 +0,0 @@ -//===--- CppWriter.h - Generate C++ IR to C++ Source Interface ------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file declares a function, WriteModuleToCppFile that will convert a -// Module into the corresponding C++ code to construct the same module. -// -//===------------------------------------------------------------------------=== -#include -namespace llvm { -class Module; -void WriteModuleToCppFile(Module* mod, std::ostream& out); -} Removed: llvm/trunk/tools/llvm2cpp/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm2cpp/Makefile?rev=50613&view=auto ============================================================================== --- llvm/trunk/tools/llvm2cpp/Makefile (original) +++ llvm/trunk/tools/llvm2cpp/Makefile (removed) @@ -1,15 +0,0 @@ -##===- tools/llvm2cpp/Makefile -----------------------------*- Makefile -*-===## -# -# The LLVM Compiler Infrastructure -# -# This file is distributed under the University of Illinois Open Source -# License. See LICENSE.TXT for details. -# -##===----------------------------------------------------------------------===## -LEVEL = ../.. -TOOLNAME = llvm2cpp -LINK_COMPONENTS = bitreader - -include $(LEVEL)/Makefile.common - -CompileCommonOpts := $(CompileCommonOpts) -Wno-format Removed: llvm/trunk/tools/llvm2cpp/llvm2cpp.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm2cpp/llvm2cpp.cpp?rev=50613&view=auto ============================================================================== --- llvm/trunk/tools/llvm2cpp/llvm2cpp.cpp (original) +++ llvm/trunk/tools/llvm2cpp/llvm2cpp.cpp (removed) @@ -1,122 +0,0 @@ -//===--- llvm2cpp.cpp - LLVM IR to C++ Translator -------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This program converts an input LLVM assembly file (.ll) into a C++ source -// file that makes calls to the LLVM C++ API to produce the same module. The -// generated program verifies what it built and then runs the PrintAssemblyPass -// to reproduce the input originally given to llvm2cpp. -// -// Use the --help option for help with command line options. -// -//===------------------------------------------------------------------------=== - -#include "llvm/Module.h" -#include "llvm/Bitcode/ReaderWriter.h" -#include "llvm/Analysis/Verifier.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/Support/ManagedStatic.h" -#include "llvm/Support/MemoryBuffer.h" -#include "llvm/Support/SystemUtils.h" -#include "llvm/System/Signals.h" -#include "CppWriter.h" -#include -#include -#include -using namespace llvm; - -static cl::opt -InputFilename(cl::Positional, cl::desc(""), - cl::init("-")); - -static cl::opt -OutputFilename("o", cl::desc("Override output filename"), - cl::value_desc("filename")); - -static cl::opt -Force("f", cl::desc("Overwrite output files")); - -int main(int argc, char **argv) { - llvm_shutdown_obj X; // Call llvm_shutdown() on exit. - cl::ParseCommandLineOptions(argc, argv, "llvm .ll -> .cpp assembler\n"); - sys::PrintStackTraceOnErrorSignal(); - - int exitCode = 0; - std::ostream *Out = 0; - std::string ErrorMessage; - - std::auto_ptr M; - std::auto_ptr Buffer( - MemoryBuffer::getFileOrSTDIN(InputFilename, &ErrorMessage)); - if (Buffer.get()) - M.reset(ParseBitcodeFile(Buffer.get(), &ErrorMessage)); - if (M.get() == 0) { - std::cerr << argv[0] << ": "; - if (ErrorMessage.size()) - std::cerr << ErrorMessage << "\n"; - else - std::cerr << "bitcode didn't read correctly.\n"; - return 1; - } - - if (OutputFilename != "") { // Specified an output filename? - if (OutputFilename != "-") { // Not stdout? - if (!Force && std::ifstream(OutputFilename.c_str())) { - // If force is not specified, make sure not to overwrite a file! - std::cerr << argv[0] << ": error opening '" << OutputFilename - << "': file exists!\n" - << "Use -f command line argument to force output\n"; - return 1; - } - Out = new std::ofstream(OutputFilename.c_str(), std::ios::out | - std::ios::trunc | std::ios::binary); - } else { // Specified stdout - Out = &std::cout; - } - } else { - if (InputFilename == "-") { - OutputFilename = "-"; - Out = &std::cout; - } else { - std::string IFN = InputFilename; - int Len = IFN.length(); - if (IFN[Len-3] == '.' && IFN[Len-2] == 'l' && IFN[Len-1] == 'l') { - // Source ends in .ll - OutputFilename = std::string(IFN.begin(), IFN.end()-3); - } else { - OutputFilename = IFN; // Append a .cpp to it - } - OutputFilename += ".cpp"; - - if (!Force && std::ifstream(OutputFilename.c_str())) { - // If force is not specified, make sure not to overwrite a file! - std::cerr << argv[0] << ": error opening '" << OutputFilename - << "': file exists!\n" - << "Use -f command line argument to force output\n"; - return 1; - } - - Out = new std::ofstream(OutputFilename.c_str(), std::ios::out | - std::ios::trunc | std::ios::binary); - // Make sure that the Out file gets unlinked from the disk if we get a - // SIGINT - sys::RemoveFileOnSignal(sys::Path(OutputFilename)); - } - } - - if (!Out->good()) { - std::cerr << argv[0] << ": error opening " << OutputFilename << "!\n"; - return 1; - } - - WriteModuleToCppFile(M.get(), *Out); - - if (Out != &std::cout) delete Out; - return exitCode; -} - From asl at math.spbu.ru Sun May 4 01:19:55 2008 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Sun, 04 May 2008 06:19:55 -0000 Subject: [llvm-commits] [llvm] r50615 - in /llvm/trunk: docs/CommandGuide/llvmc.pod tools/llvmc/CompilerDriver.cpp tools/llvmc/CompilerDriver.h tools/llvmc/ConfigLexer.cpp.cvs tools/llvmc/ConfigLexer.h tools/llvmc/ConfigLexer.l tools/llvmc/ConfigLexer.l.cvs tools/llvmc/Configuration.cpp tools/llvmc/Configuration.h tools/llvmc/LICENSE.TXT tools/llvmc/Makefile tools/llvmc/c tools/llvmc/cpp tools/llvmc/ll tools/llvmc/llvmc.cpp tools/llvmc/st Message-ID: <200805040619.m446JuoB019730@zion.cs.uiuc.edu> Author: asl Date: Sun May 4 01:19:55 2008 New Revision: 50615 URL: http://llvm.org/viewvc/llvm-project?rev=50615&view=rev Log: Drop llvmc also, it will be replaced by shiny new llvmc2 Removed: llvm/trunk/docs/CommandGuide/llvmc.pod llvm/trunk/tools/llvmc/CompilerDriver.cpp llvm/trunk/tools/llvmc/CompilerDriver.h llvm/trunk/tools/llvmc/ConfigLexer.cpp.cvs llvm/trunk/tools/llvmc/ConfigLexer.h llvm/trunk/tools/llvmc/ConfigLexer.l llvm/trunk/tools/llvmc/ConfigLexer.l.cvs llvm/trunk/tools/llvmc/Configuration.cpp llvm/trunk/tools/llvmc/Configuration.h llvm/trunk/tools/llvmc/LICENSE.TXT llvm/trunk/tools/llvmc/Makefile llvm/trunk/tools/llvmc/c llvm/trunk/tools/llvmc/cpp llvm/trunk/tools/llvmc/ll llvm/trunk/tools/llvmc/llvmc.cpp llvm/trunk/tools/llvmc/st Removed: llvm/trunk/docs/CommandGuide/llvmc.pod URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/llvmc.pod?rev=50614&view=auto ============================================================================== --- llvm/trunk/docs/CommandGuide/llvmc.pod (original) +++ llvm/trunk/docs/CommandGuide/llvmc.pod (removed) @@ -1,431 +0,0 @@ -=pod - -=head1 NAME - -llvmc - The LLVM Compiler Driver (experimental) - -=head1 SYNOPSIS - -B [I] [I...] - -=head1 DESCRIPTION - -B is a configurable driver for invoking other LLVM (and non-LLVM) tools -in order to compile, optimize and link software for multiple languages. For -those familiar with FSF's B tool, it is very similar. Please note that -B is considered an experimental tool. B has the following goals: - -=over - -=item * provide a single point of access to the LLVM tool set, - -=item * hide the complexities of the LLVM tools through a single interface, - -=item * make integration of existing non-LLVM tools simple, - -=item * extend the capabilities of minimal front ends, and - -=item * make the interface for compiling consistent for all languages. - -=back - -The tool itself does nothing with a user's program. It merely invokes other -tools to get the compilation tasks done. - -The options supported by B generalize the compilation process and -provide a consistent and simple interface for multiple programming languages. -This makes it easier for developers to get their software compiled with LLVM. -Without B, developers would need to understand how to invoke the -front-end compiler, optimizer, assembler, and linker in order to compile their -programs. B's sole mission is to trivialize that process. - -=head2 Basic Operation - -B always takes the following basic actions: - -=over - -=item * Command line options and filenames are collected. - -The command line options provide the marching orders to B on what actions -it should perform. This is the I the user is making of B and it -is interpreted first. - -=item * Configuration files are read. - -Based on the options and the suffixes of the filenames presented, a set of -configuration files are read to configure the actions B will take. -Configuration files are provided by either LLVM or the front end compiler tools -that B invokes. Users generally don't need to be concerned with the -contents of the configuration files. - -=item * Determine actions to take. - -The tool chain needed to complete the task is determined. This is the primary -work of B. It breaks the request specified by the command line options -into a set of basic actions to be done: - -=over - -=item * Pre-processing: gathering/filtering compiler input (optional). - -=item * Translation: source language to bitcode conversion. - -=item * Assembly: bitcode to native code conversion. - -=item * Optimization: conversion of bitcode to something that runs faster. - -=item * Linking: combining multiple bitcode files to produce executable program. - -=back - -=item * Execute actions. - -The actions determined previously are executed sequentially and then -B terminates. - -=back - -=head1 OPTIONS - -=head2 Control Options - -Control options tell B what to do at a high level. The -following control options are defined: - -=over - -=item B<-c> or B<--compile> - -This option specifies that the linking phase is not to be run. All -previous phases, if applicable will run. This is generally how a given -bitcode file is compiled and optimized for a source language module. - -=item B<-k> or B<--link> or default - -This option (or the lack of any control option) specifies that all stages -of compilation, optimization, and linking should be attempted. Source files -specified on the command line will be compiled and linked with objects and -libraries also specified. - -=item B<-S> - -This option specifies that compilation should end in the creation of -an LLVM assembly file that can be later converted to an LLVM object -file. - -=item B<-E> - -This option specifies that no compilation or linking should be -performed. Only pre-processing, if applicable to the language being -compiled, is performed. For languages that support it, this will -result in the output containing the raw input to the compiler. - -=back - -=head2 Optimization Options - -Optimization with B is based on goals and specified with -the following -O options. The specific details of which -optimizations run is controlled by the configuration files because -each source language will have different needs. - -=over - -=item B<-O1> or B<-O0> (default, fast compilation) - -Only those optimizations that will hasten the compilation (mostly by reducing -the output) are applied. In general these are extremely fast and simple -optimizations that reduce emitted code size. The goal here is not to make the -resulting program fast but to make the compilation fast. If not specified, -this is the default level of optimization. - -=item B<-O2> (basic optimization) - -This level of optimization specifies a balance between generating good code -that will execute reasonably quickly and not spending too much time optimizing -the code to get there. For example, this level of optimization may include -things like global common sub-expression elimination, aggressive dead code -elimination, and scalar replication. - -=item B<-O3> (aggressive optimization) - -This level of optimization aggressively optimizes each set of files compiled -together. However, no link-time inter-procedural optimization is performed. -This level implies all the optimizations of the B<-O1> and B<-O2> optimization -levels, and should also provide loop optimizations and compile time -inter-procedural optimizations. Essentially, this level tries to do as much -as it can with the input it is given but doesn't do any link time IPO. - -=item B<-O4> (link time optimization) - -In addition to the previous three levels of optimization, this level of -optimization aggressively optimizes each program at link time. It employs -basic analysis and basic link-time inter-procedural optimizations, -considering the program as a whole. - -=item B<-O5> (aggressive link time optimization) - -This is the same as B<-O4> except it employs aggressive analyses and -aggressive inter-procedural optimization. - -=item B<-O6> (profile guided optimization: not implemented) - -This is the same as B<-O5> except that it employs profile-guided -re-optimization of the program after it has executed. Note that this implies -a single level of re-optimization based on run time profile analysis. Once -the re-optimization has completed, the profiling instrumentation is -removed and final optimizations are employed. - -=item B<-O7> (lifelong optimization: not implemented) - -This is the same as B<-O5> and similar to B<-O6> except that re-optimization -is performed through the life of the program. That is, each run will update -the profile by which future re-optimizations are directed. - -=back - -=head2 Input Options - -=over - -=item B<-l> I - -This option instructs B to locate a library named I and search -it for unresolved symbols when linking the program. - -=item B<-L> F - -This option instructs B to add F to the list of places in which -the linker will - -=item B<-x> I - -This option instructs B to regard the following input files as -containing programs in the language I. Normally, input file languages -are identified by their suffix but this option will override that default -behavior. The B<-x> option stays in effect until the end of the options or -a new B<-x> option is encountered. - -=back - -=head2 Output Options - -=over - -=item B<-m>I - -This option selects the back end code generator to use. The I portion -of the option names the back end to use. - -=item B<--native> - -Normally, B produces bitcode files at most stages of compilation. -With this option, B will arrange for native object files to be -generated with the B<-c> option, native assembly files to be generated -with the B<-S> option, and native executables to be generated with the -B<--link> option. In the case of the B<-E> option, the output will not -differ as there is no I version of pre-processed output. - -=item B<-o> F - -Specify the output file name. The contents of the file depend on other -options. - -=back - -=head2 Information Options - -=over - -=item B<-n> or B<--no-op> - -This option tells B to do everything but actually execute the -resulting tools. In combination with the B<-v> option, this causes B -to merely print out what it would have done. - -=item B<-v> or B<--verbose> - -This option will cause B to print out (on standard output) each of the -actions it takes to accomplish the objective. The output will immediately -precede the invocation of other tools. - -=item B<--stats> - -Print all statistics gathered during the compilation to the standard error. -Note that this option is merely passed through to the sub-tools to do with -as they please. - -=item B<--time-passes> - -Record the amount of time needed for each optimization pass and print it -to standard error. Like B<--stats> this option is just passed through to -the sub-tools to do with as they please. - -=item B<--time-programs> - -Record the amount of time each program (compilation tool) takes and print -it to the standard error. - -=back - -=head2 Language Specific Options - -=over - -=item B<-T,pre>=I - -Pass an arbitrary option to the pre-processor. - -=item B<-T,opt>=I - -Pass an arbitrary option to the optimizer. - -=item B<-T,lnk>=I - -Pass an arbitrary option to the linker. - -=item B<-T,asm>=I - -Pass an arbitrary option to the code generator. - -=back - -=head2 C/C++ Specific Options - -=over - -=item B<-I>F - -This option is just passed through to a C or C++ front end compiler to tell it -where include files can be found. - -=item B<-D>F - -This option is just passed through to a C or C++ front end compiler to tell it -to define a symbol. - -=back - -=head2 Miscellaneous Options - -=over - -=item B<--help> - -Print a summary of command line options. - -=item B<--version> - -This option will cause B to print out its version number and terminate. - -=back - -=head2 Advanced Options - -You better know what you're doing if you use these options. Improper use -of these options can produce drastically wrong results. - -=over - -=item B<--config-dir> F - -This option tells B to read configuration data from the I -named F. Data from such directories will be read in the order -specified on the command line after all other standard configuration files have -been read. This allows users or groups of users to conveniently create -their own configuration directories in addition to the standard ones to which -they may not have write access. - -=back - - -=head2 Unimplemented Options - -The options below are not currently implemented in B but will be -eventually. They are documented here as "future design". - -=over - -=item B<--show-config> I<[suffixes...]> - -When this option is given, the only action taken by B is to show its -final configuration state in the form of a configuration file. No compilation -tasks will be conducted when this option is given; processing will stop once -the configuration has been printed. The optional (comma separated) list of -suffixes controls what is printed. Without any suffixes, the configuration -for all languages is printed. With suffixes, only the languages pertaining -to those file suffixes will be printed. The configuration information is -printed after all command line options and configuration files have been -read and processed. This allows the user to verify that the correct -configuration data has been read by B. - -=item B<--config> :I
    :I=I - -This option instructs B to accept I as the value for configuration -item I in the section named I
    . This is a quick way to override -a configuration item on the command line without resorting to changing the -configuration files. - -=item B<--config-only-from> F - -This option tells B to skip the normal processing of configuration -files and only configure from the contents of the F directory. Multiple -B<--config-only-from> options may be given in which case the directories are -read in the order given on the command line. - -=item B<--emit-raw-code> - -No optimization is done whatsoever. The compilers invoked by B with -this option given will be instructed to produce raw, unoptimized code. This -option is useful only to front end language developers and therefore does not -participate in the list of B<-O> options. This is distinctly different from -the B<-O0> option (a synonym for B<-O1>) because those optimizations will -reduce code size to make compilation faster. With B<--emit-raw-code>, only -the full raw code produced by the compiler will be generated. - -=back - - -=head1 EXIT STATUS - -If B succeeds, it will exit with 0. Otherwise, if an error -occurs, it will exit with a non-zero value and no compilation actions -will be taken. If one of the compilation tools returns a non-zero -status, pending actions will be discarded and B will return the -same result code as the failing compilation tool. - -=head1 DEFICIENCIES - -B is considered an experimental LLVM tool because it has these -deficiencies: - -=over - -=item Insufficient support for native linking - -Because B doesn't handle native linking, neither can B - -=item Poor configuration support - -The support for configuring new languages, etc. is weak. There are many -command line configurations that cannot be achieved with the current -support. Furthermore the grammar is cumbersome for configuration files. -Please see L for further details. - -=item Does not handle target specific configurations - -This is one of the major deficiencies, also addressed in -L - -=back - -=head1 SEE ALSO - -L, L, L, L - -=head1 AUTHORS - -Maintained by the LLVM Team (L). - -=cut Removed: llvm/trunk/tools/llvmc/CompilerDriver.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/CompilerDriver.cpp?rev=50614&view=auto ============================================================================== --- llvm/trunk/tools/llvmc/CompilerDriver.cpp (original) +++ llvm/trunk/tools/llvmc/CompilerDriver.cpp (removed) @@ -1,1032 +0,0 @@ -//===- CompilerDriver.cpp - The LLVM Compiler Driver ------------*- C++ -*-===// -// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements the bulk of the LLVM Compiler Driver (llvmc). -// -//===----------------------------------------------------------------------===// - -#include "CompilerDriver.h" -#include "ConfigLexer.h" -#include "llvm/Module.h" -#include "llvm/ModuleProvider.h" -#include "llvm/Bitcode/ReaderWriter.h" -#include "llvm/Support/MemoryBuffer.h" -#include "llvm/Support/Timer.h" -#include "llvm/System/Signals.h" -#include "llvm/ADT/SetVector.h" -#include "llvm/ADT/StringExtras.h" -#include "llvm/Config/alloca.h" -#include -using namespace llvm; - - -namespace { - -void WriteAction(CompilerDriver::Action* action ) { - std::cerr << action->program.c_str(); - std::vector::const_iterator I = action->args.begin(); - while (I != action->args.end()) { - std::cerr << ' ' << *I; - ++I; - } - std::cerr << '\n'; -} - -void DumpAction(CompilerDriver::Action* action) { - std::cerr << "command = " << action->program.c_str(); - std::vector::const_iterator I = action->args.begin(); - while (I != action->args.end()) { - std::cerr << ' ' << *I; - ++I; - } - std::cerr << '\n'; - std::cerr << "flags = " << action->flags << '\n'; -} - -void DumpConfigData(CompilerDriver::ConfigData* cd, const std::string& type ){ - std::cerr << "Configuration Data For '" << cd->langName << "' (" << type - << ")\n"; - std::cerr << "PreProcessor: "; - DumpAction(&cd->PreProcessor); - std::cerr << "Translator: "; - DumpAction(&cd->Translator); - std::cerr << "Optimizer: "; - DumpAction(&cd->Optimizer); - std::cerr << "Assembler: "; - DumpAction(&cd->Assembler); - std::cerr << "Linker: "; - DumpAction(&cd->Linker); -} - -static bool GetBitcodeDependentLibraries(const std::string &fname, - Module::LibraryListType& deplibs, - std::string* ErrMsg) { - ModuleProvider *MP = 0; - if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(fname)) { - MP = getBitcodeModuleProvider(Buffer); - if (MP == 0) delete Buffer; - } - if (!MP) { - deplibs.clear(); - return true; - } - deplibs = MP->getModule()->getLibraries(); - delete MP; - return false; -} - - -class CompilerDriverImpl : public CompilerDriver { -/// @name Constructors -/// @{ -public: - CompilerDriverImpl(ConfigDataProvider& confDatProv ) - : cdp(&confDatProv) - , finalPhase(LINKING) - , optLevel(OPT_FAST_COMPILE) - , Flags(0) - , machine() - , LibraryPaths() - , TempDir() - , AdditionalArgs() - { - AdditionalArgs.reserve(NUM_PHASES); - StringVector emptyVec; - for (unsigned i = 0; i < NUM_PHASES; ++i) - AdditionalArgs.push_back(emptyVec); - } - - virtual ~CompilerDriverImpl() { - cleanup(); - cdp = 0; - LibraryPaths.clear(); - IncludePaths.clear(); - Defines.clear(); - TempDir.clear(); - AdditionalArgs.clear(); - fOptions.clear(); - MOptions.clear(); - WOptions.clear(); - } - -/// @} -/// @name Methods -/// @{ -public: - virtual void setFinalPhase(Phases phase) { - finalPhase = phase; - } - - virtual void setOptimization(OptimizationLevels level) { - optLevel = level; - } - - virtual void setDriverFlags(unsigned flags) { - Flags = flags & DRIVER_FLAGS_MASK; - } - - virtual void setOutputMachine(const std::string& machineName) { - machine = machineName; - } - - virtual void setPhaseArgs(Phases phase, const StringVector& opts) { - assert(phase <= LINKING && phase >= PREPROCESSING); - AdditionalArgs[phase] = opts; - } - - virtual void setIncludePaths(const StringVector& paths) { - StringVector::const_iterator I = paths.begin(); - StringVector::const_iterator E = paths.end(); - while (I != E) { - sys::Path tmp; - tmp.set(*I); - IncludePaths.push_back(tmp); - ++I; - } - } - - virtual void setSymbolDefines(const StringVector& defs) { - Defines = defs; - } - - virtual void setLibraryPaths(const StringVector& paths) { - StringVector::const_iterator I = paths.begin(); - StringVector::const_iterator E = paths.end(); - while (I != E) { - sys::Path tmp; - tmp.set(*I); - LibraryPaths.push_back(tmp); - ++I; - } - } - - virtual void addLibraryPath(const sys::Path& libPath) { - LibraryPaths.push_back(libPath); - } - - virtual void addToolPath(const sys::Path& toolPath) { - ToolPaths.push_back(toolPath); - } - - virtual void setfPassThrough(const StringVector& fOpts) { - fOptions = fOpts; - } - - /// @brief Set the list of -M options to be passed through - virtual void setMPassThrough(const StringVector& MOpts) { - MOptions = MOpts; - } - - /// @brief Set the list of -W options to be passed through - virtual void setWPassThrough(const StringVector& WOpts) { - WOptions = WOpts; - } - -/// @} -/// @name Functions -/// @{ -private: - bool isSet(DriverFlags flag) { - return 0 != ((flag & DRIVER_FLAGS_MASK) & Flags); - } - - void cleanup() { - if (!isSet(KEEP_TEMPS_FLAG)) { - const sys::FileStatus *Status = TempDir.getFileStatus(); - if (Status && Status->isDir) - TempDir.eraseFromDisk(/*remove_contents=*/true); - } else { - std::cout << "Temporary files are in " << TempDir << "\n"; - } - } - - sys::Path MakeTempFile(const std::string& basename, - const std::string& suffix, - std::string* ErrMsg) { - if (TempDir.isEmpty()) { - TempDir = sys::Path::GetTemporaryDirectory(ErrMsg); - if (TempDir.isEmpty()) - return sys::Path(); - sys::RemoveDirectoryOnSignal(TempDir); - } - sys::Path result(TempDir); - if (!result.appendComponent(basename)) { - if (ErrMsg) - *ErrMsg = basename + ": can't use this file name"; - return sys::Path(); - } - if (!result.appendSuffix(suffix)) { - if (ErrMsg) - *ErrMsg = suffix + ": can't use this file suffix"; - return sys::Path(); - } - return result; - } - - Action* GetAction(ConfigData* cd, - const sys::Path& input, - const sys::Path& output, - Phases phase) - { - Action* pat = 0; ///< The pattern/template for the action - Action* action = new Action; ///< The actual action to execute - - // Get the action pattern - switch (phase) { - case PREPROCESSING: pat = &cd->PreProcessor; break; - case TRANSLATION: pat = &cd->Translator; break; - case OPTIMIZATION: pat = &cd->Optimizer; break; - case ASSEMBLY: pat = &cd->Assembler; break; - case LINKING: pat = &cd->Linker; break; - default: - assert(!"Invalid driver phase!"); - break; - } - assert(pat != 0 && "Invalid command pattern"); - - // Copy over some pattern things that don't need to change - action->flags = pat->flags; - - // See if program starts with wildcard... - std::string programName=pat->program.toString(); - if (programName[0] == '%' && programName.length() >2) { - switch(programName[1]){ - case 'b': - if (programName.substr(0,8) == "%bindir%") { - std::string tmp(LLVM_BINDIR); - tmp.append(programName.substr(8)); - pat->program.set(tmp); - } - break; - case 'l': - if (programName.substr(0,12) == "%llvmgccdir%"){ - std::string tmp(LLVMGCCDIR); - tmp.append(programName.substr(12)); - pat->program.set(tmp); - }else if (programName.substr(0,13) == "%llvmgccarch%"){ - std::string tmp(LLVMGCCARCH); - tmp.append(programName.substr(13)); - pat->program.set(tmp); - }else if (programName.substr(0,9) == "%llvmgcc%"){ - std::string tmp(LLVMGCC); - tmp.append(programName.substr(9)); - pat->program.set(tmp); - }else if (programName.substr(0,9) == "%llvmgxx%"){ - std::string tmp(LLVMGXX); - tmp.append(programName.substr(9)); - pat->program.set(tmp); - }else if (programName.substr(0,9) == "%llvmcc1%"){ - std::string tmp(LLVMCC1); - tmp.append(programName.substr(9)); - pat->program.set(tmp); - }else if (programName.substr(0,13) == "%llvmcc1plus%"){ - std::string tmp(LLVMCC1PLUS); - tmp.append(programName.substr(13)); - pat->program.set(tmp); - }else if (programName.substr(0,8) == "%libdir%") { - std::string tmp(LLVM_LIBDIR); - tmp.append(programName.substr(8)); - pat->program.set(tmp); - } - break; - } - } - action->program = pat->program; - - // Do the substitutions from the pattern to the actual - StringVector::iterator PI = pat->args.begin(); - StringVector::iterator PE = pat->args.end(); - while (PI != PE) { - if ((*PI)[0] == '%' && PI->length() >2) { - bool found = true; - switch ((*PI)[1]) { - case 'a': - if (*PI == "%args%") { - if (AdditionalArgs.size() > unsigned(phase)) - if (!AdditionalArgs[phase].empty()) { - // Get specific options for each kind of action type - StringVector& addargs = AdditionalArgs[phase]; - // Add specific options for each kind of action type - action->args.insert(action->args.end(), addargs.begin(), - addargs.end()); - } - } else - found = false; - break; - case 'b': - if (*PI == "%bindir%") { - std::string tmp(*PI); - tmp.replace(0,8,LLVM_BINDIR); - action->args.push_back(tmp); - } else - found = false; - break; - case 'd': - if (*PI == "%defs%") { - StringVector::iterator I = Defines.begin(); - StringVector::iterator E = Defines.end(); - while (I != E) { - action->args.push_back( std::string("-D") + *I); - ++I; - } - } else - found = false; - break; - case 'f': - if (*PI == "%fOpts%") { - if (!fOptions.empty()) - action->args.insert(action->args.end(), fOptions.begin(), - fOptions.end()); - } else - found = false; - break; - case 'i': - if (*PI == "%in%") { - action->args.push_back(input.toString()); - } else if (*PI == "%incls%") { - PathVector::iterator I = IncludePaths.begin(); - PathVector::iterator E = IncludePaths.end(); - while (I != E) { - action->args.push_back( std::string("-I") + I->toString() ); - ++I; - } - } else - found = false; - break; - case 'l': - if ((*PI)[1] == 'l') { - std::string tmp(*PI); - if (*PI == "%llvmgccdir%") - tmp.replace(0,12,LLVMGCCDIR); - else if (*PI == "%llvmgccarch%") - tmp.replace(0,13,LLVMGCCARCH); - else if (*PI == "%llvmgcc%") - tmp.replace(0,9,LLVMGCC); - else if (*PI == "%llvmgxx%") - tmp.replace(0,9,LLVMGXX); - else if (*PI == "%llvmcc1%") - tmp.replace(0,9,LLVMCC1); - else if (*PI == "%llvmcc1plus%") - tmp.replace(0,9,LLVMCC1); - else - found = false; - if (found) - action->args.push_back(tmp); - } else if (*PI == "%libs%") { - PathVector::iterator I = LibraryPaths.begin(); - PathVector::iterator E = LibraryPaths.end(); - while (I != E) { - action->args.push_back( std::string("-L") + I->toString() ); - ++I; - } - } else if (*PI == "%libdir%") { - std::string tmp(*PI); - tmp.replace(0,8,LLVM_LIBDIR); - action->args.push_back(tmp); - } else - found = false; - break; - case 'o': - if (*PI == "%out%") { - action->args.push_back(output.toString()); - } else if (*PI == "%opt%") { - if (!isSet(EMIT_RAW_FLAG)) { - if (cd->opts.size() > static_cast(optLevel) && - !cd->opts[optLevel].empty()) - action->args.insert(action->args.end(), - cd->opts[optLevel].begin(), - cd->opts[optLevel].end()); - else - throw std::string("Optimization options for level ") + - utostr(unsigned(optLevel)) + " were not specified"; - } - } else - found = false; - break; - case 's': - if (*PI == "%stats%") { - if (isSet(SHOW_STATS_FLAG)) - action->args.push_back("-stats"); - } else - found = false; - break; - case 't': - if (*PI == "%target%") { - action->args.push_back(std::string("-march=") + machine); - } else if (*PI == "%time%") { - if (isSet(TIME_PASSES_FLAG)) - action->args.push_back("-time-passes"); - } else - found = false; - break; - case 'v': - if (*PI == "%verbose%") { - if (isSet(VERBOSE_FLAG)) - action->args.push_back("-v"); - } else - found = false; - break; - case 'M': - if (*PI == "%Mopts%") { - if (!MOptions.empty()) - action->args.insert(action->args.end(), MOptions.begin(), - MOptions.end()); - } else - found = false; - break; - case 'W': - if (*PI == "%Wopts%") { - for (StringVector::iterator I = WOptions.begin(), - E = WOptions.end(); I != E ; ++I ) { - action->args.push_back(std::string("-W") + *I); - } - } else - found = false; - break; - default: - found = false; - break; - } - if (!found) { - // Did it even look like a substitution? - if (PI->length()>1 && (*PI)[0] == '%' && - (*PI)[PI->length()-1] == '%') { - throw std::string("Invalid substitution token: '") + *PI + - "' for command '" + pat->program.toString() + "'"; - } else if (!PI->empty()) { - // It's not a legal substitution, just pass it through - action->args.push_back(*PI); - } - } - } else if (!PI->empty()) { - // Its not a substitution, just put it in the action - action->args.push_back(*PI); - } - PI++; - } - - // Finally, we're done - return action; - } - - int DoAction(Action*action, std::string& ErrMsg) { - assert(action != 0 && "Invalid Action!"); - if (isSet(VERBOSE_FLAG)) - WriteAction(action); - if (!isSet(DRY_RUN_FLAG)) { - sys::Path progpath = sys::Program::FindProgramByName( - action->program.toString()); - if (progpath.isEmpty()) - throw std::string("Can't find program '" + - action->program.toString()+"'"); - else if (progpath.canExecute()) - action->program = progpath; - else - throw std::string("Program '"+action->program.toString()+ - "' is not executable."); - - // Invoke the program - const char** Args = (const char**) - alloca(sizeof(const char*)*(action->args.size()+2)); - Args[0] = action->program.toString().c_str(); - for (unsigned i = 1; i <= action->args.size(); ++i) - Args[i] = action->args[i-1].c_str(); - Args[action->args.size()+1] = 0; // null terminate list. - if (isSet(TIME_ACTIONS_FLAG)) { - Timer timer(action->program.toString()); - timer.startTimer(); - int resultCode = - sys::Program::ExecuteAndWait(action->program, Args,0,0,0,0, &ErrMsg); - timer.stopTimer(); - timer.print(timer,std::cerr); - return resultCode; - } - else - return - sys::Program::ExecuteAndWait(action->program, Args, 0,0,0,0, &ErrMsg); - } - return 0; - } - - /// This method tries various variants of a linkage item's file - /// name to see if it can find an appropriate file to link with - /// in the directories of the LibraryPaths. - llvm::sys::Path GetPathForLinkageItem(const std::string& link_item, - bool native = false) { - sys::Path fullpath; - fullpath.set(link_item); - if (fullpath.canRead()) - return fullpath; - for (PathVector::iterator PI = LibraryPaths.begin(), - PE = LibraryPaths.end(); PI != PE; ++PI) { - fullpath.set(PI->toString()); - fullpath.appendComponent(link_item); - if (fullpath.canRead()) - return fullpath; - if (native) { - fullpath.appendSuffix("a"); - } else { - fullpath.appendSuffix("bc"); - if (fullpath.canRead()) - return fullpath; - fullpath.eraseSuffix(); - fullpath.appendSuffix("o"); - if (fullpath.canRead()) - return fullpath; - fullpath = *PI; - fullpath.appendComponent(std::string("lib") + link_item); - fullpath.appendSuffix("a"); - if (fullpath.canRead()) - return fullpath; - fullpath.eraseSuffix(); - fullpath.appendSuffix("so"); - if (fullpath.canRead()) - return fullpath; - } - } - - // Didn't find one. - fullpath.clear(); - return fullpath; - } - - /// This method processes a linkage item. The item could be a - /// Bitcode file needing translation to native code and that is - /// dependent on other bitcode libraries, or a native code - /// library that should just be linked into the program. - bool ProcessLinkageItem(const llvm::sys::Path& link_item, - SetVector& set, - std::string& err) { - // First, see if the unadorned file name is not readable. If so, - // we must track down the file in the lib search path. - sys::Path fullpath; - if (!link_item.canRead()) { - // look for the library using the -L arguments specified - // on the command line. - fullpath = GetPathForLinkageItem(link_item.toString()); - - // If we didn't find the file in any of the library search paths - // we have to bail. No where else to look. - if (fullpath.isEmpty()) { - err = - std::string("Can't find linkage item '") + link_item.toString() + "'"; - return false; - } - } else { - fullpath = link_item; - } - - // If we got here fullpath is the path to the file, and its readable. - set.insert(fullpath); - - // If its an LLVM bitcode file ... - if (fullpath.isBitcodeFile()) { - // Process the dependent libraries recursively - Module::LibraryListType modlibs; - if (GetBitcodeDependentLibraries(fullpath.toString(),modlibs, &err)) { - // Traverse the dependent libraries list - Module::lib_iterator LI = modlibs.begin(); - Module::lib_iterator LE = modlibs.end(); - while ( LI != LE ) { - if (!ProcessLinkageItem(sys::Path(*LI),set,err)) { - if (err.empty()) { - err = std::string("Library '") + *LI + - "' is not valid for linking but is required by file '" + - fullpath.toString() + "'"; - } else { - err += " which is required by file '" + fullpath.toString() + "'"; - } - return false; - } - ++LI; - } - } else if (err.empty()) { - err = std::string( - "The dependent libraries could not be extracted from '") + - fullpath.toString(); - return false; - } else - return false; - } - return true; - } - -/// @} -/// @name Methods -/// @{ -public: - virtual int execute(const InputList& InpList, const sys::Path& Output, std::string& ErrMsg ) { - try { - // Echo the configuration of options if we're running verbose - if (isSet(DEBUG_FLAG)) { - std::cerr << "Compiler Driver Options:\n"; - std::cerr << "DryRun = " << isSet(DRY_RUN_FLAG) << "\n"; - std::cerr << "Verbose = " << isSet(VERBOSE_FLAG) << " \n"; - std::cerr << "TimeActions = " << isSet(TIME_ACTIONS_FLAG) << "\n"; - std::cerr << "TimePasses = " << isSet(TIME_PASSES_FLAG) << "\n"; - std::cerr << "ShowStats = " << isSet(SHOW_STATS_FLAG) << "\n"; - std::cerr << "EmitRawCode = " << isSet(EMIT_RAW_FLAG) << "\n"; - std::cerr << "EmitNativeCode = " << isSet(EMIT_NATIVE_FLAG) << "\n"; - std::cerr << "KeepTemps = " << isSet(KEEP_TEMPS_FLAG) << "\n"; - std::cerr << "OutputMachine = " << machine << "\n"; - InputList::const_iterator I = InpList.begin(); - while ( I != InpList.end() ) { - std::cerr << "Input: " << I->first << "(" << I->second - << ")\n"; - ++I; - } - std::cerr << "Output: " << Output << "\n"; - } - - // If there's no input, we're done. - if (InpList.empty()) - throw std::string("Nothing to compile."); - - // If they are asking for linking and didn't provide an output - // file then its an error (no way for us to "make up" a meaningful - // file name based on the various linker input files). - if (finalPhase == LINKING && Output.isEmpty()) - throw std::string( - "An output file name must be specified for linker output"); - - // If they are not asking for linking, provided an output file and - // there is more than one input file, its an error - if (finalPhase != LINKING && !Output.isEmpty() && InpList.size() > 1) - throw std::string("An output file name cannot be specified ") + - "with more than one input file name when not linking"; - - // This vector holds all the resulting actions of the following loop. - std::vector actions; - - /// PRE-PROCESSING / TRANSLATION / OPTIMIZATION / ASSEMBLY phases - // for each input item - SetVector LinkageItems; - StringVector LibFiles; - InputList::const_iterator I = InpList.begin(); - for (InputList::const_iterator I = InpList.begin(), E = InpList.end(); - I != E; ++I ) { - // Get the suffix of the file name - const std::string& ftype = I->second; - - // If its a library, bitcode file, or object file, save - // it for linking below and short circuit the - // pre-processing/translation/assembly phases - if (ftype.empty() || ftype == "o" || ftype == "bc" || ftype=="a") { - // We shouldn't get any of these types of files unless we're - // later going to link. Enforce this limit now. - if (finalPhase != LINKING) { - throw std::string( - "Pre-compiled objects found but linking not requested"); - } - if (ftype.empty()) - LibFiles.push_back(I->first.toString()); - else - LinkageItems.insert(I->first); - continue; // short circuit remainder of loop - } - - // At this point, we know its something we need to translate - // and/or optimize. See if we can get the configuration data - // for this kind of file. - ConfigData* cd = cdp->ProvideConfigData(I->second); - if (cd == 0) - throw std::string("Files of type '") + I->second + - "' are not recognized."; - if (isSet(DEBUG_FLAG)) - DumpConfigData(cd,I->second); - - // Add the config data's library paths to the end of the list - for (StringVector::iterator LPI = cd->libpaths.begin(), - LPE = cd->libpaths.end(); LPI != LPE; ++LPI){ - LibraryPaths.push_back(sys::Path(*LPI)); - } - - // Initialize the input and output files - sys::Path InFile(I->first); - sys::Path OutFile(I->first.getBasename()); - - // PRE-PROCESSING PHASE - Action& action = cd->PreProcessor; - - // Get the preprocessing action, if needed, or error if appropriate - if (!action.program.isEmpty()) { - if (action.isSet(REQUIRED_FLAG) || finalPhase == PREPROCESSING) { - if (finalPhase == PREPROCESSING) { - if (Output.isEmpty()) { - OutFile.appendSuffix("E"); - actions.push_back(GetAction(cd,InFile,OutFile,PREPROCESSING)); - } else { - actions.push_back(GetAction(cd,InFile,Output,PREPROCESSING)); - } - } else { - sys::Path TempFile( - MakeTempFile(I->first.getBasename(),"E",&ErrMsg)); - if (TempFile.isEmpty()) - return 1; - actions.push_back(GetAction(cd,InFile,TempFile, - PREPROCESSING)); - InFile = TempFile; - } - } - } else if (finalPhase == PREPROCESSING) { - throw cd->langName + " does not support pre-processing"; - } else if (action.isSet(REQUIRED_FLAG)) { - throw std::string("Don't know how to pre-process ") + - cd->langName + " files"; - } - - // Short-circuit remaining actions if all they want is - // pre-processing - if (finalPhase == PREPROCESSING) { continue; }; - - /// TRANSLATION PHASE - action = cd->Translator; - - // Get the translation action, if needed, or error if appropriate - if (!action.program.isEmpty()) { - if (action.isSet(REQUIRED_FLAG) || finalPhase == TRANSLATION) { - if (finalPhase == TRANSLATION) { - if (Output.isEmpty()) { - OutFile.appendSuffix("o"); - actions.push_back(GetAction(cd,InFile,OutFile,TRANSLATION)); - } else { - actions.push_back(GetAction(cd,InFile,Output,TRANSLATION)); - } - } else { - sys::Path TempFile( - MakeTempFile(I->first.getBasename(),"trans", &ErrMsg)); - if (TempFile.isEmpty()) - return 1; - actions.push_back(GetAction(cd,InFile,TempFile,TRANSLATION)); - InFile = TempFile; - } - - // ll -> bc Helper - if (action.isSet(OUTPUT_IS_ASM_FLAG)) { - /// The output of the translator is an LLVM Assembly program - /// We need to translate it to bitcode - Action* action = new Action(); - action->program.set("llvm-as"); - action->args.push_back(InFile.toString()); - action->args.push_back("-o"); - InFile.appendSuffix("bc"); - action->args.push_back(InFile.toString()); - actions.push_back(action); - } - } - } else if (finalPhase == TRANSLATION) { - throw cd->langName + " does not support translation"; - } else if (action.isSet(REQUIRED_FLAG)) { - throw std::string("Don't know how to translate ") + - cd->langName + " files"; - } - - // Short-circuit remaining actions if all they want is translation - if (finalPhase == TRANSLATION) { continue; } - - /// OPTIMIZATION PHASE - action = cd->Optimizer; - - // Get the optimization action, if needed, or error if appropriate - if (!isSet(EMIT_RAW_FLAG)) { - if (!action.program.isEmpty()) { - if (action.isSet(REQUIRED_FLAG) || finalPhase == OPTIMIZATION) { - if (finalPhase == OPTIMIZATION) { - if (Output.isEmpty()) { - OutFile.appendSuffix("o"); - actions.push_back(GetAction(cd,InFile,OutFile,OPTIMIZATION)); - } else { - actions.push_back(GetAction(cd,InFile,Output,OPTIMIZATION)); - } - } else { - sys::Path TempFile( - MakeTempFile(I->first.getBasename(),"opt", &ErrMsg)); - if (TempFile.isEmpty()) - return 1; - actions.push_back(GetAction(cd,InFile,TempFile,OPTIMIZATION)); - InFile = TempFile; - } - // ll -> bc Helper - if (action.isSet(OUTPUT_IS_ASM_FLAG)) { - /// The output of the optimizer is an LLVM Assembly program - /// We need to translate it to bitcode with llvm-as - Action* action = new Action(); - action->program.set("llvm-as"); - action->args.push_back(InFile.toString()); - action->args.push_back("-f"); - action->args.push_back("-o"); - InFile.appendSuffix("bc"); - action->args.push_back(InFile.toString()); - actions.push_back(action); - } - } - } else if (finalPhase == OPTIMIZATION) { - throw cd->langName + " does not support optimization"; - } else if (action.isSet(REQUIRED_FLAG)) { - throw std::string("Don't know how to optimize ") + - cd->langName + " files"; - } - } - - // Short-circuit remaining actions if all they want is optimization - if (finalPhase == OPTIMIZATION) { continue; } - - /// ASSEMBLY PHASE - action = cd->Assembler; - - if (finalPhase == ASSEMBLY) { - - // Build either a native compilation action or a disassembly action - Action* action = new Action(); - if (isSet(EMIT_NATIVE_FLAG)) { - // Use llc to get the native assembly file - action->program.set("llc"); - action->args.push_back(InFile.toString()); - action->args.push_back("-f"); - action->args.push_back("-o"); - if (Output.isEmpty()) { - OutFile.appendSuffix("o"); - action->args.push_back(OutFile.toString()); - } else { - action->args.push_back(Output.toString()); - } - actions.push_back(action); - } else { - // Just convert back to llvm assembly with llvm-dis - action->program.set("llvm-dis"); - action->args.push_back(InFile.toString()); - action->args.push_back("-f"); - action->args.push_back("-o"); - if (Output.isEmpty()) { - OutFile.appendSuffix("ll"); - action->args.push_back(OutFile.toString()); - } else { - action->args.push_back(Output.toString()); - } - } - - // Put the action on the list - actions.push_back(action); - - // Short circuit the rest of the loop, we don't want to link - continue; - } - - // Register the result of the actions as a link candidate - LinkageItems.insert(InFile); - - } // end while loop over each input file - - /// RUN THE COMPILATION ACTIONS - std::vector::iterator AI = actions.begin(); - std::vector::iterator AE = actions.end(); - while (AI != AE) { - int ActionResult = DoAction(*AI, ErrMsg); - if (ActionResult != 0) - return ActionResult; - AI++; - } - - /// LINKING PHASE - if (finalPhase == LINKING) { - - // Insert the platform-specific system libraries to the path list - std::vector SysLibs; - sys::Path::GetSystemLibraryPaths(SysLibs); - LibraryPaths.insert(LibraryPaths.end(), SysLibs.begin(), SysLibs.end()); - - // Set up the linking action with llvm-ld - Action* link = new Action(); - link->program.set("llvm-ld"); - - // Add in the optimization level requested - switch (optLevel) { - case OPT_FAST_COMPILE: - link->args.push_back("-O1"); - break; - case OPT_SIMPLE: - link->args.push_back("-O2"); - break; - case OPT_AGGRESSIVE: - link->args.push_back("-O3"); - break; - case OPT_LINK_TIME: - link->args.push_back("-O4"); - break; - case OPT_AGGRESSIVE_LINK_TIME: - link->args.push_back("-O5"); - break; - case OPT_NONE: - break; - } - - // Add in all the linkage items we generated. This includes the - // output from the translation/optimization phases as well as any - // -l arguments specified. - for (PathVector::const_iterator I=LinkageItems.begin(), - E=LinkageItems.end(); I != E; ++I ) - link->args.push_back(I->toString()); - - // Add in all the libraries we found. - for (StringVector::const_iterator I=LibFiles.begin(), - E=LibFiles.end(); I != E; ++I ) - link->args.push_back(std::string("-l")+*I); - - // Add in all the library paths to the command line - for (PathVector::const_iterator I=LibraryPaths.begin(), - E=LibraryPaths.end(); I != E; ++I) - link->args.push_back( std::string("-L") + I->toString()); - - // Add in the additional linker arguments requested - for (StringVector::const_iterator I=AdditionalArgs[LINKING].begin(), - E=AdditionalArgs[LINKING].end(); I != E; ++I) - link->args.push_back( *I ); - - // Add in other optional flags - if (isSet(EMIT_NATIVE_FLAG)) - link->args.push_back("-native"); - if (isSet(VERBOSE_FLAG)) - link->args.push_back("-v"); - if (isSet(TIME_PASSES_FLAG)) - link->args.push_back("-time-passes"); - if (isSet(SHOW_STATS_FLAG)) - link->args.push_back("-stats"); - if (isSet(STRIP_OUTPUT_FLAG)) - link->args.push_back("-s"); - if (isSet(DEBUG_FLAG)) { - link->args.push_back("-debug"); - link->args.push_back("-debug-pass=Details"); - } - - // Add in mandatory flags - link->args.push_back("-o"); - link->args.push_back(Output.toString()); - - // Execute the link - int ActionResult = DoAction(link, ErrMsg); - if (ActionResult != 0) - return ActionResult; - } - } catch (std::string& msg) { - cleanup(); - throw; - } catch (...) { - cleanup(); - throw std::string("Unspecified error"); - } - cleanup(); - return 0; - } - -/// @} -/// @name Data -/// @{ -private: - ConfigDataProvider* cdp; ///< Where we get configuration data from - Phases finalPhase; ///< The final phase of compilation - OptimizationLevels optLevel; ///< The optimization level to apply - unsigned Flags; ///< The driver flags - std::string machine; ///< Target machine name - PathVector LibraryPaths; ///< -L options - PathVector IncludePaths; ///< -I options - PathVector ToolPaths; ///< -B options - StringVector Defines; ///< -D options - sys::PathWithStatus TempDir; ///< Name of the temporary directory. - StringTable AdditionalArgs; ///< The -Txyz options - StringVector fOptions; ///< -f options - StringVector MOptions; ///< -M options - StringVector WOptions; ///< -W options - -/// @} -}; -} - -CompilerDriver::~CompilerDriver() { -} - -CompilerDriver::ConfigDataProvider::~ConfigDataProvider() {} - -CompilerDriver* -CompilerDriver::Get(ConfigDataProvider& CDP) { - return new CompilerDriverImpl(CDP); -} - -CompilerDriver::ConfigData::ConfigData() - : langName() - , PreProcessor() - , Translator() - , Optimizer() - , Assembler() - , Linker() -{ - StringVector emptyVec; - for (unsigned i = 0; i < NUM_PHASES; ++i) - opts.push_back(emptyVec); -} Removed: llvm/trunk/tools/llvmc/CompilerDriver.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/CompilerDriver.h?rev=50614&view=auto ============================================================================== --- llvm/trunk/tools/llvmc/CompilerDriver.h (original) +++ llvm/trunk/tools/llvmc/CompilerDriver.h (removed) @@ -1,206 +0,0 @@ -//===- CompilerDriver.h - Compiler Driver -----------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file declares the CompilerDriver class which implements the bulk of the -// LLVM Compiler Driver program (llvmc). -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_TOOLS_LLVMC_COMPILERDRIVER_H -#define LLVM_TOOLS_LLVMC_COMPILERDRIVER_H - -#include -#include -#include "llvm/System/Program.h" - -namespace llvm { - /// This class provides the high level interface to the LLVM Compiler Driver. - /// The driver's purpose is to make it easier for compiler writers and users - /// of LLVM to utilize the compiler toolkits and LLVM toolset by learning only - /// the interface of one program (llvmc). - /// - /// @see llvmc.cpp - /// @brief The interface to the LLVM Compiler Driver. - class CompilerDriver { - /// @name Types - /// @{ - public: - /// @brief A vector of strings, used for argument lists - typedef std::vector StringVector; - - /// @brief A vector of sys::Path, used for path lists - typedef std::vector PathVector; - - /// @brief A table of strings, indexed typically by Phases - typedef std::vector StringTable; - - /// @brief The phases of processing that llvmc understands - enum Phases { - PREPROCESSING, ///< Source language combining, filtering, substitution - TRANSLATION, ///< Translate source -> LLVM bitcode/assembly - OPTIMIZATION, ///< Optimize translation result - ASSEMBLY, ///< Convert program to executable - LINKING, ///< Link bitcode and native code - NUM_PHASES ///< Always last! - }; - - /// @brief The levels of optimization llvmc understands - enum OptimizationLevels { - OPT_FAST_COMPILE, ///< Optimize to make >compile< go faster - OPT_SIMPLE, ///< Standard/simple optimizations - OPT_AGGRESSIVE, ///< Aggressive optimizations - OPT_LINK_TIME, ///< Aggressive + LinkTime optimizations - OPT_AGGRESSIVE_LINK_TIME, ///< Make it go way fast! - OPT_NONE ///< No optimizations. Keep this at the end! - }; - - /// @brief Action specific flags - enum ConfigurationFlags { - REQUIRED_FLAG = 0x0001, ///< Should the action always be run? - PREPROCESSES_FLAG = 0x0002, ///< Does this action preprocess? - TRANSLATES_FLAG = 0x0004, ///< Does this action translate? - OUTPUT_IS_ASM_FLAG = 0x0008, ///< Action produces .ll files? - FLAGS_MASK = 0x000F ///< Union of all flags - }; - - /// This type is the input list to the CompilerDriver. It provides - /// a vector of pathname/filetype pairs. The filetype is used to look up - /// the configuration of the actions to be taken by the driver. - /// @brief The Input Data to the execute method - typedef std::vector > InputList; - - /// This type is read from configuration files or otherwise provided to - /// the CompilerDriver through a "ConfigDataProvider". It serves as both - /// the template of what to do and the actual Action to be executed. - /// @brief A structure to hold the action data for a given source - /// language. - struct Action { - Action() : flags(0) {} - sys::Path program; ///< The program to execve - StringVector args; ///< Arguments to the program - unsigned flags; ///< Action specific flags - void set(unsigned fl ) { flags |= fl; } - void clear(unsigned fl) { flags &= (FLAGS_MASK ^ fl); } - bool isSet(unsigned fl) { return (flags&fl) != 0; } - }; - - struct ConfigData { - ConfigData(); - std::string version; ///< The version number. - std::string langName; ///< The name of the source language - StringTable opts; ///< The o10n options for each level - StringVector libpaths; ///< The library paths - Action PreProcessor; ///< PreProcessor command line - Action Translator; ///< Translator command line - Action Optimizer; ///< Optimizer command line - Action Assembler; ///< Assembler command line - Action Linker; ///< Linker command line - }; - - /// This pure virtual interface class defines the interface between the - /// CompilerDriver and other software that provides ConfigData objects to - /// it. The CompilerDriver must be configured to use an object of this - /// type so it can obtain the configuration data. - /// @see setConfigDataProvider - /// @brief Configuration Data Provider interface - class ConfigDataProvider { - public: - virtual ~ConfigDataProvider(); - virtual ConfigData* ProvideConfigData(const std::string& filetype) = 0; - virtual void setConfigDir(const sys::Path& dirName) = 0; - }; - - /// These flags control various actions of the compiler driver. They are - /// used by adding the needed flag values together and passing them to the - /// compiler driver's setDriverFlags method. - /// @see setDriverFlags - /// @brief Driver specific flags - enum DriverFlags { - DRY_RUN_FLAG = 0x0001, ///< Do everything but execute actions - VERBOSE_FLAG = 0x0002, ///< Print each action - DEBUG_FLAG = 0x0004, ///< Print debug information - TIME_PASSES_FLAG = 0x0008, ///< Time the passes as they execute - TIME_ACTIONS_FLAG = 0x0010, ///< Time the actions as they execute - SHOW_STATS_FLAG = 0x0020, ///< Show pass statistics - EMIT_NATIVE_FLAG = 0x0040, ///< Emit native code instead of bc - EMIT_RAW_FLAG = 0x0080, ///< Emit raw, unoptimized bitcode - KEEP_TEMPS_FLAG = 0x0100, ///< Don't delete temporary files - STRIP_OUTPUT_FLAG = 0x0200, ///< Strip symbols from linked output - DRIVER_FLAGS_MASK = 0x03FF ///< Union of the above flags - }; - - /// @} - /// @name Constructors - /// @{ - public: - /// @brief Static Constructor - static CompilerDriver* Get(ConfigDataProvider& CDP); - - /// @brief Virtual destructor - virtual ~CompilerDriver(); - - /// @} - /// @name Methods - /// @{ - public: - /// @brief Execute the actions requested for the given input list. - virtual int execute( - const InputList& list, const sys::Path& output, std::string& ErrMsg) =0; - - /// @brief Set the final phase at which compilation terminates - virtual void setFinalPhase(Phases phase) = 0; - - /// @brief Set the optimization level for the compilation - virtual void setOptimization(OptimizationLevels level) = 0; - - /// @brief Set the driver flags. - virtual void setDriverFlags(unsigned flags) = 0; - - /// @brief Set the output machine name. - virtual void setOutputMachine(const std::string& machineName) = 0; - - /// @brief Set the options for a given phase. - virtual void setPhaseArgs(Phases phase, const StringVector& opts) = 0; - - /// @brief Set Library Paths - virtual void setIncludePaths(const StringVector& paths) = 0; - - /// @brief Set Library Paths - virtual void setSymbolDefines(const StringVector& paths) = 0; - - /// @brief Set Library Paths - virtual void setLibraryPaths(const StringVector& paths) = 0; - - /// @brief Add a path to the list of library paths - virtual void addLibraryPath( const sys::Path& libPath ) = 0; - - /// @brief Add a path to the list of paths in which to find tools - virtual void addToolPath( const sys::Path& toolPath) = 0; - - /// @brief Set the list of -f options to be passed through - virtual void setfPassThrough(const StringVector& fOpts) = 0; - - /// @brief Set the list of -M options to be passed through - virtual void setMPassThrough(const StringVector& fOpts) = 0; - - /// @brief Set the list of -W options to be passed through - virtual void setWPassThrough(const StringVector& fOpts) = 0; - - /// @brief Determine where a linkage file is located in the file system - virtual sys::Path GetPathForLinkageItem( - const std::string& link_item, ///< Item to be sought - bool native = false ///< Looking for native? - ) = 0; - - /// @} - }; -} - -// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab -#endif Removed: llvm/trunk/tools/llvmc/ConfigLexer.cpp.cvs URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/ConfigLexer.cpp.cvs?rev=50614&view=auto ============================================================================== --- llvm/trunk/tools/llvmc/ConfigLexer.cpp.cvs (original) +++ llvm/trunk/tools/llvmc/ConfigLexer.cpp.cvs (removed) @@ -1,2900 +0,0 @@ -#line 2 "ConfigLexer.cpp" - -#line 4 "ConfigLexer.cpp" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 33 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#endif /* ! FLEXINT_H */ - -#ifdef __cplusplus - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -#if __STDC__ - -#define YY_USE_CONST - -#endif /* __STDC__ */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN (yy_start) = 1 + 2 * - -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START (((yy_start) - 1) / 2) -#define YYSTATE YY_START - -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE Configrestart(Configin ) - -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#define YY_BUF_SIZE (16384*64) -#endif - -/* The state buf must be large enough to hold one state per character in the main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -extern int Configleng; - -extern FILE *Configin, *Configout; - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - - #define YY_LESS_LINENO(n) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up Configtext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = (yy_hold_char); \ - YY_RESTORE_YY_MORE_OFFSET \ - (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up Configtext again */ \ - } \ - while ( 0 ) - -#define unput(c) yyunput( c, (yytext_ptr) ) - -/* The following is because we cannot portably get our hands on size_t - * (without autoconf's help, which isn't available because we want - * flex-generated scanners to compile on their own). - */ - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef unsigned int yy_size_t; -#endif - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via Configrestart()), so that the user can continue scanning by - * just pointing Configin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* Stack of input buffers. */ -static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ -static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ - ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ - : NULL) - -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] - -/* yy_hold_char holds the character lost when Configtext is formed. */ -static char yy_hold_char; -static int yy_n_chars; /* number of characters read into yy_ch_buf */ -int Configleng; - -/* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; -static int yy_init = 0; /* whether we need to initialize */ -static int yy_start = 0; /* start state number */ - -/* Flag which is used to allow Configwrap()'s to do buffer switches - * instead of setting up a fresh Configin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; - -void Configrestart (FILE *input_file ); -void Config_switch_to_buffer (YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE Config_create_buffer (FILE *file,int size ); -void Config_delete_buffer (YY_BUFFER_STATE b ); -void Config_flush_buffer (YY_BUFFER_STATE b ); -void Configpush_buffer_state (YY_BUFFER_STATE new_buffer ); -void Configpop_buffer_state (void ); - -static void Configensure_buffer_stack (void ); -static void Config_load_buffer_state (void ); -static void Config_init_buffer (YY_BUFFER_STATE b,FILE *file ); - -#define YY_FLUSH_BUFFER Config_flush_buffer(YY_CURRENT_BUFFER ) - -YY_BUFFER_STATE Config_scan_buffer (char *base,yy_size_t size ); -YY_BUFFER_STATE Config_scan_string (yyconst char *yy_str ); -YY_BUFFER_STATE Config_scan_bytes (yyconst char *bytes,int len ); - -void *Configalloc (yy_size_t ); -void *Configrealloc (void *,yy_size_t ); -void Configfree (void * ); - -#define yy_new_buffer Config_create_buffer - -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ - Configensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - Config_create_buffer(Configin,YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } - -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ - Configensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - Config_create_buffer(Configin,YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } - -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -/* Begin user sect3 */ - -#define Configwrap(n) 1 -#define YY_SKIP_YYWRAP - -typedef unsigned char YY_CHAR; - -FILE *Configin = (FILE *) 0, *Configout = (FILE *) 0; - -typedef int yy_state_type; - -extern int Configlineno; - -int Configlineno = 1; - -extern char *Configtext; -#define yytext_ptr Configtext - -static yy_state_type yy_get_previous_state (void ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); -static int yy_get_next_buffer (void ); -static void yy_fatal_error (yyconst char msg[] ); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up Configtext. - */ -#define YY_DO_BEFORE_ACTION \ - (yytext_ptr) = yy_bp; \ - Configleng = (size_t) (yy_cp - yy_bp); \ - (yy_hold_char) = *yy_cp; \ - *yy_cp = '\0'; \ - (yy_c_buf_p) = yy_cp; - -#define YY_NUM_RULES 55 -#define YY_END_OF_BUFFER 56 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; -static yyconst flex_int16_t yy_accept[408] = - { 0, - 1, 1, 56, 55, 1, 4, 55, 55, 55, 52, - 52, 6, 5, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 1, 4, - 0, 53, 0, 2, 0, 54, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 49, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 51, 52, 52, 50, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 3, 0, 52, 52, 52, 52, 52, - - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 48, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 29, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 8, 9, 52, 52, 10, - - 11, 12, 13, 14, 15, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 39, 40, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 26, 52, 28, 52, - 52, 52, 32, 52, 52, 52, 52, 43, 52, 52, - 52, 52, 52, 52, 52, 25, 52, 21, 52, 52, - - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 46, 47, 52, 45, 30, - 52, 52, 52, 52, 41, 52, 52, 52, 52, 17, - 52, 52, 52, 52, 52, 52, 52, 52, 7, 52, - 52, 52, 52, 52, 27, 31, 52, 52, 52, 42, - 52, 52, 52, 52, 52, 52, 52, 18, 52, 52, - 52, 52, 52, 52, 37, 52, 35, 52, 52, 36, - 44, 24, 22, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 23, 19, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - - 52, 33, 20, 16, 38, 34, 0 - } ; - -static yyconst flex_int32_t yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 1, 5, 6, 1, 7, 1, 1, 1, - 1, 1, 8, 8, 8, 9, 8, 8, 10, 11, - 12, 13, 14, 8, 8, 8, 8, 8, 1, 1, - 15, 1, 1, 16, 17, 18, 19, 20, 21, 22, - 23, 24, 25, 24, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 24, 39, 40, - 1, 41, 1, 1, 8, 1, 42, 43, 44, 45, - - 46, 47, 48, 49, 50, 24, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 24, 63, - 64, 65, 1, 8, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static yyconst flex_int32_t yy_meta[66] = - { 0, - 1, 1, 1, 1, 1, 1, 2, 3, 1, 3, - 3, 3, 3, 3, 1, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3 - } ; - -static yyconst flex_int16_t yy_base[412] = - { 0, - 0, 0, 716, 3252, 713, 3252, 711, 708, 63, 61, - 0, 3252, 3252, 36, 57, 50, 67, 68, 70, 93, - 59, 73, 68, 93, 106, 75, 652, 46, 655, 667, - 41, 86, 89, 650, 661, 648, 659, 658, 701, 3252, - 697, 3252, 94, 3252, 698, 3252, 0, 148, 183, 218, - 253, 305, 349, 389, 424, 472, 518, 573, 627, 671, - 103, 641, 0, 664, 638, 669, 643, 668, 642, 664, - 115, 638, 92, 663, 0, 637, 667, 0, 653, 651, - 633, 616, 615, 653, 627, 640, 614, 115, 92, 637, - 609, 632, 606, 3252, 661, 89, 603, 609, 609, 606, - - 114, 606, 611, 597, 596, 609, 597, 121, 595, 593, - 711, 761, 811, 853, 901, 942, 992, 1030, 1067, 1123, - 1177, 1231, 1267, 1319, 1366, 0, 630, 604, 630, 604, - 619, 593, 611, 585, 619, 602, 606, 583, 571, 578, - 607, 581, 159, 595, 164, 569, 593, 592, 586, 560, - 591, 598, 564, 571, 582, 556, 567, 568, 558, 551, - 561, 549, 556, 560, 190, 549, 548, 542, 548, 555, - 541, 1418, 1472, 1526, 1579, 1618, 1671, 3252, 1725, 1771, - 1824, 231, 242, 1871, 1925, 1967, 2007, 571, 545, 567, - 541, 577, 551, 571, 545, 0, 0, 569, 542, 0, - - 0, 0, 0, 0, 0, 550, 541, 523, 514, 540, - 514, 546, 513, 526, 499, 531, 500, 494, 491, 501, - 491, 481, 468, 458, 452, 459, 448, 451, 2044, 2097, - 263, 2150, 279, 2194, 2247, 2300, 289, 2344, 3252, 3252, - 2386, 2439, 325, 2479, 473, 438, 457, 431, 445, 419, - 438, 403, 430, 417, 399, 383, 409, 378, 396, 370, - 400, 373, 386, 360, 370, 367, 357, 352, 359, 348, - 352, 348, 346, 339, 337, 363, 3252, 2528, 3252, 373, - 410, 2580, 3252, 2632, 2670, 434, 2727, 3252, 2781, 366, - 340, 370, 342, 362, 327, 0, 329, 0, 303, 348, - - 320, 337, 308, 335, 301, 313, 286, 282, 285, 284, - 263, 283, 280, 283, 270, 3252, 3252, 446, 3252, 3252, - 456, 482, 2834, 2872, 3252, 492, 2929, 144, 121, 0, - 302, 276, 293, 264, 289, 263, 272, 246, 0, 134, - 252, 242, 240, 224, 3252, 3252, 74, 2969, 504, 3252, - 528, 249, 223, 247, 220, 234, 203, 0, 158, 160, - 199, 193, 187, 161, 3252, 185, 3252, 3008, 3060, 3252, - 3252, 0, 0, 202, 176, 199, 194, 164, 164, 162, - 161, 154, 150, 3104, 3142, 187, 163, 0, 0, 164, - 146, 3194, 541, 158, 154, 127, 123, 107, 80, 81, - - 554, 3252, 0, 0, 3252, 3252, 3252, 3243, 3246, 3248, - 83 - } ; - -static yyconst flex_int16_t yy_def[412] = - { 0, - 407, 1, 407, 407, 407, 407, 407, 408, 409, 410, - 411, 407, 407, 411, 411, 411, 411, 411, 411, 411, - 411, 411, 411, 411, 411, 411, 411, 411, 411, 411, - 411, 411, 411, 411, 411, 411, 411, 411, 407, 407, - 408, 407, 409, 407, 407, 407, 411, 410, 410, 410, - 410, 410, 410, 410, 410, 410, 410, 410, 410, 410, - 411, 411, 411, 411, 411, 411, 411, 411, 411, 411, - 411, 411, 411, 411, 411, 411, 411, 411, 411, 411, - 411, 411, 411, 411, 411, 411, 411, 411, 411, 411, - 411, 411, 411, 407, 407, 411, 411, 411, 411, 411, - - 411, 411, 411, 411, 411, 411, 411, 411, 411, 411, - 410, 410, 410, 410, 410, 410, 410, 410, 410, 410, - 410, 410, 410, 410, 410, 411, 411, 411, 411, 411, - 411, 411, 411, 411, 411, 411, 411, 411, 411, 411, - 411, 411, 411, 411, 411, 411, 411, 411, 411, 411, - 411, 411, 411, 411, 411, 411, 411, 411, 411, 411, - 411, 411, 411, 411, 411, 411, 411, 411, 411, 411, - 411, 410, 410, 410, 410, 410, 410, 407, 410, 410, - 410, 410, 410, 410, 410, 410, 410, 411, 411, 411, - 411, 411, 411, 411, 411, 411, 411, 411, 411, 411, - - 411, 411, 411, 411, 411, 411, 411, 411, 411, 411, - 411, 411, 411, 411, 411, 411, 411, 411, 411, 411, - 411, 411, 411, 411, 411, 411, 411, 411, 410, 410, - 410, 410, 410, 410, 410, 410, 410, 410, 407, 407, - 410, 410, 410, 410, 411, 411, 411, 411, 411, 411, - 411, 411, 411, 411, 411, 411, 411, 411, 411, 411, - 411, 411, 411, 411, 411, 411, 411, 411, 411, 411, - 411, 411, 411, 411, 410, 410, 407, 410, 407, 410, - 410, 410, 407, 410, 410, 410, 410, 407, 410, 411, - 411, 411, 411, 411, 411, 411, 411, 411, 411, 411, - - 411, 411, 411, 411, 411, 411, 411, 411, 411, 411, - 411, 411, 411, 411, 411, 407, 407, 410, 407, 407, - 410, 410, 410, 410, 407, 410, 410, 411, 411, 411, - 411, 411, 411, 411, 411, 411, 411, 411, 411, 411, - 411, 411, 411, 411, 407, 407, 411, 410, 410, 407, - 410, 411, 411, 411, 411, 411, 411, 411, 411, 411, - 411, 411, 411, 411, 407, 411, 407, 410, 410, 407, - 407, 411, 411, 411, 411, 411, 411, 411, 411, 411, - 411, 411, 411, 410, 410, 411, 411, 411, 411, 411, - 411, 410, 410, 411, 411, 411, 411, 411, 411, 411, - - 410, 407, 411, 411, 407, 407, 0, 407, 407, 407, - 407 - } ; - -static yyconst flex_int16_t yy_nxt[3318] = - { 0, - 4, 5, 6, 7, 8, 9, 10, 11, 12, 11, - 11, 11, 11, 11, 13, 4, 14, 15, 16, 11, - 11, 17, 11, 11, 11, 11, 18, 11, 19, 20, - 21, 11, 22, 11, 23, 11, 24, 11, 25, 11, - 26, 27, 28, 29, 11, 11, 30, 11, 11, 11, - 11, 31, 11, 32, 33, 34, 11, 35, 11, 36, - 11, 37, 11, 38, 11, 44, 45, 46, 47, 61, - 47, 47, 47, 47, 47, 63, 47, 94, 95, 66, - 365, 64, 100, 68, 70, 47, 74, 405, 49, 63, - 101, 84, 71, 86, 62, 97, 44, 45, 50, 75, - - 88, 47, 51, 52, 67, 53, 65, 54, 69, 72, - 55, 76, 56, 90, 77, 57, 85, 73, 87, 58, - 59, 78, 60, 79, 75, 89, 92, 102, 80, 366, - 126, 151, 136, 153, 139, 103, 127, 404, 91, 81, - 75, 126, 78, 137, 104, 140, 78, 157, 82, 105, - 152, 93, 154, 83, 46, 47, 162, 47, 47, 47, - 47, 47, 169, 47, 352, 403, 353, 163, 201, 202, - 203, 204, 205, 201, 202, 203, 204, 205, 376, 361, - 404, 170, 126, 206, 126, 403, 404, 377, 47, 46, - 47, 403, 47, 47, 47, 47, 47, 126, 47, 201, - - 202, 203, 204, 205, 400, 378, 381, 394, 396, 398, - 391, 389, 111, 208, 379, 382, 395, 397, 399, 388, - 390, 389, 388, 47, 46, 47, 389, 47, 47, 47, - 47, 47, 388, 47, 387, 386, 383, 239, 47, 223, - 47, 47, 47, 47, 47, 380, 47, 112, 240, 47, - 373, 47, 47, 47, 47, 47, 372, 47, 47, 46, - 47, 375, 47, 47, 47, 47, 47, 374, 47, 277, - 47, 47, 47, 47, 47, 47, 47, 373, 47, 373, - 372, 372, 47, 364, 358, 279, 47, 363, 47, 47, - 47, 47, 47, 47, 47, 283, 47, 362, 47, 47, - - 47, 47, 47, 47, 47, 360, 359, 358, 358, 357, - 113, 46, 47, 356, 47, 47, 47, 47, 47, 47, - 47, 355, 354, 339, 344, 343, 342, 341, 330, 47, - 63, 288, 47, 340, 47, 47, 47, 47, 47, 339, - 47, 339, 338, 316, 47, 47, 47, 47, 47, 47, - 47, 337, 47, 336, 114, 46, 47, 335, 47, 47, - 47, 47, 47, 334, 47, 47, 333, 332, 331, 317, - 47, 330, 47, 47, 47, 47, 47, 47, 47, 319, - 47, 330, 47, 47, 47, 47, 47, 63, 47, 47, - 63, 329, 328, 315, 115, 46, 47, 314, 47, 47, - - 47, 47, 47, 47, 47, 313, 312, 298, 311, 296, - 310, 309, 308, 47, 307, 306, 320, 47, 116, 47, - 47, 47, 47, 47, 305, 47, 304, 303, 302, 47, - 46, 47, 301, 47, 47, 47, 47, 47, 300, 47, - 325, 47, 298, 47, 47, 47, 47, 47, 299, 47, - 47, 298, 345, 47, 297, 47, 47, 47, 47, 47, - 296, 47, 346, 47, 47, 47, 47, 47, 47, 47, - 296, 47, 295, 294, 47, 293, 292, 117, 46, 47, - 291, 47, 47, 47, 47, 47, 47, 47, 46, 47, - 290, 347, 47, 47, 47, 47, 47, 47, 350, 47, - - 274, 47, 47, 47, 47, 47, 273, 47, 272, 271, - 370, 47, 47, 47, 47, 47, 47, 47, 270, 47, - 269, 118, 47, 119, 46, 47, 268, 47, 47, 47, - 47, 47, 47, 47, 371, 47, 75, 47, 47, 47, - 47, 47, 267, 47, 47, 266, 265, 402, 47, 264, - 47, 47, 47, 47, 47, 263, 47, 262, 47, 261, - 406, 47, 260, 47, 47, 47, 47, 47, 47, 47, - 259, 258, 257, 120, 256, 255, 254, 253, 121, 46, - 47, 47, 47, 47, 47, 47, 47, 252, 47, 251, - 75, 75, 250, 249, 47, 248, 247, 246, 245, 228, - - 78, 227, 226, 225, 224, 200, 222, 197, 196, 221, - 220, 219, 218, 47, 217, 216, 78, 215, 78, 214, - 213, 212, 211, 210, 209, 207, 200, 200, 199, 197, - 196, 198, 122, 46, 47, 197, 47, 47, 47, 47, - 47, 196, 47, 195, 194, 193, 192, 191, 190, 189, - 188, 78, 171, 168, 167, 166, 165, 75, 164, 161, - 160, 159, 158, 94, 78, 78, 156, 47, 123, 155, - 150, 149, 148, 147, 146, 145, 124, 46, 47, 75, - 47, 47, 47, 47, 47, 144, 47, 143, 75, 142, - 141, 138, 135, 134, 133, 132, 131, 130, 129, 128, - - 44, 42, 39, 110, 109, 108, 107, 106, 99, 98, - 96, 47, 42, 40, 39, 407, 125, 46, 47, 407, - 47, 47, 47, 47, 47, 407, 47, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 47, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 172, 46, 47, 407, - 47, 47, 47, 47, 47, 407, 47, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - - 407, 47, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 173, 46, 47, 407, - 47, 47, 47, 47, 47, 407, 47, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 47, 407, 407, 407, 407, 407, 407, 174, 46, - 47, 407, 47, 47, 47, 47, 47, 407, 47, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 47, 407, 407, 407, 407, 407, 407, - - 407, 407, 407, 407, 407, 407, 175, 46, 47, 407, - 47, 47, 47, 47, 47, 407, 47, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 47, 407, 407, 407, 407, 407, 176, 46, 47, - 407, 47, 47, 47, 47, 47, 407, 47, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 47, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 177, 178, 47, - - 407, 47, 47, 47, 47, 47, 407, 47, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 47, 407, 407, 179, 46, 47, 407, 47, - 47, 47, 47, 47, 407, 47, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 47, 407, 180, 46, 47, 407, 47, 47, 47, 47, - 47, 407, 47, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - - 407, 407, 407, 407, 407, 407, 407, 47, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 181, 46, - 47, 407, 47, 47, 47, 47, 47, 407, 47, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 47, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 182, 46, 47, 407, 47, 47, 47, 47, - 47, 407, 47, 407, 407, 407, 407, 407, 407, 407, - - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 47, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 183, 46, 47, 407, - 47, 47, 47, 47, 47, 407, 47, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 47, 184, 46, 47, 407, 47, 47, 47, 47, - 47, 407, 47, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - - 407, 407, 407, 407, 407, 407, 407, 47, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 185, 46, 47, 407, 47, 47, - 47, 47, 47, 407, 47, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 47, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 186, 46, 47, 407, 47, 47, 47, 47, 47, - 407, 47, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - - 407, 407, 407, 407, 407, 407, 47, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 187, 46, 47, 407, 47, 47, 47, - 47, 47, 407, 47, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 47, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 229, 46, 47, - 407, 47, 47, 47, 47, 47, 407, 47, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 47, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 230, 46, 47, 407, 47, 47, 47, 47, 47, - 407, 47, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 47, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 231, 46, 47, 407, 47, 47, - 47, 47, 47, 407, 47, 407, 407, 407, 407, 407, - - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 47, - 407, 407, 407, 232, 46, 47, 407, 47, 47, 47, - 47, 47, 407, 47, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 47, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 233, 46, 47, 407, - 47, 47, 47, 47, 47, 407, 47, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 47, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 234, 46, 47, 407, 47, 47, 47, 47, 47, 407, - 47, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 47, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 235, 46, 47, 407, - 47, 47, 47, 47, 47, 407, 47, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 47, 407, 407, 407, 236, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 237, - 46, 47, 407, 47, 47, 47, 47, 47, 407, 47, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 47, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 238, 46, 47, 407, - 47, 47, 47, 47, 47, 407, 47, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 47, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 241, 46, 47, 407, 47, 47, 47, 47, 47, 407, - 47, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 47, 407, 407, 407, 407, - 407, 407, 242, 46, 47, 407, 47, 47, 47, 47, - 47, 407, 47, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - - 407, 407, 407, 407, 407, 407, 407, 47, 407, 407, - 407, 407, 243, 46, 47, 407, 47, 47, 47, 47, - 47, 407, 47, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 47, 407, 244, - 46, 47, 407, 47, 47, 47, 47, 47, 407, 47, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 47, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - - 407, 407, 275, 46, 47, 407, 47, 47, 47, 47, - 47, 407, 47, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 47, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 276, 46, 47, 407, 47, - 47, 47, 47, 47, 407, 47, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 47, 407, 407, 407, 407, 407, 407, 407, 407, 278, - - 46, 47, 407, 47, 47, 47, 47, 47, 407, 47, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 47, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 280, 46, 47, 407, 47, 47, 47, 47, - 47, 407, 47, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 47, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - - 407, 407, 407, 407, 407, 281, 46, 47, 407, 47, - 47, 47, 47, 47, 407, 47, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 47, 407, 407, 407, 407, 407, 407, 407, 407, 282, - 46, 47, 407, 47, 47, 47, 47, 47, 407, 47, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 47, 407, 407, 284, 407, 407, - 407, 285, 46, 47, 407, 47, 47, 47, 47, 47, - - 407, 47, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 47, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 286, 46, 47, 407, 47, 47, - 47, 47, 47, 407, 47, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 47, - 407, 407, 407, 407, 287, 46, 47, 407, 47, 47, - 47, 47, 47, 407, 47, 407, 407, 407, 407, 407, - - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 47, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 289, 46, 47, 407, 47, 47, 47, - 47, 47, 407, 47, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 47, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 318, 46, 47, 407, 47, - 47, 47, 47, 47, 407, 47, 407, 407, 407, 407, - - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 47, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 321, 46, 47, - 407, 47, 47, 47, 47, 47, 407, 47, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 47, 407, 407, 322, 46, 47, 407, 47, - 47, 47, 47, 47, 407, 47, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 47, 407, 407, 323, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 324, 46, 47, 407, 47, 47, 47, 47, - 47, 407, 47, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 47, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 326, 46, 47, 407, - 47, 47, 47, 47, 47, 407, 47, 407, 407, 407, - - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 47, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 327, - 46, 47, 407, 47, 47, 47, 47, 47, 407, 47, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 47, 407, 407, 348, 46, 47, - 407, 47, 47, 47, 47, 47, 407, 47, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 47, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 349, 46, 47, 407, 47, 47, - 47, 47, 47, 407, 47, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 47, - 407, 407, 407, 407, 351, 367, 47, 407, 47, 47, - 47, 47, 47, 407, 47, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - - 407, 407, 407, 407, 407, 407, 407, 407, 407, 47, - 368, 407, 407, 369, 46, 47, 407, 47, 47, 47, - 47, 47, 407, 47, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 47, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 384, 46, 47, 407, 47, - 47, 47, 47, 47, 407, 47, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - - 47, 407, 407, 407, 407, 407, 407, 407, 407, 385, - 46, 47, 407, 47, 47, 47, 47, 47, 407, 47, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 47, 407, 407, 392, 46, 47, - 407, 47, 47, 47, 47, 47, 407, 47, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 47, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 393, - - 46, 47, 407, 47, 47, 47, 47, 47, 407, 47, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 47, 407, 407, 407, 407, 407, - 407, 407, 401, 41, 41, 41, 43, 43, 43, 48, - 48, 3, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407 - } ; - -static yyconst flex_int16_t yy_chk[3318] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 9, 9, 10, 10, 14, - 10, 10, 10, 10, 10, 15, 10, 26, 26, 16, - 347, 15, 31, 17, 18, 411, 19, 400, 10, 28, - 31, 21, 18, 22, 14, 28, 43, 43, 10, 19, - - 23, 10, 10, 10, 16, 10, 15, 10, 17, 18, - 10, 19, 10, 24, 20, 10, 21, 18, 22, 10, - 10, 20, 10, 20, 19, 23, 25, 32, 20, 347, - 61, 88, 71, 89, 73, 33, 61, 399, 24, 20, - 32, 96, 33, 71, 33, 73, 20, 96, 20, 33, - 88, 25, 89, 20, 48, 48, 101, 48, 48, 48, - 48, 48, 108, 48, 328, 398, 329, 101, 143, 143, - 143, 143, 143, 145, 145, 145, 145, 145, 359, 340, - 397, 108, 328, 143, 329, 396, 395, 359, 48, 49, - 49, 394, 49, 49, 49, 49, 49, 340, 49, 165, - - 165, 165, 165, 165, 391, 360, 364, 386, 387, 390, - 383, 382, 49, 145, 360, 364, 386, 387, 390, 381, - 380, 379, 378, 49, 50, 50, 377, 50, 50, 50, - 50, 50, 376, 50, 375, 374, 366, 182, 182, 165, - 182, 182, 182, 182, 182, 363, 182, 50, 183, 183, - 362, 183, 183, 183, 183, 183, 361, 183, 50, 51, - 51, 357, 51, 51, 51, 51, 51, 356, 51, 231, - 231, 182, 231, 231, 231, 231, 231, 355, 231, 354, - 353, 352, 183, 344, 343, 233, 233, 342, 233, 233, - 233, 233, 233, 51, 233, 237, 237, 341, 237, 237, - - 237, 237, 237, 231, 237, 338, 337, 336, 335, 334, - 51, 52, 52, 333, 52, 52, 52, 52, 52, 233, - 52, 332, 331, 315, 314, 313, 312, 311, 310, 237, - 309, 243, 243, 308, 243, 243, 243, 243, 243, 307, - 243, 306, 305, 275, 275, 52, 275, 275, 275, 275, - 275, 304, 275, 303, 52, 53, 53, 302, 53, 53, - 53, 53, 53, 301, 53, 243, 300, 299, 297, 276, - 276, 295, 276, 276, 276, 276, 276, 275, 276, 280, - 280, 294, 280, 280, 280, 280, 280, 293, 280, 53, - 292, 291, 290, 274, 53, 54, 54, 273, 54, 54, - - 54, 54, 54, 276, 54, 272, 271, 270, 269, 268, - 267, 266, 265, 280, 264, 263, 281, 281, 54, 281, - 281, 281, 281, 281, 262, 281, 261, 260, 259, 54, - 55, 55, 258, 55, 55, 55, 55, 55, 257, 55, - 286, 286, 256, 286, 286, 286, 286, 286, 255, 286, - 281, 254, 318, 318, 253, 318, 318, 318, 318, 318, - 252, 318, 321, 321, 55, 321, 321, 321, 321, 321, - 251, 321, 250, 249, 286, 248, 247, 55, 56, 56, - 246, 56, 56, 56, 56, 56, 318, 56, 322, 322, - 245, 322, 322, 322, 322, 322, 321, 322, 326, 326, - - 228, 326, 326, 326, 326, 326, 227, 326, 226, 225, - 349, 349, 56, 349, 349, 349, 349, 349, 224, 349, - 223, 56, 322, 56, 57, 57, 222, 57, 57, 57, - 57, 57, 326, 57, 351, 351, 221, 351, 351, 351, - 351, 351, 220, 351, 349, 219, 218, 393, 393, 217, - 393, 393, 393, 393, 393, 216, 393, 215, 57, 214, - 401, 401, 213, 401, 401, 401, 401, 401, 351, 401, - 212, 211, 210, 57, 209, 208, 207, 206, 57, 58, - 58, 393, 58, 58, 58, 58, 58, 199, 58, 198, - 195, 194, 193, 192, 401, 191, 190, 189, 188, 171, - - 170, 169, 168, 167, 166, 164, 163, 162, 161, 160, - 159, 158, 157, 58, 156, 155, 154, 153, 152, 151, - 150, 149, 148, 147, 146, 144, 142, 141, 140, 139, - 138, 137, 58, 59, 59, 136, 59, 59, 59, 59, - 59, 135, 59, 134, 133, 132, 131, 130, 129, 128, - 127, 110, 109, 107, 106, 105, 104, 103, 102, 100, - 99, 98, 97, 95, 93, 92, 91, 59, 59, 90, - 87, 86, 85, 84, 83, 82, 59, 60, 60, 81, - 60, 60, 60, 60, 60, 80, 60, 79, 77, 76, - 74, 72, 70, 69, 68, 67, 66, 65, 64, 62, - - 45, 41, 39, 38, 37, 36, 35, 34, 30, 29, - 27, 60, 8, 7, 5, 3, 60, 111, 111, 0, - 111, 111, 111, 111, 111, 0, 111, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 111, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 111, 112, 112, 0, - 112, 112, 112, 112, 112, 0, 112, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 112, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 112, 113, 113, 0, - 113, 113, 113, 113, 113, 0, 113, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 113, 0, 0, 0, 0, 0, 0, 113, 114, - 114, 0, 114, 114, 114, 114, 114, 0, 114, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 114, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 114, 115, 115, 0, - 115, 115, 115, 115, 115, 0, 115, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 115, 0, 0, 0, 0, 0, 115, 116, 116, - 0, 116, 116, 116, 116, 116, 0, 116, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 116, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 116, 117, 117, - - 0, 117, 117, 117, 117, 117, 0, 117, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 117, 0, 0, 117, 118, 118, 0, 118, - 118, 118, 118, 118, 0, 118, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 118, 0, 118, 119, 119, 0, 119, 119, 119, 119, - 119, 0, 119, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 119, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 119, 120, - 120, 0, 120, 120, 120, 120, 120, 0, 120, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 120, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 120, 121, 121, 0, 121, 121, 121, 121, - 121, 0, 121, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 121, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 121, 122, 122, 0, - 122, 122, 122, 122, 122, 0, 122, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 122, 122, 123, 123, 0, 123, 123, 123, 123, - 123, 0, 123, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 123, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 123, 124, 124, 0, 124, 124, - 124, 124, 124, 0, 124, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 124, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 124, 125, 125, 0, 125, 125, 125, 125, 125, - 0, 125, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 125, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 125, 172, 172, 0, 172, 172, 172, - 172, 172, 0, 172, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 172, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 172, 173, 173, - 0, 173, 173, 173, 173, 173, 0, 173, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 173, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 173, 174, 174, 0, 174, 174, 174, 174, 174, - 0, 174, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 174, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 174, 175, 175, 0, 175, 175, - 175, 175, 175, 0, 175, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 175, - 0, 0, 0, 175, 176, 176, 0, 176, 176, 176, - 176, 176, 0, 176, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 176, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 176, 177, 177, 0, - 177, 177, 177, 177, 177, 0, 177, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 177, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 177, 179, 179, 0, 179, 179, 179, 179, 179, 0, - 179, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 179, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 179, 180, 180, 0, - 180, 180, 180, 180, 180, 0, 180, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 180, 0, 0, 0, 180, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 180, - 181, 181, 0, 181, 181, 181, 181, 181, 0, 181, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 181, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 181, 184, 184, 0, - 184, 184, 184, 184, 184, 0, 184, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 184, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 184, 185, 185, 0, 185, 185, 185, 185, 185, 0, - 185, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 185, 0, 0, 0, 0, - 0, 0, 185, 186, 186, 0, 186, 186, 186, 186, - 186, 0, 186, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 186, 0, 0, - 0, 0, 186, 187, 187, 0, 187, 187, 187, 187, - 187, 0, 187, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 187, 0, 187, - 229, 229, 0, 229, 229, 229, 229, 229, 0, 229, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 229, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 229, 230, 230, 0, 230, 230, 230, 230, - 230, 0, 230, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 230, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 230, 232, 232, 0, 232, - 232, 232, 232, 232, 0, 232, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 232, 0, 0, 0, 0, 0, 0, 0, 0, 232, - - 234, 234, 0, 234, 234, 234, 234, 234, 0, 234, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 234, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 234, 235, 235, 0, 235, 235, 235, 235, - 235, 0, 235, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 235, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 235, 236, 236, 0, 236, - 236, 236, 236, 236, 0, 236, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 236, 0, 0, 0, 0, 0, 0, 0, 0, 236, - 238, 238, 0, 238, 238, 238, 238, 238, 0, 238, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 238, 0, 0, 238, 0, 0, - 0, 238, 241, 241, 0, 241, 241, 241, 241, 241, - - 0, 241, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 241, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 241, 242, 242, 0, 242, 242, - 242, 242, 242, 0, 242, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 242, - 0, 0, 0, 0, 242, 244, 244, 0, 244, 244, - 244, 244, 244, 0, 244, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 244, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 244, 278, 278, 0, 278, 278, 278, - 278, 278, 0, 278, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 278, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 278, 282, 282, 0, 282, - 282, 282, 282, 282, 0, 282, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 282, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 282, 284, 284, - 0, 284, 284, 284, 284, 284, 0, 284, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 284, 0, 0, 284, 285, 285, 0, 285, - 285, 285, 285, 285, 0, 285, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 285, 0, 0, 285, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 285, 287, 287, 0, 287, 287, 287, 287, - 287, 0, 287, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 287, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 287, 289, 289, 0, - 289, 289, 289, 289, 289, 0, 289, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 289, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 289, - 323, 323, 0, 323, 323, 323, 323, 323, 0, 323, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 323, 0, 0, 323, 324, 324, - 0, 324, 324, 324, 324, 324, 0, 324, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 324, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 324, 327, 327, 0, 327, 327, - 327, 327, 327, 0, 327, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 327, - 0, 0, 0, 0, 327, 348, 348, 0, 348, 348, - 348, 348, 348, 0, 348, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 348, - 348, 0, 0, 348, 368, 368, 0, 368, 368, 368, - 368, 368, 0, 368, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 368, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 368, 369, 369, 0, 369, - 369, 369, 369, 369, 0, 369, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 369, 0, 0, 0, 0, 0, 0, 0, 0, 369, - 384, 384, 0, 384, 384, 384, 384, 384, 0, 384, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 384, 0, 0, 384, 385, 385, - 0, 385, 385, 385, 385, 385, 0, 385, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 385, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 385, - - 392, 392, 0, 392, 392, 392, 392, 392, 0, 392, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 392, 0, 0, 0, 0, 0, - 0, 0, 392, 408, 408, 408, 409, 409, 409, 410, - 410, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407 - } ; - -static yy_state_type yy_last_accepting_state; -static char *yy_last_accepting_cpos; - -extern int Config_flex_debug; -int Config_flex_debug = 0; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -char *Configtext; -#line 1 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -/*===- ConfigLexer.l - Scanner for CompilerDriver Config Files -*- C++ -*--===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements the flex scanner for configuration files for the -// llvmc CompilerDriver. -// -//===----------------------------------------------------------------------===*/ -#line 29 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" - -#include "ConfigLexer.h" - -#define YY_INPUT(buf,result,max_size) \ - { \ - assert(ConfigLexerInput != 0 && "Oops"); \ - result = ConfigLexerInput->read(buf,max_size); \ - if (result == 0 ) result = YY_NULL; \ - } - -#define YY_FATAL_ERROR(msg) \ - { \ - assert(ConfigLexerInput != 0 && "Oops"); \ - ConfigLexerInput->error(msg); \ - } - -#define YY_DECL ConfigLexerTokens llvm::Configlex() - -#define yyterminate() { return EOFTOK; } - -using namespace llvm; - -inline llvm::ConfigLexerTokens -handleNameContext(llvm::ConfigLexerTokens token) { - ConfigLexerState.StringVal = Configtext; - if (ConfigLexerState.in_value) - return OPTION; - return token; -} - -inline llvm::ConfigLexerTokens -handleSubstitution(llvm::ConfigLexerTokens token) { - if (ConfigLexerState.in_value) { - ConfigLexerState.StringVal = Configtext; - return token; - } - YY_FATAL_ERROR("Substitition tokens not allowed in names" ); - return ERRORTOK; -} - -inline llvm::ConfigLexerTokens handleValueContext(llvm::ConfigLexerTokens token) { - ConfigLexerState.StringVal = Configtext; - if (ConfigLexerState.in_value) - return token; - return OPTION; -} - -#line 1386 "ConfigLexer.cpp" - -#define INITIAL 0 - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -static int yy_init_globals (void ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int Configwrap (void ); -#else -extern int Configwrap (void ); -#endif -#endif - - static inline void yyunput (int c,char *buf_ptr ); - -#ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ); -#endif - -#ifndef YY_NO_INPUT - -#ifdef __cplusplus -static int yyinput (void ); -#else -static int input (void ); -#endif - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#endif - -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO (void) fwrite( Configtext, Configleng, 1, Configout ) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ - { \ - int c = '*'; \ - size_t n; \ - for ( n = 0; n < max_size && \ - (c = getc( Configin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( Configin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else \ - { \ - errno=0; \ - while ( (result = fread(buf, 1, max_size, Configin))==0 && ferror(Configin)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(Configin); \ - } \ - }\ -\ - -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) -#endif - -/* end tables serialization structures and prototypes */ - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int Configlex (void); - -#define YY_DECL int Configlex (void) -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after Configtext and Configleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK break; -#endif - -#define YY_RULE_SETUP \ - YY_USER_ACTION - -/** The main scanner function which does all the work. - */ -YY_DECL -{ - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; - -#line 114 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" - - -#line 1542 "ConfigLexer.cpp" - - if ( !(yy_init) ) - { - (yy_init) = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! (yy_start) ) - (yy_start) = 1; /* first start state */ - - if ( ! Configin ) - Configin = stdin; - - if ( ! Configout ) - Configout = stdout; - - if ( ! YY_CURRENT_BUFFER ) { - Configensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - Config_create_buffer(Configin,YY_BUF_SIZE ); - } - - Config_load_buffer_state( ); - } - - while ( 1 ) /* loops until end-of-file is reached */ - { - yy_cp = (yy_c_buf_p); - - /* Support of Configtext. */ - *yy_cp = (yy_hold_char); - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = (yy_start); -yy_match: - do - { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; - if ( yy_accept[yy_current_state] ) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 408 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - ++yy_cp; - } - while ( yy_current_state != 407 ); - yy_cp = (yy_last_accepting_cpos); - yy_current_state = (yy_last_accepting_state); - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - - YY_DO_BEFORE_ACTION; - -do_action: /* This label is used only to access EOF actions. */ - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = (yy_hold_char); - yy_cp = (yy_last_accepting_cpos); - yy_current_state = (yy_last_accepting_state); - goto yy_find_action; - -case 1: -YY_RULE_SETUP -#line 116 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ if (ConfigLexerState.in_value) return SPACE; } - YY_BREAK -case 2: -/* rule 2 can match eol */ -YY_RULE_SETUP -#line 118 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ /* Ignore comments */ - ConfigLexerState.in_value = false; - ConfigLexerState.lineNum++; - return EOLTOK; - } - YY_BREAK -case 3: -/* rule 3 can match eol */ -YY_RULE_SETUP -#line 124 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ ConfigLexerState.lineNum++; - /* Don't return EOLTOK! */ - } - YY_BREAK -case 4: -/* rule 4 can match eol */ -YY_RULE_SETUP -#line 128 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ ConfigLexerState.in_value = false; - ConfigLexerState.lineNum++; - return EOLTOK; - } - YY_BREAK -case 5: -YY_RULE_SETUP -#line 133 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ ConfigLexerState.in_value = true; - return EQUALS; - } - YY_BREAK -case 6: -YY_RULE_SETUP -#line 137 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return SEPARATOR; } - YY_BREAK -case 7: -YY_RULE_SETUP -#line 139 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleNameContext(VERSION_TOK); } - YY_BREAK -case 8: -YY_RULE_SETUP -#line 141 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleNameContext(LANG); } - YY_BREAK -case 9: -YY_RULE_SETUP -#line 142 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleNameContext(LIBS); } - YY_BREAK -case 10: -YY_RULE_SETUP -#line 143 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleNameContext(NAME); } - YY_BREAK -case 11: -YY_RULE_SETUP -#line 144 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleNameContext(OPT1); } - YY_BREAK -case 12: -YY_RULE_SETUP -#line 145 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleNameContext(OPT2); } - YY_BREAK -case 13: -YY_RULE_SETUP -#line 146 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleNameContext(OPT3); } - YY_BREAK -case 14: -YY_RULE_SETUP -#line 147 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleNameContext(OPT4); } - YY_BREAK -case 15: -YY_RULE_SETUP -#line 148 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleNameContext(OPT5); } - YY_BREAK -case 16: -YY_RULE_SETUP -#line 150 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleNameContext(PREPROCESSOR); } - YY_BREAK -case 17: -YY_RULE_SETUP -#line 151 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleNameContext(COMMAND); } - YY_BREAK -case 18: -YY_RULE_SETUP -#line 152 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleNameContext(REQUIRED); } - YY_BREAK -case 19: -YY_RULE_SETUP -#line 154 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleNameContext(TRANSLATOR); } - YY_BREAK -case 20: -YY_RULE_SETUP -#line 155 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleNameContext(PREPROCESSES); } - YY_BREAK -case 21: -YY_RULE_SETUP -#line 156 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleNameContext(OUTPUT); } - YY_BREAK -case 22: -YY_RULE_SETUP -#line 158 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleNameContext(OPTIMIZER); } - YY_BREAK -case 23: -YY_RULE_SETUP -#line 159 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleNameContext(TRANSLATES); } - YY_BREAK -case 24: -YY_RULE_SETUP -#line 161 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleNameContext(ASSEMBLER); } - YY_BREAK -case 25: -YY_RULE_SETUP -#line 163 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleNameContext(LINKER); } - YY_BREAK -case 26: -YY_RULE_SETUP -#line 165 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleSubstitution(ARGS_SUBST); } - YY_BREAK -case 27: -YY_RULE_SETUP -#line 166 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleSubstitution(BINDIR_SUBST); } - YY_BREAK -case 28: -YY_RULE_SETUP -#line 167 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleSubstitution(DEFS_SUBST); } - YY_BREAK -case 29: -YY_RULE_SETUP -#line 168 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleSubstitution(IN_SUBST); } - YY_BREAK -case 30: -YY_RULE_SETUP -#line 169 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleSubstitution(INCLS_SUBST); } - YY_BREAK -case 31: -YY_RULE_SETUP -#line 170 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleSubstitution(LIBDIR_SUBST); } - YY_BREAK -case 32: -YY_RULE_SETUP -#line 171 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleSubstitution(LIBS_SUBST); } - YY_BREAK -case 33: -YY_RULE_SETUP -#line 172 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleSubstitution(LLVMGCCDIR_SUBST); } - YY_BREAK -case 34: -YY_RULE_SETUP -#line 173 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleSubstitution(LLVMGCCARCH_SUBST); } - YY_BREAK -case 35: -YY_RULE_SETUP -#line 174 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleSubstitution(LLVMGCC_SUBST); } - YY_BREAK -case 36: -YY_RULE_SETUP -#line 175 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleSubstitution(LLVMGXX_SUBST); } - YY_BREAK -case 37: -YY_RULE_SETUP -#line 176 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleSubstitution(LLVMCC1_SUBST); } - YY_BREAK -case 38: -YY_RULE_SETUP -#line 177 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleSubstitution(LLVMCC1PLUS_SUBST); } - YY_BREAK -case 39: -YY_RULE_SETUP -#line 178 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleSubstitution(OPT_SUBST); } - YY_BREAK -case 40: -YY_RULE_SETUP -#line 179 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleSubstitution(OUT_SUBST); } - YY_BREAK -case 41: -YY_RULE_SETUP -#line 180 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleSubstitution(STATS_SUBST); } - YY_BREAK -case 42: -YY_RULE_SETUP -#line 181 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleSubstitution(TARGET_SUBST); } - YY_BREAK -case 43: -YY_RULE_SETUP -#line 182 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleSubstitution(TIME_SUBST); } - YY_BREAK -case 44: -YY_RULE_SETUP -#line 183 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleSubstitution(VERBOSE_SUBST); } - YY_BREAK -case 45: -YY_RULE_SETUP -#line 184 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleSubstitution(FOPTS_SUBST); } - YY_BREAK -case 46: -YY_RULE_SETUP -#line 185 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleSubstitution(MOPTS_SUBST); } - YY_BREAK -case 47: -YY_RULE_SETUP -#line 186 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleSubstitution(WOPTS_SUBST); } - YY_BREAK -case 48: -YY_RULE_SETUP -#line 188 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleValueContext(ASSEMBLY); } - YY_BREAK -case 49: -YY_RULE_SETUP -#line 189 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleValueContext(BITCODE); } - YY_BREAK -case 50: -YY_RULE_SETUP -#line 190 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleValueContext(TRUETOK); } - YY_BREAK -case 51: -YY_RULE_SETUP -#line 191 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ return handleValueContext(FALSETOK); } - YY_BREAK -case 52: -YY_RULE_SETUP -#line 193 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ ConfigLexerState.StringVal = Configtext; return OPTION; } - YY_BREAK -case 53: -/* rule 53 can match eol */ -YY_RULE_SETUP -#line 194 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ ConfigLexerState.StringVal = Configtext+1; // Nuke start quote - ConfigLexerState.StringVal.erase( - --ConfigLexerState.StringVal.end()); - return STRING; - } - YY_BREAK -case 54: -YY_RULE_SETUP -#line 199 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -{ YY_FATAL_ERROR("Invalid substitution token"); } - YY_BREAK -case 55: -YY_RULE_SETUP -#line 201 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" -ECHO; - YY_BREAK -#line 1915 "ConfigLexer.cpp" -case YY_STATE_EOF(INITIAL): - yyterminate(); - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = (yy_hold_char); - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed Configin at a new source and called - * Configlex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = Configin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state ); - - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++(yy_c_buf_p); - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = (yy_last_accepting_cpos); - yy_current_state = (yy_last_accepting_state); - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( ) ) - { - case EOB_ACT_END_OF_FILE: - { - (yy_did_buffer_switch_on_eof) = 0; - - if ( Configwrap( ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * Configtext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! (yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = - (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( ); - - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - (yy_c_buf_p) = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; - - yy_current_state = yy_get_previous_state( ); - - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ -} /* end of Configlex */ - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -static int yy_get_next_buffer (void) -{ - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = (yytext_ptr); - register int number_to_move, i; - int ret_val; - - if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; - - else - { - int num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER; - - int yy_c_buf_p_offset = - (int) ((yy_c_buf_p) - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - Configrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; - - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - (yy_n_chars), num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - if ( (yy_n_chars) == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - Configrestart(Configin ); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - (yy_n_chars) += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; - - (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; -} - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - - static yy_state_type yy_get_previous_state (void) -{ - register yy_state_type yy_current_state; - register char *yy_cp; - - yy_current_state = (yy_start); - - for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) - { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 408 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - } - - return yy_current_state; -} - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) -{ - register int yy_is_jam; - register char *yy_cp = (yy_c_buf_p); - - register YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 408 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 407); - - return yy_is_jam ? 0 : yy_current_state; -} - - static inline void yyunput (int c, register char * yy_bp ) -{ - register char *yy_cp; - - yy_cp = (yy_c_buf_p); - - /* undo effects of setting up Configtext */ - *yy_cp = (yy_hold_char); - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - register int number_to_move = (yy_n_chars) + 2; - register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; - register char *source = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; - - while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - *--dest = *--source; - - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - *--yy_cp = (char) c; - - (yytext_ptr) = yy_bp; - (yy_hold_char) = *yy_cp; - (yy_c_buf_p) = yy_cp; -} - -#ifndef YY_NO_INPUT -#ifdef __cplusplus - static int yyinput (void) -#else - static int input (void) -#endif - -{ - int c; - - *(yy_c_buf_p) = (yy_hold_char); - - if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) - /* This was really a NUL. */ - *(yy_c_buf_p) = '\0'; - - else - { /* need more input */ - int offset = (yy_c_buf_p) - (yytext_ptr); - ++(yy_c_buf_p); - - switch ( yy_get_next_buffer( ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - Configrestart(Configin ); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( Configwrap( ) ) - return 0; - - if ( ! (yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(); -#else - return input(); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = (yytext_ptr) + offset; - break; - } - } - } - - c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ - *(yy_c_buf_p) = '\0'; /* preserve Configtext */ - (yy_hold_char) = *++(yy_c_buf_p); - - return c; -} -#endif /* ifndef YY_NO_INPUT */ - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * - * @note This function does not reset the start condition to @c INITIAL . - */ - void Configrestart (FILE * input_file ) -{ - - if ( ! YY_CURRENT_BUFFER ){ - Configensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - Config_create_buffer(Configin,YY_BUF_SIZE ); - } - - Config_init_buffer(YY_CURRENT_BUFFER,input_file ); - Config_load_buffer_state( ); -} - -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * - */ - void Config_switch_to_buffer (YY_BUFFER_STATE new_buffer ) -{ - - /* TODO. We should be able to replace this entire function body - * with - * Configpop_buffer_state(); - * Configpush_buffer_state(new_buffer); - */ - Configensure_buffer_stack (); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - Config_load_buffer_state( ); - - /* We don't actually know whether we did this switch during - * EOF (Configwrap()) processing, but the only time this flag - * is looked at is after Configwrap() is called, so it's safe - * to go ahead and always set it. - */ - (yy_did_buffer_switch_on_eof) = 1; -} - -static void Config_load_buffer_state (void) -{ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - Configin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - (yy_hold_char) = *(yy_c_buf_p); -} - -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * - * @return the allocated buffer state. - */ - YY_BUFFER_STATE Config_create_buffer (FILE * file, int size ) -{ - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) Configalloc(sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in Config_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) Configalloc(b->yy_buf_size + 2 ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in Config_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - Config_init_buffer(b,file ); - - return b; -} - -/** Destroy the buffer. - * @param b a buffer created with Config_create_buffer() - * - */ - void Config_delete_buffer (YY_BUFFER_STATE b ) -{ - - if ( ! b ) - return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - Configfree((void *) b->yy_ch_buf ); - - Configfree((void *) b ); -} - -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a Configrestart() or at EOF. - */ - static void Config_init_buffer (YY_BUFFER_STATE b, FILE * file ) - -{ - int oerrno = errno; - - Config_flush_buffer(b ); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - - /* If b is the current buffer, then Config_init_buffer was _probably_ - * called from Configrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; - } - - b->yy_is_interactive = 0; - - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * - */ - void Config_flush_buffer (YY_BUFFER_STATE b ) -{ - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == YY_CURRENT_BUFFER ) - Config_load_buffer_state( ); -} - -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * - */ -void Configpush_buffer_state (YY_BUFFER_STATE new_buffer ) -{ - if (new_buffer == NULL) - return; - - Configensure_buffer_stack(); - - /* This block is copied from Config_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - (yy_buffer_stack_top)++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from Config_switch_to_buffer. */ - Config_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * - */ -void Configpop_buffer_state (void) -{ - if (!YY_CURRENT_BUFFER) - return; - - Config_delete_buffer(YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - if ((yy_buffer_stack_top) > 0) - --(yy_buffer_stack_top); - - if (YY_CURRENT_BUFFER) { - Config_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; - } -} - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -static void Configensure_buffer_stack (void) -{ - int num_to_alloc; - - if (!(yy_buffer_stack)) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; - (yy_buffer_stack) = (struct yy_buffer_state**)Configalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - ); - - memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - (yy_buffer_stack_max) = num_to_alloc; - (yy_buffer_stack_top) = 0; - return; - } - - if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = (yy_buffer_stack_max) + grow_size; - (yy_buffer_stack) = (struct yy_buffer_state**)Configrealloc - ((yy_buffer_stack), - num_to_alloc * sizeof(struct yy_buffer_state*) - ); - - /* zero only the new slots.*/ - memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); - (yy_buffer_stack_max) = num_to_alloc; - } -} - -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE Config_scan_buffer (char * base, yy_size_t size ) -{ - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return 0; - - b = (YY_BUFFER_STATE) Configalloc(sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in Config_scan_buffer()" ); - - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - Config_switch_to_buffer(b ); - - return b; -} - -/** Setup the input buffer state to scan a string. The next call to Configlex() will - * scan from a @e copy of @a str. - * @param str a NUL-terminated string to scan - * - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * Config_scan_bytes() instead. - */ -YY_BUFFER_STATE Config_scan_string (yyconst char * yystr ) -{ - - return Config_scan_bytes(yystr,strlen(yystr) ); -} - -/** Setup the input buffer state to scan the given bytes. The next call to Configlex() will - * scan from a @e copy of @a bytes. - * @param bytes the byte buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE Config_scan_bytes (yyconst char * yybytes, int _yybytes_len ) -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = _yybytes_len + 2; - buf = (char *) Configalloc(n ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in Config_scan_bytes()" ); - - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; - - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - - b = Config_scan_buffer(buf,n ); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in Config_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; -} - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -static void yy_fatal_error (yyconst char* msg ) -{ - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); -} - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up Configtext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - Configtext[Configleng] = (yy_hold_char); \ - (yy_c_buf_p) = Configtext + yyless_macro_arg; \ - (yy_hold_char) = *(yy_c_buf_p); \ - *(yy_c_buf_p) = '\0'; \ - Configleng = yyless_macro_arg; \ - } \ - while ( 0 ) - -/* Accessor methods (get/set functions) to struct members. */ - -/** Get the current line number. - * - */ -int Configget_lineno (void) -{ - - return Configlineno; -} - -/** Get the input stream. - * - */ -FILE *Configget_in (void) -{ - return Configin; -} - -/** Get the output stream. - * - */ -FILE *Configget_out (void) -{ - return Configout; -} - -/** Get the length of the current token. - * - */ -int Configget_leng (void) -{ - return Configleng; -} - -/** Get the current token. - * - */ - -char *Configget_text (void) -{ - return Configtext; -} - -/** Set the current line number. - * @param line_number - * - */ -void Configset_lineno (int line_number ) -{ - - Configlineno = line_number; -} - -/** Set the input stream. This does not discard the current - * input buffer. - * @param in_str A readable stream. - * - * @see Config_switch_to_buffer - */ -void Configset_in (FILE * in_str ) -{ - Configin = in_str ; -} - -void Configset_out (FILE * out_str ) -{ - Configout = out_str ; -} - -int Configget_debug (void) -{ - return Config_flex_debug; -} - -void Configset_debug (int bdebug ) -{ - Config_flex_debug = bdebug ; -} - -static int yy_init_globals (void) -{ - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from Configlex_destroy(), so don't allocate here. - */ - - (yy_buffer_stack) = 0; - (yy_buffer_stack_top) = 0; - (yy_buffer_stack_max) = 0; - (yy_c_buf_p) = (char *) 0; - (yy_init) = 0; - (yy_start) = 0; - -/* Defined in main.c */ -#ifdef YY_STDINIT - Configin = stdin; - Configout = stdout; -#else - Configin = (FILE *) 0; - Configout = (FILE *) 0; -#endif - - /* For future reference: Set errno on error, since we are called by - * Configlex_init() - */ - return 0; -} - -/* Configlex_destroy is for both reentrant and non-reentrant scanners. */ -int Configlex_destroy (void) -{ - - /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - Config_delete_buffer(YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - Configpop_buffer_state(); - } - - /* Destroy the stack itself. */ - Configfree((yy_buffer_stack) ); - (yy_buffer_stack) = NULL; - - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * Configlex() is called, initialization will occur. */ - yy_init_globals( ); - - return 0; -} - -/* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) -{ - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; -} -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s ) -{ - register int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; -} -#endif - -void *Configalloc (yy_size_t size ) -{ - return (void *) malloc( size ); -} - -void *Configrealloc (void * ptr, yy_size_t size ) -{ - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); -} - -void Configfree (void * ptr ) -{ - free( (char *) ptr ); /* see Configrealloc() for (char *) cast */ -} - -#define YYTABLES_NAME "yytables" - -#line 201 "/Users/sabre/llvm/tools/llvmc/ConfigLexer.l" - - - Removed: llvm/trunk/tools/llvmc/ConfigLexer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/ConfigLexer.h?rev=50614&view=auto ============================================================================== --- llvm/trunk/tools/llvmc/ConfigLexer.h (original) +++ llvm/trunk/tools/llvmc/ConfigLexer.h (removed) @@ -1,113 +0,0 @@ -//===- ConfigLexer.h - ConfigLexer Declarations -----------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file declares the types and data needed by ConfigLexer.l -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_TOOLS_LLVMC_CONFIGLEXER_H -#define LLVM_TOOLS_LLVMC_CONFIGLEXER_H - -#include -#include -#include - -namespace llvm { - -struct ConfigLexerInfo -{ - int64_t IntegerVal; - std::string StringVal; - bool in_value; - unsigned lineNum; -}; - -extern ConfigLexerInfo ConfigLexerState; - -class InputProvider { - public: - InputProvider(const std::string& nm) { - name = nm; - errCount = 0; - } - virtual ~InputProvider(); - virtual unsigned read(char *buf, unsigned max_size) = 0; - virtual void error(const std::string& msg); - virtual void checkErrors(); - - private: - std::string name; - unsigned errCount; -}; - -extern InputProvider* ConfigLexerInput; - -enum ConfigLexerTokens { - EOFTOK = 0, ///< Returned by Configlex when we hit end of file - EOLTOK, ///< End of line - ERRORTOK, ///< Error token - ARGS_SUBST, ///< The substitution item %args% - BINDIR_SUBST, ///< The substitution item %bindir% - ASSEMBLY, ///< The value "assembly" (and variants) - ASSEMBLER, ///< The name "assembler" (and variants) - BITCODE, ///< The value "bitcode" (and variants) - COMMAND, ///< The name "command" (and variants) - DEFS_SUBST, ///< The substitution item %defs% - EQUALS, ///< The equals sign, = - FALSETOK, ///< A boolean false value (false/no/off) - FOPTS_SUBST, ///< The substitution item %fOpts% - IN_SUBST, ///< The substitution item %in% - INCLS_SUBST, ///< The substitution item %incls% - INTEGER, ///< An integer - LANG, ///< The name "lang" (and variants) - LIBDIR_SUBST, ///< The substitution item %libdir% - LIBPATHS, ///< The name "libpaths" (and variants) - LIBS, ///< The name "libs" (and variants) - LIBS_SUBST, ///< The substitution item %libs% - LINKER, ///< The name "linker" (and variants) - LLVMGCCDIR_SUBST, ///< The substitution item %llvmgccdir% - LLVMGCCARCH_SUBST, ///< The substitution item %llvmgccarch% - LLVMGCC_SUBST, ///< The substitution item %llvmgcc% - LLVMGXX_SUBST, ///< The substitution item %llvmgxx% - LLVMCC1_SUBST, ///< The substitution item %llvmcc1% - LLVMCC1PLUS_SUBST, ///< The substitution item %llvmcc1plus% - MOPTS_SUBST, ///< The substitution item %Mopts% - NAME, ///< The name "name" (and variants) - OPT_SUBST, ///< The substitution item %opt% - OPTIMIZER, ///< The name "optimizer" (and variants) - OPTION, ///< A command line option - OPT1, ///< The name "opt1" (and variants) - OPT2, ///< The name "opt2" (and variants) - OPT3, ///< The name "opt3" (and variants) - OPT4, ///< The name "opt4" (and variants) - OPT5, ///< The name "opt5" (and variants) - OUT_SUBST, ///< The output substitution item %out% - OUTPUT, ///< The name "output" (and variants) - PREPROCESSES, ///< The name "preprocesses" (and variants) - PREPROCESSOR, ///< The name "preprocessor" (and variants) - REQUIRED, ///< The name "required" (and variants) - SEPARATOR, ///< A configuration item separator - SPACE, ///< Space between options - STATS_SUBST, ///< The stats substitution item %stats% - STRING, ///< A quoted string - TARGET_SUBST, ///< The substitition item %target% - TIME_SUBST, ///< The substitution item %time% - TRANSLATES, ///< The name "translates" (and variants) - TRANSLATOR, ///< The name "translator" (and variants) - TRUETOK, ///< A boolean true value (true/yes/on) - VERBOSE_SUBST, ///< The substitution item %verbose% - VERSION_TOK, ///< The name "version" (and variants) - WOPTS_SUBST ///< The %WOpts% substitution -}; - -extern ConfigLexerTokens Configlex(); - -} - -#endif Removed: llvm/trunk/tools/llvmc/ConfigLexer.l URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/ConfigLexer.l?rev=50614&view=auto ============================================================================== --- llvm/trunk/tools/llvmc/ConfigLexer.l (original) +++ llvm/trunk/tools/llvmc/ConfigLexer.l (removed) @@ -1,201 +0,0 @@ -/*===- ConfigLexer.l - Scanner for CompilerDriver Config Files -*- C++ -*--===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements the flex scanner for configuration files for the -// llvmc CompilerDriver. -// -//===----------------------------------------------------------------------===*/ - - -%option prefix="Config" -%option nostdinit -%option never-interactive -%option batch -%option noyywrap -%option 8bit -%option outfile="ConfigLexer.cpp" -%option ecs -%option noyymore -%option noreject -%pointer - -%{ - -#include "ConfigLexer.h" - -#define YY_INPUT(buf,result,max_size) \ - { \ - assert(ConfigLexerInput != 0 && "Oops"); \ - result = ConfigLexerInput->read(buf,max_size); \ - if (result == 0 ) result = YY_NULL; \ - } - -#define YY_FATAL_ERROR(msg) \ - { \ - assert(ConfigLexerInput != 0 && "Oops"); \ - ConfigLexerInput->error(msg); \ - } - -#define YY_DECL ConfigLexerTokens llvm::Configlex() - -#define yyterminate() { return EOFTOK; } - -using namespace llvm; - -inline llvm::ConfigLexerTokens -handleNameContext(llvm::ConfigLexerTokens token) { - ConfigLexerState.StringVal = yytext; - if (ConfigLexerState.in_value) - return OPTION; - return token; -} - -inline llvm::ConfigLexerTokens -handleSubstitution(llvm::ConfigLexerTokens token) { - if (ConfigLexerState.in_value) { - ConfigLexerState.StringVal = yytext; - return token; - } - YY_FATAL_ERROR("Substitition tokens not allowed in names" ); - return ERRORTOK; -} - -inline llvm::ConfigLexerTokens handleValueContext(llvm::ConfigLexerTokens token) { - ConfigLexerState.StringVal = yytext; - if (ConfigLexerState.in_value) - return token; - return OPTION; -} - -%} - -ASSEMBLER assembler|Assembler|ASSEMBLER -COMMAND command|Command|COMMAND -LANG lang|Lang|LANG -LIBS libs|Libs|LIBS -LINKER linker|Linker|LINKER -NAME name|Name|NAME -OPT1 opt1|Opt1|OPT1 -OPT2 opt2|Opt2|OPT2 -OPT3 opt3|Opt3|OPT3 -OPT4 opt4|Opt4|OPT4 -OPT5 opt5|Opt5|OPT5 -OPTIMIZER optimizer|Optimizer|OPTIMIZER -OUTPUT output|Output|OUTPUT -PREPROCESSES preprocesses|PreProcesses|PREPROCESSES -PREPROCESSOR preprocessor|PreProcessor|PREPROCESSOR -REQUIRED required|Required|REQUIRED -TRANSLATES translates|Translates|TRANSLATES -TRANSLATOR translator|Translator|TRANSLATOR -VERSION version|Version|VERSION - -True true|True|TRUE|on|On|ON|yes|Yes|YES -False false|False|FALSE|off|Off|OFF|no|No|NO -Bitcode bc|BC|bitcode|Bitcode|BITCODE -Assembly asm|ASM|assembly|Assembly|ASSEMBLY - -BadSubst \%[a-zA-Z]*\% -Comment \#[^\r\n]*\r?\n -NewLine \r?\n -Eq \= -EscNewLine \\\r?\n -Option [-A-Za-z0-9_:%+/\\|,][-A-Za-z0-9_:+/\\|,@]* -Sep \. -String \"[^\"]*\" -White [ \t]* - - -%% - -{White} { if (ConfigLexerState.in_value) return SPACE; } - -{Comment} { /* Ignore comments */ - ConfigLexerState.in_value = false; - ConfigLexerState.lineNum++; - return EOLTOK; - } - -{EscNewLine} { ConfigLexerState.lineNum++; - /* Don't return EOLTOK! */ - } - -{NewLine} { ConfigLexerState.in_value = false; - ConfigLexerState.lineNum++; - return EOLTOK; - } - -{Eq} { ConfigLexerState.in_value = true; - return EQUALS; - } - -{Sep} { return SEPARATOR; } - -{VERSION} { return handleNameContext(VERSION_TOK); } - -{LANG} { return handleNameContext(LANG); } -{LIBS} { return handleNameContext(LIBS); } -{NAME} { return handleNameContext(NAME); } -{OPT1} { return handleNameContext(OPT1); } -{OPT2} { return handleNameContext(OPT2); } -{OPT3} { return handleNameContext(OPT3); } -{OPT4} { return handleNameContext(OPT4); } -{OPT5} { return handleNameContext(OPT5); } - -{PREPROCESSOR} { return handleNameContext(PREPROCESSOR); } -{COMMAND} { return handleNameContext(COMMAND); } -{REQUIRED} { return handleNameContext(REQUIRED); } - -{TRANSLATOR} { return handleNameContext(TRANSLATOR); } -{PREPROCESSES} { return handleNameContext(PREPROCESSES); } -{OUTPUT} { return handleNameContext(OUTPUT); } - -{OPTIMIZER} { return handleNameContext(OPTIMIZER); } -{TRANSLATES} { return handleNameContext(TRANSLATES); } - -{ASSEMBLER} { return handleNameContext(ASSEMBLER); } - -{LINKER} { return handleNameContext(LINKER); } - -%args% { return handleSubstitution(ARGS_SUBST); } -%bindir% { return handleSubstitution(BINDIR_SUBST); } -%defs% { return handleSubstitution(DEFS_SUBST); } -%in% { return handleSubstitution(IN_SUBST); } -%incls% { return handleSubstitution(INCLS_SUBST); } -%libdir% { return handleSubstitution(LIBDIR_SUBST); } -%libs% { return handleSubstitution(LIBS_SUBST); } -%llvmgccdir% { return handleSubstitution(LLVMGCCDIR_SUBST); } -%llvmgccarch% { return handleSubstitution(LLVMGCCARCH_SUBST); } -%llvmgcc% { return handleSubstitution(LLVMGCC_SUBST); } -%llvmgxx% { return handleSubstitution(LLVMGXX_SUBST); } -%llvmcc1% { return handleSubstitution(LLVMCC1_SUBST); } -%llvmcc1plus% { return handleSubstitution(LLVMCC1PLUS_SUBST); } -%opt% { return handleSubstitution(OPT_SUBST); } -%out% { return handleSubstitution(OUT_SUBST); } -%stats% { return handleSubstitution(STATS_SUBST); } -%target% { return handleSubstitution(TARGET_SUBST); } -%time% { return handleSubstitution(TIME_SUBST); } -%verbose% { return handleSubstitution(VERBOSE_SUBST); } -%fOpts% { return handleSubstitution(FOPTS_SUBST); } -%MOpts% { return handleSubstitution(MOPTS_SUBST); } -%WOpts% { return handleSubstitution(WOPTS_SUBST); } - -{Assembly} { return handleValueContext(ASSEMBLY); } -{Bitcode} { return handleValueContext(BITCODE); } -{True} { return handleValueContext(TRUETOK); } -{False} { return handleValueContext(FALSETOK); } - -{Option} { ConfigLexerState.StringVal = yytext; return OPTION; } -{String} { ConfigLexerState.StringVal = yytext+1; // Nuke start quote - ConfigLexerState.StringVal.erase( - --ConfigLexerState.StringVal.end()); - return STRING; - } -{BadSubst} { YY_FATAL_ERROR("Invalid substitution token"); } - -%% Removed: llvm/trunk/tools/llvmc/ConfigLexer.l.cvs URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/ConfigLexer.l.cvs?rev=50614&view=auto ============================================================================== --- llvm/trunk/tools/llvmc/ConfigLexer.l.cvs (original) +++ llvm/trunk/tools/llvmc/ConfigLexer.l.cvs (removed) @@ -1,201 +0,0 @@ -/*===- ConfigLexer.l - Scanner for CompilerDriver Config Files -*- C++ -*--===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements the flex scanner for configuration files for the -// llvmc CompilerDriver. -// -//===----------------------------------------------------------------------===*/ - - -%option prefix="Config" -%option nostdinit -%option never-interactive -%option batch -%option noyywrap -%option 8bit -%option outfile="ConfigLexer.cpp" -%option ecs -%option noyymore -%option noreject -%pointer - -%{ - -#include "ConfigLexer.h" - -#define YY_INPUT(buf,result,max_size) \ - { \ - assert(ConfigLexerInput != 0 && "Oops"); \ - result = ConfigLexerInput->read(buf,max_size); \ - if (result == 0 ) result = YY_NULL; \ - } - -#define YY_FATAL_ERROR(msg) \ - { \ - assert(ConfigLexerInput != 0 && "Oops"); \ - ConfigLexerInput->error(msg); \ - } - -#define YY_DECL ConfigLexerTokens llvm::Configlex() - -#define yyterminate() { return EOFTOK; } - -using namespace llvm; - -inline llvm::ConfigLexerTokens -handleNameContext(llvm::ConfigLexerTokens token) { - ConfigLexerState.StringVal = yytext; - if (ConfigLexerState.in_value) - return OPTION; - return token; -} - -inline llvm::ConfigLexerTokens -handleSubstitution(llvm::ConfigLexerTokens token) { - if (ConfigLexerState.in_value) { - ConfigLexerState.StringVal = yytext; - return token; - } - YY_FATAL_ERROR("Substitition tokens not allowed in names" ); - return ERRORTOK; -} - -inline llvm::ConfigLexerTokens handleValueContext(llvm::ConfigLexerTokens token) { - ConfigLexerState.StringVal = yytext; - if (ConfigLexerState.in_value) - return token; - return OPTION; -} - -%} - -ASSEMBLER assembler|Assembler|ASSEMBLER -COMMAND command|Command|COMMAND -LANG lang|Lang|LANG -LIBS libs|Libs|LIBS -LINKER linker|Linker|LINKER -NAME name|Name|NAME -OPT1 opt1|Opt1|OPT1 -OPT2 opt2|Opt2|OPT2 -OPT3 opt3|Opt3|OPT3 -OPT4 opt4|Opt4|OPT4 -OPT5 opt5|Opt5|OPT5 -OPTIMIZER optimizer|Optimizer|OPTIMIZER -OUTPUT output|Output|OUTPUT -PREPROCESSES preprocesses|PreProcesses|PREPROCESSES -PREPROCESSOR preprocessor|PreProcessor|PREPROCESSOR -REQUIRED required|Required|REQUIRED -TRANSLATES translates|Translates|TRANSLATES -TRANSLATOR translator|Translator|TRANSLATOR -VERSION version|Version|VERSION - -True true|True|TRUE|on|On|ON|yes|Yes|YES -False false|False|FALSE|off|Off|OFF|no|No|NO -Bitcode bc|BC|bitcode|Bitcode|BITCODE -Assembly asm|ASM|assembly|Assembly|ASSEMBLY - -BadSubst \%[a-zA-Z]*\% -Comment \#[^\r\n]*\r?\n -NewLine \r?\n -Eq \= -EscNewLine \\\r?\n -Option [-A-Za-z0-9_:%+/\\|,][-A-Za-z0-9_:+/\\|,@]* -Sep \. -String \"[^\"]*\" -White [ \t]* - - -%% - -{White} { if (ConfigLexerState.in_value) return SPACE; } - -{Comment} { /* Ignore comments */ - ConfigLexerState.in_value = false; - ConfigLexerState.lineNum++; - return EOLTOK; - } - -{EscNewLine} { ConfigLexerState.lineNum++; - /* Don't return EOLTOK! */ - } - -{NewLine} { ConfigLexerState.in_value = false; - ConfigLexerState.lineNum++; - return EOLTOK; - } - -{Eq} { ConfigLexerState.in_value = true; - return EQUALS; - } - -{Sep} { return SEPARATOR; } - -{VERSION} { return handleNameContext(VERSION_TOK); } - -{LANG} { return handleNameContext(LANG); } -{LIBS} { return handleNameContext(LIBS); } -{NAME} { return handleNameContext(NAME); } -{OPT1} { return handleNameContext(OPT1); } -{OPT2} { return handleNameContext(OPT2); } -{OPT3} { return handleNameContext(OPT3); } -{OPT4} { return handleNameContext(OPT4); } -{OPT5} { return handleNameContext(OPT5); } - -{PREPROCESSOR} { return handleNameContext(PREPROCESSOR); } -{COMMAND} { return handleNameContext(COMMAND); } -{REQUIRED} { return handleNameContext(REQUIRED); } - -{TRANSLATOR} { return handleNameContext(TRANSLATOR); } -{PREPROCESSES} { return handleNameContext(PREPROCESSES); } -{OUTPUT} { return handleNameContext(OUTPUT); } - -{OPTIMIZER} { return handleNameContext(OPTIMIZER); } -{TRANSLATES} { return handleNameContext(TRANSLATES); } - -{ASSEMBLER} { return handleNameContext(ASSEMBLER); } - -{LINKER} { return handleNameContext(LINKER); } - -%args% { return handleSubstitution(ARGS_SUBST); } -%bindir% { return handleSubstitution(BINDIR_SUBST); } -%defs% { return handleSubstitution(DEFS_SUBST); } -%in% { return handleSubstitution(IN_SUBST); } -%incls% { return handleSubstitution(INCLS_SUBST); } -%libdir% { return handleSubstitution(LIBDIR_SUBST); } -%libs% { return handleSubstitution(LIBS_SUBST); } -%llvmgccdir% { return handleSubstitution(LLVMGCCDIR_SUBST); } -%llvmgccarch% { return handleSubstitution(LLVMGCCARCH_SUBST); } -%llvmgcc% { return handleSubstitution(LLVMGCC_SUBST); } -%llvmgxx% { return handleSubstitution(LLVMGXX_SUBST); } -%llvmcc1% { return handleSubstitution(LLVMCC1_SUBST); } -%llvmcc1plus% { return handleSubstitution(LLVMCC1PLUS_SUBST); } -%opt% { return handleSubstitution(OPT_SUBST); } -%out% { return handleSubstitution(OUT_SUBST); } -%stats% { return handleSubstitution(STATS_SUBST); } -%target% { return handleSubstitution(TARGET_SUBST); } -%time% { return handleSubstitution(TIME_SUBST); } -%verbose% { return handleSubstitution(VERBOSE_SUBST); } -%fOpts% { return handleSubstitution(FOPTS_SUBST); } -%MOpts% { return handleSubstitution(MOPTS_SUBST); } -%WOpts% { return handleSubstitution(WOPTS_SUBST); } - -{Assembly} { return handleValueContext(ASSEMBLY); } -{Bitcode} { return handleValueContext(BITCODE); } -{True} { return handleValueContext(TRUETOK); } -{False} { return handleValueContext(FALSETOK); } - -{Option} { ConfigLexerState.StringVal = yytext; return OPTION; } -{String} { ConfigLexerState.StringVal = yytext+1; // Nuke start quote - ConfigLexerState.StringVal.erase( - --ConfigLexerState.StringVal.end()); - return STRING; - } -{BadSubst} { YY_FATAL_ERROR("Invalid substitution token"); } - -%% Removed: llvm/trunk/tools/llvmc/Configuration.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/Configuration.cpp?rev=50614&view=auto ============================================================================== --- llvm/trunk/tools/llvmc/Configuration.cpp (original) +++ llvm/trunk/tools/llvmc/Configuration.cpp (removed) @@ -1,632 +0,0 @@ -//===- Configuration.cpp - Configuration Data Mgmt --------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements the parsing of configuration files for the LLVM Compiler -// Driver (llvmc). -// -//===----------------------------------------------------------------------===// - -#include "Configuration.h" -#include "ConfigLexer.h" -#include "CompilerDriver.h" -#include "llvm/Config/config.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/ADT/StringExtras.h" -#include -#include - -using namespace llvm; - -namespace sys { - // From CompilerDriver.cpp (for now) - extern bool FileIsReadable(const std::string& fname); -} - -namespace llvm { - ConfigLexerInfo ConfigLexerState; - InputProvider* ConfigLexerInput = 0; - - InputProvider::~InputProvider() {} - void InputProvider::error(const std::string& msg) { - std::cerr << name << ":" << ConfigLexerState.lineNum << ": Error: " << - msg << "\n"; - errCount++; - } - - void InputProvider::checkErrors() { - if (errCount > 0) { - std::cerr << name << " had " << errCount << " errors. Terminating.\n"; - exit(errCount); - } - } - -} - -namespace { - - class FileInputProvider : public InputProvider { - public: - FileInputProvider(const std::string & fname) - : InputProvider(fname) - , F(fname.c_str()) { - ConfigLexerInput = this; - } - virtual ~FileInputProvider() { F.close(); ConfigLexerInput = 0; } - virtual unsigned read(char *buffer, unsigned max_size) { - if (F.good()) { - F.read(buffer,max_size); - if ( F.gcount() ) return F.gcount() - 1; - } - return 0; - } - - bool okay() { return F.good(); } - private: - std::ifstream F; - }; - - cl::opt DumpTokens("dump-tokens", cl::Optional, cl::Hidden, - cl::init(false), cl::desc("Dump lexical tokens (debug use only).")); - - struct Parser - { - Parser() { - token = EOFTOK; - provider = 0; - confDat = 0; - ConfigLexerState.lineNum = 1; - ConfigLexerState.in_value = false; - ConfigLexerState.StringVal.clear(); - ConfigLexerState.IntegerVal = 0; - }; - - ConfigLexerTokens token; - InputProvider* provider; - CompilerDriver::ConfigData* confDat; - - inline int next() { - token = Configlex(); - if (DumpTokens) - std::cerr << token << "\n"; - return token; - } - - inline bool next_is_real() { - next(); - return (token != EOLTOK) && (token != ERRORTOK) && (token != 0); - } - - inline void eatLineRemnant() { - while (next_is_real()) ; - } - - void error(const std::string& msg, bool skip = true) { - provider->error(msg); - if (skip) - eatLineRemnant(); - } - - bool parseCompleteItem(std::string& result) { - result.clear(); - while (next_is_real()) { - switch (token ) { - case LLVMGCCDIR_SUBST: - case LLVMGCCARCH_SUBST: - case STRING : - case OPTION : - result += ConfigLexerState.StringVal; - break; - case SEPARATOR: - result += "."; - break; - case SPACE: - return true; - default: - return false; - } - } - return false; - } - - std::string parseName() { - std::string result; - if (next() == EQUALS) { - if (parseCompleteItem(result)) - eatLineRemnant(); - if (result.empty()) - error("Name exepected"); - } else - error("Expecting '='"); - return result; - } - - bool parseBoolean() { - bool result = true; - if (next() == EQUALS) { - if (next() == SPACE) - next(); - if (token == FALSETOK) { - result = false; - } else if (token != TRUETOK) { - error("Expecting boolean value"); - return false; - } - if (next() != EOLTOK && token != 0) { - error("Extraneous tokens after boolean"); - } - } - else - error("Expecting '='"); - return result; - } - - bool parseSubstitution(CompilerDriver::StringVector& optList) { - switch (token) { - case ARGS_SUBST: optList.push_back("%args%"); break; - case BINDIR_SUBST: optList.push_back("%bindir%"); break; - case DEFS_SUBST: optList.push_back("%defs%"); break; - case IN_SUBST: optList.push_back("%in%"); break; - case INCLS_SUBST: optList.push_back("%incls%"); break; - case LIBDIR_SUBST: optList.push_back("%libdir%"); break; - case LIBS_SUBST: optList.push_back("%libs%"); break; - case OPT_SUBST: optList.push_back("%opt%"); break; - case OUT_SUBST: optList.push_back("%out%"); break; - case TARGET_SUBST: optList.push_back("%target%"); break; - case STATS_SUBST: optList.push_back("%stats%"); break; - case TIME_SUBST: optList.push_back("%time%"); break; - case VERBOSE_SUBST: optList.push_back("%verbose%"); break; - case FOPTS_SUBST: optList.push_back("%fOpts%"); break; - case MOPTS_SUBST: optList.push_back("%Mopts%"); break; - case WOPTS_SUBST: optList.push_back("%Wopts%"); break; - default: - return false; - } - return true; - } - - void parseOptionList(CompilerDriver::StringVector& optList ) { - if (next() == EQUALS) { - while (next_is_real()) { - if (token == STRING || token == OPTION) - optList.push_back(ConfigLexerState.StringVal); - else if (!parseSubstitution(optList)) { - error("Expecting a program argument or substitution", false); - break; - } - } - } else - error("Expecting '='"); - } - - void parseVersion() { - if (next() != EQUALS) - error("Expecting '='"); - while (next_is_real()) { - if (token == STRING || token == OPTION) - confDat->version = ConfigLexerState.StringVal; - else - error("Expecting a version string"); - } - } - - void parseLibs() { - if (next() != EQUALS) - error("Expecting '='"); - std::string lib; - while (parseCompleteItem(lib)) { - if (!lib.empty()) { - confDat->libpaths.push_back(lib); - } - } - } - - void parseLang() { - if (next() != SEPARATOR) - error("Expecting '.'"); - switch (next() ) { - case LIBS: - parseLibs(); - break; - case NAME: - confDat->langName = parseName(); - break; - case OPT1: - parseOptionList(confDat->opts[CompilerDriver::OPT_FAST_COMPILE]); - break; - case OPT2: - parseOptionList(confDat->opts[CompilerDriver::OPT_SIMPLE]); - break; - case OPT3: - parseOptionList(confDat->opts[CompilerDriver::OPT_AGGRESSIVE]); - break; - case OPT4: - parseOptionList(confDat->opts[CompilerDriver::OPT_LINK_TIME]); - break; - case OPT5: - parseOptionList( - confDat->opts[CompilerDriver::OPT_AGGRESSIVE_LINK_TIME]); - break; - default: - error("Expecting 'name' or 'optN' after 'lang.'"); - break; - } - } - - bool parseProgramName(std::string& str) { - str.clear(); - do { - switch (token) { - case BINDIR_SUBST: - case LLVMGCC_SUBST: - case LLVMGXX_SUBST: - case LLVMCC1_SUBST: - case LLVMCC1PLUS_SUBST: - case OPTION: - case STRING: - case ARGS_SUBST: - case DEFS_SUBST: - case IN_SUBST: - case INCLS_SUBST: - case LIBS_SUBST: - case OPT_SUBST: - case OUT_SUBST: - case STATS_SUBST: - case TARGET_SUBST: - case TIME_SUBST: - case VERBOSE_SUBST: - case FOPTS_SUBST: - case MOPTS_SUBST: - case WOPTS_SUBST: - str += ConfigLexerState.StringVal; - break; - case SEPARATOR: - str += "."; - break; - case ASSEMBLY: - str += "assembly"; - break; - case BITCODE: - str += "bitcode"; - break; - case TRUETOK: - str += "true"; - break; - case FALSETOK: - str += "false"; - break; - default: - break; - } - next(); - } while (token != SPACE && token != EOFTOK && token != EOLTOK && - token != ERRORTOK); - return !str.empty(); - } - - void parseCommand(CompilerDriver::Action& action) { - if (next() != EQUALS) - error("Expecting '='"); - switch (next()) { - case EOLTOK: - // no value (valid) - action.program.clear(); - action.args.clear(); - break; - case SPACE: - next(); - /* FALL THROUGH */ - default: - { - std::string progname; - if (parseProgramName(progname)) - action.program.set(progname); - else - error("Expecting a program name"); - - // Get the options - std::string anOption; - while (next_is_real()) { - switch (token) { - case STRING: - case OPTION: - anOption += ConfigLexerState.StringVal; - break; - case ASSEMBLY: - anOption += "assembly"; - break; - case BITCODE: - anOption += "bitcode"; - break; - case TRUETOK: - anOption += "true"; - break; - case FALSETOK: - anOption += "false"; - break; - case SEPARATOR: - anOption += "."; - break; - case SPACE: - action.args.push_back(anOption); - anOption.clear(); - break; - default: - if (!parseSubstitution(action.args)) - error("Expecting a program argument or substitution", false); - break; - } - } - } - } - } - - void parsePreprocessor() { - if (next() != SEPARATOR) - error("Expecting '.'"); - switch (next()) { - case COMMAND: - parseCommand(confDat->PreProcessor); - break; - case REQUIRED: - if (parseBoolean()) - confDat->PreProcessor.set(CompilerDriver::REQUIRED_FLAG); - else - confDat->PreProcessor.clear(CompilerDriver::REQUIRED_FLAG); - break; - default: - error("Expecting 'command' or 'required' but found '" + - ConfigLexerState.StringVal); - break; - } - } - - bool parseOutputFlag() { - if (next() == EQUALS) { - if (next() == SPACE) - next(); - if (token == ASSEMBLY) { - return true; - } else if (token == BITCODE) { - return false; - } else { - error("Expecting output type value"); - return false; - } - if (next() != EOLTOK && token != 0) { - error("Extraneous tokens after output value"); - } - } - else - error("Expecting '='"); - return false; - } - - void parseTranslator() { - if (next() != SEPARATOR) - error("Expecting '.'"); - switch (next()) { - case COMMAND: - parseCommand(confDat->Translator); - break; - case REQUIRED: - if (parseBoolean()) - confDat->Translator.set(CompilerDriver::REQUIRED_FLAG); - else - confDat->Translator.clear(CompilerDriver::REQUIRED_FLAG); - break; - case PREPROCESSES: - if (parseBoolean()) - confDat->Translator.set(CompilerDriver::PREPROCESSES_FLAG); - else - confDat->Translator.clear(CompilerDriver::PREPROCESSES_FLAG); - break; - case OUTPUT: - if (parseOutputFlag()) - confDat->Translator.set(CompilerDriver::OUTPUT_IS_ASM_FLAG); - else - confDat->Translator.clear(CompilerDriver::OUTPUT_IS_ASM_FLAG); - break; - - default: - error("Expecting 'command', 'required', 'preprocesses', or " - "'output' but found '" + ConfigLexerState.StringVal + - "' instead"); - break; - } - } - - void parseOptimizer() { - if (next() != SEPARATOR) - error("Expecting '.'"); - switch (next()) { - case COMMAND: - parseCommand(confDat->Optimizer); - break; - case PREPROCESSES: - if (parseBoolean()) - confDat->Optimizer.set(CompilerDriver::PREPROCESSES_FLAG); - else - confDat->Optimizer.clear(CompilerDriver::PREPROCESSES_FLAG); - break; - case TRANSLATES: - if (parseBoolean()) - confDat->Optimizer.set(CompilerDriver::TRANSLATES_FLAG); - else - confDat->Optimizer.clear(CompilerDriver::TRANSLATES_FLAG); - break; - case REQUIRED: - if (parseBoolean()) - confDat->Optimizer.set(CompilerDriver::REQUIRED_FLAG); - else - confDat->Optimizer.clear(CompilerDriver::REQUIRED_FLAG); - break; - case OUTPUT: - if (parseOutputFlag()) - confDat->Translator.set(CompilerDriver::OUTPUT_IS_ASM_FLAG); - else - confDat->Translator.clear(CompilerDriver::OUTPUT_IS_ASM_FLAG); - break; - default: - error(std::string("Expecting 'command', 'preprocesses', " - "'translates' or 'output' but found '") + - ConfigLexerState.StringVal + "' instead"); - break; - } - } - - void parseAssembler() { - if (next() != SEPARATOR) - error("Expecting '.'"); - switch(next()) { - case COMMAND: - parseCommand(confDat->Assembler); - break; - default: - error("Expecting 'command'"); - break; - } - } - - void parseLinker() { - if (next() != SEPARATOR) - error("Expecting '.'"); - switch(next()) { - case LIBS: - break; //FIXME - case LIBPATHS: - break; //FIXME - default: - error("Expecting 'libs' or 'libpaths'"); - break; - } - } - - void parseAssignment() { - switch (token) { - case VERSION_TOK: parseVersion(); break; - case LANG: parseLang(); break; - case PREPROCESSOR: parsePreprocessor(); break; - case TRANSLATOR: parseTranslator(); break; - case OPTIMIZER: parseOptimizer(); break; - case ASSEMBLER: parseAssembler(); break; - case LINKER: parseLinker(); break; - case EOLTOK: break; // just ignore - case ERRORTOK: - default: - error("Invalid top level configuration item"); - break; - } - } - - void parseFile() { - while ( next() != EOFTOK ) { - if (token == ERRORTOK) - error("Invalid token"); - else if (token != EOLTOK) - parseAssignment(); - } - provider->checkErrors(); - } - }; - -void -ParseConfigData(InputProvider& provider, CompilerDriver::ConfigData& confDat) { - Parser p; - p.token = EOFTOK; - p.provider = &provider; - p.confDat = &confDat; - p.parseFile(); - } - -} - -CompilerDriver::ConfigData* -LLVMC_ConfigDataProvider::ReadConfigData(const std::string& ftype) { - CompilerDriver::ConfigData* result = 0; - sys::Path confFile; - if (configDir.isEmpty()) { - // Try the environment variable - const char* conf = getenv("LLVM_CONFIG_DIR"); - if (conf) { - confFile.set(conf); - confFile.appendComponent(ftype); - if (!confFile.canRead()) - throw std::string("Configuration file for '") + ftype + - "' is not available."; - } else { - // Try the user's home directory - confFile = sys::Path::GetUserHomeDirectory(); - if (!confFile.isEmpty()) { - confFile.appendComponent(".llvm"); - confFile.appendComponent("etc"); - confFile.appendComponent(ftype); - if (!confFile.canRead()) - confFile.clear(); - } - if (confFile.isEmpty()) { - // Okay, try the LLVM installation directory - confFile = sys::Path::GetLLVMConfigDir(); - confFile.appendComponent(ftype); - if (!confFile.canRead()) { - // Okay, try the "standard" place - confFile = sys::Path::GetLLVMDefaultConfigDir(); - confFile.appendComponent(ftype); - if (!confFile.canRead()) { - throw std::string("Configuration file for '") + ftype + - "' is not available."; - } - } - } - } - } else { - confFile = configDir; - confFile.appendComponent(ftype); - if (!confFile.canRead()) - throw std::string("Configuration file for '") + ftype + - "' is not available."; - } - FileInputProvider fip( confFile.toString() ); - if (!fip.okay()) { - throw std::string("Configuration file for '") + ftype + - "' is not available."; - } - result = new CompilerDriver::ConfigData(); - ParseConfigData(fip,*result); - return result; -} - -LLVMC_ConfigDataProvider::~LLVMC_ConfigDataProvider() -{ - ConfigDataMap::iterator cIt = Configurations.begin(); - while (cIt != Configurations.end()) { - CompilerDriver::ConfigData* cd = cIt->second; - ++cIt; - delete cd; - } -} - -CompilerDriver::ConfigData* -LLVMC_ConfigDataProvider::ProvideConfigData(const std::string& filetype) { - CompilerDriver::ConfigData* result = 0; - if (!Configurations.empty()) { - ConfigDataMap::iterator cIt = Configurations.find(filetype); - if ( cIt != Configurations.end() ) { - // We found one in the case, return it. - result = cIt->second; - } - } - if (result == 0) { - // The configuration data doesn't exist, we have to go read it. - result = ReadConfigData(filetype); - // If we got one, cache it - if (result != 0) - Configurations[filetype] = result; - } - return result; // Might return 0 -} Removed: llvm/trunk/tools/llvmc/Configuration.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/Configuration.h?rev=50614&view=auto ============================================================================== --- llvm/trunk/tools/llvmc/Configuration.h (original) +++ llvm/trunk/tools/llvmc/Configuration.h (removed) @@ -1,62 +0,0 @@ -//===- Configuration.h - Configuration Data Mgmt ----------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file declares the LLVMC_ConfigDataProvider class which implements the -// generation of ConfigData objects for the CompilerDriver. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_TOOLS_LLVMC_CONFIGDATA_H -#define LLVM_TOOLS_LLVMC_CONFIGDATA_H - -#include "llvm/ADT/StringMap.h" -#include "CompilerDriver.h" - -namespace llvm { - /// This class provides the high level interface to the LLVM Compiler Driver. - /// The driver's purpose is to make it easier for compiler writers and users - /// of LLVM to utilize the compiler toolkits and LLVM toolset by learning only - /// the interface of one program (llvmc). - /// - /// @see llvmc.cpp - /// @brief The interface to the LLVM Compiler Driver. - class LLVMC_ConfigDataProvider : public CompilerDriver::ConfigDataProvider { - /// @name Constructor - /// @{ - public: - virtual ~LLVMC_ConfigDataProvider(); - - /// @name Methods - /// @{ - public: - /// @brief Provide the configuration data to the CompilerDriver. - virtual CompilerDriver::ConfigData* - ProvideConfigData(const std::string& filetype); - - /// @brief Allow the configuration directory to be set - virtual void setConfigDir(const sys::Path& dirName) { - configDir = dirName; - } - - private: - CompilerDriver::ConfigData* ReadConfigData(const std::string& ftype); - - /// @} - /// @name Data - /// @{ - private: - /// @brief This type is used internally to hold the configuration data. - typedef StringMap ConfigDataMap; - ConfigDataMap Configurations; ///< The cache of configurations - sys::Path configDir; - /// @} - }; -} - -#endif Removed: llvm/trunk/tools/llvmc/LICENSE.TXT URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/LICENSE.TXT?rev=50614&view=auto ============================================================================== --- llvm/trunk/tools/llvmc/LICENSE.TXT (original) +++ llvm/trunk/tools/llvmc/LICENSE.TXT (removed) @@ -1,6 +0,0 @@ -LLVM Compiler Driver (llvmc) -------------------------------------------------------------------------------- -The LLVM Compiler Driver (llvmc) is licensed under the Illinois Open Source -License and has the following additional copyright: - -Copyright (C) 2004 eXtensible Systems, Inc. Removed: llvm/trunk/tools/llvmc/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/Makefile?rev=50614&view=auto ============================================================================== --- llvm/trunk/tools/llvmc/Makefile (original) +++ llvm/trunk/tools/llvmc/Makefile (removed) @@ -1,34 +0,0 @@ -##===- tools/llvmc/Makefile --------------------------------*- Makefile -*-===## -# -# The LLVM Compiler Infrastructure -# -# This file is distributed under the University of Illinois Open Source -# License. See LICENSE.TXT for details. -# -##===----------------------------------------------------------------------===## -LEVEL = ../.. -TOOLNAME = llvmc -LINK_COMPONENTS = support system core bitreader -CONFIG_FILES = c cpp ll st -EXTRA_DIST = c cpp ll ConfigLexer.cpp.cvs ConfigLexer.l.cvs -REQUIRES_EH := 1 - -# The CompilerDriver needs to know the locations of several configured -# directories and paths. We define these as preprocessor symbols so they can -# be hard coded into the process based on the configuration. Only those -# configuration values not available in llvm/include/Config/config.h need to be -# specified here. These values are used as the replacements for the -# configuration file substitution variables such as %llvmgccdir% -CPPFLAGS = -DLLVMGCCDIR="\"$(LLVMGCCDIR)\"" \ - -DLLVMGCCARCH="\"$(LLVMGCCARCH)\"" \ - -DLLVMGCC="\"$(LLVMGCC)\"" \ - -DLLVMGXX="\"$(LLVMGXX)\"" \ - -DLLVMCC1="\"$(LLVMCC1)\"" \ - -DLLVMCC1PLUS="\"$(LLVMCC1PLUS)\"" - -include $(LEVEL)/Makefile.common - -install:: - $(Echo) Installing additional C++ configuration clones - $(Verb)$(DataInstall) $(PROJ_SRC_DIR)/cpp $(PROJ_etcdir)/c++ - $(Verb)$(DataInstall) $(PROJ_SRC_DIR)/cpp $(PROJ_etcdir)/cxx Removed: llvm/trunk/tools/llvmc/c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/c?rev=50614&view=auto ============================================================================== --- llvm/trunk/tools/llvmc/c (original) +++ llvm/trunk/tools/llvmc/c (removed) @@ -1,60 +0,0 @@ -# C configuration file for llvmc - -########################################################## -# Language definitions -########################################################## - lang.name=C - lang.opt1=-O1 - lang.opt2=-O2 - lang.opt3=-O3 - lang.opt4=-O3 - lang.opt5=-O3 - lang.libs=%llvmgccdir%/lib %llvmgccdir%/lib %llvmgccdir%/lib/gcc/%llvmgccarch% - -########################################################## -# Pre-processor definitions -########################################################## - - # We use gcc as our pre-processor - preprocessor.command=gcc -E %in% -o %out% %incls% %defs% - preprocessor.required=true - -########################################################## -# Translator definitions -########################################################## - - # To compile C source, just use llvm-gcc's cc1 - translator.command=%llvmcc1% -quiet %in% -o %out% \ - %opt% %incls% %defs% %WOpts% %fOpts% %MOpts% %args% \ - -D_GNU_SOURCE - - # llvm-gcc does not pre-process - translator.preprocesses=false - - # The translator is required to run. - translator.required=true - - # Output of the translator is assembly - translator.output=assembly - -########################################################## -# Optimizer definitions -########################################################## - - # Use gccas to clean up the generated code - optimizer.command=%bindir%/gccas %in% -o %out% %args% - optimizer.required = true - - # gccas doesn't translate - optimizer.translates = false - - # gccas doesn't preprocess - optimizer.preprocesses=false - - # gccas produces bytecode - optimizer.output = bytecode - -########################################################## -# Assembler definitions -########################################################## - assembler.command=%bindir%/llc %in% -o %out% %target% %time% %stats% Removed: llvm/trunk/tools/llvmc/cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/cpp?rev=50614&view=auto ============================================================================== --- llvm/trunk/tools/llvmc/cpp (original) +++ llvm/trunk/tools/llvmc/cpp (removed) @@ -1,61 +0,0 @@ -# C++ configuration file for llvmc - -########################################################## -# Language definitions -########################################################## - lang.name=C++ - lang.opt1=-O1 - lang.opt2=-O2 - lang.opt3=-O3 - lang.opt4=-O3 - lang.opt5=-O3 - lang.libs=%llvmgccdir%/lib %llvmgccdir%/lib \ - %llvmgccdir%/lib/gcc/%llvmgccarch% - -########################################################## -# Pre-processor definitions -########################################################## - - # We use g++ as our pre-processor - preprocessor.command=g++ -E %in% -o %out% %incls% %defs% - preprocessor.required=true - -########################################################## -# Translator definitions -########################################################## - - # To compile C++ source, just use llvm-g++'s cc1 - translator.command=%llvmcc1plus% -quiet %in% -o %out% \ - %opt% %incls% %defs% %WOpts% %fOpts% %MOpts% %args% \ - -D_GNU_SOURCE - - # llvm-g++ does not pre-process - translator.preprocesses=false - - # The translator is required to run. - translator.required=true - - # Output of translator is assembly - translator.output=assembly - -########################################################## -# Optimizer definitions -########################################################## - - # Use gccas to clean up the generated code - optimizer.command=%bindir%/gccas %in% -o %out% %args% - optimizer.required = true - - # gccas doesn't translate - optimizer.translates = false - - # gccas doesn't preprocess - optimizer.preprocesses=false - - # gccas produces bytecode - optimizer.output = bytecode - -########################################################## -# Assembler definitions -########################################################## - assembler.command=%bindir%/llc %in% -o %out% %target% %time% %stats% Removed: llvm/trunk/tools/llvmc/ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/ll?rev=50614&view=auto ============================================================================== --- llvm/trunk/tools/llvmc/ll (original) +++ llvm/trunk/tools/llvmc/ll (removed) @@ -1,11 +0,0 @@ -# LLVM Assembly Config File For llvmc - version="1.0" - lang.name=LLVM Assembly - preprocessor.command= - preprocessor.required=false - translator.command=%bindir%/llvm-as %in% -o %out% - translator.preprocesses=true - translator.required=TRUE - optimizer.command=%bindir%/opt %in% -o %out% %opt% %args% - optimizer.translates=no - assembler.command=%bindir%/llc %in% -o %out% Removed: llvm/trunk/tools/llvmc/llvmc.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/llvmc.cpp?rev=50614&view=auto ============================================================================== --- llvm/trunk/tools/llvmc/llvmc.cpp (original) +++ llvm/trunk/tools/llvmc/llvmc.cpp (removed) @@ -1,374 +0,0 @@ -//===--- llvmc.cpp - The LLVM Compiler Driver -------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This tool provides a single point of access to the LLVM compilation tools. -// It has many options. To discover the options supported please refer to the -// tools' manual page (docs/CommandGuide/html/llvmc.html) or run the tool with -// the --help option. -// -//===----------------------------------------------------------------------===// - -#include "CompilerDriver.h" -#include "Configuration.h" -#include "llvm/Pass.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/Support/ManagedStatic.h" -#include "llvm/System/Signals.h" -#include -#include -using namespace llvm; - -//===----------------------------------------------------------------------===// -//=== PHASE OPTIONS -//===----------------------------------------------------------------------===// -static cl::opt FinalPhase(cl::Optional, - cl::desc("Choose final phase of compilation:"), - cl::init(CompilerDriver::LINKING), - cl::values( - clEnumValN(CompilerDriver::PREPROCESSING,"E", - "Stop compilation after pre-processing phase"), - clEnumValN(CompilerDriver::TRANSLATION, "t", - "Stop compilation after translation phase"), - clEnumValN(CompilerDriver::OPTIMIZATION,"c", - "Stop compilation after optimization phase"), - clEnumValN(CompilerDriver::ASSEMBLY,"S", - "Stop compilation after assembly phase"), - clEnumValEnd - ) -); - -//===----------------------------------------------------------------------===// -//=== OPTIMIZATION OPTIONS -//===----------------------------------------------------------------------===// -static cl::opt OptLevel(cl::ZeroOrMore, - cl::desc("Choose level of optimization to apply:"), - cl::init(CompilerDriver::OPT_FAST_COMPILE), - cl::values( - clEnumValN(CompilerDriver::OPT_FAST_COMPILE,"O0", - "An alias for the -O1 option"), - clEnumValN(CompilerDriver::OPT_FAST_COMPILE,"O1", - "Optimize for compilation speed, not execution speed"), - clEnumValN(CompilerDriver::OPT_SIMPLE,"O2", - "Perform simple translation time optimizations"), - clEnumValN(CompilerDriver::OPT_AGGRESSIVE,"O3", - "Perform aggressive translation time optimizations"), - clEnumValN(CompilerDriver::OPT_LINK_TIME,"O4", - "Perform link time optimizations"), - clEnumValN(CompilerDriver::OPT_AGGRESSIVE_LINK_TIME,"O5", - "Perform aggressive link time optimizations"), - clEnumValEnd - ) -); - -//===----------------------------------------------------------------------===// -//=== TOOL OPTIONS -//===----------------------------------------------------------------------===// - -static cl::list PreprocessorToolOpts("Tpre", cl::ZeroOrMore, - cl::desc("Pass specific options to the pre-processor"), - cl::value_desc("option")); - -static cl::alias PreprocessorToolOptsAlias("Wp,", cl::ZeroOrMore, - cl::desc("Alias for -Tpre"), cl::aliasopt(PreprocessorToolOpts)); - -static cl::list TranslatorToolOpts("Ttrn", cl::ZeroOrMore, - cl::desc("Pass specific options to the assembler"), - cl::value_desc("option")); - -static cl::list AssemblerToolOpts("Tasm", cl::ZeroOrMore, - cl::desc("Pass specific options to the assembler"), - cl::value_desc("option")); - -static cl::alias AssemblerToolOptsAlias("Wa,", cl::ZeroOrMore, - cl::desc("Alias for -Tasm"), cl::aliasopt(AssemblerToolOpts)); - -static cl::list OptimizerToolOpts("Topt", cl::ZeroOrMore, - cl::desc("Pass specific options to the optimizer"), - cl::value_desc("option")); - -static cl::list LinkerToolOpts("Tlnk", cl::ZeroOrMore, - cl::desc("Pass specific options to the linker"), - cl::value_desc("option")); - -static cl::alias LinkerToolOptsAlias("Wl,", cl::ZeroOrMore, - cl::desc("Alias for -Tlnk"), cl::aliasopt(LinkerToolOpts)); - -static cl::list fOpts("f", cl::ZeroOrMore, cl::Prefix, - cl::desc("Pass through -f options to compiler tools"), - cl::value_desc("option")); - -static cl::list MOpts("M", cl::ZeroOrMore, cl::Prefix, - cl::desc("Pass through -M options to compiler tools"), - cl::value_desc("option")); - -static cl::list WOpts("W", cl::ZeroOrMore, cl::Prefix, - cl::desc("Pass through -W options to compiler tools"), - cl::value_desc("option")); - -static cl::list BOpt("B", cl::ZeroOrMore, cl::Prefix, - cl::desc("Specify path to find llvmc sub-tools"), - cl::value_desc("dir")); - -//===----------------------------------------------------------------------===// -//=== INPUT OPTIONS -//===----------------------------------------------------------------------===// - -static cl::list LibPaths("L", cl::Prefix, - cl::desc("Specify a library search path"), cl::value_desc("dir")); - -static cl::list Libraries("l", cl::Prefix, - cl::desc("Specify base name of libraries to link to"), cl::value_desc("lib")); - -static cl::list Includes("I", cl::Prefix, - cl::desc("Specify location to search for included source"), - cl::value_desc("dir")); - -static cl::list Defines("D", cl::Prefix, - cl::desc("Specify a pre-processor symbol to define"), - cl::value_desc("symbol")); - -//===----------------------------------------------------------------------===// -//=== OUTPUT OPTIONS -//===----------------------------------------------------------------------===// - -static cl::opt OutputFilename("o", - cl::desc("Override output filename"), cl::value_desc("file")); - -static cl::opt OutputMachine("m", cl::Prefix, - cl::desc("Specify a target machine"), cl::value_desc("machine")); - -static cl::opt Native("native", cl::init(false), - cl::desc("Generative native code instead of bitcode")); - -static cl::opt DebugOutput("g", cl::init(false), - cl::desc("Generate objects that include debug symbols")); - -static cl::opt StripOutput("strip", cl::init(false), - cl::desc("Strip all symbols from linked output file")); - -static cl::opt PrintFileName("print-fname", cl::Optional, - cl::value_desc("file"), - cl::desc("Print the full path for the option's value")); - -//===----------------------------------------------------------------------===// -//=== INFORMATION OPTIONS -//===----------------------------------------------------------------------===// - -static cl::opt DryRun("dry-run", cl::Optional, cl::init(false), - cl::desc("Do everything but perform the compilation actions")); - -static cl::alias DryRunAlias("y", cl::Optional, - cl::desc("Alias for -dry-run"), cl::aliasopt(DryRun)); - -static cl::opt Verbose("verbose", cl::Optional, cl::init(false), - cl::desc("Print out each action taken")); - -static cl::alias VerboseAlias("v", cl::Optional, - cl::desc("Alias for -verbose"), cl::aliasopt(Verbose)); - -static cl::opt Debug("debug", cl::Optional, cl::init(false), - cl::Hidden, cl::desc("Print out debugging information")); - -static cl::alias DebugAlias("d", cl::Optional, - cl::desc("Alias for -debug"), cl::aliasopt(Debug)); - -static cl::opt TimeActions("time-actions", cl::Optional, cl::init(false), - cl::desc("Print execution time for each action taken")); - -static cl::opt ShowStats("stats", cl::Optional, cl::init(false), - cl::desc("Print statistics accumulated during optimization")); - -//===----------------------------------------------------------------------===// -//=== ADVANCED OPTIONS -//===----------------------------------------------------------------------===// - -static cl::opt ConfigDir("config-dir", cl::Optional, - cl::desc("Specify configuration directory to override defaults"), - cl::value_desc("dir")); - -static cl::opt EmitRawCode("emit-raw-code", cl::Hidden, cl::Optional, - cl::desc("Emit raw, unoptimized code")); - -static cl::opt PipeCommands("pipe", cl::Optional, - cl::desc("Invoke sub-commands by linking input/output with pipes")); - -static cl::opt KeepTemps("keep-temps", cl::Optional, - cl::desc("Don't delete temporary files created by llvmc")); - -//===----------------------------------------------------------------------===// -//=== POSITIONAL OPTIONS -//===----------------------------------------------------------------------===// - -static cl::list Files(cl::Positional, cl::ZeroOrMore, - cl::desc("[Sources/objects/libraries]")); - -static cl::list Languages("x", cl::ZeroOrMore, - cl::desc("Specify the source language for subsequent files"), - cl::value_desc("language")); - -//===----------------------------------------------------------------------===// -//=== GetFileType - determine type of a file -//===----------------------------------------------------------------------===// -static const std::string GetFileType(const std::string& fname, unsigned pos) { - static std::vector::iterator langIt = Languages.begin(); - static std::string CurrLang = ""; - - // If a -x LANG option has been specified .. - if (langIt != Languages.end()) - // If the -x LANG option came before the current file on command line - if (Languages.getPosition( langIt - Languages.begin() ) < pos) { - // use that language - CurrLang = *langIt++; - return CurrLang; - } - - // If there's a current language in effect - if (!CurrLang.empty()) - return CurrLang; // use that language - - // otherwise just determine lang from the filename's suffix - return fname.substr(fname.rfind('.', fname.size()) + 1); -} - -static void handleTerminatingOptions(CompilerDriver* CD) { - if (!PrintFileName.empty()) { - sys::Path path = CD->GetPathForLinkageItem(PrintFileName, false); - std::string p = path.toString(); - if (p.empty()) - std::cout << "Can't locate `" << PrintFileName << "'.\n"; - else - std::cout << p << '\n'; - exit(0); - } -} - -/// @brief The main program for llvmc -int main(int argc, char **argv) { - llvm_shutdown_obj X; // Call llvm_shutdown() on exit. - // Make sure we print stack trace if we get bad signals - sys::PrintStackTraceOnErrorSignal(); - - std::cout << "NOTE: llvmc is highly experimental and mostly useless right " - "now.\nPlease use llvm-gcc directly instead.\n\n"; - - try { - - // Parse the command line options - cl::ParseCommandLineOptions(argc, argv, - "LLVM Compiler Driver (llvmc)\n\n" - " This program provides easy invocation of the LLVM tool set\n" - " and other compiler tools.\n" - ); - - // Deal with unimplemented options. - if (PipeCommands) - throw std::string("Not implemented yet: -pipe"); - - if (OutputFilename.empty()) - if (OptLevel == CompilerDriver::LINKING) - OutputFilename = "a.out"; - - // Construct the ConfigDataProvider object - LLVMC_ConfigDataProvider Provider; - Provider.setConfigDir(sys::Path(ConfigDir)); - - // Construct the CompilerDriver object - CompilerDriver* CD = CompilerDriver::Get(Provider); - - // If the LLVM_LIB_SEARCH_PATH environment variable is - // set, append it to the list of places to search for libraries - char *srchPath = getenv("LLVM_LIB_SEARCH_PATH"); - if (srchPath != NULL && strlen(srchPath) != 0) - LibPaths.push_back(std::string(srchPath)); - - // Set the driver flags based on command line options - unsigned flags = 0; - if (Verbose) flags |= CompilerDriver::VERBOSE_FLAG; - if (Debug) flags |= CompilerDriver::DEBUG_FLAG; - if (DryRun) flags |= CompilerDriver::DRY_RUN_FLAG; - if (Native) flags |= CompilerDriver::EMIT_NATIVE_FLAG; - if (EmitRawCode) flags |= CompilerDriver::EMIT_RAW_FLAG; - if (KeepTemps) flags |= CompilerDriver::KEEP_TEMPS_FLAG; - if (ShowStats) flags |= CompilerDriver::SHOW_STATS_FLAG; - if (TimeActions) flags |= CompilerDriver::TIME_ACTIONS_FLAG; - if (StripOutput) flags |= CompilerDriver::STRIP_OUTPUT_FLAG; - CD->setDriverFlags(flags); - - // Specify required parameters - CD->setFinalPhase(FinalPhase); - CD->setOptimization(OptLevel); - CD->setOutputMachine(OutputMachine); - CD->setIncludePaths(Includes); - CD->setSymbolDefines(Defines); - CD->setLibraryPaths(LibPaths); - CD->setfPassThrough(fOpts); - CD->setMPassThrough(MOpts); - CD->setWPassThrough(WOpts); - - // Provide additional tool arguments - if (!PreprocessorToolOpts.empty()) - CD->setPhaseArgs(CompilerDriver::PREPROCESSING, PreprocessorToolOpts); - if (!TranslatorToolOpts.empty()) - CD->setPhaseArgs(CompilerDriver::TRANSLATION, TranslatorToolOpts); - if (!OptimizerToolOpts.empty()) - CD->setPhaseArgs(CompilerDriver::OPTIMIZATION, OptimizerToolOpts); - if (!AssemblerToolOpts.empty()) - CD->setPhaseArgs(CompilerDriver::ASSEMBLY,AssemblerToolOpts); - if (!LinkerToolOpts.empty()) - CD->setPhaseArgs(CompilerDriver::LINKING, LinkerToolOpts); - - // Check for options that cause us to terminate before any significant work - // is done. - handleTerminatingOptions(CD); - - // Prepare the list of files to be compiled by the CompilerDriver. - CompilerDriver::InputList InpList; - std::vector::iterator fileIt = Files.begin(); - std::vector::iterator libIt = Libraries.begin(); - unsigned libPos = 0, filePos = 0; - while ( 1 ) { - if (libIt != Libraries.end()) - libPos = Libraries.getPosition( libIt - Libraries.begin() ); - else - libPos = 0; - if (fileIt != Files.end()) - filePos = Files.getPosition(fileIt - Files.begin()); - else - filePos = 0; - - if (filePos != 0 && (libPos == 0 || filePos < libPos)) { - // Add a source file - InpList.push_back(std::make_pair(*fileIt, - GetFileType(*fileIt, filePos))); - ++fileIt; - } else if ( libPos != 0 && (filePos == 0 || libPos < filePos) ) { - // Add a library - InpList.push_back(std::make_pair(*libIt++, "")); - } - else - break; // we're done with the list - } - - // Tell the driver to do its thing - std::string ErrMsg; - int result = CD->execute(InpList, sys::Path(OutputFilename), ErrMsg); - if (result != 0) { - std::cerr << argv[0] << ": " << ErrMsg << '\n'; - return result; - } - - // All is good, return success - return 0; - } catch (const std::string& msg) { - std::cerr << argv[0] << ": " << msg << '\n'; - } catch (...) { - std::cerr << argv[0] << ": Unexpected unknown exception occurred.\n"; - } - return 1; -} Removed: llvm/trunk/tools/llvmc/st URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/st?rev=50614&view=auto ============================================================================== --- llvm/trunk/tools/llvmc/st (original) +++ llvm/trunk/tools/llvmc/st (removed) @@ -1,63 +0,0 @@ -# Stacker Configuration File For llvmc - -########################################################## -# Language definitions -########################################################## - lang.name=Stacker - lang.opt1=-O1 - lang.opt2=-O2 - lang.opt3=-O3 - lang.opt4=-O4 - lang.opt5=-O5 - -########################################################## -# Pre-processor definitions -########################################################## - - # Stacker doesn't have a preprocessor but the following - # allows the -E option to be supported - preprocessor.command=cp %in% %out% - preprocessor.required=false - -########################################################## -# Translator definitions -########################################################## - - # To compile stacker source, we just run the stacker - # compiler with a default stack size of 2048 entries. - translator.command=stkrc -s 2048 %in% -f -o %out% %opt% \ - %time% %stats% %args% - - # stkrc doesn't preprocess but we set this to true so - # that we don't run the cp command by default. - translator.preprocesses=true - - # The translator is required to run. - translator.required=false - - # stkrc doesn't handle the -On options - translator.output=bytecode - -########################################################## -# Optimizer definitions -########################################################## - - # For optimization, we use the LLVM "opt" program - optimizer.command=stkrc -s 2048 %in% -f -o %out% %opt% \ - %time% %stats% %args% - - optimizer.required = yes - - # opt doesn't translate - optimizer.translates = yes - - # opt doesn't preprocess - optimizer.preprocesses=yes - - # opt produces bytecode - optimizer.output = bc - -########################################################## -# Assembler definitions -########################################################## - assembler.command=llc %in% -o %out% %target% %time% %stats% From asl at math.spbu.ru Sun May 4 01:23:45 2008 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Sun, 04 May 2008 06:23:45 -0000 Subject: [llvm-commits] [llvm] r50616 - /llvm/trunk/docs/CommandGuide/index.html Message-ID: <200805040623.m446Nj0s019853@zion.cs.uiuc.edu> Author: asl Date: Sun May 4 01:23:44 2008 New Revision: 50616 URL: http://llvm.org/viewvc/llvm-project?rev=50616&view=rev Log: Remove entries from here also Modified: llvm/trunk/docs/CommandGuide/index.html Modified: llvm/trunk/docs/CommandGuide/index.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/index.html?rev=50616&r1=50615&r2=50616&view=diff ============================================================================== --- llvm/trunk/docs/CommandGuide/index.html (original) +++ llvm/trunk/docs/CommandGuide/index.html Sun May 4 01:23:44 2008 @@ -63,17 +63,12 @@
  • llvm-prof - format raw `llvmprof.out' data into a human-readable report
  • -
  • llvmc - - generic and configurable compiler driver
  • -
  • llvm-ld - general purpose linker with loadable runtime optimization support
  • llvm-config - print out LLVM compilation options, libraries, etc. as configured.
  • -
  • llvm2cpp - convert LLVM assembly - into the corresponding LLVM C++ API calls to produce it
  • From edwintorok at gmail.com Sun May 4 03:51:25 2008 From: edwintorok at gmail.com (Torok Edwin) Date: Sun, 04 May 2008 08:51:25 -0000 Subject: [llvm-commits] [llvm] r50618 - /llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Message-ID: <200805040851.m448pQPE031943@zion.cs.uiuc.edu> Author: edwin Date: Sun May 4 03:51:25 2008 New Revision: 50618 URL: http://llvm.org/viewvc/llvm-project?rev=50618&view=rev Log: processStore may delete the instruction, avoid using dyn_cast<> on already freed memory. Modified: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Modified: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp?rev=50618&r1=50617&r2=50618&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Sun May 4 03:51:25 2008 @@ -718,8 +718,7 @@ if (StoreInst *SI = dyn_cast(I)) changed_function |= processStore(SI, BI); - - if (MemCpyInst* M = dyn_cast(I)) { + else if (MemCpyInst* M = dyn_cast(I)) { changed_function |= processMemCpy(M); } } From edwintorok at gmail.com Sun May 4 03:52:27 2008 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Sun, 04 May 2008 11:52:27 +0300 Subject: [llvm-commits] [PATCH] PostDominators: avoid memory leak In-Reply-To: References: <481C8B10.5010704@gmail.com> <481CCCA3.4030507@gmail.com> Message-ID: <481D794B.3050903@gmail.com> Chris Lattner wrote: > On May 3, 2008, at 1:35 PM, T?r?k Edwin wrote: > > >> Bill Wendling wrote: >> >>> On May 3, 2008, at 8:56 AM, T?r?k Edwin wrote: >>> >>> >>> >>>> Hi, >>>> >>>> The DT member of PostDominatorTree is never freed, and valgrind >>>> reports >>>> a leak. >>>> No other optimization passess leak, and I like to see as few >>>> errors as >>>> possible from valgrind, hence this patch. >>>> It is only a matter of adding a simple destructor. >>>> >>>> Can I commit? >>>> >>>> >>>> >>> Looks good to me. Please commit. >>> >> Thanks commited in r50607. >> >> BTW my commit messages never reach this list (I consulted the archives >> at lists.cs.uiuc.edu), and it is not just this commit. >> My previous commits don't show up either ... >> > > Try another test commit please. Thanks! Thanks, it works now! --Edwin From evan.cheng at apple.com Sun May 4 04:15:51 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Sun, 04 May 2008 09:15:51 -0000 Subject: [llvm-commits] [llvm] r50619 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp test/CodeGen/X86/mmx-shift.ll test/CodeGen/X86/vec_shift3.ll Message-ID: <200805040915.m449Fpcp000757@zion.cs.uiuc.edu> Author: evancheng Date: Sun May 4 04:15:50 2008 New Revision: 50619 URL: http://llvm.org/viewvc/llvm-project?rev=50619&view=rev Log: Select vector shift with non-immediate i32 shift amount operand by first moving the operand into the right register. Added: llvm/trunk/test/CodeGen/X86/vec_shift3.ll Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/test/CodeGen/X86/mmx-shift.ll Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=50619&r1=50618&r2=50619&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Sun May 4 04:15:50 2008 @@ -4909,7 +4909,7 @@ unsigned IntNo = cast(Op.getOperand(0))->getValue(); switch (IntNo) { default: return SDOperand(); // Don't custom lower most intrinsics. - // Comparison intrinsics. + // Comparison intrinsics. case Intrinsic::x86_sse_comieq_ss: case Intrinsic::x86_sse_comilt_ss: case Intrinsic::x86_sse_comile_ss: @@ -5010,6 +5010,95 @@ DAG.getConstant(X86CC, MVT::i8), Cond); return DAG.getNode(ISD::ANY_EXTEND, MVT::i32, SetCC); } + + // Fix vector shift instructions where the last operand is a non-immediate + // i32 value. + case Intrinsic::x86_sse2_pslli_w: + case Intrinsic::x86_sse2_pslli_d: + case Intrinsic::x86_sse2_pslli_q: + case Intrinsic::x86_sse2_psrli_w: + case Intrinsic::x86_sse2_psrli_d: + case Intrinsic::x86_sse2_psrli_q: + case Intrinsic::x86_sse2_psrai_w: + case Intrinsic::x86_sse2_psrai_d: + case Intrinsic::x86_mmx_pslli_w: + case Intrinsic::x86_mmx_pslli_d: + case Intrinsic::x86_mmx_pslli_q: + case Intrinsic::x86_mmx_psrli_w: + case Intrinsic::x86_mmx_psrli_d: + case Intrinsic::x86_mmx_psrli_q: + case Intrinsic::x86_mmx_psrai_w: + case Intrinsic::x86_mmx_psrai_d: { + SDOperand ShAmt = Op.getOperand(2); + if (isa(ShAmt)) + return SDOperand(); + + unsigned NewIntNo = 0; + MVT::ValueType ShAmtVT = MVT::v4i32; + switch (IntNo) { + case Intrinsic::x86_sse2_pslli_w: + NewIntNo = Intrinsic::x86_sse2_psll_w; + break; + case Intrinsic::x86_sse2_pslli_d: + NewIntNo = Intrinsic::x86_sse2_psll_d; + break; + case Intrinsic::x86_sse2_pslli_q: + NewIntNo = Intrinsic::x86_sse2_psll_q; + break; + case Intrinsic::x86_sse2_psrli_w: + NewIntNo = Intrinsic::x86_sse2_psrl_w; + break; + case Intrinsic::x86_sse2_psrli_d: + NewIntNo = Intrinsic::x86_sse2_psrl_d; + break; + case Intrinsic::x86_sse2_psrli_q: + NewIntNo = Intrinsic::x86_sse2_psrl_q; + break; + case Intrinsic::x86_sse2_psrai_w: + NewIntNo = Intrinsic::x86_sse2_psra_w; + break; + case Intrinsic::x86_sse2_psrai_d: + NewIntNo = Intrinsic::x86_sse2_psra_d; + break; + default: { + ShAmtVT = MVT::v2i32; + switch (IntNo) { + case Intrinsic::x86_mmx_pslli_w: + NewIntNo = Intrinsic::x86_mmx_psll_w; + break; + case Intrinsic::x86_mmx_pslli_d: + NewIntNo = Intrinsic::x86_mmx_psll_d; + break; + case Intrinsic::x86_mmx_pslli_q: + NewIntNo = Intrinsic::x86_mmx_psll_q; + break; + case Intrinsic::x86_mmx_psrli_w: + NewIntNo = Intrinsic::x86_mmx_psrl_w; + break; + case Intrinsic::x86_mmx_psrli_d: + NewIntNo = Intrinsic::x86_mmx_psrl_d; + break; + case Intrinsic::x86_mmx_psrli_q: + NewIntNo = Intrinsic::x86_mmx_psrl_q; + break; + case Intrinsic::x86_mmx_psrai_w: + NewIntNo = Intrinsic::x86_mmx_psra_w; + break; + case Intrinsic::x86_mmx_psrai_d: + NewIntNo = Intrinsic::x86_mmx_psra_d; + break; + default: abort(); // Can't reach here. + } + break; + } + } + MVT::ValueType VT = Op.getValueType(); + ShAmt = DAG.getNode(ISD::BIT_CONVERT, VT, + DAG.getNode(ISD::SCALAR_TO_VECTOR, ShAmtVT, ShAmt)); + return DAG.getNode(ISD::INTRINSIC_WO_CHAIN, VT, + DAG.getConstant(NewIntNo, MVT::i32), + Op.getOperand(1), ShAmt); + } } } Modified: llvm/trunk/test/CodeGen/X86/mmx-shift.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/mmx-shift.ll?rev=50619&r1=50618&r2=50619&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/mmx-shift.ll (original) +++ llvm/trunk/test/CodeGen/X86/mmx-shift.ll Sun May 4 04:15:50 2008 @@ -1,6 +1,7 @@ ; RUN: llvm-as < %s | llc -march=x86 -mattr=+mmx | grep psllq | grep 32 ; RUN: llvm-as < %s | llc -march=x86-64 -mattr=+mmx | grep psllq | grep 32 ; RUN: llvm-as < %s | llc -march=x86 -mattr=+mmx | grep psrad +; RUN: llvm-as < %s | llc -march=x86-64 -mattr=+mmx | grep psrlw define i64 @t1(<1 x i64> %mm1) nounwind { entry: @@ -19,3 +20,13 @@ } declare <2 x i32> @llvm.x86.mmx.psra.d(<2 x i32>, <2 x i32>) nounwind readnone + +define i64 @t3(<1 x i64> %mm1, i32 %bits) nounwind { +entry: + %tmp6 = bitcast <1 x i64> %mm1 to <4 x i16> ; <<4 x i16>> [#uses=1] + %tmp8 = tail call <4 x i16> @llvm.x86.mmx.psrli.w( <4 x i16> %tmp6, i32 %bits ) nounwind readnone ; <<4 x i16>> [#uses=1] + %retval1314 = bitcast <4 x i16> %tmp8 to i64 ; [#uses=1] + ret i64 %retval1314 +} + +declare <4 x i16> @llvm.x86.mmx.psrli.w(<4 x i16>, i32) nounwind readnone Added: llvm/trunk/test/CodeGen/X86/vec_shift3.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_shift3.ll?rev=50619&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_shift3.ll (added) +++ llvm/trunk/test/CodeGen/X86/vec_shift3.ll Sun May 4 04:15:50 2008 @@ -0,0 +1,26 @@ +; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 | grep psllq +; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 | grep psraw +; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 | grep movd | count 2 + +define <2 x i64> @t1(<2 x i64> %x1, i32 %bits) nounwind { +entry: + %tmp3 = tail call <2 x i64> @llvm.x86.sse2.pslli.q( <2 x i64> %x1, i32 %bits ) nounwind readnone ; <<2 x i64>> [#uses=1] + ret <2 x i64> %tmp3 +} + +define <2 x i64> @t2(<2 x i64> %x1) nounwind { +entry: + %tmp3 = tail call <2 x i64> @llvm.x86.sse2.pslli.q( <2 x i64> %x1, i32 10 ) nounwind readnone ; <<2 x i64>> [#uses=1] + ret <2 x i64> %tmp3 +} + +define <2 x i64> @t3(<2 x i64> %x1, i32 %bits) nounwind { +entry: + %tmp2 = bitcast <2 x i64> %x1 to <8 x i16> ; <<8 x i16>> [#uses=1] + %tmp4 = tail call <8 x i16> @llvm.x86.sse2.psrai.w( <8 x i16> %tmp2, i32 %bits ) nounwind readnone ; <<8 x i16>> [#uses=1] + %tmp5 = bitcast <8 x i16> %tmp4 to <2 x i64> ; <<2 x i64>> [#uses=1] + ret <2 x i64> %tmp5 +} + +declare <8 x i16> @llvm.x86.sse2.psrai.w(<8 x i16>, i32) nounwind readnone +declare <2 x i64> @llvm.x86.sse2.pslli.q(<2 x i64>, i32) nounwind readnone From baldrick at free.fr Sun May 4 05:09:20 2008 From: baldrick at free.fr (Duncan Sands) Date: Sun, 4 May 2008 12:09:20 +0200 Subject: [llvm-commits] [llvm] r50451 - /llvm/trunk/lib/CodeGen/DwarfWriter.cpp In-Reply-To: <200804292258.m3TMwKqh014302@zion.cs.uiuc.edu> References: <200804292258.m3TMwKqh014302@zion.cs.uiuc.edu> Message-ID: <200805041209.20943.baldrick@free.fr> Hi, > + Asm->EmitAlignment(TD->getPointerSize() == sizeof(int32_t) ? 2 : 3, > + 0, 0, false); how about using log of the pointer size? Ciao, Duncan. From baldrick at free.fr Sun May 4 05:12:02 2008 From: baldrick at free.fr (Duncan Sands) Date: Sun, 4 May 2008 12:12:02 +0200 Subject: [llvm-commits] atomic operator patch In-Reply-To: <74859BF3-9BE5-4418-8482-7AC4171E565B@apple.com> References: <74859BF3-9BE5-4418-8482-7AC4171E565B@apple.com> Message-ID: <200805041212.03175.baldrick@free.fr> On Wednesday 30 April 2008 03:38:34 Mon P Wang wrote: > Currently, llvm support add, swap, and the compare and swap. I want > to add support for atomic support for sub, and, or, xor, min and max > (the latter two in both signed and unsigned version) in X86 line. The > intrinsic names are of the form __sync_fetch_and_[opname] like other > sync intrinsics. If you have any issues or concerns, please let me > know. Does gcc implement these? Ciao, Duncan. From baldrick at free.fr Sun May 4 07:30:06 2008 From: baldrick at free.fr (Duncan Sands) Date: Sun, 4 May 2008 14:30:06 +0200 Subject: [llvm-commits] [llvm] r50600 - /llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp In-Reply-To: <200805030036.m430aUuF015909@zion.cs.uiuc.edu> References: <200805030036.m430aUuF015909@zion.cs.uiuc.edu> Message-ID: <200805041430.06226.baldrick@free.fr> > + // FIXME: Remove GetREsultInst test when first class support for aggregates is GetREsultInst -> GetResultInst Ciao, Duncan. From gordonhenriksen at mac.com Sun May 4 07:55:35 2008 From: gordonhenriksen at mac.com (Gordon Henriksen) Date: Sun, 04 May 2008 12:55:35 -0000 Subject: [llvm-commits] [llvm] r50620 - in /llvm/trunk: include/llvm-c/Core.h include/llvm-c/lto.h lib/VMCore/Core.cpp Message-ID: <200805041255.m44CtZH8031376@zion.cs.uiuc.edu> Author: gordon Date: Sun May 4 07:55:34 2008 New Revision: 50620 URL: http://llvm.org/viewvc/llvm-project?rev=50620&view=rev Log: Use (void) instead of () in C code. Modified: llvm/trunk/include/llvm-c/Core.h llvm/trunk/include/llvm-c/lto.h llvm/trunk/lib/VMCore/Core.cpp Modified: llvm/trunk/include/llvm-c/Core.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=50620&r1=50619&r2=50620&view=diff ============================================================================== --- llvm/trunk/include/llvm-c/Core.h (original) +++ llvm/trunk/include/llvm-c/Core.h Sun May 4 07:55:34 2008 @@ -228,20 +228,20 @@ void LLVMRefineAbstractType(LLVMTypeRef AbstractType, LLVMTypeRef ConcreteType); /* Operations on integer types */ -LLVMTypeRef LLVMInt1Type(); -LLVMTypeRef LLVMInt8Type(); -LLVMTypeRef LLVMInt16Type(); -LLVMTypeRef LLVMInt32Type(); -LLVMTypeRef LLVMInt64Type(); +LLVMTypeRef LLVMInt1Type(void); +LLVMTypeRef LLVMInt8Type(void); +LLVMTypeRef LLVMInt16Type(void); +LLVMTypeRef LLVMInt32Type(void); +LLVMTypeRef LLVMInt64Type(void); LLVMTypeRef LLVMIntType(unsigned NumBits); unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy); /* Operations on real types */ -LLVMTypeRef LLVMFloatType(); -LLVMTypeRef LLVMDoubleType(); -LLVMTypeRef LLVMX86FP80Type(); -LLVMTypeRef LLVMFP128Type(); -LLVMTypeRef LLVMPPCFP128Type(); +LLVMTypeRef LLVMFloatType(void); +LLVMTypeRef LLVMDoubleType(void); +LLVMTypeRef LLVMX86FP80Type(void); +LLVMTypeRef LLVMFP128Type(void); +LLVMTypeRef LLVMPPCFP128Type(void); /* Operations on function types */ LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType, @@ -270,9 +270,9 @@ unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy); /* Operations on other types */ -LLVMTypeRef LLVMVoidType(); -LLVMTypeRef LLVMLabelType(); -LLVMTypeRef LLVMOpaqueType(); +LLVMTypeRef LLVMVoidType(void); +LLVMTypeRef LLVMLabelType(void); +LLVMTypeRef LLVMOpaqueType(void); /* Operations on type handles */ LLVMTypeHandleRef LLVMCreateTypeHandle(LLVMTypeRef PotentiallyAbstractTy); @@ -477,7 +477,7 @@ * exclusive means of building instructions using the C interface. */ -LLVMBuilderRef LLVMCreateBuilder(); +LLVMBuilderRef LLVMCreateBuilder(void); void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block, LLVMValueRef Instr); void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr); @@ -637,7 +637,7 @@ /** Constructs a new whole-module pass pipeline. This type of pipeline is suitable for link-time optimization and whole-module transformations. See llvm::PassManager::PassManager. */ -LLVMPassManagerRef LLVMCreatePassManager(); +LLVMPassManagerRef LLVMCreatePassManager(void); /** Constructs a new function-by-function pass pipeline over the module provider. It does not take ownership of the module provider. This type of Modified: llvm/trunk/include/llvm-c/lto.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/lto.h?rev=50620&r1=50619&r2=50620&view=diff ============================================================================== --- llvm/trunk/include/llvm-c/lto.h (original) +++ llvm/trunk/include/llvm-c/lto.h Sun May 4 07:55:34 2008 @@ -63,14 +63,14 @@ * Returns a printable string. */ extern const char* -lto_get_version(); +lto_get_version(void); /** * Returns the last error string or NULL if last operation was sucessful. */ extern const char* -lto_get_error_message(); +lto_get_error_message(void); /** @@ -160,7 +160,7 @@ * Returns NULL on error (check lto_get_error_message() for details). */ extern lto_code_gen_t -lto_codegen_create(); +lto_codegen_create(void); /** Modified: llvm/trunk/lib/VMCore/Core.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=50620&r1=50619&r2=50620&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Core.cpp (original) +++ llvm/trunk/lib/VMCore/Core.cpp Sun May 4 07:55:34 2008 @@ -97,11 +97,11 @@ /*--.. Operations on integer types .........................................--*/ -LLVMTypeRef LLVMInt1Type() { return (LLVMTypeRef) Type::Int1Ty; } -LLVMTypeRef LLVMInt8Type() { return (LLVMTypeRef) Type::Int8Ty; } -LLVMTypeRef LLVMInt16Type() { return (LLVMTypeRef) Type::Int16Ty; } -LLVMTypeRef LLVMInt32Type() { return (LLVMTypeRef) Type::Int32Ty; } -LLVMTypeRef LLVMInt64Type() { return (LLVMTypeRef) Type::Int64Ty; } +LLVMTypeRef LLVMInt1Type(void) { return (LLVMTypeRef) Type::Int1Ty; } +LLVMTypeRef LLVMInt8Type(void) { return (LLVMTypeRef) Type::Int8Ty; } +LLVMTypeRef LLVMInt16Type(void) { return (LLVMTypeRef) Type::Int16Ty; } +LLVMTypeRef LLVMInt32Type(void) { return (LLVMTypeRef) Type::Int32Ty; } +LLVMTypeRef LLVMInt64Type(void) { return (LLVMTypeRef) Type::Int64Ty; } LLVMTypeRef LLVMIntType(unsigned NumBits) { return wrap(IntegerType::get(NumBits)); @@ -113,11 +113,11 @@ /*--.. Operations on real types ............................................--*/ -LLVMTypeRef LLVMFloatType() { return (LLVMTypeRef) Type::FloatTy; } -LLVMTypeRef LLVMDoubleType() { return (LLVMTypeRef) Type::DoubleTy; } -LLVMTypeRef LLVMX86FP80Type() { return (LLVMTypeRef) Type::X86_FP80Ty; } -LLVMTypeRef LLVMFP128Type() { return (LLVMTypeRef) Type::FP128Ty; } -LLVMTypeRef LLVMPPCFP128Type() { return (LLVMTypeRef) Type::PPC_FP128Ty; } +LLVMTypeRef LLVMFloatType(void) { return (LLVMTypeRef) Type::FloatTy; } +LLVMTypeRef LLVMDoubleType(void) { return (LLVMTypeRef) Type::DoubleTy; } +LLVMTypeRef LLVMX86FP80Type(void) { return (LLVMTypeRef) Type::X86_FP80Ty; } +LLVMTypeRef LLVMFP128Type(void) { return (LLVMTypeRef) Type::FP128Ty; } +LLVMTypeRef LLVMPPCFP128Type(void) { return (LLVMTypeRef) Type::PPC_FP128Ty; } /*--.. Operations on function types ........................................--*/ @@ -209,10 +209,10 @@ /*--.. Operations on other types ...........................................--*/ -LLVMTypeRef LLVMVoidType() { return (LLVMTypeRef) Type::VoidTy; } -LLVMTypeRef LLVMLabelType() { return (LLVMTypeRef) Type::LabelTy; } +LLVMTypeRef LLVMVoidType(void) { return (LLVMTypeRef) Type::VoidTy; } +LLVMTypeRef LLVMLabelType(void) { return (LLVMTypeRef) Type::LabelTy; } -LLVMTypeRef LLVMOpaqueType() { +LLVMTypeRef LLVMOpaqueType(void) { return wrap(llvm::OpaqueType::get()); } @@ -996,7 +996,7 @@ /*===-- Instruction builders ----------------------------------------------===*/ -LLVMBuilderRef LLVMCreateBuilder() { +LLVMBuilderRef LLVMCreateBuilder(void) { return wrap(new IRBuilder()); } From sabre at nondot.org Sun May 4 12:18:48 2008 From: sabre at nondot.org (Chris Lattner) Date: Sun, 04 May 2008 17:18:48 -0000 Subject: [llvm-commits] [llvm] r50621 - in /llvm/trunk/lib/AsmParser: llvmAsmParser.cpp.cvs llvmAsmParser.h.cvs Message-ID: <200805041718.m44HImb2006593@zion.cs.uiuc.edu> Author: lattner Date: Sun May 4 12:18:47 2008 New Revision: 50621 URL: http://llvm.org/viewvc/llvm-project?rev=50621&view=rev Log: regenerate Modified: llvm/trunk/lib/AsmParser/llvmAsmParser.cpp.cvs llvm/trunk/lib/AsmParser/llvmAsmParser.h.cvs Modified: llvm/trunk/lib/AsmParser/llvmAsmParser.cpp.cvs URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/llvmAsmParser.cpp.cvs?rev=50621&r1=50620&r2=50621&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/llvmAsmParser.cpp.cvs (original) +++ llvm/trunk/lib/AsmParser/llvmAsmParser.cpp.cvs Sun May 4 12:18:47 2008 @@ -139,90 +139,89 @@ X86_STDCALLCC_TOK = 320, X86_FASTCALLCC_TOK = 321, DATALAYOUT = 322, - UNWINDS = 323, - RET = 324, - BR = 325, - SWITCH = 326, - INVOKE = 327, - UNWIND = 328, - UNREACHABLE = 329, - ADD = 330, - SUB = 331, - MUL = 332, - UDIV = 333, - SDIV = 334, - FDIV = 335, - UREM = 336, - SREM = 337, - FREM = 338, - AND = 339, - OR = 340, - XOR = 341, - SHL = 342, - LSHR = 343, - ASHR = 344, - ICMP = 345, - FCMP = 346, - EQ = 347, - NE = 348, - SLT = 349, - SGT = 350, - SLE = 351, - SGE = 352, - ULT = 353, - UGT = 354, - ULE = 355, - UGE = 356, - OEQ = 357, - ONE = 358, - OLT = 359, - OGT = 360, - OLE = 361, - OGE = 362, - ORD = 363, - UNO = 364, - UEQ = 365, - UNE = 366, - MALLOC = 367, - ALLOCA = 368, - FREE = 369, - LOAD = 370, - STORE = 371, - GETELEMENTPTR = 372, - TRUNC = 373, - ZEXT = 374, - SEXT = 375, - FPTRUNC = 376, - FPEXT = 377, - BITCAST = 378, - UITOFP = 379, - SITOFP = 380, - FPTOUI = 381, - FPTOSI = 382, - INTTOPTR = 383, - PTRTOINT = 384, - PHI_TOK = 385, - SELECT = 386, - VAARG = 387, - EXTRACTELEMENT = 388, - INSERTELEMENT = 389, - SHUFFLEVECTOR = 390, - GETRESULT = 391, - SIGNEXT = 392, - ZEROEXT = 393, - NORETURN = 394, - INREG = 395, - SRET = 396, - NOUNWIND = 397, - NOALIAS = 398, - BYVAL = 399, - NEST = 400, - READNONE = 401, - READONLY = 402, - GC = 403, - DEFAULT = 404, - HIDDEN = 405, - PROTECTED = 406 + RET = 323, + BR = 324, + SWITCH = 325, + INVOKE = 326, + UNWIND = 327, + UNREACHABLE = 328, + ADD = 329, + SUB = 330, + MUL = 331, + UDIV = 332, + SDIV = 333, + FDIV = 334, + UREM = 335, + SREM = 336, + FREM = 337, + AND = 338, + OR = 339, + XOR = 340, + SHL = 341, + LSHR = 342, + ASHR = 343, + ICMP = 344, + FCMP = 345, + EQ = 346, + NE = 347, + SLT = 348, + SGT = 349, + SLE = 350, + SGE = 351, + ULT = 352, + UGT = 353, + ULE = 354, + UGE = 355, + OEQ = 356, + ONE = 357, + OLT = 358, + OGT = 359, + OLE = 360, + OGE = 361, + ORD = 362, + UNO = 363, + UEQ = 364, + UNE = 365, + MALLOC = 366, + ALLOCA = 367, + FREE = 368, + LOAD = 369, + STORE = 370, + GETELEMENTPTR = 371, + TRUNC = 372, + ZEXT = 373, + SEXT = 374, + FPTRUNC = 375, + FPEXT = 376, + BITCAST = 377, + UITOFP = 378, + SITOFP = 379, + FPTOUI = 380, + FPTOSI = 381, + INTTOPTR = 382, + PTRTOINT = 383, + PHI_TOK = 384, + SELECT = 385, + VAARG = 386, + EXTRACTELEMENT = 387, + INSERTELEMENT = 388, + SHUFFLEVECTOR = 389, + GETRESULT = 390, + SIGNEXT = 391, + ZEROEXT = 392, + NORETURN = 393, + INREG = 394, + SRET = 395, + NOUNWIND = 396, + NOALIAS = 397, + BYVAL = 398, + NEST = 399, + READNONE = 400, + READONLY = 401, + GC = 402, + DEFAULT = 403, + HIDDEN = 404, + PROTECTED = 405 }; #endif /* Tokens. */ @@ -291,96 +290,95 @@ #define X86_STDCALLCC_TOK 320 #define X86_FASTCALLCC_TOK 321 #define DATALAYOUT 322 -#define UNWINDS 323 -#define RET 324 -#define BR 325 -#define SWITCH 326 -#define INVOKE 327 -#define UNWIND 328 -#define UNREACHABLE 329 -#define ADD 330 -#define SUB 331 -#define MUL 332 -#define UDIV 333 -#define SDIV 334 -#define FDIV 335 -#define UREM 336 -#define SREM 337 -#define FREM 338 -#define AND 339 -#define OR 340 -#define XOR 341 -#define SHL 342 -#define LSHR 343 -#define ASHR 344 -#define ICMP 345 -#define FCMP 346 -#define EQ 347 -#define NE 348 -#define SLT 349 -#define SGT 350 -#define SLE 351 -#define SGE 352 -#define ULT 353 -#define UGT 354 -#define ULE 355 -#define UGE 356 -#define OEQ 357 -#define ONE 358 -#define OLT 359 -#define OGT 360 -#define OLE 361 -#define OGE 362 -#define ORD 363 -#define UNO 364 -#define UEQ 365 -#define UNE 366 -#define MALLOC 367 -#define ALLOCA 368 -#define FREE 369 -#define LOAD 370 -#define STORE 371 -#define GETELEMENTPTR 372 -#define TRUNC 373 -#define ZEXT 374 -#define SEXT 375 -#define FPTRUNC 376 -#define FPEXT 377 -#define BITCAST 378 -#define UITOFP 379 -#define SITOFP 380 -#define FPTOUI 381 -#define FPTOSI 382 -#define INTTOPTR 383 -#define PTRTOINT 384 -#define PHI_TOK 385 -#define SELECT 386 -#define VAARG 387 -#define EXTRACTELEMENT 388 -#define INSERTELEMENT 389 -#define SHUFFLEVECTOR 390 -#define GETRESULT 391 -#define SIGNEXT 392 -#define ZEROEXT 393 -#define NORETURN 394 -#define INREG 395 -#define SRET 396 -#define NOUNWIND 397 -#define NOALIAS 398 -#define BYVAL 399 -#define NEST 400 -#define READNONE 401 -#define READONLY 402 -#define GC 403 -#define DEFAULT 404 -#define HIDDEN 405 -#define PROTECTED 406 +#define RET 323 +#define BR 324 +#define SWITCH 325 +#define INVOKE 326 +#define UNWIND 327 +#define UNREACHABLE 328 +#define ADD 329 +#define SUB 330 +#define MUL 331 +#define UDIV 332 +#define SDIV 333 +#define FDIV 334 +#define UREM 335 +#define SREM 336 +#define FREM 337 +#define AND 338 +#define OR 339 +#define XOR 340 +#define SHL 341 +#define LSHR 342 +#define ASHR 343 +#define ICMP 344 +#define FCMP 345 +#define EQ 346 +#define NE 347 +#define SLT 348 +#define SGT 349 +#define SLE 350 +#define SGE 351 +#define ULT 352 +#define UGT 353 +#define ULE 354 +#define UGE 355 +#define OEQ 356 +#define ONE 357 +#define OLT 358 +#define OGT 359 +#define OLE 360 +#define OGE 361 +#define ORD 362 +#define UNO 363 +#define UEQ 364 +#define UNE 365 +#define MALLOC 366 +#define ALLOCA 367 +#define FREE 368 +#define LOAD 369 +#define STORE 370 +#define GETELEMENTPTR 371 +#define TRUNC 372 +#define ZEXT 373 +#define SEXT 374 +#define FPTRUNC 375 +#define FPEXT 376 +#define BITCAST 377 +#define UITOFP 378 +#define SITOFP 379 +#define FPTOUI 380 +#define FPTOSI 381 +#define INTTOPTR 382 +#define PTRTOINT 383 +#define PHI_TOK 384 +#define SELECT 385 +#define VAARG 386 +#define EXTRACTELEMENT 387 +#define INSERTELEMENT 388 +#define SHUFFLEVECTOR 389 +#define GETRESULT 390 +#define SIGNEXT 391 +#define ZEROEXT 392 +#define NORETURN 393 +#define INREG 394 +#define SRET 395 +#define NOUNWIND 396 +#define NOALIAS 397 +#define BYVAL 398 +#define NEST 399 +#define READNONE 400 +#define READONLY 401 +#define GC 402 +#define DEFAULT 403 +#define HIDDEN 404 +#define PROTECTED 405 /* Copy the first part of user declarations. */ -#line 14 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 14 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" #include "ParserInternals.h" #include "llvm/CallingConv.h" @@ -887,7 +885,7 @@ /// defineBBVal - This is a definition of a new basic block with the specified /// identifier which must be the same as CurFun.NextValNum, if its numeric. -static BasicBlock *defineBBVal(const ValID &ID, BasicBlock *unwindDest) { +static BasicBlock *defineBBVal(const ValID &ID) { assert(inFunctionScope() && "Can't get basic block at global scope!"); BasicBlock *BB = 0; @@ -929,7 +927,6 @@ } ID.destroy(); - BB->setUnwindDest(unwindDest); return BB; } @@ -1337,7 +1334,7 @@ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -#line 950 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 949 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { llvm::Module *ModuleVal; llvm::Function *FunctionVal; @@ -1385,7 +1382,7 @@ llvm::FCmpInst::Predicate FPredicate; } /* Line 193 of yacc.c. */ -#line 1389 "llvmAsmParser.tab.c" +#line 1386 "llvmAsmParser.tab.c" YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 @@ -1398,7 +1395,7 @@ /* Line 216 of yacc.c. */ -#line 1402 "llvmAsmParser.tab.c" +#line 1399 "llvmAsmParser.tab.c" #ifdef short # undef short @@ -1613,20 +1610,20 @@ /* YYFINAL -- State number of the termination state. */ #define YYFINAL 43 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 2015 +#define YYLAST 1978 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 166 +#define YYNTOKENS 165 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 85 /* YYNRULES -- Number of rules. */ -#define YYNRULES 324 +#define YYNRULES 322 /* YYNRULES -- Number of states. */ -#define YYNSTATES 635 +#define YYNSTATES 629 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 406 +#define YYMAXUTOK 405 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -1638,15 +1635,15 @@ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 152, 153, 156, 2, 155, 2, 2, 2, 2, 2, + 151, 152, 155, 2, 154, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 161, 154, 162, 2, 2, 2, 2, 2, 2, 2, + 160, 153, 161, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 158, 157, 160, 2, 2, 2, 2, 2, 165, + 2, 157, 156, 159, 2, 2, 2, 2, 2, 164, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 159, 2, 2, 163, 2, 164, 2, 2, 2, 2, + 158, 2, 2, 162, 2, 163, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -1674,7 +1671,7 @@ 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, - 145, 146, 147, 148, 149, 150, 151 + 145, 146, 147, 148, 149, 150 }; #if YYDEBUG @@ -1709,158 +1706,157 @@ 664, 675, 677, 679, 684, 686, 688, 691, 695, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 718, 720, 726, 728, 730, 732, 734, 736, 738, 741, 743, - 747, 750, 753, 757, 760, 761, 765, 767, 772, 775, - 778, 782, 792, 802, 811, 826, 828, 830, 837, 843, - 846, 853, 861, 866, 871, 878, 885, 886, 887, 891, - 894, 896, 902, 908, 915, 922, 927, 934, 939, 944, - 951, 958, 961, 970, 972, 974, 975, 979, 986, 990, - 997, 1000, 1006, 1014, 1020 + 747, 750, 753, 757, 760, 761, 763, 766, 769, 773, + 783, 793, 802, 817, 819, 821, 828, 834, 837, 844, + 852, 857, 862, 869, 876, 877, 878, 882, 885, 887, + 893, 899, 906, 913, 918, 925, 930, 935, 942, 949, + 952, 961, 963, 965, 966, 970, 977, 981, 988, 991, + 997, 1005, 1011 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int16 yyrhs[] = { - 212, 0, -1, 75, -1, 76, -1, 77, -1, 78, - -1, 79, -1, 80, -1, 81, -1, 82, -1, 83, - -1, 87, -1, 88, -1, 89, -1, 84, -1, 85, - -1, 86, -1, 118, -1, 119, -1, 120, -1, 121, - -1, 122, -1, 123, -1, 124, -1, 125, -1, 126, - -1, 127, -1, 128, -1, 129, -1, 92, -1, 93, - -1, 94, -1, 95, -1, 96, -1, 97, -1, 98, - -1, 99, -1, 100, -1, 101, -1, 102, -1, 103, - -1, 104, -1, 105, -1, 106, -1, 107, -1, 108, - -1, 109, -1, 110, -1, 111, -1, 98, -1, 99, - -1, 100, -1, 101, -1, 26, -1, 27, -1, 11, + 211, 0, -1, 74, -1, 75, -1, 76, -1, 77, + -1, 78, -1, 79, -1, 80, -1, 81, -1, 82, + -1, 86, -1, 87, -1, 88, -1, 83, -1, 84, + -1, 85, -1, 117, -1, 118, -1, 119, -1, 120, + -1, 121, -1, 122, -1, 123, -1, 124, -1, 125, + -1, 126, -1, 127, -1, 128, -1, 91, -1, 92, + -1, 93, -1, 94, -1, 95, -1, 96, -1, 97, + -1, 98, -1, 99, -1, 100, -1, 101, -1, 102, + -1, 103, -1, 104, -1, 105, -1, 106, -1, 107, + -1, 108, -1, 109, -1, 110, -1, 97, -1, 98, + -1, 99, -1, 100, -1, 26, -1, 27, -1, 11, -1, 12, -1, 13, -1, 16, -1, 15, -1, 14, - -1, 19, -1, 22, -1, 24, -1, 174, -1, -1, - 54, 152, 4, 153, -1, -1, 174, 154, -1, -1, - 20, -1, 23, -1, 180, -1, -1, 178, 154, -1, + -1, 19, -1, 22, -1, 24, -1, 173, -1, -1, + 54, 151, 4, 152, -1, -1, 173, 153, -1, -1, + 20, -1, 23, -1, 179, -1, -1, 177, 153, -1, 42, -1, 44, -1, 43, -1, 45, -1, 47, -1, - 46, -1, 48, -1, 50, -1, -1, 149, -1, 150, - -1, 151, -1, -1, 46, -1, 48, -1, -1, 42, + 46, -1, 48, -1, 50, -1, -1, 148, -1, 149, + -1, 150, -1, -1, 46, -1, 48, -1, -1, 42, -1, 43, -1, 44, -1, 47, -1, -1, 44, -1, 42, -1, -1, 62, -1, 63, -1, 64, -1, 65, - -1, 66, -1, 61, 4, -1, 138, -1, 119, -1, - 137, -1, 120, -1, 140, -1, 141, -1, 143, -1, - 144, -1, 145, -1, 53, 4, -1, -1, 189, 188, - -1, 139, -1, 142, -1, 138, -1, 137, -1, 146, - -1, 147, -1, -1, 191, 190, -1, -1, 148, 22, - -1, -1, 53, 4, -1, -1, 155, 53, 4, -1, - 34, 22, -1, -1, 195, -1, -1, 155, 198, 197, - -1, 195, -1, 53, 4, -1, 11, -1, 12, -1, + -1, 66, -1, 61, 4, -1, 137, -1, 118, -1, + 136, -1, 119, -1, 139, -1, 140, -1, 142, -1, + 143, -1, 144, -1, 53, 4, -1, -1, 188, 187, + -1, 138, -1, 141, -1, 137, -1, 136, -1, 145, + -1, 146, -1, -1, 190, 189, -1, -1, 147, 22, + -1, -1, 53, 4, -1, -1, 154, 53, 4, -1, + 34, 22, -1, -1, 194, -1, -1, 154, 197, 196, + -1, 194, -1, 53, 4, -1, 11, -1, 12, -1, 13, -1, 16, -1, 15, -1, 14, -1, 17, -1, - 49, -1, 199, -1, 200, 176, 156, -1, 234, -1, - 157, 4, -1, 200, 152, 204, 153, 191, -1, 10, - 152, 204, 153, 191, -1, 158, 4, 159, 200, 160, - -1, 161, 4, 159, 200, 162, -1, 163, 205, 164, - -1, 163, 164, -1, 161, 163, 205, 164, 162, -1, - 161, 163, 164, 162, -1, 200, 189, -1, 200, -1, - 10, -1, 201, -1, 203, 155, 201, -1, 203, -1, - 203, 155, 39, -1, 39, -1, -1, 200, -1, 205, - 155, 200, -1, 200, 158, 208, 160, -1, 200, 158, - 160, -1, 200, 165, 22, -1, 200, 161, 208, 162, - -1, 200, 163, 208, 164, -1, 200, 163, 164, -1, - 200, 161, 163, 208, 164, 162, -1, 200, 161, 163, - 164, 162, -1, 200, 40, -1, 200, 41, -1, 200, - 234, -1, 200, 207, -1, 200, 25, -1, 172, 3, - -1, 172, 5, -1, 172, 4, -1, 172, 6, -1, - 11, 26, -1, 11, 27, -1, 173, 9, -1, 169, - 152, 206, 38, 200, 153, -1, 117, 152, 206, 246, - 153, -1, 131, 152, 206, 155, 206, 155, 206, 153, - -1, 167, 152, 206, 155, 206, 153, -1, 168, 152, - 206, 155, 206, 153, -1, 90, 170, 152, 206, 155, - 206, 153, -1, 91, 171, 152, 206, 155, 206, 153, - -1, 133, 152, 206, 155, 206, 153, -1, 134, 152, - 206, 155, 206, 155, 206, 153, -1, 135, 152, 206, - 155, 206, 155, 206, 153, -1, 208, 155, 206, -1, - 206, -1, 32, -1, 33, -1, 37, -1, -1, 202, - 234, -1, 123, 152, 211, 38, 200, 153, -1, 213, - -1, -1, 214, -1, 213, 214, -1, -1, 31, 215, - 230, -1, -1, 30, 216, 231, -1, 59, 58, 220, - -1, 177, 18, 200, -1, 177, 18, 10, -1, -1, - 179, 183, 210, 209, 206, 176, 217, 197, -1, -1, - 179, 181, 183, 210, 209, 206, 176, 218, 197, -1, - -1, 179, 182, 183, 210, 209, 200, 176, 219, 197, - -1, 179, 183, 35, 186, 211, -1, 51, 221, -1, - 55, 154, 222, -1, 22, -1, 52, 154, 22, -1, - 67, 154, 22, -1, 158, 223, 160, -1, 223, 155, - 22, -1, 22, -1, -1, 224, 155, 200, 189, 175, - -1, 200, 189, 175, -1, 224, -1, 224, 155, 39, - -1, 39, -1, -1, 187, 202, 178, 152, 225, 153, - 191, 196, 193, 192, -1, 28, -1, 163, -1, 185, - 183, 226, 227, -1, 29, -1, 164, -1, 238, 229, - -1, 184, 183, 226, -1, -1, 60, -1, 3, -1, + 49, -1, 198, -1, 199, 175, 155, -1, 233, -1, + 156, 4, -1, 199, 151, 203, 152, 190, -1, 10, + 151, 203, 152, 190, -1, 157, 4, 158, 199, 159, + -1, 160, 4, 158, 199, 161, -1, 162, 204, 163, + -1, 162, 163, -1, 160, 162, 204, 163, 161, -1, + 160, 162, 163, 161, -1, 199, 188, -1, 199, -1, + 10, -1, 200, -1, 202, 154, 200, -1, 202, -1, + 202, 154, 39, -1, 39, -1, -1, 199, -1, 204, + 154, 199, -1, 199, 157, 207, 159, -1, 199, 157, + 159, -1, 199, 164, 22, -1, 199, 160, 207, 161, + -1, 199, 162, 207, 163, -1, 199, 162, 163, -1, + 199, 160, 162, 207, 163, 161, -1, 199, 160, 162, + 163, 161, -1, 199, 40, -1, 199, 41, -1, 199, + 233, -1, 199, 206, -1, 199, 25, -1, 171, 3, + -1, 171, 5, -1, 171, 4, -1, 171, 6, -1, + 11, 26, -1, 11, 27, -1, 172, 9, -1, 168, + 151, 205, 38, 199, 152, -1, 116, 151, 205, 245, + 152, -1, 130, 151, 205, 154, 205, 154, 205, 152, + -1, 166, 151, 205, 154, 205, 152, -1, 167, 151, + 205, 154, 205, 152, -1, 89, 169, 151, 205, 154, + 205, 152, -1, 90, 170, 151, 205, 154, 205, 152, + -1, 132, 151, 205, 154, 205, 152, -1, 133, 151, + 205, 154, 205, 154, 205, 152, -1, 134, 151, 205, + 154, 205, 154, 205, 152, -1, 207, 154, 205, -1, + 205, -1, 32, -1, 33, -1, 37, -1, -1, 201, + 233, -1, 122, 151, 210, 38, 199, 152, -1, 212, + -1, -1, 213, -1, 212, 213, -1, -1, 31, 214, + 229, -1, -1, 30, 215, 230, -1, 59, 58, 219, + -1, 176, 18, 199, -1, 176, 18, 10, -1, -1, + 178, 182, 209, 208, 205, 175, 216, 196, -1, -1, + 178, 180, 182, 209, 208, 205, 175, 217, 196, -1, + -1, 178, 181, 182, 209, 208, 199, 175, 218, 196, + -1, 178, 182, 35, 185, 210, -1, 51, 220, -1, + 55, 153, 221, -1, 22, -1, 52, 153, 22, -1, + 67, 153, 22, -1, 157, 222, 159, -1, 222, 154, + 22, -1, 22, -1, -1, 223, 154, 199, 188, 174, + -1, 199, 188, 174, -1, 223, -1, 223, 154, 39, + -1, 39, -1, -1, 186, 201, 177, 151, 224, 152, + 190, 195, 192, 191, -1, 28, -1, 162, -1, 184, + 182, 225, 226, -1, 29, -1, 163, -1, 237, 228, + -1, 183, 182, 225, -1, -1, 60, -1, 3, -1, 4, -1, 9, -1, 26, -1, 27, -1, 40, -1, - 41, -1, 25, -1, 161, 208, 162, -1, 207, -1, - 58, 232, 22, 155, 22, -1, 7, -1, 8, -1, - 174, -1, 178, -1, 234, -1, 233, -1, 200, 235, - -1, 236, -1, 237, 155, 236, -1, 238, 239, -1, - 228, 239, -1, 240, 177, 241, -1, 240, 243, -1, - -1, 68, 38, 235, -1, 21, -1, 21, 68, 38, - 235, -1, 69, 237, -1, 69, 10, -1, 70, 17, - 235, -1, 70, 11, 235, 155, 17, 235, 155, 17, - 235, -1, 71, 172, 235, 155, 17, 235, 158, 242, - 160, -1, 71, 172, 235, 155, 17, 235, 158, 160, - -1, 72, 187, 202, 235, 152, 245, 153, 191, 38, - 17, 235, 73, 17, 235, -1, 73, -1, 74, -1, - 242, 172, 233, 155, 17, 235, -1, 172, 233, 155, - 17, 235, -1, 177, 248, -1, 200, 158, 235, 155, - 235, 160, -1, 244, 155, 158, 235, 155, 235, 160, - -1, 200, 189, 235, 189, -1, 17, 189, 235, 189, - -1, 245, 155, 200, 189, 235, 189, -1, 245, 155, - 17, 189, 235, 189, -1, -1, -1, 246, 155, 236, - -1, 57, 56, -1, 56, -1, 167, 200, 235, 155, - 235, -1, 168, 200, 235, 155, 235, -1, 90, 170, - 200, 235, 155, 235, -1, 91, 171, 200, 235, 155, - 235, -1, 169, 236, 38, 200, -1, 131, 236, 155, - 236, 155, 236, -1, 132, 236, 155, 200, -1, 133, - 236, 155, 236, -1, 134, 236, 155, 236, 155, 236, - -1, 135, 236, 155, 236, 155, 236, -1, 130, 244, - -1, 247, 187, 202, 235, 152, 245, 153, 191, -1, - 250, -1, 36, -1, -1, 112, 200, 194, -1, 112, - 200, 155, 11, 235, 194, -1, 113, 200, 194, -1, - 113, 200, 155, 11, 235, 194, -1, 114, 236, -1, - 249, 115, 200, 235, 194, -1, 249, 116, 236, 155, - 200, 235, 194, -1, 136, 200, 235, 155, 4, -1, - 117, 200, 235, 246, -1 + 41, -1, 25, -1, 160, 207, 161, -1, 206, -1, + 58, 231, 22, 154, 22, -1, 7, -1, 8, -1, + 173, -1, 177, -1, 233, -1, 232, -1, 199, 234, + -1, 235, -1, 236, 154, 235, -1, 237, 238, -1, + 227, 238, -1, 239, 176, 240, -1, 239, 242, -1, + -1, 21, -1, 68, 236, -1, 68, 10, -1, 69, + 17, 234, -1, 69, 11, 234, 154, 17, 234, 154, + 17, 234, -1, 70, 171, 234, 154, 17, 234, 157, + 241, 159, -1, 70, 171, 234, 154, 17, 234, 157, + 159, -1, 71, 186, 201, 234, 151, 244, 152, 190, + 38, 17, 234, 72, 17, 234, -1, 72, -1, 73, + -1, 241, 171, 232, 154, 17, 234, -1, 171, 232, + 154, 17, 234, -1, 176, 247, -1, 199, 157, 234, + 154, 234, 159, -1, 243, 154, 157, 234, 154, 234, + 159, -1, 199, 188, 234, 188, -1, 17, 188, 234, + 188, -1, 244, 154, 199, 188, 234, 188, -1, 244, + 154, 17, 188, 234, 188, -1, -1, -1, 245, 154, + 235, -1, 57, 56, -1, 56, -1, 166, 199, 234, + 154, 234, -1, 167, 199, 234, 154, 234, -1, 89, + 169, 199, 234, 154, 234, -1, 90, 170, 199, 234, + 154, 234, -1, 168, 235, 38, 199, -1, 130, 235, + 154, 235, 154, 235, -1, 131, 235, 154, 199, -1, + 132, 235, 154, 235, -1, 133, 235, 154, 235, 154, + 235, -1, 134, 235, 154, 235, 154, 235, -1, 129, + 243, -1, 246, 186, 201, 234, 151, 244, 152, 190, + -1, 249, -1, 36, -1, -1, 111, 199, 193, -1, + 111, 199, 154, 11, 234, 193, -1, 112, 199, 193, + -1, 112, 199, 154, 11, 234, 193, -1, 113, 235, + -1, 248, 114, 199, 234, 193, -1, 248, 115, 235, + 154, 199, 234, 193, -1, 135, 199, 234, 154, 4, + -1, 116, 199, 234, 245, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 1112, 1112, 1112, 1112, 1112, 1112, 1112, 1112, 1112, - 1112, 1113, 1113, 1113, 1113, 1113, 1113, 1114, 1114, 1114, - 1114, 1114, 1114, 1115, 1115, 1115, 1115, 1115, 1115, 1118, - 1118, 1119, 1119, 1120, 1120, 1121, 1121, 1122, 1122, 1126, - 1126, 1127, 1127, 1128, 1128, 1129, 1129, 1130, 1130, 1131, - 1131, 1132, 1132, 1133, 1134, 1139, 1140, 1140, 1140, 1140, - 1140, 1142, 1142, 1142, 1143, 1143, 1145, 1146, 1150, 1154, - 1159, 1159, 1161, 1162, 1167, 1173, 1174, 1175, 1176, 1177, - 1181, 1182, 1183, 1187, 1188, 1189, 1190, 1194, 1195, 1196, - 1200, 1201, 1202, 1203, 1204, 1208, 1209, 1210, 1213, 1214, - 1215, 1216, 1217, 1218, 1219, 1226, 1227, 1228, 1229, 1230, - 1231, 1232, 1233, 1234, 1235, 1239, 1240, 1245, 1246, 1247, - 1248, 1249, 1250, 1253, 1254, 1259, 1260, 1267, 1268, 1274, - 1275, 1284, 1292, 1293, 1298, 1299, 1300, 1305, 1318, 1318, - 1318, 1318, 1318, 1318, 1318, 1321, 1325, 1329, 1336, 1341, - 1349, 1378, 1403, 1408, 1418, 1428, 1432, 1442, 1449, 1458, - 1465, 1470, 1475, 1482, 1483, 1490, 1497, 1505, 1511, 1523, - 1551, 1567, 1594, 1622, 1648, 1668, 1694, 1714, 1726, 1733, - 1799, 1809, 1819, 1825, 1835, 1841, 1851, 1856, 1861, 1874, - 1886, 1908, 1916, 1922, 1933, 1938, 1943, 1949, 1955, 1964, - 1968, 1976, 1976, 1979, 1979, 1982, 1994, 2015, 2020, 2028, - 2029, 2033, 2033, 2037, 2037, 2040, 2043, 2067, 2079, 2078, - 2090, 2089, 2099, 2098, 2109, 2149, 2152, 2158, 2168, 2172, - 2177, 2179, 2184, 2189, 2198, 2208, 2219, 2223, 2232, 2241, - 2246, 2375, 2375, 2377, 2386, 2386, 2388, 2393, 2405, 2409, - 2414, 2418, 2422, 2426, 2430, 2434, 2438, 2442, 2446, 2471, - 2475, 2485, 2489, 2493, 2498, 2505, 2505, 2511, 2520, 2525, - 2530, 2534, 2543, 2552, 2561, 2565, 2569, 2574, 2581, 2588, - 2592, 2597, 2607, 2626, 2635, 2720, 2724, 2731, 2742, 2755, - 2765, 2776, 2786, 2797, 2805, 2815, 2822, 2825, 2826, 2833, - 2837, 2842, 2858, 2875, 2889, 2903, 2915, 2923, 2930, 2936, - 2942, 2948, 2963, 3053, 3058, 3062, 3069, 3076, 3084, 3091, - 3099, 3107, 3121, 3138, 3146 + 0, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, + 1111, 1112, 1112, 1112, 1112, 1112, 1112, 1113, 1113, 1113, + 1113, 1113, 1113, 1114, 1114, 1114, 1114, 1114, 1114, 1117, + 1117, 1118, 1118, 1119, 1119, 1120, 1120, 1121, 1121, 1125, + 1125, 1126, 1126, 1127, 1127, 1128, 1128, 1129, 1129, 1130, + 1130, 1131, 1131, 1132, 1133, 1138, 1139, 1139, 1139, 1139, + 1139, 1141, 1141, 1141, 1142, 1142, 1144, 1145, 1149, 1153, + 1158, 1158, 1160, 1161, 1166, 1172, 1173, 1174, 1175, 1176, + 1180, 1181, 1182, 1186, 1187, 1188, 1189, 1193, 1194, 1195, + 1199, 1200, 1201, 1202, 1203, 1207, 1208, 1209, 1212, 1213, + 1214, 1215, 1216, 1217, 1218, 1225, 1226, 1227, 1228, 1229, + 1230, 1231, 1232, 1233, 1234, 1238, 1239, 1244, 1245, 1246, + 1247, 1248, 1249, 1252, 1253, 1258, 1259, 1266, 1267, 1273, + 1274, 1283, 1291, 1292, 1297, 1298, 1299, 1304, 1317, 1317, + 1317, 1317, 1317, 1317, 1317, 1320, 1324, 1328, 1335, 1340, + 1348, 1377, 1402, 1407, 1417, 1427, 1431, 1441, 1448, 1457, + 1464, 1469, 1474, 1481, 1482, 1489, 1496, 1504, 1510, 1522, + 1550, 1566, 1593, 1621, 1647, 1667, 1693, 1713, 1725, 1732, + 1798, 1808, 1818, 1824, 1834, 1840, 1850, 1855, 1860, 1873, + 1885, 1907, 1915, 1921, 1932, 1937, 1942, 1948, 1954, 1963, + 1967, 1975, 1975, 1978, 1978, 1981, 1993, 2014, 2019, 2027, + 2028, 2032, 2032, 2036, 2036, 2039, 2042, 2066, 2078, 2077, + 2089, 2088, 2098, 2097, 2108, 2148, 2151, 2157, 2167, 2171, + 2176, 2178, 2183, 2188, 2197, 2207, 2218, 2222, 2231, 2240, + 2245, 2374, 2374, 2376, 2385, 2385, 2387, 2392, 2404, 2408, + 2413, 2417, 2421, 2425, 2429, 2433, 2437, 2441, 2445, 2470, + 2474, 2484, 2488, 2492, 2497, 2504, 2504, 2510, 2519, 2524, + 2529, 2533, 2542, 2551, 2560, 2564, 2572, 2579, 2583, 2588, + 2598, 2617, 2626, 2711, 2715, 2722, 2733, 2746, 2756, 2767, + 2777, 2788, 2796, 2806, 2813, 2816, 2817, 2824, 2828, 2833, + 2849, 2866, 2880, 2894, 2906, 2914, 2921, 2927, 2933, 2939, + 2954, 3044, 3049, 3053, 3060, 3067, 3075, 3082, 3090, 3098, + 3112, 3129, 3137 }; #endif @@ -1881,27 +1877,26 @@ "EXTERNAL", "TARGET", "TRIPLE", "ALIGN", "ADDRSPACE", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK", "FASTCC_TOK", "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", - "DATALAYOUT", "UNWINDS", "RET", "BR", "SWITCH", "INVOKE", "UNWIND", - "UNREACHABLE", "ADD", "SUB", "MUL", "UDIV", "SDIV", "FDIV", "UREM", - "SREM", "FREM", "AND", "OR", "XOR", "SHL", "LSHR", "ASHR", "ICMP", - "FCMP", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT", "UGT", "ULE", - "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD", "UNO", "UEQ", - "UNE", "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", - "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT", "BITCAST", "UITOFP", - "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR", "PTRTOINT", "PHI_TOK", - "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR", - "GETRESULT", "SIGNEXT", "ZEROEXT", "NORETURN", "INREG", "SRET", - "NOUNWIND", "NOALIAS", "BYVAL", "NEST", "READNONE", "READONLY", "GC", - "DEFAULT", "HIDDEN", "PROTECTED", "'('", "')'", "'='", "','", "'*'", - "'\\\\'", "'['", "'x'", "']'", "'<'", "'>'", "'{'", "'}'", "'c'", - "$accept", "ArithmeticOps", "LogicalOps", "CastOps", "IPredicates", - "FPredicates", "IntType", "FPType", "LocalName", "OptLocalName", - "OptAddrSpace", "OptLocalAssign", "GlobalName", "OptGlobalAssign", - "GlobalAssign", "GVInternalLinkage", "GVExternalLinkage", - "GVVisibilityStyle", "FunctionDeclareLinkage", "FunctionDefineLinkage", - "AliasLinkage", "OptCallingConv", "ParamAttr", "OptParamAttrs", - "FuncAttr", "OptFuncAttrs", "OptGC", "OptAlign", "OptCAlign", - "SectionString", "OptSection", "GlobalVarAttributes", + "DATALAYOUT", "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", + "ADD", "SUB", "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM", + "AND", "OR", "XOR", "SHL", "LSHR", "ASHR", "ICMP", "FCMP", "EQ", "NE", + "SLT", "SGT", "SLE", "SGE", "ULT", "UGT", "ULE", "UGE", "OEQ", "ONE", + "OLT", "OGT", "OLE", "OGE", "ORD", "UNO", "UEQ", "UNE", "MALLOC", + "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "TRUNC", "ZEXT", + "SEXT", "FPTRUNC", "FPEXT", "BITCAST", "UITOFP", "SITOFP", "FPTOUI", + "FPTOSI", "INTTOPTR", "PTRTOINT", "PHI_TOK", "SELECT", "VAARG", + "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR", "GETRESULT", + "SIGNEXT", "ZEROEXT", "NORETURN", "INREG", "SRET", "NOUNWIND", "NOALIAS", + "BYVAL", "NEST", "READNONE", "READONLY", "GC", "DEFAULT", "HIDDEN", + "PROTECTED", "'('", "')'", "'='", "','", "'*'", "'\\\\'", "'['", "'x'", + "']'", "'<'", "'>'", "'{'", "'}'", "'c'", "$accept", "ArithmeticOps", + "LogicalOps", "CastOps", "IPredicates", "FPredicates", "IntType", + "FPType", "LocalName", "OptLocalName", "OptAddrSpace", "OptLocalAssign", + "GlobalName", "OptGlobalAssign", "GlobalAssign", "GVInternalLinkage", + "GVExternalLinkage", "GVVisibilityStyle", "FunctionDeclareLinkage", + "FunctionDefineLinkage", "AliasLinkage", "OptCallingConv", "ParamAttr", + "OptParamAttrs", "FuncAttr", "OptFuncAttrs", "OptGC", "OptAlign", + "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes", "GlobalVarAttribute", "PrimType", "Types", "ArgType", "ResultTypes", "ArgTypeList", "ArgTypeListI", "TypeListI", "ConstVal", "ConstExpr", "ConstVector", "GlobalType", "ThreadLocal", "AliaseeRef", "Module", @@ -1936,47 +1931,47 @@ 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, - 405, 406, 40, 41, 61, 44, 42, 92, 91, 120, - 93, 60, 62, 123, 125, 99 + 405, 40, 41, 61, 44, 42, 92, 91, 120, 93, + 60, 62, 123, 125, 99 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 166, 167, 167, 167, 167, 167, 167, 167, 167, - 167, 168, 168, 168, 168, 168, 168, 169, 169, 169, + 0, 165, 166, 166, 166, 166, 166, 166, 166, 166, + 166, 167, 167, 167, 167, 167, 167, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 170, - 170, 170, 170, 170, 170, 170, 170, 170, 170, 171, - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 172, 173, 173, 173, 173, - 173, 174, 174, 174, 175, 175, 176, 176, 177, 177, - 178, 178, 179, 179, 180, 181, 181, 181, 181, 181, - 182, 182, 182, 183, 183, 183, 183, 184, 184, 184, - 185, 185, 185, 185, 185, 186, 186, 186, 187, 187, - 187, 187, 187, 187, 187, 188, 188, 188, 188, 188, - 188, 188, 188, 188, 188, 189, 189, 190, 190, 190, - 190, 190, 190, 191, 191, 192, 192, 193, 193, 194, - 194, 195, 196, 196, 197, 197, 198, 198, 199, 199, - 199, 199, 199, 199, 199, 200, 200, 200, 200, 200, - 200, 200, 200, 200, 200, 200, 200, 200, 201, 202, - 202, 203, 203, 204, 204, 204, 204, 205, 205, 206, - 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, + 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, + 170, 170, 170, 170, 170, 171, 172, 172, 172, 172, + 172, 173, 173, 173, 174, 174, 175, 175, 176, 176, + 177, 177, 178, 178, 179, 180, 180, 180, 180, 180, + 181, 181, 181, 182, 182, 182, 182, 183, 183, 183, + 184, 184, 184, 184, 184, 185, 185, 185, 186, 186, + 186, 186, 186, 186, 186, 187, 187, 187, 187, 187, + 187, 187, 187, 187, 187, 188, 188, 189, 189, 189, + 189, 189, 189, 190, 190, 191, 191, 192, 192, 193, + 193, 194, 195, 195, 196, 196, 197, 197, 198, 198, + 198, 198, 198, 198, 198, 199, 199, 199, 199, 199, + 199, 199, 199, 199, 199, 199, 199, 199, 200, 201, + 201, 202, 202, 203, 203, 203, 203, 204, 204, 205, + 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, + 205, 205, 205, 205, 205, 205, 205, 205, 205, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 207, - 207, 207, 207, 207, 207, 207, 207, 207, 207, 208, - 208, 209, 209, 210, 210, 211, 211, 212, 212, 213, - 213, 215, 214, 216, 214, 214, 214, 214, 217, 214, - 218, 214, 219, 214, 214, 214, 214, 220, 221, 221, - 222, 223, 223, 223, 224, 224, 225, 225, 225, 225, - 226, 227, 227, 228, 229, 229, 230, 231, 232, 232, - 233, 233, 233, 233, 233, 233, 233, 233, 233, 233, - 233, 234, 234, 234, 234, 235, 235, 236, 237, 237, - 238, 238, 239, 240, 240, 240, 240, 240, 241, 241, - 241, 241, 241, 241, 241, 241, 241, 242, 242, 243, - 244, 244, 245, 245, 245, 245, 245, 246, 246, 247, - 247, 248, 248, 248, 248, 248, 248, 248, 248, 248, - 248, 248, 248, 248, 249, 249, 250, 250, 250, 250, - 250, 250, 250, 250, 250 + 207, 208, 208, 209, 209, 210, 210, 211, 211, 212, + 212, 214, 213, 215, 213, 213, 213, 213, 216, 213, + 217, 213, 218, 213, 213, 213, 213, 219, 220, 220, + 221, 222, 222, 222, 223, 223, 224, 224, 224, 224, + 225, 226, 226, 227, 228, 228, 229, 230, 231, 231, + 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, + 232, 233, 233, 233, 233, 234, 234, 235, 236, 236, + 237, 237, 238, 239, 239, 239, 240, 240, 240, 240, + 240, 240, 240, 240, 240, 241, 241, 242, 243, 243, + 244, 244, 244, 244, 244, 245, 245, 246, 246, 247, + 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, + 247, 247, 248, 248, 249, 249, 249, 249, 249, 249, + 249, 249, 249 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ @@ -2009,12 +2004,12 @@ 10, 1, 1, 4, 1, 1, 2, 3, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 5, 1, 1, 1, 1, 1, 1, 2, 1, 3, - 2, 2, 3, 2, 0, 3, 1, 4, 2, 2, - 3, 9, 9, 8, 14, 1, 1, 6, 5, 2, - 6, 7, 4, 4, 6, 6, 0, 0, 3, 2, - 1, 5, 5, 6, 6, 4, 6, 4, 4, 6, - 6, 2, 8, 1, 1, 0, 3, 6, 3, 6, - 2, 5, 7, 5, 4 + 2, 2, 3, 2, 0, 1, 2, 2, 3, 9, + 9, 8, 14, 1, 1, 6, 5, 2, 6, 7, + 4, 4, 6, 6, 0, 0, 3, 2, 1, 5, + 5, 6, 6, 4, 6, 4, 4, 6, 6, 2, + 8, 1, 1, 0, 3, 6, 3, 6, 2, 5, + 7, 5, 4 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state @@ -2031,160 +2026,158 @@ 226, 227, 215, 261, 262, 217, 138, 139, 140, 143, 142, 141, 144, 145, 0, 0, 0, 0, 263, 264, 146, 216, 148, 204, 204, 95, 203, 0, 98, 98, - 276, 0, 271, 69, 244, 245, 246, 270, 228, 229, - 232, 0, 166, 149, 0, 0, 0, 0, 155, 167, - 0, 0, 166, 0, 0, 0, 97, 96, 0, 201, - 202, 0, 0, 99, 100, 101, 102, 103, 0, 247, - 0, 0, 0, 315, 273, 0, 230, 165, 115, 161, - 163, 0, 0, 0, 0, 0, 0, 154, 0, 0, - 147, 0, 0, 160, 0, 159, 0, 224, 138, 139, - 140, 143, 142, 141, 0, 0, 67, 67, 104, 0, - 241, 242, 243, 0, 250, 251, 252, 257, 253, 254, - 255, 256, 248, 2, 3, 4, 5, 6, 7, 8, - 9, 10, 14, 15, 16, 11, 12, 13, 0, 0, - 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 0, 0, 0, 0, 0, 0, 0, - 0, 259, 266, 265, 275, 314, 300, 0, 0, 0, - 0, 98, 285, 286, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 272, 98, 289, 0, 313, 231, 158, 0, 123, 67, - 67, 157, 0, 168, 0, 123, 67, 67, 0, 205, - 186, 187, 182, 184, 183, 185, 188, 181, 177, 178, - 0, 0, 0, 0, 180, 179, 218, 0, 277, 249, - 0, 29, 30, 31, 32, 33, 34, 35, 36, 37, - 38, 0, 53, 54, 49, 50, 51, 52, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 0, 0, - 0, 0, 0, 0, 200, 0, 0, 0, 0, 299, - 279, 67, 268, 278, 0, 0, 55, 0, 0, 0, - 0, 129, 129, 320, 67, 67, 311, 0, 0, 0, - 0, 0, 67, 67, 67, 0, 0, 0, 0, 0, - 106, 108, 107, 105, 109, 110, 111, 112, 113, 116, - 164, 162, 151, 152, 153, 156, 66, 150, 220, 222, - 0, 170, 0, 0, 0, 174, 0, 171, 134, 239, - 0, 0, 0, 297, 0, 0, 0, 0, 0, 258, - 0, 0, 0, 267, 0, 0, 280, 0, 0, 67, - 67, 0, 316, 0, 318, 297, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, - 114, 120, 119, 117, 118, 121, 122, 124, 134, 134, - 0, 169, 155, 167, 0, 172, 173, 0, 219, 238, - 115, 236, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 199, 0, 0, 0, 269, 0, 0, 0, 0, - 0, 0, 0, 0, 324, 0, 0, 0, 307, 308, - 0, 0, 0, 0, 0, 305, 0, 129, 0, 221, - 223, 67, 176, 0, 0, 0, 136, 134, 65, 0, - 123, 260, 0, 0, 190, 0, 0, 0, 0, 0, - 0, 0, 67, 0, 0, 296, 0, 0, 129, 130, - 129, 0, 0, 0, 0, 0, 323, 301, 302, 296, - 0, 321, 67, 206, 175, 131, 137, 135, 64, 235, - 237, 115, 132, 0, 0, 298, 0, 196, 0, 0, - 192, 193, 189, 0, 0, 115, 115, 0, 303, 304, - 317, 319, 0, 0, 306, 309, 310, 0, 129, 65, - 133, 127, 194, 195, 0, 0, 0, 0, 0, 0, - 0, 123, 0, 290, 0, 123, 322, 234, 0, 125, - 191, 197, 198, 0, 283, 0, 0, 106, 108, 115, - 115, 0, 115, 115, 291, 312, 128, 0, 240, 281, - 0, 282, 0, 293, 292, 0, 0, 0, 126, 0, - 0, 0, 115, 115, 0, 0, 0, 295, 294, 288, - 0, 0, 287, 0, 284 + 275, 271, 69, 244, 245, 246, 270, 228, 229, 232, + 0, 166, 149, 0, 0, 0, 0, 155, 167, 0, + 0, 166, 0, 0, 0, 97, 96, 0, 201, 202, + 0, 0, 99, 100, 101, 102, 103, 0, 247, 0, + 313, 273, 0, 230, 165, 115, 161, 163, 0, 0, + 0, 0, 0, 0, 154, 0, 0, 147, 0, 0, + 160, 0, 159, 0, 224, 138, 139, 140, 143, 142, + 141, 0, 0, 67, 67, 104, 0, 241, 242, 243, + 312, 298, 0, 0, 0, 0, 98, 283, 284, 2, + 3, 4, 5, 6, 7, 8, 9, 10, 14, 15, + 16, 11, 12, 13, 0, 0, 0, 0, 0, 0, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 272, 98, 287, 0, 311, 231, 158, 0, + 123, 67, 67, 157, 0, 168, 0, 123, 67, 67, + 0, 205, 186, 187, 182, 184, 183, 185, 188, 181, + 177, 178, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 180, 179, 218, 0, + 297, 277, 67, 268, 276, 0, 0, 55, 0, 0, + 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 0, 53, 54, 49, 50, 51, 52, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 0, 129, 129, + 318, 67, 67, 309, 0, 0, 0, 0, 0, 67, + 67, 67, 0, 0, 0, 0, 0, 106, 108, 107, + 105, 109, 110, 111, 112, 113, 116, 164, 162, 151, + 152, 153, 156, 66, 150, 220, 222, 0, 0, 0, + 0, 0, 0, 0, 0, 170, 200, 0, 0, 0, + 174, 0, 171, 0, 0, 0, 134, 239, 250, 251, + 252, 257, 253, 254, 255, 256, 248, 0, 259, 266, + 265, 267, 0, 0, 278, 0, 0, 67, 67, 0, + 314, 0, 316, 295, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 67, 0, 114, 120, + 119, 117, 118, 121, 122, 124, 134, 134, 0, 0, + 0, 295, 0, 0, 0, 0, 0, 169, 155, 167, + 0, 172, 173, 0, 0, 0, 0, 219, 238, 115, + 236, 0, 249, 0, 0, 269, 0, 0, 0, 0, + 0, 0, 0, 0, 322, 0, 0, 0, 305, 306, + 0, 0, 0, 0, 0, 303, 0, 129, 0, 221, + 223, 67, 0, 0, 0, 0, 0, 0, 0, 199, + 176, 0, 0, 0, 0, 0, 0, 136, 134, 65, + 0, 123, 0, 258, 0, 0, 294, 0, 0, 129, + 130, 129, 0, 0, 0, 0, 0, 0, 321, 299, + 300, 294, 0, 319, 67, 206, 0, 0, 190, 0, + 0, 0, 0, 175, 0, 0, 67, 131, 137, 135, + 64, 235, 237, 115, 132, 0, 0, 0, 115, 115, + 0, 301, 302, 315, 317, 296, 0, 0, 304, 307, + 308, 0, 129, 0, 0, 0, 196, 0, 0, 192, + 193, 189, 65, 133, 127, 260, 0, 0, 0, 0, + 123, 0, 288, 0, 123, 320, 194, 195, 0, 0, + 0, 234, 0, 125, 0, 281, 0, 0, 106, 108, + 115, 115, 0, 115, 115, 289, 310, 191, 197, 198, + 128, 0, 240, 279, 0, 280, 0, 291, 290, 0, + 0, 0, 126, 0, 0, 0, 115, 115, 0, 0, + 0, 293, 292, 286, 0, 0, 285, 0, 282 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { - -1, 218, 219, 220, 301, 318, 164, 165, 78, 539, - 113, 12, 79, 14, 15, 40, 41, 42, 47, 53, - 118, 128, 369, 256, 437, 372, 608, 589, 412, 496, - 571, 448, 497, 80, 166, 139, 156, 140, 141, 110, - 324, 221, 325, 121, 87, 157, 16, 17, 18, 20, - 19, 388, 438, 439, 62, 23, 60, 101, 451, 452, - 129, 172, 54, 96, 55, 48, 290, 222, 82, 224, - 332, 333, 56, 92, 93, 250, 596, 134, 346, 557, - 456, 251, 252, 253, 254 + -1, 263, 264, 265, 290, 307, 161, 162, 78, 531, + 112, 12, 79, 14, 15, 40, 41, 42, 47, 53, + 117, 127, 336, 228, 415, 339, 602, 583, 390, 487, + 564, 437, 488, 80, 163, 136, 153, 137, 138, 109, + 356, 378, 357, 120, 87, 154, 16, 17, 18, 20, + 19, 366, 416, 417, 62, 23, 60, 100, 440, 441, + 128, 169, 54, 95, 55, 48, 443, 379, 82, 381, + 273, 274, 56, 91, 92, 222, 587, 131, 313, 540, + 454, 223, 224, 225, 226 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -536 +#define YYPACT_NINF -561 static const yytype_int16 yypact[] = { - 369, -536, -536, -536, -536, -536, -536, -536, 39, -128, - -20, -82, 67, -9, 258, -536, 177, 506, -536, 239, - 226, 57, 78, -536, 22, 214, -536, 1572, -536, -536, - -536, -536, -536, -536, -536, -536, -536, -536, -536, -536, - -35, -35, 244, -536, -536, -536, -536, -35, -536, -536, - -536, -536, -536, -35, 15, -536, -2, 221, 232, 235, - -536, -536, -536, -536, -536, 99, -536, -536, -536, -536, - -536, -536, -536, -536, 262, 268, 8, 35, -536, -536, - -536, -26, -536, 225, 225, 265, -536, 128, 233, 233, - 208, 254, -536, 256, -536, -536, -536, -536, -536, -536, - -536, -22, 1126, -536, 161, 165, 815, 99, -536, -26, - -91, 174, 1126, 171, 128, 128, -536, -536, 1372, -536, - -536, 1612, 324, -536, -536, -536, -536, -536, 1652, -536, - -6, 293, 906, 1867, -536, 313, -536, -536, -26, -536, - 181, 184, 1692, 1692, 179, -84, 1692, -536, 338, 190, - -536, 1612, 1692, 99, 192, -26, 410, -536, 223, 336, - 343, 347, 351, 352, 204, 353, 1182, 309, -536, 126, - -536, -536, -536, 906, -536, -536, -536, -536, -536, -536, - -536, -536, 304, -536, -536, -536, -536, -536, -536, -536, - -536, -536, -536, -536, -536, -536, -536, -536, 511, 491, - 216, -536, -536, -536, -536, -536, -536, -536, -536, -536, - -536, -536, -536, 218, 219, 220, 222, 1612, 231, 234, - 238, -536, -536, -536, -536, -536, -536, 310, 1732, 50, - 364, 233, -536, -536, 511, 491, 1692, 1692, 1692, 1692, - 1692, 1692, 1692, 1692, 1692, 1692, 1692, 1692, 1692, 1692, - -536, 233, -536, 79, -536, -536, 210, 1452, -536, -25, - -31, -536, 242, -26, 252, -536, 309, 2, 1372, -536, - -536, -536, -536, -536, -536, -536, -536, -536, -536, -536, - 1412, 1772, 855, 362, -536, -536, -536, 259, -536, -536, - 363, -536, -536, -536, -536, -536, -536, -536, -536, -536, - -536, 260, -536, -536, -536, -536, -536, -536, -536, -536, - -536, -536, -536, -536, -536, -536, -536, -536, 263, 1612, - 1612, 1612, 1612, 1612, -536, -42, 1612, 1612, 1612, -536, - 99, 766, -536, 255, 906, 906, -536, 906, 1652, 1692, - 1692, 20, 45, -536, 766, -29, 264, 270, 271, 272, - 276, 281, 766, 766, 766, 385, 1652, 1692, 1692, 433, - -536, -536, -536, -536, -536, -536, -536, -536, -536, -536, - -536, -536, -37, -536, -536, -536, -536, -37, -536, 171, - 404, -536, -7, 1080, -30, -536, -66, -536, 290, 1492, - 294, 1612, 1612, -536, 295, 297, 298, 299, 1612, -536, - 300, 305, 421, -536, 1692, 306, -536, 308, 906, 766, - 766, 10, -536, 26, -536, -536, 906, 311, 1692, 1692, - 1692, 1692, 1692, 315, 316, 317, 1692, 906, 766, 318, - -536, -536, -536, -536, -536, -536, -536, -536, 290, 290, - 1692, -536, 312, 1035, -47, -536, -536, 42, -536, -536, - -26, 321, 325, 444, 322, 327, 133, 1612, 1612, 1612, - 1612, -536, 1612, 1612, 1692, -536, 462, 463, 331, 329, - 330, 906, 482, 906, 332, 333, 906, 334, -26, -536, - 335, 337, 490, 906, 906, -26, 344, 340, 1692, -536, - -536, 38, -536, 341, 475, 498, -536, 290, 115, 1532, - -536, -536, 1612, 1612, -536, 1692, 349, 354, 356, 360, - 355, 366, 53, 906, 906, 1812, 906, 906, 340, -536, - 340, 906, 361, 1692, 1692, 1692, -536, -536, -536, 1812, - 468, -536, 766, -536, -536, -536, -536, -536, -536, -536, - -536, -26, 5, 374, 380, -536, 1612, -536, 1612, 1612, - -536, -536, -536, 367, 376, 33, -26, 166, -536, -536, - -536, -536, 375, 906, -536, -536, -536, 170, 340, 115, - -536, 485, -536, -536, 386, 387, 388, 525, 3, 623, - 623, -536, 1852, -536, 383, -536, -536, -536, 540, 397, - -536, -536, -536, 906, -536, 1323, 7, 396, 398, -536, - -536, 27, 33, -26, -536, -37, -536, 527, -536, -536, - 400, -536, 1323, 210, 210, 535, 623, 623, -536, 536, - 401, 906, -536, -536, 906, 542, 489, 210, 210, -536, - 906, 547, -536, 906, -536 + 284, -561, -561, -561, -561, -561, -561, -561, -34, -121, + 14, -63, 101, -22, 17, -561, 127, 883, -561, 22, + 162, 10, 23, -561, 12, 158, -561, 1464, -561, -561, + -561, -561, -561, -561, -561, -561, -561, -561, -561, -561, + -46, -46, 176, -561, -561, -561, -561, -46, -561, -561, + -561, -561, -561, -46, 200, -561, -10, 209, 219, 234, + -561, -561, -561, -561, -561, 124, -561, -561, -561, -561, + -561, -561, -561, -561, 272, 275, 2, 126, -561, -561, + -561, 28, -561, 243, 243, 196, -561, 165, 33, 33, + -561, -561, 215, -561, -561, -561, -561, -561, -561, -561, + -73, 1059, -561, 129, 132, 506, 124, -561, 28, -111, + 134, 1059, 137, 165, 165, -561, -561, 1014, -561, -561, + 1504, 292, -561, -561, -561, -561, -561, 1562, -561, -6, + 1843, -561, 278, -561, -561, 28, -561, 147, 153, 1620, + 1620, 148, -110, 1620, -561, 309, 164, -561, 1504, 1620, + 124, 166, 28, 388, -561, 342, 310, 311, 314, 316, + 317, 156, 322, 1115, 279, -561, 16, -561, -561, -561, + -561, -561, 281, 1660, 20, 327, 33, -561, -561, -561, + -561, -561, -561, -561, -561, -561, -561, -561, -561, -561, + -561, -561, -561, -561, 511, 787, 1620, 1620, 1620, 1620, + -561, -561, -561, -561, -561, -561, -561, -561, -561, -561, + -561, -561, 1620, 1620, 1620, 1620, 1620, 1620, 1620, 1620, + 1620, 1620, -561, 33, -561, -60, -561, -561, 434, 1345, + -561, -7, -33, -561, 181, 28, 192, -561, 279, -16, + 1014, -561, -561, -561, -561, -561, -561, -561, -561, -561, + -561, -561, 511, 787, 198, 199, 201, 203, 204, 1385, + 1678, 609, 329, 207, 208, 210, -561, -561, -561, 211, + -561, 124, 702, -561, 206, 841, 841, -561, 841, 1562, + -561, -561, -561, -561, -561, -561, -561, -561, -561, -561, + 1620, -561, -561, -561, -561, -561, -561, -561, -561, -561, + -561, -561, -561, -561, -561, -561, -561, 1620, 100, 114, + -561, 702, -31, 222, 225, 227, 228, 235, 239, 702, + 702, 702, 325, 1562, 1620, 1620, 360, -561, -561, -561, + -561, -561, -561, -561, -561, -561, -561, -561, -561, -96, + -561, -561, -561, -561, -96, -561, 137, 361, 247, 252, + 1504, 1504, 1504, 1504, 1504, -561, -561, -54, 788, -88, + -561, -85, -561, 1504, 1504, 1504, 250, 1406, -561, -561, + -561, -561, -561, -561, -561, -561, 345, 1504, -561, -561, + -561, -561, 1620, 255, -561, 259, 841, 702, 702, 4, + -561, 5, -561, -561, 841, 249, 1620, 1620, 1620, 1620, + 1620, 261, 262, 263, 1620, 841, 702, 266, -561, -561, + -561, -561, -561, -561, -561, -561, 250, 250, 1620, 1504, + 1504, -561, 269, 274, 276, 277, 1504, -561, 265, 969, + -83, -561, -561, 282, 283, 391, -5, -561, -561, 28, + 285, 289, -561, 413, -78, -561, 426, 427, 294, 293, + 295, 841, 442, 841, 296, 299, 841, 300, 28, -561, + 301, 302, 444, 841, 841, 28, 306, 305, 1620, -561, + -561, -45, 307, 308, 94, 1504, 1504, 1504, 1504, -561, + -561, 312, 1504, 1504, 1620, 438, 463, -561, 250, 1746, + 1446, -561, 315, -561, 841, 841, 1718, 841, 841, 305, + -561, 305, 1620, 841, 318, 1620, 1620, 1620, -561, -561, + -561, 1718, 415, -561, 702, -561, 1504, 1504, -561, 320, + 323, 324, 328, -561, 331, 332, -30, -561, -561, -561, + -561, -561, -561, 28, 81, 455, 334, 333, 123, 28, + 95, -561, -561, -561, -561, -561, 335, 841, -561, -561, + -561, 98, 305, 339, 343, 1504, -561, 1504, 1504, -561, + -561, -561, 1746, -561, 433, -561, 479, -4, 560, 560, + -561, 1736, -561, 341, -561, -561, -561, -561, 346, 349, + 351, -561, 500, 358, 841, -561, 1255, -1, 355, 356, + -561, -561, 87, 123, 28, -561, -96, -561, -561, -561, + -561, 489, -561, -561, 370, -561, 1255, 434, 434, 495, + 560, 560, -561, 498, 373, 841, -561, -561, 841, 514, + 460, 434, 434, -561, 841, 516, -561, 841, -561 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { - -536, 434, 435, 437, 339, 346, -229, -536, 0, -3, - -126, 478, 13, -536, -536, -536, -536, 28, -536, -536, - -536, -207, -536, -444, -536, -263, -536, -536, -337, 30, - -536, -407, -536, -536, -24, 319, -108, -536, 466, 473, - -81, -150, -247, 88, 229, 314, -536, -536, 557, -536, - -536, -536, -536, -536, -536, -536, -536, -536, -536, -536, - 494, -536, -536, -536, -536, -536, -536, -535, -70, 104, - -234, -536, -536, 528, -536, -536, -536, -536, -536, 56, - 198, -536, -536, -536, -536 + -561, 406, 407, 408, 298, 303, -173, -561, 0, -15, + -150, 454, 8, -561, -561, -561, -561, 189, -561, -561, + -561, -149, -561, -409, -561, -234, -561, -561, -289, 24, + -561, -404, -561, -561, -26, 330, -122, -561, 443, 452, + -92, -159, -226, 102, 183, 321, -561, -561, 548, -561, + -561, -561, -561, -561, -561, -561, -561, -561, -561, -561, + 477, -561, -561, -561, -561, -561, -561, -560, -76, 46, + -105, -561, -561, 519, -561, -561, -561, -561, -561, 61, + 160, -561, -561, -561, -561 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If @@ -2194,414 +2187,406 @@ #define YYTABLE_NINF -209 static const yytype_int16 yytable[] = { - 11, 337, 377, 81, 343, 414, 498, 347, 348, 349, - 350, 351, 105, 13, 336, 355, 284, 11, 336, 90, - 169, 471, 170, 111, 338, 111, 24, 94, 111, 111, - 13, 489, 490, 382, 384, 386, 90, 473, 25, 494, - 167, 286, 63, 64, 356, 107, 66, 67, 68, 69, - 70, 71, 72, 109, 1, 2, 111, 3, 4, 5, - 610, 334, 223, 472, 146, 615, 91, 335, 83, 84, - 266, 146, 26, 147, 111, 88, 494, 620, 138, 472, - 262, 89, 109, 91, 73, 27, 269, -144, 138, 398, - 537, 21, 111, 11, 155, 495, 285, 569, 446, 111, - 431, 432, 433, 223, 155, 434, 22, 111, 398, 435, - 436, 579, 580, 398, 37, 38, 39, 493, 259, 260, - 399, 112, 263, 112, 429, 398, 112, 112, 267, 416, - -67, 374, 445, 135, 1, 373, 444, 3, 136, 5, - 378, 379, 431, 432, 433, 28, 2, 434, 398, 4, - 531, 435, 436, 441, 112, 613, 614, 171, 616, 617, - 119, 120, 95, 594, 431, 432, 433, 611, 359, 434, - 465, 106, 112, 435, 436, 411, -67, 43, 627, 628, - 59, 560, 287, 561, 477, -144, 479, 480, 481, -144, - 112, 533, 74, 75, 357, 358, 76, 112, 77, 108, - 413, -67, 151, 152, 331, 112, 552, 272, 273, 274, - 275, 57, 341, 342, 331, 344, 345, 331, 331, 331, - 331, 331, 352, 353, 354, 331, -55, -55, -55, -55, - 408, 586, 58, 138, 360, 361, 61, 542, 393, 394, - 395, 396, 397, 98, 155, 400, 401, 402, 427, 270, - 271, 102, 362, 363, 99, 364, 365, 100, 366, 367, - 368, 223, 86, 359, 223, 223, 103, 223, 49, 50, - 51, 545, 104, 52, 223, 1, 131, 288, 3, 85, - 5, 86, 223, 223, 223, 45, 504, 46, 505, 564, - 565, 566, 132, 284, 122, 123, 124, 125, 126, 127, - 29, 30, 31, 32, 33, 34, 35, 116, 36, 117, - 454, 455, 114, 115, 155, 409, 410, 461, 601, 581, - 142, 582, 605, 585, 143, 582, 148, 150, 168, 360, - 361, 173, 155, 428, 331, 255, 257, 258, 223, 223, - 223, 261, 264, 265, 268, -56, 223, 362, 363, 595, - 364, 365, -57, 366, 367, 368, -60, 223, 223, 443, - -59, -58, 276, 111, 289, 450, 329, 612, 319, -208, - 320, 321, 322, 285, 323, 336, 506, 507, 508, 509, - 331, 510, 511, 326, 387, 390, 327, -69, 1, 2, - 328, 3, 4, 5, 331, 478, 331, 331, 331, 6, - 7, 223, 485, 223, 375, 376, 223, 37, 38, 39, - 404, 389, 391, 223, 223, 392, 491, 63, 64, 417, - 8, 543, 544, 426, 9, 418, 419, 420, 10, 1, - 2, 421, 3, 4, 5, 403, 422, 430, 405, 406, - 512, 407, 440, 223, 223, 447, 223, 223, 415, 453, - 457, 223, 458, 459, 460, 462, 423, 424, 425, 464, - 463, 466, 223, 467, 532, 574, 501, 575, 576, 476, - 482, 483, 484, 488, 492, 541, 499, 502, 500, 513, - 514, 331, 503, 515, 516, 517, 519, 505, 521, 523, - 524, 556, 525, 223, 526, 530, 529, 535, 538, 331, - 331, 331, 536, 534, 546, 556, -207, 547, 550, 223, - 223, 548, 468, 469, 470, 549, 563, 302, 303, 551, - 475, 472, 577, 223, -69, 1, 2, 572, 3, 4, - 5, 486, 487, 573, 578, 583, 6, 7, 588, 590, - 591, 592, 593, 604, 606, 607, 223, 223, -18, 618, - -19, 223, 621, 624, 223, 619, 625, 8, 603, 630, - 223, 9, 631, 223, 633, 10, 587, 247, 248, 538, - 249, 133, 570, 339, 44, 518, 371, 520, 149, 145, - 522, 340, 380, 130, 97, 567, 0, 527, 528, 304, - 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, - 315, 316, 317, 291, 292, 293, 294, 295, 296, 297, - 298, 299, 300, 474, 0, 0, 0, 553, 554, 0, - 558, 559, 0, 0, 0, 562, 174, 175, 0, 0, - 63, 64, 176, 0, 0, 0, 568, 0, 0, 0, - 0, 0, 1, 2, 0, 3, 4, 5, 177, 178, - 179, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 180, 181, 0, 0, 584, 0, 0, - 0, 0, 0, 0, 0, 0, 359, 0, 0, 0, - 0, 182, 0, 599, 600, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 609, 183, 184, - 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, - 195, 196, 197, 198, 199, 0, 0, 0, 0, 0, - 622, 623, 0, 0, 0, 626, 0, 0, 629, 0, - 0, 0, 0, 0, 632, 0, 0, 634, 0, 0, - 200, 201, 597, 598, 204, 205, 206, 207, 208, 209, - 210, 211, 212, 0, 213, 0, 214, 215, 216, 0, - 362, 363, 0, 364, 365, 0, 366, 367, 368, 174, - 175, 0, 0, 63, 64, 176, 0, 0, 0, 0, - 0, 0, 0, 0, 217, 1, 2, 0, 3, 4, - 5, 177, 178, 179, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 180, 181, 0, 0, + 11, 81, 278, 344, 266, 166, 104, 277, 13, 110, + 277, 90, 469, 470, 268, 451, 453, 11, 21, 93, + 392, 110, 167, 110, 110, 13, 604, 279, 164, 485, + 489, 275, 24, 22, 359, 361, 2, 276, 110, 4, + 409, 410, 411, 143, 143, 412, 614, 110, 486, 413, + 414, 108, 144, 234, 324, 325, 238, 452, 452, 29, + 30, 31, 32, 33, 34, 35, 426, 36, 45, 426, + 46, 426, 25, 431, 323, 135, 426, 241, 432, 108, + 481, 132, 110, 493, 529, 135, 133, 267, 345, 346, + 26, 152, 11, 310, 121, 122, 123, 124, 125, 126, + 426, 152, 37, 38, 39, 427, 111, 515, 314, 315, + 316, 317, 318, 231, 232, 485, 322, 235, 111, 27, + 111, 111, 561, 239, 562, 609, 394, 43, 341, 568, + 569, 28, 430, 63, 64, 111, 106, 66, 67, 68, + 69, 70, 71, 72, 111, 1, 2, 272, 3, 4, + 5, 444, 340, 94, 110, 585, 168, 386, 605, 244, + 245, 246, 247, 57, 105, 37, 38, 39, 110, 59, + 308, 309, 272, 311, 269, 73, 58, -144, 513, 111, + 61, 607, 608, -67, 610, 611, 312, 272, 272, 272, + 272, 272, 319, 320, 321, 272, 380, 118, 119, 380, + 380, 405, 380, 135, 49, 50, 51, 621, 622, 52, + 543, 85, 544, 86, 152, 148, 149, 409, 410, 411, + 407, 90, 412, 409, 410, 411, 413, 414, 412, 83, + 84, 97, 413, 414, 1, 380, 88, 3, 115, 5, + 116, 98, 89, 380, 380, 380, 518, 570, 502, 571, + 574, 111, 571, 152, 389, -67, 99, 534, 421, 422, + 423, 424, 425, 575, 387, 111, 113, 114, 391, -67, + 266, 433, 434, 435, -144, 101, 102, 445, -144, 103, + 86, 388, 74, 75, -208, 145, 76, 139, 77, 107, + 140, 457, 147, 459, 460, 461, 165, 152, 406, 272, + 227, 229, -69, 1, 2, 230, 3, 4, 5, 233, + 380, 380, 380, 236, 6, 7, 237, 240, 380, -56, + -57, 383, 384, -60, 385, -59, -58, 472, 473, 380, + 380, 248, 429, 110, 479, 8, 592, 270, 277, 9, + 596, 439, 342, 10, 343, -55, -55, -55, -55, 350, + 351, 362, 352, 267, 353, 354, 272, 393, 363, 364, + 382, 365, 367, 404, 408, 401, 402, 403, 242, 243, + 272, 458, 272, 272, 272, 380, 395, 380, 465, 396, + 380, 397, 398, 519, 520, 521, 522, 380, 380, 399, + 524, 525, 471, 400, 586, 63, 64, 545, 419, 418, + 548, 549, 550, 420, 436, 442, 456, 1, 2, 446, + 3, 4, 5, 447, 606, 462, 463, 464, 380, 380, + 468, 380, 380, 475, 553, 554, 480, 380, 476, 484, + 477, 478, 448, 449, 450, 492, 482, 483, 380, 490, + 455, 491, 514, 494, 495, 496, 500, 497, 508, 498, + 502, 466, 467, 503, 505, 506, 507, 511, 526, 512, + 527, 516, 517, 578, 533, 579, 580, 528, 452, 535, + 539, 380, 547, 523, 555, 556, 272, 565, 557, 272, + 272, 272, 558, 559, 560, 539, 582, 326, 566, 530, + 567, 576, 380, 380, 572, 577, 584, 499, 597, 501, + 595, 598, 504, 599, 600, 601, -18, -19, 380, 509, + 510, 612, 615, 63, 64, 618, 106, 66, 67, 68, + 69, 70, 71, 72, 613, 1, 2, 619, 3, 4, + 5, 624, 625, 627, 380, 380, 219, 220, 221, 380, + 536, 537, 380, 541, 542, 594, 130, 581, 380, 546, + 348, 380, 327, 328, 146, 73, 349, 142, 563, 338, + 552, 347, 530, 368, 369, 44, 129, 63, 64, 370, + 329, 330, 551, 331, 332, 96, 333, 334, 335, 1, + 2, 474, 3, 4, 5, 371, 372, 373, 0, 0, + 0, 0, 0, 573, 0, 0, 0, 0, 0, 0, + 374, 375, 280, 281, 282, 283, 284, 285, 286, 287, + 288, 289, 0, 326, 590, 591, 63, 64, 376, 106, + 155, 156, 157, 158, 159, 160, 72, 0, 1, 2, + 603, 3, 4, 5, 179, 180, 181, 182, 183, 184, + 185, 186, 187, 188, 189, 190, 191, 192, 193, 252, + 253, 0, 0, 0, 0, 0, 616, 617, 73, 0, + 0, 620, 74, 75, 623, 0, 76, 0, 77, 141, + 626, 0, 0, 628, 0, 0, 254, 200, 588, 589, + 203, 204, 205, 206, 207, 208, 209, 210, 211, 0, + 255, 0, 256, 257, 258, 0, 329, 330, 0, 331, + 332, 0, 333, 334, 335, 368, 369, 0, 0, 63, + 64, 370, 0, 0, 0, 0, 0, 0, 0, 0, + 377, 1, 2, 0, 3, 4, 5, 371, 372, 373, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 111, 0, 63, 64, 182, 107, 66, 67, 68, 69, - 70, 71, 72, 0, 1, 2, 0, 3, 4, 5, - 0, 183, 184, 185, 186, 187, 188, 189, 190, 191, - 192, 193, 194, 195, 196, 197, 198, 199, 0, 0, - 0, 0, 63, 64, 73, 107, 158, 159, 160, 161, - 162, 163, 72, 0, 1, 2, 0, 3, 4, 5, - 0, 0, 0, 200, 201, 202, 203, 204, 205, 206, - 207, 208, 209, 210, 211, 212, 0, 213, 0, 214, - 215, 216, 0, 0, 73, 0, 0, 0, 0, 174, - 175, 0, 0, 63, 64, 176, 0, 0, 112, 0, - 0, 0, 0, 0, 0, 1, 2, 217, 3, 4, - 5, 177, 178, 179, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 180, 181, 0, 0, + 0, 0, 374, 375, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 110, 0, 0, 0, + 376, 0, 0, 0, 0, 74, 75, 0, 0, 76, + 0, 77, 360, 0, 0, 0, 179, 180, 181, 182, + 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, + 193, 252, 253, 0, 0, 63, 64, 0, 106, 155, + 156, 157, 158, 159, 160, 72, 0, 1, 2, 0, + 3, 4, 5, 291, 292, 0, 0, 0, 254, 200, + 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, + 211, 0, 255, 0, 256, 257, 258, 73, 0, 0, + 0, 0, 0, 0, 368, 369, 0, 0, 63, 64, + 370, 0, 0, 111, 0, 0, 0, 0, 0, 0, + 1, 2, 377, 3, 4, 5, 371, 372, 373, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 182, 0, 0, 0, 0, 0, - 0, 0, 74, 75, 0, 0, 76, 0, 77, 144, - 0, 183, 184, 185, 186, 187, 188, 189, 190, 191, - 192, 193, 194, 195, 196, 197, 198, 199, 0, 0, + 0, 374, 375, -207, 293, 294, 295, 296, 297, 298, + 299, 300, 301, 302, 303, 304, 305, 306, 0, 376, + 0, -69, 1, 2, 0, 3, 4, 5, 0, 0, + 0, 0, 0, 6, 7, 179, 180, 181, 182, 183, + 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, + 252, 253, 0, 0, 8, 0, 0, 0, 9, 0, + 0, 0, 10, 0, 74, 75, 0, 0, 76, 0, + 77, 428, 0, 0, 0, 0, 0, 254, 200, 201, + 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, + 0, 255, 0, 256, 257, 258, 63, 64, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, + 0, 3, 4, 5, 249, 0, 0, 0, 0, 0, + 0, 377, 0, 0, 0, 0, 0, 0, 0, 250, + 251, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 63, 64, 110, 150, 66, 67, 68, 69, 70, + 71, 72, 0, 1, 2, 0, 3, 4, 5, 0, + 0, 0, 0, 179, 180, 181, 182, 183, 184, 185, + 186, 187, 188, 189, 190, 191, 192, 193, 252, 253, + 0, 0, 0, 73, 0, 0, 63, 64, 0, 106, + 66, 67, 68, 69, 70, 71, 72, 0, 1, 2, + 0, 3, 4, 5, 0, 254, 200, 201, 202, 203, + 204, 205, 206, 207, 208, 209, 210, 211, 134, 255, + 0, 256, 257, 258, 0, 0, 0, 0, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 74, 75, 0, 0, 76, 0, 77, 385, - 0, 0, 0, 200, 201, 202, 203, 204, 205, 206, - 207, 208, 209, 210, 211, 212, 0, 213, 0, 214, - 215, 216, 63, 64, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 2, 0, 3, 4, 5, - 277, 0, 0, 0, 0, 0, 0, 217, 0, 0, - 0, 0, 0, 0, 0, 278, 279, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 63, 64, 111, - 107, 158, 159, 160, 161, 162, 163, 72, 0, 1, - 2, 0, 3, 4, 5, 0, 0, 0, 0, 0, - 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, - 193, 194, 195, 196, 197, 198, 199, 0, 0, 73, - 0, 0, 0, 63, 64, 0, 107, 66, 67, 68, + 111, 0, 63, 64, -67, 0, 259, 0, 0, 260, + 0, 261, 0, 262, 1, 2, 151, 3, 4, 5, + 249, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 250, 251, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 110, + 74, 75, 0, 0, 76, 0, 77, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 179, + 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, + 190, 191, 192, 193, 252, 253, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 74, 75, 0, 0, 76, + 0, 77, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 254, 200, 201, 202, 203, 204, 205, 206, 207, + 208, 209, 210, 211, 0, 255, 0, 256, 257, 258, + 0, 0, 0, 0, 0, 0, 0, 0, 368, 369, + 0, 0, 0, 0, 370, 0, 111, 0, 0, 0, + 0, 0, 259, 0, 0, 260, 0, 261, 0, 262, + 371, 372, 373, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 374, 375, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 376, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 179, + 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, + 190, 191, 192, 193, 252, 253, 0, 0, 0, 0, + 0, 0, 63, 64, 0, 106, 66, 67, 68, 69, + 70, 71, 72, 0, 1, 2, 0, 3, 4, 5, + 0, 254, 200, 201, 202, 203, 204, 205, 206, 207, + 208, 209, 210, 211, 337, 255, 0, 256, 257, 258, + 0, 0, 63, 64, 73, 106, 155, 156, 157, 158, + 159, 160, 72, 0, 1, 2, 0, 3, 4, 5, + 0, 0, 0, 63, 64, 377, 106, 66, 67, 68, 69, 70, 71, 72, 0, 1, 2, 0, 3, 4, - 5, 0, 200, 201, 202, 203, 204, 205, 206, 207, - 208, 209, 210, 211, 212, 137, 213, 0, 214, 215, - 216, 0, 0, 0, 0, 73, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 112, 0, 63, - 64, -67, 0, 280, 0, 0, 281, 0, 282, 0, - 283, 1, 2, 0, 3, 4, 5, 277, 0, 0, + 5, 0, 0, 0, 73, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 438, 0, 0, 0, 0, + 0, 0, 0, 63, 64, 73, 106, 66, 67, 68, + 69, 70, 71, 72, 0, 1, 2, 0, 3, 4, + 5, 63, 64, 0, 65, 66, 67, 68, 69, 70, + 71, 72, 0, 1, 2, 532, 3, 4, 5, 0, + 0, 0, 0, 0, 0, 73, 0, 0, 0, 0, + 0, 74, 75, 0, 0, 76, 0, 77, 0, 0, + 0, 63, 64, 73, 106, 155, 156, 157, 158, 159, + 160, 72, 0, 1, 2, 0, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 278, 279, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 111, 74, 75, 0, - 0, 76, 0, 77, 442, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 183, 184, 185, - 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, - 196, 197, 198, 199, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 74, 75, 0, 0, 76, 0, 77, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 200, - 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, - 211, 212, 0, 213, 0, 214, 215, 216, 0, 0, - 0, 0, 0, 0, 0, 0, 174, 175, 0, 0, - 0, 0, 176, 0, 112, 0, 0, 0, 0, 0, - 280, 0, 0, 281, 0, 282, 0, 283, 177, 178, - 179, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 180, 181, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 63, - 64, 182, 153, 66, 67, 68, 69, 70, 71, 72, - 0, 1, 2, 0, 3, 4, 5, 0, 183, 184, - 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, - 195, 196, 197, 198, 199, 0, 0, 0, 0, 63, - 64, 73, 107, 158, 159, 160, 161, 162, 163, 72, - 0, 1, 2, 0, 3, 4, 5, 0, 0, 0, - 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, - 210, 211, 212, 0, 213, 0, 214, 215, 216, 63, - 64, 73, 107, 66, 67, 68, 69, 70, 71, 72, - 0, 1, 2, 0, 3, 4, 5, 0, 0, 0, - 0, 0, 0, 0, 217, 0, 0, 0, 0, 0, - 0, 370, 0, 0, 0, 154, 0, 0, 0, 63, - 64, 73, 107, 66, 67, 68, 69, 70, 71, 72, - 0, 1, 2, 0, 3, 4, 5, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 74, - 75, 449, 0, 76, 0, 77, 0, 0, 0, 63, - 64, 73, 107, 66, 67, 68, 69, 70, 71, 72, - 0, 1, 2, 0, 3, 4, 5, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 74, - 75, 540, 381, 76, 0, 77, 0, 0, 0, 63, - 64, 73, 65, 66, 67, 68, 69, 70, 71, 72, - 0, 1, 2, 0, 3, 4, 5, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 74, - 75, 0, 0, 76, 0, 77, 0, 0, 0, 63, - 64, 73, 107, 158, 159, 160, 161, 162, 163, 72, - 0, 1, 2, 0, 3, 4, 5, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 74, - 75, 0, 0, 76, 0, 77, 0, 0, 0, 63, - 64, 73, 153, 66, 67, 68, 69, 70, 71, 72, - 0, 1, 2, 0, 3, 4, 5, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 74, - 75, 0, 0, 76, 0, 77, 0, 0, 0, 63, - 64, 73, 107, 66, 67, 68, 69, 70, 71, 72, - 0, 1, 2, 0, 3, 4, 5, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 74, - 75, 0, 0, 76, 0, 77, 0, 0, 0, 63, - 64, 73, 330, 66, 67, 68, 69, 70, 71, 72, - 0, 1, 2, 0, 3, 4, 5, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 74, - 75, 0, 0, 76, 0, 77, 0, 0, 0, 63, - 64, 73, 107, 158, 159, 160, 161, 162, 163, 72, - 0, 1, 2, 0, 3, 4, 5, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 74, - 75, 0, 0, 76, 0, 77, 0, 0, 0, 63, - 64, 73, 107, 66, 67, 68, 69, 70, 71, 555, + 0, 74, 75, 0, 355, 76, 0, 77, 0, 0, + 0, 0, 0, 73, 0, 0, 0, 0, 0, 0, + 0, 0, 74, 75, 0, 0, 76, 0, 77, 63, + 64, 0, 150, 66, 67, 68, 69, 70, 71, 72, 0, 1, 2, 0, 3, 4, 5, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 74, - 75, 0, 0, 76, 0, 77, 0, 0, 0, 63, - 64, 73, 107, 66, 67, 68, 69, 70, 71, 602, - 0, 1, 2, 0, 3, 4, 5, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 74, - 75, 0, 0, 76, 0, 77, 0, 0, 0, 0, - 0, 73, 0, 225, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 226, 227, 0, 0, 0, 0, 74, - 75, 0, 0, 76, 0, 383, 228, 229, 230, 231, - 232, 233, 183, 184, 185, 186, 187, 188, 189, 190, - 191, 192, 193, 194, 195, 196, 197, 234, 235, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 74, - 75, 0, 0, 76, 0, 77, 0, 0, 0, 236, - 237, 238, 0, 0, 239, 201, 202, 203, 204, 205, - 206, 207, 208, 209, 210, 211, 212, 240, 241, 242, - 243, 244, 245, 246, 0, 0, 0, 0, 0, 74, - 75, 0, 0, 76, 0, 77 + 0, 0, 74, 75, 0, 0, 76, 0, 77, 0, + 0, 73, 0, 0, 0, 0, 0, 0, 0, 0, + 74, 75, 0, 0, 76, 0, 77, 63, 64, 0, + 106, 66, 67, 68, 69, 70, 71, 72, 0, 1, + 2, 0, 3, 4, 5, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 74, 75, 0, 0, 76, 0, 77, 63, 64, 73, + 271, 66, 67, 68, 69, 70, 71, 72, 0, 1, + 2, 0, 3, 4, 5, 63, 64, 0, 106, 155, + 156, 157, 158, 159, 160, 72, 0, 1, 2, 0, + 3, 4, 5, 0, 0, 0, 0, 0, 0, 73, + 0, 0, 0, 0, 0, 0, 0, 0, 74, 75, + 0, 0, 76, 0, 77, 63, 64, 73, 106, 66, + 67, 68, 69, 70, 71, 538, 0, 1, 2, 0, + 3, 4, 5, 63, 64, 0, 106, 66, 67, 68, + 69, 70, 71, 593, 0, 1, 2, 0, 3, 4, + 5, 0, 0, 0, 0, 1, 0, 73, 3, 0, + 5, 0, 0, 0, 0, 0, 74, 75, 0, 0, + 76, 0, 77, 0, 0, 73, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 326, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 74, 75, 0, 0, + 76, 0, 77, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 74, 75, 0, 0, 76, 0, + 358, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 327, 328, 0, 0, 0, 0, + 0, 0, 0, 0, 74, 75, 0, 0, 76, 170, + 77, 0, 329, 330, 0, 331, 332, 0, 333, 334, + 335, 0, 74, 75, 0, 0, 76, 0, 77, 171, + 172, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 173, 174, 175, 176, 177, 178, 179, 180, 181, + 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, + 192, 193, 194, 195, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 196, 197, 198, 0, 0, 199, + 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, + 210, 211, 212, 213, 214, 215, 216, 217, 218 }; static const yytype_int16 yycheck[] = { - 0, 230, 265, 27, 238, 342, 450, 241, 242, 243, - 244, 245, 4, 0, 11, 249, 166, 17, 11, 21, - 128, 11, 28, 54, 231, 54, 154, 29, 54, 54, - 17, 438, 439, 280, 281, 282, 21, 11, 58, 34, - 121, 167, 7, 8, 251, 10, 11, 12, 13, 14, - 15, 16, 17, 77, 19, 20, 54, 22, 23, 24, - 595, 11, 132, 53, 155, 38, 68, 17, 40, 41, - 151, 155, 154, 164, 54, 47, 34, 612, 102, 53, - 164, 53, 106, 68, 49, 18, 156, 54, 112, 155, - 497, 52, 54, 93, 118, 53, 166, 541, 164, 54, - 137, 138, 139, 173, 128, 142, 67, 54, 155, 146, - 147, 555, 556, 155, 149, 150, 151, 164, 142, 143, - 162, 152, 146, 152, 358, 155, 152, 152, 152, 158, - 156, 162, 162, 155, 19, 160, 383, 22, 160, 24, - 266, 267, 137, 138, 139, 154, 20, 142, 155, 23, - 487, 146, 147, 160, 152, 599, 600, 163, 602, 603, - 32, 33, 164, 160, 137, 138, 139, 160, 53, 142, - 404, 163, 152, 146, 147, 155, 156, 0, 622, 623, - 158, 518, 169, 520, 418, 152, 420, 421, 422, 156, - 152, 153, 157, 158, 115, 116, 161, 152, 163, 164, - 155, 156, 114, 115, 228, 152, 153, 3, 4, 5, - 6, 154, 236, 237, 238, 239, 240, 241, 242, 243, - 244, 245, 246, 247, 248, 249, 3, 4, 5, 6, - 338, 568, 154, 257, 119, 120, 22, 500, 319, 320, - 321, 322, 323, 22, 268, 326, 327, 328, 356, 26, - 27, 152, 137, 138, 22, 140, 141, 22, 143, 144, - 145, 331, 37, 53, 334, 335, 4, 337, 42, 43, - 44, 505, 4, 47, 344, 19, 68, 173, 22, 35, - 24, 37, 352, 353, 354, 46, 153, 48, 155, 523, - 524, 525, 38, 443, 61, 62, 63, 64, 65, 66, - 42, 43, 44, 45, 46, 47, 48, 42, 50, 44, - 391, 392, 83, 84, 338, 339, 340, 398, 581, 153, - 159, 155, 585, 153, 159, 155, 152, 156, 4, 119, - 120, 38, 356, 357, 358, 22, 155, 153, 408, 409, - 410, 162, 4, 153, 152, 9, 416, 137, 138, 578, - 140, 141, 9, 143, 144, 145, 9, 427, 428, 383, - 9, 9, 9, 54, 60, 389, 56, 596, 152, 0, - 152, 152, 152, 443, 152, 11, 457, 458, 459, 460, - 404, 462, 463, 152, 22, 22, 152, 18, 19, 20, - 152, 22, 23, 24, 418, 419, 420, 421, 422, 30, - 31, 471, 426, 473, 162, 153, 476, 149, 150, 151, - 155, 152, 152, 483, 484, 152, 440, 7, 8, 155, - 51, 502, 503, 38, 55, 155, 155, 155, 59, 19, - 20, 155, 22, 23, 24, 331, 155, 4, 334, 335, - 464, 337, 38, 513, 514, 155, 516, 517, 344, 155, - 155, 521, 155, 155, 155, 155, 352, 353, 354, 38, - 155, 155, 532, 155, 488, 546, 22, 548, 549, 158, - 155, 155, 155, 155, 162, 499, 155, 155, 153, 17, - 17, 505, 155, 152, 155, 155, 4, 155, 155, 155, - 155, 515, 155, 563, 4, 155, 152, 22, 498, 523, - 524, 525, 4, 162, 155, 529, 0, 153, 153, 579, - 580, 155, 408, 409, 410, 155, 155, 26, 27, 153, - 416, 53, 155, 593, 18, 19, 20, 153, 22, 23, - 24, 427, 428, 153, 158, 160, 30, 31, 53, 153, - 153, 153, 17, 160, 4, 148, 616, 617, 152, 22, - 152, 621, 17, 17, 624, 155, 155, 51, 582, 17, - 630, 55, 73, 633, 17, 59, 569, 133, 133, 569, - 133, 93, 542, 234, 17, 471, 257, 473, 112, 106, - 476, 235, 268, 89, 56, 529, -1, 483, 484, 98, - 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, - 109, 110, 111, 92, 93, 94, 95, 96, 97, 98, - 99, 100, 101, 415, -1, -1, -1, 513, 514, -1, - 516, 517, -1, -1, -1, 521, 3, 4, -1, -1, - 7, 8, 9, -1, -1, -1, 532, -1, -1, -1, - -1, -1, 19, 20, -1, 22, 23, 24, 25, 26, - 27, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 40, 41, -1, -1, 563, -1, -1, - -1, -1, -1, -1, -1, -1, 53, -1, -1, -1, - -1, 58, -1, 579, 580, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 593, 75, 76, - 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, - 87, 88, 89, 90, 91, -1, -1, -1, -1, -1, - 616, 617, -1, -1, -1, 621, -1, -1, 624, -1, - -1, -1, -1, -1, 630, -1, -1, 633, -1, -1, - 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, - 127, 128, 129, -1, 131, -1, 133, 134, 135, -1, - 137, 138, -1, 140, 141, -1, 143, 144, 145, 3, - 4, -1, -1, 7, 8, 9, -1, -1, -1, -1, - -1, -1, -1, -1, 161, 19, 20, -1, 22, 23, - 24, 25, 26, 27, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 40, 41, -1, -1, + 0, 27, 175, 237, 163, 127, 4, 11, 0, 54, + 11, 21, 416, 417, 164, 11, 11, 17, 52, 29, + 309, 54, 28, 54, 54, 17, 586, 176, 120, 34, + 439, 11, 153, 67, 260, 261, 20, 17, 54, 23, + 136, 137, 138, 154, 154, 141, 606, 54, 53, 145, + 146, 77, 163, 163, 114, 115, 148, 53, 53, 42, + 43, 44, 45, 46, 47, 48, 154, 50, 46, 154, + 48, 154, 58, 161, 223, 101, 154, 153, 163, 105, + 163, 154, 54, 161, 488, 111, 159, 163, 238, 239, + 153, 117, 92, 198, 61, 62, 63, 64, 65, 66, + 154, 127, 148, 149, 150, 159, 151, 152, 213, 214, + 215, 216, 217, 139, 140, 34, 221, 143, 151, 18, + 151, 151, 152, 149, 533, 38, 157, 0, 161, 538, + 539, 153, 358, 7, 8, 151, 10, 11, 12, 13, + 14, 15, 16, 17, 151, 19, 20, 173, 22, 23, + 24, 377, 159, 163, 54, 159, 162, 279, 159, 3, + 4, 5, 6, 153, 162, 148, 149, 150, 54, 157, + 196, 197, 198, 199, 166, 49, 153, 54, 467, 151, + 22, 590, 591, 155, 593, 594, 212, 213, 214, 215, + 216, 217, 218, 219, 220, 221, 272, 32, 33, 275, + 276, 323, 278, 229, 42, 43, 44, 616, 617, 47, + 499, 35, 501, 37, 240, 113, 114, 136, 137, 138, + 325, 21, 141, 136, 137, 138, 145, 146, 141, 40, + 41, 22, 145, 146, 19, 311, 47, 22, 42, 24, + 44, 22, 53, 319, 320, 321, 152, 152, 154, 154, + 152, 151, 154, 279, 154, 155, 22, 491, 350, 351, + 352, 353, 354, 552, 290, 151, 83, 84, 154, 155, + 429, 363, 364, 365, 151, 151, 4, 382, 155, 4, + 37, 307, 156, 157, 0, 151, 160, 158, 162, 163, + 158, 396, 155, 398, 399, 400, 4, 323, 324, 325, + 22, 154, 18, 19, 20, 152, 22, 23, 24, 161, + 386, 387, 388, 4, 30, 31, 152, 151, 394, 9, + 9, 275, 276, 9, 278, 9, 9, 419, 420, 405, + 406, 9, 358, 54, 426, 51, 570, 56, 11, 55, + 574, 367, 161, 59, 152, 3, 4, 5, 6, 151, + 151, 22, 151, 429, 151, 151, 382, 311, 151, 151, + 154, 151, 151, 38, 4, 319, 320, 321, 26, 27, + 396, 397, 398, 399, 400, 451, 154, 453, 404, 154, + 456, 154, 154, 475, 476, 477, 478, 463, 464, 154, + 482, 483, 418, 154, 567, 7, 8, 502, 151, 38, + 505, 506, 507, 151, 154, 60, 157, 19, 20, 154, + 22, 23, 24, 154, 587, 154, 154, 154, 494, 495, + 154, 497, 498, 154, 516, 517, 161, 503, 154, 38, + 154, 154, 386, 387, 388, 22, 154, 154, 514, 154, + 394, 152, 468, 17, 17, 151, 4, 154, 4, 154, + 154, 405, 406, 154, 154, 154, 154, 151, 484, 154, + 22, 154, 154, 555, 490, 557, 558, 4, 53, 154, + 496, 547, 154, 161, 154, 152, 502, 22, 154, 505, + 506, 507, 154, 152, 152, 511, 53, 53, 154, 489, + 157, 152, 568, 569, 159, 152, 17, 451, 152, 453, + 159, 152, 456, 152, 4, 147, 151, 151, 584, 463, + 464, 22, 17, 7, 8, 17, 10, 11, 12, 13, + 14, 15, 16, 17, 154, 19, 20, 154, 22, 23, + 24, 17, 72, 17, 610, 611, 130, 130, 130, 615, + 494, 495, 618, 497, 498, 571, 92, 562, 624, 503, + 252, 627, 118, 119, 111, 49, 253, 105, 534, 229, + 514, 240, 562, 3, 4, 17, 89, 7, 8, 9, + 136, 137, 511, 139, 140, 56, 142, 143, 144, 19, + 20, 421, 22, 23, 24, 25, 26, 27, -1, -1, + -1, -1, -1, 547, -1, -1, -1, -1, -1, -1, + 40, 41, 91, 92, 93, 94, 95, 96, 97, 98, + 99, 100, -1, 53, 568, 569, 7, 8, 58, 10, + 11, 12, 13, 14, 15, 16, 17, -1, 19, 20, + 584, 22, 23, 24, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, + 90, -1, -1, -1, -1, -1, 610, 611, 49, -1, + -1, 615, 156, 157, 618, -1, 160, -1, 162, 163, + 624, -1, -1, 627, -1, -1, 116, 117, 118, 119, + 120, 121, 122, 123, 124, 125, 126, 127, 128, -1, + 130, -1, 132, 133, 134, -1, 136, 137, -1, 139, + 140, -1, 142, 143, 144, 3, 4, -1, -1, 7, + 8, 9, -1, -1, -1, -1, -1, -1, -1, -1, + 160, 19, 20, -1, 22, 23, 24, 25, 26, 27, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 54, -1, 7, 8, 58, 10, 11, 12, 13, 14, + -1, -1, 40, 41, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 54, -1, -1, -1, + 58, -1, -1, -1, -1, 156, 157, -1, -1, 160, + -1, 162, 163, -1, -1, -1, 74, 75, 76, 77, + 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, + 88, 89, 90, -1, -1, 7, 8, -1, 10, 11, + 12, 13, 14, 15, 16, 17, -1, 19, 20, -1, + 22, 23, 24, 26, 27, -1, -1, -1, 116, 117, + 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, + 128, -1, 130, -1, 132, 133, 134, 49, -1, -1, + -1, -1, -1, -1, 3, 4, -1, -1, 7, 8, + 9, -1, -1, 151, -1, -1, -1, -1, -1, -1, + 19, 20, 160, 22, 23, 24, 25, 26, 27, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 40, 41, 0, 97, 98, 99, 100, 101, 102, + 103, 104, 105, 106, 107, 108, 109, 110, -1, 58, + -1, 18, 19, 20, -1, 22, 23, 24, -1, -1, + -1, -1, -1, 30, 31, 74, 75, 76, 77, 78, + 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, + 89, 90, -1, -1, 51, -1, -1, -1, 55, -1, + -1, -1, 59, -1, 156, 157, -1, -1, 160, -1, + 162, 163, -1, -1, -1, -1, -1, 116, 117, 118, + 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, + -1, 130, -1, 132, 133, 134, 7, 8, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 19, 20, + -1, 22, 23, 24, 25, -1, -1, -1, -1, -1, + -1, 160, -1, -1, -1, -1, -1, -1, -1, 40, + 41, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 7, 8, 54, 10, 11, 12, 13, 14, 15, + 16, 17, -1, 19, 20, -1, 22, 23, 24, -1, + -1, -1, -1, 74, 75, 76, 77, 78, 79, 80, + 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, + -1, -1, -1, 49, -1, -1, 7, 8, -1, 10, + 11, 12, 13, 14, 15, 16, 17, -1, 19, 20, + -1, 22, 23, 24, -1, 116, 117, 118, 119, 120, + 121, 122, 123, 124, 125, 126, 127, 128, 39, 130, + -1, 132, 133, 134, -1, -1, -1, -1, 49, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 151, -1, 7, 8, 155, -1, 157, -1, -1, 160, + -1, 162, -1, 164, 19, 20, 122, 22, 23, 24, + 25, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 40, 41, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 54, + 156, 157, -1, -1, 160, -1, 162, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 74, + 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, + 85, 86, 87, 88, 89, 90, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 156, 157, -1, -1, 160, + -1, 162, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 116, 117, 118, 119, 120, 121, 122, 123, 124, + 125, 126, 127, 128, -1, 130, -1, 132, 133, 134, + -1, -1, -1, -1, -1, -1, -1, -1, 3, 4, + -1, -1, -1, -1, 9, -1, 151, -1, -1, -1, + -1, -1, 157, -1, -1, 160, -1, 162, -1, 164, + 25, 26, 27, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 40, 41, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 58, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 74, + 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, + 85, 86, 87, 88, 89, 90, -1, -1, -1, -1, + -1, -1, 7, 8, -1, 10, 11, 12, 13, 14, 15, 16, 17, -1, 19, 20, -1, 22, 23, 24, - -1, 75, 76, 77, 78, 79, 80, 81, 82, 83, - 84, 85, 86, 87, 88, 89, 90, 91, -1, -1, + -1, 116, 117, 118, 119, 120, 121, 122, 123, 124, + 125, 126, 127, 128, 39, 130, -1, 132, 133, 134, -1, -1, 7, 8, 49, 10, 11, 12, 13, 14, 15, 16, 17, -1, 19, 20, -1, 22, 23, 24, - -1, -1, -1, 117, 118, 119, 120, 121, 122, 123, - 124, 125, 126, 127, 128, 129, -1, 131, -1, 133, - 134, 135, -1, -1, 49, -1, -1, -1, -1, 3, - 4, -1, -1, 7, 8, 9, -1, -1, 152, -1, - -1, -1, -1, -1, -1, 19, 20, 161, 22, 23, - 24, 25, 26, 27, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 40, 41, -1, -1, + -1, -1, -1, 7, 8, 160, 10, 11, 12, 13, + 14, 15, 16, 17, -1, 19, 20, -1, 22, 23, + 24, -1, -1, -1, 49, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 39, -1, -1, -1, -1, + -1, -1, -1, 7, 8, 49, 10, 11, 12, 13, + 14, 15, 16, 17, -1, 19, 20, -1, 22, 23, + 24, 7, 8, -1, 10, 11, 12, 13, 14, 15, + 16, 17, -1, 19, 20, 39, 22, 23, 24, -1, + -1, -1, -1, -1, -1, 49, -1, -1, -1, -1, + -1, 156, 157, -1, -1, 160, -1, 162, -1, -1, + -1, 7, 8, 49, 10, 11, 12, 13, 14, 15, + 16, 17, -1, 19, 20, -1, 22, 23, 24, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 58, -1, -1, -1, -1, -1, - -1, -1, 157, 158, -1, -1, 161, -1, 163, 164, - -1, 75, 76, 77, 78, 79, 80, 81, 82, 83, - 84, 85, 86, 87, 88, 89, 90, 91, -1, -1, + -1, 156, 157, -1, 159, 160, -1, 162, -1, -1, + -1, -1, -1, 49, -1, -1, -1, -1, -1, -1, + -1, -1, 156, 157, -1, -1, 160, -1, 162, 7, + 8, -1, 10, 11, 12, 13, 14, 15, 16, 17, + -1, 19, 20, -1, 22, 23, 24, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 157, 158, -1, -1, 161, -1, 163, 164, - -1, -1, -1, 117, 118, 119, 120, 121, 122, 123, - 124, 125, 126, 127, 128, 129, -1, 131, -1, 133, - 134, 135, 7, 8, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 19, 20, -1, 22, 23, 24, - 25, -1, -1, -1, -1, -1, -1, 161, -1, -1, - -1, -1, -1, -1, -1, 40, 41, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 7, 8, 54, + -1, -1, 156, 157, -1, -1, 160, -1, 162, -1, + -1, 49, -1, -1, -1, -1, -1, -1, -1, -1, + 156, 157, -1, -1, 160, -1, 162, 7, 8, -1, 10, 11, 12, 13, 14, 15, 16, 17, -1, 19, 20, -1, 22, 23, 24, -1, -1, -1, -1, -1, - 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, - 85, 86, 87, 88, 89, 90, 91, -1, -1, 49, - -1, -1, -1, 7, 8, -1, 10, 11, 12, 13, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 156, 157, -1, -1, 160, -1, 162, 7, 8, 49, + 10, 11, 12, 13, 14, 15, 16, 17, -1, 19, + 20, -1, 22, 23, 24, 7, 8, -1, 10, 11, + 12, 13, 14, 15, 16, 17, -1, 19, 20, -1, + 22, 23, 24, -1, -1, -1, -1, -1, -1, 49, + -1, -1, -1, -1, -1, -1, -1, -1, 156, 157, + -1, -1, 160, -1, 162, 7, 8, 49, 10, 11, + 12, 13, 14, 15, 16, 17, -1, 19, 20, -1, + 22, 23, 24, 7, 8, -1, 10, 11, 12, 13, 14, 15, 16, 17, -1, 19, 20, -1, 22, 23, - 24, -1, 117, 118, 119, 120, 121, 122, 123, 124, - 125, 126, 127, 128, 129, 39, 131, -1, 133, 134, - 135, -1, -1, -1, -1, 49, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 152, -1, 7, - 8, 156, -1, 158, -1, -1, 161, -1, 163, -1, - 165, 19, 20, -1, 22, 23, 24, 25, -1, -1, + 24, -1, -1, -1, -1, 19, -1, 49, 22, -1, + 24, -1, -1, -1, -1, -1, 156, 157, -1, -1, + 160, -1, 162, -1, -1, 49, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 53, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 40, 41, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 54, 157, 158, -1, - -1, 161, -1, 163, 164, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 75, 76, 77, - 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, - 88, 89, 90, 91, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 157, 158, -1, -1, 161, -1, 163, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 117, - 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, - 128, 129, -1, 131, -1, 133, 134, 135, -1, -1, - -1, -1, -1, -1, -1, -1, 3, 4, -1, -1, - -1, -1, 9, -1, 152, -1, -1, -1, -1, -1, - 158, -1, -1, 161, -1, 163, -1, 165, 25, 26, - 27, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 40, 41, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 7, - 8, 58, 10, 11, 12, 13, 14, 15, 16, 17, - -1, 19, 20, -1, 22, 23, 24, -1, 75, 76, + -1, -1, -1, -1, -1, -1, 156, 157, -1, -1, + 160, -1, 162, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 156, 157, -1, -1, 160, -1, + 162, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 118, 119, -1, -1, -1, -1, + -1, -1, -1, -1, 156, 157, -1, -1, 160, 36, + 162, -1, 136, 137, -1, 139, 140, -1, 142, 143, + 144, -1, 156, 157, -1, -1, 160, -1, 162, 56, + 57, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, - 87, 88, 89, 90, 91, -1, -1, -1, -1, 7, - 8, 49, 10, 11, 12, 13, 14, 15, 16, 17, - -1, 19, 20, -1, 22, 23, 24, -1, -1, -1, - 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, - 127, 128, 129, -1, 131, -1, 133, 134, 135, 7, - 8, 49, 10, 11, 12, 13, 14, 15, 16, 17, - -1, 19, 20, -1, 22, 23, 24, -1, -1, -1, - -1, -1, -1, -1, 161, -1, -1, -1, -1, -1, - -1, 39, -1, -1, -1, 123, -1, -1, -1, 7, - 8, 49, 10, 11, 12, 13, 14, 15, 16, 17, - -1, 19, 20, -1, 22, 23, 24, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 157, - 158, 39, -1, 161, -1, 163, -1, -1, -1, 7, - 8, 49, 10, 11, 12, 13, 14, 15, 16, 17, - -1, 19, 20, -1, 22, 23, 24, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 157, - 158, 39, 160, 161, -1, 163, -1, -1, -1, 7, - 8, 49, 10, 11, 12, 13, 14, 15, 16, 17, - -1, 19, 20, -1, 22, 23, 24, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 157, - 158, -1, -1, 161, -1, 163, -1, -1, -1, 7, - 8, 49, 10, 11, 12, 13, 14, 15, 16, 17, - -1, 19, 20, -1, 22, 23, 24, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 157, - 158, -1, -1, 161, -1, 163, -1, -1, -1, 7, - 8, 49, 10, 11, 12, 13, 14, 15, 16, 17, - -1, 19, 20, -1, 22, 23, 24, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 157, - 158, -1, -1, 161, -1, 163, -1, -1, -1, 7, - 8, 49, 10, 11, 12, 13, 14, 15, 16, 17, - -1, 19, 20, -1, 22, 23, 24, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 157, - 158, -1, -1, 161, -1, 163, -1, -1, -1, 7, - 8, 49, 10, 11, 12, 13, 14, 15, 16, 17, - -1, 19, 20, -1, 22, 23, 24, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 157, - 158, -1, -1, 161, -1, 163, -1, -1, -1, 7, - 8, 49, 10, 11, 12, 13, 14, 15, 16, 17, - -1, 19, 20, -1, 22, 23, 24, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 157, - 158, -1, -1, 161, -1, 163, -1, -1, -1, 7, - 8, 49, 10, 11, 12, 13, 14, 15, 16, 17, - -1, 19, 20, -1, 22, 23, 24, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 157, - 158, -1, -1, 161, -1, 163, -1, -1, -1, 7, - 8, 49, 10, 11, 12, 13, 14, 15, 16, 17, - -1, 19, 20, -1, 22, 23, 24, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 157, - 158, -1, -1, 161, -1, 163, -1, -1, -1, -1, - -1, 49, -1, 36, -1, -1, -1, -1, -1, -1, + 87, 88, 89, 90, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 56, 57, -1, -1, -1, -1, 157, - 158, -1, -1, 161, -1, 163, 69, 70, 71, 72, - 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, - 83, 84, 85, 86, 87, 88, 89, 90, 91, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 157, - 158, -1, -1, 161, -1, 163, -1, -1, -1, 112, - 113, 114, -1, -1, 117, 118, 119, 120, 121, 122, - 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, - 133, 134, 135, 136, -1, -1, -1, -1, -1, 157, - 158, -1, -1, 161, -1, 163 + -1, -1, -1, -1, 111, 112, 113, -1, -1, 116, + 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, + 127, 128, 129, 130, 131, 132, 133, 134, 135 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing @@ -2609,69 +2594,68 @@ static const yytype_uint8 yystos[] = { 0, 19, 20, 22, 23, 24, 30, 31, 51, 55, - 59, 174, 177, 178, 179, 180, 212, 213, 214, 216, - 215, 52, 67, 221, 154, 58, 154, 18, 154, 42, - 43, 44, 45, 46, 47, 48, 50, 149, 150, 151, - 181, 182, 183, 0, 214, 46, 48, 184, 231, 42, - 43, 44, 47, 185, 228, 230, 238, 154, 154, 158, - 222, 22, 220, 7, 8, 10, 11, 12, 13, 14, - 15, 16, 17, 49, 157, 158, 161, 163, 174, 178, - 199, 200, 234, 183, 183, 35, 37, 210, 183, 183, - 21, 68, 239, 240, 29, 164, 229, 239, 22, 22, - 22, 223, 152, 4, 4, 4, 163, 10, 164, 200, - 205, 54, 152, 176, 210, 210, 42, 44, 186, 32, - 33, 209, 61, 62, 63, 64, 65, 66, 187, 226, - 226, 68, 38, 177, 243, 155, 160, 39, 200, 201, - 203, 204, 159, 159, 164, 205, 155, 164, 152, 204, - 156, 209, 209, 10, 123, 200, 202, 211, 11, 12, - 13, 14, 15, 16, 172, 173, 200, 206, 4, 202, - 28, 163, 227, 38, 3, 4, 9, 25, 26, 27, - 40, 41, 58, 75, 76, 77, 78, 79, 80, 81, - 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, + 59, 173, 176, 177, 178, 179, 211, 212, 213, 215, + 214, 52, 67, 220, 153, 58, 153, 18, 153, 42, + 43, 44, 45, 46, 47, 48, 50, 148, 149, 150, + 180, 181, 182, 0, 213, 46, 48, 183, 230, 42, + 43, 44, 47, 184, 227, 229, 237, 153, 153, 157, + 221, 22, 219, 7, 8, 10, 11, 12, 13, 14, + 15, 16, 17, 49, 156, 157, 160, 162, 173, 177, + 198, 199, 233, 182, 182, 35, 37, 209, 182, 182, + 21, 238, 239, 29, 163, 228, 238, 22, 22, 22, + 222, 151, 4, 4, 4, 162, 10, 163, 199, 204, + 54, 151, 175, 209, 209, 42, 44, 185, 32, 33, + 208, 61, 62, 63, 64, 65, 66, 186, 225, 225, + 176, 242, 154, 159, 39, 199, 200, 202, 203, 158, + 158, 163, 204, 154, 163, 151, 203, 155, 208, 208, + 10, 122, 199, 201, 210, 11, 12, 13, 14, 15, + 16, 171, 172, 199, 205, 4, 201, 28, 162, 226, + 36, 56, 57, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, + 85, 86, 87, 88, 89, 90, 111, 112, 113, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, - 127, 128, 129, 131, 133, 134, 135, 161, 167, 168, - 169, 207, 233, 234, 235, 36, 56, 57, 69, 70, - 71, 72, 73, 74, 90, 91, 112, 113, 114, 117, - 130, 131, 132, 133, 134, 135, 136, 167, 168, 169, - 241, 247, 248, 249, 250, 22, 189, 155, 153, 200, - 200, 162, 164, 200, 4, 153, 206, 200, 152, 234, - 26, 27, 3, 4, 5, 6, 9, 25, 40, 41, - 158, 161, 163, 165, 207, 234, 176, 178, 235, 60, - 232, 92, 93, 94, 95, 96, 97, 98, 99, 100, - 101, 170, 26, 27, 98, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 109, 110, 111, 171, 152, - 152, 152, 152, 152, 206, 208, 152, 152, 152, 56, - 10, 200, 236, 237, 11, 17, 11, 172, 187, 170, - 171, 200, 200, 236, 200, 200, 244, 236, 236, 236, - 236, 236, 200, 200, 200, 236, 187, 115, 116, 53, - 119, 120, 137, 138, 140, 141, 143, 144, 145, 188, - 39, 201, 191, 160, 162, 162, 153, 191, 176, 176, - 211, 160, 208, 163, 208, 164, 208, 22, 217, 152, - 22, 152, 152, 206, 206, 206, 206, 206, 155, 162, - 206, 206, 206, 235, 155, 235, 235, 235, 202, 200, - 200, 155, 194, 155, 194, 235, 158, 155, 155, 155, - 155, 155, 155, 235, 235, 235, 38, 202, 200, 236, - 4, 137, 138, 139, 142, 146, 147, 190, 218, 219, - 38, 160, 164, 200, 208, 162, 164, 155, 197, 39, - 200, 224, 225, 155, 206, 206, 246, 155, 155, 155, - 155, 206, 155, 155, 38, 236, 155, 155, 235, 235, - 235, 11, 53, 11, 246, 235, 158, 236, 200, 236, - 236, 236, 155, 155, 155, 200, 235, 235, 155, 197, - 197, 200, 162, 164, 34, 53, 195, 198, 189, 155, - 153, 22, 155, 155, 153, 155, 206, 206, 206, 206, - 206, 206, 200, 17, 17, 152, 155, 155, 235, 4, - 235, 155, 235, 155, 155, 155, 4, 235, 235, 152, - 155, 194, 200, 153, 162, 22, 4, 197, 174, 175, - 39, 200, 191, 206, 206, 236, 155, 153, 155, 155, - 153, 153, 153, 235, 235, 17, 200, 245, 235, 235, - 194, 194, 235, 155, 236, 236, 236, 245, 235, 189, - 195, 196, 153, 153, 206, 206, 206, 155, 158, 189, - 189, 153, 155, 160, 235, 153, 194, 175, 53, 193, - 153, 153, 153, 17, 160, 172, 242, 119, 120, 235, - 235, 191, 17, 200, 160, 191, 4, 148, 192, 235, - 233, 160, 172, 189, 189, 38, 189, 189, 22, 155, - 233, 17, 235, 235, 17, 155, 235, 189, 189, 235, - 17, 73, 235, 17, 235 + 127, 128, 129, 130, 131, 132, 133, 134, 135, 166, + 167, 168, 240, 246, 247, 248, 249, 22, 188, 154, + 152, 199, 199, 161, 163, 199, 4, 152, 205, 199, + 151, 233, 26, 27, 3, 4, 5, 6, 9, 25, + 40, 41, 89, 90, 116, 130, 132, 133, 134, 157, + 160, 162, 164, 166, 167, 168, 206, 233, 175, 177, + 56, 10, 199, 235, 236, 11, 17, 11, 171, 186, + 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, + 169, 26, 27, 97, 98, 99, 100, 101, 102, 103, + 104, 105, 106, 107, 108, 109, 110, 170, 199, 199, + 235, 199, 199, 243, 235, 235, 235, 235, 235, 199, + 199, 199, 235, 186, 114, 115, 53, 118, 119, 136, + 137, 139, 140, 142, 143, 144, 187, 39, 200, 190, + 159, 161, 161, 152, 190, 175, 175, 210, 169, 170, + 151, 151, 151, 151, 151, 159, 205, 207, 162, 207, + 163, 207, 22, 151, 151, 151, 216, 151, 3, 4, + 9, 25, 26, 27, 40, 41, 58, 160, 206, 232, + 233, 234, 154, 234, 234, 234, 201, 199, 199, 154, + 193, 154, 193, 234, 157, 154, 154, 154, 154, 154, + 154, 234, 234, 234, 38, 201, 199, 235, 4, 136, + 137, 138, 141, 145, 146, 189, 217, 218, 38, 151, + 151, 205, 205, 205, 205, 205, 154, 159, 163, 199, + 207, 161, 163, 205, 205, 205, 154, 196, 39, 199, + 223, 224, 60, 231, 207, 235, 154, 154, 234, 234, + 234, 11, 53, 11, 245, 234, 157, 235, 199, 235, + 235, 235, 154, 154, 154, 199, 234, 234, 154, 196, + 196, 199, 205, 205, 245, 154, 154, 154, 154, 205, + 161, 163, 154, 154, 38, 34, 53, 194, 197, 188, + 154, 152, 22, 161, 17, 17, 151, 154, 154, 234, + 4, 234, 154, 154, 234, 154, 154, 154, 4, 234, + 234, 151, 154, 193, 199, 152, 154, 154, 152, 205, + 205, 205, 205, 161, 205, 205, 199, 22, 4, 196, + 173, 174, 39, 199, 190, 154, 234, 234, 17, 199, + 244, 234, 234, 193, 193, 235, 234, 154, 235, 235, + 235, 244, 234, 205, 205, 154, 152, 154, 154, 152, + 152, 152, 188, 194, 195, 22, 154, 157, 188, 188, + 152, 154, 159, 234, 152, 193, 152, 152, 205, 205, + 205, 174, 53, 192, 17, 159, 171, 241, 118, 119, + 234, 234, 190, 17, 199, 159, 190, 152, 152, 152, + 4, 147, 191, 234, 232, 159, 171, 188, 188, 38, + 188, 188, 22, 154, 232, 17, 234, 234, 17, 154, + 234, 188, 188, 234, 17, 72, 234, 17, 234 }; #define yyerrok (yyerrstatus = 0) @@ -3486,152 +3470,152 @@ switch (yyn) { case 29: -#line 1118 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1117 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;} break; case 30: -#line 1118 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1117 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;} break; case 31: -#line 1119 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1118 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;} break; case 32: -#line 1119 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1118 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;} break; case 33: -#line 1120 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1119 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;} break; case 34: -#line 1120 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1119 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;} break; case 35: -#line 1121 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1120 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;} break; case 36: -#line 1121 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1120 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;} break; case 37: -#line 1122 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1121 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;} break; case 38: -#line 1122 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1121 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;} break; case 39: -#line 1126 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1125 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;} break; case 40: -#line 1126 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1125 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;} break; case 41: -#line 1127 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1126 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;} break; case 42: -#line 1127 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1126 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;} break; case 43: -#line 1128 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1127 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;} break; case 44: -#line 1128 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1127 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;} break; case 45: -#line 1129 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1128 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;} break; case 46: -#line 1129 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1128 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;} break; case 47: -#line 1130 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1129 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;} break; case 48: -#line 1130 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1129 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;} break; case 49: -#line 1131 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1130 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;} break; case 50: -#line 1131 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1130 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;} break; case 51: -#line 1132 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1131 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;} break; case 52: -#line 1132 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1131 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;} break; case 53: -#line 1133 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1132 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;} break; case 54: -#line 1134 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1133 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;} break; case 65: -#line 1143 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1142 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.StrVal) = 0; ;} break; case 66: -#line 1145 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1144 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.UIntVal)=(yyvsp[(3) - (4)].UInt64Val); ;} break; case 67: -#line 1146 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1145 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.UIntVal)=0; ;} break; case 68: -#line 1150 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1149 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal); CHECK_FOR_ERROR @@ -3639,7 +3623,7 @@ break; case 69: -#line 1154 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1153 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.StrVal) = 0; CHECK_FOR_ERROR @@ -3647,7 +3631,7 @@ break; case 73: -#line 1162 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1161 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.StrVal) = 0; CHECK_FOR_ERROR @@ -3655,7 +3639,7 @@ break; case 74: -#line 1167 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1166 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal); CHECK_FOR_ERROR @@ -3663,152 +3647,152 @@ break; case 75: -#line 1173 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1172 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::InternalLinkage; ;} break; case 76: -#line 1174 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1173 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::WeakLinkage; ;} break; case 77: -#line 1175 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1174 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;} break; case 78: -#line 1176 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1175 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;} break; case 79: -#line 1177 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1176 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;} break; case 80: -#line 1181 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1180 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;} break; case 81: -#line 1182 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1181 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;} break; case 82: -#line 1183 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1182 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} break; case 83: -#line 1187 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1186 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;} break; case 84: -#line 1188 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1187 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;} break; case 85: -#line 1189 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1188 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;} break; case 86: -#line 1190 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1189 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.Visibility) = GlobalValue::ProtectedVisibility; ;} break; case 87: -#line 1194 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1193 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} break; case 88: -#line 1195 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1194 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;} break; case 89: -#line 1196 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1195 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;} break; case 90: -#line 1200 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1199 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} break; case 91: -#line 1201 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1200 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::InternalLinkage; ;} break; case 92: -#line 1202 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1201 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;} break; case 93: -#line 1203 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1202 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::WeakLinkage; ;} break; case 94: -#line 1204 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1203 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;} break; case 95: -#line 1208 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1207 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} break; case 96: -#line 1209 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1208 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::WeakLinkage; ;} break; case 97: -#line 1210 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1209 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::InternalLinkage; ;} break; case 98: -#line 1213 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1212 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.UIntVal) = CallingConv::C; ;} break; case 99: -#line 1214 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1213 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.UIntVal) = CallingConv::C; ;} break; case 100: -#line 1215 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1214 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.UIntVal) = CallingConv::Fast; ;} break; case 101: -#line 1216 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1215 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.UIntVal) = CallingConv::Cold; ;} break; case 102: -#line 1217 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1216 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.UIntVal) = CallingConv::X86_StdCall; ;} break; case 103: -#line 1218 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1217 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.UIntVal) = CallingConv::X86_FastCall; ;} break; case 104: -#line 1219 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1218 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val)) GEN_ERROR("Calling conv too large"); @@ -3818,129 +3802,129 @@ break; case 105: -#line 1226 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1225 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ParamAttrs) = ParamAttr::ZExt; ;} break; case 106: -#line 1227 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1226 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ParamAttrs) = ParamAttr::ZExt; ;} break; case 107: -#line 1228 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1227 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ParamAttrs) = ParamAttr::SExt; ;} break; case 108: -#line 1229 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1228 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ParamAttrs) = ParamAttr::SExt; ;} break; case 109: -#line 1230 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1229 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ParamAttrs) = ParamAttr::InReg; ;} break; case 110: -#line 1231 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1230 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ParamAttrs) = ParamAttr::StructRet; ;} break; case 111: -#line 1232 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1231 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ParamAttrs) = ParamAttr::NoAlias; ;} break; case 112: -#line 1233 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1232 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ParamAttrs) = ParamAttr::ByVal; ;} break; case 113: -#line 1234 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1233 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ParamAttrs) = ParamAttr::Nest; ;} break; case 114: -#line 1235 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1234 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ParamAttrs) = ParamAttr::constructAlignmentFromInt((yyvsp[(2) - (2)].UInt64Val)); ;} break; case 115: -#line 1239 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1238 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ParamAttrs) = ParamAttr::None; ;} break; case 116: -#line 1240 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1239 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs); ;} break; case 117: -#line 1245 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1244 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ParamAttrs) = ParamAttr::NoReturn; ;} break; case 118: -#line 1246 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1245 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ParamAttrs) = ParamAttr::NoUnwind; ;} break; case 119: -#line 1247 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1246 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ParamAttrs) = ParamAttr::ZExt; ;} break; case 120: -#line 1248 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1247 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ParamAttrs) = ParamAttr::SExt; ;} break; case 121: -#line 1249 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1248 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ParamAttrs) = ParamAttr::ReadNone; ;} break; case 122: -#line 1250 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1249 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ParamAttrs) = ParamAttr::ReadOnly; ;} break; case 123: -#line 1253 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1252 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ParamAttrs) = ParamAttr::None; ;} break; case 124: -#line 1254 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1253 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs); ;} break; case 125: -#line 1259 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1258 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.StrVal) = 0; ;} break; case 126: -#line 1260 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1259 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal); ;} break; case 127: -#line 1267 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1266 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.UIntVal) = 0; ;} break; case 128: -#line 1268 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1267 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val); if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) @@ -3950,12 +3934,12 @@ break; case 129: -#line 1274 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1273 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.UIntVal) = 0; ;} break; case 130: -#line 1275 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1274 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val); if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) @@ -3965,7 +3949,7 @@ break; case 131: -#line 1284 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1283 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { for (unsigned i = 0, e = (yyvsp[(2) - (2)].StrVal)->length(); i != e; ++i) if ((*(yyvsp[(2) - (2)].StrVal))[i] == '"' || (*(yyvsp[(2) - (2)].StrVal))[i] == '\\') @@ -3976,27 +3960,27 @@ break; case 132: -#line 1292 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1291 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.StrVal) = 0; ;} break; case 133: -#line 1293 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1292 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;} break; case 134: -#line 1298 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1297 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" {;} break; case 135: -#line 1299 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1298 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" {;} break; case 136: -#line 1300 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1299 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { CurGV->setSection(*(yyvsp[(1) - (1)].StrVal)); delete (yyvsp[(1) - (1)].StrVal); @@ -4005,7 +3989,7 @@ break; case 137: -#line 1305 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1304 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val))) GEN_ERROR("Alignment must be a power of two"); @@ -4015,7 +3999,7 @@ break; case 145: -#line 1321 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1320 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.TypeVal) = new PATypeHolder(OpaqueType::get()); CHECK_FOR_ERROR @@ -4023,7 +4007,7 @@ break; case 146: -#line 1325 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1324 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.TypeVal) = new PATypeHolder((yyvsp[(1) - (1)].PrimType)); CHECK_FOR_ERROR @@ -4031,7 +4015,7 @@ break; case 147: -#line 1329 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1328 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // Pointer type? if (*(yyvsp[(1) - (3)].TypeVal) == Type::LabelTy) GEN_ERROR("Cannot form a pointer to a basic block"); @@ -4042,7 +4026,7 @@ break; case 148: -#line 1336 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1335 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // Named types are also simple types... const Type* tmp = getTypeVal((yyvsp[(1) - (1)].ValIDVal)); CHECK_FOR_ERROR @@ -4051,7 +4035,7 @@ break; case 149: -#line 1341 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1340 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // Type UpReference if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range"); OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder @@ -4063,7 +4047,7 @@ break; case 150: -#line 1349 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1348 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // Allow but ignore attributes on function types; this permits auto-upgrade. // FIXME: remove in LLVM 3.0. @@ -4096,7 +4080,7 @@ break; case 151: -#line 1378 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1377 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // Allow but ignore attributes on function types; this permits auto-upgrade. // FIXME: remove in LLVM 3.0. @@ -4124,7 +4108,7 @@ break; case 152: -#line 1403 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1402 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // Sized array type? (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val)))); delete (yyvsp[(4) - (5)].TypeVal); @@ -4133,7 +4117,7 @@ break; case 153: -#line 1408 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1407 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // Vector type? const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal)->get(); if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val)) @@ -4147,7 +4131,7 @@ break; case 154: -#line 1418 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1417 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // Structure type? std::vector Elements; for (std::list::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(), @@ -4161,7 +4145,7 @@ break; case 155: -#line 1428 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1427 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // Empty structure type? (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector())); CHECK_FOR_ERROR @@ -4169,7 +4153,7 @@ break; case 156: -#line 1432 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1431 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { std::vector Elements; for (std::list::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(), @@ -4183,7 +4167,7 @@ break; case 157: -#line 1442 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1441 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // Empty structure type? (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector(), true)); CHECK_FOR_ERROR @@ -4191,7 +4175,7 @@ break; case 158: -#line 1449 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1448 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // Allow but ignore attributes on function types; this permits auto-upgrade. // FIXME: remove in LLVM 3.0. @@ -4201,7 +4185,7 @@ break; case 159: -#line 1458 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1457 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal))->getDescription()); @@ -4212,14 +4196,14 @@ break; case 160: -#line 1465 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1464 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.TypeVal) = new PATypeHolder(Type::VoidTy); ;} break; case 161: -#line 1470 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1469 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.TypeWithAttrsList) = new TypeWithAttrsList(); (yyval.TypeWithAttrsList)->push_back((yyvsp[(1) - (1)].TypeWithAttrs)); @@ -4228,7 +4212,7 @@ break; case 162: -#line 1475 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1474 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { ((yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList))->push_back((yyvsp[(3) - (3)].TypeWithAttrs)); CHECK_FOR_ERROR @@ -4236,7 +4220,7 @@ break; case 164: -#line 1483 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1482 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList); TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None; @@ -4247,7 +4231,7 @@ break; case 165: -#line 1490 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1489 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.TypeWithAttrsList) = new TypeWithAttrsList; TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None; @@ -4258,7 +4242,7 @@ break; case 166: -#line 1497 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1496 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.TypeWithAttrsList) = new TypeWithAttrsList(); CHECK_FOR_ERROR @@ -4266,7 +4250,7 @@ break; case 167: -#line 1505 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1504 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.TypeList) = new std::list(); (yyval.TypeList)->push_back(*(yyvsp[(1) - (1)].TypeVal)); @@ -4276,7 +4260,7 @@ break; case 168: -#line 1511 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1510 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(*(yyvsp[(3) - (3)].TypeVal)); delete (yyvsp[(3) - (3)].TypeVal); @@ -4285,7 +4269,7 @@ break; case 169: -#line 1523 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1522 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // Nonempty unsized arr if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription()); @@ -4317,7 +4301,7 @@ break; case 170: -#line 1551 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1550 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription()); @@ -4337,7 +4321,7 @@ break; case 171: -#line 1567 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1566 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription()); @@ -4368,7 +4352,7 @@ break; case 172: -#line 1594 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1593 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // Nonempty unsized arr if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription()); @@ -4400,7 +4384,7 @@ break; case 173: -#line 1622 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1621 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { const StructType *STy = dyn_cast((yyvsp[(1) - (4)].TypeVal)->get()); if (STy == 0) @@ -4430,7 +4414,7 @@ break; case 174: -#line 1648 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1647 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription()); @@ -4454,7 +4438,7 @@ break; case 175: -#line 1668 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1667 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { const StructType *STy = dyn_cast((yyvsp[(1) - (6)].TypeVal)->get()); if (STy == 0) @@ -4484,7 +4468,7 @@ break; case 176: -#line 1694 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1693 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (5)].TypeVal))->getDescription()); @@ -4508,7 +4492,7 @@ break; case 177: -#line 1714 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1713 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription()); @@ -4524,7 +4508,7 @@ break; case 178: -#line 1726 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1725 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription()); @@ -4535,7 +4519,7 @@ break; case 179: -#line 1733 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1732 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription()); @@ -4605,7 +4589,7 @@ break; case 180: -#line 1799 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1798 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription()); @@ -4619,7 +4603,7 @@ break; case 181: -#line 1809 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1808 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription()); @@ -4633,7 +4617,7 @@ break; case 182: -#line 1819 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1818 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // integral constants if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val))) GEN_ERROR("Constant value doesn't fit in type"); @@ -4643,7 +4627,7 @@ break; case 183: -#line 1825 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1824 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // arbitrary precision integer constants uint32_t BitWidth = cast((yyvsp[(1) - (2)].PrimType))->getBitWidth(); if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) { @@ -4657,7 +4641,7 @@ break; case 184: -#line 1835 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1834 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // integral constants if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val))) GEN_ERROR("Constant value doesn't fit in type"); @@ -4667,7 +4651,7 @@ break; case 185: -#line 1841 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1840 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // arbitrary precision integer constants uint32_t BitWidth = cast((yyvsp[(1) - (2)].PrimType))->getBitWidth(); if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) { @@ -4681,7 +4665,7 @@ break; case 186: -#line 1851 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1850 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // Boolean constants assert(cast((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?"); (yyval.ConstVal) = ConstantInt::getTrue(); @@ -4690,7 +4674,7 @@ break; case 187: -#line 1856 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1855 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // Boolean constants assert(cast((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?"); (yyval.ConstVal) = ConstantInt::getFalse(); @@ -4699,7 +4683,7 @@ break; case 188: -#line 1861 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1860 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // Floating point constants if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType), *(yyvsp[(2) - (2)].FPVal))) GEN_ERROR("Floating point constant invalid for type"); @@ -4714,7 +4698,7 @@ break; case 189: -#line 1874 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1873 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (6)].TypeVal))->getDescription()); @@ -4730,7 +4714,7 @@ break; case 190: -#line 1886 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1885 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!isa((yyvsp[(3) - (5)].ConstVal)->getType())) GEN_ERROR("GetElementPtr requires a pointer operand"); @@ -4756,7 +4740,7 @@ break; case 191: -#line 1908 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1907 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if ((yyvsp[(3) - (8)].ConstVal)->getType() != Type::Int1Ty) GEN_ERROR("Select condition must be of boolean type"); @@ -4768,7 +4752,7 @@ break; case 192: -#line 1916 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1915 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType()) GEN_ERROR("Binary operator types must match"); @@ -4778,7 +4762,7 @@ break; case 193: -#line 1922 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1921 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType()) GEN_ERROR("Logical operator types must match"); @@ -4793,7 +4777,7 @@ break; case 194: -#line 1933 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1932 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType()) GEN_ERROR("icmp operand types must match"); @@ -4802,7 +4786,7 @@ break; case 195: -#line 1938 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1937 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType()) GEN_ERROR("fcmp operand types must match"); @@ -4811,7 +4795,7 @@ break; case 196: -#line 1943 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1942 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal))) GEN_ERROR("Invalid extractelement operands"); @@ -4821,7 +4805,7 @@ break; case 197: -#line 1949 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1948 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal))) GEN_ERROR("Invalid insertelement operands"); @@ -4831,7 +4815,7 @@ break; case 198: -#line 1955 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1954 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal))) GEN_ERROR("Invalid shufflevector operands"); @@ -4841,7 +4825,7 @@ break; case 199: -#line 1964 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1963 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal)); CHECK_FOR_ERROR @@ -4849,7 +4833,7 @@ break; case 200: -#line 1968 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1967 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ConstVector) = new std::vector(); (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal)); @@ -4858,27 +4842,27 @@ break; case 201: -#line 1976 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1975 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.BoolVal) = false; ;} break; case 202: -#line 1976 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1975 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.BoolVal) = true; ;} break; case 203: -#line 1979 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1978 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.BoolVal) = true; ;} break; case 204: -#line 1979 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1978 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.BoolVal) = false; ;} break; case 205: -#line 1982 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1981 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { const Type* VTy = (yyvsp[(1) - (2)].TypeVal)->get(); Value *V = getVal(VTy, (yyvsp[(2) - (2)].ValIDVal)); @@ -4894,7 +4878,7 @@ break; case 206: -#line 1994 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 1993 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { Constant *Val = (yyvsp[(3) - (6)].ConstVal); const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get(); @@ -4910,7 +4894,7 @@ break; case 207: -#line 2015 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2014 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule; CurModule.ModuleDone(); @@ -4919,7 +4903,7 @@ break; case 208: -#line 2020 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2019 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule; CurModule.ModuleDone(); @@ -4928,12 +4912,12 @@ break; case 211: -#line 2033 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2032 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { CurFun.isDeclare = false; ;} break; case 212: -#line 2033 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2032 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { CurFun.FunctionDone(); CHECK_FOR_ERROR @@ -4941,26 +4925,26 @@ break; case 213: -#line 2037 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2036 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { CurFun.isDeclare = true; ;} break; case 214: -#line 2037 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2036 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { CHECK_FOR_ERROR ;} break; case 215: -#line 2040 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2039 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { CHECK_FOR_ERROR ;} break; case 216: -#line 2043 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2042 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (3)].TypeVal))->getDescription()); @@ -4988,7 +4972,7 @@ break; case 217: -#line 2067 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2066 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { ResolveTypeTo((yyvsp[(1) - (3)].StrVal), (yyvsp[(3) - (3)].PrimType)); @@ -5003,7 +4987,7 @@ break; case 218: -#line 2079 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2078 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { /* "Externally Visible" Linkage */ if ((yyvsp[(5) - (6)].ConstVal) == 0) @@ -5015,14 +4999,14 @@ break; case 219: -#line 2086 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2085 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { CurGV = 0; ;} break; case 220: -#line 2090 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2089 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if ((yyvsp[(6) - (7)].ConstVal) == 0) GEN_ERROR("Global value initializer is not a constant"); @@ -5032,14 +5016,14 @@ break; case 221: -#line 2095 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2094 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { CurGV = 0; ;} break; case 222: -#line 2099 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2098 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(6) - (7)].TypeVal))->getDescription()); @@ -5050,7 +5034,7 @@ break; case 223: -#line 2105 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2104 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { CurGV = 0; CHECK_FOR_ERROR @@ -5058,7 +5042,7 @@ break; case 224: -#line 2109 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2108 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { std::string Name; if ((yyvsp[(1) - (5)].StrVal)) { @@ -5102,21 +5086,21 @@ break; case 225: -#line 2149 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2148 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { CHECK_FOR_ERROR ;} break; case 226: -#line 2152 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2151 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { CHECK_FOR_ERROR ;} break; case 227: -#line 2158 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2157 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm(); if (AsmSoFar.empty()) @@ -5129,7 +5113,7 @@ break; case 228: -#line 2168 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2167 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { CurModule.CurrentModule->setTargetTriple(*(yyvsp[(3) - (3)].StrVal)); delete (yyvsp[(3) - (3)].StrVal); @@ -5137,7 +5121,7 @@ break; case 229: -#line 2172 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2171 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { CurModule.CurrentModule->setDataLayout(*(yyvsp[(3) - (3)].StrVal)); delete (yyvsp[(3) - (3)].StrVal); @@ -5145,7 +5129,7 @@ break; case 231: -#line 2179 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2178 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { CurModule.CurrentModule->addLibrary(*(yyvsp[(3) - (3)].StrVal)); delete (yyvsp[(3) - (3)].StrVal); @@ -5154,7 +5138,7 @@ break; case 232: -#line 2184 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2183 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { CurModule.CurrentModule->addLibrary(*(yyvsp[(1) - (1)].StrVal)); delete (yyvsp[(1) - (1)].StrVal); @@ -5163,14 +5147,14 @@ break; case 233: -#line 2189 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2188 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { CHECK_FOR_ERROR ;} break; case 234: -#line 2198 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2197 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription()); @@ -5184,7 +5168,7 @@ break; case 235: -#line 2208 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2207 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription()); @@ -5198,7 +5182,7 @@ break; case 236: -#line 2219 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2218 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList); CHECK_FOR_ERROR @@ -5206,7 +5190,7 @@ break; case 237: -#line 2223 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2222 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList); struct ArgListEntry E; @@ -5219,7 +5203,7 @@ break; case 238: -#line 2232 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2231 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ArgList) = new ArgListType; struct ArgListEntry E; @@ -5232,7 +5216,7 @@ break; case 239: -#line 2241 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2240 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ArgList) = 0; CHECK_FOR_ERROR @@ -5240,7 +5224,7 @@ break; case 240: -#line 2247 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2246 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { std::string FunctionName(*(yyvsp[(3) - (10)].StrVal)); delete (yyvsp[(3) - (10)].StrVal); // Free strdup'd memory! @@ -5371,7 +5355,7 @@ break; case 243: -#line 2377 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2376 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.FunctionVal) = CurFun.CurrentFunction; @@ -5383,7 +5367,7 @@ break; case 246: -#line 2388 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2387 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal); CHECK_FOR_ERROR @@ -5391,7 +5375,7 @@ break; case 247: -#line 2393 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2392 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { CurFun.CurrentFunction->setLinkage((yyvsp[(1) - (3)].Linkage)); CurFun.CurrentFunction->setVisibility((yyvsp[(2) - (3)].Visibility)); @@ -5402,7 +5386,7 @@ break; case 248: -#line 2405 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2404 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.BoolVal) = false; CHECK_FOR_ERROR @@ -5410,7 +5394,7 @@ break; case 249: -#line 2409 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2408 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.BoolVal) = true; CHECK_FOR_ERROR @@ -5418,7 +5402,7 @@ break; case 250: -#line 2414 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2413 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // A reference to a direct constant (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val)); CHECK_FOR_ERROR @@ -5426,7 +5410,7 @@ break; case 251: -#line 2418 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2417 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val)); CHECK_FOR_ERROR @@ -5434,7 +5418,7 @@ break; case 252: -#line 2422 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2421 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // Perhaps it's an FP constant? (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal)); CHECK_FOR_ERROR @@ -5442,7 +5426,7 @@ break; case 253: -#line 2426 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2425 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue()); CHECK_FOR_ERROR @@ -5450,7 +5434,7 @@ break; case 254: -#line 2430 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2429 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse()); CHECK_FOR_ERROR @@ -5458,7 +5442,7 @@ break; case 255: -#line 2434 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2433 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ValIDVal) = ValID::createNull(); CHECK_FOR_ERROR @@ -5466,7 +5450,7 @@ break; case 256: -#line 2438 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2437 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ValIDVal) = ValID::createUndef(); CHECK_FOR_ERROR @@ -5474,7 +5458,7 @@ break; case 257: -#line 2442 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2441 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // A vector zero constant. (yyval.ValIDVal) = ValID::createZeroInit(); CHECK_FOR_ERROR @@ -5482,7 +5466,7 @@ break; case 258: -#line 2446 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2445 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // Nonempty unsized packed vector const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType(); int NumElements = (yyvsp[(2) - (3)].ConstVector)->size(); @@ -5511,7 +5495,7 @@ break; case 259: -#line 2471 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2470 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal)); CHECK_FOR_ERROR @@ -5519,7 +5503,7 @@ break; case 260: -#line 2475 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2474 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ValIDVal) = ValID::createInlineAsm(*(yyvsp[(3) - (5)].StrVal), *(yyvsp[(5) - (5)].StrVal), (yyvsp[(2) - (5)].BoolVal)); delete (yyvsp[(3) - (5)].StrVal); @@ -5529,7 +5513,7 @@ break; case 261: -#line 2485 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2484 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // Is it an integer reference...? (yyval.ValIDVal) = ValID::createLocalID((yyvsp[(1) - (1)].UIntVal)); CHECK_FOR_ERROR @@ -5537,7 +5521,7 @@ break; case 262: -#line 2489 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2488 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[(1) - (1)].UIntVal)); CHECK_FOR_ERROR @@ -5545,7 +5529,7 @@ break; case 263: -#line 2493 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2492 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // Is it a named reference...? (yyval.ValIDVal) = ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal)); delete (yyvsp[(1) - (1)].StrVal); @@ -5554,7 +5538,7 @@ break; case 264: -#line 2498 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2497 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // Is it a named reference...? (yyval.ValIDVal) = ValID::createGlobalName(*(yyvsp[(1) - (1)].StrVal)); delete (yyvsp[(1) - (1)].StrVal); @@ -5563,7 +5547,7 @@ break; case 267: -#line 2511 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2510 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription()); @@ -5574,7 +5558,7 @@ break; case 268: -#line 2520 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2519 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ValueList) = new std::vector(); (yyval.ValueList)->push_back((yyvsp[(1) - (1)].ValueVal)); @@ -5583,7 +5567,7 @@ break; case 269: -#line 2525 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2524 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { ((yyval.ValueList)=(yyvsp[(1) - (3)].ValueList))->push_back((yyvsp[(3) - (3)].ValueVal)); CHECK_FOR_ERROR @@ -5591,7 +5575,7 @@ break; case 270: -#line 2530 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2529 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal); CHECK_FOR_ERROR @@ -5599,7 +5583,7 @@ break; case 271: -#line 2534 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2533 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // Do not allow functions with 0 basic blocks (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal); CHECK_FOR_ERROR @@ -5607,7 +5591,7 @@ break; case 272: -#line 2543 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2542 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal)); CHECK_FOR_ERROR @@ -5619,7 +5603,7 @@ break; case 273: -#line 2552 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2551 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (CastInst *CI1 = dyn_cast((yyvsp[(2) - (2)].InstVal))) if (CastInst *CI2 = dyn_cast(CI1->getOperand(0))) @@ -5632,41 +5616,25 @@ break; case 274: -#line 2561 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2560 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // Empty space between instruction lists - (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum), 0); + (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum)); CHECK_FOR_ERROR ;} break; case 275: -#line 2565 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" - { // Only the unwind to block - (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum), getBBVal((yyvsp[(3) - (3)].ValIDVal))); - CHECK_FOR_ERROR - ;} - break; - - case 276: -#line 2569 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 2564 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // Labelled (named) basic block - (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal)), 0); + (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal))); delete (yyvsp[(1) - (1)].StrVal); CHECK_FOR_ERROR - ;} - break; - case 277: -#line 2574 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" - { - (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName(*(yyvsp[(1) - (4)].StrVal)), getBBVal((yyvsp[(4) - (4)].ValIDVal))); - delete (yyvsp[(1) - (4)].StrVal); - CHECK_FOR_ERROR ;} break; - case 278: -#line 2581 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 276: +#line 2572 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // Return with a result... ValueList &VL = *(yyvsp[(2) - (2)].ValueList); assert(!VL.empty() && "Invalid ret operands!"); @@ -5676,16 +5644,16 @@ ;} break; - case 279: -#line 2588 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 277: +#line 2579 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // Return with no result... (yyval.TermInstVal) = ReturnInst::Create(); CHECK_FOR_ERROR ;} break; - case 280: -#line 2592 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 278: +#line 2583 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // Unconditional Branch... BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal)); CHECK_FOR_ERROR @@ -5693,8 +5661,8 @@ ;} break; - case 281: -#line 2597 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 279: +#line 2588 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { assert(cast((yyvsp[(2) - (9)].PrimType))->getBitWidth() == 1 && "Not Bool?"); BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal)); @@ -5707,8 +5675,8 @@ ;} break; - case 282: -#line 2607 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 280: +#line 2598 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType), (yyvsp[(3) - (9)].ValIDVal)); CHECK_FOR_ERROR @@ -5730,8 +5698,8 @@ ;} break; - case 283: -#line 2626 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 281: +#line 2617 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType), (yyvsp[(3) - (8)].ValIDVal)); CHECK_FOR_ERROR @@ -5743,8 +5711,8 @@ ;} break; - case 284: -#line 2636 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 282: +#line 2627 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // Handle the short syntax @@ -5831,24 +5799,24 @@ ;} break; - case 285: -#line 2720 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 283: +#line 2711 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.TermInstVal) = new UnwindInst(); CHECK_FOR_ERROR ;} break; - case 286: -#line 2724 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 284: +#line 2715 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.TermInstVal) = new UnreachableInst(); CHECK_FOR_ERROR ;} break; - case 287: -#line 2731 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 285: +#line 2722 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable); Constant *V = cast(getExistingVal((yyvsp[(2) - (6)].PrimType), (yyvsp[(3) - (6)].ValIDVal))); @@ -5862,8 +5830,8 @@ ;} break; - case 288: -#line 2742 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 286: +#line 2733 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.JumpTable) = new std::vector >(); Constant *V = cast(getExistingVal((yyvsp[(1) - (5)].PrimType), (yyvsp[(2) - (5)].ValIDVal))); @@ -5878,8 +5846,8 @@ ;} break; - case 289: -#line 2755 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 287: +#line 2746 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // Is this definition named?? if so, assign the name... setValueName((yyvsp[(2) - (2)].InstVal), (yyvsp[(1) - (2)].StrVal)); @@ -5890,8 +5858,8 @@ ;} break; - case 290: -#line 2765 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 288: +#line 2756 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // Used for PHI nodes if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (6)].TypeVal))->getDescription()); @@ -5905,8 +5873,8 @@ ;} break; - case 291: -#line 2776 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 289: +#line 2767 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList); Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList)->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal)); @@ -5917,8 +5885,8 @@ ;} break; - case 292: -#line 2786 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 290: +#line 2777 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0 if (!UpRefs.empty()) @@ -5932,8 +5900,8 @@ ;} break; - case 293: -#line 2797 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 291: +#line 2788 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0 // Labels are only valid in ASMs @@ -5944,8 +5912,8 @@ ;} break; - case 294: -#line 2805 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 292: +#line 2796 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0 if (!UpRefs.empty()) @@ -5958,8 +5926,8 @@ ;} break; - case 295: -#line 2815 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 293: +#line 2806 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0 (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList); @@ -5969,18 +5937,18 @@ ;} break; - case 296: -#line 2822 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 294: +#line 2813 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ParamList) = new ParamList(); ;} break; - case 297: -#line 2825 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 295: +#line 2816 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ValueList) = new std::vector(); ;} break; - case 298: -#line 2826 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 296: +#line 2817 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList); (yyval.ValueList)->push_back((yyvsp[(3) - (3)].ValueVal)); @@ -5988,24 +5956,24 @@ ;} break; - case 299: -#line 2833 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 297: +#line 2824 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.BoolVal) = true; CHECK_FOR_ERROR ;} break; - case 300: -#line 2837 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 298: +#line 2828 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.BoolVal) = false; CHECK_FOR_ERROR ;} break; - case 301: -#line 2842 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 299: +#line 2833 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription()); @@ -6024,8 +5992,8 @@ ;} break; - case 302: -#line 2858 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 300: +#line 2849 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription()); @@ -6045,8 +6013,8 @@ ;} break; - case 303: -#line 2875 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 301: +#line 2866 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription()); @@ -6063,8 +6031,8 @@ ;} break; - case 304: -#line 2889 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 302: +#line 2880 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription()); @@ -6081,8 +6049,8 @@ ;} break; - case 305: -#line 2903 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 303: +#line 2894 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription()); @@ -6097,8 +6065,8 @@ ;} break; - case 306: -#line 2915 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 304: +#line 2906 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if ((yyvsp[(2) - (6)].ValueVal)->getType() != Type::Int1Ty) GEN_ERROR("select condition must be boolean"); @@ -6109,8 +6077,8 @@ ;} break; - case 307: -#line 2923 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 305: +#line 2914 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription()); @@ -6120,8 +6088,8 @@ ;} break; - case 308: -#line 2930 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 306: +#line 2921 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal))) GEN_ERROR("Invalid extractelement operands"); @@ -6130,8 +6098,8 @@ ;} break; - case 309: -#line 2936 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 307: +#line 2927 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal))) GEN_ERROR("Invalid insertelement operands"); @@ -6140,8 +6108,8 @@ ;} break; - case 310: -#line 2942 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 308: +#line 2933 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal))) GEN_ERROR("Invalid shufflevector operands"); @@ -6150,8 +6118,8 @@ ;} break; - case 311: -#line 2948 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 309: +#line 2939 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { const Type *Ty = (yyvsp[(2) - (2)].PHIList)->front().first->getType(); if (!Ty->isFirstClassType()) @@ -6169,8 +6137,8 @@ ;} break; - case 312: -#line 2964 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 310: +#line 2955 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { // Handle the short syntax @@ -6262,32 +6230,32 @@ ;} break; - case 313: -#line 3053 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 311: +#line 3044 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal); CHECK_FOR_ERROR ;} break; - case 314: -#line 3058 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 312: +#line 3049 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.BoolVal) = true; CHECK_FOR_ERROR ;} break; - case 315: -#line 3062 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 313: +#line 3053 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.BoolVal) = false; CHECK_FOR_ERROR ;} break; - case 316: -#line 3069 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 314: +#line 3060 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription()); @@ -6297,8 +6265,8 @@ ;} break; - case 317: -#line 3076 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 315: +#line 3067 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription()); @@ -6309,8 +6277,8 @@ ;} break; - case 318: -#line 3084 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 316: +#line 3075 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription()); @@ -6320,8 +6288,8 @@ ;} break; - case 319: -#line 3091 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 317: +#line 3082 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription()); @@ -6332,8 +6300,8 @@ ;} break; - case 320: -#line 3099 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 318: +#line 3090 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!isa((yyvsp[(2) - (2)].ValueVal)->getType())) GEN_ERROR("Trying to free nonpointer type " + @@ -6343,8 +6311,8 @@ ;} break; - case 321: -#line 3107 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 319: +#line 3098 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription()); @@ -6361,8 +6329,8 @@ ;} break; - case 322: -#line 3121 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 320: +#line 3112 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (7)].TypeVal))->getDescription()); @@ -6382,8 +6350,8 @@ ;} break; - case 323: -#line 3138 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 321: +#line 3129 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { Value *TmpVal = getVal((yyvsp[(2) - (5)].TypeVal)->get(), (yyvsp[(3) - (5)].ValIDVal)); if (!GetResultInst::isValidOperands(TmpVal, (yyvsp[(5) - (5)].UInt64Val))) @@ -6394,8 +6362,8 @@ ;} break; - case 324: -#line 3146 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" + case 322: +#line 3137 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription()); @@ -6415,7 +6383,7 @@ /* Line 1267 of yacc.c. */ -#line 6419 "llvmAsmParser.tab.c" +#line 6387 "llvmAsmParser.tab.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -6629,7 +6597,7 @@ } -#line 3163 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 3154 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" // common code from the two 'RunVMAsmParser' functions Modified: llvm/trunk/lib/AsmParser/llvmAsmParser.h.cvs URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/llvmAsmParser.h.cvs?rev=50621&r1=50620&r2=50621&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/llvmAsmParser.h.cvs (original) +++ llvm/trunk/lib/AsmParser/llvmAsmParser.h.cvs Sun May 4 12:18:47 2008 @@ -104,90 +104,89 @@ X86_STDCALLCC_TOK = 320, X86_FASTCALLCC_TOK = 321, DATALAYOUT = 322, - UNWINDS = 323, - RET = 324, - BR = 325, - SWITCH = 326, - INVOKE = 327, - UNWIND = 328, - UNREACHABLE = 329, - ADD = 330, - SUB = 331, - MUL = 332, - UDIV = 333, - SDIV = 334, - FDIV = 335, - UREM = 336, - SREM = 337, - FREM = 338, - AND = 339, - OR = 340, - XOR = 341, - SHL = 342, - LSHR = 343, - ASHR = 344, - ICMP = 345, - FCMP = 346, - EQ = 347, - NE = 348, - SLT = 349, - SGT = 350, - SLE = 351, - SGE = 352, - ULT = 353, - UGT = 354, - ULE = 355, - UGE = 356, - OEQ = 357, - ONE = 358, - OLT = 359, - OGT = 360, - OLE = 361, - OGE = 362, - ORD = 363, - UNO = 364, - UEQ = 365, - UNE = 366, - MALLOC = 367, - ALLOCA = 368, - FREE = 369, - LOAD = 370, - STORE = 371, - GETELEMENTPTR = 372, - TRUNC = 373, - ZEXT = 374, - SEXT = 375, - FPTRUNC = 376, - FPEXT = 377, - BITCAST = 378, - UITOFP = 379, - SITOFP = 380, - FPTOUI = 381, - FPTOSI = 382, - INTTOPTR = 383, - PTRTOINT = 384, - PHI_TOK = 385, - SELECT = 386, - VAARG = 387, - EXTRACTELEMENT = 388, - INSERTELEMENT = 389, - SHUFFLEVECTOR = 390, - GETRESULT = 391, - SIGNEXT = 392, - ZEROEXT = 393, - NORETURN = 394, - INREG = 395, - SRET = 396, - NOUNWIND = 397, - NOALIAS = 398, - BYVAL = 399, - NEST = 400, - READNONE = 401, - READONLY = 402, - GC = 403, - DEFAULT = 404, - HIDDEN = 405, - PROTECTED = 406 + RET = 323, + BR = 324, + SWITCH = 325, + INVOKE = 326, + UNWIND = 327, + UNREACHABLE = 328, + ADD = 329, + SUB = 330, + MUL = 331, + UDIV = 332, + SDIV = 333, + FDIV = 334, + UREM = 335, + SREM = 336, + FREM = 337, + AND = 338, + OR = 339, + XOR = 340, + SHL = 341, + LSHR = 342, + ASHR = 343, + ICMP = 344, + FCMP = 345, + EQ = 346, + NE = 347, + SLT = 348, + SGT = 349, + SLE = 350, + SGE = 351, + ULT = 352, + UGT = 353, + ULE = 354, + UGE = 355, + OEQ = 356, + ONE = 357, + OLT = 358, + OGT = 359, + OLE = 360, + OGE = 361, + ORD = 362, + UNO = 363, + UEQ = 364, + UNE = 365, + MALLOC = 366, + ALLOCA = 367, + FREE = 368, + LOAD = 369, + STORE = 370, + GETELEMENTPTR = 371, + TRUNC = 372, + ZEXT = 373, + SEXT = 374, + FPTRUNC = 375, + FPEXT = 376, + BITCAST = 377, + UITOFP = 378, + SITOFP = 379, + FPTOUI = 380, + FPTOSI = 381, + INTTOPTR = 382, + PTRTOINT = 383, + PHI_TOK = 384, + SELECT = 385, + VAARG = 386, + EXTRACTELEMENT = 387, + INSERTELEMENT = 388, + SHUFFLEVECTOR = 389, + GETRESULT = 390, + SIGNEXT = 391, + ZEROEXT = 392, + NORETURN = 393, + INREG = 394, + SRET = 395, + NOUNWIND = 396, + NOALIAS = 397, + BYVAL = 398, + NEST = 399, + READNONE = 400, + READONLY = 401, + GC = 402, + DEFAULT = 403, + HIDDEN = 404, + PROTECTED = 405 }; #endif /* Tokens. */ @@ -256,97 +255,96 @@ #define X86_STDCALLCC_TOK 320 #define X86_FASTCALLCC_TOK 321 #define DATALAYOUT 322 -#define UNWINDS 323 -#define RET 324 -#define BR 325 -#define SWITCH 326 -#define INVOKE 327 -#define UNWIND 328 -#define UNREACHABLE 329 -#define ADD 330 -#define SUB 331 -#define MUL 332 -#define UDIV 333 -#define SDIV 334 -#define FDIV 335 -#define UREM 336 -#define SREM 337 -#define FREM 338 -#define AND 339 -#define OR 340 -#define XOR 341 -#define SHL 342 -#define LSHR 343 -#define ASHR 344 -#define ICMP 345 -#define FCMP 346 -#define EQ 347 -#define NE 348 -#define SLT 349 -#define SGT 350 -#define SLE 351 -#define SGE 352 -#define ULT 353 -#define UGT 354 -#define ULE 355 -#define UGE 356 -#define OEQ 357 -#define ONE 358 -#define OLT 359 -#define OGT 360 -#define OLE 361 -#define OGE 362 -#define ORD 363 -#define UNO 364 -#define UEQ 365 -#define UNE 366 -#define MALLOC 367 -#define ALLOCA 368 -#define FREE 369 -#define LOAD 370 -#define STORE 371 -#define GETELEMENTPTR 372 -#define TRUNC 373 -#define ZEXT 374 -#define SEXT 375 -#define FPTRUNC 376 -#define FPEXT 377 -#define BITCAST 378 -#define UITOFP 379 -#define SITOFP 380 -#define FPTOUI 381 -#define FPTOSI 382 -#define INTTOPTR 383 -#define PTRTOINT 384 -#define PHI_TOK 385 -#define SELECT 386 -#define VAARG 387 -#define EXTRACTELEMENT 388 -#define INSERTELEMENT 389 -#define SHUFFLEVECTOR 390 -#define GETRESULT 391 -#define SIGNEXT 392 -#define ZEROEXT 393 -#define NORETURN 394 -#define INREG 395 -#define SRET 396 -#define NOUNWIND 397 -#define NOALIAS 398 -#define BYVAL 399 -#define NEST 400 -#define READNONE 401 -#define READONLY 402 -#define GC 403 -#define DEFAULT 404 -#define HIDDEN 405 -#define PROTECTED 406 +#define RET 323 +#define BR 324 +#define SWITCH 325 +#define INVOKE 326 +#define UNWIND 327 +#define UNREACHABLE 328 +#define ADD 329 +#define SUB 330 +#define MUL 331 +#define UDIV 332 +#define SDIV 333 +#define FDIV 334 +#define UREM 335 +#define SREM 336 +#define FREM 337 +#define AND 338 +#define OR 339 +#define XOR 340 +#define SHL 341 +#define LSHR 342 +#define ASHR 343 +#define ICMP 344 +#define FCMP 345 +#define EQ 346 +#define NE 347 +#define SLT 348 +#define SGT 349 +#define SLE 350 +#define SGE 351 +#define ULT 352 +#define UGT 353 +#define ULE 354 +#define UGE 355 +#define OEQ 356 +#define ONE 357 +#define OLT 358 +#define OGT 359 +#define OLE 360 +#define OGE 361 +#define ORD 362 +#define UNO 363 +#define UEQ 364 +#define UNE 365 +#define MALLOC 366 +#define ALLOCA 367 +#define FREE 368 +#define LOAD 369 +#define STORE 370 +#define GETELEMENTPTR 371 +#define TRUNC 372 +#define ZEXT 373 +#define SEXT 374 +#define FPTRUNC 375 +#define FPEXT 376 +#define BITCAST 377 +#define UITOFP 378 +#define SITOFP 379 +#define FPTOUI 380 +#define FPTOSI 381 +#define INTTOPTR 382 +#define PTRTOINT 383 +#define PHI_TOK 384 +#define SELECT 385 +#define VAARG 386 +#define EXTRACTELEMENT 387 +#define INSERTELEMENT 388 +#define SHUFFLEVECTOR 389 +#define GETRESULT 390 +#define SIGNEXT 391 +#define ZEROEXT 392 +#define NORETURN 393 +#define INREG 394 +#define SRET 395 +#define NOUNWIND 396 +#define NOALIAS 397 +#define BYVAL 398 +#define NEST 399 +#define READNONE 400 +#define READONLY 401 +#define GC 402 +#define DEFAULT 403 +#define HIDDEN 404 +#define PROTECTED 405 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -#line 950 "/Users/gohman/LLVM/llvm/lib/AsmParser/llvmAsmParser.y" +#line 949 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y" { llvm::Module *ModuleVal; llvm::Function *FunctionVal; @@ -394,7 +392,7 @@ llvm::FCmpInst::Predicate FPredicate; } /* Line 1529 of yacc.c. */ -#line 398 "llvmAsmParser.tab.h" +#line 396 "llvmAsmParser.tab.h" YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 From clattner at apple.com Sun May 4 13:08:38 2008 From: clattner at apple.com (Chris Lattner) Date: Sun, 4 May 2008 11:08:38 -0700 Subject: [llvm-commits] [PATCH] PostDominators: avoid memory leak In-Reply-To: <481D794B.3050903@gmail.com> References: <481C8B10.5010704@gmail.com> <481CCCA3.4030507@gmail.com> <481D794B.3050903@gmail.com> Message-ID: <3CA8B571-19C2-440B-8896-4FF16DAC4293@apple.com> On May 4, 2008, at 1:52 AM, T?r?k Edwin wrote: >>>> Looks good to me. Please commit. >>>> >>> Thanks commited in r50607. >>> >>> BTW my commit messages never reach this list (I consulted the >>> archives >>> at lists.cs.uiuc.edu), and it is not just this commit. >>> My previous commits don't show up either ... >>> >> >> Try another test commit please. Thanks! > > Thanks, it works now! Great! It looks like the mailer doesn't like "T?r?k", so all mail from commits will be coming through as "Torok". Hopefully that is ok. -Chris From edwintorok at gmail.com Sun May 4 13:12:21 2008 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Sun, 04 May 2008 21:12:21 +0300 Subject: [llvm-commits] [PATCH] PostDominators: avoid memory leak In-Reply-To: <3CA8B571-19C2-440B-8896-4FF16DAC4293@apple.com> References: <481C8B10.5010704@gmail.com> <481CCCA3.4030507@gmail.com> <481D794B.3050903@gmail.com> <3CA8B571-19C2-440B-8896-4FF16DAC4293@apple.com> Message-ID: <481DFC85.9060408@gmail.com> Chris Lattner wrote: > On May 4, 2008, at 1:52 AM, T?r?k Edwin wrote: > >>>>> Looks good to me. Please commit. >>>>> >>>>> >>>> Thanks commited in r50607. >>>> >>>> BTW my commit messages never reach this list (I consulted the >>>> archives >>>> at lists.cs.uiuc.edu), and it is not just this commit. >>>> My previous commits don't show up either ... >>>> >>>> >>> Try another test commit please. Thanks! >>> >> Thanks, it works now! >> > > Great! It looks like the mailer doesn't like "T?r?k", so all mail > from commits will be coming through as "Torok". Hopefully that is ok. Sure, its fine. --Edwin From sabre at nondot.org Sun May 4 13:14:55 2008 From: sabre at nondot.org (Chris Lattner) Date: Sun, 04 May 2008 18:14:55 -0000 Subject: [llvm-commits] [llvm] r50622 - /llvm/trunk/include/llvm/Constants.h Message-ID: <200805041814.m44IEtg9008426@zion.cs.uiuc.edu> Author: lattner Date: Sun May 4 13:14:55 2008 New Revision: 50622 URL: http://llvm.org/viewvc/llvm-project?rev=50622&view=rev Log: remove obsolete method. Modified: llvm/trunk/include/llvm/Constants.h Modified: llvm/trunk/include/llvm/Constants.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Constants.h?rev=50622&r1=50621&r2=50622&view=diff ============================================================================== --- llvm/trunk/include/llvm/Constants.h (original) +++ llvm/trunk/include/llvm/Constants.h Sun May 4 13:14:55 2008 @@ -233,9 +233,6 @@ public: /// get() - Static factory methods - Return objects of the specified value static ConstantFP *get(const APFloat &V); - static ConstantFP *get(const Type *Ty, const APFloat &V) { - return get(V); - } /// get() - This returns a constant fp for the specified value in the /// specified type. This should only be used for simple constant values like From nicolas.geoffray at lip6.fr Sun May 4 15:03:54 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sun, 04 May 2008 20:03:54 -0000 Subject: [llvm-commits] [vmkit] r50626 - in /vmkit/trunk/lib/JnJVM/VMCore: JavaClass.cpp JavaJIT.cpp Message-ID: <200805042003.m44K3swY012183@zion.cs.uiuc.edu> Author: geoffray Date: Sun May 4 15:03:54 2008 New Revision: 50626 URL: http://llvm.org/viewvc/llvm-project?rev=50626&view=rev Log: Do a load when compiling exceptions read in the exception table. The compiledPtr() method catches the exception to release the class lock and throw a NoClassDefFoundError. Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp?rev=50626&r1=50625&r2=50626&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp Sun May 4 15:03:54 2008 @@ -215,7 +215,20 @@ if (isNative(access)) { llvmFunction = jit.nativeCompile(); } else { - llvmFunction = jit.javaCompile(); + JavaObject* exc = 0; + try { + llvmFunction = jit.javaCompile(); + } catch(...) { + // Happens when it can not load an exception class + classDef->release(); + exc = JavaThread::getJavaException(); + assert(exc && "no exception?"); + JavaThread::clearException(); + } + if (exc) { + Jnjvm* vm = JavaThread::get()->isolate; + vm->errorWithExcp(Jnjvm::NoClassDefFoundError, exc); + } } } // We can compile it, since if we're here, it's for a good reason Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp?rev=50626&r1=50625&r2=50626&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Sun May 4 15:03:54 2008 @@ -824,7 +824,7 @@ ex->catche = reader->readU2(); if (ex->catche) { - Class* cl = (Class*)(ctpInfo->getMethodClassIfLoaded(ex->catche)); + Class* cl = (Class*)(ctpInfo->loadClass(ex->catche)); ex->catchClass = cl; } else { ex->catchClass = Classpath::newThrowable; @@ -919,10 +919,8 @@ Module* M = compilingClass->isolate->module; Value* cl = 0; currentBlock = cur->realTest; - if (cur->catchClass) - cl = new LoadInst(cur->catchClass->llvmVar(M), "", currentBlock); - else - cl = getResolvedClass(cur->catche, false); + assert(cur->catchClass); + cl = new LoadInst(cur->catchClass->llvmVar(M), "", currentBlock); Value* cmp = llvm::CallInst::Create(compareExceptionLLVM, cl, "", currentBlock); llvm::BranchInst::Create(cur->handler, bbNext, cmp, currentBlock); From nicolas.geoffray at lip6.fr Sun May 4 15:09:55 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sun, 04 May 2008 20:09:55 -0000 Subject: [llvm-commits] [vmkit] r50627 - in /vmkit/trunk/lib/JnJVM/VMCore: JavaClass.cpp JavaJIT.cpp Message-ID: <200805042009.m44K9t1W012396@zion.cs.uiuc.edu> Author: geoffray Date: Sun May 4 15:09:55 2008 New Revision: 50627 URL: http://llvm.org/viewvc/llvm-project?rev=50627&view=rev Log: Revert 50626 in JavaClass, and do the catch in JavaJIT. Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp?rev=50627&r1=50626&r2=50627&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp Sun May 4 15:09:55 2008 @@ -215,20 +215,7 @@ if (isNative(access)) { llvmFunction = jit.nativeCompile(); } else { - JavaObject* exc = 0; - try { - llvmFunction = jit.javaCompile(); - } catch(...) { - // Happens when it can not load an exception class - classDef->release(); - exc = JavaThread::getJavaException(); - assert(exc && "no exception?"); - JavaThread::clearException(); - } - if (exc) { - Jnjvm* vm = JavaThread::get()->isolate; - vm->errorWithExcp(Jnjvm::NoClassDefFoundError, exc); - } + llvmFunction = jit.javaCompile(); } } // We can compile it, since if we're here, it's for a good reason Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp?rev=50627&r1=50626&r2=50627&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Sun May 4 15:09:55 2008 @@ -824,7 +824,22 @@ ex->catche = reader->readU2(); if (ex->catche) { - Class* cl = (Class*)(ctpInfo->loadClass(ex->catche)); + JavaObject* exc = 0; + Class* cl = 0; + try { + cl = (Class*)(ctpInfo->loadClass(ex->catche)); + } catch(...) { + compilingClass->release(); + exc = JavaThread::getJavaException(); + assert(exc && "no exception?"); + JavaThread::clearException(); + } + + if (exc) { + Jnjvm* vm = JavaThread::get()->isolate; + vm->errorWithExcp(Jnjvm::NoClassDefFoundError, exc); + } + ex->catchClass = cl; } else { ex->catchClass = Classpath::newThrowable; From resistor at mac.com Sun May 4 16:07:35 2008 From: resistor at mac.com (Owen Anderson) Date: Sun, 04 May 2008 21:07:35 -0000 Subject: [llvm-commits] [llvm] r50628 - in /llvm/trunk: include/llvm/Analysis/DominatorInternals.h include/llvm/Analysis/Dominators.h test/Analysis/PostDominators/ test/Analysis/PostDominators/dg.exp test/Analysis/PostDominators/pr1098.ll Message-ID: <200805042107.m44L7aIQ014188@zion.cs.uiuc.edu> Author: resistor Date: Sun May 4 16:07:35 2008 New Revision: 50628 URL: http://llvm.org/viewvc/llvm-project?rev=50628&view=rev Log: Fix PR1098 by correcting the postdominators analysis. Patch by Florian Brandner. Added: llvm/trunk/test/Analysis/PostDominators/ llvm/trunk/test/Analysis/PostDominators/dg.exp llvm/trunk/test/Analysis/PostDominators/pr1098.ll Modified: llvm/trunk/include/llvm/Analysis/DominatorInternals.h llvm/trunk/include/llvm/Analysis/Dominators.h Modified: llvm/trunk/include/llvm/Analysis/DominatorInternals.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DominatorInternals.h?rev=50628&r1=50627&r2=50628&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DominatorInternals.h (original) +++ llvm/trunk/include/llvm/Analysis/DominatorInternals.h Sun May 4 16:07:35 2008 @@ -233,14 +233,7 @@ typedef GraphTraits GraphT; unsigned N = 0; - - // Add a node for the root. This node might be the actual root, if there is - // one exit block, or it may be the virtual exit (denoted by (BasicBlock *)0) - // which postdominates all real exits if there are multiple exit blocks. - typename GraphT::NodeType* Root = DT.Roots.size() == 1 ? DT.Roots[0] - : 0; bool MultipleRoots = (DT.Roots.size() > 1); - if (MultipleRoots) { typename DominatorTreeBase::InfoRec &BBInfo = DT.Info[NULL]; @@ -258,6 +251,10 @@ for (unsigned i = 0, e = DT.Roots.size(); i != e; ++i) N = DFSPass(DT, DT.Roots[i], N); + // it might be that some blocks did not get a DFS number (e.g., blocks of + // infinite loops). In these cases an artificial exit node is required. + MultipleRoots |= (DT.isPostDominator() && N != F.size()); + for (unsigned i = N; i >= 2; --i) { typename GraphT::NodeType* W = DT.Vertex[i]; typename DominatorTreeBase::InfoRec &WInfo = @@ -311,15 +308,18 @@ if (WIDom != DT.Vertex[DT.Info[W].Semi]) WIDom = DT.IDoms[WIDom]; } - + if (DT.Roots.empty()) return; - + // Add a node for the root. This node might be the actual root, if there is // one exit block, or it may be the virtual exit (denoted by (BasicBlock *)0) - // which postdominates all real exits if there are multiple exit blocks. + // which postdominates all real exits if there are multiple exit blocks, or + // an infinite loop. + typename GraphT::NodeType* Root = !MultipleRoots ? DT.Roots[0] : 0; + DT.DomTreeNodes[Root] = DT.RootNode = new DomTreeNodeBase(Root, 0); - + // Loop over all of the reachable blocks in the function... for (unsigned i = 2; i <= N; ++i) { typename GraphT::NodeType* W = DT.Vertex[i]; @@ -329,20 +329,12 @@ typename GraphT::NodeType* ImmDom = DT.getIDom(W); - // skip all non root nodes that have no dominator - this occures with - // infinite loops. - if (!ImmDom && std::count(DT.Roots.begin(), DT.Roots.end(), W) == 0) - continue; + assert(ImmDom || DT.DomTreeNodes[NULL]); // Get or calculate the node for the immediate dominator DomTreeNodeBase *IDomNode = DT.getNodeForBlock(ImmDom); - // skip all children that are dominated by a non root node that, by itself, - // has no dominator. - if (!IDomNode) - continue; - // Add a new tree node for this BasicBlock, and link it as a child of // IDomNode DomTreeNodeBase *C = Modified: llvm/trunk/include/llvm/Analysis/Dominators.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/Dominators.h?rev=50628&r1=50627&r2=50628&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/Dominators.h (original) +++ llvm/trunk/include/llvm/Analysis/Dominators.h Sun May 4 16:07:35 2008 @@ -605,17 +605,9 @@ // immediate dominator. NodeT *IDom = getIDom(BB); - // skip all non root nodes that have no dominator - if (!IDom && std::count(this->Roots.begin(), this->Roots.end(), BB) == 0) - return NULL; - + assert(IDom || this->DomTreeNodes[NULL]); DomTreeNodeBase *IDomNode = getNodeForBlock(IDom); - // skip all nodes that are dominated by a non root node that, by itself, - // has no dominator. - if (!IDomNode) - return NULL; - // Add a new tree node for this BasicBlock, and link it as a child of // IDomNode DomTreeNodeBase *C = new DomTreeNodeBase(BB, IDomNode); Added: llvm/trunk/test/Analysis/PostDominators/dg.exp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/PostDominators/dg.exp?rev=50628&view=auto ============================================================================== --- llvm/trunk/test/Analysis/PostDominators/dg.exp (added) +++ llvm/trunk/test/Analysis/PostDominators/dg.exp Sun May 4 16:07:35 2008 @@ -0,0 +1,3 @@ +load_lib llvm.exp + +RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,llx,c,cpp,tr}]] Added: llvm/trunk/test/Analysis/PostDominators/pr1098.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/PostDominators/pr1098.ll?rev=50628&view=auto ============================================================================== --- llvm/trunk/test/Analysis/PostDominators/pr1098.ll (added) +++ llvm/trunk/test/Analysis/PostDominators/pr1098.ll Sun May 4 16:07:35 2008 @@ -0,0 +1,14 @@ +; RUN: llvm-as < %s | opt -postdomtree -analyze | grep entry +; PR932 + +define void @foo(i1 %x) { +entry: + br i1 %x, label %bb1, label %bb0 +bb0: ; preds = %entry, bb0 + br label %bb0 +bb1: ; preds = %entry + br label %bb2 +bb2: ; preds = %bb1 + ret void +} + From asl at math.spbu.ru Sun May 4 16:21:55 2008 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Sun, 04 May 2008 21:21:55 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r50629 - /llvm-gcc-4.2/trunk/gcc/Makefile.in Message-ID: <200805042121.m44LLunQ014687@zion.cs.uiuc.edu> Author: asl Date: Sun May 4 16:21:54 2008 New Revision: 50629 URL: http://llvm.org/viewvc/llvm-project?rev=50629&view=rev Log: Pull LLVM objdir before srcdir into includes. This fixes PR2282, when old Intrinsics.gen was pulled from srcdir, instead of new from objdir. Modified: llvm-gcc-4.2/trunk/gcc/Makefile.in Modified: llvm-gcc-4.2/trunk/gcc/Makefile.in URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/Makefile.in?rev=50629&r1=50628&r2=50629&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/Makefile.in (original) +++ llvm-gcc-4.2/trunk/gcc/Makefile.in Sun May 4 16:21:54 2008 @@ -935,13 +935,13 @@ # LLVM LOCAL begin ifneq ($(LLVMOBJDIR),) -INCLUDES += -I$(LLVMSRCDIR)/include - # If LLVM is built srcdir != objdir, include the objdir headers for configured # headers, like DataTypes.h. ifneq (($LLVMOBJDIR),$(LLVMSRCDIR)) INCLUDES += -I$(LLVMOBJDIR)/include endif + +INCLUDES += -I$(LLVMSRCDIR)/include endif # LLVM LOCAL end .c.o: From vadve at cs.uiuc.edu Sun May 4 16:24:54 2008 From: vadve at cs.uiuc.edu (Vikram Adve) Date: Sun, 4 May 2008 16:24:54 -0500 Subject: [llvm-commits] CVS: llvm-www/pubs/index.html Message-ID: <200805042124.m44LOsjF028227@apoc.cs.uiuc.edu> Changes in directory llvm-www/pubs: index.html updated: 1.68 -> 1.69 --- Log message: Added ICSE 06 paper. --- Diffs of the changes: (+7 -0) index.html | 7 +++++++ 1 files changed, 7 insertions(+) Index: llvm-www/pubs/index.html diff -u llvm-www/pubs/index.html:1.68 llvm-www/pubs/index.html:1.69 --- llvm-www/pubs/index.html:1.68 Fri Apr 25 11:06:00 2008 +++ llvm-www/pubs/index.html Sun May 4 16:24:07 2008 @@ -110,6 +110,13 @@
  • "A Virtual Instruction Set Interface for Operating System Kernels"
    John Criswell, Brent Monroe, and Vikram Adve.
    Workshop on the Interaction between Operating Systems and Computer Architecture (WIOSCA '06), Boston, Massachusetts, 2006.
  • +
  • " +"Backwards-Compatible Array Bounds Checking for C with Very Low Overhead", +
    By Dinakar Dhurjati and Vikram Adve, +
    Proceedings of the 28th +International Conference on Software Engineering (ICSE '06), +Shanghai, China, 2006. +
  • "Vector LLVA: A Virtual Vector Instruction Set for Media Processing"
    Robert L. Bocchino Jr. and Vikram S. Adve.
    Proc. of the Second International Conference on Virtual Execution Environments (VEE'06), Ottawa, Canada, 2006.
  • From vadve at cs.uiuc.edu Sun May 4 16:27:36 2008 From: vadve at cs.uiuc.edu (Vikram Adve) Date: Sun, 4 May 2008 16:27:36 -0500 Subject: [llvm-commits] CVS: llvm-www/pubs/index.html Message-ID: <200805042127.m44LRadS028339@apoc.cs.uiuc.edu> Changes in directory llvm-www/pubs: index.html updated: 1.69 -> 1.70 --- Log message: Fixed quotes. --- Diffs of the changes: (+1 -1) index.html | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm-www/pubs/index.html diff -u llvm-www/pubs/index.html:1.69 llvm-www/pubs/index.html:1.70 --- llvm-www/pubs/index.html:1.69 Sun May 4 16:24:07 2008 +++ llvm-www/pubs/index.html Sun May 4 16:26:44 2008 @@ -111,7 +111,7 @@ Workshop on the Interaction between Operating Systems and Computer Architecture (WIOSCA '06), Boston, Massachusetts, 2006.
  • " -"Backwards-Compatible Array Bounds Checking for C with Very Low Overhead", +Backwards-Compatible Array Bounds Checking for C with Very Low Overhead"
    By Dinakar Dhurjati and Vikram Adve,
    Proceedings of the 28th International Conference on Software Engineering (ICSE '06), From asl at math.spbu.ru Sun May 4 16:36:33 2008 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Sun, 04 May 2008 21:36:33 -0000 Subject: [llvm-commits] [llvm] r50630 - in /llvm/trunk/lib/Target/X86: X86ATTAsmPrinter.cpp X86ISelLowering.cpp X86Instr64bit.td X86InstrInfo.td Message-ID: <200805042136.m44LaX0W015127@zion.cs.uiuc.edu> Author: asl Date: Sun May 4 16:36:32 2008 New Revision: 50630 URL: http://llvm.org/viewvc/llvm-project?rev=50630&view=rev Log: Add General Dynamic TLS model for X86-64. Some parts looks really ugly (look for tlsaddr pattern), but should work. Work is in progress, more models will follow Modified: llvm/trunk/lib/Target/X86/X86ATTAsmPrinter.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Target/X86/X86Instr64bit.td llvm/trunk/lib/Target/X86/X86InstrInfo.td Modified: llvm/trunk/lib/Target/X86/X86ATTAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ATTAsmPrinter.cpp?rev=50630&r1=50629&r2=50630&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ATTAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ATTAsmPrinter.cpp Sun May 4 16:36:32 2008 @@ -347,7 +347,7 @@ if (GV->hasExternalWeakLinkage()) ExtWeakSymbols.insert(GV); - + int Offset = MO.getOffset(); if (Offset > 0) O << "+" << Offset; @@ -355,7 +355,7 @@ O << Offset; if (isThreadLocal) { - if (TM.getRelocationModel() == Reloc::PIC_) + if (TM.getRelocationModel() == Reloc::PIC_ || Subtarget->is64Bit()) O << "@TLSGD"; // general dynamic TLS model else if (GV->isDeclaration()) Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=50630&r1=50629&r2=50630&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Sun May 4 16:36:32 2008 @@ -267,6 +267,8 @@ setOperationAction(ISD::JumpTable , MVT::i32 , Custom); setOperationAction(ISD::GlobalAddress , MVT::i32 , Custom); setOperationAction(ISD::GlobalTLSAddress, MVT::i32 , Custom); + if (Subtarget->is64Bit()) + setOperationAction(ISD::GlobalTLSAddress, MVT::i64, Custom); setOperationAction(ISD::ExternalSymbol , MVT::i32 , Custom); if (Subtarget->is64Bit()) { setOperationAction(ISD::ConstantPool , MVT::i64 , Custom); @@ -4001,10 +4003,10 @@ return Result; } -// Lower ISD::GlobalTLSAddress using the "general dynamic" model +// Lower ISD::GlobalTLSAddress using the "general dynamic" model, 32 bit static SDOperand -LowerToTLSGeneralDynamicModel(GlobalAddressSDNode *GA, SelectionDAG &DAG, - const MVT::ValueType PtrVT) { +LowerToTLSGeneralDynamicModel32(GlobalAddressSDNode *GA, SelectionDAG &DAG, + const MVT::ValueType PtrVT) { SDOperand InFlag; SDOperand Chain = DAG.getCopyToReg(DAG.getEntryNode(), X86::EBX, DAG.getNode(X86ISD::GlobalBaseReg, @@ -4039,6 +4041,39 @@ return DAG.getCopyFromReg(Chain, X86::EAX, PtrVT, InFlag); } +// Lower ISD::GlobalTLSAddress using the "general dynamic" model, 64 bit +static SDOperand +LowerToTLSGeneralDynamicModel64(GlobalAddressSDNode *GA, SelectionDAG &DAG, + const MVT::ValueType PtrVT) { + SDOperand InFlag, Chain; + + // emit leaq symbol at TLSGD(%rip), %rdi + SDVTList NodeTys = DAG.getVTList(PtrVT, MVT::Other, MVT::Flag); + SDOperand TGA = DAG.getTargetGlobalAddress(GA->getGlobal(), + GA->getValueType(0), + GA->getOffset()); + SDOperand Ops[] = { DAG.getEntryNode(), TGA}; + SDOperand Result = DAG.getNode(X86ISD::TLSADDR, NodeTys, Ops, 2); + Chain = Result.getValue(1); + InFlag = Result.getValue(2); + + // call ___tls_get_addr. This function receives its argument in + // the register RDI. + Chain = DAG.getCopyToReg(Chain, X86::RDI, Result, InFlag); + InFlag = Chain.getValue(1); + + NodeTys = DAG.getVTList(MVT::Other, MVT::Flag); + SDOperand Ops1[] = { Chain, + DAG.getTargetExternalSymbol("___tls_get_addr", + PtrVT), + DAG.getRegister(X86::RDI, PtrVT), + InFlag }; + Chain = DAG.getNode(X86ISD::CALL, NodeTys, Ops1, 4); + InFlag = Chain.getValue(1); + + return DAG.getCopyFromReg(Chain, X86::RAX, PtrVT, InFlag); +} + // Lower ISD::GlobalTLSAddress using the "initial exec" (for no-pic) or // "local exec" model. static SDOperand @@ -4066,15 +4101,19 @@ X86TargetLowering::LowerGlobalTLSAddress(SDOperand Op, SelectionDAG &DAG) { // TODO: implement the "local dynamic" model // TODO: implement the "initial exec"model for pic executables - assert(!Subtarget->is64Bit() && Subtarget->isTargetELF() && - "TLS not implemented for non-ELF and 64-bit targets"); + assert(Subtarget->isTargetELF() && + "TLS not implemented for non-ELF targets"); GlobalAddressSDNode *GA = cast(Op); // If the relocation model is PIC, use the "General Dynamic" TLS Model, // otherwise use the "Local Exec"TLS Model - if (getTargetMachine().getRelocationModel() == Reloc::PIC_) - return LowerToTLSGeneralDynamicModel(GA, DAG, getPointerTy()); - else - return LowerToTLSExecModel(GA, DAG, getPointerTy()); + if (Subtarget->is64Bit()) { + return LowerToTLSGeneralDynamicModel64(GA, DAG, getPointerTy()); + } else { + if (getTargetMachine().getRelocationModel() == Reloc::PIC_) + return LowerToTLSGeneralDynamicModel32(GA, DAG, getPointerTy()); + else + return LowerToTLSExecModel(GA, DAG, getPointerTy()); + } } SDOperand Modified: llvm/trunk/lib/Target/X86/X86Instr64bit.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Instr64bit.td?rev=50630&r1=50629&r2=50630&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Instr64bit.td (original) +++ llvm/trunk/lib/Target/X86/X86Instr64bit.td Sun May 4 16:36:32 2008 @@ -1102,6 +1102,13 @@ "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}", [(set GR64:$dst, i64immZExt32:$src)]>; +//===----------------------------------------------------------------------===// +// Thread Local Storage Instructions +//===----------------------------------------------------------------------===// + +def TLS_addr64 : I<0, Pseudo, (outs GR64:$dst), (ins i64imm:$sym), + ".byte\t0x66; leaq\t${sym:mem}(%rip), $dst; .word\t0x6666; rex64", + [(set GR64:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>; //===----------------------------------------------------------------------===// // Atomic Instructions Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=50630&r1=50629&r2=50630&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Sun May 4 16:36:32 2008 @@ -109,7 +109,7 @@ def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>; def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR, - [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>; + [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>; def X86TLStp : SDNode<"X86ISD::THREAD_POINTER", SDT_X86TLSTP, []>; def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET, @@ -2500,12 +2500,12 @@ // let Uses = [EBX] in -def TLS_addr : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym), - "leal\t${sym:mem}(,%ebx,1), $dst", - [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>; +def TLS_addr32 : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym), + "leal\t${sym:mem}(,%ebx,1), $dst", + [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>; let AddedComplexity = 10 in -def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src), +def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src), "movl\t%gs:($src), $dst", [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>; From gohman at apple.com Sun May 4 19:28:39 2008 From: gohman at apple.com (Dan Gohman) Date: Mon, 05 May 2008 00:28:39 -0000 Subject: [llvm-commits] [llvm] r50634 - in /llvm/trunk: include/llvm/Target/TargetAsmInfo.h lib/CodeGen/AsmPrinter.cpp lib/Target/TargetAsmInfo.cpp lib/Target/X86/X86Subtarget.cpp lib/Target/X86/X86Subtarget.h lib/Target/X86/X86TargetAsmInfo.cpp test/CodeGen/X86/xor_not.ll Message-ID: <200805050028.m450Sd8J021018@zion.cs.uiuc.edu> Author: djg Date: Sun May 4 19:28:39 2008 New Revision: 50634 URL: http://llvm.org/viewvc/llvm-project?rev=50634&view=rev Log: Add AsmPrinter support for emitting a directive to declare that the code being generated does not require an executable stack. Also, add target-specific code to make use of this on Linux on x86. Modified: llvm/trunk/include/llvm/Target/TargetAsmInfo.h llvm/trunk/lib/CodeGen/AsmPrinter.cpp llvm/trunk/lib/Target/TargetAsmInfo.cpp llvm/trunk/lib/Target/X86/X86Subtarget.cpp llvm/trunk/lib/Target/X86/X86Subtarget.h llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp llvm/trunk/test/CodeGen/X86/xor_not.ll Modified: llvm/trunk/include/llvm/Target/TargetAsmInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetAsmInfo.h?rev=50634&r1=50633&r2=50634&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetAsmInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetAsmInfo.h Sun May 4 19:28:39 2008 @@ -61,10 +61,16 @@ /// Null if this target doesn't support a BSS section. /// const char *TLSBSSSection;// Default to ".section .tbss,"awT", at nobits". + /// ZeroFillDirective - Directive for emitting a global to the ZeroFill /// section on this target. Null if this target doesn't support zerofill. const char *ZeroFillDirective; // Default is null. + /// NonexecutableStackDirective - Directive for declaring to the + /// linker and beyond that the emitted code does not require stack + /// memory to be executable. + const char *NonexecutableStackDirective; // Default is null. + /// NeedsSet - True if target asm treats expressions in data directives /// as linktime-relocatable. For assembly-time computation, we need to /// use a .set. Thus: @@ -440,6 +446,9 @@ const char *getZeroFillDirective() const { return ZeroFillDirective; } + const char *getNonexecutableStackDirective() const { + return NonexecutableStackDirective; + } bool needsSet() const { return NeedsSet; } Modified: llvm/trunk/lib/CodeGen/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter.cpp?rev=50634&r1=50633&r2=50634&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter.cpp Sun May 4 19:28:39 2008 @@ -192,6 +192,13 @@ E = CMM->begin(); I != E; ) (*--I)->finishAssembly(O, *this, *TAI); + // If we don't have any trampolines, then we don't require stack memory + // to be executable. Some targets have a directive to declare this. + Function* InitTrampolineIntrinsic = M.getFunction("llvm.init.trampoline"); + if (!InitTrampolineIntrinsic || InitTrampolineIntrinsic->use_empty()) + if (TAI->getNonexecutableStackDirective()) + O << TAI->getNonexecutableStackDirective() << "\n"; + delete Mang; Mang = 0; return false; } Modified: llvm/trunk/lib/Target/TargetAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetAsmInfo.cpp?rev=50634&r1=50633&r2=50634&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/TargetAsmInfo.cpp Sun May 4 19:28:39 2008 @@ -26,6 +26,7 @@ TLSDataSection("\t.section .tdata,\"awT\", at progbits"), TLSBSSSection("\t.section .tbss,\"awT\", at nobits"), ZeroFillDirective(0), + NonexecutableStackDirective(0), NeedsSet(false), MaxInstLength(4), PCSymbol("$"), Modified: llvm/trunk/lib/Target/X86/X86Subtarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.cpp?rev=50634&r1=50633&r2=50634&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Subtarget.cpp (original) +++ llvm/trunk/lib/Target/X86/X86Subtarget.cpp Sun May 4 19:28:39 2008 @@ -278,6 +278,8 @@ DarwinVers = atoi(&TT[Pos+7]); else DarwinVers = 8; // Minimum supported darwin is Tiger. + } else if (TT.find("linux") != std::string::npos) { + TargetType = isELFLinux; } else if (TT.find("cygwin") != std::string::npos) { TargetType = isCygwin; } else if (TT.find("mingw") != std::string::npos) { @@ -302,6 +304,9 @@ #elif defined(_WIN32) || defined(_WIN64) TargetType = isWindows; +#elif defined(__linux__) + // Linux doesn't imply ELF, but we don't currently support anything else. + TargetType = isELFLinux; #endif } Modified: llvm/trunk/lib/Target/X86/X86Subtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.h?rev=50634&r1=50633&r2=50634&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Subtarget.h (original) +++ llvm/trunk/lib/Target/X86/X86Subtarget.h Sun May 4 19:28:39 2008 @@ -84,7 +84,7 @@ public: enum { - isELF, isCygwin, isDarwin, isWindows, isMingw + isELF, isELFLinux, isCygwin, isDarwin, isWindows, isMingw } TargetType; /// This constructor initializes the data members to match that @@ -132,7 +132,12 @@ bool isFlavorIntel() const { return AsmFlavor == Intel; } bool isTargetDarwin() const { return TargetType == isDarwin; } - bool isTargetELF() const { return TargetType == isELF; } + bool isTargetELF() const { + return TargetType == isELF || TargetType == isELFLinux; + } + bool isTargetLinux() const { + return TargetType == isELFLinux; + } bool isTargetWindows() const { return TargetType == isWindows; } bool isTargetMingw() const { return TargetType == isMingw; } bool isTargetCygMing() const { return (TargetType == isMingw || Modified: llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp?rev=50634&r1=50633&r2=50634&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp Sun May 4 19:28:39 2008 @@ -128,6 +128,7 @@ break; case X86Subtarget::isELF: + case X86Subtarget::isELFLinux: ReadOnlySection = "\t.section\t.rodata"; FourByteConstantSection = "\t.section\t.rodata.cst4,\"aM\", at progbits,4"; EightByteConstantSection = "\t.section\t.rodata.cst8,\"aM\", at progbits,8"; @@ -229,6 +230,10 @@ SectionEndDirectiveSuffix = "\tends\n"; } + // On Linux we must declare when we can use a non-executable stack. + if (Subtarget->isTargetLinux()) + NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\", at progbits"; + AssemblerDialect = Subtarget->getAsmFlavor(); } Modified: llvm/trunk/test/CodeGen/X86/xor_not.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/xor_not.ll?rev=50634&r1=50633&r2=50634&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/xor_not.ll (original) +++ llvm/trunk/test/CodeGen/X86/xor_not.ll Sun May 4 19:28:39 2008 @@ -1,5 +1,5 @@ -; RUN: llvm-as < %s | llc -march=x86 | grep {not} | count 3 -; RUN: llvm-as < %s | llc -march=x86-64 | grep {not} | count 4 +; RUN: llvm-as < %s | llc -march=x86 | grep {not\[lwb\]} | count 3 +; RUN: llvm-as < %s | llc -march=x86-64 | grep {not\[lwb\]} | count 4 define i32 @test(i32 %a, i32 %b) nounwind { entry: %tmp1not = xor i32 %b, -2 From gohman at apple.com Sun May 4 20:17:34 2008 From: gohman at apple.com (Dan Gohman) Date: Sun, 4 May 2008 18:17:34 -0700 (PDT) Subject: [llvm-commits] [llvm] r50628 - in /llvm/trunk: include/llvm/Analysis/DominatorInternals.h include/llvm/Analysis/Dominators.h test/Analysis/PostDominators/ test/Analysis/PostDominators/dg.exp test/Analysis/PostDominators/pr1098.ll Message-ID: <53237.76.126.213.14.1209950254.squirrel@webmail.apple.com> On Sun, May 4, 2008 2:07 pm, Owen Anderson wrote: > Author: resistor > Date: Sun May 4 16:07:35 2008 > New Revision: 50628 > > URL: http://llvm.org/viewvc/llvm-project?rev=50628&view=rev > Log: > Fix PR1098 by correcting the postdominators analysis. > > Patch by Florian Brandner. Cool, thanks for working on this! > --- llvm/trunk/test/Analysis/PostDominators/pr1098.ll (added) > +++ llvm/trunk/test/Analysis/PostDominators/pr1098.ll Sun May 4 16:07:35 > 2008 > @@ -0,0 +1,14 @@ > +; RUN: llvm-as < %s | opt -postdomtree -analyze | grep entry > +; PR932 This seems to be the wrong PR number. > + > +define void @foo(i1 %x) { > +entry: > + br i1 %x, label %bb1, label %bb0 > +bb0: ; preds = %entry, bb0 > + br label %bb0 > +bb1: ; preds = %entry > + br label %bb2 > +bb2: ; preds = %bb1 > + ret void > +} This testcase is subtly different from the one in PR1098. bb0 is an infinite loop instead of being a return block. Was that intended? The output for the original testcase appears correct after this commit. However, the output for this pr1098.ll testcase is Inorder PostDominator Tree: [1] <> {4294967295,4294967295} [2] %bb2 {4294967295,4294967295} [3] %bb1 {4294967295,4294967295} [2] %entry {4294967295,4294967295} This seems inconsistent, since %entry is listed as being post-dominated by the exit node, while %bb0 is not listed at all. Dan From clattner at apple.com Sun May 4 22:58:48 2008 From: clattner at apple.com (Chris Lattner) Date: Sun, 4 May 2008 20:58:48 -0700 Subject: [llvm-commits] [llvm] r50634 - in /llvm/trunk: include/llvm/Target/TargetAsmInfo.h lib/CodeGen/AsmPrinter.cpp lib/Target/TargetAsmInfo.cpp lib/Target/X86/X86Subtarget.cpp lib/Target/X86/X86Subtarget.h lib/Target/X86/X86TargetAsmInfo.cpp test/CodeGen/X86/xor_not.ll In-Reply-To: <200805050028.m450Sd8J021018@zion.cs.uiuc.edu> References: <200805050028.m450Sd8J021018@zion.cs.uiuc.edu> Message-ID: <6E396B78-B4CA-4230-B859-38B232C42D81@apple.com> On May 4, 2008, at 5:28 PM, Dan Gohman wrote: > URL: http://llvm.org/viewvc/llvm-project?rev=50634&view=rev > Log: > Add AsmPrinter support for emitting a directive to declare that > the code being generated does not require an executable stack. > > Also, add target-specific code to make use of this on Linux > on x86. Ok. > @@ -84,7 +84,7 @@ > > public: > enum { > - isELF, isCygwin, isDarwin, isWindows, isMingw > + isELF, isELFLinux, isCygwin, isDarwin, isWindows, isMingw > } TargetType; Why do we need an isELFLinux target here? Isn't "isElf && isLinux" acceptable? The isLinux predicate should be orthogonal to the object file type as you say. -Chris