Changeset b502055 for src


Ignore:
Timestamp:
Feb 23, 2016, 4:33:06 PM (8 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
91b8a17, ae7f1e0
Parents:
4067aa8 (diff), 6ce67ce (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 plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AlternativeFinder.cc

    r4067aa8 rb502055  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // AlternativeFinder.cc -- 
     7// AlternativeFinder.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Sat May 16 23:52:08 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul  3 17:58:39 2015
    13 // Update Count     : 22
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Feb 10 17:00:04 2016
     13// Update Count     : 24
    1414//
    1515
     
    4141
    4242extern bool resolvep;
    43 #define PRINT( text ) if ( resolvep ) { text } 
     43#define PRINT( text ) if ( resolvep ) { text }
    4444//#define DEBUG_COST
    4545
     
    107107                                        if ( candidate->cost < mapPlace->second.candidate->cost ) {
    108108                                                PRINT(
    109                                                         std::cout << "cost " << candidate->cost << " beats " << mapPlace->second.candidate->cost << std::endl;
     109                                                        std::cerr << "cost " << candidate->cost << " beats " << mapPlace->second.candidate->cost << std::endl;
    110110                                                )
    111111                                                selected[ mangleName ] = current;
    112112                                        } else if ( candidate->cost == mapPlace->second.candidate->cost ) {
    113113                                                PRINT(
    114                                                         std::cout << "marking ambiguous" << std::endl;
     114                                                        std::cerr << "marking ambiguous" << std::endl;
    115115                                                )
    116116                                                mapPlace->second.isAmbiguous = true;
     
    122122
    123123                        PRINT(
    124                                 std::cout << "there are " << selected.size() << " alternatives before elimination" << std::endl;
     124                                std::cerr << "there are " << selected.size() << " alternatives before elimination" << std::endl;
    125125                        )
    126126
     
    182182                        begin++;
    183183                        PRINT(
    184                                 std::cout << "findSubExprs" << std::endl;
    185                                 printAlts( finder.alternatives, std::cout );
     184                                std::cerr << "findSubExprs" << std::endl;
     185                                printAlts( finder.alternatives, std::cerr );
    186186                        )
    187187                        *out++ = finder;
     
    204204                }
    205205                PRINT(
    206                         std::cout << "alternatives before prune:" << std::endl;
    207                         printAlts( alternatives, std::cout );
     206                        std::cerr << "alternatives before prune:" << std::endl;
     207                        printAlts( alternatives, std::cerr );
    208208                )
    209209                AltList::iterator oldBegin = alternatives.begin();
     
    221221                alternatives.erase( oldBegin, alternatives.end() );
    222222                PRINT(
    223                         std::cout << "there are " << alternatives.size() << " alternatives after elimination" << std::endl;
     223                        std::cerr << "there are " << alternatives.size() << " alternatives after elimination" << std::endl;
    224224                )
    225225        }
     
    261261                for ( std::list< Expression* >::iterator actualExpr = actuals.begin(); actualExpr != actuals.end(); ++actualExpr ) {
    262262                        PRINT(
    263                                 std::cout << "actual expression:" << std::endl;
    264                                 (*actualExpr)->print( std::cout, 8 );
    265                                 std::cout << "--- results are" << std::endl;
    266                                 printAll( (*actualExpr)->get_results(), std::cout, 8 );
     263                                std::cerr << "actual expression:" << std::endl;
     264                                (*actualExpr)->print( std::cerr, 8 );
     265                                std::cerr << "--- results are" << std::endl;
     266                                printAll( (*actualExpr)->get_results(), std::cerr, 8 );
    267267                        )
    268268                        std::list< DeclarationWithType* >::iterator startFormal = formal;
     
    278278                                }
    279279                                PRINT(
    280                                         std::cout << std::endl << "converting ";
    281                                         (*actual)->print( std::cout, 8 );
    282                                         std::cout << std::endl << " to ";
    283                                         (*formal)->get_type()->print( std::cout, 8 );
     280                                        std::cerr << std::endl << "converting ";
     281                                        (*actual)->print( std::cerr, 8 );
     282                                        std::cerr << std::endl << " to ";
     283                                        (*formal)->get_type()->print( std::cerr, 8 );
    284284                                )
    285285                                Cost newCost = conversionCost( *actual, (*formal)->get_type(), indexer, alt.env );
    286286                                PRINT(
    287                                         std::cout << std::endl << "cost is" << newCost << std::endl;
     287                                        std::cerr << std::endl << "cost is" << newCost << std::endl;
    288288                                )
    289289
     
    323323                for ( InferredParams::const_iterator assert = appExpr->get_inferParams().begin(); assert != appExpr->get_inferParams().end(); ++assert ) {
    324324                        PRINT(
    325                                 std::cout << std::endl << "converting ";
    326                                 assert->second.actualType->print( std::cout, 8 );
    327                                 std::cout << std::endl << " to ";
    328                                 assert->second.formalType->print( std::cout, 8 );
     325                                std::cerr << std::endl << "converting ";
     326                                assert->second.actualType->print( std::cerr, 8 );
     327                                std::cerr << std::endl << " to ";
     328                                assert->second.formalType->print( std::cerr, 8 );
    329329                                )
    330330                                Cost newCost = conversionCost( assert->second.actualType, assert->second.formalType, indexer, alt.env );
    331331                        PRINT(
    332                                 std::cout << std::endl << "cost of conversion is " << newCost << std::endl;
     332                                std::cerr << std::endl << "cost of conversion is " << newCost << std::endl;
    333333                                )
    334334                                if ( newCost == Cost::infinity ) {
     
    448448                std::list< DeclarationWithType* > candidates;
    449449                decls.lookupId( curDecl->get_name(), candidates );
    450 ///   if ( candidates.empty() ) { std::cout << "no candidates!" << std::endl; }
     450///   if ( candidates.empty() ) { std::cerr << "no candidates!" << std::endl; }
    451451                for ( std::list< DeclarationWithType* >::const_iterator candidate = candidates.begin(); candidate != candidates.end(); ++candidate ) {
    452452                        PRINT(
    453                                 std::cout << "inferRecursive: candidate is ";
    454                                 (*candidate)->print( std::cout );
    455                                 std::cout << std::endl;
     453                                std::cerr << "inferRecursive: candidate is ";
     454                                (*candidate)->print( std::cerr );
     455                                std::cerr << std::endl;
    456456                        )
    457457                        AssertionSet newHave, newerNeed( newNeed );
     
    482482                                varExpr->get_results().push_front( adjType->clone() );
    483483                                PRINT(
    484                                         std::cout << "satisfying assertion " << curDecl->get_uniqueId() << " ";
    485                                         curDecl->print( std::cout );
    486                                         std::cout << " with declaration " << (*candidate)->get_uniqueId() << " ";
    487                                         (*candidate)->print( std::cout );
    488                                         std::cout << std::endl;
     484                                        std::cerr << "satisfying assertion " << curDecl->get_uniqueId() << " ";
     485                                        curDecl->print( std::cerr );
     486                                        std::cerr << " with declaration " << (*candidate)->get_uniqueId() << " ";
     487                                        (*candidate)->print( std::cerr );
     488                                        std::cerr << std::endl;
    489489                                )
    490490                                ApplicationExpr *appExpr = static_cast< ApplicationExpr* >( newerAlt.expr );
     
    501501        void AlternativeFinder::inferParameters( const AssertionSet &need, AssertionSet &have, const Alternative &newAlt, OpenVarSet &openVars, OutputIterator out ) {
    502502//      PRINT(
    503 //          std::cout << "inferParameters: assertions needed are" << std::endl;
    504 //          printAll( need, std::cout, 8 );
     503//          std::cerr << "inferParameters: assertions needed are" << std::endl;
     504//          printAll( need, std::cerr, 8 );
    505505//          )
    506506                SymTab::Indexer decls( indexer );
    507507                PRINT(
    508                         std::cout << "============= original indexer" << std::endl;
    509                         indexer.print( std::cout );
    510                         std::cout << "============= new indexer" << std::endl;
    511                         decls.print( std::cout );
     508                        std::cerr << "============= original indexer" << std::endl;
     509                        indexer.print( std::cerr );
     510                        std::cerr << "============= new indexer" << std::endl;
     511                        decls.print( std::cerr );
    512512                )
    513513                addToIndexer( have, decls );
     
    515515                inferRecursive( need.begin(), need.end(), newAlt, openVars, decls, newNeed, 0, indexer, out );
    516516//      PRINT(
    517 //          std::cout << "declaration 14 is ";
     517//          std::cerr << "declaration 14 is ";
    518518//          Declaration::declFromId
    519519//          *out++ = newAlt;
     
    532532                        makeExprList( actualAlt, appExpr->get_args() );
    533533                        PRINT(
    534                                 std::cout << "need assertions:" << std::endl;
    535                                 printAssertionSet( resultNeed, std::cout, 8 );
     534                                std::cerr << "need assertions:" << std::endl;
     535                                printAssertionSet( resultNeed, std::cerr, 8 );
    536536                        )
    537537                        inferParameters( resultNeed, resultHave, newAlt, openVars, out );
     
    543543                AlternativeFinder funcOpFinder( indexer, env );
    544544
    545                 AlternativeFinder funcFinder( indexer, env ); {
     545                AlternativeFinder funcFinder( indexer, env );
     546
     547                {
    546548                        NameExpr *fname = 0;;
    547549                        if ( ( fname = dynamic_cast<NameExpr *>( untypedExpr->get_function()))
     
    573575                for ( AltList::const_iterator func = funcFinder.alternatives.begin(); func != funcFinder.alternatives.end(); ++func ) {
    574576                        PRINT(
    575                                 std::cout << "working on alternative: " << std::endl;
    576                                 func->print( std::cout, 8 );
     577                                std::cerr << "working on alternative: " << std::endl;
     578                                func->print( std::cerr, 8 );
    577579                        )
    578580                        // check if the type is pointer to function
     
    606608                                        }
    607609                                        PRINT(
    608                                                 std::cout << "known function ops:" << std::endl;
    609                                                 printAlts( funcOpFinder.alternatives, std::cout, 8 );
     610                                                std::cerr << "known function ops:" << std::endl;
     611                                                printAlts( funcOpFinder.alternatives, std::cerr, 8 );
    610612                                        )
    611613                                }
     
    639641                                FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() );
    640642                                assert( function );
    641                                 std::cout << "Case +++++++++++++" << std::endl;
    642                                 std::cout << "formals are:" << std::endl;
    643                                 printAll( function->get_parameters(), std::cout, 8 );
    644                                 std::cout << "actuals are:" << std::endl;
    645                                 printAll( appExpr->get_args(), std::cout, 8 );
    646                                 std::cout << "bindings are:" << std::endl;
    647                                 withFunc->env.print( std::cout, 8 );
    648                                 std::cout << "cost of conversion is:" << cvtCost << std::endl;
     643                                std::cerr << "Case +++++++++++++" << std::endl;
     644                                std::cerr << "formals are:" << std::endl;
     645                                printAll( function->get_parameters(), std::cerr, 8 );
     646                                std::cerr << "actuals are:" << std::endl;
     647                                printAll( appExpr->get_args(), std::cerr, 8 );
     648                                std::cerr << "bindings are:" << std::endl;
     649                                withFunc->env.print( std::cerr, 8 );
     650                                std::cerr << "cost of conversion is:" << cvtCost << std::endl;
    649651                        )
    650652                        if ( cvtCost != Cost::infinity ) {
     
    824826                }
    825827        }
    826        
     828
    827829        void AlternativeFinder::visit( UntypedOffsetofExpr *offsetofExpr ) {
    828830                AlternativeFinder funcFinder( indexer, env );
     
    833835                }
    834836        }
    835        
     837
    836838        void AlternativeFinder::visit( OffsetofExpr *offsetofExpr ) {
    837839                alternatives.push_back( Alternative( offsetofExpr->clone(), env, Cost::zero ) );
     
    843845                assert( function->get_parameters().size() == 1 );
    844846                PRINT(
    845                         std::cout << "resolvAttr: funcDecl is ";
    846                         funcDecl->print( std::cout );
    847                         std::cout << " argType is ";
    848                         argType->print( std::cout );
    849                         std::cout << std::endl;
     847                        std::cerr << "resolvAttr: funcDecl is ";
     848                        funcDecl->print( std::cerr );
     849                        std::cerr << " argType is ";
     850                        argType->print( std::cerr );
     851                        std::cerr << std::endl;
    850852                )
    851853                if ( typesCompatibleIgnoreQualifiers( argType, function->get_parameters().front()->get_type(), indexer, env ) ) {
Note: See TracChangeset for help on using the changeset viewer.