Changes in / [ae63a18:c23f807]
- Location:
- src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Box.cc
rae63a18 rc23f807 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Box.cc -- 7 // Box.cc -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Fri Dec 18 14:53:08201513 // Update Count : 21 711 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Dec 15 15:30:31 2015 13 // Update Count : 215 14 14 // 15 15 … … 65 65 virtual Type *mutate( PointerType *pointerType ); 66 66 virtual Type * mutate( FunctionType *functionType ); 67 67 68 68 virtual void doBeginScope(); 69 69 virtual void doEndScope(); … … 103 103 private: 104 104 void addAdapters( FunctionType *functionType ); 105 105 106 106 std::map< UniqueId, std::string > adapterName; 107 107 }; … … 151 151 // the correct thing in some situations. It's not clear to me why this wasn't working. 152 152 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 155 155 // with the same mangled name, so we need to further mangle the names. 156 156 for ( std::list< DeclarationWithType *>::iterator retval = function->get_returnVals().begin(); retval != function->get_returnVals().end(); ++retval ) { … … 167 167 name << "P"; 168 168 } else { 169 name << "M"; 169 name << "M"; 170 170 } 171 171 } // for … … 185 185 } 186 186 187 // returns true if the given declaration is: (*?=?)(T *, T) for some T (return not checked, but maybe should be)188 187 bool checkAssignment( DeclarationWithType *decl, std::string &name ) { 189 188 if ( decl->get_name() == "?=?" ) { … … 234 233 if ( isPolyRet( functionDecl->get_functionType(), typeName ) && functionDecl->get_linkage() == LinkageSpec::Cforall ) { 235 234 retval = functionDecl->get_functionType()->get_returnVals().front(); 236 235 237 236 // give names to unnamed return values 238 237 if ( retval->get_name() == "" ) { … … 241 240 } // if 242 241 } // if 243 242 244 243 FunctionType *functionType = functionDecl->get_functionType(); 245 244 makeTyVarMap( functionDecl->get_functionType(), scopeTyVars ); … … 266 265 267 266 functionDecl->set_statements( functionDecl->get_statements()->acceptMutator( *this ) ); 268 267 269 268 scopeTyVars = oldtyVars; 270 269 assignOps = oldassignOps; … … 329 328 FunctionType *funcType = getFunctionType( appExpr->get_function()->get_results().front() ); 330 329 assert( funcType ); 331 330 332 331 std::list< DeclarationWithType* >::const_iterator fnParm = funcType->get_parameters().begin(); 333 332 std::list< Expression* >::const_iterator fnArg = arg; … … 406 405 appExpr->get_args().push_front( appExpr->get_function() ); 407 406 appExpr->set_function( new NameExpr( adapterName ) ); 408 407 409 408 return ret; 410 409 } … … 529 528 ApplicationExpr *adapteeApp = new ApplicationExpr( new CastExpr( new VariableExpr( adapteeDecl ), new PointerType( Type::Qualifiers(), realType ) ) ); 530 529 Statement *bodyStmt; 531 530 532 531 std::list< TypeDecl *>::iterator tyArg = realType->get_forall().begin(); 533 532 std::list< TypeDecl *>::iterator tyParam = adapterType->get_forall().begin(); … … 543 542 } // for 544 543 } // for 545 544 546 545 std::list< DeclarationWithType *>::iterator arg = realType->get_parameters().begin(); 547 546 std::list< DeclarationWithType *>::iterator param = adapterType->get_parameters().begin(); … … 600 599 if ( adaptersDone.find( mangleName ) == adaptersDone.end() ) { 601 600 adaptersDone.insert( adaptersDone.begin(), mangleName ); 602 601 603 602 // apply substitution to type variables to figure out what the adapter's type should look like 604 603 assert( env ); 605 604 env->apply( realFunction ); 606 mangleName = SymTab::Mangler::mangle( realFunction ); 605 mangleName = SymTab::Mangler::mangle( realFunction ); 607 606 mangleName += makePolyMonoSuffix( originalFunction, exprTyVars ); 608 607 … … 655 654 Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_results().front(), scopeTyVars, env ); 656 655 Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_results().front(), scopeTyVars, env ); 657 assert( ! baseType1 || ! baseType2 ); // the arguments cannot both be polymorphic pointers656 assert( ! baseType1 || ! baseType2 ); 658 657 UntypedExpr *ret = 0; 659 if ( baseType1 || baseType2 ) { // one of the arguments is a polymorphic pointer658 if ( baseType1 || baseType2 ) { 660 659 ret = new UntypedExpr( new NameExpr( "?+?" ) ); 661 660 } // if … … 778 777 mutateAll( appExpr->get_args(), *this ); 779 778 useRetval = oldUseRetval; 780 779 781 780 assert( ! appExpr->get_function()->get_results().empty() ); 782 781 PointerType *pointer = dynamic_cast< PointerType *>( appExpr->get_function()->get_results().front() ); … … 784 783 FunctionType *function = dynamic_cast< FunctionType *>( pointer->get_base() ); 785 784 assert( function ); 786 785 787 786 if ( Expression *newExpr = handleIntrinsics( appExpr ) ) { 788 787 return newExpr; 789 788 } // if 790 789 791 790 Expression *ret = appExpr; 792 791 793 792 std::list< Expression *>::iterator arg = appExpr->get_args().begin(); 794 793 std::list< Expression *>::iterator paramBegin = appExpr->get_args().begin(); 795 794 796 795 std::string typeName; 797 796 if ( isPolyRet( function, typeName ) ) { … … 807 806 } // if 808 807 arg = appExpr->get_args().begin(); 809 808 810 809 TyVarMap exprTyVars; 811 810 makeTyVarMap( function, exprTyVars ); 812 811 813 812 passTypeVars( appExpr, arg, exprTyVars ); 814 813 addInferredParams( appExpr, function, arg, exprTyVars ); 815 814 816 815 arg = paramBegin; 817 816 818 817 boxParams( appExpr, function, arg, exprTyVars ); 819 818 … … 875 874 // ***** Code Removal ***** After introducing a temporary variable for all return expressions, the following code appears superfluous. 876 875 // if ( returnStmt->get_expr()->get_results().front()->get_isLvalue() ) { 877 // by this point, a cast expr on a polymorphic return value is redundant876 // a cast expr on a polymorphic return value is either redundant or invalid 878 877 while ( CastExpr *castExpr = dynamic_cast< CastExpr *>( returnStmt->get_expr() ) ) { 879 878 returnStmt->set_expr( castExpr->get_arg() ); … … 910 909 TyVarMap oldtyVars = scopeTyVars; 911 910 makeTyVarMap( pointerType, scopeTyVars ); 912 911 913 912 Type *ret = Mutator::mutate( pointerType ); 914 913 915 914 scopeTyVars = oldtyVars; 916 915 return ret; … … 920 919 TyVarMap oldtyVars = scopeTyVars; 921 920 makeTyVarMap( functionType, scopeTyVars ); 922 921 923 922 Type *ret = Mutator::mutate( functionType ); 924 923 925 924 scopeTyVars = oldtyVars; 926 925 return ret; … … 989 988 TyVarMap oldtyVars = scopeTyVars; 990 989 makeTyVarMap( pointerType, scopeTyVars ); 991 990 992 991 Type *ret = Mutator::mutate( pointerType ); 993 992 994 993 scopeTyVars = oldtyVars; 995 994 return ret; … … 1019 1018 if ( (*tyParm)->get_kind() == TypeDecl::Any ) { 1020 1019 TypeInstType parmType( Type::Qualifiers(), (*tyParm)->get_name(), *tyParm ); 1021 1020 1022 1021 sizeParm = newObj.clone(); 1023 1022 sizeParm->set_name( sizeofName( &parmType ) ); … … 1045 1044 std::string sizeName = sizeofName( parmType ); 1046 1045 if ( seenTypes.count( sizeName ) ) continue; 1047 1046 1048 1047 ObjectDecl *sizeParm, *alignParm; 1049 1048 sizeParm = newObj.clone(); … … 1066 1065 mutateAll( funcType->get_returnVals(), *this ); 1067 1066 mutateAll( funcType->get_parameters(), *this ); 1068 1067 1069 1068 scopeTyVars = oldtyVars; 1070 1069 return funcType; … … 1077 1076 TyVarMap oldtyVars = scopeTyVars; 1078 1077 makeTyVarMap( type, scopeTyVars ); 1079 1078 1080 1079 DeclClass *ret = static_cast< DeclClass *>( Mutator::mutate( decl ) ); 1081 1080 ScrubTyVars::scrub( decl, scopeTyVars ); … … 1113 1112 TyVarMap oldtyVars = scopeTyVars; 1114 1113 makeTyVarMap( pointerType, scopeTyVars ); 1115 1114 1116 1115 Type *ret = Mutator::mutate( pointerType ); 1117 1116 1118 1117 scopeTyVars = oldtyVars; 1119 1118 return ret; … … 1123 1122 TyVarMap oldtyVars = scopeTyVars; 1124 1123 makeTyVarMap( functionType, scopeTyVars ); 1125 1124 1126 1125 Type *ret = Mutator::mutate( functionType ); 1127 1126 1128 1127 scopeTyVars = oldtyVars; 1129 1128 return ret; -
src/GenPoly/PolyMutator.h
rae63a18 rc23f807 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Tue Dec 08 15:19:05201513 // Update Count : 512 // Last Modified On : Fri Aug 14 15:27:38 2015 13 // Update Count : 4 14 14 // 15 15 … … 51 51 virtual void doBeginScope() {} 52 52 virtual void doEndScope() {} 53 54 static void makeTyVarMap( Type *type, TyVarMap &tyVarMap );55 53 protected: 56 54 void mutateStatementList( std::list< Statement* > &statements ); 57 55 Statement* mutateStatement( Statement *stmt ); 58 56 Expression* mutateExpression( Expression *expr ); 57 static void makeTyVarMap( Type *type, TyVarMap &tyVarMap ); 59 58 60 59 TyVarMap scopeTyVars; -
src/SynTree/Declaration.cc
rae63a18 rc23f807 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Dec 09 14:08:29201513 // Update Count : 1 211 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jul 13 17:58:38 2015 13 // Update Count : 10 14 14 // 15 15 … … 55 55 } 56 56 57 std::ostream & operator<<( std::ostream & out, Declaration * decl ) {58 decl->print( out );59 return out;60 }61 62 63 57 // Local Variables: // 64 58 // tab-width: 4 // -
src/SynTree/Declaration.h
rae63a18 rc23f807 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Dec 09 14:08:22201513 // Update Count : 3211 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jul 13 18:15:59 2015 13 // Update Count : 28 14 14 // 15 15 … … 259 259 }; 260 260 261 std::ostream & operator<<( std::ostream & out, Declaration * decl );262 263 261 #endif // DECLARATION_H 264 262 -
src/SynTree/Expression.cc
rae63a18 rc23f807 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Dec 09 14:10:29201513 // Update Count : 3 412 // Last Modified On : Wed Sep 02 12:07:10 2015 13 // Update Count : 33 14 14 // 15 15 … … 376 376 } 377 377 378 std::ostream & operator<<( std::ostream & out, Expression * expr ) {379 expr->print( out );380 return out;381 }382 383 378 // Local Variables: // 384 379 // tab-width: 4 // -
src/SynTree/Expression.h
rae63a18 rc23f807 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Dec 09 14:10:21201513 // Update Count : 1 911 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 24 13:49:28 2015 13 // Update Count : 18 14 14 // 15 15 … … 512 512 }; 513 513 514 std::ostream & operator<<( std::ostream & out, Expression * expr );515 516 514 #endif // EXPRESSION_H 517 515 -
src/SynTree/Statement.cc
rae63a18 rc23f807 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Dec 09 14:09:34201513 // Update Count : 5 411 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 25 12:19:50 2015 13 // Update Count : 53 14 14 // 15 15 … … 337 337 } 338 338 339 std::ostream & operator<<( std::ostream & out, Statement * statement ) {340 statement->print( out );341 return out;342 }343 344 339 // Local Variables: // 345 340 // tab-width: 4 // -
src/SynTree/Statement.h
rae63a18 rc23f807 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Dec 09 14:09:24201513 // Update Count : 4 611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 25 18:25:37 2015 13 // Update Count : 44 14 14 // 15 15 … … 396 396 }; 397 397 398 std::ostream & operator<<( std::ostream & out, Statement * statement );399 400 398 #endif // STATEMENT_H 401 399 -
src/SynTree/Type.cc
rae63a18 rc23f807 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Dec 09 14:08:48201513 // Update Count : 411 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 9 16:45:13 2015 13 // Update Count : 3 14 14 // 15 15 … … 80 80 } 81 81 82 std::ostream & operator<<( std::ostream & out, Type * type ) {83 type->print( out );84 return out;85 }86 87 82 // Local Variables: // 88 83 // tab-width: 4 // -
src/SynTree/Type.h
rae63a18 rc23f807 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Type.h -- 7 // Type.h -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Fri Dec 18 14:46:18201513 // Update Count : 1 811 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Nov 27 17:54:31 2015 13 // Update Count : 16 14 14 // 15 15 … … 23 23 class Type { 24 24 public: 25 struct Qualifiers { 25 struct Qualifiers { 26 26 Qualifiers(): isConst( false ), isVolatile( false ), isRestrict( false ), isLvalue( false ), isAtomic( false ), isAttribute( false ) {} 27 27 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 29 29 Qualifiers &operator+=( const Qualifiers &other ); 30 30 Qualifiers &operator-=( const Qualifiers &other ); … … 36 36 bool operator<( const Qualifiers &other ); 37 37 bool operator>( const Qualifiers &other ); 38 38 39 39 bool isConst; 40 40 bool isVolatile; … … 43 43 bool isAtomic; 44 44 bool isAttribute; 45 }; 45 }; 46 46 47 47 Type( const Qualifiers &tq ); … … 85 85 class BasicType : public Type { 86 86 public: 87 enum Kind { 87 enum Kind { 88 88 Bool, 89 89 Char, … … 108 108 LongDoubleImaginary, 109 109 NUMBER_OF_BASIC_TYPES 110 }; 110 }; 111 111 112 112 static const char *typeNames[]; // string names for basic types, MUST MATCH with Kind … … 149 149 private: 150 150 Type *base; 151 151 152 152 // In C99, pointer types can be qualified in many ways e.g., int f( int a[ static 3 ] ) 153 153 Expression *dimension; … … 217 217 void set_name( std::string newValue ) { name = newValue; } 218 218 std::list< Expression* >& get_parameters() { return parameters; } 219 219 220 220 virtual ReferenceToType *clone() const = 0; 221 221 virtual void accept( Visitor &v ) = 0; … … 240 240 /// Accesses generic parameters of base struct (NULL if none such) 241 241 std::list<TypeDecl*> * get_baseParameters(); 242 242 243 243 /// Looks up the members of this struct named "name" and places them into "foundDecls". 244 244 /// Clones declarations into "foundDecls", caller responsible for freeing … … 250 250 private: 251 251 virtual std::string typeString() const; 252 252 253 253 // this decl is not "owned" by the struct inst; it is merely a pointer to elsewhere in the tree, 254 254 // where the structure used in this type is actually defined … … 267 267 /// Accesses generic parameters of base union (NULL if none such) 268 268 std::list<TypeDecl*> * get_baseParameters(); 269 269 270 270 /// looks up the members of this union named "name" and places them into "foundDecls" 271 271 /// Clones declarations into "foundDecls", caller responsible for freeing … … 277 277 private: 278 278 virtual std::string typeString() const; 279 279 280 280 // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree, 281 281 // where the union used in this type is actually defined … … 310 310 private: 311 311 virtual std::string typeString() const; 312 312 313 313 // this member is filled in by the validate pass, which instantiates the members of the correponding 314 314 // aggregate with the actual type parameters specified for this use of the context … … 327 327 bool get_isFtype() const { return isFtype; } 328 328 void set_isFtype( bool newValue ) { isFtype = newValue; } 329 329 330 330 virtual TypeInstType *clone() const { return new TypeInstType( *this ); } 331 331 virtual void accept( Visitor &v ) { v.visit( this ); } … … 463 463 } 464 464 465 std::ostream & operator<<( std::ostream & out, Type * type );466 467 465 #endif // TYPE_H 468 466
Note: See TracChangeset
for help on using the changeset viewer.