Changes in / [ae63a18:c23f807]


Ignore:
Location:
src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    rae63a18 rc23f807  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Box.cc --
     7// Box.cc -- 
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri Dec 18 14:53:08 2015
    13 // Update Count     : 217
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Tue Dec 15 15:30:31 2015
     13// Update Count     : 215
    1414//
    1515
     
    6565                        virtual Type *mutate( PointerType *pointerType );
    6666                        virtual Type * mutate( FunctionType *functionType );
    67 
     67 
    6868                        virtual void doBeginScope();
    6969                        virtual void doEndScope();
     
    103103                  private:
    104104                        void addAdapters( FunctionType *functionType );
    105 
     105 
    106106                        std::map< UniqueId, std::string > adapterName;
    107107                };
     
    151151                        // the correct thing in some situations. It's not clear to me why this wasn't working.
    152152
    153                         // if the return type or a parameter type involved polymorphic types, then the adapter will need
    154                         // to take those polymorphic types as pointers. Therefore, there can be two different functions
     153                        // if the return type or a parameter type involved polymorphic types, then the adapter will need 
     154                        // to take those polymorphic types as pointers. Therefore, there can be two different functions 
    155155                        // with the same mangled name, so we need to further mangle the names.
    156156                        for ( std::list< DeclarationWithType *>::iterator retval = function->get_returnVals().begin(); retval != function->get_returnVals().end(); ++retval ) {
     
    167167                                        name << "P";
    168168                                } else {
    169                                         name << "M";
     169                                        name << "M";                           
    170170                                }
    171171                        } // for
     
    185185                }
    186186
    187                 // returns true if the given declaration is: (*?=?)(T *, T) for some T (return not checked, but maybe should be)
    188187                bool checkAssignment( DeclarationWithType *decl, std::string &name ) {
    189188                        if ( decl->get_name() == "?=?" ) {
     
    234233                                if ( isPolyRet( functionDecl->get_functionType(), typeName ) && functionDecl->get_linkage() == LinkageSpec::Cforall ) {
    235234                                        retval = functionDecl->get_functionType()->get_returnVals().front();
    236 
     235 
    237236                                        // give names to unnamed return values
    238237                                        if ( retval->get_name() == "" ) {
     
    241240                                        } // if
    242241                                } // if
    243 
     242       
    244243                                FunctionType *functionType = functionDecl->get_functionType();
    245244                                makeTyVarMap( functionDecl->get_functionType(), scopeTyVars );
     
    266265
    267266                                functionDecl->set_statements( functionDecl->get_statements()->acceptMutator( *this ) );
    268 
     267 
    269268                                scopeTyVars = oldtyVars;
    270269                                assignOps = oldassignOps;
     
    329328                        FunctionType *funcType = getFunctionType( appExpr->get_function()->get_results().front() );
    330329                        assert( funcType );
    331 
     330                       
    332331                        std::list< DeclarationWithType* >::const_iterator fnParm = funcType->get_parameters().begin();
    333332                        std::list< Expression* >::const_iterator fnArg = arg;
     
    406405                        appExpr->get_args().push_front( appExpr->get_function() );
    407406                        appExpr->set_function( new NameExpr( adapterName ) );
    408 
     407 
    409408                        return ret;
    410409                }
     
    529528                        ApplicationExpr *adapteeApp = new ApplicationExpr( new CastExpr( new VariableExpr( adapteeDecl ), new PointerType( Type::Qualifiers(), realType ) ) );
    530529                        Statement *bodyStmt;
    531 
     530 
    532531                        std::list< TypeDecl *>::iterator tyArg = realType->get_forall().begin();
    533532                        std::list< TypeDecl *>::iterator tyParam = adapterType->get_forall().begin();
     
    543542                                } // for
    544543                        } // for
    545 
     544 
    546545                        std::list< DeclarationWithType *>::iterator arg = realType->get_parameters().begin();
    547546                        std::list< DeclarationWithType *>::iterator param = adapterType->get_parameters().begin();
     
    600599                                if ( adaptersDone.find( mangleName ) == adaptersDone.end() ) {
    601600                                        adaptersDone.insert( adaptersDone.begin(), mangleName );
    602 
     601                                       
    603602                                        // apply substitution to type variables to figure out what the adapter's type should look like
    604603                                        assert( env );
    605604                                        env->apply( realFunction );
    606                                         mangleName = SymTab::Mangler::mangle( realFunction );
     605                                        mangleName = SymTab::Mangler::mangle( realFunction ); 
    607606                                        mangleName += makePolyMonoSuffix( originalFunction, exprTyVars );
    608607
     
    655654                                                Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_results().front(), scopeTyVars, env );
    656655                                                Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_results().front(), scopeTyVars, env );
    657                                                 assert( ! baseType1 || ! baseType2 ); // the arguments cannot both be polymorphic pointers
     656                                                assert( ! baseType1 || ! baseType2 );
    658657                                                UntypedExpr *ret = 0;
    659                                                 if ( baseType1 || baseType2 ) { // one of the arguments is a polymorphic pointer
     658                                                if ( baseType1 || baseType2 ) {
    660659                                                        ret = new UntypedExpr( new NameExpr( "?+?" ) );
    661660                                                } // if
     
    778777                        mutateAll( appExpr->get_args(), *this );
    779778                        useRetval = oldUseRetval;
    780 
     779 
    781780                        assert( ! appExpr->get_function()->get_results().empty() );
    782781                        PointerType *pointer = dynamic_cast< PointerType *>( appExpr->get_function()->get_results().front() );
     
    784783                        FunctionType *function = dynamic_cast< FunctionType *>( pointer->get_base() );
    785784                        assert( function );
    786 
     785 
    787786                        if ( Expression *newExpr = handleIntrinsics( appExpr ) ) {
    788787                                return newExpr;
    789788                        } // if
    790 
     789 
    791790                        Expression *ret = appExpr;
    792 
     791 
    793792                        std::list< Expression *>::iterator arg = appExpr->get_args().begin();
    794793                        std::list< Expression *>::iterator paramBegin = appExpr->get_args().begin();
    795 
     794 
    796795                        std::string typeName;
    797796                        if ( isPolyRet( function, typeName ) ) {
     
    807806                        } // if
    808807                        arg = appExpr->get_args().begin();
    809 
     808 
    810809                        TyVarMap exprTyVars;
    811810                        makeTyVarMap( function, exprTyVars );
    812 
     811 
    813812                        passTypeVars( appExpr, arg, exprTyVars );
    814813                        addInferredParams( appExpr, function, arg, exprTyVars );
    815814
    816815                        arg = paramBegin;
    817 
     816 
    818817                        boxParams( appExpr, function, arg, exprTyVars );
    819818
     
    875874                                // ***** Code Removal ***** After introducing a temporary variable for all return expressions, the following code appears superfluous.
    876875                                // if ( returnStmt->get_expr()->get_results().front()->get_isLvalue() ) {
    877                                 // by this point, a cast expr on a polymorphic return value is redundant
     876                                // a cast expr on a polymorphic return value is either redundant or invalid
    878877                                while ( CastExpr *castExpr = dynamic_cast< CastExpr *>( returnStmt->get_expr() ) ) {
    879878                                        returnStmt->set_expr( castExpr->get_arg() );
     
    910909                        TyVarMap oldtyVars = scopeTyVars;
    911910                        makeTyVarMap( pointerType, scopeTyVars );
    912 
     911 
    913912                        Type *ret = Mutator::mutate( pointerType );
    914 
     913 
    915914                        scopeTyVars = oldtyVars;
    916915                        return ret;
     
    920919                        TyVarMap oldtyVars = scopeTyVars;
    921920                        makeTyVarMap( functionType, scopeTyVars );
    922 
     921 
    923922                        Type *ret = Mutator::mutate( functionType );
    924 
     923 
    925924                        scopeTyVars = oldtyVars;
    926925                        return ret;
     
    989988                        TyVarMap oldtyVars = scopeTyVars;
    990989                        makeTyVarMap( pointerType, scopeTyVars );
    991 
     990 
    992991                        Type *ret = Mutator::mutate( pointerType );
    993 
     992 
    994993                        scopeTyVars = oldtyVars;
    995994                        return ret;
     
    10191018                                if ( (*tyParm)->get_kind() == TypeDecl::Any ) {
    10201019                                        TypeInstType parmType( Type::Qualifiers(), (*tyParm)->get_name(), *tyParm );
    1021 
     1020                                       
    10221021                                        sizeParm = newObj.clone();
    10231022                                        sizeParm->set_name( sizeofName( &parmType ) );
     
    10451044                                        std::string sizeName = sizeofName( parmType );
    10461045                                        if ( seenTypes.count( sizeName ) ) continue;
    1047 
     1046                                       
    10481047                                        ObjectDecl *sizeParm, *alignParm;
    10491048                                        sizeParm = newObj.clone();
     
    10661065                        mutateAll( funcType->get_returnVals(), *this );
    10671066                        mutateAll( funcType->get_parameters(), *this );
    1068 
     1067 
    10691068                        scopeTyVars = oldtyVars;
    10701069                        return funcType;
     
    10771076                        TyVarMap oldtyVars = scopeTyVars;
    10781077                        makeTyVarMap( type, scopeTyVars );
    1079 
     1078 
    10801079                        DeclClass *ret = static_cast< DeclClass *>( Mutator::mutate( decl ) );
    10811080                        ScrubTyVars::scrub( decl, scopeTyVars );
     
    11131112                        TyVarMap oldtyVars = scopeTyVars;
    11141113                        makeTyVarMap( pointerType, scopeTyVars );
    1115 
     1114 
    11161115                        Type *ret = Mutator::mutate( pointerType );
    1117 
     1116 
    11181117                        scopeTyVars = oldtyVars;
    11191118                        return ret;
     
    11231122                        TyVarMap oldtyVars = scopeTyVars;
    11241123                        makeTyVarMap( functionType, scopeTyVars );
    1125 
     1124 
    11261125                        Type *ret = Mutator::mutate( functionType );
    1127 
     1126 
    11281127                        scopeTyVars = oldtyVars;
    11291128                        return ret;
  • src/GenPoly/PolyMutator.h

    rae63a18 rc23f807  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Tue Dec 08 15:19:05 2015
    13 // Update Count     : 5
     12// Last Modified On : Fri Aug 14 15:27:38 2015
     13// Update Count     : 4
    1414//
    1515
     
    5151                virtual void doBeginScope() {}
    5252                virtual void doEndScope() {}
    53                
    54                 static void makeTyVarMap( Type *type, TyVarMap &tyVarMap );
    5553          protected:
    5654                void mutateStatementList( std::list< Statement* > &statements );
    5755                Statement* mutateStatement( Statement *stmt );
    5856                Expression* mutateExpression( Expression *expr );
     57                static void makeTyVarMap( Type *type, TyVarMap &tyVarMap );
    5958 
    6059                TyVarMap scopeTyVars;
  • src/SynTree/Declaration.cc

    rae63a18 rc23f807  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Dec 09 14:08:29 2015
    13 // Update Count     : 12
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Mon Jul 13 17:58:38 2015
     13// Update Count     : 10
    1414//
    1515
     
    5555}
    5656
    57 std::ostream & operator<<( std::ostream & out, Declaration * decl ) {
    58         decl->print( out );
    59         return out;
    60 }
    61 
    62 
    6357// Local Variables: //
    6458// tab-width: 4 //
  • src/SynTree/Declaration.h

    rae63a18 rc23f807  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Dec 09 14:08:22 2015
    13 // Update Count     : 32
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Mon Jul 13 18:15:59 2015
     13// Update Count     : 28
    1414//
    1515
     
    259259};
    260260
    261 std::ostream & operator<<( std::ostream & out, Declaration * decl );
    262 
    263261#endif // DECLARATION_H
    264262
  • src/SynTree/Expression.cc

    rae63a18 rc23f807  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Dec 09 14:10:29 2015
    13 // Update Count     : 34
     12// Last Modified On : Wed Sep 02 12:07:10 2015
     13// Update Count     : 33
    1414//
    1515
     
    376376}
    377377
    378 std::ostream & operator<<( std::ostream & out, Expression * expr ) {
    379         expr->print( out );
    380         return out;
    381 }
    382 
    383378// Local Variables: //
    384379// tab-width: 4 //
  • src/SynTree/Expression.h

    rae63a18 rc23f807  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Dec 09 14:10:21 2015
    13 // Update Count     : 19
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Jul 24 13:49:28 2015
     13// Update Count     : 18
    1414//
    1515
     
    512512};
    513513
    514 std::ostream & operator<<( std::ostream & out, Expression * expr );
    515 
    516514#endif // EXPRESSION_H
    517515
  • src/SynTree/Statement.cc

    rae63a18 rc23f807  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Dec 09 14:09:34 2015
    13 // Update Count     : 54
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sat Jul 25 12:19:50 2015
     13// Update Count     : 53
    1414//
    1515
     
    337337}
    338338
    339 std::ostream & operator<<( std::ostream & out, Statement * statement ) {
    340         statement->print( out );
    341         return out;
    342 }
    343 
    344339// Local Variables: //
    345340// tab-width: 4 //
  • src/SynTree/Statement.h

    rae63a18 rc23f807  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Dec 09 14:09:24 2015
    13 // Update Count     : 46
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sat Jul 25 18:25:37 2015
     13// Update Count     : 44
    1414//
    1515
     
    396396};
    397397
    398 std::ostream & operator<<( std::ostream & out, Statement * statement );
    399 
    400398#endif // STATEMENT_H
    401399
  • src/SynTree/Type.cc

    rae63a18 rc23f807  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Dec 09 14:08:48 2015
    13 // Update Count     : 4
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Jul  9 16:45:13 2015
     13// Update Count     : 3
    1414//
    1515
     
    8080}
    8181
    82 std::ostream & operator<<( std::ostream & out, Type * type ) {
    83         type->print( out );
    84         return out;
    85 }
    86 
    8782// Local Variables: //
    8883// tab-width: 4 //
  • src/SynTree/Type.h

    rae63a18 rc23f807  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Type.h --
     7// Type.h -- 
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri Dec 18 14:46:18 2015
    13 // Update Count     : 18
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Nov 27 17:54:31 2015
     13// Update Count     : 16
    1414//
    1515
     
    2323class Type {
    2424  public:
    25         struct Qualifiers {
     25        struct Qualifiers { 
    2626                Qualifiers(): isConst( false ), isVolatile( false ), isRestrict( false ), isLvalue( false ), isAtomic( false ), isAttribute( false ) {}
    2727                Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue, bool isAtomic, bool isAttribute ): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ), isAtomic( isAtomic ), isAttribute( isAttribute ) {}
    28 
     28       
    2929                Qualifiers &operator+=( const Qualifiers &other );
    3030                Qualifiers &operator-=( const Qualifiers &other );
     
    3636                bool operator<( const Qualifiers &other );
    3737                bool operator>( const Qualifiers &other );
    38 
     38       
    3939                bool isConst;
    4040                bool isVolatile;
     
    4343                bool isAtomic;
    4444                bool isAttribute;
    45         };
     45        };     
    4646
    4747        Type( const Qualifiers &tq );
     
    8585class BasicType : public Type {
    8686  public:
    87         enum Kind {
     87        enum Kind { 
    8888                Bool,
    8989                Char,
     
    108108                LongDoubleImaginary,
    109109                NUMBER_OF_BASIC_TYPES
    110         };
     110        }; 
    111111
    112112        static const char *typeNames[];                                         // string names for basic types, MUST MATCH with Kind
     
    149149  private:
    150150        Type *base;
    151 
     151       
    152152        // In C99, pointer types can be qualified in many ways e.g., int f( int a[ static 3 ] )
    153153        Expression *dimension;
     
    217217        void set_name( std::string newValue ) { name = newValue; }
    218218        std::list< Expression* >& get_parameters() { return parameters; }
    219 
     219       
    220220        virtual ReferenceToType *clone() const = 0;
    221221        virtual void accept( Visitor &v ) = 0;
     
    240240        /// Accesses generic parameters of base struct (NULL if none such)
    241241        std::list<TypeDecl*> * get_baseParameters();
    242 
     242       
    243243        /// Looks up the members of this struct named "name" and places them into "foundDecls".
    244244        /// Clones declarations into "foundDecls", caller responsible for freeing
     
    250250  private:
    251251        virtual std::string typeString() const;
    252 
     252       
    253253        // this decl is not "owned" by the struct inst; it is merely a pointer to elsewhere in the tree,
    254254        // where the structure used in this type is actually defined
     
    267267        /// Accesses generic parameters of base union (NULL if none such)
    268268        std::list<TypeDecl*> * get_baseParameters();
    269 
     269       
    270270        /// looks up the members of this union named "name" and places them into "foundDecls"
    271271        /// Clones declarations into "foundDecls", caller responsible for freeing
     
    277277  private:
    278278        virtual std::string typeString() const;
    279 
     279       
    280280        // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree,
    281281        // where the union used in this type is actually defined
     
    310310  private:
    311311        virtual std::string typeString() const;
    312 
     312       
    313313        // this member is filled in by the validate pass, which instantiates the members of the correponding
    314314        // aggregate with the actual type parameters specified for this use of the context
     
    327327        bool get_isFtype() const { return isFtype; }
    328328        void set_isFtype( bool newValue ) { isFtype = newValue; }
    329 
     329       
    330330        virtual TypeInstType *clone() const { return new TypeInstType( *this ); }
    331331        virtual void accept( Visitor &v ) { v.visit( this ); }
     
    463463}
    464464
    465 std::ostream & operator<<( std::ostream & out, Type * type );
    466 
    467465#endif // TYPE_H
    468466
Note: See TracChangeset for help on using the changeset viewer.