Changeset bedb40e for driver


Ignore:
Timestamp:
Sep 10, 2018, 5:17:34 PM (7 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
Children:
67982887, 9fce933a
Parents:
0cf9ffd (diff), e15ba975 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg2.cs.uwaterloo.ca:software/cfa/cfa-cc

Location:
driver
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • driver/as.cc

    r0cf9ffd rbedb40e  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // as.c --
     7// as.c -- map assembler file, scan for debug information. If found, expand file by one character and insert Cforall
     8//         language code on the N line from the start of the debug information.
    89//
    910// Author           : Peter A. Buhr
    1011// Created On       : Wed Aug  1 10:49:42 2018
    1112// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 22 17:30:24 2018
    13 // Update Count     : 93
     13// Last Modified On : Sat Sep  8 08:40:16 2018
     14// Update Count     : 97
    1415//
    1516
     
    4344        off_t size = mystat.st_size;
    4445
    45         char * start = (char *)mmap( NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0 );
    46         if ( start == (void *)-1 ) { perror( "mmap" ); exit( EXIT_FAILURE ); };
     46        if ( size ) {                                                                           // cannot map 0 sized file
     47                char * start = (char *)mmap( NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0 );
     48                if ( start == (void *)-1 ) { perror( "mmap" ); exit( EXIT_FAILURE ); };
    4749
    48         if ( char * cursor = strstr( start, ".Ldebug_info0:" ) ) { // debug information ?
    49                 // Expand file by one byte to hold 2 character Cforall language code.
    50                 if ( ftruncate( fd, size + 1 ) ) { perror( "ftruncate" ); exit( EXIT_FAILURE ); };
     50                if ( char * cursor = strstr( start, ".Ldebug_info0:" ) ) { // debug information ?
     51                        // Expand file by one byte to hold 2 character Cforall language code.
     52                        if ( ftruncate( fd, size + 1 ) ) { perror( "ftruncate" ); exit( EXIT_FAILURE ); };
    5153
    52                 for ( int i = 0; i < 8; i += 1 ) {                              // move N (magic) lines forward
    53                         cursor = strstr( cursor, "\n" ) + 1;
    54                 } // for
     54                        for ( int i = 0; i < 8; i += 1 ) {                      // move N (magic) lines forward
     55                                cursor = strstr( cursor, "\n" ) + 1;
     56                        } // for
    5557
    56                 cursor -= 2;                                                                    // backup over "c\n" language value
    57                 if ( *(cursor - 1) != 'x' ) { fprintf( stderr, "invalid C language code\n" ); exit( EXIT_FAILURE ); };
     58                        cursor -= 2;                                                            // backup over "c\n" language value
     59                        if ( *(cursor - 1) != 'x' ) { fprintf( stderr, "invalid C language code\n" ); exit( EXIT_FAILURE ); };
    5860
    59                 memmove( cursor + 2, cursor + 1, start + size - cursor - 1 ); // move remaining text 1 character right
     61                        memmove( cursor + 2, cursor + 1, start + size - cursor - 1 ); // move remaining text 1 character right
    6062
    61                 *(cursor) = '2';                                                                // replace C language value with CFA
    62                 *(cursor + 1) = '5';
     63                        *(cursor) = '2';                                                        // replace C language value with CFA
     64                        *(cursor + 1) = '5';
     65                } // if
     66
     67                if ( munmap( start, size ) ) { perror( "munmap" ); exit( EXIT_FAILURE ); }; // update on disk
    6368        } // if
    64 
    65         if ( munmap( start, size ) ) { perror( "munmap" ); exit( EXIT_FAILURE ); }; // update on disk
    6669
    6770        argv[0] = "as";
  • driver/cc1.cc

    r0cf9ffd rbedb40e  
    1010// Created On       : Fri Aug 26 14:23:51 2005
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug 23 09:48:40 2018
    13 // Update Count     : 122
     12// Last Modified On : Mon Sep  3 16:57:05 2018
     13// Update Count     : 125
    1414//
    1515
     
    3232string compiler_name( CFA_BACKEND_CC );                                 // path/name of C compiler
    3333
    34 string D__GCC_X__( "-D__GCC_X__=" );
    3534string D__GCC_BPREFIX__( "-D__GCC_BPREFIX__=" );
    3635string D__CFA_FLAGPREFIX__( "-D__CFA_FLAG__=" );
     
    4645enum { NumSuffixes = 2 };
    4746const string suffixes[NumSuffixes] = { "cfa", "hfa", };
    48 
    4947
    5048void suffix( string arg, const char * args[], int & nargs ) {
     
    116114void Stage1( const int argc, const char * const argv[] ) {
    117115        int code;
    118         int i;
    119116
    120117        string arg;
     
    139136        cerr << "Stage1" << endl;
    140137        #endif // __DEBUG_H__
     138        checkEnv( args, nargs );                                                        // arguments passed via environment variables
     139        #ifdef __DEBUG_H__
     140        for ( int i = 1; i < argc; i += 1 ) {
     141                cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl;
     142        } // for
     143        #endif // __DEBUG_H__
    141144
    142145        // process all the arguments
    143146
    144         checkEnv( args, nargs );                                                        // arguments passed via environment variables
    145 
    146         for ( i = 1; i < argc; i += 1 ) {
    147                 #ifdef __DEBUG_H__
    148                 cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl;
    149                 #endif // __DEBUG_H__
     147        for ( int i = 1; i < argc; i += 1 ) {
    150148                arg = argv[i];
    151                 #ifdef __DEBUG_H__
    152                 cerr << "arg:\"" << arg << "\"" << endl;
    153                 #endif // __DEBUG_H__
    154149                if ( prefix( arg, "-" ) ) {
    155150                        // strip g++ flags that are inappropriate or cause duplicates in subsequent passes
     
    185180                                ncargs += 1;
    186181                                i += 1;                                                                 // and the argument
    187                         // } else if ( prefix( arg, D__GCC_X__ ) ) {
    188                         //      args[nargs] = "-x";
    189                         //      nargs += 1;
    190                         //      args[nargs] = ( *new string( arg.substr( D__GCC_X__.size() ) ) ).c_str(); // pass the flag along
    191                         //      nargs += 1;
    192                         // } else if ( arg == "-D" && prefix( argv[i + 1], D__GCC_X__.substr(2) ) ) {
    193                         //      args[nargs] = "-x";
    194                         //      nargs += 1;
    195                         //      args[nargs] = ( *new string( string( argv[i + 1] ).substr( D__GCC_X__.size() - 2 ) ) ).c_str(); // pass the flag along
    196                         //      nargs += 1;
    197                         //      i += 1;                                                                 // and the argument
    198182                        } else if ( prefix( arg, D__GCC_BPREFIX__ ) ) {
    199183                                bprefix = arg.substr( D__GCC_BPREFIX__.size() );
     
    251235        #ifdef __DEBUG_H__
    252236        cerr << "args:";
    253         for ( i = 1; i < nargs; i += 1 ) {
     237        for ( int i = 1; i < nargs; i += 1 ) {
    254238                cerr << " " << args[i];
    255239        } // for
     
    282266                #ifdef __DEBUG_H__
    283267                cerr << "nargs: " << nargs << endl;
    284                 for ( i = 0; args[i] != NULL; i += 1 ) {
     268                for ( int i = 0; args[i] != NULL; i += 1 ) {
    285269                        cerr << args[i] << " ";
    286270                } // for
     
    324308                #ifdef __DEBUG_H__
    325309                cerr << "cpp nargs: " << nargs << endl;
    326                 for ( i = 0; args[i] != NULL; i += 1 ) {
     310                for ( int i = 0; args[i] != NULL; i += 1 ) {
    327311                        cerr << args[i] << " ";
    328312                } // for
     
    377361                #ifdef __DEBUG_H__
    378362                cerr << "cfa-cpp ncargs: " << o_name << " " << CFA_flag << " " << ncargs << endl;
    379                 for ( i = 0; cargs[i] != NULL; i += 1 ) {
     363                for ( int i = 0; cargs[i] != NULL; i += 1 ) {
    380364                        cerr << cargs[i] << " ";
    381365                } // for
     
    407391
    408392void Stage2( const int argc, const char * const * argv ) {
    409         int i;
    410 
    411393        string arg;
    412394
     
    419401        cerr << "Stage2" << endl;
    420402        #endif // __DEBUG_H__
     403        checkEnv( args, nargs );                                                        // arguments passed via environment variables
     404        #ifdef __DEBUG_H__
     405        for ( int i = 1; i < argc; i += 1 ) {
     406                cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl;
     407        } // for
     408        #endif // __DEBUG_H__
    421409
    422410        // process all the arguments
    423411
    424         checkEnv( args, nargs );                                                        // arguments passed via environment variables
    425 
    426         for ( i = 1; i < argc; i += 1 ) {
    427                 #ifdef __DEBUG_H__
    428                 cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl;
    429                 #endif // __DEBUG_H__
     412        for ( int i = 1; i < argc; i += 1 ) {
    430413                arg = argv[i];
    431                 #ifdef __DEBUG_H__
    432                 cerr << "arg:\"" << arg << "\"" << endl;
    433                 #endif // __DEBUG_H__
    434414                if ( prefix( arg, "-" ) ) {
    435415                        // strip inappropriate flags
     
    476456        #ifdef __DEBUG_H__
    477457        cerr << "args:";
    478         for ( i = 1; i < nargs; i += 1 ) {
     458        for ( int i = 1; i < nargs; i += 1 ) {
    479459                cerr << " " << args[i];
    480460        } // for
     
    492472        #ifdef __DEBUG_H__
    493473        cerr << "stage2 nargs: " << nargs << endl;
    494         for ( i = 0; args[i] != NULL; i += 1 ) {
     474        for ( int i = 0; args[i] != NULL; i += 1 ) {
    495475                cerr << args[i] << " ";
    496476        } // for
     
    506486int main( const int argc, const char * const argv[], __attribute__((unused)) const char * const env[] ) {
    507487        #ifdef __DEBUG_H__
    508         for ( int i = 0; env[i] != NULL; i += 1 ) {
     488        for ( int int i = 0; env[i] != NULL; i += 1 ) {
    509489                cerr << env[i] << endl;
    510490        } // for
  • driver/cfa.cc

    r0cf9ffd rbedb40e  
    1010// Created On       : Tue Aug 20 13:44:49 2002
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug 23 15:41:55 2018
    13 // Update Count     : 270
     12// Last Modified On : Mon Sep  3 16:47:59 2018
     13// Update Count     : 275
    1414//
    1515
     
    4343const string suffixes[NumSuffixes] = { "cfa", "hfa", };
    4444
    45 void suffix( string arg, const char * args[], int & nargs ) {
     45bool suffix( string arg, const char * args[], int & nargs ) {
    4646        //std::cerr << arg << std::endl;
    4747        size_t dot = arg.find_last_of( "." );
    4848        //std::cerr << dot << " " << (dot != string::npos ? arg.substr( dot + 1 ) : "fred" ) << std::endl;
    49         if ( dot == string::npos ) return;
     49        if ( dot == string::npos ) return false;
    5050        string sx = arg.substr( dot + 1 );
    5151        for ( int i = 0; i < NumSuffixes; i += 1 ) {
     
    5555                        args[nargs] = "c";
    5656                        nargs += 1;
    57                         return;
     57                        return true;
    5858                } // if
    5959        } // for
     60        return false;
    6061} // suffix
    6162
     
    128129        #ifdef __DEBUG_H__
    129130        cerr << "CFA:" << endl;
     131        for ( int i = 1; i < argc; i += 1 ) {
     132            cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl;
     133        } // for
    130134        #endif // __DEBUG_H__
    131135
     
    133137
    134138        for ( int i = 1; i < argc; i += 1 ) {
    135                 #ifdef __DEBUG_H__
    136                 cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl;
    137                 #endif // __DEBUG_H__
    138139                arg = argv[i];                                                                  // convert to string value
    139                 #ifdef __DEBUG_H__
    140                 cerr << "arg:\"" << arg << "\"" << endl;
    141                 #endif // __DEBUG_H__
    142140                if ( prefix( arg, "-" ) ) {
    143141                        // pass through arguments
     
    202200                                args[nargs] = argv[i];                                  // pass the argument along
    203201                                nargs += 1;
    204                         } else if ( arg == "-x" ) {
    205                                 xflag = true;
    206                                 args[nargs] = argv[i];                                  // pass the argument along
    207                                 nargs += 1;
    208                                 i += 1;                                                                 // advance to argument
    209                                 args[nargs] = argv[i];                                  // pass the argument along
    210                                 nargs += 1;
    211                                 // args[nargs] = ( *new string( string("-D__GCC_X__=") + argv[i] ) ).c_str(); // add the argument for -x
    212                                 // nargs += 1;
    213                         } else if ( prefix( arg, "-x" ) ) {
    214                                 xflag = true;
    215                                 args[nargs] = argv[i];                                  // pass the argument along
    216                                 nargs += 1;
    217                                 // args[nargs] = ( *new string( string("-D__GCC_X__=") + arg.substr(2) ) ).c_str(); // add the argument for -x
    218                                 // nargs += 1;
    219202                        } else if ( arg == "-w" ) {
    220203                                args[nargs] = argv[i];                                  // pass the argument along
     
    298281                        } // if
    299282                } else {
    300                         bool opt = false;
    301                         if ( ! xflag ) {
    302                                 suffix( arg, args, nargs );                             // check suffix
    303                                 // args[nargs] = ( *new string( string("-D__GCC_X__=c") ) ).c_str(); // add the argument for -x
    304                                 // nargs += 1;
    305                                 opt = true;
    306                         } // if
    307                         // concatenate other arguments
    308                         args[nargs] = argv[i];
     283                        bool cfa = suffix( arg, args, nargs );          // check suffix
     284                        args[nargs] = argv[i];                                          // concatenate file
    309285                        nargs += 1;
    310                         if ( opt ) {
     286                        if ( cfa ) {
    311287                                args[nargs] = "-x";
    312288                                nargs += 1;
    313289                                args[nargs] = "none";
    314290                                nargs += 1;
    315                                 // args[nargs] = ( *new string( string("-D__GCC_X__=none") ) ).c_str(); // add the argument for -x
    316                                 // nargs += 1;
    317291                        } // if
    318292                        nonoptarg = true;
     
    320294                } // if
    321295        } // for
     296
     297    args[nargs] = "-x";                                 // turn off language
     298    nargs += 1;
     299    args[nargs] = "none";
     300    nargs += 1;
    322301
    323302        #ifdef __x86_64__
Note: See TracChangeset for help on using the changeset viewer.