From criswell at cs.uiuc.edu Mon Aug 25 10:05:01 2003
From: criswell at cs.uiuc.edu (John Criswell)
Date: Mon Aug 25 10:05:01 2003
Subject: [llvm-commits] CVS: llvm/test/QMTestDB/regression.qms/tablegen.qms/2003-08-03-passcode.qmt bitsinitoverflow.qmt cstylecomment.qmt generallist.qmt include.qmt intbitinit.qmt listconversion.qmt tree.qmt treenames.qmt unterminatedcomment.qmt
Message-ID: <200308251504.KAA20322@choi.cs.uiuc.edu>
Changes in directory llvm/test/QMTestDB/regression.qms/tablegen.qms:
2003-08-03-passcode.qmt added (r1.1)
bitsinitoverflow.qmt added (r1.1)
cstylecomment.qmt added (r1.1)
generallist.qmt added (r1.1)
include.qmt added (r1.1)
intbitinit.qmt added (r1.1)
listconversion.qmt added (r1.1)
tree.qmt added (r1.1)
treenames.qmt added (r1.1)
unterminatedcomment.qmt added (r1.1)
---
Log message:
Adding the tablegen tests to the QMTest test suite.
---
Diffs of the changes:
Index: llvm/test/QMTestDB/regression.qms/tablegen.qms/2003-08-03-passcode.qmt
diff -c /dev/null llvm/test/QMTestDB/regression.qms/tablegen.qms/2003-08-03-passcode.qmt:1.1
*** /dev/null Mon Aug 25 10:04:48 2003
--- llvm/test/QMTestDB/regression.qms/tablegen.qms/2003-08-03-passcode.qmt Mon Aug 25 10:04:38 2003
***************
*** 0 ****
--- 1,2 ----
+
+ .*test/Regression/TableGen/2003-08-03-PassCode.td
Index: llvm/test/QMTestDB/regression.qms/tablegen.qms/bitsinitoverflow.qmt
diff -c /dev/null llvm/test/QMTestDB/regression.qms/tablegen.qms/bitsinitoverflow.qmt:1.1
*** /dev/null Mon Aug 25 10:04:48 2003
--- llvm/test/QMTestDB/regression.qms/tablegen.qms/bitsinitoverflow.qmt Mon Aug 25 10:04:38 2003
***************
*** 0 ****
--- 1,2 ----
+
+ .*test/Regression/TableGen/BitsInitOverflow.td
Index: llvm/test/QMTestDB/regression.qms/tablegen.qms/cstylecomment.qmt
diff -c /dev/null llvm/test/QMTestDB/regression.qms/tablegen.qms/cstylecomment.qmt:1.1
*** /dev/null Mon Aug 25 10:04:48 2003
--- llvm/test/QMTestDB/regression.qms/tablegen.qms/cstylecomment.qmt Mon Aug 25 10:04:38 2003
***************
*** 0 ****
--- 1,2 ----
+
+ .*test/Regression/TableGen/CStyleComment.td
Index: llvm/test/QMTestDB/regression.qms/tablegen.qms/generallist.qmt
diff -c /dev/null llvm/test/QMTestDB/regression.qms/tablegen.qms/generallist.qmt:1.1
*** /dev/null Mon Aug 25 10:04:48 2003
--- llvm/test/QMTestDB/regression.qms/tablegen.qms/generallist.qmt Mon Aug 25 10:04:38 2003
***************
*** 0 ****
--- 1,2 ----
+
+ .*test/Regression/TableGen/GeneralList.td
Index: llvm/test/QMTestDB/regression.qms/tablegen.qms/include.qmt
diff -c /dev/null llvm/test/QMTestDB/regression.qms/tablegen.qms/include.qmt:1.1
*** /dev/null Mon Aug 25 10:04:48 2003
--- llvm/test/QMTestDB/regression.qms/tablegen.qms/include.qmt Mon Aug 25 10:04:38 2003
***************
*** 0 ****
--- 1,2 ----
+
+ .*test/Regression/TableGen/Include.td
Index: llvm/test/QMTestDB/regression.qms/tablegen.qms/intbitinit.qmt
diff -c /dev/null llvm/test/QMTestDB/regression.qms/tablegen.qms/intbitinit.qmt:1.1
*** /dev/null Mon Aug 25 10:04:48 2003
--- llvm/test/QMTestDB/regression.qms/tablegen.qms/intbitinit.qmt Mon Aug 25 10:04:38 2003
***************
*** 0 ****
--- 1,2 ----
+
+ .*test/Regression/TableGen/IntBitInit.td
Index: llvm/test/QMTestDB/regression.qms/tablegen.qms/listconversion.qmt
diff -c /dev/null llvm/test/QMTestDB/regression.qms/tablegen.qms/listconversion.qmt:1.1
*** /dev/null Mon Aug 25 10:04:48 2003
--- llvm/test/QMTestDB/regression.qms/tablegen.qms/listconversion.qmt Mon Aug 25 10:04:38 2003
***************
*** 0 ****
--- 1,2 ----
+
+ .*test/Regression/TableGen/ListConversion.td
Index: llvm/test/QMTestDB/regression.qms/tablegen.qms/tree.qmt
diff -c /dev/null llvm/test/QMTestDB/regression.qms/tablegen.qms/tree.qmt:1.1
*** /dev/null Mon Aug 25 10:04:48 2003
--- llvm/test/QMTestDB/regression.qms/tablegen.qms/tree.qmt Mon Aug 25 10:04:38 2003
***************
*** 0 ****
--- 1,2 ----
+
+ .*test/Regression/TableGen/Tree.td
Index: llvm/test/QMTestDB/regression.qms/tablegen.qms/treenames.qmt
diff -c /dev/null llvm/test/QMTestDB/regression.qms/tablegen.qms/treenames.qmt:1.1
*** /dev/null Mon Aug 25 10:04:48 2003
--- llvm/test/QMTestDB/regression.qms/tablegen.qms/treenames.qmt Mon Aug 25 10:04:38 2003
***************
*** 0 ****
--- 1,2 ----
+
+ .*test/Regression/TableGen/TreeNames.td
Index: llvm/test/QMTestDB/regression.qms/tablegen.qms/unterminatedcomment.qmt
diff -c /dev/null llvm/test/QMTestDB/regression.qms/tablegen.qms/unterminatedcomment.qmt:1.1
*** /dev/null Mon Aug 25 10:04:48 2003
--- llvm/test/QMTestDB/regression.qms/tablegen.qms/unterminatedcomment.qmt Mon Aug 25 10:04:38 2003
***************
*** 0 ****
--- 1,2 ----
+
+ .*test/Regression/TableGen/UnterminatedComment.td
From criswell at cs.uiuc.edu Mon Aug 25 10:05:05 2003
From: criswell at cs.uiuc.edu (John Criswell)
Date: Mon Aug 25 10:05:05 2003
Subject: [llvm-commits] CVS: llvm/test/QMTestDB/regression.qms/tablegen.qms/
Message-ID: <200308251504.KAA20289@choi.cs.uiuc.edu>
Changes in directory llvm/test/QMTestDB/regression.qms/tablegen.qms:
---
Log message:
Directory /home/vadve/vadve/Research/DynOpt/CVSRepository/llvm/test/QMTestDB/regression.qms/tablegen.qms added to the repository
---
Diffs of the changes:
From criswell at cs.uiuc.edu Mon Aug 25 10:22:01 2003
From: criswell at cs.uiuc.edu (John Criswell)
Date: Mon Aug 25 10:22:01 2003
Subject: [llvm-commits] CVS: llvm/test/QMTestDB/regression.qms/transforms.qms/decomposemultidimrefs.qms/multidim.qmt
Message-ID: <200308251521.KAA20369@choi.cs.uiuc.edu>
Changes in directory llvm/test/QMTestDB/regression.qms/transforms.qms/decomposemultidimrefs.qms:
multidim.qmt added (r1.1)
---
Log message:
Adding to the QMTest based test suite.
---
Diffs of the changes:
Index: llvm/test/QMTestDB/regression.qms/transforms.qms/decomposemultidimrefs.qms/multidim.qmt
diff -c /dev/null llvm/test/QMTestDB/regression.qms/transforms.qms/decomposemultidimrefs.qms/multidim.qmt:1.1
*** /dev/null Mon Aug 25 10:21:55 2003
--- llvm/test/QMTestDB/regression.qms/transforms.qms/decomposemultidimrefs.qms/multidim.qmt Mon Aug 25 10:21:45 2003
***************
*** 0 ****
--- 1,2 ----
+
+ .*test/Regression/Transforms/DecomposeMultiDimRefs/multidim.ll
From criswell at cs.uiuc.edu Mon Aug 25 10:22:02 2003
From: criswell at cs.uiuc.edu (John Criswell)
Date: Mon Aug 25 10:22:02 2003
Subject: [llvm-commits] CVS: llvm/test/QMTestDB/regression.qms/transforms.qms/decomposemultidimrefs.qms/
Message-ID: <200308251521.KAA20355@choi.cs.uiuc.edu>
Changes in directory llvm/test/QMTestDB/regression.qms/transforms.qms/decomposemultidimrefs.qms:
---
Log message:
Directory /home/vadve/vadve/Research/DynOpt/CVSRepository/llvm/test/QMTestDB/regression.qms/transforms.qms/decomposemultidimrefs.qms added to the repository
---
Diffs of the changes:
From criswell at cs.uiuc.edu Mon Aug 25 11:51:02 2003
From: criswell at cs.uiuc.edu (John Criswell)
Date: Mon Aug 25 11:51:02 2003
Subject: [llvm-commits] CVS: llvm/autoconf/configure.ac
Message-ID: <200308251650.LAA12627@choi.cs.uiuc.edu>
Changes in directory llvm/autoconf:
configure.ac updated: 1.5 -> 1.6
---
Log message:
Added code to check for python and qmtest.
Added code that verifies that GCC is version 3.0 or higher.
---
Diffs of the changes:
Index: llvm/autoconf/configure.ac
diff -u llvm/autoconf/configure.ac:1.5 llvm/autoconf/configure.ac:1.6
--- llvm/autoconf/configure.ac:1.5 Thu Aug 14 13:59:53 2003
+++ llvm/autoconf/configure.ac Mon Aug 25 11:49:54 2003
@@ -93,6 +93,13 @@
AC_MSG_ERROR([g++ required but not found])
fi
+dnl Verify that GCC is version 3.0 or higher
+gccmajor=`$CC --version | head -n 1 | awk '{print $NF;}' | cut -d. -f1`
+if test "$gccmajor" -lt "3"
+then
+ AC_MSG_ERROR([gcc 3.x required])
+fi
+
dnl Check for GNU Make. We use its extensions to, so don't build without it
CHECK_GNU_MAKE
if test -z "$_cv_gnu_make_command"
@@ -108,6 +115,7 @@
AC_PROG_LIBTOOL
dnl Check for our special programs
+AC_PATH_PROG(RPWD,[pwd])
AC_PATH_PROG(AR,[ar])
AC_PATH_PROG(SED,[sed])
AC_PATH_PROG(RM,[rm])
@@ -118,6 +126,26 @@
AC_PATH_PROG(DOT,[dot])
AC_PATH_PROG(ETAGS,[etags])
AC_PATH_PROG(PURIFY,[purify])
+AC_PATH_PROG(PYTHON,[python])
+AC_PATH_PROG(QMTEST,[qmtest])
+
+dnl Verify that the version of python available is high enough for qmtest
+pyversion=`$PYTHON -V 2>&1 | cut -d\ -f2`
+pymajor=`echo $pyversion | cut -d. -f1`
+pyminor=`echo $pyversion | cut -d. -f2`
+
+if test "$pymajor" -ge "2"
+then
+ if test "$pymajor" -eq "2"
+ then
+ if test "$pyminor" -lt "2"
+ then
+ AC_MSG_ERROR([Python 2.2 or greater required])
+ fi
+ fi
+else
+ AC_MSG_ERROR([Python 2.2 or greater required])
+fi
dnl Verify that the source directory is valid
AC_CONFIG_SRCDIR(["Makefile.config.in"])
@@ -324,6 +352,10 @@
fi
AC_ARG_WITH(objroot,AC_HELP_STRING([--with-objroot],[Location where object files should be placed (default is .)]),AC_SUBST(OBJROOT,[$withval]))
+
+dnl **************************************************************************
+dnl * Configure other software packages (via AC_CONFIG_SUBDIRS)
+dnl **************************************************************************
dnl **************************************************************************
dnl * Create the output files
From criswell at cs.uiuc.edu Mon Aug 25 11:51:04 2003
From: criswell at cs.uiuc.edu (John Criswell)
Date: Mon Aug 25 11:51:04 2003
Subject: [llvm-commits] CVS: llvm/configure
Message-ID: <200308251650.LAA12620@choi.cs.uiuc.edu>
Changes in directory llvm:
configure updated: 1.12 -> 1.13
---
Log message:
Added code to check for python and qmtest.
Added code that verifies that GCC is version 3.0 or higher.
---
Diffs of the changes:
Index: llvm/configure
diff -u llvm/configure:1.12 llvm/configure:1.13
--- llvm/configure:1.12 Thu Jul 31 11:45:35 2003
+++ llvm/configure Mon Aug 25 11:49:50 2003
@@ -464,7 +464,7 @@
#endif"
ac_unique_file=""Makefile.config.in""
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os OS LLVMGCCDIR ARCH CXX CXXFLAGS LDFLAGS CPPFLAGS ac_ct_CXX EXEEXT OBJEXT CC CFLAGS ac_ct_CC CPP ifGNUmake LEX LEXLIB LEX_OUTPUT_ROOT YACC EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB STRIP ac_ct_STRIP CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL SED RM MKDIR DATE MV DOT ETAGS PURIFY ALLOCA LIBOBJS MMAP_FILE ENABLE_PURIFY ENABLE_OPTIMIZED USE_SPEC UPB DISABLE_LLC_DIFFS JIT SPEC_ROOT BCR PAPIDIR OBJROOT LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os OS LLVMGCCDIR ARCH CXX CXXFLAGS LDFLAGS CPPFLAGS ac_ct_CXX EXEEXT OBJEXT CC CFLAGS ac_ct_CC CPP ifGNUmake LEX LEXLIB LEX_OUTPUT_ROOT YACC EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB STRIP ac_ct_STRIP CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL RPWD SED RM MKDIR DATE MV DOT ETAGS PURIFY PYTHON QMTEST ALLOCA LIBOBJS MMAP_FILE ENABLE_PURIFY ENABLE_OPTIMIZED USE_SPEC UPB DISABLE_LLC_DIFFS JIT SPEC_ROOT BCR PAPIDIR OBJROOT LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
@@ -2930,6 +2930,14 @@
{ (exit 1); exit 1; }; }
fi
+gccmajor=`$CC --version | head -n 1 | awk '{print $NF;}' | cut -d. -f1`
+if test "$gccmajor" -lt "3"
+then
+ { { echo "$as_me:$LINENO: error: gcc 3.x required" >&5
+echo "$as_me: error: gcc 3.x required" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
echo "$as_me:$LINENO: checking for GNU make" >&5
echo $ECHO_N "checking for GNU make... $ECHO_C" >&6
if test "${_cv_gnu_make_command+set}" = set; then
@@ -3852,7 +3860,7 @@
;;
*-*-irix6*)
# Find out which ABI we are using.
- echo '#line 3855 "configure"' > conftest.$ac_ext
+ echo '#line 3863 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
@@ -4693,7 +4701,7 @@
# Provide some information about the compiler.
-echo "$as_me:4696:" \
+echo "$as_me:4704:" \
"checking for Fortran 77 compiler version" >&5
ac_compiler=`set X $ac_compile; echo $2`
{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5
@@ -5702,11 +5710,11 @@
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:5705: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:5713: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:5709: \$? = $ac_status" >&5
+ echo "$as_me:5717: \$? = $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
@@ -5934,11 +5942,11 @@
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:5937: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:5945: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:5941: \$? = $ac_status" >&5
+ echo "$as_me:5949: \$? = $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
@@ -6001,11 +6009,11 @@
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:6004: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:6012: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:6008: \$? = $ac_status" >&5
+ echo "$as_me:6016: \$? = $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
@@ -8013,7 +8021,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:10258: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:10254: \$? = $ac_status" >&5
+ echo "$as_me:10262: \$? = $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
@@ -10314,11 +10322,11 @@
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:10317: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:10325: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:10321: \$? = $ac_status" >&5
+ echo "$as_me:10329: \$? = $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
@@ -11557,7 +11565,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:12488: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:12484: \$? = $ac_status" >&5
+ echo "$as_me:12492: \$? = $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
@@ -12544,11 +12552,11 @@
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:12547: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:12555: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:12551: \$? = $ac_status" >&5
+ echo "$as_me:12559: \$? = $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
@@ -14488,11 +14496,11 @@
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:14491: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:14499: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:14495: \$? = $ac_status" >&5
+ echo "$as_me:14503: \$? = $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
@@ -14720,11 +14728,11 @@
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:14723: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:14731: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:14727: \$? = $ac_status" >&5
+ echo "$as_me:14735: \$? = $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
@@ -14787,11 +14795,11 @@
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:14790: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:14798: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:14794: \$? = $ac_status" >&5
+ echo "$as_me:14802: \$? = $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
@@ -16799,7 +16807,7 @@
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext < conftest.$ac_ext <&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_RPWD+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ case $RPWD in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_RPWD="$RPWD" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_RPWD="$as_dir/$ac_word$ac_exec_ext"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+ ;;
+esac
+fi
+RPWD=$ac_cv_path_RPWD
+
+if test -n "$RPWD"; then
+ echo "$as_me:$LINENO: result: $RPWD" >&5
+echo "${ECHO_T}$RPWD" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
# Extract the first word of "ar", so it can be a program name with args.
set dummy ar; ac_word=$2
echo "$as_me:$LINENO: checking for $ac_word" >&5
@@ -18294,6 +18341,105 @@
echo "${ECHO_T}no" >&6
fi
+# Extract the first word of "python", so it can be a program name with args.
+set dummy python; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_PYTHON+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ case $PYTHON in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_PYTHON="$PYTHON" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_PYTHON="$as_dir/$ac_word$ac_exec_ext"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+ ;;
+esac
+fi
+PYTHON=$ac_cv_path_PYTHON
+
+if test -n "$PYTHON"; then
+ echo "$as_me:$LINENO: result: $PYTHON" >&5
+echo "${ECHO_T}$PYTHON" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+# Extract the first word of "qmtest", so it can be a program name with args.
+set dummy qmtest; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_QMTEST+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ case $QMTEST in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_QMTEST="$QMTEST" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_QMTEST="$as_dir/$ac_word$ac_exec_ext"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+ ;;
+esac
+fi
+QMTEST=$ac_cv_path_QMTEST
+
+if test -n "$QMTEST"; then
+ echo "$as_me:$LINENO: result: $QMTEST" >&5
+echo "${ECHO_T}$QMTEST" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+
+pyversion=`$PYTHON -V 2>&1 | cut -d\ -f2`
+pymajor=`echo $pyversion | cut -d. -f1`
+pyminor=`echo $pyversion | cut -d. -f2`
+
+if test "$pymajor" -ge "2"
+then
+ if test "$pymajor" -eq "2"
+ then
+ if test "$pyminor" -lt "2"
+ then
+ { { echo "$as_me:$LINENO: error: Python 2.2 or greater required" >&5
+echo "$as_me: error: Python 2.2 or greater required" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+ fi
+else
+ { { echo "$as_me:$LINENO: error: Python 2.2 or greater required" >&5
+echo "$as_me: error: Python 2.2 or greater required" >&2;}
+ { (exit 1); exit 1; }; }
+fi
@@ -22067,7 +22213,7 @@
PAPIDIR=$withval
else
- PAPIDIR=/home/vadve/shared/papi-2.3.4.1
+ PAPIDIR=/home/vadve/shared/Sparc/papi-2.3.4.1
fi;
@@ -22102,6 +22248,7 @@
fi;
+
ac_config_files="$ac_config_files Makefile.config"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@@ -22761,6 +22908,7 @@
s, at FFLAGS@,$FFLAGS,;t t
s, at ac_ct_F77@,$ac_ct_F77,;t t
s, at LIBTOOL@,$LIBTOOL,;t t
+s, at RPWD@,$RPWD,;t t
s, at SED@,$SED,;t t
s, at RM@,$RM,;t t
s, at MKDIR@,$MKDIR,;t t
@@ -22769,6 +22917,8 @@
s, at DOT@,$DOT,;t t
s, at ETAGS@,$ETAGS,;t t
s, at PURIFY@,$PURIFY,;t t
+s, at PYTHON@,$PYTHON,;t t
+s, at QMTEST@,$QMTEST,;t t
s, at ALLOCA@,$ALLOCA,;t t
s, at LIBOBJS@,$LIBOBJS,;t t
s, at MMAP_FILE@,$MMAP_FILE,;t t
From criswell at cs.uiuc.edu Mon Aug 25 11:53:01 2003
From: criswell at cs.uiuc.edu (John Criswell)
Date: Mon Aug 25 11:53:01 2003
Subject: [llvm-commits] CVS: llvm/www/docs/ReleaseTasks.html
Message-ID: <200308251651.LAA14806@tank.cs.uiuc.edu>
Changes in directory llvm/www/docs:
ReleaseTasks.html updated: 1.8 -> 1.9
---
Log message:
Added autoconf code that verifies that the C compiler is at the minimum
supported version (3.x).
---
Diffs of the changes:
Index: llvm/www/docs/ReleaseTasks.html
diff -u llvm/www/docs/ReleaseTasks.html:1.8 llvm/www/docs/ReleaseTasks.html:1.9
--- llvm/www/docs/ReleaseTasks.html:1.8 Thu Aug 21 10:25:55 2003
+++ llvm/www/docs/ReleaseTasks.html Mon Aug 25 11:51:44 2003
@@ -118,7 +118,6 @@
Move the Reoptimizer code out of mainline CVS and the release.
- Add autoconf checks to ensure that the compiler is GCC 3.x or higher.
Documentation
From gaeke at cs.uiuc.edu Mon Aug 25 12:30:01 2003
From: gaeke at cs.uiuc.edu (Brian Gaeke)
Date: Mon Aug 25 12:30:01 2003
Subject: [llvm-commits] CVS: llvm/test/Regression/Linker/2003-08-23-RecursiveOpaqueTypeResolve.ll
Message-ID: <200308251729.MAA10874@trinity.cs.uiuc.edu>
Changes in directory llvm/test/Regression/Linker:
2003-08-23-RecursiveOpaqueTypeResolve.ll updated: 1.1 -> 1.2
---
Log message:
Fix spelling error in comment.
---
Diffs of the changes:
Index: llvm/test/Regression/Linker/2003-08-23-RecursiveOpaqueTypeResolve.ll
diff -u llvm/test/Regression/Linker/2003-08-23-RecursiveOpaqueTypeResolve.ll:1.1 llvm/test/Regression/Linker/2003-08-23-RecursiveOpaqueTypeResolve.ll:1.2
--- llvm/test/Regression/Linker/2003-08-23-RecursiveOpaqueTypeResolve.ll:1.1 Sat Aug 23 16:13:26 2003
+++ llvm/test/Regression/Linker/2003-08-23-RecursiveOpaqueTypeResolve.ll Mon Aug 25 12:29:40 2003
@@ -1,4 +1,4 @@
-; It's a bad idea to go recursively trapesing through types without a safety
+; It's a bad idea to go recursively traipsing through types without a safety
; net.
; RUN: as < %s > Output/%s.out1.bc
From lattner at cs.uiuc.edu Mon Aug 25 17:35:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon Aug 25 17:35:01 2003
Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/InlineFunction.cpp
Message-ID: <200308252234.RAA10300@apoc.cs.uiuc.edu>
Changes in directory llvm/lib/Transforms/Utils:
InlineFunction.cpp updated: 1.4 -> 1.5
---
Log message:
Remove special casing
---
Diffs of the changes:
Index: llvm/lib/Transforms/Utils/InlineFunction.cpp
diff -u llvm/lib/Transforms/Utils/InlineFunction.cpp:1.4 llvm/lib/Transforms/Utils/InlineFunction.cpp:1.5
--- llvm/lib/Transforms/Utils/InlineFunction.cpp:1.4 Sun Aug 24 07:24:11 2003
+++ llvm/lib/Transforms/Utils/InlineFunction.cpp Mon Aug 25 17:34:15 2003
@@ -211,9 +211,6 @@
}
break; // Done with this basic block!
- } else if (ID == LLVMIntrinsic::exc_setcurrent ||
- ID == LLVMIntrinsic::exc_getcurrent) {
- ShouldInvokify = false; // Not correct to invokify exc.throw!
}
// If we should convert this function into an invoke instruction, do
From lattner at cs.uiuc.edu Mon Aug 25 17:36:00 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon Aug 25 17:36:00 2003
Subject: [llvm-commits] CVS: llvm/runtime/GCCLibraries/libexception/Makefile c++-exception.cpp c++-exception.h exception.h
Message-ID: <200308252235.RAA10562@apoc.cs.uiuc.edu>
Changes in directory llvm/runtime/GCCLibraries/libexception:
Makefile added (r1.1)
c++-exception.cpp added (r1.1)
c++-exception.h added (r1.1)
exception.h added (r1.1)
---
Log message:
Initial checking of C++ exception handling library
---
Diffs of the changes:
Index: llvm/runtime/GCCLibraries/libexception/Makefile
diff -c /dev/null llvm/runtime/GCCLibraries/libexception/Makefile:1.1
*** /dev/null Mon Aug 25 17:35:47 2003
--- llvm/runtime/GCCLibraries/libexception/Makefile Mon Aug 25 17:35:36 2003
***************
*** 0 ****
--- 1,17 ----
+ LEVEL = ../../..
+ BYTECODE_LIBRARY=1
+ DONT_BUILD_RELINKED=1
+ LIBRARYNAME=exception
+
+ #Source = crtend.c listend.ll
+
+ ###EXPORTED_SYMBOL_LIST = __main,llvm.global_ctors,llvm.global_dtors
+
+ include $(LEVEL)/Makefile.common
+
+
+ $(LLVMGCCDIR)/bytecode-libs/crtend.o: $(LIBNAME_BC)
+ @cp $< $@
+
+ install:: $(LLVMGCCDIR)/bytecode-libs/crtend.o
+ @rm $(LLVMGCCDIR)/bytecode-libs/libcrtend.bc
Index: llvm/runtime/GCCLibraries/libexception/c++-exception.cpp
diff -c /dev/null llvm/runtime/GCCLibraries/libexception/c++-exception.cpp:1.1
*** /dev/null Mon Aug 25 17:35:47 2003
--- llvm/runtime/GCCLibraries/libexception/c++-exception.cpp Mon Aug 25 17:35:36 2003
***************
*** 0 ****
--- 1,223 ----
+ //===- c++-exception.cpp - Exception handling support for C++ exceptions --===//
+ //
+ // This file defines the methods used to implement C++ exception handling in
+ // terms of the invoke and %llvm.unwind intrinsic. These primitives implement
+ // an exception handling ABI similar (but simpler and more efficient than) the
+ // Itanium C++ ABI exception handling standard.
+ //
+ //===----------------------------------------------------------------------===//
+
+ #include "c++-exception.h"
+ #include
+ #include
+
+ //===----------------------------------------------------------------------===//
+ // Generic exception support
+ //
+
+ // Thread local state for exception handling.
+ // FIXME: This should really be made thread-local!
+ //
+ static llvm_exception *CaughtExceptionStack = 0;
+
+ // 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(void) {
+ 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) {
+ assert(UncaughtExceptionStack && "No uncaught exception!");
+ if (UncaughtExceptionStack->ExceptionType == HandlerType)
+ return UncaughtExceptionStack+1;
+ return 0;
+ }
+
+
+ /*===----------------------------------------------------------------------===**
+ * C++ Specific exception handling support...
+ */
+
+ // __llvm_cxxeh_allocate_exception - This function allocates space for the
+ // specified number of bytes, plus a C++ exception object header.
+ //
+ void *__llvm_cxxeh_allocate_exception(unsigned NumBytes) {
+ // FIXME: This should eventually have back-up buffers for out-of-memory
+ // situations.
+ //
+ llvm_cxx_exception *E =
+ (llvm_cxx_exception *)malloc(NumBytes+sizeof(llvm_cxx_exception));
+ E->BaseException.ExceptionType = 0; // intialize to invalid
+
+ return E+1; // return the pointer after the header
+ }
+
+ // __llvm_cxxeh_free_exception - Low-level function to free an exception. This
+ // is called directly from generated C++ code if evaluating the exception value
+ // into the exception location throws. Otherwise it is called from the C++
+ // exception object destructor.
+ //
+ void __llvm_cxxeh_free_exception(void *ObjectPtr) {
+ llvm_cxx_exception *E = (llvm_cxx_exception *)ObjectPtr - 1;
+ free(E);
+ }
+
+ // cxx_destructor - This function is called through the generic
+ // exception->ExceptionDestructor function pointer to destroy a caught
+ // exception.
+ //
+ static void cxx_destructor(llvm_exception *LE) {
+ void *ObjectPtr = LE+1;
+ llvm_cxx_exception *E = (llvm_cxx_exception *)ObjectPtr - 1;
+
+ // The exception is no longer caught.
+ assert(CaughtExceptionStack == LE &&
+ "Destroying an exception which is not the current caught exception?");
+ CaughtExceptionStack = LE->Next;
+
+ struct ExceptionFreer {
+ void *Ptr;
+ ExceptionFreer(void *P) : Ptr(P) {}
+ ~ExceptionFreer() {
+ // Free the memory for the exception, when the function is left, even if
+ // the exception object dtor throws its own exception!
+ __llvm_cxxeh_free_exception(Ptr);
+ }
+ } EF(E+1);
+
+ // Run the exception object dtor if it exists. */
+ if (E->ExceptionObjectDestructor)
+ E->ExceptionObjectDestructor(E);
+ }
+
+ // __llvm_cxxeh_throw - Given a pointer to memory which has an exception object
+ // evaluated into it, this sets up all of the fields of the exception allowing
+ // it to be thrown. After calling this, the code should call %llvm.unwind
+ //
+ void __llvm_cxxeh_throw(void *ObjectPtr, const std::type_info *TypeInfoPtr,
+ void (*DtorPtr)(void*)) {
+ llvm_cxx_exception *E = (llvm_cxx_exception *)ObjectPtr - 1;
+ E->BaseException.ExceptionDestructor = cxx_destructor;
+ E->BaseException.ExceptionType = CXXException;
+ E->BaseException.Next = UncaughtExceptionStack;
+ UncaughtExceptionStack = &E->BaseException;
+ E->BaseException.HandlerCount = 0;
+
+ E->TypeInfo = TypeInfoPtr;
+ E->ExceptionObjectDestructor = DtorPtr;
+ E->UnexpectedHandler = 0; /* FIXME */
+ E->TerminateHandler = 0; /* FIXME */
+ }
+
+ // __llvm_cxxeh_current_uncaught_exception_isa - This function checks to see if
+ // the current uncaught exception is a C++ exception, and if it is of the
+ // specified type id. If so, it returns a pointer to the object adjusted as
+ // appropriate, otherwise it returns null.
+ //
+ void *__llvm_cxxeh_current_uncaught_exception_isa(
+ const std::type_info *CatchType) {
+ assert(UncaughtExceptionStack && "No uncaught exception!");
+ if (UncaughtExceptionStack->ExceptionType != CXXException)
+ return 0; /* If it's not a c++ exception, it doesn't match! */
+
+ // If it is a C++ exception, use the type info object stored in the exception
+ // to see if TypeID matches and, if so, to adjust the exception object
+ // pointer.
+ //
+ llvm_cxx_exception *E = (llvm_cxx_exception*)UncaughtExceptionStack;
+
+ // ThrownPtr is a pointer to the object being thrown...
+ void *ThrownPtr = E+1;
+ const std::type_info *ThrownType = E->TypeInfo;
+
+ // FIXME: this code exists in the GCC exception handling library: I haven't
+ // thought about this yet, so it should be verified at some point!
+ #if 1
+ // Pointer types need to adjust the actual pointer, not
+ // the pointer to pointer that is the exception object.
+ // This also has the effect of passing pointer types
+ // "by value" through the __cxa_begin_catch return value.
+ if (ThrownType->__is_pointer_p())
+ ThrownPtr = *(void **)ThrownPtr;
+ #endif
+
+ if (CatchType->__do_catch(ThrownType, &ThrownPtr, 1))
+ return ThrownPtr;
+
+ return 0;
+ }
+
+
+ /* __llvm_cxxeh_begin_catch - This function is called by "exception handlers",
+ * which transition an exception from being uncaught to being caught. It
+ * returns a pointer to the exception object portion of the exception. This
+ * function must work with foreign exceptions.
+ */
+ void *__llvm_cxxeh_begin_catch(void) {
+ llvm_exception *E = UncaughtExceptionStack;
+ assert(UncaughtExceptionStack && "There are no uncaught exceptions!?!?");
+
+ /* The exception is now no longer uncaught... */
+ UncaughtExceptionStack = E->Next;
+
+ /* The exception is now caught... */
+ E->Next = CaughtExceptionStack;
+ CaughtExceptionStack = E->Next;
+
+ /* Increment the handler count for this exception. */
+ E->HandlerCount++;
+
+ /* Return a pointer to the exception object */
+ return E+1;
+ }
+
+ /* __llvm_cxxeh_end_catch - This function decrements the HandlerCount of the
+ * top-level caught exception, destroying it if this is the last handler for the
+ * exception.
+ */
+ void __llvm_cxxeh_end_catch(void) {
+ llvm_exception *E = CaughtExceptionStack;
+ assert(E && "There are no caught exceptions!");
+
+ /* If this is the last handler using the exception, destroy it now! */
+ if (--E->HandlerCount == 0) {
+ CaughtExceptionStack = E->Next; /* Unlink from the stack */
+ E->ExceptionDestructor(E); /* Release memory for the exception */
+ }
+ }
+
+ /* __llvm_cxxeh_rethrow - This function turns the top-level caught exception
+ * into an uncaught exception, in preparation for an llvm.unwind, which should
+ * follow immediately after the call to this function. This function must be
+ * prepared to deal with foreign exceptions.
+ */
+ void __llvm_cxxeh_rethrow(void) {
+ llvm_exception *E = CaughtExceptionStack;
+ if (E == 0) {
+ /* 15.1.8 - If there are no uncaught exceptions being thrown, 'throw;'
+ * should call terminate.
+ */
+ /* FIXME */assert(0 && "FIXME: this should call E->Terminate!");
+ }
+
+ /* Otherwise we have an exception to rethrow. Move it back to the uncaught
+ * stack.
+ */
+ CaughtExceptionStack = E->Next;
+ E->Next = UncaughtExceptionStack;
+ UncaughtExceptionStack = E;
+
+ /* Decrement the number of handlers which are using the exception. */
+ --E->HandlerCount;
+
+ /* Return to the caller, which should perform the unwind now. */
+ }
+
Index: llvm/runtime/GCCLibraries/libexception/c++-exception.h
diff -c /dev/null llvm/runtime/GCCLibraries/libexception/c++-exception.h:1.1
*** /dev/null Mon Aug 25 17:35:47 2003
--- llvm/runtime/GCCLibraries/libexception/c++-exception.h Mon Aug 25 17:35:36 2003
***************
*** 0 ****
--- 1,62 ----
+ //===- c++-exception.h - C++ Specific exception Handling --------*- C++ -*-===//
+ //
+ // This file defines the data structures and API used by the C++ exception
+ // handling runtime library.
+ //
+ //===----------------------------------------------------------------------===//
+
+ #ifndef CXX_EXCEPTION_H
+ #define CXX_EXCEPTION_H
+
+ #include "exception.h"
+ #include
+
+ typedef struct llvm_cxx_exception {
+ /* TypeInfo - A pointer to the C++ std::type_info object for this exception
+ * class. This is required because the class may not be polymorphic.
+ */
+ const std::type_info *TypeInfo;
+
+ /* ExceptionObjectDestructor - A pointer to the function which destroys the
+ * object represented by this exception. This is required because the class
+ * may not be polymorphic. This may be null if there is no cleanup required.
+ */
+ void (*ExceptionObjectDestructor)(void *);
+
+ /* UnexpectedHandler - This contains a pointer to the "unexpected" handler
+ * which may be registered by the user program with set_unexpected. Calls to
+ * unexpected which are a result of an exception throw are supposed to use the
+ * value of the handler at the time of the throw, not the currently set value.
+ */
+ void *UnexpectedHandler;
+
+ /* TerminateHandler - This contains a pointer to the "terminate" handler which
+ * may be registered by the user program with set_terminate. Calls to
+ * unexpected which are a result of an exception throw are supposed to use the
+ * value of the handler at the time of the throw, not the currently set value.
+ */
+ void *TerminateHandler;
+
+ /* 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;
+ } llvm_cxx_exception;
+
+
+
+ extern "C" {
+ void *__llvm_cxxeh_allocate_exception(unsigned NumBytes);
+ void __llvm_cxxeh_free_exception(void *ObjectPtr);
+ void __llvm_cxxeh_throw(void *ObjectPtr, const std::type_info *TypeInfoPtr,
+ void (*DtorPtr)(void*));
+
+ void * __llvm_cxxeh_current_uncaught_exception_isa(const std::type_info *Ty);
+ void *__llvm_cxxeh_begin_catch(void);
+ void __llvm_cxxeh_end_catch(void);
+
+ void __llvm_cxxeh_rethrow(void);
+ }
+
+ #endif
Index: llvm/runtime/GCCLibraries/libexception/exception.h
diff -c /dev/null llvm/runtime/GCCLibraries/libexception/exception.h:1.1
*** /dev/null Mon Aug 25 17:35:47 2003
--- llvm/runtime/GCCLibraries/libexception/exception.h Mon Aug 25 17:35:36 2003
***************
*** 0 ****
--- 1,49 ----
+ //===- exception.h - Generic language-independent exceptions ----*- C++ -*-===//
+ //
+ // This file defines the the shared data structures used by all language
+ // specific exception handling runtime libraries.
+ //
+ //===----------------------------------------------------------------------===//
+
+ #ifndef EXCEPTION_H
+ #define EXCEPTION_H
+
+ typedef 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)(struct 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.
+ struct 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;
+ } llvm_exception;
+
+ enum {
+ ErrorException = 0,
+ LongjmpException = 1,
+ CXXException = 2,
+ };
+
+ // Language independent exception handling API...
+ //
+ extern "C" {
+ bool __llvm_eh_has_uncaught_exception(void);
+ void *__llvm_eh_current_uncaught_exception_type(unsigned HandlerType);
+ }
+
+ #endif
From lattner at cs.uiuc.edu Mon Aug 25 17:36:02 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon Aug 25 17:36:02 2003
Subject: [llvm-commits] CVS: llvm/runtime/GCCLibraries/libexception/
Message-ID: <200308252235.RAA10544@apoc.cs.uiuc.edu>
Changes in directory llvm/runtime/GCCLibraries/libexception:
---
Log message:
Directory /home/vadve/vadve/Research/DynOpt/CVSRepository/llvm/runtime/GCCLibraries/libexception added to the repository
---
Diffs of the changes:
From lattner at cs.uiuc.edu Mon Aug 25 17:36:03 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon Aug 25 17:36:03 2003
Subject: [llvm-commits] CVS: llvm/lib/VMCore/Function.cpp Verifier.cpp
Message-ID: <200308252235.RAA10532@apoc.cs.uiuc.edu>
Changes in directory llvm/lib/VMCore:
Function.cpp updated: 1.45 -> 1.46
Verifier.cpp updated: 1.57 -> 1.58
---
Log message:
As it turns out, things will be simpler than I first expected. We no longer
need any exception handling intrinsics beyond llvm.unwind. (yaay)
---
Diffs of the changes:
Index: llvm/lib/VMCore/Function.cpp
diff -u llvm/lib/VMCore/Function.cpp:1.45 llvm/lib/VMCore/Function.cpp:1.46
--- llvm/lib/VMCore/Function.cpp:1.45 Sun Aug 24 07:24:08 2003
+++ llvm/lib/VMCore/Function.cpp Mon Aug 25 17:35:01 2003
@@ -195,10 +195,6 @@
if (getName() == alpha_intrinsics[i].name)
return alpha_intrinsics[i].id;
break;
- case 'e':
- if (getName() == "llvm.exc.getcurrent")return LLVMIntrinsic::exc_getcurrent;
- if (getName() == "llvm.exc.setcurrent")return LLVMIntrinsic::exc_setcurrent;
- break;
case 'l':
if (getName() == "llvm.longjmp") return LLVMIntrinsic::longjmp;
break;
Index: llvm/lib/VMCore/Verifier.cpp
diff -u llvm/lib/VMCore/Verifier.cpp:1.57 llvm/lib/VMCore/Verifier.cpp:1.58
--- llvm/lib/VMCore/Verifier.cpp:1.57 Sun Aug 24 07:24:08 2003
+++ llvm/lib/VMCore/Verifier.cpp Mon Aug 25 17:35:01 2003
@@ -523,8 +523,6 @@
case LLVMIntrinsic::va_copy: NumArgs = 2; break;
case LLVMIntrinsic::unwind: NumArgs = 0; break;
- case LLVMIntrinsic::exc_setcurrent: NumArgs = 1; break;
- case LLVMIntrinsic::exc_getcurrent: NumArgs = 0; break;
case LLVMIntrinsic::setjmp: NumArgs = 1; break;
case LLVMIntrinsic::longjmp: NumArgs = 2; break;
From lattner at cs.uiuc.edu Mon Aug 25 17:36:04 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon Aug 25 17:36:04 2003
Subject: [llvm-commits] CVS: llvm/include/llvm/Intrinsics.h
Message-ID: <200308252235.RAA10521@apoc.cs.uiuc.edu>
Changes in directory llvm/include/llvm:
Intrinsics.h updated: 1.8 -> 1.9
---
Log message:
As it turns out, things will be simpler than I first expected. We no longer
need any exception handling intrinsics beyond llvm.unwind. (yaay)
---
Diffs of the changes:
Index: llvm/include/llvm/Intrinsics.h
diff -u llvm/include/llvm/Intrinsics.h:1.8 llvm/include/llvm/Intrinsics.h:1.9
--- llvm/include/llvm/Intrinsics.h:1.8 Sun Aug 24 07:24:03 2003
+++ llvm/include/llvm/Intrinsics.h Mon Aug 25 17:34:59 2003
@@ -24,10 +24,6 @@
unwind, // Unwind stack until containing invoke is found
- // Exception handling intrinsics...
- exc_setcurrent, // Set the current pending exception
- exc_getcurrent, // Get the current pending exception
-
// Setjmp/Longjmp intrinsics...
setjmp, // Used to represent a setjmp call in C
longjmp, // Used to represent a longjmp call in C
From lattner at cs.uiuc.edu Mon Aug 25 17:38:02 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon Aug 25 17:38:02 2003
Subject: [llvm-commits] CVS: llvm/runtime/GCCLibraries/libexception/Makefile
Message-ID: <200308252237.RAA10693@apoc.cs.uiuc.edu>
Changes in directory llvm/runtime/GCCLibraries/libexception:
Makefile updated: 1.1 -> 1.2
---
Log message:
Remove copy-and-paste gunk
---
Diffs of the changes:
Index: llvm/runtime/GCCLibraries/libexception/Makefile
diff -u llvm/runtime/GCCLibraries/libexception/Makefile:1.1 llvm/runtime/GCCLibraries/libexception/Makefile:1.2
--- llvm/runtime/GCCLibraries/libexception/Makefile:1.1 Mon Aug 25 17:35:36 2003
+++ llvm/runtime/GCCLibraries/libexception/Makefile Mon Aug 25 17:37:04 2003
@@ -3,15 +3,4 @@
DONT_BUILD_RELINKED=1
LIBRARYNAME=exception
-#Source = crtend.c listend.ll
-
-###EXPORTED_SYMBOL_LIST = __main,llvm.global_ctors,llvm.global_dtors
-
include $(LEVEL)/Makefile.common
-
-
-$(LLVMGCCDIR)/bytecode-libs/crtend.o: $(LIBNAME_BC)
- @cp $< $@
-
-install:: $(LLVMGCCDIR)/bytecode-libs/crtend.o
- @rm $(LLVMGCCDIR)/bytecode-libs/libcrtend.bc
From tbrethou at cs.uiuc.edu Mon Aug 25 17:43:01 2003
From: tbrethou at cs.uiuc.edu (Tanya Brethour)
Date: Mon Aug 25 17:43:01 2003
Subject: [llvm-commits] CVS: llvm/lib/CodeGen/InstrSched/SchedGraphCommon.cpp InstrScheduling.cpp SchedGraph.cpp SchedGraph.h SchedPriorities.cpp
Message-ID: <200308252242.RAA10324@tank.cs.uiuc.edu>
Changes in directory llvm/lib/CodeGen/InstrSched:
SchedGraphCommon.cpp added (r1.1)
InstrScheduling.cpp updated: 1.56 -> 1.57
SchedGraph.cpp updated: 1.46 -> 1.47
SchedGraph.h updated: 1.30 -> 1.31
SchedPriorities.cpp updated: 1.25 -> 1.26
---
Log message:
First version of SchedGraph common class and refactoring of SchedGraph.
---
Diffs of the changes:
Index: llvm/lib/CodeGen/InstrSched/SchedGraphCommon.cpp
diff -c /dev/null llvm/lib/CodeGen/InstrSched/SchedGraphCommon.cpp:1.1
*** /dev/null Mon Aug 25 17:42:32 2003
--- llvm/lib/CodeGen/InstrSched/SchedGraphCommon.cpp Mon Aug 25 17:42:20 2003
***************
*** 0 ****
--- 1,237 ----
+ #include "llvm/CodeGen/SchedGraphCommon.h"
+ #include "Support/STLExtras.h"
+
+ class SchedGraphCommon;
+
+ //
+ // class SchedGraphEdge
+ //
+
+ /*ctor*/
+ SchedGraphEdge::SchedGraphEdge(SchedGraphNodeCommon* _src,
+ SchedGraphNodeCommon* _sink,
+ SchedGraphEdgeDepType _depType,
+ unsigned int _depOrderType,
+ int _minDelay)
+ : src(_src),
+ sink(_sink),
+ depType(_depType),
+ depOrderType(_depOrderType),
+ minDelay((_minDelay >= 0)? _minDelay : _src->getLatency()),
+ val(NULL)
+ {
+ iteDiff=0;
+ assert(src != sink && "Self-loop in scheduling graph!");
+ src->addOutEdge(this);
+ sink->addInEdge(this);
+ }
+
+
+ /*ctor*/
+ SchedGraphEdge::SchedGraphEdge(SchedGraphNodeCommon* _src,
+ SchedGraphNodeCommon* _sink,
+ const Value* _val,
+ unsigned int _depOrderType,
+ int _minDelay)
+ : src(_src),
+ sink(_sink),
+ depType(ValueDep),
+ depOrderType(_depOrderType),
+ minDelay((_minDelay >= 0)? _minDelay : _src->getLatency()),
+ val(_val)
+ {
+ iteDiff=0;
+ assert(src != sink && "Self-loop in scheduling graph!");
+ src->addOutEdge(this);
+ sink->addInEdge(this);
+ }
+
+
+ /*ctor*/
+ SchedGraphEdge::SchedGraphEdge(SchedGraphNodeCommon* _src,
+ SchedGraphNodeCommon* _sink,
+ unsigned int _regNum,
+ unsigned int _depOrderType,
+ int _minDelay)
+ : src(_src),
+ sink(_sink),
+ depType(MachineRegister),
+ depOrderType(_depOrderType),
+ minDelay((_minDelay >= 0)? _minDelay : _src->getLatency()),
+ machineRegNum(_regNum)
+ {
+ iteDiff=0;
+ assert(src != sink && "Self-loop in scheduling graph!");
+ src->addOutEdge(this);
+ sink->addInEdge(this);
+ }
+
+
+ /*ctor*/
+ SchedGraphEdge::SchedGraphEdge(SchedGraphNodeCommon* _src,
+ SchedGraphNodeCommon* _sink,
+ ResourceId _resourceId,
+ int _minDelay)
+ : src(_src),
+ sink(_sink),
+ depType(MachineResource),
+ depOrderType(NonDataDep),
+ minDelay((_minDelay >= 0)? _minDelay : _src->getLatency()),
+ resourceId(_resourceId)
+ {
+ iteDiff=0;
+ assert(src != sink && "Self-loop in scheduling graph!");
+ src->addOutEdge(this);
+ sink->addInEdge(this);
+ }
+
+ /*dtor*/
+ SchedGraphEdge::~SchedGraphEdge()
+ {
+ }
+
+ void SchedGraphEdge::dump(int indent) const {
+ std::cerr << std::string(indent*2, ' ') << *this;
+ }
+
+
+
+ /*ctor*/
+
+ SchedGraphNodeCommon::SchedGraphNodeCommon(unsigned _nodeId)
+ :ID(_nodeId),
+ latency(0){
+
+ }
+
+ /*dtor*/
+ SchedGraphNodeCommon::~SchedGraphNodeCommon()
+ {
+ // for each node, delete its out-edges
+ std::for_each(beginOutEdges(), endOutEdges(),
+ deleter);
+ }
+
+
+ void SchedGraphNodeCommon::dump(int indent) const {
+ std::cerr << std::string(indent*2, ' ') << *this;
+ }
+
+
+ inline void
+ SchedGraphNodeCommon::addInEdge(SchedGraphEdge* edge)
+ {
+ inEdges.push_back(edge);
+ }
+
+
+ inline void
+ SchedGraphNodeCommon::addOutEdge(SchedGraphEdge* edge)
+ {
+ outEdges.push_back(edge);
+ }
+
+ inline void
+ SchedGraphNodeCommon::removeInEdge(const SchedGraphEdge* edge)
+ {
+ assert(edge->getSink() == this);
+
+ for (iterator I = beginInEdges(); I != endInEdges(); ++I)
+ if ((*I) == edge)
+ {
+ inEdges.erase(I);
+ break;
+ }
+ }
+
+ inline void
+ SchedGraphNodeCommon::removeOutEdge(const SchedGraphEdge* edge)
+ {
+ assert(edge->getSrc() == this);
+
+ for (iterator I = beginOutEdges(); I != endOutEdges(); ++I)
+ if ((*I) == edge)
+ {
+ outEdges.erase(I);
+ break;
+ }
+ }
+
+
+ //class SchedGraphCommon
+
+ /*ctor*/
+ SchedGraphCommon::SchedGraphCommon()
+ {
+ }
+
+
+ /*dtor*/
+ SchedGraphCommon::~SchedGraphCommon()
+ {
+
+ delete graphRoot;
+ delete graphLeaf;
+ }
+
+
+ void
+ SchedGraphCommon::eraseIncomingEdges(SchedGraphNodeCommon* node, bool addDummyEdges)
+ {
+ // Delete and disconnect all in-edges for the node
+ for (SchedGraphNodeCommon::iterator I = node->beginInEdges();
+ I != node->endInEdges(); ++I)
+ {
+ SchedGraphNodeCommon* srcNode = (*I)->getSrc();
+ srcNode->removeOutEdge(*I);
+ delete *I;
+
+ if (addDummyEdges &&
+ srcNode != getRoot() &&
+ srcNode->beginOutEdges() == srcNode->endOutEdges())
+ { // srcNode has no more out edges, so add an edge to dummy EXIT node
+ assert(node != getLeaf() && "Adding edge that was just removed?");
+ (void) new SchedGraphEdge(srcNode, getLeaf(),
+ SchedGraphEdge::CtrlDep, SchedGraphEdge::NonDataDep, 0);
+ }
+ }
+
+ node->inEdges.clear();
+ }
+
+ void
+ SchedGraphCommon::eraseOutgoingEdges(SchedGraphNodeCommon* node, bool addDummyEdges)
+ {
+ // Delete and disconnect all out-edges for the node
+ for (SchedGraphNodeCommon::iterator I = node->beginOutEdges();
+ I != node->endOutEdges(); ++I)
+ {
+ SchedGraphNodeCommon* sinkNode = (*I)->getSink();
+ sinkNode->removeInEdge(*I);
+ delete *I;
+
+ if (addDummyEdges &&
+ sinkNode != getLeaf() &&
+ sinkNode->beginInEdges() == sinkNode->endInEdges())
+ { //sinkNode has no more in edges, so add an edge from dummy ENTRY node
+ assert(node != getRoot() && "Adding edge that was just removed?");
+ (void) new SchedGraphEdge(getRoot(), sinkNode,
+ SchedGraphEdge::CtrlDep, SchedGraphEdge::NonDataDep, 0);
+ }
+ }
+
+ node->outEdges.clear();
+ }
+
+ void
+ SchedGraphCommon::eraseIncidentEdges(SchedGraphNodeCommon* node, bool addDummyEdges)
+ {
+ this->eraseIncomingEdges(node, addDummyEdges);
+ this->eraseOutgoingEdges(node, addDummyEdges);
+ }
+
+ std::ostream &operator<<(std::ostream &os, const SchedGraphNodeCommon& node)
+ {
+
+ return os;
+ }
Index: llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp
diff -u llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp:1.56 llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp:1.57
--- llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp:1.56 Fri Aug 15 00:20:06 2003
+++ llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp Mon Aug 25 17:42:20 2003
@@ -1047,8 +1047,8 @@
for (SchedGraphNode::const_iterator EI = node->beginInEdges();
EI != node->endInEdges(); ++EI)
- if (! (*EI)->getSrc()->isDummyNode()
- && mii.isLoad((*EI)->getSrc()->getOpCode())
+ if (! ((SchedGraphNode*)(*EI)->getSrc())->isDummyNode()
+ && mii.isLoad(((SchedGraphNode*)(*EI)->getSrc())->getOpCode())
&& (*EI)->getDepType() == SchedGraphEdge::CtrlDep)
return false;
@@ -1065,7 +1065,7 @@
bool onlyCDEdgeToBranch = true;
for (SchedGraphNode::const_iterator OEI = node->beginOutEdges();
OEI != node->endOutEdges(); ++OEI)
- if (! (*OEI)->getSink()->isDummyNode()
+ if (! ((SchedGraphNode*)(*OEI)->getSink())->isDummyNode()
&& ((*OEI)->getSink() != brNode
|| (*OEI)->getDepType() != SchedGraphEdge::CtrlDep))
{
Index: llvm/lib/CodeGen/InstrSched/SchedGraph.cpp
diff -u llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.46 llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.47
--- llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.46 Tue Jul 1 20:16:01 2003
+++ llvm/lib/CodeGen/InstrSched/SchedGraph.cpp Mon Aug 25 17:42:20 2003
@@ -7,16 +7,21 @@
//===----------------------------------------------------------------------===//
#include "SchedGraph.h"
-#include "llvm/CodeGen/InstrSelection.h"
-#include "llvm/CodeGen/MachineCodeForInstruction.h"
-#include "llvm/CodeGen/MachineFunction.h"
-#include "llvm/Target/TargetRegInfo.h"
+#include "llvm/CodeGen/SchedGraphCommon.h"
+#include
+
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetInstrInfo.h"
+#include "Support/STLExtras.h"
+#include "llvm/BasicBlock.h"
+#include "llvm/CodeGen/MachineCodeForInstruction.h"
+#include "llvm/Target/TargetRegInfo.h"
#include "llvm/Function.h"
+#include "llvm/CodeGen/MachineFunction.h"
+#include "llvm/CodeGen/InstrSelection.h"
#include "llvm/iOther.h"
#include "Support/StringExtras.h"
-#include "Support/STLExtras.h"
+
//*********************** Internal Data Structures *************************/
@@ -39,93 +44,6 @@
typedef hash_map::const_iterator const_iterator;
};
-//
-// class SchedGraphEdge
-//
-
-/*ctor*/
-SchedGraphEdge::SchedGraphEdge(SchedGraphNode* _src,
- SchedGraphNode* _sink,
- SchedGraphEdgeDepType _depType,
- unsigned int _depOrderType,
- int _minDelay)
- : src(_src),
- sink(_sink),
- depType(_depType),
- depOrderType(_depOrderType),
- minDelay((_minDelay >= 0)? _minDelay : _src->getLatency()),
- val(NULL)
-{
- assert(src != sink && "Self-loop in scheduling graph!");
- src->addOutEdge(this);
- sink->addInEdge(this);
-}
-
-
-/*ctor*/
-SchedGraphEdge::SchedGraphEdge(SchedGraphNode* _src,
- SchedGraphNode* _sink,
- const Value* _val,
- unsigned int _depOrderType,
- int _minDelay)
- : src(_src),
- sink(_sink),
- depType(ValueDep),
- depOrderType(_depOrderType),
- minDelay((_minDelay >= 0)? _minDelay : _src->getLatency()),
- val(_val)
-{
- assert(src != sink && "Self-loop in scheduling graph!");
- src->addOutEdge(this);
- sink->addInEdge(this);
-}
-
-
-/*ctor*/
-SchedGraphEdge::SchedGraphEdge(SchedGraphNode* _src,
- SchedGraphNode* _sink,
- unsigned int _regNum,
- unsigned int _depOrderType,
- int _minDelay)
- : src(_src),
- sink(_sink),
- depType(MachineRegister),
- depOrderType(_depOrderType),
- minDelay((_minDelay >= 0)? _minDelay : _src->getLatency()),
- machineRegNum(_regNum)
-{
- assert(src != sink && "Self-loop in scheduling graph!");
- src->addOutEdge(this);
- sink->addInEdge(this);
-}
-
-
-/*ctor*/
-SchedGraphEdge::SchedGraphEdge(SchedGraphNode* _src,
- SchedGraphNode* _sink,
- ResourceId _resourceId,
- int _minDelay)
- : src(_src),
- sink(_sink),
- depType(MachineResource),
- depOrderType(NonDataDep),
- minDelay((_minDelay >= 0)? _minDelay : _src->getLatency()),
- resourceId(_resourceId)
-{
- assert(src != sink && "Self-loop in scheduling graph!");
- src->addOutEdge(this);
- sink->addInEdge(this);
-}
-
-/*dtor*/
-SchedGraphEdge::~SchedGraphEdge()
-{
-}
-
-void SchedGraphEdge::dump(int indent) const {
- std::cerr << std::string(indent*2, ' ') << *this;
-}
-
//
// class SchedGraphNode
@@ -136,11 +54,11 @@
MachineBasicBlock *mbb,
int indexInBB,
const TargetMachine& Target)
- : nodeId(NID), MBB(mbb), minstr(mbb ? (*mbb)[indexInBB] : 0),
- origIndexInBB(indexInBB), latency(0) {
- if (minstr)
+ : SchedGraphNodeCommon(NID), origIndexInBB(indexInBB), MBB(mbb), MI(mbb ? (*mbb)[indexInBB] : 0)
+ {
+ if (MI)
{
- MachineOpCode mopCode = minstr->getOpCode();
+ MachineOpCode mopCode = MI->getOpCode();
latency = Target.getInstrInfo().hasResultInterlock(mopCode)
? Target.getInstrInfo().minLatency(mopCode)
: Target.getInstrInfo().maxLatency(mopCode);
@@ -156,51 +74,6 @@
deleter);
}
-void SchedGraphNode::dump(int indent) const {
- std::cerr << std::string(indent*2, ' ') << *this;
-}
-
-
-inline void
-SchedGraphNode::addInEdge(SchedGraphEdge* edge)
-{
- inEdges.push_back(edge);
-}
-
-
-inline void
-SchedGraphNode::addOutEdge(SchedGraphEdge* edge)
-{
- outEdges.push_back(edge);
-}
-
-inline void
-SchedGraphNode::removeInEdge(const SchedGraphEdge* edge)
-{
- assert(edge->getSink() == this);
-
- for (iterator I = beginInEdges(); I != endInEdges(); ++I)
- if ((*I) == edge)
- {
- inEdges.erase(I);
- break;
- }
-}
-
-inline void
-SchedGraphNode::removeOutEdge(const SchedGraphEdge* edge)
-{
- assert(edge->getSrc() == this);
-
- for (iterator I = beginOutEdges(); I != endOutEdges(); ++I)
- if ((*I) == edge)
- {
- outEdges.erase(I);
- break;
- }
-}
-
-
//
// class SchedGraph
//
@@ -243,62 +116,6 @@
}
-void
-SchedGraph::eraseIncomingEdges(SchedGraphNode* node, bool addDummyEdges)
-{
- // Delete and disconnect all in-edges for the node
- for (SchedGraphNode::iterator I = node->beginInEdges();
- I != node->endInEdges(); ++I)
- {
- SchedGraphNode* srcNode = (*I)->getSrc();
- srcNode->removeOutEdge(*I);
- delete *I;
-
- if (addDummyEdges &&
- srcNode != getRoot() &&
- srcNode->beginOutEdges() == srcNode->endOutEdges())
- {
- // srcNode has no more out edges, so add an edge to dummy EXIT node
- assert(node != getLeaf() && "Adding edge that was just removed?");
- (void) new SchedGraphEdge(srcNode, getLeaf(),
- SchedGraphEdge::CtrlDep, SchedGraphEdge::NonDataDep, 0);
- }
- }
-
- node->inEdges.clear();
-}
-
-void
-SchedGraph::eraseOutgoingEdges(SchedGraphNode* node, bool addDummyEdges)
-{
- // Delete and disconnect all out-edges for the node
- for (SchedGraphNode::iterator I = node->beginOutEdges();
- I != node->endOutEdges(); ++I)
- {
- SchedGraphNode* sinkNode = (*I)->getSink();
- sinkNode->removeInEdge(*I);
- delete *I;
-
- if (addDummyEdges &&
- sinkNode != getLeaf() &&
- sinkNode->beginInEdges() == sinkNode->endInEdges())
- { //sinkNode has no more in edges, so add an edge from dummy ENTRY node
- assert(node != getRoot() && "Adding edge that was just removed?");
- (void) new SchedGraphEdge(getRoot(), sinkNode,
- SchedGraphEdge::CtrlDep, SchedGraphEdge::NonDataDep, 0);
- }
- }
-
- node->outEdges.clear();
-}
-
-void
-SchedGraph::eraseIncidentEdges(SchedGraphNode* node, bool addDummyEdges)
-{
- this->eraseIncomingEdges(node, addDummyEdges);
- this->eraseOutgoingEdges(node, addDummyEdges);
-}
-
void
SchedGraph::addDummyEdges()
@@ -697,10 +514,10 @@
// Collect the register references and value defs. for explicit operands
//
- const MachineInstr& minstr = *node->getMachineInstr();
- for (int i=0, numOps = (int) minstr.getNumOperands(); i < numOps; i++)
+ const MachineInstr& MI = *node->getMachineInstr();
+ for (int i=0, numOps = (int) MI.getNumOperands(); i < numOps; i++)
{
- const MachineOperand& mop = minstr.getOperand(i);
+ const MachineOperand& mop = MI.getOperand(i);
// if this references a register other than the hardwired
// "zero" register, record the reference.
@@ -728,8 +545,8 @@
}
// ignore all other non-def operands
- if (!minstr.getOperand(i).opIsDefOnly() &&
- !minstr.getOperand(i).opIsDefAndUse())
+ if (!MI.getOperand(i).opIsDefOnly() &&
+ !MI.getOperand(i).opIsDefAndUse())
continue;
// We must be defining a value.
@@ -745,21 +562,21 @@
// Collect value defs. for implicit operands. They may have allocated
// physical registers also.
//
- for (unsigned i=0, N = minstr.getNumImplicitRefs(); i != N; ++i)
+ for (unsigned i=0, N = MI.getNumImplicitRefs(); i != N; ++i)
{
- const MachineOperand& mop = minstr.getImplicitOp(i);
+ const MachineOperand& mop = MI.getImplicitOp(i);
if (mop.hasAllocatedReg())
{
int regNum = mop.getAllocatedRegNum();
if (regNum != target.getRegInfo().getZeroRegNum())
regToRefVecMap[mop.getAllocatedRegNum()]
- .push_back(std::make_pair(node, i + minstr.getNumOperands()));
+ .push_back(std::make_pair(node, i + MI.getNumOperands()));
continue; // nothing more to do
}
if (mop.opIsDefOnly() || mop.opIsDefAndUse()) {
- assert(minstr.getImplicitRef(i) != NULL && "Null value being defined?");
- valueToDefVecMap[minstr.getImplicitRef(i)].push_back(std::make_pair(node,
+ assert(MI.getImplicitRef(i) != NULL && "Null value being defined?");
+ valueToDefVecMap[MI.getImplicitRef(i)].push_back(std::make_pair(node,
-i));
}
}
@@ -885,9 +702,9 @@
/*ctor*/
SchedGraphSet::SchedGraphSet(const Function* _function,
const TargetMachine& target) :
- method(_function)
+ function(_function)
{
- buildGraphsForMethod(method, target);
+ buildGraphsForMethod(function, target);
}
@@ -903,13 +720,13 @@
void
SchedGraphSet::dump() const
{
- std::cerr << "======== Sched graphs for function `" << method->getName()
+ std::cerr << "======== Sched graphs for function `" << function->getName()
<< "' ========\n\n";
for (const_iterator I=begin(); I != end(); ++I)
(*I)->dump();
- std::cerr << "\n====== End graphs for function `" << method->getName()
+ std::cerr << "\n====== End graphs for function `" << function->getName()
<< "' ========\n\n";
}
@@ -946,7 +763,7 @@
std::ostream &operator<<(std::ostream &os, const SchedGraphNode& node)
{
os << std::string(8, ' ')
- << "Node " << node.nodeId << " : "
+ << "Node " << node.ID << " : "
<< "latency = " << node.latency << "\n" << std::string(12, ' ');
if (node.getMachineInstr() == NULL)
Index: llvm/lib/CodeGen/InstrSched/SchedGraph.h
diff -u llvm/lib/CodeGen/InstrSched/SchedGraph.h:1.30 llvm/lib/CodeGen/InstrSched/SchedGraph.h:1.31
--- llvm/lib/CodeGen/InstrSched/SchedGraph.h:1.30 Sat Jul 26 18:22:19 2003
+++ llvm/lib/CodeGen/InstrSched/SchedGraph.h Mon Aug 25 17:42:20 2003
@@ -17,264 +17,80 @@
#include "llvm/CodeGen/MachineInstr.h"
#include "Support/GraphTraits.h"
#include "Support/hash_map"
+#include "llvm/Transforms/Scalar.h"
+#include "llvm/CodeGen/SchedGraphCommon.h"
-class Value;
-class Instruction;
-class TerminatorInst;
-class BasicBlock;
-class Function;
-class TargetMachine;
-class SchedGraphEdge;
-class SchedGraphNode;
-class SchedGraph;
class RegToRefVecMap;
class ValueToDefVecMap;
class RefVec;
-class MachineInstr;
-class MachineBasicBlock;
+class SchedGraphNode : public SchedGraphNodeCommon {
-/******************** Exported Data Types and Constants ********************/
-
-typedef int ResourceId;
-const ResourceId InvalidRID = -1;
-const ResourceId MachineCCRegsRID = -2; // use +ve numbers for actual regs
-const ResourceId MachineIntRegsRID = -3; // use +ve numbers for actual regs
-const ResourceId MachineFPRegsRID = -4; // use +ve numbers for actual regs
-
-
-//*********************** Public Class Declarations ************************/
-
-class SchedGraphEdge {
- SchedGraphEdge(const SchedGraphEdge &); // DO NOT IMPLEMENT
- void operator=(const SchedGraphEdge &); // DO NOT IMPLEMENT
-public:
- enum SchedGraphEdgeDepType {
- CtrlDep, MemoryDep, ValueDep, MachineRegister, MachineResource
- };
- enum DataDepOrderType {
- TrueDep = 0x1, AntiDep=0x2, OutputDep=0x4, NonDataDep=0x8
- };
-
-private:
- SchedGraphNode* src;
- SchedGraphNode* sink;
- SchedGraphEdgeDepType depType;
- unsigned int depOrderType;
- int minDelay; // cached latency (assumes fixed target arch)
-
- union {
- const Value* val;
- int machineRegNum;
- ResourceId resourceId;
- };
-
-public:
- // For all constructors, if minDelay is unspecified, minDelay is
- // set to _src->getLatency().
- // constructor for CtrlDep or MemoryDep edges, selected by 3rd argument
- /*ctor*/ SchedGraphEdge(SchedGraphNode* _src,
- SchedGraphNode* _sink,
- SchedGraphEdgeDepType _depType,
- unsigned int _depOrderType,
- int _minDelay = -1);
-
- // constructor for explicit value dependence (may be true/anti/output)
- /*ctor*/ SchedGraphEdge(SchedGraphNode* _src,
- SchedGraphNode* _sink,
- const Value* _val,
- unsigned int _depOrderType,
- int _minDelay = -1);
-
- // constructor for machine register dependence
- /*ctor*/ SchedGraphEdge(SchedGraphNode* _src,
- SchedGraphNode* _sink,
- unsigned int _regNum,
- unsigned int _depOrderType,
- int _minDelay = -1);
-
- // constructor for any other machine resource dependences.
- // DataDepOrderType is always NonDataDep. It it not an argument to
- // avoid overloading ambiguity with previous constructor.
- /*ctor*/ SchedGraphEdge(SchedGraphNode* _src,
- SchedGraphNode* _sink,
- ResourceId _resourceId,
- int _minDelay = -1);
-
- /*dtor*/ ~SchedGraphEdge();
-
- SchedGraphNode* getSrc () const { return src; }
- SchedGraphNode* getSink () const { return sink; }
- int getMinDelay () const { return minDelay; }
- SchedGraphEdgeDepType getDepType () const { return depType; }
-
- const Value* getValue () const {
- assert(depType == ValueDep); return val;
- }
- int getMachineReg () const {
- assert(depType == MachineRegister); return machineRegNum;
- }
- int getResourceId () const {
- assert(depType == MachineResource); return resourceId;
- }
-
-public:
- //
- // Debugging support
- //
- friend std::ostream& operator<<(std::ostream& os, const SchedGraphEdge& edge);
-
- void dump (int indent=0) const;
-
-private:
- // disable default ctor
- /*ctor*/ SchedGraphEdge(); // DO NOT IMPLEMENT
-};
+ int origIndexInBB; // original position of machine instr in BB
+ MachineBasicBlock *MBB;
+ const MachineInstr *MI;
+ SchedGraphNode (unsigned nodeId, MachineBasicBlock *mbb,
+ int indexInBB, const TargetMachine& Target);
+ ~SchedGraphNode ();
-class SchedGraphNode {
- unsigned nodeId;
- MachineBasicBlock *MBB;
- const MachineInstr* minstr;
- std::vector inEdges;
- std::vector outEdges;
- int origIndexInBB; // original position of machine instr in BB
- int latency;
+ friend class SchedGraph; // give access for ctor and dtor
+ friend class SchedGraphEdge; // give access for adding edges
- SchedGraphNode(const SchedGraphNode &); // DO NOT IMPLEMENT
- void operator=(const SchedGraphNode &); // DO NOT IMPLEMENT
public:
- typedef std::vector:: iterator iterator;
- typedef std::vector::const_iterator const_iterator;
- typedef std::vector:: reverse_iterator reverse_iterator;
- typedef std::vector::const_reverse_iterator const_reverse_iterator;
-
-public:
- //
// Accessor methods
- //
- unsigned getNodeId () const { return nodeId; }
- const MachineInstr* getMachineInstr () const { return minstr; }
- const MachineOpCode getOpCode () const { return minstr->getOpCode(); }
- int getLatency () const { return latency; }
- unsigned getNumInEdges () const { return inEdges.size(); }
- unsigned getNumOutEdges () const { return outEdges.size(); }
- bool isDummyNode () const { return (minstr == NULL); }
+ const MachineInstr* getMachineInstr () const { return MI; }
+ const MachineOpCode getOpCode () const { return MI->getOpCode(); }
+ bool isDummyNode () const { return (MI == NULL); }
MachineBasicBlock &getMachineBasicBlock() const { return *MBB; }
- int getOrigIndexInBB() const { return origIndexInBB; }
-
- //
- // Iterators
- //
- iterator beginInEdges () { return inEdges.begin(); }
- iterator endInEdges () { return inEdges.end(); }
- iterator beginOutEdges () { return outEdges.begin(); }
- iterator endOutEdges () { return outEdges.end(); }
-
- const_iterator beginInEdges () const { return inEdges.begin(); }
- const_iterator endInEdges () const { return inEdges.end(); }
- const_iterator beginOutEdges () const { return outEdges.begin(); }
- const_iterator endOutEdges () const { return outEdges.end(); }
-
-public:
- //
- // Debugging support
- //
- friend std::ostream& operator<<(std::ostream& os, const SchedGraphNode& node);
-
- void dump (int indent=0) const;
-
-private:
- friend class SchedGraph; // give access for ctor and dtor
- friend class SchedGraphEdge; // give access for adding edges
-
- void addInEdge (SchedGraphEdge* edge);
- void addOutEdge (SchedGraphEdge* edge);
-
- void removeInEdge (const SchedGraphEdge* edge);
- void removeOutEdge (const SchedGraphEdge* edge);
-
- // disable default constructor and provide a ctor for single-block graphs
- /*ctor*/ SchedGraphNode(); // DO NOT IMPLEMENT
- /*ctor*/ SchedGraphNode (unsigned nodeId,
- MachineBasicBlock *mbb,
- int indexInBB,
- const TargetMachine& Target);
- /*dtor*/ ~SchedGraphNode ();
-};
-
+ int getOrigIndexInBB() const { return origIndexInBB; }
+};
-class SchedGraph : private hash_map {
- MachineBasicBlock &MBB; // basic blocks for this graph
- SchedGraphNode* graphRoot; // the root and leaf are not inserted
- SchedGraphNode* graphLeaf; // in the hash_map (see getNumNodes())
-
- typedef hash_map map_base;
- SchedGraph(const SchedGraph &); // DO NOT IMPLEMENT
- void operator=(const SchedGraph &); // DO NOT IMPLEMENT
-public:
- using map_base::iterator;
- using map_base::const_iterator;
+class SchedGraph : public SchedGraphCommon {
+ MachineBasicBlock &MBB;
+ hash_map GraphMap;
public:
- //
- // Accessor methods
- //
- MachineBasicBlock &getBasicBlock() const { return MBB; }
- unsigned getNumNodes() const { return size()+2; }
- SchedGraphNode* getRoot() const { return graphRoot; }
- SchedGraphNode* getLeaf() const { return graphLeaf; }
-
- SchedGraphNode* getGraphNodeForInstr(const MachineInstr* minstr) const {
- const_iterator onePair = this->find(minstr);
- return (onePair != this->end())? (*onePair).second : NULL;
+ typedef hash_map::const_iterator iterator;
+ typedef hash_map::const_iterator const_iterator;
+
+ MachineBasicBlock& getBasicBlock() const{return MBB;}
+ const unsigned int getNumNodes() const { return GraphMap.size()+2; }
+ SchedGraphNode* getGraphNodeForInstr(const MachineInstr* MI) const {
+ const_iterator onePair = find(MI);
+ return (onePair != end())? onePair->second : NULL;
}
- //
- // Delete nodes or edges from the graph.
- //
- void eraseNode (SchedGraphNode* node);
-
- void eraseIncomingEdges (SchedGraphNode* node,
- bool addDummyEdges = true);
-
- void eraseOutgoingEdges (SchedGraphNode* node,
- bool addDummyEdges = true);
-
- void eraseIncidentEdges (SchedGraphNode* node,
- bool addDummyEdges = true);
+ // Debugging support
+ void dump () const;
- //
- // Unordered iterators.
- // Return values is pair.
- //
- using map_base::begin;
- using map_base::end;
+protected:
+ SchedGraph(MachineBasicBlock& mbb, const TargetMachine& TM);
+ ~SchedGraph();
- //
- // Ordered iterators.
+ // Unordered iterators.
// Return values is pair.
//
- // void postord_init();
- // postorder_iterator postord_begin();
- // postorder_iterator postord_end();
- // const_postorder_iterator postord_begin() const;
- // const_postorder_iterator postord_end() const;
+ hash_map::const_iterator begin() const {
+ return GraphMap.begin();
+ }
+ hash_map::const_iterator end() const {
+ return GraphMap.end();
+ }
+
+ unsigned size() { return GraphMap.size(); }
+ iterator find(const MachineInstr *MI) const { return GraphMap.find(MI); }
- //
- // Debugging support
- //
- void dump () const;
+ SchedGraphNode *&operator[](const MachineInstr *MI) {
+ return GraphMap[MI];
+ }
private:
friend class SchedGraphSet; // give access to ctor
- // disable default constructor and provide a ctor for single-block graphs
- /*ctor*/ SchedGraph (MachineBasicBlock &bb,
- const TargetMachine& target);
- /*dtor*/ ~SchedGraph ();
+
inline void noteGraphNodeForInstr (const MachineInstr* minstr,
SchedGraphNode* node)
@@ -288,12 +104,13 @@
//
void buildGraph (const TargetMachine& target);
- void buildNodesForBB (const TargetMachine& target,
+ void buildNodesForBB (const TargetMachine& target,
MachineBasicBlock &MBB,
std::vector& memNV,
std::vector& callNV,
RegToRefVecMap& regToRefVecMap,
ValueToDefVecMap& valueToDefVecMap);
+
void findDefUseInfoAtInstr (const TargetMachine& target,
SchedGraphNode* node,
@@ -301,6 +118,7 @@
std::vector& callNV,
RegToRefVecMap& regToRefVecMap,
ValueToDefVecMap& valueToDefVecMap);
+
void addEdgesForInstruction(const MachineInstr& minstr,
const ValueToDefVecMap& valueToDefVecMap,
@@ -309,12 +127,15 @@
void addCDEdges (const TerminatorInst* term,
const TargetMachine& target);
- void addMemEdges (const std::vector& memNV,
+ void addMemEdges (const std::vector& memNod,
const TargetMachine& target);
+ void addCallCCEdges (const std::vector& memNod,
+ MachineBasicBlock& bbMvec,
+ const TargetMachine& target);
void addCallDepEdges (const std::vector& callNV,
const TargetMachine& target);
-
+
void addMachineRegEdges (RegToRefVecMap& regToRefVecMap,
const TargetMachine& target);
@@ -324,44 +145,41 @@
bool refNodeIsDef,
bool refNodeIsDefAndUse,
const TargetMachine& target);
-
- void addDummyEdges ();
+ void addDummyEdges();
+
};
-class SchedGraphSet : private std::vector {
-private:
- const Function* method;
- SchedGraphSet(const SchedGraphSet&); // DO NOT IMPLEMENT
- void operator=(const SchedGraphSet&); // DO NOT IMPLEMENT
-public:
- typedef std::vector baseVector;
- using baseVector::iterator;
- using baseVector::const_iterator;
-
+class SchedGraphSet {
+ const Function* function;
+ std::vector Graphs;
+
+ // Graph builder
+ void buildGraphsForMethod (const Function *F, const TargetMachine& target);
+
+ inline void addGraph(SchedGraph* graph) {
+ assert(graph != NULL);
+ Graphs.push_back(graph);
+ }
+
public:
- SchedGraphSet(const Function *F, const TargetMachine &TM);
+ SchedGraphSet(const Function * function, const TargetMachine& target);
~SchedGraphSet();
- // Iterators
- using baseVector::begin;
- using baseVector::end;
-
+ //iterators
+ typedef std::vector::const_iterator iterator;
+ typedef std::vector::const_iterator const_iterator;
+
+ std::vector::const_iterator begin() const { return Graphs.begin(); }
+ std::vector::const_iterator end() const { return Graphs.end(); }
+
// Debugging support
void dump() const;
-
-private:
- inline void addGraph(SchedGraph* graph) {
- assert(graph != NULL);
- this->push_back(graph);
- }
-
- // Graph builder
- void buildGraphsForMethod(const Function *F, const TargetMachine &TM);
};
+
//********************** Sched Graph Iterators *****************************/
// Ok to make it a template because it shd get instantiated at most twice:
@@ -381,7 +199,7 @@
inline bool operator!=(const _Self& x) const { return !operator==(x); }
// operator*() differs for pred or succ iterator
- inline _NodeType* operator*() const { return (*oi)->getSrc(); }
+ inline _NodeType* operator*() const { return (_NodeType*)(*oi)->getSrc(); }
inline _NodeType* operator->() const { return operator*(); }
inline _EdgeType* getEdge() const { return *(oi); }
@@ -409,7 +227,7 @@
inline bool operator==(const _Self& x) const { return oi == x.oi; }
inline bool operator!=(const _Self& x) const { return !operator==(x); }
- inline _NodeType* operator*() const { return (*oi)->getSink(); }
+ inline _NodeType* operator*() const { return (_NodeType*)(*oi)->getSink(); }
inline _NodeType* operator->() const { return operator*(); }
inline _EdgeType* getEdge() const { return *(oi); }
@@ -477,7 +295,7 @@
typedef SchedGraphNode NodeType;
typedef sg_succ_iterator ChildIteratorType;
- static inline NodeType *getEntryNode(SchedGraph *SG) { return SG->getRoot(); }
+ static inline NodeType *getEntryNode(SchedGraph *SG) { return (NodeType*)SG->getRoot(); }
static inline ChildIteratorType child_begin(NodeType *N) {
return succ_begin(N);
}
@@ -491,7 +309,7 @@
typedef sg_succ_const_iterator ChildIteratorType;
static inline NodeType *getEntryNode(const SchedGraph *SG) {
- return SG->getRoot();
+ return (NodeType*)SG->getRoot();
}
static inline ChildIteratorType child_begin(NodeType *N) {
return succ_begin(N);
Index: llvm/lib/CodeGen/InstrSched/SchedPriorities.cpp
diff -u llvm/lib/CodeGen/InstrSched/SchedPriorities.cpp:1.25 llvm/lib/CodeGen/InstrSched/SchedPriorities.cpp:1.26
--- llvm/lib/CodeGen/InstrSched/SchedPriorities.cpp:1.25 Tue Jan 14 17:05:04 2003
+++ llvm/lib/CodeGen/InstrSched/SchedPriorities.cpp Mon Aug 25 17:42:20 2003
@@ -59,7 +59,7 @@
for (SchedGraphNode::const_iterator E=node->beginOutEdges();
E != node->endOutEdges(); ++E)
{
- cycles_t sinkDelay = getNodeDelay((*E)->getSink());
+ cycles_t sinkDelay = getNodeDelay((SchedGraphNode*)(*E)->getSink());
nodeDelay = std::max(nodeDelay, sinkDelay + (*E)->getMinDelay());
}
}
@@ -71,7 +71,7 @@
void
SchedPriorities::initializeReadyHeap(const SchedGraph* graph)
{
- const SchedGraphNode* graphRoot = graph->getRoot();
+ const SchedGraphNode* graphRoot = (const SchedGraphNode*)graph->getRoot();
assert(graphRoot->getMachineInstr() == NULL && "Expect dummy root");
// Insert immediate successors of dummy root, which are the actual roots
@@ -137,7 +137,7 @@
for (SchedGraphNode::const_iterator E=node->beginOutEdges();
E != node->endOutEdges(); ++E)
{
- cycles_t& etime = getEarliestReadyTimeForNodeRef((*E)->getSink());
+ cycles_t& etime = getEarliestReadyTimeForNodeRef((SchedGraphNode*)(*E)->getSink());
etime = std::max(etime, curTime + (*E)->getMinDelay());
}
}
From tbrethou at cs.uiuc.edu Mon Aug 25 18:13:01 2003
From: tbrethou at cs.uiuc.edu (Tanya Brethour)
Date: Mon Aug 25 18:13:01 2003
Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/SchedGraphCommon.h
Message-ID: <200308252312.SAA19355@tank.cs.uiuc.edu>
Changes in directory llvm/include/llvm/CodeGen:
SchedGraphCommon.h added (r1.1)
---
Log message:
SchedGraphCommon header file. Contains class definition for SchedGraphCommon which is used by SchedGraph and ModuloSchedGraph (coming soon).
---
Diffs of the changes:
Index: llvm/include/llvm/CodeGen/SchedGraphCommon.h
diff -c /dev/null llvm/include/llvm/CodeGen/SchedGraphCommon.h:1.1
*** /dev/null Mon Aug 25 18:12:33 2003
--- llvm/include/llvm/CodeGen/SchedGraphCommon.h Mon Aug 25 18:12:23 2003
***************
*** 0 ****
--- 1,215 ----
+ //===-- SchedGraphCommon.h - Scheduling Base Graph ---------------*- C++ -*---=//
+ //
+ // A common graph class that is based on the SSA graph. It includes
+ // extra dependencies that are caused by machine resources.
+ //
+ //===-------------------------------------------------------------------------=//
+
+ #ifndef LLVM_CODEGEN_SCHEDGRAPHCOMMON_H
+ #define LLVM_CODEGEN_SCHEDGRAPHCOMMON_H
+
+ #include
+ #include
+ #include "llvm/Value.h"
+
+
+ class SchedGraphEdge;
+ class SchedGraphNode;
+
+ /******************** Exported Data Types and Constants ********************/
+
+ typedef int ResourceId;
+ const ResourceId InvalidRID = -1;
+ const ResourceId MachineCCRegsRID = -2; // use +ve numbers for actual regs
+ const ResourceId MachineIntRegsRID = -3; // use +ve numbers for actual regs
+ const ResourceId MachineFPRegsRID = -4; // use +ve numbers for actual regs
+
+ //*********************** Public Class Declarations ************************/
+
+ class SchedGraphNodeCommon {
+ protected:
+ unsigned ID;
+ std::vector inEdges;
+ std::vector outEdges;
+ int latency;
+
+ friend std::ostream& operator<<(std::ostream& os, const SchedGraphNode& node);
+
+ public:
+ typedef std::vector:: iterator iterator;
+ typedef std::vector::const_iterator const_iterator;
+ typedef std::vector:: reverse_iterator reverse_iterator;
+ typedef std::vector::const_reverse_iterator const_reverse_iterator;
+
+ // Accessor methods
+ unsigned getNodeId () const { return ID; }
+ int getLatency () const { return latency; }
+ unsigned getNumInEdges () const { return inEdges.size(); }
+ unsigned getNumOutEdges () const { return outEdges.size(); }
+
+
+ // Iterators
+ iterator beginInEdges () { return inEdges.begin(); }
+ iterator endInEdges () { return inEdges.end(); }
+ iterator beginOutEdges () { return outEdges.begin(); }
+ iterator endOutEdges () { return outEdges.end(); }
+
+ const_iterator beginInEdges () const { return inEdges.begin(); }
+ const_iterator endInEdges () const { return inEdges.end(); }
+ const_iterator beginOutEdges () const { return outEdges.begin(); }
+ const_iterator endOutEdges () const { return outEdges.end(); }
+
+
+ // Debugging support
+ friend std::ostream& operator<<(std::ostream& os, const SchedGraphNodeCommon& node);
+
+ void dump (int indent=0) const;
+
+ protected:
+ friend class SchedGraph;
+ friend class SchedGraphCommon;
+ friend class SchedGraphEdge; // give access for adding edges
+ //friend class ModuloSchedGraph;
+
+ void addInEdge (SchedGraphEdge* edge);
+ void addOutEdge (SchedGraphEdge* edge);
+
+ void removeInEdge (const SchedGraphEdge* edge);
+ void removeOutEdge (const SchedGraphEdge* edge);
+
+ // disable default constructor and provide a ctor for single-block graphs
+ SchedGraphNodeCommon(); // DO NOT IMPLEMENT
+
+ SchedGraphNodeCommon(unsigned Id);
+
+ virtual ~SchedGraphNodeCommon();
+ };
+
+
+ class SchedGraphEdge {
+ public:
+ enum SchedGraphEdgeDepType {
+ CtrlDep, MemoryDep, ValueDep, MachineRegister, MachineResource
+ };
+ enum DataDepOrderType {
+ TrueDep = 0x1, AntiDep=0x2, OutputDep=0x4, NonDataDep=0x8
+ };
+
+ protected:
+ SchedGraphNodeCommon* src;
+ SchedGraphNodeCommon* sink;
+ SchedGraphEdgeDepType depType;
+ unsigned int depOrderType;
+ int minDelay; // cached latency (assumes fixed target arch)
+ int iteDiff;
+
+ union {
+ const Value* val;
+ int machineRegNum;
+ ResourceId resourceId;
+ };
+
+ public:
+ // For all constructors, if minDelay is unspecified, minDelay is
+ // set to _src->getLatency().
+ // constructor for CtrlDep or MemoryDep edges, selected by 3rd argument
+ /*ctor*/ SchedGraphEdge(SchedGraphNodeCommon* _src,
+ SchedGraphNodeCommon* _sink,
+ SchedGraphEdgeDepType _depType,
+ unsigned int _depOrderType,
+ int _minDelay = -1);
+
+ // constructor for explicit value dependence (may be true/anti/output)
+ /*ctor*/ SchedGraphEdge(SchedGraphNodeCommon* _src,
+ SchedGraphNodeCommon* _sink,
+ const Value* _val,
+ unsigned int _depOrderType,
+ int _minDelay = -1);
+
+ // constructor for machine register dependence
+ /*ctor*/ SchedGraphEdge(SchedGraphNodeCommon* _src,
+ SchedGraphNodeCommon* _sink,
+ unsigned int _regNum,
+ unsigned int _depOrderType,
+ int _minDelay = -1);
+
+ // constructor for any other machine resource dependences.
+ // DataDepOrderType is always NonDataDep. It it not an argument to
+ // avoid overloading ambiguity with previous constructor.
+ /*ctor*/ SchedGraphEdge(SchedGraphNodeCommon* _src,
+ SchedGraphNodeCommon* _sink,
+ ResourceId _resourceId,
+ int _minDelay = -1);
+
+ /*dtor*/ ~SchedGraphEdge();
+
+ SchedGraphNodeCommon* getSrc () const { return src; }
+ SchedGraphNodeCommon* getSink () const { return sink; }
+ int getMinDelay () const { return minDelay; }
+ SchedGraphEdgeDepType getDepType () const { return depType; }
+
+ const Value* getValue () const {
+ assert(depType == ValueDep); return val;
+ }
+ int getMachineReg () const {
+ assert(depType == MachineRegister); return machineRegNum;
+ }
+ int getResourceId () const {
+ assert(depType == MachineResource); return resourceId;
+ }
+ void setIteDiff (int _iteDiff) {
+ iteDiff = _iteDiff;
+ }
+ int getIteDiff (){
+ return iteDiff;
+ }
+
+ public:
+ //
+ // Debugging support
+ //
+ friend std::ostream& operator<<(std::ostream& os, const SchedGraphEdge& edge);
+
+ void dump (int indent=0) const;
+
+ private:
+ // disable default ctor
+ /*ctor*/ SchedGraphEdge(); // DO NOT IMPLEMENT
+ };
+
+
+ class SchedGraphCommon {
+
+ protected:
+ SchedGraphNodeCommon* graphRoot; // the root and leaf are not inserted
+ SchedGraphNodeCommon* graphLeaf; // in the hash_map (see getNumNodes())
+
+ public:
+ //
+ // Accessor methods
+ //
+ SchedGraphNodeCommon* getRoot() const { return graphRoot; }
+ SchedGraphNodeCommon* getLeaf() const { return graphLeaf; }
+
+ //
+ // Delete nodes or edges from the graph.
+ //
+ void eraseNode (SchedGraphNodeCommon* node);
+
+ void eraseIncomingEdges (SchedGraphNodeCommon* node,
+ bool addDummyEdges = true);
+
+ void eraseOutgoingEdges (SchedGraphNodeCommon* node,
+ bool addDummyEdges = true);
+
+ void eraseIncidentEdges (SchedGraphNodeCommon* node,
+ bool addDummyEdges = true);
+
+ /*ctor*/ SchedGraphCommon ();
+ /*dtor*/ ~SchedGraphCommon ();
+
+ };
+
+
+
+ #endif
From lattner at cs.uiuc.edu Tue Aug 26 18:48:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Tue Aug 26 18:48:01 2003
Subject: [llvm-commits] CVS: llvm/runtime/GCCLibraries/libexception/c++-exception.cpp c++-exception.h
Message-ID: <200308262347.SAA30663@apoc.cs.uiuc.edu>
Changes in directory llvm/runtime/GCCLibraries/libexception:
c++-exception.cpp updated: 1.1 -> 1.2
c++-exception.h updated: 1.1 -> 1.2
---
Log message:
Add new __llvm_cxxeh_begin_catch_if_isa function, change C -> C++ comments
---
Diffs of the changes:
Index: llvm/runtime/GCCLibraries/libexception/c++-exception.cpp
diff -u llvm/runtime/GCCLibraries/libexception/c++-exception.cpp:1.1 llvm/runtime/GCCLibraries/libexception/c++-exception.cpp:1.2
--- llvm/runtime/GCCLibraries/libexception/c++-exception.cpp:1.1 Mon Aug 25 17:35:36 2003
+++ llvm/runtime/GCCLibraries/libexception/c++-exception.cpp Tue Aug 26 18:46:53 2003
@@ -42,9 +42,9 @@
}
-/*===----------------------------------------------------------------------===**
- * C++ Specific exception handling support...
- */
+//===----------------------------------------------------------------------===//
+// C++ Specific exception handling support...
+//
// __llvm_cxxeh_allocate_exception - This function allocates space for the
// specified number of bytes, plus a C++ exception object header.
@@ -113,8 +113,8 @@
E->TypeInfo = TypeInfoPtr;
E->ExceptionObjectDestructor = DtorPtr;
- E->UnexpectedHandler = 0; /* FIXME */
- E->TerminateHandler = 0; /* FIXME */
+ E->UnexpectedHandler = 0; // FIXME
+ E->TerminateHandler = 0; // FIXME
}
// __llvm_cxxeh_current_uncaught_exception_isa - This function checks to see if
@@ -126,7 +126,7 @@
const std::type_info *CatchType) {
assert(UncaughtExceptionStack && "No uncaught exception!");
if (UncaughtExceptionStack->ExceptionType != CXXException)
- return 0; /* If it's not a c++ exception, it doesn't match! */
+ return 0; // If it's not a c++ exception, it doesn't match!
// If it is a C++ exception, use the type info object stored in the exception
// to see if TypeID matches and, if so, to adjust the exception object
@@ -156,68 +156,83 @@
}
-/* __llvm_cxxeh_begin_catch - This function is called by "exception handlers",
- * which transition an exception from being uncaught to being caught. It
- * returns a pointer to the exception object portion of the exception. This
- * function must work with foreign exceptions.
- */
+// __llvm_cxxeh_begin_catch - This function is called by "exception handlers",
+// which transition an exception from being uncaught to being caught. It
+// returns a pointer to the exception object portion of the exception. This
+// function must work with foreign exceptions.
+//
void *__llvm_cxxeh_begin_catch(void) {
llvm_exception *E = UncaughtExceptionStack;
assert(UncaughtExceptionStack && "There are no uncaught exceptions!?!?");
- /* The exception is now no longer uncaught... */
+ // The exception is now no longer uncaught.
UncaughtExceptionStack = E->Next;
- /* The exception is now caught... */
+ // The exception is now caught.
E->Next = CaughtExceptionStack;
CaughtExceptionStack = E->Next;
- /* Increment the handler count for this exception. */
+ // Increment the handler count for this exception.
E->HandlerCount++;
-
- /* Return a pointer to the exception object */
+
+ // Return a pointer to the raw exception object.
return E+1;
}
-/* __llvm_cxxeh_end_catch - This function decrements the HandlerCount of the
- * top-level caught exception, destroying it if this is the last handler for the
- * exception.
- */
+// __llvm_cxxeh_begin_catch_if_isa - This function checks to see if the current
+// uncaught exception is of the specified type. If not, it returns a null
+// pointer, otherwise it 'catches' the exception and returns a pointer to the
+// object of the specified type. This function does never succeeds with foreign
+// exceptions (because they can never be of type CatchType).
+//
+void *__llvm_cxxeh_begin_catch_if_isa(const std::type_info *CatchType) {
+ void *ObjPtr = __llvm_cxxeh_current_uncaught_exception_isa(CatchType);
+ if (!ObjPtr) return 0;
+
+ // begin_catch, meaning that the object is now "caught", not "uncaught"
+ __llvm_cxxeh_begin_catch();
+ return ObjPtr;
+}
+
+
+// __llvm_cxxeh_end_catch - This function decrements the HandlerCount of the
+// top-level caught exception, destroying it if this is the last handler for the
+// exception.
+//
void __llvm_cxxeh_end_catch(void) {
llvm_exception *E = CaughtExceptionStack;
assert(E && "There are no caught exceptions!");
- /* If this is the last handler using the exception, destroy it now! */
+ // If this is the last handler using the exception, destroy it now!
if (--E->HandlerCount == 0) {
- CaughtExceptionStack = E->Next; /* Unlink from the stack */
- E->ExceptionDestructor(E); /* Release memory for the exception */
+ CaughtExceptionStack = E->Next; // Unlink from the stack
+ E->ExceptionDestructor(E); // Release memory for the exception
}
}
-/* __llvm_cxxeh_rethrow - This function turns the top-level caught exception
- * into an uncaught exception, in preparation for an llvm.unwind, which should
- * follow immediately after the call to this function. This function must be
- * prepared to deal with foreign exceptions.
- */
+// __llvm_cxxeh_rethrow - This function turns the top-level caught exception
+// into an uncaught exception, in preparation for an llvm.unwind, which should
+// follow immediately after the call to this function. This function must be
+// prepared to deal with foreign exceptions.
+//
void __llvm_cxxeh_rethrow(void) {
llvm_exception *E = CaughtExceptionStack;
if (E == 0) {
- /* 15.1.8 - If there are no uncaught exceptions being thrown, 'throw;'
- * should call terminate.
- */
- /* FIXME */assert(0 && "FIXME: this should call E->Terminate!");
+ // 15.1.8 - If there are no uncaught exceptions being thrown, 'throw;'
+ // should call terminate.
+ //
+ assert(0 && "FIXME: this should call E->Terminate!"); // FIXME!
}
- /* Otherwise we have an exception to rethrow. Move it back to the uncaught
- * stack.
- */
+ // Otherwise we have an exception to rethrow. Move it back to the uncaught
+ // stack.
CaughtExceptionStack = E->Next;
E->Next = UncaughtExceptionStack;
UncaughtExceptionStack = E;
- /* Decrement the number of handlers which are using the exception. */
+ // Decrement the number of handlers which are using the exception.
--E->HandlerCount;
- /* Return to the caller, which should perform the unwind now. */
+ // Return to the caller, which should perform the unwind now.
}
Index: llvm/runtime/GCCLibraries/libexception/c++-exception.h
diff -u llvm/runtime/GCCLibraries/libexception/c++-exception.h:1.1 llvm/runtime/GCCLibraries/libexception/c++-exception.h:1.2
--- llvm/runtime/GCCLibraries/libexception/c++-exception.h:1.1 Mon Aug 25 17:35:36 2003
+++ llvm/runtime/GCCLibraries/libexception/c++-exception.h Tue Aug 26 18:46:53 2003
@@ -54,6 +54,7 @@
void * __llvm_cxxeh_current_uncaught_exception_isa(const std::type_info *Ty);
void *__llvm_cxxeh_begin_catch(void);
+ void *__llvm_cxxeh_begin_catch_if_isa(const std::type_info *CatchType);
void __llvm_cxxeh_end_catch(void);
void __llvm_cxxeh_rethrow(void);
From lattner at cs.uiuc.edu Tue Aug 26 20:06:02 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Tue Aug 26 20:06:02 2003
Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/SCCP/2003-08-26-InvokeHandling.ll
Message-ID: <200308270105.UAA32481@apoc.cs.uiuc.edu>
Changes in directory llvm/test/Regression/Transforms/SCCP:
2003-08-26-InvokeHandling.ll added (r1.1)
---
Log message:
New testcase
---
Diffs of the changes:
Index: llvm/test/Regression/Transforms/SCCP/2003-08-26-InvokeHandling.ll
diff -c /dev/null llvm/test/Regression/Transforms/SCCP/2003-08-26-InvokeHandling.ll:1.1
*** /dev/null Tue Aug 26 20:05:29 2003
--- llvm/test/Regression/Transforms/SCCP/2003-08-26-InvokeHandling.ll Tue Aug 26 20:05:19 2003
***************
*** 0 ****
--- 1,15 ----
+ ; The PHI cannot be eliminated from this testcase, SCCP is mishandling invoke's!
+ ; RUN: as < %s | opt -sccp | dis | grep phi
+
+ declare void %foo()
+ int %test(bool %cond) {
+ Entry:
+ br bool %cond, label %Inv, label %Cont
+ Inv:
+ invoke void %foo() to label %Ok except label %Cont
+ Ok:
+ br label %Cont
+ Cont:
+ %X = phi int [0, %Entry], [1,%Ok], [0, %Inv]
+ ret int %X
+ }
From lattner at cs.uiuc.edu Tue Aug 26 20:09:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Tue Aug 26 20:09:01 2003
Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/SCCP.cpp
Message-ID: <200308270108.UAA00528@apoc.cs.uiuc.edu>
Changes in directory llvm/lib/Transforms/Scalar:
SCCP.cpp updated: 1.72 -> 1.73
---
Log message:
Fix bug: SCCP/2003-08-26-InvokeHandling.ll
---
Diffs of the changes:
Index: llvm/lib/Transforms/Scalar/SCCP.cpp
diff -u llvm/lib/Transforms/Scalar/SCCP.cpp:1.72 llvm/lib/Transforms/Scalar/SCCP.cpp:1.73
--- llvm/lib/Transforms/Scalar/SCCP.cpp:1.72 Mon Aug 18 09:33:38 2003
+++ llvm/lib/Transforms/Scalar/SCCP.cpp Tue Aug 26 20:08:35 2003
@@ -192,7 +192,10 @@
void visitLoadInst (Instruction &I) { markOverdefined(&I); }
void visitGetElementPtrInst(GetElementPtrInst &I);
void visitCallInst (Instruction &I) { markOverdefined(&I); }
- void visitInvokeInst (Instruction &I) { markOverdefined(&I); }
+ void visitInvokeInst (TerminatorInst &I) {
+ markOverdefined(&I);
+ visitTerminatorInst(I);
+ }
void visitAllocationInst(Instruction &I) { markOverdefined(&I); }
void visitVarArgInst (Instruction &I) { markOverdefined(&I); }
void visitFreeInst (Instruction &I) { /*returns void*/ }
From tbrethou at niobe.cs.uiuc.edu Tue Aug 26 21:44:01 2003
From: tbrethou at niobe.cs.uiuc.edu (Tanya Brethour)
Date: Tue Aug 26 21:44:01 2003
Subject: [llvm-commits] CVS: llvm/lib/CodeGen/InstrSched/SchedGraph.cpp SchedGraph.h SchedGraphCommon.cpp
Message-ID: <200308270243.h7R2h9e10148@niobe.cs.uiuc.edu>
Changes in directory llvm/lib/CodeGen/InstrSched:
SchedGraph.cpp updated: 1.47 -> 1.48
SchedGraph.h updated: 1.31 -> 1.32
SchedGraphCommon.cpp updated: 1.1 -> 1.2
---
Log message:
(null)
---
Diffs of the changes:
Index: llvm/lib/CodeGen/InstrSched/SchedGraph.cpp
diff -u llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.47 llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.48
--- llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.47 Mon Aug 25 17:42:20 2003
+++ llvm/lib/CodeGen/InstrSched/SchedGraph.cpp Tue Aug 26 21:42:58 2003
@@ -7,21 +7,14 @@
//===----------------------------------------------------------------------===//
#include "SchedGraph.h"
-#include "llvm/CodeGen/SchedGraphCommon.h"
-#include
-
-#include "llvm/Target/TargetMachine.h"
-#include "llvm/Target/TargetInstrInfo.h"
-#include "Support/STLExtras.h"
-#include "llvm/BasicBlock.h"
-#include "llvm/CodeGen/MachineCodeForInstruction.h"
-#include "llvm/Target/TargetRegInfo.h"
#include "llvm/Function.h"
-#include "llvm/CodeGen/MachineFunction.h"
-#include "llvm/CodeGen/InstrSelection.h"
#include "llvm/iOther.h"
-#include "Support/StringExtras.h"
-
+#include "llvm/CodeGen/MachineCodeForInstruction.h"
+#include "llvm/CodeGen/MachineFunction.h"
+#include "llvm/Target/TargetInstrInfo.h"
+#include "llvm/Target/TargetMachine.h"
+#include "llvm/Target/TargetRegInfo.h"
+#include "Support/STLExtras.h"
//*********************** Internal Data Structures *************************/
@@ -49,26 +42,19 @@
// class SchedGraphNode
//
-/*ctor*/
-SchedGraphNode::SchedGraphNode(unsigned NID,
- MachineBasicBlock *mbb,
- int indexInBB,
- const TargetMachine& Target)
- : SchedGraphNodeCommon(NID), origIndexInBB(indexInBB), MBB(mbb), MI(mbb ? (*mbb)[indexInBB] : 0)
- {
- if (MI)
- {
- MachineOpCode mopCode = MI->getOpCode();
- latency = Target.getInstrInfo().hasResultInterlock(mopCode)
- ? Target.getInstrInfo().minLatency(mopCode)
- : Target.getInstrInfo().maxLatency(mopCode);
- }
+SchedGraphNode::SchedGraphNode(unsigned NID, MachineBasicBlock *mbb,
+ int indexInBB, const TargetMachine& Target)
+ : SchedGraphNodeCommon(NID), origIndexInBB(indexInBB), MBB(mbb),
+ MI(mbb ? (*mbb)[indexInBB] : 0) {
+ if (MI) {
+ MachineOpCode mopCode = MI->getOpCode();
+ latency = Target.getInstrInfo().hasResultInterlock(mopCode)
+ ? Target.getInstrInfo().minLatency(mopCode)
+ : Target.getInstrInfo().maxLatency(mopCode);
+ }
}
-
-/*dtor*/
-SchedGraphNode::~SchedGraphNode()
-{
+SchedGraphNode::~SchedGraphNode() {
// for each node, delete its out-edges
std::for_each(beginOutEdges(), endOutEdges(),
deleter);
@@ -77,28 +63,19 @@
//
// class SchedGraph
//
-
-
-/*ctor*/
SchedGraph::SchedGraph(MachineBasicBlock &mbb, const TargetMachine& target)
: MBB(mbb) {
buildGraph(target);
}
-
-/*dtor*/
-SchedGraph::~SchedGraph()
-{
+SchedGraph::~SchedGraph() {
for (const_iterator I = begin(); I != end(); ++I)
delete I->second;
delete graphRoot;
delete graphLeaf;
}
-
-void
-SchedGraph::dump() const
-{
+void SchedGraph::dump() const {
std::cerr << " Sched Graph for Basic Block: ";
std::cerr << MBB.getBasicBlock()->getName()
<< " (" << MBB.getBasicBlock() << ")";
@@ -117,13 +94,10 @@
-void
-SchedGraph::addDummyEdges()
-{
+void SchedGraph::addDummyEdges() {
assert(graphRoot->outEdges.size() == 0);
- for (const_iterator I=begin(); I != end(); ++I)
- {
+ for (const_iterator I=begin(); I != end(); ++I) {
SchedGraphNode* node = (*I).second;
assert(node != graphRoot && node != graphLeaf);
if (node->beginInEdges() == node->endInEdges())
@@ -136,10 +110,8 @@
}
-void
-SchedGraph::addCDEdges(const TerminatorInst* term,
- const TargetMachine& target)
-{
+void SchedGraph::addCDEdges(const TerminatorInst* term,
+ const TargetMachine& target) {
const TargetInstrInfo& mii = target.getInstrInfo();
MachineCodeForInstruction &termMvec = MachineCodeForInstruction::get(term);
@@ -153,22 +125,20 @@
"No branch instructions for terminator? Ok, but weird!");
if (first == termMvec.size())
return;
-
+
SchedGraphNode* firstBrNode = getGraphNodeForInstr(termMvec[first]);
-
+
// Add CD edges from each instruction in the sequence to the
// *last preceding* branch instr. in the sequence
// Use a latency of 0 because we only need to prevent out-of-order issue.
//
- for (unsigned i = termMvec.size(); i > first+1; --i)
- {
+ for (unsigned i = termMvec.size(); i > first+1; --i) {
SchedGraphNode* toNode = getGraphNodeForInstr(termMvec[i-1]);
assert(toNode && "No node for instr generated for branch/ret?");
-
+
for (unsigned j = i-1; j != 0; --j)
if (mii.isBranch(termMvec[j-1]->getOpCode()) ||
- mii.isReturn(termMvec[j-1]->getOpCode()))
- {
+ mii.isReturn(termMvec[j-1]->getOpCode())) {
SchedGraphNode* brNode = getGraphNodeForInstr(termMvec[j-1]);
assert(brNode && "No node for instr generated for branch/ret?");
(void) new SchedGraphEdge(brNode, toNode, SchedGraphEdge::CtrlDep,
@@ -180,8 +150,7 @@
// Add CD edges from each instruction preceding the first branch
// to the first branch. Use a latency of 0 as above.
//
- for (unsigned i = first; i != 0; --i)
- {
+ for (unsigned i = first; i != 0; --i) {
SchedGraphNode* fromNode = getGraphNodeForInstr(termMvec[i-1]);
assert(fromNode && "No node for instr generated for branch?");
(void) new SchedGraphEdge(fromNode, firstBrNode, SchedGraphEdge::CtrlDep,
@@ -191,15 +160,14 @@
// Now add CD edges to the first branch instruction in the sequence from
// all preceding instructions in the basic block. Use 0 latency again.
//
- for (unsigned i=0, N=MBB.size(); i < N; i++)
- {
+ for (unsigned i=0, N=MBB.size(); i < N; i++) {
if (MBB[i] == termMvec[first]) // reached the first branch
break;
-
+
SchedGraphNode* fromNode = this->getGraphNodeForInstr(MBB[i]);
if (fromNode == NULL)
continue; // dummy instruction, e.g., PHI
-
+
(void) new SchedGraphEdge(fromNode, firstBrNode,
SchedGraphEdge::CtrlDep,
SchedGraphEdge::NonDataDep, 0);
@@ -211,8 +179,7 @@
unsigned d = mii.getNumDelaySlots(MBB[i]->getOpCode());
assert(i+d < N && "Insufficient delay slots for instruction?");
- for (unsigned j=1; j <= d; j++)
- {
+ for (unsigned j=1; j <= d; j++) {
SchedGraphNode* toNode = this->getGraphNodeForInstr(MBB[i+j]);
assert(toNode && "No node for machine instr in delay slot?");
(void) new SchedGraphEdge(fromNode, toNode,
@@ -228,15 +195,15 @@
static const unsigned int SG_DepOrderArray[][3] = {
{ SchedGraphEdge::NonDataDep,
- SchedGraphEdge::AntiDep,
- SchedGraphEdge::AntiDep },
+ SchedGraphEdge::AntiDep,
+ SchedGraphEdge::AntiDep },
{ SchedGraphEdge::TrueDep,
- SchedGraphEdge::OutputDep,
- SchedGraphEdge::TrueDep | SchedGraphEdge::OutputDep },
+ SchedGraphEdge::OutputDep,
+ SchedGraphEdge::TrueDep | SchedGraphEdge::OutputDep },
{ SchedGraphEdge::TrueDep,
- SchedGraphEdge::AntiDep | SchedGraphEdge::OutputDep,
- SchedGraphEdge::TrueDep | SchedGraphEdge::AntiDep
- | SchedGraphEdge::OutputDep }
+ SchedGraphEdge::AntiDep | SchedGraphEdge::OutputDep,
+ SchedGraphEdge::TrueDep | SchedGraphEdge::AntiDep
+ | SchedGraphEdge::OutputDep }
};
@@ -245,28 +212,24 @@
// Use latency 1 just to ensure that memory operations are ordered;
// latency does not otherwise matter (true dependences enforce that).
//
-void
-SchedGraph::addMemEdges(const std::vector& memNodeVec,
- const TargetMachine& target)
-{
+void SchedGraph::addMemEdges(const std::vector& memNodeVec,
+ const TargetMachine& target) {
const TargetInstrInfo& mii = target.getInstrInfo();
// Instructions in memNodeVec are in execution order within the basic block,
// so simply look at all pairs i]>.
//
- for (unsigned im=0, NM=memNodeVec.size(); im < NM; im++)
- {
+ for (unsigned im=0, NM=memNodeVec.size(); im < NM; im++) {
MachineOpCode fromOpCode = memNodeVec[im]->getOpCode();
int fromType = (mii.isCall(fromOpCode)? SG_CALL_REF
: (mii.isLoad(fromOpCode)? SG_LOAD_REF
: SG_STORE_REF));
- for (unsigned jm=im+1; jm < NM; jm++)
- {
+ for (unsigned jm=im+1; jm < NM; jm++) {
MachineOpCode toOpCode = memNodeVec[jm]->getOpCode();
int toType = (mii.isCall(toOpCode)? SG_CALL_REF
: (mii.isLoad(toOpCode)? SG_LOAD_REF
: SG_STORE_REF));
-
+
if (fromType != SG_LOAD_REF || toType != SG_LOAD_REF)
(void) new SchedGraphEdge(memNodeVec[im], memNodeVec[jm],
SchedGraphEdge::MemoryDep,
@@ -281,30 +244,27 @@
// Use a latency of 0 because we only need to prevent out-of-order issue,
// like with control dependences.
//
-void
-SchedGraph::addCallDepEdges(const std::vector& callDepNodeVec,
- const TargetMachine& target)
-{
+void SchedGraph::addCallDepEdges(const std::vector& callDepNodeVec,
+ const TargetMachine& target) {
const TargetInstrInfo& mii = target.getInstrInfo();
// Instructions in memNodeVec are in execution order within the basic block,
// so simply look at all pairs i]>.
//
for (unsigned ic=0, NC=callDepNodeVec.size(); ic < NC; ic++)
- if (mii.isCall(callDepNodeVec[ic]->getOpCode()))
- {
- // Add SG_CALL_REF edges from all preds to this instruction.
- for (unsigned jc=0; jc < ic; jc++)
- (void) new SchedGraphEdge(callDepNodeVec[jc], callDepNodeVec[ic],
- SchedGraphEdge::MachineRegister,
- MachineIntRegsRID, 0);
-
- // And do the same from this instruction to all successors.
- for (unsigned jc=ic+1; jc < NC; jc++)
- (void) new SchedGraphEdge(callDepNodeVec[ic], callDepNodeVec[jc],
- SchedGraphEdge::MachineRegister,
- MachineIntRegsRID, 0);
- }
+ if (mii.isCall(callDepNodeVec[ic]->getOpCode())) {
+ // Add SG_CALL_REF edges from all preds to this instruction.
+ for (unsigned jc=0; jc < ic; jc++)
+ (void) new SchedGraphEdge(callDepNodeVec[jc], callDepNodeVec[ic],
+ SchedGraphEdge::MachineRegister,
+ MachineIntRegsRID, 0);
+
+ // And do the same from this instruction to all successors.
+ for (unsigned jc=ic+1; jc < NC; jc++)
+ (void) new SchedGraphEdge(callDepNodeVec[ic], callDepNodeVec[jc],
+ SchedGraphEdge::MachineRegister,
+ MachineIntRegsRID, 0);
+ }
#ifdef CALL_DEP_NODE_VEC_CANNOT_WORK
// Find the call instruction nodes and put them in a vector.
@@ -320,16 +280,14 @@
//
int lastCallNodeIdx = -1;
for (unsigned i=0, N=bbMvec.size(); i < N; i++)
- if (mii.isCall(bbMvec[i]->getOpCode()))
- {
+ if (mii.isCall(bbMvec[i]->getOpCode())) {
++lastCallNodeIdx;
for ( ; lastCallNodeIdx < (int)callNodeVec.size(); ++lastCallNodeIdx)
if (callNodeVec[lastCallNodeIdx]->getMachineInstr() == bbMvec[i])
break;
assert(lastCallNodeIdx < (int)callNodeVec.size() && "Missed Call?");
}
- else if (mii.isCCInstr(bbMvec[i]->getOpCode()))
- {
+ else if (mii.isCCInstr(bbMvec[i]->getOpCode())) {
// Add incoming/outgoing edges from/to preceding/later calls
SchedGraphNode* ccNode = this->getGraphNodeForInstr(bbMvec[i]);
int j=0;
@@ -344,19 +302,16 @@
}
-void
-SchedGraph::addMachineRegEdges(RegToRefVecMap& regToRefVecMap,
- const TargetMachine& target)
-{
+void SchedGraph::addMachineRegEdges(RegToRefVecMap& regToRefVecMap,
+ const TargetMachine& target) {
// This code assumes that two registers with different numbers are
// not aliased!
//
for (RegToRefVecMap::iterator I = regToRefVecMap.begin();
- I != regToRefVecMap.end(); ++I)
- {
+ I != regToRefVecMap.end(); ++I) {
int regNum = (*I).first;
RefVec& regRefVec = (*I).second;
-
+
// regRefVec is ordered by control flow order in the basic block
for (unsigned i=0; i < regRefVec.size(); ++i) {
SchedGraphNode* node = regRefVec[i].first;
@@ -382,7 +337,7 @@
new SchedGraphEdge(prevNode, node, regNum,
SchedGraphEdge::AntiDep);
}
-
+
if (prevIsDef)
if (!isDef || isDefAndUse)
new SchedGraphEdge(prevNode, node, regNum,
@@ -398,23 +353,20 @@
// in the basic block. refNode may be a use, a def, or both.
// We do not consider other uses because we are not building use-use deps.
//
-void
-SchedGraph::addEdgesForValue(SchedGraphNode* refNode,
- const RefVec& defVec,
- const Value* defValue,
- bool refNodeIsDef,
- bool refNodeIsDefAndUse,
- const TargetMachine& target)
-{
+void SchedGraph::addEdgesForValue(SchedGraphNode* refNode,
+ const RefVec& defVec,
+ const Value* defValue,
+ bool refNodeIsDef,
+ bool refNodeIsDefAndUse,
+ const TargetMachine& target) {
bool refNodeIsUse = !refNodeIsDef || refNodeIsDefAndUse;
// Add true or output dep edges from all def nodes before refNode in BB.
// Add anti or output dep edges to all def nodes after refNode.
- for (RefVec::const_iterator I=defVec.begin(), E=defVec.end(); I != E; ++I)
- {
+ for (RefVec::const_iterator I=defVec.begin(), E=defVec.end(); I != E; ++I) {
if ((*I).first == refNode)
continue; // Dont add any self-loops
-
+
if ((*I).first->getOrigIndexInBB() < refNode->getOrigIndexInBB()) {
// (*).first is before refNode
if (refNodeIsDef)
@@ -436,25 +388,20 @@
}
-void
-SchedGraph::addEdgesForInstruction(const MachineInstr& MI,
- const ValueToDefVecMap& valueToDefVecMap,
- const TargetMachine& target)
-{
+void SchedGraph::addEdgesForInstruction(const MachineInstr& MI,
+ const ValueToDefVecMap& valueToDefVecMap,
+ const TargetMachine& target) {
SchedGraphNode* node = getGraphNodeForInstr(&MI);
if (node == NULL)
return;
// Add edges for all operands of the machine instruction.
//
- for (unsigned i = 0, numOps = MI.getNumOperands(); i != numOps; ++i)
- {
- switch (MI.getOperand(i).getType())
- {
+ for (unsigned i = 0, numOps = MI.getNumOperands(); i != numOps; ++i) {
+ switch (MI.getOperand(i).getType()) {
case MachineOperand::MO_VirtualRegister:
case MachineOperand::MO_CCRegister:
- if (const Value* srcI = MI.getOperand(i).getVRegValue())
- {
+ if (const Value* srcI = MI.getOperand(i).getVRegValue()) {
ValueToDefVecMap::const_iterator I = valueToDefVecMap.find(srcI);
if (I != valueToDefVecMap.end())
addEdgesForValue(node, I->second, srcI,
@@ -462,15 +409,15 @@
MI.getOperand(i).opIsDefAndUse(), target);
}
break;
-
+
case MachineOperand::MO_MachineRegister:
break;
-
+
case MachineOperand::MO_SignExtendedImmed:
case MachineOperand::MO_UnextendedImmed:
case MachineOperand::MO_PCRelativeDisp:
break; // nothing to do for immediate fields
-
+
default:
assert(0 && "Unknown machine operand type in SchedGraph builder");
break;
@@ -483,8 +430,7 @@
//
for (unsigned i=0, N=MI.getNumImplicitRefs(); i < N; ++i)
if (MI.getImplicitOp(i).opIsUse() || MI.getImplicitOp(i).opIsDefAndUse())
- if (const Value* srcI = MI.getImplicitRef(i))
- {
+ if (const Value* srcI = MI.getImplicitRef(i)) {
ValueToDefVecMap::const_iterator I = valueToDefVecMap.find(srcI);
if (I != valueToDefVecMap.end())
addEdgesForValue(node, I->second, srcI,
@@ -494,37 +440,33 @@
}
-void
-SchedGraph::findDefUseInfoAtInstr(const TargetMachine& target,
- SchedGraphNode* node,
- std::vector& memNodeVec,
- std::vector& callDepNodeVec,
- RegToRefVecMap& regToRefVecMap,
- ValueToDefVecMap& valueToDefVecMap)
-{
+void SchedGraph::findDefUseInfoAtInstr(const TargetMachine& target,
+ SchedGraphNode* node,
+ std::vector& memNodeVec,
+ std::vector& callDepNodeVec,
+ RegToRefVecMap& regToRefVecMap,
+ ValueToDefVecMap& valueToDefVecMap) {
const TargetInstrInfo& mii = target.getInstrInfo();
MachineOpCode opCode = node->getOpCode();
-
+
if (mii.isCall(opCode) || mii.isCCInstr(opCode))
callDepNodeVec.push_back(node);
-
+
if (mii.isLoad(opCode) || mii.isStore(opCode) || mii.isCall(opCode))
memNodeVec.push_back(node);
// Collect the register references and value defs. for explicit operands
//
const MachineInstr& MI = *node->getMachineInstr();
- for (int i=0, numOps = (int) MI.getNumOperands(); i < numOps; i++)
- {
+ for (int i=0, numOps = (int) MI.getNumOperands(); i < numOps; i++) {
const MachineOperand& mop = MI.getOperand(i);
-
+
// if this references a register other than the hardwired
// "zero" register, record the reference.
- if (mop.hasAllocatedReg())
- {
+ if (mop.hasAllocatedReg()) {
int regNum = mop.getAllocatedRegNum();
-
+
// If this is not a dummy zero register, record the reference in order
if (regNum != target.getRegInfo().getZeroRegNum())
regToRefVecMap[mop.getAllocatedRegNum()]
@@ -554,7 +496,7 @@
mop.getType() == MachineOperand::MO_CCRegister)
&& "Do not expect any other kind of operand to be defined!");
assert(mop.getVRegValue() != NULL && "Null value being defined?");
-
+
valueToDefVecMap[mop.getVRegValue()].push_back(std::make_pair(node, i));
}
@@ -562,11 +504,9 @@
// Collect value defs. for implicit operands. They may have allocated
// physical registers also.
//
- for (unsigned i=0, N = MI.getNumImplicitRefs(); i != N; ++i)
- {
+ for (unsigned i=0, N = MI.getNumImplicitRefs(); i != N; ++i) {
const MachineOperand& mop = MI.getImplicitOp(i);
- if (mop.hasAllocatedReg())
- {
+ if (mop.hasAllocatedReg()) {
int regNum = mop.getAllocatedRegNum();
if (regNum != target.getRegInfo().getZeroRegNum())
regToRefVecMap[mop.getAllocatedRegNum()]
@@ -583,14 +523,12 @@
}
-void
-SchedGraph::buildNodesForBB(const TargetMachine& target,
- MachineBasicBlock& MBB,
- std::vector& memNodeVec,
- std::vector& callDepNodeVec,
- RegToRefVecMap& regToRefVecMap,
- ValueToDefVecMap& valueToDefVecMap)
-{
+void SchedGraph::buildNodesForBB(const TargetMachine& target,
+ MachineBasicBlock& MBB,
+ std::vector& memNodeVec,
+ std::vector& callDepNodeVec,
+ RegToRefVecMap& regToRefVecMap,
+ ValueToDefVecMap& valueToDefVecMap) {
const TargetInstrInfo& mii = target.getInstrInfo();
// Build graph nodes for each VM instruction and gather def/use info.
@@ -607,9 +545,7 @@
}
-void
-SchedGraph::buildGraph(const TargetMachine& target)
-{
+void SchedGraph::buildGraph(const TargetMachine& target) {
// Use this data structure to note all machine operands that compute
// ordinary LLVM values. These must be computed defs (i.e., instructions).
// Note that there may be multiple machine instructions that define
@@ -698,28 +634,20 @@
//
// class SchedGraphSet
//
-
-/*ctor*/
SchedGraphSet::SchedGraphSet(const Function* _function,
const TargetMachine& target) :
- function(_function)
-{
+ function(_function) {
buildGraphsForMethod(function, target);
}
-
-/*dtor*/
-SchedGraphSet::~SchedGraphSet()
-{
+SchedGraphSet::~SchedGraphSet() {
// delete all the graphs
for(iterator I = begin(), E = end(); I != E; ++I)
delete *I; // destructor is a friend
}
-void
-SchedGraphSet::dump() const
-{
+void SchedGraphSet::dump() const {
std::cerr << "======== Sched graphs for function `" << function->getName()
<< "' ========\n\n";
@@ -731,54 +659,58 @@
}
-void
-SchedGraphSet::buildGraphsForMethod(const Function *F,
- const TargetMachine& target)
-{
+void SchedGraphSet::buildGraphsForMethod(const Function *F,
+ const TargetMachine& target) {
MachineFunction &MF = MachineFunction::get(F);
for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I)
addGraph(new SchedGraph(*I, target));
}
-std::ostream &operator<<(std::ostream &os, const SchedGraphEdge& edge)
-{
- os << "edge [" << edge.src->getNodeId() << "] -> ["
- << edge.sink->getNodeId() << "] : ";
-
- switch(edge.depType) {
- case SchedGraphEdge::CtrlDep: os<< "Control Dep"; break;
- case SchedGraphEdge::ValueDep: os<< "Reg Value " << edge.val; break;
- case SchedGraphEdge::MemoryDep: os<< "Memory Dep"; break;
- case SchedGraphEdge::MachineRegister: os<< "Reg " <getNodeId() << "] -> ["
+ << sink->getNodeId() << "] : ";
+
+ switch(depType) {
+ case SchedGraphEdge::CtrlDep:
+ os<< "Control Dep";
+ break;
+ case SchedGraphEdge::ValueDep:
+ os<< "Reg Value " << val;
+ break;
+ case SchedGraphEdge::MemoryDep:
+ os<< "Memory Dep";
+ break;
+ case SchedGraphEdge::MachineRegister:
+ os<< "Reg " << machineRegNum;
+ break;
+ case SchedGraphEdge::MachineResource:
+ os<<"Resource "<< resourceId;
+ break;
+ default:
+ assert(0);
+ break;
}
- os << " : delay = " << edge.minDelay << "\n";
-
- return os;
+ os << " : delay = " << minDelay << "\n";
}
-std::ostream &operator<<(std::ostream &os, const SchedGraphNode& node)
-{
+void SchedGraphNode::print(std::ostream &os) const {
os << std::string(8, ' ')
- << "Node " << node.ID << " : "
- << "latency = " << node.latency << "\n" << std::string(12, ' ');
+ << "Node " << ID << " : "
+ << "latency = " << latency << "\n" << std::string(12, ' ');
- if (node.getMachineInstr() == NULL)
+ if (getMachineInstr() == NULL)
os << "(Dummy node)\n";
else {
- os << *node.getMachineInstr() << "\n" << std::string(12, ' ');
- os << node.inEdges.size() << " Incoming Edges:\n";
- for (unsigned i=0, N=node.inEdges.size(); i < N; i++)
- os << std::string(16, ' ') << *node.inEdges[i];
+ os << *getMachineInstr() << "\n" << std::string(12, ' ');
+ os << inEdges.size() << " Incoming Edges:\n";
+ for (unsigned i=0, N = inEdges.size(); i < N; i++)
+ os << std::string(16, ' ') << *inEdges[i];
- os << std::string(12, ' ') << node.outEdges.size()
+ os << std::string(12, ' ') << outEdges.size()
<< " Outgoing Edges:\n";
- for (unsigned i=0, N=node.outEdges.size(); i < N; i++)
- os << std::string(16, ' ') << *node.outEdges[i];
+ for (unsigned i=0, N= outEdges.size(); i < N; i++)
+ os << std::string(16, ' ') << *outEdges[i];
}
-
- return os;
}
Index: llvm/lib/CodeGen/InstrSched/SchedGraph.h
diff -u llvm/lib/CodeGen/InstrSched/SchedGraph.h:1.31 llvm/lib/CodeGen/InstrSched/SchedGraph.h:1.32
--- llvm/lib/CodeGen/InstrSched/SchedGraph.h:1.31 Mon Aug 25 17:42:20 2003
+++ llvm/lib/CodeGen/InstrSched/SchedGraph.h Tue Aug 26 21:42:58 2003
@@ -14,11 +14,12 @@
#ifndef LLVM_CODEGEN_SCHEDGRAPH_H
#define LLVM_CODEGEN_SCHEDGRAPH_H
+#include "llvm/CodeGen/SchedGraphCommon.h"
#include "llvm/CodeGen/MachineInstr.h"
-#include "Support/GraphTraits.h"
-#include "Support/hash_map"
#include "llvm/Transforms/Scalar.h"
-#include "llvm/CodeGen/SchedGraphCommon.h"
+#include "Support/hash_map"
+#include "Support/GraphTraits.h"
+
class RegToRefVecMap;
class ValueToDefVecMap;
@@ -31,21 +32,23 @@
const MachineInstr *MI;
- SchedGraphNode (unsigned nodeId, MachineBasicBlock *mbb,
- int indexInBB, const TargetMachine& Target);
- ~SchedGraphNode ();
+ SchedGraphNode(unsigned nodeId, MachineBasicBlock *mbb, int indexInBB,
+ const TargetMachine& Target);
+ ~SchedGraphNode();
friend class SchedGraph; // give access for ctor and dtor
friend class SchedGraphEdge; // give access for adding edges
public:
+
// Accessor methods
- const MachineInstr* getMachineInstr () const { return MI; }
- const MachineOpCode getOpCode () const { return MI->getOpCode(); }
- bool isDummyNode () const { return (MI == NULL); }
- MachineBasicBlock &getMachineBasicBlock() const { return *MBB; }
+ const MachineInstr* getMachineInstr() const { return MI; }
+ const MachineOpCode getOpCode() const { return MI->getOpCode(); }
+ bool isDummyNode() const { return (MI == NULL); }
+ MachineBasicBlock &getMachineBasicBlock() const { return *MBB; }
- int getOrigIndexInBB() const { return origIndexInBB; }
+ int getOrigIndexInBB() const { return origIndexInBB; }
+ void print(std::ostream &os) const;
};
class SchedGraph : public SchedGraphCommon {
@@ -56,15 +59,15 @@
typedef hash_map::const_iterator iterator;
typedef hash_map::const_iterator const_iterator;
- MachineBasicBlock& getBasicBlock() const{return MBB;}
- const unsigned int getNumNodes() const { return GraphMap.size()+2; }
+ MachineBasicBlock& getBasicBlock() const{return MBB;}
+ const unsigned int getNumNodes() const { return GraphMap.size()+2; }
SchedGraphNode* getGraphNodeForInstr(const MachineInstr* MI) const {
const_iterator onePair = find(MI);
return (onePair != end())? onePair->second : NULL;
}
// Debugging support
- void dump () const;
+ void dump() const;
protected:
SchedGraph(MachineBasicBlock& mbb, const TargetMachine& TM);
@@ -89,12 +92,9 @@
private:
friend class SchedGraphSet; // give access to ctor
-
-
-
+
inline void noteGraphNodeForInstr (const MachineInstr* minstr,
- SchedGraphNode* node)
- {
+ SchedGraphNode* node) {
assert((*this)[minstr] == NULL);
(*this)[minstr] = node;
}
@@ -102,50 +102,46 @@
//
// Graph builder
//
- void buildGraph (const TargetMachine& target);
+ void buildGraph(const TargetMachine& target);
- void buildNodesForBB (const TargetMachine& target,
- MachineBasicBlock &MBB,
- std::vector& memNV,
- std::vector& callNV,
- RegToRefVecMap& regToRefVecMap,
- ValueToDefVecMap& valueToDefVecMap);
-
-
- void findDefUseInfoAtInstr (const TargetMachine& target,
- SchedGraphNode* node,
- std::vector& memNV,
- std::vector& callNV,
- RegToRefVecMap& regToRefVecMap,
- ValueToDefVecMap& valueToDefVecMap);
+ void buildNodesForBB(const TargetMachine& target,MachineBasicBlock &MBB,
+ std::vector& memNV,
+ std::vector& callNV,
+ RegToRefVecMap& regToRefVecMap,
+ ValueToDefVecMap& valueToDefVecMap);
+
+ void findDefUseInfoAtInstr(const TargetMachine& target, SchedGraphNode* node,
+ std::vector& memNV,
+ std::vector& callNV,
+ RegToRefVecMap& regToRefVecMap,
+ ValueToDefVecMap& valueToDefVecMap);
- void addEdgesForInstruction(const MachineInstr& minstr,
- const ValueToDefVecMap& valueToDefVecMap,
- const TargetMachine& target);
-
- void addCDEdges (const TerminatorInst* term,
- const TargetMachine& target);
-
- void addMemEdges (const std::vector& memNod,
- const TargetMachine& target);
-
- void addCallCCEdges (const std::vector& memNod,
- MachineBasicBlock& bbMvec,
- const TargetMachine& target);
- void addCallDepEdges (const std::vector& callNV,
- const TargetMachine& target);
-
- void addMachineRegEdges (RegToRefVecMap& regToRefVecMap,
- const TargetMachine& target);
-
- void addEdgesForValue (SchedGraphNode* refNode,
- const RefVec& defVec,
- const Value* defValue,
- bool refNodeIsDef,
- bool refNodeIsDefAndUse,
- const TargetMachine& target);
- void addDummyEdges();
+ void addEdgesForInstruction(const MachineInstr& minstr,
+ const ValueToDefVecMap& valueToDefVecMap,
+ const TargetMachine& target);
+
+ void addCDEdges(const TerminatorInst* term, const TargetMachine& target);
+
+ void addMemEdges(const std::vector& memNod,
+ const TargetMachine& target);
+
+ void addCallCCEdges(const std::vector& memNod,
+ MachineBasicBlock& bbMvec,
+ const TargetMachine& target);
+
+ void addCallDepEdges(const std::vector& callNV,
+ const TargetMachine& target);
+
+ void addMachineRegEdges(RegToRefVecMap& regToRefVecMap,
+ const TargetMachine& target);
+
+ void addEdgesForValue(SchedGraphNode* refNode, const RefVec& defVec,
+ const Value* defValue, bool refNodeIsDef,
+ bool refNodeIsDefAndUse,
+ const TargetMachine& target);
+
+ void addDummyEdges();
};
@@ -156,7 +152,7 @@
std::vector Graphs;
// Graph builder
- void buildGraphsForMethod (const Function *F, const TargetMachine& target);
+ void buildGraphsForMethod(const Function *F, const TargetMachine& target);
inline void addGraph(SchedGraph* graph) {
assert(graph != NULL);
@@ -164,7 +160,7 @@
}
public:
- SchedGraphSet(const Function * function, const TargetMachine& target);
+ SchedGraphSet(const Function *function, const TargetMachine& target);
~SchedGraphSet();
//iterators
@@ -200,7 +196,7 @@
// operator*() differs for pred or succ iterator
inline _NodeType* operator*() const { return (_NodeType*)(*oi)->getSrc(); }
- inline _NodeType* operator->() const { return operator*(); }
+ inline _NodeType* operator->() const { return operator*(); }
inline _EdgeType* getEdge() const { return *(oi); }
@@ -228,7 +224,7 @@
inline bool operator!=(const _Self& x) const { return !operator==(x); }
inline _NodeType* operator*() const { return (_NodeType*)(*oi)->getSink(); }
- inline _NodeType* operator->() const { return operator*(); }
+ inline _NodeType* operator->() const { return operator*(); }
inline _EdgeType* getEdge() const { return *(oi); }
@@ -252,16 +248,16 @@
typedef SGPredIterator
sg_pred_const_iterator;
-inline sg_pred_iterator pred_begin( SchedGraphNode *N) {
+inline sg_pred_iterator pred_begin(SchedGraphNode *N) {
return sg_pred_iterator(N->beginInEdges());
}
-inline sg_pred_iterator pred_end( SchedGraphNode *N) {
+inline sg_pred_iterator pred_end(SchedGraphNode *N) {
return sg_pred_iterator(N->endInEdges());
}
inline sg_pred_const_iterator pred_begin(const SchedGraphNode *N) {
return sg_pred_const_iterator(N->beginInEdges());
}
-inline sg_pred_const_iterator pred_end( const SchedGraphNode *N) {
+inline sg_pred_const_iterator pred_end(const SchedGraphNode *N) {
return sg_pred_const_iterator(N->endInEdges());
}
@@ -275,16 +271,16 @@
typedef SGSuccIterator
sg_succ_const_iterator;
-inline sg_succ_iterator succ_begin( SchedGraphNode *N) {
+inline sg_succ_iterator succ_begin(SchedGraphNode *N) {
return sg_succ_iterator(N->beginOutEdges());
}
-inline sg_succ_iterator succ_end( SchedGraphNode *N) {
+inline sg_succ_iterator succ_end(SchedGraphNode *N) {
return sg_succ_iterator(N->endOutEdges());
}
inline sg_succ_const_iterator succ_begin(const SchedGraphNode *N) {
return sg_succ_const_iterator(N->beginOutEdges());
}
-inline sg_succ_const_iterator succ_end( const SchedGraphNode *N) {
+inline sg_succ_const_iterator succ_end(const SchedGraphNode *N) {
return sg_succ_const_iterator(N->endOutEdges());
}
@@ -318,9 +314,5 @@
return succ_end(N);
}
};
-
-
-std::ostream &operator<<(std::ostream& os, const SchedGraphEdge& edge);
-std::ostream &operator<<(std::ostream &os, const SchedGraphNode& node);
#endif
Index: llvm/lib/CodeGen/InstrSched/SchedGraphCommon.cpp
diff -u llvm/lib/CodeGen/InstrSched/SchedGraphCommon.cpp:1.1 llvm/lib/CodeGen/InstrSched/SchedGraphCommon.cpp:1.2
--- llvm/lib/CodeGen/InstrSched/SchedGraphCommon.cpp:1.1 Mon Aug 25 17:42:20 2003
+++ llvm/lib/CodeGen/InstrSched/SchedGraphCommon.cpp Tue Aug 26 21:42:58 2003
@@ -1,107 +1,78 @@
+//===- SchedGraphCommon.cpp - Scheduling Graphs Base Class- ---------------===//
+//
+// Scheduling graph base class that contains common information for SchedGraph
+// and ModuloSchedGraph scheduling graphs.
+//
+//===----------------------------------------------------------------------===//
+
#include "llvm/CodeGen/SchedGraphCommon.h"
#include "Support/STLExtras.h"
class SchedGraphCommon;
-//
+//
// class SchedGraphEdge
//
-
-/*ctor*/
SchedGraphEdge::SchedGraphEdge(SchedGraphNodeCommon* _src,
SchedGraphNodeCommon* _sink,
SchedGraphEdgeDepType _depType,
unsigned int _depOrderType,
int _minDelay)
- : src(_src),
- sink(_sink),
- depType(_depType),
- depOrderType(_depOrderType),
- minDelay((_minDelay >= 0)? _minDelay : _src->getLatency()),
- val(NULL)
-{
+ : src(_src), sink(_sink), depType(_depType), depOrderType(_depOrderType),
+ minDelay((_minDelay >= 0)? _minDelay : _src->getLatency()), val(NULL) {
+
iteDiff=0;
assert(src != sink && "Self-loop in scheduling graph!");
src->addOutEdge(this);
sink->addInEdge(this);
}
-
-/*ctor*/
SchedGraphEdge::SchedGraphEdge(SchedGraphNodeCommon* _src,
SchedGraphNodeCommon* _sink,
const Value* _val,
unsigned int _depOrderType,
int _minDelay)
- : src(_src),
- sink(_sink),
- depType(ValueDep),
- depOrderType(_depOrderType),
- minDelay((_minDelay >= 0)? _minDelay : _src->getLatency()),
- val(_val)
-{
+ : src(_src), sink(_sink), depType(ValueDep), depOrderType(_depOrderType),
+ minDelay((_minDelay >= 0)? _minDelay : _src->getLatency()), val(_val) {
iteDiff=0;
assert(src != sink && "Self-loop in scheduling graph!");
src->addOutEdge(this);
sink->addInEdge(this);
}
-
-/*ctor*/
SchedGraphEdge::SchedGraphEdge(SchedGraphNodeCommon* _src,
SchedGraphNodeCommon* _sink,
unsigned int _regNum,
unsigned int _depOrderType,
int _minDelay)
- : src(_src),
- sink(_sink),
- depType(MachineRegister),
+ : src(_src), sink(_sink), depType(MachineRegister),
depOrderType(_depOrderType),
minDelay((_minDelay >= 0)? _minDelay : _src->getLatency()),
- machineRegNum(_regNum)
-{
+ machineRegNum(_regNum) {
iteDiff=0;
assert(src != sink && "Self-loop in scheduling graph!");
src->addOutEdge(this);
sink->addInEdge(this);
}
-
-/*ctor*/
SchedGraphEdge::SchedGraphEdge(SchedGraphNodeCommon* _src,
SchedGraphNodeCommon* _sink,
ResourceId _resourceId,
int _minDelay)
- : src(_src),
- sink(_sink),
- depType(MachineResource),
- depOrderType(NonDataDep),
+ : src(_src), sink(_sink), depType(MachineResource), depOrderType(NonDataDep),
minDelay((_minDelay >= 0)? _minDelay : _src->getLatency()),
- resourceId(_resourceId)
-{
+ resourceId(_resourceId) {
iteDiff=0;
assert(src != sink && "Self-loop in scheduling graph!");
src->addOutEdge(this);
sink->addInEdge(this);
}
-/*dtor*/
-SchedGraphEdge::~SchedGraphEdge()
-{
-}
-
-void SchedGraphEdge::dump(int indent) const {
- std::cerr << std::string(indent*2, ' ') << *this;
-}
-/*ctor*/
-
-SchedGraphNodeCommon::SchedGraphNodeCommon(unsigned _nodeId)
- :ID(_nodeId),
- latency(0){
-
+void SchedGraphEdge::dump(int indent) const {
+ std::cerr << std::string(indent*2, ' ') << *this;
}
/*dtor*/
@@ -112,126 +83,88 @@
deleter);
}
-
-void SchedGraphNodeCommon::dump(int indent) const {
- std::cerr << std::string(indent*2, ' ') << *this;
-}
-
-
-inline void
-SchedGraphNodeCommon::addInEdge(SchedGraphEdge* edge)
-{
- inEdges.push_back(edge);
-}
-
-
-inline void
-SchedGraphNodeCommon::addOutEdge(SchedGraphEdge* edge)
-{
- outEdges.push_back(edge);
-}
-
-inline void
-SchedGraphNodeCommon::removeInEdge(const SchedGraphEdge* edge)
-{
+void SchedGraphNodeCommon::removeInEdge(const SchedGraphEdge* edge) {
assert(edge->getSink() == this);
for (iterator I = beginInEdges(); I != endInEdges(); ++I)
- if ((*I) == edge)
- {
- inEdges.erase(I);
- break;
- }
+ if ((*I) == edge) {
+ inEdges.erase(I);
+ break;
+ }
}
-inline void
-SchedGraphNodeCommon::removeOutEdge(const SchedGraphEdge* edge)
-{
+void SchedGraphNodeCommon::removeOutEdge(const SchedGraphEdge* edge) {
assert(edge->getSrc() == this);
for (iterator I = beginOutEdges(); I != endOutEdges(); ++I)
- if ((*I) == edge)
- {
- outEdges.erase(I);
- break;
- }
+ if ((*I) == edge) {
+ outEdges.erase(I);
+ break;
+ }
}
-
-//class SchedGraphCommon
-
-/*ctor*/
-SchedGraphCommon::SchedGraphCommon()
-{
+void SchedGraphNodeCommon::dump(int indent) const {
+ std::cerr << std::string(indent*2, ' ') << *this;
}
+//class SchedGraphCommon
-/*dtor*/
-SchedGraphCommon::~SchedGraphCommon()
-{
-
+SchedGraphCommon::~SchedGraphCommon() {
delete graphRoot;
delete graphLeaf;
}
-void
-SchedGraphCommon::eraseIncomingEdges(SchedGraphNodeCommon* node, bool addDummyEdges)
-{
+void SchedGraphCommon::eraseIncomingEdges(SchedGraphNodeCommon* node,
+ bool addDummyEdges) {
// Delete and disconnect all in-edges for the node
for (SchedGraphNodeCommon::iterator I = node->beginInEdges();
- I != node->endInEdges(); ++I)
- {
- SchedGraphNodeCommon* srcNode = (*I)->getSrc();
- srcNode->removeOutEdge(*I);
- delete *I;
+ I != node->endInEdges(); ++I) {
+ SchedGraphNodeCommon* srcNode = (*I)->getSrc();
+ srcNode->removeOutEdge(*I);
+ delete *I;
+
+ if (addDummyEdges && srcNode != getRoot() &&
+ srcNode->beginOutEdges() == srcNode->endOutEdges()) {
- if (addDummyEdges &&
- srcNode != getRoot() &&
- srcNode->beginOutEdges() == srcNode->endOutEdges())
- { // srcNode has no more out edges, so add an edge to dummy EXIT node
- assert(node != getLeaf() && "Adding edge that was just removed?");
- (void) new SchedGraphEdge(srcNode, getLeaf(),
- SchedGraphEdge::CtrlDep, SchedGraphEdge::NonDataDep, 0);
- }
+ // srcNode has no more out edges, so add an edge to dummy EXIT node
+ assert(node != getLeaf() && "Adding edge that was just removed?");
+ (void) new SchedGraphEdge(srcNode, getLeaf(),
+ SchedGraphEdge::CtrlDep,
+ SchedGraphEdge::NonDataDep, 0);
}
+ }
node->inEdges.clear();
}
-void
-SchedGraphCommon::eraseOutgoingEdges(SchedGraphNodeCommon* node, bool addDummyEdges)
-{
+void SchedGraphCommon::eraseOutgoingEdges(SchedGraphNodeCommon* node,
+ bool addDummyEdges) {
// Delete and disconnect all out-edges for the node
for (SchedGraphNodeCommon::iterator I = node->beginOutEdges();
- I != node->endOutEdges(); ++I)
- {
- SchedGraphNodeCommon* sinkNode = (*I)->getSink();
- sinkNode->removeInEdge(*I);
- delete *I;
+ I != node->endOutEdges(); ++I) {
+ SchedGraphNodeCommon* sinkNode = (*I)->getSink();
+ sinkNode->removeInEdge(*I);
+ delete *I;
+
+ if (addDummyEdges &&
+ sinkNode != getLeaf() &&
+ sinkNode->beginInEdges() == sinkNode->endInEdges()) {
- if (addDummyEdges &&
- sinkNode != getLeaf() &&
- sinkNode->beginInEdges() == sinkNode->endInEdges())
- { //sinkNode has no more in edges, so add an edge from dummy ENTRY node
- assert(node != getRoot() && "Adding edge that was just removed?");
- (void) new SchedGraphEdge(getRoot(), sinkNode,
- SchedGraphEdge::CtrlDep, SchedGraphEdge::NonDataDep, 0);
- }
+ //sinkNode has no more in edges, so add an edge from dummy ENTRY node
+ assert(node != getRoot() && "Adding edge that was just removed?");
+ (void) new SchedGraphEdge(getRoot(), sinkNode,
+ SchedGraphEdge::CtrlDep,
+ SchedGraphEdge::NonDataDep, 0);
}
+ }
node->outEdges.clear();
}
-void
-SchedGraphCommon::eraseIncidentEdges(SchedGraphNodeCommon* node, bool addDummyEdges)
-{
+void SchedGraphCommon::eraseIncidentEdges(SchedGraphNodeCommon* node,
+ bool addDummyEdges) {
this->eraseIncomingEdges(node, addDummyEdges);
this->eraseOutgoingEdges(node, addDummyEdges);
}
-std::ostream &operator<<(std::ostream &os, const SchedGraphNodeCommon& node)
-{
-
- return os;
-}
From tbrethou at cs.uiuc.edu Tue Aug 26 21:46:01 2003
From: tbrethou at cs.uiuc.edu (Tanya Brethour)
Date: Tue Aug 26 21:46:01 2003
Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/SchedGraphCommon.h
Message-ID: <200308270245.VAA07855@tank.cs.uiuc.edu>
Changes in directory llvm/include/llvm/CodeGen:
SchedGraphCommon.h updated: 1.1 -> 1.2
---
Log message:
Cleaned up the code (spacing, not needed headers) and changed ostream function. Also made some functions inline.
---
Diffs of the changes:
Index: llvm/include/llvm/CodeGen/SchedGraphCommon.h
diff -u llvm/include/llvm/CodeGen/SchedGraphCommon.h:1.1 llvm/include/llvm/CodeGen/SchedGraphCommon.h:1.2
--- llvm/include/llvm/CodeGen/SchedGraphCommon.h:1.1 Mon Aug 25 18:12:23 2003
+++ llvm/include/llvm/CodeGen/SchedGraphCommon.h Tue Aug 26 21:45:08 2003
@@ -8,11 +8,8 @@
#ifndef LLVM_CODEGEN_SCHEDGRAPHCOMMON_H
#define LLVM_CODEGEN_SCHEDGRAPHCOMMON_H
-#include
-#include
#include "llvm/Value.h"
-
class SchedGraphEdge;
class SchedGraphNode;
@@ -24,8 +21,8 @@
const ResourceId MachineIntRegsRID = -3; // use +ve numbers for actual regs
const ResourceId MachineFPRegsRID = -4; // use +ve numbers for actual regs
-//*********************** Public Class Declarations ************************/
+//*********************** Public Class Declarations ************************/
class SchedGraphNodeCommon {
protected:
unsigned ID;
@@ -33,59 +30,67 @@
std::vector outEdges;
int latency;
- friend std::ostream& operator<<(std::ostream& os, const SchedGraphNode& node);
-
public:
- typedef std::vector:: iterator iterator;
- typedef std::vector::const_iterator const_iterator;
- typedef std::vector:: reverse_iterator reverse_iterator;
+ typedef std::vector::iterator iterator;
+ typedef std::vector::const_iterator const_iterator;
+ typedef std::vector::reverse_iterator reverse_iterator;
typedef std::vector::const_reverse_iterator const_reverse_iterator;
// Accessor methods
- unsigned getNodeId () const { return ID; }
- int getLatency () const { return latency; }
- unsigned getNumInEdges () const { return inEdges.size(); }
- unsigned getNumOutEdges () const { return outEdges.size(); }
+ unsigned getNodeId() const { return ID; }
+ int getLatency() const { return latency; }
+ unsigned getNumInEdges() const { return inEdges.size(); }
+ unsigned getNumOutEdges() const { return outEdges.size(); }
// Iterators
- iterator beginInEdges () { return inEdges.begin(); }
- iterator endInEdges () { return inEdges.end(); }
- iterator beginOutEdges () { return outEdges.begin(); }
- iterator endOutEdges () { return outEdges.end(); }
-
- const_iterator beginInEdges () const { return inEdges.begin(); }
- const_iterator endInEdges () const { return inEdges.end(); }
- const_iterator beginOutEdges () const { return outEdges.begin(); }
- const_iterator endOutEdges () const { return outEdges.end(); }
+ iterator beginInEdges() { return inEdges.begin(); }
+ iterator endInEdges() { return inEdges.end(); }
+ iterator beginOutEdges() { return outEdges.begin(); }
+ iterator endOutEdges() { return outEdges.end(); }
+
+ const_iterator beginInEdges() const { return inEdges.begin(); }
+ const_iterator endInEdges() const { return inEdges.end(); }
+ const_iterator beginOutEdges() const { return outEdges.begin(); }
+ const_iterator endOutEdges() const { return outEdges.end(); }
+ void dump(int indent=0) const;
// Debugging support
- friend std::ostream& operator<<(std::ostream& os, const SchedGraphNodeCommon& node);
-
- void dump (int indent=0) const;
-
+ virtual void print(std::ostream &os) const = 0;
+
protected:
friend class SchedGraph;
friend class SchedGraphCommon;
friend class SchedGraphEdge; // give access for adding edges
- //friend class ModuloSchedGraph;
- void addInEdge (SchedGraphEdge* edge);
- void addOutEdge (SchedGraphEdge* edge);
- void removeInEdge (const SchedGraphEdge* edge);
- void removeOutEdge (const SchedGraphEdge* edge);
-
// disable default constructor and provide a ctor for single-block graphs
SchedGraphNodeCommon(); // DO NOT IMPLEMENT
- SchedGraphNodeCommon(unsigned Id);
-
+ inline SchedGraphNodeCommon(unsigned Id) : ID(Id), latency(0) {}
virtual ~SchedGraphNodeCommon();
+
+ //Functions to add and remove edges
+ inline void addInEdge(SchedGraphEdge* edge) { inEdges.push_back(edge); }
+ inline void addOutEdge(SchedGraphEdge* edge) { outEdges.push_back(edge); }
+ void removeInEdge(const SchedGraphEdge* edge);
+ void removeOutEdge(const SchedGraphEdge* edge);
};
+// ostream << operator for SchedGraphNode class
+inline std::ostream &operator<<(std::ostream &os,
+ const SchedGraphNodeCommon &node) {
+ node.print(os);
+ return os;
+}
+
+
+
+//
+// SchedGraphEdge - Edge class to represent dependencies
+//
class SchedGraphEdge {
public:
enum SchedGraphEdgeDepType {
@@ -99,117 +104,107 @@
SchedGraphNodeCommon* src;
SchedGraphNodeCommon* sink;
SchedGraphEdgeDepType depType;
- unsigned int depOrderType;
- int minDelay; // cached latency (assumes fixed target arch)
- int iteDiff;
+ unsigned int depOrderType;
+ int minDelay; // cached latency (assumes fixed target arch)
+ int iteDiff;
union {
const Value* val;
int machineRegNum;
ResourceId resourceId;
};
-
+
public:
// For all constructors, if minDelay is unspecified, minDelay is
// set to _src->getLatency().
+
// constructor for CtrlDep or MemoryDep edges, selected by 3rd argument
- /*ctor*/ SchedGraphEdge(SchedGraphNodeCommon* _src,
- SchedGraphNodeCommon* _sink,
- SchedGraphEdgeDepType _depType,
- unsigned int _depOrderType,
- int _minDelay = -1);
+ SchedGraphEdge(SchedGraphNodeCommon* _src, SchedGraphNodeCommon* _sink,
+ SchedGraphEdgeDepType _depType, unsigned int _depOrderType,
+ int _minDelay = -1);
// constructor for explicit value dependence (may be true/anti/output)
- /*ctor*/ SchedGraphEdge(SchedGraphNodeCommon* _src,
- SchedGraphNodeCommon* _sink,
- const Value* _val,
- unsigned int _depOrderType,
- int _minDelay = -1);
+ SchedGraphEdge(SchedGraphNodeCommon* _src, SchedGraphNodeCommon* _sink,
+ const Value* _val, unsigned int _depOrderType,
+ int _minDelay = -1);
// constructor for machine register dependence
- /*ctor*/ SchedGraphEdge(SchedGraphNodeCommon* _src,
- SchedGraphNodeCommon* _sink,
- unsigned int _regNum,
- unsigned int _depOrderType,
- int _minDelay = -1);
+ SchedGraphEdge(SchedGraphNodeCommon* _src,SchedGraphNodeCommon* _sink,
+ unsigned int _regNum, unsigned int _depOrderType,
+ int _minDelay = -1);
// constructor for any other machine resource dependences.
// DataDepOrderType is always NonDataDep. It it not an argument to
// avoid overloading ambiguity with previous constructor.
- /*ctor*/ SchedGraphEdge(SchedGraphNodeCommon* _src,
- SchedGraphNodeCommon* _sink,
- ResourceId _resourceId,
- int _minDelay = -1);
-
- /*dtor*/ ~SchedGraphEdge();
-
- SchedGraphNodeCommon* getSrc () const { return src; }
- SchedGraphNodeCommon* getSink () const { return sink; }
- int getMinDelay () const { return minDelay; }
- SchedGraphEdgeDepType getDepType () const { return depType; }
+ SchedGraphEdge(SchedGraphNodeCommon* _src, SchedGraphNodeCommon* _sink,
+ ResourceId _resourceId, int _minDelay = -1);
- const Value* getValue () const {
+ ~SchedGraphEdge();
+
+ SchedGraphNodeCommon* getSrc() const { return src; }
+ SchedGraphNodeCommon* getSink() const { return sink; }
+ int getMinDelay() const { return minDelay; }
+ SchedGraphEdgeDepType getDepType() const { return depType; }
+
+ const Value* getValue() const {
assert(depType == ValueDep); return val;
}
- int getMachineReg () const {
+
+ int getMachineReg() const {
assert(depType == MachineRegister); return machineRegNum;
}
- int getResourceId () const {
+
+ int getResourceId() const {
assert(depType == MachineResource); return resourceId;
}
- void setIteDiff (int _iteDiff) {
+
+ void setIteDiff(int _iteDiff) {
iteDiff = _iteDiff;
}
- int getIteDiff (){
+
+ int getIteDiff() {
return iteDiff;
}
public:
- //
// Debugging support
- //
- friend std::ostream& operator<<(std::ostream& os, const SchedGraphEdge& edge);
-
- void dump (int indent=0) const;
+ void print(std::ostream &os) const;
+ void dump(int indent=0) const;
private:
// disable default ctor
- /*ctor*/ SchedGraphEdge(); // DO NOT IMPLEMENT
+ SchedGraphEdge(); // DO NOT IMPLEMENT
};
+// ostream << operator for SchedGraphNode class
+inline std::ostream &operator<<(std::ostream &os, const SchedGraphEdge &edge) {
+ edge.print(os);
+ return os;
+}
class SchedGraphCommon {
protected:
- SchedGraphNodeCommon* graphRoot; // the root and leaf are not inserted
- SchedGraphNodeCommon* graphLeaf; // in the hash_map (see getNumNodes())
+ SchedGraphNodeCommon* graphRoot; // the root and leaf are not inserted
+ SchedGraphNodeCommon* graphLeaf; // in the hash_map (see getNumNodes())
public:
//
// Accessor methods
//
- SchedGraphNodeCommon* getRoot() const { return graphRoot; }
- SchedGraphNodeCommon* getLeaf() const { return graphLeaf; }
+ SchedGraphNodeCommon* getRoot() const { return graphRoot; }
+ SchedGraphNodeCommon* getLeaf() const { return graphLeaf; }
//
// Delete nodes or edges from the graph.
//
- void eraseNode (SchedGraphNodeCommon* node);
-
- void eraseIncomingEdges (SchedGraphNodeCommon* node,
- bool addDummyEdges = true);
-
- void eraseOutgoingEdges (SchedGraphNodeCommon* node,
- bool addDummyEdges = true);
-
- void eraseIncidentEdges (SchedGraphNodeCommon* node,
- bool addDummyEdges = true);
+ void eraseNode(SchedGraphNodeCommon* node);
+ void eraseIncomingEdges(SchedGraphNodeCommon* node, bool addDummyEdges = true);
+ void eraseOutgoingEdges(SchedGraphNodeCommon* node, bool addDummyEdges = true);
+ void eraseIncidentEdges(SchedGraphNodeCommon* node, bool addDummyEdges = true);
- /*ctor*/ SchedGraphCommon ();
- /*dtor*/ ~SchedGraphCommon ();
-
+ SchedGraphCommon();
+ ~SchedGraphCommon();
};
-
-
#endif
From lattner at cs.uiuc.edu Tue Aug 26 23:51:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Tue Aug 26 23:51:01 2003
Subject: [llvm-commits] CVS: llvm/runtime/GCCLibraries/libexception/c++-exception.h
Message-ID: <200308270450.XAA12324@apoc.cs.uiuc.edu>
Changes in directory llvm/runtime/GCCLibraries/libexception:
c++-exception.h updated: 1.2 -> 1.3
---
Log message:
C++ify, add new get_cxx_exception function to convert from generic llvm_exceptions to llvm_cxx_exception's
---
Diffs of the changes:
Index: llvm/runtime/GCCLibraries/libexception/c++-exception.h
diff -u llvm/runtime/GCCLibraries/libexception/c++-exception.h:1.2 llvm/runtime/GCCLibraries/libexception/c++-exception.h:1.3
--- llvm/runtime/GCCLibraries/libexception/c++-exception.h:1.2 Tue Aug 26 18:46:53 2003
+++ llvm/runtime/GCCLibraries/libexception/c++-exception.h Tue Aug 26 23:50:45 2003
@@ -10,8 +10,9 @@
#include "exception.h"
#include
+#include
-typedef struct llvm_cxx_exception {
+struct llvm_cxx_exception {
/* TypeInfo - A pointer to the C++ std::type_info object for this exception
* class. This is required because the class may not be polymorphic.
*/
@@ -42,9 +43,12 @@
* this structure without breaking binary compatibility.
*/
llvm_exception BaseException;
-} llvm_cxx_exception;
-
+};
+inline llvm_cxx_exception *get_cxx_exception(llvm_exception *E) {
+ assert(E->ExceptionType == CXXException && "Not a C++ exception?");
+ return (llvm_cxx_exception*)(E+1)-1;
+}
extern "C" {
void *__llvm_cxxeh_allocate_exception(unsigned NumBytes);
From lattner at cs.uiuc.edu Tue Aug 26 23:51:03 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Tue Aug 26 23:51:03 2003
Subject: [llvm-commits] CVS: llvm/runtime/GCCLibraries/libexception/exception.h
Message-ID: <200308270450.XAA12312@apoc.cs.uiuc.edu>
Changes in directory llvm/runtime/GCCLibraries/libexception:
exception.h updated: 1.1 -> 1.2
---
Log message:
Remove Cisms. We love C++
---
Diffs of the changes:
Index: llvm/runtime/GCCLibraries/libexception/exception.h
diff -u llvm/runtime/GCCLibraries/libexception/exception.h:1.1 llvm/runtime/GCCLibraries/libexception/exception.h:1.2
--- llvm/runtime/GCCLibraries/libexception/exception.h:1.1 Mon Aug 25 17:35:36 2003
+++ llvm/runtime/GCCLibraries/libexception/exception.h Tue Aug 26 23:50:12 2003
@@ -8,12 +8,12 @@
#ifndef EXCEPTION_H
#define EXCEPTION_H
-typedef struct llvm_exception {
+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)(struct llvm_exception *);
+ void (*ExceptionDestructor)(llvm_exception *);
// ExceptionType - This field identifies what runtime library this exception
// came from. Currently defined values are:
@@ -24,14 +24,14 @@
unsigned ExceptionType;
// Next - This points to the next exception in the current stack.
- struct llvm_exception *Next;
+ 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;
-} llvm_exception;
+};
enum {
ErrorException = 0,
From lattner at cs.uiuc.edu Tue Aug 26 23:52:00 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Tue Aug 26 23:52:00 2003
Subject: [llvm-commits] CVS: llvm/runtime/GCCLibraries/libexception/c++-exception.cpp
Message-ID: <200308270451.XAA12336@apoc.cs.uiuc.edu>
Changes in directory llvm/runtime/GCCLibraries/libexception:
c++-exception.cpp updated: 1.2 -> 1.3
---
Log message:
Fix several _killer_ bugs. This now actually WORKS for really complex testcases :)
---
Diffs of the changes:
Index: llvm/runtime/GCCLibraries/libexception/c++-exception.cpp
diff -u llvm/runtime/GCCLibraries/libexception/c++-exception.cpp:1.2 llvm/runtime/GCCLibraries/libexception/c++-exception.cpp:1.3
--- llvm/runtime/GCCLibraries/libexception/c++-exception.cpp:1.2 Tue Aug 26 18:46:53 2003
+++ llvm/runtime/GCCLibraries/libexception/c++-exception.cpp Tue Aug 26 23:51:26 2003
@@ -9,7 +9,6 @@
#include "c++-exception.h"
#include
-#include
//===----------------------------------------------------------------------===//
// Generic exception support
@@ -75,8 +74,7 @@
// exception.
//
static void cxx_destructor(llvm_exception *LE) {
- void *ObjectPtr = LE+1;
- llvm_cxx_exception *E = (llvm_cxx_exception *)ObjectPtr - 1;
+ llvm_cxx_exception *E = get_cxx_exception(LE);
// The exception is no longer caught.
assert(CaughtExceptionStack == LE &&
@@ -132,7 +130,7 @@
// to see if TypeID matches and, if so, to adjust the exception object
// pointer.
//
- llvm_cxx_exception *E = (llvm_cxx_exception*)UncaughtExceptionStack;
+ llvm_cxx_exception *E = get_cxx_exception(UncaughtExceptionStack);
// ThrownPtr is a pointer to the object being thrown...
void *ThrownPtr = E+1;
@@ -170,7 +168,7 @@
// The exception is now caught.
E->Next = CaughtExceptionStack;
- CaughtExceptionStack = E->Next;
+ CaughtExceptionStack = E;
// Increment the handler count for this exception.
E->HandlerCount++;
@@ -204,10 +202,8 @@
assert(E && "There are no caught exceptions!");
// If this is the last handler using the exception, destroy it now!
- if (--E->HandlerCount == 0) {
- CaughtExceptionStack = E->Next; // Unlink from the stack
+ if (--E->HandlerCount == 0)
E->ExceptionDestructor(E); // Release memory for the exception
- }
}
// __llvm_cxxeh_rethrow - This function turns the top-level caught exception
@@ -229,9 +225,6 @@
CaughtExceptionStack = E->Next;
E->Next = UncaughtExceptionStack;
UncaughtExceptionStack = E;
-
- // Decrement the number of handlers which are using the exception.
- --E->HandlerCount;
// Return to the caller, which should perform the unwind now.
}
From lattner at cs.uiuc.edu Tue Aug 26 23:58:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Tue Aug 26 23:58:01 2003
Subject: [llvm-commits] CVS: llvm/test/Regression/C++Frontend/EH/simple_throw.cpp throw_rethrow_test.cpp
Message-ID: <200308270457.XAA12454@apoc.cs.uiuc.edu>
Changes in directory llvm/test/Regression/C++Frontend/EH:
simple_throw.cpp added (r1.1)
throw_rethrow_test.cpp added (r1.1)
---
Log message:
New testcases, which WORK with LLVMG++ and the CBE.
---
Diffs of the changes:
Index: llvm/test/Regression/C++Frontend/EH/simple_throw.cpp
diff -c /dev/null llvm/test/Regression/C++Frontend/EH/simple_throw.cpp:1.1
*** /dev/null Tue Aug 26 23:57:43 2003
--- llvm/test/Regression/C++Frontend/EH/simple_throw.cpp Tue Aug 26 23:57:33 2003
***************
*** 0 ****
--- 1,13 ----
+ // Test throwing a constant int
+ #include
+
+ static void foo() { throw 5; }
+ int main() {
+ try {
+ foo();
+ } catch (...) {
+ printf("All ok\n");
+ return 0;
+ }
+ return 1;
+ }
Index: llvm/test/Regression/C++Frontend/EH/throw_rethrow_test.cpp
diff -c /dev/null llvm/test/Regression/C++Frontend/EH/throw_rethrow_test.cpp:1.1
*** /dev/null Tue Aug 26 23:57:43 2003
--- llvm/test/Regression/C++Frontend/EH/throw_rethrow_test.cpp Tue Aug 26 23:57:33 2003
***************
*** 0 ****
--- 1,40 ----
+ // This tests hard situations for throwing, including the case where an
+ // exception is active in more than one handler at a time (ie, it needs
+ // refcounting)
+ #include
+
+ struct foo {
+ int i;
+ foo() : i(1) { }
+ foo(const foo&) : i(2) {}
+ };
+
+ int callee(unsigned i) {
+ if (i < 3) throw (int)i;
+ if (i < 6) throw 1.0;
+ if (i < 9) throw foo();
+ return 0;
+ }
+
+ void rethrow() {
+ throw;
+ }
+
+ int main() {
+ for (unsigned i = 0; i < 10; ++i) {
+ try {
+ return callee(i);
+ } catch (foo &F) {
+ try {
+ rethrow();
+ } catch (foo &F) {
+ std::printf("%d: 3\n", i);
+ }
+ } catch (int) {
+ std::printf("%d: 1\n", i);
+ } catch (...) {
+ std::printf("%d: 2\n", i);
+ }
+ }
+ }
+
From criswell at cs.uiuc.edu Wed Aug 27 08:43:03 2003
From: criswell at cs.uiuc.edu (John Criswell)
Date: Wed Aug 27 08:43:03 2003
Subject: [llvm-commits] CVS: llvm/utils/TableGen/FileLexer.l TableGen.cpp
Message-ID: <200308271342.IAA02595@choi.cs.uiuc.edu>
Changes in directory llvm/utils/TableGen:
FileLexer.l updated: 1.12 -> 1.13
TableGen.cpp updated: 1.19 -> 1.20
---
Log message:
Added an option to TableGen that allows users to specify a directory in which
to find include files. TableGen will load include files from this directory if
it cannot find them in the current directory.
This feature was needed for building code inside the object tree (a la autoconf
style).
TODO: Allow for multiple -I options to specify a list of directories to search.
---
Diffs of the changes:
Index: llvm/utils/TableGen/FileLexer.l
diff -u llvm/utils/TableGen/FileLexer.l:1.12 llvm/utils/TableGen/FileLexer.l:1.13
--- llvm/utils/TableGen/FileLexer.l:1.12 Sun Aug 10 17:04:25 2003
+++ llvm/utils/TableGen/FileLexer.l Wed Aug 27 08:41:57 2003
@@ -21,9 +21,13 @@
%{
#include "Record.h"
+#include "Support/CommandLine.h"
typedef std::pair*> SubClassRefTy;
#include "FileParser.h"
+// Global variable recording the location of the include directory
+std::string IncludeDirectory;
+
// ParseInt - This has to handle the special case of binary numbers 0b0101
static int ParseInt(const char *Str) {
if (Str[0] == '0' && Str[1] == 'b')
@@ -61,7 +65,18 @@
int Fileparse();
-void ParseFile(const std::string &Filename) {
+//
+// Function: ParseFile()
+//
+// Description:
+// This function begins the parsing of the specified tablegen file.
+//
+// Inputs:
+// Filename - A string containing the name of the file to parse.
+// IncludeDir - A string containing the directory from which include
+// files can be found.
+//
+void ParseFile(const std::string &Filename, const std::string & IncludeDir) {
FILE *F = stdin;
if (Filename != "-") {
F = fopen(Filename.c_str(), "r");
@@ -75,6 +90,12 @@
IncludeStack.push_back(IncludeRec("", stdin));
}
+ //
+ // Record the location of the include directory so that the lexer can find
+ // it later.
+ //
+ IncludeDirectory = IncludeDir;
+
Filein = F;
Filelineno = 1;
Fileparse();
@@ -103,8 +124,20 @@
// Open the new input file...
yyin = fopen(Filename.c_str(), "r");
if (yyin == 0) {
- err() << "Could not find include file '" << Filename << "'!\n";
- abort();
+ //
+ // If we couldn't find the file in the current directory, look for it in
+ // the include directories.
+ //
+ // NOTE:
+ // Right now, there is only one directory. We need to eventually add
+ // support for more.
+ //
+ Filename = IncludeDirectory + "/" + Filename;
+ yyin = fopen(Filename.c_str(), "r");
+ if (yyin == 0) {
+ err() << "Could not find include file '" << Filename << "'!\n";
+ abort();
+ }
}
// Add the file to our include stack...
Index: llvm/utils/TableGen/TableGen.cpp
diff -u llvm/utils/TableGen/TableGen.cpp:1.19 llvm/utils/TableGen/TableGen.cpp:1.20
--- llvm/utils/TableGen/TableGen.cpp:1.19 Thu Aug 14 11:05:35 2003
+++ llvm/utils/TableGen/TableGen.cpp Wed Aug 27 08:41:57 2003
@@ -64,10 +64,14 @@
cl::opt
InputFilename(cl::Positional, cl::desc(""), cl::init("-"));
+
+ cl::opt
+ IncludeDir("I", cl::desc("Directory of include files"),
+ cl::value_desc("directory"), cl::init(""));
}
-void ParseFile(const std::string &Filename);
+void ParseFile(const std::string &Filename, const std::string & IncludeDir);
RecordKeeper Records;
@@ -398,7 +402,7 @@
int main(int argc, char **argv) {
cl::ParseCommandLineOptions(argc, argv);
- ParseFile(InputFilename);
+ ParseFile(InputFilename, IncludeDir);
std::ostream *Out = &std::cout;
if (OutputFilename != "-") {
From tbrethou at cs.uiuc.edu Wed Aug 27 10:13:01 2003
From: tbrethou at cs.uiuc.edu (Tanya Brethour)
Date: Wed Aug 27 10:13:01 2003
Subject: [llvm-commits] CVS: llvm/lib/CodeGen/InstrSched/SchedGraph.h
Message-ID: <200308271512.KAA13991@tank.cs.uiuc.edu>
Changes in directory llvm/lib/CodeGen/InstrSched:
SchedGraph.h updated: 1.32 -> 1.33
---
Log message:
Added/removed header file
---
Diffs of the changes:
Index: llvm/lib/CodeGen/InstrSched/SchedGraph.h
diff -u llvm/lib/CodeGen/InstrSched/SchedGraph.h:1.32 llvm/lib/CodeGen/InstrSched/SchedGraph.h:1.33
--- llvm/lib/CodeGen/InstrSched/SchedGraph.h:1.32 Tue Aug 26 21:42:58 2003
+++ llvm/lib/CodeGen/InstrSched/SchedGraph.h Wed Aug 27 10:12:24 2003
@@ -20,7 +20,6 @@
#include "Support/hash_map"
#include "Support/GraphTraits.h"
-
class RegToRefVecMap;
class ValueToDefVecMap;
class RefVec;
From tbrethou at niobe.cs.uiuc.edu Wed Aug 27 10:53:02 2003
From: tbrethou at niobe.cs.uiuc.edu (Tanya Brethour)
Date: Wed Aug 27 10:53:02 2003
Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/SchedGraphCommon.h
Message-ID: <200308271552.h7RFqYu19666@niobe.cs.uiuc.edu>
Changes in directory llvm/include/llvm/CodeGen:
SchedGraphCommon.h updated: 1.2 -> 1.3
---
Log message:
(null)
---
Diffs of the changes:
Index: llvm/include/llvm/CodeGen/SchedGraphCommon.h
diff -u llvm/include/llvm/CodeGen/SchedGraphCommon.h:1.2 llvm/include/llvm/CodeGen/SchedGraphCommon.h:1.3
--- llvm/include/llvm/CodeGen/SchedGraphCommon.h:1.2 Tue Aug 26 21:45:08 2003
+++ llvm/include/llvm/CodeGen/SchedGraphCommon.h Wed Aug 27 10:52:23 2003
@@ -139,7 +139,7 @@
SchedGraphEdge(SchedGraphNodeCommon* _src, SchedGraphNodeCommon* _sink,
ResourceId _resourceId, int _minDelay = -1);
- ~SchedGraphEdge();
+ ~SchedGraphEdge() {}
SchedGraphNodeCommon* getSrc() const { return src; }
SchedGraphNodeCommon* getSink() const { return sink; }
@@ -203,7 +203,7 @@
void eraseOutgoingEdges(SchedGraphNodeCommon* node, bool addDummyEdges = true);
void eraseIncidentEdges(SchedGraphNodeCommon* node, bool addDummyEdges = true);
- SchedGraphCommon();
+ SchedGraphCommon() {}
~SchedGraphCommon();
};
From lattner at cs.uiuc.edu Wed Aug 27 13:21:03 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Aug 27 13:21:03 2003
Subject: [llvm-commits] CVS: llvm/test/Regression/C++Frontend/EH/copy_ctor_throw.cpp
Message-ID: <200308271820.NAA19957@apoc.cs.uiuc.edu>
Changes in directory llvm/test/Regression/C++Frontend/EH:
copy_ctor_throw.cpp added (r1.1)
---
Log message:
New testcase. Unfortunately, native GCC gets this wrong. Someday we will have to figure out how to deal with this.
---
Diffs of the changes:
Index: llvm/test/Regression/C++Frontend/EH/copy_ctor_throw.cpp
diff -c /dev/null llvm/test/Regression/C++Frontend/EH/copy_ctor_throw.cpp:1.1
*** /dev/null Wed Aug 27 13:20:03 2003
--- llvm/test/Regression/C++Frontend/EH/copy_ctor_throw.cpp Wed Aug 27 13:19:53 2003
***************
*** 0 ****
--- 1,25 ----
+ /* Test for throwing an exception from the copy ctor of the exception object
+ * invoked while building an exception.
+ */
+ #include
+
+ struct foo {
+ foo() {}
+ foo(const foo &F) { throw 1; }
+ };
+
+ int main() {
+ try {
+ foo f;
+ throw f;
+ } catch (int i) {
+ printf("Success!\n");
+ return 0;
+ } catch (foo &f) {
+ printf("Failure: caught a foo!\n");
+ return 1;
+ } catch (...) {
+ printf("Failure: caught something else!\n");
+ return 1;
+ }
+ }
From lattner at cs.uiuc.edu Wed Aug 27 13:27:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Aug 27 13:27:01 2003
Subject: [llvm-commits] CVS: llvm/Makefile.common
Message-ID: <200308271826.NAA16751@neo.cs.uiuc.edu>
Changes in directory llvm:
Makefile.common updated: 1.128 -> 1.129
---
Log message:
Refactor code slightly. Make code compiled with llvmgcc use the warning options
as well. Compile with -fshort-enums whether in debug or release mode, because it breaks the ABI
---
Diffs of the changes:
Index: llvm/Makefile.common
diff -u llvm/Makefile.common:1.128 llvm/Makefile.common:1.129
--- llvm/Makefile.common:1.128 Sat Aug 23 10:56:38 2003
+++ llvm/Makefile.common Wed Aug 27 13:26:44 2003
@@ -354,8 +354,9 @@
# Allow gnu extensions...
CPPFLAGS += -D_GNU_SOURCE
-CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused -I$(LEVEL)/include
-CompileOptimizeOpts := -O3 -DNDEBUG -finline-functions -fshort-enums
+CompileWarnings := -Wall -W -Wwrite-strings -Wno-unused
+CompileCommonOpts := $(CompileWarnings) -I$(LEVEL)/include -fshort-enums
+CompileOptimizeOpts := -O3 -DNDEBUG -finline-functions
#
# Compile commands with libtool.
@@ -739,11 +740,11 @@
$(BUILD_OBJ_DIR)/Bytecode/%.bc: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Bytecode/.dir $(LCC1XX)
@echo "Compiling $< to bytecode"
- $(VERB) $(LLVMGXX) $(CPPFLAGS) -c $< -o $@
+ $(VERB) $(LLVMGXX) $(CompileWarnings) $(CPPFLAGS) -c $< -o $@
$(BUILD_OBJ_DIR)/Bytecode/%.bc: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Bytecode/.dir $(LCC1)
@echo "Compiling $< to bytecode"
- $(VERB) $(LLVMGCC) $(CPPFLAGS) -c $< -o $@
+ $(VERB) $(LLVMGCC) $(CompileWarnings) $(CPPFLAGS) -c $< -o $@
$(BUILD_OBJ_DIR)/Bytecode/%.bc: $(SourceDir)%.ll $(BUILD_OBJ_DIR)/Bytecode/.dir $(LLVMAS)
@echo "Compiling $< to bytecode"
From brukman at cs.uiuc.edu Wed Aug 27 13:27:04 2003
From: brukman at cs.uiuc.edu (Misha Brukman)
Date: Wed Aug 27 13:27:04 2003
Subject: [llvm-commits] CVS: llvm/include/Support/Casting.h
Message-ID: <200308271826.NAA19341@zion.cs.uiuc.edu>
Changes in directory llvm/include/Support:
Casting.h updated: 1.6 -> 1.7
---
Log message:
Spell `incompatible' correctly.
---
Diffs of the changes:
Index: llvm/include/Support/Casting.h
diff -u llvm/include/Support/Casting.h:1.6 llvm/include/Support/Casting.h:1.7
--- llvm/include/Support/Casting.h:1.6 Mon Jun 30 16:58:23 2003
+++ llvm/include/Support/Casting.h Wed Aug 27 13:26:28 2003
@@ -184,7 +184,7 @@
//
template
inline typename cast_retty::ret_type cast(const Y &Val) {
- assert(isa(Val) && "cast() argument of uncompatible type!");
+ assert(isa(Val) && "cast() argument of incompatible type!");
return cast_convert_val::SimpleType>::doit(Val);
}
@@ -195,7 +195,7 @@
template
inline typename cast_retty::ret_type cast_or_null(Y *Val) {
if (Val == 0) return 0;
- assert(isa(Val) && "cast_or_null() argument of uncompatible type!");
+ assert(isa(Val) && "cast_or_null() argument of incompatible type!");
return cast(Val);
}
From lattner at cs.uiuc.edu Wed Aug 27 14:07:11 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Aug 27 14:07:11 2003
Subject: [llvm-commits] CVS: llvm/test/Regression/C++Frontend/EH/copy_ctor_throw.cpp
Message-ID: <200308271906.OAA22167@apoc.cs.uiuc.edu>
Changes in directory llvm/test/Regression/C++Frontend/EH:
copy_ctor_throw.cpp (r1.1) removed
---
Log message:
Move the testcase elsewhere
---
Diffs of the changes:
From gaeke at cs.uiuc.edu Wed Aug 27 15:42:03 2003
From: gaeke at cs.uiuc.edu (Brian Gaeke)
Date: Wed Aug 27 15:42:03 2003
Subject: [llvm-commits] CVS: reopt/test/TEST.reopt.Makefile
Message-ID: <200308272041.PAA11312@trinity.cs.uiuc.edu>
Changes in directory reopt/test:
TEST.reopt.Makefile updated: 1.3 -> 1.4
---
Log message:
Don't need to link in libanalysis.a.
Turn on -disable-strip to help with debugging.
Print out the name of the output file, so it's easier to `less' it afterwards.
---
Diffs of the changes:
Index: reopt/test/TEST.reopt.Makefile
diff -u reopt/test/TEST.reopt.Makefile:1.3 reopt/test/TEST.reopt.Makefile:1.4
--- reopt/test/TEST.reopt.Makefile:1.3 Fri Aug 22 13:33:38 2003
+++ reopt/test/TEST.reopt.Makefile Wed Aug 27 15:40:56 2003
@@ -23,8 +23,7 @@
# Libraries that contain common LLVM code the Reoptimizer depends on
REOPTIMIZER_LLVM_SUPPORT_LIBS = $(DESTLIBCURRENT)/libscalaropts.a \
$(DESTLIBCURRENT)/libtransformutils.a $(DESTLIBCURRENT)/vmcore.o \
- $(DESTLIBCURRENT)/libsupport.a $(DESTLIBCURRENT)/bcreader.o \
- $(DESTLIBCURRENT)/libanalysis.a
+ $(DESTLIBCURRENT)/libsupport.a $(DESTLIBCURRENT)/bcreader.o
# Solaris libraries that the Reoptimizer depends on
REOPTIMIZER_SOLARIS_SUPPORT_LIBS = -lcpc -lm -lrt -lmalloc
@@ -52,7 +51,7 @@
Output/%.reopt-llc.s: Output/%.llvm.bc
@echo "========================================="
@echo "Compiling Reoptimizer version of '$(TESTNAME)'"
- -$(LOPT) -q -inline -lowerswitch -branch-combine -emitfuncs -instloops $< | $(LLC) $(LLCFLAGS) -disable-sched -f -enable-maps -o $@
+ -$(LOPT) -q -inline -lowerswitch -branch-combine -emitfuncs -instloops $< | $(LLC) $(LLCFLAGS) -disable-sched -disable-strip -f -enable-maps -o $@
# 2. Link the instrumented binary with the necessary parts of the
# compiler.
@@ -65,4 +64,5 @@
Output/%.out-reopt-llc: Output/%.reopt-llc
@echo "Running Reoptimizer version of '$(TESTNAME)'"
-$(RUNSAFELY) $(STDIN_FILENAME) $@ $< $(RUN_OPTIONS)
+ @echo "Output in" `pwd`/$@
From lattner at cs.uiuc.edu Wed Aug 27 17:19:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Aug 27 17:19:01 2003
Subject: [llvm-commits] CVS: llvm/runtime/GCCLibraries/Makefile
Message-ID: <200308272218.RAA18405@neo.cs.uiuc.edu>
Changes in directory llvm/runtime/GCCLibraries:
Makefile updated: 1.1 -> 1.2
---
Log message:
Hack out libexception temporarily until the Sparc FE is improved
---
Diffs of the changes:
Index: llvm/runtime/GCCLibraries/Makefile
diff -u llvm/runtime/GCCLibraries/Makefile:1.1 llvm/runtime/GCCLibraries/Makefile:1.2
--- llvm/runtime/GCCLibraries/Makefile:1.1 Thu Aug 14 21:33:49 2003
+++ llvm/runtime/GCCLibraries/Makefile Wed Aug 27 17:18:23 2003
@@ -2,6 +2,7 @@
LEVEL = ../..
PARALLEL_DIRS := $(sort $(filter-out Output/, $(filter-out CVS/, $(wildcard */))))
+PARALLEL_DIRS := $(filter-out libexception/, $(PARALLEL_DIRS))
include $(LEVEL)/Makefile.common
From lattner at cs.uiuc.edu Wed Aug 27 18:00:02 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Aug 27 18:00:02 2003
Subject: [llvm-commits] CVS: llvm/runtime/GCCLibraries/libexception/exception.h
Message-ID: <200308272259.RAA13610@apoc.cs.uiuc.edu>
Changes in directory llvm/runtime/GCCLibraries/libexception:
exception.h updated: 1.2 -> 1.3
---
Log message:
Add throw specs to the functions, remove (void) from the functions
---
Diffs of the changes:
Index: llvm/runtime/GCCLibraries/libexception/exception.h
diff -u llvm/runtime/GCCLibraries/libexception/exception.h:1.2 llvm/runtime/GCCLibraries/libexception/exception.h:1.3
--- llvm/runtime/GCCLibraries/libexception/exception.h:1.2 Tue Aug 26 23:50:12 2003
+++ llvm/runtime/GCCLibraries/libexception/exception.h Wed Aug 27 17:58:51 2003
@@ -42,8 +42,8 @@
// Language independent exception handling API...
//
extern "C" {
- bool __llvm_eh_has_uncaught_exception(void);
- void *__llvm_eh_current_uncaught_exception_type(unsigned HandlerType);
+ bool __llvm_eh_has_uncaught_exception() throw();
+ void *__llvm_eh_current_uncaught_exception_type(unsigned HandlerType) throw();
}
#endif
From lattner at cs.uiuc.edu Wed Aug 27 18:01:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Aug 27 18:01:01 2003
Subject: [llvm-commits] CVS: llvm/runtime/GCCLibraries/libexception/c++-exception.h
Message-ID: <200308272300.SAA13654@apoc.cs.uiuc.edu>
Changes in directory llvm/runtime/GCCLibraries/libexception:
c++-exception.h updated: 1.3 -> 1.4
---
Log message:
Be more type-safe, add throw specs to all functions
---
Diffs of the changes:
Index: llvm/runtime/GCCLibraries/libexception/c++-exception.h
diff -u llvm/runtime/GCCLibraries/libexception/c++-exception.h:1.3 llvm/runtime/GCCLibraries/libexception/c++-exception.h:1.4
--- llvm/runtime/GCCLibraries/libexception/c++-exception.h:1.3 Tue Aug 26 23:50:45 2003
+++ llvm/runtime/GCCLibraries/libexception/c++-exception.h Wed Aug 27 17:59:15 2003
@@ -29,14 +29,14 @@
* unexpected which are a result of an exception throw are supposed to use the
* value of the handler at the time of the throw, not the currently set value.
*/
- void *UnexpectedHandler;
+ void (*UnexpectedHandler)();
/* TerminateHandler - This contains a pointer to the "terminate" handler which
* may be registered by the user program with set_terminate. Calls to
* unexpected which are a result of an exception throw are supposed to use the
* value of the handler at the time of the throw, not the currently set value.
*/
- void *TerminateHandler;
+ void (*TerminateHandler)();
/* 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
@@ -45,23 +45,37 @@
llvm_exception BaseException;
};
-inline llvm_cxx_exception *get_cxx_exception(llvm_exception *E) {
+inline llvm_cxx_exception *get_cxx_exception(llvm_exception *E) throw() {
assert(E->ExceptionType == CXXException && "Not a C++ exception?");
return (llvm_cxx_exception*)(E+1)-1;
}
-extern "C" {
- void *__llvm_cxxeh_allocate_exception(unsigned NumBytes);
- void __llvm_cxxeh_free_exception(void *ObjectPtr);
- void __llvm_cxxeh_throw(void *ObjectPtr, const std::type_info *TypeInfoPtr,
- void (*DtorPtr)(void*));
-
- void * __llvm_cxxeh_current_uncaught_exception_isa(const std::type_info *Ty);
- void *__llvm_cxxeh_begin_catch(void);
- void *__llvm_cxxeh_begin_catch_if_isa(const std::type_info *CatchType);
- void __llvm_cxxeh_end_catch(void);
+// Interface to the C++ standard library to get to the terminate and unexpected
+// handler stuff.
+namespace __cxxabiv1 {
+ // Invokes given handler, dying appropriately if the user handler was
+ // so inconsiderate as to return.
+ extern void __terminate(std::terminate_handler) __attribute__((noreturn));
+ extern void __unexpected(std::unexpected_handler) __attribute__((noreturn));
+
+ // The current installed user handlers.
+ extern std::terminate_handler __terminate_handler;
+ extern std::unexpected_handler __unexpected_handler;
+}
- void __llvm_cxxeh_rethrow(void);
+extern "C" {
+ void *__llvm_cxxeh_allocate_exception(unsigned NumBytes) throw();
+ void __llvm_cxxeh_free_exception(void *ObjectPtr) throw();
+ void __llvm_cxxeh_throw(void *ObjectPtr, void *TypeInfoPtr,
+ void (*DtorPtr)(void*)) throw();
+
+ void * __llvm_cxxeh_current_uncaught_exception_isa(void *Ty)
+ throw();
+ void *__llvm_cxxeh_begin_catch() throw();
+ void *__llvm_cxxeh_begin_catch_if_isa(void *CatchType) throw();
+ void __llvm_cxxeh_end_catch() /* might throw */;
+ void __llvm_cxxeh_rethrow() throw();
+ void __llvm_cxxeh_check_eh_spec(void *Info, ...);
}
#endif
From lattner at cs.uiuc.edu Wed Aug 27 18:01:04 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Wed Aug 27 18:01:04 2003
Subject: [llvm-commits] CVS: llvm/runtime/GCCLibraries/libexception/c++-exception.cpp
Message-ID: <200308272300.SAA13649@apoc.cs.uiuc.edu>
Changes in directory llvm/runtime/GCCLibraries/libexception:
c++-exception.cpp updated: 1.3 -> 1.4
---
Log message:
Be more typesafe
Call terminate and unexpected where appropriate.
Interface to libstdc++ as appropriate
Initial cut at implementing function exception specifications
---
Diffs of the changes:
Index: llvm/runtime/GCCLibraries/libexception/c++-exception.cpp
diff -u llvm/runtime/GCCLibraries/libexception/c++-exception.cpp:1.3 llvm/runtime/GCCLibraries/libexception/c++-exception.cpp:1.4
--- llvm/runtime/GCCLibraries/libexception/c++-exception.cpp:1.3 Tue Aug 26 23:51:26 2003
+++ llvm/runtime/GCCLibraries/libexception/c++-exception.cpp Wed Aug 27 18:00:11 2003
@@ -9,6 +9,7 @@
#include "c++-exception.h"
#include
+#include
//===----------------------------------------------------------------------===//
// Generic exception support
@@ -25,7 +26,7 @@
// __llvm_eh_has_uncaught_exception - This is used to implement
// std::uncaught_exception.
//
-bool __llvm_eh_has_uncaught_exception(void) {
+bool __llvm_eh_has_uncaught_exception() throw() {
return UncaughtExceptionStack != 0;
}
@@ -33,7 +34,7 @@
// 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) {
+void *__llvm_eh_current_uncaught_exception_type(unsigned HandlerType) throw() {
assert(UncaughtExceptionStack && "No uncaught exception!");
if (UncaughtExceptionStack->ExceptionType == HandlerType)
return UncaughtExceptionStack+1;
@@ -44,11 +45,12 @@
//===----------------------------------------------------------------------===//
// C++ Specific exception handling support...
//
+using namespace __cxxabiv1;
// __llvm_cxxeh_allocate_exception - This function allocates space for the
// specified number of bytes, plus a C++ exception object header.
//
-void *__llvm_cxxeh_allocate_exception(unsigned NumBytes) {
+void *__llvm_cxxeh_allocate_exception(unsigned NumBytes) throw() {
// FIXME: This should eventually have back-up buffers for out-of-memory
// situations.
//
@@ -64,7 +66,7 @@
// into the exception location throws. Otherwise it is called from the C++
// exception object destructor.
//
-void __llvm_cxxeh_free_exception(void *ObjectPtr) {
+void __llvm_cxxeh_free_exception(void *ObjectPtr) throw() {
llvm_cxx_exception *E = (llvm_cxx_exception *)ObjectPtr - 1;
free(E);
}
@@ -73,7 +75,7 @@
// exception->ExceptionDestructor function pointer to destroy a caught
// exception.
//
-static void cxx_destructor(llvm_exception *LE) {
+static void cxx_destructor(llvm_exception *LE) /* might throw */{
llvm_cxx_exception *E = get_cxx_exception(LE);
// The exception is no longer caught.
@@ -100,8 +102,8 @@
// evaluated into it, this sets up all of the fields of the exception allowing
// it to be thrown. After calling this, the code should call %llvm.unwind
//
-void __llvm_cxxeh_throw(void *ObjectPtr, const std::type_info *TypeInfoPtr,
- void (*DtorPtr)(void*)) {
+void __llvm_cxxeh_throw(void *ObjectPtr, void *TypeInfoPtr,
+ void (*DtorPtr)(void*)) throw() {
llvm_cxx_exception *E = (llvm_cxx_exception *)ObjectPtr - 1;
E->BaseException.ExceptionDestructor = cxx_destructor;
E->BaseException.ExceptionType = CXXException;
@@ -109,29 +111,17 @@
UncaughtExceptionStack = &E->BaseException;
E->BaseException.HandlerCount = 0;
- E->TypeInfo = TypeInfoPtr;
+ E->TypeInfo = (const std::type_info*)TypeInfoPtr;
E->ExceptionObjectDestructor = DtorPtr;
- E->UnexpectedHandler = 0; // FIXME
- E->TerminateHandler = 0; // FIXME
+ E->UnexpectedHandler = __unexpected_handler;
+ E->TerminateHandler = __terminate_handler;
}
-// __llvm_cxxeh_current_uncaught_exception_isa - This function checks to see if
-// the current uncaught exception is a C++ exception, and if it is of the
-// specified type id. If so, it returns a pointer to the object adjusted as
-// appropriate, otherwise it returns null.
-//
-void *__llvm_cxxeh_current_uncaught_exception_isa(
- const std::type_info *CatchType) {
- assert(UncaughtExceptionStack && "No uncaught exception!");
- if (UncaughtExceptionStack->ExceptionType != CXXException)
- return 0; // If it's not a c++ exception, it doesn't match!
-
- // If it is a C++ exception, use the type info object stored in the exception
- // to see if TypeID matches and, if so, to adjust the exception object
- // pointer.
- //
- llvm_cxx_exception *E = get_cxx_exception(UncaughtExceptionStack);
+// CXXExceptionISA - use the type info object stored in the exception to see if
+// TypeID matches and, if so, to adjust the exception object pointer.
+//
+static void *CXXExceptionISA(llvm_cxx_exception *E, const std::type_info *Type){
// ThrownPtr is a pointer to the object being thrown...
void *ThrownPtr = E+1;
const std::type_info *ThrownType = E->TypeInfo;
@@ -147,19 +137,37 @@
ThrownPtr = *(void **)ThrownPtr;
#endif
- if (CatchType->__do_catch(ThrownType, &ThrownPtr, 1))
+ if (Type->__do_catch(ThrownType, &ThrownPtr, 1))
return ThrownPtr;
return 0;
}
+// __llvm_cxxeh_current_uncaught_exception_isa - This function checks to see if
+// the current uncaught exception is a C++ exception, and if it is of the
+// specified type id. If so, it returns a pointer to the object adjusted as
+// appropriate, otherwise it returns null.
+//
+void *__llvm_cxxeh_current_uncaught_exception_isa(void *CatchType) throw() {
+ assert(UncaughtExceptionStack && "No uncaught exception!");
+ if (UncaughtExceptionStack->ExceptionType != CXXException)
+ return 0; // If it's not a c++ exception, it doesn't match!
+
+ // If it is a C++ exception, use the type info object stored in the exception
+ // to see if TypeID matches and, if so, to adjust the exception object
+ // pointer.
+ //
+ const std::type_info *Info = (const std::type_info *)CatchType;
+ return CXXExceptionISA(get_cxx_exception(UncaughtExceptionStack), Info);
+}
+
// __llvm_cxxeh_begin_catch - This function is called by "exception handlers",
// which transition an exception from being uncaught to being caught. It
// returns a pointer to the exception object portion of the exception. This
// function must work with foreign exceptions.
//
-void *__llvm_cxxeh_begin_catch(void) {
+void *__llvm_cxxeh_begin_catch() throw() {
llvm_exception *E = UncaughtExceptionStack;
assert(UncaughtExceptionStack && "There are no uncaught exceptions!?!?");
@@ -183,7 +191,7 @@
// object of the specified type. This function does never succeeds with foreign
// exceptions (because they can never be of type CatchType).
//
-void *__llvm_cxxeh_begin_catch_if_isa(const std::type_info *CatchType) {
+void *__llvm_cxxeh_begin_catch_if_isa(void *CatchType) throw() {
void *ObjPtr = __llvm_cxxeh_current_uncaught_exception_isa(CatchType);
if (!ObjPtr) return 0;
@@ -197,7 +205,7 @@
// top-level caught exception, destroying it if this is the last handler for the
// exception.
//
-void __llvm_cxxeh_end_catch(void) {
+void __llvm_cxxeh_end_catch() /* might throw */ {
llvm_exception *E = CaughtExceptionStack;
assert(E && "There are no caught exceptions!");
@@ -206,19 +214,19 @@
E->ExceptionDestructor(E); // Release memory for the exception
}
+
// __llvm_cxxeh_rethrow - This function turns the top-level caught exception
// into an uncaught exception, in preparation for an llvm.unwind, which should
// follow immediately after the call to this function. This function must be
// prepared to deal with foreign exceptions.
//
-void __llvm_cxxeh_rethrow(void) {
+void __llvm_cxxeh_rethrow() throw() {
llvm_exception *E = CaughtExceptionStack;
- if (E == 0) {
+ if (E == 0)
// 15.1.8 - If there are no uncaught exceptions being thrown, 'throw;'
// should call terminate.
//
- assert(0 && "FIXME: this should call E->Terminate!"); // FIXME!
- }
+ __terminate(__terminate_handler);
// Otherwise we have an exception to rethrow. Move it back to the uncaught
// stack.
@@ -229,3 +237,115 @@
// Return to the caller, which should perform the unwind now.
}
+static bool ExceptionSpecificationPermitsException(llvm_exception *E,
+ const std::type_info *Info,
+ va_list Args) {
+ // The only way it could match one of the types is if it is a C++ exception.
+ if (E->ExceptionType != CXXException) return false;
+
+ llvm_cxx_exception *Ex = get_cxx_exception(E);
+
+ // Scan the list of accepted types, checking to see if the uncaught
+ // exception is any of them.
+ do {
+ // Check to see if the exception matches one of the types allowed by the
+ // exception specification. If so, return to the caller to have the
+ // exception rethrown.
+ if (CXXExceptionISA(Ex, Info))
+ return true;
+
+ Info = va_arg(Args, std::type_info *);
+ } while (Info);
+ return false;
+}
+
+
+// __llvm_cxxeh_check_eh_spec - If a function with an exception specification is
+// throwing an exception, this function gets called with the list of type_info
+// objects that it is allowing to propagate. Check to see if the current
+// uncaught exception is one of these types, and if so, allow it to be thrown by
+// returning to the caller, which should immediately follow this call with
+// llvm.unwind.
+//
+// Note that this function does not throw any exceptions, but we can't put an
+// exception specification on it or else we'll get infinite loops!
+//
+void __llvm_cxxeh_check_eh_spec(void *Info, ...) {
+ const std::type_info *TypeInfo = (const std::type_info *)Info;
+ llvm_exception *E = UncaughtExceptionStack;
+ assert(E && "No uncaught exceptions!");
+
+ if (TypeInfo == 0) { // Empty exception specification
+ // Whatever exception this is, it is not allowed by the (empty) spec, call
+ // unexpected, according to 15.4.8.
+ try {
+ __llvm_cxxeh_begin_catch(); // Start the catch
+ __llvm_cxxeh_end_catch(); // Free the exception
+ __unexpected(__unexpected_handler);
+ } catch (...) {
+ // Any exception thrown by unexpected cannot match the ehspec. Call
+ // terminate, according to 15.4.9.
+ __terminate(__terminate_handler);
+ }
+ }
+
+ // Check to see if the exception matches one of the types allowed by the
+ // exception specification. If so, return to the caller to have the
+ // exception rethrown.
+
+ va_list Args;
+ va_start(Args, Info);
+ bool Ok = ExceptionSpecificationPermitsException(E, TypeInfo, Args);
+ va_end(Args);
+ if (Ok) return;
+
+ // Ok, now we know that the exception is either not a C++ exception (thus not
+ // permitted to pass through) or not a C++ exception that is allowed. Kill
+ // the exception and call the unexpected handler.
+ try {
+ __llvm_cxxeh_begin_catch(); // Start the catch
+ __llvm_cxxeh_end_catch(); // Free the exception
+ } catch (...) {
+ __terminate(__terminate_handler); // Exception dtor threw
+ }
+
+ try {
+ __unexpected(__unexpected_handler);
+ } catch (...) {
+ // If the unexpected handler threw an exception, we will get here. Since
+ // entering the try block calls ..._begin_catch, we need to "rethrow" the
+ // exception to make it uncaught again. Exiting the catch will then leave
+ // it in the uncaught state.
+ __llvm_cxxeh_rethrow();
+ }
+
+ // Grab the newly caught exception. If this exception is permitted by the
+ // specification, allow it to be thrown.
+ E = UncaughtExceptionStack;
+ assert(E && "No uncaught exceptions!");
+
+ va_start(Args, Info);
+ Ok = ExceptionSpecificationPermitsException(E, TypeInfo, Args);
+ va_end(Args);
+ if (Ok) return;
+
+ // Final case, check to see if we can throw an std::bad_exception.
+ try {
+ throw std::bad_exception();
+ } catch (...) {
+ __llvm_cxxeh_rethrow();
+ }
+
+ // Grab the new bad_exception...
+ E = UncaughtExceptionStack;
+ assert(E && "No uncaught exceptions!");
+
+ // If it's permitted, allow it to be thrown instead.
+ va_start(Args, Info);
+ Ok = ExceptionSpecificationPermitsException(E, TypeInfo, Args);
+ va_end(Args);
+ if (Ok) return;
+
+ // Otherwise, we are out of options, terminate, according to 15.5.2.2.
+ __terminate(__terminate_handler);
+}
From lattner at cs.uiuc.edu Thu Aug 28 09:36:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Thu Aug 28 09:36:01 2003
Subject: [llvm-commits] CVS: llvm/runtime/GCCLibraries/libc/string.c
Message-ID: <200308281435.JAA23909@apoc.cs.uiuc.edu>
Changes in directory llvm/runtime/GCCLibraries/libc:
string.c updated: 1.4 -> 1.5
---
Log message:
Squelch warning
---
Diffs of the changes:
Index: llvm/runtime/GCCLibraries/libc/string.c
diff -u llvm/runtime/GCCLibraries/libc/string.c:1.4 llvm/runtime/GCCLibraries/libc/string.c:1.5
--- llvm/runtime/GCCLibraries/libc/string.c:1.4 Tue Feb 18 14:42:15 2003
+++ llvm/runtime/GCCLibraries/libc/string.c Thu Aug 28 09:35:12 2003
@@ -5,6 +5,7 @@
//===----------------------------------------------------------------------===//
#include
+#include
void *malloc(size_t);
void free(void *);
From lattner at cs.uiuc.edu Thu Aug 28 09:37:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Thu Aug 28 09:37:01 2003
Subject: [llvm-commits] CVS: llvm/runtime/GCCLibraries/libexception/c++-exception.cpp c++-exception.h
Message-ID: <200308281436.JAA23923@apoc.cs.uiuc.edu>
Changes in directory llvm/runtime/GCCLibraries/libexception:
c++-exception.cpp updated: 1.4 -> 1.5
c++-exception.h updated: 1.4 -> 1.5
---
Log message:
New wrapper around the terminate call.
---
Diffs of the changes:
Index: llvm/runtime/GCCLibraries/libexception/c++-exception.cpp
diff -u llvm/runtime/GCCLibraries/libexception/c++-exception.cpp:1.4 llvm/runtime/GCCLibraries/libexception/c++-exception.cpp:1.5
--- llvm/runtime/GCCLibraries/libexception/c++-exception.cpp:1.4 Wed Aug 27 18:00:11 2003
+++ llvm/runtime/GCCLibraries/libexception/c++-exception.cpp Thu Aug 28 09:35:52 2003
@@ -214,6 +214,10 @@
E->ExceptionDestructor(E); // Release memory for the exception
}
+void __llvm_cxxeh_call_terminate() throw() {
+ __terminate(__terminate_handler);
+}
+
// __llvm_cxxeh_rethrow - This function turns the top-level caught exception
// into an uncaught exception, in preparation for an llvm.unwind, which should
Index: llvm/runtime/GCCLibraries/libexception/c++-exception.h
diff -u llvm/runtime/GCCLibraries/libexception/c++-exception.h:1.4 llvm/runtime/GCCLibraries/libexception/c++-exception.h:1.5
--- llvm/runtime/GCCLibraries/libexception/c++-exception.h:1.4 Wed Aug 27 17:59:15 2003
+++ llvm/runtime/GCCLibraries/libexception/c++-exception.h Thu Aug 28 09:35:52 2003
@@ -69,6 +69,7 @@
void __llvm_cxxeh_throw(void *ObjectPtr, void *TypeInfoPtr,
void (*DtorPtr)(void*)) throw();
+ void __llvm_cxxeh_call_terminate() throw() __attribute__((noreturn));
void * __llvm_cxxeh_current_uncaught_exception_isa(void *Ty)
throw();
void *__llvm_cxxeh_begin_catch() throw();
From lattner at cs.uiuc.edu Thu Aug 28 09:44:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Thu Aug 28 09:44:01 2003
Subject: [llvm-commits] CVS: llvm/runtime/GCCLibraries/libexception/c++-exception.h
Message-ID: <200308281443.JAA24239@apoc.cs.uiuc.edu>
Changes in directory llvm/runtime/GCCLibraries/libexception:
c++-exception.h updated: 1.5 -> 1.6
---
Log message:
Convert C comments to C++
---
Diffs of the changes:
Index: llvm/runtime/GCCLibraries/libexception/c++-exception.h
diff -u llvm/runtime/GCCLibraries/libexception/c++-exception.h:1.5 llvm/runtime/GCCLibraries/libexception/c++-exception.h:1.6
--- llvm/runtime/GCCLibraries/libexception/c++-exception.h:1.5 Thu Aug 28 09:35:52 2003
+++ llvm/runtime/GCCLibraries/libexception/c++-exception.h Thu Aug 28 09:43:36 2003
@@ -13,35 +13,35 @@
#include
struct llvm_cxx_exception {
- /* TypeInfo - A pointer to the C++ std::type_info object for this exception
- * class. This is required because the class may not be polymorphic.
- */
+ // TypeInfo - A pointer to the C++ std::type_info object for this exception
+ // class. This is required because the class may not be polymorphic.
+ //
const std::type_info *TypeInfo;
- /* ExceptionObjectDestructor - A pointer to the function which destroys the
- * object represented by this exception. This is required because the class
- * may not be polymorphic. This may be null if there is no cleanup required.
- */
+ // ExceptionObjectDestructor - A pointer to the function which destroys the
+ // object represented by this exception. This is required because the class
+ // may not be polymorphic. This may be null if there is no cleanup required.
+ //
void (*ExceptionObjectDestructor)(void *);
- /* UnexpectedHandler - This contains a pointer to the "unexpected" handler
- * which may be registered by the user program with set_unexpected. Calls to
- * unexpected which are a result of an exception throw are supposed to use the
- * value of the handler at the time of the throw, not the currently set value.
- */
+ // UnexpectedHandler - This contains a pointer to the "unexpected" handler
+ // which may be registered by the user program with set_unexpected. Calls to
+ // unexpected which are a result of an exception throw are supposed to use the
+ // value of the handler at the time of the throw, not the currently set value.
+ //
void (*UnexpectedHandler)();
- /* TerminateHandler - This contains a pointer to the "terminate" handler which
- * may be registered by the user program with set_terminate. Calls to
- * unexpected which are a result of an exception throw are supposed to use the
- * value of the handler at the time of the throw, not the currently set value.
- */
+ // TerminateHandler - This contains a pointer to the "terminate" handler which
+ // may be registered by the user program with set_terminate. Calls to
+ // unexpected which are a result of an exception throw are supposed to use the
+ // value of the handler at the time of the throw, not the currently set value.
+ //
void (*TerminateHandler)();
- /* 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.
- */
+ // 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;
};
From tbrethou at niobe.cs.uiuc.edu Thu Aug 28 10:22:01 2003
From: tbrethou at niobe.cs.uiuc.edu (Tanya Brethour)
Date: Thu Aug 28 10:22:01 2003
Subject: [llvm-commits] CVS: llvm/tools/llvm-ar/
Message-ID: <200308281521.h7SFLT312886@niobe.cs.uiuc.edu>
Changes in directory llvm/tools/llvm-ar:
---
Log message:
Directory /home/vadve/vadve/Research/DynOpt/CVSRepository/llvm/tools/llvm-ar added to the repository
---
Diffs of the changes:
From tbrethou at niobe.cs.uiuc.edu Thu Aug 28 10:23:01 2003
From: tbrethou at niobe.cs.uiuc.edu (Tanya Brethour)
Date: Thu Aug 28 10:23:01 2003
Subject: [llvm-commits] CVS: llvm/tools/llvm-ar/llvm-ar.cpp Makefile
Message-ID: <200308281522.h7SFMmG12997@niobe.cs.uiuc.edu>
Changes in directory llvm/tools/llvm-ar:
llvm-ar.cpp added (r1.1)
Makefile added (r1.1)
---
Log message:
First version of llvm-ar added to cvs repository.
---
Diffs of the changes:
Index: llvm/tools/llvm-ar/llvm-ar.cpp
diff -c /dev/null llvm/tools/llvm-ar/llvm-ar.cpp:1.1
*** /dev/null Thu Aug 28 10:22:48 2003
--- llvm/tools/llvm-ar/llvm-ar.cpp Thu Aug 28 10:22:38 2003
***************
*** 0 ****
--- 1,373 ----
+ //===----------------------------------------------------------------------===//
+ // LLVM 'ar' UTILITY
+ //
+ // This utility may be invoked in the following manner:
+ // llvm-ar archivename files..
+ //
+ //===----------------------------------------------------------------------===//
+ #include "Support/CommandLine.h"
+ #include "llvm/Bytecode/Reader.h"
+ #include "llvm/Module.h"
+
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+
+
+ using std::string;
+ using std::vector;
+ using std::cout;
+
+
+ #define ARFMAG "\n" /* header trailer string */
+ #define ARMAG "!\n" /* magic string */
+ #define SARMAG 8 /* length of magic string */
+
+ namespace {
+
+ // Each file member is preceded by a file member header. Which is
+ // of the following format:
+ //
+ // char ar_name[16] - '/' terminated file member name.
+ // If the file name does not fit, a dummy name is used.
+ // char ar_date[12] - file date in decimal
+ // char ar_uid[6] - User id of file owner in decimal.
+ // char ar_gid[6] - Group ID file belongs to in decimal.
+ // char ar_mode[8] - File mode in octal.
+ // char ar_size[10] - Size of file in decimal.
+ // char ar_fmag[2] - Trailer of header file, a newline.
+ struct ar_hdr {
+ char name[16];
+ char date[12];
+ char uid[6];
+ char gid[6];
+ char mode[8];
+ char size[10];
+ char fmag[2];
+ void init() {
+ memset(name,' ',16);
+ memset(date,' ',12);
+ memset(uid,' ',6);
+ memset(gid,' ',6);
+ memset(mode,' ',8);
+ memset(size,' ',10);
+ memset(fmag,' ',2);
+ }
+ };
+ }
+
+ //Option to generate symbol table or not
+ //running llvm-ar -s is the same as ranlib
+ cl::opt SymbolTable ("s", cl::desc("Generate an archive symbol table"));
+
+ //Archive name
+ cl::opt Archive (cl::Positional, cl::desc(""),
+ cl::Required);
+
+ //For now we require one or more member files, this should change so
+ //we can just run llvm-ar -s on an archive to generate the symbol
+ //table
+ cl::list Members(cl::ConsumeAfter, cl::desc("..."));
+
+
+ static inline bool Error(std::string *ErrorStr, const char *Message) {
+ if (ErrorStr) *ErrorStr = Message;
+ return true;
+ }
+
+
+ // WriteSymbolTable - Writes symbol table to ArchiveFile, return false
+ // on errors. Also returns by reference size of symbol table.
+ //
+ // Overview of method:
+ // 1) Generate the header for the symbol table. This is a normal
+ // archive member header, but it has a zero length name.
+ // 2) For each archive member file, stat the file and parse the bytecode
+ // Store cummulative offset (file size + header size).
+ // 3) Loop over all the symbols for the current member file,
+ // add offset entry to offset vector, and add symbol name to its vector.
+ // Note: The symbol name vector is a vector of chars to speed up calculating
+ // the total size of the symbol table.
+ // 4) Update offset vector once we know the total size of symbol table. This is
+ // because the symbol table appears before all archive member file contents.
+ // We add the size of magic string, and size of symbol table to each offset.
+ // 5) If the new updated offset it not even, we add 1 byte to offset because
+ // a newline will be inserted when writing member files. This adjustment is
+ // cummulative (ie. each time we have an odd offset we add 1 to total adjustment).
+ // 6) Lastly, write symbol table to file.
+ //
+ bool WriteSymbolTable(std::ofstream &ArchiveFile) {
+
+ //Create header for symbol table. This is essentially an empty header with the
+ //name set to a '/' to indicate its a symbol table.
+ ar_hdr Hdr;
+ Hdr.init();
+
+ //Name of symbol table is '/'
+ Hdr.name[0] = '/';
+ Hdr.name[1] = '/0';
+
+ //Set the header trailer to a newline
+ memcpy(Hdr.fmag,ARFMAG,sizeof(ARFMAG));
+
+
+ //Write header to archive file
+ ArchiveFile.write((char*)&Hdr, sizeof(Hdr));
+
+
+ unsigned memoff = 0; //Keep Track of total size of files added to archive
+ vector offsets; //Vector of offsets into archive file
+ vector names; //Vector of characters that are the symbol names.
+
+ //Loop over archive member files, parse bytecode, and generate symbol table.
+ for(unsigned i=0; ibegin(), E=M->end(); I != E; ++I) {
+
+ //get function name
+ string NM = ((Function*)I)->getName();
+
+ //Loop over the characters in the name and add to symbol name vector
+ for(unsigned i=0; i> 24) & 255;
+ num[1] = (temp >> 16) & 255;
+ num[2] = (temp >> 8) & 255;
+ num[3] = temp & 255;
+
+ //Write number of symbols to archive file
+ ArchiveFile.write(num,4);
+
+ //Adjustment to offset to start files on even byte boundaries
+ unsigned adjust = 0;
+
+ //Update offsets write symbol tabel to archive.
+ for(unsigned i=0; i> 24) & 255;
+ output[1] = (offsets[i] >> 16) & 255;
+ output[2] = (offsets[i] >> 8) & 255;
+ output[3] = offsets[i] & 255;
+ ArchiveFile.write(output,4);
+ }
+
+
+ //Write out symbol name vector.
+ for(unsigned i=0; i
Changes in directory llvm/include/llvm/CodeGen:
SchedGraphCommon.h updated: 1.3 -> 1.4
---
Log message:
Moved index in BB to common graph class.
---
Diffs of the changes:
Index: llvm/include/llvm/CodeGen/SchedGraphCommon.h
diff -u llvm/include/llvm/CodeGen/SchedGraphCommon.h:1.3 llvm/include/llvm/CodeGen/SchedGraphCommon.h:1.4
--- llvm/include/llvm/CodeGen/SchedGraphCommon.h:1.3 Wed Aug 27 10:52:23 2003
+++ llvm/include/llvm/CodeGen/SchedGraphCommon.h Thu Aug 28 10:31:28 2003
@@ -29,6 +29,7 @@
std::vector inEdges;
std::vector outEdges;
int latency;
+ int origIndexInBB; // original position of instr in BB
public:
typedef std::vector::iterator iterator;
@@ -41,7 +42,7 @@
int getLatency() const { return latency; }
unsigned getNumInEdges() const { return inEdges.size(); }
unsigned getNumOutEdges() const { return outEdges.size(); }
-
+ int getOrigIndexInBB() const { return origIndexInBB; }
// Iterators
iterator beginInEdges() { return inEdges.begin(); }
@@ -68,7 +69,8 @@
// disable default constructor and provide a ctor for single-block graphs
SchedGraphNodeCommon(); // DO NOT IMPLEMENT
- inline SchedGraphNodeCommon(unsigned Id) : ID(Id), latency(0) {}
+ inline SchedGraphNodeCommon(unsigned Id, int index) : ID(Id), latency(0),
+ origIndexInBB(index) {}
virtual ~SchedGraphNodeCommon();
//Functions to add and remove edges
From tbrethou at cs.uiuc.edu Thu Aug 28 10:32:05 2003
From: tbrethou at cs.uiuc.edu (Tanya Brethour)
Date: Thu Aug 28 10:32:05 2003
Subject: [llvm-commits] CVS: llvm/lib/CodeGen/InstrSched/SchedGraph.cpp SchedGraph.h
Message-ID: <200308281530.KAA21485@tank.cs.uiuc.edu>
Changes in directory llvm/lib/CodeGen/InstrSched:
SchedGraph.cpp updated: 1.48 -> 1.49
SchedGraph.h updated: 1.33 -> 1.34
---
Log message:
Moved index into BB to common graph class because its needed by ModuloSchedGraph.
---
Diffs of the changes:
Index: llvm/lib/CodeGen/InstrSched/SchedGraph.cpp
diff -u llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.48 llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.49
--- llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.48 Tue Aug 26 21:42:58 2003
+++ llvm/lib/CodeGen/InstrSched/SchedGraph.cpp Thu Aug 28 10:30:40 2003
@@ -44,8 +44,7 @@
SchedGraphNode::SchedGraphNode(unsigned NID, MachineBasicBlock *mbb,
int indexInBB, const TargetMachine& Target)
- : SchedGraphNodeCommon(NID), origIndexInBB(indexInBB), MBB(mbb),
- MI(mbb ? (*mbb)[indexInBB] : 0) {
+ : SchedGraphNodeCommon(NID,indexInBB), MBB(mbb), MI(mbb ? (*mbb)[indexInBB] : 0) {
if (MI) {
MachineOpCode mopCode = MI->getOpCode();
latency = Target.getInstrInfo().hasResultInterlock(mopCode)
Index: llvm/lib/CodeGen/InstrSched/SchedGraph.h
diff -u llvm/lib/CodeGen/InstrSched/SchedGraph.h:1.33 llvm/lib/CodeGen/InstrSched/SchedGraph.h:1.34
--- llvm/lib/CodeGen/InstrSched/SchedGraph.h:1.33 Wed Aug 27 10:12:24 2003
+++ llvm/lib/CodeGen/InstrSched/SchedGraph.h Thu Aug 28 10:30:40 2003
@@ -26,7 +26,6 @@
class SchedGraphNode : public SchedGraphNodeCommon {
- int origIndexInBB; // original position of machine instr in BB
MachineBasicBlock *MBB;
const MachineInstr *MI;
@@ -46,7 +45,6 @@
bool isDummyNode() const { return (MI == NULL); }
MachineBasicBlock &getMachineBasicBlock() const { return *MBB; }
- int getOrigIndexInBB() const { return origIndexInBB; }
void print(std::ostream &os) const;
};
From lattner at cs.uiuc.edu Thu Aug 28 10:51:02 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Thu Aug 28 10:51:02 2003
Subject: [llvm-commits] CVS: llvm/test/Programs/TEST.nightly.report
Message-ID: <200308281550.KAA19719@neo.cs.uiuc.edu>
Changes in directory llvm/test/Programs:
TEST.nightly.report updated: 1.13 -> 1.14
---
Log message:
Add support for the funny sparc syntax for time
---
Diffs of the changes:
Index: llvm/test/Programs/TEST.nightly.report
diff -u llvm/test/Programs/TEST.nightly.report:1.13 llvm/test/Programs/TEST.nightly.report:1.14
--- llvm/test/Programs/TEST.nightly.report:1.13 Mon Aug 18 10:19:13 2003
+++ llvm/test/Programs/TEST.nightly.report Thu Aug 28 10:50:29 2003
@@ -12,7 +12,7 @@
# FormatTime - Convert a time from 1m23.45 into 83.45
sub FormatTime {
my $Time = shift;
- if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
+ if ($Time =~ m/([0-9]+)[m:]([0-9.]+)/) {
$Time = sprintf("%7.4f", $1*60.0+$2);
}
return $Time;
From lattner at cs.uiuc.edu Thu Aug 28 11:26:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Thu Aug 28 11:26:01 2003
Subject: [llvm-commits] CVS: llvm/tools/link/link.cpp
Message-ID: <200308281625.LAA27205@apoc.cs.uiuc.edu>
Changes in directory llvm/tools/link:
link.cpp updated: 1.26 -> 1.27
---
Log message:
Reorder #includes
Make sure that we veryify the result before writing it out!
---
Diffs of the changes:
Index: llvm/tools/link/link.cpp
diff -u llvm/tools/link/link.cpp:1.26 llvm/tools/link/link.cpp:1.27
--- llvm/tools/link/link.cpp:1.26 Fri Jun 13 11:10:26 2003
+++ llvm/tools/link/link.cpp Thu Aug 28 11:25:34 2003
@@ -6,10 +6,11 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/Transforms/Utils/Linker.h"
+#include "llvm/Module.h"
+#include "llvm/Analysis/Verifier.h"
#include "llvm/Bytecode/Reader.h"
#include "llvm/Bytecode/Writer.h"
-#include "llvm/Module.h"
+#include "llvm/Transforms/Utils/Linker.h"
#include "Support/CommandLine.h"
#include "Support/Signals.h"
#include
@@ -123,6 +124,11 @@
// Make sure that the Out file gets unlink'd from the disk if we get a
// SIGINT
RemoveFileOnSignal(OutputFilename);
+ }
+
+ if (verifyModule(*Composite.get())) {
+ std::cerr << argv[0] << ": linked module is broken!\n";
+ return 1;
}
if (Verbose) std::cerr << "Writing bytecode...\n";
From lattner at cs.uiuc.edu Thu Aug 28 11:44:02 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Thu Aug 28 11:44:02 2003
Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/Linker.cpp
Message-ID: <200308281643.LAA27842@apoc.cs.uiuc.edu>
Changes in directory llvm/lib/Transforms/Utils:
Linker.cpp updated: 1.53 -> 1.54
---
Log message:
Fix bug where we considered function types equivalent even if they had differing numbers of arguments
---
Diffs of the changes:
Index: llvm/lib/Transforms/Utils/Linker.cpp
diff -u llvm/lib/Transforms/Utils/Linker.cpp:1.53 llvm/lib/Transforms/Utils/Linker.cpp:1.54
--- llvm/lib/Transforms/Utils/Linker.cpp:1.53 Sun Aug 24 14:30:20 2003
+++ llvm/lib/Transforms/Utils/Linker.cpp Thu Aug 28 11:42:50 2003
@@ -79,7 +79,9 @@
switch (DestTyT->getPrimitiveID()) {
case Type::FunctionTyID: {
if (cast(DestTyT)->isVarArg() !=
- cast(SrcTyT)->isVarArg())
+ cast(SrcTyT)->isVarArg() ||
+ cast(DestTyT)->getNumContainedTypes() !=
+ cast(SrcTyT)->getNumContainedTypes())
return true;
for (unsigned i = 0, e = getFT(DestTy)->getNumContainedTypes(); i != e; ++i)
if (RecursiveResolveTypesI(getFT(DestTy)->getContainedType(i),
From tbrethou at cs.uiuc.edu Thu Aug 28 12:13:03 2003
From: tbrethou at cs.uiuc.edu (Tanya Brethour)
Date: Thu Aug 28 12:13:03 2003
Subject: [llvm-commits] CVS: llvm/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.cpp ModuloSchedGraph.h ModuloScheduling.cpp ModuloScheduling.h
Message-ID: <200308281712.MAA24529@tank.cs.uiuc.edu>
Changes in directory llvm/lib/CodeGen/ModuloScheduling:
ModuloSchedGraph.cpp updated: 1.10 -> 1.11
ModuloSchedGraph.h updated: 1.9 -> 1.10
ModuloScheduling.cpp updated: 1.10 -> 1.11
ModuloScheduling.h (r1.9) removed
---
Log message:
Putting my revised version of ModuloScheduling in cvs. This is not complete...
---
Diffs of the changes:
Index: llvm/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.cpp
diff -u llvm/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.cpp:1.10 llvm/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.cpp:1.11
--- llvm/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.cpp:1.10 Thu Aug 21 17:05:57 2003
+++ llvm/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.cpp Thu Aug 28 12:12:14 2003
@@ -1,1507 +1,130 @@
-//===- ModuloSchedGraph.cpp - Graph datastructure for Modulo Scheduling ---===//
-//
-//
+//===- ModuloSchedGraph.cpp - Modulo Scheduling Graph and Set -*- C++ -*---===//
+//
+// Description here
//===----------------------------------------------------------------------===//
-#include "llvm/CodeGen/InstrSelection.h"
-#include "llvm/Function.h"
-#include "llvm/Instructions.h"
-#include "llvm/Type.h"
-#include "llvm/CodeGen/MachineCodeForInstruction.h"
-#include "llvm/CodeGen/MachineInstr.h"
-#include "llvm/Target/TargetSchedInfo.h"
-#include "Support/StringExtras.h"
-#include "Support/STLExtras.h"
-#include "Support/hash_map"
-#include "Support/Statistic.h"
-#include "ModuloScheduling.h"
#include "ModuloSchedGraph.h"
-#include
-#include
-#include
-#include
-
-
-#define UNIDELAY 1
-
-using std::cerr;
-using std::endl;
-using std::vector;
-
-
-/***********member functions for ModuloSchedGraphNode*********/
-
-
-ModuloSchedGraphNode::ModuloSchedGraphNode(unsigned int in_nodeId,
- const BasicBlock * in_bb,
- const Instruction * in_inst,
- int indexInBB,
- const TargetMachine & target)
- :SchedGraphNodeCommon(in_nodeId, indexInBB), inst(in_inst){
-
- if (inst) {
- //FIXME: find the latency
- //currently set the latency to zero
- latency = 0;
- }
-}
-
-
-/***********member functions for ModuloSchedGraph*********/
-
-void
-ModuloSchedGraph::addDefUseEdges(const BasicBlock *bb){
-
- //collect def instructions, store them in vector
- const TargetInstrInfo & mii = target.getInstrInfo();
- vector < ModuloSchedGraphNode * > defVec;
-
-
- //find those def instructions
- for (BasicBlock::const_iterator I = bb->begin(), E = bb->end(); I != E; ++I) {
- if (I->getType() != Type::VoidTy) {
- defVec.push_back(this->getGraphNodeForInst(I));
- }
- }
-
- for (unsigned int i = 0; i < defVec.size(); i++) {
- for (Value::use_const_iterator I = defVec[i]->getInst()->use_begin();
- I != defVec[i]->getInst()->use_end(); I++) {
- //for each use of a def, add a flow edge from the def instruction to the
- //ref instruction
-
- const Instruction *value = defVec[i]->getInst();
- Instruction *inst = (Instruction *) (*I);
- ModuloSchedGraphNode *node = NULL;
-
- for (BasicBlock::const_iterator ins = bb->begin(), E = bb->end();
- ins != E; ++ins)
- if ((const Instruction *) ins == inst) {
- node = (*this)[inst];
- break;
- }
-
-
- if (node == NULL){
-
- //inst is not an instruction in this block
- //do nothing
-
- } else {
- // Add a flow edge from the def instruction to the ref instruction
- // This is a true dependence, so the delay is equal to the
- //delay of the preceding node.
-
- int delay = 0;
-
- // self loop will not happen in SSA form
- assert(defVec[i] != node && "same node?");
-
- MachineCodeForInstruction & tempMvec =
- MachineCodeForInstruction::get(value);
- for (unsigned j = 0; j < tempMvec.size(); j++) {
- MachineInstr *temp = tempMvec[j];
- delay = std::max(delay, mii.minLatency(temp->getOpCode()));
- }
-
- SchedGraphEdge *trueEdge =
- new SchedGraphEdge(defVec[i], node, value,
- SchedGraphEdge::TrueDep, delay);
-
- // if the ref instruction is before the def instrution
- // then the def instruction must be a phi instruction
- // add an anti-dependence edge to from the ref instruction to the def
- // instruction
- if (node->getOrigIndexInBB() < defVec[i]->getOrigIndexInBB()) {
- assert(PHINode::classof(inst)
- && "the ref instruction befre def is not PHINode?");
- trueEdge->setIteDiff(1);
- }
-
- }
-
- }
- }
-}
-
-void
-ModuloSchedGraph::addCDEdges(const BasicBlock * bb) {
-
- // find the last instruction in the basic block
- // see if it is an branch instruction.
- // If yes, then add an edge from each node expcept the last node
- // to the last node
-
- const Instruction *inst = &(bb->back());
- ModuloSchedGraphNode *lastNode = (*this)[inst];
- if (TerminatorInst::classof(inst))
- for (BasicBlock::const_iterator I = bb->begin(), E = bb->end(); I != E;
- I++) {
- if (inst != I) {
- ModuloSchedGraphNode *node = (*this)[I];
- //use latency of 0
- (void) new SchedGraphEdge(node, lastNode, SchedGraphEdge::CtrlDep,
- SchedGraphEdge::NonDataDep, 0);
- }
-
- }
-}
-
-static const int SG_LOAD_REF = 0;
-static const int SG_STORE_REF = 1;
-static const int SG_CALL_REF = 2;
-
-static const unsigned int SG_DepOrderArray[][3] = {
- {SchedGraphEdge::NonDataDep,
- SchedGraphEdge::AntiDep,
- SchedGraphEdge::AntiDep},
- {SchedGraphEdge::TrueDep,
- SchedGraphEdge::OutputDep,
- SchedGraphEdge::TrueDep | SchedGraphEdge::OutputDep},
- {SchedGraphEdge::TrueDep,
- SchedGraphEdge::AntiDep | SchedGraphEdge::OutputDep,
- SchedGraphEdge::TrueDep | SchedGraphEdge::AntiDep
- | SchedGraphEdge::OutputDep}
-};
-
-
-// Add a dependence edge between every pair of machine load/store/call
-// instructions, where at least one is a store or a call.
-// Use latency 1 just to ensure that memory operations are ordered;
-// latency does not otherwise matter (true dependences enforce that).
-//
-void
-ModuloSchedGraph::addMemEdges(const BasicBlock * bb) {
-
- vector memNodeVec;
-
- //construct the memNodeVec
- for (BasicBlock::const_iterator I = bb->begin(),
- E = bb->end(); I != E; ++I) {
-
- if (LoadInst::classof(I) || StoreInst::classof(I)
- || CallInst::classof(I)) {
-
- ModuloSchedGraphNode *node = (*this)[(const Instruction *) I];
- memNodeVec.push_back(node);
-
- }
- }
-
- // Instructions in memNodeVec are in execution order within the
- // basic block, so simply look at all pairs
- // i]>.
-
- for (unsigned im = 0, NM = memNodeVec.size(); im < NM; im++) {
-
- const Instruction *fromInst,*toInst;
- int toType, fromType;
-
- //get the first mem instruction and instruction type
- fromInst = memNodeVec[im]->getInst();
- fromType = CallInst::classof(fromInst) ? SG_CALL_REF
- : LoadInst::classof(fromInst) ? SG_LOAD_REF : SG_STORE_REF;
-
- for (unsigned jm = im + 1; jm < NM; jm++) {
-
- //get the second mem instruction and instruction type
- toInst = memNodeVec[jm]->getInst();
- toType = CallInst::classof(toInst) ? SG_CALL_REF
- : LoadInst::classof(toInst) ? SG_LOAD_REF : SG_STORE_REF;
-
- //add two edges if not both of them are LOAD instructions
- if (fromType != SG_LOAD_REF || toType != SG_LOAD_REF) {
- (void) new SchedGraphEdge(memNodeVec[im], memNodeVec[jm],
- SchedGraphEdge::MemoryDep,
- SG_DepOrderArray[fromType][toType], 1);
-
- SchedGraphEdge *edge =
- new SchedGraphEdge(memNodeVec[jm], memNodeVec[im],
- SchedGraphEdge::MemoryDep,
- SG_DepOrderArray[toType][fromType], 1);
-
- //set the iteration difference for this edge to 1.
- edge->setIteDiff(1);
-
- }
- }
- }
-}
-
-/*
- this function build graph nodes for each instruction
- in the basicblock
-*/
-
-void
-ModuloSchedGraph::buildNodesforBB(const TargetMachine &target,
- const BasicBlock *bb){
-
- int i = 0;
- ModuloSchedGraphNode *node;
-
- for (BasicBlock::const_iterator I = bb->begin(), E = bb->end();
- I != E; ++I) {
-
- node=new ModuloSchedGraphNode(getNumNodes(), bb, I, i, target);
-
- i++;
-
- this->addHash(I, node);
- }
-
-}
-
-
-/*
- determine if this basicblock includes a loop or not
-*/
-
-bool
-ModuloSchedGraph::isLoop(const BasicBlock *bb) {
-
- //only if the last instruction in the basicblock is branch instruction and
- //there is at least an option to branch itself
-
- const Instruction *inst = &(bb->back());
-
- if (BranchInst::classof(inst)) {
- for (unsigned i = 0; i < ((BranchInst *) inst)->getNumSuccessors();
- i++) {
- BasicBlock *sb = ((BranchInst *) inst)->getSuccessor(i);
- if (sb == bb)
- return true;
- }
- }
-
- return false;
-
-}
-
-/*
- compute every node's ASAP
-
-*/
-
-//FIXME: now assume the only backward edges come from the edges from other
-//nodes to the phi Node so i will ignore all edges to the phi node; after
-//this, there shall be no recurrence.
-
-void
-ModuloSchedGraph::computeNodeASAP(const BasicBlock *bb) {
-
-
- unsigned numNodes = bb->size();
- for (unsigned i = 2; i < numNodes + 2; i++) {
- ModuloSchedGraphNode *node = getNode(i);
- node->setPropertyComputed(false);
- }
-
- for (unsigned i = 2; i < numNodes + 2; i++) {
- ModuloSchedGraphNode *node = getNode(i);
- node->ASAP = 0;
- if (i == 2 || node->getNumInEdges() == 0) {
- node->setPropertyComputed(true);
- continue;
- }
- for (ModuloSchedGraphNode::const_iterator I = node->beginInEdges(), E =
- node->endInEdges(); I != E; I++) {
- SchedGraphEdge *edge = *I;
- ModuloSchedGraphNode *pred =
- (ModuloSchedGraphNode *) (edge->getSrc());
- assert(pred->getPropertyComputed()
- && "pred node property is not computed!");
- int temp =
- pred->ASAP + edge->getMinDelay() -
- edge->getIteDiff() * this->MII;
- node->ASAP = std::max(node->ASAP, temp);
- }
- node->setPropertyComputed(true);
- }
-}
-
-
-/*
- compute every node's ALAP in the basic block
-*/
-
-void
-ModuloSchedGraph::computeNodeALAP(const BasicBlock *bb) {
-
- unsigned numNodes = bb->size();
- int maxASAP = 0;
- for (unsigned i = numNodes + 1; i >= 2; i--) {
-
- ModuloSchedGraphNode *node = getNode(i);
- node->setPropertyComputed(false);
- maxASAP = std::max(maxASAP, node->ASAP);
-
- }
-
- for (unsigned i = numNodes + 1; i >= 2; i--) {
- ModuloSchedGraphNode *node = getNode(i);
-
- node->ALAP = maxASAP;
-
- for (ModuloSchedGraphNode::const_iterator I =
- node->beginOutEdges(), E = node->endOutEdges(); I != E; I++) {
-
- SchedGraphEdge *edge = *I;
- ModuloSchedGraphNode *succ =
- (ModuloSchedGraphNode *) (edge->getSink());
- if (PHINode::classof(succ->getInst()))
- continue;
-
- assert(succ->getPropertyComputed()
- && "succ node property is not computed!");
-
- int temp =
- succ->ALAP - edge->getMinDelay() +
- edge->getIteDiff() * this->MII;
-
- node->ALAP = std::min(node->ALAP, temp);
-
- }
- node->setPropertyComputed(true);
- }
-}
-
-/*
- compute every node's mov in this basicblock
-*/
-
-void
-ModuloSchedGraph::computeNodeMov(const BasicBlock *bb){
-
- unsigned numNodes = bb->size();
- for (unsigned i = 2; i < numNodes + 2; i++) {
-
- ModuloSchedGraphNode *node = getNode(i);
- node->mov = node->ALAP - node->ASAP;
- assert(node->mov >= 0
- && "move freedom for this node is less than zero? ");
-
- }
-
-}
-
-
-/*
- compute every node's depth in this basicblock
-*/
-void
-ModuloSchedGraph::computeNodeDepth(const BasicBlock * bb){
-
- unsigned numNodes = bb->size();
-
- for (unsigned i = 2; i < numNodes + 2; i++) {
-
- ModuloSchedGraphNode *node = getNode(i);
- node->setPropertyComputed(false);
-
- }
-
- for (unsigned i = 2; i < numNodes + 2; i++) {
-
- ModuloSchedGraphNode *node = getNode(i);
- node->depth = 0;
- if (i == 2 || node->getNumInEdges() == 0) {
- node->setPropertyComputed(true);
- continue;
- }
-
- for (ModuloSchedGraphNode::const_iterator I = node->beginInEdges(), E =
- node->endInEdges(); I != E; I++) {
- SchedGraphEdge *edge = *I;
- ModuloSchedGraphNode *pred =
- (ModuloSchedGraphNode *) (edge->getSrc());
- assert(pred->getPropertyComputed()
- && "pred node property is not computed!");
- int temp = pred->depth + edge->getMinDelay();
- node->depth = std::max(node->depth, temp);
- }
- node->setPropertyComputed(true);
-
- }
-
-}
-
-
-/*
- compute every node's height in this basic block
-*/
-
-void
-ModuloSchedGraph::computeNodeHeight(const BasicBlock *bb){
-
- unsigned numNodes = bb->size();
- for (unsigned i = numNodes + 1; i >= 2; i--) {
- ModuloSchedGraphNode *node = getNode(i);
- node->setPropertyComputed(false);
- }
-
- for (unsigned i = numNodes + 1; i >= 2; i--) {
- ModuloSchedGraphNode *node = getNode(i);
- node->height = 0;
- for (ModuloSchedGraphNode::const_iterator I =
- node->beginOutEdges(), E = node->endOutEdges(); I != E; ++I) {
- SchedGraphEdge *edge = *I;
- ModuloSchedGraphNode *succ =
- (ModuloSchedGraphNode *) (edge->getSink());
- if (PHINode::classof(succ->getInst()))
- continue;
- assert(succ->getPropertyComputed()
- && "succ node property is not computed!");
- node->height = std::max(node->height, succ->height + edge->getMinDelay());
-
- }
- node->setPropertyComputed(true);
- }
-
-}
-
-/*
- compute every node's property in a basicblock
-*/
-
-void ModuloSchedGraph::computeNodeProperty(const BasicBlock * bb)
-{
- //FIXME: now assume the only backward edges come from the edges from other
- //nodes to the phi Node so i will ignore all edges to the phi node; after
- //this, there shall be no recurrence.
-
- this->computeNodeASAP(bb);
- this->computeNodeALAP(bb);
- this->computeNodeMov(bb);
- this->computeNodeDepth(bb);
- this->computeNodeHeight(bb);
-}
-
-
-/*
- compute the preset of this set without considering the edges
- between backEdgeSrc and backEdgeSink
-*/
-std::vector
-ModuloSchedGraph::predSet(std::vector set,
- unsigned backEdgeSrc,
- unsigned
- backEdgeSink){
-
- std::vector predS;
-
- for (unsigned i = 0; i < set.size(); i++) {
-
- ModuloSchedGraphNode *node = set[i];
- for (ModuloSchedGraphNode::const_iterator I = node->beginInEdges(), E =
- node->endInEdges(); I != E; I++) {
- SchedGraphEdge *edge = *I;
-
- //if edges between backEdgeSrc and backEdgeSink, omitted
- if (edge->getSrc()->getNodeId() == backEdgeSrc
- && edge->getSink()->getNodeId() == backEdgeSink)
- continue;
- ModuloSchedGraphNode *pred =
- (ModuloSchedGraphNode *) (edge->getSrc());
-
- //if pred is not in the predSet ....
- bool alreadyInset = false;
- for (unsigned j = 0; j < predS.size(); ++j)
- if (predS[j]->getNodeId() == pred->getNodeId()) {
- alreadyInset = true;
- break;
- }
-
- // and pred is not in the set ....
- for (unsigned j = 0; j < set.size(); ++j)
- if (set[j]->getNodeId() == pred->getNodeId()) {
- alreadyInset = true;
- break;
- }
-
- //push it into the predS
- if (!alreadyInset)
- predS.push_back(pred);
- }
- }
- return predS;
-}
-
-
-/*
- return pred set to this set
-*/
-
-ModuloSchedGraph::NodeVec
-ModuloSchedGraph::predSet(NodeVec set){
-
- //node number increases from 2,
- return predSet(set, 0, 0);
-}
-
-/*
- return pred set to _node, ignoring
- any edge between backEdgeSrc and backEdgeSink
-*/
-std::vector
-ModuloSchedGraph::predSet(ModuloSchedGraphNode *_node,
- unsigned backEdgeSrc, unsigned backEdgeSink){
-
- std::vector set;
- set.push_back(_node);
- return predSet(set, backEdgeSrc, backEdgeSink);
-}
-
-
-/*
- return pred set to _node, ignoring
-*/
-
-std::vector
-ModuloSchedGraph::predSet(ModuloSchedGraphNode * _node){
-
- return predSet(_node, 0, 0);
-
-}
-
-/*
- return successor set to the input set
- ignoring any edge between src and sink
-*/
-
-std::vector
-ModuloSchedGraph::succSet(std::vector set,
- unsigned src, unsigned sink){
-
- std::vector succS;
-
- for (unsigned i = 0; i < set.size(); i++) {
- ModuloSchedGraphNode *node = set[i];
- for (ModuloSchedGraphNode::const_iterator I =
- node->beginOutEdges(), E = node->endOutEdges(); I != E; I++) {
- SchedGraphEdge *edge = *I;
-
- //if the edge is between src and sink, skip
- if (edge->getSrc()->getNodeId() == src
- && edge->getSink()->getNodeId() == sink)
- continue;
- ModuloSchedGraphNode *succ =
- (ModuloSchedGraphNode *) (edge->getSink());
-
- //if pred is not in the successor set ....
- bool alreadyInset = false;
- for (unsigned j = 0; j < succS.size(); j++)
- if (succS[j]->getNodeId() == succ->getNodeId()) {
- alreadyInset = true;
- break;
- }
-
- //and not in this set ....
- for (unsigned j = 0; j < set.size(); j++)
- if (set[j]->getNodeId() == succ->getNodeId()) {
- alreadyInset = true;
- break;
- }
-
- //push it into the successor set
- if (!alreadyInset)
- succS.push_back(succ);
- }
- }
- return succS;
-}
-
-/*
- return successor set to the input set
-*/
-
-ModuloSchedGraph::NodeVec ModuloSchedGraph::succSet(NodeVec set){
-
- return succSet(set, 0, 0);
+#include "llvm/Type.h"
+ModuloSchedGraphNode::ModuloSchedGraphNode(unsigned id, int index,
+ const Instruction *inst,
+ const TargetMachine &targ)
+ : SchedGraphNodeCommon(id, index), Inst(inst), Target(targ) {
}
-/*
- return successor set to the input node
- ignoring any edge between src and sink
-*/
-
-std::vector
-ModuloSchedGraph::succSet(ModuloSchedGraphNode *_node,
- unsigned src, unsigned sink){
-
- std::vectorset;
-
- set.push_back(_node);
-
- return succSet(set, src, sink);
-
+void ModuloSchedGraphNode::print(std::ostream &os) const {
+ os << "Modulo Scheduling Node\n";
}
-/*
- return successor set to the input node
-*/
+ModuloSchedGraph::ModuloSchedGraph(const BasicBlock *bb, const TargetMachine &targ)
+ : SchedGraphCommon(), BB(bb), Target(targ) {
-std::vector
-ModuloSchedGraph::succSet(ModuloSchedGraphNode * _node){
-
- return succSet(_node, 0, 0);
-
-}
+ assert(BB != NULL && "Basic Block is null");
+ //Builds nodes from each instruction in the basic block
+ buildNodesForBB();
-/*
- find maximum delay between srcId and sinkId
-*/
-
-SchedGraphEdge*
-ModuloSchedGraph::getMaxDelayEdge(unsigned srcId,
- unsigned sinkId){
-
- ModuloSchedGraphNode *node = getNode(srcId);
- SchedGraphEdge *maxDelayEdge = NULL;
- int maxDelay = -1;
- for (ModuloSchedGraphNode::const_iterator I = node->beginOutEdges(), E =
- node->endOutEdges(); I != E; I++) {
- SchedGraphEdge *edge = *I;
- if (edge->getSink()->getNodeId() == sinkId)
- if (edge->getMinDelay() > maxDelay) {
- maxDelayEdge = edge;
- maxDelay = edge->getMinDelay();
- }
- }
- assert(maxDelayEdge != NULL && "no edge between the srcId and sinkId?");
- return maxDelayEdge;
-
}
-/*
- dump all circuits found
-*/
-
-void
-ModuloSchedGraph::dumpCircuits(){
-
- DEBUG_PRINT(std::cerr << "dumping circuits for graph:\n");
- int j = -1;
- while (circuits[++j][0] != 0) {
- int k = -1;
- while (circuits[j][++k] != 0)
- DEBUG_PRINT(std::cerr << circuits[j][k] << "\t");
- DEBUG_PRINT(std::cerr << "\n");
+void ModuloSchedGraph::buildNodesForBB() {
+ int count = 0;
+ for (BasicBlock::const_iterator i = BB->begin(), e = BB->end(); i != e; ++i) {
+ addNode(i,new ModuloSchedGraphNode(size(), count, i, Target));
+ count++;
}
-}
-/*
- dump all sets found
-*/
+ //Get machine instruction(s) for the llvm instruction
+ //MachineCodeForInstruction &MC = MachineCodeForInstruction::get(Node->first);
+
-void
-ModuloSchedGraph::dumpSet(std::vector < ModuloSchedGraphNode * >set){
-
- for (unsigned i = 0; i < set.size(); i++)
- DEBUG_PRINT(std::cerr << set[i]->getNodeId() << "\t");
- DEBUG_PRINT(std::cerr << "\n");
-
}
-/*
- return union of set1 and set2
-*/
-
-std::vector
-ModuloSchedGraph::vectorUnion(std::vector set1,
- std::vector set2){
-
- std::vector unionVec;
- for (unsigned i = 0; i < set1.size(); i++)
- unionVec.push_back(set1[i]);
- for (unsigned j = 0; j < set2.size(); j++) {
- bool inset = false;
- for (unsigned i = 0; i < unionVec.size(); i++)
- if (set2[j] == unionVec[i])
- inset = true;
- if (!inset)
- unionVec.push_back(set2[j]);
- }
- return unionVec;
+void ModuloSchedGraph::addNode(const Instruction *I,
+ ModuloSchedGraphNode *node) {
+ assert(node!= NULL && "New ModuloSchedGraphNode is null");
+ GraphMap[I] = node;
}
-/*
- return conjuction of set1 and set2
-*/
-std::vector
-ModuloSchedGraph::vectorConj(std::vector set1,
- std::vector set2){
+void ModuloSchedGraph::addDepEdges() {
- std::vector conjVec;
- for (unsigned i = 0; i < set1.size(); i++)
- for (unsigned j = 0; j < set2.size(); j++)
- if (set1[i] == set2[j])
- conjVec.push_back(set1[i]);
- return conjVec;
-
-}
-
-/*
- return the result of subtracting set2 from set1
- (set1 -set2)
-*/
-ModuloSchedGraph::NodeVec
-ModuloSchedGraph::vectorSub(NodeVec set1,
- NodeVec set2){
+ //Get Machine target information for calculating delay
+ const TargetInstrInfo &MTI = Target.getInstrInfo();
- NodeVec newVec;
- for (NodeVec::iterator I = set1.begin(); I != set1.end(); I++) {
-
- bool inset = false;
- for (NodeVec::iterator II = set2.begin(); II != set2.end(); II++)
- if ((*I)->getNodeId() == (*II)->getNodeId()) {
- inset = true;
- break;
- }
-
- if (!inset)
- newVec.push_back(*I);
+ //Loop over instruction in BB and gather dependencies
+ for(BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I != E; ++I) {
- }
-
- return newVec;
-
-}
-
-/*
- order all nodes in the basicblock
- based on the sets information and node property
-
- output: ordered nodes are stored in oNodes
-*/
-
-void ModuloSchedGraph::orderNodes() {
- oNodes.clear();
-
- std::vector < ModuloSchedGraphNode * >set;
- unsigned numNodes = bb->size();
-
- // first order all the sets
- int j = -1;
- int totalDelay = -1;
- int preDelay = -1;
- while (circuits[++j][0] != 0) {
- int k = -1;
- preDelay = totalDelay;
-
- while (circuits[j][++k] != 0) {
- ModuloSchedGraphNode *node = getNode(circuits[j][k]);
- unsigned nextNodeId;
- nextNodeId =
- circuits[j][k + 1] != 0 ? circuits[j][k + 1] : circuits[j][0];
- SchedGraphEdge *edge = getMaxDelayEdge(circuits[j][k], nextNodeId);
- totalDelay += edge->getMinDelay();
- }
- if (preDelay != -1 && totalDelay > preDelay) {
- // swap circuits[j][] and cuicuits[j-1][]
- unsigned temp[MAXNODE];
- for (int k = 0; k < MAXNODE; k++) {
- temp[k] = circuits[j - 1][k];
- circuits[j - 1][k] = circuits[j][k];
- circuits[j][k] = temp[k];
- }
- //restart
- j = -1;
- }
- }
-
-
- // build the first set
- int backEdgeSrc;
- int backEdgeSink;
- if (ModuloScheduling::printScheduleProcess())
- DEBUG_PRINT(std::cerr << "building the first set" << "\n");
- int setSeq = -1;
- int k = -1;
- setSeq++;
- while (circuits[setSeq][++k] != 0)
- set.push_back(getNode(circuits[setSeq][k]));
- if (circuits[setSeq][0] != 0) {
- backEdgeSrc = circuits[setSeq][k - 1];
- backEdgeSink = circuits[setSeq][0];
- }
- if (ModuloScheduling::printScheduleProcess()) {
- DEBUG_PRINT(std::cerr << "the first set is:");
- dumpSet(set);
- }
-
- // implement the ordering algorithm
- enum OrderSeq { bottom_up, top_down };
- OrderSeq order;
- std::vector R;
- while (!set.empty()) {
- std::vector pset = predSet(oNodes);
- std::vector sset = succSet(oNodes);
-
- if (!pset.empty() && !vectorConj(pset, set).empty()) {
- R = vectorConj(pset, set);
- order = bottom_up;
- } else if (!sset.empty() && !vectorConj(sset, set).empty()) {
- R = vectorConj(sset, set);
- order = top_down;
- } else {
- int maxASAP = -1;
- int position = -1;
- for (unsigned i = 0; i < set.size(); i++) {
- int temp = set[i]->getASAP();
- if (temp > maxASAP) {
- maxASAP = temp;
- position = i;
- }
- }
- R.push_back(set[position]);
- order = bottom_up;
- }
-
- while (!R.empty()) {
- if (order == top_down) {
- if (ModuloScheduling::printScheduleProcess())
- DEBUG_PRINT(std::cerr << "in top_down round\n");
- while (!R.empty()) {
- int maxHeight = -1;
- NodeVec::iterator chosenI;
- for (NodeVec::iterator I = R.begin(); I != R.end(); I++) {
- int temp = (*I)->height;
- if ((temp > maxHeight)
- || (temp == maxHeight && (*I)->mov <= (*chosenI)->mov)) {
-
- if ((temp > maxHeight)
- || (temp == maxHeight && (*I)->mov < (*chosenI)->mov)) {
- maxHeight = temp;
- chosenI = I;
- continue;
- }
-
- //possible case: instruction A and B has the same height and mov,
- //but A has dependence to B e.g B is the branch instruction in the
- //end, or A is the phi instruction at the beginning
- if ((*I)->mov == (*chosenI)->mov)
- for (ModuloSchedGraphNode::const_iterator oe =
- (*I)->beginOutEdges(), end = (*I)->endOutEdges();
- oe != end; oe++) {
- if ((*oe)->getSink() == (*chosenI)) {
- maxHeight = temp;
- chosenI = I;
- continue;
- }
- }
- }
- }
-
- ModuloSchedGraphNode *mu = *chosenI;
- oNodes.push_back(mu);
- R.erase(chosenI);
- std::vector succ_mu =
- succSet(mu, backEdgeSrc, backEdgeSink);
- std::vector comm =
- vectorConj(succ_mu, set);
- comm = vectorSub(comm, oNodes);
- R = vectorUnion(comm, R);
- }
- order = bottom_up;
- R = vectorConj(predSet(oNodes), set);
- } else {
- if (ModuloScheduling::printScheduleProcess())
- DEBUG_PRINT(std::cerr << "in bottom up round\n");
- while (!R.empty()) {
- int maxDepth = -1;
- NodeVec::iterator chosenI;
- for (NodeVec::iterator I = R.begin(); I != R.end(); I++) {
- int temp = (*I)->depth;
- if ((temp > maxDepth)
- || (temp == maxDepth && (*I)->mov < (*chosenI)->mov)) {
- maxDepth = temp;
- chosenI = I;
- }
- }
- ModuloSchedGraphNode *mu = *chosenI;
- oNodes.push_back(mu);
- R.erase(chosenI);
- std::vector pred_mu =
- predSet(mu, backEdgeSrc, backEdgeSink);
- std::vector comm =
- vectorConj(pred_mu, set);
- comm = vectorSub(comm, oNodes);
- R = vectorUnion(comm, R);
- }
- order = top_down;
- R = vectorConj(succSet(oNodes), set);
- }
- }
- if (ModuloScheduling::printScheduleProcess()) {
- DEBUG_PRINT(std::cerr << "order finished\n");
- DEBUG_PRINT(std::cerr << "dumping the ordered nodes:\n");
- dumpSet(oNodes);
- dumpCircuits();
- }
-
- //create a new set
- //FIXME: the nodes between onodes and this circuit should also be include in
- //this set
- if (ModuloScheduling::printScheduleProcess())
- DEBUG_PRINT(std::cerr << "building the next set\n");
- set.clear();
- int k = -1;
- setSeq++;
- while (circuits[setSeq][++k] != 0)
- set.push_back(getNode(circuits[setSeq][k]));
- if (circuits[setSeq][0] != 0) {
- backEdgeSrc = circuits[setSeq][k - 1];
- backEdgeSink = circuits[setSeq][0];
- }
-
- if (set.empty()) {
- //no circuits any more
- //collect all other nodes
- if (ModuloScheduling::printScheduleProcess())
- DEBUG_PRINT(std::cerr << "no circuits any more, collect the rest nodes\n");
- for (unsigned i = 2; i < numNodes + 2; i++) {
- bool inset = false;
- for (unsigned j = 0; j < oNodes.size(); j++)
- if (oNodes[j]->getNodeId() == i) {
- inset = true;
- break;
- }
- if (!inset)
- set.push_back(getNode(i));
+ //Ignore instructions of the void type
+ if(I->getType() != Type::VoidTy) {
+
+ //Iterate over def-use chain and add true dependencies
+ for (Value::use_const_iterator U = I->use_begin(), e = I->use_end(); U != e;
+ ++U) {
+ if (Instruction *Inst = dyn_cast(*U)) {
+ //Check if a node already exists for this instruction
+ ModuloSchedGraph::iterator Sink = find(Inst);
+
+ //If the instruction is in our graph, add appropriate edges
+ if(Sink->second != NULL) {
+ //assert if self loop
+ assert(&*I == Sink->first && "Use edge to itself!");
+
+ //Create edge and set delay equal to node latency
+ //FIXME: Is it safe to do this?
+ ModuloSchedGraph::iterator Src = find(I);
+ SchedGraphEdge *trueDep = new SchedGraphEdge(&*Src->second ,&*Sink->second, &*I,
+ SchedGraphEdge::TrueDep,
+ Src->second->getLatency());
+ //Determine the iteration difference
+ //FIXME: Will this ever happen?
+ }
+ }
}
}
- if (ModuloScheduling::printScheduleProcess()) {
- DEBUG_PRINT(std::cerr << "next set is:\n");
- dumpSet(set);
- }
- }
-
-}
-
-
-
-/*
-
- build graph for instructions in this basic block
-
-*/
-void ModuloSchedGraph::buildGraph(const TargetMachine & target)
-{
-
- assert(this->bb && "The basicBlock is NULL?");
-
- // Make a dummy root node. We'll add edges to the real roots later.
- graphRoot = new ModuloSchedGraphNode(0, NULL, NULL, -1, target);
- graphLeaf = new ModuloSchedGraphNode(1, NULL, NULL, -1, target);
-
- if (ModuloScheduling::printScheduleProcess())
- this->dump(bb);
-
- if (isLoop(bb)) {
-
- DEBUG_PRINT(cerr << "building nodes for this BasicBlock\n");
- buildNodesforBB(target, bb);
-
- DEBUG_PRINT(cerr << "adding def-use edge to this basic block\n");
- this->addDefUseEdges(bb);
-
- DEBUG_PRINT(cerr << "adding CD edges to this basic block\n");
- this->addCDEdges(bb);
-
- DEBUG_PRINT(cerr << "adding memory edges to this basicblock\n");
- this->addMemEdges(bb);
- int ResII = this->computeResII(bb);
-
- if (ModuloScheduling::printScheduleProcess())
- DEBUG_PRINT(std::cerr << "ResII is " << ResII << "\n");
-
- int RecII = this->computeRecII(bb);
- if (ModuloScheduling::printScheduleProcess())
- DEBUG_PRINT(std::cerr << "RecII is " << RecII << "\n");
-
- this->MII = std::max(ResII, RecII);
-
- this->computeNodeProperty(bb);
- if (ModuloScheduling::printScheduleProcess())
- this->dumpNodeProperty();
-
- this->orderNodes();
-
- if (ModuloScheduling::printScheduleProcess())
- this->dump();
-
}
-}
-
-/*
- get node with nodeId
-*/
-
-ModuloSchedGraphNode *
-ModuloSchedGraph::getNode(const unsigned nodeId) const{
- for (const_iterator I = begin(), E = end(); I != E; I++)
- if ((*I).second->getNodeId() == nodeId)
- return (ModuloSchedGraphNode *) (*I).second;
- return NULL;
}
-/*
- compute RecurrenceII
-*/
-
-int
-ModuloSchedGraph::computeRecII(const BasicBlock *bb){
-
- int RecII = 0;
-
+void ModuloSchedGraph::ASAP() {
- //FIXME: only deal with circuits starting at the first node: the phi node
- //nodeId=2;
-
- //search all elementary circuits in the dependence graph
- //assume maximum number of nodes is MAXNODE
-
- unsigned path[MAXNODE];
- unsigned stack[MAXNODE][MAXNODE];
-
- for (int j = 0; j < MAXNODE; j++) {
- path[j] = 0;
- for (int k = 0; k < MAXNODE; k++)
- stack[j][k] = 0;
- }
-
- //in our graph, the node number starts at 2
- const unsigned numNodes = bb->size();
-
- int i = 0;
- path[i] = 2;
-
- ModuloSchedGraphNode *initNode = getNode(path[0]);
- unsigned initNodeId = initNode->getNodeId();
- ModuloSchedGraphNode *currentNode = initNode;
-
- while (currentNode != NULL) {
- unsigned currentNodeId = currentNode->getNodeId();
- // DEBUG_PRINT(std::cerr<<"current node is "<beginOutEdges(), E = currentNode->endOutEdges();
- I != E; I++) {
- //DEBUG_PRINT(std::cerr <<" searching in outgoint edges of node
- //"<getSink()->getNodeId();
- bool inpath = false, instack = false;
- int k;
-
- //DEBUG_PRINT(std::cerr<<"nodeId is "< currentNodeId && !inpath && !instack) {
- nextNode =
- (ModuloSchedGraphNode *) ((SchedGraphEdge *) * I)->getSink();
- break;
- }
- }
-
- if (nextNode != NULL) {
- //DEBUG_PRINT(std::cerr<<"find the next Node "<getNodeId()<<"\n");
-
- int j = 0;
- while (stack[i][j] != 0)
- j++;
- stack[i][j] = nextNode->getNodeId();
-
- i++;
- path[i] = nextNode->getNodeId();
- currentNode = nextNode;
- } else {
- //DEBUG_PRINT(std::cerr<<"no expansion any more"<<"\n");
- //confirmCircuit();
- for (ModuloSchedGraphNode::const_iterator I =
- currentNode->beginOutEdges(), E = currentNode->endOutEdges();
- I != E; I++) {
- unsigned nodeId = ((SchedGraphEdge *) * I)->getSink()->getNodeId();
- if (nodeId == initNodeId) {
-
- int j = -1;
- while (circuits[++j][0] != 0);
- for (int k = 0; k < MAXNODE; k++)
- circuits[j][k] = path[k];
-
- }
- }
- //remove this node in the path and clear the corresponding entries in the
- //stack
- path[i] = 0;
- int j = 0;
- for (j = 0; j < MAXNODE; j++)
- stack[i][j] = 0;
- i--;
- currentNode = getNode(path[i]);
- }
- if (i == 0) {
-
- if (ModuloScheduling::printScheduleProcess())
- DEBUG_PRINT(std::cerr << "circuits found are:\n");
- int j = -1;
- while (circuits[++j][0] != 0) {
- int k = -1;
- while (circuits[j][++k] != 0)
- if (ModuloScheduling::printScheduleProcess())
- DEBUG_PRINT(std::cerr << circuits[j][k] << "\t");
- if (ModuloScheduling::printScheduleProcess())
- DEBUG_PRINT(std::cerr << "\n");
-
- //for this circuit, compute the sum of all edge delay
- int sumDelay = 0;
- k = -1;
- while (circuits[j][++k] != 0) {
- //ModuloSchedGraphNode* node =getNode(circuits[j][k]);
- unsigned nextNodeId;
- nextNodeId =
- circuits[j][k + 1] !=
- 0 ? circuits[j][k + 1] : circuits[j][0];
-
- sumDelay +=
- getMaxDelayEdge(circuits[j][k], nextNodeId)->getMinDelay();
-
- }
- // assume we have distance 1, in this case the sumDelay is RecII
- // this is correct for SSA form only
- //
- if (ModuloScheduling::printScheduleProcess())
- DEBUG_PRINT(std::cerr << "The total Delay in the circuit is " << sumDelay
- << "\n");
-
- RecII = RecII > sumDelay ? RecII : sumDelay;
-
- }
- return RecII;
- }
-
- }
-
- return -1;
-}
-
-/*
- update resource usage vector (ruVec)
-*/
-void
-ModuloSchedGraph::addResourceUsage(std::vector > &ruVec,
- int rid){
-
- bool alreadyExists = false;
- for (unsigned i = 0; i < ruVec.size(); i++) {
- if (rid == ruVec[i].first) {
- ruVec[i].second++;
- alreadyExists = true;
- break;
- }
- }
- if (!alreadyExists)
- ruVec.push_back(std::make_pair(rid, 1));
}
-/*
- dump the resource usage vector
-*/
+void ModuloSchedGraph::ALAP() {
-void
-ModuloSchedGraph::dumpResourceUsage(std::vector > &ru){
- TargetSchedInfo & msi = (TargetSchedInfo &) target.getSchedInfo();
-
- std::vector > resourceNumVector = msi.resourceNumVector;
- DEBUG_PRINT(std::cerr << "resourceID\t" << "resourceNum\n");
- for (unsigned i = 0; i < resourceNumVector.size(); i++)
- DEBUG_PRINT(std::cerr << resourceNumVector[i].
- first << "\t" << resourceNumVector[i].second << "\n");
-
- DEBUG_PRINT(std::cerr << " maxNumIssueTotal(issue slot in one cycle) = " << msi.
- maxNumIssueTotal << "\n");
- DEBUG_PRINT(std::cerr << "resourceID\t resourceUsage\t ResourceNum\n");
- for (unsigned i = 0; i < ru.size(); i++) {
- DEBUG_PRINT(std::cerr << ru[i].first << "\t" << ru[i].second);
- const unsigned resNum = msi.getCPUResourceNum(ru[i].first);
- DEBUG_PRINT(std::cerr << "\t" << resNum << "\n");
-
- }
}
-/*
- compute thre resource restriction II
-*/
+void ModuloSchedGraph::MOB() {
-int
-ModuloSchedGraph::computeResII(const BasicBlock * bb){
-
- const TargetInstrInfo & mii = target.getInstrInfo();
- const TargetSchedInfo & msi = target.getSchedInfo();
-
- int ResII;
- std::vector > resourceUsage;
-
- for (BasicBlock::const_iterator I = bb->begin(), E = bb->end(); I != E;
- I++) {
- if (ModuloScheduling::printScheduleProcess()) {
- DEBUG_PRINT(std::cerr << "machine instruction for llvm instruction( node " <<
- getGraphNodeForInst(I)->getNodeId() << ")\n");
- DEBUG_PRINT(std::cerr << "\t" << *I);
- }
- MachineCodeForInstruction & tempMvec =
- MachineCodeForInstruction::get(I);
- if (ModuloScheduling::printScheduleProcess())
- DEBUG_PRINT(std::cerr << "size =" << tempMvec.size() << "\n");
- for (unsigned i = 0; i < tempMvec.size(); i++) {
- MachineInstr *minstr = tempMvec[i];
-
- unsigned minDelay = mii.minLatency(minstr->getOpCode());
- InstrRUsage rUsage = msi.getInstrRUsage(minstr->getOpCode());
- InstrClassRUsage classRUsage =
- msi.getClassRUsage(mii.getSchedClass(minstr->getOpCode()));
- unsigned totCycles = classRUsage.totCycles;
-
- std::vector > resources=rUsage.resourcesByCycle;
- assert(totCycles == resources.size());
- if (ModuloScheduling::printScheduleProcess())
- DEBUG_PRINT(std::cerr << "resources Usage for this Instr(totCycles="
- << totCycles << ",mindLatency="
- << mii.minLatency(minstr->getOpCode()) << "): " << *minstr
- << "\n");
- for (unsigned j = 0; j < resources.size(); j++) {
- if (ModuloScheduling::printScheduleProcess())
- DEBUG_PRINT(std::cerr << "cycle " << j << ": ");
- for (unsigned k = 0; k < resources[j].size(); k++) {
- if (ModuloScheduling::printScheduleProcess())
- DEBUG_PRINT(std::cerr << "\t" << resources[j][k]);
- addResourceUsage(resourceUsage, resources[j][k]);
- }
- if (ModuloScheduling::printScheduleProcess())
- DEBUG_PRINT(std::cerr << "\n");
- }
- }
- }
- if (ModuloScheduling::printScheduleProcess())
- this->dumpResourceUsage(resourceUsage);
-
- //compute ResII
- ResII = 0;
- int issueSlots = msi.maxNumIssueTotal;
- for (unsigned i = 0; i < resourceUsage.size(); i++) {
- int resourceNum = msi.getCPUResourceNum(resourceUsage[i].first);
- int useNum = resourceUsage[i].second;
- double tempII;
- if (resourceNum <= issueSlots)
- tempII = ceil(1.0 * useNum / resourceNum);
- else
- tempII = ceil(1.0 * useNum / issueSlots);
- ResII = std::max((int) tempII, ResII);
- }
- return ResII;
}
+void ModuloSchedGraph::ComputeDepth() {
-
-/*
- dump the basicblock
-*/
-
-void
-ModuloSchedGraph::dump(const BasicBlock * bb){
-
- DEBUG_PRINT(std::cerr << "dumping basic block:");
- DEBUG_PRINT(std::cerr << (bb->hasName()? bb->getName() : "block")
- << " (" << bb << ")" << "\n");
-
-}
-
-/*
- dump the basicblock to ostream os
-*/
-
-void
-ModuloSchedGraph::dump(const BasicBlock * bb, std::ostream & os){
-
- os << "dumping basic block:";
- os << (bb->hasName()? bb->getName() : "block")
- << " (" << bb << ")" << "\n";
}
-/*
- dump the graph
-*/
-
-void ModuloSchedGraph::dump() const
-{
- DEBUG_PRINT(std::cerr << " ModuloSchedGraph for basic Blocks:");
-
- DEBUG_PRINT(std::cerr << (bb->hasName()? bb->getName() : "block")
- << " (" << bb << ")" << "");
-
- DEBUG_PRINT(std::cerr << "\n\n Actual Root nodes : ");
- for (unsigned i = 0, N = graphRoot->outEdges.size(); i < N; i++)
- DEBUG_PRINT(std::cerr << graphRoot->outEdges[i]->getSink()->getNodeId()
- << ((i == N - 1) ? "" : ", "));
-
- DEBUG_PRINT(std::cerr << "\n Graph Nodes:\n");
-
- unsigned numNodes = bb->size();
- for (unsigned i = 2; i < numNodes + 2; i++) {
- ModuloSchedGraphNode *node = getNode(i);
- DEBUG_PRINT(std::cerr << "\n" << *node);
- }
+void ModuloSchedGraph::ComputeHeight() {
- DEBUG_PRINT(std::cerr << "\n");
}
-
-/*
- dump all node property
-*/
-
-void ModuloSchedGraph::dumpNodeProperty() const
-{
-
- unsigned numNodes = bb->size();
- for (unsigned i = 2; i < numNodes + 2; i++) {
- ModuloSchedGraphNode *node = getNode(i);
- DEBUG_PRINT(std::cerr << "NodeId " << node->getNodeId() << "\t");
- DEBUG_PRINT(std::cerr << "ASAP " << node->getASAP() << "\t");
- DEBUG_PRINT(std::cerr << "ALAP " << node->getALAP() << "\t");
- DEBUG_PRINT(std::cerr << "mov " << node->getMov() << "\t");
- DEBUG_PRINT(std::cerr << "depth " << node->getDepth() << "\t");
- DEBUG_PRINT(std::cerr << "height " << node->getHeight() << "\t\n");
- }
+void ModuloSchedGraphSet::addGraph(ModuloSchedGraph *graph) {
+ assert(graph!=NULL && "Graph for BasicBlock is null");
+ Graphs.push_back(graph);
}
+ModuloSchedGraphSet::ModuloSchedGraphSet(const Function *F,
+ const TargetMachine &targ)
+ : function(F) {
-
-/************member functions for ModuloSchedGraphSet**************/
-
-/*
- constructor
-*/
-
-ModuloSchedGraphSet::ModuloSchedGraphSet(const Function *function,
- const TargetMachine &target)
-: method(function){
-
- buildGraphsForMethod(method, target);
-
+ //Create graph for each BB in this function
+ for (Function::const_iterator BI = F->begin(); BI != F->end(); ++BI)
+ addGraph(new ModuloSchedGraph(BI, targ));
}
-/*
- destructor
-*/
-
-
ModuloSchedGraphSet::~ModuloSchedGraphSet(){
//delete all the graphs
- for (iterator I = begin(), E = end(); I != E; ++I)
- delete *I;
}
-
-
-/*
- build graph for each basicblock in this method
-*/
-
-void
-ModuloSchedGraphSet::buildGraphsForMethod(const Function *F,
- const TargetMachine &target){
-
- for (Function::const_iterator BI = F->begin(); BI != F->end(); ++BI){
- const BasicBlock* local_bb;
-
- local_bb=BI;
- addGraph(new ModuloSchedGraph((BasicBlock*)local_bb, target));
- }
-
-}
-
-/*
- dump the graph set
-*/
-
-void
-ModuloSchedGraphSet::dump() const{
-
- DEBUG_PRINT(std::cerr << " ====== ModuloSched graphs for function `" <<
- method->getName() << "' =========\n\n");
- for (const_iterator I = begin(); I != end(); ++I)
- (*I)->dump();
-
- DEBUG_PRINT(std::cerr << "\n=========End graphs for function `" << method->getName()
- << "' ==========\n\n");
-}
-
-
-
-
-/********************misc functions***************************/
-
-
-/*
- dump the input basic block
-*/
-
-static void
-dumpBasicBlock(const BasicBlock * bb){
-
- DEBUG_PRINT(std::cerr << "dumping basic block:");
- DEBUG_PRINT(std::cerr << (bb->hasName()? bb->getName() : "block")
- << " (" << bb << ")" << "\n");
-}
-
-/*
- dump the input node
-*/
-
-std::ostream& operator<<(std::ostream &os,
- const ModuloSchedGraphNode &node)
-{
- os << std::string(8, ' ')
- << "Node " << node.nodeId << " : "
- << "latency = " << node.latency << "\n" << std::string(12, ' ');
-
- if (node.getInst() == NULL)
- os << "(Dummy node)\n";
- else {
- os << *node.getInst() << "\n" << std::string(12, ' ');
- os << node.inEdges.size() << " Incoming Edges:\n";
- for (unsigned i = 0, N = node.inEdges.size(); i < N; i++)
- os << std::string(16, ' ') << *node.inEdges[i];
-
- os << std::string(12, ' ') << node.outEdges.size()
- << " Outgoing Edges:\n";
- for (unsigned i = 0, N = node.outEdges.size(); i < N; i++)
- os << std::string(16, ' ') << *node.outEdges[i];
- }
-
- return os;
-}
Index: llvm/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.h
diff -u llvm/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.h:1.9 llvm/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.h:1.10
--- llvm/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.h:1.9 Sat Jul 26 18:01:04 2003
+++ llvm/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.h Thu Aug 28 12:12:14 2003
@@ -1,367 +1,101 @@
//===- ModuloSchedGraph.h - Modulo Scheduling Graph and Set -*- C++ -*-----===//
-//
-// This header defines the primative classes that make up a data structure
-// graph.
+//
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CODEGEN_MODULO_SCHED_GRAPH_H
-#define LLVM_CODEGEN_MODULO_SCHED_GRAPH_H
+#ifndef LLVM_MODULO_SCHED_GRAPH_H
+#define LLVM_MODULO_SCHED_GRAPH_H
#include "llvm/Instruction.h"
+#include "llvm/CodeGen/SchedGraphCommon.h"
#include "llvm/Target/TargetMachine.h"
-#include "llvm/Target/TargetInstrInfo.h"
-#include "Support/GraphTraits.h"
+#include "llvm/BasicBlock.h"
+#include "llvm/Function.h"
#include "Support/hash_map"
-#include "../InstrSched/SchedGraphCommon.h"
-#include
+#include
-//===----------------------------------------------------------------------===//
-// ModuloSchedGraphNode - Implement a data structure based on the
-// SchedGraphNodeCommon this class stores informtion needed later to order the
-// nodes in modulo scheduling
-//
-class ModuloSchedGraphNode:public SchedGraphNodeCommon {
-private:
- // the corresponding instruction
- const Instruction *inst;
-
- // whether this node's property(ASAP,ALAP, ...) has been computed
- bool propertyComputed;
-
- // ASAP: the earliest time the node could be scheduled
- // ALAP: the latest time the node couldbe scheduled
- // depth: the depth of the node
- // height: the height of the node
- // mov: the mobility function, computed as ALAP - ASAP
- // scheTime: the scheduled time if this node has been scheduled
- // earlyStart: the earliest time to be tried to schedule the node
- // lateStart: the latest time to be tried to schedule the node
- int ASAP, ALAP, depth, height, mov;
- int schTime;
- int earlyStart, lateStart;
-public:
+class ModuloSchedGraphNode : public SchedGraphNodeCommon {
- //get the instruction
- const Instruction *getInst() const {
- return inst;
- }
- //get the instruction op-code name
- const char *getInstOpcodeName() const {
- return inst->getOpcodeName();
- }
- //get the instruction op-code
- const unsigned getInstOpcode() const {
- return inst->getOpcode();
- }
-
- //return whether the node is NULL
- bool isNullNode() const {
- return (inst == NULL);
- }
- //return whether the property of the node has been computed
- bool getPropertyComputed() {
- return propertyComputed;
- }
- //set the propertyComputed
- void setPropertyComputed(bool _propertyComputed) {
- propertyComputed = _propertyComputed;
- }
-
- //get the corresponding property
- int getASAP() {
- return ASAP;
- }
- int getALAP() {
- return ALAP;
- }
- int getMov() {
- return mov;
- }
- int getDepth() {
- return depth;
- }
- int getHeight() {
- return height;
- }
- int getSchTime() {
- return schTime;
- }
- int getEarlyStart() {
- return earlyStart;
- }
- int getLateStart() {
- return lateStart;
- }
- void setEarlyStart(int _earlyStart) {
- earlyStart = _earlyStart;
- }
- void setLateStart(int _lateStart) {
- lateStart = _lateStart;
- }
- void setSchTime(int _time) {
- schTime = _time;
- }
-
-private:
- friend class ModuloSchedGraph;
- friend class SchedGraphNode;
-
- //constructor:
- //nodeId: the node id, unique within the each BasicBlock
- //_bb: which BasicBlock the corresponding instruction belongs to
- //_inst: the corresponding instruction
- //indexInBB: the corresponding instruction's index in the BasicBlock
- //target: the targetMachine
- ModuloSchedGraphNode(unsigned int _nodeId,
- const BasicBlock * _bb,
- const Instruction * _inst,
- int indexInBB, const TargetMachine &target);
-
-
- friend std::ostream & operator<<(std::ostream & os,
- const ModuloSchedGraphNode & edge);
-
-};
-
-//FIXME: these two value should not be used
-#define MAXNODE 100
-#define MAXCC 100
-
-//===----------------------------------------------------------------------===//
-/// ModuloSchedGraph- the data structure to store dependence between nodes
-/// it catches data dependence and constrol dependence
-///
-class ModuloSchedGraph :
- public SchedGraphCommon,
- protected hash_map {
-
-private:
-
- BasicBlock* bb;
-
- //iteration Interval
- int MII;
-
- //target machine
- const TargetMachine & target;
-
- //the circuits in the dependence graph
- unsigned circuits[MAXCC][MAXNODE];
-
- //the order nodes
- std::vector oNodes;
-
- typedef std::vector NodeVec;
-
- //the function to compute properties
- void computeNodeASAP(const BasicBlock * in_bb);
- void computeNodeALAP(const BasicBlock * in_bb);
- void computeNodeMov(const BasicBlock * in_bb);
- void computeNodeDepth(const BasicBlock * in_bb);
- void computeNodeHeight(const BasicBlock * in_bb);
-
- //the function to compute node property
- void computeNodeProperty(const BasicBlock * in_bb);
-
- //the function to sort nodes
- void orderNodes();
-
- //add the resource usage
-void addResourceUsage(std::vector > &, int);
-
- //debug functions:
- //dump circuits
- void dumpCircuits();
- //dump the input set of nodes
- void dumpSet(std::vector set);
- //dump the input resource usage table
- void dumpResourceUsage(std::vector > &);
+ const Instruction *Inst; //Node's Instruction
+ unsigned Earliest; //ASAP, or earliest time to be scheduled
+ unsigned Latest; //ALAP, or latested time to be scheduled
+ unsigned Depth; //Max Distance from node to the root
+ unsigned Height; //Max Distance from node to leaf
+ unsigned Mobility; //MOB, number of time slots it can be scheduled
+ const TargetMachine &Target; //Target information.
public:
- //help functions
-
- //get the maxium the delay between two nodes
- SchedGraphEdge *getMaxDelayEdge(unsigned srcId, unsigned sinkId);
-
- //FIXME:
- //get the predessor Set of the set
- NodeVec predSet(NodeVec set, unsigned, unsigned);
- NodeVec predSet(NodeVec set);
-
- //get the predessor set of the node
- NodeVec predSet(ModuloSchedGraphNode *node, unsigned, unsigned);
- NodeVec predSet(ModuloSchedGraphNode *node);
-
- //get the successor set of the set
- NodeVec succSet(NodeVec set, unsigned, unsigned);
- NodeVec succSet(NodeVec set);
-
- //get the succssor set of the node
- NodeVec succSet(ModuloSchedGraphNode *node, unsigned, unsigned);
- NodeVec succSet(ModuloSchedGraphNode *node);
-
- //return the uniton of the two vectors
- NodeVec vectorUnion(NodeVec set1, NodeVec set2);
+ ModuloSchedGraphNode(unsigned ID, int index, const Instruction *inst,
+ const TargetMachine &target);
- //return the consjuction of the two vectors
- NodeVec vectorConj(NodeVec set1, NodeVec set2);
-
- //return all nodes in set1 but not set2
- NodeVec vectorSub(NodeVec set1, NodeVec set2);
-
- typedef hash_map map_base;
-
-public:
- using map_base::iterator;
- using map_base::const_iterator;
-
-public:
-
- //get target machine
- const TargetMachine & getTarget() {
- return target;
- }
-
- //get the basic block
- BasicBlock* getBasicBlock() const {
- return bb;
- }
-
-
- //get the iteration interval
- const int getMII() {
- return MII;
- }
-
- //get the ordered nodes
- const NodeVec & getONodes() {
- return oNodes;
- }
-
- //get the number of nodes (including the root and leaf)
- //note: actually root and leaf is not used
- const unsigned int getNumNodes() const {
- return size() + 2;
- }
-
- //return wether the BasicBlock 'bb' contains a loop
- bool isLoop(const BasicBlock *bb);
-
- //return the node for the input instruction
- ModuloSchedGraphNode *getGraphNodeForInst(const Instruction *inst) const {
- const_iterator onePair = this->find(inst);
- return (onePair != this->end()) ? (*onePair).second : NULL;
- }
-
- // Debugging support
- //dump the graph
- void dump() const;
-
- // dump the basicBlock
- void dump(const BasicBlock *bb);
-
- //dump the basicBlock into 'os' stream
- void dump(const BasicBlock *bb, std::ostream &os);
-
- //dump the node property
- void dumpNodeProperty() const;
+ void print(std::ostream &os) const;
+ const Instruction* getInst() { return Inst; }
+ unsigned getEarliest() { return Earliest; }
+ unsigned getLatest() { return Latest; }
+ unsigned getDepth() { return Depth; }
+ unsigned getHeight() { return Height; }
+ unsigned getMobility() { return Mobility; }
-private:
- friend class ModuloSchedGraphSet; //give access to ctor
-
-public:
- ModuloSchedGraph(BasicBlock * in_bb,
- const TargetMachine & in_target)
- :SchedGraphCommon(), bb(in_bb),target(in_target)
- {
- buildGraph(target);
- }
-
- ~ModuloSchedGraph() {
- for (const_iterator I = begin(); I != end(); ++I)
- delete I->second;
- }
-
- // Unorder iterators
- // return values are pair
- using map_base::begin;
- using map_base::end;
-
- void addHash(const Instruction *inst,
- ModuloSchedGraphNode *node){
-
- assert((*this)[inst] == NULL);
- (*this)[inst] = node;
-
- }
-
- // Graph builder
- ModuloSchedGraphNode *getNode(const unsigned nodeId) const;
-
- // Build the graph from the basicBlock
- void buildGraph(const TargetMachine &target);
-
- // Build nodes for BasicBlock
- void buildNodesforBB(const TargetMachine &target,
- const BasicBlock *bb);
-
- //find definitiona and use information for all nodes
- void findDefUseInfoAtInstr(const TargetMachine &target,
- ModuloSchedGraphNode *node,
- NodeVec &memNode,
- RegToRefVecMap ®ToRefVecMap,
- ValueToDefVecMap &valueToDefVecMap);
-
- //add def-use edge
- void addDefUseEdges(const BasicBlock *bb);
-
- //add control dependence edges
- void addCDEdges(const BasicBlock *bb);
+ void setEarliest(unsigned early) { Earliest = early; }
+ void setLatest(unsigned late) { Latest = late; }
+ void setDepth(unsigned depth) { Depth = depth; }
+ void setHeight(unsigned height) { Height = height; }
+ void setMobility(unsigned mob) { Mobility = mob; }
- //add memory dependence dges
- void addMemEdges(const BasicBlock *bb);
- //computer source restrictoin II
- int computeResII(const BasicBlock *bb);
-
- //computer recurrence II
- int computeRecII(const BasicBlock *bb);
};
-//==================================-
-// Graph set
+class ModuloSchedGraph : public SchedGraphCommon {
+
+ const BasicBlock *BB; //The Basic block this graph represents
+ const TargetMachine &Target;
+ hash_map GraphMap;
+
+ void buildNodesForBB();
+
+public:
+ typedef hash_map::iterator iterator;
+ typedef hash_map::const_iterator const_iterator;
+
+
+ ModuloSchedGraph(const BasicBlock *bb, const TargetMachine &targ);
+
+ const BasicBlock* getBB() { return BB; }
+ void setBB(BasicBlock *bb) { BB = bb; }
+ unsigned size() { return GraphMap.size(); }
+ void addNode(const Instruction *I, ModuloSchedGraphNode *node);
+ void ASAP(); //Calculate earliest schedule time for all nodes in graph.
+ void ALAP(); //Calculate latest schedule time for all nodes in graph.
+ void MOB(); //Calculate mobility for all nodes in the graph.
+ void ComputeDepth(); //Compute depth of each node in graph
+ void ComputeHeight(); //Computer height of each node in graph
+ void addDepEdges(); //Add Dependencies
+ iterator find(const Instruction *I) { return GraphMap.find(I); }
+};
-class ModuloSchedGraphSet : public std::vector {
-private:
- const Function *method;
-public:
- typedef std::vector baseVector;
- using baseVector::iterator;
- using baseVector::const_iterator;
+class ModuloSchedGraphSet {
+
+ const Function *function; //Function this set of graphs represent.
+ std::vector Graphs;
public:
- ModuloSchedGraphSet(const Function *function, const TargetMachine &target);
+ typedef std::vector::iterator iterator;
+ typedef std::vector::const_iterator const_iterator;
+
+ iterator begin() { return Graphs.begin(); }
+ iterator end() { return Graphs.end(); }
+
+ ModuloSchedGraphSet(const Function *func, const TargetMachine &target);
~ModuloSchedGraphSet();
- // Iterators
- using baseVector::begin;
- using baseVector::end;
-
- // Debugging support
+ void addGraph(ModuloSchedGraph *graph);
void dump() const;
-private:
- void addGraph(ModuloSchedGraph *graph) {
- assert(graph != NULL);
- this->push_back(graph);
- }
-
- // Graph builder
- void buildGraphsForMethod(const Function *F,
- const TargetMachine &target);
+
};
#endif
Index: llvm/lib/CodeGen/ModuloScheduling/ModuloScheduling.cpp
diff -u llvm/lib/CodeGen/ModuloScheduling/ModuloScheduling.cpp:1.10 llvm/lib/CodeGen/ModuloScheduling/ModuloScheduling.cpp:1.11
--- llvm/lib/CodeGen/ModuloScheduling/ModuloScheduling.cpp:1.10 Wed Jul 23 09:59:40 2003
+++ llvm/lib/CodeGen/ModuloScheduling/ModuloScheduling.cpp Thu Aug 28 12:12:14 2003
@@ -1,983 +1,35 @@
-//===- ModuloScheduling.cpp - Modulo Software Pipelining ------------------===//
+//===-- ModuloScheduling.cpp - Software Pipeling Approach - SMS --*- C++ -*--=//
//
-// Implements the llvm/CodeGen/ModuloScheduling.h interface
+// The is a software pipelining pass based on the Swing Modulo Scheduling
+// alogrithm (SMS).
//
//===----------------------------------------------------------------------===//
-#include "llvm/BasicBlock.h"
-#include "llvm/Constants.h"
-#include "llvm/iTerminators.h"
-#include "llvm/iPHINode.h"
-#include "llvm/CodeGen/MachineInstr.h"
-#include "llvm/CodeGen/MachineCodeForInstruction.h"
-#include "llvm/CodeGen/MachineFunction.h"
-#include "llvm/CodeGen/InstrSelection.h"
-#include "llvm/Target/TargetSchedInfo.h"
-#include "llvm/Target/TargetMachine.h"
-#include "Support/CommandLine.h"
-#include "Support/Statistic.h"
#include "ModuloSchedGraph.h"
-#include "ModuloScheduling.h"
-#include
-#include
-//************************************************************
-// printing Debug information
-// ModuloSchedDebugLevel stores the value of debug level
-// modsched_os is the ostream to dump debug information, which is written into
-// the file 'moduloSchedDebugInfo.output'
-// see ModuloSchedulingPass::runOnFunction()
-//************************************************************
+#include "llvm/Pass.h"
+#include "llvm/Function.h"
-ModuloSchedDebugLevel_t ModuloSchedDebugLevel;
-
-cl::opt
-SDL_opt("modsched", cl::Hidden, cl::location(ModuloSchedDebugLevel),
- cl::desc("enable modulo scheduling debugging information"),
- cl::values(clEnumValN(ModuloSchedDebugLevel_NoDebugInfo,
- "none", "disable debug output"),
- clEnumValN(ModuloSchedDebugLevel_PrintSchedule,
- "psched", "print original and new schedule"),
- clEnumValN(ModuloSchedDebugLevel_PrintScheduleProcess,
- "pschedproc",
- "print how the new schdule is produced"),
- 0));
-
-// Computes the schedule and inserts epilogue and prologue
-//
-void
-ModuloScheduling::instrScheduling(){
-
-
- if (ModuloScheduling::printScheduleProcess())
- DEBUG_PRINT(std::cerr << "************ computing modulo schedule ***********\n");
-
- const TargetSchedInfo & msi = target.getSchedInfo();
-
- //number of issue slots in the in each cycle
- int numIssueSlots = msi.maxNumIssueTotal;
-
- //compute the schedule
- bool success = false;
- while (!success) {
- //clear memory from the last round and initialize if necessary
- clearInitMem(msi);
-
- //compute schedule and coreSchedule with the current II
- success = computeSchedule();
-
- if (!success) {
- II++;
- if (ModuloScheduling::printScheduleProcess())
- DEBUG_PRINT(std::cerr << "increase II to " << II << "\n");
- }
- }
-
- //print the final schedule
- dumpFinalSchedule();
-
- //the schedule has been computed
- //create epilogue, prologue and kernel BasicBlock
-
- //find the successor for this BasicBlock
- BasicBlock *succ_bb = getSuccBB(bb);
-
- //print the original BasicBlock if necessary
- if (ModuloScheduling::printSchedule()) {
- DEBUG_PRINT(std::cerr << "dumping the orginal block\n");
- graph.dump(bb);
- }
- //construction of prologue, kernel and epilogue
-
- /*
- BasicBlock *kernel = bb->splitBasicBlock(bb->begin());
- BasicBlock *prologue = bb;
- BasicBlock *epilogue = kernel->splitBasicBlock(kernel->begin());
- */
-
- // Construct prologue
- /*constructPrologue(prologue);*/
-
- // Construct kernel
-
- /*constructKernel(prologue, kernel, epilogue);*/
-
- // Construct epilogue
-
- /*constructEpilogue(epilogue, succ_bb);*/
+namespace {
- //print the BasicBlocks if necessary
-// if (0){
-// DEBUG_PRINT(std::cerr << "dumping the prologue block:\n");
-// graph.dump(prologue);
-// DEBUG_PRINT(std::cerr << "dumping the kernel block\n");
-// graph.dump(kernel);
-// DEBUG_PRINT(std::cerr << "dumping the epilogue block\n");
-// graph.dump(epilogue);
-// }
-
-}
-
-
-// Clear memory from the last round and initialize if necessary
-//
-
-void
-ModuloScheduling::clearInitMem(const TargetSchedInfo & msi){
-
- unsigned numIssueSlots = msi.maxNumIssueTotal;
- // clear nodeScheduled from the last round
- if (ModuloScheduling::printScheduleProcess()) {
- DEBUG_PRINT(std::cerr << "***** new round with II= " << II << " ***********\n");
- DEBUG_PRINT(std::cerr <<
- " ************clear the vector nodeScheduled*************\n");
- }
- nodeScheduled.clear();
-
- // clear resourceTable from the last round and reset it
- resourceTable.clear();
- for (unsigned i = 0; i < II; ++i)
- resourceTable.push_back(msi.resourceNumVector);
-
- // clear the schdule and coreSchedule from the last round
- schedule.clear();
- coreSchedule.clear();
-
- // create a coreSchedule of size II*numIssueSlots
- // each entry is NULL
- while (coreSchedule.size() < II) {
- std::vector < ModuloSchedGraphNode * >*newCycle =
- new std::vector < ModuloSchedGraphNode * >();
- for (unsigned k = 0; k < numIssueSlots; ++k)
- newCycle->push_back(NULL);
- coreSchedule.push_back(*newCycle);
- }
-}
-
-// Compute schedule and coreSchedule with the current II
-//
-bool
-ModuloScheduling::computeSchedule(){
-
-
- if (ModuloScheduling::printScheduleProcess())
- DEBUG_PRINT(std::cerr << "start to compute schedule\n");
-
- // Loop over the ordered nodes
- for (NodeVec::const_iterator I = oNodes.begin(); I != oNodes.end(); ++I) {
- // Try to schedule for node I
- if (ModuloScheduling::printScheduleProcess())
- dumpScheduling();
- ModuloSchedGraphNode *node = *I;
-
- // Compute whether this node has successor(s)
- bool succ = true;
-
- // Compute whether this node has predessor(s)
- bool pred = true;
-
- NodeVec schSucc = graph.vectorConj(nodeScheduled, graph.succSet(node));
- if (schSucc.empty())
- succ = false;
- NodeVec schPred = graph.vectorConj(nodeScheduled, graph.predSet(node));
- if (schPred.empty())
- pred = false;
-
- //startTime: the earliest time we will try to schedule this node
- //endTime: the latest time we will try to schedule this node
- int startTime, endTime;
-
- //node's earlyStart: possible earliest time to schedule this node
- //node's lateStart: possible latest time to schedule this node
- node->setEarlyStart(-1);
- node->setLateStart(9999);
-
- //this node has predessor but no successor
- if (!succ && pred) {
- // This node's earlyStart is it's predessor's schedule time + the edge
- // delay - the iteration difference* II
- for (unsigned i = 0; i < schPred.size(); i++) {
- ModuloSchedGraphNode *predNode = schPred[i];
- SchedGraphEdge *edge =
- graph.getMaxDelayEdge(predNode->getNodeId(),
- node->getNodeId());
- int temp =
- predNode->getSchTime() + edge->getMinDelay() -
- edge->getIteDiff() * II;
- node->setEarlyStart(std::max(node->getEarlyStart(), temp));
- }
- startTime = node->getEarlyStart();
- endTime = node->getEarlyStart() + II - 1;
- }
- // This node has a successor but no predecessor
- if (succ && !pred) {
- for (unsigned i = 0; i < schSucc.size(); ++i) {
- ModuloSchedGraphNode *succNode = schSucc[i];
- SchedGraphEdge *edge =
- graph.getMaxDelayEdge(succNode->getNodeId(),
- node->getNodeId());
- int temp =
- succNode->getSchTime() - edge->getMinDelay() +
- edge->getIteDiff() * II;
- node->setLateStart(std::min(node->getEarlyStart(), temp));
- }
- startTime = node->getLateStart() - II + 1;
- endTime = node->getLateStart();
- }
- // This node has both successors and predecessors
- if (succ && pred) {
- for (unsigned i = 0; i < schPred.size(); ++i) {
- ModuloSchedGraphNode *predNode = schPred[i];
- SchedGraphEdge *edge =
- graph.getMaxDelayEdge(predNode->getNodeId(),
- node->getNodeId());
- int temp =
- predNode->getSchTime() + edge->getMinDelay() -
- edge->getIteDiff() * II;
- node->setEarlyStart(std::max(node->getEarlyStart(), temp));
- }
- for (unsigned i = 0; i < schSucc.size(); ++i) {
- ModuloSchedGraphNode *succNode = schSucc[i];
- SchedGraphEdge *edge =
- graph.getMaxDelayEdge(succNode->getNodeId(),
- node->getNodeId());
- int temp =
- succNode->getSchTime() - edge->getMinDelay() +
- edge->getIteDiff() * II;
- node->setLateStart(std::min(node->getEarlyStart(), temp));
- }
- startTime = node->getEarlyStart();
- endTime = std::min(node->getLateStart(),
- node->getEarlyStart() + ((int) II) - 1);
- }
- //this node has no successor or predessor
- if (!succ && !pred) {
- node->setEarlyStart(node->getASAP());
- startTime = node->getEarlyStart();
- endTime = node->getEarlyStart() + II - 1;
- }
- //try to schedule this node based on the startTime and endTime
- if (ModuloScheduling::printScheduleProcess())
- DEBUG_PRINT(std::cerr << "scheduling the node " << (*I)->getNodeId() << "\n");
-
- bool success =
- this->ScheduleNode(node, startTime, endTime, nodeScheduled);
- if (!success)
- return false;
- }
- return true;
-}
-
-
-// Get the successor of the BasicBlock
-//
-BasicBlock *
-ModuloScheduling::getSuccBB(BasicBlock *bb){
-
- BasicBlock *succ_bb;
- for (unsigned i = 0; i < II; ++i)
- for (unsigned j = 0; j < coreSchedule[i].size(); ++j)
- if (coreSchedule[i][j]) {
- const Instruction *ist = coreSchedule[i][j]->getInst();
-
- //we can get successor from the BranchInst instruction
- //assume we only have one successor (besides itself) here
- if (BranchInst::classof(ist)) {
- BranchInst *bi = (BranchInst *) ist;
- assert(bi->isConditional() &&
- "the branchInst is not a conditional one");
- assert(bi->getNumSuccessors() == 2
- && " more than two successors?");
- BasicBlock *bb1 = bi->getSuccessor(0);
- BasicBlock *bb2 = bi->getSuccessor(1);
- assert((bb1 == bb || bb2 == bb) &&
- " None of its successors is itself?");
- if (bb1 == bb)
- succ_bb = bb2;
- else
- succ_bb = bb1;
- return succ_bb;
- }
- }
- assert(0 && "NO Successor?");
- return NULL;
-}
-
-
-// Get the predecessor of the BasicBlock
-//
-BasicBlock *
-ModuloScheduling::getPredBB(BasicBlock *bb){
-
- BasicBlock *pred_bb;
- for (unsigned i = 0; i < II; ++i)
- for (unsigned j = 0; j < coreSchedule[i].size(); ++j)
- if (coreSchedule[i][j]) {
- const Instruction *ist = coreSchedule[i][j]->getInst();
-
- //we can get predecessor from the PHINode instruction
- //assume we only have one predecessor (besides itself) here
- if (PHINode::classof(ist)) {
- PHINode *phi = (PHINode *) ist;
- assert(phi->getNumIncomingValues() == 2 &&
- " the number of incoming value is not equal to two? ");
- BasicBlock *bb1 = phi->getIncomingBlock(0);
- BasicBlock *bb2 = phi->getIncomingBlock(1);
- assert((bb1 == bb || bb2 == bb) &&
- " None of its predecessor is itself?");
- if (bb1 == bb)
- pred_bb = bb2;
- else
- pred_bb = bb1;
- return pred_bb;
- }
- }
- assert(0 && " no predecessor?");
- return NULL;
-}
-
-
-// Construct the prologue
-//
-void
-ModuloScheduling::constructPrologue(BasicBlock *prologue){
-
- InstListType & prologue_ist = prologue->getInstList();
- vvNodeType & tempSchedule_prologue =
- *(new std::vector >(schedule));
-
- //compute the schedule for prologue
- unsigned round = 0;
- unsigned scheduleSize = schedule.size();
- while (round < scheduleSize / II) {
- round++;
- for (unsigned i = 0; i < scheduleSize; ++i) {
- if (round * II + i >= scheduleSize)
- break;
- for (unsigned j = 0; j < schedule[i].size(); ++j) {
- if (schedule[i][j]) {
- assert(tempSchedule_prologue[round * II + i][j] == NULL &&
- "table not consitent with core table");
- // move the schedule one iteration ahead and overlap with the original
- tempSchedule_prologue[round * II + i][j] = schedule[i][j];
- }
- }
- }
- }
-
- // Clear the clone memory in the core schedule instructions
- clearCloneMemory();
-
- // Fill in the prologue
- for (unsigned i = 0; i < ceil(1.0 * scheduleSize / II - 1) * II; ++i)
- for (unsigned j = 0; j < tempSchedule_prologue[i].size(); ++j)
- if (tempSchedule_prologue[i][j]) {
-
- //get the instruction
- Instruction *orn =
- (Instruction *) tempSchedule_prologue[i][j]->getInst();
-
- //made a clone of it
- Instruction *cln = cloneInstSetMemory(orn);
-
- //insert the instruction
- prologue_ist.insert(prologue_ist.back(), cln);
-
- //if there is PHINode in the prologue, the incoming value from itself
- //should be removed because it is not a loop any longer
- if (PHINode::classof(cln)) {
- PHINode *phi = (PHINode *) cln;
- phi->removeIncomingValue(phi->getParent());
- }
- }
-}
-
-
-// Construct the kernel BasicBlock
-//
-void
-ModuloScheduling::constructKernel(BasicBlock *prologue,
- BasicBlock *kernel,
- BasicBlock *epilogue){
-
- //*************fill instructions in the kernel****************
- InstListType & kernel_ist = kernel->getInstList();
- BranchInst *brchInst;
- PHINode *phiInst, *phiCln;
-
- for (unsigned i = 0; i < coreSchedule.size(); ++i)
- for (unsigned j = 0; j < coreSchedule[i].size(); ++j)
- if (coreSchedule[i][j]) {
-
- // Take care of branch instruction differently with normal instructions
- if (BranchInst::classof(coreSchedule[i][j]->getInst())) {
- brchInst = (BranchInst *) coreSchedule[i][j]->getInst();
- continue;
- }
- // Take care of PHINode instruction differently with normal instructions
- if (PHINode::classof(coreSchedule[i][j]->getInst())) {
- phiInst = (PHINode *) coreSchedule[i][j]->getInst();
- Instruction *cln = cloneInstSetMemory(phiInst);
- kernel_ist.insert(kernel_ist.back(), cln);
- phiCln = (PHINode *) cln;
- continue;
- }
- //for normal instructions: made a clone and insert it in the kernel_ist
- Instruction *cln =
- cloneInstSetMemory((Instruction *) coreSchedule[i][j]->
- getInst());
- kernel_ist.insert(kernel_ist.back(), cln);
- }
- // The two incoming BasicBlock for PHINode is the prologue and the kernel
- // (itself)
- phiCln->setIncomingBlock(0, prologue);
- phiCln->setIncomingBlock(1, kernel);
-
- // The incoming value for the kernel (itself) is the new value which is
- // computed in the kernel
- Instruction *originalVal = (Instruction *) phiInst->getIncomingValue(1);
- phiCln->setIncomingValue(1, originalVal->getClone());
-
- // Make a clone of the branch instruction and insert it in the end
- BranchInst *cln = (BranchInst *) cloneInstSetMemory(brchInst);
- kernel_ist.insert(kernel_ist.back(), cln);
-
- // delete the unconditional branch instruction, which is generated when
- // splitting the basicBlock
- kernel_ist.erase(--kernel_ist.end());
-
- // set the first successor to itself
- cln->setSuccessor(0, kernel);
- // set the second successor to eiplogue
- cln->setSuccessor(1, epilogue);
-
- //*****change the condition*******
-
- //get the condition instruction
- Instruction *cond = (Instruction *) cln->getCondition();
-
- //get the condition's second operand, it should be a constant
- Value *operand = cond->getOperand(1);
- assert(ConstantSInt::classof(operand));
-
- //change the constant in the condtion instruction
- ConstantSInt *iteTimes =
- ConstantSInt::get(operand->getType(),
- ((ConstantSInt *) operand)->getValue() - II + 1);
- cond->setOperand(1, iteTimes);
-
-}
-
-
-// Construct the epilogue
-//
-void
-ModuloScheduling::constructEpilogue(BasicBlock *epilogue,
- BasicBlock *succ_bb){
-
- //compute the schedule for epilogue
- vvNodeType &tempSchedule_epilogue =
- *(new std::vector >(schedule));
- unsigned scheduleSize = schedule.size();
- int round = 0;
- while (round < ceil(1.0 * scheduleSize / II) - 1) {
- round++;
- for (unsigned i = 0; i < scheduleSize; i++) {
- if (i + round * II >= scheduleSize)
- break;
- for (unsigned j = 0; j < schedule[i].size(); j++)
- if (schedule[i + round * II][j]) {
- assert(tempSchedule_epilogue[i][j] == NULL
- && "table not consitant with core table");
-
- //move the schdule one iteration behind and overlap
- tempSchedule_epilogue[i][j] = schedule[i + round * II][j];
- }
- }
- }
-
- //fill in the epilogue
- InstListType & epilogue_ist = epilogue->getInstList();
- for (unsigned i = II; i < scheduleSize; i++)
- for (unsigned j = 0; j < tempSchedule_epilogue[i].size(); j++)
- if (tempSchedule_epilogue[i][j]) {
- Instruction *inst =
- (Instruction *) tempSchedule_epilogue[i][j]->getInst();
-
- //BranchInst and PHINode should be treated differently
- //BranchInst:unecessary, simly omitted
- //PHINode: omitted
- if (!BranchInst::classof(inst) && !PHINode::classof(inst)) {
- //make a clone instruction and insert it into the epilogue
- Instruction *cln = cloneInstSetMemory(inst);
- epilogue_ist.push_front(cln);
- }
- }
-
- //*************delete the original instructions****************//
- //to delete the original instructions, we have to make sure their use is zero
-
- //update original core instruction's uses, using its clone instread
- for (unsigned i = 0; i < II; i++)
- for (unsigned j = 0; j < coreSchedule[i].size(); j++) {
- if (coreSchedule[i][j])
- updateUseWithClone((Instruction *) coreSchedule[i][j]->getInst());
- }
-
- //erase these instructions
- for (unsigned i = 0; i < II; i++)
- for (unsigned j = 0; j < coreSchedule[i].size(); j++)
- if (coreSchedule[i][j]) {
- Instruction *ist = (Instruction *) coreSchedule[i][j]->getInst();
- ist->getParent()->getInstList().erase(ist);
- }
-
-
-
- //finally, insert an unconditional branch instruction at the end
- epilogue_ist.push_back(new BranchInst(succ_bb));
-
-}
-
-
-//------------------------------------------------------------------------------
-//this function replace the value(instruction) ist in other instructions with
-//its latest clone i.e. after this function is called, the ist is not used
-//anywhere and it can be erased.
-//------------------------------------------------------------------------------
-void
-ModuloScheduling::updateUseWithClone(Instruction * ist){
-
-
- while (ist->use_size() > 0) {
- bool destroyed = false;
-
- //other instruction is using this value ist
- assert(Instruction::classof(*ist->use_begin()));
- Instruction *inst = (Instruction *) (*ist->use_begin());
-
- for (unsigned i = 0; i < inst->getNumOperands(); i++)
- if (inst->getOperand(i) == ist && ist->getClone()) {
- // if the instruction is TmpInstruction, simly delete it because it has
- // no parent and it does not belongs to any BasicBlock
- if (TmpInstruction::classof(inst)) {
- delete inst;
- destroyed = true;
- break;
- }
-
- //otherwise, set the instruction's operand to the value's clone
- inst->setOperand(i, ist->getClone());
-
- //the use from the original value ist is destroyed
- destroyed = true;
- break;
- }
- if (!destroyed) {
- //if the use can not be destroyed , something is wrong
- inst->dump();
- assert(0 && "this use can not be destroyed");
- }
- }
-
-}
-
-
-//********************************************************
-//this function clear all clone mememoy
-//i.e. set all instruction's clone memory to NULL
-//*****************************************************
-void
-ModuloScheduling::clearCloneMemory(){
-
- for (unsigned i = 0; i < coreSchedule.size(); i++)
- for (unsigned j = 0; j < coreSchedule[i].size(); j++)
- if (coreSchedule[i][j])
- ((Instruction *) coreSchedule[i][j]->getInst())->clearClone();
-
-}
-
-
-//******************************************************************************
-// this function make a clone of the instruction orn the cloned instruction will
-// use the orn's operands' latest clone as its operands it is done this way
-// because LLVM is in SSA form and we should use the correct value
-//this fuction also update the instruction orn's latest clone memory
-//******************************************************************************
-Instruction *
-ModuloScheduling::cloneInstSetMemory(Instruction * orn){
-
- // make a clone instruction
- Instruction *cln = orn->clone();
-
- // update the operands
- for (unsigned k = 0; k < orn->getNumOperands(); k++) {
- const Value *op = orn->getOperand(k);
- if (Instruction::classof(op) && ((Instruction *) op)->getClone()) {
- Instruction *op_inst = (Instruction *) op;
- cln->setOperand(k, op_inst->getClone());
- }
- }
-
- // update clone memory
- orn->setClone(cln);
- return cln;
-}
-
-
-
-bool
-ModuloScheduling::ScheduleNode(ModuloSchedGraphNode * node,
- unsigned start, unsigned end,
- NodeVec & nodeScheduled){
-
- const TargetSchedInfo & msi = target.getSchedInfo();
- unsigned int numIssueSlots = msi.maxNumIssueTotal;
-
- if (ModuloScheduling::printScheduleProcess())
- DEBUG_PRINT(std::cerr << "startTime= " << start << " endTime= " << end << "\n");
- bool isScheduled = false;
- for (unsigned i = start; i <= end; i++) {
- if (ModuloScheduling::printScheduleProcess())
- DEBUG_PRINT(std::cerr << " now try cycle " << i << ":" << "\n");
- for (unsigned j = 0; j < numIssueSlots; j++) {
- unsigned int core_i = i % II;
- unsigned int core_j = j;
- if (ModuloScheduling::printScheduleProcess())
- DEBUG_PRINT(std::cerr << "\t Trying slot " << j << "...........");
- //check the resouce table, make sure there is no resource conflicts
- const Instruction *instr = node->getInst();
- MachineCodeForInstruction & tempMvec =
- MachineCodeForInstruction::get(instr);
- bool resourceConflict = false;
- const TargetInstrInfo & mii = msi.getInstrInfo();
-
- if (coreSchedule.size() < core_i + 1
- || !coreSchedule[core_i][core_j]) {
- //this->dumpResourceUsageTable();
- int latency = 0;
- for (unsigned k = 0; k < tempMvec.size(); k++) {
- MachineInstr *minstr = tempMvec[k];
- InstrRUsage rUsage = msi.getInstrRUsage(minstr->getOpCode());
- std::vector < std::vector < resourceId_t > >resources
- = rUsage.resourcesByCycle;
- updateResourceTable(resources, i + latency);
- latency += std::max(mii.minLatency(minstr->getOpCode()), 1);
- }
-
- //this->dumpResourceUsageTable();
-
- latency = 0;
- if (resourceTableNegative()) {
-
- //undo-update the resource table
- for (unsigned k = 0; k < tempMvec.size(); k++) {
- MachineInstr *minstr = tempMvec[k];
- InstrRUsage rUsage = msi.getInstrRUsage(minstr->getOpCode());
- std::vector < std::vector < resourceId_t > >resources
- = rUsage.resourcesByCycle;
- undoUpdateResourceTable(resources, i + latency);
- latency += std::max(mii.minLatency(minstr->getOpCode()), 1);
- }
- resourceConflict = true;
- }
- }
- if (!resourceConflict && !coreSchedule[core_i][core_j]) {
- if (ModuloScheduling::printScheduleProcess()) {
- DEBUG_PRINT(std::cerr << " OK!" << "\n");
- DEBUG_PRINT(std::cerr << "Node " << node->getNodeId() << " scheduled.\n");
- }
- //schedule[i][j]=node;
- while (schedule.size() <= i) {
- std::vector < ModuloSchedGraphNode * >*newCycle =
- new std::vector < ModuloSchedGraphNode * >();
- for (unsigned k = 0; k < numIssueSlots; k++)
- newCycle->push_back(NULL);
- schedule.push_back(*newCycle);
- }
- std::vector::iterator startIterator;
- startIterator = schedule[i].begin();
- schedule[i].insert(startIterator + j, node);
- startIterator = schedule[i].begin();
- schedule[i].erase(startIterator + j + 1);
-
- //update coreSchedule
- //coreSchedule[core_i][core_j]=node;
- while (coreSchedule.size() <= core_i) {
- std::vector *newCycle =
- new std::vector();
- for (unsigned k = 0; k < numIssueSlots; k++)
- newCycle->push_back(NULL);
- coreSchedule.push_back(*newCycle);
- }
-
- startIterator = coreSchedule[core_i].begin();
- coreSchedule[core_i].insert(startIterator + core_j, node);
- startIterator = coreSchedule[core_i].begin();
- coreSchedule[core_i].erase(startIterator + core_j + 1);
-
- node->setSchTime(i);
- isScheduled = true;
- nodeScheduled.push_back(node);
-
- break;
- } else if (coreSchedule[core_i][core_j]) {
- if (ModuloScheduling::printScheduleProcess())
- DEBUG_PRINT(std::cerr << " Slot not available\n");
- } else {
- if (ModuloScheduling::printScheduleProcess())
- DEBUG_PRINT(std::cerr << " Resource conflicts\n");
- }
- }
- if (isScheduled)
- break;
- }
- //assert(nodeScheduled &&"this node can not be scheduled?");
- return isScheduled;
-}
-
-
-void
-ModuloScheduling::updateResourceTable(Resources useResources,
- int startCycle){
-
- for (unsigned i = 0; i < useResources.size(); i++) {
- int absCycle = startCycle + i;
- int coreCycle = absCycle % II;
- std::vector > &resourceRemained =
- resourceTable[coreCycle];
- std::vector < unsigned int >&resourceUsed = useResources[i];
- for (unsigned j = 0; j < resourceUsed.size(); j++) {
- for (unsigned k = 0; k < resourceRemained.size(); k++)
- if ((int) resourceUsed[j] == resourceRemained[k].first) {
- resourceRemained[k].second--;
- }
- }
- }
-}
-
-void
-ModuloScheduling::undoUpdateResourceTable(Resources useResources,
- int startCycle){
-
- for (unsigned i = 0; i < useResources.size(); i++) {
- int absCycle = startCycle + i;
- int coreCycle = absCycle % II;
- std::vector > &resourceRemained =
- resourceTable[coreCycle];
- std::vector < unsigned int >&resourceUsed = useResources[i];
- for (unsigned j = 0; j < resourceUsed.size(); j++) {
- for (unsigned k = 0; k < resourceRemained.size(); k++)
- if ((int) resourceUsed[j] == resourceRemained[k].first) {
- resourceRemained[k].second++;
- }
- }
- }
-}
-
-
-//-----------------------------------------------------------------------
-// Function: resourceTableNegative
-// return value:
-// return false if any element in the resouceTable is negative
-// otherwise return true
-// Purpose:
-
-// this function is used to determine if an instruction is eligible for
-// schedule at certain cycle
-//-----------------------------------------------------------------------
-
-
-bool
-ModuloScheduling::resourceTableNegative(){
-
- assert(resourceTable.size() == (unsigned) II
- && "resouceTable size must be equal to II");
- bool isNegative = false;
- for (unsigned i = 0; i < resourceTable.size(); i++)
- for (unsigned j = 0; j < resourceTable[i].size(); j++) {
- if (resourceTable[i][j].second < 0) {
- isNegative = true;
- break;
- }
- }
- return isNegative;
-}
-
-
-//----------------------------------------------------------------------
-// Function: dumpResouceUsageTable
-// Purpose:
-// print out ResouceTable for debug
-//
-//------------------------------------------------------------------------
-
-void
-ModuloScheduling::dumpResourceUsageTable(){
-
- DEBUG_PRINT(std::cerr << "dumping resource usage table\n");
- for (unsigned i = 0; i < resourceTable.size(); i++) {
- for (unsigned j = 0; j < resourceTable[i].size(); j++)
- DEBUG_PRINT(std::cerr << resourceTable[i][j].first
- << ":" << resourceTable[i][j].second << " ");
- DEBUG_PRINT(std::cerr << "\n");
- }
-
-}
-
-//----------------------------------------------------------------------
-//Function: dumpSchedule
-//Purpose:
-// print out thisSchedule for debug
-//
-//-----------------------------------------------------------------------
-void
-ModuloScheduling::dumpSchedule(vvNodeType thisSchedule){
-
- const TargetSchedInfo & msi = target.getSchedInfo();
- unsigned numIssueSlots = msi.maxNumIssueTotal;
- for (unsigned i = 0; i < numIssueSlots; i++)
- DEBUG_PRINT(std::cerr << "\t#");
- DEBUG_PRINT(std::cerr << "\n");
- for (unsigned i = 0; i < thisSchedule.size(); i++) {
- DEBUG_PRINT(std::cerr << "cycle" << i << ": ");
- for (unsigned j = 0; j < thisSchedule[i].size(); j++)
- if (thisSchedule[i][j] != NULL)
- DEBUG_PRINT(std::cerr << thisSchedule[i][j]->getNodeId() << "\t");
- else
- DEBUG_PRINT(std::cerr << "\t");
- DEBUG_PRINT(std::cerr << "\n");
- }
-}
-
-
-//----------------------------------------------------
-//Function: dumpScheduling
-//Purpose:
-// print out the schedule and coreSchedule for debug
-//
-//-------------------------------------------------------
-
-void
-ModuloScheduling::dumpScheduling(){
-
- DEBUG_PRINT(std::cerr << "dump schedule:" << "\n");
- const TargetSchedInfo & msi = target.getSchedInfo();
- unsigned numIssueSlots = msi.maxNumIssueTotal;
- for (unsigned i = 0; i < numIssueSlots; i++)
- DEBUG_PRINT(std::cerr << "\t#");
- DEBUG_PRINT(std::cerr << "\n");
- for (unsigned i = 0; i < schedule.size(); i++) {
- DEBUG_PRINT(std::cerr << "cycle" << i << ": ");
- for (unsigned j = 0; j < schedule[i].size(); j++)
- if (schedule[i][j] != NULL)
- DEBUG_PRINT(std::cerr << schedule[i][j]->getNodeId() << "\t");
- else
- DEBUG_PRINT(std::cerr << "\t");
- DEBUG_PRINT(std::cerr << "\n");
- }
-
- DEBUG_PRINT(std::cerr << "dump coreSchedule:" << "\n");
- for (unsigned i = 0; i < numIssueSlots; i++)
- DEBUG_PRINT(std::cerr << "\t#");
- DEBUG_PRINT(std::cerr << "\n");
- for (unsigned i = 0; i < coreSchedule.size(); i++) {
- DEBUG_PRINT(std::cerr << "cycle" << i << ": ");
- for (unsigned j = 0; j < coreSchedule[i].size(); j++)
- if (coreSchedule[i][j] != NULL)
- DEBUG_PRINT(std::cerr << coreSchedule[i][j]->getNodeId() << "\t");
- else
- DEBUG_PRINT(std::cerr << "\t");
- DEBUG_PRINT(std::cerr << "\n");
- }
-}
-
-/*
- print out final schedule
-*/
-
-void
-ModuloScheduling::dumpFinalSchedule(){
-
- std::cerr << "dump schedule:" << "\n";
- const TargetSchedInfo & msi = target.getSchedInfo();
- unsigned numIssueSlots = msi.maxNumIssueTotal;
-
- for (unsigned i = 0; i < numIssueSlots; i++)
- std::cerr << "\t#";
- std::cerr << "\n";
-
- for (unsigned i = 0; i < schedule.size(); i++) {
- std::cerr << "cycle" << i << ": ";
+ class ModuloScheduling : public FunctionPass {
- for (unsigned j = 0; j < schedule[i].size(); j++)
- if (schedule[i][j] != NULL)
- std::cerr << schedule[i][j]->getNodeId() << "\t";
- else
- std::cerr << "\t";
- std::cerr << "\n";
- }
-
- std::cerr << "dump coreSchedule:" << "\n";
- for (unsigned i = 0; i < numIssueSlots; i++)
- std::cerr << "\t#";
- std::cerr << "\n";
-
- for (unsigned i = 0; i < coreSchedule.size(); i++) {
- std::cerr << "cycle" << i << ": ";
- for (unsigned j = 0; j < coreSchedule[i].size(); j++)
- if (coreSchedule[i][j] != NULL)
- std::cerr << coreSchedule[i][j]->getNodeId() << "\t";
- else
- std::cerr << "\t";
- std::cerr << "\n";
- }
-}
-
-//---------------------------------------------------------------------------
-// Function: ModuloSchedulingPass
-//
-// Purpose:
-// Entry point for Modulo Scheduling
-// Schedules LLVM instruction
-//
-//---------------------------------------------------------------------------
-
-namespace {
- class ModuloSchedulingPass:public FunctionPass {
- const TargetMachine ⌖
-
public:
- ModuloSchedulingPass(const TargetMachine &T):target(T) {}
-
- const char *getPassName() const {
- return "Modulo Scheduling";
- }
-
- // getAnalysisUsage - We use LiveVarInfo...
- virtual void getAnalysisUsage(AnalysisUsage &AU) const {
- //AU.addRequired(FunctionLiveVarInfo::ID);
- }
-
- bool runOnFunction(Function & F);
+ virtual bool runOnFunction(Function &F);
};
-} // end anonymous namespace
+ RegisterOpt X("modulo-sched", "Modulo Scheduling/Software Pipelining");
+}
-bool
-ModuloSchedulingPass::runOnFunction(Function &F){
-
- ModuloSchedGraphSet *graphSet = new ModuloSchedGraphSet(&F, target);
-
- ModuloSchedulingSet ModuloSchedulingSet(*graphSet);
-
- DEBUG_PRINT(std::cerr<<"runOnFunction in ModuloSchedulingPass returns\n"<<"\n");
- return false;
+//Create Modulo Scheduling Pass
+Pass *createModuloSchedPass() {
+ return new ModuloScheduling();
}
+//ModuloScheduling::runOnFunction - Main transformation entry point.
+bool ModuloScheduling::runOnFunction(Function &F) {
+ bool Changed = false;
-Pass *
-createModuloSchedulingPass(const TargetMachine & tgt){
- DEBUG_PRINT(std::cerr<<"creating modulo scheduling\n");
- return new ModuloSchedulingPass(tgt);
+ return Changed;
}
+
From tbrethou at cs.uiuc.edu Thu Aug 28 12:19:02 2003
From: tbrethou at cs.uiuc.edu (Tanya Brethour)
Date: Thu Aug 28 12:19:02 2003
Subject: [llvm-commits] CVS: llvm/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.cpp README
Message-ID: <200308281718.MAA24651@tank.cs.uiuc.edu>
Changes in directory llvm/lib/CodeGen/ModuloScheduling:
ModuloSchedGraph.cpp updated: 1.11 -> 1.12
README (r1.2) removed
---
Log message:
Removing README
---
Diffs of the changes:
Index: llvm/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.cpp
diff -u llvm/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.cpp:1.11 llvm/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.cpp:1.12
--- llvm/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.cpp:1.11 Thu Aug 28 12:12:14 2003
+++ llvm/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.cpp Thu Aug 28 12:17:59 2003
@@ -71,8 +71,8 @@
//Create edge and set delay equal to node latency
//FIXME: Is it safe to do this?
ModuloSchedGraph::iterator Src = find(I);
- SchedGraphEdge *trueDep = new SchedGraphEdge(&*Src->second ,&*Sink->second, &*I,
- SchedGraphEdge::TrueDep,
+ SchedGraphEdge *trueDep = new SchedGraphEdge(&*Src->second ,&*Sink->second,
+ &*I, SchedGraphEdge::TrueDep,
Src->second->getLatency());
//Determine the iteration difference
//FIXME: Will this ever happen?
From gaeke at cs.uiuc.edu Thu Aug 28 12:40:03 2003
From: gaeke at cs.uiuc.edu (Brian Gaeke)
Date: Thu Aug 28 12:40:03 2003
Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/TraceToFunction.cpp
Message-ID: <200308281739.MAA20298@trinity.cs.uiuc.edu>
Changes in directory reopt/lib/LightWtProfiling:
TraceToFunction.cpp added (r1.1)
---
Log message:
Initial checkin of TraceToFunction converter.
---
Diffs of the changes:
Index: reopt/lib/LightWtProfiling/TraceToFunction.cpp
diff -c /dev/null reopt/lib/LightWtProfiling/TraceToFunction.cpp:1.1
*** /dev/null Thu Aug 28 12:39:14 2003
--- reopt/lib/LightWtProfiling/TraceToFunction.cpp Thu Aug 28 12:39:03 2003
***************
*** 0 ****
--- 1,484 ----
+ //===- TraceToFunction.cpp - Convert traces to functions ---------*- C++ -*--=//
+ //
+ // Repackage traces as functions.
+ //
+ //===----------------------------------------------------------------------===//
+
+ #include "Trace.h"
+ #include "llvm/Transforms/Utils/Cloning.h"
+ #include "llvm/Pass.h"
+ #include "llvm/Module.h"
+ #include "llvm/DerivedTypes.h"
+ #include "llvm/iTerminators.h"
+ #include "llvm/iPHINode.h"
+ #include "llvm/iMemory.h"
+ #include "llvm/iOther.h"
+ #include "llvm/Constants.h"
+ #include "Support/StringExtras.h" // for utostr()
+ #include "Support/Debug.h" // for DEBUG()
+ #include
+
+ typedef std::vector TypeVector;
+ typedef std::set LiveVariableSet;
+ typedef std::map ValueToIntMap;
+ typedef std::map ValueMap;
+ typedef std::map BranchNumberMap;
+
+ class TraceToFunction {
+ ValueToIntMap LiveInToParameterMap;
+ BranchNumberMap BranchNumber;
+ virtual TypeVector createFunctionArgTypeVector (PointerType *ST,
+ LiveVariableSet S);
+ virtual void fillInFunctionBody (Trace &T, Function *F, LiveVariableSet &So);
+ virtual void fixupFunctionBodyBB (Trace &T, Function *F, BasicBlock *srcB,
+ BasicBlock *dstB, ValueMap &O2CMap,
+ LiveVariableSet &So);
+ public:
+ TraceToFunction () { }
+ virtual ~TraceToFunction () { }
+ virtual Function *traceToFunction (Trace &T);
+ };
+
+ /// getTraceLiveInSet - Return the set of variables which are used in
+ /// the trace but which are not defined in the trace.
+ ///
+ static LiveVariableSet getTraceLiveInSet (Trace &T) {
+ LiveVariableSet S;
+ for (Trace::iterator TI = T.begin (), TE = T.end (); TI != TE; ++TI) {
+ BasicBlock *B = *TI;
+ // B is a basic block in the trace.
+ for (BasicBlock::iterator BI = B->begin (), BE = B->end (); BI != BE; ++BI){
+ Instruction &I = *BI;
+ // I is an instruction in B, which is in the trace.
+ for (unsigned i = 0; i < I.getNumOperands (); ++i) {
+ Value *V = I.getOperand (i);
+ // V is used in the trace by instruction I.
+ if (Instruction *VI = dyn_cast (V))
+ // V is defined by an instruction; not a constant or global.
+ if (!T.contains (VI->getParent ()))
+ // V is defined by an instruction outside the trace.
+ S.insert (V);
+ }
+ }
+ }
+ return S;
+ }
+
+ /// getTraceLiveOutSet - Return the set of variables which are defined
+ /// by an instruction inside the trace, and used in an instruction
+ /// outside the trace (but within that trace's function.)
+ ///
+ static LiveVariableSet getTraceLiveOutSet (Trace &T) {
+ LiveVariableSet S;
+ Function &F = *T.getFunction();
+ for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI) {
+ BasicBlock &B = *FI;
+ if (!T.contains (&B)) {
+ for (BasicBlock::iterator BI = B.begin(), BE = B.end(); BI != BE; ++BI) {
+ Instruction &I = *BI;
+ // I is an instruction in the trace's function, but outside the trace.
+ // Check its operands for uses of values defined in the trace.
+ for (unsigned i = 0; i < I.getNumOperands (); ++i) {
+ Value *V = I.getOperand (i);
+ // V is used outside the trace by instruction I.
+ if (Instruction *VI = dyn_cast (V))
+ // V is defined by an instruction; not a constant or global.
+ if (T.contains (VI->getParent ()))
+ // V is defined by an instruction inside the trace.
+ S.insert (V);
+ }
+ }
+ }
+ }
+ return S;
+ }
+
+ /// containsTraceExitingBranch - If B contains a branch instruction BI
+ /// that exits the trace T, returns BI. Returns NULL otherwise.
+ ///
+ static BranchInst *containsTraceExitingBranch (BasicBlock *B, Trace T) {
+ TerminatorInst *TI = B->getTerminator ();
+ assert (TI && "Only works on well-formed LLVM basic blocks w/ terminators");
+ if (BranchInst *BI = dyn_cast (TI))
+ for (unsigned i = 0; i < BI->getNumSuccessors (); ++i) {
+ BasicBlock *BIT = BI->getSuccessor (i);
+ if (!T.contains (BIT))
+ return BI;
+ }
+ return NULL;
+ }
+
+ /// createLiveOutType - Given the live-out set S of a trace, create a
+ /// pointer-to-structure type that will encapsulate all the live-outs from S.
+ ///
+ static PointerType *createLiveOutType (LiveVariableSet S) {
+ TypeVector T;
+ // For each variable in S, make a new entry in T having its type.
+ for (LiveVariableSet::iterator I = S.begin (), E = S.end (); I != E; ++I) {
+ T.push_back ((*I)->getType ());
+ }
+ return PointerType::get (StructType::get (T));
+ }
+
+ /// createFunctionArgTypeVector - Given the live-in set S of a trace,
+ /// create a parameter list containing a parameter for each of the
+ /// variables in S as well as a pointer-to-structure type PST to fill
+ /// in which contains the live-outs. As a side effect, fill in the
+ /// mapping between live-ins and parameters in the global map named
+ /// LiveInToParameterMap.
+ ///
+ TypeVector TraceToFunction::createFunctionArgTypeVector (PointerType *PST,
+ LiveVariableSet S) {
+ TypeVector P;
+ P.push_back (PST);
+
+ LiveInToParameterMap.clear ();
+ for (LiveVariableSet::iterator I = S.begin (), E = S.end (); I != E; ++I) {
+ Value *V = *I;
+ P.push_back (V->getType ());
+ LiveInToParameterMap[V] = P.size () - 1;
+ }
+ // Print out mapping of instructions to arg numbers.
+ DEBUG(for (ValueToIntMap::iterator I = LiveInToParameterMap.begin (),
+ E = LiveInToParameterMap.end (); I != E; ++I)
+ std::cerr << I->first << " is parameter " << I->second << "\n");
+ return P;
+ }
+
+ /// giveNamesToFunctionArgs - Name the first argument of F "liveOut",
+ /// then use the ordering imposed by S's iterator to name the
+ /// remaining arguments of F.
+ ///
+ static void giveNamesToFunctionArgs (LiveVariableSet S, Function *F) {
+ Function::aiterator argIterator = F->abegin ();
+ unsigned argPosition = 0;
+
+ argIterator->setName ("liveOut"); // Arg 0 is always the live-out struct.
+ ++argPosition;
+ ++argIterator;
+
+ for (LiveVariableSet::iterator I = S.begin (), E = S.end (); I != E; ++I) {
+ std::string name ((*I)->getName ());
+ if (name == "")
+ name = "arg" + utostr (argPosition);
+ argIterator->setName ("liveIn." + name);
+ ++argPosition;
+ ++argIterator;
+ }
+ }
+
+ /// numberExitBranchesInTrace - Fill in M with pairs that map each
+ /// trace-exiting branch in T to a unique nonnegative integer.
+ ///
+ static void numberExitBranchesInTrace (Trace &T, BranchNumberMap &M) {
+ int Count = M.size ();
+ for (Trace::iterator I = T.begin (), E = T.end (); I != E; ++I) {
+ BasicBlock *B = *I;
+ BranchInst *BI = containsTraceExitingBranch (B, T);
+ if (BI)
+ M[BI] = Count++;
+ }
+ }
+
+ /// getFunctionArg - Return a pointer to F's ARGNOth argument.
+ ///
+ static Argument *getFunctionArg (Function *F, unsigned argno) {
+ Function::aiterator ai = F->abegin ();
+ while (argno) { ++ai; --argno; }
+ return &*ai;
+ }
+
+ /// cloneTraceBBsIntoFunction - Copy the BasicBlocks of the trace T into
+ /// the new Function F, which should be initially empty. Correspondences
+ /// between Original instructions (in T) and their Clones (in F) are added
+ /// to O2CMap.
+ ///
+ static void cloneTraceBBsIntoFunction (Trace &T, Function *F, ValueMap &O2CMap){
+ unsigned BBCount = 0;
+ // Clone each basic block into the new function.
+ for (Trace::iterator TI = T.begin (), TE = T.end (); TI != TE; ++TI) {
+ BasicBlock *srcB = *TI;
+ // Create a new BasicBlock dstB that corresponds to srcB in T.
+ BasicBlock *dstB = CloneBasicBlock (srcB, O2CMap, ".ttf");
+ DEBUG(dstB->setName ("trace" + utostr(BBCount++)));
+ // Add dstB to F.
+ F->getBasicBlockList ().push_back (dstB);
+ // Remember the correspondence between srcB and dstB.
+ // FIXME: Should this be something that CloneBasicBlock does?
+ O2CMap[srcB] = dstB;
+ }
+ }
+
+ /// fillInFunctionBody - Clone the BBs of T into F, then do all
+ /// necessary fixups to ensure that F's new contents are internally
+ /// consistent and that the live-outs So get stored in F's first
+ /// argument.
+ ///
+ void TraceToFunction::fillInFunctionBody (Trace &T, Function *F,
+ LiveVariableSet &So) {
+ ValueMap O2CMap;
+ // First copy the basic blocks from the trace.
+ cloneTraceBBsIntoFunction (T, F, O2CMap);
+
+ numberExitBranchesInTrace (T, BranchNumber);
+
+ // Fix up the cloned basic blocks of the function so that they are
+ // internally consistent.
+ for (Trace::iterator TI = T.begin (), TE = T.end (); TI != TE; ++TI) {
+ BasicBlock *srcB = *TI;
+ assert (O2CMap[srcB] && "Can't find clone of basic block I just cloned");
+ BasicBlock *dstB = dyn_cast (O2CMap[srcB]);
+ assert (dstB && "Clone of basic block I just cloned is not a basic block");
+ fixupFunctionBodyBB (T, F, srcB, dstB, O2CMap, So);
+ }
+ }
+
+ /// fixupFunctionBodyBB - Given srcB in T and its clone dstB in F, and
+ /// the map O2CMap detailing the correspondences between values in T
+ /// and values in F, fix up dstB so that its contents are internally
+ /// consistent, and so that it stores its live-out values So in F's first
+ /// argument. (This is where all the magic gets done...)
+ ///
+ void TraceToFunction::fixupFunctionBodyBB (Trace &T, Function *F,
+ BasicBlock *srcB, BasicBlock *dstB,
+ ValueMap &O2CMap,
+ LiveVariableSet &So) {
+ // Additional special handling for trace's entry basic block:
+ // The old entry BB's clone will start with a phi, one of whose args
+ // comes from off-trace (that's the trace entry point.) We can't
+ // leave that there because the off-trace source BB is now out of
+ // the function. So create new entry basic block to serve as source
+ // for old entry's initial phi node.
+ if (srcB == T.getEntryBasicBlock ()) {
+ BasicBlock *FEntry = new BasicBlock ("entryfixup", dstB);
+ FEntry->getInstList ().push_back (new BranchInst (dstB));
+ // Replace the references to the trace's predecessor with a
+ // reference to FEntry now. This is kind of a dodge because we
+ // don't have a pointer to the trace's predecessor, so we have
+ // to guess which one it is. Assume it's any phi value source in
+ // the entry BB which is not in the trace.
+ for (BasicBlock::iterator BI = srcB->begin ();
+ PHINode *PN = dyn_cast (BI); ++BI)
+ for (unsigned i = 0; i < PN->getNumIncomingValues (); ++i)
+ if (!T.contains (PN->getIncomingBlock (i))) {
+ // FIXME: Assert that O2CMap[PN]'s value i is live in.
+ Value *V = O2CMap[PN];
+ assert (V && "Can't find clone of Phi node from trace entry BB");
+ PHINode *PNinF = dyn_cast (V);
+ assert (PNinF
+ && "Clone of Phi node from entry BB is not a Phi node");
+ PNinF->setIncomingBlock (i, FEntry);
+ }
+ }
+
+ // If srcB contains a trace-exiting branch B, fix up B's clone in
+ // dstB to point to a new basic block in F that contains a return
+ // statement. Each return statement in F corresponds to a unique
+ // exit branch in T, and each return statement is numbered.
+ if (BranchInst *BI = containsTraceExitingBranch (srcB, T)) {
+ // Fix up this exit branch.
+ Value *V = O2CMap[BI];
+ assert(V && isa (V)
+ && "Trace-exiting branch's clone is null, or not a branch?");
+ BranchInst *BIinF = cast (V);
+ for (unsigned i = 0; i < BI->getNumSuccessors (); ++i) {
+ if (!T.contains (BI->getSuccessor (i))) {
+ // This is a trace-exiting destination of branch BI. Create a new
+ // basic block FB for its destination in the function.
+ std::string name ("exitfixup" + utostr (BranchNumber[BI]) + "_"
+ + utostr (i));
+ BasicBlock *FB = new BasicBlock (name, F);
+ // Change BI's clone's destination to FB.
+ BIinF->setSuccessor (i, FB);
+ // Add the getelementptr/store instruction pairs here that
+ // correspond to each live-out variable.
+ unsigned Slot = 0;
+ for (LiveVariableSet::iterator SI = So.begin (), SE = So.end ();
+ SI != SE; ++SI) {
+ std::vector Index;
+ Index.push_back (Constant::getNullValue (Type::LongTy)); //long 0
+ Index.push_back (ConstantUInt::get (Type::UByteTy, Slot));//ubyte Slot
+ DEBUG(std::cerr << "About to make a GEP: " << getFunctionArg (F, 0));
+ for (std::vector::iterator VI = Index.begin(),
+ VE = Index.end (); VI != VE; ++VI) {
+ DEBUG(std::cerr << ", " << **VI);
+ }
+ DEBUG(std::cerr << "\n");
+ GetElementPtrInst *GEP =
+ new GetElementPtrInst (getFunctionArg (F, 0), Index,
+ "liveOutP" + utostr (BranchNumber[BI])
+ + "_" + utostr (i) + "_" + utostr (Slot));
+ FB->getInstList ().push_back (GEP);
+ FB->getInstList ().push_back (new StoreInst (*SI, GEP));
+ ++Slot;
+ }
+ // Make FB contain a return instruction that returns the
+ // number of the taken exit-branch. Add it to the end of FB:
+ // (FIXME: Numbering the branches in this way is probably
+ // unnecessary except in DEBUG mode.)
+ FB->getInstList ().push_back
+ (new ReturnInst (ConstantUInt::get (Type::UIntTy,
+ BranchNumber[BI])));
+ } else {
+ // This is a non-trace-exiting destination of branch BI. Fix up
+ // its clone's destination to point to its successor's clone.
+ Value *V2 = O2CMap[BI->getSuccessor (i)];
+ DEBUG(if (!V2) {
+ std::cerr
+ << "I'm confused: saw non-trace-exiting dest. of branch "
+ << *BI << " whose clone is " << *BIinF
+ << " successor number is " << i << " and successor is "
+ << *BI->getSuccessor (i) << ", but where's its clone?\n";
+ assert(V2 && "Clone of basic block on trace is null?");
+ });
+ assert(isa (V2)
+ && "Clone of basic block on trace is not a basic block?");
+ BasicBlock *BIsuccInF = cast (V2);
+ BIinF->setSuccessor (i, BIsuccInF);
+ }
+ }
+ }
+
+ // Fix up operands of each instruction:
+ for (BasicBlock::iterator BI = dstB->begin (), BE = dstB->end ();
+ BI != BE; ++BI) {
+ Instruction &I = *BI;
+ for (unsigned i = 0; i < I.getNumOperands (); ++i) {
+ Value *V = I.getOperand (i);
+ // If the instruction I has an operand which is in the live-in
+ // set of the trace, then we must replace that operand with
+ // the corresponding argument of F. We can find out which
+ // operands to replace by looking them up in
+ // LiveInToParameterMap.
+ if (LiveInToParameterMap.find (V) != LiveInToParameterMap.end ()) {
+ DEBUG(std::cerr << *V << " in instruction " << I
+ << " is argument " << LiveInToParameterMap[V]
+ << " in new function\n");
+ assert (V->getType () ==
+ getFunctionArg (F, LiveInToParameterMap[V])->getType ()
+ && "Live-in Value's type doesn't match corresponding arg type");
+ I.setOperand(i, getFunctionArg (F, LiveInToParameterMap[V]));
+ }
+ // If the instruction I has an operand which is in the
+ // trace, that operand will have been cloned into the
+ // function, and I will still reference the version from
+ // outside the function. Replace any reference to an operand
+ // which has had a clone made with a reference to its clone.
+ else if (O2CMap.find (V) != O2CMap.end ()) {
+ DEBUG(std::cerr << *V << " in instruction " << I
+ << " is value " << O2CMap[V] << " in new function\n");
+ assert (V->getType () == O2CMap[V]->getType ()
+ && "Value's type doesn't match clone's type");
+ I.setOperand(i, O2CMap[V]);
+ }
+ }
+ // Make sure that our operand fixups did the Right Thing for
+ // branches.
+ DEBUG(if (BranchInst *BrI = dyn_cast (&I)) {
+ for (unsigned i = 0; i < BrI->getNumSuccessors (); ++i) {
+ assert (BrI->getSuccessor (i)->getParent () == F
+ && "Branch out of function missed by copyTraceToFunction");
+ assert (!O2CMap[BrI->getSuccessor (i)]
+ && "Branch's clone found as key in original-->clone map; "
+ "no one told me today was opposite day!");
+ }
+ });
+ }
+
+ // Fix up Phi nodes:
+ for (BasicBlock::iterator BI = dstB->begin (), BE = dstB->end ();
+ BI != BE; ++BI) {
+ Instruction &I = *BI;
+ // In all cases, if a Phi node source in T was an on-trace basic
+ // block, then it will already have been fixed up to point to
+ // that block's clone, so we find off-trace sources by looking
+ // for source BBs which are not in F.
+ if (PHINode *PN = dyn_cast (&I)) {
+ unsigned onTraceSources = 0;
+ int lastSrcFound = -1;
+ for (unsigned i = 0; i < PN->getNumIncomingValues (); ++i)
+ if (PN->getIncomingBlock (i)->getParent () == F) {
+ lastSrcFound = i;
+ ++onTraceSources;
+ }
+ // Case 0. If it has 0 sources on the trace, that should really
+ // never happen.
+ assert (onTraceSources != 0
+ && "Phi node on trace has ALL its sources from off-trace!");
+ // Case 1. If it has 1 source S on the trace, replace its uses
+ // with S.
+ if (onTraceSources == 1) {
+ DEBUG(std::cerr << "Replacing Phi node" << *PN
+ << " with its lone on-trace input "
+ << *PN->getIncomingValue (lastSrcFound) << "\n");
+ PN->replaceAllUsesWith (PN->getIncomingValue (lastSrcFound));
+ dstB->getInstList ().erase (BI); // Delete the non-used Phi node
+ } else {
+ // Case N. If it has >1 source on the trace, just delete
+ // sources from the Phi node that are not on the trace.
+ int lastOffTraceSrcFound = -1;
+ do {
+ for (unsigned i = 0; i < PN->getNumIncomingValues (); ++i)
+ if (PN->getIncomingBlock (i)->getParent () != F) {
+ lastOffTraceSrcFound = i; // Found an off-trace source.
+ break;
+ }
+ if (lastOffTraceSrcFound != -1) { // Found one?
+ DEBUG(std::cerr << "Removing off-trace input "
+ << *PN->getIncomingValue (lastOffTraceSrcFound)
+ << " from Phi node " << *PN << "\n");
+ PN->removeIncomingValue (lastOffTraceSrcFound); // Delete it.
+ }
+ } while (lastOffTraceSrcFound != -1); // Continue until none found.
+ }
+ }
+ // Make sure that our Phi fixups did the Right Thing.
+ DEBUG(if (PHINode *PN = dyn_cast (&I))
+ for (unsigned i = 0; i < PN->getNumIncomingValues (); ++i)
+ assert (PN->getIncomingBlock (i)->getParent () == F &&
+ "Sorry, copyTraceIntoFunction mishandled a Phi node"));
+ }
+
+ // Remove calls to first-level instrumentation if we find them.
+ for (BasicBlock::iterator BI = dstB->begin (), BE = dstB->end ();
+ BI != BE; ++BI) {
+ Instruction &I = *BI;
+ if (CallInst *CI = dyn_cast (&I)) {
+ Function *CF = CI->getCalledFunction ();
+ if (CF->getName () == "llvm_first_trigger" && CF->isExternal ()) {
+ DEBUG(std::cerr << " (Found a call instruction " << *CI
+ << " ... Smells like llvm_first_trigger.)\n");
+ dstB->getInstList ().erase (BI);
+ }
+ }
+ }
+ }
+
+ Function *TraceToFunction::traceToFunction (Trace &T) {
+ std::string CurrentFnName = T.getFunction ()->getName ();
+ DEBUG(std::cerr << "In traceToFunction() for " << CurrentFnName << "\n");
+
+ // Get some information about the trace's relationship to its parent
+ // function.
+ LiveVariableSet Si = getTraceLiveInSet (T);
+ LiveVariableSet So = getTraceLiveOutSet (T);
+ TypeVector P = createFunctionArgTypeVector (createLiveOutType (So), Si);
+
+ // Make a new internal Function with return type int and parameter
+ // list P, in the same Module as the trace's parent function.
+ std::string name (CurrentFnName + ".trace");
+ Function *F = new Function (FunctionType::get (Type::UIntTy, P, false),
+ GlobalValue::InternalLinkage, name,
+ T.getModule ());
+ DEBUG(giveNamesToFunctionArgs (Si, F));
+ fillInFunctionBody (T, F, So);
+ return F;
+ }
+
+ /// runTraceToFunction - Entry point for TraceToFunction transformation.
+
+ Function *runTraceToFunction (Trace &T) {
+ TraceToFunction TTF;
+ return TTF.traceToFunction (T);
+ }
+
From lattner at cs.uiuc.edu Thu Aug 28 14:57:01 2003
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Thu Aug 28 14:57:01 2003
Subject: [llvm-commits] CVS: llvm/lib/CWriter/Writer.cpp
Message-ID: <200308281956.OAA18462@apoc.cs.uiuc.edu>
Changes in directory llvm/lib/CWriter:
Writer.cpp updated: 1.119 -> 1.120
---
Log message:
Fix really nasty bugs in the CWriter, handling invoke instructions. Tracking
these down was NOT phun.
---
Diffs of the changes:
Index: llvm/lib/CWriter/Writer.cpp
diff -u llvm/lib/CWriter/Writer.cpp:1.119 llvm/lib/CWriter/Writer.cpp:1.120
--- llvm/lib/CWriter/Writer.cpp:1.119 Sun Aug 24 16:00:22 2003
+++ llvm/lib/CWriter/Writer.cpp Thu Aug 28 14:56:10 2003
@@ -894,7 +894,8 @@
UI != UE; ++UI)
if (TerminatorInst *TI = dyn_cast(*UI))
if (TI != Prev->getTerminator() ||
- isa(Prev->getTerminator())) {
+ isa