From reid at x10sys.com Mon Nov 13 02:04:14 2006 From: reid at x10sys.com (Reid Spencer) Date: Mon, 13 Nov 2006 02:04:14 -0600 Subject: [llvm-commits] CVS: llvm/docs/index.html Message-ID: <200611130804.kAD84Em6015185@zion.cs.uiuc.edu> Changes in directory llvm/docs: index.html updated: 1.59 -> 1.60 --- Log message: Add a link to the GEP FAQ. --- Diffs of the changes: (+3 -3) index.html | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: llvm/docs/index.html diff -u llvm/docs/index.html:1.59 llvm/docs/index.html:1.60 --- llvm/docs/index.html:1.59 Sun Sep 17 18:05:15 2006 +++ llvm/docs/index.html Mon Nov 13 02:03:59 2006 @@ -39,7 +39,6 @@ @@ -263,6 +263,6 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"> LLVM Compiler Infrastructure
- Last modified: $Date: 2006/09/17 23:05:15 $ + Last modified: $Date: 2006/11/13 08:03:59 $ From reid at x10sys.com Mon Nov 13 02:05:25 2006 From: reid at x10sys.com (Reid Spencer) Date: Mon, 13 Nov 2006 02:05:25 -0600 Subject: [llvm-commits] [release_19] CVS: llvm/docs/index.html Message-ID: <200611130805.kAD85PPN015279@zion.cs.uiuc.edu> Changes in directory llvm/docs: index.html updated: 1.59 -> 1.59.4.1 --- Log message: Merge From Head: Add a link to the GEP FAQ. --- Diffs of the changes: (+3 -3) index.html | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: llvm/docs/index.html diff -u llvm/docs/index.html:1.59 llvm/docs/index.html:1.59.4.1 --- llvm/docs/index.html:1.59 Sun Sep 17 18:05:15 2006 +++ llvm/docs/index.html Mon Nov 13 02:05:09 2006 @@ -39,7 +39,6 @@ @@ -263,6 +263,6 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"> LLVM Compiler Infrastructure
- Last modified: $Date: 2006/09/17 23:05:15 $ + Last modified: $Date: 2006/11/13 08:05:09 $ From reid at x10sys.com Mon Nov 13 10:09:06 2006 From: reid at x10sys.com (Reid Spencer) Date: Mon, 13 Nov 2006 10:09:06 -0600 Subject: [llvm-commits] CVS: llvm/utils/findmisopt Message-ID: <200611131609.kADG96uK031455@zion.cs.uiuc.edu> Changes in directory llvm/utils: findmisopt updated: 1.4 -> 1.5 --- Log message: Add some output so the user is informed while they wait. --- Diffs of the changes: (+14 -3) findmisopt | 17 ++++++++++++++--- 1 files changed, 14 insertions(+), 3 deletions(-) Index: llvm/utils/findmisopt diff -u llvm/utils/findmisopt:1.4 llvm/utils/findmisopt:1.5 --- llvm/utils/findmisopt:1.4 Sat Nov 11 04:22:48 2006 +++ llvm/utils/findmisopt Mon Nov 13 10:08:51 2006 @@ -54,6 +54,15 @@ echo "Unoptimized program: $prog" echo " Optimized program: $optprog" +# Create output directory if it doesn't exist +if [ -f "$outdir" ] ; then + echo "$outdir is not a directory" + exit 1 +fi + +if [ ! -d "$outdir" ] ; then + mkdir "$outdir" || exit 1 +fi # Generate the disassembly llvm-dis "$bcfile" -o "$ll" -f || exit 1 @@ -72,9 +81,9 @@ llvm-dis "$optbc" -o "$optll" -f || exit llc "$optbc" -o "$opts" -f || exit gcc "$opts" -o "$optprog" -lstdc++ -lc -lm || exit - "$prog" $args > "$out" + "$prog" $args > "$out" 2>&1 ex1=$? - "$optprog" $args > "$optout" + "$optprog" $args > "$optout" 2>&1 ex2=$? if [ -n "$match" ] ; then @@ -98,7 +107,9 @@ return 1 } +echo "Trying to find optimization that breaks program:" for sw in $all_switches ; do + echo -n " $sw" switches="$switches $sw" if tryit "$switches" ; then break; @@ -123,7 +134,7 @@ done if [ "$final" == " $all_switches" ] ; then - echo "findmisopt: Can't find a set of optimizations that make it fail" + echo "findmisopt: All optimizations pass. Perhaps this isn't a misopt?" exit 0 fi echo "Smallest Optimization list=$final" From reid at x10sys.com Mon Nov 13 10:09:51 2006 From: reid at x10sys.com (Reid Spencer) Date: Mon, 13 Nov 2006 10:09:51 -0600 Subject: [llvm-commits] CVS: llvm/test/Scripts/notcast Message-ID: <200611131609.kADG9p1I031477@zion.cs.uiuc.edu> Changes in directory llvm/test/Scripts: notcast updated: 1.4 -> 1.5 --- Log message: Handle ptrtoint and inttoptr --- Diffs of the changes: (+1 -1) notcast | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/test/Scripts/notcast diff -u llvm/test/Scripts/notcast:1.4 llvm/test/Scripts/notcast:1.5 --- llvm/test/Scripts/notcast:1.4 Fri Nov 10 19:04:13 2006 +++ llvm/test/Scripts/notcast Mon Nov 13 10:09:37 2006 @@ -10,7 +10,7 @@ # prepat - optionally allow a regular expression to go at the start # -if grep "$2"'\(\([sz]ext\)\|\(trunc\)\|\(fpto[us]i\)\|\([us]itofp\)\|\(bitconvert\)\|\(fpext\)\|\(fptrunc\)\)'"$1" +if grep "$2"'\(\([sz]ext\)\|\(trunc\)\|\(fpto[us]i\)\|\([us]itofp\)\|\(bitcast\)\|\(fpext\)\|\(fptrunc\)\|\(ptrtoint\)\|\(inttoptr\)\)'"$1" then exit 1 else exit 0 fi From reid at x10sys.com Mon Nov 13 10:11:28 2006 From: reid at x10sys.com (Reid Spencer) Date: Mon, 13 Nov 2006 10:11:28 -0600 Subject: [llvm-commits] CVS: llvm/test/Scripts/notcast Message-ID: <200611131611.kADGBSpK031519@zion.cs.uiuc.edu> Changes in directory llvm/test/Scripts: notcast updated: 1.5 -> 1.6 --- Log message: Make it handle plain old cast too, for old assembly. --- Diffs of the changes: (+1 -1) notcast | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/test/Scripts/notcast diff -u llvm/test/Scripts/notcast:1.5 llvm/test/Scripts/notcast:1.6 --- llvm/test/Scripts/notcast:1.5 Mon Nov 13 10:09:37 2006 +++ llvm/test/Scripts/notcast Mon Nov 13 10:11:14 2006 @@ -10,7 +10,7 @@ # prepat - optionally allow a regular expression to go at the start # -if grep "$2"'\(\([sz]ext\)\|\(trunc\)\|\(fpto[us]i\)\|\([us]itofp\)\|\(bitcast\)\|\(fpext\)\|\(fptrunc\)\|\(ptrtoint\)\|\(inttoptr\)\)'"$1" +if grep "$2"'\(\([sz]ext\)\|\(trunc\)\|\(fpto[us]i\)\|\([us]itofp\)\|\(bitcast\)\|\(fpext\)\|\(fptrunc\)\|\(ptrtoint\)\|\(inttoptr\)\|\(cast\)\)'"$1" then exit 1 else exit 0 fi From reid at x10sys.com Mon Nov 13 10:12:40 2006 From: reid at x10sys.com (Reid Spencer) Date: Mon, 13 Nov 2006 10:12:40 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/LevelRaise/2003-05-01-CallCast.ll Message-ID: <200611131612.kADGCehh031549@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/LevelRaise: 2003-05-01-CallCast.ll updated: 1.3 -> 1.4 --- Log message: For PR950: http://llvm.org/PR950 : Use the notcast script in preparation for 12 cast instructions. --- Diffs of the changes: (+1 -1) 2003-05-01-CallCast.ll | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/test/Regression/Transforms/LevelRaise/2003-05-01-CallCast.ll diff -u llvm/test/Regression/Transforms/LevelRaise/2003-05-01-CallCast.ll:1.3 llvm/test/Regression/Transforms/LevelRaise/2003-05-01-CallCast.ll:1.4 --- llvm/test/Regression/Transforms/LevelRaise/2003-05-01-CallCast.ll:1.3 Tue Sep 16 10:29:37 2003 +++ llvm/test/Regression/Transforms/LevelRaise/2003-05-01-CallCast.ll Mon Nov 13 10:12:25 2006 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -raise | llvm-dis | not grep cast +; RUN: llvm-as < %s | opt -raise | llvm-dis | notcast void %test(...) { ret void } From reid at x10sys.com Mon Nov 13 10:13:52 2006 From: reid at x10sys.com (Reid Spencer) Date: Mon, 13 Nov 2006 10:13:52 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/LevelRaise/2002-11-04-ConstantSharing.ll Message-ID: <200611131613.kADGDqfc031579@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/LevelRaise: 2002-11-04-ConstantSharing.ll updated: 1.2 -> 1.3 --- Log message: For PR950: http://llvm.org/PR950 : Use the notcast script in preparation for 12 casts. --- Diffs of the changes: (+1 -1) 2002-11-04-ConstantSharing.ll | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/test/Regression/Transforms/LevelRaise/2002-11-04-ConstantSharing.ll diff -u llvm/test/Regression/Transforms/LevelRaise/2002-11-04-ConstantSharing.ll:1.2 llvm/test/Regression/Transforms/LevelRaise/2002-11-04-ConstantSharing.ll:1.3 --- llvm/test/Regression/Transforms/LevelRaise/2002-11-04-ConstantSharing.ll:1.2 Sat Nov 6 15:03:41 2004 +++ llvm/test/Regression/Transforms/LevelRaise/2002-11-04-ConstantSharing.ll Mon Nov 13 10:13:38 2006 @@ -1,4 +1,4 @@ -; RUN: llvm-as < 2002-11-04-ConstantSharing.ll | opt -raise | llvm-dis | not grep cast +; RUN: llvm-as < 2002-11-04-ConstantSharing.ll | opt -raise | llvm-dis | notcast implementation From reid at x10sys.com Mon Nov 13 10:21:23 2006 From: reid at x10sys.com (Reid Spencer) Date: Mon, 13 Nov 2006 10:21:23 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/InstCombine/bittest.ll Message-ID: <200611131621.kADGLN7n031700@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/InstCombine: bittest.ll updated: 1.1 -> 1.2 --- Log message: Fix 80 cols violations. --- Diffs of the changes: (+5 -5) bittest.ll | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) Index: llvm/test/Regression/Transforms/InstCombine/bittest.ll diff -u llvm/test/Regression/Transforms/InstCombine/bittest.ll:1.1 llvm/test/Regression/Transforms/InstCombine/bittest.ll:1.2 --- llvm/test/Regression/Transforms/InstCombine/bittest.ll:1.1 Thu Feb 9 01:38:30 2006 +++ llvm/test/Regression/Transforms/InstCombine/bittest.ll Mon Nov 13 10:21:09 2006 @@ -10,9 +10,9 @@ %tmp.16 = and int %tmp.9, -805306369 ; [#uses=2] %tmp.17 = and int %tmp.9, -973078529 ; [#uses=1] store int %tmp.17, int* %b_rec.0 - %tmp.17.shrunk = cast int %tmp.16 to uint ; [#uses=1] - %tmp.22 = and uint %tmp.17.shrunk, 3221225472 ; [#uses=1] - %tmp.23 = seteq uint %tmp.22, 3221225472 ; [#uses=1] + %tmp.17.shrunk = cast int %tmp.16 to uint ; [#uses=1] + %tmp.22 = and uint %tmp.17.shrunk, 3221225472 ; [#uses=1] + %tmp.23 = seteq uint %tmp.22, 3221225472 ; [#uses=1] br bool %tmp.23, label %endif.0, label %then.0 then.0: ; preds = %entry @@ -20,8 +20,8 @@ unreachable endif.0: ; preds = %entry - %tmp.17.shrunk2 = cast int %tmp.16 to uint ; [#uses=1] - %tmp.27.mask = and uint %tmp.17.shrunk2, 100663295 ; [#uses=1] + %tmp.17.shrunk2 = cast int %tmp.16 to uint ; [#uses=1] + %tmp.27.mask = and uint %tmp.17.shrunk2, 100663295 ; [#uses=1] store uint %tmp.27.mask, uint* %P ret void } From reid at x10sys.com Mon Nov 13 11:55:49 2006 From: reid at x10sys.com (Reid Spencer) Date: Mon, 13 Nov 2006 11:55:49 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/InstCombine/cast-propagate.ll Message-ID: <200611131755.kADHtnof001005@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/InstCombine: cast-propagate.ll updated: 1.1 -> 1.2 --- Log message: Don't hard code test names into the test. --- Diffs of the changes: (+1 -1) cast-propagate.ll | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/test/Regression/Transforms/InstCombine/cast-propagate.ll diff -u llvm/test/Regression/Transforms/InstCombine/cast-propagate.ll:1.1 llvm/test/Regression/Transforms/InstCombine/cast-propagate.ll:1.2 --- llvm/test/Regression/Transforms/InstCombine/cast-propagate.ll:1.1 Thu Apr 8 15:39:40 2004 +++ llvm/test/Regression/Transforms/InstCombine/cast-propagate.ll Mon Nov 13 11:55:34 2006 @@ -1,4 +1,4 @@ -; RUN: llvm-as < cast-propagate.ll | opt -instcombine -mem2reg | llvm-dis | not grep load +; RUN: llvm-as < %s | opt -instcombine -mem2reg | llvm-dis | not grep load int %test1(uint* %P) { %A = alloca uint From reid at x10sys.com Mon Nov 13 12:01:07 2006 From: reid at x10sys.com (Reid Spencer) Date: Mon, 13 Nov 2006 12:01:07 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/InstCombine/cast-set.ll call.ll IntPtrCast.ll 2006-04-28-ShiftShiftLongLong.ll 2004-11-27-SetCCForCastLargerAndConstant.ll 2003-11-13-ConstExprCastCall.ll Message-ID: <200611131801.kADI17Tp001111@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/InstCombine: cast-set.ll updated: 1.13 -> 1.14 call.ll updated: 1.5 -> 1.6 IntPtrCast.ll updated: 1.1 -> 1.2 2006-04-28-ShiftShiftLongLong.ll updated: 1.1 -> 1.2 2004-11-27-SetCCForCastLargerAndConstant.ll updated: 1.6 -> 1.7 2003-11-13-ConstExprCastCall.ll updated: 1.1 -> 1.2 --- Log message: For PR950: http://llvm.org/PR950 : Changes for new cast instructions that are backwards compatible. --- Diffs of the changes: (+6 -6) 2003-11-13-ConstExprCastCall.ll | 2 +- 2004-11-27-SetCCForCastLargerAndConstant.ll | 2 +- 2006-04-28-ShiftShiftLongLong.ll | 2 +- IntPtrCast.ll | 2 +- call.ll | 2 +- cast-set.ll | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) Index: llvm/test/Regression/Transforms/InstCombine/cast-set.ll diff -u llvm/test/Regression/Transforms/InstCombine/cast-set.ll:1.13 llvm/test/Regression/Transforms/InstCombine/cast-set.ll:1.14 --- llvm/test/Regression/Transforms/InstCombine/cast-set.ll:1.13 Sun Nov 2 23:30:34 2003 +++ llvm/test/Regression/Transforms/InstCombine/cast-set.ll Mon Nov 13 12:00:52 2006 @@ -1,7 +1,7 @@ ; This tests for various complex cast elimination cases instcombine should ; handle. -; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep cast +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | notcast bool %test1(int %X) { %A = cast int %X to uint Index: llvm/test/Regression/Transforms/InstCombine/call.ll diff -u llvm/test/Regression/Transforms/InstCombine/call.ll:1.5 llvm/test/Regression/Transforms/InstCombine/call.ll:1.6 --- llvm/test/Regression/Transforms/InstCombine/call.ll:1.5 Fri Feb 27 23:26:06 2004 +++ llvm/test/Regression/Transforms/InstCombine/call.ll Mon Nov 13 12:00:52 2006 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep call | not grep cast +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep call | notcast implementation Index: llvm/test/Regression/Transforms/InstCombine/IntPtrCast.ll diff -u llvm/test/Regression/Transforms/InstCombine/IntPtrCast.ll:1.1 llvm/test/Regression/Transforms/InstCombine/IntPtrCast.ll:1.2 --- llvm/test/Regression/Transforms/InstCombine/IntPtrCast.ll:1.1 Tue Jul 20 00:20:39 2004 +++ llvm/test/Regression/Transforms/InstCombine/IntPtrCast.ll Mon Nov 13 12:00:52 2006 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep cast +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | notcast target pointersize = 32 int *%test(int *%P) { Index: llvm/test/Regression/Transforms/InstCombine/2006-04-28-ShiftShiftLongLong.ll diff -u llvm/test/Regression/Transforms/InstCombine/2006-04-28-ShiftShiftLongLong.ll:1.1 llvm/test/Regression/Transforms/InstCombine/2006-04-28-ShiftShiftLongLong.ll:1.2 --- llvm/test/Regression/Transforms/InstCombine/2006-04-28-ShiftShiftLongLong.ll:1.1 Fri Apr 28 17:17:20 2006 +++ llvm/test/Regression/Transforms/InstCombine/2006-04-28-ShiftShiftLongLong.ll Mon Nov 13 12:00:52 2006 @@ -1,5 +1,5 @@ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep shl && -; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep cast +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | notcast ; This cannot be turned into a sign extending cast! Index: llvm/test/Regression/Transforms/InstCombine/2004-11-27-SetCCForCastLargerAndConstant.ll diff -u llvm/test/Regression/Transforms/InstCombine/2004-11-27-SetCCForCastLargerAndConstant.ll:1.6 llvm/test/Regression/Transforms/InstCombine/2004-11-27-SetCCForCastLargerAndConstant.ll:1.7 --- llvm/test/Regression/Transforms/InstCombine/2004-11-27-SetCCForCastLargerAndConstant.ll:1.6 Thu Oct 19 13:54:08 2006 +++ llvm/test/Regression/Transforms/InstCombine/2004-11-27-SetCCForCastLargerAndConstant.ll Mon Nov 13 12:00:52 2006 @@ -9,7 +9,7 @@ ; be eliminated. In many cases the setCC is also eliminated based on the ; constant value and the range of the casted value. ; -; RUN: llvm-as %s -o - | opt -instcombine | llvm-dis | not grep 'cast.*int' +; RUN: llvm-as %s -o - | opt -instcombine | llvm-dis | notcast '.*int' implementation ; Functions: Index: llvm/test/Regression/Transforms/InstCombine/2003-11-13-ConstExprCastCall.ll diff -u llvm/test/Regression/Transforms/InstCombine/2003-11-13-ConstExprCastCall.ll:1.1 llvm/test/Regression/Transforms/InstCombine/2003-11-13-ConstExprCastCall.ll:1.2 --- llvm/test/Regression/Transforms/InstCombine/2003-11-13-ConstExprCastCall.ll:1.1 Thu Nov 13 13:05:15 2003 +++ llvm/test/Regression/Transforms/InstCombine/2003-11-13-ConstExprCastCall.ll Mon Nov 13 12:00:52 2006 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep call | not grep cast +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep call | notcast declare void %free(sbyte*) From sabre at nondot.org Mon Nov 13 14:11:20 2006 From: sabre at nondot.org (Chris Lattner) Date: Mon, 13 Nov 2006 14:11:20 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCHazardRecognizers.cpp Message-ID: <200611132011.kADKBK1f003363@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCHazardRecognizers.cpp updated: 1.14 -> 1.15 --- Log message: teach the g5 hazard recognizer about update loads. This fixes Ptrdist/anagram among others. --- Diffs of the changes: (+10 -11) PPCHazardRecognizers.cpp | 21 ++++++++++----------- 1 files changed, 10 insertions(+), 11 deletions(-) Index: llvm/lib/Target/PowerPC/PPCHazardRecognizers.cpp diff -u llvm/lib/Target/PowerPC/PPCHazardRecognizers.cpp:1.14 llvm/lib/Target/PowerPC/PPCHazardRecognizers.cpp:1.15 --- llvm/lib/Target/PowerPC/PPCHazardRecognizers.cpp:1.14 Thu Jul 13 23:42:02 2006 +++ llvm/lib/Target/PowerPC/PPCHazardRecognizers.cpp Mon Nov 13 14:11:06 2006 @@ -168,30 +168,29 @@ unsigned LoadSize; switch (Opcode) { default: assert(0 && "Unknown load!"); - case PPC::LBZ: + case PPC::LBZ: case PPC::LBZU: case PPC::LBZX: - case PPC::LBZ8: + case PPC::LBZ8: case PPC::LBZU8: case PPC::LBZX8: case PPC::LVEBX: LoadSize = 1; break; - case PPC::LHA: + case PPC::LHA: case PPC::LHAU: case PPC::LHAX: - case PPC::LHZ: + case PPC::LHZ: case PPC::LHZU: case PPC::LHZX: case PPC::LVEHX: case PPC::LHBRX: - case PPC::LHA8: + case PPC::LHA8: case PPC::LHAU8: case PPC::LHAX8: - case PPC::LHZ8: + case PPC::LHZ8: case PPC::LHZU8: case PPC::LHZX8: LoadSize = 2; break; - case PPC::LFS: + case PPC::LFS: case PPC::LFSU: case PPC::LFSX: - case PPC::LWZ: + case PPC::LWZ: case PPC::LWZU: case PPC::LWZX: - case PPC::LWZU: case PPC::LWA: case PPC::LWAX: case PPC::LVEWX: @@ -200,9 +199,9 @@ case PPC::LWZX8: LoadSize = 4; break; - case PPC::LFD: + case PPC::LFD: case PPC::LFDU: case PPC::LFDX: - case PPC::LD: + case PPC::LD: case PPC::LDU: case PPC::LDX: LoadSize = 8; break; From dpatel at apple.com Mon Nov 13 16:40:23 2006 From: dpatel at apple.com (Devang Patel) Date: Mon, 13 Nov 2006 16:40:23 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/PassManager.cpp Message-ID: <200611132240.kADMeNbu006213@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: PassManager.cpp updated: 1.20 -> 1.21 --- Log message: Check currently available anlysis in active managers. --- Diffs of the changes: (+55 -11) PassManager.cpp | 66 ++++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 55 insertions(+), 11 deletions(-) Index: llvm/lib/VMCore/PassManager.cpp diff -u llvm/lib/VMCore/PassManager.cpp:1.20 llvm/lib/VMCore/PassManager.cpp:1.21 --- llvm/lib/VMCore/PassManager.cpp:1.20 Fri Nov 10 20:22:31 2006 +++ llvm/lib/VMCore/PassManager.cpp Mon Nov 13 16:40:09 2006 @@ -33,7 +33,9 @@ bool manageablePass(Pass *P); /// Return true IFF AnalysisID AID is currently available. - bool analysisCurrentlyAvailable(AnalysisID AID); + bool isAnalysisAvailable(AnalysisID AID) { + return (AvailableAnalysis.count(AID) != 0); + } /// Augment RequiredAnalysis by adding analysis required by pass P. void noteDownRequiredAnalysis(Pass *P); @@ -85,6 +87,9 @@ /// whether any of the passes modifies the function, and if so, return true. bool runOnFunction(Function &F); + /// Return true IFF AnalysisID AID is currently available. + bool analysisCurrentlyAvailable(AnalysisID AID); + private: }; @@ -115,6 +120,9 @@ /// so, return true. bool runOnModule(Module &M); + /// Return true IFF AnalysisID AID is currently available. + bool analysisCurrentlyAvailable(AnalysisID AID); + private: // Active Pass Managers BasicBlockPassManager_New *activeBBPassManager; @@ -134,6 +142,9 @@ /// run - Execute all of the passes scheduled for execution. Keep track of /// whether any of the passes modifies the module, and if so, return true. bool runOnModule(Module &M); + + /// Return true IFF AnalysisID AID is currently available. + bool analysisCurrentlyAvailable(AnalysisID AID); private: // Active Pass Manager @@ -155,6 +166,9 @@ /// whether any of the passes modifies the module, and if so, return true. bool run(Module &M); + /// Return true IFF AnalysisID AID is currently available. + bool analysisCurrentlyAvailable(AnalysisID AID); + private: /// Add a pass into a passmanager queue. This is used by schedulePasses @@ -202,13 +216,6 @@ return true; } -/// Return true IFF AnalysisID AID is currently available. -bool CommonPassManagerImpl::analysisCurrentlyAvailable(AnalysisID AID) { - - // TODO - return false; -} - /// Augment RequiredAnalysis by adding analysis required by pass P. void CommonPassManagerImpl::noteDownRequiredAnalysis(Pass *P) { AnalysisUsage AnUsage; @@ -308,6 +315,11 @@ return Changed; } +/// Return true IFF AnalysisID AID is currently available. +bool BasicBlockPassManager_New::analysisCurrentlyAvailable(AnalysisID AID) { + return isAnalysisAvailable(AID); +} + // FunctionPassManager_New implementation /// Create new Function pass manager FunctionPassManager_New::FunctionPassManager_New() { @@ -387,6 +399,19 @@ return Changed; } +/// Return true IFF AnalysisID AID is currently available. +bool FunctionPassManagerImpl_New::analysisCurrentlyAvailable(AnalysisID AID) { + + if (isAnalysisAvailable(AID)) + return true; + + if (activeBBPassManager && + activeBBPassManager->isAnalysisAvailable(AID)) + return true; + + // TODO : Check inactive managers + return false; +} // ModulePassManager implementation @@ -442,6 +467,27 @@ return Changed; } +/// Return true IFF AnalysisID AID is currently available. +bool ModulePassManager_New::analysisCurrentlyAvailable(AnalysisID AID) { + + if (isAnalysisAvailable(AID)) + return true; + + if (activeFunctionPassManager && + activeFunctionPassManager->isAnalysisAvailable(AID)) + return true; + + // TODO : Check inactive managers + return false; +} + +/// Return true IFF AnalysisID AID is currently available. +bool PassManagerImpl_New::analysisCurrentlyAvailable(AnalysisID AID) { + + // TODO : Check inactive managers + return activeManager->analysisCurrentlyAvailable(AID); +} + /// Schedule pass P for execution. Make sure that passes required by /// P are run before P is run. Update analysis info maintained by /// the manager. Remove dead passes. This is a recursive function. @@ -453,9 +499,7 @@ for (std::vector::const_iterator I = RequiredSet.begin(), E = RequiredSet.end(); I != E; ++I) { - // TODO Check if Analysis is currently available or not. - bool available = false; - if (!available) { + if (!analysisCurrentlyAvailable(*I)) { // Schedule this analysis run first. Pass *AP = (*I)->createPass(); schedulePass(AP); From dpatel at apple.com Mon Nov 13 16:53:34 2006 From: dpatel at apple.com (Devang Patel) Date: Mon, 13 Nov 2006 16:53:34 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/PassManager.cpp Message-ID: <200611132253.kADMrYwq006477@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: PassManager.cpp updated: 1.21 -> 1.22 --- Log message: Update PassManagerImpl_New::analysisCurrentlyAvailable to check all managed passmanagers. --- Diffs of the changes: (+5 -2) PassManager.cpp | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) Index: llvm/lib/VMCore/PassManager.cpp diff -u llvm/lib/VMCore/PassManager.cpp:1.21 llvm/lib/VMCore/PassManager.cpp:1.22 --- llvm/lib/VMCore/PassManager.cpp:1.21 Mon Nov 13 16:40:09 2006 +++ llvm/lib/VMCore/PassManager.cpp Mon Nov 13 16:53:19 2006 @@ -484,8 +484,11 @@ /// Return true IFF AnalysisID AID is currently available. bool PassManagerImpl_New::analysisCurrentlyAvailable(AnalysisID AID) { - // TODO : Check inactive managers - return activeManager->analysisCurrentlyAvailable(AID); + bool available = false; + for (std::vector::iterator itr = PassManagers.begin(), + e = PassManagers.end(); !available && itr != e; ++itr) + available = (*itr)->analysisCurrentlyAvailable(AID); + return available; } /// Schedule pass P for execution. Make sure that passes required by From evan.cheng at apple.com Mon Nov 13 17:31:00 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 13 Nov 2006 17:31:00 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineInstr.h Message-ID: <200611132331.kADNV0Ts007061@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineInstr.h updated: 1.195 -> 1.196 --- Log message: - Let MachineInstr ctors add implicit def and use operands. Other operands will be inserted before these operands. If the opcode changes (by setOpcode), the implicit operands are updated as well. - Added IsKill, IsDead fields to MachineOperand in preparation for changes that move kill / dead info to MachineInstr's. --- Diffs of the changes: (+65 -10) MachineInstr.h | 75 +++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 65 insertions(+), 10 deletions(-) Index: llvm/include/llvm/CodeGen/MachineInstr.h diff -u llvm/include/llvm/CodeGen/MachineInstr.h:1.195 llvm/include/llvm/CodeGen/MachineInstr.h:1.196 --- llvm/include/llvm/CodeGen/MachineInstr.h:1.195 Sat Nov 11 04:19:03 2006 +++ llvm/include/llvm/CodeGen/MachineInstr.h Mon Nov 13 17:30:45 2006 @@ -26,6 +26,8 @@ class Value; class Function; class MachineBasicBlock; +class TargetInstrInfo; +class TargetInstrDescriptor; class TargetMachine; class GlobalValue; @@ -61,6 +63,12 @@ MachineOperandType opType:8; // Discriminate the union. bool IsDef : 1; // True if this is a def, false if this is a use. bool IsImp : 1; // True if this is an implicit def or use. + + bool IsKill : 1; // True if this is a reg use and the reg is dead + // immediately after the read. + bool IsDead : 1; // True if this is a reg def and the reg is dead + // immediately after the write. i.e. A register + // that is defined but never used. /// offset - Offset to address of global or external, only valid for /// MO_GlobalAddress, MO_ExternalSym and MO_ConstantPoolIndex @@ -80,6 +88,8 @@ Op.contents.immedVal = Val; Op.IsDef = false; Op.IsImp = false; + Op.IsKill = false; + Op.IsDead = false; Op.offset = 0; return Op; } @@ -88,6 +98,8 @@ contents = MO.contents; IsDef = MO.IsDef; IsImp = MO.IsImp; + IsKill = MO.IsKill; + IsDead = MO.IsDead; opType = MO.opType; offset = MO.offset; return *this; @@ -185,6 +197,31 @@ IsImp = true; } + bool isKill() const { + assert(isRegister() && "Wrong MachineOperand accessor"); + return IsKill; + } + bool isDead() const { + assert(isRegister() && "Wrong MachineOperand accessor"); + return IsDead; + } + void setIsKill() { + assert(isRegister() && "Wrong MachineOperand accessor"); + IsKill = true; + } + void setIsDead() { + assert(isRegister() && "Wrong MachineOperand accessor"); + IsDead = true; + } + void unsetIsKill() { + assert(isRegister() && "Wrong MachineOperand accessor"); + IsKill = false; + } + void unsetIsDead() { + assert(isRegister() && "Wrong MachineOperand accessor"); + IsDead = false; + } + /// getReg - Returns the register number. /// unsigned getReg() const { @@ -238,10 +275,13 @@ /// ChangeToRegister - Replace this operand with a new register operand of /// the specified value. If an operand is known to be an register already, /// the setReg method should be used. - void ChangeToRegister(unsigned Reg, bool isDef) { + void ChangeToRegister(unsigned Reg, bool isDef, + bool isKill = false, bool isDead = false) { opType = MO_Register; contents.RegNo = Reg; IsDef = isDef; + IsKill = isKill; + IsDead = isDead; } friend std::ostream& operator<<(std::ostream& os, const MachineOperand& mop); @@ -259,6 +299,9 @@ MachineInstr* prev, *next; // links for our intrusive list MachineBasicBlock* parent; // pointer to the owning basic block + unsigned NumImplicitOps; // Number of implicit operands (which + // are determined at construction time). + // OperandComplete - Return true if it's illegal to add a new operand bool OperandsComplete() const; @@ -270,10 +313,14 @@ friend struct ilist_traits; public: - /// MachineInstr ctor - This constructor reserve's space for numOperand + /// MachineInstr ctor - This constructor reserves space for numOperand /// operands. MachineInstr(short Opcode, unsigned numOperands); + /// MachineInstr ctor - This constructor create a MachineInstr and add the + /// implicit operands. It reserves space for numOperand operands. + MachineInstr(const TargetInstrInfo &TII, short Opcode, unsigned numOperands); + /// MachineInstr ctor - Work exactly the same as the ctor above, except that /// the MachineInstr is created and added to the end of the specified basic /// block. @@ -342,11 +389,14 @@ /// addRegOperand - Add a register operand. /// - void addRegOperand(unsigned Reg, bool IsDef, bool IsImp = false) { + void addRegOperand(unsigned Reg, bool IsDef, bool IsImp = false, + bool IsKill = false, bool IsDead = false) { MachineOperand &Op = AddNewOperand(IsImp); Op.opType = MachineOperand::MO_Register; Op.IsDef = IsDef; Op.IsImp = IsImp; + Op.IsKill = IsKill; + Op.IsDead = IsDead; Op.contents.RegNo = Reg; Op.offset = 0; } @@ -413,17 +463,13 @@ Op.offset = 0; } - /// addImplicitDefUseOperands - Add all implicit def and use operands to - /// this instruction. - void addImplicitDefUseOperands(); - //===--------------------------------------------------------------------===// // Accessors used to modify instructions in place. // /// setOpcode - Replace the opcode of the current instruction with a new one. /// - void setOpcode(unsigned Op) { Opcode = Op; } + void setOpcode(unsigned Op); /// RemoveOperand - Erase an operand from an instruction, leaving it with one /// fewer operand than it started with. @@ -435,9 +481,18 @@ MachineOperand &AddNewOperand(bool IsImp = false) { assert((IsImp || !OperandsComplete()) && "Trying to add an operand to a machine instr that is already done!"); - Operands.push_back(MachineOperand()); - return Operands.back(); + if (NumImplicitOps == 0) { // This is true most of the time. + Operands.push_back(MachineOperand()); + return Operands.back(); + } else { + return *Operands.insert(Operands.begin()+Operands.size()-NumImplicitOps, + MachineOperand()); + } } + + /// addImplicitDefUseOperands - Add all implicit def and use operands to + /// this instruction. + void addImplicitDefUseOperands(const TargetInstrDescriptor &TID); }; //===----------------------------------------------------------------------===// From evan.cheng at apple.com Mon Nov 13 17:32:47 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 13 Nov 2006 17:32:47 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineInstrBuilder.h Message-ID: <200611132332.kADNWlks007104@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineInstrBuilder.h updated: 1.39 -> 1.40 --- Log message: Matches MachineInstr changes. --- Diffs of the changes: (+15 -14) MachineInstrBuilder.h | 29 +++++++++++++++-------------- 1 files changed, 15 insertions(+), 14 deletions(-) Index: llvm/include/llvm/CodeGen/MachineInstrBuilder.h diff -u llvm/include/llvm/CodeGen/MachineInstrBuilder.h:1.39 llvm/include/llvm/CodeGen/MachineInstrBuilder.h:1.40 --- llvm/include/llvm/CodeGen/MachineInstrBuilder.h:1.39 Sat Nov 11 04:19:03 2006 +++ llvm/include/llvm/CodeGen/MachineInstrBuilder.h Mon Nov 13 17:32:33 2006 @@ -18,6 +18,8 @@ #define LLVM_CODEGEN_MACHINEINSTRBUILDER_H #include "llvm/CodeGen/MachineBasicBlock.h" +#include "llvm/CodeGen/MachineFunction.h" +#include "llvm/Target/TargetMachine.h" namespace llvm { @@ -33,8 +35,9 @@ /// addReg - Add a new virtual register operand... /// - const MachineInstrBuilder &addReg(int RegNo, bool isDef = false, - bool isImp = false) const { + const + MachineInstrBuilder &addReg(int RegNo, bool isDef = false, bool isImp = false, + bool isKill = false, bool isDead = false) const { MI->addRegOperand(RegNo, isDef, isImp); return *this; } @@ -77,28 +80,24 @@ MI->addExternalSymbolOperand(FnName); return *this; } - - const MachineInstrBuilder &addImplicitDefsUses() const { - MI->addImplicitDefUseOperands(); - return *this; - } }; /// BuildMI - Builder interface. Specify how to create the initial instruction /// itself. NumOperands is the number of operands to the machine instruction to /// allow for memory efficient representation of machine instructions. /// -inline MachineInstrBuilder BuildMI(int Opcode, unsigned NumOperands) { - return MachineInstrBuilder(new MachineInstr(Opcode, NumOperands)); +inline MachineInstrBuilder BuildMI(const TargetInstrInfo &TII, int Opcode, + unsigned NumOperands) { + return MachineInstrBuilder(new MachineInstr(TII, Opcode, NumOperands)); } /// BuildMI - This version of the builder sets up the first operand as a /// destination virtual register. NumOperands is the number of additional add* /// calls that are expected, not including the destination register. /// -inline MachineInstrBuilder -BuildMI(int Opcode, unsigned NumOperands, unsigned DestReg) { - return MachineInstrBuilder(new MachineInstr(Opcode, NumOperands+1)) +inline MachineInstrBuilder BuildMI(const TargetInstrInfo &TII, int Opcode, + unsigned NumOperands, unsigned DestReg) { + return MachineInstrBuilder(new MachineInstr(TII, Opcode, NumOperands+1)) .addReg(DestReg, true); } @@ -112,7 +111,8 @@ MachineBasicBlock::iterator I, int Opcode, unsigned NumOperands, unsigned DestReg) { - MachineInstr *MI = new MachineInstr(Opcode, NumOperands+1); + MachineInstr *MI = new MachineInstr(*BB.getParent()->getTarget(). + getInstrInfo(), Opcode, NumOperands+1); BB.insert(I, MI); return MachineInstrBuilder(MI).addReg(DestReg, true); } @@ -124,7 +124,8 @@ inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB, MachineBasicBlock::iterator I, int Opcode, unsigned NumOperands) { - MachineInstr *MI = new MachineInstr(Opcode, NumOperands); + MachineInstr *MI = new MachineInstr(*BB.getParent()->getTarget(). + getInstrInfo(), Opcode, NumOperands); BB.insert(I, MI); return MachineInstrBuilder(MI); } From evan.cheng at apple.com Mon Nov 13 17:34:21 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 13 Nov 2006 17:34:21 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/MachineInstr.cpp Message-ID: <200611132334.kADNYLON007144@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: MachineInstr.cpp updated: 1.129 -> 1.130 --- Log message: - Let MachineInstr ctors add implicit def and use operands. Other operands will be inserted before these operands. If the opcode changes (by setOpcode), the implicit operands are updated as well. - Added IsKill, IsDead fields to MachineOperand in preparation for changes that move kill / dead info to MachineInstr's. --- Diffs of the changes: (+113 -16) MachineInstr.cpp | 129 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 113 insertions(+), 16 deletions(-) Index: llvm/lib/CodeGen/MachineInstr.cpp diff -u llvm/lib/CodeGen/MachineInstr.cpp:1.129 llvm/lib/CodeGen/MachineInstr.cpp:1.130 --- llvm/lib/CodeGen/MachineInstr.cpp:1.129 Sat Nov 11 04:20:02 2006 +++ llvm/lib/CodeGen/MachineInstr.cpp Mon Nov 13 17:34:06 2006 @@ -38,20 +38,74 @@ /// Eventually, the "resizing" ctors will be phased out. /// MachineInstr::MachineInstr(short opcode, unsigned numOperands) - : Opcode(opcode), parent(0) { + : Opcode(opcode), parent(0), NumImplicitOps(0) { Operands.reserve(numOperands); // Make sure that we get added to a machine basicblock LeakDetector::addGarbageObject(this); } +void MachineInstr::addImplicitDefUseOperands(const TargetInstrDescriptor &TID) { + if (TID.ImplicitDefs) + for (const unsigned *ImpDefs = TID.ImplicitDefs; *ImpDefs; ++ImpDefs) { + MachineOperand Op; + Op.opType = MachineOperand::MO_Register; + Op.IsDef = true; + Op.IsImp = true; + Op.IsKill = false; + Op.IsDead = false; + Op.contents.RegNo = *ImpDefs; + Op.offset = 0; + Operands.push_back(Op); + } + if (TID.ImplicitUses) + for (const unsigned *ImpUses = TID.ImplicitUses; *ImpUses; ++ImpUses) { + MachineOperand Op; + Op.opType = MachineOperand::MO_Register; + Op.IsDef = false; + Op.IsImp = true; + Op.IsKill = false; + Op.IsDead = false; + Op.contents.RegNo = *ImpUses; + Op.offset = 0; + Operands.push_back(Op); + } +} + +/// MachineInstr ctor - This constructor create a MachineInstr and add the +/// implicit operands. It reserves space for numOperand operands. +MachineInstr::MachineInstr(const TargetInstrInfo &TII, short opcode, + unsigned numOperands) + : Opcode(opcode), parent(0), NumImplicitOps(0) { + const TargetInstrDescriptor &TID = TII.get(opcode); + if (TID.ImplicitDefs) + for (const unsigned *ImpDefs = TID.ImplicitDefs; *ImpDefs; ++ImpDefs) + NumImplicitOps++; + if (TID.ImplicitUses) + for (const unsigned *ImpUses = TID.ImplicitUses; *ImpUses; ++ImpUses) + NumImplicitOps++; + Operands.reserve(NumImplicitOps + numOperands); + addImplicitDefUseOperands(TID); + // Make sure that we get added to a machine basicblock + LeakDetector::addGarbageObject(this); +} + /// MachineInstr ctor - Work exactly the same as the ctor above, except that the /// MachineInstr is created and added to the end of the specified basic block. /// MachineInstr::MachineInstr(MachineBasicBlock *MBB, short opcode, unsigned numOperands) - : Opcode(opcode), parent(0) { + : Opcode(opcode), parent(0), NumImplicitOps(0) { assert(MBB && "Cannot use inserting ctor with null basic block!"); - Operands.reserve(numOperands); + const TargetInstrDescriptor &TID = MBB->getParent()->getTarget(). + getInstrInfo()->get(opcode); + if (TID.ImplicitDefs) + for (const unsigned *ImpDefs = TID.ImplicitDefs; *ImpDefs; ++ImpDefs) + NumImplicitOps++; + if (TID.ImplicitUses) + for (const unsigned *ImpUses = TID.ImplicitUses; *ImpUses; ++ImpUses) + NumImplicitOps++; + Operands.reserve(NumImplicitOps + numOperands); + addImplicitDefUseOperands(TID); // Make sure that we get added to a machine basicblock LeakDetector::addGarbageObject(this); MBB->push_back(this); // Add instruction to end of basic block! @@ -63,6 +117,7 @@ Opcode = MI.getOpcode(); Operands.reserve(MI.getNumOperands()); + NumImplicitOps = MI.NumImplicitOps; // Add operands for (unsigned i = 0; i != MI.getNumOperands(); ++i) Operands.push_back(MI.getOperand(i)); @@ -92,7 +147,7 @@ bool MachineInstr::OperandsComplete() const { int NumOperands = TargetInstrDescriptors[Opcode].numOperands; if ((TargetInstrDescriptors[Opcode].Flags & M_VARIABLE_OPS) == 0 && - getNumOperands() >= (unsigned)NumOperands) + getNumOperands()-NumImplicitOps >= (unsigned)NumOperands) return true; // Broken: we have all the operands of this instruction! return false; } @@ -125,16 +180,42 @@ } } -/// addImplicitDefUseOperands - Add all implicit def and use operands to -/// this instruction. -void MachineInstr::addImplicitDefUseOperands() { - const TargetInstrDescriptor &TID = TargetInstrDescriptors[Opcode]; +/// setOpcode - Replace the opcode of the current instruction with a new one. +/// +void MachineInstr::setOpcode(unsigned Op) { + Operands.erase(Operands.begin(), Operands.begin()+NumImplicitOps); + NumImplicitOps = 0; + Opcode = Op; + if (!getParent()) + return; + const TargetInstrDescriptor &TID = getParent()->getParent()-> + getTarget().getInstrInfo()->get(Op); if (TID.ImplicitDefs) - for (const unsigned *ImpDefs = TID.ImplicitDefs; *ImpDefs; ++ImpDefs) - addRegOperand(*ImpDefs, true, true); + for (const unsigned *ImpDefs = TID.ImplicitDefs; *ImpDefs; ++ImpDefs) { + MachineOperand Op; + Op.opType = MachineOperand::MO_Register; + Op.IsDef = true; + Op.IsImp = true; + Op.IsKill = false; + Op.IsDead = false; + Op.contents.RegNo = *ImpDefs; + Op.offset = 0; + Operands.insert(Operands.begin()+NumImplicitOps, Op); + NumImplicitOps++; + } if (TID.ImplicitUses) - for (const unsigned *ImpUses = TID.ImplicitUses; *ImpUses; ++ImpUses) - addRegOperand(*ImpUses, false, true); + for (const unsigned *ImpUses = TID.ImplicitUses; *ImpUses; ++ImpUses) { + MachineOperand Op; + Op.opType = MachineOperand::MO_Register; + Op.IsDef = false; + Op.IsImp = true; + Op.IsKill = false; + Op.IsDead = false; + Op.contents.RegNo = *ImpUses; + Op.offset = 0; + Operands.insert(Operands.begin()+NumImplicitOps, Op); + NumImplicitOps++; + } } @@ -218,10 +299,26 @@ ::print(mop, OS, TM); if (mop.isReg()) { - if (mop.isImplicit()) - OS << (mop.isDef() ? "" : ""); - else if (mop.isDef()) - OS << ""; + if (mop.isDef() || mop.isKill() || mop.isDead() || mop.isImplicit()) { + OS << "<"; + bool NeedComma = false; + if (mop.isImplicit()) { + OS << (mop.isDef() ? "imp-def" : "imp-use"); + NeedComma = true; + } else if (mop.isDef()) { + OS << "def"; + NeedComma = true; + } + if (mop.isKill() || mop.isDead()) { + if (NeedComma) + OS << ","; + if (mop.isKill()) + OS << "kill"; + if (mop.isDead()) + OS << "dead"; + } + OS << ">"; + } } } From evan.cheng at apple.com Mon Nov 13 17:35:14 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 13 Nov 2006 17:35:14 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp Message-ID: <200611132335.kADNZEt9007175@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: ScheduleDAG.cpp updated: 1.108 -> 1.109 --- Log message: Matches MachineInstr changes. --- Diffs of the changes: (+1 -4) ScheduleDAG.cpp | 5 +---- 1 files changed, 1 insertion(+), 4 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp:1.108 llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp:1.109 --- llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp:1.108 Sat Nov 11 04:20:02 2006 +++ llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp Mon Nov 13 17:35:00 2006 @@ -395,7 +395,7 @@ #endif // Create the new machine instruction. - MachineInstr *MI = new MachineInstr(Opc, NumMIOperands); + MachineInstr *MI = new MachineInstr(*TII, Opc, NumMIOperands); // Add result register values for things that are defined by this // instruction. @@ -441,9 +441,6 @@ } } - // Emit implicit def / use operands. - MI->addImplicitDefUseOperands(); - // Now that we have emitted all operands, emit this instruction itself. if ((II.Flags & M_USES_CUSTOM_DAG_SCHED_INSERTION) == 0) { BB->insert(BB->end(), MI); From evan.cheng at apple.com Mon Nov 13 17:36:53 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 13 Nov 2006 17:36:53 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcInstrInfo.cpp SparcRegisterInfo.cpp SparcRegisterInfo.h Message-ID: <200611132336.kADNarnO007259@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: SparcInstrInfo.cpp updated: 1.15 -> 1.16 SparcRegisterInfo.cpp updated: 1.45 -> 1.46 SparcRegisterInfo.h updated: 1.13 -> 1.14 --- Log message: Matches MachineInstr changes. --- Diffs of the changes: (+10 -8) SparcInstrInfo.cpp | 2 +- SparcRegisterInfo.cpp | 13 +++++++------ SparcRegisterInfo.h | 3 ++- 3 files changed, 10 insertions(+), 8 deletions(-) Index: llvm/lib/Target/Sparc/SparcInstrInfo.cpp diff -u llvm/lib/Target/Sparc/SparcInstrInfo.cpp:1.15 llvm/lib/Target/Sparc/SparcInstrInfo.cpp:1.16 --- llvm/lib/Target/Sparc/SparcInstrInfo.cpp:1.15 Tue Oct 24 12:07:11 2006 +++ llvm/lib/Target/Sparc/SparcInstrInfo.cpp Mon Nov 13 17:36:35 2006 @@ -19,7 +19,7 @@ SparcInstrInfo::SparcInstrInfo(SparcSubtarget &ST) : TargetInstrInfo(SparcInsts, sizeof(SparcInsts)/sizeof(SparcInsts[0])), - RI(ST) { + RI(ST, *this) { } static bool isZeroImm(const MachineOperand &op) { Index: llvm/lib/Target/Sparc/SparcRegisterInfo.cpp diff -u llvm/lib/Target/Sparc/SparcRegisterInfo.cpp:1.45 llvm/lib/Target/Sparc/SparcRegisterInfo.cpp:1.46 --- llvm/lib/Target/Sparc/SparcRegisterInfo.cpp:1.45 Mon Sep 4 21:31:13 2006 +++ llvm/lib/Target/Sparc/SparcRegisterInfo.cpp Mon Nov 13 17:36:35 2006 @@ -23,9 +23,10 @@ #include using namespace llvm; -SparcRegisterInfo::SparcRegisterInfo(SparcSubtarget &st) +SparcRegisterInfo::SparcRegisterInfo(SparcSubtarget &st, + const TargetInstrInfo &tii) : SparcGenRegisterInfo(SP::ADJCALLSTACKDOWN, SP::ADJCALLSTACKUP), - Subtarget(st) { + Subtarget(st), TII(tii) { } void SparcRegisterInfo:: @@ -81,10 +82,10 @@ if (MI->getOperand(1).isRegister() && MI->getOperand(1).getReg() == SP::G0&& MI->getOperand(0).isRegister() && MI->getOperand(2).isRegister()) { if (OpNum == 0) // COPY -> STORE - return BuildMI(SP::STri, 3).addFrameIndex(FI).addImm(0) + return BuildMI(TII, SP::STri, 3).addFrameIndex(FI).addImm(0) .addReg(MI->getOperand(2).getReg()); else // COPY -> LOAD - return BuildMI(SP::LDri, 2, MI->getOperand(0).getReg()) + return BuildMI(TII, SP::LDri, 2, MI->getOperand(0).getReg()) .addFrameIndex(FI).addImm(0); } break; @@ -93,10 +94,10 @@ // FALLTHROUGH case SP::FMOVD: if (OpNum == 0) // COPY -> STORE - return BuildMI(isFloat ? SP::STFri : SP::STDFri, 3) + return BuildMI(TII, isFloat ? SP::STFri : SP::STDFri, 3) .addFrameIndex(FI).addImm(0).addReg(MI->getOperand(1).getReg()); else // COPY -> LOAD - return BuildMI(isFloat ? SP::LDFri : SP::LDDFri, 2, + return BuildMI(TII, isFloat ? SP::LDFri : SP::LDDFri, 2, MI->getOperand(0).getReg()).addFrameIndex(FI).addImm(0); break; } Index: llvm/lib/Target/Sparc/SparcRegisterInfo.h diff -u llvm/lib/Target/Sparc/SparcRegisterInfo.h:1.13 llvm/lib/Target/Sparc/SparcRegisterInfo.h:1.14 --- llvm/lib/Target/Sparc/SparcRegisterInfo.h:1.13 Wed May 17 19:12:45 2006 +++ llvm/lib/Target/Sparc/SparcRegisterInfo.h Mon Nov 13 17:36:35 2006 @@ -24,8 +24,9 @@ struct SparcRegisterInfo : public SparcGenRegisterInfo { SparcSubtarget &Subtarget; + const TargetInstrInfo &TII; - SparcRegisterInfo(SparcSubtarget &st); + SparcRegisterInfo(SparcSubtarget &st, const TargetInstrInfo &tii); /// Code Generation virtual methods... void storeRegToStackSlot(MachineBasicBlock &MBB, From evan.cheng at apple.com Mon Nov 13 17:36:55 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 13 Nov 2006 17:36:55 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/IA64/IA64RegisterInfo.cpp Message-ID: <200611132336.kADNatnZ007264@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/IA64: IA64RegisterInfo.cpp updated: 1.22 -> 1.23 --- Log message: Matches MachineInstr changes. --- Diffs of the changes: (+23 -17) IA64RegisterInfo.cpp | 40 +++++++++++++++++++++++----------------- 1 files changed, 23 insertions(+), 17 deletions(-) Index: llvm/lib/Target/IA64/IA64RegisterInfo.cpp diff -u llvm/lib/Target/IA64/IA64RegisterInfo.cpp:1.22 llvm/lib/Target/IA64/IA64RegisterInfo.cpp:1.23 --- llvm/lib/Target/IA64/IA64RegisterInfo.cpp:1.22 Mon Sep 4 21:31:13 2006 +++ llvm/lib/Target/IA64/IA64RegisterInfo.cpp Mon Nov 13 17:36:35 2006 @@ -121,7 +121,7 @@ void IA64RegisterInfo:: eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const { - + const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); if (hasFP(MF)) { // If we have a frame pointer, turn the adjcallstackup instruction into a // 'sub SP, ' and the adjcallstackdown instruction into 'add SP, @@ -137,11 +137,11 @@ MachineInstr *New; if (Old->getOpcode() == IA64::ADJUSTCALLSTACKDOWN) { - New=BuildMI(IA64::ADDIMM22, 2, IA64::r12).addReg(IA64::r12) + New=BuildMI(TII, IA64::ADDIMM22, 2, IA64::r12).addReg(IA64::r12) .addImm(-Amount); } else { assert(Old->getOpcode() == IA64::ADJUSTCALLSTACKUP); - New=BuildMI(IA64::ADDIMM22, 2, IA64::r12).addReg(IA64::r12) + New=BuildMI(TII, IA64::ADDIMM22, 2, IA64::r12).addReg(IA64::r12) .addImm(Amount); } @@ -158,6 +158,7 @@ MachineInstr &MI = *II; MachineBasicBlock &MBB = *MI.getParent(); MachineFunction &MF = *MBB.getParent(); + const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); bool FP = hasFP(MF); @@ -186,16 +187,16 @@ // Fix up the old: MI.getOperand(i).ChangeToRegister(IA64::r22, false); //insert the new - MachineInstr* nMI=BuildMI(IA64::ADDIMM22, 2, IA64::r22) + MachineInstr* nMI=BuildMI(TII, IA64::ADDIMM22, 2, IA64::r22) .addReg(BaseRegister).addImm(Offset); MBB.insert(II, nMI); } else { // it's big //fix up the old: MI.getOperand(i).ChangeToRegister(IA64::r22, false); MachineInstr* nMI; - nMI=BuildMI(IA64::MOVLIMM64, 1, IA64::r22).addImm(Offset); + nMI=BuildMI(TII, IA64::MOVLIMM64, 1, IA64::r22).addImm(Offset); MBB.insert(II, nMI); - nMI=BuildMI(IA64::ADD, 2, IA64::r22).addReg(BaseRegister) + nMI=BuildMI(TII, IA64::ADD, 2, IA64::r22).addReg(BaseRegister) .addReg(IA64::r22); MBB.insert(II, nMI); } @@ -206,6 +207,7 @@ MachineBasicBlock &MBB = MF.front(); // Prolog goes in entry BB MachineBasicBlock::iterator MBBI = MBB.begin(); MachineFrameInfo *MFI = MF.getFrameInfo(); + const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); MachineInstr *MI; bool FP = hasFP(MF); @@ -250,7 +252,7 @@ } } - MI=BuildMI(IA64::ALLOC,5).addReg(dstRegOfPseudoAlloc).addImm(0).\ + MI=BuildMI(TII, IA64::ALLOC,5).addReg(dstRegOfPseudoAlloc).addImm(0). \ addImm(numStackedGPRsUsed).addImm(numOutRegsUsed).addImm(0); MBB.insert(MBBI, MI); @@ -282,22 +284,23 @@ // adjust stack pointer: r12 -= numbytes if (NumBytes <= 8191) { - MI=BuildMI(IA64::ADDIMM22,2,IA64::r12).addReg(IA64::r12).addImm(-NumBytes); + MI=BuildMI(TII, IA64::ADDIMM22,2,IA64::r12).addReg(IA64::r12). + addImm(-NumBytes); MBB.insert(MBBI, MI); } else { // we use r22 as a scratch register here - MI=BuildMI(IA64::MOVLIMM64, 1, IA64::r22).addImm(-NumBytes); + MI=BuildMI(TII, IA64::MOVLIMM64, 1, IA64::r22).addImm(-NumBytes); // FIXME: MOVLSI32 expects a _u_32imm MBB.insert(MBBI, MI); // first load the decrement into r22 - MI=BuildMI(IA64::ADD, 2, IA64::r12).addReg(IA64::r12).addReg(IA64::r22); + MI=BuildMI(TII,IA64::ADD, 2, IA64::r12).addReg(IA64::r12).addReg(IA64::r22); MBB.insert(MBBI, MI); // then add (subtract) it to r12 (stack ptr) } // now if we need to, save the old FP and set the new if (FP) { - MI = BuildMI(IA64::ST8, 2).addReg(IA64::r12).addReg(IA64::r5); + MI = BuildMI(TII, IA64::ST8, 2).addReg(IA64::r12).addReg(IA64::r5); MBB.insert(MBBI, MI); // this must be the last instr in the prolog ? (XXX: why??) - MI = BuildMI(IA64::MOV, 1, IA64::r5).addReg(IA64::r12); + MI = BuildMI(TII, IA64::MOV, 1, IA64::r5).addReg(IA64::r12); MBB.insert(MBBI, MI); } @@ -306,6 +309,7 @@ void IA64RegisterInfo::emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const { const MachineFrameInfo *MFI = MF.getFrameInfo(); + const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); MachineBasicBlock::iterator MBBI = prior(MBB.end()); MachineInstr *MI; assert(MBBI->getOpcode() == IA64::RET && @@ -320,22 +324,24 @@ if (FP) { //copy the FP into the SP (discards allocas) - MI=BuildMI(IA64::MOV, 1, IA64::r12).addReg(IA64::r5); + MI=BuildMI(TII, IA64::MOV, 1, IA64::r12).addReg(IA64::r5); MBB.insert(MBBI, MI); //restore the FP - MI=BuildMI(IA64::LD8, 1, IA64::r5).addReg(IA64::r5); + MI=BuildMI(TII, IA64::LD8, 1, IA64::r5).addReg(IA64::r5); MBB.insert(MBBI, MI); } if (NumBytes != 0) { if (NumBytes <= 8191) { - MI=BuildMI(IA64::ADDIMM22,2,IA64::r12).addReg(IA64::r12).addImm(NumBytes); + MI=BuildMI(TII, IA64::ADDIMM22,2,IA64::r12).addReg(IA64::r12). + addImm(NumBytes); MBB.insert(MBBI, MI); } else { - MI=BuildMI(IA64::MOVLIMM64, 1, IA64::r22).addImm(NumBytes); + MI=BuildMI(TII, IA64::MOVLIMM64, 1, IA64::r22).addImm(NumBytes); MBB.insert(MBBI, MI); - MI=BuildMI(IA64::ADD, 2, IA64::r12).addReg(IA64::r12).addReg(IA64::r22); + MI=BuildMI(TII, IA64::ADD, 2, IA64::r12).addReg(IA64::r12). + addReg(IA64::r22); MBB.insert(MBBI, MI); } } From evan.cheng at apple.com Mon Nov 13 17:36:56 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 13 Nov 2006 17:36:56 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaInstrInfo.cpp AlphaRegisterInfo.cpp AlphaRegisterInfo.h Message-ID: <200611132336.kADNauti007274@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaInstrInfo.cpp updated: 1.13 -> 1.14 AlphaRegisterInfo.cpp updated: 1.50 -> 1.51 AlphaRegisterInfo.h updated: 1.13 -> 1.14 --- Log message: Matches MachineInstr changes. --- Diffs of the changes: (+13 -9) AlphaInstrInfo.cpp | 3 ++- AlphaRegisterInfo.cpp | 15 ++++++++------- AlphaRegisterInfo.h | 4 +++- 3 files changed, 13 insertions(+), 9 deletions(-) Index: llvm/lib/Target/Alpha/AlphaInstrInfo.cpp diff -u llvm/lib/Target/Alpha/AlphaInstrInfo.cpp:1.13 llvm/lib/Target/Alpha/AlphaInstrInfo.cpp:1.14 --- llvm/lib/Target/Alpha/AlphaInstrInfo.cpp:1.13 Tue Oct 31 17:46:56 2006 +++ llvm/lib/Target/Alpha/AlphaInstrInfo.cpp Mon Nov 13 17:36:35 2006 @@ -19,7 +19,8 @@ using namespace llvm; AlphaInstrInfo::AlphaInstrInfo() - : TargetInstrInfo(AlphaInsts, sizeof(AlphaInsts)/sizeof(AlphaInsts[0])) { } + : TargetInstrInfo(AlphaInsts, sizeof(AlphaInsts)/sizeof(AlphaInsts[0])), + RI(*this) { } bool AlphaInstrInfo::isMoveInstr(const MachineInstr& MI, Index: llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp diff -u llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.50 llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.51 --- llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.50 Thu Nov 2 19:18:29 2006 +++ llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp Mon Nov 13 17:36:35 2006 @@ -51,8 +51,9 @@ return l - h * IMM_MULT; } -AlphaRegisterInfo::AlphaRegisterInfo() - : AlphaGenRegisterInfo(Alpha::ADJUSTSTACKDOWN, Alpha::ADJUSTSTACKUP) +AlphaRegisterInfo::AlphaRegisterInfo(const TargetInstrInfo &tii) + : AlphaGenRegisterInfo(Alpha::ADJUSTSTACKDOWN, Alpha::ADJUSTSTACKUP), + TII(tii) { } @@ -114,13 +115,13 @@ unsigned InReg = MI->getOperand(1).getReg(); Opc = (Opc == Alpha::BISr) ? Alpha::STQ : ((Opc == Alpha::CPYSS) ? Alpha::STS : Alpha::STT); - return BuildMI(Opc, 3).addReg(InReg).addFrameIndex(FrameIndex) + return BuildMI(TII, Opc, 3).addReg(InReg).addFrameIndex(FrameIndex) .addReg(Alpha::F31); } else { // load -> move unsigned OutReg = MI->getOperand(0).getReg(); Opc = (Opc == Alpha::BISr) ? Alpha::LDQ : ((Opc == Alpha::CPYSS) ? Alpha::LDS : Alpha::LDT); - return BuildMI(Opc, 2, OutReg).addFrameIndex(FrameIndex) + return BuildMI(TII, Opc, 2, OutReg).addFrameIndex(FrameIndex) .addReg(Alpha::F31); } } @@ -205,11 +206,11 @@ MachineInstr *New; if (Old->getOpcode() == Alpha::ADJUSTSTACKDOWN) { - New=BuildMI(Alpha::LDA, 2, Alpha::R30) + New=BuildMI(TII, Alpha::LDA, 2, Alpha::R30) .addImm(-Amount).addReg(Alpha::R30); } else { assert(Old->getOpcode() == Alpha::ADJUSTSTACKUP); - New=BuildMI(Alpha::LDA, 2, Alpha::R30) + New=BuildMI(TII, Alpha::LDA, 2, Alpha::R30) .addImm(Amount).addReg(Alpha::R30); } @@ -266,7 +267,7 @@ MI.getOperand(i + 1).ChangeToRegister(Alpha::R28, false); MI.getOperand(i).ChangeToImmediate(getLower16(Offset)); //insert the new - MachineInstr* nMI=BuildMI(Alpha::LDAH, 2, Alpha::R28) + MachineInstr* nMI=BuildMI(TII, Alpha::LDAH, 2, Alpha::R28) .addImm(getUpper16(Offset)).addReg(FP ? Alpha::R15 : Alpha::R30); MBB.insert(II, nMI); } else { Index: llvm/lib/Target/Alpha/AlphaRegisterInfo.h diff -u llvm/lib/Target/Alpha/AlphaRegisterInfo.h:1.13 llvm/lib/Target/Alpha/AlphaRegisterInfo.h:1.14 --- llvm/lib/Target/Alpha/AlphaRegisterInfo.h:1.13 Wed May 17 19:11:53 2006 +++ llvm/lib/Target/Alpha/AlphaRegisterInfo.h Mon Nov 13 17:36:35 2006 @@ -22,7 +22,9 @@ class Type; struct AlphaRegisterInfo : public AlphaGenRegisterInfo { - AlphaRegisterInfo(); + const TargetInstrInfo &TII; + + AlphaRegisterInfo(const TargetInstrInfo &tii); /// Code Generation virtual methods... void storeRegToStackSlot(MachineBasicBlock &MBB, From evan.cheng at apple.com Mon Nov 13 17:36:56 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 13 Nov 2006 17:36:56 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCInstrInfo.cpp PPCRegisterInfo.cpp PPCRegisterInfo.h Message-ID: <200611132336.kADNauVl007283@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCInstrInfo.cpp updated: 1.29 -> 1.30 PPCRegisterInfo.cpp updated: 1.80 -> 1.81 PPCRegisterInfo.h updated: 1.16 -> 1.17 --- Log message: Matches MachineInstr changes. --- Diffs of the changes: (+14 -12) PPCInstrInfo.cpp | 2 +- PPCRegisterInfo.cpp | 21 +++++++++++---------- PPCRegisterInfo.h | 3 ++- 3 files changed, 14 insertions(+), 12 deletions(-) Index: llvm/lib/Target/PowerPC/PPCInstrInfo.cpp diff -u llvm/lib/Target/PowerPC/PPCInstrInfo.cpp:1.29 llvm/lib/Target/PowerPC/PPCInstrInfo.cpp:1.30 --- llvm/lib/Target/PowerPC/PPCInstrInfo.cpp:1.29 Sat Oct 28 12:35:02 2006 +++ llvm/lib/Target/PowerPC/PPCInstrInfo.cpp Mon Nov 13 17:36:35 2006 @@ -20,7 +20,7 @@ PPCInstrInfo::PPCInstrInfo(PPCTargetMachine &tm) : TargetInstrInfo(PPCInsts, sizeof(PPCInsts)/sizeof(PPCInsts[0])), TM(tm), - RI(*TM.getSubtargetImpl()) {} + RI(*TM.getSubtargetImpl(), *this) {} /// getPointerRegClass - Return the register class to use to hold pointers. /// This is used for addressing modes. Index: llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp diff -u llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.80 llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.81 --- llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.80 Sat Nov 11 16:22:07 2006 +++ llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp Mon Nov 13 17:36:35 2006 @@ -80,9 +80,10 @@ } } -PPCRegisterInfo::PPCRegisterInfo(const PPCSubtarget &ST) +PPCRegisterInfo::PPCRegisterInfo(const PPCSubtarget &ST, + const TargetInstrInfo &tii) : PPCGenRegisterInfo(PPC::ADJCALLSTACKDOWN, PPC::ADJCALLSTACKUP), - Subtarget(ST) { + Subtarget(ST), TII(tii) { ImmToIdxMap[PPC::LD] = PPC::LDX; ImmToIdxMap[PPC::STD] = PPC::STDX; ImmToIdxMap[PPC::LBZ] = PPC::LBZX; ImmToIdxMap[PPC::STB] = PPC::STBX; ImmToIdxMap[PPC::LHZ] = PPC::LHZX; ImmToIdxMap[PPC::LHA] = PPC::LHAX; @@ -322,39 +323,39 @@ MI->getOperand(1).getReg() == MI->getOperand(2).getReg())) { if (OpNum == 0) { // move -> store unsigned InReg = MI->getOperand(1).getReg(); - return addFrameReference(BuildMI(PPC::STW, + return addFrameReference(BuildMI(TII, PPC::STW, 3).addReg(InReg), FrameIndex); } else { // move -> load unsigned OutReg = MI->getOperand(0).getReg(); - return addFrameReference(BuildMI(PPC::LWZ, 2, OutReg), FrameIndex); + return addFrameReference(BuildMI(TII, PPC::LWZ, 2, OutReg), FrameIndex); } } else if ((Opc == PPC::OR8 && MI->getOperand(1).getReg() == MI->getOperand(2).getReg())) { if (OpNum == 0) { // move -> store unsigned InReg = MI->getOperand(1).getReg(); - return addFrameReference(BuildMI(PPC::STD, + return addFrameReference(BuildMI(TII, PPC::STD, 3).addReg(InReg), FrameIndex); } else { // move -> load unsigned OutReg = MI->getOperand(0).getReg(); - return addFrameReference(BuildMI(PPC::LD, 2, OutReg), FrameIndex); + return addFrameReference(BuildMI(TII, PPC::LD, 2, OutReg), FrameIndex); } } else if (Opc == PPC::FMRD) { if (OpNum == 0) { // move -> store unsigned InReg = MI->getOperand(1).getReg(); - return addFrameReference(BuildMI(PPC::STFD, + return addFrameReference(BuildMI(TII, PPC::STFD, 3).addReg(InReg), FrameIndex); } else { // move -> load unsigned OutReg = MI->getOperand(0).getReg(); - return addFrameReference(BuildMI(PPC::LFD, 2, OutReg), FrameIndex); + return addFrameReference(BuildMI(TII, PPC::LFD, 2, OutReg), FrameIndex); } } else if (Opc == PPC::FMRS) { if (OpNum == 0) { // move -> store unsigned InReg = MI->getOperand(1).getReg(); - return addFrameReference(BuildMI(PPC::STFS, + return addFrameReference(BuildMI(TII, PPC::STFS, 3).addReg(InReg), FrameIndex); } else { // move -> load unsigned OutReg = MI->getOperand(0).getReg(); - return addFrameReference(BuildMI(PPC::LFS, 2, OutReg), FrameIndex); + return addFrameReference(BuildMI(TII, PPC::LFS, 2, OutReg), FrameIndex); } } return 0; Index: llvm/lib/Target/PowerPC/PPCRegisterInfo.h diff -u llvm/lib/Target/PowerPC/PPCRegisterInfo.h:1.16 llvm/lib/Target/PowerPC/PPCRegisterInfo.h:1.17 --- llvm/lib/Target/PowerPC/PPCRegisterInfo.h:1.16 Mon Jul 10 19:48:23 2006 +++ llvm/lib/Target/PowerPC/PPCRegisterInfo.h Mon Nov 13 17:36:35 2006 @@ -25,8 +25,9 @@ class PPCRegisterInfo : public PPCGenRegisterInfo { std::map ImmToIdxMap; const PPCSubtarget &Subtarget; + const TargetInstrInfo &TII; public: - PPCRegisterInfo(const PPCSubtarget &SubTarget); + PPCRegisterInfo(const PPCSubtarget &SubTarget, const TargetInstrInfo &tii); /// getRegisterNumbering - Given the enum value for some register, e.g. /// PPC::F14, return the number that it corresponds to (e.g. 14). From evan.cheng at apple.com Mon Nov 13 17:36:52 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 13 Nov 2006 17:36:52 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86FloatingPoint.cpp X86ISelDAGToDAG.cpp X86ISelLowering.cpp X86InstrInfo.cpp X86RegisterInfo.cpp Message-ID: <200611132336.kADNaqGC007250@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86FloatingPoint.cpp updated: 1.57 -> 1.58 X86ISelDAGToDAG.cpp updated: 1.126 -> 1.127 X86ISelLowering.cpp updated: 1.291 -> 1.292 X86InstrInfo.cpp updated: 1.71 -> 1.72 X86RegisterInfo.cpp updated: 1.176 -> 1.177 --- Log message: Matches MachineInstr changes. --- Diffs of the changes: (+47 -56) X86FloatingPoint.cpp | 29 +++++++++++------------------ X86ISelDAGToDAG.cpp | 9 +++------ X86ISelLowering.cpp | 2 +- X86InstrInfo.cpp | 22 +++++++++++----------- X86RegisterInfo.cpp | 41 +++++++++++++++++++++-------------------- 5 files changed, 47 insertions(+), 56 deletions(-) Index: llvm/lib/Target/X86/X86FloatingPoint.cpp diff -u llvm/lib/Target/X86/X86FloatingPoint.cpp:1.57 llvm/lib/Target/X86/X86FloatingPoint.cpp:1.58 --- llvm/lib/Target/X86/X86FloatingPoint.cpp:1.57 Sat Nov 11 04:21:44 2006 +++ llvm/lib/Target/X86/X86FloatingPoint.cpp Mon Nov 13 17:36:35 2006 @@ -40,6 +40,7 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/Compiler.h" #include "llvm/ADT/DepthFirstIterator.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/STLExtras.h" #include @@ -213,20 +214,12 @@ // Get dead variables list now because the MI pointer may be deleted as part // of processing! - LiveVariables::killed_iterator IB, IE; - tie(IB, IE) = LV->dead_range(MI); - - DEBUG( - const MRegisterInfo *MRI = MF.getTarget().getRegisterInfo(); - LiveVariables::killed_iterator I = LV->killed_begin(MI); - LiveVariables::killed_iterator E = LV->killed_end(MI); - if (I != E) { - std::cerr << "Killed Operands:"; - for (; I != E; ++I) - std::cerr << " %" << MRI->getName(*I); - std::cerr << "\n"; - } - ); + SmallVector DeadRegs; + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { + const MachineOperand &MO = MI->getOperand(i); + if (MO.isReg() && MO.isDead()) + DeadRegs.push_back(MO.getReg()); + } switch (Flags & X86II::FPTypeMask) { case X86II::ZeroArgFP: handleZeroArgFP(I); break; @@ -241,8 +234,8 @@ // Check to see if any of the values defined by this instruction are dead // after definition. If so, pop them. - for (; IB != IE; ++IB) { - unsigned Reg = *IB; + for (unsigned i = 0, e = DeadRegs.size(); i != e; ++i) { + unsigned Reg = DeadRegs[i]; if (Reg >= X86::FP0 && Reg <= X86::FP6) { DEBUG(std::cerr << "Register FP#" << Reg-X86::FP0 << " is dead!\n"); freeStackSlotAfter(I, Reg-X86::FP0); @@ -762,6 +755,7 @@ unsigned Op0 = getFPReg(MI->getOperand(0)); unsigned Op1 = getFPReg(MI->getOperand(2)); + bool KillsOp1 = LV->KillsRegister(MI, X86::FP0+Op1); // The first operand *must* be on the top of the stack. moveToTop(Op0, I); @@ -773,9 +767,8 @@ MI->getOperand(0).setReg(getSTReg(Op1)); MI->setOpcode(getConcreteOpcode(MI->getOpcode())); - // If we kill the second operand, make sure to pop it from the stack. - if (Op0 != Op1 && LV->KillsRegister(MI, X86::FP0+Op1)) { + if (Op0 != Op1 && KillsOp1) { // Get this value off of the register stack. freeStackSlotAfter(I, Op1); } Index: llvm/lib/Target/X86/X86ISelDAGToDAG.cpp diff -u llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:1.126 llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:1.127 --- llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:1.126 Sat Nov 11 04:21:44 2006 +++ llvm/lib/Target/X86/X86ISelDAGToDAG.cpp Mon Nov 13 17:36:35 2006 @@ -525,8 +525,7 @@ // Finally, if we found any FP code, emit the FP_REG_KILL instruction. if (ContainsFPCode) { - BuildMI(*BB, BB->getFirstTerminator(), X86::FP_REG_KILL, 0). - addImplicitDefsUses(); + BuildMI(*BB, BB->getFirstTerminator(), X86::FP_REG_KILL, 0); ++NumFPKill; } } @@ -537,8 +536,7 @@ void X86DAGToDAGISel::EmitSpecialCodeForMain(MachineBasicBlock *BB, MachineFrameInfo *MFI) { if (Subtarget->isTargetCygwin()) - BuildMI(BB, X86::CALLpcrel32, 1).addExternalSymbol("__main"). - addImplicitDefsUses(); + BuildMI(BB, X86::CALLpcrel32, 1).addExternalSymbol("__main"); // Switch the FPU to 64-bit precision mode for better compatibility and speed. int CWFrameIdx = MFI->CreateStackObject(2, 2); @@ -949,8 +947,7 @@ // type of register here. GlobalBaseReg = RegMap->createVirtualRegister(X86::GR32RegisterClass); BuildMI(FirstMBB, MBBI, X86::MovePCtoStack, 0); - BuildMI(FirstMBB, MBBI, X86::POP32r, 1, GlobalBaseReg). - addImplicitDefsUses(); + BuildMI(FirstMBB, MBBI, X86::POP32r, 1, GlobalBaseReg); } return CurDAG->getRegister(GlobalBaseReg, TLI.getPointerTy()).Val; } Index: llvm/lib/Target/X86/X86ISelLowering.cpp diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.291 llvm/lib/Target/X86/X86ISelLowering.cpp:1.292 --- llvm/lib/Target/X86/X86ISelLowering.cpp:1.291 Sat Nov 11 04:21:44 2006 +++ llvm/lib/Target/X86/X86ISelLowering.cpp Mon Nov 13 17:36:35 2006 @@ -5076,7 +5076,7 @@ MachineBasicBlock *sinkMBB = new MachineBasicBlock(LLVM_BB); unsigned Opc = X86::GetCondBranchFromCond((X86::CondCode)MI->getOperand(3).getImm()); - BuildMI(BB, Opc, 1).addMBB(sinkMBB).addImplicitDefsUses(); + BuildMI(BB, Opc, 1).addMBB(sinkMBB); MachineFunction *F = BB->getParent(); F->getBasicBlockList().insert(It, copy0MBB); F->getBasicBlockList().insert(It, sinkMBB); Index: llvm/lib/Target/X86/X86InstrInfo.cpp diff -u llvm/lib/Target/X86/X86InstrInfo.cpp:1.71 llvm/lib/Target/X86/X86InstrInfo.cpp:1.72 --- llvm/lib/Target/X86/X86InstrInfo.cpp:1.71 Mon Oct 30 16:27:23 2006 +++ llvm/lib/Target/X86/X86InstrInfo.cpp Mon Nov 13 17:36:35 2006 @@ -140,7 +140,7 @@ unsigned C = MI->getOperand(2).getReg(); unsigned M = MI->getOperand(3).getImmedValue(); if (!Subtarget->hasSSE2() || B != C) return 0; - return BuildMI(X86::PSHUFDri, 2, A).addReg(B).addImm(M); + return BuildMI(*this, X86::PSHUFDri, 2, A).addReg(B).addImm(M); } } @@ -157,35 +157,35 @@ case X86::INC32r: case X86::INC64_32r: assert(MI->getNumOperands() == 2 && "Unknown inc instruction!"); - return addRegOffset(BuildMI(X86::LEA32r, 5, Dest), Src, 1); + return addRegOffset(BuildMI(*this, X86::LEA32r, 5, Dest), Src, 1); case X86::INC16r: case X86::INC64_16r: if (DisableLEA16) return 0; assert(MI->getNumOperands() == 2 && "Unknown inc instruction!"); - return addRegOffset(BuildMI(X86::LEA16r, 5, Dest), Src, 1); + return addRegOffset(BuildMI(*this, X86::LEA16r, 5, Dest), Src, 1); case X86::DEC32r: case X86::DEC64_32r: assert(MI->getNumOperands() == 2 && "Unknown dec instruction!"); - return addRegOffset(BuildMI(X86::LEA32r, 5, Dest), Src, -1); + return addRegOffset(BuildMI(*this, X86::LEA32r, 5, Dest), Src, -1); case X86::DEC16r: case X86::DEC64_16r: if (DisableLEA16) return 0; assert(MI->getNumOperands() == 2 && "Unknown dec instruction!"); - return addRegOffset(BuildMI(X86::LEA16r, 5, Dest), Src, -1); + return addRegOffset(BuildMI(*this, X86::LEA16r, 5, Dest), Src, -1); case X86::ADD32rr: assert(MI->getNumOperands() == 3 && "Unknown add instruction!"); - return addRegReg(BuildMI(X86::LEA32r, 5, Dest), Src, + return addRegReg(BuildMI(*this, X86::LEA32r, 5, Dest), Src, MI->getOperand(2).getReg()); case X86::ADD16rr: if (DisableLEA16) return 0; assert(MI->getNumOperands() == 3 && "Unknown add instruction!"); - return addRegReg(BuildMI(X86::LEA16r, 5, Dest), Src, + return addRegReg(BuildMI(*this, X86::LEA16r, 5, Dest), Src, MI->getOperand(2).getReg()); case X86::ADD32ri: case X86::ADD32ri8: assert(MI->getNumOperands() == 3 && "Unknown add instruction!"); if (MI->getOperand(2).isImmediate()) - return addRegOffset(BuildMI(X86::LEA32r, 5, Dest), Src, + return addRegOffset(BuildMI(*this, X86::LEA32r, 5, Dest), Src, MI->getOperand(2).getImmedValue()); return 0; case X86::ADD16ri: @@ -193,7 +193,7 @@ if (DisableLEA16) return 0; assert(MI->getNumOperands() == 3 && "Unknown add instruction!"); if (MI->getOperand(2).isImmediate()) - return addRegOffset(BuildMI(X86::LEA16r, 5, Dest), Src, + return addRegOffset(BuildMI(*this, X86::LEA16r, 5, Dest), Src, MI->getOperand(2).getImmedValue()); break; @@ -208,7 +208,7 @@ AM.Scale = 1 << ShAmt; AM.IndexReg = Src; unsigned Opc = MI->getOpcode() == X86::SHL32ri ? X86::LEA32r :X86::LEA16r; - return addFullAddress(BuildMI(Opc, 5, Dest), AM); + return addFullAddress(BuildMI(*this, Opc, 5, Dest), AM); } break; } @@ -239,7 +239,7 @@ unsigned A = MI->getOperand(0).getReg(); unsigned B = MI->getOperand(1).getReg(); unsigned C = MI->getOperand(2).getReg(); - return BuildMI(Opc, 3, A).addReg(C).addReg(B).addImm(Size-Amt); + return BuildMI(*this, Opc, 3, A).addReg(C).addReg(B).addImm(Size-Amt); } default: return TargetInstrInfo::commuteInstruction(MI); Index: llvm/lib/Target/X86/X86RegisterInfo.cpp diff -u llvm/lib/Target/X86/X86RegisterInfo.cpp:1.176 llvm/lib/Target/X86/X86RegisterInfo.cpp:1.177 --- llvm/lib/Target/X86/X86RegisterInfo.cpp:1.176 Fri Nov 10 03:13:37 2006 +++ llvm/lib/Target/X86/X86RegisterInfo.cpp Mon Nov 13 17:36:35 2006 @@ -165,7 +165,7 @@ const TargetInstrInfo &TII) { unsigned NumOps = TII.getNumOperands(MI->getOpcode())-2; // Create the base instruction with the memory operand as the first part. - MachineInstrBuilder MIB = addFrameReference(BuildMI(Opcode, 4+NumOps), + MachineInstrBuilder MIB = addFrameReference(BuildMI(TII, Opcode, 4+NumOps), FrameIndex); // Loop over the rest of the ri operands, converting them over. @@ -188,7 +188,7 @@ static MachineInstr *FuseInst(unsigned Opcode, unsigned OpNo, unsigned FrameIndex, MachineInstr *MI, const TargetInstrInfo &TII) { - MachineInstrBuilder MIB = BuildMI(Opcode, MI->getNumOperands()+3); + MachineInstrBuilder MIB = BuildMI(TII, Opcode, MI->getNumOperands()+3); for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { MachineOperand &MO = MI->getOperand(i); @@ -209,9 +209,10 @@ return MIB; } -static MachineInstr *MakeM0Inst(unsigned Opcode, unsigned FrameIndex, +static MachineInstr *MakeM0Inst(const TargetInstrInfo &TII, + unsigned Opcode, unsigned FrameIndex, MachineInstr *MI) { - return addFrameReference(BuildMI(Opcode, 5), FrameIndex).addImm(0); + return addFrameReference(BuildMI(TII, Opcode, 5), FrameIndex).addImm(0); } @@ -464,13 +465,13 @@ isTwoAddrFold = true; } else if (i == 0) { // If operand 0 if (MI->getOpcode() == X86::MOV16r0) - return MakeM0Inst(X86::MOV16mi, FrameIndex, MI); + return MakeM0Inst(TII, X86::MOV16mi, FrameIndex, MI); else if (MI->getOpcode() == X86::MOV32r0) - return MakeM0Inst(X86::MOV32mi, FrameIndex, MI); + return MakeM0Inst(TII, X86::MOV32mi, FrameIndex, MI); else if (MI->getOpcode() == X86::MOV64r0) - return MakeM0Inst(X86::MOV64mi32, FrameIndex, MI); + return MakeM0Inst(TII, X86::MOV64mi32, FrameIndex, MI); else if (MI->getOpcode() == X86::MOV8r0) - return MakeM0Inst(X86::MOV8mi, FrameIndex, MI); + return MakeM0Inst(TII, X86::MOV8mi, FrameIndex, MI); static const TableEntry OpcodeTable[] = { { X86::CMP16ri, X86::CMP16mi }, @@ -899,7 +900,7 @@ MachineInstr *New = 0; if (Old->getOpcode() == X86::ADJCALLSTACKDOWN) { - New=BuildMI(Is64Bit ? X86::SUB64ri32 : X86::SUB32ri, 1, StackPtr) + New=BuildMI(TII, Is64Bit ? X86::SUB64ri32 : X86::SUB32ri, 1, StackPtr) .addReg(StackPtr).addImm(Amount); } else { assert(Old->getOpcode() == X86::ADJCALLSTACKUP); @@ -910,7 +911,7 @@ unsigned Opc = (Amount < 128) ? (Is64Bit ? X86::ADD64ri8 : X86::ADD32ri8) : (Is64Bit ? X86::ADD64ri32 : X86::ADD32ri); - New = BuildMI(Opc, 1, StackPtr).addReg(StackPtr).addImm(Amount); + New = BuildMI(TII, Opc, 1, StackPtr).addReg(StackPtr).addImm(Amount); } } @@ -926,7 +927,7 @@ (Is64Bit ? X86::SUB64ri8 : X86::SUB32ri8) : (Is64Bit ? X86::SUB64ri32 : X86::SUB32ri); MachineInstr *New = - BuildMI(Opc, 1, StackPtr).addReg(StackPtr).addImm(CalleeAmt); + BuildMI(TII, Opc, 1, StackPtr).addReg(StackPtr).addImm(CalleeAmt); MBB.insert(I, New); } } @@ -1003,15 +1004,15 @@ // more than 4k bytes in one go. Touching the stack at 4K increments is // necessary to ensure that the guard pages used by the OS virtual memory // manager are allocated in correct sequence. - MI = BuildMI(X86::MOV32ri, 2, X86::EAX).addImm(NumBytes); + MI = BuildMI(TII, X86::MOV32ri, 2, X86::EAX).addImm(NumBytes); MBB.insert(MBBI, MI); - MI = BuildMI(X86::CALLpcrel32, 1).addExternalSymbol("_alloca"); + MI = BuildMI(TII, X86::CALLpcrel32, 1).addExternalSymbol("_alloca"); MBB.insert(MBBI, MI); } else { unsigned Opc = (NumBytes < 128) ? (Is64Bit ? X86::SUB64ri8 : X86::SUB32ri8) : (Is64Bit ? X86::SUB64ri32 : X86::SUB32ri); - MI= BuildMI(Opc, 1, StackPtr).addReg(StackPtr).addImm(NumBytes); + MI= BuildMI(TII, Opc, 1, StackPtr).addReg(StackPtr).addImm(NumBytes); MBB.insert(MBBI, MI); } } @@ -1023,16 +1024,16 @@ // Save EBP into the appropriate stack slot... // mov [ESP-], EBP - MI = addRegOffset(BuildMI(Is64Bit ? X86::MOV64mr : X86::MOV32mr, 5), + MI = addRegOffset(BuildMI(TII, Is64Bit ? X86::MOV64mr : X86::MOV32mr, 5), StackPtr, EBPOffset+NumBytes).addReg(FramePtr); MBB.insert(MBBI, MI); // Update EBP with the new base value... if (NumBytes == SlotSize) // mov EBP, ESP - MI = BuildMI(Is64Bit ? X86::MOV64rr : X86::MOV32rr, 2, FramePtr). + MI = BuildMI(TII, Is64Bit ? X86::MOV64rr : X86::MOV32rr, 2, FramePtr). addReg(StackPtr); else // lea EBP, [ESP+StackSize] - MI = addRegOffset(BuildMI(Is64Bit ? X86::LEA64r : X86::LEA32r, + MI = addRegOffset(BuildMI(TII, Is64Bit ? X86::LEA64r : X86::LEA32r, 5, FramePtr), StackPtr, NumBytes-SlotSize); MBB.insert(MBBI, MI); @@ -1041,13 +1042,13 @@ // If it's main() on Cygwin\Mingw32 we should align stack as well if (Fn->hasExternalLinkage() && Fn->getName() == "main" && Subtarget->isTargetCygwin()) { - MI = BuildMI(X86::AND32ri, 2, X86::ESP).addReg(X86::ESP).addImm(-Align); + MI= BuildMI(TII, X86::AND32ri, 2, X86::ESP).addReg(X86::ESP).addImm(-Align); MBB.insert(MBBI, MI); // Probe the stack - MI = BuildMI(X86::MOV32ri, 2, X86::EAX).addImm(Align); + MI = BuildMI(TII, X86::MOV32ri, 2, X86::EAX).addImm(Align); MBB.insert(MBBI, MI); - MI = BuildMI(X86::CALLpcrel32, 1).addExternalSymbol("_alloca"); + MI = BuildMI(TII, X86::CALLpcrel32, 1).addExternalSymbol("_alloca"); MBB.insert(MBBI, MI); } } From dpatel at apple.com Mon Nov 13 18:03:19 2006 From: dpatel at apple.com (Devang Patel) Date: Mon, 13 Nov 2006 18:03:19 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/PassManager.cpp Message-ID: <200611140003.kAE03J0j007738@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: PassManager.cpp updated: 1.22 -> 1.23 --- Log message: Update comments. --- Diffs of the changes: (+8 -5) PassManager.cpp | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-) Index: llvm/lib/VMCore/PassManager.cpp diff -u llvm/lib/VMCore/PassManager.cpp:1.22 llvm/lib/VMCore/PassManager.cpp:1.23 --- llvm/lib/VMCore/PassManager.cpp:1.22 Mon Nov 13 16:53:19 2006 +++ llvm/lib/VMCore/PassManager.cpp Mon Nov 13 18:03:04 2006 @@ -62,10 +62,16 @@ } private: - // Analysis required by the passes managed by this manager + // Analysis required by the passes managed by this manager. This information + // used while selecting pass manager during addPass. If a pass does not + // preserve any analysis required by other passes managed by current + // pass manager then new pass manager is used. std::vector RequiredAnalysis; - // set of available Analysis + // Set of available Analysis. This information is used while scheduling + // pass. If a pass requires an analysis which is not not available then + // equired analysis pass is scheduled to run before the pass itself is + // scheduled to run. std::set AvailableAnalysis; // Collection of pass that are managed by this manager @@ -510,9 +516,6 @@ } addPass(P); - - // TODO : Walk through all managers and remove not preserved analysis - // TODO : remove dead passes } /// Schedule all passes from the queue by adding them in their From tonic at nondot.org Mon Nov 13 18:57:03 2006 From: tonic at nondot.org (Tanya Lattner) Date: Mon, 13 Nov 2006 18:57:03 -0600 Subject: [llvm-commits] [release_19] CVS: llvm/configure Message-ID: <200611140057.kAE0v356022169@zion.cs.uiuc.edu> Changes in directory llvm: configure updated: 1.254 -> 1.254.2.1 --- Log message: Updating configure script --- Diffs of the changes: (+9 -9) configure | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-) Index: llvm/configure diff -u llvm/configure:1.254 llvm/configure:1.254.2.1 --- llvm/configure:1.254 Sun Nov 5 11:08:18 2006 +++ llvm/configure Mon Nov 13 18:56:51 2006 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.60 for llvm 1.9cvs. +# Generated by GNU Autoconf 2.60 for llvm 1.9. # # Report bugs to . # @@ -715,8 +715,8 @@ # Identity of this package. PACKAGE_NAME='llvm' PACKAGE_TARNAME='-llvm-' -PACKAGE_VERSION='1.9cvs' -PACKAGE_STRING='llvm 1.9cvs' +PACKAGE_VERSION='1.9' +PACKAGE_STRING='llvm 1.9' PACKAGE_BUGREPORT='llvmbugs at cs.uiuc.edu' ac_unique_file="lib/VMCore/Module.cpp" @@ -1445,7 +1445,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures llvm 1.9cvs to adapt to many kinds of systems. +\`configure' configures llvm 1.9 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1511,7 +1511,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of llvm 1.9cvs:";; + short | recursive ) echo "Configuration of llvm 1.9:";; esac cat <<\_ACEOF @@ -1633,7 +1633,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -llvm configure 1.9cvs +llvm configure 1.9 generated by GNU Autoconf 2.60 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1649,7 +1649,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by llvm $as_me 1.9cvs, which was +It was created by llvm $as_me 1.9, which was generated by GNU Autoconf 2.60. Invocation command line was $ $0 $@ @@ -33847,7 +33847,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by llvm $as_me 1.9cvs, which was +This file was extended by llvm $as_me 1.9, which was generated by GNU Autoconf 2.60. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -33900,7 +33900,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -llvm config.status 1.9cvs +llvm config.status 1.9 configured by $0, generated by GNU Autoconf 2.60, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" From tonic at nondot.org Mon Nov 13 19:00:05 2006 From: tonic at nondot.org (Tanya Lattner) Date: Mon, 13 Nov 2006 19:00:05 -0600 Subject: [llvm-commits] CVS: llvm/configure Message-ID: <200611140100.kAE105ue026146@zion.cs.uiuc.edu> Changes in directory llvm: configure updated: 1.254 -> 1.255 --- Log message: Updating configure script for 2.0 --- Diffs of the changes: (+9 -9) configure | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-) Index: llvm/configure diff -u llvm/configure:1.254 llvm/configure:1.255 --- llvm/configure:1.254 Sun Nov 5 11:08:18 2006 +++ llvm/configure Mon Nov 13 18:59:52 2006 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.60 for llvm 1.9cvs. +# Generated by GNU Autoconf 2.60 for llvm 2.0cvs. # # Report bugs to . # @@ -715,8 +715,8 @@ # Identity of this package. PACKAGE_NAME='llvm' PACKAGE_TARNAME='-llvm-' -PACKAGE_VERSION='1.9cvs' -PACKAGE_STRING='llvm 1.9cvs' +PACKAGE_VERSION='2.0cvs' +PACKAGE_STRING='llvm 2.0cvs' PACKAGE_BUGREPORT='llvmbugs at cs.uiuc.edu' ac_unique_file="lib/VMCore/Module.cpp" @@ -1445,7 +1445,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures llvm 1.9cvs to adapt to many kinds of systems. +\`configure' configures llvm 2.0cvs to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1511,7 +1511,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of llvm 1.9cvs:";; + short | recursive ) echo "Configuration of llvm 2.0cvs:";; esac cat <<\_ACEOF @@ -1633,7 +1633,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -llvm configure 1.9cvs +llvm configure 2.0cvs generated by GNU Autoconf 2.60 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1649,7 +1649,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by llvm $as_me 1.9cvs, which was +It was created by llvm $as_me 2.0cvs, which was generated by GNU Autoconf 2.60. Invocation command line was $ $0 $@ @@ -33847,7 +33847,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by llvm $as_me 1.9cvs, which was +This file was extended by llvm $as_me 2.0cvs, which was generated by GNU Autoconf 2.60. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -33900,7 +33900,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -llvm config.status 1.9cvs +llvm config.status 2.0cvs configured by $0, generated by GNU Autoconf 2.60, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" From rspencer at reidspencer.com Mon Nov 13 19:21:22 2006 From: rspencer at reidspencer.com (Reid Spencer) Date: Mon, 13 Nov 2006 17:21:22 -0800 Subject: [llvm-commits] [release_19] CVS: llvm/configure In-Reply-To: <200611140057.kAE0v356022169@zion.cs.uiuc.edu> References: <200611140057.kAE0v356022169@zion.cs.uiuc.edu> Message-ID: <1163467282.2839.63.camel@bashful.x10sys.com> Tanya, Were there no include/llvm/Config/config.h.in changes for 1.9 or was that previously committed ? I usually commit autoconf dir, configure and config.h.in in tandem. Reid. On Mon, 2006-11-13 at 18:57 -0600, Tanya Lattner wrote: > > Changes in directory llvm: > > configure updated: 1.254 -> 1.254.2.1 > --- > Log message: > > Updating configure script > > > --- > Diffs of the changes: (+9 -9) > > configure | 18 +++++++++--------- > 1 files changed, 9 insertions(+), 9 deletions(-) > > > Index: llvm/configure > diff -u llvm/configure:1.254 llvm/configure:1.254.2.1 > --- llvm/configure:1.254 Sun Nov 5 11:08:18 2006 > +++ llvm/configure Mon Nov 13 18:56:51 2006 > @@ -1,6 +1,6 @@ > #! /bin/sh > # Guess values for system-dependent variables and create Makefiles. > -# Generated by GNU Autoconf 2.60 for llvm 1.9cvs. > +# Generated by GNU Autoconf 2.60 for llvm 1.9. > # > # Report bugs to . > # > @@ -715,8 +715,8 @@ > # Identity of this package. > PACKAGE_NAME='llvm' > PACKAGE_TARNAME='-llvm-' > -PACKAGE_VERSION='1.9cvs' > -PACKAGE_STRING='llvm 1.9cvs' > +PACKAGE_VERSION='1.9' > +PACKAGE_STRING='llvm 1.9' > PACKAGE_BUGREPORT='llvmbugs at cs.uiuc.edu' > > ac_unique_file="lib/VMCore/Module.cpp" > @@ -1445,7 +1445,7 @@ > # Omit some internal or obsolete options to make the list less imposing. > # This message is too long to be a string in the A/UX 3.1 sh. > cat <<_ACEOF > -\`configure' configures llvm 1.9cvs to adapt to many kinds of systems. > +\`configure' configures llvm 1.9 to adapt to many kinds of systems. > > Usage: $0 [OPTION]... [VAR=VALUE]... > > @@ -1511,7 +1511,7 @@ > > if test -n "$ac_init_help"; then > case $ac_init_help in > - short | recursive ) echo "Configuration of llvm 1.9cvs:";; > + short | recursive ) echo "Configuration of llvm 1.9:";; > esac > cat <<\_ACEOF > > @@ -1633,7 +1633,7 @@ > test -n "$ac_init_help" && exit $ac_status > if $ac_init_version; then > cat <<\_ACEOF > -llvm configure 1.9cvs > +llvm configure 1.9 > generated by GNU Autoconf 2.60 > > Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, > @@ -1649,7 +1649,7 @@ > This file contains any messages produced by compilers while > running configure, to aid debugging if configure makes a mistake. > > -It was created by llvm $as_me 1.9cvs, which was > +It was created by llvm $as_me 1.9, which was > generated by GNU Autoconf 2.60. Invocation command line was > > $ $0 $@ > @@ -33847,7 +33847,7 @@ > # report actual input values of CONFIG_FILES etc. instead of their > # values after options handling. > ac_log=" > -This file was extended by llvm $as_me 1.9cvs, which was > +This file was extended by llvm $as_me 1.9, which was > generated by GNU Autoconf 2.60. Invocation command line was > > CONFIG_FILES = $CONFIG_FILES > @@ -33900,7 +33900,7 @@ > _ACEOF > cat >>$CONFIG_STATUS <<_ACEOF > ac_cs_version="\\ > -llvm config.status 1.9cvs > +llvm config.status 1.9 > configured by $0, generated by GNU Autoconf 2.60, > with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" > > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From dpatel at apple.com Mon Nov 13 19:23:44 2006 From: dpatel at apple.com (Devang Patel) Date: Mon, 13 Nov 2006 19:23:44 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/PassManager.cpp Message-ID: <200611140123.kAE1Ni3f005665@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: PassManager.cpp updated: 1.23 -> 1.24 --- Log message: Manage analysis passes during run. --- Diffs of the changes: (+25 -0) PassManager.cpp | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+) Index: llvm/lib/VMCore/PassManager.cpp diff -u llvm/lib/VMCore/PassManager.cpp:1.23 llvm/lib/VMCore/PassManager.cpp:1.24 --- llvm/lib/VMCore/PassManager.cpp:1.23 Mon Nov 13 18:03:04 2006 +++ llvm/lib/VMCore/PassManager.cpp Mon Nov 13 19:23:29 2006 @@ -53,6 +53,13 @@ /// AvailableAnalysis appropriately if ProcessAnalysis is true. void addPassToManager (Pass *P, bool ProcessAnalysis = true); + /// Clear analysis vectors RequiredAnalysis and AvailableAnalysis. + /// This is used before running passes managed by the manager. + void clearAnalysis() { + RequiredAnalysis.clear(); + AvailableAnalysis.clear(); + } + inline std::vector::iterator passVectorBegin() { return PassVector.begin(); } @@ -311,12 +318,18 @@ BasicBlockPassManager_New::runOnFunction(Function &F) { bool Changed = false; + clearAnalysis(); + for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) for (std::vector::iterator itr = passVectorBegin(), e = passVectorEnd(); itr != e; ++itr) { Pass *P = *itr; + + noteDownAvailableAnalysis(P); BasicBlockPass *BP = dynamic_cast(P); Changed |= BP->runOnBasicBlock(*I); + removeNotPreservedAnalysis(P); + removeDeadPasses(); } return Changed; } @@ -395,12 +408,18 @@ FunctionPassManagerImpl_New::runOnModule(Module &M) { bool Changed = false; + clearAnalysis(); + for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) for (std::vector::iterator itr = passVectorBegin(), e = passVectorEnd(); itr != e; ++itr) { Pass *P = *itr; + + noteDownAvailableAnalysis(P); FunctionPass *FP = dynamic_cast(P); Changed |= FP->runOnFunction(*I); + removeNotPreservedAnalysis(P); + removeDeadPasses(); } return Changed; } @@ -464,11 +483,17 @@ bool ModulePassManager_New::runOnModule(Module &M) { bool Changed = false; + clearAnalysis(); + for (std::vector::iterator itr = passVectorBegin(), e = passVectorEnd(); itr != e; ++itr) { Pass *P = *itr; + + noteDownAvailableAnalysis(P); ModulePass *MP = dynamic_cast(P); Changed |= MP->runOnModule(M); + removeNotPreservedAnalysis(P); + removeDeadPasses(); } return Changed; } From tonic at nondot.org Mon Nov 13 19:32:26 2006 From: tonic at nondot.org (Tanya M. Lattner) Date: Mon, 13 Nov 2006 17:32:26 -0800 (PST) Subject: [llvm-commits] [release_19] CVS: llvm/configure In-Reply-To: <1163467282.2839.63.camel@bashful.x10sys.com> References: <200611140057.kAE0v356022169@zion.cs.uiuc.edu> <1163467282.2839.63.camel@bashful.x10sys.com> Message-ID: > Were there no include/llvm/Config/config.h.in changes for 1.9 or was > that previously committed ? I usually commit autoconf dir, configure > and config.h.in in tandem. I just updated the version of llvm so the only changes were in the configure script. I did a cvs diff on the autoconf dir and config.h.in and didn't see any changes. -Tanya > > Reid. > > On Mon, 2006-11-13 at 18:57 -0600, Tanya Lattner wrote: >> >> Changes in directory llvm: >> >> configure updated: 1.254 -> 1.254.2.1 >> --- >> Log message: >> >> Updating configure script >> >> >> --- >> Diffs of the changes: (+9 -9) >> >> configure | 18 +++++++++--------- >> 1 files changed, 9 insertions(+), 9 deletions(-) >> >> >> Index: llvm/configure >> diff -u llvm/configure:1.254 llvm/configure:1.254.2.1 >> --- llvm/configure:1.254 Sun Nov 5 11:08:18 2006 >> +++ llvm/configure Mon Nov 13 18:56:51 2006 >> @@ -1,6 +1,6 @@ >> #! /bin/sh >> # Guess values for system-dependent variables and create Makefiles. >> -# Generated by GNU Autoconf 2.60 for llvm 1.9cvs. >> +# Generated by GNU Autoconf 2.60 for llvm 1.9. >> # >> # Report bugs to . >> # >> @@ -715,8 +715,8 @@ >> # Identity of this package. >> PACKAGE_NAME='llvm' >> PACKAGE_TARNAME='-llvm-' >> -PACKAGE_VERSION='1.9cvs' >> -PACKAGE_STRING='llvm 1.9cvs' >> +PACKAGE_VERSION='1.9' >> +PACKAGE_STRING='llvm 1.9' >> PACKAGE_BUGREPORT='llvmbugs at cs.uiuc.edu' >> >> ac_unique_file="lib/VMCore/Module.cpp" >> @@ -1445,7 +1445,7 @@ >> # Omit some internal or obsolete options to make the list less imposing. >> # This message is too long to be a string in the A/UX 3.1 sh. >> cat <<_ACEOF >> -\`configure' configures llvm 1.9cvs to adapt to many kinds of systems. >> +\`configure' configures llvm 1.9 to adapt to many kinds of systems. >> >> Usage: $0 [OPTION]... [VAR=VALUE]... >> >> @@ -1511,7 +1511,7 @@ >> >> if test -n "$ac_init_help"; then >> case $ac_init_help in >> - short | recursive ) echo "Configuration of llvm 1.9cvs:";; >> + short | recursive ) echo "Configuration of llvm 1.9:";; >> esac >> cat <<\_ACEOF >> >> @@ -1633,7 +1633,7 @@ >> test -n "$ac_init_help" && exit $ac_status >> if $ac_init_version; then >> cat <<\_ACEOF >> -llvm configure 1.9cvs >> +llvm configure 1.9 >> generated by GNU Autoconf 2.60 >> >> Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, >> @@ -1649,7 +1649,7 @@ >> This file contains any messages produced by compilers while >> running configure, to aid debugging if configure makes a mistake. >> >> -It was created by llvm $as_me 1.9cvs, which was >> +It was created by llvm $as_me 1.9, which was >> generated by GNU Autoconf 2.60. Invocation command line was >> >> $ $0 $@ >> @@ -33847,7 +33847,7 @@ >> # report actual input values of CONFIG_FILES etc. instead of their >> # values after options handling. >> ac_log=" >> -This file was extended by llvm $as_me 1.9cvs, which was >> +This file was extended by llvm $as_me 1.9, which was >> generated by GNU Autoconf 2.60. Invocation command line was >> >> CONFIG_FILES = $CONFIG_FILES >> @@ -33900,7 +33900,7 @@ >> _ACEOF >> cat >>$CONFIG_STATUS <<_ACEOF >> ac_cs_version="\\ >> -llvm config.status 1.9cvs >> +llvm config.status 1.9 >> configured by $0, generated by GNU Autoconf 2.60, >> with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" >> >> >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From rspencer at reidspencer.com Mon Nov 13 19:33:46 2006 From: rspencer at reidspencer.com (Reid Spencer) Date: Mon, 13 Nov 2006 17:33:46 -0800 Subject: [llvm-commits] [release_19] CVS: llvm/configure In-Reply-To: References: <200611140057.kAE0v356022169@zion.cs.uiuc.edu> <1163467282.2839.63.camel@bashful.x10sys.com> Message-ID: <1163468026.2839.65.camel@bashful.x10sys.com> On Mon, 2006-11-13 at 17:32 -0800, Tanya M. Lattner wrote: > > Were there no include/llvm/Config/config.h.in changes for 1.9 or was > > that previously committed ? I usually commit autoconf dir, configure > > and config.h.in in tandem. > > I just updated the version of llvm so the only changes were in the > configure script. I did a cvs diff on the autoconf dir and config.h.in and > didn't see any changes. Okay. :) > > -Tanya > > > > > Reid. > > > > On Mon, 2006-11-13 at 18:57 -0600, Tanya Lattner wrote: > >> > >> Changes in directory llvm: > >> > >> configure updated: 1.254 -> 1.254.2.1 > >> --- > >> Log message: > >> > >> Updating configure script > >> > >> > >> --- > >> Diffs of the changes: (+9 -9) > >> > >> configure | 18 +++++++++--------- > >> 1 files changed, 9 insertions(+), 9 deletions(-) > >> > >> > >> Index: llvm/configure > >> diff -u llvm/configure:1.254 llvm/configure:1.254.2.1 > >> --- llvm/configure:1.254 Sun Nov 5 11:08:18 2006 > >> +++ llvm/configure Mon Nov 13 18:56:51 2006 > >> @@ -1,6 +1,6 @@ > >> #! /bin/sh > >> # Guess values for system-dependent variables and create Makefiles. > >> -# Generated by GNU Autoconf 2.60 for llvm 1.9cvs. > >> +# Generated by GNU Autoconf 2.60 for llvm 1.9. > >> # > >> # Report bugs to . > >> # > >> @@ -715,8 +715,8 @@ > >> # Identity of this package. > >> PACKAGE_NAME='llvm' > >> PACKAGE_TARNAME='-llvm-' > >> -PACKAGE_VERSION='1.9cvs' > >> -PACKAGE_STRING='llvm 1.9cvs' > >> +PACKAGE_VERSION='1.9' > >> +PACKAGE_STRING='llvm 1.9' > >> PACKAGE_BUGREPORT='llvmbugs at cs.uiuc.edu' > >> > >> ac_unique_file="lib/VMCore/Module.cpp" > >> @@ -1445,7 +1445,7 @@ > >> # Omit some internal or obsolete options to make the list less imposing. > >> # This message is too long to be a string in the A/UX 3.1 sh. > >> cat <<_ACEOF > >> -\`configure' configures llvm 1.9cvs to adapt to many kinds of systems. > >> +\`configure' configures llvm 1.9 to adapt to many kinds of systems. > >> > >> Usage: $0 [OPTION]... [VAR=VALUE]... > >> > >> @@ -1511,7 +1511,7 @@ > >> > >> if test -n "$ac_init_help"; then > >> case $ac_init_help in > >> - short | recursive ) echo "Configuration of llvm 1.9cvs:";; > >> + short | recursive ) echo "Configuration of llvm 1.9:";; > >> esac > >> cat <<\_ACEOF > >> > >> @@ -1633,7 +1633,7 @@ > >> test -n "$ac_init_help" && exit $ac_status > >> if $ac_init_version; then > >> cat <<\_ACEOF > >> -llvm configure 1.9cvs > >> +llvm configure 1.9 > >> generated by GNU Autoconf 2.60 > >> > >> Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, > >> @@ -1649,7 +1649,7 @@ > >> This file contains any messages produced by compilers while > >> running configure, to aid debugging if configure makes a mistake. > >> > >> -It was created by llvm $as_me 1.9cvs, which was > >> +It was created by llvm $as_me 1.9, which was > >> generated by GNU Autoconf 2.60. Invocation command line was > >> > >> $ $0 $@ > >> @@ -33847,7 +33847,7 @@ > >> # report actual input values of CONFIG_FILES etc. instead of their > >> # values after options handling. > >> ac_log=" > >> -This file was extended by llvm $as_me 1.9cvs, which was > >> +This file was extended by llvm $as_me 1.9, which was > >> generated by GNU Autoconf 2.60. Invocation command line was > >> > >> CONFIG_FILES = $CONFIG_FILES > >> @@ -33900,7 +33900,7 @@ > >> _ACEOF > >> cat >>$CONFIG_STATUS <<_ACEOF > >> ac_cs_version="\\ > >> -llvm config.status 1.9cvs > >> +llvm config.status 1.9 > >> configured by $0, generated by GNU Autoconf 2.60, > >> with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" > >> > >> > >> > >> > >> _______________________________________________ > >> 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 Nov 13 19:38:46 2006 From: sabre at nondot.org (Chris Lattner) Date: Mon, 13 Nov 2006 19:38:46 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCISelLowering.cpp Message-ID: <200611140138.kAE1ckW3006492@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCISelLowering.cpp updated: 1.224 -> 1.225 --- Log message: minor tweaks, reject vector preinc. --- Diffs of the changes: (+9 -4) PPCISelLowering.cpp | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-) Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp diff -u llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.224 llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.225 --- llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.224 Fri Nov 10 18:08:42 2006 +++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp Mon Nov 13 19:38:31 2006 @@ -874,17 +874,22 @@ if (!EnablePPCPreinc) return false; SDOperand Ptr; + MVT::ValueType VT; if (LoadSDNode *LD = dyn_cast(N)) { Ptr = LD->getBasePtr(); + VT = LD->getValueType(0); } else if (StoreSDNode *ST = dyn_cast(N)) { ST = ST; - //Ptr = ST->getBasePtr(); - //VT = ST->getStoredVT(); - // TODO: handle stores. - return false; + Ptr = ST->getBasePtr(); + VT = ST->getStoredVT(); + return false; // TODO: Stores. } else return false; + // PowerPC doesn't have preinc load/store instructions for vectors. + if (MVT::isVector(VT)) + return false; + // TODO: Handle reg+reg. if (!SelectAddressRegImm(Ptr, Offset, Base, DAG)) return false; From tonic at nondot.org Mon Nov 13 19:43:52 2006 From: tonic at nondot.org (Tanya Lattner) Date: Mon, 13 Nov 2006 19:43:52 -0600 Subject: [llvm-commits] [release_19] CVS: llvm/Makefile.rules Message-ID: <200611140143.kAE1hqaW006645@zion.cs.uiuc.edu> Changes in directory llvm: Makefile.rules updated: 1.408 -> 1.408.2.1 --- Log message: Merging from mainline --- Diffs of the changes: (+1 -1) Makefile.rules | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/Makefile.rules diff -u llvm/Makefile.rules:1.408 llvm/Makefile.rules:1.408.2.1 --- llvm/Makefile.rules:1.408 Thu Nov 2 14:25:49 2006 +++ llvm/Makefile.rules Mon Nov 13 19:43:40 2006 @@ -213,7 +213,7 @@ C.Flags := $(OPTIMIZE_OPTION) -pg -g LD.Flags := $(OPTIMIZE_OPTION) -pg -g else - ifdef ENABLE_OPTIMIZED + ifeq ($(ENABLE_OPTIMIZED),1) BuildMode := Release # Don't use -fomit-frame-pointer on Darwin or FreeBSD. ifneq ($(OS),FreeBSD) From sabre at nondot.org Mon Nov 13 19:58:09 2006 From: sabre at nondot.org (Chris Lattner) Date: Mon, 13 Nov 2006 19:58:09 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/README.txt Message-ID: <200611140158.kAE1w98S006969@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target: README.txt updated: 1.48 -> 1.49 --- Log message: add a note --- Diffs of the changes: (+16 -0) README.txt | 16 ++++++++++++++++ 1 files changed, 16 insertions(+) Index: llvm/lib/Target/README.txt diff -u llvm/lib/Target/README.txt:1.48 llvm/lib/Target/README.txt:1.49 --- llvm/lib/Target/README.txt:1.48 Sun Nov 12 18:23:28 2006 +++ llvm/lib/Target/README.txt Mon Nov 13 19:57:53 2006 @@ -16,6 +16,22 @@ //===---------------------------------------------------------------------===// +With the recent changes to make the implicit def/use set explicit in +machineinstrs, we should change the target descriptions for 'call' instructions +so that the .td files don't list all the call-clobbered registers as implicit +defs. Instead, these should be added by the code generator (e.g. on the dag). + +This has a number of uses: + +1. PPC32/64 and X86 32/64 can avoid having multiple copies of call instructions + for their different impdef sets. +2. Targets with multiple calling convs (e.g. x86) which have different clobber + sets don't need copies of call instructions. +3. 'Interprocedural register allocation' can be done to reduce the clobber sets + of calls. + +//===---------------------------------------------------------------------===// + FreeBench/mason contains code like this: static p_type m0u(p_type p) { From dpatel at apple.com Mon Nov 13 20:00:13 2006 From: dpatel at apple.com (Devang Patel) Date: Mon, 13 Nov 2006 20:00:13 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/PassManager.cpp Message-ID: <200611140200.kAE20DuF007022@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: PassManager.cpp updated: 1.24 -> 1.25 --- Log message: Use std::map to map AnalysisID and Pass. --- Diffs of the changes: (+28 -15) PassManager.cpp | 43 ++++++++++++++++++++++++++++--------------- 1 files changed, 28 insertions(+), 15 deletions(-) Index: llvm/lib/VMCore/PassManager.cpp diff -u llvm/lib/VMCore/PassManager.cpp:1.24 llvm/lib/VMCore/PassManager.cpp:1.25 --- llvm/lib/VMCore/PassManager.cpp:1.24 Mon Nov 13 19:23:29 2006 +++ llvm/lib/VMCore/PassManager.cpp Mon Nov 13 19:59:59 2006 @@ -15,7 +15,7 @@ #include "llvm/PassManager.h" #include "llvm/Module.h" #include -#include +#include using namespace llvm; @@ -32,9 +32,15 @@ /// manager. bool manageablePass(Pass *P); - /// Return true IFF AnalysisID AID is currently available. - bool isAnalysisAvailable(AnalysisID AID) { - return (AvailableAnalysis.count(AID) != 0); + Pass *getAnalysisPass(AnalysisID AID) const { + + std::map::const_iterator I = + AvailableAnalysis.find(AID); + + if (I != AvailableAnalysis.end()) + return NULL; + else + return I->second; } /// Augment RequiredAnalysis by adding analysis required by pass P. @@ -60,6 +66,13 @@ AvailableAnalysis.clear(); } + // All Required analyses should be available to the pass as it runs! Here + // we fill in the AnalysisImpls member of the pass so that it can + // successfully use the getAnalysis() method to retrieve the + // implementations it needs. + // + inline void initializeAnalysisImpl(Pass *P) { /* TODO : Implement */ } + inline std::vector::iterator passVectorBegin() { return PassVector.begin(); } @@ -79,7 +92,7 @@ // pass. If a pass requires an analysis which is not not available then // equired analysis pass is scheduled to run before the pass itself is // scheduled to run. - std::set AvailableAnalysis; + std::map AvailableAnalysis; // Collection of pass that are managed by this manager std::vector PassVector; @@ -242,9 +255,9 @@ /// Augement AvailableAnalysis by adding analysis made available by pass P. void CommonPassManagerImpl::noteDownAvailableAnalysis(Pass *P) { - + if (const PassInfo *PI = P->getPassInfo()) { - AvailableAnalysis.insert(PI); + AvailableAnalysis[PI] = P; //TODO This pass is the current implementation of all of the interfaces it //TODO implements as well. @@ -261,12 +274,12 @@ P->getAnalysisUsage(AnUsage); const std::vector &PreservedSet = AnUsage.getPreservedSet(); - for (std::set::iterator I = AvailableAnalysis.begin(), + for (std::map::iterator I = AvailableAnalysis.begin(), E = AvailableAnalysis.end(); I != E; ++I ) { - if (std::find(PreservedSet.begin(), PreservedSet.end(), *I) == + if (std::find(PreservedSet.begin(), PreservedSet.end(), I->first) == PreservedSet.end()) { // Remove this analysis - std::set::iterator J = I++; + std::map::iterator J = I++; AvailableAnalysis.erase(J); } } @@ -336,7 +349,7 @@ /// Return true IFF AnalysisID AID is currently available. bool BasicBlockPassManager_New::analysisCurrentlyAvailable(AnalysisID AID) { - return isAnalysisAvailable(AID); + return (getAnalysisPass(AID) != 0); } // FunctionPassManager_New implementation @@ -427,11 +440,11 @@ /// Return true IFF AnalysisID AID is currently available. bool FunctionPassManagerImpl_New::analysisCurrentlyAvailable(AnalysisID AID) { - if (isAnalysisAvailable(AID)) + if (getAnalysisPass(AID) != 0) return true; if (activeBBPassManager && - activeBBPassManager->isAnalysisAvailable(AID)) + activeBBPassManager->getAnalysisPass(AID) != 0) return true; // TODO : Check inactive managers @@ -501,11 +514,11 @@ /// Return true IFF AnalysisID AID is currently available. bool ModulePassManager_New::analysisCurrentlyAvailable(AnalysisID AID) { - if (isAnalysisAvailable(AID)) + if (getAnalysisPass(AID) != 0) return true; if (activeFunctionPassManager && - activeFunctionPassManager->isAnalysisAvailable(AID)) + activeFunctionPassManager->getAnalysisPass(AID) != 0) return true; // TODO : Check inactive managers From dpatel at apple.com Mon Nov 13 20:54:39 2006 From: dpatel at apple.com (Devang Patel) Date: Mon, 13 Nov 2006 20:54:39 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/PassManager.cpp Message-ID: <200611140254.kAE2sd18008857@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: PassManager.cpp updated: 1.25 -> 1.26 --- Log message: Keep track of Last user of analysis phase. --- Diffs of the changes: (+36 -24) PassManager.cpp | 60 +++++++++++++++++++++++++++++++++----------------------- 1 files changed, 36 insertions(+), 24 deletions(-) Index: llvm/lib/VMCore/PassManager.cpp diff -u llvm/lib/VMCore/PassManager.cpp:1.25 llvm/lib/VMCore/PassManager.cpp:1.26 --- llvm/lib/VMCore/PassManager.cpp:1.25 Mon Nov 13 19:59:59 2006 +++ llvm/lib/VMCore/PassManager.cpp Mon Nov 13 20:54:23 2006 @@ -64,6 +64,7 @@ void clearAnalysis() { RequiredAnalysis.clear(); AvailableAnalysis.clear(); + LastUser.clear(); } // All Required analyses should be available to the pass as it runs! Here @@ -81,6 +82,8 @@ return PassVector.end(); } + inline void setLastUser(Pass *P, Pass *LU) { LastUser[P] = LU; } + private: // Analysis required by the passes managed by this manager. This information // used while selecting pass manager during addPass. If a pass does not @@ -94,6 +97,10 @@ // scheduled to run. std::map AvailableAnalysis; + // Map to keep track of last user of the analysis pass. + // LastUser->second is the last user of Lastuser->first. + std::map LastUser; + // Collection of pass that are managed by this manager std::vector PassVector; }; @@ -114,7 +121,7 @@ bool runOnFunction(Function &F); /// Return true IFF AnalysisID AID is currently available. - bool analysisCurrentlyAvailable(AnalysisID AID); + Pass *getAnalysisPassFromManager(AnalysisID AID); private: }; @@ -147,7 +154,7 @@ bool runOnModule(Module &M); /// Return true IFF AnalysisID AID is currently available. - bool analysisCurrentlyAvailable(AnalysisID AID); + Pass *getAnalysisPassFromManager(AnalysisID AID); private: // Active Pass Managers @@ -170,7 +177,7 @@ bool runOnModule(Module &M); /// Return true IFF AnalysisID AID is currently available. - bool analysisCurrentlyAvailable(AnalysisID AID); + Pass *getAnalysisPassFromManager(AnalysisID AID); private: // Active Pass Manager @@ -193,7 +200,7 @@ bool run(Module &M); /// Return true IFF AnalysisID AID is currently available. - bool analysisCurrentlyAvailable(AnalysisID AID); + Pass *getAnalysisPassFromManager(AnalysisID AID); private: @@ -348,8 +355,8 @@ } /// Return true IFF AnalysisID AID is currently available. -bool BasicBlockPassManager_New::analysisCurrentlyAvailable(AnalysisID AID) { - return (getAnalysisPass(AID) != 0); +Pass * BasicBlockPassManager_New::getAnalysisPassFromManager(AnalysisID AID) { + return getAnalysisPass(AID); } // FunctionPassManager_New implementation @@ -438,17 +445,18 @@ } /// Return true IFF AnalysisID AID is currently available. -bool FunctionPassManagerImpl_New::analysisCurrentlyAvailable(AnalysisID AID) { +Pass *FunctionPassManagerImpl_New::getAnalysisPassFromManager(AnalysisID AID) { - if (getAnalysisPass(AID) != 0) - return true; + Pass *P = getAnalysisPass(AID); + if (P) + return P; if (activeBBPassManager && activeBBPassManager->getAnalysisPass(AID) != 0) - return true; + return activeBBPassManager->getAnalysisPass(AID); // TODO : Check inactive managers - return false; + return NULL; } // ModulePassManager implementation @@ -512,27 +520,29 @@ } /// Return true IFF AnalysisID AID is currently available. -bool ModulePassManager_New::analysisCurrentlyAvailable(AnalysisID AID) { +Pass *ModulePassManager_New::getAnalysisPassFromManager(AnalysisID AID) { - if (getAnalysisPass(AID) != 0) - return true; + + Pass *P = getAnalysisPass(AID); + if (P) + return P; if (activeFunctionPassManager && activeFunctionPassManager->getAnalysisPass(AID) != 0) - return true; + return activeFunctionPassManager->getAnalysisPass(AID); // TODO : Check inactive managers - return false; + return NULL; } /// Return true IFF AnalysisID AID is currently available. -bool PassManagerImpl_New::analysisCurrentlyAvailable(AnalysisID AID) { +Pass *PassManagerImpl_New::getAnalysisPassFromManager(AnalysisID AID) { - bool available = false; + Pass *P = NULL; for (std::vector::iterator itr = PassManagers.begin(), - e = PassManagers.end(); !available && itr != e; ++itr) - available = (*itr)->analysisCurrentlyAvailable(AID); - return available; + e = PassManagers.end(); !P && itr != e; ++itr) + P = (*itr)->getAnalysisPassFromManager(AID); + return P; } /// Schedule pass P for execution. Make sure that passes required by @@ -546,11 +556,13 @@ for (std::vector::const_iterator I = RequiredSet.begin(), E = RequiredSet.end(); I != E; ++I) { - if (!analysisCurrentlyAvailable(*I)) { + Pass *AnalysisPass = getAnalysisPassFromManager(*I); + if (!AnalysisPass) { // Schedule this analysis run first. - Pass *AP = (*I)->createPass(); - schedulePass(AP); + AnalysisPass = (*I)->createPass(); + schedulePass(AnalysisPass); } + setLastUser (AnalysisPass, P); } addPass(P); From dpatel at apple.com Mon Nov 13 21:05:24 2006 From: dpatel at apple.com (Devang Patel) Date: Mon, 13 Nov 2006 21:05:24 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/PassManager.cpp Message-ID: <200611140305.kAE35Olr009237@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: PassManager.cpp updated: 1.26 -> 1.27 --- Log message: Implement removeDeadPasses(). --- Diffs of the changes: (+23 -4) PassManager.cpp | 27 +++++++++++++++++++++++---- 1 files changed, 23 insertions(+), 4 deletions(-) Index: llvm/lib/VMCore/PassManager.cpp diff -u llvm/lib/VMCore/PassManager.cpp:1.26 llvm/lib/VMCore/PassManager.cpp:1.27 --- llvm/lib/VMCore/PassManager.cpp:1.26 Mon Nov 13 20:54:23 2006 +++ llvm/lib/VMCore/PassManager.cpp Mon Nov 13 21:05:08 2006 @@ -53,7 +53,7 @@ void removeNotPreservedAnalysis(Pass *P); /// Remove dead passes - void removeDeadPasses() { /* TODO : Implement */ } + void removeDeadPasses(Pass *P); /// Add pass P into the PassVector. Update RequiredAnalysis and /// AvailableAnalysis appropriately if ProcessAnalysis is true. @@ -292,6 +292,25 @@ } } +/// Remove analysis passes that are not used any longer +void CommonPassManagerImpl::removeDeadPasses(Pass *P) { + + for (std::map::iterator I = LastUser.begin(), + E = LastUser.end(); I !=E; ++I) { + if (I->second == P) { + Pass *deadPass = I->first; + deadPass->releaseMemory(); + + std::map::iterator Pos = + AvailableAnalysis.find(deadPass->getPassInfo()); + + assert (Pos != AvailableAnalysis.end() && + "Pass is not available"); + AvailableAnalysis.erase(Pos); + } + } +} + /// Add pass P into the PassVector. Update RequiredAnalysis and /// AvailableAnalysis appropriately if ProcessAnalysis is true. void CommonPassManagerImpl::addPassToManager (Pass *P, @@ -349,7 +368,7 @@ BasicBlockPass *BP = dynamic_cast(P); Changed |= BP->runOnBasicBlock(*I); removeNotPreservedAnalysis(P); - removeDeadPasses(); + removeDeadPasses(P); } return Changed; } @@ -439,7 +458,7 @@ FunctionPass *FP = dynamic_cast(P); Changed |= FP->runOnFunction(*I); removeNotPreservedAnalysis(P); - removeDeadPasses(); + removeDeadPasses(P); } return Changed; } @@ -514,7 +533,7 @@ ModulePass *MP = dynamic_cast(P); Changed |= MP->runOnModule(M); removeNotPreservedAnalysis(P); - removeDeadPasses(); + removeDeadPasses(P); } return Changed; } From reid at x10sys.com Mon Nov 13 22:47:39 2006 From: reid at x10sys.com (Reid Spencer) Date: Mon, 13 Nov 2006 22:47:39 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Bytecode/Analyzer.h Format.h Message-ID: <200611140447.kAE4ldiQ011569@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Bytecode: Analyzer.h updated: 1.11 -> 1.12 Format.h updated: 1.13 -> 1.14 --- Log message: Discard code that supported old bytecode formats. This makes the Bytecode Reader code much easier to read and maintain. Backwards compatibility from version 5 format has been retained. Older formats will produce an error. --- Diffs of the changes: (+21 -62) Analyzer.h | 2 - Format.h | 81 +++++++++++++++---------------------------------------------- 2 files changed, 21 insertions(+), 62 deletions(-) Index: llvm/include/llvm/Bytecode/Analyzer.h diff -u llvm/include/llvm/Bytecode/Analyzer.h:1.11 llvm/include/llvm/Bytecode/Analyzer.h:1.12 --- llvm/include/llvm/Bytecode/Analyzer.h:1.11 Thu Apr 21 15:34:13 2005 +++ llvm/include/llvm/Bytecode/Analyzer.h Mon Nov 13 22:47:22 2006 @@ -68,7 +68,7 @@ unsigned vbrCompBytes; ///< Number of vbr bytes (compressed) unsigned vbrExpdBytes; ///< Number of vbr bytes (expanded) - typedef std::map + typedef std::map BlockSizeMap; BlockSizeMap BlockSizes; Index: llvm/include/llvm/Bytecode/Format.h diff -u llvm/include/llvm/Bytecode/Format.h:1.13 llvm/include/llvm/Bytecode/Format.h:1.14 --- llvm/include/llvm/Bytecode/Format.h:1.13 Wed Feb 22 10:23:42 2006 +++ llvm/include/llvm/Bytecode/Format.h Mon Nov 13 22:47:22 2006 @@ -20,78 +20,37 @@ class BytecodeFormat { // Throw the constants into a poorman's namespace... BytecodeFormat(); // do not implement public: - - // ID Numbers that are used in bytecode files... - enum FileBlockIDs { - // File level identifiers... - Module = 0x01, - - // Module subtypes: - Function = 0x11, - ConstantPool, - SymbolTable, - ModuleGlobalInfo, - GlobalTypePlane, - DependentLibs, - - // Function subtypes: - // Can also have ConstantPool block - // Can also have SymbolTable block - BasicBlock = 0x31,// May contain many basic blocks (obsolete since LLVM 1.1) - - // InstructionList - The instructions in the body of a function. This - // superceeds the old BasicBlock node used in LLVM 1.0. - InstructionList = 0x32, - - // CompactionTable - blocks with this id are used to define local remapping - // tables for a function, allowing the indices used within the function to - // be as small as possible. This often allows the instructions to be - // encoded more efficiently. - CompactionTable = 0x33 - }; - - /// In LLVM 1.3 format, the identifier and the size of the block are - /// encoded into a single vbr_uint32 with 5 bits for the block identifier - /// and 27-bits for block length. This limits blocks to a maximum of + /// The the identifier and the size of the block are encoded into a single + /// vbr_uint32 with 5 bits for the block identifier and 27-bits for block + /// length. This limits blocks to a maximum of /// 128MBytes of data, and block types to 31 which should be sufficient /// for the foreseeable usage. Because the values of block identifiers MUST /// fit within 5 bits (values 1-31), this enumeration is used to ensure /// smaller values are used for 1.3 and subsequent bytecode versions. /// @brief The block number identifiers used in LLVM 1.3 bytecode /// format. - enum CompressedBytecodeBlockIdentifiers { + enum BytecodeBlockIdentifiers { - // Zero value ist verbotten! - Reserved_DoNotUse = 0x00, ///< Don't use this! - - // This is the uber block that contains the rest of the blocks. - ModuleBlockID = 0x01, ///< 1.3 identifier for modules - - // Module subtypes: - - // This is the identifier for a function - FunctionBlockID = 0x02, ///< 1.3 identifier for Functions - ConstantPoolBlockID = 0x03, ///< 1.3 identifier for constant pool - SymbolTableBlockID = 0x04, ///< 1.3 identifier for symbol table - ModuleGlobalInfoBlockID = 0x05,///< 1.3 identifier for module globals - GlobalTypePlaneBlockID = 0x06, ///< 1.3 identifier for global types - - // Function subtypes: - - // InstructionList - The instructions in the body of a function. This - // superceeds the old BasicBlock node used in LLVM 1.0. - InstructionListBlockID = 0x07, ///< 1.3 identifier for insruction list - - // CompactionTable - blocks with this id are used to define local remapping - // tables for a function, allowing the indices used within the function to - // be as small as possible. This often allows the instructions to be - // encoded more efficiently. - CompactionTableBlockID = 0x08, ///< 1.3 identifier for compaction tables + Reserved_DoNotUse = 0, ///< Zero value is forbidden, do not use. + ModuleBlockID = 1, ///< Module block that contains other blocks. + FunctionBlockID = 2, ///< Function block identifier + ConstantPoolBlockID = 3, ///< Constant pool identifier + SymbolTableBlockID = 4, ///< Symbol table identifier + ModuleGlobalInfoBlockID= 5, ///< Module global info identifier + GlobalTypePlaneBlockID = 6, ///< Global type plan identifier + InstructionListBlockID = 7, ///< All instructions in a function + + /// Blocks with this id are used to define a function local remapping + /// table for the function's values. This allows the indices used within + /// the function to be as small as possible. This often allows the + /// instructions to be encoded more efficiently because VBR takes fewer + /// bytes with smaller values. + /// @brief Value Compaction Table Block + CompactionTableBlockID = 0x08, // Not a block id, just used to count them NumberOfBlockIDs }; - }; } // End llvm namespace From reid at x10sys.com Mon Nov 13 22:47:39 2006 From: reid at x10sys.com (Reid Spencer) Date: Mon, 13 Nov 2006 22:47:39 -0600 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/Analyzer.cpp Reader.cpp Reader.h Message-ID: <200611140447.kAE4ld2W011576@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: Analyzer.cpp updated: 1.24 -> 1.25 Reader.cpp updated: 1.204 -> 1.205 Reader.h updated: 1.37 -> 1.38 --- Log message: Discard code that supported old bytecode formats. This makes the Bytecode Reader code much easier to read and maintain. Backwards compatibility from version 5 format has been retained. Older formats will produce an error. --- Diffs of the changes: (+146 -550) Analyzer.cpp | 2 Reader.cpp | 617 +++++++++++++---------------------------------------------- Reader.h | 77 ------- 3 files changed, 146 insertions(+), 550 deletions(-) Index: llvm/lib/Bytecode/Reader/Analyzer.cpp diff -u llvm/lib/Bytecode/Reader/Analyzer.cpp:1.24 llvm/lib/Bytecode/Reader/Analyzer.cpp:1.25 --- llvm/lib/Bytecode/Reader/Analyzer.cpp:1.24 Thu Nov 2 19:44:51 2006 +++ llvm/lib/Bytecode/Reader/Analyzer.cpp Mon Nov 13 22:47:22 2006 @@ -532,7 +532,7 @@ assert(BType >= BytecodeFormat::ModuleBlockID); assert(BType < BytecodeFormat::NumberOfBlockIDs); bca.BlockSizes[ - llvm::BytecodeFormat::CompressedBytecodeBlockIdentifiers(BType)] += Size; + llvm::BytecodeFormat::BytecodeBlockIdentifiers(BType)] += Size; if (bca.version < 3) // Check for long block headers versions bca.BlockSizes[llvm::BytecodeFormat::Reserved_DoNotUse] += 8; Index: llvm/lib/Bytecode/Reader/Reader.cpp diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.204 llvm/lib/Bytecode/Reader/Reader.cpp:1.205 --- llvm/lib/Bytecode/Reader/Reader.cpp:1.204 Wed Nov 8 15:27:54 2006 +++ llvm/lib/Bytecode/Reader/Reader.cpp Mon Nov 13 22:47:22 2006 @@ -73,18 +73,6 @@ " block."); } -/// Align the buffer position to a 32 bit boundary -inline void BytecodeReader::align32() { - if (hasAlignment) { - BufPtr Save = At; - At = (const unsigned char *)((intptr_t)(At+3) & (~3UL)); - if (At > Save) - if (Handler) Handler->handleAlignment(At - Save); - if (At > BlockEnd) - error("Ran out of data while aligning!"); - } -} - /// Read a whole unsigned integer inline unsigned BytecodeReader::read_uint() { if (At+4 > BlockEnd) @@ -179,43 +167,9 @@ /// Read a block header and obtain its type and size inline void BytecodeReader::read_block(unsigned &Type, unsigned &Size) { - if ( hasLongBlockHeaders ) { - Type = read_uint(); - Size = read_uint(); - switch (Type) { - case BytecodeFormat::Reserved_DoNotUse : - error("Reserved_DoNotUse used as Module Type?"); - Type = BytecodeFormat::ModuleBlockID; break; - case BytecodeFormat::Module: - Type = BytecodeFormat::ModuleBlockID; break; - case BytecodeFormat::Function: - Type = BytecodeFormat::FunctionBlockID; break; - case BytecodeFormat::ConstantPool: - Type = BytecodeFormat::ConstantPoolBlockID; break; - case BytecodeFormat::SymbolTable: - Type = BytecodeFormat::SymbolTableBlockID; break; - case BytecodeFormat::ModuleGlobalInfo: - Type = BytecodeFormat::ModuleGlobalInfoBlockID; break; - case BytecodeFormat::GlobalTypePlane: - Type = BytecodeFormat::GlobalTypePlaneBlockID; break; - case BytecodeFormat::InstructionList: - Type = BytecodeFormat::InstructionListBlockID; break; - case BytecodeFormat::CompactionTable: - Type = BytecodeFormat::CompactionTableBlockID; break; - case BytecodeFormat::BasicBlock: - /// This block type isn't used after version 1.1. However, we have to - /// still allow the value in case this is an old bc format file. - /// We just let its value creep thru. - break; - default: - error("Invalid block id found: " + utostr(Type)); - break; - } - } else { - Size = read_uint(); - Type = Size & 0x1F; // mask low order five bits - Size >>= 5; // get rid of five low order bits, leaving high 27 - } + Size = read_uint(); // Read the header + Type = Size & 0x1F; // mask low order five bits to get type + Size >>= 5; // high order 27 bits is the size BlockStart = At; if (At + Size > BlockEnd) error("Attempt to size a block past end of memory"); @@ -223,56 +177,13 @@ if (Handler) Handler->handleBlock(Type, BlockStart, Size); } - -/// In LLVM 1.2 and before, Types were derived from Value and so they were -/// written as part of the type planes along with any other Value. In LLVM -/// 1.3 this changed so that Type does not derive from Value. Consequently, -/// the BytecodeReader's containers for Values can't contain Types because -/// there's no inheritance relationship. This means that the "Type Type" -/// plane is defunct along with the Type::TypeTyID TypeID. In LLVM 1.3 -/// whenever a bytecode construct must have both types and values together, -/// the types are always read/written first and then the Values. Furthermore -/// since Type::TypeTyID no longer exists, its value (12) now corresponds to -/// Type::LabelTyID. In order to overcome this we must "sanitize" all the -/// type TypeIDs we encounter. For LLVM 1.3 bytecode files, there's no change. -/// For LLVM 1.2 and before, this function will decrement the type id by -/// one to account for the missing Type::TypeTyID enumerator if the value is -/// larger than 12 (Type::LabelTyID). If the value is exactly 12, then this -/// function returns true, otherwise false. This helps detect situations -/// where the pre 1.3 bytecode is indicating that what follows is a type. -/// @returns true iff type id corresponds to pre 1.3 "type type" -inline bool BytecodeReader::sanitizeTypeId(unsigned &TypeId) { - if (hasTypeDerivedFromValue) { /// do nothing if 1.3 or later - if (TypeId == Type::LabelTyID) { - TypeId = Type::VoidTyID; // sanitize it - return true; // indicate we got TypeTyID in pre 1.3 bytecode - } else if (TypeId > Type::LabelTyID) - --TypeId; // shift all planes down because type type plane is missing - } - return false; -} - -/// Reads a vbr uint to read in a type id and does the necessary -/// conversion on it by calling sanitizeTypeId. -/// @returns true iff \p TypeId read corresponds to a pre 1.3 "type type" -/// @see sanitizeTypeId -inline bool BytecodeReader::read_typeid(unsigned &TypeId) { - TypeId = read_vbr_uint(); - if ( !has32BitTypes ) - if ( TypeId == 0x00FFFFFF ) - TypeId = read_vbr_uint(); - return sanitizeTypeId(TypeId); -} - //===----------------------------------------------------------------------===// // IR Lookup Methods //===----------------------------------------------------------------------===// /// Determine if a type id has an implicit null value inline bool BytecodeReader::hasImplicitNull(unsigned TyID) { - if (!hasExplicitPrimitiveZeros) - return TyID != Type::LabelTyID && TyID != Type::VoidTyID; - return TyID >= Type::FirstDerivedTyID; + return TyID != Type::LabelTyID && TyID != Type::VoidTyID; } /// Obtain a type given a typeid and account for things like compaction tables, @@ -304,23 +215,11 @@ return Type::VoidTy; } -/// Get a sanitized type id. This just makes sure that the \p ID -/// is both sanitized and not the "type type" of pre-1.3 bytecode. -/// @see sanitizeTypeId -inline const Type* BytecodeReader::getSanitizedType(unsigned& ID) { - if (sanitizeTypeId(ID)) - error("Invalid type id encountered"); - return getType(ID); -} - -/// This method just saves some coding. It uses read_typeid to read +/// This method just saves some coding. It uses read_vbr_uint to read /// in a sanitized type id, errors that its not the type type, and /// then calls getType to return the type value. -inline const Type* BytecodeReader::readSanitizedType() { - unsigned ID; - if (read_typeid(ID)) - error("Invalid type id encountered"); - return getType(ID); +inline const Type* BytecodeReader::readType() { + return getType(read_vbr_uint()); } /// Get the slot number associated with a type accounting for primitive @@ -590,12 +489,6 @@ if (!hasSignlessDivRem && !hasSignlessShrCastSetcc) return 0; // The opcode is fine the way it is. - // If this is a bytecode format that did not include the unreachable - // instruction, bump up the opcode number to adjust it. - if (hasNoUnreachableInst) - if (Opcode >= 6 && Opcode < 62) - ++Opcode; - // If this is bytecode version 6, that only had signed Rem and Div // instructions, then we must compensate for those two instructions only. // So that the switch statement below works, we're trying to turn this into @@ -779,7 +672,7 @@ CallInst* bar = new CallInst(NF, getValue(iType, Oprnds[0])); BB->getInstList().push_back(bar); BB->getInstList().push_back(new StoreInst(bar, foo)); - Instruction* tmp = new VAArgInst(foo, getSanitizedType(Oprnds[1])); + Instruction* tmp = new VAArgInst(foo, getType(Oprnds[1])); BB->getInstList().push_back(tmp); Result = new LoadInst(foo); break; @@ -803,7 +696,7 @@ CallInst* bar = new CallInst(NF, getValue(iType, Oprnds[0])); BB->getInstList().push_back(bar); BB->getInstList().push_back(new StoreInst(bar, foo)); - Result = new VAArgInst(foo, getSanitizedType(Oprnds[1])); + Result = new VAArgInst(foo, getType(Oprnds[1])); break; } case 34: // Select @@ -919,11 +812,10 @@ for (unsigned i = 0; i != NumOprnds; ++i) Oprnds[i] = read_vbr_uint(); - align32(); break; } - const Type *InstTy = getSanitizedType(iType); + const Type *InstTy = getType(iType); // Make the necessary adjustments for dealing with backwards compatibility // of opcodes. @@ -955,7 +847,7 @@ if (Oprnds.size() != 2) error("Invalid VAArg instruction!"); Result = new VAArgInst(getValue(iType, Oprnds[0]), - getSanitizedType(Oprnds[1])); + getType(Oprnds[1])); break; case Instruction::ExtractElement: { if (Oprnds.size() != 2) @@ -1001,7 +893,7 @@ if (Oprnds.size() != 2) error("Invalid Cast instruction!"); Result = new CastInst(getValue(iType, Oprnds[0]), - getSanitizedType(Oprnds[1])); + getType(Oprnds[1])); break; case Instruction::Select: if (Oprnds.size() != 3) @@ -1235,34 +1127,22 @@ unsigned ValIdx = Oprnds[i]; unsigned IdxTy = 0; - if (!hasRestrictedGEPTypes) { - // Struct indices are always uints, sequential type indices can be - // any of the 32 or 64-bit integer types. The actual choice of - // type is encoded in the low two bits of the slot number. - if (isa(TopTy)) - IdxTy = Type::UIntTyID; - else { - switch (ValIdx & 3) { - default: - case 0: IdxTy = Type::UIntTyID; break; - case 1: IdxTy = Type::IntTyID; break; - case 2: IdxTy = Type::ULongTyID; break; - case 3: IdxTy = Type::LongTyID; break; - } - ValIdx >>= 2; + // Struct indices are always uints, sequential type indices can be + // any of the 32 or 64-bit integer types. The actual choice of + // type is encoded in the low two bits of the slot number. + if (isa(TopTy)) + IdxTy = Type::UIntTyID; + else { + switch (ValIdx & 3) { + default: + case 0: IdxTy = Type::UIntTyID; break; + case 1: IdxTy = Type::IntTyID; break; + case 2: IdxTy = Type::ULongTyID; break; + case 3: IdxTy = Type::LongTyID; break; } - } else { - IdxTy = isa(TopTy) ? Type::UByteTyID : Type::LongTyID; + ValIdx >>= 2; } - Idx.push_back(getValue(IdxTy, ValIdx)); - - // Convert ubyte struct indices into uint struct indices. - if (isa(TopTy) && hasRestrictedGEPTypes) - if (ConstantInt *C = dyn_cast(Idx.back())) - if (C->getType() == Type::UByteTy) - Idx[Idx.size()-1] = ConstantExpr::getCast(C, Type::UIntTy); - NextTy = GetElementPtrInst::getIndexedType(InstTy, Idx, true); } @@ -1309,16 +1189,16 @@ } /// Get a particular numbered basic block, which might be a forward reference. -/// This works together with ParseBasicBlock to handle these forward references -/// in a clean manner. This function is used when constructing phi, br, switch, -/// and other instructions that reference basic blocks. Blocks are numbered -/// sequentially as they appear in the function. +/// This works together with ParseInstructionList to handle these forward +/// references in a clean manner. This function is used when constructing +/// phi, br, switch, and other instructions that reference basic blocks. +/// Blocks are numbered sequentially as they appear in the function. BasicBlock *BytecodeReader::getBasicBlock(unsigned ID) { // Make sure there is room in the table... if (ParsedBasicBlocks.size() <= ID) ParsedBasicBlocks.resize(ID+1); - // First check to see if this is a backwards reference, i.e., ParseBasicBlock - // has already created this block, or if the forward reference has already + // First check to see if this is a backwards reference, i.e. this block + // has already been created, or if the forward reference has already // been created. if (ParsedBasicBlocks[ID]) return ParsedBasicBlocks[ID]; @@ -1328,34 +1208,10 @@ return ParsedBasicBlocks[ID] = new BasicBlock(); } -/// In LLVM 1.0 bytecode files, we used to output one basicblock at a time. -/// This method reads in one of the basicblock packets. This method is not used -/// for bytecode files after LLVM 1.0 -/// @returns The basic block constructed. -BasicBlock *BytecodeReader::ParseBasicBlock(unsigned BlockNo) { - if (Handler) Handler->handleBasicBlockBegin(BlockNo); - - BasicBlock *BB = 0; - - if (ParsedBasicBlocks.size() == BlockNo) - ParsedBasicBlocks.push_back(BB = new BasicBlock()); - else if (ParsedBasicBlocks[BlockNo] == 0) - BB = ParsedBasicBlocks[BlockNo] = new BasicBlock(); - else - BB = ParsedBasicBlocks[BlockNo]; - - std::vector Operands; - while (moreInBlock()) - ParseInstruction(Operands, BB); - - if (Handler) Handler->handleBasicBlockEnd(BlockNo); - return BB; -} - /// Parse all of the BasicBlock's & Instruction's in the body of a function. /// In post 1.0 bytecode files, we no longer emit basic block individually, /// in order to avoid per-basic-block overhead. -/// @returns Rhe number of basic blocks encountered. +/// @returns the number of basic blocks encountered. unsigned BytecodeReader::ParseInstructionList(Function* F) { unsigned BlockNo = 0; std::vector Args; @@ -1401,52 +1257,35 @@ E = CurrentFunction->end(); I != E; ++I) BBMap.push_back(I); - /// In LLVM 1.3 we write types separately from values so - /// The types are always first in the symbol table. This is - /// because Type no longer derives from Value. - if (!hasTypeDerivedFromValue) { - // Symtab block header: [num entries] - unsigned NumEntries = read_vbr_uint(); - for (unsigned i = 0; i < NumEntries; ++i) { - // Symtab entry: [def slot #][name] - unsigned slot = read_vbr_uint(); - std::string Name = read_str(); - const Type* T = getType(slot); - ST->insert(Name, T); - } + // Symtab block header: [num entries] + unsigned NumEntries = read_vbr_uint(); + for (unsigned i = 0; i < NumEntries; ++i) { + // Symtab entry: [def slot #][name] + unsigned slot = read_vbr_uint(); + std::string Name = read_str(); + const Type* T = getType(slot); + ST->insert(Name, T); } while (moreInBlock()) { // Symtab block header: [num entries][type id number] unsigned NumEntries = read_vbr_uint(); - unsigned Typ = 0; - bool isTypeType = read_typeid(Typ); + unsigned Typ = read_vbr_uint(); for (unsigned i = 0; i != NumEntries; ++i) { // Symtab entry: [def slot #][name] unsigned slot = read_vbr_uint(); std::string Name = read_str(); - - // if we're reading a pre 1.3 bytecode file and the type plane - // is the "type type", handle it here - if (isTypeType) { - const Type* T = getType(slot); - if (T == 0) - error("Failed type look-up for name '" + Name + "'"); - ST->insert(Name, T); - continue; // code below must be short circuited + Value *V = 0; + if (Typ == Type::LabelTyID) { + if (slot < BBMap.size()) + V = BBMap[slot]; } else { - Value *V = 0; - if (Typ == Type::LabelTyID) { - if (slot < BBMap.size()) - V = BBMap[slot]; - } else { - V = getValue(Typ, slot, false); // Find mapping... - } - if (V == 0) - error("Failed value look-up for name '" + Name + "'"); - V->setName(Name); + V = getValue(Typ, slot, false); // Find mapping... } + if (V == 0) + error("Failed value look-up for name '" + Name + "'"); + V->setName(Name); } } checkPastBlockEnd("Symbol Table"); @@ -1456,9 +1295,7 @@ /// Read in the types portion of a compaction table. void BytecodeReader::ParseCompactionTypes(unsigned NumEntries) { for (unsigned i = 0; i != NumEntries; ++i) { - unsigned TypeSlot = 0; - if (read_typeid(TypeSlot)) - error("Invalid type in compaction table: type type"); + unsigned TypeSlot = read_vbr_uint(); const Type *Typ = getGlobalTableType(TypeSlot); CompactionTypes.push_back(std::make_pair(Typ, TypeSlot)); if (Handler) Handler->handleCompactionTableType(i, TypeSlot, Typ); @@ -1471,14 +1308,9 @@ // Notify handler that we're beginning a compaction table. if (Handler) Handler->handleCompactionTableBegin(); - // In LLVM 1.3 Type no longer derives from Value. So, - // we always write them first in the compaction table - // because they can't occupy a "type plane" where the - // Values reside. - if (! hasTypeDerivedFromValue) { - unsigned NumEntries = read_vbr_uint(); - ParseCompactionTypes(NumEntries); - } + // Get the types for the compaction table. + unsigned NumEntries = read_vbr_uint(); + ParseCompactionTypes(NumEntries); // Compaction tables live in separate blocks so we have to loop // until we've read the whole thing. @@ -1486,7 +1318,6 @@ // Read the number of Value* entries in the compaction table unsigned NumEntries = read_vbr_uint(); unsigned Ty = 0; - unsigned isTypeType = false; // Decode the type from value read in. Most compaction table // planes will have one or two entries in them. If that's the @@ -1496,42 +1327,35 @@ // In this case, both low-order bits are set (value 3). This // is a signal that the typeid follows. NumEntries >>= 2; - isTypeType = read_typeid(Ty); + Ty = read_vbr_uint(); } else { // In this case, the low-order bits specify the number of entries // and the high order bits specify the type. Ty = NumEntries >> 2; - isTypeType = sanitizeTypeId(Ty); NumEntries &= 3; } - // if we're reading a pre 1.3 bytecode file and the type plane - // is the "type type", handle it here - if (isTypeType) { - ParseCompactionTypes(NumEntries); - } else { - // Make sure we have enough room for the plane. - if (Ty >= CompactionValues.size()) - CompactionValues.resize(Ty+1); - - // Make sure the plane is empty or we have some kind of error. - if (!CompactionValues[Ty].empty()) - error("Compaction table plane contains multiple entries!"); - - // Notify handler about the plane. - if (Handler) Handler->handleCompactionTablePlane(Ty, NumEntries); - - // Push the implicit zero. - CompactionValues[Ty].push_back(Constant::getNullValue(getType(Ty))); - - // Read in each of the entries, put them in the compaction table - // and notify the handler that we have a new compaction table value. - for (unsigned i = 0; i != NumEntries; ++i) { - unsigned ValSlot = read_vbr_uint(); - Value *V = getGlobalTableValue(Ty, ValSlot); - CompactionValues[Ty].push_back(V); - if (Handler) Handler->handleCompactionTableValue(i, Ty, ValSlot); - } + // Make sure we have enough room for the plane. + if (Ty >= CompactionValues.size()) + CompactionValues.resize(Ty+1); + + // Make sure the plane is empty or we have some kind of error. + if (!CompactionValues[Ty].empty()) + error("Compaction table plane contains multiple entries!"); + + // Notify handler about the plane. + if (Handler) Handler->handleCompactionTablePlane(Ty, NumEntries); + + // Push the implicit zero. + CompactionValues[Ty].push_back(Constant::getNullValue(getType(Ty))); + + // Read in each of the entries, put them in the compaction table + // and notify the handler that we have a new compaction table value. + for (unsigned i = 0; i != NumEntries; ++i) { + unsigned ValSlot = read_vbr_uint(); + Value *V = getGlobalTableValue(Ty, ValSlot); + CompactionValues[Ty].push_back(V); + if (Handler) Handler->handleCompactionTableValue(i, Ty, ValSlot); } } // Notify handler that the compaction table is done. @@ -1543,23 +1367,20 @@ // a derived type, then additional data is read to fill out the type // definition. const Type *BytecodeReader::ParseType() { - unsigned PrimType = 0; - if (read_typeid(PrimType)) - error("Invalid type (type type) in type constants!"); - + unsigned PrimType = read_vbr_uint(); const Type *Result = 0; if ((Result = Type::getPrimitiveType((Type::TypeID)PrimType))) return Result; switch (PrimType) { case Type::FunctionTyID: { - const Type *RetType = readSanitizedType(); + const Type *RetType = readType(); unsigned NumParams = read_vbr_uint(); std::vector Params; while (NumParams--) - Params.push_back(readSanitizedType()); + Params.push_back(readType()); bool isVarArg = Params.size() && Params.back() == Type::VoidTy; if (isVarArg) Params.pop_back(); @@ -1568,34 +1389,30 @@ break; } case Type::ArrayTyID: { - const Type *ElementType = readSanitizedType(); + const Type *ElementType = readType(); unsigned NumElements = read_vbr_uint(); Result = ArrayType::get(ElementType, NumElements); break; } case Type::PackedTyID: { - const Type *ElementType = readSanitizedType(); + const Type *ElementType = readType(); unsigned NumElements = read_vbr_uint(); Result = PackedType::get(ElementType, NumElements); break; } case Type::StructTyID: { std::vector Elements; - unsigned Typ = 0; - if (read_typeid(Typ)) - error("Invalid element type (type type) for structure!"); - + unsigned Typ = read_vbr_uint(); while (Typ) { // List is terminated by void/0 typeid Elements.push_back(getType(Typ)); - if (read_typeid(Typ)) - error("Invalid element type (type type) for structure!"); + Typ = read_vbr_uint(); } Result = StructType::get(Elements); break; } case Type::PointerTyID: { - Result = PointerType::get(readSanitizedType()); + Result = PointerType::get(readType()); break; } @@ -1676,14 +1493,6 @@ if (!hasSignlessDivRem && !hasSignlessShrCastSetcc) return Opcode; -#if 0 - // If this is a bytecode format that did not include the unreachable - // instruction, bump up the opcode number to adjust it. - if (hasNoUnreachableInst) - if (Opcode >= 6 && Opcode < 62) - ++Opcode; -#endif - // If this is bytecode version 6, that only had signed Rem and Div // instructions, then we must compensate for those two instructions only. // So that the switch statement below works, we're trying to turn this into @@ -1805,46 +1614,39 @@ unsigned isExprNumArgs = read_vbr_uint(); if (isExprNumArgs) { - if (!hasNoUndefValue) { - // 'undef' is encoded with 'exprnumargs' == 1. - if (isExprNumArgs == 1) - return UndefValue::get(getType(TypeID)); - - // Inline asm is encoded with exprnumargs == ~0U. - if (isExprNumArgs == ~0U) { - std::string AsmStr = read_str(); - std::string ConstraintStr = read_str(); - unsigned Flags = read_vbr_uint(); - - const PointerType *PTy = dyn_cast(getType(TypeID)); - const FunctionType *FTy = - PTy ? dyn_cast(PTy->getElementType()) : 0; - - if (!FTy || !InlineAsm::Verify(FTy, ConstraintStr)) - error("Invalid constraints for inline asm"); - if (Flags & ~1U) - error("Invalid flags for inline asm"); - bool HasSideEffects = Flags & 1; - return InlineAsm::get(FTy, AsmStr, ConstraintStr, HasSideEffects); - } + // 'undef' is encoded with 'exprnumargs' == 1. + if (isExprNumArgs == 1) + return UndefValue::get(getType(TypeID)); + + // Inline asm is encoded with exprnumargs == ~0U. + if (isExprNumArgs == ~0U) { + std::string AsmStr = read_str(); + std::string ConstraintStr = read_str(); + unsigned Flags = read_vbr_uint(); - --isExprNumArgs; + const PointerType *PTy = dyn_cast(getType(TypeID)); + const FunctionType *FTy = + PTy ? dyn_cast(PTy->getElementType()) : 0; + + if (!FTy || !InlineAsm::Verify(FTy, ConstraintStr)) + error("Invalid constraints for inline asm"); + if (Flags & ~1U) + error("Invalid flags for inline asm"); + bool HasSideEffects = Flags & 1; + return InlineAsm::get(FTy, AsmStr, ConstraintStr, HasSideEffects); } + + --isExprNumArgs; // FIXME: Encoding of constant exprs could be much more compact! std::vector ArgVec; ArgVec.reserve(isExprNumArgs); unsigned Opcode = read_vbr_uint(); - // Bytecode files before LLVM 1.4 need have a missing terminator inst. - if (hasNoUnreachableInst) Opcode++; - // Read the slot number and types of each of the arguments for (unsigned i = 0; i != isExprNumArgs; ++i) { unsigned ArgValSlot = read_vbr_uint(); - unsigned ArgTypeSlot = 0; - if (read_typeid(ArgTypeSlot)) - error("Invalid argument type (type type) for constant value"); + unsigned ArgTypeSlot = read_vbr_uint(); // Get the arg value from its slot if it exists, otherwise a placeholder ArgVec.push_back(getConstantValue(ArgTypeSlot, ArgValSlot)); @@ -1863,20 +1665,6 @@ return Result; } else if (Opcode == Instruction::GetElementPtr) { // GetElementPtr std::vector IdxList(ArgVec.begin()+1, ArgVec.end()); - - if (hasRestrictedGEPTypes) { - const Type *BaseTy = ArgVec[0]->getType(); - generic_gep_type_iterator::iterator> - GTI = gep_type_begin(BaseTy, IdxList.begin(), IdxList.end()), - E = gep_type_end(BaseTy, IdxList.begin(), IdxList.end()); - for (unsigned i = 0; GTI != E; ++GTI, ++i) - if (isa(*GTI)) { - if (IdxList[i]->getType() != Type::UByteTy) - error("Invalid index for getelementptr!"); - IdxList[i] = ConstantExpr::getCast(IdxList[i], Type::UIntTy); - } - } - Constant* Result = ConstantExpr::getGetElementPtr(ArgVec[0], IdxList); if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result); return Result; @@ -2068,9 +1856,7 @@ /// Parse the constant strings section. void BytecodeReader::ParseStringConstants(unsigned NumEntries, ValueTable &Tab){ for (; NumEntries; --NumEntries) { - unsigned Typ = 0; - if (read_typeid(Typ)) - error("Invalid type (type type) for string constant"); + unsigned Typ = read_vbr_uint(); const Type *Ty = getType(Typ); if (!isa(Ty)) error("String constant data invalid!"); @@ -2106,22 +1892,16 @@ /// In LLVM 1.3 Type does not derive from Value so the types /// do not occupy a plane. Consequently, we read the types /// first in the constant pool. - if (isFunction && !hasTypeDerivedFromValue) { + if (isFunction) { unsigned NumEntries = read_vbr_uint(); ParseTypes(TypeTab, NumEntries); } while (moreInBlock()) { unsigned NumEntries = read_vbr_uint(); - unsigned Typ = 0; - bool isTypeType = read_typeid(Typ); + unsigned Typ = read_vbr_uint(); - /// In LLVM 1.2 and before, Types were written to the - /// bytecode file in the "Type Type" plane (#12). - /// In 1.3 plane 12 is now the label plane. Handle this here. - if (isTypeType) { - ParseTypes(TypeTab, NumEntries); - } else if (Typ == Type::VoidTyID) { + if (Typ == Type::VoidTyID) { /// Use of Type::VoidTyID is a misnomer. It actually means /// that the following plane is constant strings assert(&Tab == &ModuleValues && "Cannot read strings in functions!"); @@ -2213,20 +1993,6 @@ ParseCompactionTable(); break; - case BytecodeFormat::BasicBlock: { - if (!InsertedArguments) { - // Insert arguments into the value table before we parse the first basic - // block in the function, but after we potentially read in the - // compaction table. - insertArguments(F); - InsertedArguments = true; - } - - BasicBlock *BB = ParseBasicBlock(BlockNum++); - F->getBasicBlockList().push_back(BB); - break; - } - case BytecodeFormat::InstructionListBlockID: { // Insert arguments into the value table before we parse the instruction // list for the function, but after we potentially read in the compaction @@ -2253,9 +2019,6 @@ break; } BlockEnd = MyEnd; - - // Malformed bc file if read past end of block. - align32(); } // Make sure there were no references to non-existant basic blocks. @@ -2382,11 +2145,6 @@ void BytecodeReader::ParseGlobalTypes() { // Read the number of types unsigned NumEntries = read_vbr_uint(); - - // Ignore the type plane identifier for types if the bc file is pre 1.3 - if (hasTypeDerivedFromValue) - read_vbr_uint(); - ParseTypes(ModuleTypes, NumEntries); } @@ -2405,8 +2163,6 @@ // VarType Fields: bit0 = isConstant, bit1 = hasInitializer, bit2,3,4 = // Linkage, bit4+ = slot# unsigned SlotNo = VarType >> 5; - if (sanitizeTypeId(SlotNo)) - error("Invalid type (type type) for global var!"); unsigned LinkageID = (VarType >> 2) & 7; bool isConstant = VarType & 1; bool hasInitializer = (VarType & 2) != 0; @@ -2477,9 +2233,6 @@ // Read the function objects for all of the functions that are coming unsigned FnSignature = read_vbr_uint(); - if (hasNoFlagsForFunctions) - FnSignature = (FnSignature << 5) + 1; - // List is terminated by VoidTy. while (((FnSignature & (~0U >> 1)) >> 5) != Type::VoidTyID) { const Type *Ty = getType((FnSignature & (~0U >> 1)) >> 5); @@ -2535,8 +2288,6 @@ // Get the next function signature. FnSignature = read_vbr_uint(); - if (hasNoFlagsForFunctions) - FnSignature = (FnSignature << 5) + 1; } // Now that the function signature list is set up, reverse it so that we can @@ -2548,37 +2299,32 @@ /// into this to get their section name. std::vector SectionNames; - if (hasInconsistentModuleGlobalInfo) { - align32(); - } else if (!hasNoDependentLibraries) { - // If this bytecode format has dependent library information in it, read in - // the number of dependent library items that follow. - unsigned num_dep_libs = read_vbr_uint(); - std::string dep_lib; - while (num_dep_libs--) { - dep_lib = read_str(); - TheModule->addLibrary(dep_lib); - if (Handler) - Handler->handleDependentLibrary(dep_lib); - } - - // Read target triple and place into the module. - std::string triple = read_str(); - TheModule->setTargetTriple(triple); + // Read in the dependent library information. + unsigned num_dep_libs = read_vbr_uint(); + std::string dep_lib; + while (num_dep_libs--) { + dep_lib = read_str(); + TheModule->addLibrary(dep_lib); if (Handler) - Handler->handleTargetTriple(triple); - - if (!hasAlignment && At != BlockEnd) { - // If the file has section info in it, read the section names now. - unsigned NumSections = read_vbr_uint(); - while (NumSections--) - SectionNames.push_back(read_str()); - } - - // If the file has module-level inline asm, read it now. - if (!hasAlignment && At != BlockEnd) - TheModule->setModuleInlineAsm(read_str()); + Handler->handleDependentLibrary(dep_lib); + } + + // Read target triple and place into the module. + std::string triple = read_str(); + TheModule->setTargetTriple(triple); + if (Handler) + Handler->handleTargetTriple(triple); + + if (At != BlockEnd) { + // If the file has section info in it, read the section names now. + unsigned NumSections = read_vbr_uint(); + while (NumSections--) + SectionNames.push_back(read_str()); } + + // If the file has module-level inline asm, read it now. + if (At != BlockEnd) + TheModule->setModuleInlineAsm(read_str()); // If any globals are in specified sections, assign them now. for (std::map::iterator I = SectionID.begin(), E = @@ -2613,97 +2359,22 @@ RevisionNum = Version >> 4; - // Default values for the current bytecode version - hasInconsistentModuleGlobalInfo = false; - hasExplicitPrimitiveZeros = false; - hasRestrictedGEPTypes = false; - hasTypeDerivedFromValue = false; - hasLongBlockHeaders = false; - has32BitTypes = false; - hasNoDependentLibraries = false; - hasAlignment = false; - hasNoUndefValue = false; - hasNoFlagsForFunctions = false; - hasNoUnreachableInst = false; + // Default the backwards compatibility flag values for the current BC version hasSignlessDivRem = false; hasSignlessShrCastSetcc = false; // Determine which backwards compatibility flags to set based on the // bytecode file's version number switch (RevisionNum) { - case 0: // LLVM 1.0, 1.1 (Released) - // Base LLVM 1.0 bytecode format. - hasInconsistentModuleGlobalInfo = true; - hasExplicitPrimitiveZeros = true; - - // FALL THROUGH - - case 1: // LLVM 1.2 (Released) - // LLVM 1.2 added explicit support for emitting strings efficiently. - - // Also, it fixed the problem where the size of the ModuleGlobalInfo block - // included the size for the alignment at the end, where the rest of the - // blocks did not. - - // LLVM 1.2 and before required that GEP indices be ubyte constants for - // structures and longs for sequential types. - hasRestrictedGEPTypes = true; - - // LLVM 1.2 and before had the Type class derive from Value class. This - // changed in release 1.3 and consequently LLVM 1.3 bytecode files are - // written differently because Types can no longer be part of the - // type planes for Values. - hasTypeDerivedFromValue = true; - - // FALL THROUGH - - case 2: // 1.2.5 (Not Released) - - // LLVM 1.2 and earlier had two-word block headers. This is a bit wasteful, - // especially for small files where the 8 bytes per block is a large - // fraction of the total block size. In LLVM 1.3, the block type and length - // are compressed into a single 32-bit unsigned integer. 27 bits for length, - // 5 bits for block type. - hasLongBlockHeaders = true; - - // LLVM 1.2 and earlier wrote type slot numbers as vbr_uint32. In LLVM 1.3 - // this has been reduced to vbr_uint24. It shouldn't make much difference - // since we haven't run into a module with > 24 million types, but for - // safety the 24-bit restriction has been enforced in 1.3 to free some bits - // in various places and to ensure consistency. - has32BitTypes = true; - - // LLVM 1.2 and earlier did not provide a target triple nor a list of - // libraries on which the bytecode is dependent. LLVM 1.3 provides these - // features, for use in future versions of LLVM. - hasNoDependentLibraries = true; - - // FALL THROUGH - - case 3: // LLVM 1.3 (Released) - // LLVM 1.3 and earlier caused alignment bytes to be written on some block - // boundaries and at the end of some strings. In extreme cases (e.g. lots - // of GEP references to a constant array), this can increase the file size - // by 30% or more. In version 1.4 alignment is done away with completely. - hasAlignment = true; - - // FALL THROUGH - - case 4: // 1.3.1 (Not Released) - // In version 4, we did not support the 'undef' constant. - hasNoUndefValue = true; - - // In version 4 and above, we did not include space for flags for functions - // in the module info block. - hasNoFlagsForFunctions = true; - - // In version 4 and above, we did not include the 'unreachable' instruction - // in the opcode numbering in the bytecode file. - hasNoUnreachableInst = true; - - // FALL THROUGH + case 0: // LLVM 1.0, 1.1 (Released) + case 1: // LLVM 1.2 (Released) + case 2: // 1.2.5 (Not Released) + case 3: // LLVM 1.3 (Released) + case 4: // 1.3.1 (Not Released) + error("Old bytecode formats no longer supported"); + break; - case 5: // 1.4 (Released) + case 5: // 1.4 (Released) // In version 6, the Div and Rem instructions were converted to their // signed and floating point counterparts: UDiv, SDiv, FDiv, URem, SRem, // and FRem. Versions prior to 6 need to indicate that they have the @@ -2712,7 +2383,7 @@ // FALL THROUGH - case 6: // Signless Rem & Div Implementation (1.9 release) + case 6: // 1.9 (Released) // In version 5 and prior, instructions were signless while integer types // were signed. In version 6, instructions became signed and types became // signless. For example in version 5 we have the DIV instruction but in @@ -2747,7 +2418,6 @@ // Read into instance variables... ParseVersionInfo(); - align32(); bool SeenModuleGlobalInfo = false; bool SeenGlobalTypePlane = false; @@ -2794,7 +2464,6 @@ break; } BlockEnd = MyEnd; - align32(); } // After the module constant pool has been read, we can safely initialize Index: llvm/lib/Bytecode/Reader/Reader.h diff -u llvm/lib/Bytecode/Reader/Reader.h:1.37 llvm/lib/Bytecode/Reader/Reader.h:1.38 --- llvm/lib/Bytecode/Reader/Reader.h:1.37 Sat Nov 11 05:54:25 2006 +++ llvm/lib/Bytecode/Reader/Reader.h Mon Nov 13 22:47:22 2006 @@ -292,69 +292,6 @@ /// Flags to distinguish LLVM 1.0 & 1.1 bytecode formats (revision #0) - /// Revision #0 had an explicit alignment of data only for the - /// ModuleGlobalInfo block. This was fixed to be like all other blocks in 1.2 - bool hasInconsistentModuleGlobalInfo; - - /// Revision #0 also explicitly encoded zero values for primitive types like - /// int/sbyte/etc. - bool hasExplicitPrimitiveZeros; - - // Flags to control features specific the LLVM 1.2 and before (revision #1) - - /// LLVM 1.2 and earlier required that getelementptr structure indices were - /// ubyte constants and that sequential type indices were longs. - bool hasRestrictedGEPTypes; - - /// LLVM 1.2 and earlier had class Type deriving from Value and the Type - /// objects were located in the "Type Type" plane of various lists in read - /// by the bytecode reader. In LLVM 1.3 this is no longer the case. Types are - /// completely distinct from Values. Consequently, Types are written in fixed - /// locations in LLVM 1.3. This flag indicates that the older Type derived - /// from Value style of bytecode file is being read. - bool hasTypeDerivedFromValue; - - /// LLVM 1.2 and earlier encoded block headers as two uint (8 bytes), one for - /// the size and one for the type. This is a bit wasteful, especially for - /// small files where the 8 bytes per block is a large fraction of the total - /// block size. In LLVM 1.3, the block type and length are encoded into a - /// single uint32 by restricting the number of block types (limit 31) and the - /// maximum size of a block (limit 2^27-1=134,217,727). Note that the module - /// block still uses the 8-byte format so the maximum size of a file can be - /// 2^32-1 bytes long. - bool hasLongBlockHeaders; - - /// LLVM 1.2 and earlier wrote type slot numbers as vbr_uint32. In LLVM 1.3 - /// this has been reduced to vbr_uint24. It shouldn't make much difference - /// since we haven't run into a module with > 24 million types, but for safety - /// the 24-bit restriction has been enforced in 1.3 to free some bits in - /// various places and to ensure consistency. In particular, global vars are - /// restricted to 24-bits. - bool has32BitTypes; - - /// LLVM 1.2 and earlier did not provide a target triple nor a list of - /// libraries on which the bytecode is dependent. LLVM 1.3 provides these - /// features, for use in future versions of LLVM. - bool hasNoDependentLibraries; - - /// LLVM 1.3 and earlier caused blocks and other fields to start on 32-bit - /// aligned boundaries. This can lead to as much as 30% bytecode size overhead - /// in various corner cases (lots of long instructions). In LLVM 1.4, - /// alignment of bytecode fields was done away with completely. - bool hasAlignment; - - // In version 4 and earlier, the bytecode format did not support the 'undef' - // constant. - bool hasNoUndefValue; - - // In version 4 and earlier, the bytecode format did not save space for flags - // in the global info block for functions. - bool hasNoFlagsForFunctions; - - // In version 4 and earlier, there was no opcode space reserved for the - // unreachable instruction. - bool hasNoUnreachableInst; - // In version 6, the Div and Rem instructions were converted to be the // signed instructions UDiv, SDiv, URem and SRem. This flag will be true if // the Div and Rem instructions are signless (ver 5 and prior). @@ -453,12 +390,8 @@ /// @brief Converts a type slot number to its Type* const Type *getType(unsigned ID); - /// @brief Converts a pre-sanitized type slot number to its Type* and - /// sanitizes the type id. - inline const Type* getSanitizedType(unsigned& ID ); - - /// @brief Read in and get a sanitized type id - inline const Type* readSanitizedType(); + /// @brief Read in a type id and turn it into a Type* + inline const Type* readType(); /// @brief Converts a Type* to its type slot number unsigned getTypeSlot(const Type *Ty); @@ -559,12 +492,6 @@ /// @brief Read a bytecode block header inline void read_block(unsigned &Type, unsigned &Size); - - /// @brief Read a type identifier and sanitize it. - inline bool read_typeid(unsigned &TypeId); - - /// @brief Recalculate type ID for pre 1.3 bytecode files. - inline bool sanitizeTypeId(unsigned &TypeId ); /// @} }; From reid at x10sys.com Mon Nov 13 22:47:42 2006 From: reid at x10sys.com (Reid Spencer) Date: Mon, 13 Nov 2006 22:47:42 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Bytecode/ver6.ll constexpr.ll constexpr.ll.bc-13 slow.ll slow.ll.bc-13 Message-ID: <200611140447.kAE4lgEX011583@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/Bytecode: ver6.ll updated: 1.1 -> 1.2 constexpr.ll (r1.1) removed constexpr.ll.bc-13 (r1.1) removed slow.ll (r1.2) removed slow.ll.bc-13 (r1.1) removed --- Log message: Discard code that supported old bytecode formats. This makes the Bytecode Reader code much easier to read and maintain. Backwards compatibility from version 5 format has been retained. Older formats will produce an error. --- Diffs of the changes: (+1 -0) ver6.ll | 1 + 1 files changed, 1 insertion(+) Index: llvm/test/Regression/Bytecode/ver6.ll diff -u llvm/test/Regression/Bytecode/ver6.ll:1.1 llvm/test/Regression/Bytecode/ver6.ll:1.2 --- llvm/test/Regression/Bytecode/ver6.ll:1.1 Wed Nov 8 15:28:30 2006 +++ llvm/test/Regression/Bytecode/ver6.ll Mon Nov 13 22:47:22 2006 @@ -1,2 +1,3 @@ ; Just see if we can disassemble the ver6.ll.bc bc file for upgrade purposes. ; RUN: llvm-dis < %s.bc | llvm-as | llc -o /dev/null -f -march=c +; RUN: llvm-dis < %s.bc | llvm-as | opt -verify | llvm-dis | llvm-as -o /dev/null -f From alenhar2 at cs.uiuc.edu Mon Nov 13 23:20:44 2006 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Mon, 13 Nov 2006 23:20:44 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/AliasDebugger.cpp Message-ID: <200611140520.kAE5KiHO012474@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: AliasDebugger.cpp added (r1.1) --- Log message: A shim over other AA impls to catch incorrect uses --- Diffs of the changes: (+125 -0) AliasDebugger.cpp | 125 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 125 insertions(+) Index: llvm/lib/Analysis/AliasDebugger.cpp diff -c /dev/null llvm/lib/Analysis/AliasDebugger.cpp:1.1 *** /dev/null Mon Nov 13 23:20:38 2006 --- llvm/lib/Analysis/AliasDebugger.cpp Mon Nov 13 23:20:28 2006 *************** *** 0 **** --- 1,125 ---- + //===- AliasDebugger.cpp - Simple Alias Analysis Use Checker --------------===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by Andrew Lenharth and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This simple pass checks alias analysis users to ensure that if they + // create a new value, they do not query AA without informing it of the value. + // It acts as a shim over any other AA pass you want. + // + // Yes keeping track of every value in the program is expensive, but this is + // a debugging pass. + // + //===----------------------------------------------------------------------===// + + #include "llvm/Analysis/Passes.h" + #include "llvm/Module.h" + #include "llvm/Pass.h" + #include "llvm/Instructions.h" + #include "llvm/Constants.h" + #include "llvm/DerivedTypes.h" + #include "llvm/Analysis/AliasAnalysis.h" + #include + using namespace llvm; + + namespace { + + class AliasDebugger : public ModulePass, public AliasAnalysis { + + //What we do is simple. Keep track of every value the AA could + //know about, and verify that queries are one of those. + //A query to a value that didn't exist when the AA was created + //means someone forgot to update the AA when creating new values + + std::set Vals; + + public: + bool runOnModule(Module &M) { + InitializeAliasAnalysis(this); // set up super class + + for(Module::global_iterator I = M.global_begin(), + E = M.global_end(); I != E; ++I) + Vals.insert(&*I); + + for(Module::iterator I = M.begin(), + E = M.end(); I != E; ++I){ + Vals.insert(&*I); + if(!I->isExternal()) { + for (Function::arg_iterator AI = I->arg_begin(), AE = I->arg_end(); + AI != AE; ++AI) + Vals.insert(&*AI); + for (Function::const_iterator FI = I->begin(), FE = I->end(); + FI != FE; ++FI) + for (BasicBlock::const_iterator BI = FI->begin(), BE = FI->end(); + BI != BE; ++BI) + Vals.insert(&*BI); + } + + } + return false; + } + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AliasAnalysis::getAnalysisUsage(AU); + AU.setPreservesAll(); // Does not transform code + } + + //------------------------------------------------ + // Implement the AliasAnalysis API + // + AliasResult alias(const Value *V1, unsigned V1Size, + const Value *V2, unsigned V2Size) { + assert(Vals.find(V1) != Vals.end() && "Never seen value in AA before"); + assert(Vals.find(V2) != Vals.end() && "Never seen value in AA before"); + return AliasAnalysis::alias(V1, V1Size, V2, V2Size); + } + + ModRefResult getModRefInfo(CallSite CS, Value *P, unsigned Size) { + assert(Vals.find(P) != Vals.end() && "Never seen value in AA before"); + return AliasAnalysis::getModRefInfo(CS, P, Size); + } + + ModRefResult getModRefInfo(CallSite CS1, CallSite CS2) { + return AliasAnalysis::getModRefInfo(CS1,CS2); + } + + void getMustAliases(Value *P, std::vector &RetVals) { + assert(Vals.find(P) != Vals.end() && "Never seen value in AA before"); + return AliasAnalysis::getMustAliases(P, RetVals); + } + + bool pointsToConstantMemory(const Value *P) { + assert(Vals.find(P) != Vals.end() && "Never seen value in AA before"); + return AliasAnalysis::pointsToConstantMemory(P); + } + + /// getModRefBehavior - Return the behavior of the specified function if + /// called from the specified call site. The call site may be null in which + /// case the most generic behavior of this function should be returned. + virtual ModRefBehavior getModRefBehavior(Function *F, CallSite CS, + std::vector *Info) { + assert(Vals.find(F) != Vals.end() && "Never seen value in AA before"); + return AliasAnalysis::getModRefBehavior(F, CS, Info); + } + + virtual void deleteValue(Value *V) { + assert(Vals.find(V) != Vals.end() && "Never seen value in AA before"); + AliasAnalysis::deleteValue(V); + } + virtual void copyValue(Value *From, Value *To) { + Vals.insert(To); + AliasAnalysis::copyValue(From, To); + } + + }; + + RegisterPass X("debug-aa", "AA use debugger"); + RegisterAnalysisGroup Y(X); + } + + Pass *llvm::createAliasDebugger() { return new AliasDebugger(); } + From alenhar2 at cs.uiuc.edu Mon Nov 13 23:21:21 2006 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Mon, 13 Nov 2006 23:21:21 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/Passes.h Message-ID: <200611140521.kAE5LL89012584@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: Passes.h updated: 1.7 -> 1.8 --- Log message: A shim over other AA impls to catch incorrect uses --- Diffs of the changes: (+6 -0) Passes.h | 6 ++++++ 1 files changed, 6 insertions(+) Index: llvm/include/llvm/Analysis/Passes.h diff -u llvm/include/llvm/Analysis/Passes.h:1.7 llvm/include/llvm/Analysis/Passes.h:1.8 --- llvm/include/llvm/Analysis/Passes.h:1.7 Sun Oct 23 20:00:32 2005 +++ llvm/include/llvm/Analysis/Passes.h Mon Nov 13 23:21:04 2006 @@ -30,6 +30,12 @@ //===--------------------------------------------------------------------===// // + // createAliasDebugger - This pass helps debug clients of AA + // + Pass *createAliasDebugger(); + + //===--------------------------------------------------------------------===// + // // createAliasAnalysisCounterPass - This pass counts alias queries and how the // alias analysis implementation responds. // From alenhar2 at cs.uiuc.edu Mon Nov 13 23:21:20 2006 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Mon, 13 Nov 2006 23:21:20 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/LinkAllPasses.h Message-ID: <200611140521.kAE5LKti012578@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: LinkAllPasses.h updated: 1.3 -> 1.4 --- Log message: A shim over other AA impls to catch incorrect uses --- Diffs of the changes: (+1 -0) LinkAllPasses.h | 1 + 1 files changed, 1 insertion(+) Index: llvm/include/llvm/LinkAllPasses.h diff -u llvm/include/llvm/LinkAllPasses.h:1.3 llvm/include/llvm/LinkAllPasses.h:1.4 --- llvm/include/llvm/LinkAllPasses.h:1.3 Mon Aug 28 17:44:55 2006 +++ llvm/include/llvm/LinkAllPasses.h Mon Nov 13 23:21:04 2006 @@ -45,6 +45,7 @@ (void) llvm::createAAEvalPass(); (void) llvm::createAggressiveDCEPass(); (void) llvm::createAliasAnalysisCounterPass(); + (void) llvm::createAliasDebugger(); (void) llvm::createAndersensPass(); (void) llvm::createArgumentPromotionPass(); (void) llvm::createBasicAliasAnalysisPass(); From sabre at nondot.org Mon Nov 13 23:28:25 2006 From: sabre at nondot.org (Chris Lattner) Date: Mon, 13 Nov 2006 23:28:25 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCISelLowering.cpp Message-ID: <200611140528.kAE5SPMo013305@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCISelLowering.cpp updated: 1.225 -> 1.226 --- Log message: lower "X = seteq Y, Z" to '(shr (ctlz (xor Y, Z)), 5)' instead of '(shr (ctlz (sub Y, Z)), 5)'. The use of xor better exposes the operation to bit-twiddling logic in the dag combiner. For example, this: typedef struct { unsigned prefix : 4; unsigned code : 4; unsigned unsigned_p : 4; } tree_common; int foo(tree_common *a, tree_common *b) { return a->code == b->code; } Now compiles to: _foo: lwz r2, 0(r4) lwz r3, 0(r3) xor r2, r3, r2 rlwinm r2, r2, 28, 28, 31 cntlzw r2, r2 srwi r3, r2, 5 blr instead of: _foo: lbz r2, 3(r4) lbz r3, 3(r3) srwi r2, r2, 4 srwi r3, r3, 4 subf r2, r2, r3 cntlzw r2, r2 srwi r3, r2, 5 blr saving a cycle. --- Diffs of the changes: (+5 -3) PPCISelLowering.cpp | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp diff -u llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.225 llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.226 --- llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.225 Mon Nov 13 19:38:31 2006 +++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp Mon Nov 13 23:28:08 2006 @@ -1038,12 +1038,14 @@ } // If we have an integer seteq/setne, turn it into a compare against zero - // by subtracting the rhs from the lhs, which is faster than setting a - // condition register, reading it back out, and masking the correct bit. + // by xor'ing the rhs with the lhs, which is faster than setting a + // condition register, reading it back out, and masking the correct bit. The + // normal approach here uses sub to do this instead of xor. Using xor exposes + // the result to other bit-twiddling opportunities. MVT::ValueType LHSVT = Op.getOperand(0).getValueType(); if (MVT::isInteger(LHSVT) && (CC == ISD::SETEQ || CC == ISD::SETNE)) { MVT::ValueType VT = Op.getValueType(); - SDOperand Sub = DAG.getNode(ISD::SUB, LHSVT, Op.getOperand(0), + SDOperand Sub = DAG.getNode(ISD::XOR, LHSVT, Op.getOperand(0), Op.getOperand(1)); return DAG.getSetCC(VT, Sub, DAG.getConstant(0, LHSVT), CC); } From sabre at nondot.org Tue Nov 14 00:06:22 2006 From: sabre at nondot.org (Chris Lattner) Date: Tue, 14 Nov 2006 00:06:22 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200611140606.kAE66MSg017293@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.542 -> 1.543 --- Log message: implement InstCombine/and-compare.ll:test1. This compiles: typedef struct { unsigned prefix : 4; unsigned code : 4; unsigned unsigned_p : 4; } tree_common; int foo(tree_common *a, tree_common *b) { return a->code == b->code; } into: _foo: movl 4(%esp), %eax movl 8(%esp), %ecx movl (%eax), %eax xorl (%ecx), %eax # TRUNCATE movb %al, %al shrb $4, %al testb %al, %al sete %al movzbl %al, %eax ret instead of: _foo: movl 8(%esp), %eax movb (%eax), %al shrb $4, %al movl 4(%esp), %ecx movb (%ecx), %cl shrb $4, %cl cmpb %al, %cl sete %al movzbl %al, %eax ret saving one cycle by eliminating a shift. --- Diffs of the changes: (+26 -0) InstructionCombining.cpp | 26 ++++++++++++++++++++++++++ 1 files changed, 26 insertions(+) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.542 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.543 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.542 Fri Nov 10 17:38:52 2006 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Tue Nov 14 00:06:06 2006 @@ -4950,6 +4950,32 @@ return BinaryOperator::create(I.getOpcode(), B, Constant::getNullValue(B->getType())); } + + Value *C, *D; + // (X&Z) == (Y&Z) -> (X^Y) & Z == 0 + if (Op0->hasOneUse() && Op1->hasOneUse() && + match(Op0, m_And(m_Value(A), m_Value(B))) && + match(Op1, m_And(m_Value(C), m_Value(D)))) { + Value *X = 0, *Y = 0, *Z = 0; + + if (A == C) { + X = B; Y = D; Z = A; + } else if (A == D) { + X = B; Y = C; Z = A; + } else if (B == C) { + X = A; Y = D; Z = B; + } else if (B == D) { + X = A; Y = C; Z = B; + } + + if (X) { // Build (X^Y) & Z + Op1 = InsertNewInstBefore(BinaryOperator::createXor(X, Y, "tmp"), I); + Op1 = InsertNewInstBefore(BinaryOperator::createAnd(Op1, Z, "tmp"), I); + I.setOperand(0, Op1); + I.setOperand(1, Constant::getNullValue(Op1->getType())); + return &I; + } + } } return Changed ? &I : 0; } From sabre at nondot.org Tue Nov 14 00:04:52 2006 From: sabre at nondot.org (Chris Lattner) Date: Tue, 14 Nov 2006 00:04:52 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/InstCombine/and-compare.ll Message-ID: <200611140604.kAE64qrG017176@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/InstCombine: and-compare.ll added (r1.1) --- Log message: new testcase --- Diffs of the changes: (+10 -0) and-compare.ll | 10 ++++++++++ 1 files changed, 10 insertions(+) Index: llvm/test/Regression/Transforms/InstCombine/and-compare.ll diff -c /dev/null llvm/test/Regression/Transforms/InstCombine/and-compare.ll:1.1 *** /dev/null Tue Nov 14 00:04:45 2006 --- llvm/test/Regression/Transforms/InstCombine/and-compare.ll Tue Nov 14 00:04:35 2006 *************** *** 0 **** --- 1,10 ---- + ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep and | wc -l | grep 1 + + ; Should be optimized to one and. + bool %test1(uint %a, uint %b) { + %tmp1 = and uint %a, 65280 + %tmp3 = and uint %b, 65280 + %tmp = setne uint %tmp1, %tmp3 + ret bool %tmp + } + From clattner at apple.com Tue Nov 14 01:09:23 2006 From: clattner at apple.com (Chris Lattner) Date: Mon, 13 Nov 2006 23:09:23 -0800 Subject: [llvm-commits] New llvm-gcc README.LLVM Message-ID: New, improved, actually works on darwin! Jim, I just committed this as r120083. Please pull it into the 1.9 release branch, thanks! -Chris -------------- next part -------------- A non-text attachment was scrubbed... Name: README.LLVM Type: application/octet-stream Size: 5189 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20061113/dc0f6d45/attachment.obj From sabre at nondot.org Tue Nov 14 01:45:51 2006 From: sabre at nondot.org (Chris Lattner) Date: Tue, 14 Nov 2006 01:45:51 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/InstCombine/shift-simplify.ll Message-ID: <200611140745.kAE7jpMl026420@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/InstCombine: shift-simplify.ll added (r1.1) --- Log message: new testcase --- Diffs of the changes: (+22 -0) shift-simplify.ll | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+) Index: llvm/test/Regression/Transforms/InstCombine/shift-simplify.ll diff -c /dev/null llvm/test/Regression/Transforms/InstCombine/shift-simplify.ll:1.1 *** /dev/null Tue Nov 14 01:45:46 2006 --- llvm/test/Regression/Transforms/InstCombine/shift-simplify.ll Tue Nov 14 01:45:36 2006 *************** *** 0 **** --- 1,22 ---- + ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | egrep 'shl|lshr|ashr' | wc -l | grep 3 + + int %test0(int %A, int %B, ubyte %C) { + %X = shl int %A, ubyte %C + %Y = shl int %B, ubyte %C + %Z = and int %X, %Y + ret int %Z + } + + int %test1(int %A, int %B, ubyte %C) { + %X = lshr int %A, ubyte %C + %Y = lshr int %B, ubyte %C + %Z = or int %X, %Y + ret int %Z + } + + int %test2(int %A, int %B, ubyte %C) { + %X = ashr int %A, ubyte %C + %Y = ashr int %B, ubyte %C + %Z = xor int %X, %Y + ret int %Z + } From sabre at nondot.org Tue Nov 14 01:47:04 2006 From: sabre at nondot.org (Chris Lattner) Date: Tue, 14 Nov 2006 01:47:04 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200611140747.kAE7l4Ba026555@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.543 -> 1.544 --- Log message: implement InstCombine/shift-simplify.ll by transforming: (X >> Z) op (Y >> Z) -> (X op Y) >> Z for all shifts and all ops={and/or/xor}. --- Diffs of the changes: (+46 -3) InstructionCombining.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 46 insertions(+), 3 deletions(-) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.543 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.544 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.543 Tue Nov 14 00:06:06 2006 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Tue Nov 14 01:46:50 2006 @@ -3310,9 +3310,9 @@ } // fold (and (cast A), (cast B)) -> (cast (and A, B)) - if (CastInst *Op0C = dyn_cast(Op0)) { - const Type *SrcTy = Op0C->getOperand(0)->getType(); - if (CastInst *Op1C = dyn_cast(Op1)) + if (CastInst *Op1C = dyn_cast(Op1)) { + if (CastInst *Op0C = dyn_cast(Op0)) { + const Type *SrcTy = Op0C->getOperand(0)->getType(); if (SrcTy == Op1C->getOperand(0)->getType() && SrcTy->isIntegral() && // Only do this if the casts both really cause code to be generated. ValueRequiresCast(Op0C->getOperand(0), I.getType(), TD) && @@ -3323,6 +3323,21 @@ InsertNewInstBefore(NewOp, I); return new CastInst(NewOp, I.getType()); } + } + } + + // (X >> Z) & (Y >> Z) -> (X&Y) >> Z for all shifts. + if (ShiftInst *SI1 = dyn_cast(Op1)) { + if (ShiftInst *SI0 = dyn_cast(Op0)) + if (SI0->getOpcode() == SI1->getOpcode() && + SI0->getOperand(1) == SI1->getOperand(1) && + (SI0->hasOneUse() || SI1->hasOneUse())) { + Instruction *NewOp = + InsertNewInstBefore(BinaryOperator::createAnd(SI0->getOperand(0), + SI1->getOperand(0), + SI0->getName()), I); + return new ShiftInst(SI1->getOpcode(), NewOp, SI1->getOperand(1)); + } } return Changed ? &I : 0; @@ -3567,6 +3582,20 @@ } } } + + // (X >> Z) | (Y >> Z) -> (X|Y) >> Z for all shifts. + if (ShiftInst *SI1 = dyn_cast(Op1)) { + if (ShiftInst *SI0 = dyn_cast(Op0)) + if (SI0->getOpcode() == SI1->getOpcode() && + SI0->getOperand(1) == SI1->getOperand(1) && + (SI0->hasOneUse() || SI1->hasOneUse())) { + Instruction *NewOp = + InsertNewInstBefore(BinaryOperator::createOr(SI0->getOperand(0), + SI1->getOperand(0), + SI0->getName()), I); + return new ShiftInst(SI1->getOpcode(), NewOp, SI1->getOperand(1)); + } + } if (match(Op0, m_Not(m_Value(A)))) { // ~A | Op1 if (A == Op1) // ~A | A == -1 @@ -3879,6 +3908,20 @@ return new CastInst(NewOp, I.getType()); } } + + // (X >> Z) ^ (Y >> Z) -> (X^Y) >> Z for all shifts. + if (ShiftInst *SI1 = dyn_cast(Op1)) { + if (ShiftInst *SI0 = dyn_cast(Op0)) + if (SI0->getOpcode() == SI1->getOpcode() && + SI0->getOperand(1) == SI1->getOperand(1) && + (SI0->hasOneUse() || SI1->hasOneUse())) { + Instruction *NewOp = + InsertNewInstBefore(BinaryOperator::createXor(SI0->getOperand(0), + SI1->getOperand(0), + SI0->getName()), I); + return new ShiftInst(SI1->getOpcode(), NewOp, SI1->getOperand(1)); + } + } return Changed ? &I : 0; } From sabre at nondot.org Tue Nov 14 02:09:09 2006 From: sabre at nondot.org (Chris Lattner) Date: Tue, 14 Nov 2006 02:09:09 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/README.txt Message-ID: <200611140809.kAE899Xx009052@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: README.txt updated: 1.144 -> 1.145 --- Log message: it would be nice of ctlz were lowered to bsf etc. --- Diffs of the changes: (+9 -0) README.txt | 9 +++++++++ 1 files changed, 9 insertions(+) Index: llvm/lib/Target/X86/README.txt diff -u llvm/lib/Target/X86/README.txt:1.144 llvm/lib/Target/X86/README.txt:1.145 --- llvm/lib/Target/X86/README.txt:1.144 Fri Nov 10 16:03:35 2006 +++ llvm/lib/Target/X86/README.txt Tue Nov 14 02:08:46 2006 @@ -114,6 +114,15 @@ however, check that these are defined for 0 and 32. Our intrinsics are, GCC's aren't. +Another example (use predsimplify to eliminate a select): + +int foo (unsigned long j) { + if (j) + return __builtin_ffs (j) - 1; + else + return 0; +} + //===---------------------------------------------------------------------===// Use push/pop instructions in prolog/epilog sequences instead of stores off From reid at x10sys.com Tue Nov 14 12:35:06 2006 From: reid at x10sys.com (Reid Spencer) Date: Tue, 14 Nov 2006 12:35:06 -0600 Subject: [llvm-commits] CVS: llvm-test/SingleSource/Benchmarks/McGill/exptree.c Message-ID: <200611141835.kAEIZ6nL025877@zion.cs.uiuc.edu> Changes in directory llvm-test/SingleSource/Benchmarks/McGill: exptree.c updated: 1.1 -> 1.2 --- Log message: Shut gcc up about main not returning int. --- Diffs of the changes: (+2 -1) exptree.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-) Index: llvm-test/SingleSource/Benchmarks/McGill/exptree.c diff -u llvm-test/SingleSource/Benchmarks/McGill/exptree.c:1.1 llvm-test/SingleSource/Benchmarks/McGill/exptree.c:1.2 --- llvm-test/SingleSource/Benchmarks/McGill/exptree.c:1.1 Tue Oct 5 15:58:37 2004 +++ llvm-test/SingleSource/Benchmarks/McGill/exptree.c Tue Nov 14 12:34:51 2006 @@ -381,8 +381,9 @@ doSearch(); } -void main( int argc, char *argv[] ) +int main( int argc, char *argv[] ) { if( getInput() ) search(); + return 0; } From sabre at nondot.org Tue Nov 14 12:41:53 2006 From: sabre at nondot.org (Chris Lattner) Date: Tue, 14 Nov 2006 12:41:53 -0600 Subject: [llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp Message-ID: <200611141841.kAEIfrwO026024@zion.cs.uiuc.edu> Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.281 -> 1.282 --- Log message: Fix a bug handling nodes with variable arguments. The code was fixed to assume that there were two input operands before the variable operand portion. This *happened* to be true for all call instructions, which took a chain and a destination, but was not true for the PPC BCTRL instruction, whose destination is implicit. Making this code more general allows elimination of the custom selection logic for BCTRL. --- Diffs of the changes: (+15 -8) DAGISelEmitter.cpp | 23 +++++++++++++++-------- 1 files changed, 15 insertions(+), 8 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.281 llvm/utils/TableGen/DAGISelEmitter.cpp:1.282 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.281 Wed Nov 8 17:01:03 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Tue Nov 14 12:41:38 2006 @@ -2852,6 +2852,11 @@ if (NodeHasOutFlag) Code += ", MVT::Flag"; + // Figure out how many fixed inputs the node has. This is important to + // know which inputs are the variable ones if present. + unsigned NumInputs = AllOps.size(); + NumInputs += NodeHasChain; + // Inputs. if (HasVarOps) { for (unsigned i = 0, e = AllOps.size(); i != e; ++i) @@ -2860,15 +2865,17 @@ } if (HasVarOps) { + // Figure out whether any operands at the end of the op list are not + // part of the variable section. + std::string EndAdjust; if (NodeHasInFlag || HasImpInputs) - emitCode("for (unsigned i = 2, e = N.getNumOperands()-1; " - "i != e; ++i) {"); - else if (NodeHasOptInFlag) - emitCode("for (unsigned i = 2, e = N.getNumOperands()-" - "(HasInFlag?1:0); i != e; ++i) {"); - else - emitCode("for (unsigned i = 2, e = N.getNumOperands(); " - "i != e; ++i) {"); + EndAdjust = "-1"; // Always has one flag. + else if (NodeHasOptInFlag) + EndAdjust = "-(HasInFlag?1:0)"; // May have a flag. + + emitCode("for (unsigned i = " + utostr(NumInputs) + + ", e = N.getNumOperands()" + EndAdjust + "; i != e; ++i) {"); + emitCode(" AddToISelQueue(N.getOperand(i));"); emitCode(" Ops" + utostr(OpsNo) + ".push_back(N.getOperand(i));"); emitCode("}"); From sabre at nondot.org Tue Nov 14 12:43:26 2006 From: sabre at nondot.org (Chris Lattner) Date: Tue, 14 Nov 2006 12:43:26 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp Message-ID: <200611141843.kAEIhQxh026118@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCISelDAGToDAG.cpp updated: 1.218 -> 1.219 --- Log message: remove a ton of custom selection logic no longer needed --- Diffs of the changes: (+7 -145) PPCISelDAGToDAG.cpp | 152 ++-------------------------------------------------- 1 files changed, 7 insertions(+), 145 deletions(-) Index: llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp diff -u llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:1.218 llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:1.219 --- llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:1.218 Fri Nov 10 22:53:30 2006 +++ llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp Tue Nov 14 12:43:11 2006 @@ -190,8 +190,6 @@ private: SDNode *SelectSETCC(SDOperand Op); - SDNode *MySelect_PPCbctrl(SDOperand N); - SDNode *MySelect_PPCcall(SDOperand N); }; } @@ -282,13 +280,15 @@ MachineBasicBlock::iterator MBBI = FirstMBB.begin(); SSARegMap *RegMap = BB->getParent()->getSSARegMap(); - if (PPCLowering.getPointerTy() == MVT::i32) + if (PPCLowering.getPointerTy() == MVT::i32) { GlobalBaseReg = RegMap->createVirtualRegister(PPC::GPRCRegisterClass); - else + BuildMI(FirstMBB, MBBI, PPC::MovePCtoLR, 0, PPC::LR); + BuildMI(FirstMBB, MBBI, PPC::MFLR, 1, GlobalBaseReg); + } else { GlobalBaseReg = RegMap->createVirtualRegister(PPC::G8RCRegisterClass); - - BuildMI(FirstMBB, MBBI, PPC::MovePCtoLR, 0, PPC::LR); - BuildMI(FirstMBB, MBBI, PPC::MFLR, 1, GlobalBaseReg); + BuildMI(FirstMBB, MBBI, PPC::MovePCtoLR8, 0, PPC::LR8); + BuildMI(FirstMBB, MBBI, PPC::MFLR8, 1, GlobalBaseReg); + } } return CurDAG->getRegister(GlobalBaseReg, PPCLowering.getPointerTy()).Val; } @@ -1013,150 +1013,12 @@ Chain), 0); return CurDAG->SelectNodeTo(N, PPC::BCTR, MVT::Other, Chain); } - // FIXME: These are manually selected because tblgen isn't handling varargs - // nodes correctly. - case PPCISD::BCTRL: return MySelect_PPCbctrl(Op); - case PPCISD::CALL: return MySelect_PPCcall(Op); } return SelectCode(Op); } -// FIXME: This is manually selected because tblgen isn't handling varargs nodes -// correctly. -SDNode *PPCDAGToDAGISel::MySelect_PPCbctrl(SDOperand N) { - SDOperand Chain(0, 0); - - bool hasFlag = - N.getOperand(N.getNumOperands()-1).getValueType() == MVT::Flag; - - SmallVector Ops; - // Push varargs arguments, including optional flag. - for (unsigned i = 1, e = N.getNumOperands()-hasFlag; i != e; ++i) { - Chain = N.getOperand(i); - AddToISelQueue(Chain); - Ops.push_back(Chain); - } - - Chain = N.getOperand(0); - AddToISelQueue(Chain); - Ops.push_back(Chain); - - if (hasFlag) { - Chain = N.getOperand(N.getNumOperands()-1); - AddToISelQueue(Chain); - Ops.push_back(Chain); - } - - return CurDAG->getTargetNode(PPC::BCTRL, MVT::Other, MVT::Flag, - &Ops[0], Ops.size()); -} - -// FIXME: This is manually selected because tblgen isn't handling varargs nodes -// correctly. -SDNode *PPCDAGToDAGISel::MySelect_PPCcall(SDOperand N) { - SDOperand Chain(0, 0); - SDOperand N1(0, 0); - SDOperand Tmp0(0, 0); - Chain = N.getOperand(0); - N1 = N.getOperand(1); - - // Pattern: (PPCcall:void (imm:i32):$func) - // Emits: (BLA:void (imm:i32):$func) - // Pattern complexity = 4 cost = 1 - if (N1.getOpcode() == ISD::Constant) { - unsigned Tmp0C = (unsigned)cast(N1)->getValue(); - - SmallVector Ops; - Ops.push_back(CurDAG->getTargetConstant(Tmp0C, MVT::i32)); - - bool hasFlag = - N.getOperand(N.getNumOperands()-1).getValueType() == MVT::Flag; - - // Push varargs arguments, not including optional flag. - for (unsigned i = 2, e = N.getNumOperands()-hasFlag; i != e; ++i) { - Chain = N.getOperand(i); - AddToISelQueue(Chain); - Ops.push_back(Chain); - } - Chain = N.getOperand(0); - AddToISelQueue(Chain); - Ops.push_back(Chain); - if (hasFlag) { - Chain = N.getOperand(N.getNumOperands()-1); - AddToISelQueue(Chain); - Ops.push_back(Chain); - } - return CurDAG->getTargetNode(PPC::BLA, MVT::Other, MVT::Flag, - &Ops[0], Ops.size()); - } - - // Pattern: (PPCcall:void (tglobaladdr:i32):$dst) - // Emits: (BL:void (tglobaladdr:i32):$dst) - // Pattern complexity = 4 cost = 1 - if (N1.getOpcode() == ISD::TargetGlobalAddress) { - SmallVector Ops; - Ops.push_back(N1); - - bool hasFlag = - N.getOperand(N.getNumOperands()-1).getValueType() == MVT::Flag; - - // Push varargs arguments, not including optional flag. - for (unsigned i = 2, e = N.getNumOperands()-hasFlag; i != e; ++i) { - Chain = N.getOperand(i); - AddToISelQueue(Chain); - Ops.push_back(Chain); - } - Chain = N.getOperand(0); - AddToISelQueue(Chain); - Ops.push_back(Chain); - if (hasFlag) { - Chain = N.getOperand(N.getNumOperands()-1); - AddToISelQueue(Chain); - Ops.push_back(Chain); - } - - return CurDAG->getTargetNode(PPC::BL, MVT::Other, MVT::Flag, - &Ops[0], Ops.size()); - } - - // Pattern: (PPCcall:void (texternalsym:i32):$dst) - // Emits: (BL:void (texternalsym:i32):$dst) - // Pattern complexity = 4 cost = 1 - if (N1.getOpcode() == ISD::TargetExternalSymbol) { - std::vector Ops; - Ops.push_back(N1); - - bool hasFlag = - N.getOperand(N.getNumOperands()-1).getValueType() == MVT::Flag; - - // Push varargs arguments, not including optional flag. - for (unsigned i = 2, e = N.getNumOperands()-hasFlag; i != e; ++i) { - Chain = N.getOperand(i); - AddToISelQueue(Chain); - Ops.push_back(Chain); - } - Chain = N.getOperand(0); - AddToISelQueue(Chain); - Ops.push_back(Chain); - if (hasFlag) { - Chain = N.getOperand(N.getNumOperands()-1); - AddToISelQueue(Chain); - Ops.push_back(Chain); - } - - return CurDAG->getTargetNode(PPC::BL, MVT::Other, MVT::Flag, - &Ops[0], Ops.size()); - } - std::cerr << "Cannot yet select: "; - N.Val->dump(CurDAG); - std::cerr << '\n'; - abort(); - - return NULL; -} - /// createPPCISelDag - This pass converts a legalized DAG into a /// PowerPC-specific DAG, ready for instruction scheduling. From sabre at nondot.org Tue Nov 14 12:45:01 2006 From: sabre at nondot.org (Chris Lattner) Date: Tue, 14 Nov 2006 12:45:01 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCCodeEmitter.cpp PPCInstr64Bit.td PPCInstrInfo.td PPCRegisterInfo.cpp PPCRegisterInfo.td Message-ID: <200611141845.kAEIj14L026196@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCCodeEmitter.cpp updated: 1.68 -> 1.69 PPCInstr64Bit.td updated: 1.25 -> 1.26 PPCInstrInfo.td updated: 1.257 -> 1.258 PPCRegisterInfo.cpp updated: 1.81 -> 1.82 PPCRegisterInfo.td updated: 1.38 -> 1.39 --- Log message: Rework PPC64 calls. Now we have a LR8/CTR8 register which the PPC64 calls clobber. This allows LR8 to be save/restored correctly as a 64-bit quantity, instead of handling it as a 32-bit quantity. This unbreaks ppc64 codegen when the code is actually located above the 4G boundary. --- Diffs of the changes: (+107 -38) PPCCodeEmitter.cpp | 1 PPCInstr64Bit.td | 43 ++++++++++++++++++++++++++- PPCInstrInfo.td | 6 ++- PPCRegisterInfo.cpp | 82 ++++++++++++++++++++++++++++++++-------------------- PPCRegisterInfo.td | 13 +++++--- 5 files changed, 107 insertions(+), 38 deletions(-) Index: llvm/lib/Target/PowerPC/PPCCodeEmitter.cpp diff -u llvm/lib/Target/PowerPC/PPCCodeEmitter.cpp:1.68 llvm/lib/Target/PowerPC/PPCCodeEmitter.cpp:1.69 --- llvm/lib/Target/PowerPC/PPCCodeEmitter.cpp:1.68 Thu Nov 2 14:25:49 2006 +++ llvm/lib/Target/PowerPC/PPCCodeEmitter.cpp Tue Nov 14 12:44:47 2006 @@ -102,6 +102,7 @@ case PPC::IMPLICIT_DEF_VRRC: break; // pseudo opcode, no side effects case PPC::MovePCtoLR: + case PPC::MovePCtoLR8: assert(0 && "CodeEmitter does not support MovePCtoLR instruction"); break; } Index: llvm/lib/Target/PowerPC/PPCInstr64Bit.td diff -u llvm/lib/Target/PowerPC/PPCInstr64Bit.td:1.25 llvm/lib/Target/PowerPC/PPCInstr64Bit.td:1.26 --- llvm/lib/Target/PowerPC/PPCInstr64Bit.td:1.25 Sat Nov 11 13:05:28 2006 +++ llvm/lib/Target/PowerPC/PPCInstr64Bit.td Tue Nov 14 12:44:47 2006 @@ -60,11 +60,52 @@ def IMPLICIT_DEF_G8RC : Pseudo<(ops G8RC:$rD), "; IMPLICIT_DEF_G8RC $rD", [(set G8RC:$rD, (undef))]>; + +//===----------------------------------------------------------------------===// +// Calls. +// + +let Defs = [LR8] in + def MovePCtoLR8 : Pseudo<(ops piclabel:$label), "bl $label", []>, + PPC970_Unit_BRU; + +let isCall = 1, noResults = 1, PPC970_Unit = 7, + // All calls clobber the PPC64 non-callee saved registers. + Defs = [X0,X2,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12, + F0,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13, + V0,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11,V12,V13,V14,V15,V16,V17,V18,V19, + LR8,CTR8, + CR0,CR1,CR5,CR6,CR7] in { + // Convenient aliases for call instructions + def BL8 : IForm<18, 0, 1, (ops calltarget:$func, variable_ops), + "bl $func", BrB, []>; // See Pat patterns below. + + def BLA8 : IForm<18, 1, 1, (ops aaddr:$func, variable_ops), + "bla $func", BrB, [(PPCcall (i64 imm:$func))]>; +} + +// Calls +def : Pat<(PPCcall (i64 tglobaladdr:$dst)), + (BL8 tglobaladdr:$dst)>; +def : Pat<(PPCcall (i64 texternalsym:$dst)), + (BL8 texternalsym:$dst)>; + +//===----------------------------------------------------------------------===// +// 64-bit SPR manipulation instrs. + +def MFCTR8 : XFXForm_1_ext<31, 339, 9, (ops G8RC:$rT), "mfctr $rT", SprMFSPR>, + PPC970_DGroup_First, PPC970_Unit_FXU; let Pattern = [(PPCmtctr G8RC:$rS)] in { def MTCTR8 : XFXForm_7_ext<31, 467, 9, (ops G8RC:$rS), "mtctr $rS", SprMTSPR>, - PPC970_DGroup_First, PPC970_Unit_FXU; + PPC970_DGroup_First, PPC970_Unit_FXU; } +def MTLR8 : XFXForm_7_ext<31, 467, 8, (ops G8RC:$rS), "mtlr $rS", SprMTSPR>, + PPC970_DGroup_First, PPC970_Unit_FXU; +def MFLR8 : XFXForm_1_ext<31, 339, 8, (ops G8RC:$rT), "mflr $rT", SprMFSPR>, + PPC970_DGroup_First, PPC970_Unit_FXU; + + //===----------------------------------------------------------------------===// // Fixed point instructions. // Index: llvm/lib/Target/PowerPC/PPCInstrInfo.td diff -u llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.257 llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.258 --- llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.257 Fri Nov 10 22:51:36 2006 +++ llvm/lib/Target/PowerPC/PPCInstrInfo.td Tue Nov 14 12:44:47 2006 @@ -274,6 +274,7 @@ // PowerPC Instruction Predicate Definitions. def FPContractions : Predicate<"!NoExcessFPPrecision">; + //===----------------------------------------------------------------------===// // PowerPC Instruction Definitions. @@ -328,6 +329,7 @@ } + let Defs = [LR] in def MovePCtoLR : Pseudo<(ops piclabel:$label), "bl $label", []>, PPC970_Unit_BRU; @@ -1014,9 +1016,9 @@ (RLWNM GPRC:$in, GPRC:$sh, (MB maskimm32:$imm), (ME maskimm32:$imm))>; // Calls -def : Pat<(PPCcall tglobaladdr:$dst), +def : Pat<(PPCcall (i32 tglobaladdr:$dst)), (BL tglobaladdr:$dst)>; -def : Pat<(PPCcall texternalsym:$dst), +def : Pat<(PPCcall (i32 texternalsym:$dst)), (BL texternalsym:$dst)>; // Hi and Lo for Darwin Global Addresses. Index: llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp diff -u llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.81 llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.82 --- llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.81 Mon Nov 13 17:36:35 2006 +++ llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp Tue Nov 14 12:44:47 2006 @@ -99,12 +99,32 @@ MachineBasicBlock::iterator MI, unsigned SrcReg, int FrameIdx, const TargetRegisterClass *RC) const { - if (SrcReg == PPC::LR) { - // FIXME: this spills LR immediately to memory in one step. To do this, we - // use R11, which we know cannot be used in the prolog/epilog. This is a - // hack. - BuildMI(MBB, MI, PPC::MFLR, 1, PPC::R11); - addFrameReference(BuildMI(MBB, MI, PPC::STW, 3).addReg(PPC::R11), FrameIdx); + if (RC == PPC::GPRCRegisterClass) { + if (SrcReg != PPC::LR) { + addFrameReference(BuildMI(MBB, MI, PPC::STW, 3).addReg(SrcReg),FrameIdx); + } else { + // FIXME: this spills LR immediately to memory in one step. To do this, + // we use R11, which we know cannot be used in the prolog/epilog. This is + // a hack. + BuildMI(MBB, MI, PPC::MFLR, 1, PPC::R11); + addFrameReference(BuildMI(MBB, MI, PPC::STW, 3).addReg(PPC::R11), + FrameIdx); + } + } else if (RC == PPC::G8RCRegisterClass) { + if (SrcReg != PPC::LR8) { + addFrameReference(BuildMI(MBB, MI, PPC::STD, 3).addReg(SrcReg), FrameIdx); + } else { + // FIXME: this spills LR immediately to memory in one step. To do this, + // we use R11, which we know cannot be used in the prolog/epilog. This is + // a hack. + BuildMI(MBB, MI, PPC::MFLR8, 1, PPC::X11); + addFrameReference(BuildMI(MBB, MI, PPC::STD, 3).addReg(PPC::X11), + FrameIdx); + } + } else if (RC == PPC::F8RCRegisterClass) { + addFrameReference(BuildMI(MBB, MI, PPC::STFD, 3).addReg(SrcReg),FrameIdx); + } else if (RC == PPC::F4RCRegisterClass) { + addFrameReference(BuildMI(MBB, MI, PPC::STFS, 3).addReg(SrcReg),FrameIdx); } else if (RC == PPC::CRRCRegisterClass) { // FIXME: We use R0 here, because it isn't available for RA. // We need to store the CR in the low 4-bits of the saved value. First, @@ -121,14 +141,6 @@ } addFrameReference(BuildMI(MBB, MI, PPC::STW, 3).addReg(PPC::R0), FrameIdx); - } else if (RC == PPC::GPRCRegisterClass) { - addFrameReference(BuildMI(MBB, MI, PPC::STW, 3).addReg(SrcReg),FrameIdx); - } else if (RC == PPC::G8RCRegisterClass) { - addFrameReference(BuildMI(MBB, MI, PPC::STD, 3).addReg(SrcReg),FrameIdx); - } else if (RC == PPC::F8RCRegisterClass) { - addFrameReference(BuildMI(MBB, MI, PPC::STFD, 3).addReg(SrcReg),FrameIdx); - } else if (RC == PPC::F4RCRegisterClass) { - addFrameReference(BuildMI(MBB, MI, PPC::STFS, 3).addReg(SrcReg),FrameIdx); } else if (RC == PPC::VRRCRegisterClass) { // We don't have indexed addressing for vector loads. Emit: // R11 = ADDI FI# @@ -146,12 +158,27 @@ void PPCRegisterInfo::loadRegFromStackSlot(MachineBasicBlock &MBB, - MachineBasicBlock::iterator MI, - unsigned DestReg, int FrameIdx, - const TargetRegisterClass *RC) const { - if (DestReg == PPC::LR) { - addFrameReference(BuildMI(MBB, MI, PPC::LWZ, 2, PPC::R11), FrameIdx); - BuildMI(MBB, MI, PPC::MTLR, 1).addReg(PPC::R11); + MachineBasicBlock::iterator MI, + unsigned DestReg, int FrameIdx, + const TargetRegisterClass *RC) const { + if (RC == PPC::GPRCRegisterClass) { + if (DestReg != PPC::LR) { + addFrameReference(BuildMI(MBB, MI, PPC::LWZ, 2, DestReg), FrameIdx); + } else { + addFrameReference(BuildMI(MBB, MI, PPC::LWZ, 2, PPC::R11), FrameIdx); + BuildMI(MBB, MI, PPC::MTLR, 1).addReg(PPC::R11); + } + } else if (RC == PPC::G8RCRegisterClass) { + if (DestReg != PPC::LR8) { + addFrameReference(BuildMI(MBB, MI, PPC::LD, 2, DestReg), FrameIdx); + } else { + addFrameReference(BuildMI(MBB, MI, PPC::LD, 2, PPC::R11), FrameIdx); + BuildMI(MBB, MI, PPC::MTLR8, 1).addReg(PPC::R11); + } + } else if (RC == PPC::F8RCRegisterClass) { + addFrameReference(BuildMI(MBB, MI, PPC::LFD, 2, DestReg), FrameIdx); + } else if (RC == PPC::F4RCRegisterClass) { + addFrameReference(BuildMI(MBB, MI, PPC::LFS, 2, DestReg), FrameIdx); } else if (RC == PPC::CRRCRegisterClass) { // FIXME: We use R0 here, because it isn't available for RA. addFrameReference(BuildMI(MBB, MI, PPC::LWZ, 2, PPC::R0), FrameIdx); @@ -166,14 +193,6 @@ } BuildMI(MBB, MI, PPC::MTCRF, 1, DestReg).addReg(PPC::R0); - } else if (RC == PPC::GPRCRegisterClass) { - addFrameReference(BuildMI(MBB, MI, PPC::LWZ, 2, DestReg), FrameIdx); - } else if (RC == PPC::G8RCRegisterClass) { - addFrameReference(BuildMI(MBB, MI, PPC::LD, 2, DestReg), FrameIdx); - } else if (RC == PPC::F8RCRegisterClass) { - addFrameReference(BuildMI(MBB, MI, PPC::LFD, 2, DestReg), FrameIdx); - } else if (RC == PPC::F4RCRegisterClass) { - addFrameReference(BuildMI(MBB, MI, PPC::LFS, 2, DestReg), FrameIdx); } else if (RC == PPC::VRRCRegisterClass) { // We don't have indexed addressing for vector loads. Emit: // R11 = ADDI FI# @@ -251,7 +270,7 @@ PPC::V24, PPC::V25, PPC::V26, PPC::V27, PPC::V28, PPC::V29, PPC::V30, PPC::V31, - PPC::LR, 0 + PPC::LR8, 0 }; return Subtarget.isPPC64() ? Darwin64_CalleeSaveRegs : @@ -303,7 +322,7 @@ &PPC::VRRCRegClass,&PPC::VRRCRegClass,&PPC::VRRCRegClass,&PPC::VRRCRegClass, &PPC::VRRCRegClass,&PPC::VRRCRegClass,&PPC::VRRCRegClass,&PPC::VRRCRegClass, - &PPC::GPRCRegClass, 0 + &PPC::G8RCRegClass, 0 }; return Subtarget.isPPC64() ? Darwin64_CalleeSaveRegClasses : @@ -780,7 +799,8 @@ } unsigned PPCRegisterInfo::getRARegister() const { - return PPC::LR; + return !Subtarget.isPPC64() ? PPC::LR : PPC::LR8; + } unsigned PPCRegisterInfo::getFrameRegister(MachineFunction &MF) const { Index: llvm/lib/Target/PowerPC/PPCRegisterInfo.td diff -u llvm/lib/Target/PowerPC/PPCRegisterInfo.td:1.38 llvm/lib/Target/PowerPC/PPCRegisterInfo.td:1.39 --- llvm/lib/Target/PowerPC/PPCRegisterInfo.td:1.38 Thu Aug 17 17:00:08 2006 +++ llvm/lib/Target/PowerPC/PPCRegisterInfo.td Tue Nov 14 12:44:47 2006 @@ -195,8 +195,13 @@ // Link register def LR : SPR<8, "lr">, DwarfRegNum<65>; +//let Aliases = [LR] in +def LR8 : SPR<8, "lr">, DwarfRegNum<65>; + // Count register -def CTR : SPR<9, "ctr">, DwarfRegNum<66>; +def CTR : SPR<9, "ctr">, DwarfRegNum<66>; +def CTR8 : SPR<9, "ctr">, DwarfRegNum<66>; + // VRsave register def VRSAVE: SPR<256, "VRsave">, DwarfRegNum<107>; @@ -229,7 +234,7 @@ def G8RC : RegisterClass<"PPC", [i64], 64, [X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X30, X29, X28, X27, X26, X25, X24, X23, X22, X21, X20, X19, X18, X17, - X16, X15, X14, X13, X31, X0, X1]> + X16, X15, X14, X13, X31, X0, X1, LR8]> { let MethodProtos = [{ iterator allocation_order_begin(const MachineFunction &MF) const; @@ -243,9 +248,9 @@ G8RCClass::iterator G8RCClass::allocation_order_end(const MachineFunction &MF) const { if (hasFP(MF)) - return end()-3; + return end()-4; else - return end()-2; + return end()-3; } }]; } From sabre at nondot.org Tue Nov 14 13:13:54 2006 From: sabre at nondot.org (Chris Lattner) Date: Tue, 14 Nov 2006 13:13:54 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/TargetSelectionDAG.td Message-ID: <200611141913.kAEJDsNH026724@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target: TargetSelectionDAG.td updated: 1.76 -> 1.77 --- Log message: Fix predicates for unindexed stores so they don't accidentally match indexed stores. --- Diffs of the changes: (+39 -33) TargetSelectionDAG.td | 72 +++++++++++++++++++++++++++----------------------- 1 files changed, 39 insertions(+), 33 deletions(-) Index: llvm/lib/Target/TargetSelectionDAG.td diff -u llvm/lib/Target/TargetSelectionDAG.td:1.76 llvm/lib/Target/TargetSelectionDAG.td:1.77 --- llvm/lib/Target/TargetSelectionDAG.td:1.76 Thu Nov 9 12:44:21 2006 +++ llvm/lib/Target/TargetSelectionDAG.td Tue Nov 14 13:13:39 2006 @@ -408,7 +408,7 @@ def load : PatFrag<(ops node:$ptr), (ld node:$ptr), [{ if (LoadSDNode *LD = dyn_cast(N)) return LD->getExtensionType() == ISD::NON_EXTLOAD && - LD->getAddressingMode() == ISD::UNINDEXED; + LD->getAddressingMode() == ISD::UNINDEXED; return false; }]>; @@ -416,94 +416,94 @@ def extloadi1 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{ if (LoadSDNode *LD = dyn_cast(N)) return LD->getExtensionType() == ISD::EXTLOAD && - LD->getAddressingMode() == ISD::UNINDEXED && - LD->getLoadedVT() == MVT::i1; + LD->getAddressingMode() == ISD::UNINDEXED && + LD->getLoadedVT() == MVT::i1; return false; }]>; def extloadi8 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{ if (LoadSDNode *LD = dyn_cast(N)) return LD->getExtensionType() == ISD::EXTLOAD && - LD->getAddressingMode() == ISD::UNINDEXED && - LD->getLoadedVT() == MVT::i8; + LD->getAddressingMode() == ISD::UNINDEXED && + LD->getLoadedVT() == MVT::i8; return false; }]>; def extloadi16 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{ if (LoadSDNode *LD = dyn_cast(N)) return LD->getExtensionType() == ISD::EXTLOAD && - LD->getAddressingMode() == ISD::UNINDEXED && - LD->getLoadedVT() == MVT::i16; + LD->getAddressingMode() == ISD::UNINDEXED && + LD->getLoadedVT() == MVT::i16; return false; }]>; def extloadi32 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{ if (LoadSDNode *LD = dyn_cast(N)) return LD->getExtensionType() == ISD::EXTLOAD && - LD->getAddressingMode() == ISD::UNINDEXED && - LD->getLoadedVT() == MVT::i32; + LD->getAddressingMode() == ISD::UNINDEXED && + LD->getLoadedVT() == MVT::i32; return false; }]>; def extloadf32 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{ if (LoadSDNode *LD = dyn_cast(N)) return LD->getExtensionType() == ISD::EXTLOAD && - LD->getAddressingMode() == ISD::UNINDEXED && - LD->getLoadedVT() == MVT::f32; + LD->getAddressingMode() == ISD::UNINDEXED && + LD->getLoadedVT() == MVT::f32; return false; }]>; def sextloadi1 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{ if (LoadSDNode *LD = dyn_cast(N)) return LD->getExtensionType() == ISD::SEXTLOAD && - LD->getAddressingMode() == ISD::UNINDEXED && - LD->getLoadedVT() == MVT::i1; + LD->getAddressingMode() == ISD::UNINDEXED && + LD->getLoadedVT() == MVT::i1; return false; }]>; def sextloadi8 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{ if (LoadSDNode *LD = dyn_cast(N)) return LD->getExtensionType() == ISD::SEXTLOAD && - LD->getAddressingMode() == ISD::UNINDEXED && - LD->getLoadedVT() == MVT::i8; + LD->getAddressingMode() == ISD::UNINDEXED && + LD->getLoadedVT() == MVT::i8; return false; }]>; def sextloadi16 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{ if (LoadSDNode *LD = dyn_cast(N)) return LD->getExtensionType() == ISD::SEXTLOAD && - LD->getAddressingMode() == ISD::UNINDEXED && - LD->getLoadedVT() == MVT::i16; + LD->getAddressingMode() == ISD::UNINDEXED && + LD->getLoadedVT() == MVT::i16; return false; }]>; def sextloadi32 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{ if (LoadSDNode *LD = dyn_cast(N)) return LD->getExtensionType() == ISD::SEXTLOAD && - LD->getAddressingMode() == ISD::UNINDEXED && - LD->getLoadedVT() == MVT::i32; + LD->getAddressingMode() == ISD::UNINDEXED && + LD->getLoadedVT() == MVT::i32; return false; }]>; def zextloadi1 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{ if (LoadSDNode *LD = dyn_cast(N)) return LD->getExtensionType() == ISD::ZEXTLOAD && - LD->getAddressingMode() == ISD::UNINDEXED && - LD->getLoadedVT() == MVT::i1; + LD->getAddressingMode() == ISD::UNINDEXED && + LD->getLoadedVT() == MVT::i1; return false; }]>; def zextloadi8 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{ if (LoadSDNode *LD = dyn_cast(N)) return LD->getExtensionType() == ISD::ZEXTLOAD && - LD->getAddressingMode() == ISD::UNINDEXED && - LD->getLoadedVT() == MVT::i8; + LD->getAddressingMode() == ISD::UNINDEXED && + LD->getLoadedVT() == MVT::i8; return false; }]>; def zextloadi16 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{ if (LoadSDNode *LD = dyn_cast(N)) return LD->getExtensionType() == ISD::ZEXTLOAD && - LD->getAddressingMode() == ISD::UNINDEXED && - LD->getLoadedVT() == MVT::i16; + LD->getAddressingMode() == ISD::UNINDEXED && + LD->getLoadedVT() == MVT::i16; return false; }]>; def zextloadi32 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{ if (LoadSDNode *LD = dyn_cast(N)) return LD->getExtensionType() == ISD::ZEXTLOAD && - LD->getAddressingMode() == ISD::UNINDEXED && - LD->getLoadedVT() == MVT::i32; + LD->getAddressingMode() == ISD::UNINDEXED && + LD->getLoadedVT() == MVT::i32; return false; }]>; @@ -511,7 +511,8 @@ def store : PatFrag<(ops node:$val, node:$ptr), (st node:$val, node:$ptr), [{ if (StoreSDNode *ST = dyn_cast(N)) - return !ST->isTruncatingStore(); + return !ST->isTruncatingStore() && + ST->getAddressingMode() == ISD::UNINDEXED; return false; }]>; @@ -519,31 +520,36 @@ def truncstorei1 : PatFrag<(ops node:$val, node:$ptr), (st node:$val, node:$ptr), [{ if (StoreSDNode *ST = dyn_cast(N)) - return ST->isTruncatingStore() && ST->getStoredVT() == MVT::i1; + return ST->isTruncatingStore() && ST->getStoredVT() == MVT::i1 && + ST->getAddressingMode() == ISD::UNINDEXED; return false; }]>; def truncstorei8 : PatFrag<(ops node:$val, node:$ptr), (st node:$val, node:$ptr), [{ if (StoreSDNode *ST = dyn_cast(N)) - return ST->isTruncatingStore() && ST->getStoredVT() == MVT::i8; + return ST->isTruncatingStore() && ST->getStoredVT() == MVT::i8 && + ST->getAddressingMode() == ISD::UNINDEXED; return false; }]>; def truncstorei16 : PatFrag<(ops node:$val, node:$ptr), (st node:$val, node:$ptr), [{ if (StoreSDNode *ST = dyn_cast(N)) - return ST->isTruncatingStore() && ST->getStoredVT() == MVT::i16; + return ST->isTruncatingStore() && ST->getStoredVT() == MVT::i16 && + ST->getAddressingMode() == ISD::UNINDEXED; return false; }]>; def truncstorei32 : PatFrag<(ops node:$val, node:$ptr), (st node:$val, node:$ptr), [{ if (StoreSDNode *ST = dyn_cast(N)) - return ST->isTruncatingStore() && ST->getStoredVT() == MVT::i32; + return ST->isTruncatingStore() && ST->getStoredVT() == MVT::i32 && + ST->getAddressingMode() == ISD::UNINDEXED; return false; }]>; def truncstoref32 : PatFrag<(ops node:$val, node:$ptr), (st node:$val, node:$ptr), [{ if (StoreSDNode *ST = dyn_cast(N)) - return ST->isTruncatingStore() && ST->getStoredVT() == MVT::f32; + return ST->isTruncatingStore() && ST->getStoredVT() == MVT::f32 && + ST->getAddressingMode() == ISD::UNINDEXED; return false; }]>; From sabre at nondot.org Tue Nov 14 13:20:07 2006 From: sabre at nondot.org (Chris Lattner) Date: Tue, 14 Nov 2006 13:20:07 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCInstrInfo.td Message-ID: <200611141920.kAEJK7Ar026905@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCInstrInfo.td updated: 1.258 -> 1.259 --- Log message: group load and store instructions together. No functionality change. --- Diffs of the changes: (+110 -99) PPCInstrInfo.td | 209 +++++++++++++++++++++++++++++--------------------------- 1 files changed, 110 insertions(+), 99 deletions(-) Index: llvm/lib/Target/PowerPC/PPCInstrInfo.td diff -u llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.258 llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.259 --- llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.258 Tue Nov 14 12:44:47 2006 +++ llvm/lib/Target/PowerPC/PPCInstrInfo.td Tue Nov 14 13:19:53 2006 @@ -405,10 +405,12 @@ def DCBZL : DCB_Form<1014, 1, (ops memrr:$dst), "dcbzl $dst", LdStDCBF, [(int_ppc_dcbzl xoaddr:$dst)]>, PPC970_DGroup_Single; - -// D-Form instructions. Most instructions that perform an operation on a -// register and an immediate are of this type. + +//===----------------------------------------------------------------------===// +// PPC32 Load Instructions. // + +// Unindexed (r+i) Loads. let isLoad = 1, PPC970_Unit = 2 in { def LBZ : DForm_1<34, (ops GPRC:$rD, memri:$src), "lbz $rD, $src", LdStGeneral, @@ -431,7 +433,6 @@ "lfd $rD, $src", LdStLFD, [(set F8RC:$rD, (load iaddr:$src))]>; -// FIXME: PTRRC for Pointer regs for ppc64. // 'Update' load forms. def LBZU : DForm_1<35, (ops GPRC:$rD, ptr_rc:$rA_result, symbolLo:$disp, @@ -464,6 +465,108 @@ []>, RegConstraint<"$rA = $rA_result">; } +// Indexed (r+r) loads. +// +let isLoad = 1, PPC970_Unit = 2 in { +def LBZX : XForm_1<31, 87, (ops GPRC:$rD, memrr:$src), + "lbzx $rD, $src", LdStGeneral, + [(set GPRC:$rD, (zextloadi8 xaddr:$src))]>; +def LHAX : XForm_1<31, 343, (ops GPRC:$rD, memrr:$src), + "lhax $rD, $src", LdStLHA, + [(set GPRC:$rD, (sextloadi16 xaddr:$src))]>, + PPC970_DGroup_Cracked; +def LHZX : XForm_1<31, 279, (ops GPRC:$rD, memrr:$src), + "lhzx $rD, $src", LdStGeneral, + [(set GPRC:$rD, (zextloadi16 xaddr:$src))]>; +def LWZX : XForm_1<31, 23, (ops GPRC:$rD, memrr:$src), + "lwzx $rD, $src", LdStGeneral, + [(set GPRC:$rD, (load xaddr:$src))]>; + + +def LHBRX : XForm_1<31, 790, (ops GPRC:$rD, memrr:$src), + "lhbrx $rD, $src", LdStGeneral, + [(set GPRC:$rD, (PPClbrx xoaddr:$src, srcvalue:$sv, i16))]>; +def LWBRX : XForm_1<31, 534, (ops GPRC:$rD, memrr:$src), + "lwbrx $rD, $src", LdStGeneral, + [(set GPRC:$rD, (PPClbrx xoaddr:$src, srcvalue:$sv, i32))]>; + +def LFSX : XForm_25<31, 535, (ops F4RC:$frD, memrr:$src), + "lfsx $frD, $src", LdStLFDU, + [(set F4RC:$frD, (load xaddr:$src))]>; +def LFDX : XForm_25<31, 599, (ops F8RC:$frD, memrr:$src), + "lfdx $frD, $src", LdStLFDU, + [(set F8RC:$frD, (load xaddr:$src))]>; +} + +//===----------------------------------------------------------------------===// +// PPC32 Store Instructions. +// + +// Unindexed (r+i) Stores. +let isStore = 1, noResults = 1, PPC970_Unit = 2 in { +def STB : DForm_3<38, (ops GPRC:$rS, memri:$src), + "stb $rS, $src", LdStGeneral, + [(truncstorei8 GPRC:$rS, iaddr:$src)]>; +def STH : DForm_3<44, (ops GPRC:$rS, memri:$src), + "sth $rS, $src", LdStGeneral, + [(truncstorei16 GPRC:$rS, iaddr:$src)]>; +def STW : DForm_3<36, (ops GPRC:$rS, memri:$src), + "stw $rS, $src", LdStGeneral, + [(store GPRC:$rS, iaddr:$src)]>; +def STWU : DForm_3<37, (ops GPRC:$rS, s16imm:$disp, GPRC:$rA), + "stwu $rS, $disp($rA)", LdStGeneral, + []>; + +def STFS : DForm_1<52, (ops F4RC:$rS, memri:$dst), + "stfs $rS, $dst", LdStUX, + [(store F4RC:$rS, iaddr:$dst)]>; +def STFD : DForm_1<54, (ops F8RC:$rS, memri:$dst), + "stfd $rS, $dst", LdStUX, + [(store F8RC:$rS, iaddr:$dst)]>; +} + +// Indexed (r+r) Stores. +// +let isStore = 1, noResults = 1, PPC970_Unit = 2 in { +def STBX : XForm_8<31, 215, (ops GPRC:$rS, memrr:$dst), + "stbx $rS, $dst", LdStGeneral, + [(truncstorei8 GPRC:$rS, xaddr:$dst)]>, + PPC970_DGroup_Cracked; +def STHX : XForm_8<31, 407, (ops GPRC:$rS, memrr:$dst), + "sthx $rS, $dst", LdStGeneral, + [(truncstorei16 GPRC:$rS, xaddr:$dst)]>, + PPC970_DGroup_Cracked; +def STWX : XForm_8<31, 151, (ops GPRC:$rS, memrr:$dst), + "stwx $rS, $dst", LdStGeneral, + [(store GPRC:$rS, xaddr:$dst)]>, + PPC970_DGroup_Cracked; +def STWUX : XForm_8<31, 183, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB), + "stwux $rS, $rA, $rB", LdStGeneral, + []>; +def STHBRX: XForm_8<31, 918, (ops GPRC:$rS, memrr:$dst), + "sthbrx $rS, $dst", LdStGeneral, + [(PPCstbrx GPRC:$rS, xoaddr:$dst, srcvalue:$dummy, i16)]>, + PPC970_DGroup_Cracked; +def STWBRX: XForm_8<31, 662, (ops GPRC:$rS, memrr:$dst), + "stwbrx $rS, $dst", LdStGeneral, + [(PPCstbrx GPRC:$rS, xoaddr:$dst, srcvalue:$dummy, i32)]>, + PPC970_DGroup_Cracked; + +def STFIWX: XForm_28<31, 983, (ops F8RC:$frS, memrr:$dst), + "stfiwx $frS, $dst", LdStUX, + [(PPCstfiwx F8RC:$frS, xoaddr:$dst)]>; +def STFSX : XForm_28<31, 663, (ops F4RC:$frS, memrr:$dst), + "stfsx $frS, $dst", LdStUX, + [(store F4RC:$frS, xaddr:$dst)]>; +def STFDX : XForm_28<31, 727, (ops F8RC:$frS, memrr:$dst), + "stfdx $frS, $dst", LdStUX, + [(store F8RC:$frS, xaddr:$dst)]>; +} + + +//===----------------------------------------------------------------------===// +// PPC32 Arithmetic Instructions. +// let PPC970_Unit = 1 in { // FXU Operations. def ADDI : DForm_2<14, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm), @@ -496,20 +599,7 @@ "lis $rD, $imm", IntGeneral, [(set GPRC:$rD, imm16ShiftedSExt:$imm)]>; } -let isStore = 1, noResults = 1, PPC970_Unit = 2 in { -def STB : DForm_3<38, (ops GPRC:$rS, memri:$src), - "stb $rS, $src", LdStGeneral, - [(truncstorei8 GPRC:$rS, iaddr:$src)]>; -def STH : DForm_3<44, (ops GPRC:$rS, memri:$src), - "sth $rS, $src", LdStGeneral, - [(truncstorei16 GPRC:$rS, iaddr:$src)]>; -def STW : DForm_3<36, (ops GPRC:$rS, memri:$src), - "stw $rS, $src", LdStGeneral, - [(store GPRC:$rS, iaddr:$src)]>; -def STWU : DForm_3<37, (ops GPRC:$rS, s16imm:$disp, GPRC:$rA), - "stwu $rS, $disp($rA)", LdStGeneral, - []>; -} + let PPC970_Unit = 1 in { // FXU Operations. def ANDIo : DForm_4<28, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2), "andi. $dst, $src1, $src2", IntGeneral, @@ -538,42 +628,7 @@ def CMPLWI : DForm_6_ext<10, (ops CRRC:$dst, GPRC:$src1, u16imm:$src2), "cmplwi $dst, $src1, $src2", IntCompare>; } -let isStore = 1, noResults = 1, PPC970_Unit = 2 in { -def STFS : DForm_1<52, (ops F4RC:$rS, memri:$dst), - "stfs $rS, $dst", LdStUX, - [(store F4RC:$rS, iaddr:$dst)]>; -def STFD : DForm_1<54, (ops F8RC:$rS, memri:$dst), - "stfd $rS, $dst", LdStUX, - [(store F8RC:$rS, iaddr:$dst)]>; -} - -// X-Form instructions. Most instructions that perform an operation on a -// register and another register are of this type. -// -let isLoad = 1, PPC970_Unit = 2 in { -def LBZX : XForm_1<31, 87, (ops GPRC:$rD, memrr:$src), - "lbzx $rD, $src", LdStGeneral, - [(set GPRC:$rD, (zextloadi8 xaddr:$src))]>; -def LHAX : XForm_1<31, 343, (ops GPRC:$rD, memrr:$src), - "lhax $rD, $src", LdStLHA, - [(set GPRC:$rD, (sextloadi16 xaddr:$src))]>, - PPC970_DGroup_Cracked; -def LHZX : XForm_1<31, 279, (ops GPRC:$rD, memrr:$src), - "lhzx $rD, $src", LdStGeneral, - [(set GPRC:$rD, (zextloadi16 xaddr:$src))]>; -def LWZX : XForm_1<31, 23, (ops GPRC:$rD, memrr:$src), - "lwzx $rD, $src", LdStGeneral, - [(set GPRC:$rD, (load xaddr:$src))]>; - - -def LHBRX : XForm_1<31, 790, (ops GPRC:$rD, memrr:$src), - "lhbrx $rD, $src", LdStGeneral, - [(set GPRC:$rD, (PPClbrx xoaddr:$src, srcvalue:$sv, i16))]>; -def LWBRX : XForm_1<31, 534, (ops GPRC:$rD, memrr:$src), - "lwbrx $rD, $src", LdStGeneral, - [(set GPRC:$rD, (PPClbrx xoaddr:$src, srcvalue:$sv, i32))]>; -} let PPC970_Unit = 1 in { // FXU Operations. def NAND : XForm_6<31, 476, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB), @@ -610,31 +665,7 @@ "sraw $rA, $rS, $rB", IntShift, [(set GPRC:$rA, (PPCsra GPRC:$rS, GPRC:$rB))]>; } -let isStore = 1, noResults = 1, PPC970_Unit = 2 in { -def STBX : XForm_8<31, 215, (ops GPRC:$rS, memrr:$dst), - "stbx $rS, $dst", LdStGeneral, - [(truncstorei8 GPRC:$rS, xaddr:$dst)]>, - PPC970_DGroup_Cracked; -def STHX : XForm_8<31, 407, (ops GPRC:$rS, memrr:$dst), - "sthx $rS, $dst", LdStGeneral, - [(truncstorei16 GPRC:$rS, xaddr:$dst)]>, - PPC970_DGroup_Cracked; -def STWX : XForm_8<31, 151, (ops GPRC:$rS, memrr:$dst), - "stwx $rS, $dst", LdStGeneral, - [(store GPRC:$rS, xaddr:$dst)]>, - PPC970_DGroup_Cracked; -def STWUX : XForm_8<31, 183, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB), - "stwux $rS, $rA, $rB", LdStGeneral, - []>; -def STHBRX: XForm_8<31, 918, (ops GPRC:$rS, memrr:$dst), - "sthbrx $rS, $dst", LdStGeneral, - [(PPCstbrx GPRC:$rS, xoaddr:$dst, srcvalue:$dummy, i16)]>, - PPC970_DGroup_Cracked; -def STWBRX: XForm_8<31, 662, (ops GPRC:$rS, memrr:$dst), - "stwbrx $rS, $dst", LdStGeneral, - [(PPCstbrx GPRC:$rS, xoaddr:$dst, srcvalue:$dummy, i32)]>, - PPC970_DGroup_Cracked; -} + let PPC970_Unit = 1 in { // FXU Operations. def SRAWI : XForm_10<31, 824, (ops GPRC:$rA, GPRC:$rS, u5imm:$SH), "srawi $rA, $rS, $SH", IntShift, @@ -661,16 +692,7 @@ "fcmpu $crD, $fA, $fB", FPCompare>; def FCMPUD : XForm_17<63, 0, (ops CRRC:$crD, F8RC:$fA, F8RC:$fB), "fcmpu $crD, $fA, $fB", FPCompare>; -} -let isLoad = 1, PPC970_Unit = 2 in { -def LFSX : XForm_25<31, 535, (ops F4RC:$frD, memrr:$src), - "lfsx $frD, $src", LdStLFDU, - [(set F4RC:$frD, (load xaddr:$src))]>; -def LFDX : XForm_25<31, 599, (ops F8RC:$frD, memrr:$src), - "lfdx $frD, $src", LdStLFDU, - [(set F8RC:$frD, (load xaddr:$src))]>; -} -let PPC970_Unit = 3 in { // FPU Operations. + def FCTIWZ : XForm_26<63, 15, (ops F8RC:$frD, F8RC:$frB), "fctiwz $frD, $frB", FPGeneral, [(set F8RC:$frD, (PPCfctiwz F8RC:$frB))]>; @@ -726,17 +748,6 @@ [(set F8RC:$frD, (fneg F8RC:$frB))]>; } -let isStore = 1, noResults = 1, PPC970_Unit = 2 in { -def STFIWX: XForm_28<31, 983, (ops F8RC:$frS, memrr:$dst), - "stfiwx $frS, $dst", LdStUX, - [(PPCstfiwx F8RC:$frS, xoaddr:$dst)]>; -def STFSX : XForm_28<31, 663, (ops F4RC:$frS, memrr:$dst), - "stfsx $frS, $dst", LdStUX, - [(store F4RC:$frS, xaddr:$dst)]>; -def STFDX : XForm_28<31, 727, (ops F8RC:$frS, memrr:$dst), - "stfdx $frS, $dst", LdStUX, - [(store F8RC:$frS, xaddr:$dst)]>; -} // XL-Form instructions. condition register logical ops. // From evan.cheng at apple.com Tue Nov 14 13:20:48 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 14 Nov 2006 13:20:48 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86FloatingPoint.cpp Message-ID: <200611141920.kAEJKmD1026929@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86FloatingPoint.cpp updated: 1.58 -> 1.59 --- Log message: Revert. This wasn't meant to be checked in. --- Diffs of the changes: (+18 -11) X86FloatingPoint.cpp | 29 ++++++++++++++++++----------- 1 files changed, 18 insertions(+), 11 deletions(-) Index: llvm/lib/Target/X86/X86FloatingPoint.cpp diff -u llvm/lib/Target/X86/X86FloatingPoint.cpp:1.58 llvm/lib/Target/X86/X86FloatingPoint.cpp:1.59 --- llvm/lib/Target/X86/X86FloatingPoint.cpp:1.58 Mon Nov 13 17:36:35 2006 +++ llvm/lib/Target/X86/X86FloatingPoint.cpp Tue Nov 14 13:20:33 2006 @@ -40,7 +40,6 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/Compiler.h" #include "llvm/ADT/DepthFirstIterator.h" -#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/STLExtras.h" #include @@ -214,12 +213,20 @@ // Get dead variables list now because the MI pointer may be deleted as part // of processing! - SmallVector DeadRegs; - for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { - const MachineOperand &MO = MI->getOperand(i); - if (MO.isReg() && MO.isDead()) - DeadRegs.push_back(MO.getReg()); - } + LiveVariables::killed_iterator IB, IE; + tie(IB, IE) = LV->dead_range(MI); + + DEBUG( + const MRegisterInfo *MRI = MF.getTarget().getRegisterInfo(); + LiveVariables::killed_iterator I = LV->killed_begin(MI); + LiveVariables::killed_iterator E = LV->killed_end(MI); + if (I != E) { + std::cerr << "Killed Operands:"; + for (; I != E; ++I) + std::cerr << " %" << MRI->getName(*I); + std::cerr << "\n"; + } + ); switch (Flags & X86II::FPTypeMask) { case X86II::ZeroArgFP: handleZeroArgFP(I); break; @@ -234,8 +241,8 @@ // Check to see if any of the values defined by this instruction are dead // after definition. If so, pop them. - for (unsigned i = 0, e = DeadRegs.size(); i != e; ++i) { - unsigned Reg = DeadRegs[i]; + for (; IB != IE; ++IB) { + unsigned Reg = *IB; if (Reg >= X86::FP0 && Reg <= X86::FP6) { DEBUG(std::cerr << "Register FP#" << Reg-X86::FP0 << " is dead!\n"); freeStackSlotAfter(I, Reg-X86::FP0); @@ -755,7 +762,6 @@ unsigned Op0 = getFPReg(MI->getOperand(0)); unsigned Op1 = getFPReg(MI->getOperand(2)); - bool KillsOp1 = LV->KillsRegister(MI, X86::FP0+Op1); // The first operand *must* be on the top of the stack. moveToTop(Op0, I); @@ -767,8 +773,9 @@ MI->getOperand(0).setReg(getSTReg(Op1)); MI->setOpcode(getConcreteOpcode(MI->getOpcode())); + // If we kill the second operand, make sure to pop it from the stack. - if (Op0 != Op1 && KillsOp1) { + if (Op0 != Op1 && LV->KillsRegister(MI, X86::FP0+Op1)) { // Get this value off of the register stack. freeStackSlotAfter(I, Op1); } From sabre at nondot.org Tue Nov 14 15:18:54 2006 From: sabre at nondot.org (Chris Lattner) Date: Tue, 14 Nov 2006 15:18:54 -0600 Subject: [llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp Message-ID: <200611142118.kAELIsBG028809@zion.cs.uiuc.edu> Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.282 -> 1.283 --- Log message: changes to get ptr_rc to be accepted in patterns. This is needed for ppc preinc stores. --- Diffs of the changes: (+22 -8) DAGISelEmitter.cpp | 30 ++++++++++++++++++++++-------- 1 files changed, 22 insertions(+), 8 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.282 llvm/utils/TableGen/DAGISelEmitter.cpp:1.283 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.282 Tue Nov 14 12:41:38 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Tue Nov 14 15:18:40 2006 @@ -618,6 +618,9 @@ std::vector ComplexPat(1, TP.getDAGISelEmitter().getComplexPattern(R).getValueType()); return ComplexPat; + } else if (R->getName() == "ptr_rc") { + Other[0] = MVT::iPTR; + return Other; } else if (R->getName() == "node" || R->getName() == "srcvalue") { // Placeholder. return Unknown; @@ -747,16 +750,23 @@ CodeGenInstruction &InstInfo = ISE.getTargetInfo().getInstruction(getOperator()->getName()); // Apply the result type to the node - if (NumResults == 0 || InstInfo.noResults) { // FIXME: temporary hack... + if (NumResults == 0 || InstInfo.noResults) { // FIXME: temporary hack. MadeChange = UpdateNodeType(MVT::isVoid, TP); } else { Record *ResultNode = Inst.getResult(0); - assert(ResultNode->isSubClassOf("RegisterClass") && - "Operands should be register classes!"); + + if (ResultNode->getName() == "ptr_rc") { + std::vector VT; + VT.push_back(MVT::iPTR); + MadeChange = UpdateNodeType(VT, TP); + } else { + assert(ResultNode->isSubClassOf("RegisterClass") && + "Operands should be register classes!"); - const CodeGenRegisterClass &RC = - ISE.getTargetInfo().getRegisterClass(ResultNode); - MadeChange = UpdateNodeType(ConvertVTs(RC.getValueTypes()), TP); + const CodeGenRegisterClass &RC = + ISE.getTargetInfo().getRegisterClass(ResultNode); + MadeChange = UpdateNodeType(ConvertVTs(RC.getValueTypes()), TP); + } } unsigned ChildNo = 0; @@ -782,6 +792,8 @@ } else if (OperandNode->isSubClassOf("Operand")) { VT = getValueType(OperandNode->getValueAsDef("Type")); MadeChange |= Child->UpdateNodeType(VT, TP); + } else if (OperandNode->getName() == "ptr_rc") { + MadeChange |= Child->UpdateNodeType(MVT::iPTR, TP); } else { assert(0 && "Unknown operand type!"); abort(); @@ -1381,7 +1393,8 @@ if (!Val) I->error("set destination should be a register!"); - if (Val->getDef()->isSubClassOf("RegisterClass")) { + if (Val->getDef()->isSubClassOf("RegisterClass") || + Val->getDef()->getName() == "ptr_rc") { if (Dest->getName().empty()) I->error("set destination must have a name!"); if (InstResults.count(Dest->getName())) @@ -2507,7 +2520,8 @@ // Handle leaves of various types. if (DefInit *DI = dynamic_cast(Child->getLeafValue())) { Record *LeafRec = DI->getDef(); - if (LeafRec->isSubClassOf("RegisterClass")) { + if (LeafRec->isSubClassOf("RegisterClass") || + LeafRec->getName() == "ptr_rc") { // Handle register references. Nothing to do here. } else if (LeafRec->isSubClassOf("Register")) { // Handle register references. From sabre at nondot.org Tue Nov 14 15:32:15 2006 From: sabre at nondot.org (Chris Lattner) Date: Tue, 14 Nov 2006 15:32:15 -0600 Subject: [llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp Message-ID: <200611142132.kAELWFwG029058@zion.cs.uiuc.edu> Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.283 -> 1.284 --- Log message: Add support for nodes that return iPTR. --- Diffs of the changes: (+6 -4) DAGISelEmitter.cpp | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.283 llvm/utils/TableGen/DAGISelEmitter.cpp:1.284 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.283 Tue Nov 14 15:18:40 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Tue Nov 14 15:32:01 2006 @@ -3601,8 +3601,11 @@ } // Print function. - std::string OpVTStr = (OpVT != MVT::isVoid && OpVT != MVT::iPTR) - ? getEnumName(OpVT).substr(5) : "" ; + std::string OpVTStr; + if (OpVT == MVT::iPTR) + OpVTStr = "iPTR"; + else + OpVTStr = getEnumName(OpVT).substr(5); // Skip 'MVT::' std::map >::iterator OpVTI = OpcodeVTMap.find(OpName); if (OpVTI == OpcodeVTMap.end()) { @@ -3613,8 +3616,7 @@ OpVTI->second.push_back(OpVTStr); OS << "SDNode *Select_" << getLegalCName(OpName) - << (OpVTStr != "" ? "_" : "") - << OpVTStr << "(const SDOperand &N) {\n"; + << "_" << OpVTStr << "(const SDOperand &N) {\n"; // Loop through and reverse all of the CodeList vectors, as we will be // accessing them from their logical front, but accessing the end of a From sabre at nondot.org Tue Nov 14 15:41:49 2006 From: sabre at nondot.org (Chris Lattner) Date: Tue, 14 Nov 2006 15:41:49 -0600 Subject: [llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp Message-ID: <200611142141.kAELfnwQ029238@zion.cs.uiuc.edu> Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.284 -> 1.285 --- Log message: remove some dead code --- Diffs of the changes: (+2 -9) DAGISelEmitter.cpp | 11 ++--------- 1 files changed, 2 insertions(+), 9 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.284 llvm/utils/TableGen/DAGISelEmitter.cpp:1.285 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.284 Tue Nov 14 15:32:01 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Tue Nov 14 15:41:35 2006 @@ -3725,23 +3725,16 @@ OS << " return Select_" << getLegalCName(OpName) << (VTStr != "" ? "_" : "") << VTStr << "(N);\n"; } else { - int Default = -1; OS << " switch (NVT) {\n"; for (unsigned i = 0, e = OpVTs.size(); i < e; ++i) { std::string &VTStr = OpVTs[i]; - if (VTStr == "") { - Default = i; - continue; - } + assert(!VTStr.empty() && "Unset vtstr?"); OS << " case MVT::" << VTStr << ":\n" << " return Select_" << getLegalCName(OpName) << "_" << VTStr << "(N);\n"; } OS << " default:\n"; - if (Default != -1) - OS << " return Select_" << getLegalCName(OpName) << "(N);\n"; - else - OS << " break;\n"; + OS << " break;\n"; OS << " }\n"; OS << " break;\n"; } From dpatel at apple.com Tue Nov 14 15:49:50 2006 From: dpatel at apple.com (Devang Patel) Date: Tue, 14 Nov 2006 15:49:50 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/PassManager.cpp Message-ID: <200611142149.kAELnoGg029369@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: PassManager.cpp updated: 1.27 -> 1.28 --- Log message: Copy initializeAnalysisImpl() implementation from PassManagerT. Update LastUser to recursively walk required transitive set. --- Diffs of the changes: (+39 -2) PassManager.cpp | 41 +++++++++++++++++++++++++++++++++++++++-- 1 files changed, 39 insertions(+), 2 deletions(-) Index: llvm/lib/VMCore/PassManager.cpp diff -u llvm/lib/VMCore/PassManager.cpp:1.27 llvm/lib/VMCore/PassManager.cpp:1.28 --- llvm/lib/VMCore/PassManager.cpp:1.27 Mon Nov 13 21:05:08 2006 +++ llvm/lib/VMCore/PassManager.cpp Tue Nov 14 15:49:36 2006 @@ -72,7 +72,7 @@ // successfully use the getAnalysis() method to retrieve the // implementations it needs. // - inline void initializeAnalysisImpl(Pass *P) { /* TODO : Implement */ } + void initializeAnalysisImpl(Pass *P); inline std::vector::iterator passVectorBegin() { return PassVector.begin(); @@ -82,7 +82,23 @@ return PassVector.end(); } - inline void setLastUser(Pass *P, Pass *LU) { LastUser[P] = LU; } + inline void setLastUser(Pass *P, Pass *LU) { + LastUser[P] = LU; + // TODO : Check if pass P is available. + + // Prolong live range of analyses that are needed after an analysis pass + // is destroyed, for querying by subsequent passes + AnalysisUsage AnUsage; + P->getAnalysisUsage(AnUsage); + const std::vector &IDs = AnUsage.getRequiredTransitiveSet(); + for (std::vector::const_iterator I = IDs.begin(), + E = IDs.end(); I != E; ++I) { + Pass *AnalysisPass = getAnalysisPass(*I); // getAnalysisPassFromManager(*I); + assert (AnalysisPass && "Analysis pass is not available"); + setLastUser(AnalysisPass, LU); + } + + } private: // Analysis required by the passes managed by this manager. This information @@ -258,6 +274,8 @@ // FIXME: What about duplicates ? RequiredAnalysis.insert(RequiredAnalysis.end(), RequiredSet.begin(), RequiredSet.end()); + + initializeAnalysisImpl(P); } /// Augement AvailableAnalysis by adding analysis made available by pass P. @@ -329,6 +347,25 @@ PassVector.push_back(P); } +// All Required analyses should be available to the pass as it runs! Here +// we fill in the AnalysisImpls member of the pass so that it can +// successfully use the getAnalysis() method to retrieve the +// implementations it needs. +// +void CommonPassManagerImpl::initializeAnalysisImpl(Pass *P) { + AnalysisUsage AnUsage; + P->getAnalysisUsage(AnUsage); + + for (std::vector::const_iterator + I = AnUsage.getRequiredSet().begin(), + E = AnUsage.getRequiredSet().end(); I != E; ++I) { + Pass *Impl = getAnalysisPass(*I); + if (Impl == 0) + assert(0 && "Analysis used but not available!"); + // TODO: P->AnalysisImpls.push_back(std::make_pair(*I, Impl)); + } +} + /// BasicBlockPassManager implementation /// Add pass P into PassVector and return true. If this pass is not From sabre at nondot.org Tue Nov 14 15:50:42 2006 From: sabre at nondot.org (Chris Lattner) Date: Tue, 14 Nov 2006 15:50:42 -0600 Subject: [llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp Message-ID: <200611142150.kAELogQD029438@zion.cs.uiuc.edu> Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.285 -> 1.286 --- Log message: minimal hack to get patterns whose result type is iPTR to be selected. --- Diffs of the changes: (+16 -0) DAGISelEmitter.cpp | 16 ++++++++++++++++ 1 files changed, 16 insertions(+) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.285 llvm/utils/TableGen/DAGISelEmitter.cpp:1.286 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.285 Tue Nov 14 15:41:35 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Tue Nov 14 15:50:27 2006 @@ -3725,15 +3725,31 @@ OS << " return Select_" << getLegalCName(OpName) << (VTStr != "" ? "_" : "") << VTStr << "(N);\n"; } else { + // Keep track of whether we see a pattern that has an iPtr result. + bool HasPtrPattern = false; + OS << " switch (NVT) {\n"; for (unsigned i = 0, e = OpVTs.size(); i < e; ++i) { std::string &VTStr = OpVTs[i]; assert(!VTStr.empty() && "Unset vtstr?"); + + // If this is a match on iPTR: don't emit it directly, we need special + // code. + if (VTStr == "iPTR") { + HasPtrPattern = true; + continue; + } OS << " case MVT::" << VTStr << ":\n" << " return Select_" << getLegalCName(OpName) << "_" << VTStr << "(N);\n"; } OS << " default:\n"; + + // If there is an iPTR result version of this pattern, emit it here. + if (HasPtrPattern) { + OS << " if (NVT == TLI.getPointerTy())\n"; + OS << " return Select_" << getLegalCName(OpName) <<"_iPTR(N);\n"; + } OS << " break;\n"; OS << " }\n"; OS << " break;\n"; From sabre at nondot.org Tue Nov 14 16:17:25 2006 From: sabre at nondot.org (Chris Lattner) Date: Tue, 14 Nov 2006 16:17:25 -0600 Subject: [llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp Message-ID: <200611142217.kAEMHPaA029924@zion.cs.uiuc.edu> Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.286 -> 1.287 --- Log message: restore some 'magic' code that I removed: it is needed. Add comments explaining why. --- Diffs of the changes: (+22 -10) DAGISelEmitter.cpp | 32 ++++++++++++++++++++++---------- 1 files changed, 22 insertions(+), 10 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.286 llvm/utils/TableGen/DAGISelEmitter.cpp:1.287 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.286 Tue Nov 14 15:50:27 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Tue Nov 14 16:17:10 2006 @@ -3602,10 +3602,15 @@ // Print function. std::string OpVTStr; - if (OpVT == MVT::iPTR) - OpVTStr = "iPTR"; - else - OpVTStr = getEnumName(OpVT).substr(5); // Skip 'MVT::' + if (OpVT == MVT::iPTR) { + OpVTStr = "_iPTR"; + } else if (OpVT == MVT::isVoid) { + // Nodes with a void result actually have a first result type of either + // Other (a chain) or Flag. Since there is no one-to-one mapping from + // void to this case, we handle it specially here. + } else { + OpVTStr = "_" + getEnumName(OpVT).substr(5); // Skip 'MVT::' + } std::map >::iterator OpVTI = OpcodeVTMap.find(OpName); if (OpVTI == OpcodeVTMap.end()) { @@ -3616,7 +3621,7 @@ OpVTI->second.push_back(OpVTStr); OS << "SDNode *Select_" << getLegalCName(OpName) - << "_" << OpVTStr << "(const SDOperand &N) {\n"; + << OpVTStr << "(const SDOperand &N) {\n"; // Loop through and reverse all of the CodeList vectors, as we will be // accessing them from their logical front, but accessing the end of a @@ -3723,25 +3728,29 @@ if (OpVTs.size() == 1) { std::string &VTStr = OpVTs[0]; OS << " return Select_" << getLegalCName(OpName) - << (VTStr != "" ? "_" : "") << VTStr << "(N);\n"; + << VTStr << "(N);\n"; } else { // Keep track of whether we see a pattern that has an iPtr result. bool HasPtrPattern = false; + bool HasDefaultPattern = false; OS << " switch (NVT) {\n"; for (unsigned i = 0, e = OpVTs.size(); i < e; ++i) { std::string &VTStr = OpVTs[i]; - assert(!VTStr.empty() && "Unset vtstr?"); + if (VTStr.empty()) { + HasDefaultPattern = true; + continue; + } // If this is a match on iPTR: don't emit it directly, we need special // code. - if (VTStr == "iPTR") { + if (VTStr == "_iPTR") { HasPtrPattern = true; continue; } - OS << " case MVT::" << VTStr << ":\n" + OS << " case MVT::" << VTStr.substr(1) << ":\n" << " return Select_" << getLegalCName(OpName) - << "_" << VTStr << "(N);\n"; + << VTStr << "(N);\n"; } OS << " default:\n"; @@ -3750,6 +3759,9 @@ OS << " if (NVT == TLI.getPointerTy())\n"; OS << " return Select_" << getLegalCName(OpName) <<"_iPTR(N);\n"; } + if (HasDefaultPattern) { + OS << " return Select_" << getLegalCName(OpName) << "(N);\n"; + } OS << " break;\n"; OS << " }\n"; OS << " break;\n"; From dpatel at apple.com Tue Nov 14 19:11:41 2006 From: dpatel at apple.com (Devang Patel) Date: Tue, 14 Nov 2006 19:11:41 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/PassManager.cpp Message-ID: <200611150111.kAF1BfB7032643@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: PassManager.cpp updated: 1.28 -> 1.29 --- Log message: Do not derive CommonPassManagerImpl from Pass. Now BasicBlockPassManager_New is a FunctionPass, FunctionPassManager_New is a ModulePass --- Diffs of the changes: (+7 -5) PassManager.cpp | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-) Index: llvm/lib/VMCore/PassManager.cpp diff -u llvm/lib/VMCore/PassManager.cpp:1.28 llvm/lib/VMCore/PassManager.cpp:1.29 --- llvm/lib/VMCore/PassManager.cpp:1.28 Tue Nov 14 15:49:36 2006 +++ llvm/lib/VMCore/PassManager.cpp Tue Nov 14 19:11:27 2006 @@ -24,7 +24,7 @@ /// CommonPassManagerImpl helps pass manager analysis required by /// the managed passes. It provides methods to add/remove analysis /// available and query if certain analysis is available or not. -class CommonPassManagerImpl : public Pass { +class CommonPassManagerImpl { public: @@ -124,7 +124,8 @@ /// BasicBlockPassManager_New manages BasicBlockPass. It batches all the /// pass together and sequence them to process one basic block before /// processing next basic block. -class BasicBlockPassManager_New : public CommonPassManagerImpl { +class BasicBlockPassManager_New : public CommonPassManagerImpl, + public FunctionPass { public: BasicBlockPassManager_New() { } @@ -146,7 +147,8 @@ /// It batches all function passes and basic block pass managers together and /// sequence them to process one function at a time before processing next /// function. -class FunctionPassManagerImpl_New : public CommonPassManagerImpl { +class FunctionPassManagerImpl_New : public CommonPassManagerImpl, + public ModulePass { public: FunctionPassManagerImpl_New(ModuleProvider *P) { /* TODO */ } FunctionPassManagerImpl_New() { @@ -353,8 +355,8 @@ // implementations it needs. // void CommonPassManagerImpl::initializeAnalysisImpl(Pass *P) { - AnalysisUsage AnUsage; - P->getAnalysisUsage(AnUsage); + AnalysisUsage AnUsage; + P->getAnalysisUsage(AnUsage); for (std::vector::const_iterator I = AnUsage.getRequiredSet().begin(), From dpatel at apple.com Tue Nov 14 19:27:20 2006 From: dpatel at apple.com (Devang Patel) Date: Tue, 14 Nov 2006 19:27:20 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/PassManager.cpp Message-ID: <200611150127.kAF1RKDo000444@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: PassManager.cpp updated: 1.29 -> 1.30 --- Log message: Add doInitialization and doFinalization support in FunctionManager_New. --- Diffs of the changes: (+52 -2) PassManager.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 52 insertions(+), 2 deletions(-) Index: llvm/lib/VMCore/PassManager.cpp diff -u llvm/lib/VMCore/PassManager.cpp:1.29 llvm/lib/VMCore/PassManager.cpp:1.30 --- llvm/lib/VMCore/PassManager.cpp:1.29 Tue Nov 14 19:11:27 2006 +++ llvm/lib/VMCore/PassManager.cpp Tue Nov 14 19:27:05 2006 @@ -14,6 +14,7 @@ #include "llvm/PassManager.h" #include "llvm/Module.h" +#include "llvm/ModuleProvider.h" #include #include @@ -174,6 +175,13 @@ /// Return true IFF AnalysisID AID is currently available. Pass *getAnalysisPassFromManager(AnalysisID AID); + /// doInitialization - Run all of the initializers for the function passes. + /// + bool doInitialization(Module &M); + + /// doFinalization - Run all of the initializers for the function passes. + /// + bool doFinalization(Module &M); private: // Active Pass Managers BasicBlockPassManager_New *activeBBPassManager; @@ -355,8 +363,8 @@ // implementations it needs. // void CommonPassManagerImpl::initializeAnalysisImpl(Pass *P) { - AnalysisUsage AnUsage; - P->getAnalysisUsage(AnUsage); + AnalysisUsage AnUsage; + P->getAnalysisUsage(AnUsage); for (std::vector::const_iterator I = AnUsage.getRequiredSet().begin(), @@ -441,6 +449,18 @@ return FPM->runOnModule(M); } +/// doInitialization - Run all of the initializers for the function passes. +/// +bool FunctionPassManager_New::doInitialization() { + return FPM->doInitialization(*MP->getModule()); +} + +/// doFinalization - Run all of the initializers for the function passes. +/// +bool FunctionPassManager_New::doFinalization() { + return FPM->doFinalization(*MP->getModule()); +} + // FunctionPassManagerImpl_New implementation // FunctionPassManager @@ -517,6 +537,36 @@ return NULL; } +inline bool FunctionPassManagerImpl_New::doInitialization(Module &M) { + bool Changed = false; + + for (std::vector::iterator itr = passVectorBegin(), + e = passVectorEnd(); itr != e; ++itr) { + Pass *P = *itr; + + FunctionPass *FP = dynamic_cast(P); + Changed |= FP->doInitialization(M); + } + + return Changed; +} + +inline bool FunctionPassManagerImpl_New::doFinalization(Module &M) { + bool Changed = false; + + for (std::vector::iterator itr = passVectorBegin(), + e = passVectorEnd(); itr != e; ++itr) { + Pass *P = *itr; + + FunctionPass *FP = dynamic_cast(P); + Changed |= FP->doFinalization(M); + } + + + return Changed; +} + + // ModulePassManager implementation /// Add P into pass vector if it is manageble. If P is a FunctionPass From dpatel at apple.com Tue Nov 14 19:48:28 2006 From: dpatel at apple.com (Devang Patel) Date: Tue, 14 Nov 2006 19:48:28 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/PassManager.cpp Message-ID: <200611150148.kAF1mSf0000804@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: PassManager.cpp updated: 1.30 -> 1.31 --- Log message: Tidy up marking of last analysis user pass. --- Diffs of the changes: (+11 -15) PassManager.cpp | 26 +++++++++++--------------- 1 files changed, 11 insertions(+), 15 deletions(-) Index: llvm/lib/VMCore/PassManager.cpp diff -u llvm/lib/VMCore/PassManager.cpp:1.30 llvm/lib/VMCore/PassManager.cpp:1.31 --- llvm/lib/VMCore/PassManager.cpp:1.30 Tue Nov 14 19:27:05 2006 +++ llvm/lib/VMCore/PassManager.cpp Tue Nov 14 19:48:14 2006 @@ -83,22 +83,9 @@ return PassVector.end(); } - inline void setLastUser(Pass *P, Pass *LU) { + inline void setLastUser(Pass *P, Pass *LU) { LastUser[P] = LU; // TODO : Check if pass P is available. - - // Prolong live range of analyses that are needed after an analysis pass - // is destroyed, for querying by subsequent passes - AnalysisUsage AnUsage; - P->getAnalysisUsage(AnUsage); - const std::vector &IDs = AnUsage.getRequiredTransitiveSet(); - for (std::vector::const_iterator I = IDs.begin(), - E = IDs.end(); I != E; ++I) { - Pass *AnalysisPass = getAnalysisPass(*I); // getAnalysisPassFromManager(*I); - assert (AnalysisPass && "Analysis pass is not available"); - setLastUser(AnalysisPass, LU); - } - } private: @@ -671,8 +658,17 @@ schedulePass(AnalysisPass); } setLastUser (AnalysisPass, P); + + // Prolong live range of analyses that are needed after an analysis pass + // is destroyed, for querying by subsequent passes + const std::vector &IDs = AnUsage.getRequiredTransitiveSet(); + for (std::vector::const_iterator I = IDs.begin(), + E = IDs.end(); I != E; ++I) { + Pass *AP = getAnalysisPassFromManager(*I); + assert (AP && "Analysis pass is not available"); + setLastUser(AP, P); + } } - addPass(P); } From dpatel at apple.com Tue Nov 14 20:07:40 2006 From: dpatel at apple.com (Devang Patel) Date: Tue, 14 Nov 2006 20:07:40 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/PassManager.h Message-ID: <200611150207.kAF27ef6001116@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: PassManager.h updated: 1.30 -> 1.31 --- Log message: Add doInitialization and doFinalization support in FunctionManager_New. --- Diffs of the changes: (+8 -1) PassManager.h | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletion(-) Index: llvm/include/llvm/PassManager.h diff -u llvm/include/llvm/PassManager.h:1.30 llvm/include/llvm/PassManager.h:1.31 --- llvm/include/llvm/PassManager.h:1.30 Fri Nov 10 19:31:05 2006 +++ llvm/include/llvm/PassManager.h Tue Nov 14 20:07:25 2006 @@ -135,10 +135,17 @@ /// so, return true. bool runOnModule(Module &M); + /// doInitialization - Run all of the initializers for the function passes. + /// + bool doInitialization(); + + /// doFinalization - Run all of the initializers for the function passes. + /// + bool doFinalization(); private: FunctionPassManagerImpl_New *FPM; - + ModuleProvider *MP; }; From sabre at nondot.org Tue Nov 14 20:38:31 2006 From: sabre at nondot.org (Chris Lattner) Date: Tue, 14 Nov 2006 20:38:31 -0600 Subject: [llvm-commits] CVS: llvm/utils/TableGen/CodeGenInstruction.h CodeGenTarget.cpp InstrInfoEmitter.cpp Message-ID: <200611150238.kAF2cVsM001770@zion.cs.uiuc.edu> Changes in directory llvm/utils/TableGen: CodeGenInstruction.h updated: 1.23 -> 1.24 CodeGenTarget.cpp updated: 1.77 -> 1.78 InstrInfoEmitter.cpp updated: 1.52 -> 1.53 --- Log message: ADd support for adding constraints to suboperands --- Diffs of the changes: (+111 -32) CodeGenInstruction.h | 20 +++++++- CodeGenTarget.cpp | 121 ++++++++++++++++++++++++++++++++++++++------------- InstrInfoEmitter.cpp | 2 3 files changed, 111 insertions(+), 32 deletions(-) Index: llvm/utils/TableGen/CodeGenInstruction.h diff -u llvm/utils/TableGen/CodeGenInstruction.h:1.23 llvm/utils/TableGen/CodeGenInstruction.h:1.24 --- llvm/utils/TableGen/CodeGenInstruction.h:1.23 Mon Nov 6 17:49:51 2006 +++ llvm/utils/TableGen/CodeGenInstruction.h Tue Nov 14 20:38:17 2006 @@ -61,8 +61,9 @@ /// up of multiple MI operands. DagInit *MIOperandInfo; - /// Constraint info for this operand. - std::string Constraint; + /// Constraint info for this operand. This operand can have pieces, so we + /// track constraint info for each. + std::vector Constraints; OperandInfo(Record *R, const std::string &N, const std::string &PMN, unsigned MION, unsigned MINO, DagInit *MIOI) @@ -91,6 +92,21 @@ bool hasVariableNumberOfOperands; bool hasCtrlDep; bool noResults; + + /// ParseOperandName - Parse an operand name like "$foo" or "$foo.bar", + /// where $foo is a whole operand and $foo.bar refers to a suboperand. + /// This throws an exception if the name is invalid. If AllowWholeOp is + /// true, references to operands with suboperands are allowed, otherwise + /// not. + std::pair ParseOperandName(const std::string &Op, + bool AllowWholeOp = true); + + /// getFlattenedOperandNumber - Flatten a operand/suboperand pair into a + /// flat machineinstr operand #. + unsigned getFlattenedOperandNumber(std::pair Op) const { + return OperandList[Op.first].MIOperandNo + Op.second; + } + CodeGenInstruction(Record *R, const std::string &AsmStr); Index: llvm/utils/TableGen/CodeGenTarget.cpp diff -u llvm/utils/TableGen/CodeGenTarget.cpp:1.77 llvm/utils/TableGen/CodeGenTarget.cpp:1.78 --- llvm/utils/TableGen/CodeGenTarget.cpp:1.77 Thu Nov 9 20:01:40 2006 +++ llvm/utils/TableGen/CodeGenTarget.cpp Tue Nov 14 20:38:17 2006 @@ -273,34 +273,49 @@ return getInstructionSet()->getValueAsBit("isLittleEndianEncoding"); } -static std::string ParseConstraint(const std::string &CStr, - CodeGenInstruction *I, unsigned &DestOp) { - const std::string ops("="); // FIXME: Only supports TIED_TO for now. - std::string::size_type pos = CStr.find_first_of(ops); + + +static void ParseConstraint(const std::string &CStr, CodeGenInstruction *I) { + // FIXME: Only supports TIED_TO for now. + std::string::size_type pos = CStr.find_first_of('='); assert(pos != std::string::npos && "Unrecognized constraint"); - std::string Name = CStr.substr(1, pos); // Skip '$' + std::string Name = CStr.substr(0, pos); // TIED_TO: $src1 = $dst - const std::string delims(" \t"); - std::string::size_type wpos = Name.find_first_of(delims); - if (wpos != std::string::npos) - Name = Name.substr(0, wpos); - DestOp = I->getOperandNamed(Name); + std::string::size_type wpos = Name.find_first_of(" \t"); + if (wpos == std::string::npos) + throw "Illegal format for tied-to constraint: '" + CStr + "'"; + std::string DestOpName = Name.substr(0, wpos); + std::pair DestOp = I->ParseOperandName(DestOpName, false); Name = CStr.substr(pos+1); - wpos = Name.find_first_not_of(delims); - if (wpos != std::string::npos) - Name = Name.substr(wpos+1); - - unsigned TIdx = I->getOperandNamed(Name); - if (TIdx >= DestOp) + wpos = Name.find_first_not_of(" \t"); + if (wpos == std::string::npos) + throw "Illegal format for tied-to constraint: '" + CStr + "'"; + + std::pair SrcOp = + I->ParseOperandName(Name.substr(wpos), false); + if (SrcOp > DestOp) throw "Illegal tied-to operand constraint '" + CStr + "'"; - // Build the string. - return "((" + utostr(TIdx) + " << 16) | (1 << TargetInstrInfo::TIED_TO))"; + + unsigned FlatOpNo = I->getFlattenedOperandNumber(SrcOp); + // Build the string for the operand. + std::string OpConstraint = + "((" + utostr(FlatOpNo) + " << 16) | (1 << TargetInstrInfo::TIED_TO))"; + + + if (!I->OperandList[DestOp.first].Constraints[DestOp.second].empty()) + throw "Operand '" + DestOpName + "' cannot have multiple constraints!"; + I->OperandList[DestOp.first].Constraints[DestOp.second] = OpConstraint; } static void ParseConstraints(const std::string &CStr, CodeGenInstruction *I) { + // Make sure the constraints list for each operand is large enough to hold + // constraint info, even if none is present. + for (unsigned i = 0, e = I->OperandList.size(); i != e; ++i) + I->OperandList[i].Constraints.resize(I->OperandList[i].MINumOperands); + if (CStr.empty()) return; const std::string delims(","); @@ -312,13 +327,7 @@ if (eidx == std::string::npos) eidx = CStr.length(); - unsigned OpNo; - std::string Constr = ParseConstraint(CStr.substr(bidx, eidx), I, OpNo); - assert(OpNo < I->OperandList.size() && "Invalid operand no?"); - - if (!I->OperandList[OpNo].Constraint.empty()) - throw "Operand #" + utostr(OpNo) + " cannot have multiple constraints!"; - I->OperandList[OpNo].Constraint = Constr; + ParseConstraint(CStr.substr(bidx, eidx), I); bidx = CStr.find_first_not_of(delims, eidx); } } @@ -408,13 +417,19 @@ // For backward compatibility: isTwoAddress means operand 1 is tied to // operand 0. - if (isTwoAddress && OperandList[1].Constraint.empty()) - OperandList[1].Constraint = "((0 << 16) | (1 << TargetInstrInfo::TIED_TO))"; + if (isTwoAddress) { + if (!OperandList[1].Constraints[0].empty()) + throw R->getName() + ": cannot use isTwoAddress property: instruction " + "already has constraint set!"; + OperandList[1].Constraints[0] = + "((0 << 16) | (1 << TargetInstrInfo::TIED_TO))"; + } // Any operands with unset constraints get 0 as their constraint. for (unsigned op = 0, e = OperandList.size(); op != e; ++op) - if (OperandList[op].Constraint.empty()) - OperandList[op].Constraint = "0"; + for (unsigned j = 0, e = OperandList[op].MINumOperands; j != e; ++j) + if (OperandList[op].Constraints[j].empty()) + OperandList[op].Constraints[j] = "0"; } @@ -431,6 +446,54 @@ "' does not have an operand named '$" + Name + "'!"; } +std::pair +CodeGenInstruction::ParseOperandName(const std::string &Op, + bool AllowWholeOp) { + if (Op.empty() || Op[0] != '$') + throw TheDef->getName() + ": Illegal operand name: '" + Op + "'"; + + std::string OpName = Op.substr(1); + std::string SubOpName; + + // Check to see if this is $foo.bar. + std::string::size_type DotIdx = OpName.find_first_of("."); + if (DotIdx != std::string::npos) { + SubOpName = OpName.substr(DotIdx+1); + if (SubOpName.empty()) + throw TheDef->getName() + ": illegal empty suboperand name in '" +Op +"'"; + OpName = OpName.substr(0, DotIdx); + } + + unsigned OpIdx = getOperandNamed(OpName); + + if (SubOpName.empty()) { // If no suboperand name was specified: + // If one was needed, throw. + if (OperandList[OpIdx].MINumOperands > 1 && !AllowWholeOp && + SubOpName.empty()) + throw TheDef->getName() + ": Illegal to refer to" + " whole operand part of complex operand '" + Op + "'"; + + // Otherwise, return the operand. + return std::make_pair(OpIdx, 0U); + } + + // Find the suboperand number involved. + DagInit *MIOpInfo = OperandList[OpIdx].MIOperandInfo; + if (MIOpInfo == 0) + throw TheDef->getName() + ": unknown suboperand name in '" + Op + "'"; + + // Find the operand with the right name. + for (unsigned i = 0, e = MIOpInfo->getNumArgs(); i != e; ++i) + if (MIOpInfo->getArgName(i) == SubOpName) + return std::make_pair(OpIdx, i); + + // Otherwise, didn't find it! + throw TheDef->getName() + ": unknown suboperand name in '" + Op + "'"; +} + + + + //===----------------------------------------------------------------------===// // ComplexPattern implementation // Index: llvm/utils/TableGen/InstrInfoEmitter.cpp diff -u llvm/utils/TableGen/InstrInfoEmitter.cpp:1.52 llvm/utils/TableGen/InstrInfoEmitter.cpp:1.53 --- llvm/utils/TableGen/InstrInfoEmitter.cpp:1.52 Thu Nov 9 20:01:40 2006 +++ llvm/utils/TableGen/InstrInfoEmitter.cpp Tue Nov 14 20:38:17 2006 @@ -111,7 +111,7 @@ Res += "|M_PREDICATE_OPERAND"; // Fill in constraint info. - Res += ", " + Inst.OperandList[i].Constraint; + Res += ", " + Inst.OperandList[i].Constraints[j]; Result.push_back(Res); } } From sabre at nondot.org Tue Nov 14 20:43:35 2006 From: sabre at nondot.org (Chris Lattner) Date: Tue, 14 Nov 2006 20:43:35 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCHazardRecognizers.cpp PPCInstrInfo.td Message-ID: <200611150243.kAF2hZ6g001907@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCHazardRecognizers.cpp updated: 1.15 -> 1.16 PPCInstrInfo.td updated: 1.259 -> 1.260 --- Log message: Switch loads over to use memri as the operand instead of a reg/imm operand pair for cleanliness. Add instructions for PPC32 preinc-stores with commented out patterns. More improvement is needed to enable the patterns, but we're getting close. --- Diffs of the changes: (+60 -43) PPCHazardRecognizers.cpp | 11 ++--- PPCInstrInfo.td | 92 ++++++++++++++++++++++++++++------------------- 2 files changed, 60 insertions(+), 43 deletions(-) Index: llvm/lib/Target/PowerPC/PPCHazardRecognizers.cpp diff -u llvm/lib/Target/PowerPC/PPCHazardRecognizers.cpp:1.15 llvm/lib/Target/PowerPC/PPCHazardRecognizers.cpp:1.16 --- llvm/lib/Target/PowerPC/PPCHazardRecognizers.cpp:1.15 Mon Nov 13 14:11:06 2006 +++ llvm/lib/Target/PowerPC/PPCHazardRecognizers.cpp Tue Nov 14 20:43:19 2006 @@ -234,14 +234,14 @@ unsigned ThisStoreSize; switch (Opcode) { default: assert(0 && "Unknown store instruction!"); - case PPC::STB: + case PPC::STB: case PPC::STBU: case PPC::STBX: case PPC::STB8: case PPC::STBX8: case PPC::STVEBX: ThisStoreSize = 1; break; - case PPC::STH: + case PPC::STH: case PPC::STHU: case PPC::STHX: case PPC::STH8: case PPC::STHX8: @@ -249,12 +249,11 @@ case PPC::STHBRX: ThisStoreSize = 2; break; - case PPC::STFS: + case PPC::STFS: case PPC::STFSU: case PPC::STFSX: - case PPC::STWU: case PPC::STWX: case PPC::STWUX: - case PPC::STW: + case PPC::STW: case PPC::STWU: case PPC::STW8: case PPC::STWX8: case PPC::STVEWX: @@ -264,7 +263,7 @@ break; case PPC::STD_32: case PPC::STDX_32: - case PPC::STD: + case PPC::STD: case PPC::STDU: case PPC::STFD: case PPC::STFDX: case PPC::STDX: Index: llvm/lib/Target/PowerPC/PPCInstrInfo.td diff -u llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.259 llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.260 --- llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.259 Tue Nov 14 13:19:53 2006 +++ llvm/lib/Target/PowerPC/PPCInstrInfo.td Tue Nov 14 20:43:19 2006 @@ -247,7 +247,7 @@ // Address operands def memri : Operand { let PrintMethod = "printMemRegImm"; - let MIOperandInfo = (ops i32imm, ptr_rc); + let MIOperandInfo = (ops i32imm:$imm, ptr_rc:$reg); } def memrr : Operand { let PrintMethod = "printMemRegReg"; @@ -270,6 +270,7 @@ def xoaddr : ComplexPattern; def ixaddr : ComplexPattern; // "std" + //===----------------------------------------------------------------------===// // PowerPC Instruction Predicate Definitions. def FPContractions : Predicate<"!NoExcessFPPrecision">; @@ -410,7 +411,7 @@ // PPC32 Load Instructions. // -// Unindexed (r+i) Loads. +// Unindexed (r+i) Loads. let isLoad = 1, PPC970_Unit = 2 in { def LBZ : DForm_1<34, (ops GPRC:$rD, memri:$src), "lbz $rD, $src", LdStGeneral, @@ -434,38 +435,32 @@ [(set F8RC:$rD, (load iaddr:$src))]>; -// 'Update' load forms. -def LBZU : DForm_1<35, (ops GPRC:$rD, ptr_rc:$rA_result, symbolLo:$disp, - ptr_rc:$rA), - "lbzu $rD, $disp($rA)", LdStGeneral, - []>, RegConstraint<"$rA = $rA_result">; - -def LHAU : DForm_1<43, (ops GPRC:$rD, ptr_rc:$rA_result, symbolLo:$disp, - ptr_rc:$rA), - "lhau $rD, $disp($rA)", LdStGeneral, - []>, RegConstraint<"$rA = $rA_result">; - -def LHZU : DForm_1<41, (ops GPRC:$rD, ptr_rc:$rA_result, symbolLo:$disp, - ptr_rc:$rA), - "lhzu $rD, $disp($rA)", LdStGeneral, - []>, RegConstraint<"$rA = $rA_result">; - -def LWZU : DForm_1<33, (ops GPRC:$rD, ptr_rc:$rA_result, symbolLo:$disp, - ptr_rc:$rA), - "lwzu $rD, $disp($rA)", LdStGeneral, - []>, RegConstraint<"$rA = $rA_result">; - -def LFSU : DForm_1<49, (ops F4RC:$rD, ptr_rc:$rA_result, symbolLo:$disp, - ptr_rc:$rA), - "lfs $rD, $disp($rA)", LdStLFDU, - []>, RegConstraint<"$rA = $rA_result">; -def LFDU : DForm_1<51, (ops F8RC:$rD, ptr_rc:$rA_result, symbolLo:$disp, - ptr_rc:$rA), - "lfd $rD, $disp($rA)", LdStLFD, - []>, RegConstraint<"$rA = $rA_result">; +// Unindexed (r+i) Loads with Update (preinc). +def LBZU : DForm_1<35, (ops GPRC:$rD, ptr_rc:$ea_result, memri:$addr), + "lbzu $rD, $addr", LdStGeneral, + []>, RegConstraint<"$addr.reg = $ea_result">; + +def LHAU : DForm_1<43, (ops GPRC:$rD, ptr_rc:$ea_result, memri:$addr), + "lhau $rD, $addr", LdStGeneral, + []>, RegConstraint<"$addr.reg = $ea_result">; + +def LHZU : DForm_1<41, (ops GPRC:$rD, ptr_rc:$ea_result, memri:$addr), + "lhzu $rD, $addr", LdStGeneral, + []>, RegConstraint<"$addr.reg = $ea_result">; + +def LWZU : DForm_1<33, (ops GPRC:$rD, ptr_rc:$ea_result, memri:$addr), + "lwzu $rD, $addr", LdStGeneral, + []>, RegConstraint<"$addr.reg = $ea_result">; + +def LFSU : DForm_1<49, (ops F4RC:$rD, ptr_rc:$ea_result, memri:$addr), + "lfs $rD, $addr", LdStLFDU, + []>, RegConstraint<"$addr.reg = $ea_result">; +def LFDU : DForm_1<51, (ops F8RC:$rD, ptr_rc:$ea_result, memri:$addr), + "lfd $rD, $addr", LdStLFD, + []>, RegConstraint<"$addr.reg = $ea_result">; } -// Indexed (r+r) loads. +// Indexed (r+r) Loads. // let isLoad = 1, PPC970_Unit = 2 in { def LBZX : XForm_1<31, 87, (ops GPRC:$rD, memrr:$src), @@ -502,7 +497,7 @@ // PPC32 Store Instructions. // -// Unindexed (r+i) Stores. +// Unindexed (r+i) Stores. let isStore = 1, noResults = 1, PPC970_Unit = 2 in { def STB : DForm_3<38, (ops GPRC:$rS, memri:$src), "stb $rS, $src", LdStGeneral, @@ -513,10 +508,6 @@ def STW : DForm_3<36, (ops GPRC:$rS, memri:$src), "stw $rS, $src", LdStGeneral, [(store GPRC:$rS, iaddr:$src)]>; -def STWU : DForm_3<37, (ops GPRC:$rS, s16imm:$disp, GPRC:$rA), - "stwu $rS, $disp($rA)", LdStGeneral, - []>; - def STFS : DForm_1<52, (ops F4RC:$rS, memri:$dst), "stfs $rS, $dst", LdStUX, [(store F4RC:$rS, iaddr:$dst)]>; @@ -525,6 +516,33 @@ [(store F8RC:$rS, iaddr:$dst)]>; } +// Unindexed (r+i) Stores with Update (preinc). +let isStore = 1, PPC970_Unit = 2 in { +def STBU : DForm_3<39, (ops ptr_rc:$ea_res, GPRC:$rS, memri:$addr), + "stbu $rS, $addr", LdStGeneral, + [/*(set ptr_rc:$ea_res, + (pre_truncsti8 GPRC:$rS, iaddr:$addr))*/]>, + RegConstraint<"$addr.reg = $ea_res">; +def STHU : DForm_3<37, (ops ptr_rc:$ea_res, GPRC:$rS, memri:$addr), + "sthu $rS, $addr", LdStGeneral, + [/*(set ptr_rc:$ea_res, + (pre_truncsti16 GPRC:$rS, iaddr:$addr))*/]>, + RegConstraint<"$addr.reg = $ea_res">; +def STWU : DForm_3<37, (ops ptr_rc:$ea_res, GPRC:$rS, memri:$addr), + "stwu $rS, $addr", LdStGeneral, + [/*(set ptr_rc:$ea_res, (pre_store GPRC:$rS, iaddr:$addr))*/]>, + RegConstraint<"$addr.reg = $ea_res">; +def STFSU : DForm_3<37, (ops ptr_rc:$ea_res, F4RC:$rS, memri:$addr), + "stfsu $rS, $addr", LdStGeneral, + [/*(set ptr_rc:$ea_res, (pre_store F4RC:$rS, iaddr:$addr))*/]>, + RegConstraint<"$addr.reg = $ea_res">; +def STFDU : DForm_3<37, (ops ptr_rc:$ea_res, F8RC:$rS, memri:$addr), + "stfdu $rS, $addr", LdStGeneral, + [/*(set ptr_rc:$ea_res, (pre_store F8RC:$rS, iaddr:$addr))*/]>, + RegConstraint<"$addr.reg = $ea_res">; +} + + // Indexed (r+r) Stores. // let isStore = 1, noResults = 1, PPC970_Unit = 2 in { From reid at x10sys.com Tue Nov 14 21:02:55 2006 From: reid at x10sys.com (Reid Spencer) Date: Tue, 14 Nov 2006 21:02:55 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/DerivedTypes.h Message-ID: <200611150302.kAF32t9x002241@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: DerivedTypes.h updated: 1.71 -> 1.72 --- Log message: Add a method to get the bit width of a packed type. --- Diffs of the changes: (+6 -0) DerivedTypes.h | 6 ++++++ 1 files changed, 6 insertions(+) Index: llvm/include/llvm/DerivedTypes.h diff -u llvm/include/llvm/DerivedTypes.h:1.71 llvm/include/llvm/DerivedTypes.h:1.72 --- llvm/include/llvm/DerivedTypes.h:1.71 Tue Feb 7 00:17:10 2006 +++ llvm/include/llvm/DerivedTypes.h Tue Nov 14 21:02:41 2006 @@ -299,8 +299,14 @@ /// static PackedType *get(const Type *ElementType, unsigned NumElements); + /// @brief Return the number of elements in the Packed type. inline unsigned getNumElements() const { return NumElements; } + /// @brief Return the number of bits in the Packed type. + inline unsigned getBitWidth() const { + return NumElements *getElementType()->getPrimitiveSizeInBits(); + } + // Implement the AbstractTypeUser interface. virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy); virtual void typeBecameConcrete(const DerivedType *AbsTy); From sabre at nondot.org Tue Nov 14 22:53:38 2006 From: sabre at nondot.org (Chris Lattner) Date: Tue, 14 Nov 2006 22:53:38 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200611150453.kAF4rc7k004063@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.544 -> 1.545 --- Log message: Fix a gcc 4.2 warning. --- Diffs of the changes: (+2 -0) InstructionCombining.cpp | 2 ++ 1 files changed, 2 insertions(+) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.544 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.545 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.544 Tue Nov 14 01:46:50 2006 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Tue Nov 14 22:53:24 2006 @@ -2760,6 +2760,7 @@ } // FoldSetCCLogical - Implements (setcc1 A, B) & (setcc2 A, B) --> (setcc3 A, B) +namespace { struct FoldSetCCLogical { InstCombiner &IC; Value *LHS, *RHS; @@ -2795,6 +2796,7 @@ return IC.ReplaceInstUsesWith(Log, RV); } }; +} // end anonymous namespace // OptAndOp - This handles expressions of the form ((val OP C1) & C2). Where // the Op parameter is 'OP', OpRHS is 'C1', and AndRHS is 'C2'. Op is From sabre at nondot.org Wed Nov 15 00:57:09 2006 From: sabre at nondot.org (Chris Lattner) Date: Wed, 15 Nov 2006 00:57:09 -0600 Subject: [llvm-commits] CVS: llvm-www/Features.html Message-ID: <200611150657.kAF6v9Om006776@zion.cs.uiuc.edu> Changes in directory llvm-www: Features.html updated: 1.17 -> 1.18 --- Log message: Update --- Diffs of the changes: (+3 -3) Features.html | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: llvm-www/Features.html diff -u llvm-www/Features.html:1.17 llvm-www/Features.html:1.18 --- llvm-www/Features.html:1.17 Sat Sep 2 19:03:59 2006 +++ llvm-www/Features.html Wed Nov 15 00:56:55 2006 @@ -5,7 +5,7 @@ following:

    -
  • Front-ends for C and C++ based on the GCC 3.4 and 4.0.01 parsers. +
  • Front-ends for C and C++ based on the GCC 3.4 and 4.0.1 parsers. They support the full ANSI-standard C and C++ languages, plus many GCC extensions. LLVM also includes a front-end for "Stacker", a @@ -27,9 +27,9 @@ optimizations.
  • An easily retargettable code generator, which currently supports X86, - Sparc, PowerPC, Alpha, and IA-64.
  • + X86-64, PowerPC, PowerPC-64, SPARC, Alpha, and IA-64. -
  • A Just-In-Time (JIT) code generation system for X86, Sparc, +
  • A Just-In-Time (JIT) code generation system for X86, X86-64, PowerPC and PowerPC-64.
  • A C back-end useful for testing and for generating native code on targets From sabre at nondot.org Wed Nov 15 11:41:06 2006 From: sabre at nondot.org (Chris Lattner) Date: Wed, 15 Nov 2006 11:41:06 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp PPCInstr64Bit.td Message-ID: <200611151741.kAFHf62T027168@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCRegisterInfo.cpp updated: 1.82 -> 1.83 PPCInstr64Bit.td updated: 1.26 -> 1.27 --- Log message: Fix the PPC regressions last night --- Diffs of the changes: (+7 -7) PPCInstr64Bit.td | 2 +- PPCRegisterInfo.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) Index: llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp diff -u llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.82 llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.83 --- llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.82 Tue Nov 14 12:44:47 2006 +++ llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp Wed Nov 15 11:40:51 2006 @@ -418,11 +418,11 @@ if (Old->getOpcode() == PPC::ADJCALLSTACKDOWN) { if (!Subtarget.isPPC64()) { BuildMI(MBB, I, PPC::LWZ, 2, PPC::R0).addImm(0).addReg(PPC::R31); - BuildMI(MBB, I, PPC::STWU, 3) + BuildMI(MBB, I, PPC::STWU, 3, PPC::R1) .addReg(PPC::R0).addImm(-Amount).addReg(PPC::R1); } else { BuildMI(MBB, I, PPC::LD, 2, PPC::X0).addImm(0).addReg(PPC::X31); - BuildMI(MBB, I, PPC::STDU, 3) + BuildMI(MBB, I, PPC::STDU, 3, PPC::X1) .addReg(PPC::X0).addImm(-Amount/4).addReg(PPC::X1); } } else { @@ -684,8 +684,8 @@ BuildMI(MBB, MBBI, PPC::STWUX, 3) .addReg(PPC::R1).addReg(PPC::R1).addReg(PPC::R0); } else if (NumBytes <= 32768) { - BuildMI(MBB, MBBI, PPC::STWU, 3).addReg(PPC::R1).addImm(NegNumbytes) - .addReg(PPC::R1); + BuildMI(MBB, MBBI, PPC::STWU, 3, + PPC::R1).addReg(PPC::R1).addImm(NegNumbytes).addReg(PPC::R1); } else { BuildMI(MBB, MBBI, PPC::LIS, 1, PPC::R0).addImm(NegNumbytes >> 16); BuildMI(MBB, MBBI, PPC::ORI, 2, PPC::R0).addReg(PPC::R0) @@ -704,8 +704,8 @@ BuildMI(MBB, MBBI, PPC::STDUX, 3) .addReg(PPC::X1).addReg(PPC::X1).addReg(PPC::X0); } else if (NumBytes <= 32768*4) { - BuildMI(MBB, MBBI, PPC::STDU, 3).addReg(PPC::X1).addImm(NegNumbytes/4) - .addReg(PPC::X1); + BuildMI(MBB, MBBI, PPC::STDU, 3, PPC::X1) + .addReg(PPC::X1).addImm(NegNumbytes/4).addReg(PPC::X1); } else { BuildMI(MBB, MBBI, PPC::LIS8, 1, PPC::X0).addImm(NegNumbytes >> 16); BuildMI(MBB, MBBI, PPC::ORI8, 2, PPC::X0).addReg(PPC::X0) Index: llvm/lib/Target/PowerPC/PPCInstr64Bit.td diff -u llvm/lib/Target/PowerPC/PPCInstr64Bit.td:1.26 llvm/lib/Target/PowerPC/PPCInstr64Bit.td:1.27 --- llvm/lib/Target/PowerPC/PPCInstr64Bit.td:1.26 Tue Nov 14 12:44:47 2006 +++ llvm/lib/Target/PowerPC/PPCInstr64Bit.td Wed Nov 15 11:40:51 2006 @@ -364,7 +364,7 @@ [(store G8RC:$rS, xaddr:$dst)]>, isPPC64, PPC970_DGroup_Cracked; -def STDU : DSForm_1<62, 1, (ops G8RC:$rS, memrix:$dst), +def STDU : DSForm_1<62, 1, (ops G8RC:$ea_res, G8RC:$rS, memrix:$dst), "stdu $rS, $dst", LdStSTD, []>, isPPC64; def STDUX : XForm_8<31, 181, (ops G8RC:$rS, memrr:$dst), From sabre at nondot.org Wed Nov 15 11:51:30 2006 From: sabre at nondot.org (Chris Lattner) Date: Wed, 15 Nov 2006 11:51:30 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <200611151751.kAFHpUPm027347@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: SelectionDAGISel.cpp updated: 1.317 -> 1.318 --- Log message: remove dead #include --- Diffs of the changes: (+0 -1) SelectionDAGISel.cpp | 1 - 1 files changed, 1 deletion(-) Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.317 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.318 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.317 Thu Nov 9 22:41:34 2006 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Wed Nov 15 11:51:15 2006 @@ -24,7 +24,6 @@ #include "llvm/Instructions.h" #include "llvm/Intrinsics.h" #include "llvm/IntrinsicInst.h" -#include "llvm/CodeGen/IntrinsicLowering.h" #include "llvm/CodeGen/MachineDebugInfo.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineFrameInfo.h" From sabre at nondot.org Wed Nov 15 11:53:28 2006 From: sabre at nondot.org (Chris Lattner) Date: Wed, 15 Nov 2006 11:53:28 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86.h X86JITInfo.h Message-ID: <200611151753.kAFHrSDC027462@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86.h updated: 1.48 -> 1.49 X86JITInfo.h updated: 1.11 -> 1.12 --- Log message: Remove unneeded forward decls --- Diffs of the changes: (+0 -2) X86.h | 1 - X86JITInfo.h | 1 - 2 files changed, 2 deletions(-) Index: llvm/lib/Target/X86/X86.h diff -u llvm/lib/Target/X86/X86.h:1.48 llvm/lib/Target/X86/X86.h:1.49 --- llvm/lib/Target/X86/X86.h:1.48 Sun Sep 3 23:14:57 2006 +++ llvm/lib/Target/X86/X86.h Wed Nov 15 11:53:13 2006 @@ -22,7 +22,6 @@ class X86TargetMachine; class FunctionPassManager; class FunctionPass; -class IntrinsicLowering; class MachineCodeEmitter; /// createX86ISelDag - This pass converts a legalized DAG into a Index: llvm/lib/Target/X86/X86JITInfo.h diff -u llvm/lib/Target/X86/X86JITInfo.h:1.11 llvm/lib/Target/X86/X86JITInfo.h:1.12 --- llvm/lib/Target/X86/X86JITInfo.h:1.11 Sun Sep 3 23:14:57 2006 +++ llvm/lib/Target/X86/X86JITInfo.h Wed Nov 15 11:53:13 2006 @@ -18,7 +18,6 @@ namespace llvm { class X86TargetMachine; - class IntrinsicLowering; class X86JITInfo : public TargetJITInfo { X86TargetMachine &TM; From sabre at nondot.org Wed Nov 15 12:00:27 2006 From: sabre at nondot.org (Chris Lattner) Date: Wed, 15 Nov 2006 12:00:27 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/CBackend/Writer.cpp Message-ID: <200611151800.kAFI0R2a027625@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/CBackend: Writer.cpp updated: 1.281 -> 1.282 --- Log message: Simplify IntrinsicLowering and clarify that it is only for use by the CBE and interpreter. --- Diffs of the changes: (+1 -1) Writer.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Target/CBackend/Writer.cpp diff -u llvm/lib/Target/CBackend/Writer.cpp:1.281 llvm/lib/Target/CBackend/Writer.cpp:1.282 --- llvm/lib/Target/CBackend/Writer.cpp:1.281 Wed Nov 8 00:47:33 2006 +++ llvm/lib/Target/CBackend/Writer.cpp Wed Nov 15 12:00:10 2006 @@ -69,7 +69,7 @@ /// module to a C translation unit. class CWriter : public FunctionPass, public InstVisitor { std::ostream &Out; - DefaultIntrinsicLowering IL; + IntrinsicLowering IL; Mangler *Mang; LoopInfo *LI; const Module *TheModule; From sabre at nondot.org Wed Nov 15 12:00:28 2006 From: sabre at nondot.org (Chris Lattner) Date: Wed, 15 Nov 2006 12:00:28 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/IntrinsicLowering.h Message-ID: <200611151800.kAFI0SUF027629@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: IntrinsicLowering.h updated: 1.10 -> 1.11 --- Log message: Simplify IntrinsicLowering and clarify that it is only for use by the CBE and interpreter. --- Diffs of the changes: (+3 -30) IntrinsicLowering.h | 33 +++------------------------------ 1 files changed, 3 insertions(+), 30 deletions(-) Index: llvm/include/llvm/CodeGen/IntrinsicLowering.h diff -u llvm/include/llvm/CodeGen/IntrinsicLowering.h:1.10 llvm/include/llvm/CodeGen/IntrinsicLowering.h:1.11 --- llvm/include/llvm/CodeGen/IntrinsicLowering.h:1.10 Fri Mar 10 16:49:05 2006 +++ llvm/include/llvm/CodeGen/IntrinsicLowering.h Wed Nov 15 12:00:10 2006 @@ -9,24 +9,7 @@ // // This file defines the IntrinsicLowering interface. This interface allows // addition of domain-specific or front-end specific intrinsics to LLVM without -// having to modify all of the code generators to support the new intrinsic. -// Later, as desired, targets can incrementally add support for particular -// intrinsic functions, as desired, to generate better code. -// -// If a code generator cannot handle or does not know about an intrinsic -// function, it will use the intrinsic lowering interface to change an intrinsic -// function name into a concrete function name which can be used to implement -// the functionality of the intrinsic. For example, llvm.memcpy can be -// implemented as a call to the math library 'memcpy' function if the target -// doesn't have hardware support for the intrinsic, or if it has not yet been -// implemented yet. -// -// Another use for this interface is the addition of domain-specific intrinsics. -// The default implementation of this interface would then lower the intrinsics -// to noop calls, allowing the direct execution of programs with instrumentation -// or other hooks placed in them. When a specific tool or flag is used, a -// different implementation of these interfaces may be used, which activates the -// intrinsics in some way. +// having to modify all of the C backend or interpreter. // //===----------------------------------------------------------------------===// @@ -42,12 +25,11 @@ class IntrinsicLowering { public: IntrinsicLowering() {} - virtual ~IntrinsicLowering() {} /// AddPrototypes - This method, if called, causes all of the prototypes /// that might be needed by an intrinsic lowering implementation to be /// inserted into the module specified. - virtual void AddPrototypes(Module &M) = 0; + void AddPrototypes(Module &M); /// LowerIntrinsicCall - This method returns the LLVM function which should /// be used to implement the specified intrinsic function call. If an @@ -59,16 +41,7 @@ /// _after_ the call instruction and the call is deleted. The caller must /// be capable of handling this kind of change. /// - virtual void LowerIntrinsicCall(CallInst *CI) = 0; - }; - - /// DefaultIntrinsicLower - This is the default intrinsic lowering pass which - /// is used if no other one is specified. Custom intrinsic lowering - /// implementations should pass any unhandled intrinsics to this - /// implementation to allow for future extensibility. - struct DefaultIntrinsicLowering : public IntrinsicLowering { - virtual void AddPrototypes(Module &M); - virtual void LowerIntrinsicCall(CallInst *CI); + void LowerIntrinsicCall(CallInst *CI); }; } From sabre at nondot.org Wed Nov 15 12:00:28 2006 From: sabre at nondot.org (Chris Lattner) Date: Wed, 15 Nov 2006 12:00:28 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/IntrinsicLowering.cpp Message-ID: <200611151800.kAFI0Sl2027630@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: IntrinsicLowering.cpp updated: 1.45 -> 1.46 --- Log message: Simplify IntrinsicLowering and clarify that it is only for use by the CBE and interpreter. --- Diffs of the changes: (+3 -3) IntrinsicLowering.cpp | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: llvm/lib/CodeGen/IntrinsicLowering.cpp diff -u llvm/lib/CodeGen/IntrinsicLowering.cpp:1.45 llvm/lib/CodeGen/IntrinsicLowering.cpp:1.46 --- llvm/lib/CodeGen/IntrinsicLowering.cpp:1.45 Wed Nov 8 00:47:33 2006 +++ llvm/lib/CodeGen/IntrinsicLowering.cpp Wed Nov 15 12:00:10 2006 @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// This file implements the default intrinsic lowering implementation. +// This file implements the IntrinsicLowering class. // //===----------------------------------------------------------------------===// @@ -82,7 +82,7 @@ return NewCI; } -void DefaultIntrinsicLowering::AddPrototypes(Module &M) { +void IntrinsicLowering::AddPrototypes(Module &M) { for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) if (I->isExternal() && !I->use_empty()) switch (I->getIntrinsicID()) { @@ -263,7 +263,7 @@ -void DefaultIntrinsicLowering::LowerIntrinsicCall(CallInst *CI) { +void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) { Function *Callee = CI->getCalledFunction(); assert(Callee && "Cannot lower an indirect call!"); From sabre at nondot.org Wed Nov 15 12:00:30 2006 From: sabre at nondot.org (Chris Lattner) Date: Wed, 15 Nov 2006 12:00:30 -0600 Subject: [llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp Message-ID: <200611151800.kAFI0Uuv027641@zion.cs.uiuc.edu> Changes in directory llvm/lib/ExecutionEngine/Interpreter: Interpreter.cpp updated: 1.32 -> 1.33 --- Log message: Simplify IntrinsicLowering and clarify that it is only for use by the CBE and interpreter. --- Diffs of the changes: (+1 -1) Interpreter.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp diff -u llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp:1.32 llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp:1.33 --- llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp:1.32 Fri Jun 16 13:24:38 2006 +++ llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp Wed Nov 15 12:00:10 2006 @@ -67,7 +67,7 @@ initializeExternalFunctions(); emitGlobals(); - IL = new DefaultIntrinsicLowering(); + IL = new IntrinsicLowering(); } Interpreter::~Interpreter() { From dpatel at apple.com Wed Nov 15 13:40:09 2006 From: dpatel at apple.com (Devang Patel) Date: Wed, 15 Nov 2006 13:40:09 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/PassManager.cpp Message-ID: <200611151940.kAFJe98x029416@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: PassManager.cpp updated: 1.31 -> 1.32 --- Log message: Add run(Function &F) support in FunctionPassManager_New --- Diffs of the changes: (+41 -6) PassManager.cpp | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 41 insertions(+), 6 deletions(-) Index: llvm/lib/VMCore/PassManager.cpp diff -u llvm/lib/VMCore/PassManager.cpp:1.31 llvm/lib/VMCore/PassManager.cpp:1.32 --- llvm/lib/VMCore/PassManager.cpp:1.31 Tue Nov 14 19:48:14 2006 +++ llvm/lib/VMCore/PassManager.cpp Wed Nov 15 13:39:54 2006 @@ -17,6 +17,7 @@ #include "llvm/ModuleProvider.h" #include #include +#include using namespace llvm; @@ -158,6 +159,7 @@ /// track of whether any of the passes modifies the function, and if /// so, return true. bool runOnModule(Module &M); + bool runOnFunction(Function &F); /// Return true IFF AnalysisID AID is currently available. Pass *getAnalysisPassFromManager(AnalysisID AID); @@ -423,19 +425,31 @@ /// PassManager_X is destroyed, the pass will be destroyed as well, so /// there is no need to delete the pass. (TODO delete passes.) /// This implies that all passes MUST be allocated with 'new'. -void -FunctionPassManager_New::add(Pass *P) { +void FunctionPassManager_New::add(Pass *P) { FPM->add(P); } /// Execute all of the passes scheduled for execution. Keep /// track of whether any of the passes modifies the function, and if /// so, return true. -bool -FunctionPassManager_New::runOnModule(Module &M) { +bool FunctionPassManager_New::runOnModule(Module &M) { return FPM->runOnModule(M); } +/// run - Execute all of the passes scheduled for execution. Keep +/// track of whether any of the passes modifies the function, and if +/// so, return true. +/// +bool FunctionPassManager_New::run(Function &F) { + std::string errstr; + if (MP->materializeFunction(&F, &errstr)) { + std::cerr << "Error reading bytecode file: " << errstr << "\n"; + abort(); + } + return FPM->runOnFunction(F); +} + + /// doInitialization - Run all of the initializers for the function passes. /// bool FunctionPassManager_New::doInitialization() { @@ -489,8 +503,7 @@ /// Execute all of the passes scheduled for execution by invoking /// runOnFunction method. Keep track of whether any of the passes modifies /// the function, and if so, return true. -bool -FunctionPassManagerImpl_New::runOnModule(Module &M) { +bool FunctionPassManagerImpl_New::runOnModule(Module &M) { bool Changed = false; clearAnalysis(); @@ -509,6 +522,28 @@ return Changed; } +/// Execute all of the passes scheduled for execution by invoking +/// runOnFunction method. Keep track of whether any of the passes modifies +/// the function, and if so, return true. +bool FunctionPassManagerImpl_New::runOnFunction(Function &F) { + + bool Changed = false; + clearAnalysis(); + + for (std::vector::iterator itr = passVectorBegin(), + e = passVectorEnd(); itr != e; ++itr) { + Pass *P = *itr; + + noteDownAvailableAnalysis(P); + FunctionPass *FP = dynamic_cast(P); + Changed |= FP->runOnFunction(F); + removeNotPreservedAnalysis(P); + removeDeadPasses(P); + } + return Changed; +} + + /// Return true IFF AnalysisID AID is currently available. Pass *FunctionPassManagerImpl_New::getAnalysisPassFromManager(AnalysisID AID) { From dpatel at apple.com Wed Nov 15 13:40:10 2006 From: dpatel at apple.com (Devang Patel) Date: Wed, 15 Nov 2006 13:40:10 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/PassManager.h Message-ID: <200611151940.kAFJeAYu029419@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: PassManager.h updated: 1.31 -> 1.32 --- Log message: Add run(Function &F) support in FunctionPassManager_New --- Diffs of the changes: (+6 -0) PassManager.h | 6 ++++++ 1 files changed, 6 insertions(+) Index: llvm/include/llvm/PassManager.h diff -u llvm/include/llvm/PassManager.h:1.31 llvm/include/llvm/PassManager.h:1.32 --- llvm/include/llvm/PassManager.h:1.31 Tue Nov 14 20:07:25 2006 +++ llvm/include/llvm/PassManager.h Wed Nov 15 13:39:54 2006 @@ -135,6 +135,12 @@ /// so, return true. bool runOnModule(Module &M); + /// run - Execute all of the passes scheduled for execution. Keep + /// track of whether any of the passes modifies the function, and if + /// so, return true. + /// + bool run(Function &F); + /// doInitialization - Run all of the initializers for the function passes. /// bool doInitialization(); From sabre at nondot.org Wed Nov 15 13:55:28 2006 From: sabre at nondot.org (Chris Lattner) Date: Wed, 15 Nov 2006 13:55:28 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp PPCISelLowering.cpp PPCInstr64Bit.td PPCInstrInfo.td Message-ID: <200611151955.kAFJtSWA029686@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCISelDAGToDAG.cpp updated: 1.219 -> 1.220 PPCISelLowering.cpp updated: 1.226 -> 1.227 PPCInstr64Bit.td updated: 1.27 -> 1.28 PPCInstrInfo.td updated: 1.260 -> 1.261 --- Log message: fix ldu/stu jit encoding. Swith 64-bit preinc load instrs to use memri addrmodes. --- Diffs of the changes: (+58 -52) PPCISelDAGToDAG.cpp | 55 ++++++++++++++++++++++++++-------------------------- PPCISelLowering.cpp | 25 ++++++++++++++++------- PPCInstr64Bit.td | 28 +++++++++++--------------- PPCInstrInfo.td | 2 - 4 files changed, 58 insertions(+), 52 deletions(-) Index: llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp diff -u llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:1.219 llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:1.220 --- llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:1.219 Tue Nov 14 12:43:11 2006 +++ llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp Wed Nov 15 13:55:13 2006 @@ -828,36 +828,37 @@ if (LD->getAddressingMode() != ISD::PRE_INC) break; - unsigned Opcode; - bool isSExt = LD->getExtensionType() == ISD::SEXTLOAD; - if (LD->getValueType(0) != MVT::i64) { - // Handle PPC32 integer and normal FP loads. - assert(!isSExt || LoadedVT == MVT::i16 && "Invalid sext update load"); - switch (LoadedVT) { - default: assert(0 && "Invalid PPC load type!"); - case MVT::f64: Opcode = PPC::LFDU; break; - case MVT::f32: Opcode = PPC::LFSU; break; - case MVT::i32: Opcode = PPC::LWZU; break; - case MVT::i16: Opcode = isSExt ? PPC::LHAU : PPC::LHZU; break; - case MVT::i1: - case MVT::i8: Opcode = PPC::LBZU; break; - } - } else { - assert(LD->getValueType(0) == MVT::i64 && "Unknown load result type!"); - assert(!isSExt || LoadedVT == MVT::i16 && "Invalid sext update load"); - switch (LoadedVT) { - default: assert(0 && "Invalid PPC load type!"); - case MVT::i64: Opcode = PPC::LDU; break; - case MVT::i32: Opcode = PPC::LWZU8; break; - case MVT::i16: Opcode = isSExt ? PPC::LHAU8 : PPC::LHZU8; break; - case MVT::i1: - case MVT::i8: Opcode = PPC::LBZU8; break; - } - } - SDOperand Offset = LD->getOffset(); if (isa(Offset) || Offset.getOpcode() == ISD::TargetGlobalAddress) { + + unsigned Opcode; + bool isSExt = LD->getExtensionType() == ISD::SEXTLOAD; + if (LD->getValueType(0) != MVT::i64) { + // Handle PPC32 integer and normal FP loads. + assert(!isSExt || LoadedVT == MVT::i16 && "Invalid sext update load"); + switch (LoadedVT) { + default: assert(0 && "Invalid PPC load type!"); + case MVT::f64: Opcode = PPC::LFDU; break; + case MVT::f32: Opcode = PPC::LFSU; break; + case MVT::i32: Opcode = PPC::LWZU; break; + case MVT::i16: Opcode = isSExt ? PPC::LHAU : PPC::LHZU; break; + case MVT::i1: + case MVT::i8: Opcode = PPC::LBZU; break; + } + } else { + assert(LD->getValueType(0) == MVT::i64 && "Unknown load result type!"); + assert(!isSExt || LoadedVT == MVT::i16 && "Invalid sext update load"); + switch (LoadedVT) { + default: assert(0 && "Invalid PPC load type!"); + case MVT::i64: Opcode = PPC::LDU; break; + case MVT::i32: Opcode = PPC::LWZU8; break; + case MVT::i16: Opcode = isSExt ? PPC::LHAU8 : PPC::LHZU8; break; + case MVT::i1: + case MVT::i8: Opcode = PPC::LBZU8; break; + } + } + SDOperand Chain = LD->getChain(); SDOperand Base = LD->getBasePtr(); AddToISelQueue(Chain); Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp diff -u llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.226 llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.227 --- llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.226 Mon Nov 13 23:28:08 2006 +++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp Wed Nov 15 13:55:13 2006 @@ -877,12 +877,12 @@ MVT::ValueType VT; if (LoadSDNode *LD = dyn_cast(N)) { Ptr = LD->getBasePtr(); - VT = LD->getValueType(0); + VT = LD->getLoadedVT(); + } else if (StoreSDNode *ST = dyn_cast(N)) { ST = ST; Ptr = ST->getBasePtr(); VT = ST->getStoredVT(); - return false; // TODO: Stores. } else return false; @@ -890,18 +890,27 @@ if (MVT::isVector(VT)) return false; - // TODO: Handle reg+reg. - if (!SelectAddressRegImm(Ptr, Offset, Base, DAG)) - return false; + // TODO: Check reg+reg first. + + // LDU/STU use reg+imm*4, others use reg+imm. + if (VT != MVT::i64) { + // reg + imm + if (!SelectAddressRegImm(Ptr, Offset, Base, DAG)) + return false; + } else { + // reg + imm * 4. + if (!SelectAddressRegImmShift(Ptr, Offset, Base, DAG)) + return false; + } - // PPC64 doesn't have lwau, but it does have lwaux. Reject preinc load of - // sext i32 to i64 when addr mode is r+i. if (LoadSDNode *LD = dyn_cast(N)) { + // PPC64 doesn't have lwau, but it does have lwaux. Reject preinc load of + // sext i32 to i64 when addr mode is r+i. if (LD->getValueType(0) == MVT::i64 && LD->getLoadedVT() == MVT::i32 && LD->getExtensionType() == ISD::SEXTLOAD && isa(Offset)) return false; - } + } AM = ISD::PRE_INC; return true; Index: llvm/lib/Target/PowerPC/PPCInstr64Bit.td diff -u llvm/lib/Target/PowerPC/PPCInstr64Bit.td:1.27 llvm/lib/Target/PowerPC/PPCInstr64Bit.td:1.28 --- llvm/lib/Target/PowerPC/PPCInstr64Bit.td:1.27 Wed Nov 15 11:40:51 2006 +++ llvm/lib/Target/PowerPC/PPCInstr64Bit.td Wed Nov 15 13:55:13 2006 @@ -322,18 +322,15 @@ // Update forms. -def LBZU8 : DForm_1<35, (ops G8RC:$rD, ptr_rc:$rA_result, symbolLo:$disp, - ptr_rc:$rA), - "lbzu $rD, $disp($rA)", LdStGeneral, - []>, RegConstraint<"$rA = $rA_result">; -def LHZU8 : DForm_1<41, (ops G8RC:$rD, ptr_rc:$rA_result, symbolLo:$disp, - ptr_rc:$rA), - "lhzu $rD, $disp($rA)", LdStGeneral, - []>, RegConstraint<"$rA = $rA_result">; -def LWZU8 : DForm_1<33, (ops G8RC:$rD, ptr_rc:$rA_result, symbolLo:$disp, - ptr_rc:$rA), - "lwzu $rD, $disp($rA)", LdStGeneral, - []>, RegConstraint<"$rA = $rA_result">; +def LBZU8 : DForm_1<35, (ops G8RC:$rD, ptr_rc:$ea_result, memri:$addr), + "lbzu $rD, $addr", LdStGeneral, + []>, RegConstraint<"$addr.reg = $ea_result">; +def LHZU8 : DForm_1<41, (ops G8RC:$rD, ptr_rc:$ea_result, memri:$addr), + "lhzu $rD, $addr", LdStGeneral, + []>, RegConstraint<"$addr.reg = $ea_result">; +def LWZU8 : DForm_1<33, (ops G8RC:$rD, ptr_rc:$ea_result, memri:$addr), + "lwzu $rD, $addr", LdStGeneral, + []>, RegConstraint<"$addr.reg = $ea_result">; } @@ -347,10 +344,9 @@ "ldx $rD, $src", LdStLD, [(set G8RC:$rD, (load xaddr:$src))]>, isPPC64; -def LDU : DSForm_1<58, 1, (ops G8RC:$rD, ptr_rc:$rA_result, symbolLo:$disp, - ptr_rc:$rA), - "ldu $rD, $disp($rA)", LdStLD, - []>, RegConstraint<"$rA = $rA_result">, isPPC64; +def LDU : DSForm_1<58, 1, (ops G8RC:$rD, ptr_rc:$ea_result, memrix:$addr), + "ldu $rD, $addr", LdStLD, + []>, RegConstraint<"$addr.reg = $ea_result">, isPPC64; } Index: llvm/lib/Target/PowerPC/PPCInstrInfo.td diff -u llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.260 llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.261 --- llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.260 Tue Nov 14 20:43:19 2006 +++ llvm/lib/Target/PowerPC/PPCInstrInfo.td Wed Nov 15 13:55:13 2006 @@ -255,7 +255,7 @@ } def memrix : Operand { // memri where the imm is shifted 2 bits. let PrintMethod = "printMemRegImmShifted"; - let MIOperandInfo = (ops i32imm, ptr_rc); + let MIOperandInfo = (ops i32imm:$imm, ptr_rc:$reg); } // PowerPC Predicate operand. 20 = (0<<5)|20 = always, CR0 is a dummy reg From evan.cheng at apple.com Wed Nov 15 14:47:45 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 15 Nov 2006 14:47:45 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/LiveVariables.h Message-ID: <200611152047.kAFKljBt030492@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: LiveVariables.h updated: 1.30 -> 1.31 --- Log message: Do away with kill / dead maps. Move kill / dead info onto MI's. --- Diffs of the changes: (+36 -95) LiveVariables.h | 131 +++++++++++++++----------------------------------------- 1 files changed, 36 insertions(+), 95 deletions(-) Index: llvm/include/llvm/CodeGen/LiveVariables.h diff -u llvm/include/llvm/CodeGen/LiveVariables.h:1.30 llvm/include/llvm/CodeGen/LiveVariables.h:1.31 --- llvm/include/llvm/CodeGen/LiveVariables.h:1.30 Tue Oct 3 02:20:20 2006 +++ llvm/include/llvm/CodeGen/LiveVariables.h Wed Nov 15 14:47:31 2006 @@ -107,23 +107,6 @@ /// std::vector VirtRegInfo; - /// RegistersKilled - This map keeps track of all of the registers that - /// are dead immediately after an instruction reads its operands. If an - /// instruction does not have an entry in this map, it kills no registers. - /// - std::map > RegistersKilled; - - /// RegistersDead - This map keeps track of all of the registers that are - /// dead immediately after an instruction executes, which are not dead after - /// the operands are evaluated. In practice, this only contains registers - /// which are defined by an instruction, but never used. - /// - std::map > RegistersDead; - - /// Dummy - An always empty vector used for instructions without dead or - /// killed operands. - std::vector Dummy; - /// AllocatablePhysicalRegisters - This vector keeps track of which registers /// are actually register allocatable by the target machine. We can not track /// liveness for values that are not in this set. @@ -141,6 +124,15 @@ PHIVarInfoMap PHIVarInfo; + + /// addRegisterKilled - We have determined MI kills a register. Look for the + /// operand that uses it and mark it as IsKill. + void addRegisterKilled(unsigned IncomingReg, MachineInstr *MI); + + /// addRegisterDead - We have determined MI defined a register without a use. + /// Look for the operand that defines it and mark it as IsDead. + void addRegisterDead(unsigned IncomingReg, MachineInstr *MI); + void HandlePhysRegUse(unsigned Reg, MachineInstr *MI); void HandlePhysRegDef(unsigned Reg, MachineInstr *MI); @@ -153,55 +145,17 @@ virtual bool runOnMachineFunction(MachineFunction &MF); - /// killed_iterator - Iterate over registers killed by a machine instruction - /// - typedef std::vector::iterator killed_iterator; - - std::vector &getKillsVector(MachineInstr *MI) { - std::map >::iterator I = - RegistersKilled.find(MI); - return I != RegistersKilled.end() ? I->second : Dummy; - } - std::vector &getDeadDefsVector(MachineInstr *MI) { - std::map >::iterator I = - RegistersDead.find(MI); - return I != RegistersDead.end() ? I->second : Dummy; - } - - - /// killed_begin/end - Get access to the range of registers killed by a - /// machine instruction. - killed_iterator killed_begin(MachineInstr *MI) { - return getKillsVector(MI).begin(); - } - killed_iterator killed_end(MachineInstr *MI) { - return getKillsVector(MI).end(); - } - std::pair - killed_range(MachineInstr *MI) { - std::vector &V = getKillsVector(MI); - return std::make_pair(V.begin(), V.end()); - } - /// KillsRegister - Return true if the specified instruction kills the /// specified register. bool KillsRegister(MachineInstr *MI, unsigned Reg) const; - killed_iterator dead_begin(MachineInstr *MI) { - return getDeadDefsVector(MI).begin(); - } - killed_iterator dead_end(MachineInstr *MI) { - return getDeadDefsVector(MI).end(); - } - std::pair - dead_range(MachineInstr *MI) { - std::vector &V = getDeadDefsVector(MI); - return std::make_pair(V.begin(), V.end()); - } - /// RegisterDefIsDead - Return true if the specified instruction defines the /// specified register, but that definition is dead. bool RegisterDefIsDead(MachineInstr *MI, unsigned Reg) const; + + /// ModifiesRegister - Return true if the specified instruction modifies the + /// specified register. + bool ModifiesRegister(MachineInstr *MI, unsigned Reg) const; //===--------------------------------------------------------------------===// // API to update live variable information @@ -217,19 +171,9 @@ /// instruction. /// void addVirtualRegisterKilled(unsigned IncomingReg, MachineInstr *MI) { - std::vector &V = RegistersKilled[MI]; - // Insert in a sorted order. - if (V.empty() || IncomingReg > V.back()) { - V.push_back(IncomingReg); - } else { - std::vector::iterator I = V.begin(); - for (; *I < IncomingReg; ++I) - /*empty*/; - if (*I != IncomingReg) // Don't insert duplicates. - V.insert(I, IncomingReg); - } - getVarInfo(IncomingReg).Kills.push_back(MI); - } + addRegisterKilled(IncomingReg, MI); + getVarInfo(IncomingReg).Kills.push_back(MI); + } /// removeVirtualRegisterKilled - Remove the specified virtual /// register from the live variable information. Returns true if the @@ -241,12 +185,17 @@ if (!getVarInfo(reg).removeKill(MI)) return false; - std::vector &V = getKillsVector(MI); - for (unsigned i = 0, e = V.size(); i != e; ++i) - if (V[i] == reg) { - V.erase(V.begin()+i); - return true; + bool Removed = false; + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { + MachineOperand &MO = MI->getOperand(i); + if (MO.isReg() && MO.isUse() && MO.getReg() == reg) { + MO.unsetIsKill(); + Removed = true; + break; } + } + + assert(Removed && "Register is not used by this instruction!"); return true; } @@ -258,17 +207,7 @@ /// register is dead after being used by the specified instruction. /// void addVirtualRegisterDead(unsigned IncomingReg, MachineInstr *MI) { - std::vector &V = RegistersDead[MI]; - // Insert in a sorted order. - if (V.empty() || IncomingReg > V.back()) { - V.push_back(IncomingReg); - } else { - std::vector::iterator I = V.begin(); - for (; *I < IncomingReg; ++I) - /*empty*/; - if (*I != IncomingReg) // Don't insert duplicates. - V.insert(I, IncomingReg); - } + addRegisterDead(IncomingReg, MI); getVarInfo(IncomingReg).Kills.push_back(MI); } @@ -282,12 +221,16 @@ if (!getVarInfo(reg).removeKill(MI)) return false; - std::vector &V = getDeadDefsVector(MI); - for (unsigned i = 0, e = V.size(); i != e; ++i) - if (V[i] == reg) { - V.erase(V.begin()+i); - return true; + bool Removed = false; + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { + MachineOperand &MO = MI->getOperand(i); + if (MO.isReg() && MO.isDef() && MO.getReg() == reg) { + MO.unsetIsDead(); + Removed = true; + break; } + } + assert(Removed && "Register is not defined by this instruction!"); return true; } @@ -301,8 +244,6 @@ virtual void releaseMemory() { VirtRegInfo.clear(); - RegistersKilled.clear(); - RegistersDead.clear(); } /// getVarInfo - Return the VarInfo structure for the specified VIRTUAL From evan.cheng at apple.com Wed Nov 15 14:48:32 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 15 Nov 2006 14:48:32 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineInstr.h Message-ID: <200611152048.kAFKmWOn030514@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineInstr.h updated: 1.196 -> 1.197 --- Log message: Add copyKillDeadInfo to copy kill / dead info; other minor updates. --- Diffs of the changes: (+28 -8) MachineInstr.h | 36 ++++++++++++++++++++++++++++-------- 1 files changed, 28 insertions(+), 8 deletions(-) Index: llvm/include/llvm/CodeGen/MachineInstr.h diff -u llvm/include/llvm/CodeGen/MachineInstr.h:1.196 llvm/include/llvm/CodeGen/MachineInstr.h:1.197 --- llvm/include/llvm/CodeGen/MachineInstr.h:1.196 Mon Nov 13 17:30:45 2006 +++ llvm/include/llvm/CodeGen/MachineInstr.h Wed Nov 15 14:48:17 2006 @@ -206,19 +206,19 @@ return IsDead; } void setIsKill() { - assert(isRegister() && "Wrong MachineOperand accessor"); + assert(isRegister() && !IsDef && "Wrong MachineOperand accessor"); IsKill = true; } void setIsDead() { - assert(isRegister() && "Wrong MachineOperand accessor"); + assert(isRegister() && IsDef && "Wrong MachineOperand accessor"); IsDead = true; } void unsetIsKill() { - assert(isRegister() && "Wrong MachineOperand accessor"); + assert(isRegister() && !IsDef && "Wrong MachineOperand accessor"); IsKill = false; } void unsetIsDead() { - assert(isRegister() && "Wrong MachineOperand accessor"); + assert(isRegister() && IsDef && "Wrong MachineOperand accessor"); IsDead = false; } @@ -261,7 +261,7 @@ } /// isIdenticalTo - Return true if this operand is identical to the specified - /// operand. + /// operand. Note: This method ignores isKill and isDead properties. bool isIdenticalTo(const MachineOperand &Other) const; /// ChangeToImmediate - Replace this operand with a new immediate operand of @@ -295,13 +295,13 @@ /// class MachineInstr { short Opcode; // the opcode + short NumImplicitOps; // Number of implicit operands (which + // are determined at construction time). + std::vector Operands; // the operands MachineInstr* prev, *next; // links for our intrusive list MachineBasicBlock* parent; // pointer to the owning basic block - unsigned NumImplicitOps; // Number of implicit operands (which - // are determined at construction time). - // OperandComplete - Return true if it's illegal to add a new operand bool OperandsComplete() const; @@ -376,6 +376,26 @@ delete removeFromParent(); } + /// copyKillDeadInfo - Copies kill / dead operand properties from MI. + /// + void copyKillDeadInfo(const MachineInstr *MI) { + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { + const MachineOperand &MO = MI->getOperand(i); + if (MO.isReg() && (MO.isKill() || MO.isDead())) { + for (unsigned j = 0, ee = getNumOperands(); j != ee; ++j) { + MachineOperand &MOp = getOperand(j); + if (MOp.isIdenticalTo(MO)) { + if (MO.isKill()) + MOp.setIsKill(); + else + MOp.setIsDead(); + break; + } + } + } + } + } + // // Debugging support // From evan.cheng at apple.com Wed Nov 15 14:52:14 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 15 Nov 2006 14:52:14 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveVariables.cpp Message-ID: <200611152052.kAFKqEpr030654@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveVariables.cpp updated: 1.62 -> 1.63 --- Log message: Do away with kill / dead maps. Move kill / dead info onto MI's. --- Diffs of the changes: (+107 -81) LiveVariables.cpp | 188 ++++++++++++++++++++++++++++++------------------------ 1 files changed, 107 insertions(+), 81 deletions(-) Index: llvm/lib/CodeGen/LiveVariables.cpp diff -u llvm/lib/CodeGen/LiveVariables.cpp:1.62 llvm/lib/CodeGen/LiveVariables.cpp:1.63 --- llvm/lib/CodeGen/LiveVariables.cpp:1.62 Fri Nov 10 02:38:19 2006 +++ llvm/lib/CodeGen/LiveVariables.cpp Wed Nov 15 14:51:59 2006 @@ -72,24 +72,56 @@ return VirtRegInfo[RegIdx]; } +/// registerOverlap - Returns true if register 1 is equal to register 2 +/// or if register 1 is equal to any of alias of register 2. +static bool registerOverlap(unsigned Reg1, unsigned Reg2, + const MRegisterInfo *RegInfo) { + bool isVirt1 = MRegisterInfo::isVirtualRegister(Reg1); + bool isVirt2 = MRegisterInfo::isVirtualRegister(Reg2); + if (isVirt1 != isVirt2) + return false; + if (Reg1 == Reg2) + return true; + else if (isVirt1) + return false; + for (const unsigned *AliasSet = RegInfo->getAliasSet(Reg2); + unsigned Alias = *AliasSet; ++AliasSet) { + if (Reg1 == Alias) + return true; + } + return false; +} + bool LiveVariables::KillsRegister(MachineInstr *MI, unsigned Reg) const { - std::map >::const_iterator I = - RegistersKilled.find(MI); - if (I == RegistersKilled.end()) return false; - - // Do a binary search, as these lists can grow pretty big, particularly for - // call instructions on targets with lots of call-clobbered registers. - return std::binary_search(I->second.begin(), I->second.end(), Reg); + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { + MachineOperand &MO = MI->getOperand(i); + if (MO.isReg() && MO.isKill()) { + if (registerOverlap(Reg, MO.getReg(), RegInfo)) + return true; + } + } + return false; } bool LiveVariables::RegisterDefIsDead(MachineInstr *MI, unsigned Reg) const { - std::map >::const_iterator I = - RegistersDead.find(MI); - if (I == RegistersDead.end()) return false; - - // Do a binary search, as these lists can grow pretty big, particularly for - // call instructions on targets with lots of call-clobbered registers. - return std::binary_search(I->second.begin(), I->second.end(), Reg); + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { + MachineOperand &MO = MI->getOperand(i); + if (MO.isReg() && MO.isDead()) + if (registerOverlap(Reg, MO.getReg(), RegInfo)) + return true; + } + return false; +} + +bool LiveVariables::ModifiesRegister(MachineInstr *MI, unsigned Reg) const { + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { + MachineOperand &MO = MI->getOperand(i); + if (MO.isReg() && MO.isDef()) { + if (registerOverlap(Reg, MO.getReg(), RegInfo)) + return true; + } + } + return false; } void LiveVariables::MarkVirtRegAliveInBlock(VarInfo &VRInfo, @@ -149,6 +181,26 @@ MarkVirtRegAliveInBlock(VRInfo, *PI); } +void LiveVariables::addRegisterKilled(unsigned IncomingReg, MachineInstr *MI) { + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { + MachineOperand &MO = MI->getOperand(i); + if (MO.isReg() && MO.isUse() && MO.getReg() == IncomingReg) { + MO.setIsKill(); + break; + } + } +} + +void LiveVariables::addRegisterDead(unsigned IncomingReg, MachineInstr *MI) { + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { + MachineOperand &MO = MI->getOperand(i); + if (MO.isReg() && MO.isDef() && MO.getReg() == IncomingReg) { + MO.setIsDead(); + break; + } + } +} + void LiveVariables::HandlePhysRegUse(unsigned Reg, MachineInstr *MI) { PhysRegInfo[Reg] = MI; PhysRegUsed[Reg] = true; @@ -164,9 +216,9 @@ // Does this kill a previous version of this register? if (MachineInstr *LastUse = PhysRegInfo[Reg]) { if (PhysRegUsed[Reg]) - RegistersKilled[LastUse].push_back(Reg); + addRegisterKilled(Reg, LastUse); else - RegistersDead[LastUse].push_back(Reg); + addRegisterDead(Reg, LastUse); } PhysRegInfo[Reg] = MI; PhysRegUsed[Reg] = false; @@ -175,9 +227,9 @@ unsigned Alias = *AliasSet; ++AliasSet) { if (MachineInstr *LastUse = PhysRegInfo[Alias]) { if (PhysRegUsed[Alias]) - RegistersKilled[LastUse].push_back(Alias); + addRegisterKilled(Alias, LastUse); else - RegistersDead[LastUse].push_back(Alias); + addRegisterDead(Alias, LastUse); } PhysRegInfo[Alias] = MI; PhysRegUsed[Alias] = false; @@ -286,7 +338,7 @@ } } - // Finally, if the last block in the function is a return, make sure to mark + // Finally, if the last instruction in the block is a return, make sure to mark // it as using all of the live-out values in the function. if (!MBB->empty() && TII.isReturn(MBB->back().getOpcode())) { MachineInstr *Ret = &MBB->back(); @@ -295,6 +347,8 @@ assert(MRegisterInfo::isPhysicalRegister(*I) && "Cannot have a live-in virtual register!"); HandlePhysRegUse(*I, Ret); + // Add live-out registers as implicit uses. + Ret->addRegOperand(*I, false, true); } } @@ -305,30 +359,19 @@ HandlePhysRegDef(i, 0); } - // Convert the information we have gathered into VirtRegInfo and transform it - // into a form usable by RegistersKilled. + // Convert and transfer the dead / killed information we have gathered into + // VirtRegInfo onto MI's. // for (unsigned i = 0, e = VirtRegInfo.size(); i != e; ++i) for (unsigned j = 0, e = VirtRegInfo[i].Kills.size(); j != e; ++j) { if (VirtRegInfo[i].Kills[j] == VirtRegInfo[i].DefInst) - RegistersDead[VirtRegInfo[i].Kills[j]].push_back( - i + MRegisterInfo::FirstVirtualRegister); - + addRegisterDead(i + MRegisterInfo::FirstVirtualRegister, + VirtRegInfo[i].Kills[j]); else - RegistersKilled[VirtRegInfo[i].Kills[j]].push_back( - i + MRegisterInfo::FirstVirtualRegister); + addRegisterKilled(i + MRegisterInfo::FirstVirtualRegister, + VirtRegInfo[i].Kills[j]); } - // Walk through the RegistersKilled/Dead sets, and sort the registers killed - // or dead. This allows us to use efficient binary search for membership - // testing. - for (std::map >::iterator - I = RegistersKilled.begin(), E = RegistersKilled.end(); I != E; ++I) - std::sort(I->second.begin(), I->second.end()); - for (std::map >::iterator - I = RegistersDead.begin(), E = RegistersDead.end(); I != E; ++I) - std::sort(I->second.begin(), I->second.end()); - // Check to make sure there are no unreachable blocks in the MC CFG for the // function. If so, it is due to a bug in the instruction selector or some // other part of the code generator if this happens. @@ -347,8 +390,8 @@ /// the records for NewMI. void LiveVariables::instructionChanged(MachineInstr *OldMI, MachineInstr *NewMI) { - // If the instruction defines any virtual registers, update the VarInfo for - // the instruction. + // If the instruction defines any virtual registers, update the VarInfo, + // kill and dead information for the instruction. for (unsigned i = 0, e = OldMI->getNumOperands(); i != e; ++i) { MachineOperand &MO = OldMI->getOperand(i); if (MO.isRegister() && MO.getReg() && @@ -356,74 +399,57 @@ unsigned Reg = MO.getReg(); VarInfo &VI = getVarInfo(Reg); if (MO.isDef()) { + if (MO.isDead()) { + MO.unsetIsDead(); + addVirtualRegisterDead(Reg, NewMI); + } // Update the defining instruction. if (VI.DefInst == OldMI) VI.DefInst = NewMI; } if (MO.isUse()) { + if (MO.isKill()) { + MO.unsetIsKill(); + addVirtualRegisterKilled(Reg, NewMI); + } // If this is a kill of the value, update the VI kills list. if (VI.removeKill(OldMI)) VI.Kills.push_back(NewMI); // Yes, there was a kill of it } } } - - // Move the killed information over... - killed_iterator I, E; - tie(I, E) = killed_range(OldMI); - if (I != E) { - std::vector &V = RegistersKilled[NewMI]; - bool WasEmpty = V.empty(); - V.insert(V.end(), I, E); - if (!WasEmpty) - std::sort(V.begin(), V.end()); // Keep the reg list sorted. - RegistersKilled.erase(OldMI); - } - - // Move the dead information over... - tie(I, E) = dead_range(OldMI); - if (I != E) { - std::vector &V = RegistersDead[NewMI]; - bool WasEmpty = V.empty(); - V.insert(V.end(), I, E); - if (!WasEmpty) - std::sort(V.begin(), V.end()); // Keep the reg list sorted. - RegistersDead.erase(OldMI); - } } /// removeVirtualRegistersKilled - Remove all killed info for the specified /// instruction. void LiveVariables::removeVirtualRegistersKilled(MachineInstr *MI) { - std::map >::iterator I = - RegistersKilled.find(MI); - if (I == RegistersKilled.end()) return; - - std::vector &Regs = I->second; - for (unsigned i = 0, e = Regs.size(); i != e; ++i) { - if (MRegisterInfo::isVirtualRegister(Regs[i])) { - bool removed = getVarInfo(Regs[i]).removeKill(MI); - assert(removed && "kill not in register's VarInfo?"); + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { + MachineOperand &MO = MI->getOperand(i); + if (MO.isReg() && MO.isKill()) { + MO.unsetIsKill(); + unsigned Reg = MO.getReg(); + if (MRegisterInfo::isVirtualRegister(Reg)) { + bool removed = getVarInfo(Reg).removeKill(MI); + assert(removed && "kill not in register's VarInfo?"); + } } } - RegistersKilled.erase(I); } /// removeVirtualRegistersDead - Remove all of the dead registers for the /// specified instruction from the live variable information. void LiveVariables::removeVirtualRegistersDead(MachineInstr *MI) { - std::map >::iterator I = - RegistersDead.find(MI); - if (I == RegistersDead.end()) return; - - std::vector &Regs = I->second; - for (unsigned i = 0, e = Regs.size(); i != e; ++i) { - if (MRegisterInfo::isVirtualRegister(Regs[i])) { - bool removed = getVarInfo(Regs[i]).removeKill(MI); - assert(removed && "kill not in register's VarInfo?"); + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { + MachineOperand &MO = MI->getOperand(i); + if (MO.isReg() && MO.isDead()) { + MO.unsetIsDead(); + unsigned Reg = MO.getReg(); + if (MRegisterInfo::isVirtualRegister(Reg)) { + bool removed = getVarInfo(Reg).removeKill(MI); + assert(removed && "kill not in register's VarInfo?"); + } } } - RegistersDead.erase(I); } /// analyzePHINodes - Gather information about the PHI nodes in here. In From evan.cheng at apple.com Wed Nov 15 14:54:26 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 15 Nov 2006 14:54:26 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Message-ID: <200611152054.kAFKsQqv030706@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervalAnalysis.cpp updated: 1.194 -> 1.195 --- Log message: A register def can be partially dead when the whole register has use(s) but a subreg does not. --- Diffs of the changes: (+8 -1) LiveIntervalAnalysis.cpp | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletion(-) Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.194 llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.195 --- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.194 Fri Nov 10 02:38:19 2006 +++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Wed Nov 15 14:54:11 2006 @@ -575,7 +575,6 @@ // A physical register cannot be live across basic block, so its // lifetime must end somewhere in its defining basic block. DEBUG(std::cerr << "\t\tregister: "; printRegName(interval.reg)); - typedef LiveVariables::killed_iterator KillIter; unsigned baseIndex = MIIdx; unsigned start = getDefIndex(baseIndex); @@ -599,6 +598,14 @@ DEBUG(std::cerr << " killed"); end = getUseIndex(baseIndex) + 1; goto exit; + } else if (lv_->ModifiesRegister(mi, interval.reg)) { + // Another instruction redefines the register before it is ever read. + // Then the register is essentially dead at the instruction that defines + // it. Hence its interval is: + // [defSlot(def), defSlot(def)+1) + DEBUG(std::cerr << " dead"); + end = getDefIndex(start) + 1; + goto exit; } } From evan.cheng at apple.com Wed Nov 15 14:54:44 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 15 Nov 2006 14:54:44 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/MachineInstr.cpp Message-ID: <200611152054.kAFKsiCt030723@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: MachineInstr.cpp updated: 1.130 -> 1.131 --- Log message: Minor updates. --- Diffs of the changes: (+4 -4) MachineInstr.cpp | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) Index: llvm/lib/CodeGen/MachineInstr.cpp diff -u llvm/lib/CodeGen/MachineInstr.cpp:1.130 llvm/lib/CodeGen/MachineInstr.cpp:1.131 --- llvm/lib/CodeGen/MachineInstr.cpp:1.130 Mon Nov 13 17:34:06 2006 +++ llvm/lib/CodeGen/MachineInstr.cpp Wed Nov 15 14:54:29 2006 @@ -38,7 +38,7 @@ /// Eventually, the "resizing" ctors will be phased out. /// MachineInstr::MachineInstr(short opcode, unsigned numOperands) - : Opcode(opcode), parent(0), NumImplicitOps(0) { + : Opcode(opcode), NumImplicitOps(0), parent(0) { Operands.reserve(numOperands); // Make sure that we get added to a machine basicblock LeakDetector::addGarbageObject(this); @@ -75,7 +75,7 @@ /// implicit operands. It reserves space for numOperand operands. MachineInstr::MachineInstr(const TargetInstrInfo &TII, short opcode, unsigned numOperands) - : Opcode(opcode), parent(0), NumImplicitOps(0) { + : Opcode(opcode), NumImplicitOps(0), parent(0) { const TargetInstrDescriptor &TID = TII.get(opcode); if (TID.ImplicitDefs) for (const unsigned *ImpDefs = TID.ImplicitDefs; *ImpDefs; ++ImpDefs) @@ -94,7 +94,7 @@ /// MachineInstr::MachineInstr(MachineBasicBlock *MBB, short opcode, unsigned numOperands) - : Opcode(opcode), parent(0), NumImplicitOps(0) { + : Opcode(opcode), NumImplicitOps(0), parent(0) { assert(MBB && "Cannot use inserting ctor with null basic block!"); const TargetInstrDescriptor &TID = MBB->getParent()->getTarget(). getInstrInfo()->get(opcode); @@ -115,9 +115,9 @@ /// MachineInstr::MachineInstr(const MachineInstr &MI) { Opcode = MI.getOpcode(); + NumImplicitOps = MI.NumImplicitOps; Operands.reserve(MI.getNumOperands()); - NumImplicitOps = MI.NumImplicitOps; // Add operands for (unsigned i = 0; i != MI.getNumOperands(); ++i) Operands.push_back(MI.getOperand(i)); From evan.cheng at apple.com Wed Nov 15 14:55:30 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 15 Nov 2006 14:55:30 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAllocLocal.cpp Message-ID: <200611152055.kAFKtUYY030745@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: RegAllocLocal.cpp updated: 1.94 -> 1.95 --- Log message: Match live variable changes. --- Diffs of the changes: (+56 -10) RegAllocLocal.cpp | 66 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 56 insertions(+), 10 deletions(-) Index: llvm/lib/CodeGen/RegAllocLocal.cpp diff -u llvm/lib/CodeGen/RegAllocLocal.cpp:1.94 llvm/lib/CodeGen/RegAllocLocal.cpp:1.95 --- llvm/lib/CodeGen/RegAllocLocal.cpp:1.94 Fri Nov 10 02:38:19 2006 +++ llvm/lib/CodeGen/RegAllocLocal.cpp Wed Nov 15 14:55:15 2006 @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #define DEBUG_TYPE "regalloc" +#include "llvm/BasicBlock.h" #include "llvm/CodeGen/Passes.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstr.h" @@ -26,6 +27,7 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/Compiler.h" #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Statistic.h" #include #include @@ -309,7 +311,18 @@ *AliasSet; ++AliasSet) if (PhysRegsUsed[*AliasSet] != -1 && // Spill aliased register. PhysRegsUsed[*AliasSet] != -2) // If allocatable. - if (PhysRegsUsed[*AliasSet] || !OnlyVirtRegs) + if (PhysRegsUsed[*AliasSet] == 0) { + // This must have been a dead def due to something like this: + // %EAX := + // := op %AL + // No more use of %EAX, %AH, etc. + // %EAX isn't dead upon definition, but %AH is. However %AH isn't + // an operand of definition MI so it's not marked as such. + DEBUG(std::cerr << " Register " << RegInfo->getName(*AliasSet) + << " [%reg" << *AliasSet + << "] is never used, removing it frame live list\n"); + removePhysReg(*AliasSet); + } else spillVirtReg(MBB, I, PhysRegsUsed[*AliasSet], *AliasSet); } } @@ -512,6 +525,9 @@ MachineBasicBlock::iterator MII = MBB.begin(); const TargetInstrInfo &TII = *TM->getInstrInfo(); + DEBUG(const BasicBlock *LBB = MBB.getBasicBlock(); + if (LBB) std::cerr << "\nStarting RegAlloc of BB: " << LBB->getName()); + // If this is the first basic block in the machine function, add live-in // registers as active. if (&MBB == &*MF->begin()) { @@ -552,6 +568,13 @@ MarkPhysRegRecentlyUsed(*ImplicitUses); } + SmallVector Kills; + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { + MachineOperand& MO = MI->getOperand(i); + if (MO.isRegister() && MO.isKill()) + Kills.push_back(MO.getReg()); + } + // Get the used operands into registers. This has the potential to spill // incoming values if we are out of registers. Note that we completely // ignore physical register uses here. We assume that if an explicit @@ -561,18 +584,17 @@ for (unsigned i = 0; i != MI->getNumOperands(); ++i) { MachineOperand& MO = MI->getOperand(i); // here we are looking for only used operands (never def&use) - if (MO.isRegister() && !MO.isDef() && !MO.isImplicit() && MO.getReg() && + if (MO.isRegister() && !MO.isDef() && MO.getReg() && !MO.isImplicit() && MRegisterInfo::isVirtualRegister(MO.getReg())) MI = reloadVirtReg(MBB, MI, i); } - // If this instruction is the last user of anything in registers, kill the + // If this instruction is the last user of this register, kill the // value, freeing the register being used, so it doesn't need to be // spilled to memory. // - for (LiveVariables::killed_iterator KI = LV->killed_begin(MI), - KE = LV->killed_end(MI); KI != KE; ++KI) { - unsigned VirtReg = *KI; + for (unsigned i = 0, e = Kills.size(); i != e; ++i) { + unsigned VirtReg = Kills[i]; unsigned PhysReg = VirtReg; if (MRegisterInfo::isVirtualRegister(VirtReg)) { // If the virtual register was never materialized into a register, it @@ -589,6 +611,15 @@ DEBUG(std::cerr << " Last use of " << RegInfo->getName(PhysReg) << "[%reg" << VirtReg <<"], removing it from live set\n"); removePhysReg(PhysReg); + for (const unsigned *AliasSet = RegInfo->getAliasSet(PhysReg); + *AliasSet; ++AliasSet) { + if (PhysRegsUsed[*AliasSet] != -2) { + DEBUG(std::cerr << " Last use of " + << RegInfo->getName(*AliasSet) + << "[%reg" << VirtReg <<"], removing it from live set\n"); + removePhysReg(*AliasSet); + } + } } } @@ -602,7 +633,7 @@ if (PhysRegsUsed[Reg] == -2) continue; // Something like ESP. PhysRegsEverUsed[Reg] = true; - spillPhysReg(MBB, MI, Reg, true); // Spill any existing value in the reg + spillPhysReg(MBB, MI, Reg, true); // Spill any existing value in reg PhysRegsUsed[Reg] = 0; // It is free and reserved now PhysRegsUseOrder.push_back(Reg); for (const unsigned *AliasSet = RegInfo->getAliasSet(Reg); @@ -642,6 +673,13 @@ } } + SmallVector DeadDefs; + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { + MachineOperand& MO = MI->getOperand(i); + if (MO.isRegister() && MO.isDead()) + DeadDefs.push_back(MO.getReg()); + } + // Okay, we have allocated all of the source operands and spilled any values // that would be destroyed by defs of this instruction. Loop over the // explicit defs and assign them to a register, spilling incoming values if @@ -666,9 +704,8 @@ // If this instruction defines any registers that are immediately dead, // kill them now. // - for (LiveVariables::killed_iterator KI = LV->dead_begin(MI), - KE = LV->dead_end(MI); KI != KE; ++KI) { - unsigned VirtReg = *KI; + for (unsigned i = 0, e = DeadDefs.size(); i != e; ++i) { + unsigned VirtReg = DeadDefs[i]; unsigned PhysReg = VirtReg; if (MRegisterInfo::isVirtualRegister(VirtReg)) { unsigned &PhysRegSlot = getVirt2PhysRegMapSlot(VirtReg); @@ -685,6 +722,15 @@ << " [%reg" << VirtReg << "] is never used, removing it frame live list\n"); removePhysReg(PhysReg); + for (const unsigned *AliasSet = RegInfo->getAliasSet(PhysReg); + *AliasSet; ++AliasSet) { + if (PhysRegsUsed[*AliasSet] != -2) { + DEBUG(std::cerr << " Register " << RegInfo->getName(*AliasSet) + << " [%reg" << *AliasSet + << "] is never used, removing it frame live list\n"); + removePhysReg(*AliasSet); + } + } } } From evan.cheng at apple.com Wed Nov 15 14:56:17 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 15 Nov 2006 14:56:17 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/TargetInstrInfo.cpp Message-ID: <200611152056.kAFKuHqW030768@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target: TargetInstrInfo.cpp updated: 1.21 -> 1.22 --- Log message: commuteInstruction should propagate kill / dead info. --- Diffs of the changes: (+10 -0) TargetInstrInfo.cpp | 10 ++++++++++ 1 files changed, 10 insertions(+) Index: llvm/lib/Target/TargetInstrInfo.cpp diff -u llvm/lib/Target/TargetInstrInfo.cpp:1.21 llvm/lib/Target/TargetInstrInfo.cpp:1.22 --- llvm/lib/Target/TargetInstrInfo.cpp:1.21 Wed Nov 1 17:14:15 2006 +++ llvm/lib/Target/TargetInstrInfo.cpp Wed Nov 15 14:56:03 2006 @@ -60,7 +60,17 @@ "This only knows how to commute register operands so far"); unsigned Reg1 = MI->getOperand(1).getReg(); unsigned Reg2 = MI->getOperand(2).getReg(); + bool Reg1IsKill = MI->getOperand(1).isKill(); + bool Reg2IsKill = MI->getOperand(2).isKill(); MI->getOperand(2).setReg(Reg1); MI->getOperand(1).setReg(Reg2); + if (Reg1IsKill) + MI->getOperand(2).setIsKill(); + else + MI->getOperand(2).unsetIsKill(); + if (Reg2IsKill) + MI->getOperand(1).setIsKill(); + else + MI->getOperand(1).unsetIsKill(); return MI; } From evan.cheng at apple.com Wed Nov 15 14:56:53 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 15 Nov 2006 14:56:53 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86FloatingPoint.cpp Message-ID: <200611152056.kAFKurhc030787@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86FloatingPoint.cpp updated: 1.59 -> 1.60 --- Log message: Kill / dead info has been moved to MI's. --- Diffs of the changes: (+11 -18) X86FloatingPoint.cpp | 29 +++++++++++------------------ 1 files changed, 11 insertions(+), 18 deletions(-) Index: llvm/lib/Target/X86/X86FloatingPoint.cpp diff -u llvm/lib/Target/X86/X86FloatingPoint.cpp:1.59 llvm/lib/Target/X86/X86FloatingPoint.cpp:1.60 --- llvm/lib/Target/X86/X86FloatingPoint.cpp:1.59 Tue Nov 14 13:20:33 2006 +++ llvm/lib/Target/X86/X86FloatingPoint.cpp Wed Nov 15 14:56:39 2006 @@ -40,6 +40,7 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/Compiler.h" #include "llvm/ADT/DepthFirstIterator.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/STLExtras.h" #include @@ -213,20 +214,12 @@ // Get dead variables list now because the MI pointer may be deleted as part // of processing! - LiveVariables::killed_iterator IB, IE; - tie(IB, IE) = LV->dead_range(MI); - - DEBUG( - const MRegisterInfo *MRI = MF.getTarget().getRegisterInfo(); - LiveVariables::killed_iterator I = LV->killed_begin(MI); - LiveVariables::killed_iterator E = LV->killed_end(MI); - if (I != E) { - std::cerr << "Killed Operands:"; - for (; I != E; ++I) - std::cerr << " %" << MRI->getName(*I); - std::cerr << "\n"; - } - ); + SmallVector DeadRegs; + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { + const MachineOperand &MO = MI->getOperand(i); + if (MO.isReg() && MO.isDead()) + DeadRegs.push_back(MO.getReg()); + } switch (Flags & X86II::FPTypeMask) { case X86II::ZeroArgFP: handleZeroArgFP(I); break; @@ -241,8 +234,8 @@ // Check to see if any of the values defined by this instruction are dead // after definition. If so, pop them. - for (; IB != IE; ++IB) { - unsigned Reg = *IB; + for (unsigned i = 0, e = DeadRegs.size(); i != e; ++i) { + unsigned Reg = DeadRegs[i]; if (Reg >= X86::FP0 && Reg <= X86::FP6) { DEBUG(std::cerr << "Register FP#" << Reg-X86::FP0 << " is dead!\n"); freeStackSlotAfter(I, Reg-X86::FP0); @@ -762,6 +755,7 @@ unsigned Op0 = getFPReg(MI->getOperand(0)); unsigned Op1 = getFPReg(MI->getOperand(2)); + bool KillsOp1 = LV->KillsRegister(MI, X86::FP0+Op1); // The first operand *must* be on the top of the stack. moveToTop(Op0, I); @@ -773,9 +767,8 @@ MI->getOperand(0).setReg(getSTReg(Op1)); MI->setOpcode(getConcreteOpcode(MI->getOpcode())); - // If we kill the second operand, make sure to pop it from the stack. - if (Op0 != Op1 && LV->KillsRegister(MI, X86::FP0+Op1)) { + if (Op0 != Op1 && KillsOp1) { // Get this value off of the register stack. freeStackSlotAfter(I, Op1); } From evan.cheng at apple.com Wed Nov 15 14:58:28 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 15 Nov 2006 14:58:28 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp Message-ID: <200611152058.kAFKwSfe030841@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaRegisterInfo.cpp updated: 1.51 -> 1.52 --- Log message: Properly transfer kill / dead info. --- Diffs of the changes: (+5 -2) AlphaRegisterInfo.cpp | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) Index: llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp diff -u llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.51 llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.52 --- llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.51 Mon Nov 13 17:36:35 2006 +++ llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp Wed Nov 15 14:58:11 2006 @@ -104,6 +104,7 @@ // Make sure this is a reg-reg copy. unsigned Opc = MI->getOpcode(); + MachineInstr *NewMI = NULL; switch(Opc) { default: break; @@ -115,18 +116,20 @@ unsigned InReg = MI->getOperand(1).getReg(); Opc = (Opc == Alpha::BISr) ? Alpha::STQ : ((Opc == Alpha::CPYSS) ? Alpha::STS : Alpha::STT); - return BuildMI(TII, Opc, 3).addReg(InReg).addFrameIndex(FrameIndex) + NewMI = BuildMI(TII, Opc, 3).addReg(InReg).addFrameIndex(FrameIndex) .addReg(Alpha::F31); } else { // load -> move unsigned OutReg = MI->getOperand(0).getReg(); Opc = (Opc == Alpha::BISr) ? Alpha::LDQ : ((Opc == Alpha::CPYSS) ? Alpha::LDS : Alpha::LDT); - return BuildMI(TII, Opc, 2, OutReg).addFrameIndex(FrameIndex) + NewMI = BuildMI(TII, Opc, 2, OutReg).addFrameIndex(FrameIndex) .addReg(Alpha::F31); } } break; } + if (NewMI) + NewMI->copyKillDeadInfo(MI); return 0; } From evan.cheng at apple.com Wed Nov 15 14:58:31 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 15 Nov 2006 14:58:31 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86InstrInfo.cpp X86RegisterInfo.cpp Message-ID: <200611152058.kAFKwVsR030856@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86InstrInfo.cpp updated: 1.72 -> 1.73 X86RegisterInfo.cpp updated: 1.177 -> 1.178 --- Log message: Properly transfer kill / dead info. --- Diffs of the changes: (+41 -21) X86InstrInfo.cpp | 41 +++++++++++++++++++++++++++-------------- X86RegisterInfo.cpp | 21 ++++++++++++++------- 2 files changed, 41 insertions(+), 21 deletions(-) Index: llvm/lib/Target/X86/X86InstrInfo.cpp diff -u llvm/lib/Target/X86/X86InstrInfo.cpp:1.72 llvm/lib/Target/X86/X86InstrInfo.cpp:1.73 --- llvm/lib/Target/X86/X86InstrInfo.cpp:1.72 Mon Nov 13 17:36:35 2006 +++ llvm/lib/Target/X86/X86InstrInfo.cpp Wed Nov 15 14:58:11 2006 @@ -130,6 +130,7 @@ unsigned Dest = MI->getOperand(0).getReg(); unsigned Src = MI->getOperand(1).getReg(); + MachineInstr *NewMI = NULL; switch (MI->getOpcode()) { default: break; case X86::SHUFPSrri: { @@ -140,7 +141,9 @@ unsigned C = MI->getOperand(2).getReg(); unsigned M = MI->getOperand(3).getImmedValue(); if (!Subtarget->hasSSE2() || B != C) return 0; - return BuildMI(*this, X86::PSHUFDri, 2, A).addReg(B).addImm(M); + NewMI = BuildMI(*this, X86::PSHUFDri, 2, A).addReg(B).addImm(M); + NewMI->copyKillDeadInfo(MI); + return NewMI; } } @@ -157,46 +160,51 @@ case X86::INC32r: case X86::INC64_32r: assert(MI->getNumOperands() == 2 && "Unknown inc instruction!"); - return addRegOffset(BuildMI(*this, X86::LEA32r, 5, Dest), Src, 1); + NewMI = addRegOffset(BuildMI(*this, X86::LEA32r, 5, Dest), Src, 1); + break; case X86::INC16r: case X86::INC64_16r: if (DisableLEA16) return 0; assert(MI->getNumOperands() == 2 && "Unknown inc instruction!"); - return addRegOffset(BuildMI(*this, X86::LEA16r, 5, Dest), Src, 1); + NewMI = addRegOffset(BuildMI(*this, X86::LEA16r, 5, Dest), Src, 1); + break; case X86::DEC32r: case X86::DEC64_32r: assert(MI->getNumOperands() == 2 && "Unknown dec instruction!"); - return addRegOffset(BuildMI(*this, X86::LEA32r, 5, Dest), Src, -1); + NewMI = addRegOffset(BuildMI(*this, X86::LEA32r, 5, Dest), Src, -1); + break; case X86::DEC16r: case X86::DEC64_16r: if (DisableLEA16) return 0; assert(MI->getNumOperands() == 2 && "Unknown dec instruction!"); - return addRegOffset(BuildMI(*this, X86::LEA16r, 5, Dest), Src, -1); + NewMI = addRegOffset(BuildMI(*this, X86::LEA16r, 5, Dest), Src, -1); + break; case X86::ADD32rr: assert(MI->getNumOperands() == 3 && "Unknown add instruction!"); - return addRegReg(BuildMI(*this, X86::LEA32r, 5, Dest), Src, + NewMI = addRegReg(BuildMI(*this, X86::LEA32r, 5, Dest), Src, MI->getOperand(2).getReg()); + break; case X86::ADD16rr: if (DisableLEA16) return 0; assert(MI->getNumOperands() == 3 && "Unknown add instruction!"); - return addRegReg(BuildMI(*this, X86::LEA16r, 5, Dest), Src, + NewMI = addRegReg(BuildMI(*this, X86::LEA16r, 5, Dest), Src, MI->getOperand(2).getReg()); + break; case X86::ADD32ri: case X86::ADD32ri8: assert(MI->getNumOperands() == 3 && "Unknown add instruction!"); if (MI->getOperand(2).isImmediate()) - return addRegOffset(BuildMI(*this, X86::LEA32r, 5, Dest), Src, + NewMI = addRegOffset(BuildMI(*this, X86::LEA32r, 5, Dest), Src, MI->getOperand(2).getImmedValue()); - return 0; + break; case X86::ADD16ri: case X86::ADD16ri8: if (DisableLEA16) return 0; assert(MI->getNumOperands() == 3 && "Unknown add instruction!"); if (MI->getOperand(2).isImmediate()) - return addRegOffset(BuildMI(*this, X86::LEA16r, 5, Dest), Src, + NewMI = addRegOffset(BuildMI(*this, X86::LEA16r, 5, Dest), Src, MI->getOperand(2).getImmedValue()); break; - case X86::SHL16ri: if (DisableLEA16) return 0; case X86::SHL32ri: @@ -208,12 +216,14 @@ AM.Scale = 1 << ShAmt; AM.IndexReg = Src; unsigned Opc = MI->getOpcode() == X86::SHL32ri ? X86::LEA32r :X86::LEA16r; - return addFullAddress(BuildMI(*this, Opc, 5, Dest), AM); + NewMI = addFullAddress(BuildMI(*this, Opc, 5, Dest), AM); } break; } - return 0; + if (NewMI) + NewMI->copyKillDeadInfo(MI); + return NewMI; } /// commuteInstruction - We have a few instructions that must be hacked on to @@ -239,7 +249,10 @@ unsigned A = MI->getOperand(0).getReg(); unsigned B = MI->getOperand(1).getReg(); unsigned C = MI->getOperand(2).getReg(); - return BuildMI(*this, Opc, 3, A).addReg(C).addReg(B).addImm(Size-Amt); + bool BisKill = MI->getOperand(1).isKill(); + bool CisKill = MI->getOperand(2).isKill(); + return BuildMI(*this, Opc, 3, A).addReg(C, false, false, CisKill) + .addReg(B, false, false, BisKill).addImm(Size-Amt); } default: return TargetInstrInfo::commuteInstruction(MI); Index: llvm/lib/Target/X86/X86RegisterInfo.cpp diff -u llvm/lib/Target/X86/X86RegisterInfo.cpp:1.177 llvm/lib/Target/X86/X86RegisterInfo.cpp:1.178 --- llvm/lib/Target/X86/X86RegisterInfo.cpp:1.177 Mon Nov 13 17:36:35 2006 +++ llvm/lib/Target/X86/X86RegisterInfo.cpp Wed Nov 15 14:58:11 2006 @@ -291,6 +291,7 @@ bool isTwoAddr = NumOps > 1 && TII.getOperandConstraint(MI->getOpcode(), 1,TargetInstrInfo::TIED_TO) != -1; + MachineInstr *NewMI = NULL; // Folding a memory location into the two-address part of a two-address // instruction is different than folding it other places. It requires // replacing the *two* registers with the memory location. @@ -465,13 +466,17 @@ isTwoAddrFold = true; } else if (i == 0) { // If operand 0 if (MI->getOpcode() == X86::MOV16r0) - return MakeM0Inst(TII, X86::MOV16mi, FrameIndex, MI); + NewMI = MakeM0Inst(TII, X86::MOV16mi, FrameIndex, MI); else if (MI->getOpcode() == X86::MOV32r0) - return MakeM0Inst(TII, X86::MOV32mi, FrameIndex, MI); + NewMI = MakeM0Inst(TII, X86::MOV32mi, FrameIndex, MI); else if (MI->getOpcode() == X86::MOV64r0) - return MakeM0Inst(TII, X86::MOV64mi32, FrameIndex, MI); + NewMI = MakeM0Inst(TII, X86::MOV64mi32, FrameIndex, MI); else if (MI->getOpcode() == X86::MOV8r0) - return MakeM0Inst(TII, X86::MOV8mi, FrameIndex, MI); + NewMI = MakeM0Inst(TII, X86::MOV8mi, FrameIndex, MI); + if (NewMI) { + NewMI->copyKillDeadInfo(MI); + return NewMI; + } static const TableEntry OpcodeTable[] = { { X86::CMP16ri, X86::CMP16mi }, @@ -828,9 +833,11 @@ if (const TableEntry *Entry = TableLookup(OpcodeTablePtr, OpcodeTableSize, fromOpcode)) { if (isTwoAddrFold) - return FuseTwoAddrInst(Entry->to, FrameIndex, MI, TII); - - return FuseInst(Entry->to, i, FrameIndex, MI, TII); + NewMI = FuseTwoAddrInst(Entry->to, FrameIndex, MI, TII); + else + NewMI = FuseInst(Entry->to, i, FrameIndex, MI, TII); + NewMI->copyKillDeadInfo(MI); + return NewMI; } } From evan.cheng at apple.com Wed Nov 15 14:58:31 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 15 Nov 2006 14:58:31 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcRegisterInfo.cpp Message-ID: <200611152058.kAFKwVOc030861@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: SparcRegisterInfo.cpp updated: 1.46 -> 1.47 --- Log message: Properly transfer kill / dead info. --- Diffs of the changes: (+9 -5) SparcRegisterInfo.cpp | 14 +++++++++----- 1 files changed, 9 insertions(+), 5 deletions(-) Index: llvm/lib/Target/Sparc/SparcRegisterInfo.cpp diff -u llvm/lib/Target/Sparc/SparcRegisterInfo.cpp:1.46 llvm/lib/Target/Sparc/SparcRegisterInfo.cpp:1.47 --- llvm/lib/Target/Sparc/SparcRegisterInfo.cpp:1.46 Mon Nov 13 17:36:35 2006 +++ llvm/lib/Target/Sparc/SparcRegisterInfo.cpp Wed Nov 15 14:58:11 2006 @@ -77,15 +77,16 @@ unsigned OpNum, int FI) const { bool isFloat = false; + MachineInstr *NewMI = NULL; switch (MI->getOpcode()) { case SP::ORrr: if (MI->getOperand(1).isRegister() && MI->getOperand(1).getReg() == SP::G0&& MI->getOperand(0).isRegister() && MI->getOperand(2).isRegister()) { if (OpNum == 0) // COPY -> STORE - return BuildMI(TII, SP::STri, 3).addFrameIndex(FI).addImm(0) + NewMI = BuildMI(TII, SP::STri, 3).addFrameIndex(FI).addImm(0) .addReg(MI->getOperand(2).getReg()); else // COPY -> LOAD - return BuildMI(TII, SP::LDri, 2, MI->getOperand(0).getReg()) + NewMI = BuildMI(TII, SP::LDri, 2, MI->getOperand(0).getReg()) .addFrameIndex(FI).addImm(0); } break; @@ -94,14 +95,17 @@ // FALLTHROUGH case SP::FMOVD: if (OpNum == 0) // COPY -> STORE - return BuildMI(TII, isFloat ? SP::STFri : SP::STDFri, 3) + NewMI = BuildMI(TII, isFloat ? SP::STFri : SP::STDFri, 3) .addFrameIndex(FI).addImm(0).addReg(MI->getOperand(1).getReg()); else // COPY -> LOAD - return BuildMI(TII, isFloat ? SP::LDFri : SP::LDDFri, 2, + NewMI = BuildMI(TII, isFloat ? SP::LDFri : SP::LDDFri, 2, MI->getOperand(0).getReg()).addFrameIndex(FI).addImm(0); break; } - return 0; + + if (NewMI) + NewMI->copyKillDeadInfo(MI); + return NewMI; } const unsigned* SparcRegisterInfo::getCalleeSaveRegs() const { From evan.cheng at apple.com Wed Nov 15 14:58:28 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 15 Nov 2006 14:58:28 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCInstrInfo.cpp PPCRegisterInfo.cpp Message-ID: <200611152058.kAFKwS1t030848@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCInstrInfo.cpp updated: 1.30 -> 1.31 PPCRegisterInfo.cpp updated: 1.83 -> 1.84 --- Log message: Properly transfer kill / dead info. --- Diffs of the changes: (+27 -13) PPCInstrInfo.cpp | 10 ++++++++++ PPCRegisterInfo.cpp | 30 +++++++++++++++++------------- 2 files changed, 27 insertions(+), 13 deletions(-) Index: llvm/lib/Target/PowerPC/PPCInstrInfo.cpp diff -u llvm/lib/Target/PowerPC/PPCInstrInfo.cpp:1.30 llvm/lib/Target/PowerPC/PPCInstrInfo.cpp:1.31 --- llvm/lib/Target/PowerPC/PPCInstrInfo.cpp:1.30 Mon Nov 13 17:36:35 2006 +++ llvm/lib/Target/PowerPC/PPCInstrInfo.cpp Wed Nov 15 14:58:11 2006 @@ -147,8 +147,18 @@ // Swap op1/op2 unsigned Reg1 = MI->getOperand(1).getReg(); unsigned Reg2 = MI->getOperand(2).getReg(); + bool Reg1IsKill = MI->getOperand(1).isKill(); + bool Reg2IsKill = MI->getOperand(2).isKill(); MI->getOperand(2).setReg(Reg1); MI->getOperand(1).setReg(Reg2); + if (Reg1IsKill) + MI->getOperand(2).setIsKill(); + else + MI->getOperand(2).unsetIsKill(); + if (Reg2IsKill) + MI->getOperand(1).setIsKill(); + else + MI->getOperand(1).unsetIsKill(); // Swap the mask around. unsigned MB = MI->getOperand(4).getImmedValue(); Index: llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp diff -u llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.83 llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.84 --- llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.83 Wed Nov 15 11:40:51 2006 +++ llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp Wed Nov 15 14:58:11 2006 @@ -337,47 +337,51 @@ // Make sure this is a reg-reg copy. Note that we can't handle MCRF, because // it takes more than one instruction to store it. unsigned Opc = MI->getOpcode(); - + + MachineInstr *NewMI = NULL; if ((Opc == PPC::OR && MI->getOperand(1).getReg() == MI->getOperand(2).getReg())) { if (OpNum == 0) { // move -> store unsigned InReg = MI->getOperand(1).getReg(); - return addFrameReference(BuildMI(TII, PPC::STW, - 3).addReg(InReg), FrameIndex); + NewMI = addFrameReference(BuildMI(TII, PPC::STW, + 3).addReg(InReg), FrameIndex); } else { // move -> load unsigned OutReg = MI->getOperand(0).getReg(); - return addFrameReference(BuildMI(TII, PPC::LWZ, 2, OutReg), FrameIndex); + NewMI = addFrameReference(BuildMI(TII, PPC::LWZ, 2, OutReg), FrameIndex); } } else if ((Opc == PPC::OR8 && MI->getOperand(1).getReg() == MI->getOperand(2).getReg())) { if (OpNum == 0) { // move -> store unsigned InReg = MI->getOperand(1).getReg(); - return addFrameReference(BuildMI(TII, PPC::STD, - 3).addReg(InReg), FrameIndex); + NewMI = addFrameReference(BuildMI(TII, PPC::STD, + 3).addReg(InReg), FrameIndex); } else { // move -> load unsigned OutReg = MI->getOperand(0).getReg(); - return addFrameReference(BuildMI(TII, PPC::LD, 2, OutReg), FrameIndex); + NewMI = addFrameReference(BuildMI(TII, PPC::LD, 2, OutReg), FrameIndex); } } else if (Opc == PPC::FMRD) { if (OpNum == 0) { // move -> store unsigned InReg = MI->getOperand(1).getReg(); - return addFrameReference(BuildMI(TII, PPC::STFD, - 3).addReg(InReg), FrameIndex); + NewMI = addFrameReference(BuildMI(TII, PPC::STFD, + 3).addReg(InReg), FrameIndex); } else { // move -> load unsigned OutReg = MI->getOperand(0).getReg(); - return addFrameReference(BuildMI(TII, PPC::LFD, 2, OutReg), FrameIndex); + NewMI = addFrameReference(BuildMI(TII, PPC::LFD, 2, OutReg), FrameIndex); } } else if (Opc == PPC::FMRS) { if (OpNum == 0) { // move -> store unsigned InReg = MI->getOperand(1).getReg(); - return addFrameReference(BuildMI(TII, PPC::STFS, + NewMI = addFrameReference(BuildMI(TII, PPC::STFS, 3).addReg(InReg), FrameIndex); } else { // move -> load unsigned OutReg = MI->getOperand(0).getReg(); - return addFrameReference(BuildMI(TII, PPC::LFS, 2, OutReg), FrameIndex); + NewMI = addFrameReference(BuildMI(TII, PPC::LFS, 2, OutReg), FrameIndex); } } - return 0; + + if (NewMI) + NewMI->copyKillDeadInfo(MI); + return NewMI; } //===----------------------------------------------------------------------===// From sabre at nondot.org Wed Nov 15 15:04:30 2006 From: sabre at nondot.org (Chris Lattner) Date: Wed, 15 Nov 2006 15:04:30 -0600 Subject: [llvm-commits] CVS: llvm/Makefile.rules Message-ID: <200611152104.kAFL4UIb031004@zion.cs.uiuc.edu> Changes in directory llvm: Makefile.rules updated: 1.409 -> 1.410 --- Log message: Fix typo pointed out by Bryan Adams --- Diffs of the changes: (+1 -1) Makefile.rules | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/Makefile.rules diff -u llvm/Makefile.rules:1.409 llvm/Makefile.rules:1.410 --- llvm/Makefile.rules:1.409 Fri Nov 10 18:00:31 2006 +++ llvm/Makefile.rules Wed Nov 15 15:04:15 2006 @@ -747,7 +747,7 @@ ifdef LINK_LIBS_IN_SHARED ifdef LOADABLE_MODULE -SharedLibKindMessage := "Lodable Module" +SharedLibKindMessage := "Loadable Module" else SharedLibKindMessage := "Shared Library" endif From reid at x10sys.com Wed Nov 15 15:41:31 2006 From: reid at x10sys.com (Reid Spencer) Date: Wed, 15 Nov 2006 15:41:31 -0600 Subject: [llvm-commits] CVS: llvm-test/SingleSource/UnitTests/SignlessTypes/cast2.cpp Message-ID: <200611152141.kAFLfVqN031648@zion.cs.uiuc.edu> Changes in directory llvm-test/SingleSource/UnitTests/SignlessTypes: cast2.cpp added (r1.1) --- Log message: A test case, derived from MultiSource/Applications/hbd involving the incorrect ZEXT of a cast involved in a setcc. --- Diffs of the changes: (+15 -0) cast2.cpp | 15 +++++++++++++++ 1 files changed, 15 insertions(+) Index: llvm-test/SingleSource/UnitTests/SignlessTypes/cast2.cpp diff -c /dev/null llvm-test/SingleSource/UnitTests/SignlessTypes/cast2.cpp:1.1 *** /dev/null Wed Nov 15 15:41:26 2006 --- llvm-test/SingleSource/UnitTests/SignlessTypes/cast2.cpp Wed Nov 15 15:41:16 2006 *************** *** 0 **** --- 1,15 ---- + #include + int bug(unsigned char inbuff) + { + int incnum = (signed char)(inbuff); + if ((incnum!=1)&&(incnum!=-1)) { + return (incnum > 1) ? 42 : 23 ; + } else { + return 17; + } + } + + int main(int argc, char** argv) + { + printf("%d\n", bug(-1)); + } From sabre at nondot.org Wed Nov 15 16:55:19 2006 From: sabre at nondot.org (Chris Lattner) Date: Wed, 15 Nov 2006 16:55:19 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Target.td Message-ID: <200611152255.kAFMtJ0h000372@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target: Target.td updated: 1.89 -> 1.90 --- Log message: add a new field needed by the code emitter generator. --- Diffs of the changes: (+4 -0) Target.td | 4 ++++ 1 files changed, 4 insertions(+) Index: llvm/lib/Target/Target.td diff -u llvm/lib/Target/Target.td:1.89 llvm/lib/Target/Target.td:1.90 --- llvm/lib/Target/Target.td:1.89 Fri Nov 3 17:52:18 2006 +++ llvm/lib/Target/Target.td Wed Nov 15 16:55:04 2006 @@ -173,6 +173,10 @@ InstrItinClass Itinerary = NoItinerary;// Execution steps used for scheduling. string Constraints = ""; + + /// DisableEncoding - List of operand names (e.g. "$op1,$op2") that should not + /// be encoded into the output machineinstr. + string DisableEncoding = ""; } /// Imp - Helper class for specifying the implicit uses/defs set for an From sabre at nondot.org Wed Nov 15 17:23:17 2006 From: sabre at nondot.org (Chris Lattner) Date: Wed, 15 Nov 2006 17:23:17 -0600 Subject: [llvm-commits] CVS: llvm/utils/TableGen/AsmWriterEmitter.cpp CodeEmitterGen.cpp CodeGenInstruction.h CodeGenTarget.cpp Message-ID: <200611152323.kAFNNHe4000869@zion.cs.uiuc.edu> Changes in directory llvm/utils/TableGen: AsmWriterEmitter.cpp updated: 1.45 -> 1.46 CodeEmitterGen.cpp updated: 1.50 -> 1.51 CodeGenInstruction.h updated: 1.24 -> 1.25 CodeGenTarget.cpp updated: 1.78 -> 1.79 --- Log message: Remove the isTwoAddress property from the CodeGenInstruction class. It should not be used for anything other than backwards compat constraint handling. Add support for a new DisableEncoding property which contains a list of registers that should not be encoded by the generated code emitter. Convert the codeemitter generator to use this, fixing some PPC JIT regressions. --- Diffs of the changes: (+53 -19) AsmWriterEmitter.cpp | 11 +++-------- CodeEmitterGen.cpp | 18 +++++++++--------- CodeGenInstruction.h | 25 ++++++++++++++++++++++++- CodeGenTarget.cpp | 18 +++++++++++++++++- 4 files changed, 53 insertions(+), 19 deletions(-) Index: llvm/utils/TableGen/AsmWriterEmitter.cpp diff -u llvm/utils/TableGen/AsmWriterEmitter.cpp:1.45 llvm/utils/TableGen/AsmWriterEmitter.cpp:1.46 --- llvm/utils/TableGen/AsmWriterEmitter.cpp:1.45 Sun Nov 5 13:31:28 2006 +++ llvm/utils/TableGen/AsmWriterEmitter.cpp Wed Nov 15 17:23:02 2006 @@ -220,16 +220,11 @@ unsigned OpNo = CGI.getOperandNamed(VarName); CodeGenInstruction::OperandInfo OpInfo = CGI.OperandList[OpNo]; - // If this is a two-address instruction, verify the second operand isn't - // used. - unsigned MIOp = OpInfo.MIOperandNo; - if (CGI.isTwoAddress && MIOp == 1) - throw "Should refer to operand #0 instead of #1 for two-address" - " instruction '" + CGI.TheDef->getName() + "'!"; - - if (CurVariant == Variant || CurVariant == ~0U) + if (CurVariant == Variant || CurVariant == ~0U) { + unsigned MIOp = OpInfo.MIOperandNo; Operands.push_back(AsmWriterOperand(OpInfo.PrinterMethodName, MIOp, Modifier)); + } } LastEmitted = VarEnd; } Index: llvm/utils/TableGen/CodeEmitterGen.cpp diff -u llvm/utils/TableGen/CodeEmitterGen.cpp:1.50 llvm/utils/TableGen/CodeEmitterGen.cpp:1.51 --- llvm/utils/TableGen/CodeEmitterGen.cpp:1.50 Thu Nov 2 19:48:30 2006 +++ llvm/utils/TableGen/CodeEmitterGen.cpp Wed Nov 15 17:23:02 2006 @@ -125,7 +125,8 @@ BitsInit *BI = R->getValueAsBitsInit("Inst"); const std::vector &Vals = R->getValues(); - + CodeGenInstruction &CGI = Target.getInstruction(InstName); + // Loop over all of the fields in the instruction, determining which are the // operands to the instruction. unsigned op = 0; @@ -154,16 +155,15 @@ } if (!gotOp) { + /// If this operand is not supposed to be emitted by the generated + /// emitter, skip it. + while (CGI.isFlatOperandNotEmitted(op)) + ++op; + Case += " // op: " + VarName + "\n" + " op = getMachineOpValue(MI, MI.getOperand(" - + utostr(op++) - + "));\n"; + + utostr(op++) + "));\n"; gotOp = true; - - // If this is a two-address instruction and we just got the dest - // op, skip the src op. - if (op == 1 && Target.getInstruction(InstName).isTwoAddress) - ++op; } unsigned opMask = (1 << N) - 1; @@ -185,7 +185,7 @@ } } - std::vector &InstList = CaseMap[Case]; + std::vector &InstList = CaseMap[Case]; InstList.push_back(InstName); } Index: llvm/utils/TableGen/CodeGenInstruction.h diff -u llvm/utils/TableGen/CodeGenInstruction.h:1.24 llvm/utils/TableGen/CodeGenInstruction.h:1.25 --- llvm/utils/TableGen/CodeGenInstruction.h:1.24 Tue Nov 14 20:38:17 2006 +++ llvm/utils/TableGen/CodeGenInstruction.h Wed Nov 15 17:23:02 2006 @@ -57,6 +57,11 @@ unsigned MIOperandNo; unsigned MINumOperands; // The number of operands. + /// DoNotEncode - Bools are set to true in this vector for each operand in + /// the DisableEncoding list. These should not be emitted by the code + /// emitter. + std::vector DoNotEncode; + /// MIOperandInfo - Default MI operand type. Note an operand may be made /// up of multiple MI operands. DagInit *MIOperandInfo; @@ -82,7 +87,6 @@ bool isCall; bool isLoad; bool isStore; - bool isTwoAddress; bool isPredicated; bool isConvertibleToThreeAddress; bool isCommutable; @@ -107,6 +111,25 @@ return OperandList[Op.first].MIOperandNo + Op.second; } + /// getSubOperandNumber - Unflatten a operand number into an + /// operand/suboperand pair. + std::pair getSubOperandNumber(unsigned Op) const { + for (unsigned i = 0; ; ++i) { + assert(i < OperandList.size() && "Invalid flat operand #"); + if (OperandList[i].MIOperandNo+OperandList[i].MINumOperands > Op) + return std::make_pair(i, Op-OperandList[i].MIOperandNo); + } + } + + + /// isFlatOperandNotEmitted - Return true if the specified flat operand # + /// should not be emitted with the code emitter. + bool isFlatOperandNotEmitted(unsigned FlatOpNo) const { + std::pair Op = getSubOperandNumber(FlatOpNo); + if (OperandList[Op.first].DoNotEncode.size() > Op.second) + return OperandList[Op.first].DoNotEncode[Op.second]; + return false; + } CodeGenInstruction(Record *R, const std::string &AsmStr); Index: llvm/utils/TableGen/CodeGenTarget.cpp diff -u llvm/utils/TableGen/CodeGenTarget.cpp:1.78 llvm/utils/TableGen/CodeGenTarget.cpp:1.79 --- llvm/utils/TableGen/CodeGenTarget.cpp:1.78 Tue Nov 14 20:38:17 2006 +++ llvm/utils/TableGen/CodeGenTarget.cpp Wed Nov 15 17:23:02 2006 @@ -343,7 +343,7 @@ isCall = R->getValueAsBit("isCall"); isLoad = R->getValueAsBit("isLoad"); isStore = R->getValueAsBit("isStore"); - isTwoAddress = R->getValueAsBit("isTwoAddress"); + bool isTwoAddress = R->getValueAsBit("isTwoAddress"); isPredicated = false; // set below. isConvertibleToThreeAddress = R->getValueAsBit("isConvertibleToThreeAddress"); isCommutable = R->getValueAsBit("isCommutable"); @@ -413,6 +413,7 @@ MIOperandNo += NumOps; } + // Parse Constraints. ParseConstraints(R->getValueAsString("Constraints"), this); // For backward compatibility: isTwoAddress means operand 1 is tied to @@ -430,6 +431,21 @@ for (unsigned j = 0, e = OperandList[op].MINumOperands; j != e; ++j) if (OperandList[op].Constraints[j].empty()) OperandList[op].Constraints[j] = "0"; + + // Parse the DisableEncoding field. + std::string DisableEncoding = R->getValueAsString("DisableEncoding"); + while (1) { + std::string OpName = getToken(DisableEncoding, " ,\t"); + if (OpName.empty()) break; + + // Figure out which operand this is. + std::pair Op = ParseOperandName(OpName, false); + + // Mark the operand as not-to-be encoded. + if (Op.second >= OperandList[Op.first].DoNotEncode.size()) + OperandList[Op.first].DoNotEncode.resize(Op.second+1); + OperandList[Op.first].DoNotEncode[Op.second] = true; + } } From sabre at nondot.org Wed Nov 15 17:24:32 2006 From: sabre at nondot.org (Chris Lattner) Date: Wed, 15 Nov 2006 17:24:32 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCInstr64Bit.td PPCInstrFormats.td PPCInstrInfo.td Message-ID: <200611152324.kAFNOWhE000922@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCInstr64Bit.td updated: 1.28 -> 1.29 PPCInstrFormats.td updated: 1.83 -> 1.84 PPCInstrInfo.td updated: 1.261 -> 1.262 --- Log message: Stop using isTwoAddress, switching to operand constraints instead. Tell the codegen emitter that specific operands are not to be encoded, fixing JIT regressions w.r.t. pre-inc loads and stores (e.g. lwzu, which we generate even when general preinc loads are not enabled). --- Diffs of the changes: (+54 -38) PPCInstr64Bit.td | 29 +++++++++++++++----------- PPCInstrFormats.td | 5 ---- PPCInstrInfo.td | 58 +++++++++++++++++++++++++++++++++-------------------- 3 files changed, 54 insertions(+), 38 deletions(-) Index: llvm/lib/Target/PowerPC/PPCInstr64Bit.td diff -u llvm/lib/Target/PowerPC/PPCInstr64Bit.td:1.28 llvm/lib/Target/PowerPC/PPCInstr64Bit.td:1.29 --- llvm/lib/Target/PowerPC/PPCInstr64Bit.td:1.28 Wed Nov 15 13:55:13 2006 +++ llvm/lib/Target/PowerPC/PPCInstr64Bit.td Wed Nov 15 17:24:18 2006 @@ -246,11 +246,12 @@ [(set G8RC:$rT, (mul G8RC:$rA, G8RC:$rB))]>, isPPC64; -let isTwoAddress = 1, isCommutable = 1 in { +let isCommutable = 1 in { def RLDIMI : MDForm_1<30, 3, (ops G8RC:$rA, G8RC:$rSi, G8RC:$rS, u6imm:$SH, u6imm:$MB), "rldimi $rA, $rS, $SH, $MB", IntRotateD, - []>, isPPC64; + []>, isPPC64, RegConstraint<"$rSi = $rA">, + NoEncode<"$rSi">; } // Rotate instructions. @@ -290,10 +291,11 @@ PPC970_DGroup_Cracked; // Update forms. -def LHAU8 : DForm_1<43, (ops G8RC:$rD, ptr_rc:$rA_result, symbolLo:$disp, +def LHAU8 : DForm_1<43, (ops G8RC:$rD, ptr_rc:$ea_result, symbolLo:$disp, ptr_rc:$rA), "lhau $rD, $disp($rA)", LdStGeneral, - []>, RegConstraint<"$rA = $rA_result">; + []>, RegConstraint<"$rA = $ea_result">, + NoEncode<"$ea_result">; // NO LWAU! } @@ -324,14 +326,16 @@ // Update forms. def LBZU8 : DForm_1<35, (ops G8RC:$rD, ptr_rc:$ea_result, memri:$addr), "lbzu $rD, $addr", LdStGeneral, - []>, RegConstraint<"$addr.reg = $ea_result">; + []>, RegConstraint<"$addr.reg = $ea_result">, + NoEncode<"$ea_result">; def LHZU8 : DForm_1<41, (ops G8RC:$rD, ptr_rc:$ea_result, memri:$addr), "lhzu $rD, $addr", LdStGeneral, - []>, RegConstraint<"$addr.reg = $ea_result">; + []>, RegConstraint<"$addr.reg = $ea_result">, + NoEncode<"$ea_result">; def LWZU8 : DForm_1<33, (ops G8RC:$rD, ptr_rc:$ea_result, memri:$addr), "lwzu $rD, $addr", LdStGeneral, - []>, RegConstraint<"$addr.reg = $ea_result">; - + []>, RegConstraint<"$addr.reg = $ea_result">, + NoEncode<"$ea_result">; } @@ -346,7 +350,8 @@ def LDU : DSForm_1<58, 1, (ops G8RC:$rD, ptr_rc:$ea_result, memrix:$addr), "ldu $rD, $addr", LdStLD, - []>, RegConstraint<"$addr.reg = $ea_result">, isPPC64; + []>, RegConstraint<"$addr.reg = $ea_result">, isPPC64, + NoEncode<"$ea_result">; } @@ -378,13 +383,13 @@ // Truncating stores. -def STB8 : DForm_3<38, (ops G8RC:$rS, memri:$src), +def STB8 : DForm_1<38, (ops G8RC:$rS, memri:$src), "stb $rS, $src", LdStGeneral, [(truncstorei8 G8RC:$rS, iaddr:$src)]>; -def STH8 : DForm_3<44, (ops G8RC:$rS, memri:$src), +def STH8 : DForm_1<44, (ops G8RC:$rS, memri:$src), "sth $rS, $src", LdStGeneral, [(truncstorei16 G8RC:$rS, iaddr:$src)]>; -def STW8 : DForm_3<36, (ops G8RC:$rS, memri:$src), +def STW8 : DForm_1<36, (ops G8RC:$rS, memri:$src), "stw $rS, $src", LdStGeneral, [(truncstorei32 G8RC:$rS, iaddr:$src)]>; def STBX8 : XForm_8<31, 215, (ops G8RC:$rS, memrr:$dst), Index: llvm/lib/Target/PowerPC/PPCInstrFormats.td diff -u llvm/lib/Target/PowerPC/PPCInstrFormats.td:1.83 llvm/lib/Target/PowerPC/PPCInstrFormats.td:1.84 --- llvm/lib/Target/PowerPC/PPCInstrFormats.td:1.83 Fri Nov 10 17:58:45 2006 +++ llvm/lib/Target/PowerPC/PPCInstrFormats.td Wed Nov 15 17:24:18 2006 @@ -120,11 +120,6 @@ let Inst{16-31} = B; } -// Currently we make the use/def reg distinction in ISel, not tablegen -class DForm_3 opcode, dag OL, string asmstr, InstrItinClass itin, - list pattern> - : DForm_1; - class DForm_4 opcode, dag OL, string asmstr, InstrItinClass itin, list pattern> : I { Index: llvm/lib/Target/PowerPC/PPCInstrInfo.td diff -u llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.261 llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.262 --- llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.261 Wed Nov 15 13:55:13 2006 +++ llvm/lib/Target/PowerPC/PPCInstrInfo.td Wed Nov 15 17:24:18 2006 @@ -200,6 +200,9 @@ class RegConstraint { string Constraints = C; } +class NoEncode { + string DisableEncoding = E; +} //===----------------------------------------------------------------------===// @@ -438,26 +441,33 @@ // Unindexed (r+i) Loads with Update (preinc). def LBZU : DForm_1<35, (ops GPRC:$rD, ptr_rc:$ea_result, memri:$addr), "lbzu $rD, $addr", LdStGeneral, - []>, RegConstraint<"$addr.reg = $ea_result">; + []>, RegConstraint<"$addr.reg = $ea_result">, + NoEncode<"$ea_result">; def LHAU : DForm_1<43, (ops GPRC:$rD, ptr_rc:$ea_result, memri:$addr), "lhau $rD, $addr", LdStGeneral, - []>, RegConstraint<"$addr.reg = $ea_result">; + []>, RegConstraint<"$addr.reg = $ea_result">, + NoEncode<"$ea_result">; def LHZU : DForm_1<41, (ops GPRC:$rD, ptr_rc:$ea_result, memri:$addr), "lhzu $rD, $addr", LdStGeneral, - []>, RegConstraint<"$addr.reg = $ea_result">; + []>, RegConstraint<"$addr.reg = $ea_result">, + NoEncode<"$ea_result">; def LWZU : DForm_1<33, (ops GPRC:$rD, ptr_rc:$ea_result, memri:$addr), "lwzu $rD, $addr", LdStGeneral, - []>, RegConstraint<"$addr.reg = $ea_result">; + []>, RegConstraint<"$addr.reg = $ea_result">, + NoEncode<"$ea_result">; def LFSU : DForm_1<49, (ops F4RC:$rD, ptr_rc:$ea_result, memri:$addr), "lfs $rD, $addr", LdStLFDU, - []>, RegConstraint<"$addr.reg = $ea_result">; + []>, RegConstraint<"$addr.reg = $ea_result">, + NoEncode<"$ea_result">; + def LFDU : DForm_1<51, (ops F8RC:$rD, ptr_rc:$ea_result, memri:$addr), "lfd $rD, $addr", LdStLFD, - []>, RegConstraint<"$addr.reg = $ea_result">; + []>, RegConstraint<"$addr.reg = $ea_result">, + NoEncode<"$ea_result">; } // Indexed (r+r) Loads. @@ -499,13 +509,13 @@ // Unindexed (r+i) Stores. let isStore = 1, noResults = 1, PPC970_Unit = 2 in { -def STB : DForm_3<38, (ops GPRC:$rS, memri:$src), +def STB : DForm_1<38, (ops GPRC:$rS, memri:$src), "stb $rS, $src", LdStGeneral, [(truncstorei8 GPRC:$rS, iaddr:$src)]>; -def STH : DForm_3<44, (ops GPRC:$rS, memri:$src), +def STH : DForm_1<44, (ops GPRC:$rS, memri:$src), "sth $rS, $src", LdStGeneral, [(truncstorei16 GPRC:$rS, iaddr:$src)]>; -def STW : DForm_3<36, (ops GPRC:$rS, memri:$src), +def STW : DForm_1<36, (ops GPRC:$rS, memri:$src), "stw $rS, $src", LdStGeneral, [(store GPRC:$rS, iaddr:$src)]>; def STFS : DForm_1<52, (ops F4RC:$rS, memri:$dst), @@ -518,28 +528,33 @@ // Unindexed (r+i) Stores with Update (preinc). let isStore = 1, PPC970_Unit = 2 in { -def STBU : DForm_3<39, (ops ptr_rc:$ea_res, GPRC:$rS, memri:$addr), +def STBU : DForm_1<39, (ops ptr_rc:$ea_res, GPRC:$rS, memri:$addr), "stbu $rS, $addr", LdStGeneral, [/*(set ptr_rc:$ea_res, (pre_truncsti8 GPRC:$rS, iaddr:$addr))*/]>, - RegConstraint<"$addr.reg = $ea_res">; -def STHU : DForm_3<37, (ops ptr_rc:$ea_res, GPRC:$rS, memri:$addr), + RegConstraint<"$addr.reg = $ea_res">, + NoEncode<"$ea_res">; +def STHU : DForm_1<37, (ops ptr_rc:$ea_res, GPRC:$rS, memri:$addr), "sthu $rS, $addr", LdStGeneral, [/*(set ptr_rc:$ea_res, (pre_truncsti16 GPRC:$rS, iaddr:$addr))*/]>, - RegConstraint<"$addr.reg = $ea_res">; -def STWU : DForm_3<37, (ops ptr_rc:$ea_res, GPRC:$rS, memri:$addr), + RegConstraint<"$addr.reg = $ea_res">, + NoEncode<"$ea_res">; +def STWU : DForm_1<37, (ops ptr_rc:$ea_res, GPRC:$rS, memri:$addr), "stwu $rS, $addr", LdStGeneral, [/*(set ptr_rc:$ea_res, (pre_store GPRC:$rS, iaddr:$addr))*/]>, - RegConstraint<"$addr.reg = $ea_res">; -def STFSU : DForm_3<37, (ops ptr_rc:$ea_res, F4RC:$rS, memri:$addr), + RegConstraint<"$addr.reg = $ea_res">, + NoEncode<"$ea_res">; +def STFSU : DForm_1<37, (ops ptr_rc:$ea_res, F4RC:$rS, memri:$addr), "stfsu $rS, $addr", LdStGeneral, [/*(set ptr_rc:$ea_res, (pre_store F4RC:$rS, iaddr:$addr))*/]>, - RegConstraint<"$addr.reg = $ea_res">; -def STFDU : DForm_3<37, (ops ptr_rc:$ea_res, F8RC:$rS, memri:$addr), + RegConstraint<"$addr.reg = $ea_res">, + NoEncode<"$ea_res">; +def STFDU : DForm_1<37, (ops ptr_rc:$ea_res, F8RC:$rS, memri:$addr), "stfdu $rS, $addr", LdStGeneral, [/*(set ptr_rc:$ea_res, (pre_store F8RC:$rS, iaddr:$addr))*/]>, - RegConstraint<"$addr.reg = $ea_res">; + RegConstraint<"$addr.reg = $ea_res">, + NoEncode<"$ea_res">; } @@ -965,12 +980,13 @@ let PPC970_Unit = 1 in { // FXU Operations. // M-Form instructions. rotate and mask instructions. // -let isTwoAddress = 1, isCommutable = 1 in { +let isCommutable = 1 in { // RLWIMI can be commuted if the rotate amount is zero. def RLWIMI : MForm_2<20, (ops GPRC:$rA, GPRC:$rSi, GPRC:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME), "rlwimi $rA, $rS, $SH, $MB, $ME", IntRotate, - []>, PPC970_DGroup_Cracked; + []>, PPC970_DGroup_Cracked, RegConstraint<"$rSi = $rA">, + NoEncode<"$rSi">; } def RLWINM : MForm_2<21, (ops GPRC:$rA, GPRC:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME), From sabre at nondot.org Wed Nov 15 17:35:45 2006 From: sabre at nondot.org (Chris Lattner) Date: Wed, 15 Nov 2006 17:35:45 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp Message-ID: <200611152335.kAFNZjP7001158@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCRegisterInfo.cpp updated: 1.84 -> 1.85 --- Log message: Fix ppc64 epilog bug. --- Diffs of the changes: (+1 -1) PPCRegisterInfo.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp diff -u llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.84 llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.85 --- llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.84 Wed Nov 15 14:58:11 2006 +++ llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp Wed Nov 15 17:35:30 2006 @@ -767,7 +767,7 @@ // Get the number of bytes allocated from the FrameInfo. unsigned NumBytes = MFI->getStackSize(); - unsigned GPRSize = 4; + unsigned GPRSize = Subtarget.isPPC64() ? 8 : 4; if (NumBytes != 0) { // If this function has a frame pointer, load the saved stack pointer from From evan.cheng at apple.com Wed Nov 15 17:55:17 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 15 Nov 2006 17:55:17 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineInstr.h Message-ID: <200611152355.kAFNtHGL001453@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineInstr.h updated: 1.197 -> 1.198 --- Log message: ChangeToRegister should clear IsImp bit. --- Diffs of the changes: (+4 -4) MachineInstr.h | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) Index: llvm/include/llvm/CodeGen/MachineInstr.h diff -u llvm/include/llvm/CodeGen/MachineInstr.h:1.197 llvm/include/llvm/CodeGen/MachineInstr.h:1.198 --- llvm/include/llvm/CodeGen/MachineInstr.h:1.197 Wed Nov 15 14:48:17 2006 +++ llvm/include/llvm/CodeGen/MachineInstr.h Wed Nov 15 17:55:03 2006 @@ -275,13 +275,13 @@ /// ChangeToRegister - Replace this operand with a new register operand of /// the specified value. If an operand is known to be an register already, /// the setReg method should be used. - void ChangeToRegister(unsigned Reg, bool isDef, - bool isKill = false, bool isDead = false) { + void ChangeToRegister(unsigned Reg, bool isDef) { opType = MO_Register; contents.RegNo = Reg; IsDef = isDef; - IsKill = isKill; - IsDead = isDead; + IsImp = false; + IsKill = false; + IsDead = false; } friend std::ostream& operator<<(std::ostream& os, const MachineOperand& mop); From evan.cheng at apple.com Wed Nov 15 18:08:34 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 15 Nov 2006 18:08:34 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp SelectionDAG.cpp Message-ID: <200611160008.kAG08YJN001684@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: DAGCombiner.cpp updated: 1.252 -> 1.253 SelectionDAG.cpp updated: 1.373 -> 1.374 --- Log message: Fix an incorrectly inverted condition. --- Diffs of the changes: (+1 -2) DAGCombiner.cpp | 2 +- SelectionDAG.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp diff -u llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.252 llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.253 --- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.252 Fri Nov 10 19:00:15 2006 +++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Wed Nov 15 18:08:20 2006 @@ -2856,7 +2856,7 @@ } else return false; - if (!Ptr.Val->hasOneUse()) + if (Ptr.Val->hasOneUse()) return false; for (SDNode::use_iterator I = Ptr.Val->use_begin(), Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.373 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.374 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.373 Sat Nov 11 14:07:59 2006 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Wed Nov 15 18:08:20 2006 @@ -1481,7 +1481,6 @@ // Perform various simplifications. ConstantSDNode *N1C = dyn_cast(N1.Val); ConstantSDNode *N2C = dyn_cast(N2.Val); - //ConstantSDNode *N3C = dyn_cast(N3.Val); switch (Opcode) { case ISD::SETCC: { // Use FoldSetCC to simplify SETCC's. From sabre at nondot.org Wed Nov 15 18:33:48 2006 From: sabre at nondot.org (Chris Lattner) Date: Wed, 15 Nov 2006 18:33:48 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCInstrInfo.td Message-ID: <200611160033.kAG0Xmp0002102@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCInstrInfo.td updated: 1.262 -> 1.263 --- Log message: switch these back to the 'bad old way' --- Diffs of the changes: (+20 -20) PPCInstrInfo.td | 40 ++++++++++++++++++++-------------------- 1 files changed, 20 insertions(+), 20 deletions(-) Index: llvm/lib/Target/PowerPC/PPCInstrInfo.td diff -u llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.262 llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.263 --- llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.262 Wed Nov 15 17:24:18 2006 +++ llvm/lib/Target/PowerPC/PPCInstrInfo.td Wed Nov 15 18:33:34 2006 @@ -528,33 +528,33 @@ // Unindexed (r+i) Stores with Update (preinc). let isStore = 1, PPC970_Unit = 2 in { -def STBU : DForm_1<39, (ops ptr_rc:$ea_res, GPRC:$rS, memri:$addr), - "stbu $rS, $addr", LdStGeneral, +def STBU : DForm_1<39, (ops ptr_rc:$ea_res, GPRC:$rS, + symbolLo:$ptroff, ptr_rc:$ptrreg), + "stbu $rS, $ptroff($ptrreg)", LdStGeneral, [/*(set ptr_rc:$ea_res, (pre_truncsti8 GPRC:$rS, iaddr:$addr))*/]>, - RegConstraint<"$addr.reg = $ea_res">, - NoEncode<"$ea_res">; -def STHU : DForm_1<37, (ops ptr_rc:$ea_res, GPRC:$rS, memri:$addr), - "sthu $rS, $addr", LdStGeneral, + RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">; +def STHU : DForm_1<37, (ops ptr_rc:$ea_res, GPRC:$rS, + symbolLo:$ptroff, ptr_rc:$ptrreg), + "sthu $rS, $ptroff($ptrreg)", LdStGeneral, [/*(set ptr_rc:$ea_res, (pre_truncsti16 GPRC:$rS, iaddr:$addr))*/]>, - RegConstraint<"$addr.reg = $ea_res">, - NoEncode<"$ea_res">; -def STWU : DForm_1<37, (ops ptr_rc:$ea_res, GPRC:$rS, memri:$addr), - "stwu $rS, $addr", LdStGeneral, + RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">; +def STWU : DForm_1<37, (ops ptr_rc:$ea_res, GPRC:$rS, + symbolLo:$ptroff, ptr_rc:$ptrreg), + "stwu $rS, $ptroff($ptrreg)", LdStGeneral, [/*(set ptr_rc:$ea_res, (pre_store GPRC:$rS, iaddr:$addr))*/]>, - RegConstraint<"$addr.reg = $ea_res">, - NoEncode<"$ea_res">; -def STFSU : DForm_1<37, (ops ptr_rc:$ea_res, F4RC:$rS, memri:$addr), - "stfsu $rS, $addr", LdStGeneral, + RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">; +def STFSU : DForm_1<37, (ops ptr_rc:$ea_res, F4RC:$rS, + symbolLo:$ptroff, ptr_rc:$ptrreg), + "stfsu $rS, $ptroff($ptrreg)", LdStGeneral, [/*(set ptr_rc:$ea_res, (pre_store F4RC:$rS, iaddr:$addr))*/]>, - RegConstraint<"$addr.reg = $ea_res">, - NoEncode<"$ea_res">; -def STFDU : DForm_1<37, (ops ptr_rc:$ea_res, F8RC:$rS, memri:$addr), - "stfdu $rS, $addr", LdStGeneral, + RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">; +def STFDU : DForm_1<37, (ops ptr_rc:$ea_res, F8RC:$rS, + symbolLo:$ptroff, ptr_rc:$ptrreg), + "stfdu $rS, $ptroff($ptrreg)", LdStGeneral, [/*(set ptr_rc:$ea_res, (pre_store F8RC:$rS, iaddr:$addr))*/]>, - RegConstraint<"$addr.reg = $ea_res">, - NoEncode<"$ea_res">; + RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">; } From sabre at nondot.org Wed Nov 15 18:41:51 2006 From: sabre at nondot.org (Chris Lattner) Date: Wed, 15 Nov 2006 18:41:51 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp PPCInstrInfo.td Message-ID: <200611160041.kAG0fpxk002263@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCISelDAGToDAG.cpp updated: 1.220 -> 1.221 PPCInstrInfo.td updated: 1.263 -> 1.264 --- Log message: add patterns for ppc32 preinc stores. ppc64 next. --- Diffs of the changes: (+22 -7) PPCISelDAGToDAG.cpp | 8 ++++++++ PPCInstrInfo.td | 21 ++++++++++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) Index: llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp diff -u llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:1.220 llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:1.221 --- llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:1.220 Wed Nov 15 13:55:13 2006 +++ llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp Wed Nov 15 18:41:37 2006 @@ -108,6 +108,14 @@ SDOperand &Base) { return PPCLowering.SelectAddressRegImm(N, Disp, Base, *CurDAG); } + + /// SelectAddrImmOffs - Return true if the operand is valid for a preinc + /// immediate field. Because preinc imms have already been validated, just + /// accept it. + bool SelectAddrImmOffs(SDOperand Op, SDOperand N, SDOperand &Out) const { + Out = N; + return true; + } /// SelectAddrIdx - Given the specified addressed, check to see if it can be /// represented as an indexed [r+r] operation. Returns false if it can Index: llvm/lib/Target/PowerPC/PPCInstrInfo.td diff -u llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.263 llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.264 --- llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.263 Wed Nov 15 18:33:34 2006 +++ llvm/lib/Target/PowerPC/PPCInstrInfo.td Wed Nov 15 18:41:37 2006 @@ -273,6 +273,8 @@ def xoaddr : ComplexPattern; def ixaddr : ComplexPattern; // "std" +/// This is just the offset part of iaddr, used for preinc. +def iaddroff : ComplexPattern; //===----------------------------------------------------------------------===// // PowerPC Instruction Predicate Definitions. @@ -531,29 +533,34 @@ def STBU : DForm_1<39, (ops ptr_rc:$ea_res, GPRC:$rS, symbolLo:$ptroff, ptr_rc:$ptrreg), "stbu $rS, $ptroff($ptrreg)", LdStGeneral, - [/*(set ptr_rc:$ea_res, - (pre_truncsti8 GPRC:$rS, iaddr:$addr))*/]>, + [(set ptr_rc:$ea_res, + (pre_truncsti8 GPRC:$rS, ptr_rc:$ptrreg, + iaddroff:$ptroff))]>, RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">; def STHU : DForm_1<37, (ops ptr_rc:$ea_res, GPRC:$rS, symbolLo:$ptroff, ptr_rc:$ptrreg), "sthu $rS, $ptroff($ptrreg)", LdStGeneral, - [/*(set ptr_rc:$ea_res, - (pre_truncsti16 GPRC:$rS, iaddr:$addr))*/]>, + [(set ptr_rc:$ea_res, + (pre_truncsti16 GPRC:$rS, ptr_rc:$ptrreg, + iaddroff:$ptroff))]>, RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">; def STWU : DForm_1<37, (ops ptr_rc:$ea_res, GPRC:$rS, symbolLo:$ptroff, ptr_rc:$ptrreg), "stwu $rS, $ptroff($ptrreg)", LdStGeneral, - [/*(set ptr_rc:$ea_res, (pre_store GPRC:$rS, iaddr:$addr))*/]>, + [(set ptr_rc:$ea_res, (pre_store GPRC:$rS, ptr_rc:$ptrreg, + iaddroff:$ptroff))]>, RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">; def STFSU : DForm_1<37, (ops ptr_rc:$ea_res, F4RC:$rS, symbolLo:$ptroff, ptr_rc:$ptrreg), "stfsu $rS, $ptroff($ptrreg)", LdStGeneral, - [/*(set ptr_rc:$ea_res, (pre_store F4RC:$rS, iaddr:$addr))*/]>, + [(set ptr_rc:$ea_res, (pre_store F4RC:$rS, ptr_rc:$ptrreg, + iaddroff:$ptroff))]>, RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">; def STFDU : DForm_1<37, (ops ptr_rc:$ea_res, F8RC:$rS, symbolLo:$ptroff, ptr_rc:$ptrreg), "stfdu $rS, $ptroff($ptrreg)", LdStGeneral, - [/*(set ptr_rc:$ea_res, (pre_store F8RC:$rS, iaddr:$addr))*/]>, + [(set ptr_rc:$ea_res, (pre_store F8RC:$rS, ptr_rc:$ptrreg, + iaddroff:$ptroff))]>, RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">; } From sabre at nondot.org Wed Nov 15 18:57:34 2006 From: sabre at nondot.org (Chris Lattner) Date: Wed, 15 Nov 2006 18:57:34 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCHazardRecognizers.cpp PPCInstr64Bit.td Message-ID: <200611160057.kAG0vYVs002585@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCHazardRecognizers.cpp updated: 1.16 -> 1.17 PPCInstr64Bit.td updated: 1.29 -> 1.30 --- Log message: add ppc64 r+i stores with update. --- Diffs of the changes: (+72 -40) PPCHazardRecognizers.cpp | 27 +++++++------- PPCInstr64Bit.td | 85 ++++++++++++++++++++++++++++++++--------------- 2 files changed, 72 insertions(+), 40 deletions(-) Index: llvm/lib/Target/PowerPC/PPCHazardRecognizers.cpp diff -u llvm/lib/Target/PowerPC/PPCHazardRecognizers.cpp:1.16 llvm/lib/Target/PowerPC/PPCHazardRecognizers.cpp:1.17 --- llvm/lib/Target/PowerPC/PPCHazardRecognizers.cpp:1.16 Tue Nov 14 20:43:19 2006 +++ llvm/lib/Target/PowerPC/PPCHazardRecognizers.cpp Wed Nov 15 18:57:19 2006 @@ -234,28 +234,26 @@ unsigned ThisStoreSize; switch (Opcode) { default: assert(0 && "Unknown store instruction!"); - case PPC::STB: case PPC::STBU: - case PPC::STBX: - case PPC::STB8: - case PPC::STBX8: + case PPC::STB: case PPC::STB8: + case PPC::STBU: case PPC::STBU8: + case PPC::STBX: case PPC::STBX8: case PPC::STVEBX: ThisStoreSize = 1; break; - case PPC::STH: case PPC::STHU: - case PPC::STHX: - case PPC::STH8: - case PPC::STHX8: + case PPC::STH: case PPC::STH8: + case PPC::STHU: case PPC::STHU8: + case PPC::STHX: case PPC::STHX8: case PPC::STVEHX: case PPC::STHBRX: ThisStoreSize = 2; break; - case PPC::STFS: case PPC::STFSU: + case PPC::STFS: + case PPC::STFSU: case PPC::STFSX: - case PPC::STWX: + case PPC::STWX: case PPC::STWX8: case PPC::STWUX: - case PPC::STW: case PPC::STWU: - case PPC::STW8: - case PPC::STWX8: + case PPC::STW: case PPC::STW8: + case PPC::STWU: case PPC::STWU8: case PPC::STVEWX: case PPC::STFIWX: case PPC::STWBRX: @@ -263,7 +261,8 @@ break; case PPC::STD_32: case PPC::STDX_32: - case PPC::STD: case PPC::STDU: + case PPC::STD: + case PPC::STDU: case PPC::STFD: case PPC::STFDX: case PPC::STDX: Index: llvm/lib/Target/PowerPC/PPCInstr64Bit.td diff -u llvm/lib/Target/PowerPC/PPCInstr64Bit.td:1.29 llvm/lib/Target/PowerPC/PPCInstr64Bit.td:1.30 --- llvm/lib/Target/PowerPC/PPCInstr64Bit.td:1.29 Wed Nov 15 17:24:18 2006 +++ llvm/lib/Target/PowerPC/PPCInstr64Bit.td Wed Nov 15 18:57:19 2006 @@ -356,32 +356,6 @@ } let isStore = 1, noResults = 1, PPC970_Unit = 2 in { -// Normal stores. -def STD : DSForm_1<62, 0, (ops G8RC:$rS, memrix:$dst), - "std $rS, $dst", LdStSTD, - [(store G8RC:$rS, ixaddr:$dst)]>, isPPC64; -def STDX : XForm_8<31, 149, (ops G8RC:$rS, memrr:$dst), - "stdx $rS, $dst", LdStSTD, - [(store G8RC:$rS, xaddr:$dst)]>, isPPC64, - PPC970_DGroup_Cracked; - -def STDU : DSForm_1<62, 1, (ops G8RC:$ea_res, G8RC:$rS, memrix:$dst), - "stdu $rS, $dst", LdStSTD, - []>, isPPC64; -def STDUX : XForm_8<31, 181, (ops G8RC:$rS, memrr:$dst), - "stdux $rS, $dst", LdStSTD, - []>, isPPC64; - -// STD_32/STDX_32 - Just like STD/STDX, but uses a '32-bit' input register. -def STD_32 : DSForm_1<62, 0, (ops GPRC:$rT, memrix:$dst), - "std $rT, $dst", LdStSTD, - [(PPCstd_32 GPRC:$rT, ixaddr:$dst)]>, isPPC64; -def STDX_32 : XForm_8<31, 149, (ops GPRC:$rT, memrr:$dst), - "stdx $rT, $dst", LdStSTD, - [(PPCstd_32 GPRC:$rT, xaddr:$dst)]>, isPPC64, - PPC970_DGroup_Cracked; - - // Truncating stores. def STB8 : DForm_1<38, (ops G8RC:$rS, memri:$src), "stb $rS, $src", LdStGeneral, @@ -404,6 +378,65 @@ "stwx $rS, $dst", LdStGeneral, [(truncstorei32 G8RC:$rS, xaddr:$dst)]>, PPC970_DGroup_Cracked; +// Normal 8-byte stores. +def STD : DSForm_1<62, 0, (ops G8RC:$rS, memrix:$dst), + "std $rS, $dst", LdStSTD, + [(store G8RC:$rS, ixaddr:$dst)]>, isPPC64; +def STDX : XForm_8<31, 149, (ops G8RC:$rS, memrr:$dst), + "stdx $rS, $dst", LdStSTD, + [(store G8RC:$rS, xaddr:$dst)]>, isPPC64, + PPC970_DGroup_Cracked; +} + +let isStore = 1, PPC970_Unit = 2 in { + +def STBU8 : DForm_1<38, (ops ptr_rc:$ea_res, G8RC:$rS, + symbolLo:$ptroff, ptr_rc:$ptrreg), + "stbu $rS, $ptroff($ptrreg)", LdStGeneral, + [(set ptr_rc:$ea_res, + (pre_truncsti8 G8RC:$rS, ptr_rc:$ptrreg, + iaddroff:$ptroff))]>, + RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">; +def STHU8 : DForm_1<45, (ops ptr_rc:$ea_res, G8RC:$rS, + symbolLo:$ptroff, ptr_rc:$ptrreg), + "sthu $rS, $ptroff($ptrreg)", LdStGeneral, + [(set ptr_rc:$ea_res, + (pre_truncsti16 G8RC:$rS, ptr_rc:$ptrreg, + iaddroff:$ptroff))]>, + RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">; +def STWU8 : DForm_1<37, (ops ptr_rc:$ea_res, G8RC:$rS, + symbolLo:$ptroff, ptr_rc:$ptrreg), + "stwu $rS, $ptroff($ptrreg)", LdStGeneral, + [(set ptr_rc:$ea_res, (pre_store G8RC:$rS, ptr_rc:$ptrreg, + iaddroff:$ptroff))]>, + RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">; + + +def STDU : DSForm_1<62, 1, (ops ptr_rc:$ea_res, G8RC:$rS, + symbolLo:$ptroff, ptr_rc:$ptrreg), + "stdu $rS, $ptroff($ptrreg)", LdStSTD, + [(set ptr_rc:$ea_res, (pre_store G8RC:$rS, ptr_rc:$ptrreg, + iaddroff:$ptroff))]>, + RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">, + isPPC64; + +} + +let isStore = 1, noResults = 1, PPC970_Unit = 2 in { + +def STDUX : XForm_8<31, 181, (ops G8RC:$rS, memrr:$dst), + "stdux $rS, $dst", LdStSTD, + []>, isPPC64; + + +// STD_32/STDX_32 - Just like STD/STDX, but uses a '32-bit' input register. +def STD_32 : DSForm_1<62, 0, (ops GPRC:$rT, memrix:$dst), + "std $rT, $dst", LdStSTD, + [(PPCstd_32 GPRC:$rT, ixaddr:$dst)]>, isPPC64; +def STDX_32 : XForm_8<31, 149, (ops GPRC:$rT, memrr:$dst), + "stdx $rT, $dst", LdStSTD, + [(PPCstd_32 GPRC:$rT, xaddr:$dst)]>, isPPC64, + PPC970_DGroup_Cracked; } From sabre at nondot.org Wed Nov 15 19:00:21 2006 From: sabre at nondot.org (Chris Lattner) Date: Wed, 15 Nov 2006 19:00:21 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LLVMTargetMachine.cpp Message-ID: <200611160100.kAG10LpK002687@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LLVMTargetMachine.cpp updated: 1.5 -> 1.6 --- Log message: enable the branch folding pass for the JIT. --- Diffs of the changes: (+3 -0) LLVMTargetMachine.cpp | 3 +++ 1 files changed, 3 insertions(+) Index: llvm/lib/CodeGen/LLVMTargetMachine.cpp diff -u llvm/lib/CodeGen/LLVMTargetMachine.cpp:1.5 llvm/lib/CodeGen/LLVMTargetMachine.cpp:1.6 --- llvm/lib/CodeGen/LLVMTargetMachine.cpp:1.5 Tue Nov 7 13:33:46 2006 +++ llvm/lib/CodeGen/LLVMTargetMachine.cpp Wed Nov 15 19:00:07 2006 @@ -147,6 +147,9 @@ if (PrintMachineCode) // Print the register-allocated code PM.add(createMachineFunctionPrinterPass(&std::cerr)); + // Branch folding must be run after regalloc and prolog/epilog insertion. + if (!Fast) + PM.add(createBranchFoldingPass()); if (addPreEmitPass(PM, Fast) && PrintMachineCode) PM.add(createMachineFunctionPrinterPass(&std::cerr)); From sabre at nondot.org Wed Nov 15 19:01:42 2006 From: sabre at nondot.org (Chris Lattner) Date: Wed, 15 Nov 2006 19:01:42 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCInstrInfo.td Message-ID: <200611160101.kAG11gNR002766@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCInstrInfo.td updated: 1.264 -> 1.265 --- Log message: fix broken encoding --- Diffs of the changes: (+1 -1) PPCInstrInfo.td | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Target/PowerPC/PPCInstrInfo.td diff -u llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.264 llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.265 --- llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.264 Wed Nov 15 18:41:37 2006 +++ llvm/lib/Target/PowerPC/PPCInstrInfo.td Wed Nov 15 19:01:28 2006 @@ -537,7 +537,7 @@ (pre_truncsti8 GPRC:$rS, ptr_rc:$ptrreg, iaddroff:$ptroff))]>, RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">; -def STHU : DForm_1<37, (ops ptr_rc:$ea_res, GPRC:$rS, +def STHU : DForm_1<45, (ops ptr_rc:$ea_res, GPRC:$rS, symbolLo:$ptroff, ptr_rc:$ptrreg), "sthu $rS, $ptroff($ptrreg)", LdStGeneral, [(set ptr_rc:$ea_res, From wendling at apple.com Wed Nov 15 19:03:04 2006 From: wendling at apple.com (Bill Wendling) Date: Wed, 15 Nov 2006 17:03:04 -0800 Subject: [llvm-commits] Priority-Based Coloring Approach to Register Allocation Message-ID: Hi all, This is meant for a code review and NOT for submission (just yet). This is my implementation of Chow & Hennesey's Priority-Based Coloring Approach to Register Allocation. It's still in the experimental stages (though it compiles the tests). I'd like people to look at it and let me know what you think. The patch included is needed for compilation. You'd place the "RegAllocGraphColoring.cpp" file in the llvm/lib/ CodeGen directory. You can use the graph coloring with the commandline: llc -regalloc=graphcoloring foo.bc All comments are welcome! -bw -------------- next part -------------- A non-text attachment was scrubbed... Name: RegAllocGraphColoring.cpp Type: application/octet-stream Size: 38966 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20061115/f9dd6422/attachment.obj -------------- next part -------------- -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: ra-patch.txt Url: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20061115/f9dd6422/attachment.txt From sabre at nondot.org Wed Nov 15 19:23:07 2006 From: sabre at nondot.org (Chris Lattner) Date: Wed, 15 Nov 2006 19:23:07 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/CodeGen/PowerPC/mem_update.ll Message-ID: <200611160123.kAG1N7IX003123@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/CodeGen/PowerPC: mem_update.ll updated: 1.3 -> 1.4 --- Log message: make this harder --- Diffs of the changes: (+26 -0) mem_update.ll | 26 ++++++++++++++++++++++++++ 1 files changed, 26 insertions(+) Index: llvm/test/Regression/CodeGen/PowerPC/mem_update.ll diff -u llvm/test/Regression/CodeGen/PowerPC/mem_update.ll:1.3 llvm/test/Regression/CodeGen/PowerPC/mem_update.ll:1.4 --- llvm/test/Regression/CodeGen/PowerPC/mem_update.ll:1.3 Fri Nov 10 18:13:07 2006 +++ llvm/test/Regression/CodeGen/PowerPC/mem_update.ll Wed Nov 15 19:22:52 2006 @@ -2,6 +2,7 @@ ; RUN: llvm-as < %s | llc -march=ppc32 -enable-ppc-preinc | not grep addi && ; RUN: llvm-as < %s | llc -march=ppc64 -enable-ppc-preinc && ; RUN: llvm-as < %s | llc -march=ppc64 -enable-ppc-preinc | not grep addi +%Glob = global ulong 4 int *%test0(int *%X, int *%dest) { %Y = getelementptr int* %X, int 4 @@ -33,6 +34,13 @@ ret ushort* %Y } +short *%test3a(short *%X, long *%dest) { + %Y = getelementptr short* %X, int 4 + %A = load short* %Y + %B = cast short %A to long + store long %B, long* %dest + ret short* %Y +} long *%test4(long *%X, long *%dest) { %Y = getelementptr long* %X, int 4 @@ -40,3 +48,21 @@ store long %A, long* %dest ret long* %Y } + +ushort *%test5(ushort *%X) { + %Y = getelementptr ushort* %X, int 4 + store ushort 7, ushort* %Y + ret ushort* %Y +} + +ulong *%test6(ulong *%X, ulong %A) { + %Y = getelementptr ulong* %X, int 4 + store ulong %A, ulong* %Y + ret ulong* %Y +} + +ulong *%test7(ulong *%X, ulong %A) { + store ulong %A, ulong* %Glob + ret ulong *%Glob +} + From clattner at apple.com Wed Nov 15 20:04:23 2006 From: clattner at apple.com (Chris Lattner) Date: Wed, 15 Nov 2006 18:04:23 -0800 Subject: [llvm-commits] Priority-Based In-Reply-To: References: Message-ID: On Nov 15, 2006, at 5:03 PM, Bill Wendling wrote: > Hi all, > > This is meant for a code review and NOT for submission (just yet). > This is my implementation of Chow & Hennesey's Priority-Based > Coloring Approach to Register Allocation. It's still in the > experimental stages (though it compiles the tests). I'd like people > to look at it and let me know what you think. The patch included is > needed for compilation. You'd place the "RegAllocGraphColoring.cpp" > file in the llvm/lib/CodeGen directory. You can use the graph > coloring with the commandline: Cool. I'll review the patch. Evan, can you take a first look at the new file? The patch looks good, but please: 1. Change CreateNewLiveInterval to take LRs by const reference. This will require changing the iterators to be const_iterator instead of just iterator's. 2. Please change "int* X" to "int *X" to fit with the rest of the code. 3. Why do this? + lv_ = getAnalysisToUpdate(); Isn't lv_ already valid when the method is called? 4. I don't think this is sufficient: + MachineOperand& MOp = MI->getOperand(J); + if (MOp.isRegister() && MOp.getReg() == LI->reg) { In particular, consider if you have two vregs (R1025 and R1027) that get coallesced before RA. When this happens I believe that live intervals just marks the two vregs as having the same interval, and that interval only has one reg (say R1027). When this happens, the actual machine instrs are not updated. This means that you can have a reference to R1025, even though the interval says it is R1027. To fix this, try using: + MachineOperand& MOp = MI->getOperand(J); + if (MOp.isRegister() && rep(MOp.getReg()) == LI->reg) { which should handle this case. 5. It is unclear to me why you have this loop: + for (unsigned K = J + 1; K != MI->getNumOperands(); ++K) + if (MI->getOperand(K).isReg() && + MI->getOperand(K).getReg() == LI->reg) + MI->getOperand(K).setReg(NewVReg); If not needed, just remove it. 6. I don't think this is right: + // Update live variables if it is available + if (lv_) + lv_->addVirtualRegisterKilled(NewVReg, MI); With Evan's recent change, kill/dead markers are now stored on the instruction. If MOp.setReg doesn't modify these markers, you probably don't need to do anything to update live vars. 7. The comment: +/// CreateNewLiveInterval - Create a new live interval with the given live +/// ranges. Should mention that the created interval has an infinite spill weight. If you make these changes, go ahead and commit the LiveIntervalAnalysis.cpp, LiveIntervalAnalysis.h, and LiveInterval.h changes, even before the rest is reviewed. Thanks Bill! -Chris From wendling at apple.com Wed Nov 15 20:34:34 2006 From: wendling at apple.com (Bill Wendling) Date: Wed, 15 Nov 2006 18:34:34 -0800 Subject: [llvm-commits] Priority-Based In-Reply-To: References: Message-ID: On Nov 15, 2006, at 6:04 PM, Chris Lattner wrote: > The patch looks good, but please: > > 1. Change CreateNewLiveInterval to take LRs by const reference. > This will require changing the iterators to be const_iterator > instead of just iterator's. > Will do. > 2. Please change "int* X" to "int *X" to fit with the rest of the > code. > ARRRGH!! ;-) But okay. Consistency is a good thing :-) > 3. Why do this? > + lv_ = getAnalysisToUpdate(); > Isn't lv_ already valid when the method is called? > I was kind of copying the code from addIntervalsForSpills. It has this comment: // since this is called after the analysis is done we don't know if // LiveVariables is available I'm not sure if this is also valid for this method...I'll try it without this in it. > 4. I don't think this is sufficient: > > + MachineOperand& MOp = MI->getOperand(J); > + if (MOp.isRegister() && MOp.getReg() == LI->reg) { > > In particular, consider if you have two vregs (R1025 and R1027) > that get coallesced before RA. When this happens I believe that > live intervals just marks the two vregs as having the same interval, > and that interval only has one reg (say R1027). When this happens, > the actual machine instrs are not updated. This means that you can > have a reference to R1025, even though the interval says it is R1027. > > To fix this, try using: > > + MachineOperand& MOp = MI->getOperand(J); > + if (MOp.isRegister() && rep(MOp.getReg()) == LI->reg) { > > which should handle this case. > Ah! Okay. That's a good point. If this isn't documented, it might be a good idea to throw it in a webpage somewhere. > 5. It is unclear to me why you have this loop: > + for (unsigned K = J + 1; K != MI->getNumOperands(); ++K) > + if (MI->getOperand(K).isReg() && > + MI->getOperand(K).getReg() == LI->reg) > + MI->getOperand(K).setReg(NewVReg); > > If not needed, just remove it. > Hmm...you're right. It looks superfluous. I probably wrote it at 2AM or something. > 6. I don't think this is right: > > + // Update live variables if it is available > + if (lv_) > + lv_->addVirtualRegisterKilled(NewVReg, MI); > > With Evan's recent change, kill/dead markers are now stored on the > instruction. If MOp.setReg doesn't modify these markers, you > probably don't need to do anything to update live vars. > Alrighty. > 7. The comment: > > +/// CreateNewLiveInterval - Create a new live interval with the > given live > +/// ranges. > > Should mention that the created interval has an infinite spill weight. > Okay. > If you make these changes, go ahead and commit the > LiveIntervalAnalysis.cpp, LiveIntervalAnalysis.h, and LiveInterval.h > changes, even before the rest is reviewed. > Cool. Thanks! -bw From isanbard at gmail.com Wed Nov 15 20:42:04 2006 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 15 Nov 2006 20:42:04 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Message-ID: <200611160242.kAG2g4rL004543@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervalAnalysis.cpp updated: 1.195 -> 1.196 --- Log message: Added a new method "CreateNewLiveInterval" which, given a list of LiveRanges, creates a new LiveInterval from them. The LiveRanges should have existed already in another LiveInterval, but removed. --- Diffs of the changes: (+49 -0) LiveIntervalAnalysis.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 49 insertions(+) Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.195 llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.196 --- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.195 Wed Nov 15 14:54:11 2006 +++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Wed Nov 15 20:41:50 2006 @@ -251,6 +251,55 @@ } } +/// CreateNewLiveInterval - Create a new live interval with the given live +/// ranges. The new live interval will have an infinite spill weight. +LiveInterval& +LiveIntervals::CreateNewLiveInterval(const LiveInterval *LI, + const std::vector &LRs) { + const TargetRegisterClass *RC = mf_->getSSARegMap()->getRegClass(LI->reg); + + // Create a new virtual register for the spill interval. + unsigned NewVReg = mf_->getSSARegMap()->createVirtualRegister(RC); + + // Replace the old virtual registers in the machine operands with the shiny + // new one. + for (std::vector::const_iterator + I = LRs.begin(), E = LRs.end(); I != E; ++I) { + unsigned Index = getBaseIndex(I->start); + unsigned End = getBaseIndex(I->end - 1) + InstrSlots::NUM; + + for (; Index != End; Index += InstrSlots::NUM) { + // Skip deleted instructions + while (Index != End && !getInstructionFromIndex(Index)) + Index += InstrSlots::NUM; + + if (Index == End) break; + + MachineInstr *MI = getInstructionFromIndex(Index); + + for (unsigned J = 0; J != MI->getNumOperands(); ++J) { + MachineOperand &MOp = MI->getOperand(J); + if (MOp.isRegister() && rep(MOp.getReg()) == LI->reg) + MOp.setReg(NewVReg); + } + } + } + + LiveInterval &NewLI = getOrCreateInterval(NewVReg); + + // The spill weight is now infinity as it cannot be spilled again + NewLI.weight = float(HUGE_VAL); + + for (std::vector::const_iterator + I = LRs.begin(), E = LRs.end(); I != E; ++I) { + DEBUG(std::cerr << " Adding live range " << *I << " to new interval\n"); + NewLI.addRange(*I); + } + + DEBUG(std::cerr << "Created new live interval " << NewLI << "\n"); + return NewLI; +} + std::vector LiveIntervals:: addIntervalsForSpills(const LiveInterval &li, VirtRegMap &vrm, int slot) { // since this is called after the analysis is done we don't know if From isanbard at gmail.com Wed Nov 15 20:42:05 2006 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 15 Nov 2006 20:42:05 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h Message-ID: <200611160242.kAG2g5Jf004548@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: LiveIntervalAnalysis.h updated: 1.64 -> 1.65 --- Log message: Added a new method "CreateNewLiveInterval" which, given a list of LiveRanges, creates a new LiveInterval from them. The LiveRanges should have existed already in another LiveInterval, but removed. --- Diffs of the changes: (+5 -0) LiveIntervalAnalysis.h | 5 +++++ 1 files changed, 5 insertions(+) Index: llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h diff -u llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h:1.64 llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h:1.65 --- llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h:1.64 Thu Sep 14 22:57:23 2006 +++ llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h Wed Nov 15 20:41:50 2006 @@ -148,6 +148,11 @@ VirtRegMap& vrm, int slot); + /// CreateNewLiveInterval - Create a new live interval with the given live + /// ranges. The new live interval will have an infinite spill weight. + LiveInterval &CreateNewLiveInterval(const LiveInterval *LI, + const std::vector &LRs); + virtual void getAnalysisUsage(AnalysisUsage &AU) const; virtual void releaseMemory(); From isanbard at gmail.com Wed Nov 15 20:43:46 2006 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 15 Nov 2006 20:43:46 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/LiveInterval.h Message-ID: <200611160243.kAG2hkqh004584@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: LiveInterval.h updated: 1.25 -> 1.26 --- Log message: Added "removeRange", which takes and removes an entire LiveRange. --- Diffs of the changes: (+4 -0) LiveInterval.h | 4 ++++ 1 files changed, 4 insertions(+) Index: llvm/include/llvm/CodeGen/LiveInterval.h diff -u llvm/include/llvm/CodeGen/LiveInterval.h:1.25 llvm/include/llvm/CodeGen/LiveInterval.h:1.26 --- llvm/include/llvm/CodeGen/LiveInterval.h:1.25 Sat Sep 2 00:37:53 2006 +++ llvm/include/llvm/CodeGen/LiveInterval.h Wed Nov 15 20:43:32 2006 @@ -244,6 +244,10 @@ /// the range must already be in this interval in its entirety. void removeRange(unsigned Start, unsigned End); + void removeRange(LiveRange LR) { + removeRange(LR.start, LR.end); + } + bool operator<(const LiveInterval& other) const { return beginNumber() < other.beginNumber(); } From reid at x10sys.com Wed Nov 15 21:50:05 2006 From: reid at x10sys.com (Reid Spencer) Date: Wed, 15 Nov 2006 21:50:05 -0600 Subject: [llvm-commits] CVS: llvm-test/Makefile.programs Message-ID: <200611160350.kAG3o5fS005578@zion.cs.uiuc.edu> Changes in directory llvm-test: Makefile.programs updated: 1.238 -> 1.239 --- Log message: Add a facility for using the -disable-loop-extraction option with bugpoint. --- Diffs of the changes: (+4 -0) Makefile.programs | 4 ++++ 1 files changed, 4 insertions(+) Index: llvm-test/Makefile.programs diff -u llvm-test/Makefile.programs:1.238 llvm-test/Makefile.programs:1.239 --- llvm-test/Makefile.programs:1.238 Thu Nov 9 20:08:26 2006 +++ llvm-test/Makefile.programs Wed Nov 15 21:49:51 2006 @@ -391,6 +391,10 @@ BUGPOINT_OPTIONS += -abs-tolerance $(FP_ABSTOLERANCE) endif +ifdef DISABLE_LOOP_EXTRACT +BUGPOINT_OPTIONS += -disable-loop-extraction +endif + # Give bugpoint information about LDFLAGS to pass down to the actual link stage # of the program. BUGPOINT_OPTIONS += $(LDFLAGS:%=-Xlinker=%) $(EXTRA_OPTIONS:%=-Xlinker=%) From isanbard at gmail.com Thu Nov 16 01:35:33 2006 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 16 Nov 2006 01:35:33 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Message-ID: <200611160735.kAG7ZXnJ009109@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervalAnalysis.cpp updated: 1.196 -> 1.197 --- Log message: Don't recompute getNumOperands for each iteration. --- Diffs of the changes: (+1 -1) LiveIntervalAnalysis.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.196 llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.197 --- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.196 Wed Nov 15 20:41:50 2006 +++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Thu Nov 16 01:35:18 2006 @@ -277,7 +277,7 @@ MachineInstr *MI = getInstructionFromIndex(Index); - for (unsigned J = 0; J != MI->getNumOperands(); ++J) { + for (unsigned J = 0, e = MI->getNumOperands(); J != e; ++J) { MachineOperand &MOp = MI->getOperand(J); if (MOp.isRegister() && rep(MOp.getReg()) == LI->reg) MOp.setReg(NewVReg); From isanbard at gmail.com Thu Nov 16 03:31:40 2006 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 16 Nov 2006 03:31:40 -0600 Subject: [llvm-commits] CVS: llvm/docs/CFEBuildInstrs.html Message-ID: <200611160931.kAG9Veo3019837@zion.cs.uiuc.edu> Changes in directory llvm/docs: CFEBuildInstrs.html updated: 1.59 -> 1.60 --- Log message: Cleaned up the document. Added "doc_code" divisions for code examples. --- Diffs of the changes: (+283 -208) CFEBuildInstrs.html | 490 ++++++++++++++++++++++++++++++---------------------- 1 files changed, 283 insertions(+), 207 deletions(-) Index: llvm/docs/CFEBuildInstrs.html diff -u llvm/docs/CFEBuildInstrs.html:1.59 llvm/docs/CFEBuildInstrs.html:1.60 --- llvm/docs/CFEBuildInstrs.html:1.59 Mon Jul 31 16:37:55 2006 +++ llvm/docs/CFEBuildInstrs.html Thu Nov 16 03:31:19 2006 @@ -36,22 +36,24 @@
    -

    This document is intended to explain the process of building the -LLVM C/C++ front-end from its source code. You have to do this, for example, if -you are porting LLVM to a new architecture or operating system, if you are -working from Top-Of-Tree CVS/SVN, or if there is no precompiled snapshot -available.

    -

    NOTE: This is currently a somewhat fragile, error-prone -process, and you should only try to do it if:

    +

    This document is intended to explain the process of building the LLVM C/C++ +front-end from its source code. You have to do this, for example, if you are +porting LLVM to a new architecture or operating system, if you are working from +Top-Of-Tree CVS/SVN, or if there is no precompiled snapshot available.

    + +

    NOTE: This is currently a somewhat fragile, error-prone process, and +you should only try to do it if:

      -
    1. you really, really, really can't use the binaries we distribute
    2. +
    3. you really, really, really can't use the + binaries we distribute
    4. you are an elite GCC hacker.
    5. you want to use the latest bits from CVS.

    We welcome patches to help make this process simpler.

    +
    @@ -61,38 +63,48 @@
    +

    If you are building LLVM and the GCC front-end under Cygwin, please note that the LLVM and GCC makefiles do not correctly handle spaces in paths. To deal -with this issue, make sure that your LLVM and GCC source and build trees are -located in a top-level directory (like /cygdrive/c/llvm and +with this issue, make sure that your LLVM and GCC source and build trees are +located in a top-level directory (like /cygdrive/c/llvm and /cygdrive/c/llvm-cfrontend), not in a directory that contains a space -(which includes your "home directory", because it lives under the "Documents -and Settings" directory). We welcome patches to fix this issue. -

    +(which includes your "home directory", because it lives under the "Documents and +Settings" directory). We welcome patches to fix this issue.

    +

    It has been found that the GCC 3.3.3 compiler provided with recent Cygwin versions is incapable of compiling the LLVM GCC front-end correctly. If your -Cygwin -installation includes GCC 3.3.3, we strongly recommend that you download -GCC 3.4.3, build it separately, and use it for compiling the LLVM GCC front-end. - This has been -shown to work correctly.

    +Cygwin installation includes GCC 3.3.3, we strongly recommend that you +download GCC 3.4.3, build it separately, and use it for compiling the LLVM GCC +front-end. This has been shown to work correctly.

    +

    Some versions of Cygwin utilize an experimental version of GNU binutils that will cause the GNU ld linker to fail an assertion when linking components of the libstdc++. It is recommended that you replace the entire binutils package with version 2.15 such that "ld --version" responds with

    + +
    GNU ld version 2.15
    -not with:
    +
    + +

    not with:

    + +
    GNU ld version 2.15.91 20040725
    +
    + +
    +

    If you are building LLVM and the GCC front-end under AIX, do NOT use GNU Binutils. They are not stable under AIX and may produce incorrect and/or -invalid code. Instead, use the system assembler and linker. -

    +invalid code. Instead, use the system assembler and linker.

    +
    @@ -104,33 +116,37 @@

    This section describes how to aquire and build llvm-gcc4, which is based on -the GCC 4.0.1 front-end. This front-end supports C, C++, Objective-C, and +the GCC 4.0.1 front-end. This front-end supports C, C++, Objective-C, and Objective-C++. Note that the instructions for building this front-end are -completely different than those for building llvm-gcc3. -

    +completely different than those for building llvm-gcc3.

      -
    1. -

      Retrieve the appropriate llvm-gcc4-x.y.source.tar.gz archive from the llvm -web site.

      -

      It is also possible to download the sources of the llvm-gcc4 front end from -a read-only mirror using subversion. To check out the code the first time use: -

      +
    2. Retrieve the appropriate llvm-gcc4-x.y.source.tar.gz archive from the + llvm web site.

      -svn co svn://anonsvn.opensource.apple.com/svn/llvm/trunk -dst-directory +

      It is also possible to download the sources of the llvm-gcc4 front end + from a read-only mirror using subversion. To check out the code the + first time use:

      -

      After that, the code can be be updated in the destination directory using; -

      +
      +
      +svn co svn://anonsvn.opensource.apple.com/svn/llvm/trunk dst-directory
      +
      +
      -svn update +

      After that, the code can be be updated in the destination directory + using:

      -

      The mirror is brought up to date every evening.

      -
    3. +
      +
      svn update
      +
      -
    4. Follow the directions in the top-level README.LLVM file for up-to-date - instructions on how to build llvm-gcc4.
    5. +

      The mirror is brought up to date every evening.

      + +
    6. Follow the directions in the top-level README.LLVM file for + up-to-date instructions on how to build llvm-gcc4.
    +
    @@ -140,192 +156,251 @@
    +
      -
    1. Aquire llvm-gcc3 from LLVM CVS or -from a release tarball.
    2. +
    3. Aquire llvm-gcc3 from LLVM CVS + or from a release tarball.
    4. -
    5. Configure and build the LLVM libraries and tools. There are two ways to -do this: either with objdir == srcdir or -objdir != srcdir. It is recommended -that srcdir be the same as objdir for your LLVM tree (but note -that you should always use srcdir != objdir for llvm-gcc):

      -
        -
      • With objdir != srcdir:
        - % cd objdir
        - % srcdir/configure --prefix=/some/path/you/can/install/to [options...]
        - % gmake tools-only
        -  
      • -
      • With objdir == srcdir:
        - % cd llvm
        - % ./configure --prefix=/some/path/you/can/install/to [options...]
        - % gmake tools-only
        -  
      • -
      -

      This will build all of the LLVM tools and libraries. The --prefix -option defaults to /usr/local (per configure standards) but unless you are a -system administrator, you probably won't be able to install LLVM there because -of permissions. Specify a path into which LLVM can be installed (e.g. ---prefix=/home/user/llvm).

      -
    6. - -
    7. Add the directory containing the tools to your PATH.

      -
      - % set path = ( `cd llvm/Debug/bin && pwd` $path )
      -
    8. - -
    9. Unpack the C/C++ front-end source into cfrontend/src, either by - untar'ing a cfrontend.source.tar.gz file or checking out CVS into this - directory.

    10. - -
    11. Make "build" and "install" directories as siblings of the "src" tree:

      -
      - % pwd
      - /usr/local/example/cfrontend/src
      - % cd ..
      - % mkdir build install
      - % set CFEINSTALL = `pwd`/install
      -
    12. +
    13. Configure and build the LLVM libraries and tools. There are two ways to + do this: either with objdir == srcdir or + objdir != srcdir. It is recommended that + srcdir be the same as objdir for your + LLVM tree (but note that you should always use srcdir != + objdir for llvm-gcc):

      +
        +
      • With objdir != srcdir:

        -
      • Configure, build, and install the GCC front-end:

        +
        +
        +% cd objdir
        +% srcdir/configure --prefix=/some/path/you/can/install/to [options...]
        +% gmake tools-only
        +
        +
        +
      • +
      • With objdir == srcdir:

        -

        -Linux/x86:
        -Linux/IA-64:
        -MacOS X/PowerPC (requires dlcompat library):
        -AIX/PowerPC: -

        +
        +
        +% cd llvm
        +% ./configure --prefix=/some/path/you/can/install/to [options...]
        +% gmake tools-only
        +
        +
        +
      • +
      + +

      This will build all of the LLVM tools and libraries. The + --prefix option defaults to /usr/local (per configure + standards) but unless you are a system administrator, you probably + won't be able to install LLVM there because of permissions. Specify a + path into which LLVM can be installed + (e.g. --prefix=/home/user/llvm).

    14. +
    15. Add the directory containing the tools to your PATH.

      + +
      +csh: +
      +  % set path = ( `cd llvm/Debug/bin && pwd` $path )
      +
      +sh: +
      +  % export PATH=`cd llvm/Debug/bin && pwd`:$PATH
      +
      +
      +
    16. + +
    17. Unpack the C/C++ front-end source into cfrontend/src, either by + untar'ing a cfrontend.source.tar.gz file or checking out CVS into this + directory.

    18. +
    19. Make "build" and "install" directories as siblings of the "src" + tree:

      +
      +csh: +
      +  % pwd
      +  /usr/local/example/cfrontend/src
      +  % cd ..
      +  % mkdir build install
      +  % set CFEINSTALL = `pwd`/install
      +
      +sh:
      - % cd build
      - % ../src/configure --prefix=$CFEINSTALL --disable-threads --disable-nls \
      -   --disable-shared --enable-languages=c,c++ --program-prefix=llvm-
      - % gmake all; gmake install
      +  % pwd
      +  /usr/local/example/cfrontend/src
      +  % cd ..
      +  % mkdir build install
      +  % export CFEINSTALL=`pwd`/install
       
      +
      +
    20. + +
    21. Configure, build, and install the GCC front-end:

      -

      Cygwin/x86:

      +

      + Linux/x86:
      + Linux/IA-64:
      + MacOS X/PowerPC (requires dlcompat library):
      + AIX/PowerPC: +

      +
      - % cd build
      - % ../src/configure --prefix=$CFEINSTALL --disable-threads --disable-nls \
      -   --disable-shared --enable-languages=c,c++ --disable-c-mbchar \
      -   --program-prefix=llvm-
      - % gmake all; gmake install
      +% cd build
      +% ../src/configure --prefix=$CFEINSTALL --disable-threads --disable-nls \
      +  --disable-shared --enable-languages=c,c++ --program-prefix=llvm-
      +% gmake all; gmake install
       
      +
      -

      Solaris/SPARC:

      +

      Cygwin/x86:

      -

      -The GCC front-end can be configured for either SPARC V8 (32 bit) or SPARC V9 (64 -bit). This changes, among other things, the sizes of integer types and the -macros defined for conditional compilation. -

      +
      +
      +% cd build
      +% ../src/configure --prefix=$CFEINSTALL --disable-threads --disable-nls \
      +  --disable-shared --enable-languages=c,c++ --disable-c-mbchar \
      +  --program-prefix=llvm-
      +% gmake all; gmake install
      +
      +
      -

      -The SPARC V8 ABI support is more robust than the V9 ABI support and can generate -SPARC V9 code. It is highly recommended that you use the V8 ABI with LLVM, as -shown below. Also, -note that Solaris has trouble with various wide (multibyte) character -functions from C as referenced from C++, so we typically configure with ---disable-c-mbchar (cf. Bug 206). -

      +

      Solaris/SPARC:

      +

      The GCC front-end can be configured for either SPARC V8 (32 bit) or + SPARC V9 (64 bit). This changes, among other things, the sizes of + integer types and the macros defined for conditional compilation.

      + +

      The SPARC V8 ABI support is more robust than the V9 ABI support and can + generate SPARC V9 code. It is highly recommended that you use the V8 + ABI with LLVM, as shown below. Also, note that Solaris has trouble + with various wide (multibyte) character functions from C as referenced + from C++, so we typically configure with --disable-c-mbchar (cf. Bug 206).

      + +
      - % cd build
      - % ../src/configure --prefix=$CFEINSTALL --disable-threads --disable-nls \
      -   --disable-shared --enable-languages=c,c++ --host=sparc-sun-solaris2.8 \
      -   --disable-c-mbchar --program-prefix=llvm-
      - % gmake all; gmake install
      -
      - -

      Common Problem: You may get error messages regarding the fact - that LLVM does not support inline assembly. Here are two common - fixes:

      - -
        -
      • Fix 1: If you have system header files that include - inline assembly, you may have to modify them to remove the inline - assembly and install the modified versions in - $CFEINSTALL/lib/gcc/target-triplet/3.4-llvm/include.

      • - -
      • Fix 2: If you are building the C++ front-end on a CPU we - haven't tried yet, you will probably have to edit the appropriate - version of atomicity.h under - src/libstdc++-v3/config/cpu/name-of-cpu/atomicity.h - and apply a patch so that it does not use inline assembly.
      • -
      - -

      Porting to a new architecture: If you are porting the front-end - to a new architecture or compiling in a configuration that we have - not tried previously, there are probably several changes you will have to make - to the GCC target to get it to work correctly. These include:

      - -

        -
      • Often targets include special assembler or linker flags which - gccas/gccld does not understand. In general, these can - just be removed.
      • -
      • LLVM currently does not support any floating point values other than - 32-bit and 64-bit IEEE floating point. The primary effect of this is - that you may have to map "long double" onto "double".
      • -
      • The profiling hooks in GCC do not apply at all to the LLVM front-end. - These may need to be disabled.
      • -
      • No inline assembly for position independent code. At the LLVM level, - everything is position independent.
      • -
      • We handle .init and .fini differently.
      • -
      • You may have to disable multilib support in your target. Using multilib - support causes the GCC compiler driver to add a lot of "-L" - options to the link line, which do not relate to LLVM and confuse - gccld. To disable multilibs, delete any - MULTILIB_OPTIONS lines from your target files.
      • -
      • Did we mention that we don't support inline assembly? You'll probably - have to add some fixinclude hacks to disable it in the system - headers.
      • -
      -
    22. - -
    23. Put $CFEINSTALL/bin into your PATH environment -variable.

      -
        -
      • sh: export PATH=$CFEINSTALL/bin:$PATH
      • -
      • csh: setenv PATH $CFEINSTALL/bin:$PATH
      • -
      -
    24. - -
    25. Go back into the LLVM source tree proper. Rerun configure, using -the same options as the last time. This will cause the configuration to now find -the newly built llvm-gcc and llvm-g++ executables.

    26. - -
    27. Rebuild your CVS tree. This shouldn't cause the whole thing to be - rebuilt, but it should build the runtime libraries. After the tree is - built, install the runtime libraries into your GCC front-end build tree. - These are the commands you need:

      -
      - % gmake
      - % gmake -C runtime install-bytecode
      -
    28. - -
    29. Optionally, build a symbol table for the newly installed runtime -libraries. Although this step is optional, you are strongly encouraged to -do this as the symbol tables will make a significant difference in your -link times. Use the llvm-ranlib tool to do this, as follows:

      -
      - % cd $CFEINSTALL/lib
      - % llvm-ranlib libiberty.a
      - % llvm-ranlib libstdc++.a
      - % llvm-ranlib libsupc++.a
      - % cd $CFEINSTALL/lib/gcc/target-triplet/3.4-llvm
      - % llvm-ranlib libgcc.a
      - % llvm-ranlib libgcov.a
      -
      - -
    30. Test the newly-installed C frontend by one or more of the -following means:

      -
        -
      • running the feature & regression tests via make check
      • -
      • compiling and running a "hello, LLVM" program in C and C++.
      • -
      • running the tests found in the llvm-test CVS module
      • -
    31. +% cd build +% ../src/configure --prefix=$CFEINSTALL --disable-threads --disable-nls \ + --disable-shared --enable-languages=c,c++ --host=sparc-sun-solaris2.8 \ + --disable-c-mbchar --program-prefix=llvm- +% gmake all; gmake install + +
    + +

    Common Problem: You may get error messages regarding the fact + that LLVM does not support inline assembly. Here are two common + fixes:

    + +
      +
    • Fix 1: If you have system header files that include inline + assembly, you may have to modify them to remove the inline assembly + and install the modified versions in + $CFEINSTALL/lib/gcc/target-triplet/3.4-llvm/include.

    • + +
    • Fix 2: If you are building the C++ front-end on a CPU we + haven't tried yet, you will probably have to edit the appropriate + version of atomicity.h under + src/libstdc++-v3/config/cpu/name-of-cpu/atomicity.h + and apply a patch so that it does not use inline assembly.
    • +
    + +

    Porting to a new architecture: If you are porting the front-end + to a new architecture or compiling in a configuration that we have not + tried previously, there are probably several changes you will have to + make to the GCC target to get it to work correctly. These include:

    + +
      +
    • Often targets include special assembler or linker flags which + gccas/gccld does not understand. In general, + these can just be removed.
    • + +
    • LLVM currently does not support any floating point values other than + 32-bit and 64-bit IEEE floating point. The primary effect of this + is that you may have to map "long double" onto "double".
    • + +
    • The profiling hooks in GCC do not apply at all to the LLVM + front-end. These may need to be disabled.
    • + +
    • No inline assembly for position independent code. At the LLVM + level, everything is position independent.
    • + +
    • We handle .init and .fini differently.
    • + +
    • You may have to disable multilib support in your target. Using + multilib support causes the GCC compiler driver to add a lot of + "-L" options to the link line, which do not relate to LLVM + and confuse gccld. To disable multilibs, delete any + MULTILIB_OPTIONS lines from your target files.
    • + +
    • Did we mention that we don't support inline assembly? You'll + probably have to add some fixinclude hacks to disable it in the + system headers.
    • +
  • + +
  • Put $CFEINSTALL/bin into your PATH environment + variable.

    + +
    +csh: +
    +  % setenv PATH $CFEINSTALL/bin:$PATH
    +
    +sh: +
    +  % export PATH=$CFEINSTALL/bin:$PATH
    +
    +
    +
  • + +
  • Go back into the LLVM source tree proper. Rerun configure, using the + same options as the last time. This will cause the configuration to now + find the newly built llvm-gcc and llvm-g++ executables.

  • + +
  • Rebuild your CVS tree. This shouldn't cause the whole thing to be + rebuilt, but it should build the runtime libraries. After the tree is + built, install the runtime libraries into your GCC front-end build tree. + These are the commands you need:

    + +
    +
    +% gmake
    +% gmake -C runtime install-bytecode
    +
    +
    +
  • + +
  • Optionally, build a symbol table for the newly installed runtime + libraries. Although this step is optional, you are strongly encouraged to + do this as the symbol tables will make a significant difference in your + link times. Use the llvm-ranlib tool to do this, as follows:

    + +
    +
    +% cd $CFEINSTALL/lib
    +% llvm-ranlib libiberty.a
    +% llvm-ranlib libstdc++.a
    +% llvm-ranlib libsupc++.a
    +% cd $CFEINSTALL/lib/gcc/target-triplet/3.4-llvm
    +% llvm-ranlib libgcc.a
    +% llvm-ranlib libgcov.a
    +
    +
    +
  • + +
  • Test the newly-installed C frontend by one or more of the following + means:

    + +
      +
    • running the feature & regression tests via make + check
    • +
    • compiling and running a "hello, LLVM" program in C and C++.
    • +
    • running the tests found in the llvm-test CVS module
    • +
  • + @@ -357,7 +432,7 @@ Brian Gaeke
    LLVM Compiler Infrastructure
    - Last modified: $Date: 2006/07/31 21:37:55 $ + Last modified: $Date: 2006/11/16 09:31:19 $ From sabre at nondot.org Thu Nov 16 12:14:04 2006 From: sabre at nondot.org (Chris Lattner) Date: Thu, 16 Nov 2006 12:14:04 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCBranchSelector.cpp Message-ID: <200611161814.kAGIE4xg017777@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCBranchSelector.cpp updated: 1.29 -> 1.30 --- Log message: add a statistic --- Diffs of the changes: (+6 -1) PPCBranchSelector.cpp | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletion(-) Index: llvm/lib/Target/PowerPC/PPCBranchSelector.cpp diff -u llvm/lib/Target/PowerPC/PPCBranchSelector.cpp:1.29 llvm/lib/Target/PowerPC/PPCBranchSelector.cpp:1.30 --- llvm/lib/Target/PowerPC/PPCBranchSelector.cpp:1.29 Fri Oct 13 12:56:02 2006 +++ llvm/lib/Target/PowerPC/PPCBranchSelector.cpp Thu Nov 16 12:13:49 2006 @@ -19,12 +19,16 @@ #include "PPCInstrBuilder.h" #include "PPCInstrInfo.h" #include "llvm/CodeGen/MachineFunctionPass.h" -#include "llvm/Support/Compiler.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetAsmInfo.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/Support/Compiler.h" #include using namespace llvm; +static Statistic<> NumExpanded("ppc-branch-select", + "Num branches expanded to long format"); + namespace { struct VISIBILITY_HIDDEN PPCBSel : public MachineFunctionPass { /// OffsetMap - Mapping between BB and byte offset from start of function. @@ -131,6 +135,7 @@ BuildMI(*MBB, MBBJ, Opcode, 2).addReg(CRReg).addMBB(trueMBB); } else { // Long branch, skip next branch instruction (i.e. $PC+8). + ++NumExpanded; BuildMI(*MBB, MBBJ, Inverted, 2).addReg(CRReg).addImm(2); BuildMI(*MBB, MBBJ, PPC::B, 1).addMBB(trueMBB); } From reid at x10sys.com Thu Nov 16 12:33:01 2006 From: reid at x10sys.com (Reid Spencer) Date: Thu, 16 Nov 2006 12:33:01 -0600 Subject: [llvm-commits] CVS: llvm/utils/findmisopt Message-ID: <200611161833.kAGIX1Mh018357@zion.cs.uiuc.edu> Changes in directory llvm/utils: findmisopt updated: 1.5 -> 1.6 --- Log message: Use a release version of bugpoint, if found. Include gccld passes. --- Diffs of the changes: (+19 -5) findmisopt | 24 +++++++++++++++++++----- 1 files changed, 19 insertions(+), 5 deletions(-) Index: llvm/utils/findmisopt diff -u llvm/utils/findmisopt:1.5 llvm/utils/findmisopt:1.6 --- llvm/utils/findmisopt:1.5 Mon Nov 13 10:08:51 2006 +++ llvm/utils/findmisopt Thu Nov 16 12:32:47 2006 @@ -12,7 +12,9 @@ # uses (in the same order) and will narrow down which optimizations # cause the program either generate different output or return a # different result code. When the passes have been narrowed down, -# bugpoint is invoked to further refine the problem to its origin. +# bugpoint is invoked to further refine the problem to its origin. If a +# release version of bugpoint is available it will be used, otherwise +# debug. # # Usage: # findmisopt bcfile outdir progargs [match] @@ -24,7 +26,7 @@ # is a directory into which intermediate results are placed # progargs # is a single argument containing all the arguments the program needs -# match +# match # if specified to any value causes the result code of the program to # be used to determine success/fail. If not specified success/fail is # determined by diffing the program's output with the non-optimized @@ -35,6 +37,16 @@ exit 1 fi +dir="${0%%/utils/findmisopt}" +if [ -x "$dir/Release/bin/bugpoint" ] ; then + bugpoint="$dir/Release/bin/bugpoint" +elif [ -x "$dir/Debug/bin/bugpoint" ] ; then + bugpoint="$dir/Debug/bin/bugpoint" +else + echo "findmisopt: bugpoint not found" + exit 1 +fi + bcfile="$1" outdir="$2" args="$3" @@ -71,8 +83,9 @@ llc "$bcfile" -o "$s" -f || exit 1 gcc "$s" -o "$prog" -lstdc++ -lc -lm || exit 1 -# Define the list of optimizations to run -all_switches="-verify -lowersetjmp -funcresolve -raiseallocs -simplifycfg -mem2reg -globalopt -globaldce -ipconstprop -deadargelim -instcombine -simplifycfg -prune-eh -inline -simplify-libcalls -argpromotion -raise -tailduplicate -simplifycfg -scalarrepl -instcombine -predsimplify -condprop -tailcallelim -simplifycfg -reassociate -licm -loop-unswitch -instcombine -indvars -loop-unroll -instcombine -load-vn -gcse -sccp -instcombine -condprop -dse -dce -simplifycfg -deadtypeelim -constmerge" +# Define the list of optimizations to run. This comprises the same set of +# optimizations that gccas and gccld run, in the same order. +all_switches="-verify -lowersetjmp -funcresolve -raiseallocs -simplifycfg -mem2reg -globalopt -globaldce -ipconstprop -deadargelim -instcombine -simplifycfg -prune-eh -inline -simplify-libcalls -argpromotion -raise -tailduplicate -simplifycfg -scalarrepl -instcombine -predsimplify -condprop -tailcallelim -simplifycfg -reassociate -licm -loop-unswitch -instcombine -indvars -loop-unroll -instcombine -load-vn -gcse -sccp -instcombine -condprop -dse -dce -simplifycfg -deadtypeelim -constmerge -funcresolve -internalize -ipsccp -globalopt -constmerge -deadargelim -inline -prune-eh -globalopt -globaldce -argpromotion -instcombine -predsimplify -scalarrepl -globalsmodref-aa -licm -load-vn -gcse -dse -instcombine -simplify-cfg -verify" # Current set of switches is empty function tryit { @@ -138,7 +151,8 @@ exit 0 fi echo "Smallest Optimization list=$final" -bpcmd="bugpoint -run-llc --output "$out" --input /dev/null $bcfile $final --args $args" + +bpcmd="$bugpoint -run-llc -disable-loop-extraction --output "$out" --input /dev/null $bcfile $final --args $args" echo "Running: $bpcmd" $bpcmd From evan.cheng at apple.com Thu Nov 16 14:02:36 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 16 Nov 2006 14:02:36 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineCodeEmitter.h Message-ID: <200611162002.kAGK2ajx019975@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineCodeEmitter.h updated: 1.41 -> 1.42 --- Log message: Allow target to specify alignment for function stub. --- Diffs of the changes: (+1 -1) MachineCodeEmitter.h | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/include/llvm/CodeGen/MachineCodeEmitter.h diff -u llvm/include/llvm/CodeGen/MachineCodeEmitter.h:1.41 llvm/include/llvm/CodeGen/MachineCodeEmitter.h:1.42 --- llvm/include/llvm/CodeGen/MachineCodeEmitter.h:1.41 Tue Jun 20 19:29:14 2006 +++ llvm/include/llvm/CodeGen/MachineCodeEmitter.h Thu Nov 16 14:02:22 2006 @@ -80,7 +80,7 @@ /// have constant pools, the can only use the other emitByte*/emitWord* /// methods. /// - virtual void startFunctionStub(unsigned StubSize) = 0; + virtual void startFunctionStub(unsigned StubSize, unsigned Alignment = 1) = 0; /// finishFunctionStub - This callback is invoked to terminate a function /// stub. From evan.cheng at apple.com Thu Nov 16 14:04:19 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 16 Nov 2006 14:04:19 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/ELFWriter.cpp MachOWriter.cpp Message-ID: <200611162004.kAGK4JLv020042@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: ELFWriter.cpp updated: 1.27 -> 1.28 MachOWriter.cpp updated: 1.6 -> 1.7 --- Log message: Match MachineCodeEmitter changes. --- Diffs of the changes: (+2 -2) ELFWriter.cpp | 2 +- MachOWriter.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/lib/CodeGen/ELFWriter.cpp diff -u llvm/lib/CodeGen/ELFWriter.cpp:1.27 llvm/lib/CodeGen/ELFWriter.cpp:1.28 --- llvm/lib/CodeGen/ELFWriter.cpp:1.27 Thu Nov 2 14:25:49 2006 +++ llvm/lib/CodeGen/ELFWriter.cpp Thu Nov 16 14:04:04 2006 @@ -81,7 +81,7 @@ } /// JIT SPECIFIC FUNCTIONS - DO NOT IMPLEMENT THESE HERE! - void startFunctionStub(unsigned StubSize) { + void startFunctionStub(unsigned StubSize, unsigned Alignment = 1) { assert(0 && "JIT specific function called!"); abort(); } Index: llvm/lib/CodeGen/MachOWriter.cpp diff -u llvm/lib/CodeGen/MachOWriter.cpp:1.6 llvm/lib/CodeGen/MachOWriter.cpp:1.7 --- llvm/lib/CodeGen/MachOWriter.cpp:1.6 Sun Sep 10 18:03:44 2006 +++ llvm/lib/CodeGen/MachOWriter.cpp Thu Nov 16 14:04:04 2006 @@ -100,7 +100,7 @@ } /// JIT SPECIFIC FUNCTIONS - DO NOT IMPLEMENT THESE HERE! - void startFunctionStub(unsigned StubSize) { + void startFunctionStub(unsigned StubSize, unsigned Alignment = 1) { assert(0 && "JIT specific function called!"); abort(); } From evan.cheng at apple.com Thu Nov 16 14:05:08 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 16 Nov 2006 14:05:08 -0600 Subject: [llvm-commits] CVS: llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp Message-ID: <200611162005.kAGK582a020068@zion.cs.uiuc.edu> Changes in directory llvm/lib/ExecutionEngine/JIT: JITEmitter.cpp updated: 1.118 -> 1.119 --- Log message: Allow target to specify alignment for function stub. --- Diffs of the changes: (+11 -5) JITEmitter.cpp | 16 +++++++++++----- 1 files changed, 11 insertions(+), 5 deletions(-) Index: llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp diff -u llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp:1.118 llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp:1.119 --- llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp:1.118 Thu Nov 9 13:32:13 2006 +++ llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp Thu Nov 16 14:04:54 2006 @@ -275,7 +275,7 @@ JITMemoryManager(bool useGOT); ~JITMemoryManager(); - inline unsigned char *allocateStub(unsigned StubSize); + inline unsigned char *allocateStub(unsigned StubSize, unsigned Alignment); /// startFunctionBody - When a function starts, allocate a block of free /// executable memory, returning a pointer to it and its actual size. @@ -403,8 +403,11 @@ Blocks.clear(); } -unsigned char *JITMemoryManager::allocateStub(unsigned StubSize) { +unsigned char *JITMemoryManager::allocateStub(unsigned StubSize, + unsigned Alignment) { CurStubPtr -= StubSize; + CurStubPtr = (unsigned char*)(((intptr_t)CurStubPtr) & + ~(intptr_t)(Alignment-1)); if (CurStubPtr < StubBase) { // FIXME: allocate a new block std::cerr << "JIT ran out of memory for function stubs!\n"; @@ -700,7 +703,7 @@ void initJumpTableInfo(MachineJumpTableInfo *MJTI); void emitJumpTableInfo(MachineJumpTableInfo *MJTI); - virtual void startFunctionStub(unsigned StubSize); + virtual void startFunctionStub(unsigned StubSize, unsigned Alignment = 1); virtual void* finishFunctionStub(const Function *F); virtual void addRelocation(const MachineRelocation &MR) { @@ -769,6 +772,9 @@ BufferBegin = CurBufferPtr = MemMgr.startFunctionBody(ActualSize); BufferEnd = BufferBegin+ActualSize; + // Ensure the constant pool/jump table info is at least 4-byte aligned. + emitAlignment(16); + emitConstantPool(F.getConstantPool()); initJumpTableInfo(F.getJumpTableInfo()); @@ -928,12 +934,12 @@ } } -void JITEmitter::startFunctionStub(unsigned StubSize) { +void JITEmitter::startFunctionStub(unsigned StubSize, unsigned Alignment) { SavedBufferBegin = BufferBegin; SavedBufferEnd = BufferEnd; SavedCurBufferPtr = CurBufferPtr; - BufferBegin = CurBufferPtr = MemMgr.allocateStub(StubSize); + BufferBegin = CurBufferPtr = MemMgr.allocateStub(StubSize, Alignment); BufferEnd = BufferBegin+StubSize+1; } From isanbard at gmail.com Thu Nov 16 14:11:48 2006 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 16 Nov 2006 14:11:48 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/Passes.cpp Message-ID: <200611162011.kAGKBm2j013630@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: Passes.cpp updated: 1.22 -> 1.23 --- Log message: --- Diffs of the changes: (+0 -1) Passes.cpp | 1 - 1 files changed, 1 deletion(-) Index: llvm/lib/CodeGen/Passes.cpp diff -u llvm/lib/CodeGen/Passes.cpp:1.22 llvm/lib/CodeGen/Passes.cpp:1.23 --- llvm/lib/CodeGen/Passes.cpp:1.22 Wed Aug 2 19:16:56 2006 +++ llvm/lib/CodeGen/Passes.cpp Thu Nov 16 14:11:33 2006 @@ -14,7 +14,6 @@ #include "llvm/CodeGen/RegAllocRegistry.h" #include "llvm/CodeGen/Passes.h" -#include using namespace llvm; From evan.cheng at apple.com Thu Nov 16 14:13:50 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 16 Nov 2006 14:13:50 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86JITInfo.cpp Message-ID: <200611162013.kAGKDoYT018807@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86JITInfo.cpp updated: 1.30 -> 1.31 --- Log message: Align stubs on 4 byte boundary. This fixes 447.dealII. --- Diffs of the changes: (+2 -2) X86JITInfo.cpp | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/lib/Target/X86/X86JITInfo.cpp diff -u llvm/lib/Target/X86/X86JITInfo.cpp:1.30 llvm/lib/Target/X86/X86JITInfo.cpp:1.31 --- llvm/lib/Target/X86/X86JITInfo.cpp:1.30 Mon Oct 16 18:44:08 2006 +++ llvm/lib/Target/X86/X86JITInfo.cpp Thu Nov 16 14:13:34 2006 @@ -288,13 +288,13 @@ bool NotCC = Fn != (void*)(intptr_t)X86CompilationCallback; #endif if (NotCC) { - MCE.startFunctionStub(5); + MCE.startFunctionStub(5, 4); MCE.emitByte(0xE9); MCE.emitWordLE((intptr_t)Fn-MCE.getCurrentPCValue()-4); return MCE.finishFunctionStub(0); } - MCE.startFunctionStub(6); + MCE.startFunctionStub(6, 4); MCE.emitByte(0xE8); // Call with 32 bit pc-rel destination... MCE.emitWordLE((intptr_t)Fn-MCE.getCurrentPCValue()-4); From isanbard at gmail.com Thu Nov 16 14:17:30 2006 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 16 Nov 2006 12:17:30 -0800 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/Passes.cpp In-Reply-To: <200611162011.kAGKBm2j013630@zion.cs.uiuc.edu> References: <200611162011.kAGKBm2j013630@zion.cs.uiuc.edu> Message-ID: <16e5fdf90611161217j2da93470nd8d00acb141c1502@mail.gmail.com> Sorry that there's no log message. It should be: removed unnecessary #include -bw On 11/16/06, Bill Wendling wrote: > > > Changes in directory llvm/lib/CodeGen: > > Passes.cpp updated: 1.22 -> 1.23 > --- > Log message: > > > > --- > Diffs of the changes: (+0 -1) > > Passes.cpp | 1 - > 1 files changed, 1 deletion(-) > > > Index: llvm/lib/CodeGen/Passes.cpp > diff -u llvm/lib/CodeGen/Passes.cpp:1.22 llvm/lib/CodeGen/Passes.cpp:1.23 > --- llvm/lib/CodeGen/Passes.cpp:1.22 Wed Aug 2 19:16:56 2006 > +++ llvm/lib/CodeGen/Passes.cpp Thu Nov 16 14:11:33 2006 > @@ -14,7 +14,6 @@ > > #include "llvm/CodeGen/RegAllocRegistry.h" > #include "llvm/CodeGen/Passes.h" > -#include > > using namespace llvm; > > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From sabre at nondot.org Thu Nov 16 15:45:45 2006 From: sabre at nondot.org (Chris Lattner) Date: Thu, 16 Nov 2006 15:45:45 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp PPCInstr64Bit.td Message-ID: <200611162145.kAGLjja0008282@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCAsmPrinter.cpp updated: 1.207 -> 1.208 PPCInstr64Bit.td updated: 1.30 -> 1.31 --- Log message: fix a regression that I introduced. stdu should scale the offset by 4 before printing it. --- Diffs of the changes: (+11 -2) PPCAsmPrinter.cpp | 11 ++++++++++- PPCInstr64Bit.td | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.207 llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.208 --- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.207 Fri Nov 3 23:27:39 2006 +++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp Thu Nov 16 15:45:30 2006 @@ -127,7 +127,16 @@ O << (unsigned short)MI->getOperand(OpNo).getImmedValue(); } void printS16X4ImmOperand(const MachineInstr *MI, unsigned OpNo) { - O << (short)(MI->getOperand(OpNo).getImmedValue()*4); + if (MI->getOperand(OpNo).isImmediate()) { + O << (short)(MI->getOperand(OpNo).getImmedValue()*4); + } else { + O << "lo16("; + printOp(MI->getOperand(OpNo)); + if (TM.getRelocationModel() == Reloc::PIC_) + O << "-\"L" << getFunctionNumber() << "$pb\")"; + else + O << ')'; + } } void printBranchOperand(const MachineInstr *MI, unsigned OpNo) { // Branches can take an immediate operand. This is used by the branch Index: llvm/lib/Target/PowerPC/PPCInstr64Bit.td diff -u llvm/lib/Target/PowerPC/PPCInstr64Bit.td:1.30 llvm/lib/Target/PowerPC/PPCInstr64Bit.td:1.31 --- llvm/lib/Target/PowerPC/PPCInstr64Bit.td:1.30 Wed Nov 15 18:57:19 2006 +++ llvm/lib/Target/PowerPC/PPCInstr64Bit.td Thu Nov 16 15:45:30 2006 @@ -413,7 +413,7 @@ def STDU : DSForm_1<62, 1, (ops ptr_rc:$ea_res, G8RC:$rS, - symbolLo:$ptroff, ptr_rc:$ptrreg), + s16immX4:$ptroff, ptr_rc:$ptrreg), "stdu $rS, $ptroff($ptrreg)", LdStSTD, [(set ptr_rc:$ea_res, (pre_store G8RC:$rS, ptr_rc:$ptrreg, iaddroff:$ptroff))]>, From reid at x10sys.com Thu Nov 16 17:18:00 2006 From: reid at x10sys.com (Reid Spencer) Date: Thu, 16 Nov 2006 17:18:00 -0600 Subject: [llvm-commits] CVS: llvm/autoconf/configure.ac Message-ID: <200611162318.kAGNI0Je010523@zion.cs.uiuc.edu> Changes in directory llvm/autoconf: configure.ac updated: 1.250 -> 1.251 --- Log message: In LLVM 2.0 we won't use the runtime libraries as llvm-gcc3 support will be dropped. This patch pertains to removing the runtime directory from LLVM. --- Diffs of the changes: (+2 -14) configure.ac | 16 ++-------------- 1 files changed, 2 insertions(+), 14 deletions(-) Index: llvm/autoconf/configure.ac diff -u llvm/autoconf/configure.ac:1.250 llvm/autoconf/configure.ac:1.251 --- llvm/autoconf/configure.ac:1.250 Mon Nov 6 23:31:00 2006 +++ llvm/autoconf/configure.ac Thu Nov 16 17:17:26 2006 @@ -268,15 +268,6 @@ AC_SUBST(DISABLE_ASSERTIONS,[[DISABLE_ASSERTIONS=1]]) fi -dnl --enable-debug-runtime : should runtime libraries have debug symbols? -AC_ARG_ENABLE(debug-runtime, - AS_HELP_STRING([--enable-debug-runtime,Build runtime libs with debug symbols (default is NO)]),,enableval=no) -if test ${enableval} = "no" ; then - AC_SUBST(DEBUG_RUNTIME,[[]]) -else - AC_SUBST(DEBUG_RUNTIME,[[DEBUG_RUNTIME=1]]) -fi - dnl --enable-jit: check whether they want to enable the jit AC_ARG_ENABLE(jit, AS_HELP_STRING(--enable-jit, @@ -820,7 +811,6 @@ AC_CONFIG_MAKEFILE(Makefile.common) AC_CONFIG_MAKEFILE(examples/Makefile) AC_CONFIG_MAKEFILE(lib/Makefile) -AC_CONFIG_MAKEFILE(runtime/Makefile) AC_CONFIG_MAKEFILE(test/Makefile) AC_CONFIG_MAKEFILE(test/Makefile.tests) AC_CONFIG_MAKEFILE(tools/Makefile) @@ -833,8 +823,6 @@ dnl Warn loudly if llvm-gcc was not obviously working if test "$llvm_cv_llvmgcc_sanity" = "no" ; then AC_MSG_WARN([***** llvm-gcc/llvm-g++ was not found, or does not appear to be ]) - AC_MSG_WARN([***** working. Please make sure you have llvm-gcc and llvm-g++ in]) - AC_MSG_WARN([***** your path before configuring LLVM. The runtime libraries]) - AC_MSG_WARN([***** (llvm/runtime) will not be built but you should be able to]) - AC_MSG_WARN([***** build the llvm tools.]) + AC_MSG_WARN([***** working. Please make sure you have llvm-gcc and llvm-g++ ]) + AC_MSG_WARN([***** in your path before configuring LLVM.]) fi From reid at x10sys.com Thu Nov 16 17:18:06 2006 From: reid at x10sys.com (Reid Spencer) Date: Thu, 16 Nov 2006 17:18:06 -0600 Subject: [llvm-commits] CVS: llvm/Makefile Makefile.config.in Makefile.rules configure Message-ID: <200611162318.kAGNI6Zf010539@zion.cs.uiuc.edu> Changes in directory llvm: Makefile updated: 1.65 -> 1.66 Makefile.config.in updated: 1.66 -> 1.67 Makefile.rules updated: 1.410 -> 1.411 configure updated: 1.255 -> 1.256 --- Log message: In LLVM 2.0 we won't use the runtime libraries as llvm-gcc3 support will be dropped. This patch pertains to removing the runtime directory from LLVM. --- Diffs of the changes: (+34 -80) Makefile | 13 ++----- Makefile.config.in | 5 --- Makefile.rules | 8 ---- configure | 88 ++++++++++++++++++----------------------------------- 4 files changed, 34 insertions(+), 80 deletions(-) Index: llvm/Makefile diff -u llvm/Makefile:1.65 llvm/Makefile:1.66 --- llvm/Makefile:1.65 Sun Sep 3 23:27:07 2006 +++ llvm/Makefile Thu Nov 16 17:17:26 2006 @@ -15,28 +15,23 @@ # 3. Build VMCore, which builds the Intrinsics.inc file used by libs. # 4. Build libs, which are needed by llvm-config. # 5. Build llvm-config, which determines inter-lib dependencies for tools. -# 6. Build tools, runtime, docs. +# 6. Build tools, docs. # DIRS := lib/System lib/Support utils lib/VMCore lib tools/llvm-config \ - tools runtime docs + tools docs OPTIONAL_DIRS := examples projects EXTRA_DIST := test llvm.spec include win32 Xcode include $(LEVEL)/Makefile.config -# llvm-gcc4 doesn't need runtime libs. -ifeq ($(LLVMGCC_MAJVERS),4) - DIRS := $(filter-out runtime, $(DIRS)) -endif - ifeq ($(MAKECMDGOALS),libs-only) - DIRS := $(filter-out tools runtime docs, $(DIRS)) + DIRS := $(filter-out tools docs, $(DIRS)) OPTIONAL_DIRS := endif ifeq ($(MAKECMDGOALS),tools-only) - DIRS := $(filter-out runtime docs, $(DIRS)) + DIRS := $(filter-out docs, $(DIRS)) OPTIONAL_DIRS := endif Index: llvm/Makefile.config.in diff -u llvm/Makefile.config.in:1.66 llvm/Makefile.config.in:1.67 --- llvm/Makefile.config.in:1.66 Sun Nov 5 14:10:16 2006 +++ llvm/Makefile.config.in Thu Nov 16 17:17:26 2006 @@ -207,11 +207,6 @@ #DISABLE_ASSERTIONS = 1 @DISABLE_ASSERTIONS@ -# When DEBUG_RUNTIME is enabled, the runtime libraries will retain debug -# symbols. -#DEBUG_RUNTIME = 1 - at DEBUG_RUNTIME@ - # When ENABLE_PROFILING is enabled, the llvm source base is built with profile # information to allow gprof to be used to get execution frequencies. #ENABLE_PROFILING = 1 Index: llvm/Makefile.rules diff -u llvm/Makefile.rules:1.410 llvm/Makefile.rules:1.411 --- llvm/Makefile.rules:1.410 Wed Nov 15 15:04:15 2006 +++ llvm/Makefile.rules Thu Nov 16 17:17:26 2006 @@ -1099,18 +1099,10 @@ $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG) $(MAYBE_PIC_Compile.C) $< -o $@ -S - # make the C and C++ compilers strip debug info out of bytecode libraries. -ifdef DEBUG_RUNTIME -$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(GCCAS) - $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)" - $(Verb) $(GCCAS) $< -o $@ -else $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(GCCAS) $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)" $(Verb) $(GCCAS) -strip-debug $< -o $@ -endif - #--------------------------------------------------------- # Provide rule to build .bc files from .ll sources, Index: llvm/configure diff -u llvm/configure:1.255 llvm/configure:1.256 --- llvm/configure:1.255 Mon Nov 13 18:59:52 2006 +++ llvm/configure Thu Nov 16 17:17:26 2006 @@ -830,7 +830,6 @@ CVSBUILD ENABLE_OPTIMIZED DISABLE_ASSERTIONS -DEBUG_RUNTIME JIT TARGET_HAS_JIT ENABLE_DOXYGEN @@ -1520,7 +1519,6 @@ --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-optimized --enable-assertions - --enable-debug-runtime --enable-jit Enable Just In Time Compiling (default is YES) --enable-doxygen Build doxygen documentation (default is NO) --enable-threads Use threads if available (default is YES) @@ -4563,21 +4561,6 @@ fi -# Check whether --enable-debug-runtime was given. -if test "${enable_debug_runtime+set}" = set; then - enableval=$enable_debug_runtime; -else - enableval=no -fi - -if test ${enableval} = "no" ; then - DEBUG_RUNTIME= - -else - DEBUG_RUNTIME=DEBUG_RUNTIME=1 - -fi - # Check whether --enable-jit was given. if test "${enable_jit+set}" = set; then enableval=$enable_jit; @@ -10298,7 +10281,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext + echo '#line 12428 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -14160,11 +14143,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14163: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14146: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:14167: \$? = $ac_status" >&5 + echo "$as_me:14150: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -14428,11 +14411,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14431: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14414: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:14435: \$? = $ac_status" >&5 + echo "$as_me:14418: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -14532,11 +14515,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14535: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14518: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:14539: \$? = $ac_status" >&5 + echo "$as_me:14522: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -16984,7 +16967,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:19438: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:19459: \$? = $ac_status" >&5 + echo "$as_me:19442: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -19556,11 +19539,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:19559: $lt_compile\"" >&5) + (eval echo "\"\$as_me:19542: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:19563: \$? = $ac_status" >&5 + echo "$as_me:19546: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -21126,11 +21109,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:21129: $lt_compile\"" >&5) + (eval echo "\"\$as_me:21112: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:21133: \$? = $ac_status" >&5 + echo "$as_me:21116: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -21230,11 +21213,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:21233: $lt_compile\"" >&5) + (eval echo "\"\$as_me:21216: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:21237: \$? = $ac_status" >&5 + echo "$as_me:21220: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -23465,11 +23448,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:23468: $lt_compile\"" >&5) + (eval echo "\"\$as_me:23451: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:23472: \$? = $ac_status" >&5 + echo "$as_me:23455: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -23733,11 +23716,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:23736: $lt_compile\"" >&5) + (eval echo "\"\$as_me:23719: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:23740: \$? = $ac_status" >&5 + echo "$as_me:23723: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -23837,11 +23820,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:23840: $lt_compile\"" >&5) + (eval echo "\"\$as_me:23823: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:23844: \$? = $ac_status" >&5 + echo "$as_me:23827: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -33431,9 +33414,6 @@ ac_config_commands="$ac_config_commands lib/Makefile" -ac_config_commands="$ac_config_commands runtime/Makefile" - - ac_config_commands="$ac_config_commands test/Makefile" @@ -34027,7 +34007,6 @@ "Makefile.common") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile.common" ;; "examples/Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS examples/Makefile" ;; "lib/Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS lib/Makefile" ;; - "runtime/Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS runtime/Makefile" ;; "test/Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS test/Makefile" ;; "test/Makefile.tests") CONFIG_COMMANDS="$CONFIG_COMMANDS test/Makefile.tests" ;; "tools/Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS tools/Makefile" ;; @@ -34169,7 +34148,6 @@ CVSBUILD!$CVSBUILD$ac_delim ENABLE_OPTIMIZED!$ENABLE_OPTIMIZED$ac_delim DISABLE_ASSERTIONS!$DISABLE_ASSERTIONS$ac_delim -DEBUG_RUNTIME!$DEBUG_RUNTIME$ac_delim JIT!$JIT$ac_delim TARGET_HAS_JIT!$TARGET_HAS_JIT$ac_delim ENABLE_DOXYGEN!$ENABLE_DOXYGEN$ac_delim @@ -34192,6 +34170,7 @@ LN_S!$LN_S$ac_delim CMP!$CMP$ac_delim CP!$CP$ac_delim +DATE!$DATE$ac_delim _ACEOF if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then @@ -34233,7 +34212,6 @@ ac_delim='%!_!# ' for ac_last_try in false false false false false :; do cat >conf$$subs.sed <<_ACEOF -DATE!$DATE$ac_delim FIND!$FIND$ac_delim MKDIR!$MKDIR$ac_delim MV!$MV$ac_delim @@ -34299,7 +34277,7 @@ LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 64; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 63; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 @@ -34710,8 +34688,6 @@ ${SHELL} ${llvm_src}/autoconf/install-sh -c ${srcdir}/examples/Makefile examples/Makefile ;; "lib/Makefile":C) ${llvm_src}/autoconf/mkinstalldirs `dirname lib/Makefile` ${SHELL} ${llvm_src}/autoconf/install-sh -c ${srcdir}/lib/Makefile lib/Makefile ;; - "runtime/Makefile":C) ${llvm_src}/autoconf/mkinstalldirs `dirname runtime/Makefile` - ${SHELL} ${llvm_src}/autoconf/install-sh -c ${srcdir}/runtime/Makefile runtime/Makefile ;; "test/Makefile":C) ${llvm_src}/autoconf/mkinstalldirs `dirname test/Makefile` ${SHELL} ${llvm_src}/autoconf/install-sh -c ${srcdir}/test/Makefile test/Makefile ;; "test/Makefile.tests":C) ${llvm_src}/autoconf/mkinstalldirs `dirname test/Makefile.tests` @@ -34933,12 +34909,8 @@ if test "$llvm_cv_llvmgcc_sanity" = "no" ; then { echo "$as_me:$LINENO: WARNING: ***** llvm-gcc/llvm-g++ was not found, or does not appear to be " >&5 echo "$as_me: WARNING: ***** llvm-gcc/llvm-g++ was not found, or does not appear to be " >&2;} - { echo "$as_me:$LINENO: WARNING: ***** working. Please make sure you have llvm-gcc and llvm-g++ in" >&5 -echo "$as_me: WARNING: ***** working. Please make sure you have llvm-gcc and llvm-g++ in" >&2;} - { echo "$as_me:$LINENO: WARNING: ***** your path before configuring LLVM. The runtime libraries" >&5 -echo "$as_me: WARNING: ***** your path before configuring LLVM. The runtime libraries" >&2;} - { echo "$as_me:$LINENO: WARNING: ***** (llvm/runtime) will not be built but you should be able to" >&5 -echo "$as_me: WARNING: ***** (llvm/runtime) will not be built but you should be able to" >&2;} - { echo "$as_me:$LINENO: WARNING: ***** build the llvm tools." >&5 -echo "$as_me: WARNING: ***** build the llvm tools." >&2;} + { echo "$as_me:$LINENO: WARNING: ***** working. Please make sure you have llvm-gcc and llvm-g++ " >&5 +echo "$as_me: WARNING: ***** working. Please make sure you have llvm-gcc and llvm-g++ " >&2;} + { echo "$as_me:$LINENO: WARNING: ***** in your path before configuring LLVM." >&5 +echo "$as_me: WARNING: ***** in your path before configuring LLVM." >&2;} fi From llvm at cs.uiuc.edu Thu Nov 16 17:18:21 2006 From: llvm at cs.uiuc.edu (LLVM) Date: Thu, 16 Nov 2006 17:18:21 -0600 Subject: [llvm-commits] CVS: llvm/runtime/GC/SemiSpace/Makefile semispace.c Message-ID: <200611162318.kAGNILOr010557@zion.cs.uiuc.edu> Changes in directory llvm/runtime/GC/SemiSpace: Makefile (r1.7) removed semispace.c (r1.5) removed --- Log message: In LLVM 2.0 we won't use the runtime libraries as llvm-gcc3 support will be dropped. This patch pertains to removing the runtime directory from LLVM. --- Diffs of the changes: (+0 -0) 0 files changed From llvm at cs.uiuc.edu Thu Nov 16 17:18:23 2006 From: llvm at cs.uiuc.edu (LLVM) Date: Thu, 16 Nov 2006 17:18:23 -0600 Subject: [llvm-commits] CVS: llvm/runtime/GCCLibraries/Makefile README.txt Message-ID: <200611162318.kAGNINbW010568@zion.cs.uiuc.edu> Changes in directory llvm/runtime/GCCLibraries: Makefile (r1.8) removed README.txt (r1.1) removed --- Log message: In LLVM 2.0 we won't use the runtime libraries as llvm-gcc3 support will be dropped. This patch pertains to removing the runtime directory from LLVM. --- Diffs of the changes: (+0 -0) 0 files changed From llvm at cs.uiuc.edu Thu Nov 16 17:18:21 2006 From: llvm at cs.uiuc.edu (LLVM) Date: Thu, 16 Nov 2006 17:18:21 -0600 Subject: [llvm-commits] CVS: llvm/runtime/Makefile README.txt Message-ID: <200611162318.kAGNILCR010552@zion.cs.uiuc.edu> Changes in directory llvm/runtime: Makefile (r1.28) removed README.txt (r1.2) removed --- Log message: In LLVM 2.0 we won't use the runtime libraries as llvm-gcc3 support will be dropped. This patch pertains to removing the runtime directory from LLVM. --- Diffs of the changes: (+0 -0) 0 files changed From llvm at cs.uiuc.edu Thu Nov 16 17:18:22 2006 From: llvm at cs.uiuc.edu (LLVM) Date: Thu, 16 Nov 2006 17:18:22 -0600 Subject: [llvm-commits] CVS: llvm/runtime/GCCLibraries/libm/Makefile temp.c Message-ID: <200611162318.kAGNIMpK010562@zion.cs.uiuc.edu> Changes in directory llvm/runtime/GCCLibraries/libm: Makefile (r1.10) removed temp.c (r1.2) removed --- Log message: In LLVM 2.0 we won't use the runtime libraries as llvm-gcc3 support will be dropped. This patch pertains to removing the runtime directory from LLVM. --- Diffs of the changes: (+0 -0) 0 files changed From llvm at cs.uiuc.edu Thu Nov 16 17:18:23 2006 From: llvm at cs.uiuc.edu (LLVM) Date: Thu, 16 Nov 2006 17:18:23 -0600 Subject: [llvm-commits] CVS: llvm/runtime/GCCLibraries/libgcc/Makefile eprintf.c Message-ID: <200611162318.kAGNINNw010574@zion.cs.uiuc.edu> Changes in directory llvm/runtime/GCCLibraries/libgcc: Makefile (r1.8) removed eprintf.c (r1.1) removed --- Log message: In LLVM 2.0 we won't use the runtime libraries as llvm-gcc3 support will be dropped. This patch pertains to removing the runtime directory from LLVM. --- Diffs of the changes: (+0 -0) 0 files changed From llvm at cs.uiuc.edu Thu Nov 16 17:18:42 2006 From: llvm at cs.uiuc.edu (LLVM) Date: Thu, 16 Nov 2006 17:18:42 -0600 Subject: [llvm-commits] CVS: llvm/runtime/GC/GCInterface.h Makefile gc_exported_symbols.lst Message-ID: <200611162318.kAGNIgwJ010597@zion.cs.uiuc.edu> Changes in directory llvm/runtime/GC: GCInterface.h (r1.4) removed Makefile (r1.3) removed gc_exported_symbols.lst (r1.1) removed --- Log message: In LLVM 2.0 we won't use the runtime libraries as llvm-gcc3 support will be dropped. This patch pertains to removing the runtime directory from LLVM. --- Diffs of the changes: (+0 -0) 0 files changed From llvm at cs.uiuc.edu Thu Nov 16 17:18:38 2006 From: llvm at cs.uiuc.edu (LLVM) Date: Thu, 16 Nov 2006 17:18:38 -0600 Subject: [llvm-commits] CVS: llvm/runtime/libdummy/Makefile README.txt dummylib.c Message-ID: <200611162318.kAGNIcFn010589@zion.cs.uiuc.edu> Changes in directory llvm/runtime/libdummy: Makefile (r1.8) removed README.txt (r1.1) removed dummylib.c (r1.6) removed --- Log message: In LLVM 2.0 we won't use the runtime libraries as llvm-gcc3 support will be dropped. This patch pertains to removing the runtime directory from LLVM. --- Diffs of the changes: (+0 -0) 0 files changed From llvm at cs.uiuc.edu Thu Nov 16 17:19:27 2006 From: llvm at cs.uiuc.edu (LLVM) Date: Thu, 16 Nov 2006 17:19:27 -0600 Subject: [llvm-commits] CVS: llvm/runtime/GCCLibraries/crtend/Exception.cpp Exception.h Makefile README.txt SJLJ-Exception.cpp SJLJ-Exception.h comp_genericeh.lst comp_main.lst comp_sjljeh.lst crtend.c Message-ID: <200611162319.kAGNJRnS010641@zion.cs.uiuc.edu> Changes in directory llvm/runtime/GCCLibraries/crtend: Exception.cpp (r1.2) removed Exception.h (r1.10) removed Makefile (r1.34) removed README.txt (r1.2) removed SJLJ-Exception.cpp (r1.5) removed SJLJ-Exception.h (r1.5) removed comp_genericeh.lst (r1.1) removed comp_main.lst (r1.1) removed comp_sjljeh.lst (r1.1) removed crtend.c (r1.6) removed --- Log message: In LLVM 2.0 we won't use the runtime libraries as llvm-gcc3 support will be dropped. This patch pertains to removing the runtime directory from LLVM. --- Diffs of the changes: (+0 -0) 0 files changed From llvm at cs.uiuc.edu Thu Nov 16 17:18:49 2006 From: llvm at cs.uiuc.edu (LLVM) Date: Thu, 16 Nov 2006 17:18:49 -0600 Subject: [llvm-commits] CVS: llvm/runtime/libtrace/Makefile README.txt tracelib.c tracelib.h Message-ID: <200611162318.kAGNInYU010607@zion.cs.uiuc.edu> Changes in directory llvm/runtime/libtrace: Makefile (r1.14) removed README.txt (r1.1) removed tracelib.c (r1.12) removed tracelib.h (r1.3) removed --- Log message: In LLVM 2.0 we won't use the runtime libraries as llvm-gcc3 support will be dropped. This patch pertains to removing the runtime directory from LLVM. --- Diffs of the changes: (+0 -0) 0 files changed From llvm at cs.uiuc.edu Thu Nov 16 17:19:23 2006 From: llvm at cs.uiuc.edu (LLVM) Date: Thu, 16 Nov 2006 17:19:23 -0600 Subject: [llvm-commits] CVS: llvm/runtime/libprofile/BasicBlockTracing.c BlockProfiling.c CommonProfiling.c EdgeProfiling.c FunctionProfiling.c Makefile Profiling.h exported_symbols.lst Message-ID: <200611162319.kAGNJNF3010633@zion.cs.uiuc.edu> Changes in directory llvm/runtime/libprofile: BasicBlockTracing.c (r1.2) removed BlockProfiling.c (r1.3) removed CommonProfiling.c (r1.8) removed EdgeProfiling.c (r1.2) removed FunctionProfiling.c (r1.3) removed Makefile (r1.8) removed Profiling.h (r1.5) removed exported_symbols.lst (r1.2) removed --- Log message: In LLVM 2.0 we won't use the runtime libraries as llvm-gcc3 support will be dropped. This patch pertains to removing the runtime directory from LLVM. --- Diffs of the changes: (+0 -0) 0 files changed From llvm at cs.uiuc.edu Thu Nov 16 17:19:28 2006 From: llvm at cs.uiuc.edu (LLVM) Date: Thu, 16 Nov 2006 17:19:28 -0600 Subject: [llvm-commits] CVS: llvm/runtime/GCCLibraries/libc/COPYING.LIB LICENSE.TXT LICENSES Makefile README.txt atox.c io.c qsort.c remove.c string.c Message-ID: <200611162319.kAGNJS2O010646@zion.cs.uiuc.edu> Changes in directory llvm/runtime/GCCLibraries/libc: COPYING.LIB (r1.1) removed LICENSE.TXT (r1.4) removed LICENSES (r1.1) removed Makefile (r1.8) removed README.txt (r1.1) removed atox.c (r1.2) removed io.c (r1.1) removed qsort.c (r1.5) removed remove.c (r1.2) removed string.c (r1.9) removed --- Log message: In LLVM 2.0 we won't use the runtime libraries as llvm-gcc3 support will be dropped. This patch pertains to removing the runtime directory from LLVM. --- Diffs of the changes: (+0 -0) 0 files changed From evan.cheng at apple.com Thu Nov 16 17:22:41 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 16 Nov 2006 17:22:41 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86InstrInfo.cpp Message-ID: <200611162322.kAGNMfa3010724@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86InstrInfo.cpp updated: 1.73 -> 1.74 --- Log message: Fix a potential bug: MOVPDI2DI, etc. are not copy instructions. --- Diffs of the changes: (+1 -3) X86InstrInfo.cpp | 4 +--- 1 files changed, 1 insertion(+), 3 deletions(-) Index: llvm/lib/Target/X86/X86InstrInfo.cpp diff -u llvm/lib/Target/X86/X86InstrInfo.cpp:1.73 llvm/lib/Target/X86/X86InstrInfo.cpp:1.74 --- llvm/lib/Target/X86/X86InstrInfo.cpp:1.73 Wed Nov 15 14:58:11 2006 +++ llvm/lib/Target/X86/X86InstrInfo.cpp Thu Nov 16 17:22:26 2006 @@ -44,9 +44,7 @@ oc == X86::FsMOVAPSrr || oc == X86::FsMOVAPDrr || oc == X86::MOVAPSrr || oc == X86::MOVAPDrr || oc == X86::MOVSS2PSrr || oc == X86::MOVSD2PDrr || - oc == X86::MOVPS2SSrr || oc == X86::MOVPD2SDrr || - oc == X86::MOVDI2PDIrr || oc == X86::MOVQI2PQIrr || - oc == X86::MOVPDI2DIrr) { + oc == X86::MOVPS2SSrr || oc == X86::MOVPD2SDrr) { assert(MI.getNumOperands() == 2 && MI.getOperand(0).isRegister() && MI.getOperand(1).isRegister() && From evan.cheng at apple.com Thu Nov 16 17:33:40 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 16 Nov 2006 17:33:40 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86InstrSSE.td X86InstrX86-64.td X86RegisterInfo.cpp Message-ID: <200611162333.kAGNXekv010992@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86InstrSSE.td updated: 1.171 -> 1.172 X86InstrX86-64.td updated: 1.6 -> 1.7 X86RegisterInfo.cpp updated: 1.178 -> 1.179 --- Log message: Correct instructions for moving data between GR64 and SSE registers; also correct load i64 / store i64 from v2i64. --- Diffs of the changes: (+34 -6) X86InstrSSE.td | 11 ++++++----- X86InstrX86-64.td | 26 ++++++++++++++++++++++++++ X86RegisterInfo.cpp | 3 ++- 3 files changed, 34 insertions(+), 6 deletions(-) Index: llvm/lib/Target/X86/X86InstrSSE.td diff -u llvm/lib/Target/X86/X86InstrSSE.td:1.171 llvm/lib/Target/X86/X86InstrSSE.td:1.172 --- llvm/lib/Target/X86/X86InstrSSE.td:1.171 Fri Nov 10 15:43:37 2006 +++ llvm/lib/Target/X86/X86InstrSSE.td Thu Nov 16 17:33:25 2006 @@ -1682,17 +1682,18 @@ "movd {$src, $dst|$dst, $src}", [(set VR128:$dst, (v4i32 (scalar_to_vector (loadi32 addr:$src))))]>; + // SSE2 instructions with XS prefix -def MOVQI2PQIrr : I<0x7E, MRMSrcReg, (ops VR128:$dst, VR64:$src), - "movq {$src, $dst|$dst, $src}", - [(set VR128:$dst, - (v2i64 (scalar_to_vector VR64:$src)))]>, XS, - Requires<[HasSSE2]>; def MOVQI2PQIrm : I<0x7E, MRMSrcMem, (ops VR128:$dst, i64mem:$src), "movq {$src, $dst|$dst, $src}", [(set VR128:$dst, (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>, XS, Requires<[HasSSE2]>; +def MOVPQI2QImr : PDI<0xD6, MRMDestMem, (ops i64mem:$dst, VR128:$src), + "movq {$src, $dst|$dst, $src}", + [(store (i64 (vector_extract (v2i64 VR128:$src), + (iPTR 0))), addr:$dst)]>; + // FIXME: may not be able to eliminate this movss with coalescing the src and // dest register classes are different. We really want to write this pattern // like this: Index: llvm/lib/Target/X86/X86InstrX86-64.td diff -u llvm/lib/Target/X86/X86InstrX86-64.td:1.6 llvm/lib/Target/X86/X86InstrX86-64.td:1.7 --- llvm/lib/Target/X86/X86InstrX86-64.td:1.6 Fri Nov 3 17:48:56 2006 +++ llvm/lib/Target/X86/X86InstrX86-64.td Thu Nov 16 17:33:25 2006 @@ -59,6 +59,8 @@ : SSI, REX_W; class RSDI o, Format F, dag ops, string asm, list pattern> : SDI, REX_W; +class RPDI o, Format F, dag ops, string asm, list pattern> + : PDI, REX_W; //===----------------------------------------------------------------------===// // Pattern fragments... @@ -1076,3 +1078,27 @@ def : Pat<(store (or (shl (loadi64 addr:$dst), CL:$amt), (srl GR64:$src2, (sub 64, CL:$amt))), addr:$dst), (SHLD64mrCL addr:$dst, GR64:$src2)>; + +//===----------------------------------------------------------------------===// +// X86-64 SSE Instructions +//===----------------------------------------------------------------------===// + +// Move instructions... + +def MOV64toPQIrr : RPDI<0x6E, MRMSrcReg, (ops VR128:$dst, GR64:$src), + "movq {$src, $dst|$dst, $src}", + [(set VR128:$dst, + (v2i64 (scalar_to_vector GR64:$src)))]>; +def MOV64toPQIrm : RPDI<0x6E, MRMSrcMem, (ops VR128:$dst, i64mem:$src), + "movq {$src, $dst|$dst, $src}", + [(set VR128:$dst, + (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>; + +def MOVPQIto64rr : RPDI<0x7E, MRMDestReg, (ops GR64:$dst, VR128:$src), + "movd {$src, $dst|$dst, $src}", + [(set GR64:$dst, (vector_extract (v2i64 VR128:$src), + (iPTR 0)))]>; +def MOVPQIto64mr : RPDI<0x7E, MRMDestMem, (ops i64mem:$dst, VR128:$src), + "movd {$src, $dst|$dst, $src}", + [(store (i64 (vector_extract (v2i64 VR128:$src), + (iPTR 0))), addr:$dst)]>; Index: llvm/lib/Target/X86/X86RegisterInfo.cpp diff -u llvm/lib/Target/X86/X86RegisterInfo.cpp:1.178 llvm/lib/Target/X86/X86RegisterInfo.cpp:1.179 --- llvm/lib/Target/X86/X86RegisterInfo.cpp:1.178 Wed Nov 15 14:58:11 2006 +++ llvm/lib/Target/X86/X86RegisterInfo.cpp Thu Nov 16 17:33:25 2006 @@ -509,6 +509,7 @@ { X86::MOVAPDrr, X86::MOVAPDmr }, { X86::MOVAPSrr, X86::MOVAPSmr }, { X86::MOVPDI2DIrr, X86::MOVPDI2DImr }, + { X86::MOVPQIto64rr,X86::MOVPQIto64mr }, { X86::MOVPS2SSrr, X86::MOVPS2SSmr }, { X86::MOVSDrr, X86::MOVSDmr }, { X86::MOVSSrr, X86::MOVSSmr }, @@ -606,12 +607,12 @@ { X86::MOV16rr, X86::MOV16rm }, { X86::MOV32rr, X86::MOV32rm }, { X86::MOV64rr, X86::MOV64rm }, + { X86::MOV64toPQIrr, X86::MOV64toPQIrm }, { X86::MOV8rr, X86::MOV8rm }, { X86::MOVAPDrr, X86::MOVAPDrm }, { X86::MOVAPSrr, X86::MOVAPSrm }, { X86::MOVDDUPrr, X86::MOVDDUPrm }, { X86::MOVDI2PDIrr, X86::MOVDI2PDIrm }, - { X86::MOVQI2PQIrr, X86::MOVQI2PQIrm }, { X86::MOVSD2PDrr, X86::MOVSD2PDrm }, { X86::MOVSDrr, X86::MOVSDrm }, { X86::MOVSHDUPrr, X86::MOVSHDUPrm }, From evan.cheng at apple.com Thu Nov 16 17:38:36 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 16 Nov 2006 17:38:36 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/CodeGen/X86/xmm-r64.ll fabs.ll Message-ID: <200611162338.kAGNcaFK011120@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/CodeGen/X86: xmm-r64.ll added (r1.1) fabs.ll updated: 1.9 -> 1.10 --- Log message: New test case. --- Diffs of the changes: (+13 -2) fabs.ll | 4 ++-- xmm-r64.ll | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) Index: llvm/test/Regression/CodeGen/X86/xmm-r64.ll diff -c /dev/null llvm/test/Regression/CodeGen/X86/xmm-r64.ll:1.1 *** /dev/null Thu Nov 16 17:38:31 2006 --- llvm/test/Regression/CodeGen/X86/xmm-r64.ll Thu Nov 16 17:38:21 2006 *************** *** 0 **** --- 1,11 ---- + ; RUN: llvm-as < %s | llc -march=x86-64 + + <4 x int> %test() { + %tmp1039 = call <4 x int> %llvm.x86.sse2.psll.d( <4 x int> zeroinitializer, <4 x int> zeroinitializer ) ; <<4 x int>> [#uses=1] + %tmp1040 = cast <4 x int> %tmp1039 to <2 x long> ; <<2 x long>> [#uses=1] + %tmp1048 = add <2 x long> %tmp1040, zeroinitializer ; <<2 x long>> [#uses=1] + %tmp1048 = cast <2 x long> %tmp1048 to <4 x int> ; <<4 x int>> [#uses=1] + ret <4 x int> %tmp1048 + } + + declare <4 x int> %llvm.x86.sse2.psll.d(<4 x int>, <4 x int>) Index: llvm/test/Regression/CodeGen/X86/fabs.ll diff -u llvm/test/Regression/CodeGen/X86/fabs.ll:1.9 llvm/test/Regression/CodeGen/X86/fabs.ll:1.10 --- llvm/test/Regression/CodeGen/X86/fabs.ll:1.9 Tue Aug 29 17:01:39 2006 +++ llvm/test/Regression/CodeGen/X86/fabs.ll Thu Nov 16 17:38:21 2006 @@ -7,12 +7,12 @@ declare float %fabsf(float) -float %fabsftest(float %X) { +float %test1(float %X) { %Y = call float %fabsf(float %X) ret float %Y } -double %fabstest2(double %X) { +double %test2(double %X) { %Y = setge double %X, -0.0 %Z = sub double -0.0, %X %Q = select bool %Y, double %X, double %Z From sabre at nondot.org Thu Nov 16 17:50:07 2006 From: sabre at nondot.org (Chris Lattner) Date: Thu, 16 Nov 2006 17:50:07 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCBranchSelector.cpp Message-ID: <200611162350.kAGNo765011347@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCBranchSelector.cpp updated: 1.30 -> 1.31 --- Log message: implicit_def_vrrc doesn't generate code. --- Diffs of the changes: (+31 -31) PPCBranchSelector.cpp | 62 +++++++++++++++++++++++++------------------------- 1 files changed, 31 insertions(+), 31 deletions(-) Index: llvm/lib/Target/PowerPC/PPCBranchSelector.cpp diff -u llvm/lib/Target/PowerPC/PPCBranchSelector.cpp:1.30 llvm/lib/Target/PowerPC/PPCBranchSelector.cpp:1.31 --- llvm/lib/Target/PowerPC/PPCBranchSelector.cpp:1.30 Thu Nov 16 12:13:49 2006 +++ llvm/lib/Target/PowerPC/PPCBranchSelector.cpp Thu Nov 16 17:49:52 2006 @@ -64,6 +64,7 @@ case PPC::IMPLICIT_DEF_G8RC: // no asm emitted case PPC::IMPLICIT_DEF_F4: // no asm emitted case PPC::IMPLICIT_DEF_F8: // no asm emitted + case PPC::IMPLICIT_DEF_VRRC: // no asm emitted return 0; case PPC::INLINEASM: { // Inline Asm: Variable size. MachineFunction *MF = MI->getParent()->getParent(); @@ -114,38 +115,37 @@ // We may end up deleting the MachineInstr that MBBI points to, so // remember its opcode now so we can refer to it after calling erase() unsigned ByteSize = getNumBytesForInstruction(MBBI); - if (MBBI->getOpcode() == PPC::COND_BRANCH) { - MachineBasicBlock::iterator MBBJ = MBBI; - ++MBBJ; - - // condbranch operands: - // 0. CR0 register - // 1. bc opcode - // 2. target MBB - // 3. fallthrough MBB - MachineBasicBlock *trueMBB = - MBBI->getOperand(2).getMachineBasicBlock(); - - int Displacement = OffsetMap[trueMBB] - ByteCount; - unsigned Opcode = MBBI->getOperand(1).getImmedValue(); - unsigned CRReg = MBBI->getOperand(0).getReg(); - unsigned Inverted = PPCInstrInfo::invertPPCBranchOpcode(Opcode); - - if (Displacement >= -32768 && Displacement <= 32767) { - BuildMI(*MBB, MBBJ, Opcode, 2).addReg(CRReg).addMBB(trueMBB); - } else { - // Long branch, skip next branch instruction (i.e. $PC+8). - ++NumExpanded; - BuildMI(*MBB, MBBJ, Inverted, 2).addReg(CRReg).addImm(2); - BuildMI(*MBB, MBBJ, PPC::B, 1).addMBB(trueMBB); - } - - // Erase the psuedo COND_BRANCH instruction, and then back up the - // iterator so that when the for loop increments it, we end up in - // the correct place rather than iterating off the end. - MBB->erase(MBBI); - MBBI = --MBBJ; + if (MBBI->getOpcode() != PPC::COND_BRANCH) { + ByteCount += ByteSize; + continue; } + + // condbranch operands: + // 0. CR register + // 1. PPC branch opcode + // 2. Target MBB + MachineBasicBlock *DestMBB = MBBI->getOperand(2).getMachineBasicBlock(); + unsigned Opcode = MBBI->getOperand(1).getImmedValue(); + unsigned CRReg = MBBI->getOperand(0).getReg(); + + int Displacement = OffsetMap[DestMBB] - ByteCount; + unsigned Inverted = PPCInstrInfo::invertPPCBranchOpcode(Opcode); + + MachineBasicBlock::iterator MBBJ; + if (Displacement >= -32768 && Displacement <= 32767) { + MBBJ = BuildMI(*MBB, MBBJ, Opcode, 2).addReg(CRReg).addMBB(DestMBB); + } else { + // Long branch, skip next branch instruction (i.e. $PC+8). + ++NumExpanded; + BuildMI(*MBB, MBBJ, Inverted, 2).addReg(CRReg).addImm(2); + MBBJ = BuildMI(*MBB, MBBJ, PPC::B, 1).addMBB(DestMBB); + } + + // Erase the psuedo COND_BRANCH instruction, and then back up the + // iterator so that when the for loop increments it, we end up in + // the correct place rather than iterating off the end. + MBB->erase(MBBI); + MBBI = MBBJ; ByteCount += ByteSize; } } From jlaskey at apple.com Thu Nov 16 16:43:52 2006 From: jlaskey at apple.com (Jim Laskey) Date: Thu, 16 Nov 2006 16:43:52 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.h PPCFrameInfo.h PPCISelLowering.cpp PPCISelLowering.h PPCInstr64Bit.td PPCInstrInfo.td PPCRegisterInfo.cpp PPCRegisterInfo.h PPCRegisterInfo.td Message-ID: <200611162243.kAGMhq55009724@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCMachineFunctionInfo.h added (r1.1) PPCFrameInfo.h updated: 1.9 -> 1.10 PPCISelLowering.cpp updated: 1.227 -> 1.228 PPCISelLowering.h updated: 1.56 -> 1.57 PPCInstr64Bit.td updated: 1.31 -> 1.32 PPCInstrInfo.td updated: 1.265 -> 1.266 PPCRegisterInfo.cpp updated: 1.85 -> 1.86 PPCRegisterInfo.h updated: 1.17 -> 1.18 PPCRegisterInfo.td updated: 1.39 -> 1.40 --- Log message: This is a general clean up of the PowerPC ABI. Address several problems and bugs including making sure that the TOS links back to the previous frame, that the maximum call frame size is not included twice when using frame pointers, no longer growing the frame on calls, double storing of SP and a cleaner/faster dynamic alloca. --- Diffs of the changes: (+409 -150) PPCFrameInfo.h | 34 ++++ PPCISelLowering.cpp | 75 +++++++-- PPCISelLowering.h | 5 PPCInstr64Bit.td | 6 PPCInstrInfo.td | 11 + PPCMachineFunctionInfo.h | 43 +++++ PPCRegisterInfo.cpp | 376 ++++++++++++++++++++++++++++++----------------- PPCRegisterInfo.h | 5 PPCRegisterInfo.td | 4 9 files changed, 409 insertions(+), 150 deletions(-) Index: llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.h diff -c /dev/null llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.h:1.1 *** /dev/null Thu Nov 16 16:43:47 2006 --- llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.h Thu Nov 16 16:43:37 2006 *************** *** 0 **** --- 1,43 ---- + //===-- PPCMachineFunctionInfo.h - Private data used for PowerPC --*- C++ -*-=// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by James M. Laskey and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file declares the PowerPC specific subclass of MachineFunctionInfo. + // + //===----------------------------------------------------------------------===// + + #ifndef PPC_MACHINE_FUNCTION_INFO_H + #define PPC_MACHINE_FUNCTION_INFO_H + + #include "llvm/CodeGen/MachineFunction.h" + + namespace llvm { + + /// PPCFunctionInfo - This class is derived from MachineFunction private + /// PowerPC target-specific information for each MachineFunction. + class PPCFunctionInfo : public MachineFunctionInfo { + private: + /// FramePointerSaveIndex - Frame index of where the old frame pointer is + /// stored. Also used as an anchor for instructions that need to be altered + /// when using frame pointers (dyna_add, dyna_sub.) + int FramePointerSaveIndex; + + public: + PPCFunctionInfo(MachineFunction& MF) + : FramePointerSaveIndex(0) + {} + + int getFramePointerSaveIndex() const { return FramePointerSaveIndex; } + void setFramePointerSaveIndex(int Idx) { FramePointerSaveIndex = Idx; } + + }; + + } // end of namespace llvm + + + #endif \ No newline at end of file Index: llvm/lib/Target/PowerPC/PPCFrameInfo.h diff -u llvm/lib/Target/PowerPC/PPCFrameInfo.h:1.9 llvm/lib/Target/PowerPC/PPCFrameInfo.h:1.10 --- llvm/lib/Target/PowerPC/PPCFrameInfo.h:1.9 Sun Oct 16 00:39:50 2005 +++ llvm/lib/Target/PowerPC/PPCFrameInfo.h Thu Nov 16 16:43:37 2006 @@ -35,6 +35,40 @@ NumEntries = 1; return &LR[0]; } + + /// getFramePointerSaveOffset - Return the previous frame offset to save the + /// frame pointer. + static unsigned getFramePointerSaveOffset(bool LP64) { + // Use the TOC save slot in the PowerPC linkage area for saving the frame + // pointer (if needed.) LLVM does not generate code that uses the TOC (R2 + // is treated as a caller saved register.) + return LP64 ? 40 : 20; + } + + /// getLinkageSize - Return the size of the PowerPC ABI linkage area. + /// + static unsigned getLinkageSize(bool LP64) { + return 6 * (LP64 ? 8 : 4); + } + + /// getMinCallArgumentsSize - Return the size of the minium PowerPC ABI + /// argument area. + static unsigned getMinCallArgumentsSize(bool LP64) { + // 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. + return 8 * (LP64 ? 8 : 4); + } + + /// getMinCallFrameSize - Return the minimum size a call frame can be using + /// the PowerPC ABI. + static unsigned getMinCallFrameSize(bool LP64) { + // The call frame needs to be at least big enough for linkage and 8 args. + return getLinkageSize(LP64) + getMinCallArgumentsSize(LP64); + } + }; } // End llvm namespace Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp diff -u llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.227 llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.228 --- llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.227 Wed Nov 15 13:55:13 2006 +++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp Thu Nov 16 16:43:37 2006 @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "PPCISelLowering.h" +#include "PPCMachineFunctionInfo.h" #include "PPCTargetMachine.h" #include "PPCPerfectShuffle.h" #include "llvm/ADT/VectorExtras.h" @@ -169,8 +170,8 @@ setOperationAction(ISD::VAEND , MVT::Other, Expand); setOperationAction(ISD::STACKSAVE , MVT::Other, Expand); setOperationAction(ISD::STACKRESTORE , MVT::Other, Expand); - setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i32 , Expand); - setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i64 , Expand); + setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i32 , Custom); + setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i64 , Custom); // We want to custom lower some of our intrinsics. setOperationAction(ISD::INTRINSIC_WO_CHAIN, MVT::Other, Custom); @@ -1082,11 +1083,10 @@ SmallVector ArgValues; SDOperand Root = Op.getOperand(0); - unsigned ArgOffset = 24; - const unsigned Num_GPR_Regs = 8; - const unsigned Num_FPR_Regs = 13; - const unsigned Num_VR_Regs = 12; - unsigned GPR_idx = 0, FPR_idx = 0, VR_idx = 0; + MVT::ValueType PtrVT = DAG.getTargetLoweringInfo().getPointerTy(); + bool isPPC64 = PtrVT == MVT::i64; + + unsigned ArgOffset = PPCFrameInfo::getLinkageSize(isPPC64); static const unsigned GPR_32[] = { // 32-bit registers. PPC::R3, PPC::R4, PPC::R5, PPC::R6, @@ -1105,13 +1105,17 @@ PPC::V9, PPC::V10, PPC::V11, PPC::V12, PPC::V13 }; - MVT::ValueType PtrVT = DAG.getTargetLoweringInfo().getPointerTy(); - bool isPPC64 = PtrVT == MVT::i64; + const unsigned Num_GPR_Regs = sizeof(GPR_32)/sizeof(GPR_32[0]); + const unsigned Num_FPR_Regs = sizeof(FPR)/sizeof(FPR[0]); + const unsigned Num_VR_Regs = sizeof( VR)/sizeof( VR[0]); + + unsigned GPR_idx = 0, FPR_idx = 0, VR_idx = 0; + const unsigned *GPR = isPPC64 ? GPR_64 : GPR_32; // Add DAG nodes to load the arguments or copy them out of registers. On - // entry to a function on PPC, the arguments start at offset 24, although the - // first ones are often in registers. + // entry to a function on PPC, the arguments start after the linkage area, + // although the first ones are often in registers. for (unsigned ArgNo = 0, e = Op.Val->getNumValues()-1; ArgNo != e; ++ArgNo) { SDOperand ArgVal; bool needsLoad = false; @@ -1266,7 +1270,6 @@ MVT::ValueType PtrVT = DAG.getTargetLoweringInfo().getPointerTy(); bool isPPC64 = PtrVT == MVT::i64; unsigned PtrByteSize = isPPC64 ? 8 : 4; - // args_to_use will accumulate outgoing args for the PPCISD::CALL case in // SelectExpr to use to put the arguments in the appropriate registers. @@ -1275,7 +1278,7 @@ // 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 = 6*PtrByteSize; + unsigned NumBytes = PPCFrameInfo::getLinkageSize(isPPC64); // Add up all the space actually used. for (unsigned i = 0; i != NumOps; ++i) @@ -1286,8 +1289,7 @@ // 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. - if (NumBytes < 6*PtrByteSize+8*PtrByteSize) - NumBytes = 6*PtrByteSize+8*PtrByteSize; + NumBytes = std::max(NumBytes, PPCFrameInfo::getMinCallFrameSize(isPPC64)); // Adjust the stack pointer for the new arguments... // These operations are automatically eliminated by the prolog/epilog pass @@ -1307,8 +1309,9 @@ // memory. Also, if this is a vararg function, floating point operations // must be stored to our stack, and loaded into integer regs as well, if // any integer regs are available for argument passing. - unsigned ArgOffset = 6*PtrByteSize; + unsigned ArgOffset = PPCFrameInfo::getLinkageSize(isPPC64); unsigned GPR_idx = 0, FPR_idx = 0, VR_idx = 0; + static const unsigned GPR_32[] = { // 32-bit registers. PPC::R3, PPC::R4, PPC::R5, PPC::R6, PPC::R7, PPC::R8, PPC::R9, PPC::R10, @@ -1585,6 +1588,44 @@ return DAG.getNode(PPCISD::RET_FLAG, MVT::Other, Copy, Copy.getValue(1)); } +static SDOperand LowerDYNAMIC_STACKALLOC(SDOperand Op, SelectionDAG &DAG, + const PPCSubtarget &Subtarget) { + MachineFunction &MF = DAG.getMachineFunction(); + bool IsPPC64 = Subtarget.isPPC64(); + + // 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. + int Offset = PPCFrameInfo::getFramePointerSaveOffset(IsPPC64); + // Allocate the frame index for frame pointer save area. + FPSI = MF.getFrameInfo()->CreateFixedObject(IsPPC64? 8 : 4, Offset); + // Save the result. + FI->setFramePointerSaveIndex(FPSI); + } + + // Get the inputs. + SDOperand Chain = Op.getOperand(0); + SDOperand Size = Op.getOperand(1); + + // Get the corect type for pointers. + MVT::ValueType PtrVT = DAG.getTargetLoweringInfo().getPointerTy(); + // Negate the size. + 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); + // Build a DYNALLOC node. + SDOperand Ops[3] = { Chain, NegSize, FPSIdx }; + SDVTList VTs = DAG.getVTList(PtrVT, MVT::Other); + return DAG.getNode(PPCISD::DYNALLOC, VTs, Ops, 3); +} + + /// LowerSELECT_CC - Lower floating point select_cc's into fsel instruction when /// possible. static SDOperand LowerSELECT_CC(SDOperand Op, SelectionDAG &DAG) { @@ -2517,6 +2558,8 @@ return LowerFORMAL_ARGUMENTS(Op, DAG, VarArgsFrameIndex); case ISD::CALL: return LowerCALL(Op, DAG); case ISD::RET: return LowerRET(Op, DAG); + case ISD::DYNAMIC_STACKALLOC: return LowerDYNAMIC_STACKALLOC(Op, DAG, + PPCSubTarget); case ISD::SELECT_CC: return LowerSELECT_CC(Op, DAG); case ISD::FP_TO_SINT: return LowerFP_TO_SINT(Op, DAG); Index: llvm/lib/Target/PowerPC/PPCISelLowering.h diff -u llvm/lib/Target/PowerPC/PPCISelLowering.h:1.56 llvm/lib/Target/PowerPC/PPCISelLowering.h:1.57 --- llvm/lib/Target/PowerPC/PPCISelLowering.h:1.56 Thu Nov 9 11:55:04 2006 +++ llvm/lib/Target/PowerPC/PPCISelLowering.h Thu Nov 16 16:43:37 2006 @@ -60,6 +60,11 @@ /// though these are usually folded into other nodes. Hi, Lo, + /// OPRC, CHAIN = DYNALLOC(CHAIN, NEGSIZE, FRAME_INDEX) + /// This instruction is lowered in PPCRegisterInfo::eliminateFrameIndex to + /// compute an allocation on the stack. + DYNALLOC, + /// GlobalBaseReg - On Darwin, this node represents the result of the mflr /// at function entry, used for PIC code. GlobalBaseReg, Index: llvm/lib/Target/PowerPC/PPCInstr64Bit.td diff -u llvm/lib/Target/PowerPC/PPCInstr64Bit.td:1.31 llvm/lib/Target/PowerPC/PPCInstr64Bit.td:1.32 --- llvm/lib/Target/PowerPC/PPCInstr64Bit.td:1.31 Thu Nov 16 15:45:30 2006 +++ llvm/lib/Target/PowerPC/PPCInstr64Bit.td Thu Nov 16 16:43:37 2006 @@ -100,6 +100,12 @@ PPC970_DGroup_First, PPC970_Unit_FXU; } +def DYNALLOC8 : Pseudo<(ops G8RC:$result, G8RC:$negsize, memri:$fpsi), + "${:comment} DYNALLOC8 $result, $negsize, $fpsi", + [(set G8RC:$result, + (PPCdynalloc G8RC:$negsize, iaddr:$fpsi))]>, + Imp<[X1],[X1]>; + def MTLR8 : XFXForm_7_ext<31, 467, 8, (ops G8RC:$rS), "mtlr $rS", SprMTSPR>, PPC970_DGroup_First, PPC970_Unit_FXU; def MFLR8 : XFXForm_1_ext<31, 339, 8, (ops G8RC:$rT), "mflr $rT", SprMFSPR>, Index: llvm/lib/Target/PowerPC/PPCInstrInfo.td diff -u llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.265 llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.266 --- llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.265 Wed Nov 15 19:01:28 2006 +++ llvm/lib/Target/PowerPC/PPCInstrInfo.td Thu Nov 16 16:43:37 2006 @@ -100,6 +100,10 @@ def PPClbrx : SDNode<"PPCISD::LBRX", SDT_PPClbrx, [SDNPHasChain]>; def PPCstbrx : SDNode<"PPCISD::STBRX", SDT_PPCstbrx, [SDNPHasChain]>; +// Instructions to support dynamic alloca. +def SDTDynOp : SDTypeProfile<1, 2, []>; +def PPCdynalloc : SDNode<"PPCISD::DYNALLOC", SDTDynOp, [SDNPHasChain]>; + //===----------------------------------------------------------------------===// // PowerPC specific transformation functions and pattern fragments. // @@ -297,6 +301,13 @@ def UPDATE_VRSAVE : Pseudo<(ops GPRC:$rD, GPRC:$rS), "UPDATE_VRSAVE $rD, $rS", []>; } + +def DYNALLOC : Pseudo<(ops GPRC:$result, GPRC:$negsize, memri:$fpsi), + "${:comment} DYNALLOC $result, $negsize, $fpsi", + [(set GPRC:$result, + (PPCdynalloc GPRC:$negsize, iaddr:$fpsi))]>, + Imp<[R1],[R1]>; + def IMPLICIT_DEF_GPRC: Pseudo<(ops GPRC:$rD),"${:comment}IMPLICIT_DEF_GPRC $rD", [(set GPRC:$rD, (undef))]>; def IMPLICIT_DEF_F8 : Pseudo<(ops F8RC:$rD), "${:comment} IMPLICIT_DEF_F8 $rD", Index: llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp diff -u llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.85 llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.86 --- llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.85 Wed Nov 15 17:35:30 2006 +++ llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp Thu Nov 16 16:43:37 2006 @@ -14,7 +14,9 @@ #define DEBUG_TYPE "reginfo" #include "PPC.h" #include "PPCInstrBuilder.h" +#include "PPCMachineFunctionInfo.h" #include "PPCRegisterInfo.h" +#include "PPCFrameInfo.h" #include "PPCSubtarget.h" #include "llvm/Constants.h" #include "llvm/Type.h" @@ -232,7 +234,7 @@ const unsigned* PPCRegisterInfo::getCalleeSaveRegs() const { // 32-bit Darwin calling convention. static const unsigned Darwin32_CalleeSaveRegs[] = { - PPC::R1 , PPC::R13, PPC::R14, PPC::R15, + PPC::R13, PPC::R14, PPC::R15, PPC::R16, PPC::R17, PPC::R18, PPC::R19, PPC::R20, PPC::R21, PPC::R22, PPC::R23, PPC::R24, PPC::R25, PPC::R26, PPC::R27, @@ -253,7 +255,7 @@ }; // 64-bit Darwin calling convention. static const unsigned Darwin64_CalleeSaveRegs[] = { - PPC::X1 , PPC::X13, PPC::X14, PPC::X15, + PPC::X13, PPC::X14, PPC::X15, PPC::X16, PPC::X17, PPC::X18, PPC::X19, PPC::X20, PPC::X21, PPC::X22, PPC::X23, PPC::X24, PPC::X25, PPC::X26, PPC::X27, @@ -281,7 +283,7 @@ PPCRegisterInfo::getCalleeSaveRegClasses() const { // 32-bit Darwin calling convention. static const TargetRegisterClass * const Darwin32_CalleeSaveRegClasses[] = { - &PPC::GPRCRegClass,&PPC::GPRCRegClass,&PPC::GPRCRegClass,&PPC::GPRCRegClass, + &PPC::GPRCRegClass,&PPC::GPRCRegClass,&PPC::GPRCRegClass, &PPC::GPRCRegClass,&PPC::GPRCRegClass,&PPC::GPRCRegClass,&PPC::GPRCRegClass, &PPC::GPRCRegClass,&PPC::GPRCRegClass,&PPC::GPRCRegClass,&PPC::GPRCRegClass, &PPC::GPRCRegClass,&PPC::GPRCRegClass,&PPC::GPRCRegClass,&PPC::GPRCRegClass, @@ -304,7 +306,7 @@ // 64-bit Darwin calling convention. static const TargetRegisterClass * const Darwin64_CalleeSaveRegClasses[] = { - &PPC::G8RCRegClass,&PPC::G8RCRegClass,&PPC::G8RCRegClass,&PPC::G8RCRegClass, + &PPC::G8RCRegClass,&PPC::G8RCRegClass,&PPC::G8RCRegClass, &PPC::G8RCRegClass,&PPC::G8RCRegClass,&PPC::G8RCRegClass,&PPC::G8RCRegClass, &PPC::G8RCRegClass,&PPC::G8RCRegClass,&PPC::G8RCRegClass,&PPC::G8RCRegClass, &PPC::G8RCRegClass,&PPC::G8RCRegClass,&PPC::G8RCRegClass,&PPC::G8RCRegClass, @@ -388,81 +390,150 @@ // Stack Frame Processing methods //===----------------------------------------------------------------------===// -// hasFP - Return true if the specified function should have a dedicated frame +// needsFP - Return true if the specified function should have a dedicated frame // pointer register. This is true if the function has variable sized allocas or // if frame pointer elimination is disabled. // -static bool hasFP(const MachineFunction &MF) { +static bool needsFP(const MachineFunction &MF) { const MachineFrameInfo *MFI = MF.getFrameInfo(); - - // If frame pointers are forced, or if there are variable sized stack objects, - // use a frame pointer. - // return NoFramePointerElim || MFI->hasVarSizedObjects(); } +// hasFP - Return true if the specified function actually has a dedicated frame +// pointer register. This is true if the function needs a frame pointer and has +// a non-zero stack size. +static bool hasFP(const MachineFunction &MF) { + const MachineFrameInfo *MFI = MF.getFrameInfo(); + return MFI->getStackSize() && needsFP(MF); +} + void PPCRegisterInfo:: eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const { - if (hasFP(MF)) { - // If we have a frame pointer, convert as follows: - // ADJCALLSTACKDOWN -> lwz r0, 0(r31) - // stwu, r0, -amount(r1) - // ADJCALLSTACKUP -> addi, r1, r1, amount - MachineInstr *Old = I; - unsigned Amount = Old->getOperand(0).getImmedValue(); - if (Amount != 0) { - // We need to keep the stack aligned properly. To do this, we round the - // amount of space needed for the outgoing arguments up to the next - // alignment boundary. - unsigned Align = MF.getTarget().getFrameInfo()->getStackAlignment(); - Amount = (Amount+Align-1)/Align*Align; - - // Replace the pseudo instruction with a new instruction... - if (Old->getOpcode() == PPC::ADJCALLSTACKDOWN) { - if (!Subtarget.isPPC64()) { - BuildMI(MBB, I, PPC::LWZ, 2, PPC::R0).addImm(0).addReg(PPC::R31); - BuildMI(MBB, I, PPC::STWU, 3, PPC::R1) - .addReg(PPC::R0).addImm(-Amount).addReg(PPC::R1); - } else { - BuildMI(MBB, I, PPC::LD, 2, PPC::X0).addImm(0).addReg(PPC::X31); - BuildMI(MBB, I, PPC::STDU, 3, PPC::X1) - .addReg(PPC::X0).addImm(-Amount/4).addReg(PPC::X1); - } - } else { - assert(Old->getOpcode() == PPC::ADJCALLSTACKUP); - BuildMI(MBB, I, PPC::ADDI, 2, PPC::R1).addReg(PPC::R1).addImm(Amount); - } - } - } + // Simply discard ADJCALLSTACKDOWN, ADJCALLSTACKUP instructions. MBB.erase(I); } +/// LowerDynamicAlloc - Generate the code for allocating an object in the +/// current frame. The sequence of code with be in the general form +/// +/// addi R0, SP, #frameSize ; get the address of the previous frame +/// stwxu R0, SP, Rnegsize ; add and update the SP with the negated size +/// addi Rnew, SP, #maxCalFrameSize ; get the top of the allocation +/// +void PPCRegisterInfo::lowerDynamicAlloc(MachineBasicBlock::iterator II) const { + // Get the instruction. + MachineInstr &MI = *II; + // Get the instruction's basic block. + MachineBasicBlock &MBB = *MI.getParent(); + // Get the basic block's function. + MachineFunction &MF = *MBB.getParent(); + // Get the frame info. + MachineFrameInfo *MFI = MF.getFrameInfo(); + // Determine whether 64-bit pointers are used. + bool LP64 = Subtarget.isPPC64(); + + // Determine the maximum call stack size. maxCallFrameSize may be + // less than the minimum. + unsigned maxCallFrameSize = MFI->getMaxCallFrameSize(); + unsigned getMinCallFrameSize = + PPCFrameInfo::getMinCallFrameSize(LP64); + maxCallFrameSize = std::max(maxCallFrameSize, getMinCallFrameSize); + // Get the total frame size. + unsigned FrameSize = MFI->getStackSize(); + + // Get stack alignments. + unsigned TargetAlign = MF.getTarget().getFrameInfo()->getStackAlignment(); + unsigned MaxAlign = MFI->getMaxAlignment(); + + // Determine the previous frame's address. If FrameSize can't be + // represented as 16 bits or we need special alignment, then we load the + // previous frame's address from 0(SP). Why not do an addis of the hi? + // Because R0 is our only safe tmp register and addi/addis treat R0 as zero. + // Constructing the constant and adding would take 3 instructions. + // Fortunately, a frame greater than 32K is rare. + if (MaxAlign < TargetAlign && isInt16(FrameSize)) { + BuildMI(MBB, II, PPC::ADDI, 2, PPC::R0) + .addReg(PPC::R31) + .addImm(FrameSize); + } else if (LP64) { + BuildMI(MBB, II, PPC::LD, 2, PPC::X0) + .addImm(0) + .addReg(PPC::X1); + } else { + BuildMI(MBB, II, PPC::LWZ, 2, PPC::R0) + .addImm(0) + .addReg(PPC::R1); + } + + // Grow the stack and update the stack pointer link, then + // determine the address of new allocated space. + if (LP64) { + BuildMI(MBB, II, PPC::STDUX, 3) + .addReg(PPC::X0) + .addReg(PPC::X1) + .addReg(MI.getOperand(1).getReg()); + BuildMI(MBB, II, PPC::ADDI8, 2, MI.getOperand(0).getReg()) + .addReg(PPC::X1) + .addImm(maxCallFrameSize); + } else { + BuildMI(MBB, II, PPC::STWUX, 3) + .addReg(PPC::R0) + .addReg(PPC::R1) + .addReg(MI.getOperand(1).getReg()); + BuildMI(MBB, II, PPC::ADDI, 2, MI.getOperand(0).getReg()) + .addReg(PPC::R1) + .addImm(maxCallFrameSize); + } + + // Discard the DYNALLOC instruction. + MBB.erase(II); +} + void PPCRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II) const { - unsigned i = 0; + // Get the instruction. MachineInstr &MI = *II; + // Get the instruction's basic block. MachineBasicBlock &MBB = *MI.getParent(); + // Get the basic block's function. MachineFunction &MF = *MBB.getParent(); + // Get the frame info. + MachineFrameInfo *MFI = MF.getFrameInfo(); + // Find out which operand is the frame index. + unsigned i = 0; while (!MI.getOperand(i).isFrameIndex()) { ++i; assert(i < MI.getNumOperands() && "Instr doesn't have FrameIndex operand!"); } - + // Take into account whether it's an add or mem instruction + unsigned OffIdx = (i == 2) ? 1 : 2; + // Get the frame index. int FrameIndex = MI.getOperand(i).getFrameIndex(); + + // Get the frame pointer save index. Users of this index are primarily + // DYNALLOC instructions. + PPCFunctionInfo *FI = MF.getInfo(); + int FPSI = FI->getFramePointerSaveIndex(); + // Get the instruction opcode. + unsigned OpC = MI.getOpcode(); + + // Special case for dynamic alloca. + if (FPSI && FrameIndex == FPSI && + (OpC == PPC::DYNALLOC || OpC == PPC::DYNALLOC8)) { + lowerDynamicAlloc(II); + return; + } // Replace the FrameIndex with base register with GPR1 (SP) or GPR31 (FP). MI.getOperand(i).ChangeToRegister(hasFP(MF) ? PPC::R31 : PPC::R1, false); - // Take into account whether it's an add or mem instruction - unsigned OffIdx = (i == 2) ? 1 : 2; - // Figure out if the offset in the instruction is shifted right two bits. This // is true for instructions like "STD", which the machine implicitly adds two // low zeros to. bool isIXAddr = false; - switch (MI.getOpcode()) { + switch (OpC) { case PPC::LWA: case PPC::LD: case PPC::STD: @@ -471,9 +542,8 @@ break; } - // Now add the frame object offset to the offset from r1. - int Offset = MF.getFrameInfo()->getObjectOffset(FrameIndex); + int Offset = MFI->getObjectOffset(FrameIndex); if (!isIXAddr) Offset += MI.getOperand(OffIdx).getImmedValue(); @@ -483,20 +553,19 @@ // If we're not using a Frame Pointer that has been set to the value of the // SP before having the stack size subtracted from it, then add the stack size // to Offset to get the correct offset. - Offset += MF.getFrameInfo()->getStackSize(); + Offset += MFI->getStackSize(); - if (Offset > 32767 || Offset < -32768) { + if (!isInt16(Offset)) { // Insert a set of r0 with the full offset value before the ld, st, or add - MachineBasicBlock *MBB = MI.getParent(); - BuildMI(*MBB, II, PPC::LIS, 1, PPC::R0).addImm(Offset >> 16); - BuildMI(*MBB, II, PPC::ORI, 2, PPC::R0).addReg(PPC::R0).addImm(Offset); + BuildMI(MBB, II, PPC::LIS, 1, PPC::R0).addImm(Offset >> 16); + BuildMI(MBB, II, PPC::ORI, 2, PPC::R0).addReg(PPC::R0).addImm(Offset); // convert into indexed form of the instruction // sth 0:rA, 1:imm 2:(rB) ==> sthx 0:rA, 2:rB, 1:r0 // addi 0:rA 1:rB, 2, imm ==> add 0:rA, 1:rB, 2:r0 - assert(ImmToIdxMap.count(MI.getOpcode()) && + assert(ImmToIdxMap.count(OpC) && "No indexed form of load or store available!"); - unsigned NewOpcode = ImmToIdxMap.find(MI.getOpcode())->second; + unsigned NewOpcode = ImmToIdxMap.find(OpC)->second; MI.setOpcode(NewOpcode); MI.getOperand(1).ChangeToRegister(MI.getOperand(i).getReg(), false); MI.getOperand(2).ChangeToRegister(PPC::R0, false); @@ -615,6 +684,59 @@ MI->eraseFromParent(); } +/// determineFrameLayout - Determine the size of the frame and maximum call +/// frame size. +void PPCRegisterInfo::determineFrameLayout(MachineFunction &MF) const { + MachineFrameInfo *MFI = MF.getFrameInfo(); + + // Get the number of bytes to allocate from the FrameInfo + unsigned FrameSize = MFI->getStackSize(); + + // Get the alignments provided by the target, and the maximum alignment + // (if any) of the fixed frame objects. + unsigned TargetAlign = MF.getTarget().getFrameInfo()->getStackAlignment(); + unsigned MaxAlign = MFI->getMaxAlignment(); + unsigned Align = std::max(TargetAlign, MaxAlign); + assert(isPowerOf2_32(Align) && "Alignment is not power of 2"); + unsigned AlignMask = Align - 1; // + + // If we are a leaf function, and use up to 224 bytes of stack space, + // don't have a frame pointer, calls, or dynamic alloca then we do not need + // to adjust the stack pointer (we fit in the Red Zone). + if (FrameSize <= 224 && // Fits in red zone. + !needsFP(MF) && // Frame pointer can be eliminated. + !MFI->hasCalls() && // No calls. + MaxAlign <= TargetAlign) { // No special alignment. + // No need for frame + MFI->setStackSize(0); + return; + } + + // Get the maximum call frame size of all the calls. + unsigned maxCallFrameSize = MFI->getMaxCallFrameSize(); + + // Maximum call frame needs to be at least big enough for linkage and 8 args. + unsigned minCallFrameSize = + PPCFrameInfo::getMinCallFrameSize(Subtarget.isPPC64()); + maxCallFrameSize = std::max(maxCallFrameSize, minCallFrameSize); + + // If we have dynamic alloca then maxCallFrameSize needs to be aligned so + // that allocations will be aligned. + if (MFI->hasVarSizedObjects()) + maxCallFrameSize = (maxCallFrameSize + AlignMask) & ~AlignMask; + + // Update maximum call frame size. + MFI->setMaxCallFrameSize(maxCallFrameSize); + + // Include call frame size in total. + FrameSize += maxCallFrameSize; + + // Make sure the frame is aligned. + FrameSize = (FrameSize + AlignMask) & ~AlignMask; + + // Update frame info. + MFI->setStackSize(FrameSize); +} void PPCRegisterInfo::emitPrologue(MachineFunction &MF) const { MachineBasicBlock &MBB = MF.front(); // Prolog goes in entry BB @@ -622,9 +744,6 @@ MachineFrameInfo *MFI = MF.getFrameInfo(); MachineDebugInfo *DebugInfo = MFI->getMachineDebugInfo(); - // Do we have a frame pointer for this function? - bool HasFP = hasFP(MF); - // Scan the prolog, looking for an UPDATE_VRSAVE instruction. If we find it, // process it. for (unsigned i = 0; MBBI != MBB.end(); ++i, ++MBBI) { @@ -637,83 +756,75 @@ // Move MBBI back to the beginning of the function. MBBI = MBB.begin(); - // Get the number of bytes to allocate from the FrameInfo - unsigned NumBytes = MFI->getStackSize(); + // Work out frame sizes. + determineFrameLayout(MF); + unsigned FrameSize = MFI->getStackSize(); - // Get the alignments provided by the target, and the maximum alignment - // (if any) of the fixed frame objects. - unsigned TargetAlign = MF.getTarget().getFrameInfo()->getStackAlignment(); - unsigned MaxAlign = MFI->getMaxAlignment(); + // Skip if a leaf routine. + if (!FrameSize) return; + + int NegFrameSize = -FrameSize; - // If we have calls, we cannot use the red zone to store callee save registers - // and we must set up a stack frame, so calculate the necessary size here. - if (MFI->hasCalls()) { - // We reserve argument space for call sites in the function immediately on - // entry to the current function. This eliminates the need for add/sub - // brackets around call sites. - NumBytes += MFI->getMaxCallFrameSize(); - } + // Do we have a frame pointer for this function? + bool HasFP = hasFP(MF); - // If we are a leaf function, and use up to 224 bytes of stack space, - // and don't have a frame pointer, then we do not need to adjust the stack - // pointer (we fit in the Red Zone). - if ((NumBytes == 0) || (NumBytes <= 224 && !HasFP && !MFI->hasCalls() && - MaxAlign <= TargetAlign)) { - MFI->setStackSize(0); - return; + // If there is a frame pointer, copy R31 into TOC(SP) + if (HasFP) { + int Offset = PPCFrameInfo::getFramePointerSaveOffset(Subtarget.isPPC64()); + + if (!Subtarget.isPPC64()) { + BuildMI(MBB, MBBI, PPC::STW, 3) + .addReg(PPC::R31).addImm(Offset).addReg(PPC::R1); + } else { + BuildMI(MBB, MBBI, PPC::STD, 3) + .addReg(PPC::X31).addImm(Offset/4).addReg(PPC::X1); + } } + + // Get stack alignments. + unsigned TargetAlign = MF.getTarget().getFrameInfo()->getStackAlignment(); + unsigned MaxAlign = MFI->getMaxAlignment(); - // Add the size of R1 to NumBytes size for the store of R1 to the bottom - // of the stack and round the size to a multiple of the alignment. - unsigned Align = std::max(TargetAlign, MaxAlign); - unsigned GPRSize = Subtarget.isPPC64() ? 8 : 4; - unsigned Size = HasFP ? GPRSize + GPRSize : GPRSize; - NumBytes = (NumBytes+Size+Align-1)/Align*Align; - - // Update frame info to pretend that this is part of the stack... - MFI->setStackSize(NumBytes); - int NegNumbytes = -NumBytes; - - // Adjust stack pointer: r1 -= numbytes. + // Adjust stack pointer: r1 += NegFrameSize. // If there is a preferred stack alignment, align R1 now if (!Subtarget.isPPC64()) { // PPC32. if (MaxAlign > TargetAlign) { - assert(isPowerOf2_32(MaxAlign) && MaxAlign < 32767&&"Invalid alignment!"); - assert(isInt16(0-NumBytes) && "Unhandled stack size and alignment!"); + assert(isPowerOf2_32(MaxAlign)&&isInt16(MaxAlign)&&"Invalid alignment!"); + assert(isInt16(NegFrameSize) && "Unhandled stack size and alignment!"); BuildMI(MBB, MBBI, PPC::RLWINM, 4, PPC::R0) .addReg(PPC::R1).addImm(0).addImm(32-Log2_32(MaxAlign)).addImm(31); BuildMI(MBB, MBBI, PPC::SUBFIC,2,PPC::R0).addReg(PPC::R0) - .addImm(0-NumBytes); + .addImm(NegFrameSize); BuildMI(MBB, MBBI, PPC::STWUX, 3) .addReg(PPC::R1).addReg(PPC::R1).addReg(PPC::R0); - } else if (NumBytes <= 32768) { + } else if (isInt16(NegFrameSize)) { BuildMI(MBB, MBBI, PPC::STWU, 3, - PPC::R1).addReg(PPC::R1).addImm(NegNumbytes).addReg(PPC::R1); + PPC::R1).addReg(PPC::R1).addImm(NegFrameSize).addReg(PPC::R1); } else { - BuildMI(MBB, MBBI, PPC::LIS, 1, PPC::R0).addImm(NegNumbytes >> 16); + BuildMI(MBB, MBBI, PPC::LIS, 1, PPC::R0).addImm(NegFrameSize >> 16); BuildMI(MBB, MBBI, PPC::ORI, 2, PPC::R0).addReg(PPC::R0) - .addImm(NegNumbytes & 0xFFFF); + .addImm(NegFrameSize & 0xFFFF); BuildMI(MBB, MBBI, PPC::STWUX, 3).addReg(PPC::R1).addReg(PPC::R1) .addReg(PPC::R0); } } else { // PPC64. if (MaxAlign > TargetAlign) { - assert(isPowerOf2_32(MaxAlign) && MaxAlign < 32767&&"Invalid alignment!"); - assert(isInt16(0-NumBytes) && "Unhandled stack size and alignment!"); + assert(isPowerOf2_32(MaxAlign)&&isInt16(MaxAlign)&&"Invalid alignment!"); + assert(isInt16(NegFrameSize) && "Unhandled stack size and alignment!"); BuildMI(MBB, MBBI, PPC::RLDICL, 3, PPC::X0) .addReg(PPC::X1).addImm(0).addImm(64-Log2_32(MaxAlign)); BuildMI(MBB, MBBI, PPC::SUBFIC8, 2, PPC::X0).addReg(PPC::X0) - .addImm(0-NumBytes); + .addImm(NegFrameSize); BuildMI(MBB, MBBI, PPC::STDUX, 3) .addReg(PPC::X1).addReg(PPC::X1).addReg(PPC::X0); - } else if (NumBytes <= 32768*4) { + } else if (isInt16(NegFrameSize/4)) { BuildMI(MBB, MBBI, PPC::STDU, 3, PPC::X1) - .addReg(PPC::X1).addImm(NegNumbytes/4).addReg(PPC::X1); + .addReg(PPC::X1).addImm(NegFrameSize/4).addReg(PPC::X1); } else { - BuildMI(MBB, MBBI, PPC::LIS8, 1, PPC::X0).addImm(NegNumbytes >> 16); + BuildMI(MBB, MBBI, PPC::LIS8, 1, PPC::X0).addImm(NegFrameSize >> 16); BuildMI(MBB, MBBI, PPC::ORI8, 2, PPC::X0).addReg(PPC::X0) - .addImm(NegNumbytes & 0xFFFF); + .addImm(NegFrameSize & 0xFFFF); BuildMI(MBB, MBBI, PPC::STDUX, 3).addReg(PPC::X1).addReg(PPC::X1) .addReg(PPC::X0); } @@ -728,7 +839,7 @@ // Show update of SP. MachineLocation SPDst(MachineLocation::VirtualFP); - MachineLocation SPSrc(MachineLocation::VirtualFP, NegNumbytes); + MachineLocation SPSrc(MachineLocation::VirtualFP, NegFrameSize); Moves.push_back(new MachineMove(LabelID, SPDst, SPSrc)); // Add callee saved registers to move list. @@ -740,16 +851,12 @@ Moves.push_back(new MachineMove(LabelID, CSDst, CSSrc)); } } - - // If there is a frame pointer, copy R1 (SP) into R31 (FP) + + // If there is a frame pointer, copy R1 into R31 if (HasFP) { if (!Subtarget.isPPC64()) { - BuildMI(MBB, MBBI, PPC::STW, 3) - .addReg(PPC::R31).addImm(GPRSize).addReg(PPC::R1); BuildMI(MBB, MBBI, PPC::OR, 2, PPC::R31).addReg(PPC::R1).addReg(PPC::R1); } else { - BuildMI(MBB, MBBI, PPC::STD, 3) - .addReg(PPC::X31).addImm(GPRSize/4).addReg(PPC::X1); BuildMI(MBB, MBBI, PPC::OR8, 2, PPC::X31).addReg(PPC::X1).addReg(PPC::X1); } } @@ -764,41 +871,46 @@ // Get alignment info so we know how to restore r1 const MachineFrameInfo *MFI = MF.getFrameInfo(); unsigned TargetAlign = MF.getTarget().getFrameInfo()->getStackAlignment(); + unsigned MaxAlign = MFI->getMaxAlignment(); // Get the number of bytes allocated from the FrameInfo. - unsigned NumBytes = MFI->getStackSize(); - unsigned GPRSize = Subtarget.isPPC64() ? 8 : 4; + unsigned FrameSize = MFI->getStackSize(); - if (NumBytes != 0) { - // If this function has a frame pointer, load the saved stack pointer from - // its stack slot. - if (hasFP(MF)) { - if (!Subtarget.isPPC64()) { - BuildMI(MBB, MBBI, PPC::LWZ, 2, PPC::R31) - .addImm(GPRSize).addReg(PPC::R31); - } else { - BuildMI(MBB, MBBI, PPC::LD, 2, PPC::X31) - .addImm(GPRSize/4).addReg(PPC::X31); - } - } - + if (FrameSize != 0) { // 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 (NumBytes < 32768 && TargetAlign >= MFI->getMaxAlignment()) { + if (isInt16(FrameSize) && TargetAlign >= MaxAlign && + !MFI->hasVarSizedObjects()) { BuildMI(MBB, MBBI, PPC::ADDI, 2, PPC::R1) - .addReg(PPC::R1).addImm(NumBytes); + .addReg(PPC::R1).addImm(FrameSize); } else { BuildMI(MBB, MBBI, PPC::LWZ, 2, PPC::R1).addImm(0).addReg(PPC::R1); } } else { - if (NumBytes < 32768 && TargetAlign >= MFI->getMaxAlignment()) { + if (isInt16(FrameSize) && TargetAlign >= MaxAlign && + !MFI->hasVarSizedObjects()) { BuildMI(MBB, MBBI, PPC::ADDI8, 2, PPC::X1) - .addReg(PPC::X1).addImm(NumBytes); + .addReg(PPC::X1).addImm(FrameSize); } else { BuildMI(MBB, MBBI, PPC::LD, 2, PPC::X1).addImm(0).addReg(PPC::X1); } } + + // If this function has a frame pointer, load the saved frame pointer from + // its stack slot. + if (hasFP(MF)) { + int Offset = PPCFrameInfo::getFramePointerSaveOffset(Subtarget.isPPC64()); + + if (!Subtarget.isPPC64()) { + BuildMI(MBB, MBBI, PPC::LWZ, 2, PPC::R31) + .addImm(Offset).addReg(PPC::R1); + } else { + BuildMI(MBB, MBBI, PPC::LD, 2, PPC::X31) + .addImm(Offset/4).addReg(PPC::X1); + } + } + } } Index: llvm/lib/Target/PowerPC/PPCRegisterInfo.h diff -u llvm/lib/Target/PowerPC/PPCRegisterInfo.h:1.17 llvm/lib/Target/PowerPC/PPCRegisterInfo.h:1.18 --- llvm/lib/Target/PowerPC/PPCRegisterInfo.h:1.17 Mon Nov 13 17:36:35 2006 +++ llvm/lib/Target/PowerPC/PPCRegisterInfo.h Thu Nov 16 16:43:37 2006 @@ -61,8 +61,13 @@ MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const; + void lowerDynamicAlloc(MachineBasicBlock::iterator II) const; void eliminateFrameIndex(MachineBasicBlock::iterator II) const; + /// determineFrameLayout - Determine the size of the frame and maximum call + /// frame size. + void determineFrameLayout(MachineFunction &MF) const; + void emitPrologue(MachineFunction &MF) const; void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const; Index: llvm/lib/Target/PowerPC/PPCRegisterInfo.td diff -u llvm/lib/Target/PowerPC/PPCRegisterInfo.td:1.39 llvm/lib/Target/PowerPC/PPCRegisterInfo.td:1.40 --- llvm/lib/Target/PowerPC/PPCRegisterInfo.td:1.39 Tue Nov 14 12:44:47 2006 +++ llvm/lib/Target/PowerPC/PPCRegisterInfo.td Thu Nov 16 16:43:37 2006 @@ -224,7 +224,7 @@ } GPRCClass::iterator GPRCClass::allocation_order_end(const MachineFunction &MF) const { - if (hasFP(MF)) + if (needsFP(MF)) return end()-4; // don't allocate R31, R0, R1, LR else return end()-3; // don't allocate R0, R1, LR @@ -247,7 +247,7 @@ } G8RCClass::iterator G8RCClass::allocation_order_end(const MachineFunction &MF) const { - if (hasFP(MF)) + if (needsFP(MF)) return end()-4; else return end()-3; From isanbard at gmail.com Thu Nov 16 18:49:30 2006 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 16 Nov 2006 18:49:30 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/Debug.cpp Message-ID: <200611170049.kAH0nUBC012252@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: Debug.cpp updated: 1.7 -> 1.8 --- Log message: Added "DOUT" macro. This is used as a replacement for the std::cerr stream. It centralizes the use of std::cerr so that static c'tor/d'tors aren't scattered around all over the place. The way to use it is like this: DOUT << "This is a status line: " << Var << "\n"; If "-debug" is specified, it will print. Otherwise, it'll not print. If NDEBUG is defined, the DOUT does nothing. --- Diffs of the changes: (+12 -0) Debug.cpp | 12 ++++++++++++ 1 files changed, 12 insertions(+) Index: llvm/lib/Support/Debug.cpp diff -u llvm/lib/Support/Debug.cpp:1.7 llvm/lib/Support/Debug.cpp:1.8 --- llvm/lib/Support/Debug.cpp:1.7 Thu Apr 21 17:52:05 2005 +++ llvm/lib/Support/Debug.cpp Thu Nov 16 18:49:12 2006 @@ -25,6 +25,7 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/CommandLine.h" +#include using namespace llvm; bool llvm::DebugFlag; // DebugFlag - Exported boolean set by the -debug option @@ -63,3 +64,14 @@ return false; #endif } + +// getErrorOutputStream - Returns the error output stream (std::cerr). This +// places the std::c* I/O streams into one .cpp file and relieves the whole +// program from having to have hundreds of static c'tor/d'tors for them. +// +llvm_ostream llvm::getErrorOutputStream(const char *DebugType) { + if (DebugFlag && isCurrentDebugType(DebugType)) + return llvm_ostream(std::cerr); + else + return llvm_ostream(); +} From isanbard at gmail.com Thu Nov 16 18:49:30 2006 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 16 Nov 2006 18:49:30 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Support/Debug.h Message-ID: <200611170049.kAH0nUx3012249@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Support: Debug.h updated: 1.7 -> 1.8 --- Log message: Added "DOUT" macro. This is used as a replacement for the std::cerr stream. It centralizes the use of std::cerr so that static c'tor/d'tors aren't scattered around all over the place. The way to use it is like this: DOUT << "This is a status line: " << Var << "\n"; If "-debug" is specified, it will print. Otherwise, it'll not print. If NDEBUG is defined, the DOUT does nothing. --- Diffs of the changes: (+30 -0) Debug.h | 30 ++++++++++++++++++++++++++++++ 1 files changed, 30 insertions(+) Index: llvm/include/llvm/Support/Debug.h diff -u llvm/include/llvm/Support/Debug.h:1.7 llvm/include/llvm/Support/Debug.h:1.8 --- llvm/include/llvm/Support/Debug.h:1.7 Sun Jan 22 16:54:51 2006 +++ llvm/include/llvm/Support/Debug.h Thu Nov 16 18:49:12 2006 @@ -26,6 +26,8 @@ #ifndef LLVM_SUPPORT_DEBUG_H #define LLVM_SUPPORT_DEBUG_H +#include // Doesn't have static d'tors!! + namespace llvm { // DebugFlag - This boolean is set to true if the '-debug' command line option @@ -59,6 +61,34 @@ do { if (DebugFlag && isCurrentDebugType(DEBUG_TYPE)) { X; } } while (0) #endif +// llvm_ostream - Acts like an ostream. However, it doesn't print things out if +// an ostream isn't specified. +// +class llvm_ostream { + std::ostream* Stream; +public: + llvm_ostream() : Stream(0) {} + llvm_ostream(std::ostream& OStream) : Stream(&OStream) {} + + template + llvm_ostream& operator << (const Ty& Thing) { + if (Stream) *Stream << Thing; + return *this; + } +}; + +// getErrorOutputStream - Returns the error output stream (std::cerr). This +// places the std::c* I/O streams into one .cpp file and relieves the whole +// program from having to have hundreds of static c'tor/d'tors for them. +// +llvm_ostream getErrorOutputStream(const char *DebugType); + +#ifdef NDEBUG +#define DOUT llvm_ostream() +#else +#define DOUT getErrorOutputStream(DEBUG_TYPE) +#endif + } // End llvm namespace #endif From sabre at nondot.org Thu Nov 16 18:49:50 2006 From: sabre at nondot.org (Chris Lattner) Date: Thu, 16 Nov 2006 18:49:50 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCBranchSelector.cpp Message-ID: <200611170049.kAH0no07012289@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCBranchSelector.cpp updated: 1.31 -> 1.32 --- Log message: fix typo --- Diffs of the changes: (+2 -2) PPCBranchSelector.cpp | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/lib/Target/PowerPC/PPCBranchSelector.cpp diff -u llvm/lib/Target/PowerPC/PPCBranchSelector.cpp:1.31 llvm/lib/Target/PowerPC/PPCBranchSelector.cpp:1.32 --- llvm/lib/Target/PowerPC/PPCBranchSelector.cpp:1.31 Thu Nov 16 17:49:52 2006 +++ llvm/lib/Target/PowerPC/PPCBranchSelector.cpp Thu Nov 16 18:49:36 2006 @@ -133,12 +133,12 @@ MachineBasicBlock::iterator MBBJ; if (Displacement >= -32768 && Displacement <= 32767) { - MBBJ = BuildMI(*MBB, MBBJ, Opcode, 2).addReg(CRReg).addMBB(DestMBB); + MBBJ = BuildMI(*MBB, MBBI, Opcode, 2).addReg(CRReg).addMBB(DestMBB); } else { // Long branch, skip next branch instruction (i.e. $PC+8). ++NumExpanded; BuildMI(*MBB, MBBJ, Inverted, 2).addReg(CRReg).addImm(2); - MBBJ = BuildMI(*MBB, MBBJ, PPC::B, 1).addMBB(DestMBB); + MBBJ = BuildMI(*MBB, MBBI, PPC::B, 1).addMBB(DestMBB); } // Erase the psuedo COND_BRANCH instruction, and then back up the From isanbard at gmail.com Thu Nov 16 18:50:50 2006 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 16 Nov 2006 18:50:50 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAllocLinearScan.cpp Message-ID: <200611170050.kAH0oo1E012324@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: RegAllocLinearScan.cpp updated: 1.131 -> 1.132 --- Log message: Replace std::cerr uses of the "DEBUG" macro with "DOUT" instead. Removes a #include of iostream. --- Diffs of the changes: (+27 -29) RegAllocLinearScan.cpp | 56 +++++++++++++++++++++++-------------------------- 1 files changed, 27 insertions(+), 29 deletions(-) Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp diff -u llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.131 llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.132 --- llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.131 Wed Nov 8 13:16:43 2006 +++ llvm/lib/CodeGen/RegAllocLinearScan.cpp Thu Nov 16 18:50:36 2006 @@ -29,7 +29,6 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/Compiler.h" #include -#include #include #include #include @@ -138,14 +137,14 @@ template void printIntervals(const char* const str, ItTy i, ItTy e) const { - if (str) std::cerr << str << " intervals:\n"; + if (str) DOUT << str << " intervals:\n"; for (; i != e; ++i) { - std::cerr << "\t" << *i->first << " -> "; + DOUT << "\t" << *i->first << " -> "; unsigned reg = i->first->reg; if (MRegisterInfo::isVirtualRegister(reg)) { reg = vrm_->getPhys(reg); } - std::cerr << mri_->getName(reg) << '\n'; + DOUT << mri_->getName(reg) << '\n'; } } }; @@ -243,9 +242,8 @@ void RA::linearScan() { // linear scan algorithm - DEBUG(std::cerr << "********** LINEAR SCAN **********\n"); - DEBUG(std::cerr << "********** Function: " - << mf_->getFunction()->getName() << '\n'); + DOUT << "********** LINEAR SCAN **********\n"; + DOUT << "********** Function: " << mf_->getFunction()->getName() << '\n'; // DEBUG(printIntervals("unhandled", unhandled_.begin(), unhandled_.end())); DEBUG(printIntervals("fixed", fixed_.begin(), fixed_.end())); @@ -257,7 +255,7 @@ LiveInterval* cur = unhandled_.top(); unhandled_.pop(); ++numIterations; - DEBUG(std::cerr << "\n*** CURRENT ***: " << *cur << '\n'); + DOUT << "\n*** CURRENT ***: " << *cur << '\n'; processActiveIntervals(cur->beginNumber()); processInactiveIntervals(cur->beginNumber()); @@ -280,7 +278,7 @@ for (IntervalPtrs::reverse_iterator i = active_.rbegin(); i != active_.rend(); ) { unsigned reg = i->first->reg; - DEBUG(std::cerr << "\tinterval " << *i->first << " expired\n"); + DOUT << "\tinterval " << *i->first << " expired\n"; assert(MRegisterInfo::isVirtualRegister(reg) && "Can only allocate virtual registers!"); reg = vrm_->getPhys(reg); @@ -291,18 +289,18 @@ // expire any remaining inactive intervals for (IntervalPtrs::reverse_iterator i = inactive_.rbegin(); i != inactive_.rend(); ) { - DEBUG(std::cerr << "\tinterval " << *i->first << " expired\n"); + DOUT << "\tinterval " << *i->first << " expired\n"; i = IntervalPtrs::reverse_iterator(inactive_.erase(i.base()-1)); } - DEBUG(std::cerr << *vrm_); + DOUT << *vrm_; } /// processActiveIntervals - expire old intervals and move non-overlapping ones /// to the inactive list. void RA::processActiveIntervals(unsigned CurPoint) { - DEBUG(std::cerr << "\tprocessing active intervals:\n"); + DOUT << "\tprocessing active intervals:\n"; for (unsigned i = 0, e = active_.size(); i != e; ++i) { LiveInterval *Interval = active_[i].first; @@ -312,7 +310,7 @@ IntervalPos = Interval->advanceTo(IntervalPos, CurPoint); if (IntervalPos == Interval->end()) { // Remove expired intervals. - DEBUG(std::cerr << "\t\tinterval " << *Interval << " expired\n"); + DOUT << "\t\tinterval " << *Interval << " expired\n"; assert(MRegisterInfo::isVirtualRegister(reg) && "Can only allocate virtual registers!"); reg = vrm_->getPhys(reg); @@ -325,7 +323,7 @@ } else if (IntervalPos->start > CurPoint) { // Move inactive intervals to inactive list. - DEBUG(std::cerr << "\t\tinterval " << *Interval << " inactive\n"); + DOUT << "\t\tinterval " << *Interval << " inactive\n"; assert(MRegisterInfo::isVirtualRegister(reg) && "Can only allocate virtual registers!"); reg = vrm_->getPhys(reg); @@ -348,7 +346,7 @@ /// ones to the active list. void RA::processInactiveIntervals(unsigned CurPoint) { - DEBUG(std::cerr << "\tprocessing inactive intervals:\n"); + DOUT << "\tprocessing inactive intervals:\n"; for (unsigned i = 0, e = inactive_.size(); i != e; ++i) { LiveInterval *Interval = inactive_[i].first; @@ -358,7 +356,7 @@ IntervalPos = Interval->advanceTo(IntervalPos, CurPoint); if (IntervalPos == Interval->end()) { // remove expired intervals. - DEBUG(std::cerr << "\t\tinterval " << *Interval << " expired\n"); + DOUT << "\t\tinterval " << *Interval << " expired\n"; // Pop off the end of the list. inactive_[i] = inactive_.back(); @@ -366,7 +364,7 @@ --i; --e; } else if (IntervalPos->start <= CurPoint) { // move re-activated intervals in active list - DEBUG(std::cerr << "\t\tinterval " << *Interval << " active\n"); + DOUT << "\t\tinterval " << *Interval << " active\n"; assert(MRegisterInfo::isVirtualRegister(reg) && "Can only allocate virtual registers!"); reg = vrm_->getPhys(reg); @@ -416,7 +414,7 @@ /// spill. void RA::assignRegOrStackSlotAtInterval(LiveInterval* cur) { - DEBUG(std::cerr << "\tallocating current interval: "); + DOUT << "\tallocating current interval: "; PhysRegTracker backupPrt = *prt_; @@ -516,14 +514,14 @@ // the free physical register and add this interval to the active // list. if (physReg) { - DEBUG(std::cerr << mri_->getName(physReg) << '\n'); + DOUT << mri_->getName(physReg) << '\n'; vrm_->assignVirt2Phys(cur->reg, physReg); prt_->addRegUse(physReg); active_.push_back(std::make_pair(cur, cur->begin())); handled_.push_back(cur); return; } - DEBUG(std::cerr << "no free registers\n"); + DOUT << "no free registers\n"; // Compile the spill weights into an array that is better for scanning. std::vector SpillWeights(mri_->getNumRegs(), 0.0); @@ -541,7 +539,7 @@ updateSpillWeights(SpillWeights, reg, i->first->weight, mri_); } - DEBUG(std::cerr << "\tassigning stack slot at interval "<< *cur << ":\n"); + DOUT << "\tassigning stack slot at interval "<< *cur << ":\n"; // Find a register to spill. float minWeight = HUGE_VALF; @@ -575,14 +573,14 @@ minReg = *RC->allocation_order_begin(*mf_); } - DEBUG(std::cerr << "\t\tregister with min weight: " - << mri_->getName(minReg) << " (" << minWeight << ")\n"); + DOUT << "\t\tregister with min weight: " + << mri_->getName(minReg) << " (" << minWeight << ")\n"; // if the current has the minimum weight, we need to spill it and // add any added intervals back to unhandled, and restart // linearscan. if (cur->weight != HUGE_VALF && cur->weight <= minWeight) { - DEBUG(std::cerr << "\t\t\tspilling(c): " << *cur << '\n';); + DOUT << "\t\t\tspilling(c): " << *cur << '\n'; int slot = vrm_->assignVirt2StackSlot(cur->reg); std::vector added = li_->addIntervalsForSpills(*cur, *vrm_, slot); @@ -634,7 +632,7 @@ if (//MRegisterInfo::isVirtualRegister(reg) && toSpill[vrm_->getPhys(reg)] && cur->overlapsFrom(*i->first, i->second)) { - DEBUG(std::cerr << "\t\t\tspilling(a): " << *i->first << '\n'); + DOUT << "\t\t\tspilling(a): " << *i->first << '\n'; earliestStart = std::min(earliestStart, i->first->beginNumber()); int slot = vrm_->assignVirt2StackSlot(i->first->reg); std::vector newIs = @@ -648,7 +646,7 @@ if (//MRegisterInfo::isVirtualRegister(reg) && toSpill[vrm_->getPhys(reg)] && cur->overlapsFrom(*i->first, i->second-1)) { - DEBUG(std::cerr << "\t\t\tspilling(i): " << *i->first << '\n'); + DOUT << "\t\t\tspilling(i): " << *i->first << '\n'; earliestStart = std::min(earliestStart, i->first->beginNumber()); int slot = vrm_->assignVirt2StackSlot(reg); std::vector newIs = @@ -658,7 +656,7 @@ } } - DEBUG(std::cerr << "\t\trolling back to: " << earliestStart << '\n'); + DOUT << "\t\trolling back to: " << earliestStart << '\n'; // Scan handled in reverse order up to the earliest start of a // spilled live interval and undo each one, restoring the state of @@ -668,7 +666,7 @@ // If this interval starts before t we are done. if (i->beginNumber() < earliestStart) break; - DEBUG(std::cerr << "\t\t\tundo changes for: " << *i << '\n'); + DOUT << "\t\t\tundo changes for: " << *i << '\n'; handled_.pop_back(); // When undoing a live interval allocation we must know if it is active or @@ -708,7 +706,7 @@ LiveInterval *HI = handled_[i]; if (!HI->expiredAt(earliestStart) && HI->expiredAt(cur->beginNumber())) { - DEBUG(std::cerr << "\t\t\tundo changes for: " << *HI << '\n'); + DOUT << "\t\t\tundo changes for: " << *HI << '\n'; active_.push_back(std::make_pair(HI, HI->begin())); assert(!MRegisterInfo::isPhysicalRegister(HI->reg)); prt_->addRegUse(vrm_->getPhys(HI->reg)); From isanbard at gmail.com Thu Nov 16 19:13:26 2006 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 16 Nov 2006 19:13:26 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Support/Debug.h Message-ID: <200611170113.kAH1DQF7012653@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Support: Debug.h updated: 1.8 -> 1.9 --- Log message: Adjusted the // comments so that doxygen picks them up. --- Diffs of the changes: (+7 -7) Debug.h | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) Index: llvm/include/llvm/Support/Debug.h diff -u llvm/include/llvm/Support/Debug.h:1.8 llvm/include/llvm/Support/Debug.h:1.9 --- llvm/include/llvm/Support/Debug.h:1.8 Thu Nov 16 18:49:12 2006 +++ llvm/include/llvm/Support/Debug.h Thu Nov 16 19:13:12 2006 @@ -61,9 +61,9 @@ do { if (DebugFlag && isCurrentDebugType(DEBUG_TYPE)) { X; } } while (0) #endif -// llvm_ostream - Acts like an ostream. However, it doesn't print things out if -// an ostream isn't specified. -// +/// llvm_ostream - Acts like an ostream. However, it doesn't print things out if +/// an ostream isn't specified. +/// class llvm_ostream { std::ostream* Stream; public: @@ -77,10 +77,10 @@ } }; -// getErrorOutputStream - Returns the error output stream (std::cerr). This -// places the std::c* I/O streams into one .cpp file and relieves the whole -// program from having to have hundreds of static c'tor/d'tors for them. -// +/// getErrorOutputStream - Returns the error output stream (std::cerr). This +/// places the std::c* I/O streams into one .cpp file and relieves the whole +/// program from having to have hundreds of static c'tor/d'tors for them. +/// llvm_ostream getErrorOutputStream(const char *DebugType); #ifdef NDEBUG From rspencer at reidspencer.com Thu Nov 16 19:33:29 2006 From: rspencer at reidspencer.com (Reid Spencer) Date: Thu, 16 Nov 2006 17:33:29 -0800 Subject: [llvm-commits] CVS: llvm/include/llvm/Support/Debug.h In-Reply-To: <200611170049.kAH0nUx3012249@zion.cs.uiuc.edu> References: <200611170049.kAH0nUx3012249@zion.cs.uiuc.edu> Message-ID: <1163727209.2808.10.camel@bashful.x10sys.com> Bill, On Thu, 2006-11-16 at 18:49 -0600, Bill Wendling wrote: > > Changes in directory llvm/include/llvm/Support: > > Debug.h updated: 1.7 -> 1.8 > --- > Log message: > > Added "DOUT" macro. This is used as a replacement for the std::cerr > stream. It centralizes the use of std::cerr so that static c'tor/d'tors > aren't scattered around all over the place. The way to use it is like this: > > DOUT << "This is a status line: " << Var << "\n"; > > If "-debug" is specified, it will print. Otherwise, it'll not print. If > NDEBUG is defined, the DOUT does nothing. While this may not print anything when NDEBUG is *not* defined, it isn't sufficient. You're going to leave template functions scattered all over the place and calls to them. The existing solution completely eliminates the code from an NDEBUG build. That's what we want. What's wrong with the existing solution? Or, perhaps a combination is needed. Something like: DEBUG(DOUT << "This is a debug message\n"); > > > --- > Diffs of the changes: (+30 -0) > > Debug.h | 30 ++++++++++++++++++++++++++++++ > 1 files changed, 30 insertions(+) > > > Index: llvm/include/llvm/Support/Debug.h > diff -u llvm/include/llvm/Support/Debug.h:1.7 llvm/include/llvm/Support/Debug.h:1.8 > --- llvm/include/llvm/Support/Debug.h:1.7 Sun Jan 22 16:54:51 2006 > +++ llvm/include/llvm/Support/Debug.h Thu Nov 16 18:49:12 2006 > @@ -26,6 +26,8 @@ > #ifndef LLVM_SUPPORT_DEBUG_H > #define LLVM_SUPPORT_DEBUG_H > > +#include // Doesn't have static d'tors!! > + > namespace llvm { > > // DebugFlag - This boolean is set to true if the '-debug' command line option > @@ -59,6 +61,34 @@ > do { if (DebugFlag && isCurrentDebugType(DEBUG_TYPE)) { X; } } while (0) > #endif > > +// llvm_ostream - Acts like an ostream. However, it doesn't print things out if > +// an ostream isn't specified. > +// > +class llvm_ostream { > + std::ostream* Stream; > +public: > + llvm_ostream() : Stream(0) {} > + llvm_ostream(std::ostream& OStream) : Stream(&OStream) {} > + > + template > + llvm_ostream& operator << (const Ty& Thing) { > + if (Stream) *Stream << Thing; > + return *this; > + } > +}; > + > +// getErrorOutputStream - Returns the error output stream (std::cerr). This > +// places the std::c* I/O streams into one .cpp file and relieves the whole > +// program from having to have hundreds of static c'tor/d'tors for them. > +// > +llvm_ostream getErrorOutputStream(const char *DebugType); > + > +#ifdef NDEBUG > +#define DOUT llvm_ostream() > +#else > +#define DOUT getErrorOutputStream(DEBUG_TYPE) > +#endif > + > } // End llvm namespace > > #endif > > > > _______________________________________________ > 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 Thu Nov 16 19:36:16 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 16 Nov 2006 19:36:16 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Target/TargetInstrInfo.h Message-ID: <200611170136.kAH1aG4K012982@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Target: TargetInstrInfo.h updated: 1.105 -> 1.106 --- Log message: Add opcode to TargetInstrDescriptor. --- Diffs of the changes: (+2 -1) TargetInstrInfo.h | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-) Index: llvm/include/llvm/Target/TargetInstrInfo.h diff -u llvm/include/llvm/Target/TargetInstrInfo.h:1.105 llvm/include/llvm/Target/TargetInstrInfo.h:1.106 --- llvm/include/llvm/Target/TargetInstrInfo.h:1.105 Wed Nov 8 20:20:58 2006 +++ llvm/include/llvm/Target/TargetInstrInfo.h Thu Nov 16 19:36:01 2006 @@ -110,8 +110,9 @@ class TargetInstrDescriptor { public: + MachineOpCode Opcode; // The opcode. + unsigned short numOperands; // Num of args (may be more if variable_ops). const char * Name; // Assembly language mnemonic for the opcode. - unsigned numOperands; // Num of args (may be more if variable_ops). InstrSchedClass schedClass; // enum identifying instr sched class unsigned Flags; // flags identifying machine instr class unsigned TSFlags; // Target Specific Flag values From isanbard at gmail.com Thu Nov 16 19:44:03 2006 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 16 Nov 2006 19:44:03 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Support/Debug.h Message-ID: <200611170144.kAH1i3DI013107@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Support: Debug.h updated: 1.9 -> 1.10 --- Log message: #ifndef NDEBUG the "if (Stream) ..." stuff. --- Diffs of the changes: (+2 -0) Debug.h | 2 ++ 1 files changed, 2 insertions(+) Index: llvm/include/llvm/Support/Debug.h diff -u llvm/include/llvm/Support/Debug.h:1.9 llvm/include/llvm/Support/Debug.h:1.10 --- llvm/include/llvm/Support/Debug.h:1.9 Thu Nov 16 19:13:12 2006 +++ llvm/include/llvm/Support/Debug.h Thu Nov 16 19:43:48 2006 @@ -72,7 +72,9 @@ template llvm_ostream& operator << (const Ty& Thing) { +#ifndef NDEBUG if (Stream) *Stream << Thing; +#endif return *this; } }; From isanbard at gmail.com Thu Nov 16 19:44:26 2006 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 16 Nov 2006 17:44:26 -0800 Subject: [llvm-commits] CVS: llvm/include/llvm/Support/Debug.h In-Reply-To: <1163727209.2808.10.camel@bashful.x10sys.com> References: <200611170049.kAH0nUx3012249@zion.cs.uiuc.edu> <1163727209.2808.10.camel@bashful.x10sys.com> Message-ID: <16e5fdf90611161744g594ca474q894595ed6f1a2fb4@mail.gmail.com> On 11/16/06, Reid Spencer wrote: > On Thu, 2006-11-16 at 18:49 -0600, Bill Wendling wrote: > > Added "DOUT" macro. This is used as a replacement for the std::cerr > > stream. It centralizes the use of std::cerr so that static c'tor/d'tors > > aren't scattered around all over the place. The way to use it is like this: > > > > DOUT << "This is a status line: " << Var << "\n"; > > > > If "-debug" is specified, it will print. Otherwise, it'll not print. If > > NDEBUG is defined, the DOUT does nothing. > > While this may not print anything when NDEBUG is *not* defined, it isn't > sufficient. You're going to leave template functions scattered all over > the place and calls to them. The existing solution completely eliminates > the code from an NDEBUG build. That's what we want. What's wrong with > the existing solution? Or, perhaps a combination is needed. Something > like: > > DEBUG(DOUT << "This is a debug message\n"); > Hi Reid, Basically, this is to get rid of static c'tor/d'tors scattered all over the source tree. (You get them whenever you #include .) A smart compiler should be able to remove all of the empty functions because they don't have any side-effects. -bw From evan.cheng at apple.com Thu Nov 16 19:46:42 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 16 Nov 2006 19:46:42 -0600 Subject: [llvm-commits] CVS: llvm/utils/TableGen/InstrInfoEmitter.cpp Message-ID: <200611170146.kAH1kgVK013157@zion.cs.uiuc.edu> Changes in directory llvm/utils/TableGen: InstrInfoEmitter.cpp updated: 1.53 -> 1.54 --- Log message: Add opcode to TargetInstrDescriptor. --- Diffs of the changes: (+4 -3) InstrInfoEmitter.cpp | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) Index: llvm/utils/TableGen/InstrInfoEmitter.cpp diff -u llvm/utils/TableGen/InstrInfoEmitter.cpp:1.53 llvm/utils/TableGen/InstrInfoEmitter.cpp:1.54 --- llvm/utils/TableGen/InstrInfoEmitter.cpp:1.53 Tue Nov 14 20:38:17 2006 +++ llvm/utils/TableGen/InstrInfoEmitter.cpp Thu Nov 16 19:46:27 2006 @@ -197,7 +197,9 @@ else MinOperands = 0; - OS << " { \""; + OS << " { "; + OS << Num << ",\t" << MinOperands << ",\t\""; + if (Inst.Name.empty()) OS << Inst.TheDef->getName(); else @@ -206,8 +208,7 @@ unsigned ItinClass = !IsItineraries ? 0 : ItinClassNumber(Inst.TheDef->getValueAsDef("Itinerary")->getName()); - OS << "\",\t" << MinOperands << ", " << ItinClass - << ", 0"; + OS << "\",\t" << ItinClass << ", 0"; // Try to determine (from the pattern), if the instruction is a store. bool isStore = false; From sabre at nondot.org Thu Nov 16 19:52:38 2006 From: sabre at nondot.org (Chris Lattner) Date: Thu, 16 Nov 2006 19:52:38 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCBranchSelector.cpp Message-ID: <200611170152.kAH1qcZb013268@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCBranchSelector.cpp updated: 1.32 -> 1.33 --- Log message: implement a todo: change a map into a vector --- Diffs of the changes: (+6 -6) PPCBranchSelector.cpp | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) Index: llvm/lib/Target/PowerPC/PPCBranchSelector.cpp diff -u llvm/lib/Target/PowerPC/PPCBranchSelector.cpp:1.32 llvm/lib/Target/PowerPC/PPCBranchSelector.cpp:1.33 --- llvm/lib/Target/PowerPC/PPCBranchSelector.cpp:1.32 Thu Nov 16 18:49:36 2006 +++ llvm/lib/Target/PowerPC/PPCBranchSelector.cpp Thu Nov 16 19:52:23 2006 @@ -23,7 +23,6 @@ #include "llvm/Target/TargetAsmInfo.h" #include "llvm/ADT/Statistic.h" #include "llvm/Support/Compiler.h" -#include using namespace llvm; static Statistic<> NumExpanded("ppc-branch-select", @@ -31,9 +30,8 @@ namespace { struct VISIBILITY_HIDDEN PPCBSel : public MachineFunctionPass { - /// OffsetMap - Mapping between BB and byte offset from start of function. - /// TODO: replace this with a vector, using the MBB idx as the key. - std::map OffsetMap; + /// OffsetMap - Mapping between BB # and byte offset from start of function. + std::vector OffsetMap; virtual bool runOnMachineFunction(MachineFunction &Fn); @@ -81,12 +79,14 @@ // Running total of instructions encountered since beginning of function unsigned ByteCount = 0; + OffsetMap.resize(Fn.getNumBlockIDs()); + // For each MBB, add its offset to the offset map, and count up its // instructions for (MachineFunction::iterator MFI = Fn.begin(), E = Fn.end(); MFI != E; ++MFI) { MachineBasicBlock *MBB = MFI; - OffsetMap[MBB] = ByteCount; + OffsetMap[MBB->getNumber()] = ByteCount; for (MachineBasicBlock::iterator MBBI = MBB->begin(), EE = MBB->end(); MBBI != EE; ++MBBI) @@ -128,7 +128,7 @@ unsigned Opcode = MBBI->getOperand(1).getImmedValue(); unsigned CRReg = MBBI->getOperand(0).getReg(); - int Displacement = OffsetMap[DestMBB] - ByteCount; + int Displacement = OffsetMap[DestMBB->getNumber()] - ByteCount; unsigned Inverted = PPCInstrInfo::invertPPCBranchOpcode(Opcode); MachineBasicBlock::iterator MBBJ; From isanbard at gmail.com Thu Nov 16 20:09:21 2006 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 16 Nov 2006 20:09:21 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAllocLocal.cpp VirtRegMap.cpp VirtRegMap.h Message-ID: <200611170209.kAH29LWm013719@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: RegAllocLocal.cpp updated: 1.95 -> 1.96 VirtRegMap.cpp updated: 1.79 -> 1.80 VirtRegMap.h updated: 1.22 -> 1.23 --- Log message: More removal of std::cerr and DEBUG, replacing with DOUT instead. --- Diffs of the changes: (+72 -65) RegAllocLocal.cpp | 53 +++++++++++++++++----------------- VirtRegMap.cpp | 82 ++++++++++++++++++++++++++++-------------------------- VirtRegMap.h | 2 + 3 files changed, 72 insertions(+), 65 deletions(-) Index: llvm/lib/CodeGen/RegAllocLocal.cpp diff -u llvm/lib/CodeGen/RegAllocLocal.cpp:1.95 llvm/lib/CodeGen/RegAllocLocal.cpp:1.96 --- llvm/lib/CodeGen/RegAllocLocal.cpp:1.95 Wed Nov 15 14:55:15 2006 +++ llvm/lib/CodeGen/RegAllocLocal.cpp Thu Nov 16 20:09:07 2006 @@ -30,7 +30,6 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Statistic.h" #include -#include using namespace llvm; namespace { @@ -270,10 +269,10 @@ assert(VirtReg && "Spilling a physical register is illegal!" " Must not have appropriate kill for the register or use exists beyond" " the intended one."); - DEBUG(std::cerr << " Spilling register " << RegInfo->getName(PhysReg); - std::cerr << " containing %reg" << VirtReg; - if (!isVirtRegModified(VirtReg)) - std::cerr << " which has not been modified, so no store necessary!"); + DOUT << " Spilling register " << RegInfo->getName(PhysReg) + << " containing %reg" << VirtReg; + if (!isVirtRegModified(VirtReg)) + DOUT << " which has not been modified, so no store necessary!"; // Otherwise, there is a virtual register corresponding to this physical // register. We only need to spill it into its stack slot if it has been @@ -281,14 +280,14 @@ if (isVirtRegModified(VirtReg)) { const TargetRegisterClass *RC = MF->getSSARegMap()->getRegClass(VirtReg); int FrameIndex = getStackSpaceFor(VirtReg, RC); - DEBUG(std::cerr << " to stack slot #" << FrameIndex); + DOUT << " to stack slot #" << FrameIndex; RegInfo->storeRegToStackSlot(MBB, I, PhysReg, FrameIndex, RC); ++NumStores; // Update statistics } getVirt2PhysRegMapSlot(VirtReg) = 0; // VirtReg no longer available - DEBUG(std::cerr << "\n"); + DOUT << "\n"; removePhysReg(PhysReg); } @@ -318,9 +317,9 @@ // No more use of %EAX, %AH, etc. // %EAX isn't dead upon definition, but %AH is. However %AH isn't // an operand of definition MI so it's not marked as such. - DEBUG(std::cerr << " Register " << RegInfo->getName(*AliasSet) - << " [%reg" << *AliasSet - << "] is never used, removing it frame live list\n"); + DOUT << " Register " << RegInfo->getName(*AliasSet) + << " [%reg" << *AliasSet + << "] is never used, removing it frame live list\n"; removePhysReg(*AliasSet); } else spillVirtReg(MBB, I, PhysRegsUsed[*AliasSet], *AliasSet); @@ -506,8 +505,8 @@ markVirtRegModified(VirtReg, false); // Note that this reg was just reloaded - DEBUG(std::cerr << " Reloading %reg" << VirtReg << " into " - << RegInfo->getName(PhysReg) << "\n"); + DOUT << " Reloading %reg" << VirtReg << " into " + << RegInfo->getName(PhysReg) << "\n"; // Add move instruction(s) RegInfo->loadRegFromStackSlot(MBB, MI, PhysReg, FrameIndex, RC); @@ -526,7 +525,7 @@ const TargetInstrInfo &TII = *TM->getInstrInfo(); DEBUG(const BasicBlock *LBB = MBB.getBasicBlock(); - if (LBB) std::cerr << "\nStarting RegAlloc of BB: " << LBB->getName()); + if (LBB) DOUT << "\nStarting RegAlloc of BB: " << LBB->getName()); // If this is the first basic block in the machine function, add live-in // registers as active. @@ -552,13 +551,13 @@ while (MII != MBB.end()) { MachineInstr *MI = MII++; const TargetInstrDescriptor &TID = TII.get(MI->getOpcode()); - DEBUG(std::cerr << "\nStarting RegAlloc of: " << *MI; - std::cerr << " Regs have values: "; + DEBUG(DOUT << "\nStarting RegAlloc of: " << *MI; + DOUT << " Regs have values: "; for (unsigned i = 0; i != RegInfo->getNumRegs(); ++i) if (PhysRegsUsed[i] != -1 && PhysRegsUsed[i] != -2) - std::cerr << "[" << RegInfo->getName(i) - << ",%reg" << PhysRegsUsed[i] << "] "; - std::cerr << "\n"); + DOUT << "[" << RegInfo->getName(i) + << ",%reg" << PhysRegsUsed[i] << "] "; + DOUT << "\n"); // Loop over the implicit uses, making sure that they are at the head of the // use order list, so they don't get reallocated. @@ -608,15 +607,15 @@ } if (PhysReg) { - DEBUG(std::cerr << " Last use of " << RegInfo->getName(PhysReg) - << "[%reg" << VirtReg <<"], removing it from live set\n"); + DOUT << " Last use of " << RegInfo->getName(PhysReg) + << "[%reg" << VirtReg <<"], removing it from live set\n"; removePhysReg(PhysReg); for (const unsigned *AliasSet = RegInfo->getAliasSet(PhysReg); *AliasSet; ++AliasSet) { if (PhysRegsUsed[*AliasSet] != -2) { - DEBUG(std::cerr << " Last use of " + DOUT << " Last use of " << RegInfo->getName(*AliasSet) - << "[%reg" << VirtReg <<"], removing it from live set\n"); + << "[%reg" << VirtReg <<"], removing it from live set\n"; removePhysReg(*AliasSet); } } @@ -718,16 +717,16 @@ } if (PhysReg) { - DEBUG(std::cerr << " Register " << RegInfo->getName(PhysReg) + DOUT << " Register " << RegInfo->getName(PhysReg) << " [%reg" << VirtReg - << "] is never used, removing it frame live list\n"); + << "] is never used, removing it frame live list\n"; removePhysReg(PhysReg); for (const unsigned *AliasSet = RegInfo->getAliasSet(PhysReg); *AliasSet; ++AliasSet) { if (PhysRegsUsed[*AliasSet] != -2) { - DEBUG(std::cerr << " Register " << RegInfo->getName(*AliasSet) + DOUT << " Register " << RegInfo->getName(*AliasSet) << " [%reg" << *AliasSet - << "] is never used, removing it frame live list\n"); + << "] is never used, removing it frame live list\n"; removePhysReg(*AliasSet); } } @@ -775,7 +774,7 @@ /// runOnMachineFunction - Register allocate the whole function /// bool RA::runOnMachineFunction(MachineFunction &Fn) { - DEBUG(std::cerr << "Machine Function " << "\n"); + DOUT << "Machine Function " << "\n"; MF = &Fn; TM = &Fn.getTarget(); RegInfo = TM->getRegisterInfo(); Index: llvm/lib/CodeGen/VirtRegMap.cpp diff -u llvm/lib/CodeGen/VirtRegMap.cpp:1.79 llvm/lib/CodeGen/VirtRegMap.cpp:1.80 --- llvm/lib/CodeGen/VirtRegMap.cpp:1.79 Fri Nov 3 18:21:55 2006 +++ llvm/lib/CodeGen/VirtRegMap.cpp Thu Nov 16 20:09:07 2006 @@ -30,7 +30,6 @@ #include "llvm/ADT/Statistic.h" #include "llvm/ADT/STLExtras.h" #include -#include using namespace llvm; namespace { @@ -113,6 +112,11 @@ } void VirtRegMap::print(std::ostream &OS) const { + llvm_ostream LOS(OS); + print(LOS); +} + +void VirtRegMap::print(llvm_ostream &OS) const { const MRegisterInfo* MRI = MF.getTarget().getRegisterInfo(); OS << "********** REGISTER MAP **********\n"; @@ -130,7 +134,10 @@ OS << '\n'; } -void VirtRegMap::dump() const { print(std::cerr); } +void VirtRegMap::dump() const { + llvm_ostream OS = DOUT; + print(OS); +} //===----------------------------------------------------------------------===// @@ -146,9 +153,8 @@ } bool SimpleSpiller::runOnMachineFunction(MachineFunction &MF, VirtRegMap &VRM) { - DEBUG(std::cerr << "********** REWRITE MACHINE CODE **********\n"); - DEBUG(std::cerr << "********** Function: " - << MF.getFunction()->getName() << '\n'); + DOUT << "********** REWRITE MACHINE CODE **********\n"; + DOUT << "********** Function: " << MF.getFunction()->getName() << '\n'; const TargetMachine &TM = MF.getTarget(); const MRegisterInfo &MRI = *TM.getRegisterInfo(); bool *PhysRegsUsed = MF.getUsedPhysregs(); @@ -161,7 +167,7 @@ for (MachineFunction::iterator MBBI = MF.begin(), E = MF.end(); MBBI != E; ++MBBI) { - DEBUG(std::cerr << MBBI->getBasicBlock()->getName() << ":\n"); + DOUT << MBBI->getBasicBlock()->getName() << ":\n"; MachineBasicBlock &MBB = *MBBI; for (MachineBasicBlock::iterator MII = MBB.begin(), E = MBB.end(); MII != E; ++MII) { @@ -183,7 +189,7 @@ MRI.loadRegFromStackSlot(MBB, &MI, PhysReg, StackSlot, RC); LoadedRegs.push_back(VirtReg); ++NumLoads; - DEBUG(std::cerr << '\t' << *prior(MII)); + DOUT << '\t' << *prior(MII); } if (MO.isDef()) { @@ -198,7 +204,7 @@ } } - DEBUG(std::cerr << '\t' << MI); + DOUT << '\t' << MI; LoadedRegs.clear(); } } @@ -221,8 +227,8 @@ bool runOnMachineFunction(MachineFunction &MF, VirtRegMap &VRM) { MRI = MF.getTarget().getRegisterInfo(); TII = MF.getTarget().getInstrInfo(); - DEBUG(std::cerr << "\n**** Local spiller rewriting function '" - << MF.getFunction()->getName() << "':\n"); + DOUT << "\n**** Local spiller rewriting function '" + << MF.getFunction()->getName() << "':\n"; for (MachineFunction::iterator MBB = MF.begin(), E = MF.end(); MBB != E; ++MBB) @@ -293,8 +299,8 @@ PhysRegsAvailable.insert(std::make_pair(Reg, Slot)); SpillSlotsAvailable[Slot] = (Reg << 1) | (unsigned)CanClobber; - DEBUG(std::cerr << "Remembering SS#" << Slot << " in physreg " - << MRI->getName(Reg) << "\n"); + DOUT << "Remembering SS#" << Slot << " in physreg " + << MRI->getName(Reg) << "\n"; } /// canClobberPhysReg - Return true if the spiller is allowed to change the @@ -328,8 +334,8 @@ assert((SpillSlotsAvailable[Slot] >> 1) == PhysReg && "Bidirectional map mismatch!"); SpillSlotsAvailable.erase(Slot); - DEBUG(std::cerr << "PhysReg " << MRI->getName(PhysReg) - << " clobbered, invalidating SS#" << Slot << "\n"); + DOUT << "PhysReg " << MRI->getName(PhysReg) + << " clobbered, invalidating SS#" << Slot << "\n"; } } @@ -486,9 +492,9 @@ Spills.addAvailable(NewOp.StackSlot, NewPhysReg); ++NumLoads; DEBUG(MachineBasicBlock::iterator MII = MI; - std::cerr << '\t' << *prior(MII)); + DOUT << '\t' << *prior(MII)); - DEBUG(std::cerr << "Reuse undone!\n"); + DOUT << "Reuse undone!\n"; --NumReused; // Finally, PhysReg is now available, go ahead and use it. @@ -506,7 +512,7 @@ /// register allocator is done with them. If possible, avoid reloading vregs. void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM) { - DEBUG(std::cerr << MBB.getBasicBlock()->getName() << ":\n"); + DOUT << MBB.getBasicBlock()->getName() << ":\n"; // Spills - Keep track of which spilled values are available in physregs so // that we can choose to reuse the physregs instead of emitting reloads. @@ -600,10 +606,10 @@ if (CanReuse) { // If this stack slot value is already available, reuse it! - DEBUG(std::cerr << "Reusing SS#" << StackSlot << " from physreg " - << MRI->getName(PhysReg) << " for vreg" - << VirtReg <<" instead of reloading into physreg " - << MRI->getName(VRM.getPhys(VirtReg)) << "\n"); + DOUT << "Reusing SS#" << StackSlot << " from physreg " + << MRI->getName(PhysReg) << " for vreg" + << VirtReg <<" instead of reloading into physreg " + << MRI->getName(VRM.getPhys(VirtReg)) << "\n"; MI.getOperand(i).setReg(PhysReg); // The only technical detail we have is that we don't know that @@ -654,10 +660,10 @@ // incoming, we don't need to inserted a dead copy. if (DesignatedReg == PhysReg) { // If this stack slot value is already available, reuse it! - DEBUG(std::cerr << "Reusing SS#" << StackSlot << " from physreg " - << MRI->getName(PhysReg) << " for vreg" - << VirtReg - << " instead of reloading into same physreg.\n"); + DOUT << "Reusing SS#" << StackSlot << " from physreg " + << MRI->getName(PhysReg) << " for vreg" + << VirtReg + << " instead of reloading into same physreg.\n"; MI.getOperand(i).setReg(PhysReg); ReusedOperands.markClobbered(PhysReg); ++NumReused; @@ -676,7 +682,7 @@ Spills.addAvailable(StackSlot, DesignatedReg); MI.getOperand(i).setReg(DesignatedReg); - DEBUG(std::cerr << '\t' << *prior(MII)); + DOUT << '\t' << *prior(MII); ++NumReused; continue; } @@ -706,26 +712,26 @@ Spills.addAvailable(StackSlot, PhysReg); ++NumLoads; MI.getOperand(i).setReg(PhysReg); - DEBUG(std::cerr << '\t' << *prior(MII)); + DOUT << '\t' << *prior(MII); } - DEBUG(std::cerr << '\t' << MI); + DOUT << '\t' << MI; // If we have folded references to memory operands, make sure we clear all // physical registers that may contain the value of the spilled virtual // register VirtRegMap::MI2VirtMapTy::const_iterator I, End; for (tie(I, End) = VRM.getFoldedVirts(&MI); I != End; ++I) { - DEBUG(std::cerr << "Folded vreg: " << I->second.first << " MR: " - << I->second.second); + DOUT << "Folded vreg: " << I->second.first << " MR: " + << I->second.second; unsigned VirtReg = I->second.first; VirtRegMap::ModRef MR = I->second.second; if (!VRM.hasStackSlot(VirtReg)) { - DEBUG(std::cerr << ": No stack slot!\n"); + DOUT << ": No stack slot!\n"; continue; } int SS = VRM.getStackSlot(VirtReg); - DEBUG(std::cerr << " - StackSlot: " << SS << "\n"); + DOUT << " - StackSlot: " << SS << "\n"; // If this folded instruction is just a use, check to see if it's a // straight load from the virt reg slot. @@ -736,7 +742,7 @@ // If this spill slot is available, turn it into a copy (or nothing) // instead of leaving it as a load! if (unsigned InReg = Spills.getSpillSlotPhysReg(SS)) { - DEBUG(std::cerr << "Promoted Load To Copy: " << MI); + DOUT << "Promoted Load To Copy: " << MI; MachineFunction &MF = *MBB.getParent(); if (DestReg != InReg) { MRI->copyRegToReg(MBB, &MI, DestReg, InReg, @@ -764,7 +770,7 @@ else { // If we get here, the store is dead, nuke it now. assert(VirtRegMap::isMod && "Can't be modref!"); - DEBUG(std::cerr << "Removed dead store:\t" << *MDSI->second); + DOUT << "Removed dead store:\t" << *MDSI->second; MBB.erase(MDSI->second); VRM.RemoveFromFoldedVirtMap(MDSI->second); MaybeDeadStores.erase(MDSI); @@ -813,7 +819,7 @@ unsigned Src, Dst; if (TII->isMoveInstr(MI, Src, Dst) && Src == Dst) { ++NumDCE; - DEBUG(std::cerr << "Removing now-noop copy: " << MI); + DOUT << "Removing now-noop copy: " << MI; MBB.erase(&MI); VRM.RemoveFromFoldedVirtMap(&MI); goto ProcessNextInst; @@ -861,7 +867,7 @@ PhysRegsUsed[PhysReg] = true; ReusedOperands.markClobbered(PhysReg); MRI->storeRegToStackSlot(MBB, next(MII), PhysReg, StackSlot, RC); - DEBUG(std::cerr << "Store:\t" << *next(MII)); + DOUT << "Store:\t" << *next(MII); MI.getOperand(i).setReg(PhysReg); // Check to see if this is a noop copy. If so, eliminate the @@ -870,7 +876,7 @@ unsigned Src, Dst; if (TII->isMoveInstr(MI, Src, Dst) && Src == Dst) { ++NumDCE; - DEBUG(std::cerr << "Removing now-noop copy: " << MI); + DOUT << "Removing now-noop copy: " << MI; MBB.erase(&MI); VRM.RemoveFromFoldedVirtMap(&MI); goto ProcessNextInst; @@ -880,7 +886,7 @@ // If there is a dead store to this stack slot, nuke it now. MachineInstr *&LastStore = MaybeDeadStores[StackSlot]; if (LastStore) { - DEBUG(std::cerr << "Removed dead store:\t" << *LastStore); + DOUT << "Removed dead store:\t" << *LastStore; ++NumDSE; MBB.erase(LastStore); VRM.RemoveFromFoldedVirtMap(LastStore); Index: llvm/lib/CodeGen/VirtRegMap.h diff -u llvm/lib/CodeGen/VirtRegMap.h:1.22 llvm/lib/CodeGen/VirtRegMap.h:1.23 --- llvm/lib/CodeGen/VirtRegMap.h:1.22 Mon Sep 4 21:12:02 2006 +++ llvm/lib/CodeGen/VirtRegMap.h Thu Nov 16 20:09:07 2006 @@ -24,6 +24,7 @@ namespace llvm { class MachineInstr; class TargetInstrInfo; + class llvm_ostream; class VirtRegMap { public: @@ -144,6 +145,7 @@ } void print(std::ostream &OS) const; + void print(llvm_ostream &OS) const; void dump() const; }; From rspencer at reidspencer.com Thu Nov 16 20:25:00 2006 From: rspencer at reidspencer.com (Reid Spencer) Date: Thu, 16 Nov 2006 18:25:00 -0800 Subject: [llvm-commits] CVS: llvm/include/llvm/Support/Debug.h In-Reply-To: <16e5fdf90611161744g594ca474q894595ed6f1a2fb4@mail.gmail.com> References: <200611170049.kAH0nUx3012249@zion.cs.uiuc.edu> <1163727209.2808.10.camel@bashful.x10sys.com> <16e5fdf90611161744g594ca474q894595ed6f1a2fb4@mail.gmail.com> Message-ID: <1163730300.2808.21.camel@bashful.x10sys.com> Hi Bill, On Thu, 2006-11-16 at 17:44 -0800, Bill Wendling wrote: > On 11/16/06, Reid Spencer wrote: > > While this may not print anything when NDEBUG is *not* defined, it isn't > > sufficient. You're going to leave template functions scattered all over > > the place and calls to them. The existing solution completely eliminates > > the code from an NDEBUG build. That's what we want. What's wrong with > > the existing solution? Or, perhaps a combination is needed. Something > > like: > > > > DEBUG(DOUT << "This is a debug message\n"); > > > Hi Reid, > > Basically, this is to get rid of static c'tor/d'tors scattered all > over the source tree. (You get them whenever you #include .) > A smart compiler should be able to remove all of the empty functions > because they don't have any side-effects. I understand the motivation for the change and I commend it, but I'm concerned about getting it right. You're assuming a few things: a) the compiler is smart enough to get rid of calls that have no side effects, b) the compiler knows how to determine if a function has no side effects without help (operator<< isn't marked "pure"), and c) that there aren't any side effects. c) can probably be proven by your iostream implementation but a) and b) are a little tougher. Can we build an optimized, with symbols (-g -O2) version of one of these modules and see if those symbols are getting removed ? If so, I'm fine with it. If not, we need a new strategy. Reid. From reid at x10sys.com Thu Nov 16 21:33:05 2006 From: reid at x10sys.com (Reid Spencer) Date: Thu, 16 Nov 2006 21:33:05 -0600 Subject: [llvm-commits] CVS: llvm/runtime/libdummy/Makefile README.txt dummylib.c Message-ID: <200611170333.kAH3X5mD015175@zion.cs.uiuc.edu> Changes in directory llvm/runtime/libdummy: Makefile updated: 1.9 -> 1.10 README.txt updated: 1.2 -> 1.3 dummylib.c updated: 1.7 -> 1.8 --- Log message: Undo removal of the runtime libraries. While this may have been a bit premature, these libraries will be going away for the 2.0 release. Other arrangements for profiling, gc, etc. should be made in the next few months. --- Diffs of the changes: (+165 -0) Makefile | 19 ++++++++ README.txt | 2 dummylib.c | 144 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 165 insertions(+) Index: llvm/runtime/libdummy/Makefile diff -u /dev/null llvm/runtime/libdummy/Makefile:1.10 --- /dev/null Thu Nov 16 21:32:43 2006 +++ llvm/runtime/libdummy/Makefile Thu Nov 16 21:32:33 2006 @@ -0,0 +1,19 @@ +##===- runtime/libdummy/Makefile ---------------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file was developed by the LLVM research group and is distributed under +# the University of Illinois Open Source License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +LEVEL = ../.. +BYTECODE_LIBRARY = 1 +DONT_BUILD_RELINKED = 1 +LIBRARYNAME = dummy +BYTECODE_DESTINATION = $(CFERuntimeLibDir) + +include $(LEVEL)/Makefile.common + +CompileCommonOpts := $(filter-out -pedantic,$(CompileCommonOpts)) +CompileCommonOpts := $(filter-out -Wno-long-long,$(CompileCommonOpts)) Index: llvm/runtime/libdummy/README.txt diff -u /dev/null llvm/runtime/libdummy/README.txt:1.3 --- /dev/null Thu Nov 16 21:33:05 2006 +++ llvm/runtime/libdummy/README.txt Thu Nov 16 21:32:33 2006 @@ -0,0 +1,2 @@ +This directory contains stub routines which are occasionally useful when +performing alias analysis research. Index: llvm/runtime/libdummy/dummylib.c diff -u /dev/null llvm/runtime/libdummy/dummylib.c:1.8 --- /dev/null Thu Nov 16 21:33:05 2006 +++ llvm/runtime/libdummy/dummylib.c Thu Nov 16 21:32:33 2006 @@ -0,0 +1,144 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#if 0 +int stat(const char *file_name, struct stat *buf) { return 0; } +int fstat(int filedes, struct stat *buf) { return 0; } +int lstat(const char *file_name, struct stat *buf) { return 0; } + +// Varargs function definitions +int ioctl(int d, int request, ...) {return 0; } +int printf(const char *X) {return 0; } +int sscanf(const char *X, const char *Y, ...) { return 0; } +int fprintf(FILE *stream, const char *format, ...) { return 0; } + + +int gettimeofday(struct timeval *tv, void *tz) { return 0; } +void *xmalloc(size_t X) { return malloc(X); } + +void srand(unsigned x) {} +double exp(double x) { return 0; } +double log(double x) { return 0; } +double sqrt(double x) { return 0; } +void exit(int x) {} +int puts(const char *x) { return 0; } +void __main() {} +int atoi(const char*x) { return 1; } +char *fgets(char*Ptr, int x, FILE*F) { return Ptr; } +char *gets(char *C) { return C; } +int fclose(FILE*F) { return 0; } +FILE *fopen(const char *n, const char*x) { return malloc(sizeof(FILE)); } +FILE *freopen(const char *path, const char *mode, FILE *stream) { return 0; } +int fflush(FILE *F) { return 0; } +size_t fwrite(const void* str, size_t N, size_t n, FILE *F) { return N; } +void *memset(void *P, int X, size_t N) { return P; } +void *memcpy(void *P, void *S, size_t N) { return P; } +void *memmove(void *P, void *S, size_t N) { return P; } +char *strcpy(char*Str1, const char *Str) { return Str1; } +char *strcat(char*Str1, const char *Str) { return Str1; } +size_t strlen(char *X) { return 0; } +#undef putchar +int putchar(int N) { return N; } +int putc(int c, FILE *stream) { return c; } +int fputc(int c, FILE *stream) { return c; } +int fgetc(FILE *S) { return 0; } +long ftell(FILE *F) { return 0; } +int getc(FILE *S) { return 0; } +size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream) { return 0; } +int fseek(FILE *stream, long offset, int whence) { return 0; } +int feof(FILE *stream) { return 0; } +int fputs(const char *s, char *stream) { return 0; } +int ferror(FILE *F) { return 0; } +FILE *fdopen(int fildes, const char *mode) { return 0;} +FILE *popen(const char *command, const char *type) { return 0; } +int pclose(FILE *stream) { return 0; } + +int ungetc(int c, FILE *stream) { return 0; } +int setvbuf(FILE *stream, char *buf, int mode , size_t size) { return 0; } +void rewind(FILE*F) { } +int fileno(FILE *stream) { return 1; } +char *ttyname(int desc) { return 0; } +long sysconf(int name) { return 0; } +char *tmpnam(char *s) { return s; } + +void *calloc(size_t A, size_t B) { return malloc(A*B); } +void *realloc(void *ptr, size_t N) { return ptr; } +const char *strerror(int N) { return 0; } +int unlink(const char *path) { return 0; } +void perror(const char *err) {} +char *strrchr(const char *S, int C) { return (char*)S; } +int memcmp(const char *A, const char *B, size_t N) { return 0; } +ssize_t read(int fildes, void *buf, size_t nbyte) { return nbyte; } +int close(int FD) { return 0; } +int rename(const char *oldpath, const char *newpath) { return 0; } +ssize_t write(int fd, const void *buf, size_t count) { return 0; } +pid_t getpid(void) { return 0; } +pid_t getppid(void) { return 0; } +void setbuf(FILE *stream, char *buf) {} +int isatty(int desc) { return 0; } +int vsprintf(char *str, const char *format, va_list ap) { return 0; } +char *getcwd(char *buf, size_t size) { return buf; } + +void qsort(void *base, size_t nmemb, size_t size, + int(*compar)(const void *, const void *)) { + compar(base, base); +} + + + +#include +clock_t times(struct tms *buf) { return 0; } + + +#include +int setjmp(jmp_buf env) { return 0; } +void longjmp(jmp_buf env, int val) {} +int kill(pid_t pid, int sig) { return 0; } +int system(const char *string) { return 0; } +char *getenv(const char *name) { return 0; } +typedef void (*sighandler_t)(int); + +sighandler_t signal(int signum, sighandler_t handler) { return handler; } + + + + +char *strchr(const char *s, int c) { return (char*)s; } +int strcmp(const char *s1, const char *s2) { return 0; } +int strncmp(const char *s1, const char *s2, size_t n) { return 0; } +char *strncpy(char *s1, const char *s2, size_t n) { return s1; } +char *strpbrk(const char *s, const char *accept) { return (char*)s; } +char *strncat(char *dest, const char *src, size_t n) { return dest; } + +double atof(const char *C) { return 0; } + + +long clock() { return 0; } +char *ctime(const time_t *timep) { return 0; } +time_t time(time_t *t) { return *t = 0; } + +double sin(double x) { return x; } +double cos(double x) { return x; } +double tan(double x) { return x; } +double asin(double x) { return x; } +double acos(double x) { return x; } +double atan(double x) { return x; } +double cosh(double x) { return x; } +double sinh(double x) { return x; } +double ceil(double x) { return x; } +double floor(double x) { return x; } + +double atan2(double x, double y) { return x; } +double fmod(double x, double y) { return x; } +double pow(double x, double y) { return x; } + +int tolower(int x) { return x; } +int toupper(int x) { return x; } + +#endif From reid at x10sys.com Thu Nov 16 21:33:05 2006 From: reid at x10sys.com (Reid Spencer) Date: Thu, 16 Nov 2006 21:33:05 -0600 Subject: [llvm-commits] CVS: llvm/runtime/GCCLibraries/crtend/Exception.cpp Exception.h Makefile README.txt SJLJ-Exception.cpp SJLJ-Exception.h comp_genericeh.lst comp_main.lst comp_sjljeh.lst crtend.c Message-ID: <200611170333.kAH3X5QV015193@zion.cs.uiuc.edu> Changes in directory llvm/runtime/GCCLibraries/crtend: Exception.cpp updated: 1.3 -> 1.4 Exception.h updated: 1.11 -> 1.12 Makefile updated: 1.35 -> 1.36 README.txt updated: 1.3 -> 1.4 SJLJ-Exception.cpp updated: 1.6 -> 1.7 SJLJ-Exception.h updated: 1.6 -> 1.7 comp_genericeh.lst updated: 1.2 -> 1.3 comp_main.lst updated: 1.2 -> 1.3 comp_sjljeh.lst updated: 1.2 -> 1.3 crtend.c updated: 1.7 -> 1.8 --- Log message: Undo removal of the runtime libraries. While this may have been a bit premature, these libraries will be going away for the 2.0 release. Other arrangements for profiling, gc, etc. should be made in the next few months. --- Diffs of the changes: (+484 -0) Exception.cpp | 54 +++++++++++++++++++ Exception.h | 71 +++++++++++++++++++++++++ Makefile | 83 ++++++++++++++++++++++++++++++ README.txt | 15 +++++ SJLJ-Exception.cpp | 146 +++++++++++++++++++++++++++++++++++++++++++++++++++++ SJLJ-Exception.h | 80 +++++++++++++++++++++++++++++ comp_genericeh.lst | 9 +++ comp_main.lst | 3 + comp_sjljeh.lst | 7 ++ crtend.c | 16 +++++ 10 files changed, 484 insertions(+) Index: llvm/runtime/GCCLibraries/crtend/Exception.cpp diff -u /dev/null llvm/runtime/GCCLibraries/crtend/Exception.cpp:1.4 --- /dev/null Thu Nov 16 21:32:43 2006 +++ llvm/runtime/GCCLibraries/crtend/Exception.cpp Thu Nov 16 21:32:33 2006 @@ -0,0 +1,54 @@ +//===- Exception.cpp - Generic language-independent exceptions ------------===// +// +// This file defines the the shared data structures used by all language +// specific exception handling runtime libraries. +// +//===----------------------------------------------------------------------===// + +#include "Exception.h" + +// Thread local state for exception handling. FIXME: This should really be made +// thread-local! + +// UncaughtExceptionStack - The stack of exceptions currently being thrown. +static llvm_exception *UncaughtExceptionStack = 0; + +// __llvm_eh_has_uncaught_exception - This is used to implement +// std::uncaught_exception. +// +bool __llvm_eh_has_uncaught_exception() throw() { + return UncaughtExceptionStack != 0; +} + +// __llvm_eh_current_uncaught_exception - This function checks to see if the +// current uncaught exception is of the specified language type. If so, it +// returns a pointer to the exception area data. +// +void *__llvm_eh_current_uncaught_exception_type(unsigned HandlerType) throw() { + if (UncaughtExceptionStack->ExceptionType == HandlerType) + return UncaughtExceptionStack+1; + return 0; +} + +// __llvm_eh_add_uncaught_exception - This adds the specified exception to the +// top of the uncaught exception stack. The exception should not already be on +// the stack! +void __llvm_eh_add_uncaught_exception(llvm_exception *E) throw() { + E->Next = UncaughtExceptionStack; + UncaughtExceptionStack = E; +} + + +// __llvm_eh_get_uncaught_exception - Returns the current uncaught exception. +// There must be an uncaught exception for this to work! +llvm_exception *__llvm_eh_get_uncaught_exception() throw() { + return UncaughtExceptionStack; +} + +// __llvm_eh_pop_from_uncaught_stack - Remove the current uncaught exception +// from the top of the stack. +llvm_exception *__llvm_eh_pop_from_uncaught_stack() throw() { + llvm_exception *E = __llvm_eh_get_uncaught_exception(); + UncaughtExceptionStack = E->Next; + return E; +} Index: llvm/runtime/GCCLibraries/crtend/Exception.h diff -u /dev/null llvm/runtime/GCCLibraries/crtend/Exception.h:1.12 --- /dev/null Thu Nov 16 21:33:05 2006 +++ llvm/runtime/GCCLibraries/crtend/Exception.h Thu Nov 16 21:32:33 2006 @@ -0,0 +1,71 @@ +//===- Exception.h - Generic language-independent exceptions ----*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines the the shared data structures used by all language +// specific exception handling runtime libraries. +// +// NOTE NOTE NOTE: A copy of this file lives in llvmgcc/libstdc++-v3/libsupc++/ +// Any modifications to this file must keep it in sync! +// +//===----------------------------------------------------------------------===// + +#ifndef EXCEPTION_H +#define EXCEPTION_H + +struct llvm_exception { + // ExceptionDestructor - This call-back function is used to destroy the + // current exception, without requiring the caller to know what the concrete + // exception type is. + // + void (*ExceptionDestructor)(llvm_exception *); + + // ExceptionType - This field identifies what runtime library this exception + // came from. Currently defined values are: + // 0 - Error + // 1 - longjmp exception (see longjmp-exception.c) + // 2 - C++ exception (see c++-exception.c) + // + unsigned ExceptionType; + + // Next - This points to the next exception in the current stack. + llvm_exception *Next; + + // HandlerCount - This is a count of the number of handlers which have + // currently caught this exception. If the handler is caught and this number + // falls to zero, the exception is destroyed. + // + unsigned HandlerCount; + + // isRethrown - This field is set on an exception if it has been 'throw;'n. + // This is needed because the exception might exit through a number of the + // end_catch statements matching the number of begin_catch statements that + // have been processed. When this happens, the exception should become + // uncaught, not dead. + // + int isRethrown; +}; + +enum { + ErrorException = 0, + SJLJException = 1, + CXXException = 2 +}; + +// Language independent exception handling API... +// +extern "C" { + bool __llvm_eh_has_uncaught_exception() throw(); + void *__llvm_eh_current_uncaught_exception_type(unsigned HandlerType) throw(); + void __llvm_eh_add_uncaught_exception(llvm_exception *E) throw(); + + llvm_exception *__llvm_eh_get_uncaught_exception() throw(); + llvm_exception *__llvm_eh_pop_from_uncaught_stack() throw(); +} + +#endif Index: llvm/runtime/GCCLibraries/crtend/Makefile diff -u /dev/null llvm/runtime/GCCLibraries/crtend/Makefile:1.36 --- /dev/null Thu Nov 16 21:33:05 2006 +++ llvm/runtime/GCCLibraries/crtend/Makefile Thu Nov 16 21:32:33 2006 @@ -0,0 +1,83 @@ +##===- runtime/GCCLibraries/crtend/Makefile ----------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file was developed by the LLVM research group and is distributed under +# the University of Illinois Open Source License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## +# +# This directory contains the C and C++ runtime libraries for the LLVM GCC +# front-ends. See the README.txt file for more details. +# +# Since this archive has strange requirements, we use some custom rules for +# building it. +# +##===----------------------------------------------------------------------===## + +LEVEL = ../../.. +DONT_BUILD_RELINKED = 1 +LIBRARYNAME = crtend +BYTECODE_DESTINATION = $(CFERuntimeLibDir) + +MainSrc := crtend.c +GenericEHSrc := Exception.cpp +SJLJEHSrc := SJLJ-Exception.cpp + +EXTRA_DIST := $(MainSrc) $(GenericEHSrc) $(SJLJEHSrc) \ + comp_main.lst comp_genericeh.lst comp_sjljeh.lst + +include $(LEVEL)/Makefile.common + +MainObj := $(ObjDir)/crtend.bc +GenericEHObj := $(ObjDir)/Exception.bc +SJLJEHObj := $(ObjDir)/SJLJ-Exception.bc + +# __main and ctor/dtor support component +$(ObjDir)/comp_main.bc: $(MainObj) + $(Echo) Linking $(notdir $@) component... + $(Verb) $(GCCLD) -link-as-library \ + -internalize-public-api-file=$(PROJ_SRC_DIR)/comp_main.lst \ + $(MainObj) -o $@ + +# Generic exception handling support runtime. +$(ObjDir)/comp_genericeh.bc: $(GenericEHObj) + $(Echo) Linking $(notdir $@) component... + $(Verb) $(GCCLD) -link-as-library \ + -internalize-public-api-file=$(PROJ_SRC_DIR)/comp_genericeh.lst \ + $(GenericEHObj) -o $@ + +# setjmp/longjmp exception handling support runtime. +$(ObjDir)/comp_sjljeh.bc: $(SJLJEHObj) + $(Echo) Linking $(notdir $@) component... + $(Verb) $(GCCLD) -link-as-library \ + -internalize-public-api-file=$(PROJ_SRC_DIR)/comp_sjljeh.lst \ + $(SJLJEHObj) -o $@ + +SYMBOLHACKEDOBJS := $(ObjDir)/comp_main.bc $(ObjDir)/comp_genericeh.bc \ + $(ObjDir)/comp_sjljeh.bc + +all-local:: $(LibName.BCA) + +ifdef BYTECODE_DESTINATION +BytecodeDestDir := $(BYTECODE_DESTINATION) +else +BytecodeDestDir := $(PROJ_libdir) +endif + +DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a +install-bytecode-local:: $(DestBytecodeLib) +install-local:: $(DestBytecodeLib) + +$(LibName.BCA): $(SYMBOLHACKEDOBJS) $(LibDir)/.dir $(LLVMToolDir)/llvm-ar + $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) + $(Verb) $(RM) -f $@ + $(Verb) $(LArchive) $@ $(SYMBOLHACKEDOBJS) + +$(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA) + $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib) + $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib) + +uninstall-local:: + $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib) + -$(Verb) $(RM) -f $(DestBytecodeLib) Index: llvm/runtime/GCCLibraries/crtend/README.txt diff -u /dev/null llvm/runtime/GCCLibraries/crtend/README.txt:1.4 --- /dev/null Thu Nov 16 21:33:05 2006 +++ llvm/runtime/GCCLibraries/crtend/README.txt Thu Nov 16 21:32:33 2006 @@ -0,0 +1,15 @@ +This directory contains the C and C++ runtime libraries for the LLVM GCC +front-ends. It is composed of four distinct pieces: + +1. __main: now dead, but provided for compatibility. + +2. Generic EH support routines. This is used by C/C++ programs that use + setjmp/longjmp, and by C++ programs that make use of exceptions. + +3. setjmp/longjmp EH support. This is used by C/C++ programs that call SJLJ. + +4. C++ exception handling runtime support. + +These four components are compiled together into an archive file, so that +applications using a subset of the four do not pull in unnecessary code and +dependencies. Index: llvm/runtime/GCCLibraries/crtend/SJLJ-Exception.cpp diff -u /dev/null llvm/runtime/GCCLibraries/crtend/SJLJ-Exception.cpp:1.7 --- /dev/null Thu Nov 16 21:33:05 2006 +++ llvm/runtime/GCCLibraries/crtend/SJLJ-Exception.cpp Thu Nov 16 21:32:33 2006 @@ -0,0 +1,146 @@ +//===- SJLJ-Exception.cpp - SetJmp/LongJmp Exception Handling -------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements the API used by the Setjmp/Longjmp exception handling +// runtime library. +// +//===----------------------------------------------------------------------===// + +#include "SJLJ-Exception.h" +#include +#include + +// Assert should only be used for debugging the runtime library. Enabling it in +// CVS will break some platforms! +#undef assert +#define assert(X) + +// get_sjlj_exception - Adjust the llvm_exception pointer to be an appropriate +// llvm_sjlj_exception pointer. +inline llvm_sjlj_exception *get_sjlj_exception(llvm_exception *E) { + assert(E->ExceptionType == SJLJException); + return (llvm_sjlj_exception*)(E+1) - 1; +} + +// SetJmpMapEntry - One entry in a linked list of setjmps for the current +// function. +struct SetJmpMapEntry { + void *JmpBuf; + unsigned SetJmpID; + SetJmpMapEntry *Next; +}; + +// SJLJDestructor - This function is used to free the exception when +// language-indent code needs to destroy the exception without knowing exactly +// what type it is. +static void SJLJDestructor(llvm_exception *E) { + free(get_sjlj_exception(E)); +} + + +// __llvm_sjljeh_throw_longjmp - This function creates the longjmp exception and +// returns. It takes care of mapping the longjmp value from 0 -> 1 as +// appropriate. The caller should immediately call llvm.unwind after this +// function call. +void __llvm_sjljeh_throw_longjmp(void *JmpBuffer, int Val) throw() { + llvm_sjlj_exception *E = + (llvm_sjlj_exception *)malloc(sizeof(llvm_sjlj_exception)); + E->BaseException.ExceptionDestructor = SJLJDestructor; + E->BaseException.ExceptionType = SJLJException; + E->BaseException.HandlerCount = 0; + E->BaseException.isRethrown = 0; + E->JmpBuffer = JmpBuffer; + E->LongJmpValue = Val ? Val : 1; + + __llvm_eh_add_uncaught_exception(&E->BaseException); +} + +// __llvm_sjljeh_init_setjmpmap - This funciton initializes the pointer provided +// to an empty setjmp map, and should be called on entry to a function which +// calls setjmp. +void __llvm_sjljeh_init_setjmpmap(void **SetJmpMap) throw() { + *SetJmpMap = 0; +} + +// __llvm_sjljeh_destroy_setjmpmap - This function frees all memory associated +// with the specified setjmpmap structure. It should be called on all exits +// (returns or unwinds) from the function which calls ...init_setjmpmap. +void __llvm_sjljeh_destroy_setjmpmap(void **SetJmpMap) throw() { + SetJmpMapEntry *Next; + for (SetJmpMapEntry *SJE = *(SetJmpMapEntry**)SetJmpMap; SJE; SJE = Next) { + Next = SJE->Next; + free(SJE); + } +} + +// __llvm_sjljeh_add_setjmp_to_map - This function adds or updates an entry to +// the map, to indicate which setjmp should be returned to if a longjmp happens. +void __llvm_sjljeh_add_setjmp_to_map(void **SetJmpMap, void *JmpBuf, + unsigned SetJmpID) throw() { + SetJmpMapEntry **SJE = (SetJmpMapEntry**)SetJmpMap; + + // Scan for a pre-existing entry... + for (; *SJE; SJE = &(*SJE)->Next) + if ((*SJE)->JmpBuf == JmpBuf) { + (*SJE)->SetJmpID = SetJmpID; + return; + } + + // No prexisting entry found, append to the end of the list... + SetJmpMapEntry *New = (SetJmpMapEntry *)malloc(sizeof(SetJmpMapEntry)); + *SJE = New; + New->JmpBuf = JmpBuf; + New->SetJmpID = SetJmpID; + New->Next = 0; +} + +// __llvm_sjljeh_is_longjmp_exception - This function returns true if the +// current uncaught exception is a longjmp exception. This is the first step of +// catching a sjlj exception. +bool __llvm_sjljeh_is_longjmp_exception() throw() { + return __llvm_eh_current_uncaught_exception_type(SJLJException) != 0; +} + +// __llvm_sjljeh_get_longjmp_value - This function returns the value that the +// setjmp call should "return". This requires that the current uncaught +// exception be a sjlj exception, though it does not require the exception to be +// caught by this function. +int __llvm_sjljeh_get_longjmp_value() throw() { + llvm_sjlj_exception *E = + get_sjlj_exception(__llvm_eh_get_uncaught_exception()); + return E->LongJmpValue; +} + +// __llvm_sjljeh_try_catching_longjmp_exception - This function checks to see if +// the current uncaught longjmp exception matches any of the setjmps collected +// in the setjmpmap structure. If so, it catches and destroys the exception, +// returning the index of the setjmp which caught the exception. If not, it +// leaves the exception uncaught and returns a value of ~0. +unsigned __llvm_sjljeh_try_catching_longjmp_exception(void **SetJmpMap) throw(){ + llvm_sjlj_exception *E = + get_sjlj_exception(__llvm_eh_get_uncaught_exception()); + + // Scan for a matching entry in the SetJmpMap... + SetJmpMapEntry *SJE = *(SetJmpMapEntry**)SetJmpMap; + for (; SJE; SJE = SJE->Next) + if (SJE->JmpBuf == E->JmpBuffer) { + // "Catch" and destroy the exception... + __llvm_eh_pop_from_uncaught_stack(); + + // We know it's a longjmp exception, so we can just free it instead of + // calling the destructor. + free(E); + + // Return the setjmp ID which we should branch to... + return SJE->SetJmpID; + } + + // No setjmp in this function catches the exception! + return ~0; +} Index: llvm/runtime/GCCLibraries/crtend/SJLJ-Exception.h diff -u /dev/null llvm/runtime/GCCLibraries/crtend/SJLJ-Exception.h:1.7 --- /dev/null Thu Nov 16 21:33:05 2006 +++ llvm/runtime/GCCLibraries/crtend/SJLJ-Exception.h Thu Nov 16 21:32:33 2006 @@ -0,0 +1,80 @@ +//===- SJLJ-Exception.h - SetJmp/LongJmp Exception Handling -----*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines the data structures and API used by the Setjmp/Longjmp +// exception handling runtime library. +// +//===----------------------------------------------------------------------===// + +#ifndef SJLJ_EXCEPTION_H +#define SJLJ_EXCEPTION_H + +#include "Exception.h" + +struct llvm_sjlj_exception { + // JmpBuffer - This is the buffer which was longjmp'd with. + // + void *JmpBuffer; + + // LongJmpValue - The value passed into longjmp, which the corresponding + // setjmp should return. Note that this value will never be equal to 0. + // + int LongJmpValue; + + // BaseException - The language independent portion of the exception state. + // This is at the end of the record so that we can add additional members to + // this structure without breaking binary compatibility. + // + llvm_exception BaseException; +}; + +extern "C" { + // __llvm_sjljeh_throw_longjmp - This function creates the longjmp exception + // and returns. It takes care of mapping the longjmp value from 0 -> 1 as + // appropriate. The caller should immediately call llvm.unwind after this + // function call. + void __llvm_sjljeh_throw_longjmp(void *JmpBuffer, int Val) throw(); + + // __llvm_sjljeh_init_setjmpmap - This funciton initializes the pointer + // provided to an empty setjmp map, and should be called on entry to a + // function which calls setjmp. + void __llvm_sjljeh_init_setjmpmap(void **SetJmpMap) throw(); + + // __llvm_sjljeh_destroy_setjmpmap - This function frees all memory associated + // with the specified setjmpmap structure. It should be called on all exits + // (returns or unwinds) from the function which calls ...init_setjmpmap. + void __llvm_sjljeh_destroy_setjmpmap(void **SetJmpMap) throw(); + + // __llvm_sjljeh_add_setjmp_to_map - This function adds or updates an entry to + // the map, to indicate which setjmp should be returned to if a longjmp + // happens. + void __llvm_sjljeh_add_setjmp_to_map(void **SetJmpMap, void *JmpBuf, + unsigned SetJmpID) throw(); + + // __llvm_sjljeh_is_longjmp_exception - This function returns true if the + // current uncaught exception is a longjmp exception. This is the first step + // of catching a sjlj exception. + bool __llvm_sjljeh_is_longjmp_exception() throw(); + + // __llvm_sjljeh_get_longjmp_value - This function returns the value that the + // setjmp call should "return". This requires that the current uncaught + // exception be a sjlj exception, though it does not require the exception to + // be caught by this function. + int __llvm_sjljeh_get_longjmp_value() throw(); + + // __llvm_sjljeh_try_catching_longjmp_exception - This function checks to see + // if the current uncaught longjmp exception matches any of the setjmps + // collected in the setjmpmap structure. If so, it catches and destroys the + // exception, returning the index of the setjmp which caught the exception. + // If not, it leaves the exception uncaught and returns a value of ~0. + unsigned __llvm_sjljeh_try_catching_longjmp_exception(void **SetJmpMap) + throw(); +} + +#endif Index: llvm/runtime/GCCLibraries/crtend/comp_genericeh.lst diff -u /dev/null llvm/runtime/GCCLibraries/crtend/comp_genericeh.lst:1.3 --- /dev/null Thu Nov 16 21:33:05 2006 +++ llvm/runtime/GCCLibraries/crtend/comp_genericeh.lst Thu Nov 16 21:32:33 2006 @@ -0,0 +1,9 @@ +__main +llvm.global_ctors +llvm.global_dtors + +__llvm_eh_has_uncaught_exception +__llvm_eh_current_uncaught_exception_type +__llvm_eh_add_uncaught_exception +__llvm_eh_get_uncaught_exception +__llvm_eh_pop_from_uncaught_stack Index: llvm/runtime/GCCLibraries/crtend/comp_main.lst diff -u /dev/null llvm/runtime/GCCLibraries/crtend/comp_main.lst:1.3 --- /dev/null Thu Nov 16 21:33:05 2006 +++ llvm/runtime/GCCLibraries/crtend/comp_main.lst Thu Nov 16 21:32:33 2006 @@ -0,0 +1,3 @@ +__main +llvm.global_ctors +llvm.global_dtors Index: llvm/runtime/GCCLibraries/crtend/comp_sjljeh.lst diff -u /dev/null llvm/runtime/GCCLibraries/crtend/comp_sjljeh.lst:1.3 --- /dev/null Thu Nov 16 21:33:05 2006 +++ llvm/runtime/GCCLibraries/crtend/comp_sjljeh.lst Thu Nov 16 21:32:33 2006 @@ -0,0 +1,7 @@ +__llvm_sjljeh_throw_longjmp +__llvm_sjljeh_init_setjmpmap +__llvm_sjljeh_destroy_setjmpmap +__llvm_sjljeh_add_setjmp_to_map +__llvm_sjljeh_is_longjmp_exception +__llvm_sjljeh_get_longjmp_value +__llvm_sjljeh_try_catching_longjmp_exception Index: llvm/runtime/GCCLibraries/crtend/crtend.c diff -u /dev/null llvm/runtime/GCCLibraries/crtend/crtend.c:1.8 --- /dev/null Thu Nov 16 21:33:05 2006 +++ llvm/runtime/GCCLibraries/crtend/crtend.c Thu Nov 16 21:32:33 2006 @@ -0,0 +1,16 @@ +/*===- crtend.c - Initialization code for programs ------------------------===*\ + * + * The LLVM Compiler Infrastructure + * + * This file was developed by the LLVM research group and is distributed under + * the University of Illinois Open Source License. See LICENSE.TXT for details. + * + *===----------------------------------------------------------------------===* + * + * This file defines the __main function, which we preserve for backwards + * compatibility. + * +\*===----------------------------------------------------------------------===*/ + +void __main(void) { +} From reid at x10sys.com Thu Nov 16 21:33:06 2006 From: reid at x10sys.com (Reid Spencer) Date: Thu, 16 Nov 2006 21:33:06 -0600 Subject: [llvm-commits] CVS: llvm/Makefile Makefile.config.in Makefile.rules configure Message-ID: <200611170333.kAH3X6RH015216@zion.cs.uiuc.edu> Changes in directory llvm: Makefile updated: 1.66 -> 1.67 Makefile.config.in updated: 1.67 -> 1.68 Makefile.rules updated: 1.411 -> 1.412 configure updated: 1.256 -> 1.257 --- Log message: Undo removal of the runtime libraries. While this may have been a bit premature, these libraries will be going away for the 2.0 release. Other arrangements for profiling, gc, etc. should be made in the next few months. --- Diffs of the changes: (+80 -34) Makefile | 13 +++++-- Makefile.config.in | 5 +++ Makefile.rules | 8 ++++ configure | 88 ++++++++++++++++++++++++++++++++++------------------- 4 files changed, 80 insertions(+), 34 deletions(-) Index: llvm/Makefile diff -u llvm/Makefile:1.66 llvm/Makefile:1.67 --- llvm/Makefile:1.66 Thu Nov 16 17:17:26 2006 +++ llvm/Makefile Thu Nov 16 21:32:33 2006 @@ -15,23 +15,28 @@ # 3. Build VMCore, which builds the Intrinsics.inc file used by libs. # 4. Build libs, which are needed by llvm-config. # 5. Build llvm-config, which determines inter-lib dependencies for tools. -# 6. Build tools, docs. +# 6. Build tools, runtime, docs. # DIRS := lib/System lib/Support utils lib/VMCore lib tools/llvm-config \ - tools docs + tools runtime docs OPTIONAL_DIRS := examples projects EXTRA_DIST := test llvm.spec include win32 Xcode include $(LEVEL)/Makefile.config +# llvm-gcc4 doesn't need runtime libs. +ifeq ($(LLVMGCC_MAJVERS),4) + DIRS := $(filter-out runtime, $(DIRS)) +endif + ifeq ($(MAKECMDGOALS),libs-only) - DIRS := $(filter-out tools docs, $(DIRS)) + DIRS := $(filter-out tools runtime docs, $(DIRS)) OPTIONAL_DIRS := endif ifeq ($(MAKECMDGOALS),tools-only) - DIRS := $(filter-out docs, $(DIRS)) + DIRS := $(filter-out runtime docs, $(DIRS)) OPTIONAL_DIRS := endif Index: llvm/Makefile.config.in diff -u llvm/Makefile.config.in:1.67 llvm/Makefile.config.in:1.68 --- llvm/Makefile.config.in:1.67 Thu Nov 16 17:17:26 2006 +++ llvm/Makefile.config.in Thu Nov 16 21:32:33 2006 @@ -207,6 +207,11 @@ #DISABLE_ASSERTIONS = 1 @DISABLE_ASSERTIONS@ +# When DEBUG_RUNTIME is enabled, the runtime libraries will retain debug +# symbols. +#DEBUG_RUNTIME = 1 + at DEBUG_RUNTIME@ + # When ENABLE_PROFILING is enabled, the llvm source base is built with profile # information to allow gprof to be used to get execution frequencies. #ENABLE_PROFILING = 1 Index: llvm/Makefile.rules diff -u llvm/Makefile.rules:1.411 llvm/Makefile.rules:1.412 --- llvm/Makefile.rules:1.411 Thu Nov 16 17:17:26 2006 +++ llvm/Makefile.rules Thu Nov 16 21:32:33 2006 @@ -1099,10 +1099,18 @@ $(Echo) "Compiling $*.c to asm for $(BuildMode) build" $(PIC_FLAG) $(MAYBE_PIC_Compile.C) $< -o $@ -S + # make the C and C++ compilers strip debug info out of bytecode libraries. +ifdef DEBUG_RUNTIME +$(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(GCCAS) + $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)" + $(Verb) $(GCCAS) $< -o $@ +else $(ObjectsBC): $(ObjDir)/%.bc: $(ObjDir)/%.ll $(GCCAS) $(Echo) "Compiling $*.ll to $*.bc for $(BuildMode) build (bytecode)" $(Verb) $(GCCAS) -strip-debug $< -o $@ +endif + #--------------------------------------------------------- # Provide rule to build .bc files from .ll sources, Index: llvm/configure diff -u llvm/configure:1.256 llvm/configure:1.257 --- llvm/configure:1.256 Thu Nov 16 17:17:26 2006 +++ llvm/configure Thu Nov 16 21:32:33 2006 @@ -830,6 +830,7 @@ CVSBUILD ENABLE_OPTIMIZED DISABLE_ASSERTIONS +DEBUG_RUNTIME JIT TARGET_HAS_JIT ENABLE_DOXYGEN @@ -1519,6 +1520,7 @@ --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-optimized --enable-assertions + --enable-debug-runtime --enable-jit Enable Just In Time Compiling (default is YES) --enable-doxygen Build doxygen documentation (default is NO) --enable-threads Use threads if available (default is YES) @@ -4561,6 +4563,21 @@ fi +# Check whether --enable-debug-runtime was given. +if test "${enable_debug_runtime+set}" = set; then + enableval=$enable_debug_runtime; +else + enableval=no +fi + +if test ${enableval} = "no" ; then + DEBUG_RUNTIME= + +else + DEBUG_RUNTIME=DEBUG_RUNTIME=1 + +fi + # Check whether --enable-jit was given. if test "${enable_jit+set}" = set; then enableval=$enable_jit; @@ -10281,7 +10298,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext + echo '#line 12445 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -14143,11 +14160,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14146: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14163: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:14150: \$? = $ac_status" >&5 + echo "$as_me:14167: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -14411,11 +14428,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14414: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14431: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:14418: \$? = $ac_status" >&5 + echo "$as_me:14435: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -14515,11 +14532,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14518: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14535: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:14522: \$? = $ac_status" >&5 + echo "$as_me:14539: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -16967,7 +16984,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:19455: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:19442: \$? = $ac_status" >&5 + echo "$as_me:19459: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -19539,11 +19556,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:19542: $lt_compile\"" >&5) + (eval echo "\"\$as_me:19559: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:19546: \$? = $ac_status" >&5 + echo "$as_me:19563: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -21109,11 +21126,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:21112: $lt_compile\"" >&5) + (eval echo "\"\$as_me:21129: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:21116: \$? = $ac_status" >&5 + echo "$as_me:21133: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -21213,11 +21230,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:21216: $lt_compile\"" >&5) + (eval echo "\"\$as_me:21233: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:21220: \$? = $ac_status" >&5 + echo "$as_me:21237: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -23448,11 +23465,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:23451: $lt_compile\"" >&5) + (eval echo "\"\$as_me:23468: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:23455: \$? = $ac_status" >&5 + echo "$as_me:23472: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -23716,11 +23733,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:23719: $lt_compile\"" >&5) + (eval echo "\"\$as_me:23736: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:23723: \$? = $ac_status" >&5 + echo "$as_me:23740: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -23820,11 +23837,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:23823: $lt_compile\"" >&5) + (eval echo "\"\$as_me:23840: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:23827: \$? = $ac_status" >&5 + echo "$as_me:23844: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -33414,6 +33431,9 @@ ac_config_commands="$ac_config_commands lib/Makefile" +ac_config_commands="$ac_config_commands runtime/Makefile" + + ac_config_commands="$ac_config_commands test/Makefile" @@ -34007,6 +34027,7 @@ "Makefile.common") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile.common" ;; "examples/Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS examples/Makefile" ;; "lib/Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS lib/Makefile" ;; + "runtime/Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS runtime/Makefile" ;; "test/Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS test/Makefile" ;; "test/Makefile.tests") CONFIG_COMMANDS="$CONFIG_COMMANDS test/Makefile.tests" ;; "tools/Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS tools/Makefile" ;; @@ -34148,6 +34169,7 @@ CVSBUILD!$CVSBUILD$ac_delim ENABLE_OPTIMIZED!$ENABLE_OPTIMIZED$ac_delim DISABLE_ASSERTIONS!$DISABLE_ASSERTIONS$ac_delim +DEBUG_RUNTIME!$DEBUG_RUNTIME$ac_delim JIT!$JIT$ac_delim TARGET_HAS_JIT!$TARGET_HAS_JIT$ac_delim ENABLE_DOXYGEN!$ENABLE_DOXYGEN$ac_delim @@ -34170,7 +34192,6 @@ LN_S!$LN_S$ac_delim CMP!$CMP$ac_delim CP!$CP$ac_delim -DATE!$DATE$ac_delim _ACEOF if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then @@ -34212,6 +34233,7 @@ ac_delim='%!_!# ' for ac_last_try in false false false false false :; do cat >conf$$subs.sed <<_ACEOF +DATE!$DATE$ac_delim FIND!$FIND$ac_delim MKDIR!$MKDIR$ac_delim MV!$MV$ac_delim @@ -34277,7 +34299,7 @@ LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 63; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 64; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 @@ -34688,6 +34710,8 @@ ${SHELL} ${llvm_src}/autoconf/install-sh -c ${srcdir}/examples/Makefile examples/Makefile ;; "lib/Makefile":C) ${llvm_src}/autoconf/mkinstalldirs `dirname lib/Makefile` ${SHELL} ${llvm_src}/autoconf/install-sh -c ${srcdir}/lib/Makefile lib/Makefile ;; + "runtime/Makefile":C) ${llvm_src}/autoconf/mkinstalldirs `dirname runtime/Makefile` + ${SHELL} ${llvm_src}/autoconf/install-sh -c ${srcdir}/runtime/Makefile runtime/Makefile ;; "test/Makefile":C) ${llvm_src}/autoconf/mkinstalldirs `dirname test/Makefile` ${SHELL} ${llvm_src}/autoconf/install-sh -c ${srcdir}/test/Makefile test/Makefile ;; "test/Makefile.tests":C) ${llvm_src}/autoconf/mkinstalldirs `dirname test/Makefile.tests` @@ -34909,8 +34933,12 @@ if test "$llvm_cv_llvmgcc_sanity" = "no" ; then { echo "$as_me:$LINENO: WARNING: ***** llvm-gcc/llvm-g++ was not found, or does not appear to be " >&5 echo "$as_me: WARNING: ***** llvm-gcc/llvm-g++ was not found, or does not appear to be " >&2;} - { echo "$as_me:$LINENO: WARNING: ***** working. Please make sure you have llvm-gcc and llvm-g++ " >&5 -echo "$as_me: WARNING: ***** working. Please make sure you have llvm-gcc and llvm-g++ " >&2;} - { echo "$as_me:$LINENO: WARNING: ***** in your path before configuring LLVM." >&5 -echo "$as_me: WARNING: ***** in your path before configuring LLVM." >&2;} + { echo "$as_me:$LINENO: WARNING: ***** working. Please make sure you have llvm-gcc and llvm-g++ in" >&5 +echo "$as_me: WARNING: ***** working. Please make sure you have llvm-gcc and llvm-g++ in" >&2;} + { echo "$as_me:$LINENO: WARNING: ***** your path before configuring LLVM. The runtime libraries" >&5 +echo "$as_me: WARNING: ***** your path before configuring LLVM. The runtime libraries" >&2;} + { echo "$as_me:$LINENO: WARNING: ***** (llvm/runtime) will not be built but you should be able to" >&5 +echo "$as_me: WARNING: ***** (llvm/runtime) will not be built but you should be able to" >&2;} + { echo "$as_me:$LINENO: WARNING: ***** build the llvm tools." >&5 +echo "$as_me: WARNING: ***** build the llvm tools." >&2;} fi From reid at x10sys.com Thu Nov 16 21:33:09 2006 From: reid at x10sys.com (Reid Spencer) Date: Thu, 16 Nov 2006 21:33:09 -0600 Subject: [llvm-commits] CVS: llvm/runtime/GCCLibraries/libm/Makefile temp.c Message-ID: <200611170333.kAH3X9Ij015230@zion.cs.uiuc.edu> Changes in directory llvm/runtime/GCCLibraries/libm: Makefile updated: 1.11 -> 1.12 temp.c updated: 1.3 -> 1.4 --- Log message: Undo removal of the runtime libraries. While this may have been a bit premature, these libraries will be going away for the 2.0 release. Other arrangements for profiling, gc, etc. should be made in the next few months. --- Diffs of the changes: (+17 -0) Makefile | 16 ++++++++++++++++ temp.c | 1 + 2 files changed, 17 insertions(+) Index: llvm/runtime/GCCLibraries/libm/Makefile diff -u /dev/null llvm/runtime/GCCLibraries/libm/Makefile:1.12 --- /dev/null Thu Nov 16 21:32:43 2006 +++ llvm/runtime/GCCLibraries/libm/Makefile Thu Nov 16 21:32:33 2006 @@ -0,0 +1,16 @@ +##===- runtime/GCCLibraries/libm/Makefile ------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file was developed by the LLVM research group and is distributed under +# the University of Illinois Open Source License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +LEVEL = ../../.. +BYTECODE_LIBRARY = 1 +DONT_BUILD_RELINKED = 1 +LIBRARYNAME = m +BYTECODE_DESTINATION = $(CFERuntimeLibDir) + +include $(LEVEL)/Makefile.common Index: llvm/runtime/GCCLibraries/libm/temp.c diff -u /dev/null llvm/runtime/GCCLibraries/libm/temp.c:1.4 --- /dev/null Thu Nov 16 21:33:09 2006 +++ llvm/runtime/GCCLibraries/libm/temp.c Thu Nov 16 21:32:33 2006 @@ -0,0 +1 @@ +typedef int INTEGER; From reid at x10sys.com Thu Nov 16 21:33:05 2006 From: reid at x10sys.com (Reid Spencer) Date: Thu, 16 Nov 2006 21:33:05 -0600 Subject: [llvm-commits] CVS: llvm/runtime/Makefile README.txt Message-ID: <200611170333.kAH3X5iN015198@zion.cs.uiuc.edu> Changes in directory llvm/runtime: Makefile updated: 1.29 -> 1.30 README.txt updated: 1.3 -> 1.4 --- Log message: Undo removal of the runtime libraries. While this may have been a bit premature, these libraries will be going away for the 2.0 release. Other arrangements for profiling, gc, etc. should be made in the next few months. --- Diffs of the changes: (+47 -0) Makefile | 43 +++++++++++++++++++++++++++++++++++++++++++ README.txt | 4 ++++ 2 files changed, 47 insertions(+) Index: llvm/runtime/Makefile diff -u /dev/null llvm/runtime/Makefile:1.30 --- /dev/null Thu Nov 16 21:32:43 2006 +++ llvm/runtime/Makefile Thu Nov 16 21:32:33 2006 @@ -0,0 +1,43 @@ +##===- runtime/Makefile ------------------------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file was developed by the LLVM research group and is distributed under +# the University of Illinois Open Source License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +LEVEL = .. +include $(LEVEL)/Makefile.config + +ifeq ($(LLVMGCC_MAJVERS),4) +PARALLEL_DIRS := +install all:: + $(Echo) "Warning: These runtime libraries only need to be built with" + $(Echo) "Warning: llvm-gcc version 3. They are automatically included" + $(Echo) "Warning: with llvm-gcc version 4 and beyond" +else +ifneq ($(wildcard $(LLVMGCC)),) +PARALLEL_DIRS := GCCLibraries libdummy libprofile libtrace GC +else +PARALLEL_DIRS := +install all :: + @echo '********' Warning: Your LLVMGCCDIR is set incorrectly. Check + @echo '********' Warning: llvm/Makefile.config to make sure it matches + @echo '********' Warning: the directory where the C front-end is + @echo '********' Warning: installed,and re-run configure if it does not. +endif + +# Disable libprofile: a faulty libtool is generated by autoconf which breaks the +# build on Sparc +ifeq ($(ARCH), Sparc) +PARALLEL_DIRS := $(filter-out libprofile, $(PARALLEL_DIRS)) +endif +endif + +include $(LEVEL)/Makefile.common + +# Install target for libraries: Copy into $LLVMGCCDIR/bytecode-libs +# +install:: + Index: llvm/runtime/README.txt diff -u /dev/null llvm/runtime/README.txt:1.4 --- /dev/null Thu Nov 16 21:33:05 2006 +++ llvm/runtime/README.txt Thu Nov 16 21:32:33 2006 @@ -0,0 +1,4 @@ +This directory contains the various runtime libraries used by components of +the LLVM compiler. For example, the automatic pool allocation transformation +inserts calls to an external pool allocator library. This runtime library is +an example of the type of library that lives in these directories. From reid at x10sys.com Thu Nov 16 21:33:10 2006 From: reid at x10sys.com (Reid Spencer) Date: Thu, 16 Nov 2006 21:33:10 -0600 Subject: [llvm-commits] CVS: llvm/autoconf/configure.ac Message-ID: <200611170333.kAH3XAvF015296@zion.cs.uiuc.edu> Changes in directory llvm/autoconf: configure.ac updated: 1.251 -> 1.252 --- Log message: Undo removal of the runtime libraries. While this may have been a bit premature, these libraries will be going away for the 2.0 release. Other arrangements for profiling, gc, etc. should be made in the next few months. --- Diffs of the changes: (+14 -2) configure.ac | 16 ++++++++++++++-- 1 files changed, 14 insertions(+), 2 deletions(-) Index: llvm/autoconf/configure.ac diff -u llvm/autoconf/configure.ac:1.251 llvm/autoconf/configure.ac:1.252 --- llvm/autoconf/configure.ac:1.251 Thu Nov 16 17:17:26 2006 +++ llvm/autoconf/configure.ac Thu Nov 16 21:32:33 2006 @@ -268,6 +268,15 @@ AC_SUBST(DISABLE_ASSERTIONS,[[DISABLE_ASSERTIONS=1]]) fi +dnl --enable-debug-runtime : should runtime libraries have debug symbols? +AC_ARG_ENABLE(debug-runtime, + AS_HELP_STRING([--enable-debug-runtime,Build runtime libs with debug symbols (default is NO)]),,enableval=no) +if test ${enableval} = "no" ; then + AC_SUBST(DEBUG_RUNTIME,[[]]) +else + AC_SUBST(DEBUG_RUNTIME,[[DEBUG_RUNTIME=1]]) +fi + dnl --enable-jit: check whether they want to enable the jit AC_ARG_ENABLE(jit, AS_HELP_STRING(--enable-jit, @@ -811,6 +820,7 @@ AC_CONFIG_MAKEFILE(Makefile.common) AC_CONFIG_MAKEFILE(examples/Makefile) AC_CONFIG_MAKEFILE(lib/Makefile) +AC_CONFIG_MAKEFILE(runtime/Makefile) AC_CONFIG_MAKEFILE(test/Makefile) AC_CONFIG_MAKEFILE(test/Makefile.tests) AC_CONFIG_MAKEFILE(tools/Makefile) @@ -823,6 +833,8 @@ dnl Warn loudly if llvm-gcc was not obviously working if test "$llvm_cv_llvmgcc_sanity" = "no" ; then AC_MSG_WARN([***** llvm-gcc/llvm-g++ was not found, or does not appear to be ]) - AC_MSG_WARN([***** working. Please make sure you have llvm-gcc and llvm-g++ ]) - AC_MSG_WARN([***** in your path before configuring LLVM.]) + AC_MSG_WARN([***** working. Please make sure you have llvm-gcc and llvm-g++ in]) + AC_MSG_WARN([***** your path before configuring LLVM. The runtime libraries]) + AC_MSG_WARN([***** (llvm/runtime) will not be built but you should be able to]) + AC_MSG_WARN([***** build the llvm tools.]) fi From reid at x10sys.com Thu Nov 16 21:33:06 2006 From: reid at x10sys.com (Reid Spencer) Date: Thu, 16 Nov 2006 21:33:06 -0600 Subject: [llvm-commits] CVS: llvm/runtime/GCCLibraries/libgcc/Makefile eprintf.c Message-ID: <200611170333.kAH3X6AV015221@zion.cs.uiuc.edu> Changes in directory llvm/runtime/GCCLibraries/libgcc: Makefile updated: 1.9 -> 1.10 eprintf.c updated: 1.2 -> 1.3 --- Log message: Undo removal of the runtime libraries. While this may have been a bit premature, these libraries will be going away for the 2.0 release. Other arrangements for profiling, gc, etc. should be made in the next few months. --- Diffs of the changes: (+29 -0) Makefile | 16 ++++++++++++++++ eprintf.c | 13 +++++++++++++ 2 files changed, 29 insertions(+) Index: llvm/runtime/GCCLibraries/libgcc/Makefile diff -u /dev/null llvm/runtime/GCCLibraries/libgcc/Makefile:1.10 --- /dev/null Thu Nov 16 21:32:44 2006 +++ llvm/runtime/GCCLibraries/libgcc/Makefile Thu Nov 16 21:32:33 2006 @@ -0,0 +1,16 @@ +##===- runtime/GCCLibraries/libgcc/Makefile ----------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file was developed by the LLVM research group and is distributed under +# the University of Illinois Open Source License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +LEVEL = ../../.. +BYTECODE_LIBRARY = 1 +DONT_BUILD_RELINKED = 1 +LIBRARYNAME = gcc +BYTECODE_DESTINATION = $(CFERuntimeLibDir) + +include $(LEVEL)/Makefile.common Index: llvm/runtime/GCCLibraries/libgcc/eprintf.c diff -u /dev/null llvm/runtime/GCCLibraries/libgcc/eprintf.c:1.3 --- /dev/null Thu Nov 16 21:33:06 2006 +++ llvm/runtime/GCCLibraries/libgcc/eprintf.c Thu Nov 16 21:32:33 2006 @@ -0,0 +1,13 @@ +#include +void abort(void); + +/* This is used by the `assert' macro. */ +void +__eprintf (const char *string, const char *expression, + unsigned int line, const char *filename) +{ + fprintf (stderr, string, expression, line, filename); + fflush (stderr); + abort (); +} + From reid at x10sys.com Thu Nov 16 21:33:06 2006 From: reid at x10sys.com (Reid Spencer) Date: Thu, 16 Nov 2006 21:33:06 -0600 Subject: [llvm-commits] CVS: llvm/runtime/GCCLibraries/Makefile README.txt Message-ID: <200611170333.kAH3X6NP015211@zion.cs.uiuc.edu> Changes in directory llvm/runtime/GCCLibraries: Makefile updated: 1.9 -> 1.10 README.txt updated: 1.2 -> 1.3 --- Log message: Undo removal of the runtime libraries. While this may have been a bit premature, these libraries will be going away for the 2.0 release. Other arrangements for profiling, gc, etc. should be made in the next few months. --- Diffs of the changes: (+19 -0) Makefile | 12 ++++++++++++ README.txt | 7 +++++++ 2 files changed, 19 insertions(+) Index: llvm/runtime/GCCLibraries/Makefile diff -u /dev/null llvm/runtime/GCCLibraries/Makefile:1.10 --- /dev/null Thu Nov 16 21:32:43 2006 +++ llvm/runtime/GCCLibraries/Makefile Thu Nov 16 21:32:33 2006 @@ -0,0 +1,12 @@ +##===- runtime/GCCLibraries/Makefile -----------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file was developed by the LLVM research group and is distributed under +# the University of Illinois Open Source License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +LEVEL := ../.. +PARALLEL_DIRS := crtend libc libgcc libm +include $(LEVEL)/Makefile.common Index: llvm/runtime/GCCLibraries/README.txt diff -u /dev/null llvm/runtime/GCCLibraries/README.txt:1.3 --- /dev/null Thu Nov 16 21:33:06 2006 +++ llvm/runtime/GCCLibraries/README.txt Thu Nov 16 21:32:33 2006 @@ -0,0 +1,7 @@ +This directory contains libraries which are used when building the GCC +front-end. For the most part, these are just stub libraries, but some +of them contain actual code. + +In particular, the crtend library contains the runtime code to handle +static constructors and destructors for C and C++ programs. + From reid at x10sys.com Thu Nov 16 21:33:09 2006 From: reid at x10sys.com (Reid Spencer) Date: Thu, 16 Nov 2006 21:33:09 -0600 Subject: [llvm-commits] CVS: llvm/runtime/GC/GCInterface.h Makefile gc_exported_symbols.lst Message-ID: <200611170333.kAH3X9qa015270@zion.cs.uiuc.edu> Changes in directory llvm/runtime/GC: GCInterface.h updated: 1.5 -> 1.6 Makefile updated: 1.4 -> 1.5 gc_exported_symbols.lst updated: 1.2 -> 1.3 --- Log message: Undo removal of the runtime libraries. While this may have been a bit premature, these libraries will be going away for the 2.0 release. Other arrangements for profiling, gc, etc. should be made in the next few months. --- Diffs of the changes: (+74 -0) GCInterface.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 19 +++++++++++++++++++ gc_exported_symbols.lst | 7 +++++++ 3 files changed, 74 insertions(+) Index: llvm/runtime/GC/GCInterface.h diff -u /dev/null llvm/runtime/GC/GCInterface.h:1.6 --- /dev/null Thu Nov 16 21:32:43 2006 +++ llvm/runtime/GC/GCInterface.h Thu Nov 16 21:32:33 2006 @@ -0,0 +1,48 @@ +/*===-- GCInterface.h - Public interface exposed by garbage collectors ----===*\ +|* +|* The LLVM Compiler Infrastructure +|* +|* This file was developed by the LLVM research group and is distributed under +|* the University of Illinois Open Source License. See LICENSE.TXT for details. +|* +|*===----------------------------------------------------------------------===*| +|* +|* This file defines the common public interface that must be exposed by all +|* LLVM garbage collectors. +|* +\*===----------------------------------------------------------------------===*/ + +#ifndef GCINTERFACE_H +#define GCINTERFACE_H + +/* llvm_cg_walk_gcroots - This function is exposed by the LLVM code generator, + * and allows us to traverse the roots on the stack. + */ +void llvm_cg_walk_gcroots(void (*FP)(void **Root, void *Meta)); + + +/* llvm_gc_initialize - This function is called to initalize the garbage + * collector. + */ +void llvm_gc_initialize(unsigned InitialHeapSize); + +/* llvm_gc_allocate - This function allocates Size bytes from the heap and + * returns a pointer to it. + */ +void *llvm_gc_allocate(unsigned Size); + +/* llvm_gc_collect - This function forces a garbage collection cycle. + */ +void llvm_gc_collect(); + +/* llvm_gc_read - This function should be implemented to include any read + * barrier code that is needed by the garbage collector. + */ +void *llvm_gc_read(void *ObjPtr, void **FieldPtr); + +/* llvm_gc_write - This function should be implemented to include any write + * barrier code that is needed by the garbage collector. + */ +void llvm_gc_write(void *V, void *ObjPtr, void **FieldPtr); + +#endif Index: llvm/runtime/GC/Makefile diff -u /dev/null llvm/runtime/GC/Makefile:1.5 --- /dev/null Thu Nov 16 21:33:09 2006 +++ llvm/runtime/GC/Makefile Thu Nov 16 21:32:33 2006 @@ -0,0 +1,19 @@ +##===- runtime/GC/Makefile ---------------------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file was developed by the LLVM research group and is distributed under +# the University of Illinois Open Source License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +LEVEL = ../.. +PARALLEL_DIRS := SemiSpace +EXTRA_DIST := gc_exported_symbols.lst +include $(LEVEL)/Makefile.common + +# Install target for libraries: Copy into $LLVMGCCDIR/bytecode-libs +# +install:: + +clean:: Index: llvm/runtime/GC/gc_exported_symbols.lst diff -u /dev/null llvm/runtime/GC/gc_exported_symbols.lst:1.3 --- /dev/null Thu Nov 16 21:33:09 2006 +++ llvm/runtime/GC/gc_exported_symbols.lst Thu Nov 16 21:32:33 2006 @@ -0,0 +1,7 @@ +llvm_gc_initialize +llvm_gc_allocate +llvm_gc_collect +llvm_gc_write +llvm_gc_read + +llvm_gc_root_chain \ No newline at end of file From reid at x10sys.com Thu Nov 16 21:33:10 2006 From: reid at x10sys.com (Reid Spencer) Date: Thu, 16 Nov 2006 21:33:10 -0600 Subject: [llvm-commits] CVS: llvm/runtime/libtrace/Makefile README.txt tracelib.c tracelib.h Message-ID: <200611170333.kAH3XAIG015294@zion.cs.uiuc.edu> Changes in directory llvm/runtime/libtrace: Makefile updated: 1.15 -> 1.16 README.txt updated: 1.2 -> 1.3 tracelib.c updated: 1.13 -> 1.14 tracelib.h updated: 1.4 -> 1.5 --- Log message: Undo removal of the runtime libraries. While this may have been a bit premature, these libraries will be going away for the 2.0 release. Other arrangements for profiling, gc, etc. should be made in the next few months. --- Diffs of the changes: (+452 -0) Makefile | 18 ++ README.txt | 2 tracelib.c | 392 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ tracelib.h | 40 ++++++ 4 files changed, 452 insertions(+) Index: llvm/runtime/libtrace/Makefile diff -u /dev/null llvm/runtime/libtrace/Makefile:1.16 --- /dev/null Thu Nov 16 21:32:43 2006 +++ llvm/runtime/libtrace/Makefile Thu Nov 16 21:32:33 2006 @@ -0,0 +1,18 @@ +##===- runtime/libtrace/Makefile ---------------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file was developed by the LLVM research group and is distributed under +# the University of Illinois Open Source License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +LEVEL = ../.. +BYTECODE_LIBRARY = 1 +LIBRARYNAME = trace +BYTECODE_DESTINATION = $(CFERuntimeLibDir) + +include $(LEVEL)/Makefile.common + +CompileCommonOpts := $(filter-out -pedantic,$(CompileCommonOpts)) +CompileCommonOpts := $(filter-out -Wno-long-long,$(CompileCommonOpts)) Index: llvm/runtime/libtrace/README.txt diff -u /dev/null llvm/runtime/libtrace/README.txt:1.3 --- /dev/null Thu Nov 16 21:33:10 2006 +++ llvm/runtime/libtrace/README.txt Thu Nov 16 21:32:33 2006 @@ -0,0 +1,2 @@ +These routines form the support library for the LLVM -trace and -tracem +instrumentation passes. Index: llvm/runtime/libtrace/tracelib.c diff -u /dev/null llvm/runtime/libtrace/tracelib.c:1.14 --- /dev/null Thu Nov 16 21:33:10 2006 +++ llvm/runtime/libtrace/tracelib.c Thu Nov 16 21:32:33 2006 @@ -0,0 +1,392 @@ +/*===-- tracelib.c - Runtime routines for tracing ---------------*- C++ -*-===* + * + * Runtime routines for supporting tracing of execution for code generated by + * LLVM. + * + *===----------------------------------------------------------------------===*/ + +#include "tracelib.h" +#include +#include +#include +#include +#include "llvm/Support/DataTypes.h" + +/*===---------------------------------------------------------------------===== + * HASH FUNCTIONS + *===---------------------------------------------------------------------===*/ + +/* use #defines until we have inlining */ +typedef uintptr_t Index; /* type of keys, size for hash table */ +typedef uint32_t Generic; /* type of values stored in table */ + +/* Index IntegerHashFunc(const Generic value, const Index size) */ +#define IntegerHashFunc(value, size) \ + ( ((((Index) value) << 3) ^ (((Index) value) >> 3)) % size ) + +/* Index IntegerRehashFunc(const Generic oldHashValue, const Index size) */ +#define IntegerRehashFunc(oldHashValue, size) \ + ((Index) ((oldHashValue+16) % size)) /* 16 is relatively prime to a Mersenne prime! */ + +/* Index PointerHashFunc(const void* value, const Index size) */ +#define PointerHashFunc(value, size) \ + IntegerHashFunc((Index) value, size) + +/* Index PointerRehashFunc(const void* value, const Index size) */ +#define PointerRehashFunc(value, size) \ + IntegerRehashFunc((Index) value, size) + +/*===---------------------------------------------------------------------===== + * POINTER-TO-GENERIC HASH TABLE. + * These should be moved to a separate location: HashTable.[ch] + *===---------------------------------------------------------------------===*/ + +typedef enum { FIND, ENTER } ACTION; +typedef char FULLEMPTY; +const FULLEMPTY EMPTY = '\0'; +const FULLEMPTY FULL = '\1'; + +// List of primes closest to powers of 2 in [2^20 -- 2^30], obtained from +// http://www.utm.edu/research/primes/lists/2small/0bit.html. +// Use these as the successive sizes of the hash table. +#define NUMPRIMES 11 +#define FIRSTENTRY 2 +const unsigned PRIMES[NUMPRIMES] = { (1<<20)-3, (1<<21)-9, (1<<22)-3, (1<<23)-15, + (1<<24)-3, (1<<25)-39, (1<<26)-5, (1<<27)-39, + (1<<28)-57, (1<<29)-3, (1<<30)-35 }; +unsigned CurrentSizeEntry = FIRSTENTRY; + +const unsigned MAX_NUM_PROBES = 4; + +typedef struct PtrValueHashEntry_struct { + void* key; + Generic value; +} PtrValueHashEntry; + +typedef struct PtrValueHashTable_struct { + PtrValueHashEntry* table; + FULLEMPTY* fullEmptyFlags; + Index capacity; + Index size; +} PtrValueHashTable; + + +static Generic LookupOrInsertPtr(PtrValueHashTable* ptrTable, void* ptr, + ACTION action, Generic value); + +static void Insert(PtrValueHashTable* ptrTable, void* ptr, Generic value); + +static void Delete(PtrValueHashTable* ptrTable, void* ptr); + +/* Returns 0 if the item is not found. */ +/* void* LookupPtr(PtrValueHashTable* ptrTable, void* ptr) */ +#define LookupPtr(ptrTable, ptr) \ + LookupOrInsertPtr(ptrTable, ptr, FIND, (Generic) 0) + +void +InitializeTable(PtrValueHashTable* ptrTable, Index newSize) +{ + ptrTable->table = (PtrValueHashEntry*) calloc(newSize, + sizeof(PtrValueHashEntry)); + ptrTable->fullEmptyFlags = (FULLEMPTY*) calloc(newSize, sizeof(FULLEMPTY)); + ptrTable->capacity = newSize; + ptrTable->size = 0; +} + +PtrValueHashTable* +CreateTable(Index initialSize) +{ + PtrValueHashTable* ptrTable = + (PtrValueHashTable*) malloc(sizeof(PtrValueHashTable)); + InitializeTable(ptrTable, initialSize); + return ptrTable; +} + +void +ReallocTable(PtrValueHashTable* ptrTable, Index newSize) +{ + if (newSize <= ptrTable->capacity) + return; + +#ifndef NDEBUG + printf("\n***\n*** REALLOCATING SPACE FOR POINTER HASH TABLE.\n"); + printf("*** oldSize = %ld, oldCapacity = %ld\n***\n\n", + (long) ptrTable->size, (long) ptrTable->capacity); +#endif + + unsigned int i; + PtrValueHashEntry* oldTable = ptrTable->table; + FULLEMPTY* oldFlags = ptrTable->fullEmptyFlags; + Index oldSize = ptrTable->size; + Index oldCapacity = ptrTable->capacity; + + /* allocate the new storage and flags and re-insert the old entries */ + InitializeTable(ptrTable, newSize); + for (i=0; i < oldCapacity; ++i) + if (oldFlags[i] == FULL) + Insert(ptrTable, oldTable[i].key, oldTable[i].value); + + assert(ptrTable->size == oldSize && "Incorrect number of entries copied?"); + +#ifndef NDEBUG + for (i=0; i < oldCapacity; ++i) + if (oldFlags[i] == FULL) + assert(LookupPtr(ptrTable, oldTable[i].key) == oldTable[i].value); +#endif + + free(oldTable); + free(oldFlags); +} + +void +DeleteTable(PtrValueHashTable* ptrTable) +{ + free(ptrTable->table); + free(ptrTable->fullEmptyFlags); + memset(ptrTable, '\0', sizeof(PtrValueHashTable)); + free(ptrTable); +} + +void +InsertAtIndex(PtrValueHashTable* ptrTable, void* ptr, Generic value, Index index) +{ + assert(ptrTable->fullEmptyFlags[index] == EMPTY && "Slot is in use!"); + ptrTable->table[index].key = ptr; + ptrTable->table[index].value = value; + ptrTable->fullEmptyFlags[index] = FULL; + ptrTable->size++; +} + +void +DeleteAtIndex(PtrValueHashTable* ptrTable, Index index) +{ + assert(ptrTable->fullEmptyFlags[index] == FULL && "Deleting empty slot!"); + ptrTable->table[index].key = 0; + ptrTable->table[index].value = (Generic) 0; + ptrTable->fullEmptyFlags[index] = EMPTY; + ptrTable->size--; +} + +Index +FindIndex(PtrValueHashTable* ptrTable, void* ptr) +{ + unsigned numProbes = 1; + Index index = PointerHashFunc(ptr, ptrTable->capacity); + if (ptrTable->fullEmptyFlags[index] == FULL) + { + if (ptrTable->table[index].key == ptr) + return index; + + /* First lookup failed on non-empty slot: probe further */ + while (numProbes < MAX_NUM_PROBES) + { + index = PointerRehashFunc(index, ptrTable->capacity); + if (ptrTable->fullEmptyFlags[index] == EMPTY) + break; + else if (ptrTable->table[index].key == ptr) + return index; + ++numProbes; + } + } + + /* Lookup failed: item is not in the table. */ + /* If last slot is empty, use that slot. */ + /* Otherwise, table must have been reallocated, so search again. */ + + if (numProbes == MAX_NUM_PROBES) + { /* table is too full: reallocate and search again */ + if (CurrentSizeEntry >= NUMPRIMES-1) { + fprintf(stderr, "Out of PRIME Numbers!!!"); + abort(); + } + ReallocTable(ptrTable, PRIMES[++CurrentSizeEntry]); + return FindIndex(ptrTable, ptr); + } + else + { + assert(ptrTable->fullEmptyFlags[index] == EMPTY && + "Stopped before finding an empty slot and before MAX probes!"); + return index; + } +} + +/* Look up hash table using 'ptr' as the key. If an entry exists, return + * the value mapped to 'ptr'. If not, and if action==ENTER is specified, + * create a new entry with value 'value', but return 0 in any case. + */ +Generic +LookupOrInsertPtr(PtrValueHashTable* ptrTable, void* ptr, ACTION action, + Generic value) +{ + Index index = FindIndex(ptrTable, ptr); + if (ptrTable->fullEmptyFlags[index] == FULL && + ptrTable->table[index].key == ptr) + return ptrTable->table[index].value; + + /* Lookup failed: item is not in the table */ + /* If action is ENTER, insert item into the table. Return 0 in any case. */ + if (action == ENTER) + InsertAtIndex(ptrTable, ptr, value, index); + + return (Generic) 0; +} + +void +Insert(PtrValueHashTable* ptrTable, void* ptr, Generic value) +{ + Index index = FindIndex(ptrTable, ptr); + assert(ptrTable->fullEmptyFlags[index] == EMPTY && + "ptr is already in the table: delete it first!"); + InsertAtIndex(ptrTable, ptr, value, index); +} + +void +Delete(PtrValueHashTable* ptrTable, void* ptr) +{ + Index index = FindIndex(ptrTable, ptr); + if (ptrTable->fullEmptyFlags[index] == FULL && + ptrTable->table[index].key == ptr) + { + DeleteAtIndex(ptrTable, index); + } +} + +/*===---------------------------------------------------------------------===== + * RUNTIME ROUTINES TO MAP POINTERS TO SEQUENCE NUMBERS + *===---------------------------------------------------------------------===*/ + +PtrValueHashTable* SequenceNumberTable = NULL; +#define INITIAL_SIZE (PRIMES[FIRSTENTRY]) + +#define MAX_NUM_SAVED 1024 + +typedef struct PointerSet_struct { + char* savedPointers[MAX_NUM_SAVED]; /* 1024 alloca'd ptrs shd suffice */ + unsigned int numSaved; + struct PointerSet_struct* nextOnStack; /* implement a cheap stack */ +} PointerSet; + +PointerSet* topOfStack = NULL; + +SequenceNumber +HashPointerToSeqNum(char* ptr) +{ + static SequenceNumber count = 0; + SequenceNumber seqnum; + if (SequenceNumberTable == NULL) { + assert(MAX_NUM_PROBES < INITIAL_SIZE+1 && "Initial size too small"); + SequenceNumberTable = CreateTable(INITIAL_SIZE); + } + seqnum = (SequenceNumber) + LookupOrInsertPtr(SequenceNumberTable, ptr, ENTER, count+1); + + if (seqnum == 0) /* new entry was created with value count+1 */ + seqnum = ++count; /* so increment counter */ + + assert(seqnum <= count && "Invalid sequence number in table!"); + return seqnum; +} + +void +ReleasePointerSeqNum(char* ptr) +{ /* if a sequence number was assigned to this ptr, release it */ + if (SequenceNumberTable != NULL) + Delete(SequenceNumberTable, ptr); +} + +void +PushPointerSet() +{ + PointerSet* newSet = (PointerSet*) malloc(sizeof(PointerSet)); + newSet->numSaved = 0; + newSet->nextOnStack = topOfStack; + topOfStack = newSet; +} + +void +PopPointerSet() +{ + PointerSet* oldSet; + assert(topOfStack != NULL && "popping from empty stack!"); + oldSet = topOfStack; + topOfStack = oldSet->nextOnStack; + assert(oldSet->numSaved == 0); + free(oldSet); +} + +/* free the pointers! */ +static void +ReleaseRecordedPointers(char* savedPointers[MAX_NUM_SAVED], + unsigned int numSaved) +{ + unsigned int i; + for (i=0; i < topOfStack->numSaved; ++i) + ReleasePointerSeqNum(topOfStack->savedPointers[i]); +} + +void +ReleasePointersPopSet() +{ + ReleaseRecordedPointers(topOfStack->savedPointers, topOfStack->numSaved); + topOfStack->numSaved = 0; + PopPointerSet(); +} + +void +RecordPointer(char* ptr) +{ /* record pointers for release later */ + if (topOfStack->numSaved == MAX_NUM_SAVED) { + printf("***\n*** WARNING: OUT OF ROOM FOR SAVED POINTERS." + " ALL POINTERS ARE BEING FREED.\n" + "*** THE SEQUENCE NUMBERS OF SAVED POINTERS WILL CHANGE!\n*** \n"); + ReleaseRecordedPointers(topOfStack->savedPointers, topOfStack->numSaved); + topOfStack->numSaved = 0; + } + topOfStack->savedPointers[topOfStack->numSaved++] = ptr; +} + +/*===---------------------------------------------------------------------===== + * TEST DRIVER FOR INSTRUMENTATION LIBRARY + *===---------------------------------------------------------------------===*/ + +#ifndef TEST_INSTRLIB +#undef TEST_INSTRLIB /* #define this to turn on by default */ +#endif + +#ifdef TEST_INSTRLIB +int +main(int argc, char** argv) +{ + int i, j; + int doRelease = 0; + + INITIAL_SIZE = 5; /* start with small table to test realloc's*/ + + if (argc > 1 && ! strcmp(argv[1], "-r")) + { + PushPointerSet(); + doRelease = 1; + } + + for (i=0; i < argc; ++i) + for (j=0; argv[i][j]; ++j) + { + printf("Sequence number for argc[%d][%d] (%c) = Hash(%p) = %d\n", + i, j, argv[i][j], argv[i]+j, HashPointerToSeqNum(argv[i]+j)); + + if (doRelease) + RecordPointer(argv[i]+j); + } + + if (doRelease) + ReleasePointersPopSet(); + + /* print sequence numbers out again to compare with (-r) and w/o release */ + for (i=argc-1; i >= 0; --i) + for (j=0; argv[i][j]; ++j) + printf("Sequence number for argc[%d][%d] (%c) = %d\n", + i, j, argv[i][j], argv[i]+j, HashPointerToSeqNum(argv[i]+j)); + + return 0; +} +#endif Index: llvm/runtime/libtrace/tracelib.h diff -u /dev/null llvm/runtime/libtrace/tracelib.h:1.5 --- /dev/null Thu Nov 16 21:33:10 2006 +++ llvm/runtime/libtrace/tracelib.h Thu Nov 16 21:32:33 2006 @@ -0,0 +1,40 @@ +/*===-- Libraries/tracelib.h - Runtime routines for tracing -----*- C++ -*--=== + * + * Runtime routines for supporting tracing of execution + * for code generated by LLVM. + * + *===---------------------------------------------------------------------===*/ + +#ifndef _TEST_LIBRARIES_LIBINSTR_TRACELIB_ +#define _TEST_LIBRARIES_LIBINSTR_TRACELIB_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/*===---------------------------------------------------------------------===== + * Support for tracing pointers + *===---------------------------------------------------------------------===*/ + +typedef unsigned int SequenceNumber; + +extern SequenceNumber HashPointerToSeqNum( char* ptr); + +extern void ReleasePointerSeqNum(char* ptr); + +extern void RecordPointer(char* ptr); + +extern void PushPointerSet(); + +extern void ReleasePointersPopSet(); + + +#ifdef __cplusplus +} +#endif + +/*===---------------------------------------------------------------------===*/ + +#endif From reid at x10sys.com Thu Nov 16 21:33:09 2006 From: reid at x10sys.com (Reid Spencer) Date: Thu, 16 Nov 2006 21:33:09 -0600 Subject: [llvm-commits] CVS: llvm/runtime/GC/SemiSpace/Makefile semispace.c Message-ID: <200611170333.kAH3X9u8015241@zion.cs.uiuc.edu> Changes in directory llvm/runtime/GC/SemiSpace: Makefile updated: 1.8 -> 1.9 semispace.c updated: 1.6 -> 1.7 --- Log message: Undo removal of the runtime libraries. While this may have been a bit premature, these libraries will be going away for the 2.0 release. Other arrangements for profiling, gc, etc. should be made in the next few months. --- Diffs of the changes: (+141 -0) Makefile | 19 +++++++++ semispace.c | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 141 insertions(+) Index: llvm/runtime/GC/SemiSpace/Makefile diff -u /dev/null llvm/runtime/GC/SemiSpace/Makefile:1.9 --- /dev/null Thu Nov 16 21:32:43 2006 +++ llvm/runtime/GC/SemiSpace/Makefile Thu Nov 16 21:32:33 2006 @@ -0,0 +1,19 @@ +##===- runtime/GC/SemiSpace/Makefile -----------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file was developed by the LLVM research group and is distributed under +# the University of Illinois Open Source License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +LEVEL = ../../.. +BYTECODE_LIBRARY = 1 +LIBRARYNAME = gcsemispace +BYTECODE_DESTINATION = $(CFERuntimeLibDir) +EXPORTED_SYMBOL_FILE = $(PROJ_SRC_DIR)/../gc_exported_symbols.lst + +include $(LEVEL)/Makefile.common + +CompileCommonOpts := $(filter-out -pedantic,$(CompileCommonOpts)) +CompileCommonOpts := $(filter-out -Wno-long-long,$(CompileCommonOpts)) Index: llvm/runtime/GC/SemiSpace/semispace.c diff -u /dev/null llvm/runtime/GC/SemiSpace/semispace.c:1.7 --- /dev/null Thu Nov 16 21:33:09 2006 +++ llvm/runtime/GC/SemiSpace/semispace.c Thu Nov 16 21:32:33 2006 @@ -0,0 +1,122 @@ +/*===-- semispace.c - Simple semi-space copying garbage collector ---------===*\ +|* +|* The LLVM Compiler Infrastructure +|* +|* This file was developed by the LLVM research group and is distributed under +|* the University of Illinois Open Source License. See LICENSE.TXT for details. +|* +|*===----------------------------------------------------------------------===*| +|* +|* This garbage collector is an extremely simple copying collector. It splits +|* the managed region of memory into two pieces: the current space to allocate +|* from, and the copying space. When the portion being allocated from fills up, +|* a garbage collection cycle happens, which copies all live blocks to the other +|* half of the managed space. +|* +\*===----------------------------------------------------------------------===*/ + +#include "../GCInterface.h" +#include +#include +#include + +/* AllocPtr - This points to the next byte that is available for allocation. + */ +static char *AllocPtr; + +/* AllocEnd - This points to the first byte not available for allocation. When + * AllocPtr passes this, we have run out of space. + */ +static char *AllocEnd; + +/* CurSpace/OtherSpace - These pointers point to the two regions of memory that + * we switch between. The unallocated portion of the CurSpace is known to be + * zero'd out, but the OtherSpace contains junk. + */ +static void *CurSpace, *OtherSpace; + +/* SpaceSize - The size of each space. */ +static unsigned SpaceSize; + +/* llvm_gc_initialize - Allocate the two spaces that we plan to switch between. + */ +void llvm_gc_initialize(unsigned InitialHeapSize) { + SpaceSize = InitialHeapSize/2; + CurSpace = AllocPtr = calloc(1, SpaceSize); + OtherSpace = malloc(SpaceSize); + AllocEnd = AllocPtr + SpaceSize; +} + +/* We always want to inline the fast path, but never want to inline the slow + * path. + */ +void *llvm_gc_allocate(unsigned Size) __attribute__((always_inline)); +static void* llvm_gc_alloc_slow(unsigned Size) __attribute__((noinline)); + +void *llvm_gc_allocate(unsigned Size) { + char *OldAP = AllocPtr; + char *NewEnd = OldAP+Size; + if (NewEnd > AllocEnd) + return llvm_gc_alloc_slow(Size); + AllocPtr = NewEnd; + return OldAP; +} + +static void* llvm_gc_alloc_slow(unsigned Size) { + llvm_gc_collect(); + if (AllocPtr+Size > AllocEnd) { + fprintf(stderr, "Garbage collector ran out of memory " + "allocating object of size: %d\n", Size); + exit(1); + } + + return llvm_gc_allocate(Size); +} + + +static void process_pointer(void **Root, void *Meta) { + printf("process_root[0x%p] = 0x%p\n", (void*) Root, (void*) *Root); +} + +void llvm_gc_collect() { + // Clear out the space we will be copying into. + // FIXME: This should do the copy, then clear out whatever space is left. + memset(OtherSpace, 0, SpaceSize); + + printf("Garbage collecting!!\n"); + llvm_cg_walk_gcroots(process_pointer); + abort(); +} + +/* We use no read/write barriers */ +void *llvm_gc_read(void *ObjPtr, void **FieldPtr) { return *FieldPtr; } +void llvm_gc_write(void *V, void *ObjPtr, void **FieldPtr) { *FieldPtr = V; } + + +/*===----------------------------------------------------------------------===** + * FIXME: This should be in a code-generator specific library, but for now this + * will work for all code generators. + */ +typedef struct GCRoot { + void **RootPtr; + void *Meta; +} GCRoot; + +typedef struct GCRoots { + struct GCRoots *Next; + unsigned NumRoots; + GCRoot RootRecords[]; +} GCRoots; +GCRoots *llvm_gc_root_chain; + +void llvm_cg_walk_gcroots(void (*FP)(void **Root, void *Meta)) { + GCRoots *R = llvm_gc_root_chain; + for (; R; R = R->Next) { + unsigned i, e; + for (i = 0, e = R->NumRoots; i != e; ++i) + FP(R->RootRecords[i].RootPtr, R->RootRecords[i].Meta); + } +} +/* END FIXME! */ + + From reid at x10sys.com Thu Nov 16 21:33:10 2006 From: reid at x10sys.com (Reid Spencer) Date: Thu, 16 Nov 2006 21:33:10 -0600 Subject: [llvm-commits] CVS: llvm/runtime/libprofile/BasicBlockTracing.c BlockProfiling.c CommonProfiling.c EdgeProfiling.c FunctionProfiling.c Makefile Profiling.h exported_symbols.lst Message-ID: <200611170333.kAH3XAW0015290@zion.cs.uiuc.edu> Changes in directory llvm/runtime/libprofile: BasicBlockTracing.c updated: 1.3 -> 1.4 BlockProfiling.c updated: 1.4 -> 1.5 CommonProfiling.c updated: 1.9 -> 1.10 EdgeProfiling.c updated: 1.3 -> 1.4 FunctionProfiling.c updated: 1.4 -> 1.5 Makefile updated: 1.9 -> 1.10 Profiling.h updated: 1.6 -> 1.7 exported_symbols.lst updated: 1.3 -> 1.4 --- Log message: Undo removal of the runtime libraries. While this may have been a bit premature, these libraries will be going away for the 2.0 release. Other arrangements for profiling, gc, etc. should be made in the next few months. --- Diffs of the changes: (+371 -0) BasicBlockTracing.c | 67 +++++++++++++++++++++++++++++ BlockProfiling.c | 45 +++++++++++++++++++ CommonProfiling.c | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++ EdgeProfiling.c | 45 +++++++++++++++++++ FunctionProfiling.c | 42 ++++++++++++++++++ Makefile | 19 ++++++++ Profiling.h | 31 +++++++++++++ exported_symbols.lst | 5 ++ 8 files changed, 371 insertions(+) Index: llvm/runtime/libprofile/BasicBlockTracing.c diff -u /dev/null llvm/runtime/libprofile/BasicBlockTracing.c:1.4 --- /dev/null Thu Nov 16 21:32:43 2006 +++ llvm/runtime/libprofile/BasicBlockTracing.c Thu Nov 16 21:32:33 2006 @@ -0,0 +1,67 @@ +/*===-- BasicBlockTracing.c - Support library for basic block tracing -----===*\ +|* +|* The LLVM Compiler Infrastructure +|* +|* This file was developed by the LLVM research group and is distributed under +|* the University of Illinois Open Source License. See LICENSE.TXT for details. +|* +|*===----------------------------------------------------------------------===*| +|* +|* This file implements the call back routines for the basic block tracing +|* instrumentation pass. This should be used with the -trace-basic-blocks +|* LLVM pass. +|* +\*===----------------------------------------------------------------------===*/ + +#include "Profiling.h" +#include +#include + +static unsigned *ArrayStart, *ArrayEnd, *ArrayCursor; + +/* WriteAndFlushBBTraceData - write out the currently accumulated trace data + * and reset the cursor to point to the beginning of the buffer. + */ +static void WriteAndFlushBBTraceData () { + write_profiling_data(BBTraceInfo, ArrayStart, (ArrayCursor - ArrayStart)); + ArrayCursor = ArrayStart; +} + +/* BBTraceAtExitHandler - When the program exits, just write out any remaining + * data and free the trace buffer. + */ +static void BBTraceAtExitHandler() { + WriteAndFlushBBTraceData (); + free (ArrayStart); +} + +/* llvm_trace_basic_block - called upon hitting a new basic block. */ +void llvm_trace_basic_block (unsigned BBNum) { + *ArrayCursor++ = BBNum; + if (ArrayCursor == ArrayEnd) + WriteAndFlushBBTraceData (); +} + +/* llvm_start_basic_block_tracing - This is the main entry point of the basic + * block tracing library. It is responsible for setting up the atexit + * handler and allocating the trace buffer. + */ +int llvm_start_basic_block_tracing(int argc, const char **argv, + unsigned *arrayStart, unsigned numElements) { + int Ret; + const unsigned BufferSize = 128 * 1024; + unsigned ArraySize; + + Ret = save_arguments(argc, argv); + + /* Allocate a buffer to contain BB tracing data */ + ArraySize = BufferSize / sizeof (unsigned); + ArrayStart = malloc (ArraySize * sizeof (unsigned)); + ArrayEnd = ArrayStart + ArraySize; + ArrayCursor = ArrayStart; + + /* Set up the atexit handler. */ + atexit (BBTraceAtExitHandler); + + return Ret; +} Index: llvm/runtime/libprofile/BlockProfiling.c diff -u /dev/null llvm/runtime/libprofile/BlockProfiling.c:1.5 --- /dev/null Thu Nov 16 21:33:09 2006 +++ llvm/runtime/libprofile/BlockProfiling.c Thu Nov 16 21:32:33 2006 @@ -0,0 +1,45 @@ +/*===-- BlockProfiling.c - Support library for block profiling ------------===*\ +|* +|* The LLVM Compiler Infrastructure +|* +|* This file was developed by the LLVM research group and is distributed under +|* the University of Illinois Open Source License. See LICENSE.TXT for details. +|* +|*===----------------------------------------------------------------------===*| +|* +|* This file implements the call back routines for the block profiling +|* instrumentation pass. This should be used with the -insert-block-profiling +|* LLVM pass. +|* +\*===----------------------------------------------------------------------===*/ + +#include "Profiling.h" +#include + +static unsigned *ArrayStart; +static unsigned NumElements; + +/* BlockProfAtExitHandler - When the program exits, just write out the profiling + * data. + */ +static void BlockProfAtExitHandler() { + /* Note that if this were doing something more intelligent with the + * instrumentation, we could do some computation here to expand what we + * collected into simple block profiles. (Or we could do it in llvm-prof.) + * Regardless, we directly count each block, so no expansion is necessary. + */ + write_profiling_data(BlockInfo, ArrayStart, NumElements); +} + + +/* llvm_start_block_profiling - This is the main entry point of the block + * profiling library. It is responsible for setting up the atexit handler. + */ +int llvm_start_block_profiling(int argc, const char **argv, + unsigned *arrayStart, unsigned numElements) { + int Ret = save_arguments(argc, argv); + ArrayStart = arrayStart; + NumElements = numElements; + atexit(BlockProfAtExitHandler); + return Ret; +} Index: llvm/runtime/libprofile/CommonProfiling.c diff -u /dev/null llvm/runtime/libprofile/CommonProfiling.c:1.10 --- /dev/null Thu Nov 16 21:33:09 2006 +++ llvm/runtime/libprofile/CommonProfiling.c Thu Nov 16 21:32:33 2006 @@ -0,0 +1,117 @@ +/*===-- CommonProfiling.c - Profiling support library support -------------===*\ +|* +|* The LLVM Compiler Infrastructure +|* +|* This file was developed by the LLVM research group and is distributed under +|* the University of Illinois Open Source License. See LICENSE.TXT for details. +|* +|*===----------------------------------------------------------------------===*| +|* +|* This file implements functions used by the various different types of +|* profiling implementations. +|* +\*===----------------------------------------------------------------------===*/ + +#include "Profiling.h" +#include +#include +#include +#include +#include +#include +#include + +static char *SavedArgs = 0; +static unsigned SavedArgsLength = 0; + +static const char *OutputFilename = "llvmprof.out"; + +/* save_arguments - Save argc and argv as passed into the program for the file + * we output. + */ +int save_arguments(int argc, const char **argv) { + unsigned Length, i; + if (SavedArgs || !argv) return argc; /* This can be called multiple times */ + + /* Check to see if there are any arguments passed into the program for the + * profiler. If there are, strip them off and remember their settings. + */ + while (argc > 1 && !strncmp(argv[1], "-llvmprof-", 10)) { + /* Ok, we have an llvmprof argument. Remove it from the arg list and decide + * what to do with it. + */ + const char *Arg = argv[1]; + memmove(&argv[1], &argv[2], (argc-1)*sizeof(char*)); + --argc; + + if (!strcmp(Arg, "-llvmprof-output")) { + if (argc == 1) + puts("-llvmprof-output requires a filename argument!"); + else { + OutputFilename = strdup(argv[1]); + memmove(&argv[1], &argv[2], (argc-1)*sizeof(char*)); + --argc; + } + } else { + printf("Unknown option to the profiler runtime: '%s' - ignored.\n", Arg); + } + } + + for (Length = 0, i = 0; i != (unsigned)argc; ++i) + Length += strlen(argv[i])+1; + + SavedArgs = (char*)malloc(Length); + for (Length = 0, i = 0; i != (unsigned)argc; ++i) { + unsigned Len = strlen(argv[i]); + memcpy(SavedArgs+Length, argv[i], Len); + Length += Len; + SavedArgs[Length++] = ' '; + } + + SavedArgsLength = Length; + + return argc; +} + + +/* write_profiling_data - Write a raw block of profiling counters out to the + * llvmprof.out file. Note that we allow programs to be instrumented with + * multiple different kinds of instrumentation. For this reason, this function + * may be called more than once. + */ +void write_profiling_data(enum ProfilingType PT, unsigned *Start, + unsigned NumElements) { + static int OutFile = -1; + int PTy; + + /* If this is the first time this function is called, open the output file for + * appending, creating it if it does not already exist. + */ + if (OutFile == -1) { + OutFile = open(OutputFilename, O_CREAT | O_WRONLY | O_APPEND, 0666); + if (OutFile == -1) { + fprintf(stderr, "LLVM profiling runtime: while opening '%s': ", + OutputFilename); + perror(""); + return; + } + + /* Output the command line arguments to the file. */ + { + int PTy = ArgumentInfo; + int Zeros = 0; + write(OutFile, &PTy, sizeof(int)); + write(OutFile, &SavedArgsLength, sizeof(unsigned)); + write(OutFile, SavedArgs, SavedArgsLength); + /* Pad out to a multiple of four bytes */ + if (SavedArgsLength & 3) + write(OutFile, &Zeros, 4-(SavedArgsLength&3)); + } + } + + /* Write out this record! */ + PTy = PT; + write(OutFile, &PTy, sizeof(int)); + write(OutFile, &NumElements, sizeof(unsigned)); + write(OutFile, Start, NumElements*sizeof(unsigned)); +} Index: llvm/runtime/libprofile/EdgeProfiling.c diff -u /dev/null llvm/runtime/libprofile/EdgeProfiling.c:1.4 --- /dev/null Thu Nov 16 21:33:09 2006 +++ llvm/runtime/libprofile/EdgeProfiling.c Thu Nov 16 21:32:33 2006 @@ -0,0 +1,45 @@ +/*===-- EdgeProfiling.c - Support library for edge profiling --------------===*\ +|* +|* The LLVM Compiler Infrastructure +|* +|* This file was developed by the LLVM research group and is distributed under +|* the University of Illinois Open Source License. See LICENSE.TXT for details. +|* +|*===----------------------------------------------------------------------===*| +|* +|* This file implements the call back routines for the edge profiling +|* instrumentation pass. This should be used with the -insert-edge-profiling +|* LLVM pass. +|* +\*===----------------------------------------------------------------------===*/ + +#include "Profiling.h" +#include + +static unsigned *ArrayStart; +static unsigned NumElements; + +/* EdgeProfAtExitHandler - When the program exits, just write out the profiling + * data. + */ +static void EdgeProfAtExitHandler() { + /* Note that if this were doing something more intelligent with the + * instrumentation, we could do some computation here to expand what we + * collected into simple edge profiles. Since we directly count each edge, we + * just write out all of the counters directly. + */ + write_profiling_data(EdgeInfo, ArrayStart, NumElements); +} + + +/* llvm_start_edge_profiling - This is the main entry point of the edge + * profiling library. It is responsible for setting up the atexit handler. + */ +int llvm_start_edge_profiling(int argc, const char **argv, + unsigned *arrayStart, unsigned numElements) { + int Ret = save_arguments(argc, argv); + ArrayStart = arrayStart; + NumElements = numElements; + atexit(EdgeProfAtExitHandler); + return Ret; +} Index: llvm/runtime/libprofile/FunctionProfiling.c diff -u /dev/null llvm/runtime/libprofile/FunctionProfiling.c:1.5 --- /dev/null Thu Nov 16 21:33:09 2006 +++ llvm/runtime/libprofile/FunctionProfiling.c Thu Nov 16 21:32:33 2006 @@ -0,0 +1,42 @@ +/*===-- FunctionProfiling.c - Support library for function profiling ------===*\ +|* +|* The LLVM Compiler Infrastructure +|* +|* This file was developed by the LLVM research group and is distributed under +|* the University of Illinois Open Source License. See LICENSE.TXT for details. +|* +|*===----------------------------------------------------------------------===*| +|* +|* This file implements the call back routines for the function profiling +|* instrumentation pass. This should be used with the +|* -insert-function-profiling LLVM pass. +|* +\*===----------------------------------------------------------------------===*/ + +#include "Profiling.h" +#include + +static unsigned *ArrayStart; +static unsigned NumElements; + +/* FuncProfAtExitHandler - When the program exits, just write out the profiling + * data. + */ +static void FuncProfAtExitHandler() { + /* Just write out the data we collected. + */ + write_profiling_data(FunctionInfo, ArrayStart, NumElements); +} + + +/* llvm_start_func_profiling - This is the main entry point of the function + * profiling library. It is responsible for setting up the atexit handler. + */ +int llvm_start_func_profiling(int argc, const char **argv, + unsigned *arrayStart, unsigned numElements) { + int Ret = save_arguments(argc, argv); + ArrayStart = arrayStart; + NumElements = numElements; + atexit(FuncProfAtExitHandler); + return Ret; +} Index: llvm/runtime/libprofile/Makefile diff -u /dev/null llvm/runtime/libprofile/Makefile:1.10 --- /dev/null Thu Nov 16 21:33:10 2006 +++ llvm/runtime/libprofile/Makefile Thu Nov 16 21:32:33 2006 @@ -0,0 +1,19 @@ +##===- runtime/libprofile/Makefile -------------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file was developed by the LLVM research group and is distributed under +# the University of Illinois Open Source License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +LEVEL = ../.. +BYTECODE_LIBRARY = 1 +SHARED_LIBRARY = 1 +LOADABLE_MODULE = 1 +LIBRARYNAME = profile_rt +EXTRA_DIST = exported_symbols.lst +EXPORTED_SYMBOL_FILE = $(PROJ_SRC_DIR)/exported_symbols.lst +BYTECODE_DESTINATION = $(CFERuntimeLibDir) + +include $(LEVEL)/Makefile.common Index: llvm/runtime/libprofile/Profiling.h diff -u /dev/null llvm/runtime/libprofile/Profiling.h:1.7 --- /dev/null Thu Nov 16 21:33:10 2006 +++ llvm/runtime/libprofile/Profiling.h Thu Nov 16 21:32:33 2006 @@ -0,0 +1,31 @@ +/*===-- Profiling.h - Profiling support library support routines --*- C -*-===*\ +|* +|* The LLVM Compiler Infrastructure +|* +|* This file was developed by the LLVM research group and is distributed under +|* the University of Illinois Open Source License. See LICENSE.TXT for details. +|* +|*===----------------------------------------------------------------------===*| +|* +|* This file defines functions shared by the various different profiling +|* implementations. +|* +\*===----------------------------------------------------------------------===*/ + +#ifndef PROFILING_H +#define PROFILING_H + +#include "llvm/Analysis/ProfileInfoTypes.h" /* for enum ProfilingType */ + +/* save_arguments - Save argc and argv as passed into the program for the file + * we output. + */ +int save_arguments(int argc, const char **argv); + +/* write_profiling_data - Write out a typed packet of profiling data to the + * current output file. + */ +void write_profiling_data(enum ProfilingType PT, unsigned *Start, + unsigned NumElements); + +#endif Index: llvm/runtime/libprofile/exported_symbols.lst diff -u /dev/null llvm/runtime/libprofile/exported_symbols.lst:1.4 --- /dev/null Thu Nov 16 21:33:10 2006 +++ llvm/runtime/libprofile/exported_symbols.lst Thu Nov 16 21:32:33 2006 @@ -0,0 +1,5 @@ + +llvm_start_func_profiling +llvm_start_block_profiling +llvm_start_basic_block_tracing +llvm_trace_basic_block From reid at x10sys.com Thu Nov 16 21:33:09 2006 From: reid at x10sys.com (Reid Spencer) Date: Thu, 16 Nov 2006 21:33:09 -0600 Subject: [llvm-commits] CVS: llvm/runtime/GCCLibraries/libc/COPYING.LIB LICENSE.TXT LICENSES Makefile README.txt atox.c io.c qsort.c remove.c string.c Message-ID: <200611170333.kAH3X9vh015258@zion.cs.uiuc.edu> Changes in directory llvm/runtime/GCCLibraries/libc: COPYING.LIB updated: 1.2 -> 1.3 LICENSE.TXT updated: 1.5 -> 1.6 LICENSES updated: 1.2 -> 1.3 Makefile updated: 1.9 -> 1.10 README.txt updated: 1.2 -> 1.3 atox.c updated: 1.3 -> 1.4 io.c updated: 1.2 -> 1.3 qsort.c updated: 1.6 -> 1.7 remove.c updated: 1.3 -> 1.4 string.c updated: 1.10 -> 1.11 --- Log message: Undo removal of the runtime libraries. While this may have been a bit premature, these libraries will be going away for the 2.0 release. Other arrangements for profiling, gc, etc. should be made in the next few months. --- Diffs of the changes: (+1389 -0) COPYING.LIB | 510 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ LICENSE.TXT | 17 ++ LICENSES | 219 +++++++++++++++++++++++++ Makefile | 19 ++ README.txt | 4 atox.c | 118 +++++++++++++ io.c | 18 ++ qsort.c | 261 ++++++++++++++++++++++++++++++ remove.c | 51 ++++++ string.c | 172 ++++++++++++++++++++ 10 files changed, 1389 insertions(+) Index: llvm/runtime/GCCLibraries/libc/COPYING.LIB diff -u /dev/null llvm/runtime/GCCLibraries/libc/COPYING.LIB:1.3 --- /dev/null Thu Nov 16 21:32:44 2006 +++ llvm/runtime/GCCLibraries/libc/COPYING.LIB Thu Nov 16 21:32:33 2006 @@ -0,0 +1,510 @@ + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations +below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. +^L + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it +becomes a de-facto standard. To achieve this, non-free programs must +be allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. +^L + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control +compilation and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. +^L + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. +^L + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at least + three years, to give the same user the materials specified in + Subsection 6a, above, for a charge no more than the cost of + performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. +^L + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. +^L + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply, and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License +may add an explicit geographical distribution limitation excluding those +countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. +^L + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS +^L + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms +of the ordinary General Public License). + + To apply these terms, attach the following notices to the library. +It is safest to attach them to the start of each source file to most +effectively convey the exclusion of warranty; and each file should +have at least the "copyright" line and a pointer to where the full +notice is found. + + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or +your school, if any, to sign a "copyright disclaimer" for the library, +if necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James + Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + Index: llvm/runtime/GCCLibraries/libc/LICENSE.TXT diff -u /dev/null llvm/runtime/GCCLibraries/libc/LICENSE.TXT:1.6 --- /dev/null Thu Nov 16 21:33:09 2006 +++ llvm/runtime/GCCLibraries/libc/LICENSE.TXT Thu Nov 16 21:32:33 2006 @@ -0,0 +1,17 @@ +libc +------------------------------------------------------------------------------ +The stripped down C library found in llvm/runtime/GCCLibraries/libc is licensed +to you under the GNU Lesser General Public License (LGPL). The license, along +with copyright information, is in COPYING.LIB. + +Portions of glibc also contain copyrights and licenses from third parties. +Those are listed in LICENSES. + +FSF copyright and warranty disclaimer: +Copyright (C) 1991, 1992, 1996, 1997, 1999 Free Software Foundation, Inc. +Copyright (C) 1995,96,97,2002 Free Software Foundation, Inc. + +The GNU C Library 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 +Lesser General Public License for more details. Index: llvm/runtime/GCCLibraries/libc/LICENSES diff -u /dev/null llvm/runtime/GCCLibraries/libc/LICENSES:1.3 --- /dev/null Thu Nov 16 21:33:09 2006 +++ llvm/runtime/GCCLibraries/libc/LICENSES Thu Nov 16 21:32:33 2006 @@ -0,0 +1,219 @@ +This file contains the copying permission notices for various files in the +GNU C Library distribution that have copyright owners other than the Free +Software Foundation. These notices all require that a copy of the notice +be included in the accompanying documentation and be distributed with +binary distributions of the code, so be sure to include this file along +with any binary distributions derived from the GNU C Library. + + +All code incorporated from 4.4 BSD is distributed under the following +license: + +Copyright (C) 1991 Regents of the University of California. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. [This condition was removed.] +4. Neither the name of the University nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. + +The DNS resolver code, taken from BIND 4.9.5, is copyrighted both by +UC Berkeley and by Digital Equipment Corporation. The DEC portions +are under the following license: + +Portions Copyright (C) 1993 by Digital Equipment Corporation. + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies, and +that the name of Digital Equipment Corporation not be used in +advertising or publicity pertaining to distribution of the document or +software without specific, written prior permission. + +THE SOFTWARE IS PROVIDED ``AS IS'' AND DIGITAL EQUIPMENT CORP. +DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL +DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING +FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, +NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION +WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +The Sun RPC support (from rpcsrc-4.0) is covered by the following +license: + +Copyright (C) 1984, Sun Microsystems, Inc. + +Sun RPC is a product of Sun Microsystems, Inc. and is provided for +unrestricted use provided that this legend is included on all tape media +and as a part of the software program in whole or part. Users may copy +or modify Sun RPC without charge, but are not authorized to license or +distribute it to anyone else except as part of a product or program +developed by the user. + +SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE +WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR +PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + +Sun RPC is provided with no support and without any obligation on the +part of Sun Microsystems, Inc. to assist in its use, correction, +modification or enhancement. + +SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE +INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC +OR ANY PART THEREOF. + +In no event will Sun Microsystems, Inc. be liable for any lost revenue +or profits or other special, indirect and consequential damages, even if +Sun has been advised of the possibility of such damages. + + +The following CMU license covers some of the support code for Mach, +derived from Mach 3.0: + +Mach Operating System +Copyright (C) 1991,1990,1989 Carnegie Mellon University +All Rights Reserved. + +Permission to use, copy, modify and distribute this software and its +documentation is hereby granted, provided that both the copyright +notice and this permission notice appear in all copies of the +software, derivative works or modified versions, and any portions +thereof, and that both notices appear in supporting documentation. + +CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS ``AS IS'' +CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR +ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + +Carnegie Mellon requests users of this software to return to + + Software Distribution Coordinator + School of Computer Science + Carnegie Mellon University + Pittsburgh PA 15213-3890 + +or Software.Distribution at CS.CMU.EDU any improvements or +extensions that they make and grant Carnegie Mellon the rights to +redistribute these changes. + +The file if_ppp.h is under the following CMU license: + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the University nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY AND + CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The following license covers the files from Intel's "Highly Optimized +Mathematical Functions for Itanium" collection: + +Intel License Agreement + +Copyright (c) 2000, Intel Corporation + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +* Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +* The name of Intel Corporation may not be used to endorse or promote +products derived from this software without specific prior written +permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The files inet/getnameinfo.c and sysdeps/posix/getaddrinfo.c are copyright +(C) by Craig Metz and are distributed under the following license: + +/* The Inner Net License, Version 2.00 + + The author(s) grant permission for redistribution and use in source and +binary forms, with or without modification, of the software and documentation +provided that the following conditions are met: + +0. If you receive a version of the software that is specifically labelled + as not being for redistribution (check the version message and/or README), + you are not permitted to redistribute that version of the software in any + way or form. +1. All terms of the all other applicable copyrights and licenses must be + followed. +2. Redistributions of source code must retain the authors' copyright + notice(s), this list of conditions, and the following disclaimer. +3. Redistributions in binary form must reproduce the authors' copyright + notice(s), this list of conditions, and the following disclaimer in the + documentation and/or other materials provided with the distribution. +4. [The copyright holder has authorized the removal of this clause.] +5. Neither the name(s) of the author(s) nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS ``AS IS'' AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + If these license terms cause you a real problem, contact the author. */ Index: llvm/runtime/GCCLibraries/libc/Makefile diff -u /dev/null llvm/runtime/GCCLibraries/libc/Makefile:1.10 --- /dev/null Thu Nov 16 21:33:09 2006 +++ llvm/runtime/GCCLibraries/libc/Makefile Thu Nov 16 21:32:33 2006 @@ -0,0 +1,19 @@ +##===- runtime/GCCLibraries/libc/Makefile ------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file was developed by the LLVM research group and is distributed under +# the University of Illinois Open Source License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +LEVEL = ../../.. +BYTECODE_LIBRARY = 1 +DONT_BUILD_RELINKED = 1 +LIBRARYNAME = c +BYTECODE_DESTINATION = $(CFERuntimeLibDir) + +include $(LEVEL)/Makefile.common + +CompileCommonOpts := $(filter-out -pedantic,$(CompileCommonOpts)) +CompileCommonOpts := $(filter-out -Wno-long-long,$(CompileCommonOpts)) Index: llvm/runtime/GCCLibraries/libc/README.txt diff -u /dev/null llvm/runtime/GCCLibraries/libc/README.txt:1.3 --- /dev/null Thu Nov 16 21:33:09 2006 +++ llvm/runtime/GCCLibraries/libc/README.txt Thu Nov 16 21:32:33 2006 @@ -0,0 +1,4 @@ +This directory contains source files to build the LLVM version of libc. + +Currently it is hacked together on a by-demand basis, but someday a proper +port of libc would be very nice. Index: llvm/runtime/GCCLibraries/libc/atox.c diff -u /dev/null llvm/runtime/GCCLibraries/libc/atox.c:1.4 --- /dev/null Thu Nov 16 21:33:09 2006 +++ llvm/runtime/GCCLibraries/libc/atox.c Thu Nov 16 21:32:33 2006 @@ -0,0 +1,118 @@ +//===-- atox.c - Ascii string parsers for LLVM libc Library -------*- C -*-===// +// +// A lot of this code is ripped gratuitously from glibc and libiberty. +// +//===----------------------------------------------------------------------===// + + +#define isspace(x) ((x) == ' ' || (x) == '\t' || (x) == '\n') +#define isdigit(x) ((x) >= '0' && (x) <= '9') +#define isupper(x) ((x) >= 'A' && (x) <= 'Z') +#define islower(x) ((x) >= 'a' && (x) <= 'z') +#define isalpha(x) (isupper(x) || islower(x)) + +#ifndef ULONG_MAX +#define ULONG_MAX ((unsigned long)(~0L)) /* 0xFFFFFFFF */ +#endif + +#ifndef LONG_MAX +#define LONG_MAX ((long)(ULONG_MAX >> 1)) /* 0x7FFFFFFF */ +#endif + +#ifndef LONG_MIN +#define LONG_MIN ((long)(~LONG_MAX)) /* 0x80000000 */ +#endif + +#if 0 +/* + * Convert a string to a long integer. + * + * Ignores `locale' stuff. Assumes that the upper and lower case + * alphabets and digits are each contiguous. + */ +long strtol(const char *nptr, char **endptr, int base) { + register const char *s = nptr; + register unsigned long acc; + register int c; + register unsigned long cutoff; + register int neg = 0, any, cutlim; + + /* + * Skip white space and pick up leading +/- sign if any. + * If base is 0, allow 0x for hex and 0 for octal, else + * assume decimal; if base is already 16, allow 0x. + */ + do { + c = *s++; + } while (isspace(c)); + if (c == '-') { + neg = 1; + c = *s++; + } else if (c == '+') + c = *s++; + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X')) { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + + /* + * Compute the cutoff value between legal numbers and illegal + * numbers. That is the largest legal value, divided by the + * base. An input number that is greater than this value, if + * followed by a legal input character, is too big. One that + * is equal to this value may be valid or not; the limit + * between valid and invalid numbers is then based on the last + * digit. For instance, if the range for longs is + * [-2147483648..2147483647] and the input base is 10, + * cutoff will be set to 214748364 and cutlim to either + * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated + * a value > 214748364, or equal but the next digit is > 7 (or 8), + * the number is too big, and we will return a range error. + * + * Set any if any `digits' consumed; make it negative to indicate + * overflow. + */ + cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX; + cutlim = cutoff % (unsigned long)base; + cutoff /= (unsigned long)base; + for (acc = 0, any = 0;; c = *s++) { + if (isdigit(c)) + c -= '0'; + else if (isalpha(c)) + c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim) + any = -1; + else { + any = 1; + acc *= base; + acc += c; + } + } + if (any < 0) { + acc = neg ? LONG_MIN : LONG_MAX; + } else if (neg) + acc = -acc; + if (endptr != 0) + *endptr = (char *) (any ? s - 1 : nptr); + return (acc); +} + + +/* Convert a string to an int. */ +int atoi(const char *nptr) { + return (int)strtol(nptr, 0, 10); +} + +/* Convert a string to a long int. */ +long int atol(const char *nptr) { + return strtol(nptr, 0, 10); +} +#endif Index: llvm/runtime/GCCLibraries/libc/io.c diff -u /dev/null llvm/runtime/GCCLibraries/libc/io.c:1.3 --- /dev/null Thu Nov 16 21:33:09 2006 +++ llvm/runtime/GCCLibraries/libc/io.c Thu Nov 16 21:32:33 2006 @@ -0,0 +1,18 @@ +//===-- io.c - IO routines for LLVM libc Library ------------------*- C -*-===// +// +// A lot of this code is ripped gratuitously from glibc and libiberty. +// +//===----------------------------------------------------------------------===// + +int putchar(int); + +// The puts() function writes the string pointed to by s, followed by a +// NEWLINE character, to the standard output stream stdout. On success the +// number of characters written is returned; otherwise they return EOF. +// +int puts(const char *S) { + const char *Str = S; + while (*Str) putchar(*Str++); + putchar('\n'); + return Str+1-S; +} Index: llvm/runtime/GCCLibraries/libc/qsort.c diff -u /dev/null llvm/runtime/GCCLibraries/libc/qsort.c:1.7 --- /dev/null Thu Nov 16 21:33:09 2006 +++ llvm/runtime/GCCLibraries/libc/qsort.c Thu Nov 16 21:32:33 2006 @@ -0,0 +1,261 @@ +//===-- qsort.c - The qsort function for the LLVM libc Library ----*- C -*-===// +// +// This code is a modified form of the qsort() function from the GNU C +// library. +// +// Modifications: +// 2003/05/29 - Code disabled for compilation. Line wrapping changed. +// +//===----------------------------------------------------------------------===// + +/* Copyright (C) 1991, 1992, 1996, 1997, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Written by Douglas C. Schmidt (schmidt at ics.uci.edu). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* If you consider tuning this algorithm, you should consult first: + Engineering a sort function; Jon Bentley and M. Douglas McIlroy; + Software - Practice and Experience; Vol. 23 (11), 1249-1265, 1993. */ + +#if 0 + +#include +#include +#include + +/* Byte-wise swap two items of size SIZE. */ +#define SWAP(a, b, size) \ + do \ + { \ + register size_t __size = (size); \ + register char *__a = (a), *__b = (b); \ + do \ + { \ + char __tmp = *__a; \ + *__a++ = *__b; \ + *__b++ = __tmp; \ + } while (--__size > 0); \ + } while (0) + +/* Discontinue quicksort algorithm when partition gets below this size. + This particular magic number was chosen to work best on a Sun 4/260. */ +#define MAX_THRESH 4 + +/* Stack node declarations used to store unfulfilled partition obligations. */ +typedef struct + { + char *lo; + char *hi; + } stack_node; + +/* The next 4 #defines implement a very fast in-line stack abstraction. */ +/* The stack needs log (total_elements) entries (we could even subtract + log(MAX_THRESH)). Since total_elements has type size_t, we get as + upper bound for log (total_elements): + bits per byte (CHAR_BIT) * sizeof(size_t). */ +#define STACK_SIZE (CHAR_BIT * sizeof(size_t)) +#define PUSH(low, high) ((void) ((top->lo = (low)), (top->hi = (high)), ++top)) +#define POP(low, high) ((void) (--top, (low = top->lo), (high = top->hi))) +#define STACK_NOT_EMPTY (stack < top) + + +/* Order size using quicksort. This implementation incorporates + four optimizations discussed in Sedgewick: + + 1. Non-recursive, using an explicit stack of pointer that store the + next array partition to sort. To save time, this maximum amount + of space required to store an array of SIZE_MAX is allocated on the + stack. Assuming a 32-bit (64 bit) integer for size_t, this needs + only 32 * sizeof(stack_node) == 256 bytes (for 64 bit: 1024 bytes). + Pretty cheap, actually. + + 2. Chose the pivot element using a median-of-three decision tree. + This reduces the probability of selecting a bad pivot value and + eliminates certain extraneous comparisons. + + 3. Only quicksorts TOTAL_ELEMS / MAX_THRESH partitions, leaving + insertion sort to order the MAX_THRESH items within each partition. + This is a big win, since insertion sort is faster for small, mostly + sorted array segments. + + 4. The larger of the two sub-partitions is always pushed onto the + stack first, with the algorithm then concentrating on the + smaller partition. This *guarantees* no more than log (total_elems) + stack size is needed (actually O(1) in this case)! */ + +typedef int(*__compar_fn_t)(const void *, const void *); +void +qsort (void *const pbase, size_t total_elems, size_t size, + __compar_fn_t cmp) +{ + register char *base_ptr = (char *) pbase; + + const size_t max_thresh = MAX_THRESH * size; + + if (total_elems == 0) + /* Avoid lossage with unsigned arithmetic below. */ + return; + + if (total_elems > MAX_THRESH) + { + char *lo = base_ptr; + char *hi = &lo[size * (total_elems - 1)]; + stack_node stack[STACK_SIZE]; + stack_node *top = stack + 1; + + while (STACK_NOT_EMPTY) + { + char *left_ptr; + char *right_ptr; + + /* Select median value from among LO, MID, and HI. Rearrange + LO and HI so the three values are sorted. This lowers the + probability of picking a pathological pivot value and + skips a comparison for both the LEFT_PTR and RIGHT_PTR in + the while loops. */ + + char *mid = lo + size * ((hi - lo) / size >> 1); + + if ((*cmp) ((void *) mid, (void *) lo) < 0) + SWAP (mid, lo, size); + if ((*cmp) ((void *) hi, (void *) mid) < 0) + SWAP (mid, hi, size); + else + goto jump_over; + if ((*cmp) ((void *) mid, (void *) lo) < 0) + SWAP (mid, lo, size); + jump_over:; + + left_ptr = lo + size; + right_ptr = hi - size; + + /* Here's the famous ``collapse the walls'' section of quicksort. + Gotta like those tight inner loops! They are the main reason + that this algorithm runs much faster than others. */ + do + { + while ((*cmp) ((void *) left_ptr, (void *) mid) < 0) + left_ptr += size; + + while ((*cmp) ((void *) mid, (void *) right_ptr) < 0) + right_ptr -= size; + + if (left_ptr < right_ptr) + { + SWAP (left_ptr, right_ptr, size); + if (mid == left_ptr) + mid = right_ptr; + else if (mid == right_ptr) + mid = left_ptr; + left_ptr += size; + right_ptr -= size; + } + else if (left_ptr == right_ptr) + { + left_ptr += size; + right_ptr -= size; + break; + } + } + while (left_ptr <= right_ptr); + + /* Set up pointers for next iteration. First determine whether + left and right partitions are below the threshold size. If so, + ignore one or both. Otherwise, push the larger partition's + bounds on the stack and continue sorting the smaller one. */ + + if ((size_t) (right_ptr - lo) <= max_thresh) + { + if ((size_t) (hi - left_ptr) <= max_thresh) + /* Ignore both small partitions. */ + POP (lo, hi); + else + /* Ignore small left partition. */ + lo = left_ptr; + } + else if ((size_t) (hi - left_ptr) <= max_thresh) + /* Ignore small right partition. */ + hi = right_ptr; + else if ((right_ptr - lo) > (hi - left_ptr)) + { + /* Push larger left partition indices. */ + PUSH (lo, right_ptr); + lo = left_ptr; + } + else + { + /* Push larger right partition indices. */ + PUSH (left_ptr, hi); + hi = right_ptr; + } + } + } + + /* Once the BASE_PTR array is partially sorted by quicksort the rest + is completely sorted using insertion sort, since this is efficient + for partitions below MAX_THRESH size. BASE_PTR points to the beginning + of the array to sort, and END_PTR points at the very last element in + the array (*not* one beyond it!). */ + +#define min(x, y) ((x) < (y) ? (x) : (y)) + + { + char *const end_ptr = &base_ptr[size * (total_elems - 1)]; + char *tmp_ptr = base_ptr; + char *thresh = min(end_ptr, base_ptr + max_thresh); + register char *run_ptr; + + /* Find smallest element in first threshold and place it at the + array's beginning. This is the smallest array element, + and the operation speeds up insertion sort's inner loop. */ + + for (run_ptr = tmp_ptr + size; run_ptr <= thresh; run_ptr += size) + if ((*cmp) ((void *) run_ptr, (void *) tmp_ptr) < 0) + tmp_ptr = run_ptr; + + if (tmp_ptr != base_ptr) + SWAP (tmp_ptr, base_ptr, size); + + /* Insertion sort, running from left-hand-side up to right-hand-side. */ + + run_ptr = base_ptr + size; + while ((run_ptr += size) <= end_ptr) + { + tmp_ptr = run_ptr - size; + while ((*cmp) ((void *) run_ptr, (void *) tmp_ptr) < 0) + tmp_ptr -= size; + + tmp_ptr += size; + if (tmp_ptr != run_ptr) + { + char *trav; + + trav = run_ptr + size; + while (--trav >= run_ptr) + { + char c = *trav; + char *hi, *lo; + + for (hi = lo = trav; (lo -= size) >= tmp_ptr; hi = lo) + *hi = *lo; + *hi = c; + } + } + } + } +} +#endif Index: llvm/runtime/GCCLibraries/libc/remove.c diff -u /dev/null llvm/runtime/GCCLibraries/libc/remove.c:1.4 --- /dev/null Thu Nov 16 21:33:09 2006 +++ llvm/runtime/GCCLibraries/libc/remove.c Thu Nov 16 21:32:33 2006 @@ -0,0 +1,51 @@ +//===-- remove.c - The remove function for the LLVM libc Library --*- C -*-===// +// +// This code is a modified form of the remove() function from the GNU C +// library. +// +// Modifications: +// 2005/11/28 - Added to LLVM tree. Functions renamed to allow compilation. +// Code to control symbol linkage types removed. +// +//===----------------------------------------------------------------------===// + +/* ANSI C `remove' function to delete a file or directory. POSIX.1 version. + Copyright (C) 1995,96,97,2002 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +int +remove (const char * file) +{ + int save; + + save = errno; + if (rmdir (file) == 0) + return 0; + else if (errno == ENOTDIR && unlink (file) == 0) + { + errno = (save); + return 0; + } + + return -1; +} + Index: llvm/runtime/GCCLibraries/libc/string.c diff -u /dev/null llvm/runtime/GCCLibraries/libc/string.c:1.11 --- /dev/null Thu Nov 16 21:33:09 2006 +++ llvm/runtime/GCCLibraries/libc/string.c Thu Nov 16 21:32:33 2006 @@ -0,0 +1,172 @@ +//===-- string.c - String functions for the LLVM libc Library -----*- C -*-===// +// +// A lot of this code is ripped gratuitously from glibc and libiberty. +// +//===----------------------------------------------------------------------===// + +#include +#include + +#ifdef strlen +#undef strlen +#endif +size_t strlen(const char *Str) { + size_t Count = 0; + while (*Str) { ++Count; ++Str; } + return Count; +} + +#ifdef strdup +#undef strdup +#endif +char *strdup(const char *str) { + size_t Len = strlen(str); + char *Result = (char*)malloc((Len+1)*sizeof(char)); + memcpy(Result, str, Len+1); + return Result; +} + +#ifdef strndup +#undef strndup +#endif +char *strndup(const char *str, size_t n) { + size_t Len = strlen(str); + if (Len > n) Len = n; + char *Result = (char*)malloc((Len+1)*sizeof(char)); + memcpy(Result, str, Len); + Result[Len] = 0; + return Result; +} + +#ifdef strcpy +#undef strcpy +#endif +char *strcpy(char *s1, const char *s2) { + char *dest = s1; + while ((*s1++ = *s2++)); + return dest; +} + +#ifdef strncpy +#undef strncpy +#endif +char *strncpy(char *s1, const char *s2, size_t n) { + char *dest = s1; + while (n-- && (*s1++ = *s2++)); + return dest; +} + +#ifdef strcat +#undef strcat +#endif +char *strcat(char *s1, const char *s2) { + strcpy(s1+strlen(s1), s2); + return s1; +} + + +#ifdef strcmp +#undef strcmp +#endif +/* Compare S1 and S2, returning less than, equal to or + greater than zero if S1 is lexicographically less than, + equal to or greater than S2. */ +int strcmp (const char *p1, const char *p2) { + register const unsigned char *s1 = (const unsigned char *) p1; + register const unsigned char *s2 = (const unsigned char *) p2; + unsigned char c1, c2; + + do + { + c1 = (unsigned char) *s1++; + c2 = (unsigned char) *s2++; + if (c1 == '\0') + return c1 - c2; + } + while (c1 == c2); + + return c1 - c2; +} + +// http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/generic/?cvsroot=glibc +#if 0 +typedef unsigned int op_t; +#define OPSIZ 4 + +void *memset (void *dstpp, int c, size_t len) { + long long int dstp = (long long int) dstpp; + + if (len >= 8) + { + size_t xlen; + op_t cccc; + + cccc = (unsigned char) c; + cccc |= cccc << 8; + cccc |= cccc << 16; + if (OPSIZ > 4) + /* Do the shift in two steps to avoid warning if long has 32 bits. */ + cccc |= (cccc << 16) << 16; + + /* There are at least some bytes to set. + No need to test for LEN == 0 in this alignment loop. */ + while (dstp % OPSIZ != 0) + { + ((unsigned char *) dstp)[0] = c; + dstp += 1; + len -= 1; + } + + /* Write 8 `op_t' per iteration until less than 8 `op_t' remain. */ + xlen = len / (OPSIZ * 8); + while (xlen > 0) + { + ((op_t *) dstp)[0] = cccc; + ((op_t *) dstp)[1] = cccc; + ((op_t *) dstp)[2] = cccc; + ((op_t *) dstp)[3] = cccc; + ((op_t *) dstp)[4] = cccc; + ((op_t *) dstp)[5] = cccc; + ((op_t *) dstp)[6] = cccc; + ((op_t *) dstp)[7] = cccc; + dstp += 8 * OPSIZ; + xlen -= 1; + } + len %= OPSIZ * 8; + + /* Write 1 `op_t' per iteration until less than OPSIZ bytes remain. */ + xlen = len / OPSIZ; + while (xlen > 0) + { + ((op_t *) dstp)[0] = cccc; + dstp += OPSIZ; + xlen -= 1; + } + len %= OPSIZ; + } + + /* Write the last few bytes. */ + while (len > 0) + { + ((unsigned char *) dstp)[0] = c; + dstp += 1; + len -= 1; + } + + return dstpp; +} +#endif + +#ifdef memcpy +#undef memcpy +#endif +void *memcpy(void *dstpp, const void *srcpp, size_t len) { + char *dstp = (char*)dstpp; + char *srcp = (char*) srcpp; + unsigned i; + + for (i = 0; i < len; ++i) + dstp[i] = srcp[i]; + + return dstpp; +} From isanbard at gmail.com Thu Nov 16 21:38:12 2006 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 16 Nov 2006 19:38:12 -0800 Subject: [llvm-commits] CVS: llvm/include/llvm/Support/Debug.h In-Reply-To: <1163730300.2808.21.camel@bashful.x10sys.com> References: <200611170049.kAH0nUx3012249@zion.cs.uiuc.edu> <1163727209.2808.10.camel@bashful.x10sys.com> <16e5fdf90611161744g594ca474q894595ed6f1a2fb4@mail.gmail.com> <1163730300.2808.21.camel@bashful.x10sys.com> Message-ID: <1821C322-FCA4-4ABE-85E2-0AB42BCAA993@gmail.com> On Nov 16, 2006, at 6:25 PM, Reid Spencer wrote: > On Thu, 2006-11-16 at 17:44 -0800, Bill Wendling wrote: >> Basically, this is to get rid of static c'tor/d'tors scattered all >> over the source tree. (You get them whenever you #include >> .) >> A smart compiler should be able to remove all of the empty functions >> because they don't have any side-effects. > Hi Reid, > I understand the motivation for the change and I commend it, but I'm > concerned about getting it right. You're assuming a few things: a) the > compiler is smart enough to get rid of calls that have no side > effects, > b) the compiler knows how to determine if a function has no side > effects > without help (operator<< isn't marked "pure"), and c) that there > aren't > any side effects. c) can probably be proven by your iostream > implementation but a) and b) are a little tougher. > Of course, LLVM is self-hosted, so it should be smart enough to handle it. :-) > Can we build an optimized, with symbols (-g -O2) version of one of > these > modules and see if those symbols are getting removed ? If so, I'm > fine > with it. If not, we need a new strategy. > I hope I did this correctly. Anyway, here are the files: t.h: #include class llvm_ostream { std::ostream* Stream; public: llvm_ostream() : Stream(0) {} llvm_ostream(std::ostream& OStream) : Stream(&OStream) {} template llvm_ostream& operator << (const Ty& Thing) { #ifndef NDEBUG if (Stream) *Stream << Thing; #endif return *this; } }; /// getErrorOutputStream - Returns the error output stream (std::cerr). This /// places the std::c* I/O streams into one .cpp file and relieves the whole /// program from having to have hundreds of static c'tor/d'tors for them. /// llvm_ostream getErrorOutputStream(const char *DebugType); #ifdef NDEBUG #define DOUT llvm_ostream() #else #define DOUT getErrorOutputStream(DEBUG_TYPE) #endif t.cpp: #define DEBUG_TYPE "experiment" #include "t.h" int main() { DOUT << "Hello world\n"; } foo.cpp: #include "t.h" #include llvm_ostream getErrorOutputStream(const char *DebugType) { if (DebugType) return llvm_ostream(std::cerr); else return llvm_ostream(); } Compiled with -DNDEBUG -g -O2 gives: $ nm -A foo.o foo.o: 00000170 s EH_frame1 foo.o: 00000160 s __GLOBAL__I__Z20getErrorOutputStreamPKc foo.o: 00000000 a __GLOBAL__I__Z20getErrorOutputStreamPKc.eh foo.o: 00000000 T __Z20getErrorOutputStreamPKc foo.o: 00000000 A __Z20getErrorOutputStreamPKc.eh foo.o: 000000d0 s __Z41__static_initialization_and_destruction_0ii foo.o: 0000018c s __Z41__static_initialization_and_destruction_0ii.eh foo.o: U __ZNSt8ios_base4InitC1Ev foo.o: U __ZNSt8ios_base4InitD1Ev foo.o: U __ZSt4cerr foo.o: 000001d0 b __ZSt8__ioinit foo.o: U ___cxa_atexit foo.o: U ___dso_handle foo.o: U ___gxx_personality_v0 foo.o: 00000040 t ___tcf_0 foo.o: 00000000 a ___tcf_0.eh foo.o: U dyld_stub_binding_helper $ nm -A t.o t.o: 00000000 T _main t.o: 00000000 A _main.eh Compiling with -g -O2 gives: $ nm -A foo.o foo.o: 00000170 s EH_frame1 foo.o: 00000160 s __GLOBAL__I__Z20getErrorOutputStreamPKc foo.o: 00000000 a __GLOBAL__I__Z20getErrorOutputStreamPKc.eh foo.o: 00000000 T __Z20getErrorOutputStreamPKc foo.o: 00000000 A __Z20getErrorOutputStreamPKc.eh foo.o: 000000d0 s __Z41__static_initialization_and_destruction_0ii foo.o: 0000018c s __Z41__static_initialization_and_destruction_0ii.eh foo.o: U __ZNSt8ios_base4InitC1Ev foo.o: U __ZNSt8ios_base4InitD1Ev foo.o: U __ZSt4cerr foo.o: 000001d0 b __ZSt8__ioinit foo.o: U ___cxa_atexit foo.o: U ___dso_handle foo.o: U ___gxx_personality_v0 foo.o: 00000040 t ___tcf_0 foo.o: 00000000 a ___tcf_0.eh foo.o: U dyld_stub_binding_helper $ nm -A t.o t.o: 000000bc s EH_frame1 t.o: U __Z20getErrorOutputStreamPKc t.o: U __ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc t.o: U ___gxx_personality_v0 t.o: 00000000 T _main t.o: 000000d8 S _main.eh t.o: U dyld_stub_binding_helper So it seems like gcc is doing the right thing, I suppose. I'm going to give it a try with the LLVM source in the CodeGen directory. -bw From isanbard at gmail.com Thu Nov 16 21:49:39 2006 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 16 Nov 2006 19:49:39 -0800 Subject: [llvm-commits] CVS: llvm/include/llvm/Support/Debug.h In-Reply-To: <1163730300.2808.21.camel@bashful.x10sys.com> References: <200611170049.kAH0nUx3012249@zion.cs.uiuc.edu> <1163727209.2808.10.camel@bashful.x10sys.com> <16e5fdf90611161744g594ca474q894595ed6f1a2fb4@mail.gmail.com> <1163730300.2808.21.camel@bashful.x10sys.com> Message-ID: <1362DC00-703A-452C-A093-87AA817D743C@gmail.com> On Nov 16, 2006, at 6:25 PM, Reid Spencer wrote: > Can we build an optimized, with symbols (-g -O2) version of one of > these > modules and see if those symbols are getting removed ? If so, I'm > fine > with it. If not, we need a new strategy. > I just compiled the normal way (with -g) and RegAllocLinearScan had a bunch of strings when I ran "strings" on it. When I compiled it with "-g -O2 -DNDEBUG", it gave this: Linear Scan Register Allocator regalloc Ratio of intervals processed over total intervals Number of times we had to backtrack linearscan linear scan register allocator vector::_M_insert_aux }d[x9) And there was only llvm_ostream in the -g way of compiling things. -bw From sabre at nondot.org Fri Nov 17 00:10:03 2006 From: sabre at nondot.org (Chris Lattner) Date: Fri, 17 Nov 2006 00:10:03 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/LoopStrengthReduce/var_stride_used_by_compare.ll Message-ID: <200611170610.kAH6A3Yu017750@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/LoopStrengthReduce: var_stride_used_by_compare.ll added (r1.1) --- Log message: New testcase. --- Diffs of the changes: (+48 -0) var_stride_used_by_compare.ll | 48 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 48 insertions(+) Index: llvm/test/Regression/Transforms/LoopStrengthReduce/var_stride_used_by_compare.ll diff -c /dev/null llvm/test/Regression/Transforms/LoopStrengthReduce/var_stride_used_by_compare.ll:1.1 *** /dev/null Fri Nov 17 00:09:59 2006 --- llvm/test/Regression/Transforms/LoopStrengthReduce/var_stride_used_by_compare.ll Fri Nov 17 00:09:49 2006 *************** *** 0 **** --- 1,48 ---- + ; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis && + + ; Base should not be i*3, it should be i*2. + ; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | not grep 'mul.*%i, 3' && + + ; Indvar should not start at zero: + ; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | not grep 'phi uint .* 0' + + ; mul uint %i, 3 + + ; ModuleID = 't.bc' + target datalayout = "e-p:32:32" + target endian = little + target pointersize = 32 + target triple = "i686-apple-darwin8" + %flags2 = external global [8193 x sbyte], align 32 ; <[8193 x sbyte]*> [#uses=1] + + implementation ; Functions: + + void %foo(int %k, int %i) { + entry: + %i = cast int %i to uint ; [#uses=2] + %k_addr.012 = shl int %i, ubyte 1 ; [#uses=1] + %tmp14 = setgt int %k_addr.012, 8192 ; [#uses=1] + br bool %tmp14, label %return, label %bb.preheader + + bb.preheader: ; preds = %entry + %tmp. = shl uint %i, ubyte 1 ; [#uses=1] + br label %bb + + bb: ; preds = %bb, %bb.preheader + %indvar = phi uint [ %indvar.next, %bb ], [ 0, %bb.preheader ] ; [#uses=2] + %tmp.15 = mul uint %indvar, %i ; [#uses=1] + %tmp.16 = add uint %tmp.15, %tmp. ; [#uses=2] + %k_addr.0.0 = cast uint %tmp.16 to int ; [#uses=1] + %tmp = getelementptr [8193 x sbyte]* %flags2, int 0, uint %tmp.16 ; [#uses=1] + store sbyte 0, sbyte* %tmp + %k_addr.0 = add int %k_addr.0.0, %i ; [#uses=1] + %tmp = setgt int %k_addr.0, 8192 ; [#uses=1] + %indvar.next = add uint %indvar, 1 ; [#uses=1] + br bool %tmp, label %return.loopexit, label %bb + + return.loopexit: ; preds = %bb + br label %return + + return: ; preds = %return.loopexit, %entry + ret void + } From sabre at nondot.org Fri Nov 17 00:17:47 2006 From: sabre at nondot.org (Chris Lattner) Date: Fri, 17 Nov 2006 00:17:47 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp Message-ID: <200611170617.kAH6HlbW017931@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: LoopStrengthReduce.cpp updated: 1.93 -> 1.94 --- Log message: If an indvar with a variable stride is used by the exit condition, go ahead and handle it like constant stride vars. This fixes some bad codegen in variable stride cases. For example, it compiles this: void foo(int k, int i) { for (k=i+i; k <= 8192; k+=i) flags2[k] = 0; } to: LBB1_1: #bb.preheader movl %eax, %ecx addl %ecx, %ecx movl L_flags2$non_lazy_ptr, %edx LBB1_2: #bb movb $0, (%edx,%ecx) addl %eax, %ecx cmpl $8192, %ecx jle LBB1_2 #bb LBB1_5: #return ret or (if the array is local and we are in dynamic-nonpic or static mode): LBB3_2: #bb movb $0, _flags2(%ecx) addl %eax, %ecx cmpl $8192, %ecx jle LBB3_2 #bb and: lis r2, ha16(L_flags2$non_lazy_ptr) lwz r2, lo16(L_flags2$non_lazy_ptr)(r2) slwi r3, r4, 1 LBB1_2: ;bb li r5, 0 add r6, r4, r3 stbx r5, r2, r3 cmpwi cr0, r6, 8192 bgt cr0, LBB1_5 ;return instead of: leal (%eax,%eax,2), %ecx movl %eax, %edx addl %edx, %edx addl L_flags2$non_lazy_ptr, %edx xorl %esi, %esi LBB1_2: #bb movb $0, (%edx,%esi) movl %eax, %edi addl %esi, %edi addl %ecx, %esi cmpl $8192, %esi jg LBB1_5 #return and: lis r2, ha16(L_flags2$non_lazy_ptr) lwz r2, lo16(L_flags2$non_lazy_ptr)(r2) mulli r3, r4, 3 slwi r5, r4, 1 li r6, 0 add r2, r2, r5 LBB1_2: ;bb li r5, 0 add r7, r3, r6 stbx r5, r2, r6 add r6, r4, r6 cmpwi cr0, r7, 8192 ble cr0, LBB1_2 ;bb This speeds up Benchmarks/Shootout/sieve from 8.533s to 6.464s and implements LoopStrengthReduce/var_stride_used_by_compare.ll --- Diffs of the changes: (+0 -4) LoopStrengthReduce.cpp | 4 ---- 1 files changed, 4 deletions(-) Index: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp diff -u llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.93 llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.94 --- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.93 Thu Nov 2 14:25:50 2006 +++ llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp Fri Nov 17 00:17:33 2006 @@ -1217,10 +1217,6 @@ } if (!CondUse) return; // setcc doesn't use the IV. - // setcc stride is complex, don't mess with users. - // FIXME: Evaluate whether this is a good idea or not. - if (!isa(*CondStride)) return; - // It's possible for the setcc instruction to be anywhere in the loop, and // possible for it to have multiple users. If it is not immediately before // the latch block branch, move it. From isanbard at gmail.com Fri Nov 17 01:11:05 2006 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 17 Nov 2006 01:11:05 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/AliasAnalysis.cpp PostDominators.cpp Message-ID: <200611170711.kAH7B5JY018819@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: AliasAnalysis.cpp updated: 1.29 -> 1.30 PostDominators.cpp updated: 1.61 -> 1.62 --- Log message: Removed unneeded #include. --- Diffs of the changes: (+0 -2) AliasAnalysis.cpp | 1 - PostDominators.cpp | 1 - 2 files changed, 2 deletions(-) Index: llvm/lib/Analysis/AliasAnalysis.cpp diff -u llvm/lib/Analysis/AliasAnalysis.cpp:1.29 llvm/lib/Analysis/AliasAnalysis.cpp:1.30 --- llvm/lib/Analysis/AliasAnalysis.cpp:1.29 Wed Jun 7 17:00:26 2006 +++ llvm/lib/Analysis/AliasAnalysis.cpp Fri Nov 17 01:10:51 2006 @@ -30,7 +30,6 @@ #include "llvm/Instructions.h" #include "llvm/Type.h" #include "llvm/Target/TargetData.h" -#include using namespace llvm; // Register the AliasAnalysis interface, providing a nice name to refer to. Index: llvm/lib/Analysis/PostDominators.cpp diff -u llvm/lib/Analysis/PostDominators.cpp:1.61 llvm/lib/Analysis/PostDominators.cpp:1.62 --- llvm/lib/Analysis/PostDominators.cpp:1.61 Wed Sep 27 12:18:05 2006 +++ llvm/lib/Analysis/PostDominators.cpp Fri Nov 17 01:10:51 2006 @@ -16,7 +16,6 @@ #include "llvm/Support/CFG.h" #include "llvm/ADT/DepthFirstIterator.h" #include "llvm/ADT/SetOperations.h" -#include using namespace llvm; //===----------------------------------------------------------------------===// From isanbard at gmail.com Fri Nov 17 01:34:14 2006 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 17 Nov 2006 01:34:14 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp CompleteBottomUp.cpp DataStructure.cpp EquivClassGraphs.cpp Local.cpp TopDownClosure.cpp Message-ID: <200611170734.kAH7YEKr019151@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: BottomUpClosure.cpp updated: 1.123 -> 1.124 CompleteBottomUp.cpp updated: 1.37 -> 1.38 DataStructure.cpp updated: 1.249 -> 1.250 EquivClassGraphs.cpp updated: 1.49 -> 1.50 Local.cpp updated: 1.159 -> 1.160 TopDownClosure.cpp updated: 1.93 -> 1.94 --- Log message: Replace DEBUG(std::cerr with DOUT. Removed some iostream #includes. --- Diffs of the changes: (+95 -106) BottomUpClosure.cpp | 60 ++++++++++++++++++++++++--------------------------- CompleteBottomUp.cpp | 23 +++++++++---------- DataStructure.cpp | 42 +++++++++++++++++------------------ EquivClassGraphs.cpp | 37 ++++++++++++++----------------- Local.cpp | 14 +++++------ TopDownClosure.cpp | 25 ++++++++------------- 6 files changed, 95 insertions(+), 106 deletions(-) Index: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp diff -u llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.123 llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.124 --- llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.123 Mon Oct 23 14:55:24 2006 +++ llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp Fri Nov 17 01:33:59 2006 @@ -138,8 +138,8 @@ DSNode *N = new DSNode(F->getType()->getElementType(), GI); // Create the node N->addGlobal(F); NHF.setTo(N,0); - DEBUG(std::cerr << "Adding " << F->getName() << " to a call node in " - << D.getCaller().getName() << "\n"); + DOUT << "Adding " << F->getName() << " to a call node in " + << D.getCaller().getName() << "\n"; } DL.getCalleeNode()->mergeWith(NHF, 0); } @@ -171,8 +171,8 @@ for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) if (!I->isExternal() && !DSInfo.count(I)) { if (MainFunc) - DEBUG(std::cerr << "*** BU: Function unreachable from main: " - << I->getName() << "\n"); + DOUT << "*** BU: Function unreachable from main: " + << I->getName() << "\n"; calculateGraphs(I, Stack, NextID, ValMap); // Calculate all graphs. } @@ -203,7 +203,7 @@ BuildGlobalECs(*GlobalsGraph, ECGlobals); if (!ECGlobals.empty()) { NamedRegionTimer X("Bottom-UP EC Cleanup"); - DEBUG(std::cerr << "Eliminating " << ECGlobals.size() << " EC Globals!\n"); + DOUT << "Eliminating " << ECGlobals.size() << " EC Globals!\n"; for (hash_map::iterator I = DSInfo.begin(), E = DSInfo.end(); I != E; ++I) EliminateUsesOfECGlobals(*I->second, ECGlobals); @@ -235,12 +235,12 @@ ee = MainGraph.afc_end(); ii != ee; ++ii) { std::vector Funcs; GetAllCalleesN(*ii, Funcs); - DEBUG(std::cerr << "Lost site\n"); + DOUT << "Lost site\n"; DEBUG(ii->getCallSite().getInstruction()->dump()); for (std::vector::iterator iif = Funcs.begin(), eef = Funcs.end(); iif != eef; ++iif) { AddGlobalToNode(this, *ii, *iif); - DEBUG(std::cerr << "Adding\n"); + DOUT << "Adding\n"; ActualCallees.insert(std::make_pair(ii->getCallSite().getInstruction(), *iif)); } } @@ -383,15 +383,15 @@ // If this is a new SCC, process it now. if (Stack.back() == F) { // Special case the single "SCC" case here. - DEBUG(std::cerr << "Visiting single node SCC #: " << MyID << " fn: " - << F->getName() << "\n"); + DOUT << "Visiting single node SCC #: " << MyID << " fn: " + << F->getName() << "\n"; Stack.pop_back(); DSGraph &G = getDSGraph(*F); - DEBUG(std::cerr << " [BU] Calculating graph for: " << F->getName()<< "\n"); + DOUT << " [BU] Calculating graph for: " << F->getName()<< "\n"; calculateGraph(G); - DEBUG(std::cerr << " [BU] Done inlining: " << F->getName() << " [" - << G.getGraphSize() << "+" << G.getAuxFunctionCalls().size() - << "]\n"); + DOUT << " [BU] Done inlining: " << F->getName() << " [" + << G.getGraphSize() << "+" << G.getAuxFunctionCalls().size() + << "]\n"; if (MaxSCC < 1) MaxSCC = 1; @@ -399,7 +399,7 @@ // callees. GetAllAuxCallees(Graph, CalleeFunctions); if (!CalleeFunctions.empty()) { - DEBUG(std::cerr << "Recalculating " << F->getName() << " due to new knowledge\n"); + DOUT << "Recalculating " << F->getName() << " due to new knowledge\n"; ValMap.erase(F); return calculateGraphs(F, Stack, NextID, ValMap); } else { @@ -440,8 +440,8 @@ } Stack.pop_back(); - DEBUG(std::cerr << "Calculating graph for SCC #: " << MyID << " of size: " - << SCCSize << "\n"); + DOUT << "Calculating graph for SCC #: " << MyID << " of size: " + << SCCSize << "\n"; // Compute the Max SCC Size. if (MaxSCC < SCCSize) @@ -453,10 +453,9 @@ // Now that we have one big happy family, resolve all of the call sites in // the graph... calculateGraph(SCCGraph); - DEBUG(std::cerr << " [BU] Done inlining SCC [" << SCCGraph.getGraphSize() - << "+" << SCCGraph.getAuxFunctionCalls().size() << "]\n"); - - DEBUG(std::cerr << "DONE with SCC #: " << MyID << "\n"); + DOUT << " [BU] Done inlining SCC [" << SCCGraph.getGraphSize() + << "+" << SCCGraph.getAuxFunctionCalls().size() << "]\n" + << "DONE with SCC #: " << MyID << "\n"; // We never have to revisit "SCC" processed functions... return MyID; @@ -579,12 +578,11 @@ // Get the data structure graph for the called function. GI = &getDSGraph(*Callee); // Graph to inline - DEBUG(std::cerr << " Inlining graph for " << Callee->getName()); - - DEBUG(std::cerr << "[" << GI->getGraphSize() << "+" - << GI->getAuxFunctionCalls().size() << "] into '" - << Graph.getFunctionNames() << "' [" << Graph.getGraphSize() <<"+" - << Graph.getAuxFunctionCalls().size() << "]\n"); + DOUT << " Inlining graph for " << Callee->getName() + << "[" << GI->getGraphSize() << "+" + << GI->getAuxFunctionCalls().size() << "] into '" + << Graph.getFunctionNames() << "' [" << Graph.getGraphSize() <<"+" + << Graph.getAuxFunctionCalls().size() << "]\n"; Graph.mergeInGraph(CS, *Callee, *GI, DSGraph::StripAllocaBit|DSGraph::DontCloneCallNodes); ++NumBUInlines; @@ -653,11 +651,11 @@ GI = IndCallGraph.first; // Merge the unified graph into this graph now. - DEBUG(std::cerr << " Inlining multi callee graph " - << "[" << GI->getGraphSize() << "+" - << GI->getAuxFunctionCalls().size() << "] into '" - << Graph.getFunctionNames() << "' [" << Graph.getGraphSize() <<"+" - << Graph.getAuxFunctionCalls().size() << "]\n"); + DOUT << " Inlining multi callee graph " + << "[" << GI->getGraphSize() << "+" + << GI->getAuxFunctionCalls().size() << "] into '" + << Graph.getFunctionNames() << "' [" << Graph.getGraphSize() <<"+" + << Graph.getAuxFunctionCalls().size() << "]\n"; Graph.mergeInGraph(CS, IndCallGraph.second, *GI, DSGraph::StripAllocaBit | Index: llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp diff -u llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp:1.37 llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp:1.38 --- llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp:1.37 Fri Oct 13 12:38:22 2006 +++ llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp Fri Nov 17 01:33:59 2006 @@ -21,7 +21,6 @@ #include "llvm/ADT/SCCIterator.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/STLExtras.h" -#include using namespace llvm; namespace { @@ -52,14 +51,14 @@ if (!MainFunc->isExternal()) calculateSCCGraphs(getOrCreateGraph(*MainFunc), Stack, NextID, ValMap); } else { - DEBUG(std::cerr << "CBU-DSA: No 'main' function found!\n"); + DOUT << "CBU-DSA: No 'main' function found!\n"; } for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) if (!I->isExternal() && !DSInfo.count(I)) { if (MainFunc) { - DEBUG(std::cerr << "*** CBU: Function unreachable from main: " - << I->getName() << "\n"); + DOUT << "*** CBU: Function unreachable from main: " + << I->getName() << "\n"; } calculateSCCGraphs(getOrCreateGraph(*I), Stack, NextID, ValMap); } @@ -218,14 +217,14 @@ G.mergeInGraph(CS, *CalleeFunc, GI, DSGraph::StripAllocaBit | DSGraph::DontCloneCallNodes | DSGraph::DontCloneAuxCallNodes); - DEBUG(std::cerr << " Inlining graph [" << i << "/" - << G.getFunctionCalls().size()-1 - << ":" << TNum << "/" << Num-1 << "] for " - << CalleeFunc->getName() << "[" - << GI.getGraphSize() << "+" << GI.getAuxFunctionCalls().size() - << "] into '" /*<< G.getFunctionNames()*/ << "' [" - << G.getGraphSize() << "+" << G.getAuxFunctionCalls().size() - << "]\n"); + DOUT << " Inlining graph [" << i << "/" + << G.getFunctionCalls().size()-1 + << ":" << TNum << "/" << Num-1 << "] for " + << CalleeFunc->getName() << "[" + << GI.getGraphSize() << "+" << GI.getAuxFunctionCalls().size() + << "] into '" /*<< G.getFunctionNames()*/ << "' [" + << G.getGraphSize() << "+" << G.getAuxFunctionCalls().size() + << "]\n"; } } } Index: llvm/lib/Analysis/DataStructure/DataStructure.cpp diff -u llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.249 llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.250 --- llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.249 Tue Nov 7 14:36:02 2006 +++ llvm/lib/Analysis/DataStructure/DataStructure.cpp Fri Nov 17 01:33:59 2006 @@ -431,8 +431,7 @@ /// bool DSNode::mergeTypeInfo(const Type *NewTy, unsigned Offset, bool FoldIfIncompatible) { - DEBUG(std::cerr << "merging " << *NewTy << " at " << Offset - << " with " << *Ty << "\n"); + DOUT << "merging " << *NewTy << " at " << Offset << " with " << *Ty << "\n"; const TargetData &TD = getTargetData(); // Check to make sure the Size member is up-to-date. Size can be one of the // following: @@ -521,9 +520,10 @@ //handle some common cases: // Ty: struct { t1, t2, t3, t4, ..., tn} // NewTy: struct { offset, stuff...} - // try merge with NewTy: struct {t1, t2, stuff...} if offset lands exactly on a field in Ty + // try merge with NewTy: struct {t1, t2, stuff...} if offset lands exactly + // on a field in Ty if (isa(NewTy) && isa(Ty)) { - DEBUG(std::cerr << "Ty: " << *Ty << "\nNewTy: " << *NewTy << "@" << Offset << "\n"); + DOUT << "Ty: " << *Ty << "\nNewTy: " << *NewTy << "@" << Offset << "\n"; const StructType *STy = cast(Ty); const StructLayout &SL = *TD.getStructLayout(STy); unsigned i = SL.getElementContainingOffset(Offset); @@ -539,15 +539,16 @@ nt.insert(nt.end(), STy->element_begin(), STy->element_end()); //and merge STy = StructType::get(nt); - DEBUG(std::cerr << "Trying with: " << *STy << "\n"); + DOUT << "Trying with: " << *STy << "\n"; return mergeTypeInfo(STy, 0); } //Ty: struct { t1, t2, t3 ... tn} //NewTy T offset x - //try merge with NewTy: struct : {t1, t2, T} if offset lands on a field in Ty + //try merge with NewTy: struct : {t1, t2, T} if offset lands on a field + //in Ty if (isa(Ty)) { - DEBUG(std::cerr << "Ty: " << *Ty << "\nNewTy: " << *NewTy << "@" << Offset << "\n"); + DOUT << "Ty: " << *Ty << "\nNewTy: " << *NewTy << "@" << Offset << "\n"; const StructType *STy = cast(Ty); const StructLayout &SL = *TD.getStructLayout(STy); unsigned i = SL.getElementContainingOffset(Offset); @@ -562,12 +563,13 @@ nt.push_back(NewTy); //and merge STy = StructType::get(nt); - DEBUG(std::cerr << "Trying with: " << *STy << "\n"); + DOUT << "Trying with: " << *STy << "\n"; return mergeTypeInfo(STy, 0); } - std::cerr << "UNIMP: Trying to merge a growth type into " - << "offset != 0: Collapsing!\n"; + assert(0 && + "UNIMP: Trying to merge a growth type into " + "offset != 0: Collapsing!"); abort(); if (FoldIfIncompatible) foldNodeCompletely(); return true; @@ -717,10 +719,11 @@ Module *M = 0; if (getParentGraph()->retnodes_begin() != getParentGraph()->retnodes_end()) M = getParentGraph()->retnodes_begin()->first->getParent(); - DEBUG(std::cerr << "MergeTypeInfo Folding OrigTy: "; - WriteTypeSymbolic(std::cerr, Ty, M) << "\n due to:"; + + DOUT << "MergeTypeInfo Folding OrigTy: "; + DEBUG(WriteTypeSymbolic(std::cerr, Ty, M) << "\n due to:"; WriteTypeSymbolic(std::cerr, NewTy, M) << " @ " << Offset << "!\n" - << "SubType: "; + << "SubType: "; WriteTypeSymbolic(std::cerr, SubType, M) << "\n\n"); if (FoldIfIncompatible) foldNodeCompletely(); @@ -926,8 +929,7 @@ if (N == this) { // We cannot merge two pieces of the same node together, collapse the node // completely. - DEBUG(std::cerr << "Attempting to merge two chunks of" - << " the same node together!\n"); + DOUT << "Attempting to merge two chunks of the same node together!\n"; foldNodeCompletely(); return; } @@ -1808,9 +1810,7 @@ // eliminate it. if (Callee->getNumReferrers() == 1 && Callee->isComplete() && Callee->getGlobalsList().empty()) { // No useful info? -#ifndef NDEBUG - std::cerr << "WARNING: Useless call site found.\n"; -#endif + DOUT << "WARNING: Useless call site found.\n"; Calls.erase(OldIt); ++NumDeleted; continue; @@ -1930,8 +1930,8 @@ // Track the number of call nodes merged away... NumCallNodesMerged += NumDeleted; - DEBUG(if (NumDeleted) - std::cerr << "Merged " << NumDeleted << " call nodes.\n";); + if (NumDeleted) + DOUT << "Merged " << NumDeleted << " call nodes.\n"; } @@ -2263,7 +2263,7 @@ #if 0 if (CS.getNumPtrArgs() && CS.getCalleeNode() == CS.getPtrArg(0).getNode() && CS.getCalleeNode() && CS.getCalleeNode()->getGlobals().empty()) - std::cerr << "WARNING: WEIRD CALL SITE FOUND!\n"; + DOUT << "WARNING: WEIRD CALL SITE FOUND!\n"; #endif } AssertNodeInGraph(CS.getRetVal().getNode()); Index: llvm/lib/Analysis/DataStructure/EquivClassGraphs.cpp diff -u llvm/lib/Analysis/DataStructure/EquivClassGraphs.cpp:1.49 llvm/lib/Analysis/DataStructure/EquivClassGraphs.cpp:1.50 --- llvm/lib/Analysis/DataStructure/EquivClassGraphs.cpp:1.49 Thu Nov 2 14:25:49 2006 +++ llvm/lib/Analysis/DataStructure/EquivClassGraphs.cpp Fri Nov 17 01:33:59 2006 @@ -213,7 +213,7 @@ // Now that all of the equivalences have been built, merge the graphs for // each equivalence class. // - DEBUG(std::cerr << "\nIndirect Function Equivalence Sets:\n"); + DOUT << "\nIndirect Function Equivalence Sets:\n"; for (EquivalenceClasses::iterator EQSI = FuncECs.begin(), E = FuncECs.end(); EQSI != E; ++EQSI) { if (!EQSI->isLeader()) continue; @@ -229,10 +229,10 @@ Function* LF = *SI; #ifndef NDEBUG - DEBUG(std::cerr <<" Equivalence set for leader " << LF->getName() <<" = "); + DOUT <<" Equivalence set for leader " << LF->getName() <<" = "; for (SN = SI; SN != FuncECs.member_end(); ++SN) - DEBUG(std::cerr << " " << (*SN)->getName() << "," ); - DEBUG(std::cerr << "\n"); + DOUT << " " << (*SN)->getName() << "," ; + DOUT << "\n"; #endif // This equiv class has multiple functions: merge their graphs. First, @@ -286,7 +286,7 @@ DEBUG(MergedG.AssertGraphOK()); } } - DEBUG(std::cerr << "\n"); + DOUT << "\n"; } @@ -322,8 +322,7 @@ if (It != ValMap.end() && It->first == &FG) return It->second; - DEBUG(std::cerr << " ProcessSCC for function " << FG.getFunctionNames() - << "\n"); + DOUT << " ProcessSCC for function " << FG.getFunctionNames() << "\n"; unsigned Min = NextID++, MyID = Min; ValMap[&FG] = Min; @@ -386,8 +385,7 @@ /// processGraph - Process the CBU graphs for the program in bottom-up order on /// the SCC of the __ACTUAL__ call graph. This builds final folded CBU graphs. void EquivClassGraphs::processGraph(DSGraph &G) { - DEBUG(std::cerr << " ProcessGraph for function " - << G.getFunctionNames() << "\n"); + DOUT << " ProcessGraph for function " << G.getFunctionNames() << "\n"; hash_set calls; @@ -434,15 +432,15 @@ DSGraph::StripAllocaBit | DSGraph::DontCloneCallNodes | DSGraph::DontCloneAuxCallNodes); - DEBUG(std::cerr << " Inlining graph [" << i << "/" - << G.getFunctionCalls().size()-1 - << ":" << TNum << "/" << Num-1 << "] for " - << CalleeFunc->getName() << "[" - << CalleeGraph->getGraphSize() << "+" - << CalleeGraph->getAuxFunctionCalls().size() - << "] into '" /*<< G.getFunctionNames()*/ << "' [" - << G.getGraphSize() << "+" << G.getAuxFunctionCalls().size() - << "]\n"); + DOUT << " Inlining graph [" << i << "/" + << G.getFunctionCalls().size()-1 + << ":" << TNum << "/" << Num-1 << "] for " + << CalleeFunc->getName() << "[" + << CalleeGraph->getGraphSize() << "+" + << CalleeGraph->getAuxFunctionCalls().size() + << "] into '" /*<< G.getFunctionNames()*/ << "' [" + << G.getGraphSize() << "+" << G.getAuxFunctionCalls().size() + << "]\n"; } } @@ -476,6 +474,5 @@ E = MainSM.global_end(); I != E; ++I) RC.getClonedNH(MainSM[*I]); - DEBUG(std::cerr << " -- DONE ProcessGraph for function " - << G.getFunctionNames() << "\n"); + DOUT << " -- DONE ProcessGraph for function " << G.getFunctionNames() <<"\n"; } Index: llvm/lib/Analysis/DataStructure/Local.cpp diff -u llvm/lib/Analysis/DataStructure/Local.cpp:1.159 llvm/lib/Analysis/DataStructure/Local.cpp:1.160 --- llvm/lib/Analysis/DataStructure/Local.cpp:1.159 Tue Nov 7 14:39:05 2006 +++ llvm/lib/Analysis/DataStructure/Local.cpp Fri Nov 17 01:33:59 2006 @@ -188,7 +188,7 @@ : GlobalsGraph(GG), ScalarMap(ECs), TD(td) { PrintAuxCalls = false; - DEBUG(std::cerr << " [Loc] Calculating graph for: " << F.getName() << "\n"); + DOUT << " [Loc] Calculating graph for: " << F.getName() << "\n"; // Use the graph builder to construct the local version of the graph GraphBuilder B(F, *this, ReturnNodes[&F], FunctionCalls); @@ -573,7 +573,7 @@ N->setModifiedMarker(); return true; default: - DEBUG(std::cerr << "[dsa:local] Unhandled intrinsic: " << F->getName() << "\n"); + DOUT << "[dsa:local] Unhandled intrinsic: " << F->getName() << "\n"; return false; } } @@ -1047,8 +1047,8 @@ break; } if (Warn) { - DEBUG(std::cerr << "WARNING: Call to unknown external function '" - << F->getName() << "' will cause pessimistic results!\n"); + DOUT << "WARNING: Call to unknown external function '" + << F->getName() << "' will cause pessimistic results!\n"; } } @@ -1158,7 +1158,7 @@ DSNodeHandle NewNH(NHN, NH.getOffset()+(unsigned)SL->MemberOffsets[i]); MergeConstantInitIntoNode(NewNH, cast(CS->getOperand(i))); } else if (SL->MemberOffsets[i] == SL->StructSize) { - DEBUG(std::cerr << "Zero size element at end of struct\n"); + DOUT << "Zero size element at end of struct\n"; NHN->foldNodeCompletely(); } else { assert(0 && "type was smaller than offsets of of struct layout indicate"); @@ -1280,7 +1280,7 @@ // together the globals into equivalence classes. std::set ECGlobals; BuildGlobalECs(*GlobalsGraph, ECGlobals); - DEBUG(std::cerr << "Eliminating " << ECGlobals.size() << " EC Globals!\n"); + DOUT << "Eliminating " << ECGlobals.size() << " EC Globals!\n"; ECGlobals.clear(); // Calculate all of the graphs... @@ -1298,7 +1298,7 @@ // program. BuildGlobalECs(*GlobalsGraph, ECGlobals); if (!ECGlobals.empty()) { - DEBUG(std::cerr << "Eliminating " << ECGlobals.size() << " EC Globals!\n"); + DOUT << "Eliminating " << ECGlobals.size() << " EC Globals!\n"; for (hash_map::iterator I = DSInfo.begin(), E = DSInfo.end(); I != E; ++I) EliminateUsesOfECGlobals(*I->second, ECGlobals); Index: llvm/lib/Analysis/DataStructure/TopDownClosure.cpp diff -u llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.93 llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.94 --- llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.93 Tue Nov 7 14:35:11 2006 +++ llvm/lib/Analysis/DataStructure/TopDownClosure.cpp Fri Nov 17 01:33:59 2006 @@ -21,7 +21,6 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/Timer.h" #include "llvm/ADT/Statistic.h" -#include using namespace llvm; #if 0 @@ -241,8 +240,7 @@ RC.getClonedNH(GG.getNodeForValue(*GI)); } - DEBUG(std::cerr << "[TD] Inlining callers into '" << DSG.getFunctionNames() - << "'\n"); + DOUT << "[TD] Inlining callers into '" << DSG.getFunctionNames() << "'\n"; // Iteratively inline caller graphs into this graph. while (!EdgesFromCaller.empty()) { @@ -258,16 +256,13 @@ do { const DSCallSite &CS = *EdgesFromCaller.back().CS; Function &CF = *EdgesFromCaller.back().CalledFunction; - DEBUG(std::cerr << " [TD] Inlining graph into Fn '" - << CF.getName() << "' from "); + DOUT << " [TD] Inlining graph into Fn '" << CF.getName() << "' from "; if (CallerGraph.getReturnNodes().empty()) - DEBUG(std::cerr << "SYNTHESIZED INDIRECT GRAPH"); + DOUT << "SYNTHESIZED INDIRECT GRAPH"; else - DEBUG (std::cerr << "Fn '" - << CS.getCallSite().getInstruction()-> - getParent()->getParent()->getName() << "'"); - DEBUG(std::cerr << ": " << CF.getFunctionType()->getNumParams() - << " args\n"); + DOUT << "Fn '" << CS.getCallSite().getInstruction()-> + getParent()->getParent()->getName() << "'"; + DOUT << ": " << CF.getFunctionType()->getNumParams() << " args\n"; // Get the formal argument and return nodes for the called function and // merge them with the cloned subgraph. @@ -371,8 +366,8 @@ // If we already have this graph, recycle it. if (IndCallRecI != IndCallMap.end() && IndCallRecI->first == Callees) { - DEBUG(std::cerr << " [TD] *** Reuse of indcall graph for " << Callees.size() - << " callees!\n"); + DOUT << " [TD] *** Reuse of indcall graph for " << Callees.size() + << " callees!\n"; IndCallGraph = IndCallRecI->second; } else { // Otherwise, create a new DSGraph to represent this. @@ -464,8 +459,8 @@ return; } - std::cerr << *From; - std::cerr << *To; + DOUT << *From; + DOUT << *To; assert(0 && "Do not know how to copy this yet!"); abort(); } From isanbard at gmail.com Fri Nov 17 01:37:09 2006 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 17 Nov 2006 01:37:09 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/IPA/Andersens.cpp Message-ID: <200611170737.kAH7b9ms019205@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/IPA: Andersens.cpp updated: 1.35 -> 1.36 --- Log message: Replaced DEBUG(std::cerr with DOUT. --- Diffs of the changes: (+5 -6) Andersens.cpp | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-) Index: llvm/lib/Analysis/IPA/Andersens.cpp diff -u llvm/lib/Analysis/IPA/Andersens.cpp:1.35 llvm/lib/Analysis/IPA/Andersens.cpp:1.36 --- llvm/lib/Analysis/IPA/Andersens.cpp:1.35 Wed Nov 8 00:47:33 2006 +++ llvm/lib/Analysis/IPA/Andersens.cpp Fri Nov 17 01:36:54 2006 @@ -1036,7 +1036,7 @@ while (Changed) { Changed = false; ++NumIters; - DEBUG(std::cerr << "Starting iteration #" << Iteration++ << "!\n"); + DOUT << "Starting iteration #" << Iteration++ << "!\n"; // Loop over all of the constraints, applying them in turn. for (unsigned i = 0, e = Constraints.size(); i != e; ++i) { @@ -1069,8 +1069,7 @@ // We found a function that is just now escaping. Mark it as if it // didn't have internal linkage. AddConstraintsForNonInternalLinkage(F); - DEBUG(std::cerr << "Found escaping internal function: " - << F->getName() << "\n"); + DOUT << "Found escaping internal function: " << F->getName() <<"\n"; ++NumEscapingFunctions; } @@ -1088,9 +1087,9 @@ if (IP == KnownCallees.end() || *IP != F) { // Add the constraints for the call now. AddConstraintsForCall(CS, F); - DEBUG(std::cerr << "Found actual callee '" - << F->getName() << "' for call: " - << *CS.getInstruction() << "\n"); + DOUT << "Found actual callee '" + << F->getName() << "' for call: " + << *CS.getInstruction() << "\n"; ++NumIndirectCallees; KnownCallees.insert(IP, F); } From isanbard at gmail.com Fri Nov 17 01:52:17 2006 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 17 Nov 2006 01:52:17 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp X86CodeEmitter.cpp X86ISelDAGToDAG.cpp X86JITInfo.cpp X86TargetMachine.cpp Message-ID: <200611170752.kAH7qH8N019506@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ATTAsmPrinter.cpp updated: 1.72 -> 1.73 X86CodeEmitter.cpp updated: 1.122 -> 1.123 X86ISelDAGToDAG.cpp updated: 1.127 -> 1.128 X86JITInfo.cpp updated: 1.31 -> 1.32 X86TargetMachine.cpp updated: 1.127 -> 1.128 --- Log message: Removed even more std::cerr and #include things. --- Diffs of the changes: (+20 -31) X86ATTAsmPrinter.cpp | 1 - X86CodeEmitter.cpp | 4 +--- X86ISelDAGToDAG.cpp | 34 ++++++++++++++-------------------- X86JITInfo.cpp | 11 +++++------ X86TargetMachine.cpp | 1 - 5 files changed, 20 insertions(+), 31 deletions(-) Index: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp diff -u llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.72 llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.73 --- llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.72 Tue Oct 31 14:12:30 2006 +++ llvm/lib/Target/X86/X86ATTAsmPrinter.cpp Fri Nov 17 01:52:03 2006 @@ -23,7 +23,6 @@ #include "llvm/Support/Mangler.h" #include "llvm/Target/TargetAsmInfo.h" #include "llvm/Target/TargetOptions.h" -#include using namespace llvm; /// getSectionForFunction - Return the section that we should emit the Index: llvm/lib/Target/X86/X86CodeEmitter.cpp diff -u llvm/lib/Target/X86/X86CodeEmitter.cpp:1.122 llvm/lib/Target/X86/X86CodeEmitter.cpp:1.123 --- llvm/lib/Target/X86/X86CodeEmitter.cpp:1.122 Thu Nov 9 19:28:43 2006 +++ llvm/lib/Target/X86/X86CodeEmitter.cpp Fri Nov 17 01:52:03 2006 @@ -26,7 +26,6 @@ #include "llvm/ADT/Statistic.h" #include "llvm/Support/Compiler.h" #include "llvm/Target/TargetOptions.h" -#include using namespace llvm; namespace { @@ -623,8 +622,7 @@ default: assert(0 && "psuedo instructions should be removed before code emission"); case TargetInstrInfo::INLINEASM: - std::cerr << "JIT does not support inline asm!\n"; - abort(); + assert(0 && "JIT does not support inline asm!\n"); case X86::IMPLICIT_USE: case X86::IMPLICIT_DEF: case X86::IMPLICIT_DEF_GR8: Index: llvm/lib/Target/X86/X86ISelDAGToDAG.cpp diff -u llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:1.127 llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:1.128 --- llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:1.127 Mon Nov 13 17:36:35 2006 +++ llvm/lib/Target/X86/X86ISelDAGToDAG.cpp Fri Nov 17 01:52:03 2006 @@ -464,12 +464,12 @@ // Codegen the basic block. #ifndef NDEBUG - DEBUG(std::cerr << "===== Instruction selection begins:\n"); + DOUT << "===== Instruction selection begins:\n"; Indent = 0; #endif DAG.setRoot(SelectRoot(DAG.getRoot())); #ifndef NDEBUG - DEBUG(std::cerr << "===== Instruction selection ends:\n"); + DOUT << "===== Instruction selection ends:\n"; #endif DAG.RemoveDeadNodes(); @@ -966,19 +966,17 @@ unsigned Opcode = Node->getOpcode(); #ifndef NDEBUG - DEBUG(std::cerr << std::string(Indent, ' ')); - DEBUG(std::cerr << "Selecting: "); + DOUT << std::string(Indent, ' ') << "Selecting: "; DEBUG(Node->dump(CurDAG)); - DEBUG(std::cerr << "\n"); + DOUT << "\n"; Indent += 2; #endif if (Opcode >= ISD::BUILTIN_OP_END && Opcode < X86ISD::FIRST_NUMBER) { #ifndef NDEBUG - DEBUG(std::cerr << std::string(Indent-2, ' ')); - DEBUG(std::cerr << "== "); + DOUT << std::string(Indent-2, ' ') << "== "; DEBUG(Node->dump(CurDAG)); - DEBUG(std::cerr << "\n"); + DOUT << "\n"; Indent -= 2; #endif return NULL; // Already selected. @@ -1106,10 +1104,9 @@ ReplaceUses(N1.getValue(1), Result.getValue(1)); #ifndef NDEBUG - DEBUG(std::cerr << std::string(Indent-2, ' ')); - DEBUG(std::cerr << "=> "); + DOUT << std::string(Indent-2, ' ') << "=> "; DEBUG(Result.Val->dump(CurDAG)); - DEBUG(std::cerr << "\n"); + DOUT << "\n"; Indent -= 2; #endif return NULL; @@ -1218,10 +1215,9 @@ ReplaceUses(N1.getValue(1), Result.getValue(1)); #ifndef NDEBUG - DEBUG(std::cerr << std::string(Indent-2, ' ')); - DEBUG(std::cerr << "=> "); + DOUT << std::string(Indent-2, ' ') << "=> "; DEBUG(Result.Val->dump(CurDAG)); - DEBUG(std::cerr << "\n"); + DOUT << "\n"; Indent -= 2; #endif @@ -1252,10 +1248,9 @@ SDNode *ResNode = CurDAG->getTargetNode(Opc2, NVT, Tmp); #ifndef NDEBUG - DEBUG(std::cerr << std::string(Indent-2, ' ')); - DEBUG(std::cerr << "=> "); + DOUT << std::string(Indent-2, ' ') << "=> "; DEBUG(ResNode->dump(CurDAG)); - DEBUG(std::cerr << "\n"); + DOUT << "\n"; Indent -= 2; #endif return ResNode; @@ -1268,13 +1263,12 @@ SDNode *ResNode = SelectCode(N); #ifndef NDEBUG - DEBUG(std::cerr << std::string(Indent-2, ' ')); - DEBUG(std::cerr << "=> "); + DOUT << std::string(Indent-2, ' ') << "=> "; if (ResNode == NULL || ResNode == N.Val) DEBUG(N.Val->dump(CurDAG)); else DEBUG(ResNode->dump(CurDAG)); - DEBUG(std::cerr << "\n"); + DOUT << "\n"; Indent -= 2; #endif Index: llvm/lib/Target/X86/X86JITInfo.cpp diff -u llvm/lib/Target/X86/X86JITInfo.cpp:1.31 llvm/lib/Target/X86/X86JITInfo.cpp:1.32 --- llvm/lib/Target/X86/X86JITInfo.cpp:1.31 Thu Nov 16 14:13:34 2006 +++ llvm/lib/Target/X86/X86JITInfo.cpp Fri Nov 17 01:52:03 2006 @@ -18,7 +18,6 @@ #include "llvm/CodeGen/MachineCodeEmitter.h" #include "llvm/Config/alloca.h" #include -#include using namespace llvm; #ifdef _MSC_VER @@ -195,7 +194,7 @@ #else // Not an i386 host void X86CompilationCallback() { - std::cerr << "Cannot call X86CompilationCallback() on a non-x86 arch!\n"; + assert(0 && "Cannot call X86CompilationCallback() on a non-x86 arch!\n"); abort(); } #endif @@ -225,10 +224,10 @@ RetAddr -= 4; // Backtrack to the reference itself... #if 0 - DEBUG(std::cerr << "In callback! Addr=" << (void*)RetAddr - << " ESP=" << (void*)StackPtr - << ": Resolving call to function: " - << TheVM->getFunctionReferencedName((void*)RetAddr) << "\n"); + DOUT << "In callback! Addr=" << (void*)RetAddr + << " ESP=" << (void*)StackPtr + << ": Resolving call to function: " + << TheVM->getFunctionReferencedName((void*)RetAddr) << "\n"; #endif // Sanity check to make sure this really is a call instruction. Index: llvm/lib/Target/X86/X86TargetMachine.cpp diff -u llvm/lib/Target/X86/X86TargetMachine.cpp:1.127 llvm/lib/Target/X86/X86TargetMachine.cpp:1.128 --- llvm/lib/Target/X86/X86TargetMachine.cpp:1.127 Fri Sep 8 01:48:29 2006 +++ llvm/lib/Target/X86/X86TargetMachine.cpp Fri Nov 17 01:52:03 2006 @@ -21,7 +21,6 @@ #include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetMachineRegistry.h" #include "llvm/Transforms/Scalar.h" -#include using namespace llvm; /// X86TargetMachineModule - Note that this is used on hosts that cannot link From isanbard at gmail.com Fri Nov 17 02:04:02 2006 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 17 Nov 2006 02:04:02 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp Dominators.cpp SymbolTable.cpp Type.cpp Value.cpp ValueSymbolTable.cpp Message-ID: <200611170804.kAH842BO019696@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Constants.cpp updated: 1.170 -> 1.171 Dominators.cpp updated: 1.77 -> 1.78 SymbolTable.cpp updated: 1.62 -> 1.63 Type.cpp updated: 1.149 -> 1.150 Value.cpp updated: 1.58 -> 1.59 ValueSymbolTable.cpp updated: 1.2 -> 1.3 --- Log message: Removed iostream #includes. Replaced std::cerr with DOUT. --- Diffs of the changes: (+71 -74) Constants.cpp | 12 +++++----- Dominators.cpp | 1 SymbolTable.cpp | 58 +++++++++++++++++++++++++-------------------------- Type.cpp | 47 ++++++++++++++++++++--------------------- Value.cpp | 8 +++---- ValueSymbolTable.cpp | 19 +++++++--------- 6 files changed, 71 insertions(+), 74 deletions(-) Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.170 llvm/lib/VMCore/Constants.cpp:1.171 --- llvm/lib/VMCore/Constants.cpp:1.170 Wed Nov 8 00:47:33 2006 +++ llvm/lib/VMCore/Constants.cpp Fri Nov 17 02:03:48 2006 @@ -19,11 +19,11 @@ #include "llvm/SymbolTable.h" #include "llvm/Module.h" #include "llvm/ADT/StringExtras.h" -#include "llvm/Support/MathExtras.h" #include "llvm/Support/Compiler.h" +#include "llvm/Support/Debug.h" #include "llvm/Support/ManagedStatic.h" +#include "llvm/Support/MathExtras.h" #include -#include using namespace llvm; //===----------------------------------------------------------------------===// @@ -42,9 +42,9 @@ Value *V = use_back(); #ifndef NDEBUG // Only in -g mode... if (!isa(V)) - std::cerr << "While deleting: " << *this - << "\n\nUse still stuck around after Def is destroyed: " - << *V << "\n\n"; + DOUT << "While deleting: " << *this + << "\n\nUse still stuck around after Def is destroyed: " + << *V << "\n\n"; #endif assert(isa(V) && "References remain to Constant being destroyed"); Constant *CV = cast(V); @@ -870,7 +870,7 @@ } void dump() const { - std::cerr << "Constant.cpp: ValueMap\n"; + DOUT << "Constant.cpp: ValueMap\n"; } }; } Index: llvm/lib/VMCore/Dominators.cpp diff -u llvm/lib/VMCore/Dominators.cpp:1.77 llvm/lib/VMCore/Dominators.cpp:1.78 --- llvm/lib/VMCore/Dominators.cpp:1.77 Thu Sep 21 20:07:57 2006 +++ llvm/lib/VMCore/Dominators.cpp Fri Nov 17 02:03:48 2006 @@ -20,7 +20,6 @@ #include "llvm/ADT/DepthFirstIterator.h" #include "llvm/ADT/SetOperations.h" #include -#include using namespace llvm; //===----------------------------------------------------------------------===// Index: llvm/lib/VMCore/SymbolTable.cpp diff -u llvm/lib/VMCore/SymbolTable.cpp:1.62 llvm/lib/VMCore/SymbolTable.cpp:1.63 --- llvm/lib/VMCore/SymbolTable.cpp:1.62 Mon May 29 07:54:52 2006 +++ llvm/lib/VMCore/SymbolTable.cpp Fri Nov 17 02:03:48 2006 @@ -16,9 +16,8 @@ #include "llvm/DerivedTypes.h" #include "llvm/Module.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/Support/Debug.h" #include -#include - using namespace llvm; #define DEBUG_SYMBOL_TABLE 0 @@ -39,9 +38,9 @@ for (plane_iterator PI = pmap.begin(); PI != pmap.end(); ++PI) { for (value_iterator VI = PI->second.begin(); VI != PI->second.end(); ++VI) if (!isa(VI->second) ) { - std::cerr << "Value still in symbol table! Type = '" - << PI->first->getDescription() << "' Name = '" - << VI->first << "'\n"; + DOUT << "Value still in symbol table! Type = '" + << PI->first->getDescription() << "' Name = '" + << VI->first << "'\n"; LeftoverValues = false; } } @@ -136,7 +135,7 @@ #if DEBUG_SYMBOL_TABLE dump(); - std::cerr << " Removing Value: " << Entry->second->getName() << "\n"; + DOUT << " Removing Value: " << Entry->second->getName() << "\n"; #endif // Remove the value from the plane... @@ -149,8 +148,8 @@ // if (N->getType()->isAbstract()) { #if DEBUG_ABSTYPE - std::cerr << "Plane Empty: Removing type: " - << N->getType()->getDescription() << "\n"; + DOUT << "Plane Empty: Removing type: " + << N->getType()->getDescription() << "\n"; #endif cast(N->getType())->removeAbstractTypeUser(this); } @@ -167,7 +166,7 @@ #if DEBUG_SYMBOL_TABLE dump(); - std::cerr << " Removing type: " << Entry->first << "\n"; + DOUT << " Removing type: " << Entry->first << "\n"; #endif tmap.erase(Entry); @@ -176,7 +175,8 @@ // list... if (Result->isAbstract()) { #if DEBUG_ABSTYPE - std::cerr << "Removing abstract type from symtab" << Result->getDescription()<<"\n"; + DOUT << "Removing abstract type from symtab" + << Result->getDescription() << "\n"; #endif cast(Result)->removeAbstractTypeUser(this); } @@ -194,8 +194,8 @@ #if DEBUG_SYMBOL_TABLE dump(); - std::cerr << " Inserting definition: " << Name << ": " - << VTy->getDescription() << "\n"; + DOUT << " Inserting definition: " << Name << ": " + << VTy->getDescription() << "\n"; #endif if (PI == pmap.end()) { // Not in collection yet... insert dummy entry @@ -210,8 +210,8 @@ if (VTy->isAbstract()) { cast(VTy)->addAbstractTypeUser(this); #if DEBUG_ABSTYPE - std::cerr << "Added abstract type value: " << VTy->getDescription() - << "\n"; + DOUT << "Added abstract type value: " << VTy->getDescription() + << "\n"; #endif } @@ -243,8 +243,8 @@ #if DEBUG_SYMBOL_TABLE dump(); - std::cerr << " Inserting type: " << UniqueName << ": " - << T->getDescription() << "\n"; + DOUT << " Inserting type: " << UniqueName << ": " + << T->getDescription() << "\n"; #endif // Insert the tmap entry @@ -254,7 +254,7 @@ if (T->isAbstract()) { cast(T)->addAbstractTypeUser(this); #if DEBUG_ABSTYPE - std::cerr << "Added abstract type to ST: " << T->getDescription() << "\n"; + DOUT << "Added abstract type to ST: " << T->getDescription() << "\n"; #endif } } @@ -303,8 +303,8 @@ if (NewType->isAbstract()) { cast(NewType)->addAbstractTypeUser(this); #if DEBUG_ABSTYPE - std::cerr << "[Added] refined to abstype: " << NewType->getDescription() - << "\n"; + DOUT << "[Added] refined to abstype: " << NewType->getDescription() + << "\n"; #endif } } @@ -368,7 +368,7 @@ // Ok, now we are not referencing the type anymore... take me off your user // list please! #if DEBUG_ABSTYPE - std::cerr << "Removing type " << OldType->getDescription() << "\n"; + DOUT << "Removing type " << OldType->getDescription() << "\n"; #endif OldType->removeAbstractTypeUser(this); @@ -384,14 +384,14 @@ for (type_iterator I = type_begin(), E = type_end(); I != E; ++I) { if (I->second == (Type*)OldType) { // FIXME when Types aren't const. #if DEBUG_ABSTYPE - std::cerr << "Removing type " << OldType->getDescription() << "\n"; + DOUT << "Removing type " << OldType->getDescription() << "\n"; #endif OldType->removeAbstractTypeUser(this); I->second = (Type*)NewType; // TODO FIXME when types aren't const if (NewType->isAbstract()) { #if DEBUG_ABSTYPE - std::cerr << "Added type " << NewType->getDescription() << "\n"; + DOUT << "Added type " << NewType->getDescription() << "\n"; #endif cast(NewType)->addAbstractTypeUser(this); } @@ -418,28 +418,28 @@ } static void DumpVal(const std::pair &V) { - std::cerr << " '" << V.first << "' = "; + DOUT << " '" << V.first << "' = "; V.second->dump(); - std::cerr << "\n"; + DOUT << "\n"; } static void DumpPlane(const std::pair >&P){ P.first->dump(); - std::cerr << "\n"; + DOUT << "\n"; for_each(P.second.begin(), P.second.end(), DumpVal); } static void DumpTypes(const std::pair& T ) { - std::cerr << " '" << T.first << "' = "; + DOUT << " '" << T.first << "' = "; T.second->dump(); - std::cerr << "\n"; + DOUT << "\n"; } void SymbolTable::dump() const { - std::cerr << "Symbol table dump:\n Plane:"; + DOUT << "Symbol table dump:\n Plane:"; for_each(pmap.begin(), pmap.end(), DumpPlane); - std::cerr << " Types: "; + DOUT << " Types: "; for_each(tmap.begin(), tmap.end(), DumpTypes); } Index: llvm/lib/VMCore/Type.cpp diff -u llvm/lib/VMCore/Type.cpp:1.149 llvm/lib/VMCore/Type.cpp:1.150 --- llvm/lib/VMCore/Type.cpp:1.149 Thu Oct 26 13:22:45 2006 +++ llvm/lib/VMCore/Type.cpp Fri Nov 17 02:03:48 2006 @@ -23,7 +23,6 @@ #include "llvm/Support/Compiler.h" #include "llvm/Support/ManagedStatic.h" #include -#include using namespace llvm; // DEBUG_MERGE_TYPES - Enable this #define to see how and when derived types are @@ -487,7 +486,7 @@ OpaqueType::OpaqueType() : DerivedType(OpaqueTyID) { setAbstract(true); #ifdef DEBUG_MERGE_TYPES - std::cerr << "Derived new type: " << *this << "\n"; + DOUT << "Derived new type: " << *this << "\n"; #endif } @@ -831,8 +830,8 @@ void RefineAbstractType(TypeClass *Ty, const DerivedType *OldType, const Type *NewType) { #ifdef DEBUG_MERGE_TYPES - std::cerr << "RefineAbstractType(" << (void*)OldType << "[" << *OldType - << "], " << (void*)NewType << " [" << *NewType << "])\n"; + DOUT << "RefineAbstractType(" << (void*)OldType << "[" << *OldType + << "], " << (void*)NewType << " [" << *NewType << "])\n"; #endif // Otherwise, we are changing one subelement type into another. Clearly the @@ -937,12 +936,12 @@ void print(const char *Arg) const { #ifdef DEBUG_MERGE_TYPES - std::cerr << "TypeMap<>::" << Arg << " table contents:\n"; + DOUT << "TypeMap<>::" << Arg << " table contents:\n"; unsigned i = 0; for (typename std::map::const_iterator I = Map.begin(), E = Map.end(); I != E; ++I) - std::cerr << " " << (++i) << ". " << (void*)I->second.get() << " " - << *I->second.get() << "\n"; + DOUT << " " << (++i) << ". " << (void*)I->second.get() << " " + << *I->second.get() << "\n"; #endif } @@ -1016,7 +1015,7 @@ FunctionTypes->add(VT, MT = new FunctionType(ReturnType, Params, isVarArg)); #ifdef DEBUG_MERGE_TYPES - std::cerr << "Derived new type: " << MT << "\n"; + DOUT << "Derived new type: " << MT << "\n"; #endif return MT; } @@ -1065,7 +1064,7 @@ ArrayTypes->add(AVT, AT = new ArrayType(ElementType, NumElements)); #ifdef DEBUG_MERGE_TYPES - std::cerr << "Derived new type: " << *AT << "\n"; + DOUT << "Derived new type: " << *AT << "\n"; #endif return AT; } @@ -1116,7 +1115,7 @@ PackedTypes->add(PVT, PT = new PackedType(ElementType, NumElements)); #ifdef DEBUG_MERGE_TYPES - std::cerr << "Derived new type: " << *PT << "\n"; + DOUT << "Derived new type: " << *PT << "\n"; #endif return PT; } @@ -1169,7 +1168,7 @@ StructTypes->add(STV, ST = new StructType(ETypes)); #ifdef DEBUG_MERGE_TYPES - std::cerr << "Derived new type: " << *ST << "\n"; + DOUT << "Derived new type: " << *ST << "\n"; #endif return ST; } @@ -1224,7 +1223,7 @@ PointerTypes->add(PVT, PT = new PointerType(ValueType)); #ifdef DEBUG_MERGE_TYPES - std::cerr << "Derived new type: " << *PT << "\n"; + DOUT << "Derived new type: " << *PT << "\n"; #endif return PT; } @@ -1253,14 +1252,14 @@ AbstractTypeUsers.erase(AbstractTypeUsers.begin()+i); #ifdef DEBUG_MERGE_TYPES - std::cerr << " remAbstractTypeUser[" << (void*)this << ", " - << *this << "][" << i << "] User = " << U << "\n"; + DOUT << " remAbstractTypeUser[" << (void*)this << ", " + << *this << "][" << i << "] User = " << U << "\n"; #endif if (AbstractTypeUsers.empty() && getRefCount() == 0 && isAbstract()) { #ifdef DEBUG_MERGE_TYPES - std::cerr << "DELETEing unused abstract type: <" << *this - << ">[" << (void*)this << "]" << "\n"; + DOUT << "DELETEing unused abstract type: <" << *this + << ">[" << (void*)this << "]" << "\n"; #endif delete this; // No users of this abstract type! } @@ -1281,9 +1280,9 @@ AbstractTypeDescriptions->clear(); #ifdef DEBUG_MERGE_TYPES - std::cerr << "REFINING abstract type [" << (void*)this << " " - << *this << "] to [" << (void*)NewType << " " - << *NewType << "]!\n"; + DOUT << "REFINING abstract type [" << (void*)this << " " + << *this << "] to [" << (void*)NewType << " " + << *NewType << "]!\n"; #endif // Make sure to put the type to be refined to into a holder so that if IT gets @@ -1319,10 +1318,10 @@ unsigned OldSize = AbstractTypeUsers.size(); #ifdef DEBUG_MERGE_TYPES - std::cerr << " REFINING user " << OldSize-1 << "[" << (void*)User - << "] of abstract type [" << (void*)this << " " - << *this << "] to [" << (void*)NewTy.get() << " " - << *NewTy << "]!\n"; + DOUT << " REFINING user " << OldSize-1 << "[" << (void*)User + << "] of abstract type [" << (void*)this << " " + << *this << "] to [" << (void*)NewTy.get() << " " + << *NewTy << "]!\n"; #endif User->refineAbstractType(this, NewTy); @@ -1341,7 +1340,7 @@ // void DerivedType::notifyUsesThatTypeBecameConcrete() { #ifdef DEBUG_MERGE_TYPES - std::cerr << "typeIsREFINED type: " << (void*)this << " " << *this << "\n"; + DOUT << "typeIsREFINED type: " << (void*)this << " " << *this << "\n"; #endif unsigned OldSize = AbstractTypeUsers.size(); Index: llvm/lib/VMCore/Value.cpp diff -u llvm/lib/VMCore/Value.cpp:1.58 llvm/lib/VMCore/Value.cpp:1.59 --- llvm/lib/VMCore/Value.cpp:1.58 Tue Oct 4 13:13:04 2005 +++ llvm/lib/VMCore/Value.cpp Fri Nov 17 02:03:48 2006 @@ -16,9 +16,9 @@ #include "llvm/InstrTypes.h" #include "llvm/Module.h" #include "llvm/SymbolTable.h" +#include "llvm/Support/Debug.h" #include "llvm/Support/LeakDetector.h" #include -#include using namespace llvm; //===----------------------------------------------------------------------===// @@ -50,10 +50,10 @@ // a // if (use_begin() != use_end()) { - std::cerr << "While deleting: " << *Ty << " %" << Name << "\n"; + DOUT << "While deleting: " << *Ty << " %" << Name << "\n"; for (use_iterator I = use_begin(), E = use_end(); I != E; ++I) - std::cerr << "Use still stuck around after Def is destroyed:" - << **I << "\n"; + DOUT << "Use still stuck around after Def is destroyed:" + << **I << "\n"; } #endif assert(use_begin() == use_end() && "Uses remain when a value is destroyed!"); Index: llvm/lib/VMCore/ValueSymbolTable.cpp diff -u llvm/lib/VMCore/ValueSymbolTable.cpp:1.2 llvm/lib/VMCore/ValueSymbolTable.cpp:1.3 --- llvm/lib/VMCore/ValueSymbolTable.cpp:1.2 Tue Jan 10 23:39:45 2006 +++ llvm/lib/VMCore/ValueSymbolTable.cpp Fri Nov 17 02:03:48 2006 @@ -15,9 +15,8 @@ #include "llvm/Type.h" #include "llvm/ValueSymbolTable.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/Support/Debug.h" #include -#include - using namespace llvm; #define DEBUG_SYMBOL_TABLE 0 @@ -29,9 +28,9 @@ bool LeftoverValues = true; for (iterator VI = vmap.begin(), VE = vmap.end(); VI != VE; ++VI) if (!isa(VI->second) ) { - std::cerr << "Value still in symbol table! Type = '" - << VI->second->getType()->getDescription() << "' Name = '" - << VI->first << "'\n"; + DOUT << "Value still in symbol table! Type = '" + << VI->second->getType()->getDescription() << "' Name = '" + << VI->first << "'\n"; LeftoverValues = false; } assert(LeftoverValues && "Values remain in symbol table!"); @@ -89,7 +88,7 @@ #if DEBUG_SYMBOL_TABLE dump(); - std::cerr << " Inserting value: " << UniqueName << ": " << V->dump() << "\n"; + DOUT << " Inserting value: " << UniqueName << ": " << V->dump() << "\n"; #endif // Insert the vmap entry @@ -105,7 +104,7 @@ #if DEBUG_SYMBOL_TABLE dump(); - std::cerr << " Removing Value: " << Entry->second->getName() << "\n"; + DOUT << " Removing Value: " << Entry->second->getName() << "\n"; #endif // Remove the value from the plane... @@ -153,14 +152,14 @@ // DumpVal - a std::for_each function for dumping a value // static void DumpVal(const std::pair &V) { - std::cerr << " '" << V.first << "' = "; + DOUT << " '" << V.first << "' = "; V.second->dump(); - std::cerr << "\n"; + DOUT << "\n"; } // dump - print out the symbol table // void ValueSymbolTable::dump() const { - std::cerr << "ValueSymbolTable:\n"; + DOUT << "ValueSymbolTable:\n"; for_each(vmap.begin(), vmap.end(), DumpVal); } From evan.cheng at apple.com Fri Nov 17 03:08:20 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 17 Nov 2006 01:08:20 -0800 Subject: [llvm-commits] Priority-Based Coloring Approach to Register Allocation In-Reply-To: References: Message-ID: <67B499C8-A5D3-46F0-8FA1-656D08578FA9@apple.com> Hi Bill, It's great to have a graph coloring regalloc to compare the current implement against. Thanks! Comments: 1. INode NeighborList is a std::set which is very slow. Please use a more efficient data structure. You may have to wrap LiveIntervals in something else and give each one a unique id. 2. Here is something I do have the answer for. But it's wonder considering. Graph coloring can be slow. Does it make sense to separate nodes by regclasses which cannot conflict. e.g. Do graph coloring for all integer nodes and then do another round for all floating point ones. This reduces the size of the graph. 3. Is LINodeMap a std::map? Again, you can probably use a more efficient data structure if you assign each interval unique id. You already have INode, why not use it? 4. CalculateInterference(). Why pass LINeighbors.begin() and .end(). LINodeMap is a RegAlloc ivar. 5. /// Test if this live range interferes with the current live range and that /// they're both in the same register class. if (CurNode->interferes(NeighborNode) && RelatedRegClasses.getLeaderValue(RegRC) == RCLeader) CurNode->addNeighbor(NeighborNode); else CurNode->removeNeighbor(NeighborNode); Why is removeNeighbor() needed? If it is not a neighbor, just don't add it to the list? 6. Making ForbiddenRegs a map seems unnecessary. Why not add a ivar to each INode that keeps track which registers are forbbiden? 7. SepareUnconstrainedLiveIntervals(): is it possible to create separate lists in BuildGraph() rather than separate them later? 8. CalculatePriority(): The formula in paper is based on spill cost. But it doesn't look like you are using this? For future please consider LI's which can be rematerialized. Should we give LI's which are more restricted (e.g. greater # of ForbiddenRegs, register pairs) higher priorities? 9. PriorityBasedColoring(): /// FIXME: This algorithm is pretty gross and will probably result in /// massive performance issues! if (IsUncolorable(CLI)) { RemoveNodeFromGraph(LINodeMap[CLI]); UncolorableLIs.insert(CLI); DEBUG(std::cerr << "Removing uncolorable LiveInterval: " << *CLI << "\n"); } Instead of inserting into the UncolorableLIs set and remove them outside the loop, perhaps a worklist based approach can be used? 10. GetFreeReg(): That goto inside the nested for loop is evil. :-) How about something like this: while (I != E) { bool TryAgain = false; for () { if () { TryAgain = true; break; } } if (!TryAgain) break; ++I; } I am not sure how to fix it. But GetFreeReg() seems to be pretty expensive? After a register is picked, you update ForbbidenRegs set of the neighbors. Is it more desirable to keep track a list of candidates? Perhaps we can use a bitmap representation of a register class and calculate a unique mask for each physical register before coloring? 11. Please give INode::begin() end() more descriptive names. 12. Loop c in PriorityBasedColoring() seems very expensive. There should be a cheaper way to detect whether a LI has to be split. Can we cache the result of GetNumMappableRegs()? I haven't read SplitLiveInterval in details, so no comment about it yet. Cheers, Evan On Nov 15, 2006, at 5:03 PM, Bill Wendling wrote: > Hi all, > > This is meant for a code review and NOT for submission (just yet). > This is my implementation of Chow & Hennesey's Priority-Based > Coloring Approach to Register Allocation. It's still in the > experimental stages (though it compiles the tests). I'd like people > to look at it and let me know what you think. The patch included is > needed for compilation. You'd place the "RegAllocGraphColoring.cpp" > file in the llvm/lib/CodeGen directory. You can use the graph > coloring with the commandline: > > llc -regalloc=graphcoloring foo.bc > > All comments are welcome! > > -bw > > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From isanbard at gmail.com Fri Nov 17 03:38:18 2006 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 17 Nov 2006 03:38:18 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/CFGPrinter.cpp Message-ID: <200611170938.kAH9cIes029762@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: CFGPrinter.cpp updated: 1.17 -> 1.18 --- Log message: Needs the iostream include. --- Diffs of the changes: (+1 -0) CFGPrinter.cpp | 1 + 1 files changed, 1 insertion(+) Index: llvm/lib/Analysis/CFGPrinter.cpp diff -u llvm/lib/Analysis/CFGPrinter.cpp:1.17 llvm/lib/Analysis/CFGPrinter.cpp:1.18 --- llvm/lib/Analysis/CFGPrinter.cpp:1.17 Sun Aug 27 17:30:17 2006 +++ llvm/lib/Analysis/CFGPrinter.cpp Fri Nov 17 03:38:03 2006 @@ -25,6 +25,7 @@ #include "llvm/Support/CFG.h" #include "llvm/Support/GraphWriter.h" #include "llvm/Config/config.h" +#include #include #include using namespace llvm; From isanbard at gmail.com Fri Nov 17 03:44:42 2006 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 17 Nov 2006 03:44:42 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/Printer.cpp Message-ID: <200611170944.kAH9igHS029880@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: Printer.cpp updated: 1.86 -> 1.87 --- Log message: Needed for now. --- Diffs of the changes: (+1 -0) Printer.cpp | 1 + 1 files changed, 1 insertion(+) Index: llvm/lib/Analysis/DataStructure/Printer.cpp diff -u llvm/lib/Analysis/DataStructure/Printer.cpp:1.86 llvm/lib/Analysis/DataStructure/Printer.cpp:1.87 --- llvm/lib/Analysis/DataStructure/Printer.cpp:1.86 Mon Oct 2 07:26:53 2006 +++ llvm/lib/Analysis/DataStructure/Printer.cpp Fri Nov 17 03:44:28 2006 @@ -21,6 +21,7 @@ #include "llvm/Support/GraphWriter.h" #include "llvm/ADT/Statistic.h" #include "llvm/Config/config.h" +#include #include #include using namespace llvm; From isanbard at gmail.com Fri Nov 17 03:51:36 2006 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 17 Nov 2006 03:51:36 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/Streams.cpp Message-ID: <200611170951.kAH9paJD030008@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: Streams.cpp added (r1.1) --- Log message: Added wrappers for the std::cerr/std::cout objects. The wrappers will soon replace all uses of those objects. --- Diffs of the changes: (+21 -0) Streams.cpp | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+) Index: llvm/lib/Support/Streams.cpp diff -c /dev/null llvm/lib/Support/Streams.cpp:1.1 *** /dev/null Fri Nov 17 03:51:32 2006 --- llvm/lib/Support/Streams.cpp Fri Nov 17 03:51:22 2006 *************** *** 0 **** --- 1,21 ---- + //===-- Streams.cpp - Wrappers for iostreams ------------------------------===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by Bill Wendling and is distributed under the + // University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file implements a wrapper for the std::cout and std::cerr I/O streams. + // It prevents the need to include to each file just to get I/O. + // + //===----------------------------------------------------------------------===// + + #include "llvm/Support/Streams.h" + #include + using namespace llvm; + + llvm_ostream llvm::llvm_null; + llvm_ostream llvm::llvm_cout(std::cout); + llvm_ostream llvm::llvm_cerr(std::cerr); From isanbard at gmail.com Fri Nov 17 03:51:38 2006 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 17 Nov 2006 03:51:38 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Support/Streams.h Message-ID: <200611170951.kAH9pce2030013@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Support: Streams.h added (r1.1) --- Log message: Added wrappers for the std::cerr/std::cout objects. The wrappers will soon replace all uses of those objects. --- Diffs of the changes: (+47 -0) Streams.h | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 47 insertions(+) Index: llvm/include/llvm/Support/Streams.h diff -c /dev/null llvm/include/llvm/Support/Streams.h:1.1 *** /dev/null Fri Nov 17 03:51:32 2006 --- llvm/include/llvm/Support/Streams.h Fri Nov 17 03:51:22 2006 *************** *** 0 **** --- 1,47 ---- + //===- llvm/Support/Streams.h - Wrappers for iostreams ----------*- C++ -*-===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by Bill Wendling and is distributed under the + // University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file implements a wrapper for the std::cout and std::cerr I/O streams. + // It prevents the need to include to each file just to get I/O. + // + //===----------------------------------------------------------------------===// + + #ifndef LLVM_SUPPORT_STREAMS_H + #define LLVM_SUPPORT_STREAMS_H + + #include // Doesn't have static d'tors!! + + namespace llvm { + + /// llvm_ostream - Acts like an ostream. It's a wrapper for the std::cerr and + /// std::cout ostreams. However, it doesn't require #including in + /// every file, which increases static c'tors & d'tors in the object code. + /// + class llvm_ostream { + std::ostream* Stream; + public: + llvm_ostream() : Stream(0) {} + llvm_ostream(std::ostream &OStream) : Stream(&OStream) {} + + template + llvm_ostream &operator << (const Ty &Thing) { + if (Stream) *Stream << Thing; + return *this; + } + + bool operator == (const std::ostream &OS) { return &OS == Stream; } + }; + + extern llvm_ostream llvm_null; + extern llvm_ostream llvm_cout; + extern llvm_ostream llvm_cerr; + + } // End llvm namespace + + #endif From isanbard at gmail.com Fri Nov 17 03:53:03 2006 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 17 Nov 2006 03:53:03 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Support/Casting.h Debug.h GraphWriter.h PassNameParser.h Message-ID: <200611170953.kAH9r33f030049@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Support: Casting.h updated: 1.15 -> 1.16 Debug.h updated: 1.10 -> 1.11 GraphWriter.h updated: 1.30 -> 1.31 PassNameParser.h updated: 1.12 -> 1.13 --- Log message: Used llvm_ostream instead of std::ostream objects. This will reduce use of the icky class. --- Diffs of the changes: (+13 -31) Casting.h | 6 +++--- Debug.h | 20 +------------------- GraphWriter.h | 14 +++++++------- PassNameParser.h | 4 ++-- 4 files changed, 13 insertions(+), 31 deletions(-) Index: llvm/include/llvm/Support/Casting.h diff -u llvm/include/llvm/Support/Casting.h:1.15 llvm/include/llvm/Support/Casting.h:1.16 --- llvm/include/llvm/Support/Casting.h:1.15 Sat May 13 12:50:38 2006 +++ llvm/include/llvm/Support/Casting.h Fri Nov 17 03:52:49 2006 @@ -235,7 +235,7 @@ #ifdef DEBUG_CAST_OPERATORS -#include +#include "llvm/Support/Debug.h" struct bar { bar() {} @@ -245,13 +245,13 @@ struct foo { void ext() const; /* static bool classof(const bar *X) { - cerr << "Classof: " << X << "\n"; + llvm_cerr << "Classof: " << X << "\n"; return true; }*/ }; template <> inline bool isa_impl(const bar &Val) { - cerr << "Classof: " << &Val << "\n"; + llvm_cerr << "Classof: " << &Val << "\n"; return true; } Index: llvm/include/llvm/Support/Debug.h diff -u llvm/include/llvm/Support/Debug.h:1.10 llvm/include/llvm/Support/Debug.h:1.11 --- llvm/include/llvm/Support/Debug.h:1.10 Thu Nov 16 19:43:48 2006 +++ llvm/include/llvm/Support/Debug.h Fri Nov 17 03:52:49 2006 @@ -26,7 +26,7 @@ #ifndef LLVM_SUPPORT_DEBUG_H #define LLVM_SUPPORT_DEBUG_H -#include // Doesn't have static d'tors!! +#include "llvm/Support/Streams.h" namespace llvm { @@ -61,24 +61,6 @@ do { if (DebugFlag && isCurrentDebugType(DEBUG_TYPE)) { X; } } while (0) #endif -/// llvm_ostream - Acts like an ostream. However, it doesn't print things out if -/// an ostream isn't specified. -/// -class llvm_ostream { - std::ostream* Stream; -public: - llvm_ostream() : Stream(0) {} - llvm_ostream(std::ostream& OStream) : Stream(&OStream) {} - - template - llvm_ostream& operator << (const Ty& Thing) { -#ifndef NDEBUG - if (Stream) *Stream << Thing; -#endif - return *this; - } -}; - /// getErrorOutputStream - Returns the error output stream (std::cerr). This /// places the std::c* I/O streams into one .cpp file and relieves the whole /// program from having to have hundreds of static c'tor/d'tors for them. Index: llvm/include/llvm/Support/GraphWriter.h diff -u llvm/include/llvm/Support/GraphWriter.h:1.30 llvm/include/llvm/Support/GraphWriter.h:1.31 --- llvm/include/llvm/Support/GraphWriter.h:1.30 Mon Oct 2 07:26:53 2006 +++ llvm/include/llvm/Support/GraphWriter.h Fri Nov 17 03:52:49 2006 @@ -23,12 +23,12 @@ #ifndef LLVM_SUPPORT_GRAPHWRITER_H #define LLVM_SUPPORT_GRAPHWRITER_H +#include "llvm/Support/Debug.h" #include "llvm/Support/DOTGraphTraits.h" #include "llvm/ADT/GraphTraits.h" #include "llvm/System/Path.h" -#include -#include #include +#include namespace llvm { @@ -247,16 +247,16 @@ std::string ErrMsg; sys::Path Filename = sys::Path::GetTemporaryDirectory(&ErrMsg); if (Filename.isEmpty()) { - std::cerr << "Error: " << ErrMsg << "\n"; + llvm_cerr << "Error: " << ErrMsg << "\n"; return Filename; } Filename.appendComponent(Name + ".dot"); if (Filename.makeUnique(true,&ErrMsg)) { - std::cerr << "Error: " << ErrMsg << "\n"; + llvm_cerr << "Error: " << ErrMsg << "\n"; return sys::Path(); } - std::cerr << "Writing '" << Filename << "'... "; + llvm_cerr << "Writing '" << Filename << "'... "; std::ofstream O(Filename.c_str()); @@ -275,12 +275,12 @@ // Output the end of the graph W.writeFooter(); - std::cerr << " done. \n"; + llvm_cerr << " done. \n"; O.close(); } else { - std::cerr << "error opening file for writing!\n"; + llvm_cerr << "error opening file for writing!\n"; Filename.clear(); } Index: llvm/include/llvm/Support/PassNameParser.h diff -u llvm/include/llvm/Support/PassNameParser.h:1.12 llvm/include/llvm/Support/PassNameParser.h:1.13 --- llvm/include/llvm/Support/PassNameParser.h:1.12 Sun Aug 27 17:11:07 2006 +++ llvm/include/llvm/Support/PassNameParser.h Fri Nov 17 03:52:49 2006 @@ -24,9 +24,9 @@ #define LLVM_SUPPORT_PASS_NAME_PARSER_H #include "llvm/Support/CommandLine.h" +#include "llvm/Support/Debug.h" #include "llvm/Pass.h" #include -#include namespace llvm { @@ -66,7 +66,7 @@ virtual void passRegistered(const PassInfo *P) { if (ignorablePass(P) || !Opt) return; if (findOption(P->getPassArgument()) != getNumOptions()) { - std::cerr << "Two passes with the same argument (-" + llvm_cerr << "Two passes with the same argument (-" << P->getPassArgument() << ") attempted to be registered!\n"; abort(); } From isanbard at gmail.com Fri Nov 17 03:55:01 2006 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 17 Nov 2006 03:55:01 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/Debug.cpp Message-ID: <200611170955.kAH9t17Z030092@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: Debug.cpp updated: 1.8 -> 1.9 --- Log message: Moved definition of llvm_ostream wrappers to the Streams.cpp file. --- Diffs of the changes: (+3 -4) Debug.cpp | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) Index: llvm/lib/Support/Debug.cpp diff -u llvm/lib/Support/Debug.cpp:1.8 llvm/lib/Support/Debug.cpp:1.9 --- llvm/lib/Support/Debug.cpp:1.8 Thu Nov 16 18:49:12 2006 +++ llvm/lib/Support/Debug.cpp Fri Nov 17 03:54:47 2006 @@ -23,9 +23,8 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Support/Debug.h" #include "llvm/Support/CommandLine.h" -#include +#include "llvm/Support/Debug.h" using namespace llvm; bool llvm::DebugFlag; // DebugFlag - Exported boolean set by the -debug option @@ -71,7 +70,7 @@ // llvm_ostream llvm::getErrorOutputStream(const char *DebugType) { if (DebugFlag && isCurrentDebugType(DebugType)) - return llvm_ostream(std::cerr); + return llvm_cerr; else - return llvm_ostream(); + return llvm_null; } From isanbard at gmail.com Fri Nov 17 04:09:37 2006 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 17 Nov 2006 04:09:37 -0600 Subject: [llvm-commits] CVS: llvm/tools/llvm-ld/Optimize.cpp Message-ID: <200611171009.kAHA9bGZ001945@zion.cs.uiuc.edu> Changes in directory llvm/tools/llvm-ld: Optimize.cpp updated: 1.13 -> 1.14 --- Log message: Need for the time being. --- Diffs of the changes: (+1 -0) Optimize.cpp | 1 + 1 files changed, 1 insertion(+) Index: llvm/tools/llvm-ld/Optimize.cpp diff -u llvm/tools/llvm-ld/Optimize.cpp:1.13 llvm/tools/llvm-ld/Optimize.cpp:1.14 --- llvm/tools/llvm-ld/Optimize.cpp:1.13 Sun Aug 27 17:07:43 2006 +++ llvm/tools/llvm-ld/Optimize.cpp Fri Nov 17 04:09:22 2006 @@ -24,6 +24,7 @@ #include "llvm/Transforms/Scalar.h" #include "llvm/Support/PassNameParser.h" #include "llvm/Support/PluginLoader.h" +#include using namespace llvm; // Pass Name Options as generated by the PassNameParser From isanbard at gmail.com Fri Nov 17 04:05:21 2006 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 17 Nov 2006 04:05:21 -0600 Subject: [llvm-commits] CVS: llvm/tools/opt/GraphPrinters.cpp Message-ID: <200611171005.kAHA5LSq001867@zion.cs.uiuc.edu> Changes in directory llvm/tools/opt: GraphPrinters.cpp updated: 1.13 -> 1.14 --- Log message: Need iostream to be included for the time being. --- Diffs of the changes: (+1 -0) GraphPrinters.cpp | 1 + 1 files changed, 1 insertion(+) Index: llvm/tools/opt/GraphPrinters.cpp diff -u llvm/tools/opt/GraphPrinters.cpp:1.13 llvm/tools/opt/GraphPrinters.cpp:1.14 --- llvm/tools/opt/GraphPrinters.cpp:1.13 Sun Aug 27 20:02:49 2006 +++ llvm/tools/opt/GraphPrinters.cpp Fri Nov 17 04:05:07 2006 @@ -18,6 +18,7 @@ #include "llvm/Pass.h" #include "llvm/Value.h" #include "llvm/Analysis/CallGraph.h" +#include #include using namespace llvm; From isanbard at gmail.com Fri Nov 17 04:07:39 2006 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 17 Nov 2006 04:07:39 -0600 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/bugpoint.cpp Message-ID: <200611171007.kAHA7ddr001907@zion.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: bugpoint.cpp updated: 1.33 -> 1.34 --- Log message: Need for the time being. --- Diffs of the changes: (+1 -0) bugpoint.cpp | 1 + 1 files changed, 1 insertion(+) Index: llvm/tools/bugpoint/bugpoint.cpp diff -u llvm/tools/bugpoint/bugpoint.cpp:1.33 llvm/tools/bugpoint/bugpoint.cpp:1.34 --- llvm/tools/bugpoint/bugpoint.cpp:1.33 Mon Aug 21 00:34:03 2006 +++ llvm/tools/bugpoint/bugpoint.cpp Fri Nov 17 04:07:24 2006 @@ -22,6 +22,7 @@ #include "llvm/System/Process.h" #include "llvm/System/Signals.h" #include "llvm/LinkAllVMCore.h" +#include using namespace llvm; // AsChild - Specifies that this invocation of bugpoint is being generated From jlaskey at apple.com Fri Nov 17 07:08:09 2006 From: jlaskey at apple.com (Jim Laskey) Date: Fri, 17 Nov 2006 07:08:09 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp Message-ID: <200611171308.kAHD89Hm004632@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: SelectionDAGPrinter.cpp updated: 1.43 -> 1.44 --- Log message: Fixing the ENABLE_OPTIMIZED=1 DISABLE_ASSERTIONS=1 build. --- Diffs of the changes: (+1 -0) SelectionDAGPrinter.cpp | 1 + 1 files changed, 1 insertion(+) Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp:1.43 llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp:1.44 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp:1.43 Thu Nov 9 12:43:20 2006 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp Fri Nov 17 07:07:55 2006 @@ -24,6 +24,7 @@ #include "llvm/Config/config.h" #include #include +#include using namespace llvm; namespace llvm { From jlaskey at apple.com Fri Nov 17 08:06:55 2006 From: jlaskey at apple.com (Jim Laskey) Date: Fri, 17 Nov 2006 08:06:55 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCBranchSelector.cpp Message-ID: <200611171406.kAHE6t4k005462@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCBranchSelector.cpp updated: 1.33 -> 1.34 --- Log message: Typo. Fix the nightly tests. --- Diffs of the changes: (+1 -1) PPCBranchSelector.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Target/PowerPC/PPCBranchSelector.cpp diff -u llvm/lib/Target/PowerPC/PPCBranchSelector.cpp:1.33 llvm/lib/Target/PowerPC/PPCBranchSelector.cpp:1.34 --- llvm/lib/Target/PowerPC/PPCBranchSelector.cpp:1.33 Thu Nov 16 19:52:23 2006 +++ llvm/lib/Target/PowerPC/PPCBranchSelector.cpp Fri Nov 17 08:06:41 2006 @@ -137,7 +137,7 @@ } else { // Long branch, skip next branch instruction (i.e. $PC+8). ++NumExpanded; - BuildMI(*MBB, MBBJ, Inverted, 2).addReg(CRReg).addImm(2); + BuildMI(*MBB, MBBI, Inverted, 2).addReg(CRReg).addImm(2); MBBJ = BuildMI(*MBB, MBBI, PPC::B, 1).addMBB(DestMBB); } From jlaskey at apple.com Fri Nov 17 10:09:46 2006 From: jlaskey at apple.com (Jim Laskey) Date: Fri, 17 Nov 2006 10:09:46 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp Message-ID: <200611171609.kAHG9kAK007605@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCRegisterInfo.cpp updated: 1.86 -> 1.87 --- Log message: 1. Ignore the -disable-fp-elim when the routine is a leaf. 2. Offsets on 64-bit stores are still in bytes. --- Diffs of the changes: (+2 -2) PPCRegisterInfo.cpp | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp diff -u llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.86 llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.87 --- llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.86 Thu Nov 16 16:43:37 2006 +++ llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp Fri Nov 17 10:09:31 2006 @@ -704,7 +704,7 @@ // don't have a frame pointer, calls, or dynamic alloca then we do not need // to adjust the stack pointer (we fit in the Red Zone). if (FrameSize <= 224 && // Fits in red zone. - !needsFP(MF) && // Frame pointer can be eliminated. + !MFI->hasVarSizedObjects() && // No dynamic alloca. !MFI->hasCalls() && // No calls. MaxAlign <= TargetAlign) { // No special alignment. // No need for frame @@ -818,7 +818,7 @@ .addImm(NegFrameSize); BuildMI(MBB, MBBI, PPC::STDUX, 3) .addReg(PPC::X1).addReg(PPC::X1).addReg(PPC::X0); - } else if (isInt16(NegFrameSize/4)) { + } else if (isInt16(NegFrameSize)) { BuildMI(MBB, MBBI, PPC::STDU, 3, PPC::X1) .addReg(PPC::X1).addImm(NegFrameSize/4).addReg(PPC::X1); } else { From jlaskey at apple.com Fri Nov 17 10:54:36 2006 From: jlaskey at apple.com (Jim Laskey) Date: Fri, 17 Nov 2006 10:54:36 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/CodeGen/PowerPC/Frames-alloca.ll Frames-large.ll Frames-leaf.ll Frames-small.ll Message-ID: <200611171654.kAHGsap7008292@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/CodeGen/PowerPC: Frames-alloca.ll added (r1.1) Frames-large.ll added (r1.1) Frames-leaf.ll added (r1.1) Frames-small.ll added (r1.1) --- Log message: Tests to verify PowerPC ABI. --- Diffs of the changes: (+104 -0) Frames-alloca.ll | 24 ++++++++++++++++++++++++ Frames-large.ll | 32 ++++++++++++++++++++++++++++++++ Frames-leaf.ll | 24 ++++++++++++++++++++++++ Frames-small.ll | 24 ++++++++++++++++++++++++ 4 files changed, 104 insertions(+) Index: llvm/test/Regression/CodeGen/PowerPC/Frames-alloca.ll diff -c /dev/null llvm/test/Regression/CodeGen/PowerPC/Frames-alloca.ll:1.1 *** /dev/null Fri Nov 17 10:54:31 2006 --- llvm/test/Regression/CodeGen/PowerPC/Frames-alloca.ll Fri Nov 17 10:54:21 2006 *************** *** 0 **** --- 1,24 ---- + ; RUN: llvm-as < %s | llc -march=ppc32 | grep 'stw r31, 20(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc32 | grep 'stwu r1, -64(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc32 | grep 'lwz r1, 0(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc32 | grep 'lwz r31, 20(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | grep 'stw r31, 20(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | grep 'stwu r1, -64(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | grep 'lwz r1, 0(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | grep 'lwz r31, 20(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc64 | grep 'std r31, 40(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc64 | grep 'stdu r1, -112(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc64 | grep 'ld r1, 0(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc64 | grep 'ld r31, 40(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc64 -disable-fp-elim | grep 'std r31, 40(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc64 -disable-fp-elim | grep 'stdu r1, -112(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc64 -disable-fp-elim | grep 'ld r1, 0(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc64 -disable-fp-elim | grep 'ld r31, 40(r1)' + + + implementation + + int* %f1(uint %n) { + %tmp = alloca int, uint %n + ret int* %tmp + } Index: llvm/test/Regression/CodeGen/PowerPC/Frames-large.ll diff -c /dev/null llvm/test/Regression/CodeGen/PowerPC/Frames-large.ll:1.1 *** /dev/null Fri Nov 17 10:54:36 2006 --- llvm/test/Regression/CodeGen/PowerPC/Frames-large.ll Fri Nov 17 10:54:21 2006 *************** *** 0 **** --- 1,32 ---- + ; RUN: llvm-as < %s | llc -march=ppc32 | NOT grep 'stw r31, 20(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc32 | grep 'lis r0, -1' && + ; RUN: llvm-as < %s | llc -march=ppc32 | grep 'ori r0, r0, 32704' && + ; RUN: llvm-as < %s | llc -march=ppc32 | grep 'stwux r1, r1, r0' && + ; RUN: llvm-as < %s | llc -march=ppc32 | grep 'lwz r1, 0(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc32 | NOT grep 'lwz r31, 20(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | grep 'stw r31, 20(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | grep 'lis r0, -1' && + ; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | grep 'ori r0, r0, 32704' && + ; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | grep 'stwux r1, r1, r0' && + ; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | grep 'lwz r1, 0(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | grep 'lwz r31, 20(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc64 | NOT grep 'std r31, 40(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc64 | grep 'lis r0, -1' && + ; RUN: llvm-as < %s | llc -march=ppc64 | grep 'ori r0, r0, 32656' && + ; RUN: llvm-as < %s | llc -march=ppc64 | grep 'stdux r1, r1, r0' && + ; RUN: llvm-as < %s | llc -march=ppc64 | grep 'ld r1, 0(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc64 | NOT grep 'ld r31, 40(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc64 -disable-fp-elim | grep 'std r31, 40(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc64 -disable-fp-elim | grep 'lis r0, -1' && + ; RUN: llvm-as < %s | llc -march=ppc64 -disable-fp-elim | grep 'ori r0, r0, 32656' && + ; RUN: llvm-as < %s | llc -march=ppc64 -disable-fp-elim | grep 'stdux r1, r1, r0' && + ; RUN: llvm-as < %s | llc -march=ppc64 -disable-fp-elim | grep 'ld r1, 0(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc64 -disable-fp-elim | grep 'ld r31, 40(r1)' + + + implementation + + int* %f1() { + %tmp = alloca int, uint 8191 + ret int* %tmp + } Index: llvm/test/Regression/CodeGen/PowerPC/Frames-leaf.ll diff -c /dev/null llvm/test/Regression/CodeGen/PowerPC/Frames-leaf.ll:1.1 *** /dev/null Fri Nov 17 10:54:36 2006 --- llvm/test/Regression/CodeGen/PowerPC/Frames-leaf.ll Fri Nov 17 10:54:21 2006 *************** *** 0 **** --- 1,24 ---- + ; RUN: llvm-as < %s | llc -march=ppc32 | NOT grep 'stw r31, 20(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc32 | NOT grep 'stwu r1, -.*(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc32 | NOT grep 'addi r1, r1, ' && + ; RUN: llvm-as < %s | llc -march=ppc32 | NOT grep 'lwz r31, 20(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | NOT grep 'stw r31, 20(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | NOT grep 'stwu r1, -.*(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | NOT grep 'addi r1, r1, ' && + ; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | NOT grep 'lwz r31, 20(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc64 | NOT grep 'std r31, 40(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc64 | NOT grep 'stdu r1, -.*(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc64 | NOT grep 'addi r1, r1, ' && + ; RUN: llvm-as < %s | llc -march=ppc64 | NOT grep 'ld r31, 40(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc64 -disable-fp-elim | NOT grep 'stw r31, 40(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc64 -disable-fp-elim | NOT grep 'stdu r1, -.*(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc64 -disable-fp-elim | NOT grep 'addi r1, r1, ' && + ; RUN: llvm-as < %s | llc -march=ppc64 -disable-fp-elim | NOT grep 'ld r31, 40(r1)' + + + implementation + + int* %f1() { + %tmp = alloca int, uint 2 + ret int* %tmp + } Index: llvm/test/Regression/CodeGen/PowerPC/Frames-small.ll diff -c /dev/null llvm/test/Regression/CodeGen/PowerPC/Frames-small.ll:1.1 *** /dev/null Fri Nov 17 10:54:36 2006 --- llvm/test/Regression/CodeGen/PowerPC/Frames-small.ll Fri Nov 17 10:54:21 2006 *************** *** 0 **** --- 1,24 ---- + ; RUN: llvm-as < %s | llc -march=ppc32 | NOT grep 'stw r31, 20(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc32 | grep 'stwu r1, -16448(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc32 | grep 'addi r1, r1, 16448' && + ; RUN: llvm-as < %s | llc -march=ppc32 | NOT grep 'lwz r31, 20(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | grep 'stw r31, 20(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | grep 'stwu r1, -16448(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | grep 'addi r1, r1, 16448' && + ; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | grep 'lwz r31, 20(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc64 | NOT grep 'std r31, 40(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc64 | grep 'stdu r1, -16496(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc64 | grep 'addi r1, r1, 16496' && + ; RUN: llvm-as < %s | llc -march=ppc64 | NOT grep 'ld r31, 40(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc64 -disable-fp-elim | grep 'std r31, 40(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc64 -disable-fp-elim | grep 'stdu r1, -16496(r1)' && + ; RUN: llvm-as < %s | llc -march=ppc64 -disable-fp-elim | grep 'addi r1, r1, 16496' && + ; RUN: llvm-as < %s | llc -march=ppc64 -disable-fp-elim | grep 'ld r31, 40(r1)' + + + implementation + + int* %f1() { + %tmp = alloca int, uint 4095 + ret int* %tmp + } From jlaskey at apple.com Fri Nov 17 11:20:03 2006 From: jlaskey at apple.com (Jim Laskey) Date: Fri, 17 Nov 2006 11:20:03 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/CodeGen/PowerPC/Frames-align.ll Message-ID: <200611171720.kAHHK3kP008695@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/CodeGen/PowerPC: Frames-align.ll added (r1.1) --- Log message: Check for MaxAlign. --- Diffs of the changes: (+11 -0) Frames-align.ll | 11 +++++++++++ 1 files changed, 11 insertions(+) Index: llvm/test/Regression/CodeGen/PowerPC/Frames-align.ll diff -c /dev/null llvm/test/Regression/CodeGen/PowerPC/Frames-align.ll:1.1 *** /dev/null Fri Nov 17 11:19:59 2006 --- llvm/test/Regression/CodeGen/PowerPC/Frames-align.ll Fri Nov 17 11:19:49 2006 *************** *** 0 **** --- 1,11 ---- + ; RUN: llvm-as < %s | llc -march=ppc32 | grep 'rlwinm r0, r1, 0, 22, 31' && + ; RUN: llvm-as < %s | llc -march=ppc32 | grep 'subfic r0, r0, -17408' && + ; RUN: llvm-as < %s | llc -march=ppc64 | grep 'rldicl r0, r1, 0, 54' + + + implementation + + int* %f1() { + %tmp = alloca int, uint 4095, align 1024 + ret int* %tmp + } From jlaskey at apple.com Fri Nov 17 12:00:56 2006 From: jlaskey at apple.com (Jim Laskey) Date: Fri, 17 Nov 2006 12:00:56 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/CodeGen/PowerPC/Frames-large.ll Frames-leaf.ll Frames-small.ll Message-ID: <200611171800.kAHI0uIo009436@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/CodeGen/PowerPC: Frames-large.ll updated: 1.1 -> 1.2 Frames-leaf.ll updated: 1.1 -> 1.2 Frames-small.ll updated: 1.1 -> 1.2 --- Log message: Case sensitive not. --- Diffs of the changes: (+24 -24) Frames-large.ll | 8 ++++---- Frames-leaf.ll | 32 ++++++++++++++++---------------- Frames-small.ll | 8 ++++---- 3 files changed, 24 insertions(+), 24 deletions(-) Index: llvm/test/Regression/CodeGen/PowerPC/Frames-large.ll diff -u llvm/test/Regression/CodeGen/PowerPC/Frames-large.ll:1.1 llvm/test/Regression/CodeGen/PowerPC/Frames-large.ll:1.2 --- llvm/test/Regression/CodeGen/PowerPC/Frames-large.ll:1.1 Fri Nov 17 10:54:21 2006 +++ llvm/test/Regression/CodeGen/PowerPC/Frames-large.ll Fri Nov 17 12:00:39 2006 @@ -1,21 +1,21 @@ -; RUN: llvm-as < %s | llc -march=ppc32 | NOT grep 'stw r31, 20(r1)' && +; RUN: llvm-as < %s | llc -march=ppc32 | not grep 'stw r31, 20(r1)' && ; RUN: llvm-as < %s | llc -march=ppc32 | grep 'lis r0, -1' && ; RUN: llvm-as < %s | llc -march=ppc32 | grep 'ori r0, r0, 32704' && ; RUN: llvm-as < %s | llc -march=ppc32 | grep 'stwux r1, r1, r0' && ; RUN: llvm-as < %s | llc -march=ppc32 | grep 'lwz r1, 0(r1)' && -; RUN: llvm-as < %s | llc -march=ppc32 | NOT grep 'lwz r31, 20(r1)' && +; RUN: llvm-as < %s | llc -march=ppc32 | not grep 'lwz r31, 20(r1)' && ; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | grep 'stw r31, 20(r1)' && ; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | grep 'lis r0, -1' && ; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | grep 'ori r0, r0, 32704' && ; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | grep 'stwux r1, r1, r0' && ; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | grep 'lwz r1, 0(r1)' && ; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | grep 'lwz r31, 20(r1)' && -; RUN: llvm-as < %s | llc -march=ppc64 | NOT grep 'std r31, 40(r1)' && +; RUN: llvm-as < %s | llc -march=ppc64 | not grep 'std r31, 40(r1)' && ; RUN: llvm-as < %s | llc -march=ppc64 | grep 'lis r0, -1' && ; RUN: llvm-as < %s | llc -march=ppc64 | grep 'ori r0, r0, 32656' && ; RUN: llvm-as < %s | llc -march=ppc64 | grep 'stdux r1, r1, r0' && ; RUN: llvm-as < %s | llc -march=ppc64 | grep 'ld r1, 0(r1)' && -; RUN: llvm-as < %s | llc -march=ppc64 | NOT grep 'ld r31, 40(r1)' && +; RUN: llvm-as < %s | llc -march=ppc64 | not grep 'ld r31, 40(r1)' && ; RUN: llvm-as < %s | llc -march=ppc64 -disable-fp-elim | grep 'std r31, 40(r1)' && ; RUN: llvm-as < %s | llc -march=ppc64 -disable-fp-elim | grep 'lis r0, -1' && ; RUN: llvm-as < %s | llc -march=ppc64 -disable-fp-elim | grep 'ori r0, r0, 32656' && Index: llvm/test/Regression/CodeGen/PowerPC/Frames-leaf.ll diff -u llvm/test/Regression/CodeGen/PowerPC/Frames-leaf.ll:1.1 llvm/test/Regression/CodeGen/PowerPC/Frames-leaf.ll:1.2 --- llvm/test/Regression/CodeGen/PowerPC/Frames-leaf.ll:1.1 Fri Nov 17 10:54:21 2006 +++ llvm/test/Regression/CodeGen/PowerPC/Frames-leaf.ll Fri Nov 17 12:00:39 2006 @@ -1,19 +1,19 @@ -; RUN: llvm-as < %s | llc -march=ppc32 | NOT grep 'stw r31, 20(r1)' && -; RUN: llvm-as < %s | llc -march=ppc32 | NOT grep 'stwu r1, -.*(r1)' && -; RUN: llvm-as < %s | llc -march=ppc32 | NOT grep 'addi r1, r1, ' && -; RUN: llvm-as < %s | llc -march=ppc32 | NOT grep 'lwz r31, 20(r1)' && -; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | NOT grep 'stw r31, 20(r1)' && -; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | NOT grep 'stwu r1, -.*(r1)' && -; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | NOT grep 'addi r1, r1, ' && -; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | NOT grep 'lwz r31, 20(r1)' && -; RUN: llvm-as < %s | llc -march=ppc64 | NOT grep 'std r31, 40(r1)' && -; RUN: llvm-as < %s | llc -march=ppc64 | NOT grep 'stdu r1, -.*(r1)' && -; RUN: llvm-as < %s | llc -march=ppc64 | NOT grep 'addi r1, r1, ' && -; RUN: llvm-as < %s | llc -march=ppc64 | NOT grep 'ld r31, 40(r1)' && -; RUN: llvm-as < %s | llc -march=ppc64 -disable-fp-elim | NOT grep 'stw r31, 40(r1)' && -; RUN: llvm-as < %s | llc -march=ppc64 -disable-fp-elim | NOT grep 'stdu r1, -.*(r1)' && -; RUN: llvm-as < %s | llc -march=ppc64 -disable-fp-elim | NOT grep 'addi r1, r1, ' && -; RUN: llvm-as < %s | llc -march=ppc64 -disable-fp-elim | NOT grep 'ld r31, 40(r1)' +; RUN: llvm-as < %s | llc -march=ppc32 | not grep 'stw r31, 20(r1)' && +; RUN: llvm-as < %s | llc -march=ppc32 | not grep 'stwu r1, -.*(r1)' && +; RUN: llvm-as < %s | llc -march=ppc32 | not grep 'addi r1, r1, ' && +; RUN: llvm-as < %s | llc -march=ppc32 | not grep 'lwz r31, 20(r1)' && +; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | not grep 'stw r31, 20(r1)' && +; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | not grep 'stwu r1, -.*(r1)' && +; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | not grep 'addi r1, r1, ' && +; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | not grep 'lwz r31, 20(r1)' && +; RUN: llvm-as < %s | llc -march=ppc64 | not grep 'std r31, 40(r1)' && +; RUN: llvm-as < %s | llc -march=ppc64 | not grep 'stdu r1, -.*(r1)' && +; RUN: llvm-as < %s | llc -march=ppc64 | not grep 'addi r1, r1, ' && +; RUN: llvm-as < %s | llc -march=ppc64 | not grep 'ld r31, 40(r1)' && +; RUN: llvm-as < %s | llc -march=ppc64 -disable-fp-elim | not grep 'stw r31, 40(r1)' && +; RUN: llvm-as < %s | llc -march=ppc64 -disable-fp-elim | not grep 'stdu r1, -.*(r1)' && +; RUN: llvm-as < %s | llc -march=ppc64 -disable-fp-elim | not grep 'addi r1, r1, ' && +; RUN: llvm-as < %s | llc -march=ppc64 -disable-fp-elim | not grep 'ld r31, 40(r1)' implementation Index: llvm/test/Regression/CodeGen/PowerPC/Frames-small.ll diff -u llvm/test/Regression/CodeGen/PowerPC/Frames-small.ll:1.1 llvm/test/Regression/CodeGen/PowerPC/Frames-small.ll:1.2 --- llvm/test/Regression/CodeGen/PowerPC/Frames-small.ll:1.1 Fri Nov 17 10:54:21 2006 +++ llvm/test/Regression/CodeGen/PowerPC/Frames-small.ll Fri Nov 17 12:00:39 2006 @@ -1,15 +1,15 @@ -; RUN: llvm-as < %s | llc -march=ppc32 | NOT grep 'stw r31, 20(r1)' && +; RUN: llvm-as < %s | llc -march=ppc32 | not grep 'stw r31, 20(r1)' && ; RUN: llvm-as < %s | llc -march=ppc32 | grep 'stwu r1, -16448(r1)' && ; RUN: llvm-as < %s | llc -march=ppc32 | grep 'addi r1, r1, 16448' && -; RUN: llvm-as < %s | llc -march=ppc32 | NOT grep 'lwz r31, 20(r1)' && +; RUN: llvm-as < %s | llc -march=ppc32 | not grep 'lwz r31, 20(r1)' && ; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | grep 'stw r31, 20(r1)' && ; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | grep 'stwu r1, -16448(r1)' && ; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | grep 'addi r1, r1, 16448' && ; RUN: llvm-as < %s | llc -march=ppc32 -disable-fp-elim | grep 'lwz r31, 20(r1)' && -; RUN: llvm-as < %s | llc -march=ppc64 | NOT grep 'std r31, 40(r1)' && +; RUN: llvm-as < %s | llc -march=ppc64 | not grep 'std r31, 40(r1)' && ; RUN: llvm-as < %s | llc -march=ppc64 | grep 'stdu r1, -16496(r1)' && ; RUN: llvm-as < %s | llc -march=ppc64 | grep 'addi r1, r1, 16496' && -; RUN: llvm-as < %s | llc -march=ppc64 | NOT grep 'ld r31, 40(r1)' && +; RUN: llvm-as < %s | llc -march=ppc64 | not grep 'ld r31, 40(r1)' && ; RUN: llvm-as < %s | llc -march=ppc64 -disable-fp-elim | grep 'std r31, 40(r1)' && ; RUN: llvm-as < %s | llc -march=ppc64 -disable-fp-elim | grep 'stdu r1, -16496(r1)' && ; RUN: llvm-as < %s | llc -march=ppc64 -disable-fp-elim | grep 'addi r1, r1, 16496' && From jlaskey at apple.com Fri Nov 17 12:49:53 2006 From: jlaskey at apple.com (Jim Laskey) Date: Fri, 17 Nov 2006 12:49:53 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp Message-ID: <200611171849.kAHInrpg010346@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCRegisterInfo.cpp updated: 1.87 -> 1.88 --- Log message: Assert unhandled case. --- Diffs of the changes: (+2 -0) PPCRegisterInfo.cpp | 2 ++ 1 files changed, 2 insertions(+) Index: llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp diff -u llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.87 llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.88 --- llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.87 Fri Nov 17 10:09:31 2006 +++ llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp Fri Nov 17 12:49:39 2006 @@ -445,6 +445,8 @@ // Get stack alignments. unsigned TargetAlign = MF.getTarget().getFrameInfo()->getStackAlignment(); unsigned MaxAlign = MFI->getMaxAlignment(); + assert(MaxAlign <= TargetAlign && + "Dynamic alloca with large aligns not supported"); // Determine the previous frame's address. If FrameSize can't be // represented as 16 bits or we need special alignment, then we load the From clattner at apple.com Fri Nov 17 13:14:23 2006 From: clattner at apple.com (Chris Lattner) Date: Fri, 17 Nov 2006 11:14:23 -0800 Subject: [llvm-commits] llvm-gcc4 implement VIEW_CONVERT_EXPR Message-ID: This implements an unimplemented tree code: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: vce.diff.txt Url: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20061117/168e7f36/attachment.txt -------------- next part -------------- It will get nicer once bitcast lands :) -Chris From dpatel at apple.com Fri Nov 17 13:33:44 2006 From: dpatel at apple.com (Devang Patel) Date: Fri, 17 Nov 2006 11:33:44 -0800 Subject: [llvm-commits] Fix PR 1008 Message-ID: Fix cut-n-pasto. Fix PR 1008. Thanks Chris! - Devang Index: llvm-convert.cpp =================================================================== --- llvm-convert.cpp (revision 119923) +++ llvm-convert.cpp (working copy) @@ -4135,7 +4135,7 @@ Constant *TreeConstantToLLVM::ConvertSTR const signed short *InStr = (const signed short *)TREE_STRING_POINTER(exp); for (unsigned i = 0; i != Len; ++i) Elts.push_back(ConstantInt::get(Type::ShortTy, InStr[i])); - } else if (ElTy == Type::UByteTy) { + } else if (ElTy == Type::UShortTy) { const unsigned short *InStr = (const unsigned short *)TREE_STRING_POINTER(exp); for (unsigned i = 0; i != Len; ++i) From evan.cheng at apple.com Fri Nov 17 14:42:10 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 17 Nov 2006 14:42:10 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/CodeGen/X86/2006-11-17-IllegalMove.ll Message-ID: <200611172042.kAHKgATG012364@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/CodeGen/X86: 2006-11-17-IllegalMove.ll added (r1.1) --- Log message: Add a x86-64 test case: movb %sil, %ah is illegal. --- Diffs of the changes: (+41 -0) 2006-11-17-IllegalMove.ll | 41 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 41 insertions(+) Index: llvm/test/Regression/CodeGen/X86/2006-11-17-IllegalMove.ll diff -c /dev/null llvm/test/Regression/CodeGen/X86/2006-11-17-IllegalMove.ll:1.1 *** /dev/null Fri Nov 17 14:42:05 2006 --- llvm/test/Regression/CodeGen/X86/2006-11-17-IllegalMove.ll Fri Nov 17 14:41:55 2006 *************** *** 0 **** --- 1,41 ---- + ; RUN: llvm-as < %s | llc -march=x86-64 && + ; RUN: llvm-as < %s | llc -march=x86-64 | not grep 'movb %sil, %ah' && + ; RUN: llvm-as < %s | llc -march=x86-64 | grep 'movzbw %al, %ax' + + void %handle_vector_size_attribute() { + entry: + %tmp69 = load uint* null ; [#uses=1] + switch uint %tmp69, label %bb84 [ + uint 2, label %bb77 + uint 1, label %bb77 + ] + + bb77: ; preds = %entry, %entry + %tmp99 = udiv ulong 0, 0 ; [#uses=1] + %tmp = load ubyte* null ; [#uses=1] + %tmp114 = seteq ulong 0, 0 ; [#uses=1] + br bool %tmp114, label %cond_true115, label %cond_next136 + + bb84: ; preds = %entry + ret void + + cond_true115: ; preds = %bb77 + %tmp118 = load ubyte* null ; [#uses=1] + br bool false, label %cond_next129, label %cond_true120 + + cond_true120: ; preds = %cond_true115 + %tmp127 = udiv ubyte %tmp, %tmp118 ; [#uses=1] + %tmp127 = cast ubyte %tmp127 to ulong ; [#uses=1] + br label %cond_next129 + + cond_next129: ; preds = %cond_true120, %cond_true115 + %iftmp.30.0 = phi ulong [ %tmp127, %cond_true120 ], [ 0, %cond_true115 ] ; [#uses=1] + %tmp132 = seteq ulong %iftmp.30.0, %tmp99 ; [#uses=1] + br bool %tmp132, label %cond_false148, label %cond_next136 + + cond_next136: ; preds = %cond_next129, %bb77 + ret void + + cond_false148: ; preds = %cond_next129 + ret void + } From jlaskey at apple.com Fri Nov 17 15:19:33 2006 From: jlaskey at apple.com (Jim Laskey) Date: Fri, 17 Nov 2006 15:19:33 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineFrameInfo.h Message-ID: <200611172119.kAHLJXXq012976@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineFrameInfo.h updated: 1.20 -> 1.21 --- Log message: Hopefully a good crack at making debugging work on intel -disable-fp-elim. --- Diffs of the changes: (+17 -1) MachineFrameInfo.h | 18 +++++++++++++++++- 1 files changed, 17 insertions(+), 1 deletion(-) Index: llvm/include/llvm/CodeGen/MachineFrameInfo.h diff -u llvm/include/llvm/CodeGen/MachineFrameInfo.h:1.20 llvm/include/llvm/CodeGen/MachineFrameInfo.h:1.21 --- llvm/include/llvm/CodeGen/MachineFrameInfo.h:1.20 Fri Aug 25 17:56:30 2006 +++ llvm/include/llvm/CodeGen/MachineFrameInfo.h Fri Nov 17 15:19:15 2006 @@ -112,6 +112,14 @@ /// unsigned StackSize; + /// OffsetAdjustment - The amount that a frame offset needs to be adjusted to + /// have the actual offset from the stack/frame pointer. The calculation is + /// MFI->getObjectOffset(Index) + StackSize - TFI.getOffsetOfLocalArea() + + /// OffsetAdjustment. If OffsetAdjustment is zero (default) then offsets are + /// away from TOS. If OffsetAdjustment == StackSize then offsets are toward + /// TOS. + int OffsetAdjustment; + /// MaxAlignment - The prolog/epilog code inserter may process objects /// that require greater alignment than the default alignment the target /// provides. To handle this, MaxAlignment is set to the maximum alignment @@ -148,7 +156,7 @@ public: MachineFrameInfo() { - NumFixedObjects = StackSize = MaxAlignment = 0; + NumFixedObjects = StackSize = OffsetAdjustment = MaxAlignment = 0; HasVarSizedObjects = false; HasCalls = false; MaxCallFrameSize = 0; @@ -212,6 +220,14 @@ /// setStackSize - Set the size of the stack... /// void setStackSize(unsigned Size) { StackSize = Size; } + + /// getOffsetAdjustment - Return the correction for frame offsets. + /// + int getOffsetAdjustment() const { return OffsetAdjustment; } + + /// setOffsetAdjustment - Set the correction for frame offsets. + /// + void setOffsetAdjustment(int Adj) { OffsetAdjustment = Adj; } /// getMaxAlignment - Return the alignment in bytes that this function must be /// aligned to, which is greater than the default stack alignment provided by From jlaskey at apple.com Fri Nov 17 15:19:32 2006 From: jlaskey at apple.com (Jim Laskey) Date: Fri, 17 Nov 2006 15:19:32 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86RegisterInfo.cpp Message-ID: <200611172119.kAHLJWoJ012969@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86RegisterInfo.cpp updated: 1.179 -> 1.180 --- Log message: Hopefully a good crack at making debugging work on intel -disable-fp-elim. --- Diffs of the changes: (+3 -1) X86RegisterInfo.cpp | 4 +++- 1 files changed, 3 insertions(+), 1 deletion(-) Index: llvm/lib/Target/X86/X86RegisterInfo.cpp diff -u llvm/lib/Target/X86/X86RegisterInfo.cpp:1.179 llvm/lib/Target/X86/X86RegisterInfo.cpp:1.180 --- llvm/lib/Target/X86/X86RegisterInfo.cpp:1.179 Thu Nov 16 17:33:25 2006 +++ llvm/lib/Target/X86/X86RegisterInfo.cpp Fri Nov 17 15:19:15 2006 @@ -1029,7 +1029,9 @@ // Get the offset of the stack slot for the EBP register... which is // guaranteed to be the last slot by processFunctionBeforeFrameFinalized. int EBPOffset = MFI->getObjectOffset(MFI->getObjectIndexBegin())+SlotSize; - + // Update the frame offset adjustment. + MFI->setOffsetAdjustment(SlotSize-NumBytes); + // Save EBP into the appropriate stack slot... // mov [ESP-], EBP MI = addRegOffset(BuildMI(TII, Is64Bit ? X86::MOV64mr : X86::MOV32mr, 5), From jlaskey at apple.com Fri Nov 17 15:19:33 2006 From: jlaskey at apple.com (Jim Laskey) Date: Fri, 17 Nov 2006 15:19:33 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/MRegisterInfo.cpp Message-ID: <200611172119.kAHLJXEP012978@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target: MRegisterInfo.cpp updated: 1.16 -> 1.17 --- Log message: Hopefully a good crack at making debugging work on intel -disable-fp-elim. --- Diffs of the changes: (+2 -1) MRegisterInfo.cpp | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-) Index: llvm/lib/Target/MRegisterInfo.cpp diff -u llvm/lib/Target/MRegisterInfo.cpp:1.16 llvm/lib/Target/MRegisterInfo.cpp:1.17 --- llvm/lib/Target/MRegisterInfo.cpp:1.16 Thu Aug 3 12:27:09 2006 +++ llvm/lib/Target/MRegisterInfo.cpp Fri Nov 17 15:19:15 2006 @@ -57,7 +57,8 @@ ML.set(getFrameRegister(MF), MFI->getObjectOffset(Index) + MFI->getStackSize() - - TFI.getOffsetOfLocalArea()); + TFI.getOffsetOfLocalArea() + + MFI->getOffsetAdjustment()); } /// getInitialFrameState - Returns a list of machine moves that are assumed From reid at x10sys.com Fri Nov 17 15:22:40 2006 From: reid at x10sys.com (Reid Spencer) Date: Fri, 17 Nov 2006 15:22:40 -0600 Subject: [llvm-commits] CVS: llvm-test/SingleSource/Benchmarks/Shootout-C++/sieve.cpp Message-ID: <200611172122.kAHLMeic013051@zion.cs.uiuc.edu> Changes in directory llvm-test/SingleSource/Benchmarks/Shootout-C++: sieve.cpp updated: 1.2 -> 1.3 --- Log message: Fix indentation of this program, remove tabs. No functional change. --- Diffs of the changes: (+26 -27) sieve.cpp | 53 ++++++++++++++++++++++++++--------------------------- 1 files changed, 26 insertions(+), 27 deletions(-) Index: llvm-test/SingleSource/Benchmarks/Shootout-C++/sieve.cpp diff -u llvm-test/SingleSource/Benchmarks/Shootout-C++/sieve.cpp:1.2 llvm-test/SingleSource/Benchmarks/Shootout-C++/sieve.cpp:1.3 --- llvm-test/SingleSource/Benchmarks/Shootout-C++/sieve.cpp:1.2 Tue Jun 15 15:48:16 2004 +++ llvm-test/SingleSource/Benchmarks/Shootout-C++/sieve.cpp Fri Nov 17 15:22:26 2006 @@ -7,38 +7,37 @@ void sieve(list& unknown, vector& primes) { - while (!unknown.empty()) - { - int p = unknown.front(); - unknown.pop_front(); - list::iterator i = unknown.begin(); - while (i != unknown.end()) - { - if (*i % p) - ++i; - else - i = unknown.erase(i); - } - primes.push_back(p); - } + while (!unknown.empty()) + { + int p = unknown.front(); + unknown.pop_front(); + list::iterator i = unknown.begin(); + while (i != unknown.end()) + { + if (*i % p) + ++i; + else + i = unknown.erase(i); + } + primes.push_back(p); + } } int main(int argc, char *argv[]) { - size_t NUM = (argc == 2 ? (atoi(argv[1]) < 1 ? 1 : atoi(argv[1])): - 500); + size_t NUM = (argc == 2 ? (atoi(argv[1]) < 1 ? 1 : atoi(argv[1])): 500); - vector primes; + vector primes; - // run the sieve repeatedly - while (NUM--) { - list integers; - for (int i = 2; i < 8192; ++i) - integers.push_back(i); - primes.clear(); - sieve(integers, primes); - } + // run the sieve repeatedly + while (NUM--) { + list integers; + for (int i = 2; i < 8192; ++i) + integers.push_back(i); + primes.clear(); + sieve(integers, primes); + } - cout << "Count: " << primes.size() << endl; - return 0; + cout << "Count: " << primes.size() << endl; + return 0; } From evan.cheng at apple.com Fri Nov 17 16:10:28 2006 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 17 Nov 2006 16:10:28 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ISelDAGToDAG.cpp Message-ID: <200611172210.kAHMASfb013938@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ISelDAGToDAG.cpp updated: 1.128 -> 1.129 --- Log message: For unsigned 8-bit division. Use movzbw to set the lower 8 bits of AX while clearing the upper 8-bits instead of issuing two instructions. This also eliminates the need to target the AH register which can be problematic on x86-64. --- Diffs of the changes: (+46 -29) X86ISelDAGToDAG.cpp | 75 +++++++++++++++++++++++++++++++--------------------- 1 files changed, 46 insertions(+), 29 deletions(-) Index: llvm/lib/Target/X86/X86ISelDAGToDAG.cpp diff -u llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:1.128 llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:1.129 --- llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:1.128 Fri Nov 17 01:52:03 2006 +++ llvm/lib/Target/X86/X86ISelDAGToDAG.cpp Fri Nov 17 16:10:14 2006 @@ -1141,7 +1141,7 @@ default: assert(0 && "Unsupported VT!"); case MVT::i8: LoReg = X86::AL; HiReg = X86::AH; - ClrOpcode = X86::MOV8r0; + ClrOpcode = 0; SExtOpcode = X86::CBW; break; case MVT::i16: @@ -1163,53 +1163,70 @@ SDOperand N0 = Node->getOperand(0); SDOperand N1 = Node->getOperand(1); - - bool foldedLoad = false; - SDOperand Tmp0, Tmp1, Tmp2, Tmp3; - foldedLoad = TryFoldLoad(N, N1, Tmp0, Tmp1, Tmp2, Tmp3); - SDOperand Chain; - if (foldedLoad) { - Chain = N1.getOperand(0); - AddToISelQueue(Chain); - } else - Chain = CurDAG->getEntryNode(); - SDOperand InFlag(0, 0); - AddToISelQueue(N0); - Chain = CurDAG->getCopyToReg(Chain, CurDAG->getRegister(LoReg, NVT), - N0, InFlag); - InFlag = Chain.getValue(1); - - if (isSigned) { - // Sign extend the low part into the high part. - InFlag = - SDOperand(CurDAG->getTargetNode(SExtOpcode, MVT::Flag, InFlag), 0); - } else { - // Zero out the high part, effectively zero extending the input. - SDOperand ClrNode = SDOperand(CurDAG->getTargetNode(ClrOpcode, NVT), 0); - Chain = CurDAG->getCopyToReg(Chain, CurDAG->getRegister(HiReg, NVT), - ClrNode, InFlag); + if (NVT == MVT::i8 && !isSigned) { + // Special case for div8, just use a move with zero extension to AX to + // clear the upper 8 bits (AH). + SDOperand Tmp0, Tmp1, Tmp2, Tmp3, Move, Chain; + if (TryFoldLoad(N, N0, Tmp0, Tmp1, Tmp2, Tmp3)) { + SDOperand Ops[] = { Tmp0, Tmp1, Tmp2, Tmp3, N0.getOperand(0) }; + AddToISelQueue(N0.getOperand(0)); + AddToISelQueue(Tmp0); + AddToISelQueue(Tmp1); + AddToISelQueue(Tmp2); + AddToISelQueue(Tmp3); + Move = + SDOperand(CurDAG->getTargetNode(X86::MOVZX16rm8, MVT::i16, MVT::Other, + Ops, 5), 0); + Chain = Move.getValue(1); + ReplaceUses(N0.getValue(1), Chain); + } else { + AddToISelQueue(N0); + Move = + SDOperand(CurDAG->getTargetNode(X86::MOVZX16rr8, MVT::i16, N0), 0); + Chain = CurDAG->getEntryNode(); + } + Chain = CurDAG->getCopyToReg(Chain, X86::AX, Move, InFlag); InFlag = Chain.getValue(1); + } else { + AddToISelQueue(N0); + InFlag = + CurDAG->getCopyToReg(CurDAG->getEntryNode(), LoReg, N0, + InFlag).getValue(1); + if (isSigned) { + // Sign extend the low part into the high part. + InFlag = + SDOperand(CurDAG->getTargetNode(SExtOpcode, MVT::Flag, InFlag), 0); + } else { + // Zero out the high part, effectively zero extending the input. + SDOperand ClrNode = SDOperand(CurDAG->getTargetNode(ClrOpcode, NVT), 0); + InFlag = CurDAG->getCopyToReg(CurDAG->getEntryNode(), HiReg, ClrNode, + InFlag).getValue(1); + } } + SDOperand Tmp0, Tmp1, Tmp2, Tmp3, Chain; + bool foldedLoad = TryFoldLoad(N, N1, Tmp0, Tmp1, Tmp2, Tmp3); if (foldedLoad) { + AddToISelQueue(N1.getOperand(0)); AddToISelQueue(Tmp0); AddToISelQueue(Tmp1); AddToISelQueue(Tmp2); AddToISelQueue(Tmp3); - SDOperand Ops[] = { Tmp0, Tmp1, Tmp2, Tmp3, Chain, InFlag }; + SDOperand Ops[] = { Tmp0, Tmp1, Tmp2, Tmp3, N1.getOperand(0), InFlag }; SDNode *CNode = CurDAG->getTargetNode(MOpc, MVT::Other, MVT::Flag, Ops, 6); Chain = SDOperand(CNode, 0); InFlag = SDOperand(CNode, 1); } else { AddToISelQueue(N1); + Chain = CurDAG->getEntryNode(); InFlag = SDOperand(CurDAG->getTargetNode(Opc, MVT::Flag, N1, InFlag), 0); } - SDOperand Result = CurDAG->getCopyFromReg(Chain, isDiv ? LoReg : HiReg, - NVT, InFlag); + SDOperand Result = + CurDAG->getCopyFromReg(Chain, isDiv ? LoReg : HiReg, NVT, InFlag); ReplaceUses(N.getValue(0), Result); if (foldedLoad) ReplaceUses(N1.getValue(1), Result.getValue(1)); From sabre at nondot.org Fri Nov 17 16:11:14 2006 From: sabre at nondot.org (Chris Lattner) Date: Fri, 17 Nov 2006 16:11:14 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCPredicates.cpp PPCPredicates.h PPC.h PPCAsmPrinter.cpp PPCBranchSelector.cpp PPCISelDAGToDAG.cpp PPCISelLowering.cpp PPCInstrInfo.cpp PPCInstrInfo.h PPCInstrInfo.td Message-ID: <200611172211.kAHMBE5u014015@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCPredicates.cpp added (r1.1) PPCPredicates.h added (r1.1) PPC.h updated: 1.36 -> 1.37 PPCAsmPrinter.cpp updated: 1.208 -> 1.209 PPCBranchSelector.cpp updated: 1.34 -> 1.35 PPCISelDAGToDAG.cpp updated: 1.221 -> 1.222 PPCISelLowering.cpp updated: 1.228 -> 1.229 PPCInstrInfo.cpp updated: 1.31 -> 1.32 PPCInstrInfo.h updated: 1.19 -> 1.20 PPCInstrInfo.td updated: 1.266 -> 1.267 --- Log message: start using PPC predicates more consistently. --- Diffs of the changes: (+118 -60) PPC.h | 15 --------------- PPCAsmPrinter.cpp | 1 + PPCBranchSelector.cpp | 28 +++++++++++++++++++++++----- PPCISelDAGToDAG.cpp | 26 ++++++++++++-------------- PPCISelLowering.cpp | 16 +++++++++------- PPCInstrInfo.cpp | 3 ++- PPCInstrInfo.h | 16 ---------------- PPCInstrInfo.td | 4 ++-- PPCPredicates.cpp | 30 ++++++++++++++++++++++++++++++ PPCPredicates.h | 39 +++++++++++++++++++++++++++++++++++++++ 10 files changed, 118 insertions(+), 60 deletions(-) Index: llvm/lib/Target/PowerPC/PPCPredicates.cpp diff -c /dev/null llvm/lib/Target/PowerPC/PPCPredicates.cpp:1.1 *** /dev/null Fri Nov 17 16:11:09 2006 --- llvm/lib/Target/PowerPC/PPCPredicates.cpp Fri Nov 17 16:10:59 2006 *************** *** 0 **** --- 1,30 ---- + //===-- PPCPredicates.cpp - PPC Branch Predicate Information --------------===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by Chris Lattner and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file implements the PowerPC branch predicates. + // + //===----------------------------------------------------------------------===// + + #include "PPCPredicates.h" + #include + using namespace llvm; + + PPC::Predicate PPC::InvertPredicate(PPC::Predicate Opcode) { + switch (Opcode) { + default: assert(0 && "Unknown PPC branch opcode!"); + case PPC::PRED_EQ: return PPC::PRED_NE; + case PPC::PRED_NE: return PPC::PRED_EQ; + case PPC::PRED_LT: return PPC::PRED_GE; + case PPC::PRED_GE: return PPC::PRED_LT; + case PPC::PRED_GT: return PPC::PRED_LE; + case PPC::PRED_LE: return PPC::PRED_GT; + case PPC::PRED_NU: return PPC::PRED_UN; + case PPC::PRED_UN: return PPC::PRED_NU; + } + } Index: llvm/lib/Target/PowerPC/PPCPredicates.h diff -c /dev/null llvm/lib/Target/PowerPC/PPCPredicates.h:1.1 *** /dev/null Fri Nov 17 16:11:14 2006 --- llvm/lib/Target/PowerPC/PPCPredicates.h Fri Nov 17 16:10:59 2006 *************** *** 0 **** --- 1,39 ---- + //===-- PPCPredicates.h - PPC Branch Predicate Information ------*- C++ -*-===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by Chris Lattner and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file describes the PowerPC branch predicates. + // + //===----------------------------------------------------------------------===// + + #ifndef LLVM_TARGET_POWERPC_PPCPREDICATES_H + #define LLVM_TARGET_POWERPC_PPCPREDICATES_H + + #include "PPC.h" + + namespace llvm { + namespace PPC { + /// Predicate - These are "(BI << 5) | BO" for various predicates. + enum Predicate { + PRED_ALWAYS = (0 << 5) | 20, + PRED_LT = (0 << 5) | 12, + PRED_LE = (1 << 5) | 4, + PRED_EQ = (2 << 5) | 12, + PRED_GE = (0 << 5) | 4, + PRED_GT = (1 << 5) | 12, + PRED_NE = (2 << 5) | 4, + PRED_UN = (3 << 5) | 12, + PRED_NU = (3 << 5) | 4 + }; + + /// Invert the specified predicate. != -> ==, < -> >=. + Predicate InvertPredicate(Predicate Opcode); + } + } + + #endif Index: llvm/lib/Target/PowerPC/PPC.h diff -u llvm/lib/Target/PowerPC/PPC.h:1.36 llvm/lib/Target/PowerPC/PPC.h:1.37 --- llvm/lib/Target/PowerPC/PPC.h:1.36 Fri Nov 3 23:42:48 2006 +++ llvm/lib/Target/PowerPC/PPC.h Fri Nov 17 16:10:59 2006 @@ -27,21 +27,6 @@ class FunctionPass; class MachineCodeEmitter; - namespace PPC { - /// Predicate - These are "(BI << 5) | BO" for various predicates. - enum Predicate { - PRED_ALWAYS = (0 << 5) | 20, - PRED_LT = (0 << 5) | 12, - PRED_LE = (1 << 5) | 4, - PRED_EQ = (2 << 5) | 12, - PRED_GE = (0 << 5) | 4, - PRED_GT = (1 << 5) | 12, - PRED_NE = (2 << 5) | 4, - PRED_UN = (3 << 5) | 12, - PRED_NU = (3 << 5) | 4 - }; - } - FunctionPass *createPPCBranchSelectionPass(); FunctionPass *createPPCISelDag(PPCTargetMachine &TM); FunctionPass *createPPCAsmPrinterPass(std::ostream &OS, Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.208 llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.209 --- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.208 Thu Nov 16 15:45:30 2006 +++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp Fri Nov 17 16:10:59 2006 @@ -18,6 +18,7 @@ #define DEBUG_TYPE "asmprinter" #include "PPC.h" +#include "PPCPredicates.h" #include "PPCTargetMachine.h" #include "PPCSubtarget.h" #include "llvm/Constants.h" Index: llvm/lib/Target/PowerPC/PPCBranchSelector.cpp diff -u llvm/lib/Target/PowerPC/PPCBranchSelector.cpp:1.34 llvm/lib/Target/PowerPC/PPCBranchSelector.cpp:1.35 --- llvm/lib/Target/PowerPC/PPCBranchSelector.cpp:1.34 Fri Nov 17 08:06:41 2006 +++ llvm/lib/Target/PowerPC/PPCBranchSelector.cpp Fri Nov 17 16:10:59 2006 @@ -18,6 +18,7 @@ #include "PPC.h" #include "PPCInstrBuilder.h" #include "PPCInstrInfo.h" +#include "PPCPredicates.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetAsmInfo.h" @@ -125,19 +126,36 @@ // 1. PPC branch opcode // 2. Target MBB MachineBasicBlock *DestMBB = MBBI->getOperand(2).getMachineBasicBlock(); - unsigned Opcode = MBBI->getOperand(1).getImmedValue(); + PPC::Predicate Pred = (PPC::Predicate)MBBI->getOperand(1).getImm(); unsigned CRReg = MBBI->getOperand(0).getReg(); - int Displacement = OffsetMap[DestMBB->getNumber()] - ByteCount; - unsigned Inverted = PPCInstrInfo::invertPPCBranchOpcode(Opcode); + + bool ShortBranchOk = Displacement >= -32768 && Displacement <= 32767; + + // Branch on opposite condition if a short branch isn't ok. + if (!ShortBranchOk) + Pred = PPC::InvertPredicate(Pred); + + unsigned Opcode; + switch (Pred) { + default: assert(0 && "Unknown cond branch predicate!"); + case PPC::PRED_LT: Opcode = PPC::BLT; break; + case PPC::PRED_LE: Opcode = PPC::BLE; break; + case PPC::PRED_EQ: Opcode = PPC::BEQ; break; + case PPC::PRED_GE: Opcode = PPC::BGE; break; + case PPC::PRED_GT: Opcode = PPC::BGT; break; + case PPC::PRED_NE: Opcode = PPC::BNE; break; + case PPC::PRED_UN: Opcode = PPC::BUN; break; + case PPC::PRED_NU: Opcode = PPC::BNU; break; + } MachineBasicBlock::iterator MBBJ; - if (Displacement >= -32768 && Displacement <= 32767) { + if (ShortBranchOk) { MBBJ = BuildMI(*MBB, MBBI, Opcode, 2).addReg(CRReg).addMBB(DestMBB); } else { // Long branch, skip next branch instruction (i.e. $PC+8). ++NumExpanded; - BuildMI(*MBB, MBBI, Inverted, 2).addReg(CRReg).addImm(2); + BuildMI(*MBB, MBBI, Opcode, 2).addReg(CRReg).addImm(2); MBBJ = BuildMI(*MBB, MBBI, PPC::B, 1).addMBB(DestMBB); } Index: llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp diff -u llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:1.221 llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:1.222 --- llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:1.221 Wed Nov 15 18:41:37 2006 +++ llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp Fri Nov 17 16:10:59 2006 @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include "PPC.h" +#include "PPCPredicates.h" #include "PPCTargetMachine.h" #include "PPCISelLowering.h" #include "PPCHazardRecognizers.h" @@ -594,34 +595,31 @@ return SDOperand(CurDAG->getTargetNode(Opc, MVT::i32, LHS, RHS), 0); } -/// getBCCForSetCC - Returns the PowerPC condition branch mnemonic corresponding -/// to Condition. -static unsigned getBCCForSetCC(ISD::CondCode CC) { +static PPC::Predicate getPredicateForSetCC(ISD::CondCode CC) { switch (CC) { default: assert(0 && "Unknown condition!"); abort(); case ISD::SETOEQ: // FIXME: This is incorrect see PR642. case ISD::SETUEQ: - case ISD::SETEQ: return PPC::BEQ; + case ISD::SETEQ: return PPC::PRED_EQ; case ISD::SETONE: // FIXME: This is incorrect see PR642. case ISD::SETUNE: - case ISD::SETNE: return PPC::BNE; + case ISD::SETNE: return PPC::PRED_NE; case ISD::SETOLT: // FIXME: This is incorrect see PR642. case ISD::SETULT: - case ISD::SETLT: return PPC::BLT; + case ISD::SETLT: return PPC::PRED_LT; case ISD::SETOLE: // FIXME: This is incorrect see PR642. case ISD::SETULE: - case ISD::SETLE: return PPC::BLE; + case ISD::SETLE: return PPC::PRED_LE; case ISD::SETOGT: // FIXME: This is incorrect see PR642. case ISD::SETUGT: - case ISD::SETGT: return PPC::BGT; + case ISD::SETGT: return PPC::PRED_GT; case ISD::SETOGE: // FIXME: This is incorrect see PR642. case ISD::SETUGE: - case ISD::SETGE: return PPC::BGE; + case ISD::SETGE: return PPC::PRED_GE; - case ISD::SETO: return PPC::BNU; - case ISD::SETUO: return PPC::BUN; + case ISD::SETO: return PPC::PRED_NU; + case ISD::SETUO: return PPC::PRED_UN; } - return 0; } /// getCRIdxForSetCC - Return the index of the condition register field @@ -983,7 +981,7 @@ } SDOperand CCReg = SelectCC(N->getOperand(0), N->getOperand(1), CC); - unsigned BROpc = getBCCForSetCC(CC); + unsigned BROpc = getPredicateForSetCC(CC); unsigned SelectCCOp; if (N->getValueType(0) == MVT::i32) @@ -1007,7 +1005,7 @@ AddToISelQueue(N->getOperand(0)); ISD::CondCode CC = cast(N->getOperand(1))->get(); SDOperand CondCode = SelectCC(N->getOperand(2), N->getOperand(3), CC); - SDOperand Ops[] = { CondCode, getI32Imm(getBCCForSetCC(CC)), + SDOperand Ops[] = { CondCode, getI32Imm(getPredicateForSetCC(CC)), N->getOperand(4), N->getOperand(0) }; return CurDAG->SelectNodeTo(N, PPC::COND_BRANCH, MVT::Other, Ops, 4); } Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp diff -u llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.228 llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.229 --- llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.228 Thu Nov 16 16:43:37 2006 +++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp Fri Nov 17 16:10:59 2006 @@ -13,6 +13,7 @@ #include "PPCISelLowering.h" #include "PPCMachineFunctionInfo.h" +#include "PPCPredicates.h" #include "PPCTargetMachine.h" #include "PPCPerfectShuffle.h" #include "llvm/ADT/VectorExtras.h" @@ -2611,8 +2612,9 @@ MachineBasicBlock *thisMBB = BB; MachineBasicBlock *copy0MBB = new MachineBasicBlock(LLVM_BB); MachineBasicBlock *sinkMBB = new MachineBasicBlock(LLVM_BB); - BuildMI(BB, MI->getOperand(4).getImmedValue(), 2) - .addReg(MI->getOperand(1).getReg()).addMBB(sinkMBB); + unsigned SelectPred = MI->getOperand(4).getImm(); + BuildMI(BB, PPC::COND_BRANCH, 3) + .addReg(MI->getOperand(1).getReg()).addImm(SelectPred).addMBB(sinkMBB); MachineFunction *F = BB->getParent(); F->getBasicBlockList().insert(It, copy0MBB); F->getBasicBlockList().insert(It, sinkMBB); @@ -2870,20 +2872,20 @@ SDOperand CompNode = DAG.getNode(PPCISD::VCMPo, VTs, Ops, 3); // Unpack the result based on how the target uses it. - unsigned CompOpc; + PPC::Predicate CompOpc; switch (cast(LHS.getOperand(1))->getValue()) { default: // Can't happen, don't crash on invalid number though. case 0: // Branch on the value of the EQ bit of CR6. - CompOpc = BranchOnWhenPredTrue ? PPC::BEQ : PPC::BNE; + CompOpc = BranchOnWhenPredTrue ? PPC::PRED_EQ : PPC::PRED_NE; break; case 1: // Branch on the inverted value of the EQ bit of CR6. - CompOpc = BranchOnWhenPredTrue ? PPC::BNE : PPC::BEQ; + CompOpc = BranchOnWhenPredTrue ? PPC::PRED_NE : PPC::PRED_EQ; break; case 2: // Branch on the value of the LT bit of CR6. - CompOpc = BranchOnWhenPredTrue ? PPC::BLT : PPC::BGE; + CompOpc = BranchOnWhenPredTrue ? PPC::PRED_LT : PPC::PRED_GE; break; case 3: // Branch on the inverted value of the LT bit of CR6. - CompOpc = BranchOnWhenPredTrue ? PPC::BGE : PPC::BLT; + CompOpc = BranchOnWhenPredTrue ? PPC::PRED_GE : PPC::PRED_LT; break; } Index: llvm/lib/Target/PowerPC/PPCInstrInfo.cpp diff -u llvm/lib/Target/PowerPC/PPCInstrInfo.cpp:1.31 llvm/lib/Target/PowerPC/PPCInstrInfo.cpp:1.32 --- llvm/lib/Target/PowerPC/PPCInstrInfo.cpp:1.31 Wed Nov 15 14:58:11 2006 +++ llvm/lib/Target/PowerPC/PPCInstrInfo.cpp Fri Nov 17 16:10:59 2006 @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "PPCInstrInfo.h" +#include "PPCPredicates.h" #include "PPCGenInstrInfo.inc" #include "PPCTargetMachine.h" #include "llvm/CodeGen/MachineInstrBuilder.h" @@ -284,6 +285,6 @@ ReverseBranchCondition(std::vector &Cond) const { assert(Cond.size() == 2 && "Invalid PPC branch opcode!"); // Leave the CR# the same, but invert the condition. - Cond[1].setImm(invertPPCBranchOpcode(Cond[1].getImm())); + Cond[1].setImm(PPC::InvertPredicate((PPC::Predicate)Cond[1].getImm())); return false; } Index: llvm/lib/Target/PowerPC/PPCInstrInfo.h diff -u llvm/lib/Target/PowerPC/PPCInstrInfo.h:1.19 llvm/lib/Target/PowerPC/PPCInstrInfo.h:1.20 --- llvm/lib/Target/PowerPC/PPCInstrInfo.h:1.19 Sat Oct 28 12:35:02 2006 +++ llvm/lib/Target/PowerPC/PPCInstrInfo.h Fri Nov 17 16:10:59 2006 @@ -112,22 +112,6 @@ const std::vector &Cond) const; virtual bool BlockHasNoFallThrough(MachineBasicBlock &MBB) const; virtual bool ReverseBranchCondition(std::vector &Cond) const; - - - - static unsigned invertPPCBranchOpcode(unsigned Opcode) { - switch (Opcode) { - default: assert(0 && "Unknown PPC branch opcode!"); - case PPC::BEQ: return PPC::BNE; - case PPC::BNE: return PPC::BEQ; - case PPC::BLT: return PPC::BGE; - case PPC::BGE: return PPC::BLT; - case PPC::BGT: return PPC::BLE; - case PPC::BLE: return PPC::BGT; - case PPC::BNU: return PPC::BUN; - case PPC::BUN: return PPC::BNU; - } - } }; } Index: llvm/lib/Target/PowerPC/PPCInstrInfo.td diff -u llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.266 llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.267 --- llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.266 Thu Nov 16 16:43:37 2006 +++ llvm/lib/Target/PowerPC/PPCInstrInfo.td Fri Nov 17 16:10:59 2006 @@ -338,8 +338,7 @@ let isTerminator = 1, isBarrier = 1, noResults = 1, PPC970_Unit = 7 in { let isReturn = 1 in - def BLR : XLForm_2_br<19, 16, 0, - (ops pred:$p), + def BLR : XLForm_2_br<19, 16, 0, (ops pred:$p), "b${p:cc}lr ${p:reg}", BrB, [(retflag)]>; def BCTR : XLForm_2_ext<19, 528, 20, 0, 0, (ops), "bctr", BrB, []>; @@ -354,6 +353,7 @@ let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, noResults = 1, PPC970_Unit = 7 in { // COND_BRANCH is formed before branch selection, it is turned into Bcc below. + // 'opc' is a 'PPC::Predicate' value. def COND_BRANCH : Pseudo<(ops CRRC:$crS, u16imm:$opc, target:$dst), "${:comment} COND_BRANCH $crS, $opc, $dst", [(PPCcondbranch CRRC:$crS, imm:$opc, bb:$dst)]>; From sabre at nondot.org Fri Nov 17 16:15:01 2006 From: sabre at nondot.org (Chris Lattner) Date: Fri, 17 Nov 2006 16:15:01 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCBranchSelector.cpp PPCISelDAGToDAG.cpp PPCISelLowering.cpp PPCInstrInfo.cpp PPCInstrInfo.td Message-ID: <200611172215.kAHMF1pk014105@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCBranchSelector.cpp updated: 1.35 -> 1.36 PPCISelDAGToDAG.cpp updated: 1.222 -> 1.223 PPCISelLowering.cpp updated: 1.229 -> 1.230 PPCInstrInfo.cpp updated: 1.32 -> 1.33 PPCInstrInfo.td updated: 1.267 -> 1.268 --- Log message: rename PPC::COND_BRANCH to PPC::BCC --- Diffs of the changes: (+18 -17) PPCBranchSelector.cpp | 6 +++--- PPCISelDAGToDAG.cpp | 2 +- PPCISelLowering.cpp | 2 +- PPCInstrInfo.cpp | 14 +++++++------- PPCInstrInfo.td | 11 ++++++----- 5 files changed, 18 insertions(+), 17 deletions(-) Index: llvm/lib/Target/PowerPC/PPCBranchSelector.cpp diff -u llvm/lib/Target/PowerPC/PPCBranchSelector.cpp:1.35 llvm/lib/Target/PowerPC/PPCBranchSelector.cpp:1.36 --- llvm/lib/Target/PowerPC/PPCBranchSelector.cpp:1.35 Fri Nov 17 16:10:59 2006 +++ llvm/lib/Target/PowerPC/PPCBranchSelector.cpp Fri Nov 17 16:14:47 2006 @@ -54,7 +54,7 @@ /// static unsigned getNumBytesForInstruction(MachineInstr *MI) { switch (MI->getOpcode()) { - case PPC::COND_BRANCH: + case PPC::BCC: // while this will be 4 most of the time, if we emit 8 it is just a // minor pessimization that saves us from having to worry about // keeping the offsets up to date later when we emit long branch glue. @@ -116,7 +116,7 @@ // We may end up deleting the MachineInstr that MBBI points to, so // remember its opcode now so we can refer to it after calling erase() unsigned ByteSize = getNumBytesForInstruction(MBBI); - if (MBBI->getOpcode() != PPC::COND_BRANCH) { + if (MBBI->getOpcode() != PPC::BCC) { ByteCount += ByteSize; continue; } @@ -159,7 +159,7 @@ MBBJ = BuildMI(*MBB, MBBI, PPC::B, 1).addMBB(DestMBB); } - // Erase the psuedo COND_BRANCH instruction, and then back up the + // Erase the psuedo BCC instruction, and then back up the // iterator so that when the for loop increments it, we end up in // the correct place rather than iterating off the end. MBB->erase(MBBI); Index: llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp diff -u llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:1.222 llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:1.223 --- llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:1.222 Fri Nov 17 16:10:59 2006 +++ llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp Fri Nov 17 16:14:47 2006 @@ -1007,7 +1007,7 @@ SDOperand CondCode = SelectCC(N->getOperand(2), N->getOperand(3), CC); SDOperand Ops[] = { CondCode, getI32Imm(getPredicateForSetCC(CC)), N->getOperand(4), N->getOperand(0) }; - return CurDAG->SelectNodeTo(N, PPC::COND_BRANCH, MVT::Other, Ops, 4); + return CurDAG->SelectNodeTo(N, PPC::BCC, MVT::Other, Ops, 4); } case ISD::BRIND: { // FIXME: Should custom lower this. Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp diff -u llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.229 llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.230 --- llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.229 Fri Nov 17 16:10:59 2006 +++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp Fri Nov 17 16:14:47 2006 @@ -2613,7 +2613,7 @@ MachineBasicBlock *copy0MBB = new MachineBasicBlock(LLVM_BB); MachineBasicBlock *sinkMBB = new MachineBasicBlock(LLVM_BB); unsigned SelectPred = MI->getOperand(4).getImm(); - BuildMI(BB, PPC::COND_BRANCH, 3) + BuildMI(BB, PPC::BCC, 3) .addReg(MI->getOperand(1).getReg()).addImm(SelectPred).addMBB(sinkMBB); MachineFunction *F = BB->getParent(); F->getBasicBlockList().insert(It, copy0MBB); Index: llvm/lib/Target/PowerPC/PPCInstrInfo.cpp diff -u llvm/lib/Target/PowerPC/PPCInstrInfo.cpp:1.32 llvm/lib/Target/PowerPC/PPCInstrInfo.cpp:1.33 --- llvm/lib/Target/PowerPC/PPCInstrInfo.cpp:1.32 Fri Nov 17 16:10:59 2006 +++ llvm/lib/Target/PowerPC/PPCInstrInfo.cpp Fri Nov 17 16:14:47 2006 @@ -192,7 +192,7 @@ if (LastInst->getOpcode() == PPC::B) { TBB = LastInst->getOperand(0).getMachineBasicBlock(); return false; - } else if (LastInst->getOpcode() == PPC::COND_BRANCH) { + } else if (LastInst->getOpcode() == PPC::BCC) { // Block ends with fall-through condbranch. TBB = LastInst->getOperand(2).getMachineBasicBlock(); Cond.push_back(LastInst->getOperand(0)); @@ -211,8 +211,8 @@ isTerminatorInstr((--I)->getOpcode())) return true; - // If the block ends with PPC::B and PPC:COND_BRANCH, handle it. - if (SecondLastInst->getOpcode() == PPC::COND_BRANCH && + // If the block ends with PPC::B and PPC:BCC, handle it. + if (SecondLastInst->getOpcode() == PPC::BCC && LastInst->getOpcode() == PPC::B) { TBB = SecondLastInst->getOperand(2).getMachineBasicBlock(); Cond.push_back(SecondLastInst->getOperand(0)); @@ -229,7 +229,7 @@ MachineBasicBlock::iterator I = MBB.end(); if (I == MBB.begin()) return; --I; - if (I->getOpcode() != PPC::B && I->getOpcode() != PPC::COND_BRANCH) + if (I->getOpcode() != PPC::B && I->getOpcode() != PPC::BCC) return; // Remove the branch. @@ -239,7 +239,7 @@ if (I == MBB.begin()) return; --I; - if (I->getOpcode() != PPC::COND_BRANCH) + if (I->getOpcode() != PPC::BCC) return; // Remove the branch. @@ -259,13 +259,13 @@ if (Cond.empty()) // Unconditional branch BuildMI(&MBB, PPC::B, 1).addMBB(TBB); else // Conditional branch - BuildMI(&MBB, PPC::COND_BRANCH, 3) + BuildMI(&MBB, PPC::BCC, 3) .addReg(Cond[0].getReg()).addImm(Cond[1].getImm()).addMBB(TBB); return; } // Two-way Conditional Branch. - BuildMI(&MBB, PPC::COND_BRANCH, 3) + BuildMI(&MBB, PPC::BCC, 3) .addReg(Cond[0].getReg()).addImm(Cond[1].getImm()).addMBB(TBB); BuildMI(&MBB, PPC::B, 1).addMBB(FBB); } Index: llvm/lib/Target/PowerPC/PPCInstrInfo.td diff -u llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.267 llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.268 --- llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.267 Fri Nov 17 16:10:59 2006 +++ llvm/lib/Target/PowerPC/PPCInstrInfo.td Fri Nov 17 16:14:47 2006 @@ -352,17 +352,18 @@ let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, noResults = 1, PPC970_Unit = 7 in { - // COND_BRANCH is formed before branch selection, it is turned into Bcc below. - // 'opc' is a 'PPC::Predicate' value. - def COND_BRANCH : Pseudo<(ops CRRC:$crS, u16imm:$opc, target:$dst), - "${:comment} COND_BRANCH $crS, $opc, $dst", - [(PPCcondbranch CRRC:$crS, imm:$opc, bb:$dst)]>; let isBarrier = 1 in { def B : IForm<18, 0, 0, (ops target:$dst), "b $dst", BrB, [(br bb:$dst)]>; } + // BCC is formed before branch selection, it is turned into Bxx below. + // 'opc' is a 'PPC::Predicate' value. + def BCC : Pseudo<(ops CRRC:$crS, u16imm:$opc, target:$dst), + "${:comment} BCC $crS, $opc, $dst", + [(PPCcondbranch CRRC:$crS, imm:$opc, bb:$dst)]>; + def BLT : BForm<16, 0, 0, 12, 0, (ops CRRC:$crS, target:$block), "blt $crS, $block", BrB>; def BLE : BForm<16, 0, 0, 4, 1, (ops CRRC:$crS, target:$block), From sabre at nondot.org Fri Nov 17 16:37:48 2006 From: sabre at nondot.org (Chris Lattner) Date: Fri, 17 Nov 2006 16:37:48 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCBranchSelector.cpp PPCISelDAGToDAG.cpp PPCISelLowering.cpp PPCInstrInfo.cpp PPCInstrInfo.td Message-ID: <200611172237.kAHMbmud014504@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCBranchSelector.cpp updated: 1.36 -> 1.37 PPCISelDAGToDAG.cpp updated: 1.223 -> 1.224 PPCISelLowering.cpp updated: 1.230 -> 1.231 PPCInstrInfo.cpp updated: 1.33 -> 1.34 PPCInstrInfo.td updated: 1.268 -> 1.269 --- Log message: convert PPC::BCC to use the 'pred' operand instead of separate predicate value and CR reg #. This requires swapping the order of these everywhere that touches BCC and requires us to write custom matching logic for PPCcondbranch :( --- Diffs of the changes: (+25 -14) PPCBranchSelector.cpp | 4 ++-- PPCISelDAGToDAG.cpp | 12 +++++++++++- PPCISelLowering.cpp | 4 ++-- PPCInstrInfo.cpp | 6 +++--- PPCInstrInfo.td | 13 +++++++------ 5 files changed, 25 insertions(+), 14 deletions(-) Index: llvm/lib/Target/PowerPC/PPCBranchSelector.cpp diff -u llvm/lib/Target/PowerPC/PPCBranchSelector.cpp:1.36 llvm/lib/Target/PowerPC/PPCBranchSelector.cpp:1.37 --- llvm/lib/Target/PowerPC/PPCBranchSelector.cpp:1.36 Fri Nov 17 16:14:47 2006 +++ llvm/lib/Target/PowerPC/PPCBranchSelector.cpp Fri Nov 17 16:37:34 2006 @@ -126,8 +126,8 @@ // 1. PPC branch opcode // 2. Target MBB MachineBasicBlock *DestMBB = MBBI->getOperand(2).getMachineBasicBlock(); - PPC::Predicate Pred = (PPC::Predicate)MBBI->getOperand(1).getImm(); - unsigned CRReg = MBBI->getOperand(0).getReg(); + PPC::Predicate Pred = (PPC::Predicate)MBBI->getOperand(0).getImm(); + unsigned CRReg = MBBI->getOperand(1).getReg(); int Displacement = OffsetMap[DestMBB->getNumber()] - ByteCount; bool ShortBranchOk = Displacement >= -32768 && Displacement <= 32767; Index: llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp diff -u llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:1.223 llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:1.224 --- llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:1.223 Fri Nov 17 16:14:47 2006 +++ llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp Fri Nov 17 16:37:34 2006 @@ -1001,11 +1001,21 @@ getI32Imm(BROpc) }; return CurDAG->SelectNodeTo(N, SelectCCOp, N->getValueType(0), Ops, 4); } + case PPCISD::COND_BRANCH: { + AddToISelQueue(N->getOperand(0)); // Op #0 is the Chain. + // Op #1 is the PPC::PRED_* number. + // Op #2 is the CR# + // Op #3 is the Dest MBB + AddToISelQueue(N->getOperand(4)); // Op #4 is the Flag. + SDOperand Ops[] = { N->getOperand(1), N->getOperand(2), N->getOperand(3), + N->getOperand(0), N->getOperand(4) }; + return CurDAG->SelectNodeTo(N, PPC::BCC, MVT::Other, Ops, 5); + } case ISD::BR_CC: { AddToISelQueue(N->getOperand(0)); ISD::CondCode CC = cast(N->getOperand(1))->get(); SDOperand CondCode = SelectCC(N->getOperand(2), N->getOperand(3), CC); - SDOperand Ops[] = { CondCode, getI32Imm(getPredicateForSetCC(CC)), + SDOperand Ops[] = { getI32Imm(getPredicateForSetCC(CC)), CondCode, N->getOperand(4), N->getOperand(0) }; return CurDAG->SelectNodeTo(N, PPC::BCC, MVT::Other, Ops, 4); } Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp diff -u llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.230 llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.231 --- llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.230 Fri Nov 17 16:14:47 2006 +++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp Fri Nov 17 16:37:34 2006 @@ -2614,7 +2614,7 @@ MachineBasicBlock *sinkMBB = new MachineBasicBlock(LLVM_BB); unsigned SelectPred = MI->getOperand(4).getImm(); BuildMI(BB, PPC::BCC, 3) - .addReg(MI->getOperand(1).getReg()).addImm(SelectPred).addMBB(sinkMBB); + .addImm(SelectPred).addReg(MI->getOperand(1).getReg()).addMBB(sinkMBB); MachineFunction *F = BB->getParent(); F->getBasicBlockList().insert(It, copy0MBB); F->getBasicBlockList().insert(It, sinkMBB); @@ -2890,8 +2890,8 @@ } return DAG.getNode(PPCISD::COND_BRANCH, MVT::Other, N->getOperand(0), - DAG.getRegister(PPC::CR6, MVT::i32), DAG.getConstant(CompOpc, MVT::i32), + DAG.getRegister(PPC::CR6, MVT::i32), N->getOperand(4), CompNode.getValue(1)); } break; Index: llvm/lib/Target/PowerPC/PPCInstrInfo.cpp diff -u llvm/lib/Target/PowerPC/PPCInstrInfo.cpp:1.33 llvm/lib/Target/PowerPC/PPCInstrInfo.cpp:1.34 --- llvm/lib/Target/PowerPC/PPCInstrInfo.cpp:1.33 Fri Nov 17 16:14:47 2006 +++ llvm/lib/Target/PowerPC/PPCInstrInfo.cpp Fri Nov 17 16:37:34 2006 @@ -260,13 +260,13 @@ BuildMI(&MBB, PPC::B, 1).addMBB(TBB); else // Conditional branch BuildMI(&MBB, PPC::BCC, 3) - .addReg(Cond[0].getReg()).addImm(Cond[1].getImm()).addMBB(TBB); + .addImm(Cond[0].getImm()).addReg(Cond[1].getReg()).addMBB(TBB); return; } // Two-way Conditional Branch. BuildMI(&MBB, PPC::BCC, 3) - .addReg(Cond[0].getReg()).addImm(Cond[1].getImm()).addMBB(TBB); + .addImm(Cond[0].getImm()).addReg(Cond[1].getReg()).addMBB(TBB); BuildMI(&MBB, PPC::B, 1).addMBB(FBB); } @@ -285,6 +285,6 @@ ReverseBranchCondition(std::vector &Cond) const { assert(Cond.size() == 2 && "Invalid PPC branch opcode!"); // Leave the CR# the same, but invert the condition. - Cond[1].setImm(PPC::InvertPredicate((PPC::Predicate)Cond[1].getImm())); + Cond[0].setImm(PPC::InvertPredicate((PPC::Predicate)Cond[0].getImm())); return false; } Index: llvm/lib/Target/PowerPC/PPCInstrInfo.td diff -u llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.268 llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.269 --- llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.268 Fri Nov 17 16:14:47 2006 +++ llvm/lib/Target/PowerPC/PPCInstrInfo.td Fri Nov 17 16:37:34 2006 @@ -34,7 +34,7 @@ ]>; def SDT_PPCcondbr : SDTypeProfile<0, 3, [ - SDTCisVT<1, i32>, SDTCisVT<2, OtherVT> + SDTCisVT<0, i32>, SDTCisVT<2, OtherVT> ]>; def SDT_PPClbrx : SDTypeProfile<1, 3, [ @@ -358,11 +358,12 @@ [(br bb:$dst)]>; } - // BCC is formed before branch selection, it is turned into Bxx below. - // 'opc' is a 'PPC::Predicate' value. - def BCC : Pseudo<(ops CRRC:$crS, u16imm:$opc, target:$dst), - "${:comment} BCC $crS, $opc, $dst", - [(PPCcondbranch CRRC:$crS, imm:$opc, bb:$dst)]>; + // BCC represents an arbitrary conditional branch on a predicate. + // FIXME: should be able to write a pattern for PPCcondbranch, but can't use + // a two-value operand where a dag node expects two operands. :( + def BCC : Pseudo<(ops pred:$cond, target:$dst), + "b${cond:cc} ${cond:reg}, $dst", + [/*(PPCcondbranch CRRC:$crS, imm:$opc, bb:$dst)*/]>; def BLT : BForm<16, 0, 0, 12, 0, (ops CRRC:$crS, target:$block), "blt $crS, $block", BrB>; From sabre at nondot.org Fri Nov 17 17:53:43 2006 From: sabre at nondot.org (Chris Lattner) Date: Fri, 17 Nov 2006 17:53:43 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCInstrInfo.td PPCInstrFormats.td Message-ID: <200611172353.kAHNrhRA015892@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCInstrInfo.td updated: 1.269 -> 1.270 PPCInstrFormats.td updated: 1.84 -> 1.85 --- Log message: add encoding for BCC, after finally wrestling strange ppc/tblgen endianness issues to the ground. --- Diffs of the changes: (+22 -3) PPCInstrFormats.td | 18 ++++++++++++++++++ PPCInstrInfo.td | 7 ++++--- 2 files changed, 22 insertions(+), 3 deletions(-) Index: llvm/lib/Target/PowerPC/PPCInstrInfo.td diff -u llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.269 llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.270 --- llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.269 Fri Nov 17 16:37:34 2006 +++ llvm/lib/Target/PowerPC/PPCInstrInfo.td Fri Nov 17 17:53:28 2006 @@ -361,10 +361,11 @@ // BCC represents an arbitrary conditional branch on a predicate. // FIXME: should be able to write a pattern for PPCcondbranch, but can't use // a two-value operand where a dag node expects two operands. :( - def BCC : Pseudo<(ops pred:$cond, target:$dst), - "b${cond:cc} ${cond:reg}, $dst", - [/*(PPCcondbranch CRRC:$crS, imm:$opc, bb:$dst)*/]>; + def BCC : CBForm<16, 0, 0, (ops pred:$cond, target:$dst), + "b${cond:cc} ${cond:reg}, $dst" + /*[(PPCcondbranch CRRC:$crS, imm:$opc, bb:$dst)]*/>; +// REMOVE BForm when these go away. def BLT : BForm<16, 0, 0, 12, 0, (ops CRRC:$crS, target:$block), "blt $crS, $block", BrB>; def BLE : BForm<16, 0, 0, 4, 1, (ops CRRC:$crS, target:$block), Index: llvm/lib/Target/PowerPC/PPCInstrFormats.td diff -u llvm/lib/Target/PowerPC/PPCInstrFormats.td:1.84 llvm/lib/Target/PowerPC/PPCInstrFormats.td:1.85 --- llvm/lib/Target/PowerPC/PPCInstrFormats.td:1.84 Wed Nov 15 17:24:18 2006 +++ llvm/lib/Target/PowerPC/PPCInstrFormats.td Fri Nov 17 17:53:28 2006 @@ -74,6 +74,24 @@ let Inst{31} = lk; } +class CBForm opcode, bit aa, bit lk, dag OL, + string asmstr> : I { + bits<7> BIBO; // 2 bits of BI and 5 bits of BO. + bits<3> CR; + bits<14> BD; + + bits<5> BI; + let BI{0-1} = BIBO{5-6}; + let BI{2-4} = CR{0-2}; + + let Inst{6-10} = BIBO{4-0}; + let Inst{11-15} = BI; + let Inst{16-29} = BD; + let Inst{30} = aa; + let Inst{31} = lk; +} + + // 1.7.4 D-Form class DForm_base opcode, dag OL, string asmstr, InstrItinClass itin, list pattern> From sabre at nondot.org Fri Nov 17 18:32:17 2006 From: sabre at nondot.org (Chris Lattner) Date: Fri, 17 Nov 2006 18:32:17 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCBranchSelector.cpp PPCInstrFormats.td PPCInstrInfo.td README.txt Message-ID: <200611180032.kAI0WHTt016541@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCBranchSelector.cpp updated: 1.37 -> 1.38 PPCInstrFormats.td updated: 1.85 -> 1.86 PPCInstrInfo.td updated: 1.270 -> 1.271 README.txt updated: 1.105 -> 1.106 --- Log message: Rewrite the branch selector to be correct in the face of large functions. The algorithm it used before wasn't 100% correct, we now use an iterative expansion model. This fixes assembler errors when compiling 403.gcc with tail merging enabled. Change the way the branch selector works overall: Now, the isel generates PPC::BCC instructions (as it used to) directly, and these BCC instructions are emitted to the output or jitted directly if branches don't need expansion. Only if branches need expansion are instructions rewritten and created. This should make branch select faster, and eliminates the Bxx instructions from the .td file. --- Diffs of the changes: (+108 -128) PPCBranchSelector.cpp | 189 +++++++++++++++++++++++++++----------------------- PPCInstrFormats.td | 18 ---- PPCInstrInfo.td | 24 ------ README.txt | 5 - 4 files changed, 108 insertions(+), 128 deletions(-) Index: llvm/lib/Target/PowerPC/PPCBranchSelector.cpp diff -u llvm/lib/Target/PowerPC/PPCBranchSelector.cpp:1.37 llvm/lib/Target/PowerPC/PPCBranchSelector.cpp:1.38 --- llvm/lib/Target/PowerPC/PPCBranchSelector.cpp:1.37 Fri Nov 17 16:37:34 2006 +++ llvm/lib/Target/PowerPC/PPCBranchSelector.cpp Fri Nov 17 18:32:03 2006 @@ -24,6 +24,7 @@ #include "llvm/Target/TargetAsmInfo.h" #include "llvm/ADT/Statistic.h" #include "llvm/Support/Compiler.h" +#include "llvm/Support/MathExtras.h" using namespace llvm; static Statistic<> NumExpanded("ppc-branch-select", @@ -31,13 +32,13 @@ namespace { struct VISIBILITY_HIDDEN PPCBSel : public MachineFunctionPass { - /// OffsetMap - Mapping between BB # and byte offset from start of function. - std::vector OffsetMap; + /// BlockSizes - The sizes of the basic blocks in the function. + std::vector BlockSizes; virtual bool runOnMachineFunction(MachineFunction &Fn); virtual const char *getPassName() const { - return "PowerPC Branch Selection"; + return "PowerPC Branch Selector"; } }; } @@ -54,11 +55,6 @@ /// static unsigned getNumBytesForInstruction(MachineInstr *MI) { switch (MI->getOpcode()) { - case PPC::BCC: - // while this will be 4 most of the time, if we emit 8 it is just a - // minor pessimization that saves us from having to worry about - // keeping the offsets up to date later when we emit long branch glue. - return 8; case PPC::IMPLICIT_DEF_GPRC: // no asm emitted case PPC::IMPLICIT_DEF_G8RC: // no asm emitted case PPC::IMPLICIT_DEF_F4: // no asm emitted @@ -77,98 +73,119 @@ bool PPCBSel::runOnMachineFunction(MachineFunction &Fn) { - // Running total of instructions encountered since beginning of function - unsigned ByteCount = 0; - - OffsetMap.resize(Fn.getNumBlockIDs()); - - // For each MBB, add its offset to the offset map, and count up its - // instructions + // Give the blocks of the function a dense, in-order, numbering. + Fn.RenumberBlocks(); + BlockSizes.resize(Fn.getNumBlockIDs()); + + // Measure each MBB and compute a size for the entire function. + unsigned FuncSize = 0; for (MachineFunction::iterator MFI = Fn.begin(), E = Fn.end(); MFI != E; ++MFI) { MachineBasicBlock *MBB = MFI; - OffsetMap[MBB->getNumber()] = ByteCount; - + + unsigned BlockSize = 0; for (MachineBasicBlock::iterator MBBI = MBB->begin(), EE = MBB->end(); MBBI != EE; ++MBBI) - ByteCount += getNumBytesForInstruction(MBBI); + BlockSize += getNumBytesForInstruction(MBBI); + + BlockSizes[MBB->getNumber()] = BlockSize; + FuncSize += BlockSize; } - // We're about to run over the MBB's again, so reset the ByteCount - ByteCount = 0; + // If the entire function is smaller than the displacement of a branch field, + // we know we don't need to shrink any branches in this function. This is a + // common case. + if (FuncSize < (1 << 15)) { + BlockSizes.clear(); + return false; + } - // For each MBB, find the conditional branch pseudo instructions, and - // calculate the difference between the target MBB and the current ICount - // to decide whether or not to emit a short or long branch. - // - // short branch: - // bCC .L_TARGET_MBB + // For each conditional branch, if the offset to its destination is larger + // than the offset field allows, transform it into a long branch sequence + // like this: + // short branch: + // bCC MBB + // long branch: + // b!CC $PC+8 + // b MBB // - // long branch: - // bInverseCC $PC+8 - // b .L_TARGET_MBB - for (MachineFunction::iterator MFI = Fn.begin(), E = Fn.end(); MFI != E; - ++MFI) { - MachineBasicBlock *MBB = MFI; - - for (MachineBasicBlock::iterator MBBI = MBB->begin(), EE = MBB->end(); - MBBI != EE; ++MBBI) { - // We may end up deleting the MachineInstr that MBBI points to, so - // remember its opcode now so we can refer to it after calling erase() - unsigned ByteSize = getNumBytesForInstruction(MBBI); - if (MBBI->getOpcode() != PPC::BCC) { - ByteCount += ByteSize; - continue; - } - - // condbranch operands: - // 0. CR register - // 1. PPC branch opcode - // 2. Target MBB - MachineBasicBlock *DestMBB = MBBI->getOperand(2).getMachineBasicBlock(); - PPC::Predicate Pred = (PPC::Predicate)MBBI->getOperand(0).getImm(); - unsigned CRReg = MBBI->getOperand(1).getReg(); - int Displacement = OffsetMap[DestMBB->getNumber()] - ByteCount; - - bool ShortBranchOk = Displacement >= -32768 && Displacement <= 32767; - - // Branch on opposite condition if a short branch isn't ok. - if (!ShortBranchOk) - Pred = PPC::InvertPredicate(Pred); - - unsigned Opcode; - switch (Pred) { - default: assert(0 && "Unknown cond branch predicate!"); - case PPC::PRED_LT: Opcode = PPC::BLT; break; - case PPC::PRED_LE: Opcode = PPC::BLE; break; - case PPC::PRED_EQ: Opcode = PPC::BEQ; break; - case PPC::PRED_GE: Opcode = PPC::BGE; break; - case PPC::PRED_GT: Opcode = PPC::BGT; break; - case PPC::PRED_NE: Opcode = PPC::BNE; break; - case PPC::PRED_UN: Opcode = PPC::BUN; break; - case PPC::PRED_NU: Opcode = PPC::BNU; break; - } - - MachineBasicBlock::iterator MBBJ; - if (ShortBranchOk) { - MBBJ = BuildMI(*MBB, MBBI, Opcode, 2).addReg(CRReg).addMBB(DestMBB); - } else { - // Long branch, skip next branch instruction (i.e. $PC+8). + bool MadeChange = true; + bool EverMadeChange = false; + while (MadeChange) { + // Iteratively expand branches until we reach a fixed point. + MadeChange = false; + + for (MachineFunction::iterator MFI = Fn.begin(), E = Fn.end(); MFI != E; + ++MFI) { + MachineBasicBlock &MBB = *MFI; + unsigned MBBStartOffset = 0; + for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end(); + I != E; ++I) { + if (I->getOpcode() != PPC::BCC || I->getOperand(2).isImm()) { + MBBStartOffset += getNumBytesForInstruction(I); + continue; + } + + // Determine the offset from the current branch to the destination + // block. + MachineBasicBlock *Dest = I->getOperand(2).getMachineBasicBlock(); + + int BranchSize; + if (Dest->getNumber() <= MBB.getNumber()) { + // If this is a backwards branch, the delta is the offset from the + // start of this block to this branch, plus the sizes of all blocks + // from this block to the dest. + BranchSize = MBBStartOffset; + + for (unsigned i = Dest->getNumber(), e = MBB.getNumber(); i != e; ++i) + BranchSize += BlockSizes[i]; + } else { + // Otherwise, add the size of the blocks between this block and the + // dest to the number of bytes left in this block. + BranchSize = -MBBStartOffset; + + for (unsigned i = MBB.getNumber(), e = Dest->getNumber(); i != e; ++i) + BranchSize += BlockSizes[i]; + } + + // If this branch is in range, ignore it. + if (isInt16(BranchSize)) { + MBBStartOffset += 4; + continue; + } + + // Otherwise, we have to expand it to a long branch. + // The BCC operands are: + // 0. PPC branch predicate + // 1. CR register + // 2. Target MBB + PPC::Predicate Pred = (PPC::Predicate)I->getOperand(0).getImm(); + unsigned CRReg = I->getOperand(1).getReg(); + + MachineInstr *OldBranch = I; + + // Jump over the uncond branch inst (i.e. $PC+8) on opposite condition. + BuildMI(MBB, I, PPC::BCC, 3) + .addImm(PPC::InvertPredicate(Pred)).addReg(CRReg).addImm(2); + + // Uncond branch to the real destination. + I = BuildMI(MBB, I, PPC::B, 1).addMBB(Dest); + + // Remove the old branch from the function. + OldBranch->eraseFromParent(); + + // Remember that this instruction is 8-bytes, increase the size of the + // block by 4, remember to iterate. + BlockSizes[MBB.getNumber()] += 4; + MBBStartOffset += 8; ++NumExpanded; - BuildMI(*MBB, MBBI, Opcode, 2).addReg(CRReg).addImm(2); - MBBJ = BuildMI(*MBB, MBBI, PPC::B, 1).addMBB(DestMBB); + MadeChange = true; } - - // Erase the psuedo BCC instruction, and then back up the - // iterator so that when the for loop increments it, we end up in - // the correct place rather than iterating off the end. - MBB->erase(MBBI); - MBBI = MBBJ; - ByteCount += ByteSize; } + EverMadeChange |= MadeChange; } - OffsetMap.clear(); + BlockSizes.clear(); return true; } Index: llvm/lib/Target/PowerPC/PPCInstrFormats.td diff -u llvm/lib/Target/PowerPC/PPCInstrFormats.td:1.85 llvm/lib/Target/PowerPC/PPCInstrFormats.td:1.86 --- llvm/lib/Target/PowerPC/PPCInstrFormats.td:1.85 Fri Nov 17 17:53:28 2006 +++ llvm/lib/Target/PowerPC/PPCInstrFormats.td Fri Nov 17 18:32:03 2006 @@ -60,22 +60,8 @@ } // 1.7.2 B-Form -class BForm opcode, bit aa, bit lk, bits<5> bo, bits<2> bicode, dag OL, - string asmstr, InstrItinClass itin> - : I { - bits<3> CR; - bits<14> BD; - - let Inst{6-10} = bo; - let Inst{11-13} = CR; - let Inst{14-15} = bicode; - let Inst{16-29} = BD; - let Inst{30} = aa; - let Inst{31} = lk; -} - -class CBForm opcode, bit aa, bit lk, dag OL, - string asmstr> : I { +class BForm opcode, bit aa, bit lk, dag OL, string asmstr> + : I { bits<7> BIBO; // 2 bits of BI and 5 bits of BO. bits<3> CR; bits<14> BD; Index: llvm/lib/Target/PowerPC/PPCInstrInfo.td diff -u llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.270 llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.271 --- llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.270 Fri Nov 17 17:53:28 2006 +++ llvm/lib/Target/PowerPC/PPCInstrInfo.td Fri Nov 17 18:32:03 2006 @@ -361,27 +361,9 @@ // BCC represents an arbitrary conditional branch on a predicate. // FIXME: should be able to write a pattern for PPCcondbranch, but can't use // a two-value operand where a dag node expects two operands. :( - def BCC : CBForm<16, 0, 0, (ops pred:$cond, target:$dst), - "b${cond:cc} ${cond:reg}, $dst" - /*[(PPCcondbranch CRRC:$crS, imm:$opc, bb:$dst)]*/>; - -// REMOVE BForm when these go away. - def BLT : BForm<16, 0, 0, 12, 0, (ops CRRC:$crS, target:$block), - "blt $crS, $block", BrB>; - def BLE : BForm<16, 0, 0, 4, 1, (ops CRRC:$crS, target:$block), - "ble $crS, $block", BrB>; - def BEQ : BForm<16, 0, 0, 12, 2, (ops CRRC:$crS, target:$block), - "beq $crS, $block", BrB>; - def BGE : BForm<16, 0, 0, 4, 0, (ops CRRC:$crS, target:$block), - "bge $crS, $block", BrB>; - def BGT : BForm<16, 0, 0, 12, 1, (ops CRRC:$crS, target:$block), - "bgt $crS, $block", BrB>; - def BNE : BForm<16, 0, 0, 4, 2, (ops CRRC:$crS, target:$block), - "bne $crS, $block", BrB>; - def BUN : BForm<16, 0, 0, 12, 3, (ops CRRC:$crS, target:$block), - "bun $crS, $block", BrB>; - def BNU : BForm<16, 0, 0, 4, 3, (ops CRRC:$crS, target:$block), - "bnu $crS, $block", BrB>; + def BCC : BForm<16, 0, 0, (ops pred:$cond, target:$dst), + "b${cond:cc} ${cond:reg}, $dst" + /*[(PPCcondbranch CRRC:$crS, imm:$opc, bb:$dst)]*/>; } let isCall = 1, noResults = 1, PPC970_Unit = 7, Index: llvm/lib/Target/PowerPC/README.txt diff -u llvm/lib/Target/PowerPC/README.txt:1.105 llvm/lib/Target/PowerPC/README.txt:1.106 --- llvm/lib/Target/PowerPC/README.txt:1.105 Thu Nov 9 19:33:53 2006 +++ llvm/lib/Target/PowerPC/README.txt Fri Nov 17 18:32:03 2006 @@ -88,11 +88,6 @@ ===-------------------------------------------------------------------------=== -Teach the .td file to pattern match PPC::BR_COND to appropriate bc variant, so -we don't have to always run the branch selector for small functions. - -===-------------------------------------------------------------------------=== - Lump the constant pool for each function into ONE pic object, and reference pieces of it as offsets from the start. For functions like this (contrived to have lots of constants obviously): From sabre at nondot.org Fri Nov 17 19:24:10 2006 From: sabre at nondot.org (Chris Lattner) Date: Fri, 17 Nov 2006 19:24:10 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp Message-ID: <200611180124.kAI1OAVa017498@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCAsmPrinter.cpp updated: 1.209 -> 1.210 --- Log message: Pretty print 'rldicr r2, r2, 2, 61' as 'sldi r2, r2, 2'. --- Diffs of the changes: (+12 -0) PPCAsmPrinter.cpp | 12 ++++++++++++ 1 files changed, 12 insertions(+) Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.209 llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.210 --- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.209 Fri Nov 17 16:10:59 2006 +++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp Fri Nov 17 19:23:56 2006 @@ -438,6 +438,18 @@ O << "\n"; return; } + } else if (MI->getOpcode() == PPC::RLDICR) { + unsigned char SH = MI->getOperand(2).getImmedValue(); + unsigned char ME = MI->getOperand(3).getImmedValue(); + // rldicr RA, RS, SH, 63-SH == sldi RA, RS, SH + if (63-SH == ME) { + O << "sldi "; + printOperand(MI, 0); + O << ", "; + printOperand(MI, 1); + O << ", " << (unsigned int)SH << "\n"; + return; + } } if (printInstruction(MI)) From sabre at nondot.org Fri Nov 17 19:34:58 2006 From: sabre at nondot.org (Chris Lattner) Date: Fri, 17 Nov 2006 19:34:58 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCFrameInfo.h PPCTargetMachine.cpp Message-ID: <200611180134.kAI1Ywlb017793@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCFrameInfo.h updated: 1.10 -> 1.11 PPCTargetMachine.cpp updated: 1.107 -> 1.108 --- Log message: make sure to safe LR8 in the right stack slot for PPC64 --- Diffs of the changes: (+8 -3) PPCFrameInfo.h | 9 +++++++-- PPCTargetMachine.cpp | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) Index: llvm/lib/Target/PowerPC/PPCFrameInfo.h diff -u llvm/lib/Target/PowerPC/PPCFrameInfo.h:1.10 llvm/lib/Target/PowerPC/PPCFrameInfo.h:1.11 --- llvm/lib/Target/PowerPC/PPCFrameInfo.h:1.10 Thu Nov 16 16:43:37 2006 +++ llvm/lib/Target/PowerPC/PPCFrameInfo.h Fri Nov 17 19:34:43 2006 @@ -26,8 +26,13 @@ public: PPCFrameInfo(const TargetMachine &tm, bool LP64) : TargetFrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0), TM(tm) { - LR[0].first = PPC::LR; - LR[0].second = LP64 ? 16 : 8; + if (LP64) { + LR[0].first = PPC::LR8; + LR[0].second = 16; + } else { + LR[0].first = PPC::LR; + LR[0].second = 8; + } } const std::pair * Index: llvm/lib/Target/PowerPC/PPCTargetMachine.cpp diff -u llvm/lib/Target/PowerPC/PPCTargetMachine.cpp:1.107 llvm/lib/Target/PowerPC/PPCTargetMachine.cpp:1.108 --- llvm/lib/Target/PowerPC/PPCTargetMachine.cpp:1.107 Wed Sep 20 12:12:19 2006 +++ llvm/lib/Target/PowerPC/PPCTargetMachine.cpp Fri Nov 17 19:34:43 2006 @@ -83,7 +83,7 @@ bool is64Bit) : Subtarget(M, FS, is64Bit), DataLayout(Subtarget.getTargetDataString()), InstrInfo(*this), - FrameInfo(*this, false), JITInfo(*this, is64Bit), TLInfo(*this), + FrameInfo(*this, is64Bit), JITInfo(*this, is64Bit), TLInfo(*this), InstrItins(Subtarget.getInstrItineraryData()) { if (getRelocationModel() == Reloc::Default) From sabre at nondot.org Fri Nov 17 19:57:33 2006 From: sabre at nondot.org (Chris Lattner) Date: Fri, 17 Nov 2006 19:57:33 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCISelLowering.cpp Message-ID: <200611180157.kAI1vXAI018176@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCISelLowering.cpp updated: 1.231 -> 1.232 --- Log message: on ppc64, float arguments take 8-byte stack slots not 4-byte stack slots. Also, valist should create a pointer RC reg class value, not a GPRC value. --- Diffs of the changes: (+8 -3) PPCISelLowering.cpp | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp diff -u llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.231 llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.232 --- llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.231 Fri Nov 17 16:37:34 2006 +++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp Fri Nov 17 19:57:19 2006 @@ -1155,13 +1155,13 @@ case MVT::f32: case MVT::f64: // All FP arguments reserve stack space. - ArgOffset += ObjSize; + ArgOffset += isPPC64 ? 8 : ObjSize; // Every 4 bytes of argument space consumes one of the GPRs available for // argument passing. if (GPR_idx != Num_GPR_Regs) { ++GPR_idx; - if (ObjSize == 8 && GPR_idx != Num_GPR_Regs) + if (ObjSize == 8 && GPR_idx != Num_GPR_Regs && !isPPC64) ++GPR_idx; } if (FPR_idx != Num_FPR_Regs) { @@ -1226,7 +1226,12 @@ // result of va_next. SmallVector MemOps; for (; GPR_idx != Num_GPR_Regs; ++GPR_idx) { - unsigned VReg = RegMap->createVirtualRegister(&PPC::GPRCRegClass); + unsigned VReg; + if (isPPC64) + VReg = RegMap->createVirtualRegister(&PPC::G8RCRegClass); + else + VReg = RegMap->createVirtualRegister(&PPC::GPRCRegClass); + MF.addLiveIn(GPR[GPR_idx], VReg); SDOperand Val = DAG.getCopyFromReg(Root, VReg, PtrVT); SDOperand Store = DAG.getStore(Val.getValue(1), Val, FIN, NULL, 0); From reid at x10sys.com Fri Nov 17 22:37:34 2006 From: reid at x10sys.com (Reid Spencer) Date: Fri, 17 Nov 2006 22:37:34 -0600 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.cpp Message-ID: <200611180437.kAI4bYqL020405@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: Reader.cpp updated: 1.205 -> 1.206 --- Log message: Have ConstantExprs upgrade opcodes the same way as instructions. --- Diffs of the changes: (+11 -1) Reader.cpp | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletion(-) Index: llvm/lib/Bytecode/Reader/Reader.cpp diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.205 llvm/lib/Bytecode/Reader/Reader.cpp:1.206 --- llvm/lib/Bytecode/Reader/Reader.cpp:1.205 Mon Nov 13 22:47:22 2006 +++ llvm/lib/Bytecode/Reader/Reader.cpp Fri Nov 17 22:37:19 2006 @@ -1506,9 +1506,19 @@ Opcode = 10; // Div else if (Opcode >=13 && Opcode <= 15) // URem through FRem Opcode = 11; // Rem - else if (Opcode > 15) // Everything above FRem + else if (Opcode >= 16 && Opcode <= 35) // And through Shr // Adjust for new instruction codes Opcode -= 4; + else if (Opcode >= 36 && Opcode <= 42) // Everything after Select + // In vers 6 bytecode we eliminated the placeholders for the obsolete + // VAARG and VANEXT instructions. Consequently those two slots were + // filled starting with Select (36) which was 34. So now we only need + // to subtract two. This circumvents hitting opcodes 32 and 33 + Opcode -= 2; + else { // Opcode < 10 or > 42 + // No upgrade necessary. + return 0; + } } switch (Opcode) { From reid at x10sys.com Fri Nov 17 23:52:32 2006 From: reid at x10sys.com (Reid Spencer) Date: Fri, 17 Nov 2006 23:52:32 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Analysis/BasicAA/modref.ll Message-ID: <200611180552.kAI5qW23021573@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/Analysis/BasicAA: modref.ll added (r1.1) --- Log message: Add a simple test to make sure getModRefInfo is 1/2 way sane. --- Diffs of the changes: (+12 -0) modref.ll | 12 ++++++++++++ 1 files changed, 12 insertions(+) Index: llvm/test/Regression/Analysis/BasicAA/modref.ll diff -c /dev/null llvm/test/Regression/Analysis/BasicAA/modref.ll:1.1 *** /dev/null Fri Nov 17 23:52:28 2006 --- llvm/test/Regression/Analysis/BasicAA/modref.ll Fri Nov 17 23:52:18 2006 *************** *** 0 **** --- 1,12 ---- + ; RUN: llvm-as < %s | opt -print-all-alias-modref-info -aa-eval -disable-output 2>&1 | not grep NoModRef + + int %callee() { + %X = alloca struct { int, int } + %Y = int* getelementptr struct { int, int }*, uint 1 + %Z = int load struct { int, int }* + ret %Z + } + + int %caller() { + %X = int callee(); + } From reid at x10sys.com Sat Nov 18 00:02:11 2006 From: reid at x10sys.com (Reid Spencer) Date: Sat, 18 Nov 2006 00:02:11 -0600 Subject: [llvm-commits] CVS: llvm-test/SingleSource/UnitTests/SignlessTypes/.cvsignore Message-ID: <200611180602.kAI62BK0021776@zion.cs.uiuc.edu> Changes in directory llvm-test/SingleSource/UnitTests/SignlessTypes: .cvsignore added (r1.1) --- Log message: Ignore the Output directory --- Diffs of the changes: (+1 -0) .cvsignore | 1 + 1 files changed, 1 insertion(+) Index: llvm-test/SingleSource/UnitTests/SignlessTypes/.cvsignore diff -c /dev/null llvm-test/SingleSource/UnitTests/SignlessTypes/.cvsignore:1.1 *** /dev/null Sat Nov 18 00:02:07 2006 --- llvm-test/SingleSource/UnitTests/SignlessTypes/.cvsignore Sat Nov 18 00:01:57 2006 *************** *** 0 **** --- 1 ---- + Output From reid at x10sys.com Sat Nov 18 00:02:13 2006 From: reid at x10sys.com (Reid Spencer) Date: Sat, 18 Nov 2006 00:02:13 -0600 Subject: [llvm-commits] CVS: llvm-test/SingleSource/UnitTests/Vector/SSE/.cvsignore Message-ID: <200611180602.kAI62Du1021781@zion.cs.uiuc.edu> Changes in directory llvm-test/SingleSource/UnitTests/Vector/SSE: .cvsignore added (r1.1) --- Log message: Ignore the Output directory --- Diffs of the changes: (+1 -0) .cvsignore | 1 + 1 files changed, 1 insertion(+) Index: llvm-test/SingleSource/UnitTests/Vector/SSE/.cvsignore diff -c /dev/null llvm-test/SingleSource/UnitTests/Vector/SSE/.cvsignore:1.1 *** /dev/null Sat Nov 18 00:02:07 2006 --- llvm-test/SingleSource/UnitTests/Vector/SSE/.cvsignore Sat Nov 18 00:01:57 2006 *************** *** 0 **** --- 1 ---- + Output From reid at x10sys.com Sat Nov 18 00:08:36 2006 From: reid at x10sys.com (Reid Spencer) Date: Sat, 18 Nov 2006 00:08:36 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Analysis/BasicAA/modref.ll Message-ID: <200611180608.kAI68aUX021875@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/Analysis/BasicAA: modref.ll updated: 1.1 -> 1.2 --- Log message: Fail even if opt doesn't print anything. --- Diffs of the changes: (+3 -0) modref.ll | 3 +++ 1 files changed, 3 insertions(+) Index: llvm/test/Regression/Analysis/BasicAA/modref.ll diff -u llvm/test/Regression/Analysis/BasicAA/modref.ll:1.1 llvm/test/Regression/Analysis/BasicAA/modref.ll:1.2 --- llvm/test/Regression/Analysis/BasicAA/modref.ll:1.1 Fri Nov 17 23:52:18 2006 +++ llvm/test/Regression/Analysis/BasicAA/modref.ll Sat Nov 18 00:08:21 2006 @@ -1,3 +1,6 @@ +; A very rudimentary test on AliasAnalysis::getModRefInfo. +; RUN: llvm-as < %s | opt -print-all-alias-modref-info -aa-eval -disable-output +&& ; RUN: llvm-as < %s | opt -print-all-alias-modref-info -aa-eval -disable-output 2>&1 | not grep NoModRef int %callee() { From sabre at nondot.org Sat Nov 18 01:51:29 2006 From: sabre at nondot.org (Chris Lattner) Date: Sat, 18 Nov 2006 01:51:29 -0600 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200611180751.kAI7pTDw023698@zion.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.363 -> 1.364 --- Log message: first draft of 1.9 release notes --- Diffs of the changes: (+252 -223) ReleaseNotes.html | 475 ++++++++++++++++++++++++++++-------------------------- 1 files changed, 252 insertions(+), 223 deletions(-) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.363 llvm/docs/ReleaseNotes.html:1.364 --- llvm/docs/ReleaseNotes.html:1.363 Wed Nov 1 10:15:04 2006 +++ llvm/docs/ReleaseNotes.html Sat Nov 18 01:51:14 2006 @@ -62,7 +62,8 @@

    This is the tenth public release of the LLVM Compiler Infrastructure. This -release incorporates a large number of enhancements and new features. +release incorporates a large number of enhancements, new features, and bug +fixes. We recommend that all users of previous LLVM versions upgrade.

    @@ -73,41 +74,106 @@ - +
    -

    The llvm-gcc4 C front-end now generates debugging info for C and C++ for -X86/ELF platforms (Linux). This extends the PPC/Darwin and X86/Darwin debugging -support available in release 18.8 DWARF is a standard debugging format used on -many platforms.

    +

    LLVM 1.9 now fully supports the x86-64 instruction set on Mac OS/X, and +supports it on Linux (and other operating systems) when compiling in -static +mode. LLVM includes JIT support for X86-64, and supports both Intel EMT-64T +and AMD-64 architectures. The X86-64 instruction set permits addressing a +64-bit addressing space and provides the compiler with twice the +number of integer registers to use.

    - +
    -

    As a step towards making LLVM's integer types signless, several new -instructions have been added to LLVM. The DIV instruction has become UDIV, SDIV, -and FDIV. The REM instruction has become UREM, SREM and FREM. The SHR -instruction has become ASHR and LSHR. See the Language - Reference for details on these new instructions.

    +

    LLVM now includes liblto which can +be used to integrate LLVM Link-Time Optimization support into a native linker. +This allows LLVM .bc to transparently participate with linking an application, +even when some .o files are in LLVM form and some are not.

    - +
    -

    Describe feature C here.

    +

    llvm-gcc4 now supports generating debugging info for Linux, Cygwin and MinGW. +This extends the PPC/Darwin and X86/Darwin debugging support available in the +1.8 release. DWARF is a standard debugging format used on many platforms.

    - +
    -

    Describe feature D here.

    +

    The mid-level optimizer is now faster and produces better code in many cases. + Significant changes include:

    + +
      +
    • LLVM includes a new 'predicate simplifier' pass, which + currently performs dominator tree-based optimizations.
    • +
    • The complete loop unroll pass now supports unrolling of + multiple basic block loops.
    • +
    • The 'globalopt' pass can now perform the scalar replacement of + aggregates transformation on some heap allocations.
    • +
    • The globalsmodref-aa alias analysis can now track 'indirect pointer + globals' more accurately.
    • +
    • The instruction combiner can now perform element propagation +analysis of vector expressions, eliminating computation of vector elements +that are not used.
    • +
    +
    - + +
    -

    Describe feature E here.

    +

    +The LLVM Target-Independent code generator now supports more target features and +optimizes many cases more aggressively. New features include: +

    + +
      +
    • LLVM now includes a late branch folding pass which optimizes code + layout, performs several branch optzns, and deletes unreachable code.
    • +
    • The code generator now support targets that have pre/post-increment + addressing modes.
    • +
    • LLVM now supports dynamically-loadable register allocators and + schedulers.
    • +
    • LLVM 1.9 includes several improvements to inline asm support, + including support for new constraints and modifiers.
    • +
    • The register coalescer is now more aggressive than before, + allowing it to eliminate more copies.
    • +
    + +

    In addition, the LLVM target description format has itself been extended in + several ways:

    + +
      +
    • tblgen now allows definition of 'multiclasses' which can be + used to factor instruction patterns more aggressively in .td files.
    • +
    • LLVM has a new TargetAsmInfo class which captures a variety of + information about the target assembly language format.
    • +
    • .td files now support "${:foo}" syntax for encoding + subtarget-specific assembler syntax into instruction descriptions.
    • +
    + +

    Further, several significant target-specific enhancements are included in +LLVM 1.9:

    + +
      +
    • The LLVM ARM backend now supports more instructions + and the use of a frame pointer. It is now possible to build + libgcc and a simple cross compiler, but it is not considered "complete" yet. +
    • +
    • LLVM supports the Win32 dllimport/dllexport linkage and + stdcall/fastcall calling conventions.
    • +
    +
    @@ -121,38 +187,41 @@

    More specific changes include:

      -
    • LLVM 1.8 includes an initial ARM backend. This backend is in early - development stages.
    • -
    • LLVM 1.8 now includes significantly better support for mingw and - cygwin.
    • -
    • The llvm-config tool is - now built by default and has several new features.
    • -
    • The X86 and PPC backends now use the correct platform ABI for passing - vectors as arguments to functions.
    • -
    • The X86 backend now includes support for the Microsoft ML assembler - ("MASM").
    • -
    • The PowerPC backend now pattern matches the 'rlwimi' instruction more - aggressively.
    • -
    • Most of LLVM is now built with "-pedantic", ensuring better portability - to more C++ Compilers.
    • -
    • The PowerPC backend now includes initial 64-bit support. The JIT is not - complete, and the static compiler has a couple of known bugs, but support - is mostly in place. LLVM 1.9 will include completed PPC-64 support.
    • - +
    • The llvm-test framework now supports SPEC2006.
    • +
    • LLVM now includes a FAQ about the +getelementptr instruction.
    • +
    • Bugpoint now supports a new "-find-bugs" mode. This mode makes + bugpoint permute pass sequences to try to expose bugs due to pass + sequencing.
    • +
    • The JIT now supports lazily streaming code from multiple modules at a + time, implicitly linking the code as it goes.
    + +

    Several significant API changes have been made. If you are maintaining +out-of-tree code, please be aware that:

    +
      -
    • The LLVM "SparcV9" backend (deprecated in LLVM 1.7) has been removed in -LLVM 1.8. The LLVM "Sparc" backend replaces it.
    • -
    • The --version option now prints more useful information, including the - build configuration for the tool.
    • +
    • The ConstantSInt and ConstantUInt classes have been merged into the + ConstantInt class.
    • +
    • As a step towards making LLVM's integer types signless, several new +instructions have been added to LLVM. The Div instruction is now +UDiv, SDiv, and FDiv. The Rem instruction +is now URem, SRem and FRem. See the +Language Reference for details on these new +instructions.

      +
    • ConstantBool::True and ConstantBool::False have been + renamed to ConstantBool::getTrue() and + ConstantBool::getFalse().

    • +
    • The 'analyze' tool has been merged into the 'opt' tool.
    • +
    @@ -174,7 +243,8 @@
  • Sun UltraSPARC workstations running Solaris 8.
  • Intel and AMD machines running on Win32 with the Cygwin libraries (limited support is available for native builds with Visual C++).
  • -
  • PowerPC and X86-based Mac OS X systems, running 10.2 and above.
  • +
  • PowerPC and X86-based Mac OS X systems, running 10.2 and above in 32-bit and + 64-bit modes.
  • Alpha-based machines running Debian GNU/Linux.
  • Itanium-based machines running Linux and HP-UX.
@@ -220,6 +290,7 @@
  • The -cee pass is known to be buggy, and may be removed in in a future release.
  • The IA64 code generator is experimental.
  • +
  • The ARM code generator is experimental.
  • The Alpha JIT is experimental.
  • "-filetype=asm" (the default) is the only supported value for the -filetype llc option.
  • @@ -229,16 +300,138 @@
    +
    + + + +
    + + + +
    + + + + +
    + +
      +
    • The SPARC backend only supports the 32-bit SPARC ABI (-m32), it does not + support the 64-bit SPARC ABI (-m64).
    • +
    + +
    + + + + +
    + +
      + +
    • The C back-end produces code that violates the ANSI C Type-Based Alias +Analysis rules. As such, special options may be necessary to compile the code +(for example, GCC requires the -fno-strict-aliasing option). This +problem probably cannot be fixed.
    • + +
    • Zero arg vararg functions are not +supported. This should not affect LLVM produced by the C or C++ +frontends.
    • + +
    • The C backend does not correctly implement the llvm.stacksave or +llvm.stackrestore +intrinsics. This means that some code compiled by it can run out of stack +space if they depend on these (e.g. C99 varargs).
    • + +
    • The C backend does not support inline + assembly code.
    • +
    + +
    + + + + +
    + +
      + +
    • On 21164s, some rare FP arithmetic sequences which may trap do not have the +appropriate nops inserted to ensure restartability.
    • + +
    +
    + + + + +
    + +
      + +
    • C++ programs are likely to fail on IA64, as calls to setjmp are +made where the argument is not 16-byte aligned, as required on IA64. (Strictly +speaking this is not a bug in the IA64 back-end; it will also be encountered +when building C++ programs using the C back-end.)
    • + +
    • The C++ front-end does not use IA64 +ABI compliant layout of v-tables. In particular, it just stores function +pointers instead of function descriptors in the vtable. This bug prevents +mixing C++ code compiled with LLVM with C++ objects compiled by other C++ +compilers.
    • + +
    • There are a few ABI violations which will lead to problems when mixing LLVM +output with code built with other compilers, particularly for floating-point +programs.
    • + +
    • Defining vararg functions is not supported (but calling them is ok).
    • + +
    + +
    + + + + +
    + +
      +
    • The ARM backend is currently in early development stages, it is not +ready for production use.
    • +
    + +
    @@ -264,29 +457,15 @@

    -llvm-gcc3 has many significant problems that are fixed by llvm-gcc4. -Two major ones include:

    - -
      -
    • With llvm-gcc3, - C99 variable sized arrays do not release stack memory when they go out of - scope. Thus, the following program may run out of stack space: -
      -    for (i = 0; i != 1000000; ++i) {
      -      int X[n];
      -      foo(X);
      -    }
      -
    • - -
    • With llvm-gcc3, Initialization of global union variables can only be done with the largest union member.
    • - -

    llvm-gcc4 is far more stable and produces better code than llvm-gcc3, but -does not currently support Link-Time-Optimization or C++ Exception Handling, +does not currently support Link-Time +Optimization or C++ Exception Handling, which llvm-gcc3 does.

    +

    llvm-gcc4 does not support the GCC indirect +goto extension, but llvm-gcc3 does.

    +
    @@ -302,28 +481,12 @@ support for floating point data types of any size other than 32 and 64 bits. -
  • The following Unix system functionality has not been tested and may not -work: -
      -
    1. sigsetjmp, siglongjmp - These are not turned into the - appropriate invoke/unwind instructions. Note that - setjmp and longjmp are compiled correctly. -
    2. getcontext, setcontext, makecontext - - These functions have not been tested. -
  • -
  • Although many GCC extensions are supported, some are not. In particular, the following extensions are known to not be supported:
    1. Local Labels: Labels local to a block.
    2. Nested Functions: As in Algol and Pascal, lexical scoping of functions.
    3. Constructing Calls: Dispatching a call to another function.
    4. -
    5. Extended Asm: Assembler instructions with C expressions as operands.
    6. -
    7. Constraints: Constraints for asm operands.
    8. -
    9. Asm Labels: Specifying the assembler name to use for a C symbol.
    10. -
    11. Explicit Reg Vars: Defining variables residing in specified registers.
    12. -
    13. Vector Extensions: Using vector instructions through built-in functions.
    14. -
    15. Target Builtins: Built-in functions specific to particular targets.
    16. Thread-Local: Per-thread variables.
    17. Pragmas: Pragmas accepted by GCC.
    @@ -402,6 +565,12 @@
  • Empty Structures: Structures with no members.
  • Variadic Macros: Macros with a variable number of arguments.
  • Escaped Newlines: Slightly looser rules for escaped newlines.
  • +
  • Extended Asm: Assembler instructions with C expressions as operands.
  • +
  • Constraints: Constraints for asm operands.
  • +
  • Asm Labels: Specifying the assembler name to use for a C symbol.
  • +
  • Explicit Reg Vars: Defining variables residing in specified registers.
  • +
  • Vector Extensions: Using vector instructions through built-in functions.
  • +
  • Target Builtins: Built-in functions specific to particular targets.
  • Subscripting: Any array can be subscripted, even if not an lvalue.
  • Pointer Arith: Arithmetic on void-pointers and function pointers.
  • Initializers: Non-constant initializers.
  • @@ -446,26 +615,13 @@
    -
    Bugs
    - -
    - -
      -
    • The C++ front-end inherits all problems afflicting the C - front-end.
    • - -
    - -
    - -
    Notes
    -
      +
    • llvm-gcc4 does not support C++ exception handling at all yet.
    • Destructors for local objects are not always run when a longjmp is performed. In particular, destructors for objects in the longjmping @@ -480,7 +636,7 @@ representation issues. Because we use this API, code generated by the LLVM compilers should be binary compatible with machine code generated by other Itanium ABI C++ compilers (such as G++, the Intel and HP compilers, etc). - However, the exception handling mechanism used by LLVM is very + However, the exception handling mechanism used by llvm-gcc3 is very different from the model used in the Itanium ABI, so exceptions will not interact correctly.
    • @@ -488,134 +644,7 @@
    - - - -
    - -
      - -
    • The C back-end produces code that violates the ANSI C Type-Based Alias -Analysis rules. As such, special options may be necessary to compile the code -(for example, GCC requires the -fno-strict-aliasing option). This -problem probably cannot be fixed.
    • - -
    • Zero arg vararg functions are not -supported. This should not affect LLVM produced by the C or C++ -frontends.
    • - -
    • The C backend does not correctly implement the llvm.stacksave or -llvm.stackrestore -intrinsics. This means that some code compiled by it can run out of stack -space if they depend on these (e.g. C99 varargs).
    • - -
    - -
    - - - - -
    - -
      -
    • none yet.
    • -
    - -
    - - - - - - - - - -
    - -
      - -
    • On 21164s, some rare FP arithmetic sequences which may trap do not have the -appropriate nops inserted to ensure restartability.
    • - -
    - -
    - - - - -
    - -
      - -
    • C++ programs are likely to fail on IA64, as calls to setjmp are -made where the argument is not 16-byte aligned, as required on IA64. (Strictly -speaking this is not a bug in the IA64 back-end; it will also be encountered -when building C++ programs using the C back-end.)
    • - -
    • The C++ front-end does not use IA64 -ABI compliant layout of v-tables. In particular, it just stores function -pointers instead of function descriptors in the vtable. This bug prevents -mixing C++ code compiled with LLVM with C++ objects compiled by other C++ -compilers.
    • - -
    • There are a few ABI violations which will lead to problems when mixing LLVM -output with code built with other compilers, particularly for floating-point -programs.
    • - -
    • Defining vararg functions is not supported (but calling them is ok).
    • - -
    - -
    - - - - -
    - -
      -
    • The SPARC backend only supports the 32-bit SPARC ABI (-m32), it does not - support the 64-bit SPARC ABI (-m64).
    • -
    - -
    - - - - -
    -
      -
    • The ARM backend is currently in early development stages, it is not -ready for production use.
    • -
    - -
    @@ -650,7 +679,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2006/11/01 16:15:04 $ + Last modified: $Date: 2006/11/18 07:51:14 $ From sabre at nondot.org Sat Nov 18 01:52:24 2006 From: sabre at nondot.org (Chris Lattner) Date: Sat, 18 Nov 2006 01:52:24 -0600 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200611180752.kAI7qOl8023753@zion.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.364 -> 1.365 --- Log message: fix bug --- Diffs of the changes: (+2 -2) ReleaseNotes.html | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.364 llvm/docs/ReleaseNotes.html:1.365 --- llvm/docs/ReleaseNotes.html:1.364 Sat Nov 18 01:51:14 2006 +++ llvm/docs/ReleaseNotes.html Sat Nov 18 01:52:10 2006 @@ -307,7 +307,7 @@ @@ -679,7 +679,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2006/11/18 07:51:14 $ + Last modified: $Date: 2006/11/18 07:52:10 $ From asl at math.spbu.ru Sat Nov 18 02:05:03 2006 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Sat, 18 Nov 2006 02:05:03 -0600 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200611180805.kAI853p3024040@zion.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.365 -> 1.366 --- Log message: Movind newly-intorudced dll* linkage stuff & windows CC to "supported" list --- Diffs of the changes: (+12 -10) ReleaseNotes.html | 22 ++++++++++++---------- 1 files changed, 12 insertions(+), 10 deletions(-) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.365 llvm/docs/ReleaseNotes.html:1.366 --- llvm/docs/ReleaseNotes.html:1.365 Sat Nov 18 01:52:10 2006 +++ llvm/docs/ReleaseNotes.html Sat Nov 18 02:04:48 2006 @@ -507,29 +507,31 @@ Declaring that functions have no side effects or that they can never return.
    - Supported: format, format_arg, non_null, - noreturn, constructor, destructor, - unused, used, - deprecated, warn_unused_result, weak
    + Supported: constructor, destructor, + deprecated, fastcall, format, + format_arg, non_null, noreturn, + stdcall, unused, used, + warn_unused_result, weak
    Ignored: noinline, always_inline, pure, const, nothrow, malloc, no_instrument_function, cdecl
    Unsupported: section, alias, - visibility, regparm, stdcall, - fastcall, all other target specific attributes + visibility, regparm, all other target specific + attributes
  • Variable Attributes: Specifying attributes of variables.
    Supported: cleanup, common, nocommon, - deprecated, transparent_union, + deprecated, dllimport, + dllexport, transparent_union, unused, used, weak
    Unsupported: aligned, mode, packed, section, shared, tls_model, - vector_size, dllimport, - dllexport, all target specific attributes.
  • + vector_size, all target specific attributes. +
  • Type Attributes: Specifying attributes of types.
    Supported: transparent_union, unused, @@ -679,7 +681,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2006/11/18 07:52:10 $ + Last modified: $Date: 2006/11/18 08:04:48 $ From reid at x10sys.com Sat Nov 18 02:06:33 2006 From: reid at x10sys.com (Reid Spencer) Date: Sat, 18 Nov 2006 02:06:33 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Analysis/BasicAA/modref.ll Message-ID: <200611180806.kAI86XKA024192@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/Analysis/BasicAA: modref.ll updated: 1.2 -> 1.3 --- Log message: Fix bugs in this. What was I thinking??? :) --- Diffs of the changes: (+7 -7) modref.ll | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) Index: llvm/test/Regression/Analysis/BasicAA/modref.ll diff -u llvm/test/Regression/Analysis/BasicAA/modref.ll:1.2 llvm/test/Regression/Analysis/BasicAA/modref.ll:1.3 --- llvm/test/Regression/Analysis/BasicAA/modref.ll:1.2 Sat Nov 18 00:08:21 2006 +++ llvm/test/Regression/Analysis/BasicAA/modref.ll Sat Nov 18 02:06:17 2006 @@ -1,15 +1,15 @@ ; A very rudimentary test on AliasAnalysis::getModRefInfo. -; RUN: llvm-as < %s | opt -print-all-alias-modref-info -aa-eval -disable-output -&& +; RUN: llvm-as < %s | opt -print-all-alias-modref-info -aa-eval -disable-output && ; RUN: llvm-as < %s | opt -print-all-alias-modref-info -aa-eval -disable-output 2>&1 | not grep NoModRef int %callee() { - %X = alloca struct { int, int } - %Y = int* getelementptr struct { int, int }*, uint 1 - %Z = int load struct { int, int }* - ret %Z + %X = alloca { int, int } + %Y = getelementptr { int, int }* %X, uint 0, uint 0 + %Z = load int* %Y + ret int %Z } int %caller() { - %X = int callee(); + %X = call int %callee() + ret int %X } From asl at math.spbu.ru Sat Nov 18 02:15:39 2006 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Sat, 18 Nov 2006 11:15:39 +0300 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html In-Reply-To: <200611180805.kAI853p3024040.SS3338SS@zion.cs.uiuc.edu> References: <200611180805.kAI853p3024040.SS3338SS@zion.cs.uiuc.edu> Message-ID: <1163837739.1192.17.camel@asl.dorms.spbu.ru> > --- > Log message: > > Movind newly-intorudced dll* linkage stuff & windows CC to "supported" > list Err.... Too early in the morning and so much typos.... :( -- Anton Korobeynikov Saint Petersburg State University From reid at x10sys.com Sat Nov 18 11:14:23 2006 From: reid at x10sys.com (Reid Spencer) Date: Sat, 18 Nov 2006 11:14:23 -0600 Subject: [llvm-commits] CVS: llvm/utils/findmisopt Message-ID: <200611181714.kAIHENAb010021@zion.cs.uiuc.edu> Changes in directory llvm/utils: findmisopt updated: 1.6 -> 1.7 --- Log message: Provide a list of gccld optimization switches. --- Diffs of the changes: (+4 -1) findmisopt | 5 ++++- 1 files changed, 4 insertions(+), 1 deletion(-) Index: llvm/utils/findmisopt diff -u llvm/utils/findmisopt:1.6 llvm/utils/findmisopt:1.7 --- llvm/utils/findmisopt:1.6 Thu Nov 16 12:32:47 2006 +++ llvm/utils/findmisopt Sat Nov 18 11:14:09 2006 @@ -85,7 +85,10 @@ # Define the list of optimizations to run. This comprises the same set of # optimizations that gccas and gccld run, in the same order. -all_switches="-verify -lowersetjmp -funcresolve -raiseallocs -simplifycfg -mem2reg -globalopt -globaldce -ipconstprop -deadargelim -instcombine -simplifycfg -prune-eh -inline -simplify-libcalls -argpromotion -raise -tailduplicate -simplifycfg -scalarrepl -instcombine -predsimplify -condprop -tailcallelim -simplifycfg -reassociate -licm -loop-unswitch -instcombine -indvars -loop-unroll -instcombine -load-vn -gcse -sccp -instcombine -condprop -dse -dce -simplifycfg -deadtypeelim -constmerge -funcresolve -internalize -ipsccp -globalopt -constmerge -deadargelim -inline -prune-eh -globalopt -globaldce -argpromotion -instcombine -predsimplify -scalarrepl -globalsmodref-aa -licm -load-vn -gcse -dse -instcombine -simplify-cfg -verify" +all_switches="-verify -lowersetjmp -funcresolve -raiseallocs -simplifycfg -mem2reg -globalopt -globaldce -ipconstprop -deadargelim -instcombine -simplifycfg -prune-eh -inline -simplify-libcalls -argpromotion -raise -tailduplicate -simplifycfg -scalarrepl -instcombine -predsimplify -condprop -tailcallelim -simplifycfg -reassociate -licm -loop-unswitch -instcombine -indvars -loop-unroll -instcombine -load-vn -gcse -sccp -instcombine -condprop -dse -dce -simplifycfg -deadtypeelim -constmerge -funcresolve -internalize -ipsccp -globalopt -constmerge -deadargelim -inline -prune-eh -globalopt -globaldce -argpromotion -instcombine -predsimplify -scalarrepl -globalsmodref-aa -licm -load-vn -gcse -dse -instcombine -simplifycfg -verify" +# Here's an alternative list of optimizations comprising just the ones that +# gccld uses. To use, just comment out the line above, and uncomment this one +#all_switches="-funcresolve -internalize -ipsccp -globalopt -constmerge -deadargelim -inline -prune-eh -globalopt -globaldce -argpromotion -instcombine -predsimplify -scalarrepl -globalsmodref-aa -licm -load-vn -gcse -dse -instcombine -simplifycfg -verify" # Current set of switches is empty function tryit { From reid at x10sys.com Sat Nov 18 12:02:44 2006 From: reid at x10sys.com (Reid Spencer) Date: Sat, 18 Nov 2006 12:02:44 -0600 Subject: [llvm-commits] CVS: llvm/utils/mkpatch Message-ID: <200611181802.kAII2iFs010758@zion.cs.uiuc.edu> Changes in directory llvm/utils: mkpatch added (r1.1) --- Log message: This is a utility for preparing patches against LLVM. It runs cvs diff with the correct options, places the patch content in order that makes sense for review, and filters cruft out of the patch (like diffs in *.cvs files). It produces both a NAME.patch.raw (unfiltered) and NAME.patch (filtered) file. --- Diffs of the changes: (+36 -0) mkpatch | 36 ++++++++++++++++++++++++++++++++++++ 1 files changed, 36 insertions(+) Index: llvm/utils/mkpatch diff -c /dev/null llvm/utils/mkpatch:1.1 *** /dev/null Sat Nov 18 12:02:40 2006 --- llvm/utils/mkpatch Sat Nov 18 12:02:30 2006 *************** *** 0 **** --- 1,36 ---- + #!/bin/bash + # + # This script makes a patch for LLVM ensuring the correct diff options and + # putting the files in a standard review order. + + + function error { + retcode="$?" + echo "mkpatch: error: $1 ($retcode)" + exit 1 + } + + if [ ! -e llvm.spec.in ] ; then + error "Please change directory to the LLVM top source directory" + fi + if [ "$#" -ne 1 ] ; then + error "usage: utils/mkpatch [PATCH_NAME]" + fi + NAME="$1" + echo "mkpatch: Generating differences on top level files" + cvs diff -l -Ntdup -5 . > "$NAME".patch.raw 2>&1 + echo "mkpatch: Generating differences on all directories" + cvs diff -Ntdup -5 >> "$NAME".patch.raw 2>&1 \ + autoconf docs utils include lib/System lib/Support lib/VMCore lib/AsmParser \ + lib/Bytecode lib/Analysis lib/Transforms lib/CodeGen lib/Target \ + lib/ExecutionEngine lib/Debugger lib/Linker \ + tools test runtime projects examples win32 Xcode + + echo "mkpatch: Removing cruft from the patch file" + sed "$NAME".patch.raw -e '/^[?] .*/d' -e '/^cvs diff: Diffing/d' | awk '\ + BEGIN { deleting = 0; } \ + /^Index: .*[.]cvs$/ { deleting = 1; } \ + /^Index:.*/ && !/^Index: .*[.]cvs$/ { deleting = 0; } \ + { if (! deleting) { print; } } \ + ' > "$NAME".patch || error "sed/awk cleanup failed" + From reid at x10sys.com Sat Nov 18 12:30:33 2006 From: reid at x10sys.com (Reid Spencer) Date: Sat, 18 Nov 2006 12:30:33 -0600 Subject: [llvm-commits] CVS: llvm/utils/mkpatch Message-ID: <200611181830.kAIIUXnk011199@zion.cs.uiuc.edu> Changes in directory llvm/utils: mkpatch updated: 1.1 -> 1.2 --- Log message: Make the awk filter print out which files its eliminating. --- Diffs of the changes: (+2 -1) mkpatch | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-) Index: llvm/utils/mkpatch diff -u llvm/utils/mkpatch:1.1 llvm/utils/mkpatch:1.2 --- llvm/utils/mkpatch:1.1 Sat Nov 18 12:02:30 2006 +++ llvm/utils/mkpatch Sat Nov 18 12:30:18 2006 @@ -29,7 +29,8 @@ echo "mkpatch: Removing cruft from the patch file" sed "$NAME".patch.raw -e '/^[?] .*/d' -e '/^cvs diff: Diffing/d' | awk '\ BEGIN { deleting = 0; } \ -/^Index: .*[.]cvs$/ { deleting = 1; } \ +/^Index: .*[.]cvs$/ { deleting = 1; fname=substr($0,7); + print "Skipping: ", fname > "/dev/stderr"; } \ /^Index:.*/ && !/^Index: .*[.]cvs$/ { deleting = 0; } \ { if (! deleting) { print; } } \ ' > "$NAME".patch || error "sed/awk cleanup failed" From sabre at nondot.org Sat Nov 18 13:18:06 2006 From: sabre at nondot.org (Chris Lattner) Date: Sat, 18 Nov 2006 13:18:06 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/SimplifyCFG/PhiEliminate.ll Message-ID: <200611181918.kAIJI6bb011954@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/SimplifyCFG: PhiEliminate.ll updated: 1.5 -> 1.6 --- Log message: converting massive blocks of phis into selects like this is silly. --- Diffs of the changes: (+0 -28) PhiEliminate.ll | 28 ---------------------------- 1 files changed, 28 deletions(-) Index: llvm/test/Regression/Transforms/SimplifyCFG/PhiEliminate.ll diff -u llvm/test/Regression/Transforms/SimplifyCFG/PhiEliminate.ll:1.5 llvm/test/Regression/Transforms/SimplifyCFG/PhiEliminate.ll:1.6 --- llvm/test/Regression/Transforms/SimplifyCFG/PhiEliminate.ll:1.5 Sat Dec 3 12:26:41 2005 +++ llvm/test/Regression/Transforms/SimplifyCFG/PhiEliminate.ll Sat Nov 18 13:17:52 2006 @@ -18,22 +18,8 @@ br label %F F: %B1 = phi bool [true, %0], [false, %T], [false, %X] - %B2 = phi bool [true, %T], [false, %0], [false, %X] - %I1 = phi int [1, %T], [0, %0], [2, %X] - %I2 = phi int [1, %0], [0, %T], [3, %X] - %I3 = phi int [17, %T], [0, %0], [4, %X] - %I4 = phi int [17, %T], [5, %0], [44, %X] - %I5 = phi int [%V, %T], [0, %0], [%V, %X] - %I6 = phi int [%V, %0], [0, %T], [%V, %X] %I7 = phi int [%V, %0], [%V2, %T], [%V2, %X] call void %use(bool %B1) - call void %use(bool %B2) - call void %use(int %I1) - call void %use(int %I2) - call void %use(int %I3) - call void %use(int %I4) - call void %use(int %I5) - call void %use(int %I6) call void %use(int %I7) ret void } @@ -44,22 +30,8 @@ br label %F F: %B1 = phi bool [true, %0], [false, %T] - %B2 = phi bool [true, %T], [false, %0] - %I1 = phi int [1, %T], [0, %0] - %I2 = phi int [1, %0], [0, %T] - %I3 = phi int [17, %T], [0, %0] - %I4 = phi int [17, %T], [5, %0] - %I5 = phi int [%V, %T], [0, %0] %I6 = phi int [%V, %0], [0, %T] - %I7 = phi int [%V, %0], [%V2, %T] call void %use(bool %B1) - call void %use(bool %B2) - call void %use(int %I1) - call void %use(int %I2) - call void %use(int %I3) - call void %use(int %I4) - call void %use(int %I5) call void %use(int %I6) - call void %use(int %I7) ret void } From sabre at nondot.org Sat Nov 18 13:19:51 2006 From: sabre at nondot.org (Chris Lattner) Date: Sat, 18 Nov 2006 13:19:51 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/SimplifyCFG.cpp Message-ID: <200611181919.kAIJJpWL011992@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: SimplifyCFG.cpp updated: 1.104 -> 1.105 --- Log message: Do not convert massive blocks on phi nodes into select statements. Instead only do these transformations if there are a small number of phi's. This speeds up Ptrdist/ks from 2.35s to 2.19s on my mac pro. --- Diffs of the changes: (+27 -0) SimplifyCFG.cpp | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+) Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp diff -u llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.104 llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.105 --- llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.104 Wed Nov 8 00:47:33 2006 +++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp Sat Nov 18 13:19:36 2006 @@ -1064,6 +1064,16 @@ Value *IfCond = GetIfCondition(BB, IfTrue, IfFalse); if (!IfCond) return false; + // Okay, we found that we can merge this two-entry phi node into a select. + // Doing so would require us to fold *all* two entry phi nodes in this block. + // At some point this becomes non-profitable (particularly if the target + // doesn't support cmov's). Only do this transformation if there are two or + // fewer PHI nodes in this block. + unsigned NumPhis = 0; + for (BasicBlock::iterator I = BB->begin(); isa(I); ++NumPhis, ++I) + if (NumPhis > 2) + return false; + DEBUG(std::cerr << "FOUND IF CONDITION! " << *IfCond << " T: " << IfTrue->getName() << " F: " << IfFalse->getName() << "\n"); @@ -1552,6 +1562,23 @@ // keep getting unwound. if (PBIOp != -1 && PBI->getSuccessor(PBIOp) == BB) PBIOp = BIOp = -1; + + // Do not perform this transformation if it would require + // insertion of a large number of select instructions. For targets + // without predication/cmovs, this is a big pessimization. + if (PBIOp != -1) { + BasicBlock *CommonDest = PBI->getSuccessor(PBIOp); + + unsigned NumPhis = 0; + for (BasicBlock::iterator II = CommonDest->begin(); + isa(II); ++II, ++NumPhis) { + if (NumPhis > 2) { + // Disable this xform. + PBIOp = -1; + break; + } + } + } // Finally, if everything is ok, fold the branches to logical ops. if (PBIOp != -1) { From rspencer at reidspencer.com Sat Nov 18 13:24:18 2006 From: rspencer at reidspencer.com (Reid Spencer) Date: Sat, 18 Nov 2006 11:24:18 -0800 Subject: [llvm-commits] CAST patch (For Review Only) Message-ID: <1163877858.27629.2.camel@bashful.x10sys.com> Chris, Here's the CAST patch. This passes 100% of llvm/test and llvm-test. The order of the files in the patch has been set up for logical review. Some of this you've already seen, but its changed so much that those things should probably be reviewed again. Thanks, Reid. -------------- next part -------------- A non-text attachment was scrubbed... Name: CAST.patch Type: text/x-patch Size: 421820 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20061118/ca448a96/attachment.bin From sabre at nondot.org Sat Nov 18 13:32:43 2006 From: sabre at nondot.org (Chris Lattner) Date: Sat, 18 Nov 2006 13:32:43 -0600 Subject: [llvm-commits] CVS: llvm-test/Makefile.programs Message-ID: <200611181932.kAIJWhcU012201@zion.cs.uiuc.edu> Changes in directory llvm-test: Makefile.programs updated: 1.239 -> 1.240 --- Log message: When comparing LLC to CBE, we're only interested in codegen differences, we don't want GCC's inliner to factor into the picture. --- Diffs of the changes: (+1 -1) Makefile.programs | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm-test/Makefile.programs diff -u llvm-test/Makefile.programs:1.239 llvm-test/Makefile.programs:1.240 --- llvm-test/Makefile.programs:1.239 Wed Nov 15 21:49:51 2006 +++ llvm-test/Makefile.programs Sat Nov 18 13:32:28 2006 @@ -290,7 +290,7 @@ $(PROGRAMS_TO_TEST:%=Output/%.cbe): \ Output/%.cbe: Output/%.cbe.c - -$(CC) $< $(LDFLAGS) $(CFLAGS) -fno-strict-aliasing -O2 $(TARGET_FLAGS) -o $@ + -$(CC) $< $(LDFLAGS) $(CFLAGS) -fno-strict-aliasing -O2 -fno-inline $(TARGET_FLAGS) -o $@ # # Compile a linked program to machine code with LLC. From sabre at nondot.org Sat Nov 18 14:48:08 2006 From: sabre at nondot.org (Chris Lattner) Date: Sat, 18 Nov 2006 14:48:08 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/BranchFolding.cpp Message-ID: <200611182048.kAIKm8Dx013397@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: BranchFolding.cpp updated: 1.33 -> 1.34 --- Log message: Minor code layout tweak: if we have something like this: if (cond) goto BB2 BB1: ... return; BB2: ... Move BB1 to the end of the function so that the code falls through in the non-return case. This has the effect of moving assert (and other no-return call) bodies and return blocks out of loops. --- Diffs of the changes: (+50 -0) BranchFolding.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 50 insertions(+) Index: llvm/lib/CodeGen/BranchFolding.cpp diff -u llvm/lib/CodeGen/BranchFolding.cpp:1.33 llvm/lib/CodeGen/BranchFolding.cpp:1.34 --- llvm/lib/CodeGen/BranchFolding.cpp:1.33 Tue Nov 7 19:03:21 2006 +++ llvm/lib/CodeGen/BranchFolding.cpp Sat Nov 18 14:47:54 2006 @@ -586,6 +586,24 @@ return CanFallThrough(CurBB, CurUnAnalyzable, TBB, FBB, Cond); } +/// IsBetterFallthrough - Return true if it would be clearly better to +/// fall-through to MBB1 than to fall through into MBB2. This has to return +/// a strict ordering, returning true for both (MBB1,MBB2) and (MBB2,MBB1) will +/// result in infinite loops. +static bool IsBetterFallthrough(MachineBasicBlock *MBB1, + MachineBasicBlock *MBB2, + const TargetInstrInfo &TII) { + // Right now, we use a simple heuristic. If MBB ends with a return, and + // MBB2 doesn't, we prefer to fall through into MBB1. This allows us to + // optimize branches that branch to either a return block or an assert block + // into a fallthrough to the return. + if (MBB1->empty() || MBB2->empty()) return false; + + MachineInstr *MBB1I = --MBB1->end(); + MachineInstr *MBB2I = --MBB2->end(); + return TII.isReturn(MBB1I->getOpcode()) && !TII.isReturn(MBB2I->getOpcode()); +} + /// OptimizeBlock - Analyze and optimize control flow related to the specified /// block. This is never called on the entry block. void BranchFolder::OptimizeBlock(MachineBasicBlock *MBB) { @@ -675,6 +693,38 @@ return OptimizeBlock(MBB); } } + + // If this block has no successors (e.g. it is a return block or ends with + // a call to a no-return function like abort or __cxa_throw) and if the pred + // falls through into this block, and if it would otherwise fall through + // into the block after this, move this block to the end of the function. + // We consider it more likely that execution will stay in the function (e.g. + // due to loops) than it is to exit it. This asserts in loops etc, moving + // the assert condition out of the loop body. + if (MBB->succ_empty() && !PriorCond.empty() && PriorFBB == 0 && + MachineFunction::iterator(PriorTBB) == FallThrough) { + // We have to be careful that the succs of PredBB aren't both no-successor + // blocks. If neither have successors and if PredBB is the second from + // last block in the function, we'd just keep swapping the two blocks for + // last. Only do the swap if one is clearly better to fall through than + // the other. + if (FallThrough != --MBB->getParent()->end() || + IsBetterFallthrough(PriorTBB, MBB, *TII)) { + + // Reverse the branch so we will fall through on the previous true cond. + std::vector NewPriorCond(PriorCond); + if (!TII->ReverseBranchCondition(NewPriorCond)) { + TII->RemoveBranch(PrevBB); + TII->InsertBranch(PrevBB, MBB, 0, NewPriorCond); + + // Move this block to the end of the function. + MBB->moveAfter(--MBB->getParent()->end()); + MadeChange = true; + ++NumBranchOpts; + return; + } + } + } } // Analyze the branch in the current block. From sabre at nondot.org Sat Nov 18 15:30:50 2006 From: sabre at nondot.org (Chris Lattner) Date: Sat, 18 Nov 2006 15:30:50 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/BranchFolding.cpp Message-ID: <200611182130.kAILUoRn014051@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: BranchFolding.cpp updated: 1.34 -> 1.35 --- Log message: make the previous change more aggressive, moving any block with no fallthrough. This speeds up yacr2 by 7% on a core2. --- Diffs of the changes: (+11 -9) BranchFolding.cpp | 20 +++++++++++--------- 1 files changed, 11 insertions(+), 9 deletions(-) Index: llvm/lib/CodeGen/BranchFolding.cpp diff -u llvm/lib/CodeGen/BranchFolding.cpp:1.34 llvm/lib/CodeGen/BranchFolding.cpp:1.35 --- llvm/lib/CodeGen/BranchFolding.cpp:1.34 Sat Nov 18 14:47:54 2006 +++ llvm/lib/CodeGen/BranchFolding.cpp Sat Nov 18 15:30:35 2006 @@ -593,15 +593,15 @@ static bool IsBetterFallthrough(MachineBasicBlock *MBB1, MachineBasicBlock *MBB2, const TargetInstrInfo &TII) { - // Right now, we use a simple heuristic. If MBB ends with a return, and - // MBB2 doesn't, we prefer to fall through into MBB1. This allows us to + // Right now, we use a simple heuristic. If MBB2 ends with a call, and + // MBB1 doesn't, we prefer to fall through into MBB1. This allows us to // optimize branches that branch to either a return block or an assert block // into a fallthrough to the return. if (MBB1->empty() || MBB2->empty()) return false; MachineInstr *MBB1I = --MBB1->end(); MachineInstr *MBB2I = --MBB2->end(); - return TII.isReturn(MBB1I->getOpcode()) && !TII.isReturn(MBB2I->getOpcode()); + return TII.isCall(MBB2I->getOpcode()) && !TII.isCall(MBB1I->getOpcode()); } /// OptimizeBlock - Analyze and optimize control flow related to the specified @@ -694,15 +694,17 @@ } } - // If this block has no successors (e.g. it is a return block or ends with - // a call to a no-return function like abort or __cxa_throw) and if the pred - // falls through into this block, and if it would otherwise fall through - // into the block after this, move this block to the end of the function. + // If this block doesn't fall through (e.g. it ends with an uncond branch or + // has no successors) and if the pred falls through into this block, and if + // it would otherwise fall through into the block after this, move this + // block to the end of the function. + // // We consider it more likely that execution will stay in the function (e.g. // due to loops) than it is to exit it. This asserts in loops etc, moving // the assert condition out of the loop body. - if (MBB->succ_empty() && !PriorCond.empty() && PriorFBB == 0 && - MachineFunction::iterator(PriorTBB) == FallThrough) { + if (!PriorCond.empty() && PriorFBB == 0 && + MachineFunction::iterator(PriorTBB) == FallThrough && + !CanFallThrough(MBB)) { // We have to be careful that the succs of PredBB aren't both no-successor // blocks. If neither have successors and if PredBB is the second from // last block in the function, we'd just keep swapping the two blocks for From sabre at nondot.org Sat Nov 18 15:47:31 2006 From: sabre at nondot.org (Chris Lattner) Date: Sat, 18 Nov 2006 15:47:31 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineBasicBlock.h MachineInstr.h Message-ID: <200611182147.kAILlVqm014379@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineBasicBlock.h updated: 1.47 -> 1.48 MachineInstr.h updated: 1.198 -> 1.199 --- Log message: Implement operator<< for machine basic blocks to make it easier to dump them. --- Diffs of the changes: (+2 -0) MachineBasicBlock.h | 1 + MachineInstr.h | 1 + 2 files changed, 2 insertions(+) Index: llvm/include/llvm/CodeGen/MachineBasicBlock.h diff -u llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.47 llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.48 --- llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.47 Mon Oct 23 18:35:35 2006 +++ llvm/include/llvm/CodeGen/MachineBasicBlock.h Sat Nov 18 15:47:16 2006 @@ -222,6 +222,7 @@ void removePredecessor(MachineBasicBlock *pred); }; +std::ostream& operator<<(std::ostream &OS, const MachineBasicBlock &MBB); //===--------------------------------------------------------------------===// Index: llvm/include/llvm/CodeGen/MachineInstr.h diff -u llvm/include/llvm/CodeGen/MachineInstr.h:1.198 llvm/include/llvm/CodeGen/MachineInstr.h:1.199 --- llvm/include/llvm/CodeGen/MachineInstr.h:1.198 Wed Nov 15 17:55:03 2006 +++ llvm/include/llvm/CodeGen/MachineInstr.h Sat Nov 18 15:47:16 2006 @@ -20,6 +20,7 @@ #include "llvm/Support/DataTypes.h" #include #include +#include namespace llvm { From sabre at nondot.org Sat Nov 18 15:47:51 2006 From: sabre at nondot.org (Chris Lattner) Date: Sat, 18 Nov 2006 15:47:51 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/MachineBasicBlock.cpp Message-ID: <200611182147.kAILlpni014413@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: MachineBasicBlock.cpp updated: 1.33 -> 1.34 --- Log message: Implement operator<< for machine basic blocks to make it easier to dump them. --- Diffs of the changes: (+4 -0) MachineBasicBlock.cpp | 4 ++++ 1 files changed, 4 insertions(+) Index: llvm/lib/CodeGen/MachineBasicBlock.cpp diff -u llvm/lib/CodeGen/MachineBasicBlock.cpp:1.33 llvm/lib/CodeGen/MachineBasicBlock.cpp:1.34 --- llvm/lib/CodeGen/MachineBasicBlock.cpp:1.33 Mon Oct 23 19:02:26 2006 +++ llvm/lib/CodeGen/MachineBasicBlock.cpp Sat Nov 18 15:47:36 2006 @@ -27,6 +27,10 @@ LeakDetector::removeGarbageObject(this); } +std::ostream& llvm::operator<<(std::ostream &OS, const MachineBasicBlock &MBB) { + MBB.print(OS); + return OS; +} // MBBs start out as #-1. When a MBB is added to a MachineFunction, it // gets the next available unique MBB number. If it is removed from a From sabre at nondot.org Sat Nov 18 15:48:20 2006 From: sabre at nondot.org (Chris Lattner) Date: Sat, 18 Nov 2006 15:48:20 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineBasicBlock.h Message-ID: <200611182148.kAILmKSm014469@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineBasicBlock.h updated: 1.48 -> 1.49 --- Log message: MachineInstr includes this --- Diffs of the changes: (+0 -1) MachineBasicBlock.h | 1 - 1 files changed, 1 deletion(-) Index: llvm/include/llvm/CodeGen/MachineBasicBlock.h diff -u llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.48 llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.49 --- llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.48 Sat Nov 18 15:47:16 2006 +++ llvm/include/llvm/CodeGen/MachineBasicBlock.h Sat Nov 18 15:48:05 2006 @@ -17,7 +17,6 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/ADT/GraphTraits.h" #include "llvm/ADT/ilist" -#include namespace llvm { class MachineFunction; From reid at x10sys.com Sat Nov 18 15:51:08 2006 From: reid at x10sys.com (Reid Spencer) Date: Sat, 18 Nov 2006 15:51:08 -0600 Subject: [llvm-commits] CVS: llvm/docs/LangRef.html Message-ID: <200611182151.kAILp8Lw014636@zion.cs.uiuc.edu> Changes in directory llvm/docs: LangRef.html updated: 1.170 -> 1.171 --- Log message: For PR950: http://llvm.org/PR950 : Documentation preview of the upcoming icmp and fcmp instructions that will replace the various setcc instructions. --- Diffs of the changes: (+163 -49) LangRef.html | 212 +++++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 163 insertions(+), 49 deletions(-) Index: llvm/docs/LangRef.html diff -u llvm/docs/LangRef.html:1.170 llvm/docs/LangRef.html:1.171 --- llvm/docs/LangRef.html:1.170 Sat Nov 11 17:08:07 2006 +++ llvm/docs/LangRef.html Sat Nov 18 15:50:54 2006 @@ -83,7 +83,6 @@
  • 'urem' Instruction
  • 'srem' Instruction
  • 'frem' Instruction
  • -
  • 'setcc' Instructions
  • Bitwise Binary Operations @@ -96,6 +95,7 @@
  • 'ashr' Instruction
  • +
  • Vector Operations
    1. 'extractelement' Instruction
    2. @@ -130,6 +130,8 @@
  • Other Operations
      +
    1. 'icmp' Instruction
    2. +
    3. 'fcmp' Instruction
    4. 'phi' Instruction
    5. 'select' Instruction
    6. 'call' Instruction
    7. @@ -1838,51 +1840,6 @@
      Example:
        <result> = frem float 4.0, %var          ; yields {float}:result = 4.0 % %var
       
      - -
  • - - -
    -
    Syntax:
    -
      <result> = seteq <ty> <var1>, <var2>   ; yields {bool}:result
    -  <result> = setne <ty> <var1>, <var2>   ; yields {bool}:result
    -  <result> = setlt <ty> <var1>, <var2>   ; yields {bool}:result
    -  <result> = setgt <ty> <var1>, <var2>   ; yields {bool}:result
    -  <result> = setle <ty> <var1>, <var2>   ; yields {bool}:result
    -  <result> = setge <ty> <var1>, <var2>   ; yields {bool}:result
    -
    -
    Overview:
    -

    The 'setcc' family of instructions returns a boolean -value based on a comparison of their two operands.

    -
    Arguments:
    -

    The two arguments to the 'setcc' instructions must -be of first class type (it is not possible -to compare 'label's, 'array's, 'structure' -or 'void' values, etc...). Both arguments must have identical -types.

    -
    Semantics:
    -

    The 'seteq' instruction yields a true 'bool' -value if both operands are equal.
    -The 'setne' instruction yields a true 'bool' -value if both operands are unequal.
    -The 'setlt' instruction yields a true 'bool' -value if the first operand is less than the second operand.
    -The 'setgt' instruction yields a true 'bool' -value if the first operand is greater than the second operand.
    -The 'setle' instruction yields a true 'bool' -value if the first operand is less than or equal to the second operand.
    -The 'setge' instruction yields a true 'bool' -value if the first operand is greater than or equal to the second -operand.

    -
    Example:
    -
      <result> = seteq int   4, 5        ; yields {bool}:result = false
    -  <result> = setne float 4, 5        ; yields {bool}:result = true
    -  <result> = setlt uint  4, 5        ; yields {bool}:result = true
    -  <result> = setgt sbyte 4, 5        ; yields {bool}:result = false
    -  <result> = setle sbyte 4, 5        ; yields {bool}:result = true
    -  <result> = setge sbyte 4, 5        ; yields {bool}:result = false
    -
    @@ -2537,7 +2494,7 @@ levels of a structure or to a specific index in an array. When indexing into a structure, only uint integer constants are allowed. When indexing into an array or pointer, -int and long indexes are allowed of any sign.

    +int and long and ulong indexes are allowed.

    For example, let's consider a C code fragment and how it gets compiled to LLVM:

    @@ -2578,7 +2535,7 @@

    The index types specified for the 'getelementptr' instruction depend on the pointer type that is being indexed into. Pointer -and array types require uint, int, +and array types require int, ulong, or long values, and structure types require uint constants.

    @@ -3083,6 +3040,163 @@

    The instructions in this category are the "miscellaneous" instructions, which defy better classification.

    + + + +
    +
    Syntax:
    +
      <result> = icmp <cond> <ty> <var1>, <var2>   ; yields {bool}:result
    +
    +
    Overview:
    +

    The 'icmp' instruction returns a boolean value based on comparison +of its two integer operands.

    +
    Arguments:
    +

    The 'icmp' instruction takes three operands. The first operand is +the condition code which indicates the kind of comparison to perform. It is not +a value, just a keyword. The possibilities for the condition code are: +

      +
    1. eq: equal
    2. +
    3. ne: not equal
    4. +
    5. ugt: unsigned greater than
    6. +
    7. uge: unsigned greater or equal
    8. +
    9. ult: unsigned less than
    10. +
    11. ule: unsigned less or equal
    12. +
    13. sgt: signed greater than
    14. +
    15. sge: signed greater or equal
    16. +
    17. slt: signed less than
    18. +
    19. sle: signed less or equal
    20. +
    +

    The remaining two arguments must be of integral, +pointer or a packed integral +type. They must have identical types.

    +
    Semantics:
    +

    The 'icmp' compares var1 and var2 according to +the condition code given as cond. The comparison performed always +yields a bool result, as follows: +

      +
    1. eq: yields true if the operands are equal, + false otherwise. No sign interpretation is necessary or performed. +
    2. +
    3. ne: yields true if the operands are unequal, + false otherwise. No sign interpretation is necessary or performed. +
    4. ugt: interprets the operands as unsigned values and yields + true if var1 is greater than var2.
    5. +
    6. uge: interprets the operands as unsigned values and yields + true if var1 is greater than or equal to var2.
    7. +
    8. ult: interprets the operands as unsigned values and yields + true if var1 is less than var2.
    9. +
    10. ule: interprets the operands as unsigned values and yields + true if var1 is less than or equal to var2.
    11. +
    12. sgt: interprets the operands as signed values and yields + true if var1 is greater than var2.
    13. +
    14. sge: interprets the operands as signed values and yields + true if var1 is greater than or equal to var2.
    15. +
    16. slt: interprets the operands as signed values and yields + true if var1 is less than var2.
    17. +
    18. sle: interprets the operands as signed values and yields + true if var1 is less than or equal to var2.
    19. + +
    +

    If the operands are pointer typed, the pointer +values are treated as integers and then compared.

    +

    If the operands are packed typed, the elements of +the vector are compared in turn and the predicate must hold for all elements. +While this is of dubious use for predicates other than eq and +ne, the other predicates can be used with packed types.

    + +
    Example:
    +
      <result> = icmp eq int 4, 5           ; yields: result=false
    +  <result> = icmp ne float* %X, %X      ; yields: result=false
    +  <result> = icmp ult short 4, 5        ; yields: result=true
    +  <result> = icmp sgt sbyte 4, 5        ; yields: result=false
    +  <result> = icmp ule sbyte -4, 5       ; yields: result=false
    +  <result> = icmp sge sbyte 4, 5        ; yields: result=false
    +
    +
    + + + +
    +
    Syntax:
    +
      <result> = fcmp <cond> <ty> <var1>, <var2>   ; yields {bool}:result
    +
    +
    Overview:
    +

    The 'fcmp' instruction returns a boolean value based on comparison +of its floating point operands.

    +
    Arguments:
    +

    The 'fcmp' instruction takes three operands. The first operand is +the condition code which indicates the kind of comparison to perform. It is not +a value, just a keyword. The possibilities for the condition code are: +

      +
    1. false: no comparison, always false (always folded)
    2. +
    3. oeq: ordered and equal
    4. +
    5. ogt: ordered and greater than
    6. +
    7. oge: ordered and greater than or equal
    8. +
    9. olt: ordered and less than
    10. +
    11. ole: ordered and less than or equal
    12. +
    13. one: ordered and not equal
    14. +
    15. ord: ordered (no nans)
    16. +
    17. ueq: unordered or equal
    18. +
    19. ugt: unordered or greater than
    20. +
    21. uge: unordered or greater than or equal
    22. +
    23. ult: unordered or less than
    24. +
    25. ule: unordered or less than or equal
    26. +
    27. une: unordered or not equal
    28. +
    29. uno: unordered (either nans)
    30. +
    31. true: no comparison, always true (always folded)
    32. +
    +

    The val1 and val2 arguments must be of +floating point, or a packed +floating point type. They must have identical types.

    +
    Semantics:
    +

    The 'fcmp' compares var1 and var2 according to +the condition code given as cond. The comparison performed always +yields a bool result, as follows: +

      +
    1. false: always yields false, regardless of operands.
    2. +
    3. oeq: yields true if both operands are ordered and + var1 is equal to var2.
    4. +
    5. ogt: yields true if both operands are ordered and + var1 is greather than var2.
    6. +
    7. oge: yields true if both operands are ordered and + var1 is greater than or equal to var2.
    8. +
    9. olt: yields true if both operands are ordered and + var1 is less than var2.
    10. +
    11. ole: yields true if both operands are ordered and + var1 is less than or equal to var2.
    12. +
    13. one: yields true if both operands are ordered and + var1 is not equal to var2.
    14. +
    15. ord: yields true if both operands are ordered.
    16. +
    17. ueq: yields true if either operand is unordered or + var1 is equal to var2.
    18. +
    19. ugt: yields true if either operand is unordered or + var1 is greater than var2.
    20. +
    21. uge: yields true if either operand is unordered or + var1 is greater than or equal to var2.
    22. +
    23. ult: yields true if either operand is unordered or + var1 is less than var2.
    24. +
    25. ule: yields true if either operand is unordered or + var1 is less than or equal to var2.
    26. +
    27. une: yields true if either operand is unordered or + var1 is not equal to var2.
    28. +
    29. uno: yields true if either operand is unordered.
    30. +
    31. true: always yields true, regardless of operands.
    32. +
    +

    If the operands are packed typed, the elements of +the vector are compared in turn and the predicate must hold for all elements. +While this is of dubious use for predicates other than eq and +ne, the other predicates can be used with packed types.

    + +
    Example:
    +
      <result> = fcmp oeq float 4.0, 5.0    ; yields: result=false
    +  <result> = icmp one float 4.0, 5.0    ; yields: result=true
    +  <result> = icmp olt float 4.0, 5.0    ; yields: result=true
    +  <result> = icmp ueq double 1.0, 2.0   ; yields: result=false
    +
    +
    + @@ -4313,7 +4427,7 @@ Chris Lattner
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2006/11/11 23:08:07 $ + Last modified: $Date: 2006/11/18 21:50:54 $ From reid at x10sys.com Sat Nov 18 15:55:59 2006 From: reid at x10sys.com (Reid Spencer) Date: Sat, 18 Nov 2006 15:55:59 -0600 Subject: [llvm-commits] CVS: llvm/docs/LangRef.html Message-ID: <200611182155.kAILtxND014766@zion.cs.uiuc.edu> Changes in directory llvm/docs: LangRef.html updated: 1.171 -> 1.172 --- Log message: Update a reference to the old setcc instruction. --- Diffs of the changes: (+2 -2) LangRef.html | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/docs/LangRef.html diff -u llvm/docs/LangRef.html:1.171 llvm/docs/LangRef.html:1.172 --- llvm/docs/LangRef.html:1.171 Sat Nov 18 15:50:54 2006 +++ llvm/docs/LangRef.html Sat Nov 18 15:55:45 2006 @@ -1426,7 +1426,7 @@ to the 'iftrue' label argument. If "cond" is false, control flows to the 'iffalse' label argument.

    Example:
    -
    Test:
    %cond = seteq int %a, %b
    br bool %cond, label %IfEqual, label %IfUnequal
    IfEqual:
    Test:
    %cond =
    icmp eq, int %a, %b
    br bool %cond, label %IfEqual, label %IfUnequal
    IfEqual:
    ret int 1
    IfUnequal:
    ret int 0
    @@ -4427,7 +4427,7 @@ Chris Lattner
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2006/11/18 21:50:54 $ + Last modified: $Date: 2006/11/18 21:55:45 $ From sabre at nondot.org Sat Nov 18 15:56:54 2006 From: sabre at nondot.org (Chris Lattner) Date: Sat, 18 Nov 2006 15:56:54 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/BranchFolding.cpp Message-ID: <200611182156.kAILusx3014824@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: BranchFolding.cpp updated: 1.35 -> 1.36 --- Log message: Fix another case we *don't* want to do this xform. --- Diffs of the changes: (+26 -2) BranchFolding.cpp | 28 ++++++++++++++++++++++++++-- 1 files changed, 26 insertions(+), 2 deletions(-) Index: llvm/lib/CodeGen/BranchFolding.cpp diff -u llvm/lib/CodeGen/BranchFolding.cpp:1.35 llvm/lib/CodeGen/BranchFolding.cpp:1.36 --- llvm/lib/CodeGen/BranchFolding.cpp:1.35 Sat Nov 18 15:30:35 2006 +++ llvm/lib/CodeGen/BranchFolding.cpp Sat Nov 18 15:56:39 2006 @@ -16,6 +16,7 @@ // //===----------------------------------------------------------------------===// +#define DEBUG_TYPE "branchfolding" #include "llvm/CodeGen/Passes.h" #include "llvm/CodeGen/MachineDebugInfo.h" #include "llvm/CodeGen/MachineFunctionPass.h" @@ -23,6 +24,7 @@ #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/Debug.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/STLExtras.h" #include @@ -705,17 +707,39 @@ if (!PriorCond.empty() && PriorFBB == 0 && MachineFunction::iterator(PriorTBB) == FallThrough && !CanFallThrough(MBB)) { + bool DoTransform = true; + // We have to be careful that the succs of PredBB aren't both no-successor // blocks. If neither have successors and if PredBB is the second from // last block in the function, we'd just keep swapping the two blocks for // last. Only do the swap if one is clearly better to fall through than // the other. - if (FallThrough != --MBB->getParent()->end() || - IsBetterFallthrough(PriorTBB, MBB, *TII)) { + if (FallThrough == --MBB->getParent()->end() && + !IsBetterFallthrough(PriorTBB, MBB, *TII)) + DoTransform = false; + + // We don't want to do this transformation if we have control flow like: + // br cond BB2 + // BB1: + // .. + // jmp BBX + // BB2: + // .. + // ret + // + // In this case, we could actually be moving the return block *into* a + // loop! + if (DoTransform && !MBB->succ_empty() && !CanFallThrough(PriorTBB)) + DoTransform = false; + + if (DoTransform) { // Reverse the branch so we will fall through on the previous true cond. std::vector NewPriorCond(PriorCond); if (!TII->ReverseBranchCondition(NewPriorCond)) { + DOUT << "\nMoving MBB: " << *MBB; + DOUT << "To make fallthrough to: " << *PriorTBB << "\n"; + TII->RemoveBranch(PrevBB); TII->InsertBranch(PrevBB, MBB, 0, NewPriorCond); From sabre at nondot.org Sat Nov 18 16:02:45 2006 From: sabre at nondot.org (Chris Lattner) Date: Sat, 18 Nov 2006 16:02:45 -0600 Subject: [llvm-commits] CVS: llvm-test/Makefile.programs Message-ID: <200611182202.kAIM2j90014954@zion.cs.uiuc.edu> Changes in directory llvm-test: Makefile.programs updated: 1.240 -> 1.241 --- Log message: make clean in llvm-test removes bugpoint output too --- Diffs of the changes: (+2 -0) Makefile.programs | 2 ++ 1 files changed, 2 insertions(+) Index: llvm-test/Makefile.programs diff -u llvm-test/Makefile.programs:1.240 llvm-test/Makefile.programs:1.241 --- llvm-test/Makefile.programs:1.240 Sat Nov 18 13:32:28 2006 +++ llvm-test/Makefile.programs Sat Nov 18 16:02:30 2006 @@ -428,6 +428,8 @@ Output/%.bugpoint-jit: Output/%.llvm.bc $(LBUGPOINT) Output/%.out-nat $(LBUGPOINT) $< -run-jit $(BUGPOINT_OPTIONS) $(BUGPOINT_ARGS) +clean:: + rm -f bugpoint-* LIBPROFILESO = $(LLVM_OBJ_ROOT)/Debug/lib/libprofile_rt.so From sabre at nondot.org Sat Nov 18 16:12:05 2006 From: sabre at nondot.org (Chris Lattner) Date: Sat, 18 Nov 2006 16:12:05 -0600 Subject: [llvm-commits] CVS: llvm-test/MultiSource/Benchmarks/Olden/health/list.c Message-ID: <200611182212.kAIMC5Mv015175@zion.cs.uiuc.edu> Changes in directory llvm-test/MultiSource/Benchmarks/Olden/health: list.c updated: 1.4 -> 1.5 --- Log message: remove an ugly hack dating from Nov'02. :) --- Diffs of the changes: (+0 -6) list.c | 6 ------ 1 files changed, 6 deletions(-) Index: llvm-test/MultiSource/Benchmarks/Olden/health/list.c diff -u llvm-test/MultiSource/Benchmarks/Olden/health/list.c:1.4 llvm-test/MultiSource/Benchmarks/Olden/health/list.c:1.5 --- llvm-test/MultiSource/Benchmarks/Olden/health/list.c:1.4 Wed Nov 6 01:16:04 2002 +++ llvm-test/MultiSource/Benchmarks/Olden/health/list.c Sat Nov 18 16:11:50 2006 @@ -9,11 +9,6 @@ #include #include "health.h" -/* LevelRaiseHack - Level raise is having issues with addList. This is a gross - hack to get health working better. - */ -static void LevelRaiseHack(struct List *L) {} - void addList(struct List *list, struct Patient *patient) { struct List *b; @@ -22,7 +17,6 @@ list = list->forward; } list = (struct List *)malloc(sizeof(struct List)); - LevelRaiseHack(list); list->patient = patient; list->forward = NULL; list->back = b; From sabre at nondot.org Sat Nov 18 16:25:54 2006 From: sabre at nondot.org (Chris Lattner) Date: Sat, 18 Nov 2006 16:25:54 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/BranchFolding.cpp Message-ID: <200611182225.kAIMPsFs015422@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: BranchFolding.cpp updated: 1.36 -> 1.37 --- Log message: Don't transform in another bad case: if the block is empty, it should be simplified before we do this xform so that our cost model is accurate. --- Diffs of the changes: (+2 -1) BranchFolding.cpp | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-) Index: llvm/lib/CodeGen/BranchFolding.cpp diff -u llvm/lib/CodeGen/BranchFolding.cpp:1.36 llvm/lib/CodeGen/BranchFolding.cpp:1.37 --- llvm/lib/CodeGen/BranchFolding.cpp:1.36 Sat Nov 18 15:56:39 2006 +++ llvm/lib/CodeGen/BranchFolding.cpp Sat Nov 18 16:25:39 2006 @@ -729,7 +729,8 @@ // // In this case, we could actually be moving the return block *into* a // loop! - if (DoTransform && !MBB->succ_empty() && !CanFallThrough(PriorTBB)) + if (DoTransform && !MBB->succ_empty() && + (!CanFallThrough(PriorTBB) || PriorTBB->empty())) DoTransform = false; From reid at x10sys.com Sat Nov 18 21:00:29 2006 From: reid at x10sys.com (Reid Spencer) Date: Sat, 18 Nov 2006 21:00:29 -0600 Subject: [llvm-commits] CVS: llvm/docs/LangRef.html Message-ID: <200611190300.kAJ30T8s019992@zion.cs.uiuc.edu> Changes in directory llvm/docs: LangRef.html updated: 1.172 -> 1.173 --- Log message: Corrections from review. --- Diffs of the changes: (+22 -22) LangRef.html | 44 ++++++++++++++++++++++---------------------- 1 files changed, 22 insertions(+), 22 deletions(-) Index: llvm/docs/LangRef.html diff -u llvm/docs/LangRef.html:1.172 llvm/docs/LangRef.html:1.173 --- llvm/docs/LangRef.html:1.172 Sat Nov 18 15:55:45 2006 +++ llvm/docs/LangRef.html Sat Nov 18 21:00:14 2006 @@ -3101,9 +3101,8 @@

    If the operands are pointer typed, the pointer values are treated as integers and then compared.

    If the operands are packed typed, the elements of -the vector are compared in turn and the predicate must hold for all elements. -While this is of dubious use for predicates other than eq and -ne, the other predicates can be used with packed types.

    +the vector are compared in turn and the predicate must hold for all +elements.

    Example:
      <result> = icmp eq int 4, 5           ; yields: result=false
    @@ -3130,7 +3129,7 @@
     the condition code which indicates the kind of comparison to perform. It is not
     a value, just a keyword. The possibilities for the condition code are:
     
      -
    1. false: no comparison, always false (always folded)
    2. +
    3. false: no comparison, always returns false
    4. oeq: ordered and equal
    5. ogt: ordered and greater than
    6. oge: ordered and greater than or equal
    7. @@ -3145,49 +3144,50 @@
    8. ule: unordered or less than or equal
    9. une: unordered or not equal
    10. uno: unordered (either nans)
    11. -
    12. true: no comparison, always true (always folded)
    13. +
    14. true: no comparison, always returns true

    The val1 and val2 arguments must be of floating point, or a packed floating point type. They must have identical types.

    +

    In the foregoing, ordered means that neither operand is a QNAN and +unordered means that either operand is a QNAN.

    Semantics:

    The 'fcmp' compares var1 and var2 according to the condition code given as cond. The comparison performed always yields a bool result, as follows:

    1. false: always yields false, regardless of operands.
    2. -
    3. oeq: yields true if both operands are ordered and +
    4. oeq: yields true if both operands are not a QNAN and var1 is equal to var2.
    5. -
    6. ogt: yields true if both operands are ordered and +
    7. ogt: yields true if both operands are not a QNAN and var1 is greather than var2.
    8. -
    9. oge: yields true if both operands are ordered and +
    10. oge: yields true if both operands are not a QNAN and var1 is greater than or equal to var2.
    11. -
    12. olt: yields true if both operands are ordered and +
    13. olt: yields true if both operands are not a QNAN and var1 is less than var2.
    14. -
    15. ole: yields true if both operands are ordered and +
    16. ole: yields true if both operands are not a QNAN and var1 is less than or equal to var2.
    17. -
    18. one: yields true if both operands are ordered and +
    19. one: yields true if both operands are not a QNAN and var1 is not equal to var2.
    20. -
    21. ord: yields true if both operands are ordered.
    22. -
    23. ueq: yields true if either operand is unordered or +
    24. ord: yields true if both operands are not a QNAN.
    25. +
    26. ueq: yields true if either operand is a QNAN or var1 is equal to var2.
    27. -
    28. ugt: yields true if either operand is unordered or +
    29. ugt: yields true if either operand is a QNAN or var1 is greater than var2.
    30. -
    31. uge: yields true if either operand is unordered or +
    32. uge: yields true if either operand is a QNAN or var1 is greater than or equal to var2.
    33. -
    34. ult: yields true if either operand is unordered or +
    35. ult: yields true if either operand is a QNAN or var1 is less than var2.
    36. -
    37. ule: yields true if either operand is unordered or +
    38. ule: yields true if either operand is a QNAN or var1 is less than or equal to var2.
    39. -
    40. une: yields true if either operand is unordered or +
    41. une: yields true if either operand is a QNAN or var1 is not equal to var2.
    42. -
    43. uno: yields true if either operand is unordered.
    44. +
    45. uno: yields true if either operand is a QNAN.
    46. true: always yields true, regardless of operands.

    If the operands are packed typed, the elements of the vector are compared in turn and the predicate must hold for all elements. -While this is of dubious use for predicates other than eq and -ne, the other predicates can be used with packed types.

    +

    Example:
      <result> = fcmp oeq float 4.0, 5.0    ; yields: result=false
    @@ -4427,7 +4427,7 @@
     
       Chris Lattner
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2006/11/18 21:55:45 $ + Last modified: $Date: 2006/11/19 03:00:14 $ From rspencer at reidspencer.com Sun Nov 19 01:36:36 2006 From: rspencer at reidspencer.com (Reid Spencer) Date: Sat, 18 Nov 2006 23:36:36 -0800 Subject: [llvm-commits] SETCC Patch [For Review Only] Message-ID: <1163921796.27629.24.camel@bashful.x10sys.com> This is the first in a series of patches to split the SETCC instructions into just two instructions: icmp (integer compare) and fcmp (floating point compare). This patch is a no-op. It introduces code that will be used in subsequent patches. The new instruction codes are reserved, the instruction classes are defined, and the InstVisitor class (and users) is updated to recognize the new instructions. However, nothing else in LLVM will produce these instructions (yet). The patch passes all tests. Reid. -------------- next part -------------- A non-text attachment was scrubbed... Name: SETCC.patch Type: text/x-patch Size: 30087 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20061118/7a0b3c1b/attachment.bin From clattner at apple.com Sun Nov 19 16:55:52 2006 From: clattner at apple.com (Chris Lattner) Date: Sun, 19 Nov 2006 14:55:52 -0800 Subject: [llvm-commits] SETCC Patch [For Review Only] In-Reply-To: <1163921796.27629.24.camel@bashful.x10sys.com> References: <1163921796.27629.24.camel@bashful.x10sys.com> Message-ID: On Nov 18, 2006, at 11:36 PM, Reid Spencer wrote: > This is the first in a series of patches to split the SETCC > instructions > into just two instructions: icmp (integer compare) and fcmp (floating > point compare). This patch is a no-op. It introduces code that will be > used in subsequent patches. The new instruction codes are reserved, > the > instruction classes are defined, and the InstVisitor class (and users) > is updated to recognize the new instructions. However, nothing else in > LLVM will produce these instructions (yet). The patch passes all > tests. The comments on fcmpinst are not correct in some cases: + /// For example, EQ -> NE, UGT -> ULE, SLT -> SGE, etc. + /// @returns the inverse predicate for the instructions current predicate. + /// @brief Return the inverse of the predicate These refer to SLT which isn't valid for fcmp, similarly for others. --- include/llvm/Support/InstVisitor.h 9 Oct 2006 18:33:08 -0000 1.41 +++ include/llvm/Support/InstVisitor.h 19 Nov 2006 07:32:51 -0000 @@ -167,10 +167,12 @@ public: RetTy visitSwitchInst(SwitchInst &I) { DELEGATE (TerminatorInst);} RetTy visitInvokeInst(InvokeInst &I) { DELEGATE (TerminatorInst);} RetTy visitUnwindInst(UnwindInst &I) { DELEGATE (TerminatorInst);} RetTy visitUnreachableInst(UnreachableInst &I) { DELEGATE (TerminatorInst);} RetTy visitSetCondInst(SetCondInst &I) { DELEGATE (BinaryOperator);} + RetTy visitICmpInst(ICmpInst &I) { DELEGATE (Instruction);} + RetTy visitFCmpInst(FCmpInst &I) { DELEGATE (Instruction);} RetTy visitMallocInst(MallocInst &I) { DELEGATE (AllocationInst);} RetTy visitAllocaInst(AllocaInst &I) { DELEGATE (AllocationInst);} RetTy visitFreeInst(FreeInst &I) { DELEGATE (Instruction); } RetTy visitLoadInst(LoadInst &I) { DELEGATE (Instruction); } RetTy visitStoreInst(StoreInst &I) { DELEGATE (Instruction); } This should delegate to CmpInst, which delegates to Instruction. +void CmpInst::swapOperands() { + if (ICmpInst* IC = dyn_cast(this)) { + IC->swapOperands(); + } else if (FCmpInst* FC = dyn_cast(this)) { + FC->swapOperands(); + } + assert(!"Unknown CmpInst type"); +} I'd write this as: +void CmpInst::swapOperands() { + if (ICmpInst* IC = dyn_cast(this)) { + IC->swapOperands(); + } else { + cast(this)->swapOperands(); + } which is faster in release builds. Besides, the assert will always trigger above. Please use 0 && "foo", which is the standard idiom instead of !"foo". +FCmpInst::Predicate FCmpInst::getInversePredicate(Predicate pred) { + switch (pred) { + default: + assert(!"Unknown icmp predicate!"); + case OEQ: return ONE; + case ONE: return OEQ; + case OGT: return OLE; + case OLT: return OGE; + case OGE: return OLT; + case OLE: return OGT; + case UEQ: return UNE; + case UNE: return UEQ; + case UGT: return ULE; + case ULT: return UGE; + case UGE: return ULT; + case ULE: return UGT; + case TRUE: return FALSE; + case FALSE: return TRUE; + } +} These aren't right, for example, !OEQ = UNE +void Verifier::visitICmpInst(ICmpInst& IC) { + // Check that icmp instructions return bool + Assert1(IC.getType() == Type::BoolTy, + "ICmp instructions must return boolean values!", &IC); + // Check that the operands are the same type + const Type* Op0Ty = IC.getOperand(0)->getType(); + const Type* Op1Ty = IC.getOperand(0)->getType(); + Assert1(Op0Ty == Op1Ty, + "Both operands to ICmp instruction are not of the same type!", &IC); + // Check that the operands are the right type + Assert1(Op0Ty->isIntegral() || Op0Ty->getTypeID() == Type::PointerTyID || + (isa(Op0Ty) && + cast(Op0Ty)->getElementType()->isIntegral()), + "Invalid operand types for ICmp instruction", &IC); Most of these check should also happen in the ctors. The check for the result of bool should just be in the ctor. Once an instruction is created, you can't change its result type. +void BVNImpl::visitCmpInst(CmpInst &CI1) { + Value *LHS = CI1.getOperand(0); + for (Value::use_iterator UI = LHS->use_begin(), UE = LHS->use_end(); + UI != UE; ++UI) + if (CmpInst *CI2 = dyn_cast(*UI)) + // Check to see if this comparinstruction is not CI, but same opcode, + // same predicate, and in the same function. typo comparinstruction + // And its commutative (equal or not equal) + ((isa(CI1) && cast (CI1).isCommutative()) || + (isa(CI1) && cast (CI1).isCommutative())))) The second line has a typo (ICmp -> FCmp). The second line begs for a CmpInst::isCommutative() Go ahead and commit after tweaking these, -Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20061119/d483377f/attachment.html From reid at x10sys.com Sun Nov 19 17:07:15 2006 From: reid at x10sys.com (Reid Spencer) Date: Sun, 19 Nov 2006 17:07:15 -0600 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/Lexer.l ParserInternals.h llvmAsmParser.y Message-ID: <200611192307.kAJN7F60010436@zion.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: Lexer.l updated: 1.82 -> 1.83 ParserInternals.h updated: 1.46 -> 1.47 llvmAsmParser.y updated: 1.275 -> 1.276 --- Log message: For PR950: http://llvm.org/PR950 : Retain the signedness of the old integer types in a new TypeInfo structure so that it can be used in the grammar to implement auto-upgrade of things that depended on signedness of types. This doesn't implement any new functionality in the AsmParser, its just plumbing for future changes. --- Diffs of the changes: (+277 -215) Lexer.l | 37 +++- ParserInternals.h | 26 +++ llvmAsmParser.y | 429 ++++++++++++++++++++++++++++-------------------------- 3 files changed, 277 insertions(+), 215 deletions(-) Index: llvm/lib/AsmParser/Lexer.l diff -u llvm/lib/AsmParser/Lexer.l:1.82 llvm/lib/AsmParser/Lexer.l:1.83 --- llvm/lib/AsmParser/Lexer.l:1.82 Wed Nov 8 00:47:33 2006 +++ llvm/lib/AsmParser/Lexer.l Sun Nov 19 17:07:00 2006 @@ -51,6 +51,17 @@ llvmAsmlval.type.obsolete = true; \ return sym +// Construct a token value for a non-obsolete type +#define RET_TY(CType, sym) \ + llvmAsmlval.TypeVal.type = new PATypeHolder(CType); \ + llvmAsmlval.TypeVal.signedness = isSignless; \ + return sym + +// Construct a token value for an obsolete token +#define RET_TY_OBSOLETE(CType, sign, sym) \ + llvmAsmlval.TypeVal.type = new PATypeHolder(CType); \ + llvmAsmlval.TypeVal.signedness = sign; \ + return sym namespace llvm { @@ -238,19 +249,19 @@ x86_stdcallcc { return X86_STDCALLCC_TOK; } x86_fastcallcc { return X86_FASTCALLCC_TOK; } -void { llvmAsmlval.PrimType = Type::VoidTy ; return VOID; } -bool { llvmAsmlval.PrimType = Type::BoolTy ; return BOOL; } -sbyte { llvmAsmlval.PrimType = Type::SByteTy ; return SBYTE; } -ubyte { llvmAsmlval.PrimType = Type::UByteTy ; return UBYTE; } -short { llvmAsmlval.PrimType = Type::ShortTy ; return SHORT; } -ushort { llvmAsmlval.PrimType = Type::UShortTy; return USHORT; } -int { llvmAsmlval.PrimType = Type::IntTy ; return INT; } -uint { llvmAsmlval.PrimType = Type::UIntTy ; return UINT; } -long { llvmAsmlval.PrimType = Type::LongTy ; return LONG; } -ulong { llvmAsmlval.PrimType = Type::ULongTy ; return ULONG; } -float { llvmAsmlval.PrimType = Type::FloatTy ; return FLOAT; } -double { llvmAsmlval.PrimType = Type::DoubleTy; return DOUBLE; } -label { llvmAsmlval.PrimType = Type::LabelTy ; return LABEL; } +void { RET_TY(Type::VoidTy, VOID); } +bool { RET_TY(Type::BoolTy, BOOL); } +sbyte { RET_TY_OBSOLETE(Type::SByteTy, isSigned, SBYTE); } +ubyte { RET_TY_OBSOLETE(Type::UByteTy, isUnsigned, UBYTE); } +short { RET_TY_OBSOLETE(Type::ShortTy, isSigned, SHORT); } +ushort { RET_TY_OBSOLETE(Type::UShortTy,isUnsigned, USHORT); } +int { RET_TY_OBSOLETE(Type::IntTy, isSigned, INT); } +uint { RET_TY_OBSOLETE(Type::UIntTy, isUnsigned, UINT); } +long { RET_TY_OBSOLETE(Type::LongTy, isSigned, LONG); } +ulong { RET_TY_OBSOLETE(Type::ULongTy, isUnsigned, ULONG); } +float { RET_TY(Type::FloatTy, FLOAT); } +double { RET_TY(Type::DoubleTy, DOUBLE); } +label { RET_TY(Type::LabelTy, LABEL); } type { return TYPE; } opaque { return OPAQUE; } Index: llvm/lib/AsmParser/ParserInternals.h diff -u llvm/lib/AsmParser/ParserInternals.h:1.46 llvm/lib/AsmParser/ParserInternals.h:1.47 --- llvm/lib/AsmParser/ParserInternals.h:1.46 Thu Oct 26 01:15:43 2006 +++ llvm/lib/AsmParser/ParserInternals.h Sun Nov 19 17:07:00 2006 @@ -217,4 +217,30 @@ typedef OpcodeInfo MemOpInfo; typedef OpcodeInfo OtherOpInfo; +/// This enumeration is used to indicate if a type is signed, signless or +/// unsigned. It is used for backwards compatibility with assembly code that +/// pre-dates the signless types conversion. +enum Signedness { + isSigned, + isUnsigned, + isSignless +}; + +/// This structure is used to keep track of the signedness of the obsolete +/// integer types. Instead of creating an llvm::Type directly, the Lexer will +/// create instances of TypeInfo which retains the signedness indication so +/// it can be used by the parser for upgrade decisions. +/// For example if "uint" is encountered then the type will be set "int32" +/// and the "signedness" will be "isUnsigned". If the type is not obsolete +/// then "signedness" will be "isSignless". +struct TypeInfo { + llvm::PATypeHolder *type; + Signedness signedness; +}; + +struct ValueInfo { + std::vector valuelist; + std::vector signlist; +}; + #endif Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.275 llvm/lib/AsmParser/llvmAsmParser.y:1.276 --- llvm/lib/AsmParser/llvmAsmParser.y:1.275 Sun Nov 12 05:10:39 2006 +++ llvm/lib/AsmParser/llvmAsmParser.y Sun Nov 19 17:07:00 2006 @@ -83,8 +83,8 @@ Module *CurrentModule; std::map Values; // Module level numbered definitions std::map LateResolveValues; - std::vector Types; - std::map LateResolveTypes; + std::vector Types; + std::map LateResolveTypes; /// PlaceHolderInfo - When temporary placeholder objects are created, remember /// how they were referenced and on which line of the input they came from so @@ -217,7 +217,7 @@ case ValID::NumberVal: // Is it a numbered definition? // Module constants occupy the lowest numbered slots... if ((unsigned)D.Num < CurModule.Types.size()) - return CurModule.Types[(unsigned)D.Num]; + return CurModule.Types[(unsigned)D.Num].type->get(); break; case ValID::NameVal: // Is it a named definition? if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) { @@ -247,13 +247,15 @@ } } - std::map::iterator I =CurModule.LateResolveTypes.find(D); + std::map::iterator I =CurModule.LateResolveTypes.find(D); if (I != CurModule.LateResolveTypes.end()) - return I->second; + return I->second.type->get(); - Type *Typ = OpaqueType::get(); - CurModule.LateResolveTypes.insert(std::make_pair(D, Typ)); - return Typ; + TypeInfo TI; + TI.type = new PATypeHolder(OpaqueType::get()); + TI.signedness = isSignless; + CurModule.LateResolveTypes.insert(std::make_pair(D, TI)); + return TI.type->get(); } static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) { @@ -557,10 +559,10 @@ if (Name) D = ValID::create(Name); else D = ValID::create((int)CurModule.Types.size()); - std::map::iterator I = + std::map::iterator I = CurModule.LateResolveTypes.find(D); if (I != CurModule.LateResolveTypes.end()) { - ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy); + ((DerivedType*)I->second.type->get())->refineAbstractTypeTo(ToTy); CurModule.LateResolveTypes.erase(I); } } @@ -822,14 +824,13 @@ /// instruction. This function handles converting div -> [usf]div appropriately. /// @brief Convert obsolete BinaryOps opcodes to new values static void -sanitizeOpCode(OpcodeInfo &OI, const PATypeHolder& PATy) +sanitizeOpCode(OpcodeInfo &OI, const Type *Ty) { // If its not obsolete, don't do anything if (!OI.obsolete) return; // If its a packed type we want to use the element type - const Type* Ty = PATy; if (const PackedType* PTy = dyn_cast(Ty)) Ty = PTy->getElementType(); @@ -860,13 +861,12 @@ /// operates on Instruction::OtherOps instead of Instruction::BinaryOps. /// @brief Convert obsolete OtherOps opcodes to new values static void -sanitizeOpCode(OpcodeInfo &OI, const PATypeHolder& PATy) +sanitizeOpCode(OpcodeInfo &OI, const Type *Ty) { // If its not obsolete, don't do anything if (!OI.obsolete) return; - const Type* Ty = PATy; // type conversion switch (OI.opcode) { default: GenerateError("Invalid obsolete opcode (check Lexer.l)"); @@ -1040,19 +1040,18 @@ %union { llvm::Module *ModuleVal; llvm::Function *FunctionVal; - std::pair *ArgVal; + std::pair *ArgVal; llvm::BasicBlock *BasicBlockVal; llvm::TerminatorInst *TermInstVal; llvm::Instruction *InstVal; llvm::Constant *ConstVal; - const llvm::Type *PrimType; - llvm::PATypeHolder *TypeVal; + TypeInfo TypeVal; llvm::Value *ValueVal; - std::vector > *ArgList; + std::vector >*ArgList; std::vector *ValueList; - std::list *TypeList; + std::list *TypeList; // Represent the RHS of PHI node std::list > *PHIList; @@ -1117,9 +1116,9 @@ // Built in types... %type Types TypesV UpRTypes UpRTypesV -%type SIntType UIntType IntType FPType PrimType // Classifications -%token VOID BOOL SBYTE UBYTE SHORT USHORT INT UINT LONG ULONG -%token FLOAT DOUBLE TYPE LABEL +%type SIntType UIntType IntType FPType PrimType // Classifications +%token VOID BOOL SBYTE UBYTE SHORT USHORT INT UINT LONG ULONG +%token FLOAT DOUBLE TYPE LABEL %token VAR_ID LABELSTR STRINGCONSTANT %type Name OptName OptAssign @@ -1279,15 +1278,22 @@ // // TypesV includes all of 'Types', but it also includes the void type. -TypesV : Types | VOID { $$ = new PATypeHolder($1); }; -UpRTypesV : UpRTypes | VOID { $$ = new PATypeHolder($1); }; +TypesV : Types | VOID { + $$.type = new PATypeHolder($1.type->get()); + $$.signedness = $1.signedness; +}; +UpRTypesV : UpRTypes | VOID { + $$.type = new PATypeHolder($1.type->get()); + $$.signedness = $1.signedness; +}; Types : UpRTypes { if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*$1)->getDescription()); + GEN_ERROR("Invalid upreference in type: " + + ($1.type->get())->getDescription()); $$ = $1; CHECK_FOR_ERROR - }; +}; // Derived types are added later... @@ -1295,17 +1301,19 @@ PrimType : BOOL | SBYTE | UBYTE | SHORT | USHORT | INT | UINT ; PrimType : LONG | ULONG | FLOAT | DOUBLE | TYPE | LABEL; UpRTypes : OPAQUE { - $$ = new PATypeHolder(OpaqueType::get()); + $$.type = new PATypeHolder(OpaqueType::get()); + $$.signedness = isSignless; CHECK_FOR_ERROR } | PrimType { - $$ = new PATypeHolder($1); + $$ = $1; CHECK_FOR_ERROR }; UpRTypes : SymbolicValueRef { // Named types are also simple types... const Type* tmp = getTypeVal($1); CHECK_FOR_ERROR - $$ = new PATypeHolder(tmp); + $$.type = new PATypeHolder(tmp); + $$.signedness = isSignless; }; // Include derived types in the Types production. @@ -1314,59 +1322,69 @@ if ($2 > (uint64_t)~0U) GEN_ERROR("Value out of range!"); OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder UpRefs.push_back(UpRefRecord((unsigned)$2, OT)); // Add to vector... - $$ = new PATypeHolder(OT); + $$.type = new PATypeHolder(OT); + $$.signedness = isSignless; UR_OUT("New Upreference!\n"); CHECK_FOR_ERROR } | UpRTypesV '(' ArgTypeListI ')' { // Function derived type? std::vector Params; - for (std::list::iterator I = $3->begin(), + for (std::list::iterator I = $3->begin(), E = $3->end(); I != E; ++I) - Params.push_back(*I); + Params.push_back(I->type->get()); bool isVarArg = Params.size() && Params.back() == Type::VoidTy; if (isVarArg) Params.pop_back(); - $$ = new PATypeHolder(HandleUpRefs(FunctionType::get(*$1,Params,isVarArg))); + $$.type = new PATypeHolder(HandleUpRefs( + FunctionType::get($1.type->get(),Params,isVarArg))); + $$.signedness = isSignless; delete $3; // Delete the argument list - delete $1; // Delete the return type handle + delete $1.type; CHECK_FOR_ERROR } | '[' EUINT64VAL 'x' UpRTypes ']' { // Sized array type? - $$ = new PATypeHolder(HandleUpRefs(ArrayType::get(*$4, (unsigned)$2))); - delete $4; + $$.type = new PATypeHolder(HandleUpRefs( + ArrayType::get($4.type->get(), (unsigned)$2))); + $$.signedness = isSignless; + delete $4.type; CHECK_FOR_ERROR } | '<' EUINT64VAL 'x' UpRTypes '>' { // Packed array type? - const llvm::Type* ElemTy = $4->get(); - if ((unsigned)$2 != $2) - GEN_ERROR("Unsigned result not equal to signed result"); - if (!ElemTy->isPrimitiveType()) - GEN_ERROR("Elemental type of a PackedType must be primitive"); - if (!isPowerOf2_32($2)) - GEN_ERROR("Vector length should be a power of 2!"); - $$ = new PATypeHolder(HandleUpRefs(PackedType::get(*$4, (unsigned)$2))); - delete $4; - CHECK_FOR_ERROR + const llvm::Type* ElemTy = $4.type->get(); + if ((unsigned)$2 != $2) + GEN_ERROR("Unsigned result not equal to signed result"); + if (!ElemTy->isPrimitiveType()) + GEN_ERROR("Elemental type of a PackedType must be primitive"); + if (!isPowerOf2_32($2)) + GEN_ERROR("Vector length should be a power of 2!"); + $$.type = new PATypeHolder(HandleUpRefs( + PackedType::get($4.type->get(), (unsigned)$2))); + $$.signedness = isSignless; + delete $4.type; + CHECK_FOR_ERROR } | '{' TypeListI '}' { // Structure type? std::vector Elements; - for (std::list::iterator I = $2->begin(), + for (std::list::iterator I = $2->begin(), E = $2->end(); I != E; ++I) - Elements.push_back(*I); + Elements.push_back(I->type->get()); - $$ = new PATypeHolder(HandleUpRefs(StructType::get(Elements))); + $$.type = new PATypeHolder(HandleUpRefs(StructType::get(Elements))); + $$.signedness = isSignless; delete $2; CHECK_FOR_ERROR } | '{' '}' { // Empty structure type? - $$ = new PATypeHolder(StructType::get(std::vector())); + $$.type = new PATypeHolder(StructType::get(std::vector())); + $$.signedness = isSignless; CHECK_FOR_ERROR } | UpRTypes '*' { // Pointer type? - if (*$1 == Type::LabelTy) + if ($1.type->get() == Type::LabelTy) GEN_ERROR("Cannot form a pointer to a basic block"); - $$ = new PATypeHolder(HandleUpRefs(PointerType::get(*$1))); - delete $1; + $$.type = new PATypeHolder(HandleUpRefs(PointerType::get($1.type->get()))); + $$.signedness = $1.signedness; + delete $1.type; CHECK_FOR_ERROR }; @@ -1374,27 +1392,31 @@ // declaration type lists // TypeListI : UpRTypes { - $$ = new std::list(); - $$->push_back(*$1); delete $1; + $$ = new std::list(); + $$->push_back($1); CHECK_FOR_ERROR } | TypeListI ',' UpRTypes { - ($$=$1)->push_back(*$3); delete $3; + ($$=$1)->push_back($3); CHECK_FOR_ERROR }; // ArgTypeList - List of types for a function type declaration... ArgTypeListI : TypeListI | TypeListI ',' DOTDOTDOT { - ($$=$1)->push_back(Type::VoidTy); + TypeInfo TI; + TI.type = new PATypeHolder(Type::VoidTy); TI.signedness = isSignless; + ($$=$1)->push_back(TI); CHECK_FOR_ERROR } | DOTDOTDOT { - ($$ = new std::list())->push_back(Type::VoidTy); + TypeInfo TI; + TI.type = new PATypeHolder(Type::VoidTy); TI.signedness = isSignless; + ($$ = new std::list())->push_back(TI); CHECK_FOR_ERROR } | /*empty*/ { - $$ = new std::list(); + $$ = new std::list(); CHECK_FOR_ERROR }; @@ -1405,10 +1427,10 @@ // ResolvedVal, ValueRef and ConstValueRef productions. // ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr - const ArrayType *ATy = dyn_cast($1->get()); + const ArrayType *ATy = dyn_cast($1.type->get()); if (ATy == 0) GEN_ERROR("Cannot make array constant with type: '" + - (*$1)->getDescription() + "'!"); + ($1.type->get())->getDescription() + "'!"); const Type *ETy = ATy->getElementType(); int NumElements = ATy->getNumElements(); @@ -1427,28 +1449,28 @@ } $$ = ConstantArray::get(ATy, *$3); - delete $1; delete $3; + delete $1.type; delete $3; CHECK_FOR_ERROR } | Types '[' ']' { - const ArrayType *ATy = dyn_cast($1->get()); + const ArrayType *ATy = dyn_cast($1.type->get()); if (ATy == 0) GEN_ERROR("Cannot make array constant with type: '" + - (*$1)->getDescription() + "'!"); + ($1.type->get())->getDescription() + "'!"); int NumElements = ATy->getNumElements(); if (NumElements != -1 && NumElements != 0) GEN_ERROR("Type mismatch: constant sized array initialized with 0" " arguments, but has size of " + itostr(NumElements) +"!"); $$ = ConstantArray::get(ATy, std::vector()); - delete $1; + delete $1.type; CHECK_FOR_ERROR } | Types 'c' STRINGCONSTANT { - const ArrayType *ATy = dyn_cast($1->get()); + const ArrayType *ATy = dyn_cast($1.type->get()); if (ATy == 0) GEN_ERROR("Cannot make array constant with type: '" + - (*$1)->getDescription() + "'!"); + ($1.type->get())->getDescription() + "'!"); int NumElements = ATy->getNumElements(); const Type *ETy = ATy->getElementType(); @@ -1471,14 +1493,14 @@ } free($3); $$ = ConstantArray::get(ATy, Vals); - delete $1; + delete $1.type; CHECK_FOR_ERROR } | Types '<' ConstVector '>' { // Nonempty unsized arr - const PackedType *PTy = dyn_cast($1->get()); + const PackedType *PTy = dyn_cast($1.type->get()); if (PTy == 0) GEN_ERROR("Cannot make packed constant with type: '" + - (*$1)->getDescription() + "'!"); + $1.type->get()->getDescription() + "'!"); const Type *ETy = PTy->getElementType(); int NumElements = PTy->getNumElements(); @@ -1497,14 +1519,14 @@ } $$ = ConstantPacked::get(PTy, *$3); - delete $1; delete $3; + delete $1.type; delete $3; CHECK_FOR_ERROR } | Types '{' ConstVector '}' { - const StructType *STy = dyn_cast($1->get()); + const StructType *STy = dyn_cast($1.type->get()); if (STy == 0) GEN_ERROR("Cannot make struct constant with type: '" + - (*$1)->getDescription() + "'!"); + $1.type->get()->getDescription() + "'!"); if ($3->size() != STy->getNumContainedTypes()) GEN_ERROR("Illegal number of initializers for structure type!"); @@ -1518,39 +1540,39 @@ " of structure initializer!"); $$ = ConstantStruct::get(STy, *$3); - delete $1; delete $3; + delete $1.type; delete $3; CHECK_FOR_ERROR } | Types '{' '}' { - const StructType *STy = dyn_cast($1->get()); + const StructType *STy = dyn_cast($1.type->get()); if (STy == 0) GEN_ERROR("Cannot make struct constant with type: '" + - (*$1)->getDescription() + "'!"); + $1.type->get()->getDescription() + "'!"); if (STy->getNumContainedTypes() != 0) GEN_ERROR("Illegal number of initializers for structure type!"); $$ = ConstantStruct::get(STy, std::vector()); - delete $1; + delete $1.type; CHECK_FOR_ERROR } | Types NULL_TOK { - const PointerType *PTy = dyn_cast($1->get()); + const PointerType *PTy = dyn_cast($1.type->get()); if (PTy == 0) GEN_ERROR("Cannot make null pointer constant with type: '" + - (*$1)->getDescription() + "'!"); + $1.type->get()->getDescription() + "'!"); $$ = ConstantPointerNull::get(PTy); - delete $1; + delete $1.type; CHECK_FOR_ERROR } | Types UNDEF { - $$ = UndefValue::get($1->get()); - delete $1; + $$ = UndefValue::get($1.type->get()); + delete $1.type; CHECK_FOR_ERROR } | Types SymbolicValueRef { - const PointerType *Ty = dyn_cast($1->get()); + const PointerType *Ty = dyn_cast($1.type->get()); if (Ty == 0) GEN_ERROR("Global const reference must be a pointer type!"); @@ -1607,35 +1629,35 @@ } $$ = cast(V); - delete $1; // Free the type handle + delete $1.type; // Free the type handle CHECK_FOR_ERROR } | Types ConstExpr { - if ($1->get() != $2->getType()) + if ($1.type->get() != $2->getType()) GEN_ERROR("Mismatched types for constant expression!"); $$ = $2; - delete $1; + delete $1.type; CHECK_FOR_ERROR } | Types ZEROINITIALIZER { - const Type *Ty = $1->get(); + const Type *Ty = $1.type->get(); if (isa(Ty) || Ty == Type::LabelTy || isa(Ty)) GEN_ERROR("Cannot create a null initialized value of this type!"); $$ = Constant::getNullValue(Ty); - delete $1; + delete $1.type; CHECK_FOR_ERROR }; ConstVal : SIntType EINT64VAL { // integral constants - if (!ConstantInt::isValueValidForType($1, $2)) + if (!ConstantInt::isValueValidForType($1.type->get(), $2)) GEN_ERROR("Constant value doesn't fit in type!"); - $$ = ConstantInt::get($1, $2); + $$ = ConstantInt::get($1.type->get(), $2); CHECK_FOR_ERROR } | UIntType EUINT64VAL { // integral constants - if (!ConstantInt::isValueValidForType($1, $2)) + if (!ConstantInt::isValueValidForType($1.type->get(), $2)) GEN_ERROR("Constant value doesn't fit in type!"); - $$ = ConstantInt::get($1, $2); + $$ = ConstantInt::get($1.type->get(), $2); CHECK_FOR_ERROR } | BOOL TRUETOK { // Boolean constants @@ -1647,9 +1669,9 @@ CHECK_FOR_ERROR } | FPType FPVAL { // Float & Double constants - if (!ConstantFP::isValueValidForType($1, $2)) + if (!ConstantFP::isValueValidForType($1.type->get(), $2)) GEN_ERROR("Floating point constant invalid for type!!"); - $$ = ConstantFP::get($1, $2); + $$ = ConstantFP::get($1.type->get(), $2); CHECK_FOR_ERROR }; @@ -1658,11 +1680,11 @@ if (!$3->getType()->isFirstClassType()) GEN_ERROR("cast constant expression from a non-primitive type: '" + $3->getType()->getDescription() + "'!"); - if (!$5->get()->isFirstClassType()) + if (!$5.type->get()->isFirstClassType()) GEN_ERROR("cast constant expression to a non-primitive type: '" + - $5->get()->getDescription() + "'!"); - $$ = ConstantExpr::getCast($3, $5->get()); - delete $5; + $5.type->get()->getDescription() + "'!"); + $$ = ConstantExpr::getCast($3, $5.type->get()); + delete $5.type; CHECK_FOR_ERROR } | GETELEMENTPTR '(' ConstVal IndexList ')' { @@ -1853,16 +1875,16 @@ // If types are not resolved eagerly, then the two types will not be // determined to be the same type! // - ResolveTypeTo($2, *$4); + ResolveTypeTo($2, $4.type->get()); - if (!setTypeName(*$4, $2) && !$2) { + if (!setTypeName($4.type->get(), $2) && !$2) { CHECK_FOR_ERROR // If this is a named type that is not a redefinition, add it to the slot // table. - CurModule.Types.push_back(*$4); + CurModule.Types.push_back($4); + } else { + delete $4.type; } - - delete $4; CHECK_FOR_ERROR } | ConstPool FunctionProto { // Function prototypes can be in const pool @@ -1880,26 +1902,29 @@ CurGV = 0; } | ConstPool OptAssign EXTERNAL GlobalType Types { - CurGV = ParseGlobalVariable($2, GlobalValue::ExternalLinkage, $4, *$5, 0); + CurGV = ParseGlobalVariable($2, GlobalValue::ExternalLinkage, $4, + $5.type->get(), 0); CHECK_FOR_ERROR - delete $5; + delete $5.type; } GlobalVarAttributes { CurGV = 0; CHECK_FOR_ERROR } | ConstPool OptAssign DLLIMPORT GlobalType Types { - CurGV = ParseGlobalVariable($2, GlobalValue::DLLImportLinkage, $4, *$5, 0); + CurGV = ParseGlobalVariable($2, GlobalValue::DLLImportLinkage, $4, + $5.type->get(), 0); CHECK_FOR_ERROR - delete $5; + delete $5.type; } GlobalVarAttributes { CurGV = 0; CHECK_FOR_ERROR } | ConstPool OptAssign EXTERN_WEAK GlobalType Types { CurGV = - ParseGlobalVariable($2, GlobalValue::ExternalWeakLinkage, $4, *$5, 0); + ParseGlobalVariable($2, GlobalValue::ExternalWeakLinkage, $4, + $5.type->get(), 0); CHECK_FOR_ERROR - delete $5; + delete $5.type; } GlobalVarAttributes { CurGV = 0; CHECK_FOR_ERROR @@ -1977,9 +2002,9 @@ OptName : Name | /*empty*/ { $$ = 0; }; ArgVal : Types OptName { - if (*$1 == Type::VoidTy) + if ($1.type->get() == Type::VoidTy) GEN_ERROR("void typed arguments are invalid!"); - $$ = new std::pair($1, $2); + $$ = new std::pair($1, $2); CHECK_FOR_ERROR }; @@ -1990,7 +2015,7 @@ CHECK_FOR_ERROR } | ArgVal { - $$ = new std::vector >(); + $$ = new std::vector >(); $$->push_back(*$1); delete $1; CHECK_FOR_ERROR @@ -2002,13 +2027,18 @@ } | ArgListH ',' DOTDOTDOT { $$ = $1; - $$->push_back(std::pair(new PATypeHolder(Type::VoidTy), 0)); + TypeInfo TI; + TI.type = new PATypeHolder(Type::VoidTy); + TI.signedness = isSignless; + $$->push_back(std::pair(TI,(char*)0)); CHECK_FOR_ERROR } | DOTDOTDOT { - $$ = new std::vector >(); - $$->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0)); + $$ = new std::vector >(); + TypeInfo TI; + TI.type = new PATypeHolder(Type::VoidTy); + TI.signedness = isSignless; + $$->push_back(std::make_pair(TI, (char*)0)); CHECK_FOR_ERROR } | /* empty */ { @@ -2022,22 +2052,23 @@ std::string FunctionName($3); free($3); // Free strdup'd memory! - if (!(*$2)->isFirstClassType() && *$2 != Type::VoidTy) + if (!($2.type->get())->isFirstClassType() && $2.type->get() != Type::VoidTy) GEN_ERROR("LLVM functions cannot return aggregate types!"); std::vector ParamTypeList; if ($5) { // If there are arguments... - for (std::vector >::iterator I = $5->begin(); + for (std::vector >::iterator I = $5->begin(); I != $5->end(); ++I) - ParamTypeList.push_back(I->first->get()); + ParamTypeList.push_back(I->first.type->get()); } bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy; if (isVarArg) ParamTypeList.pop_back(); - const FunctionType *FT = FunctionType::get(*$2, ParamTypeList, isVarArg); + const FunctionType *FT = FunctionType::get($2.type->get(), ParamTypeList, + isVarArg); const PointerType *PFT = PointerType::get(FT); - delete $2; + delete $2.type; ValID ID; if (!FunctionName.empty()) { @@ -2091,21 +2122,19 @@ // Add all of the arguments we parsed to the function... if ($5) { // Is null if empty... if (isVarArg) { // Nuke the last entry - assert($5->back().first->get() == Type::VoidTy && $5->back().second == 0&& - "Not a varargs marker!"); - delete $5->back().first; + assert($5->back().first.type->get() == Type::VoidTy && + $5->back().second == 0 && "Not a varargs marker!"); + delete $5->back().first.type; $5->pop_back(); // Delete the last entry } Function::arg_iterator ArgIt = Fn->arg_begin(); - for (std::vector >::iterator I = $5->begin(); + for (std::vector >::iterator I = $5->begin(); I != $5->end(); ++I, ++ArgIt) { - delete I->first; // Delete the typeholder... - + delete I->first.type; // Delete the typeholder... setValueName(ArgIt, I->second); // Insert arg into symtab... CHECK_FOR_ERROR InsertValue(ArgIt); } - delete $5; // We're now done with the argument list } CHECK_FOR_ERROR @@ -2189,12 +2218,7 @@ PackedType* pt = PackedType::get(ETy, NumElements); PATypeHolder* PTy = new PATypeHolder( - HandleUpRefs( - PackedType::get( - ETy, - NumElements) - ) - ); + HandleUpRefs(PackedType::get( ETy, NumElements))); // Verify all elements are correct type! for (unsigned i = 0; i < $2->size(); i++) { @@ -2243,7 +2267,7 @@ // type immediately preceeds the value reference, and allows complex constant // pool references (for things like: 'ret [2 x int] [ int 12, int 42]') ResolvedVal : Types ValueRef { - $$ = getVal(*$1, $2); delete $1; + $$ = getVal($1.type->get(), $2); delete $1.type; CHECK_FOR_ERROR }; @@ -2324,7 +2348,7 @@ $$ = new BranchInst(tmpBBA, tmpBBB, tmpVal); } | SWITCH IntType ValueRef ',' LABEL ValueRef '[' JumpTable ']' { - Value* tmpVal = getVal($2, $3); + Value* tmpVal = getVal($2.type->get(), $3); CHECK_FOR_ERROR BasicBlock* tmpBB = getBBVal($6); CHECK_FOR_ERROR @@ -2343,7 +2367,7 @@ CHECK_FOR_ERROR } | SWITCH IntType ValueRef ',' LABEL ValueRef '[' ']' { - Value* tmpVal = getVal($2, $3); + Value* tmpVal = getVal($2.type->get(), $3); CHECK_FOR_ERROR BasicBlock* tmpBB = getBBVal($6); CHECK_FOR_ERROR @@ -2356,7 +2380,7 @@ const PointerType *PFTy; const FunctionType *Ty; - if (!(PFTy = dyn_cast($3->get())) || + if (!(PFTy = dyn_cast($3.type->get())) || !(Ty = dyn_cast(PFTy->getElementType()))) { // Pull out the types of all of the arguments... std::vector ParamTypes; @@ -2369,7 +2393,7 @@ bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; if (isVarArg) ParamTypes.pop_back(); - Ty = FunctionType::get($3->get(), ParamTypes, isVarArg); + Ty = FunctionType::get($3.type->get(), ParamTypes, isVarArg); PFTy = PointerType::get(Ty); } @@ -2403,7 +2427,7 @@ } cast($$)->setCallingConv($2); - delete $3; + delete $3.type; delete $6; CHECK_FOR_ERROR } @@ -2420,7 +2444,7 @@ JumpTable : JumpTable IntType ConstValueRef ',' LABEL ValueRef { $$ = $1; - Constant *V = cast(getValNonImprovising($2, $3)); + Constant *V = cast(getValNonImprovising($2.type->get(), $3)); CHECK_FOR_ERROR if (V == 0) GEN_ERROR("May only switch on a constant pool value!"); @@ -2431,7 +2455,7 @@ } | IntType ConstValueRef ',' LABEL ValueRef { $$ = new std::vector >(); - Constant *V = cast(getValNonImprovising($1, $2)); + Constant *V = cast(getValNonImprovising($1.type->get(), $2)); CHECK_FOR_ERROR if (V == 0) @@ -2453,12 +2477,12 @@ PHIList : Types '[' ValueRef ',' ValueRef ']' { // Used for PHI nodes $$ = new std::list >(); - Value* tmpVal = getVal(*$1, $3); + Value* tmpVal = getVal($1.type->get(), $3); CHECK_FOR_ERROR BasicBlock* tmpBB = getBBVal($5); CHECK_FOR_ERROR $$->push_back(std::make_pair(tmpVal, tmpBB)); - delete $1; + delete $1.type; } | PHIList ',' '[' ValueRef ',' ValueRef ']' { $$ = $1; @@ -2493,55 +2517,55 @@ }; InstVal : ArithmeticOps Types ValueRef ',' ValueRef { - if (!(*$2)->isInteger() && !(*$2)->isFloatingPoint() && - !isa((*$2).get())) + if (!$2.type->get()->isInteger() && !$2.type->get()->isFloatingPoint() && + !isa($2.type->get())) GEN_ERROR( "Arithmetic operator requires integer, FP, or packed operands!"); - if (isa((*$2).get()) && + if (isa($2.type->get()) && ($1.opcode == Instruction::URem || $1.opcode == Instruction::SRem || $1.opcode == Instruction::FRem)) GEN_ERROR("U/S/FRem not supported on packed types!"); // Upgrade the opcode from obsolete versions before we do anything with it. - sanitizeOpCode($1,*$2); + sanitizeOpCode($1,$2.type->get()); CHECK_FOR_ERROR; - Value* val1 = getVal(*$2, $3); + Value* val1 = getVal($2.type->get(), $3); CHECK_FOR_ERROR - Value* val2 = getVal(*$2, $5); + Value* val2 = getVal($2.type->get(), $5); CHECK_FOR_ERROR $$ = BinaryOperator::create($1.opcode, val1, val2); if ($$ == 0) GEN_ERROR("binary operator returned null!"); - delete $2; + delete $2.type; } | LogicalOps Types ValueRef ',' ValueRef { - if (!(*$2)->isIntegral()) { - if (!isa($2->get()) || - !cast($2->get())->getElementType()->isIntegral()) + if (!$2.type->get()->isIntegral()) { + if (!isa($2.type->get()) || + !cast($2.type->get())->getElementType()->isIntegral()) GEN_ERROR("Logical operator requires integral operands!"); } - Value* tmpVal1 = getVal(*$2, $3); + Value* tmpVal1 = getVal($2.type->get(), $3); CHECK_FOR_ERROR - Value* tmpVal2 = getVal(*$2, $5); + Value* tmpVal2 = getVal($2.type->get(), $5); CHECK_FOR_ERROR $$ = BinaryOperator::create($1.opcode, tmpVal1, tmpVal2); if ($$ == 0) GEN_ERROR("binary operator returned null!"); - delete $2; + delete $2.type; } | SetCondOps Types ValueRef ',' ValueRef { - if(isa((*$2).get())) { + if(isa($2.type->get())) { GEN_ERROR( "PackedTypes currently not supported in setcc instructions!"); } - Value* tmpVal1 = getVal(*$2, $3); + Value* tmpVal1 = getVal($2.type->get(), $3); CHECK_FOR_ERROR - Value* tmpVal2 = getVal(*$2, $5); + Value* tmpVal2 = getVal($2.type->get(), $5); CHECK_FOR_ERROR $$ = new SetCondInst($1.opcode, tmpVal1, tmpVal2); if ($$ == 0) GEN_ERROR("binary operator returned null!"); - delete $2; + delete $2.type; } | NOT ResolvedVal { std::cerr << "WARNING: Use of eliminated 'not' instruction:" @@ -2568,11 +2592,11 @@ CHECK_FOR_ERROR } | CAST ResolvedVal TO Types { - if (!$4->get()->isFirstClassType()) + if (!$4.type->get()->isFirstClassType()) GEN_ERROR("cast instruction to a non-primitive type: '" + - $4->get()->getDescription() + "'!"); - $$ = new CastInst($2, *$4); - delete $4; + $4.type->get()->getDescription() + "'!"); + $$ = new CastInst($2, $4.type->get()); + delete $4.type; CHECK_FOR_ERROR } | SELECT ResolvedVal ',' ResolvedVal ',' ResolvedVal { @@ -2585,8 +2609,8 @@ } | VAARG ResolvedVal ',' Types { NewVarArgs = true; - $$ = new VAArgInst($2, *$4); - delete $4; + $$ = new VAArgInst($2, $4.type->get()); + delete $4.type; CHECK_FOR_ERROR } | VAARG_old ResolvedVal ',' Types { @@ -2605,8 +2629,8 @@ CallInst* bar = new CallInst(NF, $2); CurBB->getInstList().push_back(bar); CurBB->getInstList().push_back(new StoreInst(bar, foo)); - $$ = new VAArgInst(foo, *$4); - delete $4; + $$ = new VAArgInst(foo, $4.type->get()); + delete $4.type; CHECK_FOR_ERROR } | VANEXT_old ResolvedVal ',' Types { @@ -2626,10 +2650,10 @@ CallInst* bar = new CallInst(NF, $2); CurBB->getInstList().push_back(bar); CurBB->getInstList().push_back(new StoreInst(bar, foo)); - Instruction* tmp = new VAArgInst(foo, *$4); + Instruction* tmp = new VAArgInst(foo, $4.type->get()); CurBB->getInstList().push_back(tmp); $$ = new LoadInst(foo); - delete $4; + delete $4.type; CHECK_FOR_ERROR } | EXTRACTELEMENT ResolvedVal ',' ResolvedVal { @@ -2669,7 +2693,7 @@ const PointerType *PFTy = 0; const FunctionType *Ty = 0; - if (!(PFTy = dyn_cast($3->get())) || + if (!(PFTy = dyn_cast($3.type->get())) || !(Ty = dyn_cast(PFTy->getElementType()))) { // Pull out the types of all of the arguments... std::vector ParamTypes; @@ -2682,10 +2706,11 @@ bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; if (isVarArg) ParamTypes.pop_back(); - if (!(*$3)->isFirstClassType() && *$3 != Type::VoidTy) + if (!$3.type->get()->isFirstClassType() && + $3.type->get() != Type::VoidTy) GEN_ERROR("LLVM functions cannot return aggregate types!"); - Ty = FunctionType::get($3->get(), ParamTypes, isVarArg); + Ty = FunctionType::get($3.type->get(), ParamTypes, isVarArg); PFTy = PointerType::get(Ty); } @@ -2720,7 +2745,7 @@ } cast($$)->setTailCall($1); cast($$)->setCallingConv($2); - delete $3; + delete $3.type; delete $6; CHECK_FOR_ERROR } @@ -2751,26 +2776,26 @@ MemoryInst : MALLOC Types OptCAlign { - $$ = new MallocInst(*$2, 0, $3); - delete $2; + $$ = new MallocInst($2.type->get(), 0, $3); + delete $2.type; CHECK_FOR_ERROR } | MALLOC Types ',' UINT ValueRef OptCAlign { - Value* tmpVal = getVal($4, $5); + Value* tmpVal = getVal($4.type->get(), $5); CHECK_FOR_ERROR - $$ = new MallocInst(*$2, tmpVal, $6); - delete $2; + $$ = new MallocInst($2.type->get(), tmpVal, $6); + delete $2.type; } | ALLOCA Types OptCAlign { - $$ = new AllocaInst(*$2, 0, $3); - delete $2; + $$ = new AllocaInst($2.type->get(), 0, $3); + delete $2.type; CHECK_FOR_ERROR } | ALLOCA Types ',' UINT ValueRef OptCAlign { - Value* tmpVal = getVal($4, $5); + Value* tmpVal = getVal($4.type->get(), $5); CHECK_FOR_ERROR - $$ = new AllocaInst(*$2, tmpVal, $6); - delete $2; + $$ = new AllocaInst($2.type->get(), tmpVal, $6); + delete $2.type; } | FREE ResolvedVal { if (!isa($2->getType())) @@ -2781,54 +2806,54 @@ } | OptVolatile LOAD Types ValueRef { - if (!isa($3->get())) + if (!isa($3.type->get())) GEN_ERROR("Can't load from nonpointer type: " + - (*$3)->getDescription()); - if (!cast($3->get())->getElementType()->isFirstClassType()) + $3.type->get()->getDescription()); + if (!cast($3.type->get())->getElementType()->isFirstClassType()) GEN_ERROR("Can't load from pointer of non-first-class type: " + - (*$3)->getDescription()); - Value* tmpVal = getVal(*$3, $4); + $3.type->get()->getDescription()); + Value* tmpVal = getVal($3.type->get(), $4); CHECK_FOR_ERROR $$ = new LoadInst(tmpVal, "", $1); - delete $3; + delete $3.type; } | OptVolatile STORE ResolvedVal ',' Types ValueRef { - const PointerType *PT = dyn_cast($5->get()); + const PointerType *PT = dyn_cast($5.type->get()); if (!PT) GEN_ERROR("Can't store to a nonpointer type: " + - (*$5)->getDescription()); + ($5.type->get())->getDescription()); const Type *ElTy = PT->getElementType(); if (ElTy != $3->getType()) GEN_ERROR("Can't store '" + $3->getType()->getDescription() + "' into space of type '" + ElTy->getDescription() + "'!"); - Value* tmpVal = getVal(*$5, $6); + Value* tmpVal = getVal($5.type->get(), $6); CHECK_FOR_ERROR $$ = new StoreInst($3, tmpVal, $1); - delete $5; + delete $5.type; } | GETELEMENTPTR Types ValueRef IndexList { - if (!isa($2->get())) + if (!isa($2.type->get())) GEN_ERROR("getelementptr insn requires pointer operand!"); // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct // indices to uint struct indices for compatibility. generic_gep_type_iterator::iterator> - GTI = gep_type_begin($2->get(), $4->begin(), $4->end()), - GTE = gep_type_end($2->get(), $4->begin(), $4->end()); + GTI = gep_type_begin($2.type->get(), $4->begin(), $4->end()), + GTE = gep_type_end($2.type->get(), $4->begin(), $4->end()); for (unsigned i = 0, e = $4->size(); i != e && GTI != GTE; ++i, ++GTI) if (isa(*GTI)) // Only change struct indices if (ConstantInt *CUI = dyn_cast((*$4)[i])) if (CUI->getType() == Type::UByteTy) (*$4)[i] = ConstantExpr::getCast(CUI, Type::UIntTy); - if (!GetElementPtrInst::getIndexedType(*$2, *$4, true)) + if (!GetElementPtrInst::getIndexedType($2.type->get(), *$4, true)) GEN_ERROR("Invalid getelementptr indices for type '" + - (*$2)->getDescription()+ "'!"); - Value* tmpVal = getVal(*$2, $3); + $2.type->get()->getDescription()+ "'!"); + Value* tmpVal = getVal($2.type->get(), $3); CHECK_FOR_ERROR $$ = new GetElementPtrInst(tmpVal, *$4); - delete $2; + delete $2.type; delete $4; }; From reid at x10sys.com Sun Nov 19 19:22:53 2006 From: reid at x10sys.com (Reid Spencer) Date: Sun, 19 Nov 2006 19:22:53 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Support/InstVisitor.h Message-ID: <200611200122.kAK1Mr0c012777@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Support: InstVisitor.h updated: 1.41 -> 1.42 --- Log message: For PR950: http://llvm.org/PR950 : First in a series of patches to convert SetCondInst into ICmpInst and FCmpInst using only two opcodes and having the instructions contain their predicate value. Nothing uses these classes yet. More patches to follow. --- Diffs of the changes: (+3 -0) InstVisitor.h | 3 +++ 1 files changed, 3 insertions(+) Index: llvm/include/llvm/Support/InstVisitor.h diff -u llvm/include/llvm/Support/InstVisitor.h:1.41 llvm/include/llvm/Support/InstVisitor.h:1.42 --- llvm/include/llvm/Support/InstVisitor.h:1.41 Mon Oct 9 13:33:08 2006 +++ llvm/include/llvm/Support/InstVisitor.h Sun Nov 19 19:22:35 2006 @@ -169,6 +169,8 @@ RetTy visitUnwindInst(UnwindInst &I) { DELEGATE(TerminatorInst);} RetTy visitUnreachableInst(UnreachableInst &I) { DELEGATE(TerminatorInst);} RetTy visitSetCondInst(SetCondInst &I) { DELEGATE(BinaryOperator);} + RetTy visitICmpInst(ICmpInst &I) { DELEGATE(CmpInst);} + RetTy visitFCmpInst(FCmpInst &I) { DELEGATE(CmpInst);} RetTy visitMallocInst(MallocInst &I) { DELEGATE(AllocationInst);} RetTy visitAllocaInst(AllocaInst &I) { DELEGATE(AllocationInst);} RetTy visitFreeInst(FreeInst &I) { DELEGATE(Instruction); } @@ -192,6 +194,7 @@ RetTy visitTerminatorInst(TerminatorInst &I) { DELEGATE(Instruction); } RetTy visitBinaryOperator(BinaryOperator &I) { DELEGATE(Instruction); } RetTy visitAllocationInst(AllocationInst &I) { DELEGATE(Instruction); } + RetTy visitCmpInst(CmpInst &I) { DELEGATE(Instruction); } // If the user wants a 'default' case, they can choose to override this // function. If this function is not overloaded in the users subclass, then From reid at x10sys.com Sun Nov 19 19:22:56 2006 From: reid at x10sys.com (Reid Spencer) Date: Sun, 19 Nov 2006 19:22:56 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Instruction.cpp Instructions.cpp Verifier.cpp Message-ID: <200611200122.kAK1MtpG012786@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Instruction.cpp updated: 1.57 -> 1.58 Instructions.cpp updated: 1.46 -> 1.47 Verifier.cpp updated: 1.165 -> 1.166 --- Log message: For PR950: http://llvm.org/PR950 : First in a series of patches to convert SetCondInst into ICmpInst and FCmpInst using only two opcodes and having the instructions contain their predicate value. Nothing uses these classes yet. More patches to follow. --- Diffs of the changes: (+226 -1) Instruction.cpp | 2 Instructions.cpp | 196 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ Verifier.cpp | 29 ++++++++ 3 files changed, 226 insertions(+), 1 deletion(-) Index: llvm/lib/VMCore/Instruction.cpp diff -u llvm/lib/VMCore/Instruction.cpp:1.57 llvm/lib/VMCore/Instruction.cpp:1.58 --- llvm/lib/VMCore/Instruction.cpp:1.57 Wed Nov 8 00:47:33 2006 +++ llvm/lib/VMCore/Instruction.cpp Sun Nov 19 19:22:35 2006 @@ -11,10 +11,10 @@ // //===----------------------------------------------------------------------===// +#include "llvm/Type.h" #include "llvm/Instructions.h" #include "llvm/Function.h" #include "llvm/SymbolTable.h" -#include "llvm/Type.h" #include "llvm/Support/LeakDetector.h" using namespace llvm; Index: llvm/lib/VMCore/Instructions.cpp diff -u llvm/lib/VMCore/Instructions.cpp:1.46 llvm/lib/VMCore/Instructions.cpp:1.47 --- llvm/lib/VMCore/Instructions.cpp:1.46 Wed Nov 8 00:47:33 2006 +++ llvm/lib/VMCore/Instructions.cpp Sun Nov 19 19:22:35 2006 @@ -1290,6 +1290,197 @@ } } + +//===----------------------------------------------------------------------===// +// CmpInst Classes +//===----------------------------------------------------------------------===// + +CmpInst::CmpInst(OtherOps op, unsigned short predicate, Value *LHS, Value *RHS, + const std::string &Name, Instruction *InsertBefore) + : Instruction(Type::BoolTy, op, Ops, 2, Name, InsertBefore) { + Ops[0].init(LHS, this); + Ops[1].init(RHS, this); + SubclassData = predicate; + if (op == Instruction::ICmp) { + assert(predicate >= ICmpInst::FIRST_ICMP_PREDICATE && + predicate <= ICmpInst::LAST_ICMP_PREDICATE && + "Invalid ICmp predicate value"); + const Type* Op0Ty = getOperand(0)->getType(); + const Type* Op1Ty = getOperand(1)->getType(); + assert(Op0Ty == Op1Ty && + "Both operands to ICmp instruction are not of the same type!"); + // Check that the operands are the right type + assert(Op0Ty->isIntegral() || Op0Ty->getTypeID() == Type::PointerTyID || + (isa(Op0Ty) && + cast(Op0Ty)->getElementType()->isIntegral()) && + "Invalid operand types for ICmp instruction"); + return; + } + assert(op == Instruction::FCmp && "Invalid CmpInst opcode"); + assert(predicate <= FCmpInst::LAST_FCMP_PREDICATE && + "Invalid FCmp predicate value"); + const Type* Op0Ty = getOperand(0)->getType(); + const Type* Op1Ty = getOperand(1)->getType(); + assert(Op0Ty == Op1Ty && + "Both operands to FCmp instruction are not of the same type!"); + // Check that the operands are the right type + assert(Op0Ty->isFloatingPoint() || (isa(Op0Ty) && + cast(Op0Ty)->getElementType()->isFloatingPoint()) && + "Invalid operand types for FCmp instruction"); +} + +CmpInst::CmpInst(OtherOps op, unsigned short predicate, Value *LHS, Value *RHS, + const std::string &Name, BasicBlock *InsertAtEnd) + : Instruction(Type::BoolTy, op, Ops, 2, Name, InsertAtEnd) { + Ops[0].init(LHS, this); + Ops[1].init(RHS, this); + SubclassData = predicate; + if (op == Instruction::ICmp) { + assert(predicate >= ICmpInst::FIRST_ICMP_PREDICATE && + predicate <= ICmpInst::LAST_ICMP_PREDICATE && + "Invalid ICmp predicate value"); + + const Type* Op0Ty = getOperand(0)->getType(); + const Type* Op1Ty = getOperand(1)->getType(); + assert(Op0Ty == Op1Ty && + "Both operands to ICmp instruction are not of the same type!"); + // Check that the operands are the right type + assert(Op0Ty->isIntegral() || Op0Ty->getTypeID() == Type::PointerTyID || + (isa(Op0Ty) && + cast(Op0Ty)->getElementType()->isIntegral()) && + "Invalid operand types for ICmp instruction"); + return; + } + assert(op == Instruction::FCmp && "Invalid CmpInst opcode"); + assert(predicate <= FCmpInst::LAST_FCMP_PREDICATE && + "Invalid FCmp predicate value"); + const Type* Op0Ty = getOperand(0)->getType(); + const Type* Op1Ty = getOperand(1)->getType(); + assert(Op0Ty == Op1Ty && + "Both operands to FCmp instruction are not of the same type!"); + // Check that the operands are the right type + assert(Op0Ty->isFloatingPoint() || (isa(Op0Ty) && + cast(Op0Ty)->getElementType()->isFloatingPoint()) && + "Invalid operand types for FCmp instruction"); +} + +CmpInst * +CmpInst::create(OtherOps Op, unsigned short predicate, Value *S1, Value *S2, + const std::string &Name, Instruction *InsertBefore) { + if (Op == Instruction::ICmp) { + return new ICmpInst(ICmpInst::Predicate(predicate), S1, S2, Name, + InsertBefore); + } + return new FCmpInst(FCmpInst::Predicate(predicate), S1, S2, Name, + InsertBefore); +} + +CmpInst * +CmpInst::create(OtherOps Op, unsigned short predicate, Value *S1, Value *S2, + const std::string &Name, BasicBlock *InsertAtEnd) { + if (Op == Instruction::ICmp) { + return new ICmpInst(ICmpInst::Predicate(predicate), S1, S2, Name, + InsertAtEnd); + } + return new FCmpInst(FCmpInst::Predicate(predicate), S1, S2, Name, + InsertAtEnd); +} + +void CmpInst::swapOperands() { + if (ICmpInst *IC = dyn_cast(this)) + IC->swapOperands(); + else + cast(this)->swapOperands(); +} + +bool CmpInst::isCommutative() { + if (ICmpInst *IC = dyn_cast(this)) + return IC->isCommutative(); + return cast(this)->isCommutative(); +} + +bool CmpInst::isEquality() { + if (ICmpInst *IC = dyn_cast(this)) + return IC->isEquality(); + return cast(this)->isEquality(); +} + + +ICmpInst::Predicate ICmpInst::getInversePredicate(Predicate pred) { + switch (pred) { + default: + assert(!"Unknown icmp predicate!"); + case ICMP_EQ: return ICMP_NE; + case ICMP_NE: return ICMP_EQ; + case ICMP_UGT: return ICMP_ULE; + case ICMP_ULT: return ICMP_UGE; + case ICMP_UGE: return ICMP_ULT; + case ICMP_ULE: return ICMP_UGT; + case ICMP_SGT: return ICMP_SLE; + case ICMP_SLT: return ICMP_SGE; + case ICMP_SGE: return ICMP_SLT; + case ICMP_SLE: return ICMP_SGT; + } +} + +ICmpInst::Predicate ICmpInst::getSwappedPredicate(Predicate pred) { + switch (pred) { + default: assert(! "Unknown setcc instruction!"); + case ICMP_EQ: case ICMP_NE: + return pred; + case ICMP_SGT: return ICMP_SLT; + case ICMP_SLT: return ICMP_SGT; + case ICMP_SGE: return ICMP_SLE; + case ICMP_SLE: return ICMP_SGE; + case ICMP_UGT: return ICMP_ULT; + case ICMP_ULT: return ICMP_UGT; + case ICMP_UGE: return ICMP_ULE; + case ICMP_ULE: return ICMP_UGE; + } +} + +FCmpInst::Predicate FCmpInst::getInversePredicate(Predicate pred) { + switch (pred) { + default: + assert(!"Unknown icmp predicate!"); + case FCMP_OEQ: return FCMP_UNE; + case FCMP_ONE: return FCMP_UEQ; + case FCMP_OGT: return FCMP_ULE; + case FCMP_OLT: return FCMP_UGE; + case FCMP_OGE: return FCMP_ULT; + case FCMP_OLE: return FCMP_UGT; + case FCMP_UEQ: return FCMP_ONE; + case FCMP_UNE: return FCMP_OEQ; + case FCMP_UGT: return FCMP_OLE; + case FCMP_ULT: return FCMP_OGE; + case FCMP_UGE: return FCMP_OLT; + case FCMP_ULE: return FCMP_OGT; + case FCMP_ORD: return FCMP_UNO; + case FCMP_UNO: return FCMP_ORD; + case FCMP_TRUE: return FCMP_FALSE; + case FCMP_FALSE: return FCMP_TRUE; + } +} + +FCmpInst::Predicate FCmpInst::getSwappedPredicate(Predicate pred) { + switch (pred) { + default: assert(!"Unknown setcc instruction!"); + case FCMP_FALSE: case FCMP_TRUE: + case FCMP_OEQ: case FCMP_ONE: + case FCMP_UEQ: case FCMP_UNE: + case FCMP_ORD: case FCMP_UNO: + return pred; + case FCMP_OGT: return FCMP_OLT; + case FCMP_OLT: return FCMP_OGT; + case FCMP_OGE: return FCMP_OLE; + case FCMP_OLE: return FCMP_OGE; + case FCMP_UGT: return FCMP_ULT; + case FCMP_ULT: return FCMP_UGT; + case FCMP_UGE: return FCMP_ULE; + case FCMP_ULE: return FCMP_UGE; + } +} + //===----------------------------------------------------------------------===// // SwitchInst Implementation //===----------------------------------------------------------------------===// @@ -1412,6 +1603,11 @@ return create(getOpcode(), Ops[0], Ops[1]); } +CmpInst* CmpInst::clone() const { + return create(Instruction::OtherOps(getOpcode()), getPredicate(), + Ops[0], Ops[1]); +} + MallocInst *MallocInst::clone() const { return new MallocInst(*this); } AllocaInst *AllocaInst::clone() const { return new AllocaInst(*this); } FreeInst *FreeInst::clone() const { return new FreeInst(getOperand(0)); } Index: llvm/lib/VMCore/Verifier.cpp diff -u llvm/lib/VMCore/Verifier.cpp:1.165 llvm/lib/VMCore/Verifier.cpp:1.166 --- llvm/lib/VMCore/Verifier.cpp:1.165 Fri Oct 20 02:07:24 2006 +++ llvm/lib/VMCore/Verifier.cpp Sun Nov 19 19:22:35 2006 @@ -179,6 +179,8 @@ void visitBasicBlock(BasicBlock &BB); void visitPHINode(PHINode &PN); void visitBinaryOperator(BinaryOperator &B); + void visitICmpInst(ICmpInst &IC); + void visitFCmpInst(FCmpInst &FC); void visitShiftInst(ShiftInst &SI); void visitExtractElementInst(ExtractElementInst &EI); void visitInsertElementInst(InsertElementInst &EI); @@ -551,6 +553,33 @@ visitInstruction(B); } +void Verifier::visitICmpInst(ICmpInst& IC) { + // Check that the operands are the same type + const Type* Op0Ty = IC.getOperand(0)->getType(); + const Type* Op1Ty = IC.getOperand(1)->getType(); + Assert1(Op0Ty == Op1Ty, + "Both operands to ICmp instruction are not of the same type!", &IC); + // Check that the operands are the right type + Assert1(Op0Ty->isIntegral() || Op0Ty->getTypeID() == Type::PointerTyID || + (isa(Op0Ty) && + cast(Op0Ty)->getElementType()->isIntegral()), + "Invalid operand types for ICmp instruction", &IC); + visitInstruction(IC); +} + +void Verifier::visitFCmpInst(FCmpInst& FC) { + // Check that the operands are the same type + const Type* Op0Ty = FC.getOperand(0)->getType(); + const Type* Op1Ty = FC.getOperand(1)->getType(); + Assert1(Op0Ty == Op1Ty, + "Both operands to FCmp instruction are not of the same type!", &FC); + // Check that the operands are the right type + Assert1(Op0Ty->isFloatingPoint() || (isa(Op0Ty) && + cast(Op0Ty)->getElementType()->isFloatingPoint()), + "Invalid operand types for FCmp instruction", &FC); + visitInstruction(FC); +} + void Verifier::visitShiftInst(ShiftInst &SI) { Assert1(SI.getType()->isInteger(), "Shift must return an integer result!", &SI); From reid at x10sys.com Sun Nov 19 19:22:56 2006 From: reid at x10sys.com (Reid Spencer) Date: Sun, 19 Nov 2006 19:22:56 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/InstrTypes.h Instruction.def Instructions.h Message-ID: <200611200122.kAK1Mu9l012795@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: InstrTypes.h updated: 1.47 -> 1.48 Instruction.def updated: 1.24 -> 1.25 Instructions.h updated: 1.45 -> 1.46 --- Log message: For PR950: http://llvm.org/PR950 : First in a series of patches to convert SetCondInst into ICmpInst and FCmpInst using only two opcodes and having the instructions contain their predicate value. Nothing uses these classes yet. More patches to follow. --- Diffs of the changes: (+334 -14) InstrTypes.h | 85 ++++++++++++++++++++ Instruction.def | 30 +++---- Instructions.h | 233 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 334 insertions(+), 14 deletions(-) Index: llvm/include/llvm/InstrTypes.h diff -u llvm/include/llvm/InstrTypes.h:1.47 llvm/include/llvm/InstrTypes.h:1.48 --- llvm/include/llvm/InstrTypes.h:1.47 Sun Sep 17 14:29:56 2006 +++ llvm/include/llvm/InstrTypes.h Sun Nov 19 19:22:35 2006 @@ -243,6 +243,91 @@ } }; +//===----------------------------------------------------------------------===// +// CmpInst Class +//===----------------------------------------------------------------------===// + +/// This class is the base class for the comparison instructions. +/// @brief Abstract base class of comparison instructions. +class CmpInst: public Instruction { + CmpInst(); // do not implement +protected: + CmpInst(Instruction::OtherOps op, unsigned short pred, Value *LHS, Value *RHS, + const std::string &Name = "", Instruction *InsertBefore = 0); + + CmpInst(Instruction::OtherOps op, unsigned short pred, Value *LHS, Value *RHS, + const std::string &Name, BasicBlock *InsertAtEnd); + + Use Ops[2]; // CmpInst instructions always have 2 operands, optimize + +public: + /// Construct a compare instruction, given the opcode, the predicate and + /// the two operands. Optionally (if InstBefore is specified) insert the + /// instruction into a BasicBlock right before the specified instruction. + /// The specified Instruction is allowed to be a dereferenced end iterator. + /// @brief Create a CmpInst + static CmpInst *create(OtherOps Op, unsigned short predicate, Value *S1, + Value *S2, const std::string &Name = "", + Instruction *InsertBefore = 0); + + /// Construct a compare instruction, given the opcode, the predicate and the + /// two operands. Also automatically insert this instruction to the end of + /// the BasicBlock specified. + /// @brief Create a CmpInst + static CmpInst *create(OtherOps Op, unsigned short predicate, Value *S1, + Value *S2, const std::string &Name, + BasicBlock *InsertAtEnd); + + /// @brief Implement superclass method. + virtual CmpInst *clone() const; + + /// The predicate for CmpInst is defined by the subclasses but stored in + /// the SubclassData field (see Value.h). We allow it to be fetched here + /// as the predicate but there is no enum type for it, just the raw unsigned + /// short. This facilitates comparison of CmpInst instances without delving + /// into the subclasses since predicate values are distinct between the + /// CmpInst subclasses. + /// @brief Return the predicate for this instruction. + unsigned short getPredicate() const { + return SubclassData; + } + + /// @brief Provide more efficient getOperand methods. + Value *getOperand(unsigned i) const { + assert(i < 2 && "getOperand() out of range!"); + return Ops[i]; + } + void setOperand(unsigned i, Value *Val) { + assert(i < 2 && "setOperand() out of range!"); + Ops[i] = Val; + } + + /// @brief CmpInst instructions always have 2 operands. + unsigned getNumOperands() const { return 2; } + + /// This is just a convenience that dispatches to the subclasses. + /// @brief Swap the operands. + void swapOperands(); + + /// This is just a convenience that dispatches to the subclasses. + /// @brief Determine if this CmpInst is commutative. + bool isCommutative(); + + /// This is just a convenience that dispatches to the subclasses. + /// @brief Determine if this is an equals/not equals predicate. + bool isEquality(); + + /// @brief Methods for support type inquiry through isa, cast, and dyn_cast: + static inline bool classof(const CmpInst *) { return true; } + static inline bool classof(const Instruction *I) { + return I->getOpcode() == Instruction::ICmp || + I->getOpcode() == Instruction::FCmp; + } + static inline bool classof(const Value *V) { + return isa(V) && classof(cast(V)); + } +}; + } // End llvm namespace #endif Index: llvm/include/llvm/Instruction.def diff -u llvm/include/llvm/Instruction.def:1.24 llvm/include/llvm/Instruction.def:1.25 --- llvm/include/llvm/Instruction.def:1.24 Sat Nov 11 17:06:47 2006 +++ llvm/include/llvm/Instruction.def Sun Nov 19 19:22:35 2006 @@ -126,20 +126,22 @@ // Other operators... FIRST_OTHER_INST(31) -HANDLE_OTHER_INST(31, PHI , PHINode ) // PHI node instruction -HANDLE_OTHER_INST(32, Cast , CastInst ) // Type cast -HANDLE_OTHER_INST(33, Call , CallInst ) // Call a function -HANDLE_OTHER_INST(34, Shl , ShiftInst ) // Shift Left operations (logical) -HANDLE_OTHER_INST(35, LShr , ShiftInst ) // Logical Shift right (unsigned) -HANDLE_OTHER_INST(36, AShr , ShiftInst ) // Arithmetic shift right (signed) -HANDLE_OTHER_INST(37, Select , SelectInst ) // select instruction -HANDLE_OTHER_INST(38, UserOp1, Instruction) // May be used internally in a pass -HANDLE_OTHER_INST(39, UserOp2, Instruction) // Internal to passes only -HANDLE_OTHER_INST(40, VAArg , VAArgInst ) // vaarg instruction -HANDLE_OTHER_INST(41, ExtractElement, ExtractElementInst)// extract from vector. -HANDLE_OTHER_INST(42, InsertElement, InsertElementInst) // insert into vector -HANDLE_OTHER_INST(43, ShuffleVector, ShuffleVectorInst) // shuffle two vectors. - LAST_OTHER_INST(43) +HANDLE_OTHER_INST(31, ICmp , ICmpInst ) // Integer comparison instruction +HANDLE_OTHER_INST(32, FCmp , FCmpInst ) // Floating point comparison instr. +HANDLE_OTHER_INST(33, PHI , PHINode ) // PHI node instruction +HANDLE_OTHER_INST(34, Cast , CastInst ) // Type cast +HANDLE_OTHER_INST(35, Call , CallInst ) // Call a function +HANDLE_OTHER_INST(36, Shl , ShiftInst ) // Shift Left operations (logical) +HANDLE_OTHER_INST(37, LShr , ShiftInst ) // Logical Shift right (unsigned) +HANDLE_OTHER_INST(38, AShr , ShiftInst ) // Arithmetic shift right (signed) +HANDLE_OTHER_INST(39, Select , SelectInst ) // select instruction +HANDLE_OTHER_INST(40, UserOp1, Instruction) // May be used internally in a pass +HANDLE_OTHER_INST(41, UserOp2, Instruction) // Internal to passes only +HANDLE_OTHER_INST(42, VAArg , VAArgInst ) // vaarg instruction +HANDLE_OTHER_INST(43, ExtractElement, ExtractElementInst)// extract from vector. +HANDLE_OTHER_INST(44, InsertElement, InsertElementInst) // insert into vector +HANDLE_OTHER_INST(45, ShuffleVector, ShuffleVectorInst) // shuffle two vectors. + LAST_OTHER_INST(45) #undef FIRST_TERM_INST #undef HANDLE_TERM_INST Index: llvm/include/llvm/Instructions.h diff -u llvm/include/llvm/Instructions.h:1.45 llvm/include/llvm/Instructions.h:1.46 --- llvm/include/llvm/Instructions.h:1.45 Wed Nov 8 00:47:32 2006 +++ llvm/include/llvm/Instructions.h Sun Nov 19 19:22:35 2006 @@ -415,6 +415,239 @@ }; //===----------------------------------------------------------------------===// +// ICmpInst Class +//===----------------------------------------------------------------------===// + +/// This instruction compares its operands according to the predicate given +/// to the constructor. It only operates on integers, pointers, or packed +/// vectors of integrals. The two operands must be the same type. +/// @brief Represent an integer comparison operator. +class ICmpInst: public CmpInst { +public: + /// This enumeration lists the possible predicates for the ICmpInst. The + /// values in the range 0-31 are reserved for FCmpInst while values in the + /// range 32-64 are reserved for ICmpInst. This is necessary to ensure the + /// predicate values are not overlapping between the classes. + enum Predicate { + ICMP_EQ = 32, ///< equal + ICMP_NE = 33, ///< not equal + ICMP_UGT = 34, ///< unsigned greater than + ICMP_UGE = 35, ///< unsigned greater or equal + ICMP_ULT = 36, ///< unsigned less than + ICMP_ULE = 37, ///< unsigned less or equal + ICMP_SGT = 38, ///< signed greater than + ICMP_SGE = 39, ///< signed greater or equal + ICMP_SLT = 40, ///< signed less than + ICMP_SLE = 41, ///< signed less or equal + FIRST_ICMP_PREDICATE = ICMP_EQ, + LAST_ICMP_PREDICATE = ICMP_SLE + }; + + /// @brief Constructor with insert-before-instruction semantics. + ICmpInst( + Predicate pred, ///< The predicate to use for the comparison + Value *LHS, ///< The left-hand-side of the expression + Value *RHS, ///< The right-hand-side of the expression + const std::string &Name = "", ///< Name of the instruction + Instruction *InsertBefore = 0 ///< Where to insert + ) : CmpInst(Instruction::ICmp, pred, LHS, RHS, Name, InsertBefore) { + } + + /// @brief Constructor with insert-at-block-end semantics. + ICmpInst( + Predicate pred, ///< The predicate to use for the comparison + Value *LHS, ///< The left-hand-side of the expression + Value *RHS, ///< The right-hand-side of the expression + const std::string &Name, ///< Name of the instruction + BasicBlock *InsertAtEnd ///< Block to insert into. + ) : CmpInst(Instruction::ICmp, pred, LHS, RHS, Name, InsertAtEnd) { + } + + /// @brief Return the predicate for this instruction. + Predicate getPredicate() const { return Predicate(SubclassData); } + + /// For example, EQ -> NE, UGT -> ULE, SLT -> SGE, etc. + /// @returns the inverse predicate for the instruction's current predicate. + /// @brief Return the inverse of the instruction's predicate. + Predicate getInversePredicate() const { + return getInversePredicate(getPredicate()); + } + + /// For example, EQ -> NE, UGT -> ULE, SLT -> SGE, etc. + /// @returns the inverse predicate for predicate provided in \p pred. + /// @brief Return the inverse of a given predicate + static Predicate getInversePredicate(Predicate pred); + + /// For example, EQ->EQ, SLE->SGE, ULT->UGT, etc. + /// @returns the predicate that would be the result of exchanging the two + /// operands of the ICmpInst instruction without changing the result + /// produced. + /// @brief Return the predicate as if the operands were swapped + Predicate getSwappedPredicate() const { + return getSwappedPredicate(getPredicate()); + } + + /// This is a static version that you can use without an instruction + /// available. + /// @brief Return the predicate as if the operands were swapped. + static Predicate getSwappedPredicate(Predicate Opcode); + + /// This also tests for commutativity. If isEquality() returns true then + /// the predicate is also commutative. Only the equality predicates are + /// commutative. + /// @returns true if the predicate of this instruction is EQ or NE. + /// @brief Determine if this is an equality predicate. + bool isEquality() const { + return SubclassData == ICMP_EQ || SubclassData == ICMP_NE; + } + bool isCommutative() const { return isEquality(); } + + /// @returns true if the predicate is relational (not EQ or NE). + /// @brief Determine if this a relational predicate. + bool isRelational() const { + return !isEquality(); + } + + /// Exchange the two operands to this instruction in such a way that it does + /// not modify the semantics of the instruction. The predicate value may be + /// changed to retain the same result if the predicate is order dependent + /// (e.g. ult). + /// @brief Swap operands and adjust predicate. + void swapOperands() { + SubclassData = getSwappedPredicate(); + std::swap(Ops[0], Ops[1]); + } + + // Methods for support type inquiry through isa, cast, and dyn_cast: + static inline bool classof(const ICmpInst *) { return true; } + static inline bool classof(const Instruction *I) { + return I->getOpcode() == Instruction::ICmp; + } + static inline bool classof(const Value *V) { + return isa(V) && classof(cast(V)); + } +}; + +//===----------------------------------------------------------------------===// +// FCmpInst Class +//===----------------------------------------------------------------------===// + +/// This instruction compares its operands according to the predicate given +/// to the constructor. It only operates on floating point values or packed +/// vectors of floating point values. The operands must be identical types. +/// @brief Represents a floating point comparison operator. +class FCmpInst: public CmpInst { +public: + /// This enumeration lists the possible predicates for the FCmpInst. Values + /// in the range 0-31 are reserved for FCmpInst. + enum Predicate { + // Opcode U L G E Intuitive operation + FCMP_FALSE = 0, ///< 0 0 0 0 Always false (always folded) + FCMP_OEQ = 1, ///< 0 0 0 1 True if ordered and equal + FCMP_OGT = 2, ///< 0 0 1 0 True if ordered and greater than + FCMP_OGE = 3, ///< 0 0 1 1 True if ordered and greater than or equal + FCMP_OLT = 4, ///< 0 1 0 0 True if ordered and less than + FCMP_OLE = 5, ///< 0 1 0 1 True if ordered and less than or equal + FCMP_ONE = 6, ///< 0 1 1 0 True if ordered and operands are unequal + FCMP_ORD = 7, ///< 0 1 1 1 True if ordered (no nans) + FCMP_UNO = 8, ///< 1 0 0 0 True if unordered: isnan(X) | isnan(Y) + FCMP_UEQ = 9, ///< 1 0 0 1 True if unordered or equal + FCMP_UGT =10, ///< 1 0 1 0 True if unordered or greater than + FCMP_UGE =11, ///< 1 0 1 1 True if unordered, greater than, or equal + FCMP_ULT =12, ///< 1 1 0 0 True if unordered or less than + FCMP_ULE =13, ///< 1 1 0 1 True if unordered, less than, or equal + FCMP_UNE =14, ///< 1 1 1 0 True if unordered or not equal + FCMP_TRUE =15, ///< 1 1 1 1 Always true (always folded) + FIRST_FCMP_PREDICATE = FCMP_FALSE, + LAST_FCMP_PREDICATE = FCMP_TRUE + }; + + /// @brief Constructor with insert-before-instruction semantics. + FCmpInst( + Predicate pred, ///< The predicate to use for the comparison + Value *LHS, ///< The left-hand-side of the expression + Value *RHS, ///< The right-hand-side of the expression + const std::string &Name = "", ///< Name of the instruction + Instruction *InsertBefore = 0 ///< Where to insert + ) : CmpInst(Instruction::FCmp, pred, LHS, RHS, Name, InsertBefore) { + } + + /// @brief Constructor with insert-at-block-end semantics. + FCmpInst( + Predicate pred, ///< The predicate to use for the comparison + Value *LHS, ///< The left-hand-side of the expression + Value *RHS, ///< The right-hand-side of the expression + const std::string &Name, ///< Name of the instruction + BasicBlock *InsertAtEnd ///< Block to insert into. + ) : CmpInst(Instruction::FCmp, pred, LHS, RHS, Name, InsertAtEnd) { + } + + /// @brief Return the predicate for this instruction. + Predicate getPredicate() const { return Predicate(SubclassData); } + + /// For example, OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc. + /// @returns the inverse predicate for the instructions current predicate. + /// @brief Return the inverse of the predicate + Predicate getInversePredicate() const { + return getInversePredicate(getPredicate()); + } + + /// For example, OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc. + /// @returns the inverse predicate for \p pred. + /// @brief Return the inverse of a given predicate + static Predicate getInversePredicate(Predicate pred); + + /// For example, OEQ->OEQ, ULE->UGE, OLT->OGT, etc. + /// @returns the predicate that would be the result of exchanging the two + /// operands of the ICmpInst instruction without changing the result + /// produced. + /// @brief Return the predicate as if the operands were swapped + Predicate getSwappedPredicate() const { + return getSwappedPredicate(getPredicate()); + } + + /// This is a static version that you can use without an instruction + /// available. + /// @brief Return the predicate as if the operands were swapped. + static Predicate getSwappedPredicate(Predicate Opcode); + + /// This also tests for commutativity. If isEquality() returns true then + /// the predicate is also commutative. Only the equality predicates are + /// commutative. + /// @returns true if the predicate of this instruction is EQ or NE. + /// @brief Determine if this is an equality predicate. + bool isEquality() const { + return SubclassData == FCMP_OEQ || SubclassData == FCMP_ONE || + SubclassData == FCMP_UEQ || SubclassData == FCMP_UNE; + } + bool isCommutative() const { return isEquality(); } + + /// @returns true if the predicate is relational (not EQ or NE). + /// @brief Determine if this a relational predicate. + bool isRelational() const { return !isEquality(); } + + /// Exchange the two operands to this instruction in such a way that it does + /// not modify the semantics of the instruction. The predicate value may be + /// changed to retain the same result if the predicate is order dependent + /// (e.g. ult). + /// @brief Swap operands and adjust predicate. + void swapOperands() { + SubclassData = getSwappedPredicate(); + std::swap(Ops[0], Ops[1]); + } + + /// @brief Methods for support type inquiry through isa, cast, and dyn_cast: + static inline bool classof(const FCmpInst *) { return true; } + static inline bool classof(const Instruction *I) { + return I->getOpcode() == Instruction::FCmp; + } + static inline bool classof(const Value *V) { + return isa(V) && classof(cast(V)); + } +}; + + +//===----------------------------------------------------------------------===// // SetCondInst Class //===----------------------------------------------------------------------===// From reid at x10sys.com Sun Nov 19 19:22:56 2006 From: reid at x10sys.com (Reid Spencer) Date: Sun, 19 Nov 2006 19:22:56 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/ValueNumbering.cpp Message-ID: <200611200122.kAK1MuQV012800@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: ValueNumbering.cpp updated: 1.21 -> 1.22 --- Log message: For PR950: http://llvm.org/PR950 : First in a series of patches to convert SetCondInst into ICmpInst and FCmpInst using only two opcodes and having the instructions contain their predicate value. Nothing uses these classes yet. More patches to follow. --- Diffs of the changes: (+23 -0) ValueNumbering.cpp | 23 +++++++++++++++++++++++ 1 files changed, 23 insertions(+) Index: llvm/lib/Analysis/ValueNumbering.cpp diff -u llvm/lib/Analysis/ValueNumbering.cpp:1.21 llvm/lib/Analysis/ValueNumbering.cpp:1.22 --- llvm/lib/Analysis/ValueNumbering.cpp:1.21 Sun Aug 27 19:42:29 2006 +++ llvm/lib/Analysis/ValueNumbering.cpp Sun Nov 19 19:22:35 2006 @@ -75,6 +75,7 @@ void visitCastInst(CastInst &I); void visitGetElementPtrInst(GetElementPtrInst &I); + void visitCmpInst(CmpInst &I); void handleBinaryInst(Instruction &I); void visitBinaryOperator(Instruction &I) { handleBinaryInst(I); } @@ -124,6 +125,28 @@ } } +void BVNImpl::visitCmpInst(CmpInst &CI1) { + Value *LHS = CI1.getOperand(0); + for (Value::use_iterator UI = LHS->use_begin(), UE = LHS->use_end(); + UI != UE; ++UI) + if (CmpInst *CI2 = dyn_cast(*UI)) + // Check to see if this compare instruction is not CI, but same opcode, + // same predicate, and in the same function. + if (CI2 != &CI1 && CI2->getOpcode() == CI1.getOpcode() && + CI2->getPredicate() == CI1.getPredicate() && + CI2->getParent()->getParent() == CI1.getParent()->getParent()) + // If the operands are the same + if ((CI2->getOperand(0) == CI1.getOperand(0) && + CI2->getOperand(1) == CI1.getOperand(1)) || + // Or the compare is commutative and the operands are reversed + (CI1.isCommutative() && + CI2->getOperand(0) == CI1.getOperand(1) && + CI2->getOperand(1) == CI1.getOperand(0))) + // Then the instructiosn are identical, add to list. + RetVals.push_back(CI2); +} + + // isIdenticalBinaryInst - Return true if the two binary instructions are // identical. From reid at x10sys.com Sun Nov 19 19:22:52 2006 From: reid at x10sys.com (Reid Spencer) Date: Sun, 19 Nov 2006 19:22:52 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <200611200122.kAK1MqZX012772@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: SelectionDAGISel.cpp updated: 1.318 -> 1.319 --- Log message: For PR950: http://llvm.org/PR950 : First in a series of patches to convert SetCondInst into ICmpInst and FCmpInst using only two opcodes and having the instructions contain their predicate value. Nothing uses these classes yet. More patches to follow. --- Diffs of the changes: (+56 -0) SelectionDAGISel.cpp | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 56 insertions(+) Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.318 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.319 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.318 Wed Nov 15 11:51:15 2006 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Sun Nov 19 19:22:35 2006 @@ -541,6 +541,8 @@ void visitShl(User &I) { visitShift(I, ISD::SHL); } void visitLShr(User &I) { visitShift(I, ISD::SRL); } void visitAShr(User &I) { visitShift(I, ISD::SRA); } + void visitICmp(User &I); + void visitFCmp(User &I); void visitSetCC(User &I, ISD::CondCode SignedOpc, ISD::CondCode UnsignedOpc, ISD::CondCode FPOpc); void visitSetEQ(User &I) { visitSetCC(I, ISD::SETEQ, ISD::SETEQ, @@ -1442,6 +1444,60 @@ setValue(&I, DAG.getNode(Opcode, Op1.getValueType(), Op1, Op2)); } +void SelectionDAGLowering::visitICmp(User &I) { + ICmpInst *IC = cast(&I); + SDOperand Op1 = getValue(IC->getOperand(0)); + SDOperand Op2 = getValue(IC->getOperand(1)); + ISD::CondCode Opcode; + switch (IC->getPredicate()) { + case ICmpInst::ICMP_EQ : Opcode = ISD::SETEQ; break; + case ICmpInst::ICMP_NE : Opcode = ISD::SETNE; break; + case ICmpInst::ICMP_UGT : Opcode = ISD::SETUGT; break; + case ICmpInst::ICMP_UGE : Opcode = ISD::SETUGE; break; + case ICmpInst::ICMP_ULT : Opcode = ISD::SETULT; break; + case ICmpInst::ICMP_ULE : Opcode = ISD::SETULE; break; + case ICmpInst::ICMP_SGT : Opcode = ISD::SETGT; break; + case ICmpInst::ICMP_SGE : Opcode = ISD::SETGE; break; + case ICmpInst::ICMP_SLT : Opcode = ISD::SETLT; break; + case ICmpInst::ICMP_SLE : Opcode = ISD::SETLE; break; + default: + assert(!"Invalid ICmp predicate value"); + Opcode = ISD::SETEQ; + break; + } + setValue(&I, DAG.getSetCC(MVT::i1, Op1, Op2, Opcode)); +} + +void SelectionDAGLowering::visitFCmp(User &I) { + FCmpInst *FC = cast(&I); + SDOperand Op1 = getValue(FC->getOperand(0)); + SDOperand Op2 = getValue(FC->getOperand(1)); + ISD::CondCode Opcode; + switch (FC->getPredicate()) { + case FCmpInst::FCMP_FALSE : Opcode = ISD::SETFALSE; + case FCmpInst::FCMP_OEQ : Opcode = ISD::SETOEQ; + case FCmpInst::FCMP_OGT : Opcode = ISD::SETOGT; + case FCmpInst::FCMP_OGE : Opcode = ISD::SETOGE; + case FCmpInst::FCMP_OLT : Opcode = ISD::SETOLT; + case FCmpInst::FCMP_OLE : Opcode = ISD::SETOLE; + case FCmpInst::FCMP_ONE : Opcode = ISD::SETONE; + case FCmpInst::FCMP_ORD : Opcode = ISD::SETO; + case FCmpInst::FCMP_UNO : Opcode = ISD::SETUO; + case FCmpInst::FCMP_UEQ : Opcode = ISD::SETUEQ; + case FCmpInst::FCMP_UGT : Opcode = ISD::SETUGT; + case FCmpInst::FCMP_UGE : Opcode = ISD::SETUGE; + case FCmpInst::FCMP_ULT : Opcode = ISD::SETULT; + case FCmpInst::FCMP_ULE : Opcode = ISD::SETULE; + case FCmpInst::FCMP_UNE : Opcode = ISD::SETUNE; + case FCmpInst::FCMP_TRUE : Opcode = ISD::SETTRUE; + default: + assert(!"Invalid FCmp predicate value"); + Opcode = ISD::SETFALSE; + break; + } + setValue(&I, DAG.getSetCC(MVT::i1, Op1, Op2, Opcode)); +} + void SelectionDAGLowering::visitSetCC(User &I,ISD::CondCode SignedOpcode, ISD::CondCode UnsignedOpcode, ISD::CondCode FPOpcode) { From tonic at nondot.org Sun Nov 19 23:20:52 2006 From: tonic at nondot.org (Tanya Lattner) Date: Sun, 19 Nov 2006 23:20:52 -0600 Subject: [llvm-commits] [release_19] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200611200520.kAK5KqQM016187@zion.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.363 -> 1.363.2.1 --- Log message: Merging from mainline --- Diffs of the changes: (+263 -232) ReleaseNotes.html | 495 ++++++++++++++++++++++++++++-------------------------- 1 files changed, 263 insertions(+), 232 deletions(-) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.363 llvm/docs/ReleaseNotes.html:1.363.2.1 --- llvm/docs/ReleaseNotes.html:1.363 Wed Nov 1 10:15:04 2006 +++ llvm/docs/ReleaseNotes.html Sun Nov 19 23:20:40 2006 @@ -62,7 +62,8 @@

    This is the tenth public release of the LLVM Compiler Infrastructure. This -release incorporates a large number of enhancements and new features. +release incorporates a large number of enhancements, new features, and bug +fixes. We recommend that all users of previous LLVM versions upgrade.

    @@ -73,41 +74,106 @@ - +
    -

    The llvm-gcc4 C front-end now generates debugging info for C and C++ for -X86/ELF platforms (Linux). This extends the PPC/Darwin and X86/Darwin debugging -support available in release 18.8 DWARF is a standard debugging format used on -many platforms.

    +

    LLVM 1.9 now fully supports the x86-64 instruction set on Mac OS/X, and +supports it on Linux (and other operating systems) when compiling in -static +mode. LLVM includes JIT support for X86-64, and supports both Intel EMT-64T +and AMD-64 architectures. The X86-64 instruction set permits addressing a +64-bit addressing space and provides the compiler with twice the +number of integer registers to use.

    - +
    -

    As a step towards making LLVM's integer types signless, several new -instructions have been added to LLVM. The DIV instruction has become UDIV, SDIV, -and FDIV. The REM instruction has become UREM, SREM and FREM. The SHR -instruction has become ASHR and LSHR. See the Language - Reference for details on these new instructions.

    +

    LLVM now includes liblto which can +be used to integrate LLVM Link-Time Optimization support into a native linker. +This allows LLVM .bc to transparently participate with linking an application, +even when some .o files are in LLVM form and some are not.

    - +
    -

    Describe feature C here.

    +

    llvm-gcc4 now supports generating debugging info for Linux, Cygwin and MinGW. +This extends the PPC/Darwin and X86/Darwin debugging support available in the +1.8 release. DWARF is a standard debugging format used on many platforms.

    - +
    -

    Describe feature D here.

    +

    The mid-level optimizer is now faster and produces better code in many cases. + Significant changes include:

    + +
      +
    • LLVM includes a new 'predicate simplifier' pass, which + currently performs dominator tree-based optimizations.
    • +
    • The complete loop unroll pass now supports unrolling of + multiple basic block loops.
    • +
    • The 'globalopt' pass can now perform the scalar replacement of + aggregates transformation on some heap allocations.
    • +
    • The globalsmodref-aa alias analysis can now track 'indirect pointer + globals' more accurately.
    • +
    • The instruction combiner can now perform element propagation +analysis of vector expressions, eliminating computation of vector elements +that are not used.
    • +
    +
    - + +
    -

    Describe feature E here.

    +

    +The LLVM Target-Independent code generator now supports more target features and +optimizes many cases more aggressively. New features include: +

    + +
      +
    • LLVM now includes a late branch folding pass which optimizes code + layout, performs several branch optzns, and deletes unreachable code.
    • +
    • The code generator now support targets that have pre/post-increment + addressing modes.
    • +
    • LLVM now supports dynamically-loadable register allocators and + schedulers.
    • +
    • LLVM 1.9 includes several improvements to inline asm support, + including support for new constraints and modifiers.
    • +
    • The register coalescer is now more aggressive than before, + allowing it to eliminate more copies.
    • +
    + +

    In addition, the LLVM target description format has itself been extended in + several ways:

    + +
      +
    • tblgen now allows definition of 'multiclasses' which can be + used to factor instruction patterns more aggressively in .td files.
    • +
    • LLVM has a new TargetAsmInfo class which captures a variety of + information about the target assembly language format.
    • +
    • .td files now support "${:foo}" syntax for encoding + subtarget-specific assembler syntax into instruction descriptions.
    • +
    + +

    Further, several significant target-specific enhancements are included in +LLVM 1.9:

    + +
      +
    • The LLVM ARM backend now supports more instructions + and the use of a frame pointer. It is now possible to build + libgcc and a simple cross compiler, but it is not considered "complete" yet. +
    • +
    • LLVM supports the Win32 dllimport/dllexport linkage and + stdcall/fastcall calling conventions.
    • +
    +
    @@ -121,38 +187,41 @@

    More specific changes include:

      -
    • LLVM 1.8 includes an initial ARM backend. This backend is in early - development stages.
    • -
    • LLVM 1.8 now includes significantly better support for mingw and - cygwin.
    • -
    • The llvm-config tool is - now built by default and has several new features.
    • -
    • The X86 and PPC backends now use the correct platform ABI for passing - vectors as arguments to functions.
    • -
    • The X86 backend now includes support for the Microsoft ML assembler - ("MASM").
    • -
    • The PowerPC backend now pattern matches the 'rlwimi' instruction more - aggressively.
    • -
    • Most of LLVM is now built with "-pedantic", ensuring better portability - to more C++ Compilers.
    • -
    • The PowerPC backend now includes initial 64-bit support. The JIT is not - complete, and the static compiler has a couple of known bugs, but support - is mostly in place. LLVM 1.9 will include completed PPC-64 support.
    • - +
    • The llvm-test framework now supports SPEC2006.
    • +
    • LLVM now includes a FAQ about the +getelementptr instruction.
    • +
    • Bugpoint now supports a new "-find-bugs" mode. This mode makes + bugpoint permute pass sequences to try to expose bugs due to pass + sequencing.
    • +
    • The JIT now supports lazily streaming code from multiple modules at a + time, implicitly linking the code as it goes.
    + +

    Several significant API changes have been made. If you are maintaining +out-of-tree code, please be aware that:

    +
      -
    • The LLVM "SparcV9" backend (deprecated in LLVM 1.7) has been removed in -LLVM 1.8. The LLVM "Sparc" backend replaces it.
    • -
    • The --version option now prints more useful information, including the - build configuration for the tool.
    • +
    • The ConstantSInt and ConstantUInt classes have been merged into the + ConstantInt class.
    • +
    • As a step towards making LLVM's integer types signless, several new +instructions have been added to LLVM. The Div instruction is now +UDiv, SDiv, and FDiv. The Rem instruction +is now URem, SRem and FRem. See the +Language Reference for details on these new +instructions.

      +
    • ConstantBool::True and ConstantBool::False have been + renamed to ConstantBool::getTrue() and + ConstantBool::getFalse().

    • +
    • The 'analyze' tool has been merged into the 'opt' tool.
    • +
    @@ -174,7 +243,8 @@
  • Sun UltraSPARC workstations running Solaris 8.
  • Intel and AMD machines running on Win32 with the Cygwin libraries (limited support is available for native builds with Visual C++).
  • -
  • PowerPC and X86-based Mac OS X systems, running 10.2 and above.
  • +
  • PowerPC and X86-based Mac OS X systems, running 10.2 and above in 32-bit and + 64-bit modes.
  • Alpha-based machines running Debian GNU/Linux.
  • Itanium-based machines running Linux and HP-UX.
  • @@ -220,6 +290,7 @@
  • The -cee pass is known to be buggy, and may be removed in in a future release.
  • The IA64 code generator is experimental.
  • +
  • The ARM code generator is experimental.
  • The Alpha JIT is experimental.
  • "-filetype=asm" (the default) is the only supported value for the -filetype llc option.
  • @@ -229,16 +300,138 @@
    +
    + + + +
    + + + +
    + + + + +
    + +
      +
    • The SPARC backend only supports the 32-bit SPARC ABI (-m32), it does not + support the 64-bit SPARC ABI (-m64).
    • +
    + +
    + + + + +
    + +
      + +
    • The C back-end produces code that violates the ANSI C Type-Based Alias +Analysis rules. As such, special options may be necessary to compile the code +(for example, GCC requires the -fno-strict-aliasing option). This +problem probably cannot be fixed.
    • + +
    • Zero arg vararg functions are not +supported. This should not affect LLVM produced by the C or C++ +frontends.
    • + +
    • The C backend does not correctly implement the llvm.stacksave or +llvm.stackrestore +intrinsics. This means that some code compiled by it can run out of stack +space if they depend on these (e.g. C99 varargs).
    • + +
    • The C backend does not support inline + assembly code.
    • +
    + +
    + + + + +
    + +
      + +
    • On 21164s, some rare FP arithmetic sequences which may trap do not have the +appropriate nops inserted to ensure restartability.
    • + +
    +
    + + + + +
    + +
      + +
    • C++ programs are likely to fail on IA64, as calls to setjmp are +made where the argument is not 16-byte aligned, as required on IA64. (Strictly +speaking this is not a bug in the IA64 back-end; it will also be encountered +when building C++ programs using the C back-end.)
    • + +
    • The C++ front-end does not use IA64 +ABI compliant layout of v-tables. In particular, it just stores function +pointers instead of function descriptors in the vtable. This bug prevents +mixing C++ code compiled with LLVM with C++ objects compiled by other C++ +compilers.
    • + +
    • There are a few ABI violations which will lead to problems when mixing LLVM +output with code built with other compilers, particularly for floating-point +programs.
    • + +
    • Defining vararg functions is not supported (but calling them is ok).
    • + +
    + +
    + + + + +
    + +
      +
    • The ARM backend is currently in early development stages, it is not +ready for production use.
    • +
    + +
    @@ -264,29 +457,15 @@

    -llvm-gcc3 has many significant problems that are fixed by llvm-gcc4. -Two major ones include:

    - -
      -
    • With llvm-gcc3, - C99 variable sized arrays do not release stack memory when they go out of - scope. Thus, the following program may run out of stack space: -
      -    for (i = 0; i != 1000000; ++i) {
      -      int X[n];
      -      foo(X);
      -    }
      -
    • - -
    • With llvm-gcc3, Initialization of global union variables can only be done with the largest union member.
    • - -

    llvm-gcc4 is far more stable and produces better code than llvm-gcc3, but -does not currently support Link-Time-Optimization or C++ Exception Handling, +does not currently support Link-Time +Optimization or C++ Exception Handling, which llvm-gcc3 does.

    +

    llvm-gcc4 does not support the GCC indirect +goto extension, but llvm-gcc3 does.

    +
    @@ -302,28 +481,12 @@ support for floating point data types of any size other than 32 and 64 bits. -
  • The following Unix system functionality has not been tested and may not -work: -
      -
    1. sigsetjmp, siglongjmp - These are not turned into the - appropriate invoke/unwind instructions. Note that - setjmp and longjmp are compiled correctly. -
    2. getcontext, setcontext, makecontext - - These functions have not been tested. -
  • -
  • Although many GCC extensions are supported, some are not. In particular, the following extensions are known to not be supported:
    1. Local Labels: Labels local to a block.
    2. Nested Functions: As in Algol and Pascal, lexical scoping of functions.
    3. Constructing Calls: Dispatching a call to another function.
    4. -
    5. Extended Asm: Assembler instructions with C expressions as operands.
    6. -
    7. Constraints: Constraints for asm operands.
    8. -
    9. Asm Labels: Specifying the assembler name to use for a C symbol.
    10. -
    11. Explicit Reg Vars: Defining variables residing in specified registers.
    12. -
    13. Vector Extensions: Using vector instructions through built-in functions.
    14. -
    15. Target Builtins: Built-in functions specific to particular targets.
    16. Thread-Local: Per-thread variables.
    17. Pragmas: Pragmas accepted by GCC.
    @@ -344,29 +507,31 @@ Declaring that functions have no side effects or that they can never return.
    - Supported: format, format_arg, non_null, - noreturn, constructor, destructor, - unused, used, - deprecated, warn_unused_result, weak
    + Supported: constructor, destructor, + deprecated, fastcall, format, + format_arg, non_null, noreturn, + stdcall, unused, used, + warn_unused_result, weak
    Ignored: noinline, always_inline, pure, const, nothrow, malloc, no_instrument_function, cdecl
    Unsupported: section, alias, - visibility, regparm, stdcall, - fastcall, all other target specific attributes
  • + visibility, regparm, all other target specific + attributes
  • Variable Attributes: Specifying attributes of variables.
    Supported: cleanup, common, nocommon, - deprecated, transparent_union, + deprecated, dllimport, + dllexport, transparent_union, unused, used, weak
    Unsupported: aligned, mode, packed, section, shared, tls_model, - vector_size, dllimport, - dllexport, all target specific attributes.
  • + vector_size, all target specific attributes. +
  • Type Attributes: Specifying attributes of types.
    Supported: transparent_union, unused, @@ -402,6 +567,12 @@
  • Empty Structures: Structures with no members.
  • Variadic Macros: Macros with a variable number of arguments.
  • Escaped Newlines: Slightly looser rules for escaped newlines.
  • +
  • Extended Asm: Assembler instructions with C expressions as operands.
  • +
  • Constraints: Constraints for asm operands.
  • +
  • Asm Labels: Specifying the assembler name to use for a C symbol.
  • +
  • Explicit Reg Vars: Defining variables residing in specified registers.
  • +
  • Vector Extensions: Using vector instructions through built-in functions.
  • +
  • Target Builtins: Built-in functions specific to particular targets.
  • Subscripting: Any array can be subscripted, even if not an lvalue.
  • Pointer Arith: Arithmetic on void-pointers and function pointers.
  • Initializers: Non-constant initializers.
  • @@ -446,26 +617,13 @@
    -
    Bugs
    - -
    - -
      -
    • The C++ front-end inherits all problems afflicting the C - front-end.
    • - -
    - -
    - -
    Notes
    -
      +
    • llvm-gcc4 does not support C++ exception handling at all yet.
    • Destructors for local objects are not always run when a longjmp is performed. In particular, destructors for objects in the longjmping @@ -480,7 +638,7 @@ representation issues. Because we use this API, code generated by the LLVM compilers should be binary compatible with machine code generated by other Itanium ABI C++ compilers (such as G++, the Intel and HP compilers, etc). - However, the exception handling mechanism used by LLVM is very + However, the exception handling mechanism used by llvm-gcc3 is very different from the model used in the Itanium ABI, so exceptions will not interact correctly.
    • @@ -488,134 +646,7 @@
    - - - -
    - -
      - -
    • The C back-end produces code that violates the ANSI C Type-Based Alias -Analysis rules. As such, special options may be necessary to compile the code -(for example, GCC requires the -fno-strict-aliasing option). This -problem probably cannot be fixed.
    • - -
    • Zero arg vararg functions are not -supported. This should not affect LLVM produced by the C or C++ -frontends.
    • - -
    • The C backend does not correctly implement the llvm.stacksave or -llvm.stackrestore -intrinsics. This means that some code compiled by it can run out of stack -space if they depend on these (e.g. C99 varargs).
    • - -
    - -
    - - - - -
    - -
      -
    • none yet.
    • -
    - -
    - - - - - - - - - -
    - -
      - -
    • On 21164s, some rare FP arithmetic sequences which may trap do not have the -appropriate nops inserted to ensure restartability.
    • - -
    - -
    - - - - -
    - -
      - -
    • C++ programs are likely to fail on IA64, as calls to setjmp are -made where the argument is not 16-byte aligned, as required on IA64. (Strictly -speaking this is not a bug in the IA64 back-end; it will also be encountered -when building C++ programs using the C back-end.)
    • - -
    • The C++ front-end does not use IA64 -ABI compliant layout of v-tables. In particular, it just stores function -pointers instead of function descriptors in the vtable. This bug prevents -mixing C++ code compiled with LLVM with C++ objects compiled by other C++ -compilers.
    • - -
    • There are a few ABI violations which will lead to problems when mixing LLVM -output with code built with other compilers, particularly for floating-point -programs.
    • - -
    • Defining vararg functions is not supported (but calling them is ok).
    • - -
    - -
    - - - - -
    - -
      -
    • The SPARC backend only supports the 32-bit SPARC ABI (-m32), it does not - support the 64-bit SPARC ABI (-m64).
    • -
    - -
    - - - - -
    -
      -
    • The ARM backend is currently in early development stages, it is not -ready for production use.
    • -
    - -
    @@ -650,7 +681,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2006/11/01 16:15:04 $ + Last modified: $Date: 2006/11/20 05:20:40 $ From tonic at nondot.org Sun Nov 19 23:52:19 2006 From: tonic at nondot.org (Tanya Lattner) Date: Sun, 19 Nov 2006 23:52:19 -0600 Subject: [llvm-commits] CVS: llvm/docs/CFEBuildInstrs.html Message-ID: <200611200552.kAK5qJpf016861@zion.cs.uiuc.edu> Changes in directory llvm/docs: CFEBuildInstrs.html updated: 1.60 -> 1.61 --- Log message: Changing cfrontend dir to llvm-gcc3.4 as the example. --- Diffs of the changes: (+5 -5) CFEBuildInstrs.html | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) Index: llvm/docs/CFEBuildInstrs.html diff -u llvm/docs/CFEBuildInstrs.html:1.60 llvm/docs/CFEBuildInstrs.html:1.61 --- llvm/docs/CFEBuildInstrs.html:1.60 Thu Nov 16 03:31:19 2006 +++ llvm/docs/CFEBuildInstrs.html Sun Nov 19 23:52:06 2006 @@ -211,8 +211,8 @@
    -
  • Unpack the C/C++ front-end source into cfrontend/src, either by - untar'ing a cfrontend.source.tar.gz file or checking out CVS into this +

  • Unpack the C/C++ front-end source, either by + untar'ing/unzipping a tar.gz file or checking out CVS into this directory.

  • Make "build" and "install" directories as siblings of the "src" tree:

    @@ -221,7 +221,7 @@ csh:
       % pwd
    -  /usr/local/example/cfrontend/src
    +  /usr/local/example/llvm-gcc3.4/src
       % cd ..
       % mkdir build install
       % set CFEINSTALL = `pwd`/install
    @@ -229,7 +229,7 @@
     sh:
     
       % pwd
    -  /usr/local/example/cfrontend/src
    +  /usr/local/example/llvm-gcc3.4/src
       % cd ..
       % mkdir build install
       % export CFEINSTALL=`pwd`/install
    @@ -432,7 +432,7 @@
     
       Brian Gaeke
    LLVM Compiler Infrastructure
    - Last modified: $Date: 2006/11/16 09:31:19 $ + Last modified: $Date: 2006/11/20 05:52:06 $