Index: Jenkins/FullBuild
===================================================================
--- Jenkins/FullBuild (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ Jenkins/FullBuild (revision 330d9331f47e8030558e319939939029b7791865)
@@ -132,4 +132,5 @@
+
- Logs ----------------------------------------------------------------
Index: Jenkinsfile
===================================================================
--- Jenkinsfile (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ Jenkinsfile (revision 330d9331f47e8030558e319939939029b7791865)
@@ -197,16 +197,16 @@
if( Settings.Publish && !Settings.RunBenchmark ) { echo 'No results to publish!!!' }
- def groupCompile = new PlotGroup('Compilation', 'seconds', true)
- def groupConcurrency = new PlotGroup('Concurrency', 'nanoseconds', false)
+ def groupCompile = new PlotGroup('Compilation', 'duration (s) - lower is better', true)
+ def groupConcurrency = new PlotGroup('Concurrency', 'duration (n) - lower is better', false)
//Then publish the results
- do_plot(Settings.RunBenchmark && Settings.Publish, 'compile' , groupCompile , 'Compilation')
- do_plot(Settings.RunBenchmark && Settings.Publish, 'compile-diff' , groupCompile , 'Compilation Speed-Up')
- do_plot(Settings.RunBenchmark && Settings.Publish, 'ctxswitch' , groupConcurrency, 'Context Switching')
- do_plot(Settings.RunBenchmark && Settings.Publish, 'ctxswitch-diff', groupConcurrency, 'Context Switching Speed-Up')
- do_plot(Settings.RunBenchmark && Settings.Publish, 'mutex' , groupConcurrency, 'Mutual Exclusion')
- do_plot(Settings.RunBenchmark && Settings.Publish, 'mutex-diff' , groupConcurrency, 'Mutual Exclusion Speed-Up')
- do_plot(Settings.RunBenchmark && Settings.Publish, 'signal' , groupConcurrency, 'Internal and External Scheduling')
- do_plot(Settings.RunBenchmark && Settings.Publish, 'signal-diff' , groupConcurrency, 'Internal and External Scheduling Speed-Up')
+ do_plot(Settings.RunBenchmark && Settings.Publish, 'compile' , groupCompile , false, 'Compilation')
+ do_plot(Settings.RunBenchmark && Settings.Publish, 'compile.diff' , groupCompile , true , 'Compilation (relative)')
+ do_plot(Settings.RunBenchmark && Settings.Publish, 'ctxswitch' , groupConcurrency, false, 'Context Switching')
+ do_plot(Settings.RunBenchmark && Settings.Publish, 'ctxswitch.diff', groupConcurrency, true , 'Context Switching (relative)')
+ do_plot(Settings.RunBenchmark && Settings.Publish, 'mutex' , groupConcurrency, false, 'Mutual Exclusion')
+ do_plot(Settings.RunBenchmark && Settings.Publish, 'mutex.diff' , groupConcurrency, true , 'Mutual Exclusion (relative)')
+ do_plot(Settings.RunBenchmark && Settings.Publish, 'signal' , groupConcurrency, false, 'Internal and External Scheduling')
+ do_plot(Settings.RunBenchmark && Settings.Publish, 'signal.diff' , groupConcurrency, true , 'Internal and External Scheduling (relative)')
}
}
@@ -466,5 +466,5 @@
}
-def do_plot(boolean new_data, String file, PlotGroup group, String title) {
+def do_plot(boolean new_data, String file, PlotGroup group, boolean relative, String title) {
if(new_data) {
@@ -489,5 +489,5 @@
exclZero: false,
keepRecords: false,
- logarithmic: group.log,
+ logarithmic: !relative && group.log,
numBuilds: '120',
useDescr: true,
Index: Makefile.in
===================================================================
--- Makefile.in (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ Makefile.in (revision 330d9331f47e8030558e319939939029b7791865)
@@ -281,4 +281,5 @@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
+DEMANGLER = @DEMANGLER@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
@@ -306,4 +307,5 @@
LIBCFA_TARGET_DIRS = @LIBCFA_TARGET_DIRS@
LIBCFA_TARGET_MAKEFILES = @LIBCFA_TARGET_MAKEFILES@
+LIBDEMANGLE = @LIBDEMANGLE@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
Index: automake/cfa.m4
===================================================================
--- automake/cfa.m4 (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ automake/cfa.m4 (revision 330d9331f47e8030558e319939939029b7791865)
@@ -66,5 +66,5 @@
"x86-64" ) cannon_arch_name="x64";;
"x86_64" ) cannon_arch_name="x64";;
- "aarch64" ) cannon_arch_name="x64";;
+ "aarch64" ) cannon_arch_name="arm";;
"x86" ) cannon_arch_name="x86";;
"i386" ) cannon_arch_name="x86";;
Index: benchmark/Makefile.in
===================================================================
--- benchmark/Makefile.in (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ benchmark/Makefile.in (revision 330d9331f47e8030558e319939939029b7791865)
@@ -231,4 +231,5 @@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
+DEMANGLER = @DEMANGLER@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
@@ -256,4 +257,5 @@
LIBCFA_TARGET_DIRS = @LIBCFA_TARGET_DIRS@
LIBCFA_TARGET_MAKEFILES = @LIBCFA_TARGET_MAKEFILES@
+LIBDEMANGLE = @LIBDEMANGLE@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
Index: configure
===================================================================
--- configure (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ configure (revision 330d9331f47e8030558e319939939029b7791865)
@@ -637,4 +637,6 @@
LIBOBJS
CFA_BACKEND_CC
+DEMANGLER
+LIBDEMANGLE
WITH_LIBTCMALLOC_FALSE
WITH_LIBTCMALLOC_TRUE
@@ -797,4 +799,5 @@
with_target_hosts
enable_gprofiler
+enable_demangler
enable_dependency_tracking
enable_shared
@@ -1457,4 +1460,5 @@
--disable-silent-rules verbose build output (undo: "make V=0")
--enable-gprofiler whether or not to enable gprofiler tools (if available)
+ --enable-demangler whether or not to build the demangler (executable and library)
--enable-dependency-tracking
do not reject slow dependency extractors
@@ -3401,4 +3405,12 @@
+# Check whether --enable-demangler was given.
+if test "${enable_demangler+set}" = set; then :
+ enableval=$enable_demangler; enable_demangler=$enableval
+else
+ enable_demangler=yes
+fi
+
+
TARGET_HOSTS=${target_hosts}
@@ -3433,5 +3445,5 @@
"x86-64" ) cannon_arch_name="x64";;
"x86_64" ) cannon_arch_name="x64";;
- "aarch64" ) cannon_arch_name="x64";;
+ "aarch64" ) cannon_arch_name="arm";;
"x86" ) cannon_arch_name="x86";;
"i386" ) cannon_arch_name="x86";;
@@ -3475,5 +3487,5 @@
"x86-64" ) cannon_arch_name="x64";;
"x86_64" ) cannon_arch_name="x64";;
- "aarch64" ) cannon_arch_name="x64";;
+ "aarch64" ) cannon_arch_name="arm";;
"x86" ) cannon_arch_name="x86";;
"i386" ) cannon_arch_name="x86";;
@@ -16780,4 +16792,15 @@
+# conditionnally build the demangler
+if test "x$enable_demangler" == xyes; then
+ LIBDEMANGLE="libdemangle.a"
+ DEMANGLER="demangler"
+else
+ LIBDEMANGLE=""
+ DEMANGLER=""
+fi
+
+
+
# Checks for header files.
for ac_header in libintl.h malloc.h unistd.h
Index: configure.ac
===================================================================
--- configure.ac (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ configure.ac (revision 330d9331f47e8030558e319939939029b7791865)
@@ -133,4 +133,8 @@
enable_gprofiler=$enableval, enable_gprofiler=yes)
+AC_ARG_ENABLE(demangler,
+ [ --enable-demangler whether or not to build the demangler (executable and library)],
+ enable_demangler=$enableval, enable_demangler=yes)
+
AC_SUBST(TARGET_HOSTS, ${target_hosts})
@@ -205,4 +209,15 @@
AM_CONDITIONAL([WITH_LIBTCMALLOC], [test "x$enable_gprofiler" = "xyes" -a "$HAVE_LIBTCMALLOC" -eq 1])
+# conditionnally build the demangler
+if test "x$enable_demangler" == xyes; then
+ LIBDEMANGLE="libdemangle.a"
+ DEMANGLER="demangler"
+else
+ LIBDEMANGLE=""
+ DEMANGLER=""
+fi
+AC_SUBST([LIBDEMANGLE])
+AC_SUBST([DEMANGLER])
+
# Checks for header files.
AC_CHECK_HEADERS([libintl.h malloc.h unistd.h], [], [echo "Error: Missing required header"; exit 1])
Index: driver/Makefile.in
===================================================================
--- driver/Makefile.in (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ driver/Makefile.in (revision 330d9331f47e8030558e319939939029b7791865)
@@ -218,4 +218,5 @@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
+DEMANGLER = @DEMANGLER@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
@@ -243,4 +244,5 @@
LIBCFA_TARGET_DIRS = @LIBCFA_TARGET_DIRS@
LIBCFA_TARGET_MAKEFILES = @LIBCFA_TARGET_MAKEFILES@
+LIBDEMANGLE = @LIBDEMANGLE@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
Index: driver/cc1.cc
===================================================================
--- driver/cc1.cc (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ driver/cc1.cc (revision 330d9331f47e8030558e319939939029b7791865)
@@ -10,6 +10,6 @@
// Created On : Fri Aug 26 14:23:51 2005
// Last Modified By : Peter A. Buhr
-// Last Modified On : Mon Sep 3 16:57:05 2018
-// Update Count : 125
+// Last Modified On : Fri Aug 23 15:06:27 2019
+// Update Count : 371
//
@@ -19,8 +19,11 @@
#include
using std::string;
+#include // find
#include // stderr, stdout, perror, fprintf
#include // getenv, exit, mkstemp
#include // execvp, fork, unlink
#include // wait
+#include
+
#include "config.h" // configure info
@@ -30,111 +33,120 @@
-string compiler_name( CFA_BACKEND_CC ); // path/name of C compiler
-
-string D__GCC_BPREFIX__( "-D__GCC_BPREFIX__=" );
-string D__CFA_FLAGPREFIX__( "-D__CFA_FLAG__=" );
-
-char tmpname[] = P_tmpdir "/CFAXXXXXX";
-int tmpfilefd = -1;
-
-
-bool prefix( string arg, string pre ) {
+static string installlibdir( CFA_LIBDIR ); // fixed location of cc1 and cfa-cpp commands when installed
+static string compiler_path( CFA_BACKEND_CC ); // path/name of C compiler
+static bool CFA_flag = false; // -CFA flag
+static bool save_temps = false; // -save-temps flag
+static string o_file;
+
+
+static bool prefix( const string & arg, const string & pre ) {
return arg.substr( 0, pre.size() ) == pre;
} // prefix
-enum { NumSuffixes = 2 };
-const string suffixes[NumSuffixes] = { "cfa", "hfa", };
-
-void suffix( string arg, const char * args[], int & nargs ) {
- //std::cerr << arg << std::endl;
+static void suffix( const string & arg, const char * args[], int & nargs ) {
+ enum { NumSuffixes = 3 };
+ static const string suffixes[NumSuffixes] = { "cfa", "hfa", "ifa" };
+
size_t dot = arg.find_last_of( "." );
- //std::cerr << dot << " " << (dot != string::npos ? arg.substr( dot + 1 ) : "fred" ) << std::endl;
if ( dot == string::npos ) return;
- string sx = arg.substr( dot + 1 );
- for ( int i = 0; i < NumSuffixes; i += 1 ) {
- if ( sx == suffixes[i] ) {
- args[nargs] = "-x";
- nargs += 1;
- args[nargs] = "c";
- nargs += 1;
- return;
- } // if
- } // for
+ const string * end = suffixes + NumSuffixes;
+ if ( std::find( suffixes, end, arg.substr( dot + 1 ) ) != end ) {
+ args[nargs++] = "-x";
+ args[nargs++] = "c";
+ } // if
} // suffix
-void checkEnv( const char * args[], int & nargs ) {
- char *value;
-
- value = getenv( "__CFA_COMPILER__" );
- if ( value != NULL ) {
- compiler_name = value;
- #ifdef __DEBUG_H__
- cerr << "env arg:\"" << compiler_name << "\"" << endl;
- #endif // __DEBUG_H__
- } // if
-
- value = getenv( "__GCC_MACHINE__" );
- if ( value != NULL ) {
- args[nargs] = ( *new string( value ) ).c_str(); // pass the argument along
- #ifdef __DEBUG_H__
- cerr << "env arg:\"" << args[nargs] << "\"" << endl;
- #endif // __DEBUG_H__
- nargs += 1;
- } // if
-
- value = getenv( "__GCC_VERSION__" );
- if ( value != NULL ) {
- args[nargs] = ( *new string( value ) ).c_str(); // pass the argument along
- #ifdef __DEBUG_H__
- cerr << "env arg:\"" << args[nargs] << "\"" << endl;
- #endif // __DEBUG_H__
- nargs += 1;
- } // if
-} // checkEnv
-
-
-void rmtmpfile() {
+static string __CFA_FLAGPREFIX__( "__CFA_FLAG" );
+
+static void checkEnv1( const char * args[], int & nargs ) { // stage 1
+ extern char ** environ;
+
+ for ( int i = 0; environ[i]; i += 1 ) {
+ string arg( environ[i] );
+ #ifdef __DEBUG_H__
+ cerr << "env arg:\"" << arg << "\"" << endl;
+ #endif // __DEBUG_H__
+
+ if ( prefix( arg, __CFA_FLAGPREFIX__ ) ) {
+ string val( arg.substr( __CFA_FLAGPREFIX__.size() + 4 ) );
+ if ( prefix( val, "-compiler=" ) ) {
+ compiler_path = val.substr( 10 );
+ } // if
+ } // if
+ } // for
+} // checkEnv1
+
+
+static void checkEnv2( const char * args[], int & nargs ) { // stage 2
+ extern char ** environ;
+
+ for ( int i = 0; environ[i]; i += 1 ) {
+ string arg( environ[i] );
+ #ifdef __DEBUG_H__
+ cerr << "env arg:\"" << arg << "\"" << endl;
+ #endif // __DEBUG_H__
+
+ if ( prefix( arg, __CFA_FLAGPREFIX__ ) ) {
+ string val( arg.substr( __CFA_FLAGPREFIX__.size() + 4 ) );
+ if ( prefix( val, "-compiler=" ) ) {
+ compiler_path = val.substr( 10 );
+ } else if ( val == "-CFA" ) {
+ CFA_flag = true;
+ } else if ( val == "-save-temps" ) {
+ save_temps = true;
+ } else if ( prefix( val, "-o=" ) ) { // output file for -CFA
+ o_file = val.substr( 3 );
+ } else {
+ args[nargs++] = ( *new string( arg.substr( __CFA_FLAGPREFIX__.size() + 4 ) ) ).c_str();
+ } // if
+ } // if
+ } // for
+} // checkEnv2
+
+
+static char tmpname[] = P_tmpdir "/CFAXXXXXX.i";
+static int tmpfilefd = -1;
+static bool startrm = false;
+
+static void rmtmpfile() {
+ if ( tmpfilefd == -1 ) return; // RACE, file created ?
+
+ startrm = true; // RACE with C-c C-c
if ( unlink( tmpname ) == -1 ) { // remove tmpname
- perror ( "CFA Translator error: cpp failed" );
- exit( EXIT_FAILURE );
- } // if
- tmpfilefd = -1; // mark closed
+ perror ( "CC1 Translator error: failed, unlink" );
+ exit( EXIT_FAILURE );
+ } // if
+ tmpfilefd = -1; // mark removed
} // rmtmpfile
-void sigTermHandler( __attribute__((unused)) int signal ) {
+static void sigTermHandler( int ) { // C-c C-c
+ if ( startrm ) return; // return and let rmtmpfile finish, and then program finishes
+
if ( tmpfilefd != -1 ) { // RACE, file created ?
- rmtmpfile(); // remove
- exit( EXIT_FAILURE ); // terminate
- } // if
+ rmtmpfile(); // remove tmpname
+ } // if
+ exit( EXIT_FAILURE ); // terminate
} // sigTermHandler
-void Stage1( const int argc, const char * const argv[] ) {
+static void Stage1( const int argc, const char * const argv[] ) {
int code;
-
string arg;
- string bprefix;
-
- const char *cpp_in = NULL;
- const char *cpp_out = NULL;
-
- bool CFA_flag = false;
+
+ const char * cpp_in = nullptr;
+ const char * cpp_out = nullptr;
+
bool cpp_flag = false;
- const char *o_name = NULL;
-
- const char *args[argc + 100]; // leave space for 100 additional cpp command line values
+ bool o_flag = false;
+
+ const char * args[argc + 100]; // leave space for 100 additional cpp command line values
int nargs = 1; // number of arguments in args list; 0 => command name
- const char *cargs[20]; // leave space for 20 additional cfa-cpp command line values
- int ncargs = 1; // 0 => command name
-
- signal( SIGINT, sigTermHandler );
- signal( SIGTERM, sigTermHandler );
#ifdef __DEBUG_H__
cerr << "Stage1" << endl;
#endif // __DEBUG_H__
- checkEnv( args, nargs ); // arguments passed via environment variables
+ checkEnv1( args, nargs ); // arguments passed via environment variables
#ifdef __DEBUG_H__
for ( int i = 1; i < argc; i += 1 ) {
@@ -168,30 +180,13 @@
i += 1; // and the argument
cpp_flag = true;
- } else if ( arg == "-D__CFA_PREPROCESS__" ) {
- CFA_flag = true;
- } else if ( arg == "-D" && string( argv[i + 1] ) == "__CFA_PREPROCESS__" ) {
- i += 1; // and the argument
- CFA_flag = true;
- } else if ( prefix( arg, D__CFA_FLAGPREFIX__ ) ) {
- cargs[ncargs] = ( *new string( arg.substr( D__CFA_FLAGPREFIX__.size() ) ) ).c_str();
- ncargs += 1;
- } else if ( arg == "-D" && prefix( argv[i + 1], D__CFA_FLAGPREFIX__.substr(2) ) ) {
- cargs[ncargs] = ( *new string( string( argv[i + 1] ).substr( D__CFA_FLAGPREFIX__.size() - 2 ) ) ).c_str();
- ncargs += 1;
- i += 1; // and the argument
- } else if ( prefix( arg, D__GCC_BPREFIX__ ) ) {
- bprefix = arg.substr( D__GCC_BPREFIX__.size() );
- } else if ( arg == "-D" && prefix( argv[i + 1], D__GCC_BPREFIX__.substr(2) ) ) {
- bprefix = string( argv[i + 1] ).substr( D__GCC_BPREFIX__.size() - 2 );
- i += 1; // and the argument
-
- // all other flags
+
+ // all other flags
} else if ( arg == "-o" ) {
i += 1;
- o_name = argv[i];
+ o_flag = true;
+ cpp_out = argv[i];
} else {
- args[nargs] = argv[i]; // pass the flag along
- nargs += 1;
+ args[nargs++] = argv[i]; // pass the flag along
// CPP flags with an argument
if ( arg == "-D" || arg == "-U" || arg == "-I" || arg == "-MF" || arg == "-MT" || arg == "-MQ" ||
@@ -199,15 +194,12 @@
arg == "-iwithprefix" || arg == "-iwithprefixbefore" || arg == "-isystem" || arg == "-isysroot" ) {
i += 1;
- args[nargs] = argv[i]; // pass the argument along
- nargs += 1;
+ args[nargs++] = argv[i]; // pass the argument along
#ifdef __DEBUG_H__
cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl;
#endif // __DEBUG_H__
} else if ( arg == "-MD" || arg == "-MMD" ) {
- args[nargs] = "-MF"; // insert before file
- nargs += 1;
+ args[nargs++] = "-MF"; // insert before file
i += 1;
- args[nargs] = argv[i]; // pass the argument along
- nargs += 1;
+ args[nargs++] = argv[i]; // pass the argument along
#ifdef __DEBUG_H__
cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl;
@@ -216,10 +208,10 @@
} // if
} else { // obtain input and possibly output files
- if ( cpp_in == NULL ) {
+ if ( cpp_in == nullptr ) {
cpp_in = argv[i];
#ifdef __DEBUG_H__
cerr << "cpp_in:\"" << cpp_in << "\"" << endl;
#endif // __DEBUG_H__
- } else if ( cpp_out == NULL ) {
+ } else if ( cpp_out == nullptr ) {
cpp_out = argv[i];
#ifdef __DEBUG_H__
@@ -238,10 +230,10 @@
cerr << " " << args[i];
} // for
- if ( cpp_in != NULL ) cerr << " " << cpp_in;
- if ( cpp_out != NULL ) cerr << " " << cpp_out;
+ if ( cpp_in != nullptr ) cerr << " " << cpp_in;
+ if ( cpp_out != nullptr ) cerr << " " << cpp_out;
cerr << endl;
#endif // __DEBUG_H__
- if ( cpp_in == NULL ) {
+ if ( cpp_in == nullptr ) {
cerr << "Usage: " << argv[0] << " input-file [output-file] [options]" << endl;
exit( EXIT_FAILURE );
@@ -252,19 +244,16 @@
// output or -o. The call to cfa has a -E so it does not have to be added to the argument list.
- args[0] = compiler_name.c_str();
+ args[0] = compiler_path.c_str();
suffix( cpp_in, args, nargs ); // check suffix
- args[nargs] = cpp_in;
- nargs += 1;
- if ( o_name != NULL ) { // location for output
- args[nargs] = "-o";
- nargs += 1;
- args[nargs] = o_name;
- nargs += 1;
- } // if
- args[nargs] = NULL; // terminate argument list
+ args[nargs++] = cpp_in;
+ if ( o_flag ) { // location for output
+ args[nargs++] = "-o";
+ } // if
+ args[nargs++] = cpp_out;
+ args[nargs] = nullptr; // terminate argument list
#ifdef __DEBUG_H__
cerr << "nargs: " << nargs << endl;
- for ( int i = 0; args[i] != NULL; i += 1 ) {
+ for ( int i = 0; args[i] != nullptr; i += 1 ) {
cerr << args[i] << " ";
} // for
@@ -272,22 +261,10 @@
#endif // __DEBUG_H__
- execvp( args[0], (char *const *)args ); // should not return
- perror( "CFA Translator error: cpp level, execvp" );
- exit( EXIT_FAILURE );
- } // if
-
- // Create a temporary file to store output of the C preprocessor.
-
- tmpfilefd = mkstemp( tmpname );
- if ( tmpfilefd == -1 ) {
- perror( "CFA Translator error: cpp level, mkstemp" );
- exit( EXIT_FAILURE );
- } // if
-
- #ifdef __DEBUG_H__
- cerr << "tmpname:" << tmpname << " tmpfilefd:" << tmpfilefd << endl;
- #endif // __DEBUG_H__
-
- // Run the C preprocessor and save the output in tmpfile.
+ execvp( args[0], (char * const *)args ); // should not return
+ perror( "CC1 Translator error: stage 1, execvp" );
+ exit( EXIT_FAILURE );
+ } // if
+
+ // Run the C preprocessor and save the output in the given file.
if ( fork() == 0 ) { // child process ?
@@ -295,18 +272,17 @@
// an error (e.g., cannot find include file). Whereas, output is always generated, even when there is an error,
// when cpp writes to stdout. Hence, stdout is redirected into the temporary file.
- if ( freopen( tmpname, "w", stdout ) == NULL ) { // redirect stdout to tmpname
- perror( "CFA Translator error: cpp level, freopen" );
+ if ( freopen( cpp_out, "w", stdout ) == nullptr ) { // redirect stdout to output file
+ perror( "CC1 Translator error: stage 1, freopen" );
exit( EXIT_FAILURE );
} // if
- args[0] = compiler_name.c_str();
+ args[0] = compiler_path.c_str();
suffix( cpp_in, args, nargs ); // check suffix
- args[nargs] = cpp_in; // input to cpp
- nargs += 1;
- args[nargs] = NULL; // terminate argument list
+ args[nargs++] = cpp_in; // input to cpp
+ args[nargs] = nullptr; // terminate argument list
#ifdef __DEBUG_H__
cerr << "cpp nargs: " << nargs << endl;
- for ( int i = 0; args[i] != NULL; i += 1 ) {
+ for ( int i = 0; args[i] != nullptr; i += 1 ) {
cerr << args[i] << " ";
} // for
@@ -314,6 +290,6 @@
#endif // __DEBUG_H__
- execvp( args[0], (char *const *)args ); // should not return
- perror( "CFA Translator error: cpp level, execvp" );
+ execvp( args[0], (char * const *)args ); // should not return
+ perror( "CC1 Translator error: stage 1, execvp" );
exit( EXIT_FAILURE );
} // if
@@ -325,81 +301,29 @@
#endif // __DEBUG_H__
- if ( WIFSIGNALED(code) != 0 ) { // child failed ?
- rmtmpfile(); // remove tmpname
- cerr << "CFA Translator error: cpp failed with signal " << WTERMSIG(code) << endl;
- exit( EXIT_FAILURE );
- } // if
-
- if ( WEXITSTATUS(code) != 0 ) { // child error ?
- rmtmpfile(); // remove tmpname
- exit( WEXITSTATUS( code ) ); // do not continue
- } // if
-
- // If -CFA flag specified, run the cfa-cpp preprocessor on the temporary file, and output is written to standard
- // output. Otherwise, run the cfa-cpp preprocessor on the temporary file and save the result into the output file.
-
- if ( fork() == 0 ) { // child runs CFA
- cargs[0] = ( *new string( bprefix + "cfa-cpp" ) ).c_str();
-
- // Source file-name used to generate routine names containing global initializations for TU.
- cargs[ncargs] = ( *new string( "-F" ) ).c_str();
- ncargs += 1;
- cargs[ncargs] = ( *new string( string( cpp_in ) ) ).c_str();
- ncargs += 1;
-
- cargs[ncargs] = tmpname;
- ncargs += 1;
- if ( o_name != NULL ) {
- cargs[ncargs] = o_name;
- ncargs += 1;
- } else if ( ! CFA_flag ) { // run cfa-cpp ?
- cargs[ncargs] = cpp_out;
- ncargs += 1;
- } // if
- cargs[ncargs] = NULL; // terminate argument list
-
- #ifdef __DEBUG_H__
- cerr << "cfa-cpp ncargs: " << (o_name ? o_name : "No -o") << " " << CFA_flag << " " << ncargs << endl;
- for ( int i = 0; cargs[i] != NULL; i += 1 ) {
- cerr << cargs[i] << " ";
- } // for
- cerr << endl;
- #endif // __DEBUG_H__
-
- execvp( cargs[0], (char * const *)cargs ); // should not return
- perror( "CFA Translator error: cpp level, execvp" );
- exit( EXIT_FAILURE );
- } // if
-
- wait( &code ); // wait for child to finish
-
- #ifdef __DEBUG_H__
- cerr << "return code from cfa-cpp:" << WEXITSTATUS(code) << endl;
- #endif // __DEBUG_H__
-
- // Must unlink here because file must exist across execvp.
- rmtmpfile(); // remove tmpname
-
if ( WIFSIGNALED(code) ) { // child failed ?
- cerr << "CFA Translator error: cfa-cpp failed with signal " << WTERMSIG(code) << endl;
- exit( EXIT_FAILURE );
- } // if
-
- exit( WEXITSTATUS(code) );
+ cerr << "CC1 Translator error: stage 1, child failed " << WTERMSIG(code) << endl;
+ exit( EXIT_FAILURE );
+ } // if
+
+ exit( WEXITSTATUS(code) ); // bad cpp result stops top-level gcc
} // Stage1
-void Stage2( const int argc, const char * const * argv ) {
+static void Stage2( const int argc, const char * const * argv ) {
+ int code;
string arg;
- const char *cpp_in = NULL;
-
- const char *args[argc + 100]; // leave space for 100 additional cfa command line values
+ const char * cpp_in = nullptr;
+ const char * cpp_out = nullptr;
+
+ const char * args[argc + 100]; // leave space for 100 additional cfa command line values
int nargs = 1; // number of arguments in args list; 0 => command name
+ const char * cargs[20]; // leave space for 20 additional cfa-cpp command line values
+ int ncargs = 1; // 0 => command name
#ifdef __DEBUG_H__
cerr << "Stage2" << endl;
#endif // __DEBUG_H__
- checkEnv( args, nargs ); // arguments passed via environment variables
+ checkEnv2( cargs, ncargs ); // arguments passed via environment variables
#ifdef __DEBUG_H__
for ( int i = 1; i < argc; i += 1 ) {
@@ -430,10 +354,9 @@
} else {
- args[nargs] = argv[i]; // pass the flag along
- nargs += 1;
+ args[nargs++] = argv[i]; // pass the flag along
if ( arg == "-o" ) {
i += 1;
- args[nargs] = argv[i]; // pass the argument along
- nargs += 1;
+ cpp_out = argv[i];
+ args[nargs++] = argv[i]; // pass the argument along
#ifdef __DEBUG_H__
cerr << "arg:\"" << argv[i] << "\"" << endl;
@@ -442,15 +365,111 @@
} // if
} else { // obtain input and possibly output files
- if ( cpp_in == NULL ) {
+ if ( cpp_in == nullptr ) {
cpp_in = argv[i];
#ifdef __DEBUG_H__
cerr << "cpp_in:\"" << cpp_in << "\"" << endl;
#endif // __DEBUG_H__
+ } else if ( cpp_out == nullptr ) {
+ cpp_out = argv[i];
+ #ifdef __DEBUG_H__
+ cerr << "cpp_out:\"" << cpp_out << "\""<< endl;
+ #endif // __DEBUG_H__
} else {
- cerr << "Usage: " << argv[0] << " input-file [output-file] [options]" << endl;
+ cerr << "Usage: " << argv[0] << " more than two files specified" << endl;
exit( EXIT_FAILURE );
} // if
} // if
} // for
+
+ if ( cpp_in == nullptr ) {
+ cerr << "Usage: " << argv[0] << " missing input file" << endl;
+ exit( EXIT_FAILURE );
+ } // if
+ if ( cpp_out == nullptr ) {
+ cerr << "Usage: " << argv[0] << " missing output file" << endl;
+ exit( EXIT_FAILURE );
+ } // if
+
+ // Create a temporary file, if needed, to store output of the cfa-cpp preprocessor. Cannot be created in forked
+ // process because variables tmpname and tmpfilefd are cloned.
+
+ string cfa_cpp_out;
+
+ if ( ! CFA_flag ) { // run compiler ?
+ if ( save_temps ) {
+ cfa_cpp_out = cpp_in;
+ size_t dot = cfa_cpp_out.find_last_of( "." );
+ if ( dot == string::npos ) {
+ cerr << "CC1 Translator error: stage 2, bad file name " << endl;
+ exit( EXIT_FAILURE );
+ } // if
+
+ cfa_cpp_out = cfa_cpp_out.substr( 0, dot ) + ".ifa";
+ if ( creat( cfa_cpp_out.c_str(), 0666 ) == -1 ) {
+ perror( "CC1 Translator error: stage 2, creat" );
+ exit( EXIT_FAILURE );
+ } // if
+ } else {
+ tmpfilefd = mkstemps( tmpname, 2 );
+ if ( tmpfilefd == -1 ) {
+ perror( "CC1 Translator error: stage 2, mkstemp" );
+ exit( EXIT_FAILURE );
+ } // if
+ cfa_cpp_out = tmpname;
+ } // if
+ #ifdef __DEBUG_H__
+ cerr << "cfa_cpp_out: " << cfa_cpp_out << endl;
+ #endif // __DEBUG_H__
+ } // if
+
+ // If -CFA flag specified, run the cfa-cpp preprocessor on the temporary file, and output is written to standard
+ // output. Otherwise, run the cfa-cpp preprocessor on the temporary file and save the result into the output file.
+
+ if ( fork() == 0 ) { // child runs CFA
+ cargs[0] = ( *new string( installlibdir + "cfa-cpp" ) ).c_str();
+
+ cargs[ncargs++] = cpp_in;
+
+ if ( CFA_flag ) { // run cfa-cpp ?
+ if ( o_file.size() != 0 ) { // location for output
+ cargs[ncargs++] = ( *new string( o_file.c_str() ) ).c_str();
+ } // if
+ } else {
+ cargs[ncargs++] = cfa_cpp_out.c_str();
+ } // if
+ cargs[ncargs] = nullptr; // terminate argument list
+
+ #ifdef __DEBUG_H__
+ for ( int i = 0; cargs[i] != nullptr; i += 1 ) {
+ cerr << cargs[i] << " ";
+ } // for
+ cerr << endl;
+ #endif // __DEBUG_H__
+
+ execvp( cargs[0], (char * const *)cargs ); // should not return
+ perror( "CC1 Translator error: stage 2, execvp" );
+ exit( EXIT_FAILURE );
+ } // if
+
+ wait( &code ); // wait for child to finish
+
+ if ( WIFSIGNALED(code) ) { // child failed ?
+ rmtmpfile(); // remove tmpname
+ cerr << "CC1 Translator error: stage 2, child failed " << WTERMSIG(code) << endl;
+ exit( EXIT_FAILURE );
+ } // if
+
+ if ( CFA_flag ) { // no tmpfile created
+ exit( WEXITSTATUS( code ) ); // stop regardless of success or failure
+ } // if
+
+ #ifdef __DEBUG_H__
+ cerr << "return code from cfa-cpp:" << WEXITSTATUS(code) << endl;
+ #endif // __DEBUG_H__
+
+ if ( WEXITSTATUS(code) ) { // child error ?
+ rmtmpfile(); // remove tmpname
+ exit( WEXITSTATUS( code ) ); // do not continue
+ } // if
#ifdef __DEBUG_H__
@@ -459,37 +478,63 @@
cerr << " " << args[i];
} // for
- cerr << endl;
- if ( cpp_in != NULL ) cerr << " " << cpp_in;
- #endif // __DEBUG_H__
-
- args[0] = compiler_name.c_str();
- args[nargs] = "-S"; // only compile and put assembler output in specified file
- nargs += 1;
- args[nargs] = cpp_in;
- nargs += 1;
- args[nargs] = NULL; // terminate argument list
-
- #ifdef __DEBUG_H__
- cerr << "stage2 nargs: " << nargs << endl;
- for ( int i = 0; args[i] != NULL; i += 1 ) {
- cerr << args[i] << " ";
- } // for
- cerr << endl;
- #endif // __DEBUG_H__
-
- execvp( args[0], (char * const *)args ); // should not return
- perror( "CFA Translator error: cpp level, execvp" );
- exit( EXIT_FAILURE ); // tell gcc not to go any further
+ cerr << " " << cpp_in << endl;
+ #endif // __DEBUG_H__
+
+ if ( fork() == 0 ) { // child runs CFA
+ args[0] = compiler_path.c_str();
+ args[nargs++] = "-S"; // only compile and put assembler output in specified file
+ if ( save_temps ) { // make gcc accept .ifa suffix
+ args[nargs++] = "-x";
+ args[nargs++] = "cpp-output";
+ } // if
+ args[nargs++] = cfa_cpp_out.c_str();
+ args[nargs] = nullptr; // terminate argument list
+
+ #ifdef __DEBUG_H__
+ cerr << "stage2 nargs: " << nargs << endl;
+ for ( int i = 0; args[i] != nullptr; i += 1 ) {
+ cerr << args[i] << " ";
+ } // for
+ cerr << endl;
+ #endif // __DEBUG_H__
+
+ execvp( args[0], (char * const *)args ); // should not return
+ perror( "CC1 Translator error: stage 2, execvp" );
+ exit( EXIT_FAILURE ); // tell gcc not to go any further
+ } // if
+
+ wait( &code ); // wait for child to finish
+
+ if ( WIFSIGNALED(code) ) { // child failed ?
+ rmtmpfile(); // remove tmpname
+ cerr << "CC1 Translator error: stage 2, child failed " << WTERMSIG(code) << endl;
+ exit( EXIT_FAILURE );
+ } // if
+
+ #ifdef __DEBUG_H__
+ cerr << "return code from gcc cc1:" << WEXITSTATUS(code) << endl;
+ #endif // __DEBUG_H__
+
+ rmtmpfile(); // remove tmpname
+ exit( WEXITSTATUS( code ) ); // stop regardless of success or failure
} // Stage2
+// This program is called twice because of the -no-integrated-cpp. The calls are differentiated by the first
+// command-line argument. The first call replaces the traditional cpp pass to preprocess the C program. The second call
+// is to the compiler, which is broken into two steps: preprocess again with cfa-cpp and then call gcc to compile the
+// doubly preprocessed program.
+
int main( const int argc, const char * const argv[], __attribute__((unused)) const char * const env[] ) {
#ifdef __DEBUG_H__
- for ( int i = 0; env[i] != NULL; i += 1 ) {
+ for ( int i = 0; env[i] != nullptr; i += 1 ) {
cerr << env[i] << endl;
} // for
#endif // __DEBUG_H__
- string arg = argv[1];
+ signal( SIGINT, sigTermHandler );
+ signal( SIGTERM, sigTermHandler );
+
+ string arg( argv[1] );
// Currently, stage 1 starts with flag -E and stage 2 with flag -fpreprocessed.
Index: driver/cfa.cc
===================================================================
--- driver/cfa.cc (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ driver/cfa.cc (revision 330d9331f47e8030558e319939939029b7791865)
@@ -10,6 +10,6 @@
// Created On : Tue Aug 20 13:44:49 2002
// Last Modified By : Peter A. Buhr
-// Last Modified On : Sun Feb 10 08:28:09 2019
-// Update Count : 281
+// Last Modified On : Fri Aug 23 16:27:07 2019
+// Update Count : 411
//
@@ -20,4 +20,5 @@
#include // STL version
#include // strcmp
+#include // find
#include
@@ -32,63 +33,46 @@
using std::to_string;
-
//#define __DEBUG_H__
-bool prefix( string arg, string pre ) {
+void Putenv( char * argv[], string arg ) {
+ static int flags = 0; // environment variables must have unique names
+
+ if ( putenv( (char *)( *new string( string( "__CFA_FLAG" + to_string( flags++ ) + "__=" ) + arg ) ).c_str() ) ) {
+ cerr << argv[0] << " error, cannot set environment variable." << endl;
+ exit( EXIT_FAILURE );
+ } // if
+} // Putenv
+
+
+bool prefix( const string & arg, const string & pre ) { // check if string has prefix
return arg.substr( 0, pre.size() ) == pre;
} // prefix
-enum { NumSuffixes = 2 };
-const string suffixes[NumSuffixes] = { "cfa", "hfa", };
-
-bool suffix( string arg, const char * args[], int & nargs ) {
- //std::cerr << arg << std::endl;
+bool suffix( const string & arg ) { // check if string has suffix
+ enum { NumSuffixes = 3 };
+ static const string suffixes[NumSuffixes] = { "cfa", "hfa", "ifa" };
+
size_t dot = arg.find_last_of( "." );
- //std::cerr << dot << " " << (dot != string::npos ? arg.substr( dot + 1 ) : "fred" ) << std::endl;
if ( dot == string::npos ) return false;
- string sx = arg.substr( dot + 1 );
- for ( int i = 0; i < NumSuffixes; i += 1 ) {
- if ( sx == suffixes[i] ) {
- args[nargs] = "-x";
- nargs += 1;
- args[nargs] = "c";
- nargs += 1;
- return true;
- } // if
- } // for
+ const string * end = suffixes + NumSuffixes;
+ return std::find( suffixes, end, arg.substr( dot + 1 ) ) != end;
+} // suffix
+
+
+static inline bool dirExists( const string & path ) { // check if directory exists
+ struct stat info;
+ if ( stat( path.c_str(), &info ) != 0 ) return false;
+ if ( info.st_mode & S_IFDIR ) return true;
return false;
-} // suffix
-
-
-void shuffle( const char *args[], int S, int E, int N ) {
- // S & E index 1 passed the end so adjust with -1
- #ifdef __DEBUG_H__
- cerr << "shuffle:" << S << " " << E << " " << N << endl;
- #endif // __DEBUG_H__
- for ( int j = E-1 + N; j > S-1 + N; j -=1 ) {
- #ifdef __DEBUG_H__
- cerr << "\t" << j << " " << j-N << endl;
- #endif // __DEBUG_H__
- args[j] = args[j-N];
- } // for
-} // shuffle
-
-static inline bool dirExists(const string & path) {
- struct stat info;
- if(stat( path.c_str(), &info ) != 0)
- return false;
- else if(info.st_mode & S_IFDIR)
- return true;
- else
- return false;
-} //dirExists
-
-
+} // dirExists
+
+
+#define xstr(s) str(s)
#define str(s) #s
-int main( int argc, char *argv[] ) {
+int main( int argc, char * argv[] ) {
string Version( CFA_VERSION_LONG ); // current version number from CONFIG
- string Major( str( CFA_VERSION_MAJOR ) ), Minor( str( CFA_VERSION_MINOR ) ), Patch( str( CFA_VERSION_PATCH ) );
+ string Major( xstr( CFA_VERSION_MAJOR ) ), Minor( xstr( CFA_VERSION_MINOR ) ), Patch( xstr( CFA_VERSION_PATCH ) );
string installincdir( CFA_INCDIR ); // fixed location of include files
@@ -104,11 +88,12 @@
string compiler_name; // name of C compiler
- bool nonoptarg = false; // indicates non-option argument specified
- bool link = true; // linking as well as compiling
+ bool x_flag = false; // -x flag
+ bool nonoptarg = false; // no non-option arguments specified, i.e., no file names
+ bool link = true; // link stage occurring
bool verbose = false; // -v flag
- bool quiet = false; // -quiet flag
- bool debug = true; // -debug flag
- bool nolib = false; // -nolib flag
- bool help = false; // -help flag
+ bool quiet = false; // -quiet flag
+ bool debug = true; // -debug flag
+ bool nolib = false; // -nolib flag
+ bool help = false; // -help flag
bool CFA_flag = false; // -CFA flag
bool cpp_flag = false; // -E or -M flag, preprocessor only
@@ -116,7 +101,8 @@
bool noincstd_flag = false; // -no-include-stdhdr= flag
bool debugging __attribute(( unused )) = false; // -g flag
- bool m32 = false; // -m32 flag
- bool m64 = false; // -m64 flag
- bool intree = false;
+ bool m32 = false; // -m32 flag
+ bool m64 = false; // -m64 flag
+ bool intree = false; // build in tree
+ int o_file = 0; // -o filename position
const char *args[argc + 100]; // cfa command line values, plus some space for additional flags
@@ -142,14 +128,12 @@
if ( arg == "-Xlinker" || arg == "-o" ) {
- args[nargs] = argv[i]; // pass the argument along
- nargs += 1;
+ args[nargs++] = argv[i]; // pass argument along
i += 1;
if ( i == argc ) continue; // next argument available ?
- args[nargs] = argv[i]; // pass the argument along
- nargs += 1;
+ args[nargs++] = argv[i]; // pass argument along
+ if ( arg == "-o" ) o_file = i; // remember file
} else if ( arg == "-XCFA" ) { // CFA pass through
i += 1;
- args[nargs] = ( *new string( string("-D__CFA_FLAG__=") + argv[i] ) ).c_str();
- nargs += 1;
+ Putenv( argv, argv[i] );
// CFA specific arguments
@@ -158,10 +142,9 @@
CFA_flag = true; // strip the -CFA flag
link = false;
- args[nargs] = "-E"; // replace the argument with -E
- nargs += 1;
+ args[nargs++] = "-fsyntax-only"; // stop after stage 2
} else if ( arg == "-debug" ) {
debug = true; // strip the debug flag
} else if ( arg == "-nodebug" ) {
- debug = false; // strip the debug flag
+ debug = false; // strip the nodebug flag
} else if ( arg == "-nolib" ) {
nolib = true; // strip the nodebug flag
@@ -183,8 +166,5 @@
if ( i == argc ) continue; // next argument available ?
compiler_path = argv[i];
- if ( putenv( (char *)( *new string( string( "__CFA_COMPILER__=" ) + argv[i]) ).c_str() ) != 0 ) {
- cerr << argv[0] << " error, cannot set environment variable." << endl;
- exit( EXIT_FAILURE );
- } // if
+ Putenv( argv, arg + "=" + argv[i] );
// C specific arguments
@@ -192,31 +172,39 @@
} else if ( arg == "-v" ) {
verbose = true; // verbosity required
- args[nargs] = argv[i]; // pass the argument along
- nargs += 1;
+ args[nargs++] = argv[i]; // pass argument along
} else if ( arg == "-g" ) {
debugging = true; // symbolic debugging required
- args[nargs] = argv[i]; // pass the argument along
- nargs += 1;
+ args[nargs++] = argv[i]; // pass argument along
+ } else if ( arg == "-save-temps" ) {
+ args[nargs++] = argv[i]; // pass argument along
+ Putenv( argv, arg ); // save cfa-cpp output
+ } else if ( prefix( arg, "-x" ) ) { // file suffix ?
+ string lang;
+ args[nargs++] = argv[i]; // pass argument along
+ if ( arg.length() == 2 ) { // separate argument ?
+ i += 1;
+ if ( i == argc ) continue; // next argument available ?
+ lang = argv[i];
+ args[nargs++] = argv[i]; // pass argument along
+ } else {
+ lang = arg.substr( 2 );
+ } // if
+ x_flag = lang != "none";
} else if ( prefix( arg, "-std=" ) || prefix( arg, "--std=" ) ) {
std_flag = true; // -std=XX provided
- args[nargs] = argv[i]; // pass the argument along
- nargs += 1;
+ args[nargs++] = argv[i]; // pass argument along
} else if ( arg == "-w" ) {
- args[nargs] = argv[i]; // pass the argument along
- nargs += 1;
- args[nargs] = ( *new string( string("-D__CFA_FLAG__=") + arg ) ).c_str(); // add the argument for cfa-cpp
- nargs += 1;
+ args[nargs++] = argv[i]; // pass argument along
+ Putenv( argv, arg );
} else if ( prefix( arg, "-W" ) ) { // check before next tests
if ( arg == "-Werror" || arg == "-Wall" ) {
- args[nargs] = argv[i]; // pass the argument along
- nargs += 1;
- args[nargs] = ( *new string( string("-D__CFA_FLAG__=") + arg ) ).c_str(); // add the argument for cfa-cpp
- nargs += 1;
+ args[nargs++] = argv[i]; // pass argument along
+ Putenv( argv, argv[i] );
} else {
unsigned int adv = prefix( arg, "-Wno-" ) ? 5 : 2;
- args[nargs] = argv[i]; // conditionally pass the argument along
- const char * warning = argv[i] + adv; // extract warning
+ args[nargs] = argv[i]; // conditionally pass argument along
+ const char * warning = argv[i] + adv; // extract warning
if ( SemanticWarning_Exist( warning ) ) { // replace the argument for cfa-cpp
- args[nargs] = ( *new string( string("-D__CFA_FLAG__=") + arg ) ).c_str();
+ Putenv( argv, arg );
} // if
nargs += 1;
@@ -224,39 +212,7 @@
} else if ( prefix( arg, "-B" ) ) {
Bprefix = arg.substr(2); // strip the -B flag
- args[nargs] = ( *new string( string("-D__GCC_BPREFIX__=") + Bprefix ) ).c_str();
- nargs += 1;
- } else if ( prefix( arg, "-b" ) ) {
- if ( arg.length() == 2 ) { // separate argument ?
- i += 1;
- if ( i == argc ) continue; // next argument available ?
- arg += argv[i]; // concatenate argument
- } // if
- // later versions of gcc require the -b option to appear at the start of the command line
- shuffle( args, sargs, nargs, 1 ); // make room at front of argument list
- args[sargs] = ( *new string( arg ) ).c_str(); // pass the argument along
- if ( putenv( (char *)( *new string( string( "__GCC_MACHINE__=" ) + arg ) ).c_str() ) != 0 ) {
- cerr << argv[0] << " error, cannot set environment variable." << endl;
- exit( EXIT_FAILURE );
- } // if
- sargs += 1;
- nargs += 1;
- } else if ( prefix( arg, "-V" ) ) {
- if ( arg.length() == 2 ) { // separate argument ?
- i += 1;
- if ( i == argc ) continue; // next argument available ?
- arg += argv[i]; // concatenate argument
- } // if
- // later versions of gcc require the -V option to appear at the start of the command line
- shuffle( args, sargs, nargs, 1 ); // make room at front of argument list
- args[sargs] = ( *new string( arg ) ).c_str(); // pass the argument along
- if ( putenv( (char *)( *new string( string( "__GCC_VERSION__=" ) + arg ) ).c_str() ) != 0 ) {
- cerr << argv[0] << " error, cannot set environment variable." << endl;
- exit( EXIT_FAILURE );
- } // if
- sargs += 1;
- nargs += 1;
+ args[nargs++] = ( *new string( string("-D__GCC_BPREFIX__=") + Bprefix ) ).c_str();
} else if ( arg == "-c" || arg == "-S" || arg == "-E" || arg == "-M" || arg == "-MM" ) {
- args[nargs] = argv[i]; // pass the argument along
- nargs += 1;
+ args[nargs++] = argv[i]; // pass argument along
if ( arg == "-E" || arg == "-M" || arg == "-MM" ) {
cpp_flag = true; // cpp only
@@ -265,30 +221,27 @@
} else if ( arg[1] == 'l' ) {
// if the user specifies a library, load it after user code
- libs[nlibs] = argv[i];
- nlibs += 1;
+ libs[nlibs++] = argv[i];
} else if ( arg == "-m32" ) {
m32 = true;
m64 = false;
- args[nargs] = argv[i];
- nargs += 1;
+ args[nargs++] = argv[i];
} else if ( arg == "-m64" ) {
m64 = true;
m32 = false;
- args[nargs] = argv[i];
- nargs += 1;
+ args[nargs++] = argv[i];
} else {
// concatenate any other arguments
- args[nargs] = argv[i];
- nargs += 1;
+ args[nargs++] = argv[i];
} // if
} else {
- bool cfa = suffix( arg, args, nargs ); // check suffix
- args[nargs] = argv[i]; // concatenate file
- nargs += 1;
- if ( cfa ) {
- args[nargs] = "-x";
- nargs += 1;
- args[nargs] = "none";
- nargs += 1;
+ bool cfa = suffix( arg ); // check suffix
+ if ( ! x_flag && cfa ) { // no explicit suffix and cfa suffix ?
+ args[nargs++] = "-x";
+ args[nargs++] = "c";
+ } // if
+ args[nargs++] = argv[i]; // concatenate files
+ if ( ! x_flag && cfa ) { // no explicit suffix and cfa suffix ?
+ args[nargs++] = "-x";
+ args[nargs++] = "none";
} // if
nonoptarg = true;
@@ -296,12 +249,6 @@
} // for
- args[nargs] = "-x"; // turn off language
- nargs += 1;
- args[nargs] = "none";
- nargs += 1;
-
#ifdef __x86_64__
- args[nargs] = "-mcx16"; // allow double-wide CAA
- nargs += 1;
+ args[nargs++] = "-mcx16"; // allow double-wide CAA
#endif // __x86_64__
@@ -314,4 +261,5 @@
#endif // __DEBUG_H__
+ // -E flag stops at cc1 stage 1, so cfa-cpp in cc1 stage 2 is never executed.
if ( cpp_flag && CFA_flag ) {
cerr << argv[0] << " error, cannot use -E and -CFA flags together." << endl;
@@ -320,152 +268,102 @@
// add the CFA include-library paths, which allow direct access to header files without directory qualification
- if( !intree ) {
- args[nargs] = "-I" CFA_INCDIR;
- nargs += 1;
+ if ( ! intree ) {
+ args[nargs++] = "-I" CFA_INCDIR;
if ( ! noincstd_flag ) { // do not use during build
- args[nargs] = "-I" CFA_INCDIR "stdhdr";
- nargs += 1;
+ args[nargs++] = "-I" CFA_INCDIR "stdhdr";
} // if
- args[nargs] = "-I" CFA_INCDIR "concurrency";
- nargs += 1;
- args[nargs] = "-I" CFA_INCDIR "containers";
- nargs += 1;
- } else {
- args[nargs] = "-I" TOP_SRCDIR "libcfa/src";
- nargs += 1;
+ args[nargs++] = "-I" CFA_INCDIR "concurrency";
+ args[nargs++] = "-I" CFA_INCDIR "containers";
+ } else {
+ args[nargs++] = "-I" TOP_SRCDIR "libcfa/src";
if ( ! noincstd_flag ) { // do not use during build
- args[nargs] = "-I" TOP_SRCDIR "libcfa/src" "/stdhdr";
- nargs += 1;
+ args[nargs++] = "-I" TOP_SRCDIR "libcfa/src" "/stdhdr";
} // if
- args[nargs] = "-I" TOP_SRCDIR "libcfa/src" "/concurrency";
- nargs += 1;
- args[nargs] = "-I" TOP_SRCDIR "libcfa/src" "/containers";
- nargs += 1;
- }
+ args[nargs++] = "-I" TOP_SRCDIR "libcfa/src" "/concurrency";
+ args[nargs++] = "-I" TOP_SRCDIR "libcfa/src" "/containers";
+ } // if
// add stdbool to get defines for bool/true/false
- args[nargs] = "-imacros";
- nargs += 1;
- args[nargs] = "stdbool.h";
- nargs += 1;
+ args[nargs++] = "-imacros";
+ args[nargs++] = "stdbool.h";
string libbase;
- if( !intree ) {
+ if ( ! intree ) {
libbase = CFA_LIBDIR;
} else {
libbase = TOP_BUILDDIR "libcfa/";
- args[nargs] = "-D__CFA_FLAG__=-t";
- nargs += 1;
- }
-
- string arch = m32 ? CFA_32_CPU : (m64 ? CFA_64_CPU : CFA_DEFAULT_CPU);
+ Putenv( argv, "-t" );
+ } // if
+
+ string arch( m32 ? CFA_32_CPU : (m64 ? CFA_64_CPU : CFA_DEFAULT_CPU) );
if ( ! m32 && ! m64 ) {
if ( arch == "x86" ) {
- args[nargs] = "-m32";
- nargs += 1;
+ args[nargs++] = "-m32";
} else if ( arch == "x64" ) {
- args[nargs] = "-m64";
- nargs += 1;
+ args[nargs++] = "-m64";
} // if
} // if
- const char * config = nolib ? "nolib" : (debug ? "debug": "nodebug");
- string libdir = libbase + arch + "-" + config;
-
- if ( ! nolib && ! dirExists( libdir ) ) {
- cerr << argv[0] << " internal error, configuration " << config << " not installed." << endl;
- cerr << "Was looking for " << libdir << endl;
- libdir = libbase + arch + "-" + "nolib";
- } // if
-
+
+ string libdir( libbase + arch + "-" + (nolib ? "nolib" : (debug ? "debug": "nodebug")) );
if ( ! dirExists( libdir ) ) {
- cerr << argv[0] << " internal error, cannot find prelude directory." << endl;
- cerr << "Was looking for " << libdir << endl;
+ cerr << argv[0] << " internal error, cannot find prelude directory " << libdir << endl;
exit( EXIT_FAILURE );
} // if
- args[nargs] = ( *new string( string("-D__CFA_FLAG__=--prelude-dir=" ) + libdir + (intree ? "/prelude" : "")) ).c_str();
- nargs += 1;
-
for ( int i = 0; i < nlibs; i += 1 ) { // copy non-user libraries after all user libraries
- args[nargs] = libs[i];
- nargs += 1;
+ args[nargs++] = libs[i];
} // for
if ( link ) {
- args[nargs] = "-Xlinker";
- nargs += 1;
- args[nargs] = "--undefined=__cfaabi_dbg_bits_write";
- nargs += 1;
- args[nargs] = "-Xlinker";
- nargs += 1;
- args[nargs] = "--undefined=__cfaabi_interpose_startup";
- nargs += 1;
- args[nargs] = "-Xlinker";
- nargs += 1;
- args[nargs] = "--undefined=__cfaabi_appready_startup";
- nargs += 1;
+ args[nargs++] = "-Xlinker";
+ args[nargs++] = "--undefined=__cfaabi_dbg_bits_write";
+ args[nargs++] = "-Xlinker";
+ args[nargs++] = "--undefined=__cfaabi_interpose_startup";
+ args[nargs++] = "-Xlinker";
+ args[nargs++] = "--undefined=__cfaabi_appready_startup";
// include the cfa library in case it's needed
- args[nargs] = ( *new string( string("-L" ) + libdir + (intree ? "/src/.libs" : "")) ).c_str();
- nargs += 1;
- args[nargs] = ( *new string( string("-Wl,-rpath," ) + libdir + (intree ? "/src/.libs" : "")) ).c_str();
- nargs += 1;
- args[nargs] = "-Wl,--push-state,--as-needed";
- nargs += 1;
- args[nargs] = "-lcfathread";
- nargs += 1;
- args[nargs] = "-Wl,--pop-state";
- nargs += 1;
- args[nargs] = "-lcfa";
- nargs += 1;
- args[nargs] = "-lpthread";
- nargs += 1;
- args[nargs] = "-ldl";
- nargs += 1;
- args[nargs] = "-lrt";
- nargs += 1;
- args[nargs] = "-lm";
- nargs += 1;
- } // if
-
- // Add exception flags (unconditionally)
- args[nargs] = "-fexceptions";
- nargs += 1;
-
- // add the correct set of flags based on the type of compile this is
-
- args[nargs] = ( *new string( string("-D__CFA_MAJOR__=") + Major ) ).c_str();
- nargs += 1;
- args[nargs] = ( *new string( string("-D__CFA_MINOR__=") + Minor ) ).c_str();
- nargs += 1;
- args[nargs] = ( *new string( string("-D__CFA_PATCH__=") + Patch ) ).c_str();
- nargs += 1;
- args[nargs] = "-D__CFA__";
- nargs += 1;
- args[nargs] = "-D__CFORALL__";
- nargs += 1;
- args[nargs] = "-D__cforall";
- nargs += 1;
+ args[nargs++] = ( *new string( string("-L" ) + libdir + (intree ? "/src/.libs" : "")) ).c_str();
+ args[nargs++] = ( *new string( string("-Wl,-rpath," ) + libdir + (intree ? "/src/.libs" : "")) ).c_str();
+ args[nargs++] = "-Wl,--push-state,--as-needed";
+ args[nargs++] = "-lcfathread";
+ args[nargs++] = "-Wl,--pop-state";
+ args[nargs++] = "-lcfa";
+ args[nargs++] = "-lpthread";
+ args[nargs++] = "-ldl";
+ args[nargs++] = "-lrt";
+ args[nargs++] = "-lm";
+ } // if
+
+ args[nargs++] = "-fexceptions"; // add exception flags (unconditionally)
+
+ // add flags based on the type of compile
+
+ args[nargs++] = ( *new string( string("-D__CFA_MAJOR__=") + Major ) ).c_str();
+ args[nargs++] = ( *new string( string("-D__CFA_MINOR__=") + Minor ) ).c_str();
+ args[nargs++] = ( *new string( string("-D__CFA_PATCH__=") + Patch ) ).c_str();
+ args[nargs++] = "-D__CFA__";
+ args[nargs++] = "-D__CFORALL__";
+ args[nargs++] = "-D__cforall";
if ( cpp_flag ) {
- args[nargs] = "-D__CPP__";
- nargs += 1;
- } // if
-
- shuffle( args, sargs, nargs, 1 ); // make room at front of argument list
- nargs += 1;
+ args[nargs++] = "-D__CPP__";
+ } // if
+
if ( CFA_flag ) {
- args[sargs] = "-D__CFA_FLAG__=-N";
- args[nargs] = "-D__CFA_PREPROCESS_";
- nargs += 1;
- } else {
- args[sargs] = "-D__CFA_FLAG__=-L";
- } // if
- sargs += 1;
+ Putenv( argv, "-N" );
+ Putenv( argv, "-CFA" );
+ // -CFA implies cc1 stage 2, but gcc does not pass the -o file to this stage because it believe the file is for
+ // the linker. Hence, the -o file is explicit passed to cc1 stage 2 and used as cfa-cpp's output file.
+ if ( o_file ) Putenv( argv, string( "-o=" ) + argv[o_file] );
+ } else {
+ Putenv( argv, "-L" );
+ } // if
+
+ Putenv( argv, "--prelude-dir=" + libdir + (intree ? "/prelude" : "") );
if ( debug ) {
heading += " (debug)";
- args[nargs] = "-D__CFA_DEBUG__";
- nargs += 1;
+ args[nargs++] = "-D__CFA_DEBUG__";
} else {
heading += " (no debug)";
@@ -475,12 +373,9 @@
Bprefix = ! intree ? installlibdir : srcdriverdir;
if ( Bprefix[Bprefix.length() - 1] != '/' ) Bprefix += '/';
- args[nargs] = ( *new string( string("-D__GCC_BPREFIX__=") + Bprefix ) ).c_str();
- nargs += 1;
- } // if
-
- args[nargs] = "-Xlinker"; // used by backtrace
- nargs += 1;
- args[nargs] = "-export-dynamic";
- nargs += 1;
+ args[nargs++] = ( *new string( string("-D__GCC_BPREFIX__=") + Bprefix ) ).c_str();
+ } // if
+
+ args[nargs++] = "-Xlinker"; // used by backtrace
+ args[nargs++] = "-export-dynamic";
// execute the compilation command
@@ -496,22 +391,15 @@
if ( prefix( compiler_name, "gcc" ) ) { // allow suffix on gcc name
- args[nargs] = "-no-integrated-cpp";
- nargs += 1;
- args[nargs] = "-Wno-deprecated";
- nargs += 1;
-#ifdef HAVE_CAST_FUNCTION_TYPE
- args[nargs] = "-Wno-cast-function-type";
- nargs += 1;
-#endif // HAVE_CAST_FUNCTION_TYPE
+ args[nargs++] = "-no-integrated-cpp";
+ args[nargs++] = "-Wno-deprecated";
+ #ifdef HAVE_CAST_FUNCTION_TYPE
+ args[nargs++] = "-Wno-cast-function-type";
+ #endif // HAVE_CAST_FUNCTION_TYPE
if ( ! std_flag ) { // default c11, if none specified
- args[nargs] = "-std=gnu11";
- nargs += 1;
+ args[nargs++] = "-std=gnu11";
} // if
- args[nargs] = "-fgnu89-inline";
- nargs += 1;
- args[nargs] = "-D__int8_t_defined"; // prevent gcc type-size attributes
- nargs += 1;
- args[nargs] = ( *new string( string("-B") + Bprefix ) ).c_str();
- nargs += 1;
+ args[nargs++] = "-fgnu89-inline";
+ args[nargs++] = "-D__int8_t_defined"; // prevent gcc type-size attributes
+ args[nargs++] = ( *new string( string("-B") + Bprefix ) ).c_str();
} else {
cerr << argv[0] << " error, compiler \"" << compiler_name << "\" unsupported." << endl;
@@ -519,10 +407,10 @@
} // if
- args[nargs] = NULL; // terminate with NULL
+ args[nargs] = nullptr; // terminate
#ifdef __DEBUG_H__
cerr << "nargs: " << nargs << endl;
cerr << "args:" << endl;
- for ( int i = 0; args[i] != NULL; i += 1 ) {
+ for ( int i = 0; args[i] != nullptr; i += 1 ) {
cerr << " \"" << args[i] << "\"" << endl;
} // for
@@ -546,5 +434,5 @@
if ( argc == 2 ) exit( EXIT_SUCCESS ); // if only the -v flag is specified, do not invoke gcc
- for ( int i = 0; args[i] != NULL; i += 1 ) {
+ for ( int i = 0; args[i] != nullptr; i += 1 ) {
cerr << args[i] << " ";
} // for
@@ -560,5 +448,5 @@
execvp( args[0], (char *const *)args ); // should not return
- perror( "CFA Translator error: cfa level, execvp" );
+ perror( "CFA Translator error: execvp" );
exit( EXIT_FAILURE );
} // main
Index: libcfa/src/Makefile.am
===================================================================
--- libcfa/src/Makefile.am (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ libcfa/src/Makefile.am (revision 330d9331f47e8030558e319939939029b7791865)
@@ -26,9 +26,11 @@
VPATH += :../prelude
+gdbwaittarget=""
+
# AM_CFLAGS for all cfa source
# AM_CFAFLAGS for only cfa source
# use -no-include-stdhdr to prevent rebuild cycles
# The built sources must not depend on the installed headers
-AM_CFAFLAGS = -quiet -in-tree -I$(srcdir)/stdhdr @CONFIG_CFAFLAGS@
+AM_CFAFLAGS = -quiet -in-tree -I$(srcdir)/stdhdr $(if $(findstring ${gdbwaittarget}, ${@}), -XCFA --gdb) @CONFIG_CFAFLAGS@
AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC @ARCH_FLAGS@ @CONFIG_CFLAGS@
AM_CCASFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@ @CONFIG_CFLAGS@
Index: libcfa/src/Makefile.in
===================================================================
--- libcfa/src/Makefile.in (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ libcfa/src/Makefile.in (revision 330d9331f47e8030558e319939939029b7791865)
@@ -435,4 +435,5 @@
am__v_UPP_1 =
lib_LTLIBRARIES = libcfa.la libcfathread.la
+gdbwaittarget = ""
# AM_CFLAGS for all cfa source
@@ -440,5 +441,5 @@
# use -no-include-stdhdr to prevent rebuild cycles
# The built sources must not depend on the installed headers
-AM_CFAFLAGS = -quiet -in-tree -I$(srcdir)/stdhdr @CONFIG_CFAFLAGS@
+AM_CFAFLAGS = -quiet -in-tree -I$(srcdir)/stdhdr $(if $(findstring ${gdbwaittarget}, ${@}), -XCFA --gdb) @CONFIG_CFAFLAGS@
AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC @ARCH_FLAGS@ @CONFIG_CFLAGS@
AM_CCASFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@ @CONFIG_CFLAGS@
Index: longrun_tests/Makefile.in
===================================================================
--- longrun_tests/Makefile.in (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ longrun_tests/Makefile.in (revision 330d9331f47e8030558e319939939029b7791865)
@@ -365,4 +365,5 @@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
+DEMANGLER = @DEMANGLER@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
@@ -390,4 +391,5 @@
LIBCFA_TARGET_DIRS = @LIBCFA_TARGET_DIRS@
LIBCFA_TARGET_MAKEFILES = @LIBCFA_TARGET_MAKEFILES@
+LIBDEMANGLE = @LIBDEMANGLE@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
Index: src/BasicTypes-gen.cc
===================================================================
--- src/BasicTypes-gen.cc (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ src/BasicTypes-gen.cc (revision 330d9331f47e8030558e319939939029b7791865)
@@ -295,5 +295,29 @@
// cout << code.str();
-
+
+ // TEMPORARY DURING CHANGE OVER
+ #define TypeAST TOP_SRCDIR "src/AST/Type.hpp"
+ resetInput( file, TypeAST, buffer, code, str );
+
+ if ( (start = str.find( STARTMK )) == string::npos ) Abort( "start", TypeAST );
+ start += sizeof( STARTMK ); // includes newline
+ code << str.substr( 0, start );
+
+ code << "\t" << BYMK << endl;
+ code << "\tenum Kind {" << endl;
+ for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) {
+ code << "\t\t" << graph[r].name << "," << endl;
+ } // for
+ code << "\t\tNUMBER_OF_BASIC_TYPES" << endl;
+ code << "\t} kind;" << endl;
+ code << "\t"; // indentation for end marker
+
+ if ( (start = str.find( ENDMK, start + 1 )) == string::npos ) Abort( "end", TypeAST );
+ code << str.substr( start );
+
+ output( file, TypeAST, code );
+ // cout << code.str();
+
+
#define ConversionCost TOP_SRCDIR "src/ResolvExpr/ConversionCost.cc"
resetInput( file, ConversionCost, buffer, code, str );
@@ -310,8 +334,8 @@
code << right << setw(30) << graph[c].type << left;
} else if ( graph[c].rank != graph[c + 2].rank ) {
- code << string( 10, ' ' ) << setw(25) << graph[c].type << setw(25) << graph[c + 1].type;
+ code << string( 10, ' ' ) << setw(25) << graph[c].type << graph[c + 1].type;
c += 1;
} else {
- code << setw(20) << graph[c].type << setw(20) << graph[c + 1].type << setw(20) << graph[c + 2].type;
+ code << setw(20) << graph[c].type << setw(20) << graph[c + 1].type << graph[c + 2].type;
c += 2;
} // if
@@ -328,5 +352,5 @@
code << "\t" << BYMK << endl;
code << "\tstatic const int costMatrix[BasicType::NUMBER_OF_BASIC_TYPES][BasicType::NUMBER_OF_BASIC_TYPES] = { // path length from root to node" << endl
- << "\t\t/* ";
+ << "\t\t/* ";
for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { // titles
code << setw(5) << graph[r].abbrev;
@@ -334,5 +358,5 @@
code << " */" << endl;
for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { // costs
- code << "\t\t/*" << setw(6) << graph[r].abbrev << "*/ {";
+ code << "\t\t/* " << setw(6) << graph[r].abbrev << " */ {";
for ( int c = 0; c < NUMBER_OF_BASIC_TYPES; c += 1 ) {
code << setw(4) << costMatrix[r][c] << ",";
@@ -353,5 +377,5 @@
code << "\t" << BYMK << endl;
code << "\tstatic const int signMatrix[BasicType::NUMBER_OF_BASIC_TYPES][BasicType::NUMBER_OF_BASIC_TYPES] = { // number of sign changes in safe conversion" << endl
- << "\t\t/* ";
+ << "\t\t/* ";
for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { // titles
code << setw(5) << graph[r].abbrev;
@@ -359,5 +383,5 @@
code << " */" << endl;
for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { // costs
- code << "\t\t/*" << setw(6) << graph[r].abbrev << "*/ {";
+ code << "\t\t/* " << setw(6) << graph[r].abbrev << " */ {";
for ( int c = 0; c < NUMBER_OF_BASIC_TYPES; c += 1 ) {
code << setw(4) << signMatrix[r][c] << ",";
@@ -395,5 +419,5 @@
code << "*/" << endl;
for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { // costs
- code << "\t\t\t\t {\n\t\t/*" << setw(6) << graph[r].abbrev << "*/";
+ code << "\t\t\t\t {\n\t\t/* " << setw(6) << graph[r].abbrev << " */";
for ( int c = 0; c < NUMBER_OF_BASIC_TYPES; c += 1 ) {
string s = string{"BT "} + graph[commonTypeMatrix[r][c]].name;
Index: src/GenPoly/Box.cc
===================================================================
--- src/GenPoly/Box.cc (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ src/GenPoly/Box.cc (revision 330d9331f47e8030558e319939939029b7791865)
@@ -725,5 +725,5 @@
if ( ! needsBoxing( param, arg->result, exprTyVars, env ) ) return;
- if ( arg->result->get_lvalue() ) {
+ if ( arg->get_lvalue() ) {
// argument expression may be CFA lvalue, but not C lvalue -- apply generalizedLvalue transformations.
// if ( VariableExpr * varExpr = dynamic_cast< VariableExpr * >( arg ) ) {
Index: src/GenPoly/Lvalue.cc
===================================================================
--- src/GenPoly/Lvalue.cc (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ src/GenPoly/Lvalue.cc (revision 330d9331f47e8030558e319939939029b7791865)
@@ -363,5 +363,5 @@
int diff = depth1 - depth2;
- if ( diff > 0 && ! srcType->get_lvalue() ) {
+ if ( diff > 0 && ! castExpr->arg->get_lvalue() ) {
// rvalue to reference conversion -- introduce temporary
// know that reference depth of cast argument is 0, need to introduce n temporaries for reference depth of n, e.g.
@@ -407,5 +407,5 @@
ret = new AddressExpr( ret );
}
- if ( srcType->get_lvalue() && ! ResolvExpr::typesCompatible( srcType, strict_dynamic_cast( destType )->base, SymTab::Indexer() ) ) {
+ if ( castExpr->arg->get_lvalue() && ! ResolvExpr::typesCompatible( srcType, strict_dynamic_cast( destType )->base, SymTab::Indexer() ) ) {
// must keep cast if cast-to type is different from the actual type
castExpr->arg = ret;
Index: src/Makefile.am
===================================================================
--- src/Makefile.am (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ src/Makefile.am (revision 330d9331f47e8030558e319939939029b7791865)
@@ -11,6 +11,6 @@
## Created On : Sun May 31 08:51:46 2015
## Last Modified By : Peter A. Buhr
-## Last Modified On : Fri Feb 15 09:44:09 2019
-## Update Count : 97
+## Last Modified On : Mon Aug 5 12:57:46 2019
+## Update Count : 98
###############################################################################
@@ -55,5 +55,5 @@
$(addprefix $(srcdir)/, ResolvExpr/ConversionCost.cc ResolvExpr/CommonType.cc SymTab/ManglerCommon.cc) : $(srcdir)/SynTree/Type.h
-$(srcdir)/SynTree/Type.h : BasicTypes-gen.cc
+$(srcdir)/AST/Type.hpp : BasicTypes-gen.cc
${AM_V_GEN}${CXXCOMPILE} $< -o BasicTypes-gen -Wall -Wextra
@./BasicTypes-gen
@@ -62,5 +62,6 @@
# put into lib for now
cfa_cpplibdir = $(CFA_LIBDIR)
-cfa_cpplib_PROGRAMS = ../driver/cfa-cpp demangler
+cfa_cpplib_PROGRAMS = ../driver/cfa-cpp $(DEMANGLER)
+EXTRA_PROGRAMS = demangler
___driver_cfa_cpp_SOURCES = $(SRC)
___driver_cfa_cpp_LDADD = -ldl $(LIBPROFILER) $(LIBTCMALLOC)
@@ -74,5 +75,6 @@
demangler_LDADD = libdemangle.a -ldl # yywrap
-noinst_LIBRARIES = libdemangle.a
+noinst_LIBRARIES = $(LIBDEMANGLE)
+EXTRA_LIBRARIES = libdemangle.a
libdemangle_a_SOURCES = $(SRCDEMANGLE)
Index: src/Makefile.in
===================================================================
--- src/Makefile.in (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ src/Makefile.in (revision 330d9331f47e8030558e319939939029b7791865)
@@ -141,5 +141,6 @@
build_triplet = @build@
host_triplet = @host@
-cfa_cpplib_PROGRAMS = ../driver/cfa-cpp$(EXEEXT) demangler$(EXEEXT)
+cfa_cpplib_PROGRAMS = ../driver/cfa-cpp$(EXEEXT) $(DEMANGLER)
+EXTRA_PROGRAMS = demangler$(EXEEXT)
subdir = src
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -230,5 +231,5 @@
SynTree/Initializer.$(OBJEXT) \
SynTree/TypeSubstitution.$(OBJEXT) SynTree/Attribute.$(OBJEXT) \
- SynTree/DeclReplacer.$(OBJEXT)
+ SynTree/DeclReplacer.$(OBJEXT) SynTree/TopLvalue.$(OBJEXT)
am__objects_8 = CompilationState.$(OBJEXT) $(am__objects_1) \
$(am__objects_2) Concurrency/Keywords.$(OBJEXT) \
@@ -427,4 +428,5 @@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
+DEMANGLER = @DEMANGLER@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
@@ -452,4 +454,5 @@
LIBCFA_TARGET_DIRS = @LIBCFA_TARGET_DIRS@
LIBCFA_TARGET_MAKEFILES = @LIBCFA_TARGET_MAKEFILES@
+LIBDEMANGLE = @LIBDEMANGLE@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
@@ -691,5 +694,6 @@
SynTree/TypeSubstitution.cc \
SynTree/Attribute.cc \
- SynTree/DeclReplacer.cc
+ SynTree/DeclReplacer.cc \
+ SynTree/TopLvalue.cc
@@ -703,5 +707,6 @@
demangler_SOURCES = SymTab/demangler.cc # test driver for the demangler, also useful as a sanity check that libdemangle.a is complete
demangler_LDADD = libdemangle.a -ldl # yywrap
-noinst_LIBRARIES = libdemangle.a
+noinst_LIBRARIES = $(LIBDEMANGLE)
+EXTRA_LIBRARIES = libdemangle.a
libdemangle_a_SOURCES = $(SRCDEMANGLE)
all: $(BUILT_SOURCES)
@@ -1019,4 +1024,6 @@
SynTree/DeclReplacer.$(OBJEXT): SynTree/$(am__dirstamp) \
SynTree/$(DEPDIR)/$(am__dirstamp)
+SynTree/TopLvalue.$(OBJEXT): SynTree/$(am__dirstamp) \
+ SynTree/$(DEPDIR)/$(am__dirstamp)
Tuples/$(am__dirstamp):
@$(MKDIR_P) Tuples
@@ -1329,4 +1336,5 @@
@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/ReferenceType.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/Statement.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/TopLvalue.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/TupleExpr.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/TupleType.Po@am__quote@
@@ -1662,5 +1670,5 @@
$(addprefix $(srcdir)/, ResolvExpr/ConversionCost.cc ResolvExpr/CommonType.cc SymTab/ManglerCommon.cc) : $(srcdir)/SynTree/Type.h
-$(srcdir)/SynTree/Type.h : BasicTypes-gen.cc
+$(srcdir)/AST/Type.hpp : BasicTypes-gen.cc
${AM_V_GEN}${CXXCOMPILE} $< -o BasicTypes-gen -Wall -Wextra
@./BasicTypes-gen
Index: src/Parser/ExpressionNode.cc
===================================================================
--- src/Parser/ExpressionNode.cc (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ src/Parser/ExpressionNode.cc (revision 330d9331f47e8030558e319939939029b7791865)
@@ -10,6 +10,6 @@
// Created On : Sat May 16 13:17:07 2015
// Last Modified By : Peter A. Buhr
-// Last Modified On : Sun Mar 10 16:10:32 2019
-// Update Count : 976
+// Last Modified On : Sun Aug 4 20:57:55 2019
+// Update Count : 978
//
@@ -109,5 +109,5 @@
Expression * build_constantInteger( string & str ) {
- static const BasicType::Kind kind[2][7] = {
+ static const BasicType::Kind kind[2][6] = {
// short (h) must be before char (hh) because shorter type has the longer suffix
{ BasicType::ShortSignedInt, BasicType::SignedChar, BasicType::SignedInt, BasicType::LongSignedInt, BasicType::LongLongSignedInt, BasicType::SignedInt128, },
Index: src/Parser/lex.ll
===================================================================
--- src/Parser/lex.ll (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ src/Parser/lex.ll (revision 330d9331f47e8030558e319939939029b7791865)
@@ -10,6 +10,6 @@
* Created On : Sat Sep 22 08:58:10 2001
* Last Modified By : Peter A. Buhr
- * Last Modified On : Thu Jul 25 22:08:32 2019
- * Update Count : 716
+ * Last Modified On : Sun Aug 4 20:53:47 2019
+ * Update Count : 719
*/
@@ -273,6 +273,7 @@
__inline__ { KEYWORD_RETURN(INLINE); } // GCC
int { KEYWORD_RETURN(INT); }
+int128 { KEYWORD_RETURN(INT128); } // CFA
__int128 { KEYWORD_RETURN(INT128); } // GCC
-int128 { KEYWORD_RETURN(INT128); } // GCC
+__int128_t { KEYWORD_RETURN(INT128); } // GCC
__label__ { KEYWORD_RETURN(LABEL); } // GCC
long { KEYWORD_RETURN(LONG); }
@@ -313,4 +314,5 @@
__typeof__ { KEYWORD_RETURN(TYPEOF); } // GCC
union { KEYWORD_RETURN(UNION); }
+__uint128_t { KEYWORD_RETURN(UINT128); } // GCC
unsigned { KEYWORD_RETURN(UNSIGNED); }
__builtin_va_list { KEYWORD_RETURN(VALIST); } // GCC
Index: src/Parser/parser.yy
===================================================================
--- src/Parser/parser.yy (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ src/Parser/parser.yy (revision 330d9331f47e8030558e319939939029b7791865)
@@ -10,6 +10,6 @@
// Created On : Sat Sep 1 20:22:55 2001
// Last Modified By : Peter A. Buhr
-// Last Modified On : Thu Jul 25 22:31:38 2019
-// Update Count : 4359
+// Last Modified On : Sun Aug 4 21:48:23 2019
+// Update Count : 4364
//
@@ -268,5 +268,5 @@
%token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED
%token BOOL COMPLEX IMAGINARY // C99
-%token INT128 uuFLOAT80 uuFLOAT128 // GCC
+%token INT128 UINT128 uuFLOAT80 uuFLOAT128 // GCC
%token uFLOAT16 uFLOAT32 uFLOAT32X uFLOAT64 uFLOAT64X uFLOAT128 // GCC
%token ZERO_T ONE_T // CFA
@@ -1826,4 +1826,6 @@
| INT128
{ $$ = DeclarationNode::newBasicType( DeclarationNode::Int128 ); }
+ | UINT128
+ { $$ = DeclarationNode::newBasicType( DeclarationNode::Int128 )->addType( DeclarationNode::newSignedNess( DeclarationNode::Unsigned ) ); }
| FLOAT
{ $$ = DeclarationNode::newBasicType( DeclarationNode::Float ); }
Index: src/ResolvExpr/AlternativeFinder.cc
===================================================================
--- src/ResolvExpr/AlternativeFinder.cc (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ src/ResolvExpr/AlternativeFinder.cc (revision 330d9331f47e8030558e319939939029b7791865)
@@ -9,7 +9,7 @@
// Author : Richard C. Bilson
// Created On : Sat May 16 23:52:08 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Thu Jul 25 22:37:46 2019
-// Update Count : 37
+// Last Modified By : Andrew Beach
+// Last Modified On : Thu Aug 8 16:35:00 2019
+// Update Count : 38
//
@@ -377,5 +377,6 @@
}
- Cost computeConversionCost( Type * actualType, Type * formalType, const SymTab::Indexer &indexer, const TypeEnvironment & env ) {
+ Cost computeConversionCost( Type * actualType, Type * formalType, bool actualIsLvalue,
+ const SymTab::Indexer &indexer, const TypeEnvironment & env ) {
PRINT(
std::cerr << std::endl << "converting ";
@@ -387,5 +388,5 @@
std::cerr << std::endl;
)
- Cost convCost = conversionCost( actualType, formalType, indexer, env );
+ Cost convCost = conversionCost( actualType, formalType, actualIsLvalue, indexer, env );
PRINT(
std::cerr << std::endl << "cost is " << convCost << std::endl;
@@ -402,5 +403,6 @@
Cost computeExpressionConversionCost( Expression *& actualExpr, Type * formalType, const SymTab::Indexer &indexer, const TypeEnvironment & env ) {
- Cost convCost = computeConversionCost( actualExpr->result, formalType, indexer, env );
+ Cost convCost = computeConversionCost(
+ actualExpr->result, formalType, actualExpr->get_lvalue(), indexer, env );
// if there is a non-zero conversion cost, ignoring poly cost, then the expression requires conversion.
@@ -1135,5 +1137,5 @@
bool isLvalue( Expression *expr ) {
// xxx - recurse into tuples?
- return expr->result && ( expr->result->get_lvalue() || dynamic_cast< ReferenceType * >( expr->result ) );
+ return expr->result && ( expr->get_lvalue() || dynamic_cast< ReferenceType * >( expr->result ) );
}
@@ -1186,4 +1188,5 @@
assert( toType );
toType = resolveTypeof( toType, indexer );
+ assert(!dynamic_cast(toType));
SymTab::validateType( toType, &indexer );
adjustExprType( toType, env, indexer );
@@ -1212,6 +1215,6 @@
unify( castExpr->result, alt.expr->result, alt.env, needAssertions,
haveAssertions, openVars, indexer );
- Cost thisCost = castCost( alt.expr->result, castExpr->result, indexer,
- alt.env );
+ Cost thisCost = castCost( alt.expr->result, castExpr->result, alt.expr->get_lvalue(),
+ indexer, alt.env );
PRINT(
std::cerr << "working on cast with result: " << castExpr->result << std::endl;
@@ -1640,5 +1643,6 @@
// xxx - do some inspecting on this line... why isn't result bound to initAlt.type?
- Cost thisCost = castCost( alt.expr->result, toType, indexer, newEnv );
+ Cost thisCost = castCost( alt.expr->result, toType, alt.expr->get_lvalue(),
+ indexer, newEnv );
if ( thisCost != Cost::infinity ) {
// count one safe conversion for each value that is thrown away
Index: src/ResolvExpr/CastCost.cc
===================================================================
--- src/ResolvExpr/CastCost.cc (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ src/ResolvExpr/CastCost.cc (revision 330d9331f47e8030558e319939939029b7791865)
@@ -9,7 +9,7 @@
// Author : Richard C. Bilson
// Created On : Sun May 17 06:57:43 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Tue Feb 2 15:34:36 2016
-// Update Count : 7
+// Last Modified By : Andrew Beach
+// Last Modified On : Thu Aug 8 16:12:00 2019
+// Update Count : 8
//
@@ -37,5 +37,6 @@
struct CastCost_old : public ConversionCost {
public:
- CastCost_old( const Type * dest, const SymTab::Indexer &indexer, const TypeEnvironment &env, CostFunction costFunc );
+ CastCost_old( const Type * dest, bool srcIsLvalue,
+ const SymTab::Indexer &indexer, const TypeEnvironment &env, CostFunction costFunc );
using ConversionCost::previsit;
@@ -45,9 +46,10 @@
};
- Cost castCost( const Type * src, const Type * dest, const SymTab::Indexer &indexer, const TypeEnvironment &env ) {
+ Cost castCost( const Type * src, const Type * dest, bool srcIsLvalue,
+ const SymTab::Indexer &indexer, const TypeEnvironment &env ) {
if ( const TypeInstType * destAsTypeInst = dynamic_cast< const TypeInstType * >( dest ) ) {
if ( const EqvClass * eqvClass = env.lookup( destAsTypeInst->name ) ) {
if ( eqvClass->type ) {
- return castCost( src, eqvClass->type, indexer, env );
+ return castCost( src, eqvClass->type, srcIsLvalue, indexer, env );
} else {
return Cost::infinity;
@@ -57,5 +59,5 @@
const TypeDecl * type = strict_dynamic_cast< const TypeDecl * >( namedType );
if ( type->base ) {
- return castCost( src, type->base, indexer, env ) + Cost::safe;
+ return castCost( src, type->base, srcIsLvalue, indexer, env ) + Cost::safe;
} // if
} // if
@@ -78,11 +80,11 @@
} else if ( const ReferenceType * refType = dynamic_cast< const ReferenceType * > ( dest ) ) {
PRINT( std::cerr << "conversionCost: dest is reference" << std::endl; )
- return convertToReferenceCost( src, refType, indexer, env, [](const Type * t1, const Type * t2, const SymTab::Indexer & indexer, const TypeEnvironment & env ) {
+ return convertToReferenceCost( src, refType, srcIsLvalue, indexer, env, [](const Type * t1, const Type * t2, const SymTab::Indexer & indexer, const TypeEnvironment & env ) {
return ptrsCastable( t1, t2, env, indexer );
});
} else {
PassVisitor converter(
- dest, indexer, env,
- (Cost (*)( const Type *, const Type *, const SymTab::Indexer &, const TypeEnvironment & ))
+ dest, srcIsLvalue, indexer, env,
+ (Cost (*)( const Type *, const Type *, bool, const SymTab::Indexer &, const TypeEnvironment & ))
castCost );
src->accept( converter );
@@ -96,6 +98,7 @@
}
- CastCost_old::CastCost_old( const Type * dest, const SymTab::Indexer &indexer, const TypeEnvironment &env, CostFunction costFunc )
- : ConversionCost( dest, indexer, env, costFunc ) {
+ CastCost_old::CastCost_old( const Type * dest, bool srcIsLvalue,
+ const SymTab::Indexer &indexer, const TypeEnvironment &env, CostFunction costFunc )
+ : ConversionCost( dest, srcIsLvalue, indexer, env, costFunc ) {
}
@@ -106,5 +109,5 @@
cost = Cost::unsafe;
} else {
- cost = conversionCost( basicType, dest, indexer, env );
+ cost = conversionCost( basicType, dest, srcIsLvalue, indexer, env );
} // if
}
Index: src/ResolvExpr/CommonType.cc
===================================================================
--- src/ResolvExpr/CommonType.cc (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ src/ResolvExpr/CommonType.cc (revision 330d9331f47e8030558e319939939029b7791865)
@@ -190,5 +190,5 @@
*/
{
- /* B */ BT Bool, BT Char, BT SignedChar, BT UnsignedChar, BT ShortSignedInt, BT ShortUnsignedInt,
+ /* B */ BT Bool, BT Char, BT SignedChar, BT UnsignedChar, BT ShortSignedInt, BT ShortUnsignedInt,
BT SignedInt, BT UnsignedInt, BT LongSignedInt, BT LongUnsignedInt, BT LongLongSignedInt, BT LongLongUnsignedInt,
BT SignedInt128, BT UnsignedInt128, BT uFloat16, BT uFloat16Complex, BT uFloat32, BT uFloat32Complex,
@@ -198,5 +198,5 @@
},
{
- /* C */ BT Char, BT Char, BT SignedChar, BT UnsignedChar, BT ShortSignedInt, BT ShortUnsignedInt,
+ /* C */ BT Char, BT Char, BT SignedChar, BT UnsignedChar, BT ShortSignedInt, BT ShortUnsignedInt,
BT SignedInt, BT UnsignedInt, BT LongSignedInt, BT LongUnsignedInt, BT LongLongSignedInt, BT LongLongUnsignedInt,
BT SignedInt128, BT UnsignedInt128, BT uFloat16, BT uFloat16Complex, BT uFloat32, BT uFloat32Complex,
@@ -206,5 +206,5 @@
},
{
- /* SC */ BT SignedChar, BT SignedChar, BT SignedChar, BT UnsignedChar, BT ShortSignedInt, BT ShortUnsignedInt,
+ /* SC */ BT SignedChar, BT SignedChar, BT SignedChar, BT UnsignedChar, BT ShortSignedInt, BT ShortUnsignedInt,
BT SignedInt, BT UnsignedInt, BT LongSignedInt, BT LongUnsignedInt, BT LongLongSignedInt, BT LongLongUnsignedInt,
BT SignedInt128, BT UnsignedInt128, BT uFloat16, BT uFloat16Complex, BT uFloat32, BT uFloat32Complex,
@@ -214,5 +214,5 @@
},
{
- /* UC */ BT UnsignedChar, BT UnsignedChar, BT UnsignedChar, BT UnsignedChar, BT ShortSignedInt, BT ShortUnsignedInt,
+ /* UC */ BT UnsignedChar, BT UnsignedChar, BT UnsignedChar, BT UnsignedChar, BT ShortSignedInt, BT ShortUnsignedInt,
BT SignedInt, BT UnsignedInt, BT LongSignedInt, BT LongUnsignedInt, BT LongLongSignedInt, BT LongLongUnsignedInt,
BT SignedInt128, BT UnsignedInt128, BT uFloat16, BT uFloat16Complex, BT uFloat32, BT uFloat32Complex,
@@ -222,5 +222,5 @@
},
{
- /* SI */ BT ShortSignedInt, BT ShortSignedInt, BT ShortSignedInt, BT ShortSignedInt, BT ShortSignedInt, BT ShortUnsignedInt,
+ /* SI */ BT ShortSignedInt, BT ShortSignedInt, BT ShortSignedInt, BT ShortSignedInt, BT ShortSignedInt, BT ShortUnsignedInt,
BT SignedInt, BT UnsignedInt, BT LongSignedInt, BT LongUnsignedInt, BT LongLongSignedInt, BT LongLongUnsignedInt,
BT SignedInt128, BT UnsignedInt128, BT uFloat16, BT uFloat16Complex, BT uFloat32, BT uFloat32Complex,
@@ -230,5 +230,5 @@
},
{
- /* SUI */ BT ShortUnsignedInt, BT ShortUnsignedInt, BT ShortUnsignedInt, BT ShortUnsignedInt, BT ShortUnsignedInt, BT ShortUnsignedInt,
+ /* SUI */ BT ShortUnsignedInt, BT ShortUnsignedInt, BT ShortUnsignedInt, BT ShortUnsignedInt, BT ShortUnsignedInt, BT ShortUnsignedInt,
BT SignedInt, BT UnsignedInt, BT LongSignedInt, BT LongUnsignedInt, BT LongLongSignedInt, BT LongLongUnsignedInt,
BT SignedInt128, BT UnsignedInt128, BT uFloat16, BT uFloat16Complex, BT uFloat32, BT uFloat32Complex,
@@ -238,5 +238,5 @@
},
{
- /* I */ BT SignedInt, BT SignedInt, BT SignedInt, BT SignedInt, BT SignedInt, BT SignedInt,
+ /* I */ BT SignedInt, BT SignedInt, BT SignedInt, BT SignedInt, BT SignedInt, BT SignedInt,
BT SignedInt, BT UnsignedInt, BT LongSignedInt, BT LongUnsignedInt, BT LongLongSignedInt, BT LongLongUnsignedInt,
BT SignedInt128, BT UnsignedInt128, BT uFloat16, BT uFloat16Complex, BT uFloat32, BT uFloat32Complex,
@@ -246,5 +246,5 @@
},
{
- /* UI */ BT UnsignedInt, BT UnsignedInt, BT UnsignedInt, BT UnsignedInt, BT UnsignedInt, BT UnsignedInt,
+ /* UI */ BT UnsignedInt, BT UnsignedInt, BT UnsignedInt, BT UnsignedInt, BT UnsignedInt, BT UnsignedInt,
BT UnsignedInt, BT UnsignedInt, BT LongSignedInt, BT LongUnsignedInt, BT LongLongSignedInt, BT LongLongUnsignedInt,
BT SignedInt128, BT UnsignedInt128, BT uFloat16, BT uFloat16Complex, BT uFloat32, BT uFloat32Complex,
@@ -254,5 +254,5 @@
},
{
- /* LI */ BT LongSignedInt, BT LongSignedInt, BT LongSignedInt, BT LongSignedInt, BT LongSignedInt, BT LongSignedInt,
+ /* LI */ BT LongSignedInt, BT LongSignedInt, BT LongSignedInt, BT LongSignedInt, BT LongSignedInt, BT LongSignedInt,
BT LongSignedInt, BT LongSignedInt, BT LongSignedInt, BT LongUnsignedInt, BT LongLongSignedInt, BT LongLongUnsignedInt,
BT SignedInt128, BT UnsignedInt128, BT uFloat16, BT uFloat16Complex, BT uFloat32, BT uFloat32Complex,
@@ -262,5 +262,5 @@
},
{
- /* LUI */ BT LongUnsignedInt, BT LongUnsignedInt, BT LongUnsignedInt, BT LongUnsignedInt, BT LongUnsignedInt, BT LongUnsignedInt,
+ /* LUI */ BT LongUnsignedInt, BT LongUnsignedInt, BT LongUnsignedInt, BT LongUnsignedInt, BT LongUnsignedInt, BT LongUnsignedInt,
BT LongUnsignedInt, BT LongUnsignedInt, BT LongUnsignedInt, BT LongUnsignedInt, BT LongLongSignedInt, BT LongLongUnsignedInt,
BT SignedInt128, BT UnsignedInt128, BT uFloat16, BT uFloat16Complex, BT uFloat32, BT uFloat32Complex,
@@ -270,5 +270,5 @@
},
{
- /* LLI */ BT LongLongSignedInt, BT LongLongSignedInt, BT LongLongSignedInt, BT LongLongSignedInt, BT LongLongSignedInt, BT LongLongSignedInt,
+ /* LLI */ BT LongLongSignedInt, BT LongLongSignedInt, BT LongLongSignedInt, BT LongLongSignedInt, BT LongLongSignedInt, BT LongLongSignedInt,
BT LongLongSignedInt, BT LongLongSignedInt, BT LongLongSignedInt, BT LongLongSignedInt, BT LongLongSignedInt, BT LongLongUnsignedInt,
BT SignedInt128, BT UnsignedInt128, BT uFloat16, BT uFloat16Complex, BT uFloat32, BT uFloat32Complex,
@@ -278,5 +278,5 @@
},
{
- /* LLUI */ BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt,
+ /* LLUI */ BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt,
BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt, BT LongLongUnsignedInt,
BT SignedInt128, BT UnsignedInt128, BT uFloat16, BT uFloat16Complex, BT uFloat32, BT uFloat32Complex,
@@ -286,5 +286,5 @@
},
{
- /* IB */ BT SignedInt128, BT SignedInt128, BT SignedInt128, BT SignedInt128, BT SignedInt128, BT SignedInt128,
+ /* IB */ BT SignedInt128, BT SignedInt128, BT SignedInt128, BT SignedInt128, BT SignedInt128, BT SignedInt128,
BT SignedInt128, BT SignedInt128, BT SignedInt128, BT SignedInt128, BT SignedInt128, BT SignedInt128,
BT SignedInt128, BT UnsignedInt128, BT uFloat16, BT uFloat16Complex, BT uFloat32, BT uFloat32Complex,
@@ -294,5 +294,5 @@
},
{
- /* UIB */ BT UnsignedInt128, BT UnsignedInt128, BT UnsignedInt128, BT UnsignedInt128, BT UnsignedInt128, BT UnsignedInt128,
+ /* UIB */ BT UnsignedInt128, BT UnsignedInt128, BT UnsignedInt128, BT UnsignedInt128, BT UnsignedInt128, BT UnsignedInt128,
BT UnsignedInt128, BT UnsignedInt128, BT UnsignedInt128, BT UnsignedInt128, BT UnsignedInt128, BT UnsignedInt128,
BT UnsignedInt128, BT UnsignedInt128, BT uFloat16, BT uFloat16Complex, BT uFloat32, BT uFloat32Complex,
@@ -302,5 +302,5 @@
},
{
- /* _FH */ BT uFloat16, BT uFloat16, BT uFloat16, BT uFloat16, BT uFloat16, BT uFloat16,
+ /* _FH */ BT uFloat16, BT uFloat16, BT uFloat16, BT uFloat16, BT uFloat16, BT uFloat16,
BT uFloat16, BT uFloat16, BT uFloat16, BT uFloat16, BT uFloat16, BT uFloat16,
BT uFloat16, BT uFloat16, BT uFloat16, BT uFloat16Complex, BT uFloat32, BT uFloat32Complex,
@@ -310,5 +310,5 @@
},
{
- /* _FH */ BT uFloat16Complex, BT uFloat16Complex, BT uFloat16Complex, BT uFloat16Complex, BT uFloat16Complex, BT uFloat16Complex,
+ /* _FH */ BT uFloat16Complex, BT uFloat16Complex, BT uFloat16Complex, BT uFloat16Complex, BT uFloat16Complex, BT uFloat16Complex,
BT uFloat16Complex, BT uFloat16Complex, BT uFloat16Complex, BT uFloat16Complex, BT uFloat16Complex, BT uFloat16Complex,
BT uFloat16Complex, BT uFloat16Complex, BT uFloat16Complex, BT uFloat16Complex, BT uFloat32Complex, BT uFloat32Complex,
@@ -318,5 +318,5 @@
},
{
- /* _F */ BT uFloat32, BT uFloat32, BT uFloat32, BT uFloat32, BT uFloat32, BT uFloat32,
+ /* _F */ BT uFloat32, BT uFloat32, BT uFloat32, BT uFloat32, BT uFloat32, BT uFloat32,
BT uFloat32, BT uFloat32, BT uFloat32, BT uFloat32, BT uFloat32, BT uFloat32,
BT uFloat32, BT uFloat32, BT uFloat32, BT uFloat32Complex, BT uFloat32, BT uFloat32Complex,
@@ -326,5 +326,5 @@
},
{
- /* _FC */ BT uFloat32Complex, BT uFloat32Complex, BT uFloat32Complex, BT uFloat32Complex, BT uFloat32Complex, BT uFloat32Complex,
+ /* _FC */ BT uFloat32Complex, BT uFloat32Complex, BT uFloat32Complex, BT uFloat32Complex, BT uFloat32Complex, BT uFloat32Complex,
BT uFloat32Complex, BT uFloat32Complex, BT uFloat32Complex, BT uFloat32Complex, BT uFloat32Complex, BT uFloat32Complex,
BT uFloat32Complex, BT uFloat32Complex, BT uFloat32Complex, BT uFloat32Complex, BT uFloat32Complex, BT uFloat32Complex,
@@ -334,5 +334,5 @@
},
{
- /* F */ BT Float, BT Float, BT Float, BT Float, BT Float, BT Float,
+ /* F */ BT Float, BT Float, BT Float, BT Float, BT Float, BT Float,
BT Float, BT Float, BT Float, BT Float, BT Float, BT Float,
BT Float, BT Float, BT Float, BT FloatComplex, BT Float, BT FloatComplex,
@@ -342,5 +342,5 @@
},
{
- /* FC */ BT FloatComplex, BT FloatComplex, BT FloatComplex, BT FloatComplex, BT FloatComplex, BT FloatComplex,
+ /* FC */ BT FloatComplex, BT FloatComplex, BT FloatComplex, BT FloatComplex, BT FloatComplex, BT FloatComplex,
BT FloatComplex, BT FloatComplex, BT FloatComplex, BT FloatComplex, BT FloatComplex, BT FloatComplex,
BT FloatComplex, BT FloatComplex, BT FloatComplex, BT FloatComplex, BT FloatComplex, BT FloatComplex,
@@ -350,5 +350,5 @@
},
{
- /* _FX */ BT uFloat32x, BT uFloat32x, BT uFloat32x, BT uFloat32x, BT uFloat32x, BT uFloat32x,
+ /* _FX */ BT uFloat32x, BT uFloat32x, BT uFloat32x, BT uFloat32x, BT uFloat32x, BT uFloat32x,
BT uFloat32x, BT uFloat32x, BT uFloat32x, BT uFloat32x, BT uFloat32x, BT uFloat32x,
BT uFloat32x, BT uFloat32x, BT uFloat32x, BT uFloat32xComplex, BT uFloat32x, BT uFloat32xComplex,
@@ -358,5 +358,5 @@
},
{
- /* _FXC */ BT uFloat32xComplex, BT uFloat32xComplex, BT uFloat32xComplex, BT uFloat32xComplex, BT uFloat32xComplex, BT uFloat32xComplex,
+ /* _FXC */ BT uFloat32xComplex, BT uFloat32xComplex, BT uFloat32xComplex, BT uFloat32xComplex, BT uFloat32xComplex, BT uFloat32xComplex,
BT uFloat32xComplex, BT uFloat32xComplex, BT uFloat32xComplex, BT uFloat32xComplex, BT uFloat32xComplex, BT uFloat32xComplex,
BT uFloat32xComplex, BT uFloat32xComplex, BT uFloat32xComplex, BT uFloat32xComplex, BT uFloat32xComplex, BT uFloat32xComplex,
@@ -366,5 +366,5 @@
},
{
- /* FD */ BT uFloat64, BT uFloat64, BT uFloat64, BT uFloat64, BT uFloat64, BT uFloat64,
+ /* FD */ BT uFloat64, BT uFloat64, BT uFloat64, BT uFloat64, BT uFloat64, BT uFloat64,
BT uFloat64, BT uFloat64, BT uFloat64, BT uFloat64, BT uFloat64, BT uFloat64,
BT uFloat64, BT uFloat64, BT uFloat64, BT uFloat64Complex, BT uFloat64, BT uFloat64Complex,
@@ -374,5 +374,5 @@
},
{
- /* _FDC */ BT uFloat64Complex, BT uFloat64Complex, BT uFloat64Complex, BT uFloat64Complex, BT uFloat64Complex, BT uFloat64Complex,
+ /* _FDC */ BT uFloat64Complex, BT uFloat64Complex, BT uFloat64Complex, BT uFloat64Complex, BT uFloat64Complex, BT uFloat64Complex,
BT uFloat64Complex, BT uFloat64Complex, BT uFloat64Complex, BT uFloat64Complex, BT uFloat64Complex, BT uFloat64Complex,
BT uFloat64Complex, BT uFloat64Complex, BT uFloat64Complex, BT uFloat64Complex, BT uFloat64Complex, BT uFloat64Complex,
@@ -382,5 +382,5 @@
},
{
- /* D */ BT Double, BT Double, BT Double, BT Double, BT Double, BT Double,
+ /* D */ BT Double, BT Double, BT Double, BT Double, BT Double, BT Double,
BT Double, BT Double, BT Double, BT Double, BT Double, BT Double,
BT Double, BT Double, BT Double, BT DoubleComplex, BT Double, BT DoubleComplex,
@@ -390,5 +390,5 @@
},
{
- /* DC */ BT DoubleComplex, BT DoubleComplex, BT DoubleComplex, BT DoubleComplex, BT DoubleComplex, BT DoubleComplex,
+ /* DC */ BT DoubleComplex, BT DoubleComplex, BT DoubleComplex, BT DoubleComplex, BT DoubleComplex, BT DoubleComplex,
BT DoubleComplex, BT DoubleComplex, BT DoubleComplex, BT DoubleComplex, BT DoubleComplex, BT DoubleComplex,
BT DoubleComplex, BT DoubleComplex, BT DoubleComplex, BT DoubleComplex, BT DoubleComplex, BT DoubleComplex,
@@ -398,5 +398,5 @@
},
{
- /* F80X */ BT uFloat64x, BT uFloat64x, BT uFloat64x, BT uFloat64x, BT uFloat64x, BT uFloat64x,
+ /* F80X */ BT uFloat64x, BT uFloat64x, BT uFloat64x, BT uFloat64x, BT uFloat64x, BT uFloat64x,
BT uFloat64x, BT uFloat64x, BT uFloat64x, BT uFloat64x, BT uFloat64x, BT uFloat64x,
BT uFloat64x, BT uFloat64x, BT uFloat64x, BT uFloat64xComplex, BT uFloat64x, BT uFloat64xComplex,
@@ -406,5 +406,5 @@
},
{
- /* _FDXC */ BT uFloat64xComplex, BT uFloat64xComplex, BT uFloat64xComplex, BT uFloat64xComplex, BT uFloat64xComplex, BT uFloat64xComplex,
+ /* _FDXC */ BT uFloat64xComplex, BT uFloat64xComplex, BT uFloat64xComplex, BT uFloat64xComplex, BT uFloat64xComplex, BT uFloat64xComplex,
BT uFloat64xComplex, BT uFloat64xComplex, BT uFloat64xComplex, BT uFloat64xComplex, BT uFloat64xComplex, BT uFloat64xComplex,
BT uFloat64xComplex, BT uFloat64xComplex, BT uFloat64xComplex, BT uFloat64xComplex, BT uFloat64xComplex, BT uFloat64xComplex,
@@ -414,5 +414,5 @@
},
{
- /* F80*/ BT uuFloat80, BT uuFloat80, BT uuFloat80, BT uuFloat80, BT uuFloat80, BT uuFloat80,
+ /* F80 */ BT uuFloat80, BT uuFloat80, BT uuFloat80, BT uuFloat80, BT uuFloat80, BT uuFloat80,
BT uuFloat80, BT uuFloat80, BT uuFloat80, BT uuFloat80, BT uuFloat80, BT uuFloat80,
BT uuFloat80, BT uuFloat80, BT uuFloat80, BT uFloat64xComplex, BT uuFloat80, BT uFloat64xComplex,
@@ -422,5 +422,5 @@
},
{
- /* _FB */ BT uFloat128, BT uFloat128, BT uFloat128, BT uFloat128, BT uFloat128, BT uFloat128,
+ /* _FB */ BT uFloat128, BT uFloat128, BT uFloat128, BT uFloat128, BT uFloat128, BT uFloat128,
BT uFloat128, BT uFloat128, BT uFloat128, BT uFloat128, BT uFloat128, BT uFloat128,
BT uFloat128, BT uFloat128, BT uFloat128, BT uFloat128Complex, BT uFloat128, BT uFloat128Complex,
@@ -430,5 +430,5 @@
},
{
- /* _FLDC */ BT uFloat128Complex, BT uFloat128Complex, BT uFloat128Complex, BT uFloat128Complex, BT uFloat128Complex, BT uFloat128Complex,
+ /* _FLDC */ BT uFloat128Complex, BT uFloat128Complex, BT uFloat128Complex, BT uFloat128Complex, BT uFloat128Complex, BT uFloat128Complex,
BT uFloat128Complex, BT uFloat128Complex, BT uFloat128Complex, BT uFloat128Complex, BT uFloat128Complex, BT uFloat128Complex,
BT uFloat128Complex, BT uFloat128Complex, BT uFloat128Complex, BT uFloat128Complex, BT uFloat128Complex, BT uFloat128Complex,
@@ -438,5 +438,5 @@
},
{
- /* FB */ BT uuFloat128, BT uuFloat128, BT uuFloat128, BT uuFloat128, BT uuFloat128, BT uuFloat128,
+ /* FB */ BT uuFloat128, BT uuFloat128, BT uuFloat128, BT uuFloat128, BT uuFloat128, BT uuFloat128,
BT uuFloat128, BT uuFloat128, BT uuFloat128, BT uuFloat128, BT uuFloat128, BT uuFloat128,
BT uuFloat128, BT uuFloat128, BT uuFloat128, BT uFloat128Complex, BT uuFloat128, BT uFloat128Complex,
@@ -446,5 +446,5 @@
},
{
- /* LD */ BT LongDouble, BT LongDouble, BT LongDouble, BT LongDouble, BT LongDouble, BT LongDouble,
+ /* LD */ BT LongDouble, BT LongDouble, BT LongDouble, BT LongDouble, BT LongDouble, BT LongDouble,
BT LongDouble, BT LongDouble, BT LongDouble, BT LongDouble, BT LongDouble, BT LongDouble,
BT LongDouble, BT LongDouble, BT LongDouble, BT LongDoubleComplex, BT LongDouble, BT LongDoubleComplex,
@@ -454,5 +454,5 @@
},
{
- /* LDC */ BT LongDoubleComplex, BT LongDoubleComplex, BT LongDoubleComplex, BT LongDoubleComplex, BT LongDoubleComplex, BT LongDoubleComplex,
+ /* LDC */ BT LongDoubleComplex, BT LongDoubleComplex, BT LongDoubleComplex, BT LongDoubleComplex, BT LongDoubleComplex, BT LongDoubleComplex,
BT LongDoubleComplex, BT LongDoubleComplex, BT LongDoubleComplex, BT LongDoubleComplex, BT LongDoubleComplex, BT LongDoubleComplex,
BT LongDoubleComplex, BT LongDoubleComplex, BT LongDoubleComplex, BT LongDoubleComplex, BT LongDoubleComplex, BT LongDoubleComplex,
@@ -462,5 +462,5 @@
},
{
- /* _FBX */ BT uFloat128x, BT uFloat128x, BT uFloat128x, BT uFloat128x, BT uFloat128x, BT uFloat128x,
+ /* _FBX */ BT uFloat128x, BT uFloat128x, BT uFloat128x, BT uFloat128x, BT uFloat128x, BT uFloat128x,
BT uFloat128x, BT uFloat128x, BT uFloat128x, BT uFloat128x, BT uFloat128x, BT uFloat128x,
BT uFloat128x, BT uFloat128x, BT uFloat128x, BT uFloat128xComplex, BT uFloat128x, BT uFloat128xComplex,
Index: src/ResolvExpr/ConversionCost.cc
===================================================================
--- src/ResolvExpr/ConversionCost.cc (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ src/ResolvExpr/ConversionCost.cc (revision 330d9331f47e8030558e319939939029b7791865)
@@ -10,6 +10,6 @@
// Created On : Sun May 17 07:06:19 2015
// Last Modified By : Andrew Beach
-// Last Modified On : Mon Jun 24 13:33:00 2019
-// Update Count : 26
+// Last Modified On : Mon Aug 12 10:21:00 2019
+// Update Count : 27
//
@@ -46,10 +46,11 @@
#endif
- Cost conversionCost( const Type * src, const Type * dest, const SymTab::Indexer &indexer, const TypeEnvironment &env ) {
+ Cost conversionCost( const Type * src, const Type * dest, bool srcIsLvalue,
+ const SymTab::Indexer &indexer, const TypeEnvironment &env ) {
if ( const TypeInstType * destAsTypeInst = dynamic_cast< const TypeInstType * >( dest ) ) {
PRINT( std::cerr << "type inst " << destAsTypeInst->name; )
if ( const EqvClass * eqvClass = env.lookup( destAsTypeInst->name ) ) {
if ( eqvClass->type ) {
- return conversionCost( src, eqvClass->type, indexer, env );
+ return conversionCost( src, eqvClass->type, srcIsLvalue, indexer, env );
} else {
return Cost::infinity;
@@ -61,5 +62,6 @@
assert( type );
if ( type->base ) {
- return conversionCost( src, type->base, indexer, env ) + Cost::safe;
+ return conversionCost( src, type->base, srcIsLvalue, indexer, env )
+ + Cost::safe;
} // if
} // if
@@ -81,11 +83,11 @@
} else if ( const ReferenceType * refType = dynamic_cast< const ReferenceType * > ( dest ) ) {
PRINT( std::cerr << "conversionCost: dest is reference" << std::endl; )
- return convertToReferenceCost( src, refType, indexer, env, [](const Type * const t1, const Type * t2, const SymTab::Indexer &, const TypeEnvironment & env ){
+ return convertToReferenceCost( src, refType, srcIsLvalue, indexer, env, [](const Type * const t1, const Type * t2, const SymTab::Indexer &, const TypeEnvironment & env ){
return ptrsAssignable( t1, t2, env );
});
} else {
PassVisitor converter(
- dest, indexer, env,
- (Cost (*)(const Type *, const Type *, const SymTab::Indexer&, const TypeEnvironment&))
+ dest, srcIsLvalue, indexer, env,
+ (Cost (*)(const Type *, const Type *, bool, const SymTab::Indexer&, const TypeEnvironment&))
conversionCost );
src->accept( converter );
@@ -98,14 +100,19 @@
}
- Cost convertToReferenceCost( const Type * src, const Type * dest, int diff, const SymTab::Indexer & indexer, const TypeEnvironment & env, PtrsFunction func ) {
+ static Cost convertToReferenceCost( const Type * src, const Type * dest, bool srcIsLvalue,
+ int diff, const SymTab::Indexer & indexer, const TypeEnvironment & env, PtrsFunction func ) {
PRINT( std::cerr << "convert to reference cost... diff " << diff << " " << src << " / " << dest << std::endl; )
if ( diff > 0 ) {
// TODO: document this
- Cost cost = convertToReferenceCost( strict_dynamic_cast< const ReferenceType * >( src )->base, dest, diff-1, indexer, env, func );
+ Cost cost = convertToReferenceCost(
+ strict_dynamic_cast< const ReferenceType * >( src )->base, dest, srcIsLvalue,
+ diff-1, indexer, env, func );
cost.incReference();
return cost;
} else if ( diff < -1 ) {
// TODO: document this
- Cost cost = convertToReferenceCost( src, strict_dynamic_cast< const ReferenceType * >( dest )->base, diff+1, indexer, env, func );
+ Cost cost = convertToReferenceCost(
+ src, strict_dynamic_cast< const ReferenceType * >( dest )->base, srcIsLvalue,
+ diff+1, indexer, env, func );
cost.incReference();
return cost;
@@ -138,6 +145,6 @@
PRINT( std::cerr << "reference to rvalue conversion" << std::endl; )
PassVisitor converter(
- dest, indexer, env,
- (Cost (*)(const Type *, const Type *, const SymTab::Indexer&, const TypeEnvironment&))
+ dest, srcIsLvalue, indexer, env,
+ (Cost (*)(const Type *, const Type *, bool, const SymTab::Indexer&, const TypeEnvironment&))
conversionCost );
src->accept( converter );
@@ -150,5 +157,6 @@
if ( typesCompatibleIgnoreQualifiers( src, destAsRef->base, indexer, env ) ) {
PRINT( std::cerr << "converting compatible base type" << std::endl; )
- if ( src->get_lvalue() ) {
+ assert( src->get_lvalue() == srcIsLvalue );
+ if ( srcIsLvalue ) {
PRINT(
std::cerr << "lvalue to reference conversion" << std::endl;
@@ -178,13 +186,14 @@
}
- Cost convertToReferenceCost( const Type * src, const ReferenceType * dest, const SymTab::Indexer & indexer, const TypeEnvironment & env, PtrsFunction func ) {
+ Cost convertToReferenceCost( const Type * src, const ReferenceType * dest, bool srcIsLvalue,
+ const SymTab::Indexer & indexer, const TypeEnvironment & env, PtrsFunction func ) {
int sdepth = src->referenceDepth(), ddepth = dest->referenceDepth();
- Cost cost = convertToReferenceCost( src, dest, sdepth-ddepth, indexer, env, func );
+ Cost cost = convertToReferenceCost( src, dest, srcIsLvalue, sdepth-ddepth, indexer, env, func );
PRINT( std::cerr << "convertToReferenceCost result: " << cost << std::endl; )
return cost;
}
- ConversionCost::ConversionCost( const Type * dest, const SymTab::Indexer &indexer, const TypeEnvironment &env, CostFunction costFunc )
- : dest( dest ), indexer( indexer ), cost( Cost::infinity ), env( env ), costFunc( costFunc ) {
+ ConversionCost::ConversionCost( const Type * dest, bool srcIsLvalue, const SymTab::Indexer &indexer, const TypeEnvironment &env, CostFunction costFunc )
+ : dest( dest ), srcIsLvalue( srcIsLvalue ), indexer( indexer ), cost( Cost::infinity ), env( env ), costFunc( costFunc ) {
}
@@ -217,40 +226,40 @@
// GENERATED BY BasicTypes-gen.cc
static const int costMatrix[BasicType::NUMBER_OF_BASIC_TYPES][BasicType::NUMBER_OF_BASIC_TYPES] = { // path length from root to node
- /* B C SC UC SI SUI I UI LI LUI LLI LLUI IB UIB _FH _FH _F _FC F FC _FX _FXC FD _FDC D DC F80X_FDXC F80 _FB_FLDC FB LD LDC _FBX_FLDXC */
- /* B */ { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 17, 16, 18, 17, },
- /* C */ { -1, 0, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 16, 15, 17, 16, },
- /* SC */ { -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 16, 15, 17, 16, },
- /* UC */ { -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 16, 15, 17, 16, },
- /* SI */ { -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 15, 14, 16, 15, },
- /* SUI */ { -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 15, 14, 16, 15, },
- /* I */ { -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 14, 13, 15, 14, },
- /* UI */ { -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 14, 13, 15, 14, },
- /* LI */ { -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 13, 12, 14, 13, },
- /* LUI */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 13, 12, 14, 13, },
- /* LLI */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 12, 11, 13, 12, },
- /* LLUI */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 12, 11, 13, 12, },
- /* IB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 11, 10, 12, 11, },
- /* UIB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 11, 10, 12, 11, },
- /* _FH */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 10, 9, 11, 10, },
- /* _FH */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1, 6, -1, -1, 7, -1, -1, 8, -1, 9, },
- /* _F */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 9, 8, 10, 9, },
- /* _FC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1, -1, 6, -1, -1, 7, -1, 8, },
- /* F */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 8, 7, 9, 8, },
- /* FC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, -1, 2, -1, 3, -1, 4, -1, -1, 5, -1, -1, 6, -1, 7, },
- /* _FX */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 6, 8, 7, },
- /* _FXC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, -1, 2, -1, 3, -1, -1, 4, -1, -1, 5, -1, 6, },
- /* FD */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 5, 7, 6, },
- /* _FDC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, -1, 2, -1, -1, 3, -1, -1, 4, -1, 5, },
- /* D */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 5, 4, 6, 5, },
- /* DC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, -1, -1, 2, -1, -1, 3, -1, 4, },
- /* F80X */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 4, 3, 5, 4, },
- /* _FDXC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, 1, -1, -1, 2, -1, 3, },
- /* F80*/ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 0, 1, 2, 2, 3, 3, 4, 4, },
- /* _FB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, },
- /* _FLDC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, 1, -1, 2, },
- /* FB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 0, 1, 2, 2, 3, },
- /* LD */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, },
- /* LDC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, },
- /* _FBX */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, },
+ /* B C SC UC SI SUI I UI LI LUI LLI LLUI IB UIB _FH _FH _F _FC F FC _FX _FXC FD _FDC D DC F80X_FDXC F80 _FB_FLDC FB LD LDC _FBX_FLDXC */
+ /* B */ { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 17, 16, 18, 17, },
+ /* C */ { -1, 0, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 16, 15, 17, 16, },
+ /* SC */ { -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 16, 15, 17, 16, },
+ /* UC */ { -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 16, 15, 17, 16, },
+ /* SI */ { -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 15, 14, 16, 15, },
+ /* SUI */ { -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 15, 14, 16, 15, },
+ /* I */ { -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 14, 13, 15, 14, },
+ /* UI */ { -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 14, 13, 15, 14, },
+ /* LI */ { -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 13, 12, 14, 13, },
+ /* LUI */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 13, 12, 14, 13, },
+ /* LLI */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 12, 11, 13, 12, },
+ /* LLUI */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 12, 11, 13, 12, },
+ /* IB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 11, 10, 12, 11, },
+ /* UIB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 11, 10, 12, 11, },
+ /* _FH */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 10, 9, 11, 10, },
+ /* _FH */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1, 6, -1, -1, 7, -1, -1, 8, -1, 9, },
+ /* _F */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 9, 8, 10, 9, },
+ /* _FC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1, -1, 6, -1, -1, 7, -1, 8, },
+ /* F */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 8, 7, 9, 8, },
+ /* FC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, -1, 2, -1, 3, -1, 4, -1, -1, 5, -1, -1, 6, -1, 7, },
+ /* _FX */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 6, 8, 7, },
+ /* _FXC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, -1, 2, -1, 3, -1, -1, 4, -1, -1, 5, -1, 6, },
+ /* FD */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 5, 7, 6, },
+ /* _FDC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, -1, 2, -1, -1, 3, -1, -1, 4, -1, 5, },
+ /* D */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, 4, 5, 4, 6, 5, },
+ /* DC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, -1, -1, 2, -1, -1, 3, -1, 4, },
+ /* F80X */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 4, 3, 5, 4, },
+ /* _FDXC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, 1, -1, -1, 2, -1, 3, },
+ /* F80 */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 0, 1, 2, 2, 3, 3, 4, 4, },
+ /* _FB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, 2, 3, 3, },
+ /* _FLDC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, 1, -1, 2, },
+ /* FB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 0, 1, 2, 2, 3, },
+ /* LD */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, },
+ /* LDC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, },
+ /* _FBX */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, },
/* _FLDXC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, },
}; // costMatrix
@@ -265,40 +274,40 @@
// GENERATED BY BasicTypes-gen.cc
static const int signMatrix[BasicType::NUMBER_OF_BASIC_TYPES][BasicType::NUMBER_OF_BASIC_TYPES] = { // number of sign changes in safe conversion
- /* B C SC UC SI SUI I UI LI LUI LLI LLUI IB UIB _FH _FH _F _FC F FC _FX _FXC FD _FDC D DC F80X_FDXC F80 _FB_FLDC FB LD LDC _FBX_FLDXC */
- /* B */ { 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
- /* C */ { -1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
- /* SC */ { -1, -1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
- /* UC */ { -1, -1, -1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
- /* SI */ { -1, -1, -1, -1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
- /* SUI */ { -1, -1, -1, -1, -1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
- /* I */ { -1, -1, -1, -1, -1, -1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
- /* UI */ { -1, -1, -1, -1, -1, -1, -1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
- /* LI */ { -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
- /* LUI */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
- /* LLI */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
- /* LLUI */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
- /* IB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
- /* UIB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
- /* _FH */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
- /* _FH */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, },
- /* _F */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
- /* _FC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, },
- /* F */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
- /* FC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, },
- /* _FX */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
- /* _FXC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, -1, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, },
- /* FD */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
- /* _FDC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, },
- /* D */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
- /* DC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, },
- /* F80X */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
- /* _FDXC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, },
- /* F80*/ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
- /* _FB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, },
- /* _FLDC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, 0, -1, 0, },
- /* FB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, },
- /* LD */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, },
- /* LDC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, },
- /* _FBX */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, },
+ /* B C SC UC SI SUI I UI LI LUI LLI LLUI IB UIB _FH _FH _F _FC F FC _FX _FXC FD _FDC D DC F80X_FDXC F80 _FB_FLDC FB LD LDC _FBX_FLDXC */
+ /* B */ { 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
+ /* C */ { -1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
+ /* SC */ { -1, -1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
+ /* UC */ { -1, -1, -1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
+ /* SI */ { -1, -1, -1, -1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
+ /* SUI */ { -1, -1, -1, -1, -1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
+ /* I */ { -1, -1, -1, -1, -1, -1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
+ /* UI */ { -1, -1, -1, -1, -1, -1, -1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
+ /* LI */ { -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
+ /* LUI */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
+ /* LLI */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
+ /* LLUI */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
+ /* IB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
+ /* UIB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
+ /* _FH */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
+ /* _FH */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, },
+ /* _F */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
+ /* _FC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, },
+ /* F */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
+ /* FC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, },
+ /* _FX */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
+ /* _FXC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, -1, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, },
+ /* FD */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
+ /* _FDC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, },
+ /* D */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
+ /* DC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, },
+ /* F80X */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
+ /* _FDXC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, },
+ /* F80 */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
+ /* _FB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, },
+ /* _FLDC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, 0, -1, 0, },
+ /* FB */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, },
+ /* LD */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, },
+ /* LDC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, },
+ /* _FBX */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, },
/* _FLDXC */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, },
}; // signMatrix
@@ -371,5 +380,5 @@
// recursively compute conversion cost from T1 to T2.
// cv can be safely dropped because of 'implicit dereference' behavior.
- cost = costFunc( refType->base, dest, indexer, env );
+ cost = costFunc( refType->base, dest, srcIsLvalue, indexer, env );
if ( refType->base->tq == dest->tq ) {
cost.incReference(); // prefer exact qualifiers
@@ -403,5 +412,5 @@
static Type::Qualifiers q;
static BasicType integer( q, BasicType::SignedInt );
- cost = costFunc( &integer, dest, indexer, env ); // safe if dest >= int
+ cost = costFunc( &integer, dest, srcIsLvalue, indexer, env ); // safe if dest >= int
if ( cost < Cost::unsafe ) {
cost.incSafe();
@@ -413,5 +422,5 @@
void ConversionCost::postvisit( const TypeInstType * inst ) {
if ( const EqvClass * eqvClass = env.lookup( inst->name ) ) {
- cost = costFunc( eqvClass->type, dest, indexer, env );
+ cost = costFunc( eqvClass->type, dest, srcIsLvalue, indexer, env );
} else if ( const TypeInstType * destAsInst = dynamic_cast< const TypeInstType * >( dest ) ) {
if ( inst->name == destAsInst->name ) {
@@ -423,5 +432,5 @@
assert( type );
if ( type->base ) {
- cost = costFunc( type->base, dest, indexer, env ) + Cost::safe;
+ cost = costFunc( type->base, dest, srcIsLvalue, indexer, env ) + Cost::safe;
} // if
} // if
@@ -434,5 +443,5 @@
std::list< Type * >::const_iterator destIt = destAsTuple->types.begin();
while ( srcIt != tupleType->types.end() && destIt != destAsTuple->types.end() ) {
- Cost newCost = costFunc( * srcIt++, * destIt++, indexer, env );
+ Cost newCost = costFunc( * srcIt++, * destIt++, srcIsLvalue, indexer, env );
if ( newCost == Cost::infinity ) {
return;
@@ -534,6 +543,6 @@
}
-Cost convertToReferenceCost( const ast::Type * src, const ast::Type * dst, int diff,
- const ast::SymbolTable & symtab, const ast::TypeEnvironment & env,
+static Cost convertToReferenceCost( const ast::Type * src, const ast::Type * dst,
+ int diff, const ast::SymbolTable & symtab, const ast::TypeEnvironment & env,
NumCostCalculation func ) {
if ( 0 < diff ) {
Index: src/ResolvExpr/ConversionCost.h
===================================================================
--- src/ResolvExpr/ConversionCost.h (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ src/ResolvExpr/ConversionCost.h (revision 330d9331f47e8030558e319939939029b7791865)
@@ -10,6 +10,6 @@
// Created On : Sun May 17 09:37:28 2015
// Last Modified By : Andrew Beach
-// Last Modified On : Mon Jun 24 10:00:00 2019
-// Update Count : 5
+// Last Modified On : Thu Aug 8 16:13:00 2019
+// Update Count : 6
//
@@ -33,8 +33,11 @@
class TypeEnvironment;
- typedef std::function CostFunction;
+ typedef std::function CostFunction;
+
struct ConversionCost : public WithShortCircuiting {
public:
- ConversionCost( const Type * dest, const SymTab::Indexer &indexer, const TypeEnvironment &env, CostFunction );
+ ConversionCost( const Type * dest, bool srcIsLvalue,
+ const SymTab::Indexer &indexer, const TypeEnvironment &env, CostFunction );
Cost get_cost() const { return cost; }
@@ -59,4 +62,5 @@
protected:
const Type * dest;
+ bool srcIsLvalue;
const SymTab::Indexer &indexer;
Cost cost;
@@ -66,5 +70,6 @@
typedef std::function PtrsFunction;
- Cost convertToReferenceCost( const Type * src, const ReferenceType * dest, const SymTab::Indexer & indexer, const TypeEnvironment & env, PtrsFunction func );
+ Cost convertToReferenceCost( const Type * src, const ReferenceType * dest, bool srcIsLvalue,
+ const SymTab::Indexer & indexer, const TypeEnvironment & env, PtrsFunction func );
// Some function pointer types, differ in return type.
Index: src/ResolvExpr/ResolveAssertions.cc
===================================================================
--- src/ResolvExpr/ResolveAssertions.cc (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ src/ResolvExpr/ResolveAssertions.cc (revision 330d9331f47e8030558e319939939029b7791865)
@@ -9,7 +9,7 @@
// Author : Aaron B. Moss
// Created On : Fri Oct 05 13:46:00 2018
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Wed Jul 10 16:10:37 2019
-// Update Count : 2
+// Last Modified By : Andrew Beach
+// Last Modified On : Thu Aug 8 16:47:00 2019
+// Update Count : 3
//
@@ -156,6 +156,7 @@
for ( const auto& assn : x.assns ) {
// compute conversion cost from satisfying decl to assertion
+ assert( !assn.match.adjType->get_lvalue() );
k += computeConversionCost(
- assn.match.adjType, assn.decl->get_type(), indexer, x.env );
+ assn.match.adjType, assn.decl->get_type(), false, indexer, x.env );
// mark vars+specialization cost on function-type assertions
Index: src/ResolvExpr/typeops.h
===================================================================
--- src/ResolvExpr/typeops.h (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ src/ResolvExpr/typeops.h (revision 330d9331f47e8030558e319939939029b7791865)
@@ -9,7 +9,7 @@
// Author : Richard C. Bilson
// Created On : Sun May 17 07:28:22 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Fri Feb 8 09:30:34 2019
-// Update Count : 4
+// Last Modified By : Andrew Beach
+// Last Modified On : Thu Aug 8 16:36:00 2019
+// Update Count : 5
//
@@ -80,5 +80,6 @@
// in CastCost.cc
- Cost castCost( const Type * src, const Type * dest, const SymTab::Indexer & indexer, const TypeEnvironment & env );
+ Cost castCost( const Type * src, const Type * dest, bool srcIsLvalue,
+ const SymTab::Indexer & indexer, const TypeEnvironment & env );
Cost castCost(
const ast::Type * src, const ast::Type * dst, const ast::SymbolTable & symtab,
@@ -86,5 +87,6 @@
// in ConversionCost.cc
- Cost conversionCost( const Type * src, const Type * dest, const SymTab::Indexer & indexer, const TypeEnvironment & env );
+ Cost conversionCost( const Type * src, const Type * dest, bool srcIsLvalue,
+ const SymTab::Indexer & indexer, const TypeEnvironment & env );
Cost conversionCost(
const ast::Type * src, const ast::Type * dst, const ast::SymbolTable & symtab,
@@ -92,5 +94,5 @@
// in AlternativeFinder.cc
- Cost computeConversionCost( Type * actualType, Type * formalType,
+ Cost computeConversionCost( Type * actualType, Type * formalType, bool actualIsLvalue,
const SymTab::Indexer & indexer, const TypeEnvironment & env );
Index: src/SymTab/Validate.cc
===================================================================
--- src/SymTab/Validate.cc (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ src/SymTab/Validate.cc (revision 330d9331f47e8030558e319939939029b7791865)
@@ -9,7 +9,7 @@
// Author : Richard C. Bilson
// Created On : Sun May 17 21:50:04 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Mon Aug 28 13:47:23 2017
-// Update Count : 359
+// Last Modified By : Andrew Beach
+// Last Modified On : Wed Aug 7 6:42:00 2019
+// Update Count : 360
//
@@ -81,4 +81,5 @@
#include "SynTree/Label.h" // for operator==, Label
#include "SynTree/Mutator.h" // for Mutator
+#include "SynTree/TopLvalue.h" // for assertTopLvalue, clearInnerLvalue
#include "SynTree/Type.h" // for Type, TypeInstType, EnumInstType
#include "SynTree/TypeSubstitution.h" // for TypeSubstitution
@@ -308,4 +309,5 @@
PassVisitor fixQual;
+ assertTopLvalue( translationUnit );
{
Stats::Heap::newPass("validate-A");
@@ -316,20 +318,27 @@
acceptAll( translationUnit, epc ); // must happen before VerifyCtorDtorAssign, because void return objects should not exist; before LinkReferenceToTypes_old because it is an indexer and needs correct types for mangling
}
+ assertTopLvalue( translationUnit );
{
Stats::Heap::newPass("validate-B");
Stats::Time::BlockGuard guard("validate-B");
+ assertTopLvalue( translationUnit );
Stats::Time::TimeBlock("Link Reference To Types", [&]() {
acceptAll( translationUnit, lrt ); // must happen before autogen, because sized flag needs to propagate to generated functions
});
+ clearInnerLvalue( translationUnit );
+ assertTopLvalue( translationUnit );
Stats::Time::TimeBlock("Fix Qualified Types", [&]() {
mutateAll( translationUnit, fixQual ); // must happen after LinkReferenceToTypes_old, because aggregate members are accessed
});
+ assertTopLvalue( translationUnit );
Stats::Time::TimeBlock("Hoist Structs", [&]() {
HoistStruct::hoistStruct( translationUnit ); // must happen after EliminateTypedef, so that aggregate typedefs occur in the correct order
});
+ assertTopLvalue( translationUnit );
Stats::Time::TimeBlock("Eliminate Typedefs", [&]() {
EliminateTypedef::eliminateTypedef( translationUnit ); //
});
}
+ assertTopLvalue( translationUnit );
{
Stats::Heap::newPass("validate-C");
@@ -340,55 +349,77 @@
InitTweak::fixReturnStatements( translationUnit ); // must happen before autogen
}
+ assertTopLvalue( translationUnit );
{
Stats::Heap::newPass("validate-D");
Stats::Time::BlockGuard guard("validate-D");
+ assertTopLvalue( translationUnit );
Stats::Time::TimeBlock("Apply Concurrent Keywords", [&]() {
Concurrency::applyKeywords( translationUnit );
});
+ clearInnerLvalue( translationUnit );
+ assertTopLvalue( translationUnit );
Stats::Time::TimeBlock("Forall Pointer Decay", [&]() {
acceptAll( translationUnit, fpd ); // must happen before autogenerateRoutines, after Concurrency::applyKeywords because uniqueIds must be set on declaration before resolution
});
+ assertTopLvalue( translationUnit );
Stats::Time::TimeBlock("Hoist Control Declarations", [&]() {
ControlStruct::hoistControlDecls( translationUnit ); // hoist initialization out of for statements; must happen before autogenerateRoutines
});
+ assertTopLvalue( translationUnit );
Stats::Time::TimeBlock("Generate Autogen routines", [&]() {
autogenerateRoutines( translationUnit ); // moved up, used to be below compoundLiteral - currently needs EnumAndPointerDecay_old
});
- }
+ clearInnerLvalue( translationUnit );
+ }
+ assertTopLvalue( translationUnit );
{
Stats::Heap::newPass("validate-E");
Stats::Time::BlockGuard guard("validate-E");
+ assertTopLvalue( translationUnit );
Stats::Time::TimeBlock("Implement Mutex Func", [&]() {
Concurrency::implementMutexFuncs( translationUnit );
});
+ clearInnerLvalue( translationUnit );
+ assertTopLvalue( translationUnit );
Stats::Time::TimeBlock("Implement Thread Start", [&]() {
Concurrency::implementThreadStarter( translationUnit );
});
+ assertTopLvalue( translationUnit );
Stats::Time::TimeBlock("Compound Literal", [&]() {
mutateAll( translationUnit, compoundliteral );
});
+ assertTopLvalue( translationUnit );
Stats::Time::TimeBlock("Resolve With Expressions", [&]() {
ResolvExpr::resolveWithExprs( translationUnit ); // must happen before FixObjectType because user-code is resolved and may contain with variables
});
- }
+ clearInnerLvalue( translationUnit );
+ }
+ assertTopLvalue( translationUnit );
{
Stats::Heap::newPass("validate-F");
Stats::Time::BlockGuard guard("validate-F");
+ assertTopLvalue( translationUnit );
Stats::Time::TimeBlock("Fix Object Type", [&]() {
FixObjectType::fix( translationUnit );
});
+ assertTopLvalue( translationUnit );
Stats::Time::TimeBlock("Array Length", [&]() {
ArrayLength::computeLength( translationUnit );
});
+ clearInnerLvalue( translationUnit );
+ assertTopLvalue( translationUnit );
Stats::Time::TimeBlock("Find Special Declarations", [&]() {
Validate::findSpecialDecls( translationUnit );
});
+ assertTopLvalue( translationUnit );
Stats::Time::TimeBlock("Fix Label Address", [&]() {
mutateAll( translationUnit, labelAddrFixer );
});
+ assertTopLvalue( translationUnit );
Stats::Time::TimeBlock("Handle Attributes", [&]() {
Validate::handleAttributes( translationUnit );
});
}
+ assertTopLvalue( translationUnit );
}
Index: src/SynTree/AddressExpr.cc
===================================================================
--- src/SynTree/AddressExpr.cc (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ src/SynTree/AddressExpr.cc (revision 330d9331f47e8030558e319939939029b7791865)
@@ -42,5 +42,5 @@
AddressExpr::AddressExpr( Expression *arg ) : Expression(), arg( arg ) {
if ( arg->result ) {
- if ( arg->result->get_lvalue() ) {
+ if ( arg->get_lvalue() ) {
// lvalue, retains all layers of reference and gains a pointer inside the references
set_result( addrType( arg->result ) );
Index: src/SynTree/ApplicationExpr.cc
===================================================================
--- src/SynTree/ApplicationExpr.cc (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ src/SynTree/ApplicationExpr.cc (revision 330d9331f47e8030558e319939939029b7791865)
@@ -9,7 +9,7 @@
// Author : Richard C. Bilson
// Created On : Mon May 18 07:44:20 2015
-// Last Modified By : Rob Schluntz
-// Last Modified On : Tue Apr 26 12:41:06 2016
-// Update Count : 4
+// Last Modified By : Andrew Beach
+// Last Modified On : Mon Aug 12 14:28:00 2019
+// Update Count : 5
//
@@ -76,4 +76,8 @@
}
+bool ApplicationExpr::get_lvalue() const {
+ return result->get_lvalue();
+}
+
void ApplicationExpr::print( std::ostream &os, Indenter indent ) const {
os << "Application of" << std::endl << indent+1;
Index: src/SynTree/BasicType.cc
===================================================================
--- src/SynTree/BasicType.cc (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ src/SynTree/BasicType.cc (revision 330d9331f47e8030558e319939939029b7791865)
@@ -10,6 +10,6 @@
// Created On : Mon May 18 07:44:20 2015
// Last Modified By : Peter A. Buhr
-// Last Modified On : Thu Jan 31 21:37:36 2019
-// Update Count : 12
+// Last Modified On : Sun Aug 4 21:07:44 2019
+// Update Count : 13
//
@@ -31,39 +31,4 @@
bool BasicType::isInteger() const {
return kind <= UnsignedInt128;
-#if 0
- switch ( kind ) {
- case Bool:
- case Char:
- case SignedChar:
- case UnsignedChar:
- case ShortSignedInt:
- case ShortUnsignedInt:
- case SignedInt:
- case UnsignedInt:
- case LongSignedInt:
- case LongUnsignedInt:
- case LongLongSignedInt:
- case LongLongUnsignedInt:
- case SignedInt128:
- case UnsignedInt128:
- return true;
- case Float:
- case Double:
- case LongDouble:
- case FloatComplex:
- case DoubleComplex:
- case LongDoubleComplex:
- case FloatImaginary:
- case DoubleImaginary:
- case LongDoubleImaginary:
- case Float80:
- case Float128:
- return false;
- case NUMBER_OF_BASIC_TYPES:
- assert( false );
- } // switch
- assert( false );
- return false;
-#endif
}
Index: src/SynTree/CommaExpr.cc
===================================================================
--- src/SynTree/CommaExpr.cc (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ src/SynTree/CommaExpr.cc (revision 330d9331f47e8030558e319939939029b7791865)
@@ -9,7 +9,7 @@
// Author : Richard C. Bilson
// Created On : Mon May 18 07:44:20 2015
-// Last Modified By : Rob Schluntz
-// Last Modified On : Mon May 02 15:19:44 2016
-// Update Count : 1
+// Last Modified By : Andrew Beach
+// Last Modified On : Mon Arg 12 16:11:00 2016
+// Update Count : 2
//
@@ -39,4 +39,9 @@
}
+bool CommaExpr::get_lvalue() const {
+ // xxx - as above, shouldn't be an lvalue but that information is used anyways.
+ return result->get_lvalue();
+}
+
void CommaExpr::print( std::ostream &os, Indenter indent ) const {
os << "Comma Expression:" << std::endl;
Index: src/SynTree/Expression.cc
===================================================================
--- src/SynTree/Expression.cc (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ src/SynTree/Expression.cc (revision 330d9331f47e8030558e319939939029b7791865)
@@ -9,7 +9,7 @@
// Author : Richard C. Bilson
// Created On : Mon May 18 07:44:20 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Thu Jul 25 22:21:48 2019
-// Update Count : 61
+// Last Modified By : Andrew Beach
+// Last Modified On : Thr Aug 15 13:43:00 2019
+// Update Count : 64
//
@@ -63,4 +63,9 @@
}
+bool Expression::get_lvalue() const {
+ assert( !result->get_lvalue() );
+ return false;
+}
+
void Expression::print( std::ostream & os, Indenter indent ) const {
printInferParams( inferParams, os, indent+1, 0 );
@@ -134,4 +139,8 @@
}
+bool VariableExpr::get_lvalue() const {
+ return result->get_lvalue();
+}
+
VariableExpr * VariableExpr::functionPointer( FunctionDecl * func ) {
VariableExpr * funcExpr = new VariableExpr( func );
@@ -265,4 +274,8 @@
CastExpr::~CastExpr() {
delete arg;
+}
+
+bool CastExpr::get_lvalue() const {
+ return result->get_lvalue();
}
@@ -376,4 +389,9 @@
// don't delete the member declaration, since it points somewhere else in the tree
delete aggregate;
+}
+
+bool MemberExpr::get_lvalue() const {
+ assert( result->get_lvalue() );
+ return true;
}
@@ -428,4 +446,7 @@
}
+bool UntypedExpr::get_lvalue() const {
+ return result->get_lvalue();
+}
void UntypedExpr::print( std::ostream & os, Indenter indent ) const {
@@ -486,4 +507,8 @@
delete arg2;
delete arg3;
+}
+
+bool ConditionalExpr::get_lvalue() const {
+ return result->get_lvalue();
}
@@ -544,4 +569,8 @@
}
+bool ConstructorExpr::get_lvalue() const {
+ return result->get_lvalue();
+}
+
void ConstructorExpr::print( std::ostream & os, Indenter indent ) const {
os << "Constructor Expression: " << std::endl << indent+1;
@@ -561,4 +590,9 @@
CompoundLiteralExpr::~CompoundLiteralExpr() {
delete initializer;
+}
+
+bool CompoundLiteralExpr::get_lvalue() const {
+ assert( result->get_lvalue() );
+ return true;
}
@@ -612,4 +646,7 @@
result = new VoidType( Type::Qualifiers() );
}
+}
+bool StmtExpr::get_lvalue() const {
+ return result->get_lvalue();
}
void StmtExpr::print( std::ostream & os, Indenter indent ) const {
Index: src/SynTree/Expression.h
===================================================================
--- src/SynTree/Expression.h (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ src/SynTree/Expression.h (revision 330d9331f47e8030558e319939939029b7791865)
@@ -9,7 +9,7 @@
// Author : Richard C. Bilson
// Created On : Mon May 18 07:44:20 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Thu Jul 25 22:21:44 2019
-// Update Count : 50
+// Last Modified By : Andrew Beach
+// Last Modified On : Thr Aug 15 13:46:00 2019
+// Update Count : 54
//
@@ -71,4 +71,5 @@
const Type * get_result() const { return result; }
void set_result( Type * newValue ) { result = newValue; }
+ virtual bool get_lvalue() const;
TypeSubstitution * get_env() const { return env; }
@@ -98,4 +99,6 @@
virtual ~ApplicationExpr();
+ bool get_lvalue() const final;
+
Expression * get_function() const { return function; }
void set_function( Expression * newValue ) { function = newValue; }
@@ -120,4 +123,6 @@
UntypedExpr( const UntypedExpr & other );
virtual ~UntypedExpr();
+
+ bool get_lvalue() const final;
Expression * get_function() const { return function; }
@@ -208,4 +213,6 @@
virtual ~CastExpr();
+ bool get_lvalue() const final;
+
Expression * get_arg() const { return arg; }
void set_arg( Expression * newValue ) { arg = newValue; }
@@ -291,4 +298,6 @@
virtual ~MemberExpr();
+ bool get_lvalue() const final;
+
DeclarationWithType * get_member() const { return member; }
void set_member( DeclarationWithType * newValue ) { member = newValue; }
@@ -313,4 +322,6 @@
VariableExpr( const VariableExpr & other );
virtual ~VariableExpr();
+
+ bool get_lvalue() const final;
DeclarationWithType * get_var() const { return var; }
@@ -500,4 +511,6 @@
virtual ~ConditionalExpr();
+ bool get_lvalue() const final;
+
Expression * get_arg1() const { return arg1; }
void set_arg1( Expression * newValue ) { arg1 = newValue; }
@@ -524,4 +537,6 @@
virtual ~CommaExpr();
+ bool get_lvalue() const final;
+
Expression * get_arg1() const { return arg1; }
void set_arg1( Expression * newValue ) { arg1 = newValue; }
@@ -610,4 +625,6 @@
~ConstructorExpr();
+ bool get_lvalue() const final;
+
Expression * get_callExpr() const { return callExpr; }
void set_callExpr( Expression * newValue ) { callExpr = newValue; }
@@ -628,4 +645,6 @@
CompoundLiteralExpr( const CompoundLiteralExpr & other );
virtual ~CompoundLiteralExpr();
+
+ bool get_lvalue() const final;
Initializer * get_initializer() const { return initializer; }
@@ -686,4 +705,6 @@
virtual ~TupleExpr();
+ bool get_lvalue() const final;
+
std::list& get_exprs() { return exprs; }
@@ -704,4 +725,6 @@
TupleIndexExpr( const TupleIndexExpr & other );
virtual ~TupleIndexExpr();
+
+ bool get_lvalue() const final;
Expression * get_tuple() const { return tuple; }
@@ -753,4 +776,6 @@
StmtExpr( const StmtExpr & other );
virtual ~StmtExpr();
+
+ bool get_lvalue() const final;
CompoundStmt * get_statements() const { return statements; }
Index: src/SynTree/TopLvalue.cc
===================================================================
--- src/SynTree/TopLvalue.cc (revision 330d9331f47e8030558e319939939029b7791865)
+++ src/SynTree/TopLvalue.cc (revision 330d9331f47e8030558e319939939029b7791865)
@@ -0,0 +1,132 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// TopLvalue.cc -- Check and force that lvalue is only at the top of types.
+//
+// Author : Andrew Beach
+// Created On : Wed Jul 31 15:49:00 2019
+// Last Modified By : Andrew Beach
+// Last Modified On : Wed Aug 7 15:36:00 2019
+// Update Count : 0
+//
+
+#include
+
+#include "Common/PassVisitor.h"
+
+namespace {
+ class TopLvalue : public WithGuards {
+ bool inType = false;
+ public:
+ void previsit( const BaseSyntaxNode * ) {
+ if ( inType ) {
+ GuardValue( inType );
+ inType = false;
+ }
+ }
+
+ void previsit( const Type * type ) {
+ if ( inType ) {
+ assert( !type->get_lvalue() );
+ } else {
+ GuardValue( inType );
+ inType = true;
+ }
+ }
+
+ };
+
+ class ClearLvalue : public WithGuards {
+ bool inType = false;
+ public:
+ void previsit( BaseSyntaxNode * ) {
+ if ( inType ) {
+ GuardValue( inType );
+ inType = false;
+ }
+ }
+
+ void previsit( Type * type ) {
+ if ( !inType ) {
+ GuardValue( inType );
+ inType = true;
+ } else if ( type->get_lvalue() ) {
+ type->set_lvalue( false );
+ }
+ }
+ };
+
+ class TopLvaluePrint : public WithGuards, public WithShortCircuiting {
+ bool failed = false;
+ bool inType = false;
+ bool typeTop = false;
+ public:
+ bool failedAny = false;
+ void previsit() {
+ if ( failed ) {
+ visit_children = false;
+ } else if ( typeTop ) {
+ GuardValue( typeTop );
+ typeTop = false;
+ }
+ }
+
+ void previsit( const BaseSyntaxNode * ) {
+ previsit();
+ if ( inType ) {
+ GuardValue( inType );
+ inType = false;
+ }
+ }
+
+ void previsit( const Type * type ) {
+ previsit();
+ if ( inType ) {
+ if ( type->get_lvalue() ) {
+ failed = true;
+ failedAny = true;
+ visit_children = false;
+ std::cout << type->location << std::endl;
+ }
+ //assert( !type->get_lvalue() );
+ } else {
+ GuardValue( inType );
+ inType = true;
+ typeTop = true;
+ }
+ }
+
+ void postvisit( const Type * type ) {
+ if ( typeTop ) {
+ if ( failed ) {
+ std::cout << type->location << std::endl;
+ type->print( std::cout );
+ //assert( !failed );
+ failed = false;
+ }
+ typeTop = false;
+ }
+ }
+ };
+}
+
+void assertTopLvalue( const std::list< Declaration * > & translationUnit ) {
+ PassVisitor< TopLvaluePrint > visitor;
+ acceptAll( translationUnit, visitor );
+ assert( !visitor.pass.failedAny );
+}
+
+void clearInnerLvalue( std::list< Declaration * > & translationUnit ) {
+ PassVisitor< ClearLvalue > visitor;
+ acceptAll( translationUnit, visitor );
+}
+
+
+// Local Variables: //
+// tab-width: 4 //
+// mode: c++ //
+// compile-command: "make install" //
+// End: //
Index: src/SynTree/TopLvalue.h
===================================================================
--- src/SynTree/TopLvalue.h (revision 330d9331f47e8030558e319939939029b7791865)
+++ src/SynTree/TopLvalue.h (revision 330d9331f47e8030558e319939939029b7791865)
@@ -0,0 +1,34 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// TopLvalue.h -- Check and force that lvalue is only at the top of types.
+//
+// Author : Andrew Beach
+// Created On : Wed Jul 31 16:04:00 2019
+// Last Modified By : Andrew Beach
+// Last Modified On : Wed Aug 7 15:26:00 2019
+// Update Count : 0
+//
+
+#include
+class Declaration;
+
+void assertTopLvalue( const std::list< Declaration * > & translationUnit );
+/* Assert that all lvalue qualifiers are set on the top level.
+ *
+ * Does not return if the test fails.
+ */
+
+void clearInnerLvalue( std::list< Declaration * > & translationUnit );
+/* Make all types that are not at the top level rvalues (not-lvalues).
+ */
+
+// Local Variables: //
+// tab-width: 4 //
+// mode: c++ //
+// compile-command: "make install" //
+// End: //
+
Index: src/SynTree/TupleExpr.cc
===================================================================
--- src/SynTree/TupleExpr.cc (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ src/SynTree/TupleExpr.cc (revision 330d9331f47e8030558e319939939029b7791865)
@@ -9,7 +9,7 @@
// Author : Richard C. Bilson
// Created On : Mon May 18 07:44:20 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Fri Mar 17 09:42:29 2017
-// Update Count : 3
+// Last Modified By : Andrew Beach
+// Last Modified On : Wed Aug 14 14:34:00 2019
+// Update Count : 5
//
@@ -57,4 +57,8 @@
}
+bool TupleExpr::get_lvalue() const {
+ return result->get_lvalue();
+}
+
void TupleExpr::print( std::ostream &os, Indenter indent ) const {
os << "Tuple:" << std::endl;
@@ -76,4 +80,9 @@
TupleIndexExpr::~TupleIndexExpr() {
delete tuple;
+}
+
+bool TupleIndexExpr::get_lvalue() const {
+ assert( result->get_lvalue() );
+ return true;
}
Index: src/SynTree/Type.cc
===================================================================
--- src/SynTree/Type.cc (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ src/SynTree/Type.cc (revision 330d9331f47e8030558e319939939029b7791865)
@@ -9,7 +9,7 @@
// Author : Richard C. Bilson
// Created On : Mon May 18 07:44:20 2015
-// Last Modified By : Andrew Beach
-// Last Modified On : Fri Jul 12 15:48:00 2019
-// Update Count : 44
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Sun Aug 4 21:05:07 2019
+// Update Count : 45
//
#include "Type.h"
@@ -24,46 +24,5 @@
using namespace std;
-const char *BasicType::typeNames[] = {
-#if 0
- "_Bool",
- "char",
- "signed char",
- "unsigned char",
- "signed short int",
- "unsigned short int",
- "signed int",
- "unsigned int",
- "signed long int",
- "unsigned long int",
- "signed long long int",
- "unsigned long long int",
- "float",
- "double",
- "long double",
- "float _Complex",
- "double _Complex",
- "long double _Complex",
- "float _Imaginary",
- "double _Imaginary",
- "long double _Imaginary",
- "__int128",
- "unsigned __int128",
- "__float80",
- "__float128",
- "_Float16",
- "_Float32",
- "_Float32x",
- "_Float64",
- "_Float64x",
- "_Float128",
- "_Float128x",
- "_Float16 _Complex",
- "_Float32 _Complex",
- "_Float32x _Complex",
- "_Float64 _Complex",
- "_Float64x _Complex",
- "_Float128 _Complex",
- "_Float128x _Complex",
-#endif
+const char * BasicType::typeNames[] = {
"_Bool",
"char",
@@ -107,5 +66,5 @@
};
static_assert(
- sizeof(BasicType::typeNames)/sizeof(BasicType::typeNames[0]) == BasicType::NUMBER_OF_BASIC_TYPES,
+ sizeof(BasicType::typeNames) / sizeof(BasicType::typeNames[0]) == BasicType::NUMBER_OF_BASIC_TYPES,
"Each basic type name should have a corresponding kind enum value"
);
@@ -152,5 +111,5 @@
TypeSubstitution Type::genericSubstitution() const { assertf( false, "Non-aggregate type: %s", toCString( this ) ); }
-void Type::print( std::ostream &os, Indenter indent ) const {
+void Type::print( std::ostream & os, Indenter indent ) const {
if ( ! forall.empty() ) {
os << "forall" << std::endl;
Index: src/SynTree/module.mk
===================================================================
--- src/SynTree/module.mk (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ src/SynTree/module.mk (revision 330d9331f47e8030558e319939939029b7791865)
@@ -49,5 +49,6 @@
SynTree/TypeSubstitution.cc \
SynTree/Attribute.cc \
- SynTree/DeclReplacer.cc
+ SynTree/DeclReplacer.cc \
+ SynTree/TopLvalue.cc
SRC += $(SRC_SYNTREE)
Index: src/main.cc
===================================================================
--- src/main.cc (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ src/main.cc (revision 330d9331f47e8030558e319939939029b7791865)
@@ -10,6 +10,6 @@
// Created On : Fri May 15 23:12:02 2015
// Last Modified By : Peter A. Buhr
-// Last Modified On : Wed Jun 5 20:35:13 2019
-// Update Count : 601
+// Last Modified On : Fri Aug 23 06:50:08 2019
+// Update Count : 607
//
@@ -17,8 +17,8 @@
#include // for backtrace, backtrace_symbols
#include // for no_argument, optind, geto...
-#include // for signal, SIGABRT, SIGSEGV
#include // for assertf
#include // for fopen, FILE, fclose, stdin
#include // for exit, free, abort, EXIT_F...
+#include // for signal, SIGABRT, SIGSEGV
#include // for index
#include // for ofstream
@@ -59,8 +59,10 @@
#include "ResolvExpr/Resolver.h" // for resolve
#include "SymTab/Validate.h" // for validate
+#include "SynTree/TopLvalue.h" // for assertTopLvalue, clearInn...
#include "SynTree/Declaration.h" // for Declaration
#include "SynTree/Visitor.h" // for acceptAll
#include "Tuples/Tuples.h" // for expandMemberTuples, expan...
#include "Virtual/ExpandCasts.h" // for expandCasts
+
using namespace std;
@@ -94,7 +96,9 @@
DeclarationNode * parseTree = nullptr; // program parse tree
+static bool waiting_for_gdb = false; // flag to set cfa-cpp to wait for gdb on start
+
static std::string PreludeDirector = "";
-static void parse_cmdline( int argc, char *argv[], const char *& filename );
+static void parse_cmdline( int argc, char *argv[] );
static void parse( FILE * input, LinkageSpec::Spec linkage, bool shouldExit = false );
static void dump( list< Declaration * > & translationUnit, ostream & out = cout );
@@ -165,9 +169,7 @@
} // sigAbortHandler
-
int main( int argc, char * argv[] ) {
FILE * input; // use FILE rather than istream because yyin is FILE
ostream * output = & cout;
- const char * filename = nullptr;
list< Declaration * > translationUnit;
@@ -181,6 +183,13 @@
// } // for
- parse_cmdline( argc, argv, filename ); // process command-line arguments
+ parse_cmdline( argc, argv ); // process command-line arguments
CodeGen::FixMain::setReplaceMain( !nomainp );
+
+ if ( waiting_for_gdb ) {
+ std::cerr << "Waiting for gdb" << std::endl;
+ std::cerr << "run :" << std::endl;
+ std::cerr << " gdb attach " << getpid() << std::endl;
+ raise(SIGSTOP);
+ } // if
try {
@@ -188,15 +197,8 @@
if ( optind < argc ) { // any commands after the flags ? => input file name
input = fopen( argv[ optind ], "r" );
- assertf( input, "cannot open %s\n", argv[ optind ] );
- // if running cfa-cpp directly, might forget to pass -F option (and really shouldn't have to)
- if ( filename == nullptr ) filename = argv[ optind ];
- // prelude filename comes in differently
- if ( libcfap ) filename = "prelude.cfa";
+ assertf( input, "cannot open %s because %s\n", argv[ optind ], strerror( errno ) );
optind += 1;
} else { // no input file name
input = stdin;
- // if running cfa-cpp directly, might forget to pass -F option. Since this takes from stdin, pass
- // a fake name along
- if ( filename == nullptr ) filename = "stdin";
} // if
@@ -257,4 +259,8 @@
Stats::Time::StopBlock();
+ //std::cerr << "Post-Parse Check" << std::endl;
+ clearInnerLvalue( translationUnit );
+ assertTopLvalue( translationUnit );
+
// add the assignment statement after the initialization of a type parameter
PASS( "Validate", SymTab::validate( translationUnit, symtabp ) );
@@ -275,8 +281,13 @@
} // if
+ assertTopLvalue( translationUnit );
PASS( "Fix Labels", ControlStruct::fixLabels( translationUnit ) );
+ assertTopLvalue( translationUnit );
PASS( "Fix Names", CodeGen::fixNames( translationUnit ) );
+ assertTopLvalue( translationUnit );
PASS( "Gen Init", InitTweak::genInit( translationUnit ) );
+ assertTopLvalue( translationUnit );
PASS( "Expand Member Tuples" , Tuples::expandMemberTuples( translationUnit ) );
+ assertTopLvalue( translationUnit );
if ( libcfap ) {
// generate the bodies of cfa library functions
@@ -302,4 +313,6 @@
} // if
+ assertTopLvalue( translationUnit );
+
PASS( "Resolve", ResolvExpr::resolve( translationUnit ) );
if ( exprp ) {
@@ -308,6 +321,11 @@
} // if
+ clearInnerLvalue( translationUnit );
+ assertTopLvalue( translationUnit );
+
// fix ObjectDecl - replaces ConstructorInit nodes
PASS( "Fix Init", InitTweak::fix( translationUnit, buildingLibrary() ) );
+ clearInnerLvalue( translationUnit );
+ assertTopLvalue( translationUnit );
if ( ctorinitp ) {
dump ( translationUnit );
@@ -316,12 +334,19 @@
PASS( "Expand Unique Expr", Tuples::expandUniqueExpr( translationUnit ) ); // xxx - is this the right place for this? want to expand ASAP so tha, sequent passes don't need to worry about double-visiting a unique expr - needs to go after InitTweak::fix so that copy constructed return declarations are reused
+ assertTopLvalue( translationUnit );
PASS( "Translate EHM" , ControlStruct::translateEHM( translationUnit ) );
+ assertTopLvalue( translationUnit );
PASS( "Gen Waitfor" , Concurrency::generateWaitFor( translationUnit ) );
+ clearInnerLvalue( translationUnit );
+ assertTopLvalue( translationUnit );
PASS( "Convert Specializations", GenPoly::convertSpecializations( translationUnit ) ); // needs to happen before tuple types are expanded
+ clearInnerLvalue( translationUnit );
+ assertTopLvalue( translationUnit );
PASS( "Expand Tuples", Tuples::expandTuples( translationUnit ) ); // xxx - is this the right place for this?
+ assertTopLvalue( translationUnit );
if ( tuplep ) {
@@ -331,4 +356,5 @@
PASS( "Virtual Expand Casts", Virtual::expandCasts( translationUnit ) ); // Must come after translateEHM
+ assertTopLvalue( translationUnit );
PASS( "Instantiate Generics", GenPoly::instantiateGeneric( translationUnit ) );
@@ -337,6 +363,9 @@
return EXIT_SUCCESS;
} // if
+ clearInnerLvalue( translationUnit );
+ assertTopLvalue( translationUnit );
PASS( "Convert L-Value", GenPoly::convertLvalue( translationUnit ) );
-
+ clearInnerLvalue( translationUnit );
+ assertTopLvalue( translationUnit );
if ( bboxp ) {
@@ -345,4 +374,6 @@
} // if
PASS( "Box", GenPoly::box( translationUnit ) );
+ clearInnerLvalue( translationUnit );
+ assertTopLvalue( translationUnit );
if ( bcodegenp ) {
@@ -356,4 +387,5 @@
CodeTools::fillLocations( translationUnit );
+ assertTopLvalue( translationUnit );
PASS( "Code Gen", CodeGen::generate( translationUnit, *output, ! genproto, prettycodegenp, true, linemarks ) );
@@ -406,5 +438,5 @@
-static const char optstring[] = ":hlLmNnpP:S:twW:D:F:";
+static const char optstring[] = ":hlLmNnpP:S:twW:D:";
enum { PreludeDir = 128 };
@@ -421,8 +453,8 @@
{ "statistics", required_argument, nullptr, 'S' },
{ "tree", no_argument, nullptr, 't' },
+ { "gdb", no_argument, nullptr, 'g' },
{ "", no_argument, nullptr, 0 }, // -w
{ "", no_argument, nullptr, 0 }, // -W
{ "", no_argument, nullptr, 0 }, // -D
- { "", no_argument, nullptr, 0 }, // -F
{ nullptr, 0, nullptr, 0 }
}; // long_opts
@@ -439,9 +471,9 @@
" prelude directory for debug/nodebug", // no flag
" enable profiling information:\n counters,heap,time,all,none", // -S
- "build in tree", // -t
+ "building cfa standard lib", // -t
+ "wait for gdb to attach", // -g
"", // -w
"", // -W
"", // -D
- "", // -F
}; // description
@@ -478,5 +510,5 @@
static void usage( char *argv[] ) {
- cout << "Usage: " << argv[0] << " options are:" << endl;
+ cout << "Usage: " << argv[0] << " [options] [input-file (default stdin)] [output-file (default stdout)], where options are:" << endl;
int i = 0, j = 1; // j skips starting colon
for ( ; long_opts[i].name != 0 && optstring[j] != '\0'; i += 1, j += 1 ) {
@@ -504,5 +536,5 @@
} // usage
-static void parse_cmdline( int argc, char * argv[], const char *& filename ) {
+static void parse_cmdline( int argc, char * argv[] ) {
opterr = 0; // (global) prevent getopt from printing error messages
@@ -550,6 +582,9 @@
Stats::parse_params( optarg );
break;
- case 't': // build in tree
+ case 't': // building cfa stdlib
treep = true;
+ break;
+ case 'g': // wait for gdb
+ waiting_for_gdb = true;
break;
case 'w': // suppress all warnings, hidden
@@ -575,7 +610,4 @@
case 'D': // ignore -Dxxx, forwarded by cpp, hidden
break;
- case 'F': // source file-name without suffix, hidden
- filename = optarg;
- break;
case '?': // unknown option
if ( optopt ) { // short option ?
Index: tests/.expect/gccExtensions.x64.txt
===================================================================
--- tests/.expect/gccExtensions.x64.txt (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ tests/.expect/gccExtensions.x64.txt (revision 330d9331f47e8030558e319939939029b7791865)
@@ -291,9 +291,26 @@
signed int _X2m2A0A0i_2[((unsigned long int )10)][((unsigned long int )10)];
signed int _X2m3A0A0i_2[((unsigned long int )10)][((unsigned long int )10)];
- {
- ((void)(_X12_retval_maini_1=0) /* ?{} */);
- }
-
- return _X12_retval_maini_1;
+ void _X4f128Fv_n__2(__int128 _X1in_2);
+ void _X4f128Fv_o__2(unsigned __int128 __anonymous_object0);
+ __int128 _X6i128_0n_2;
+ {
+ ((void)_X4f128Fv_n__2(_X6i128_0n_2));
+ }
+
+ unsigned __int128 _X6i128_1o_2;
+ {
+ ((void)_X4f128Fv_o__2(_X6i128_1o_2));
+ }
+
+ __int128 _X6i128_2n_2;
+ {
+ ((void)_X4f128Fv_n__2(_X6i128_2n_2));
+ }
+
+ unsigned __int128 _X6i128_3o_2;
+ {
+ ((void)_X4f128Fv_o__2(_X6i128_3o_2));
+ }
+
{
((void)(_X12_retval_maini_1=0) /* ?{} */);
Index: tests/.expect/gccExtensions.x86.txt
===================================================================
--- tests/.expect/gccExtensions.x86.txt (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ tests/.expect/gccExtensions.x86.txt (revision 330d9331f47e8030558e319939939029b7791865)
@@ -296,9 +296,4 @@
return _X12_retval_maini_1;
- {
- ((void)(_X12_retval_maini_1=0) /* ?{} */);
- }
-
- return _X12_retval_maini_1;
}
static inline int invoke_main(int argc, char* argv[], char* envp[]) { (void)argc; (void)argv; (void)envp; return _X4mainFi_iPPKc__1((signed int )argc, (const char **)argv); }
Index: tests/Makefile.am
===================================================================
--- tests/Makefile.am (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ tests/Makefile.am (revision 330d9331f47e8030558e319939939029b7791865)
@@ -22,4 +22,5 @@
debug=yes
installed=no
+archiveerrors=
INSTALL_FLAGS=-in-tree
@@ -56,8 +57,8 @@
#----------------------------------------------------------------------------------------------------------------
all-local :
- @+${TEST_PY} --debug=${debug} --install=${installed} ${concurrent} ${timeouts} ${quick_test}
+ @+${TEST_PY} --debug=${debug} --install=${installed} --archive-errors=${archiveerrors} ${concurrent} ${timeouts} ${quick_test}
all-tests :
- @+${TEST_PY} --debug=${debug} --install=${installed} ${concurrent} ${timeouts} --all # '@' => do not echo command (SILENT), '+' => allows recursive make from within python program
+ @+${TEST_PY} --debug=${debug} --install=${installed} --archive-errors=${archiveerrors} ${concurrent} ${timeouts} --all # '@' => do not echo command (SILENT), '+' => allows recursive make from within python program
clean-local :
Index: tests/Makefile.in
===================================================================
--- tests/Makefile.in (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ tests/Makefile.in (revision 330d9331f47e8030558e319939939029b7791865)
@@ -235,4 +235,5 @@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
+DEMANGLER = @DEMANGLER@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
@@ -260,4 +261,5 @@
LIBCFA_TARGET_DIRS = @LIBCFA_TARGET_DIRS@
LIBCFA_TARGET_MAKEFILES = @LIBCFA_TARGET_MAKEFILES@
+LIBDEMANGLE = @LIBDEMANGLE@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
@@ -375,4 +377,5 @@
debug = yes
installed = no
+archiveerrors =
INSTALL_FLAGS = -in-tree
DEBUG_FLAGS = -debug -O0
@@ -768,8 +771,8 @@
#----------------------------------------------------------------------------------------------------------------
all-local :
- @+${TEST_PY} --debug=${debug} --install=${installed} ${concurrent} ${timeouts} ${quick_test}
+ @+${TEST_PY} --debug=${debug} --install=${installed} --archive-errors=${archiveerrors} ${concurrent} ${timeouts} ${quick_test}
all-tests :
- @+${TEST_PY} --debug=${debug} --install=${installed} ${concurrent} ${timeouts} --all # '@' => do not echo command (SILENT), '+' => allows recursive make from within python program
+ @+${TEST_PY} --debug=${debug} --install=${installed} --archive-errors=${archiveerrors} ${concurrent} ${timeouts} --all # '@' => do not echo command (SILENT), '+' => allows recursive make from within python program
clean-local :
Index: tests/gccExtensions.cfa
===================================================================
--- tests/gccExtensions.cfa (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ tests/gccExtensions.cfa (revision 330d9331f47e8030558e319939939029b7791865)
@@ -10,6 +10,6 @@
// Created On : Sun Aug 14 17:28:17 2016
// Last Modified By : Peter A. Buhr
-// Last Modified On : Tue Nov 6 17:54:20 2018
-// Update Count : 11
+// Last Modified On : Mon Aug 5 18:04:37 2019
+// Update Count : 28
//
@@ -50,9 +50,9 @@
L1: L2:
- asm goto ( "frob %%r5, %1; jc %l[L1]; mov (%2), %%r5"
- : /* No outputs. */
- : "r"(src), "r"(&dst)
- : "r5", "memory"
- : L1, L2 );
+ asm goto ( "frob %%r5, %1; jc %l[L1]; mov (%2), %%r5"
+ : /* No outputs. */
+ : "r"(src), "r"(&dst)
+ : "r5", "memory"
+ : L1, L2 );
// alternative type/qualifer names
@@ -110,10 +110,24 @@
struct __attribute(()) s4 { int i; } x2, y2 __attribute(());
- int m1 [10] __attribute(());
- int m2 [10][10] __attribute(());
+ int m1[10] __attribute(());
+ int m2[10][10] __attribute(());
int __attribute(()) m3 [10][10];
// int ( __attribute(()) m4 [10] )[10];
- return 0;
+ // int128
+
+#if defined( __SIZEOF_INT128__ )
+ void f128( __int128 i );
+ void f128( __uint128_t );
+
+ __int128 i128_0;
+ f128( i128_0 );
+ unsigned __int128 i128_1;
+ f128( i128_1 );
+ __int128_t i128_2;
+ f128( i128_2 );
+ __uint128_t i128_3;
+ f128( i128_3 );
+#endif
}
Index: tests/pybin/settings.py
===================================================================
--- tests/pybin/settings.py (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ tests/pybin/settings.py (revision 330d9331f47e8030558e319939939029b7791865)
@@ -4,5 +4,8 @@
from . import tools
+global original_path
+
try :
+ original_path = os.getcwd()
testpath = os.path.dirname(os.path.abspath(os.path.join(os.getcwd(), sys.argv[0])))
sys.path.append(testpath)
@@ -19,15 +22,15 @@
class Architecture:
KnownArchitectures = {
- 'x64' : 'x64',
- 'x86-64' : 'x64',
- 'x86_64' : 'x64',
- 'aarch64' : 'x64',
- 'x86' : 'x86',
+ 'x64' : 'x64',
+ 'x86-64' : 'x64',
+ 'x86_64' : 'x64',
+ 'x86' : 'x86',
+ 'aarch64' : 'arm',
'i386' : 'x86',
'i486' : 'x86',
'i686' : 'x86',
'Intel 80386' : 'x86',
- 'arm' : 'arm',
- 'ARM' : 'arm',
+ 'arm' : 'arm',
+ 'ARM' : 'arm',
}
@@ -113,4 +116,5 @@
global timeout
global output_width
+ global archive
dry_run = options.dry_run
@@ -122,4 +126,5 @@
timeout = Timeouts(options.timeout, options.global_timeout)
output_width = 24
+ archive = os.path.abspath(os.path.join(original_path, options.archive_errors)) if options.archive_errors else None
Index: tests/pybin/tools.py
===================================================================
--- tests/pybin/tools.py (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ tests/pybin/tools.py (revision 330d9331f47e8030558e319939939029b7791865)
@@ -2,4 +2,5 @@
import argparse
import contextlib
+import datetime
import fileinput
import multiprocessing
@@ -273,4 +274,9 @@
################################################################################
+def pretty_now():
+ ts = time.time()
+ print(ts, file=sys.stderr)
+ return datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d_%H:%M:%S')
+
# check if arguments is yes or no
def yes_no(string):
@@ -304,4 +310,21 @@
return sh('gdb', '-n', path, core, '-batch', '-x', cmd, output=subprocess.PIPE)
+def core_archive(dst, name, exe):
+ # Get the files to copy
+ core = os.path.join(os.getcwd(), "core" )
+
+ # Uncomment if we want timestamps on coredumps
+ # dst = os.path.join(dst, "%s_%s" % (name, pretty_now()))
+
+ # make a directory for this test
+ mkdir(os.path.join(dst, "dir"))
+
+ # moves the files
+ mv( core, os.path.join(dst, "core" ) )
+ mv( exe , os.path.join(dst, name ) )
+
+ # return explanatory test
+ return "Archiving %s (executable and core) to %s" % (os.path.relpath(exe, settings.BUILDDIR), os.path.relpath(dst, settings.original_path))
+
class Timed:
def __enter__(self):
Index: tests/test.py
===================================================================
--- tests/test.py (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ tests/test.py (revision 330d9331f47e8030558e319939939029b7791865)
@@ -91,4 +91,5 @@
parser.add_argument('--all', help='Run all test available', action='store_true')
parser.add_argument('--regenerate-expected', help='Regenerate the .expect by running the specified tets, can be used with --all option', action='store_true')
+ parser.add_argument('--archive-errors', help='If called with a valid path, on test crashes the test script will copy the core dump and the executable to the specified path.', type=str, default='')
parser.add_argument('-j', '--jobs', help='Number of tests to run simultaneously', type=int)
parser.add_argument('--list-comp', help='List all valide arguments', action='store_true')
@@ -179,4 +180,7 @@
error = error + info if error else info
+ if settings.archive:
+ error = error + '\n' + core_archive(settings.archive, test.target(), exe_file)
+
@@ -295,5 +299,5 @@
# users may want to simply list the tests
if options.list_comp :
- print("-h --help --debug --dry-run --list --arch --all --regenerate-expected --install --timeout --global-timeout -j --jobs ", end='')
+ print("-h --help --debug --dry-run --list --arch --all --regenerate-expected --archive-errors --install --timeout --global-timeout -j --jobs ", end='')
print(" ".join(map(lambda t: "%s" % (t.target()), tests)))
Index: tools/Makefile.in
===================================================================
--- tools/Makefile.in (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ tools/Makefile.in (revision 330d9331f47e8030558e319939939029b7791865)
@@ -225,4 +225,5 @@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
+DEMANGLER = @DEMANGLER@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
@@ -250,4 +251,5 @@
LIBCFA_TARGET_DIRS = @LIBCFA_TARGET_DIRS@
LIBCFA_TARGET_MAKEFILES = @LIBCFA_TARGET_MAKEFILES@
+LIBDEMANGLE = @LIBDEMANGLE@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
Index: tools/prettyprinter/Makefile.in
===================================================================
--- tools/prettyprinter/Makefile.in (revision f9bf142ef442d7af8e2d6db94b4a55098b694cfd)
+++ tools/prettyprinter/Makefile.in (revision 330d9331f47e8030558e319939939029b7791865)
@@ -254,4 +254,5 @@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
+DEMANGLER = @DEMANGLER@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
@@ -279,4 +280,5 @@
LIBCFA_TARGET_DIRS = @LIBCFA_TARGET_DIRS@
LIBCFA_TARGET_MAKEFILES = @LIBCFA_TARGET_MAKEFILES@
+LIBDEMANGLE = @LIBDEMANGLE@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@