Changes in / [261fd34:8762501]
- Location:
- src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Box.cc
r261fd34 r8762501 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 : Peter A. Buhr12 // Last Modified On : Tue Dec 15 15:30:31201513 // Update Count : 21 511 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri Dec 18 14:53:08 2015 13 // Update Count : 217 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) 187 188 bool checkAssignment( DeclarationWithType *decl, std::string &name ) { 188 189 if ( decl->get_name() == "?=?" ) { … … 233 234 if ( isPolyRet( functionDecl->get_functionType(), typeName ) && functionDecl->get_linkage() == LinkageSpec::Cforall ) { 234 235 retval = functionDecl->get_functionType()->get_returnVals().front(); 235 236 236 237 // give names to unnamed return values 237 238 if ( retval->get_name() == "" ) { … … 240 241 } // if 241 242 } // if 242 243 243 244 FunctionType *functionType = functionDecl->get_functionType(); 244 245 makeTyVarMap( functionDecl->get_functionType(), scopeTyVars ); … … 265 266 266 267 functionDecl->set_statements( functionDecl->get_statements()->acceptMutator( *this ) ); 267 268 268 269 scopeTyVars = oldtyVars; 269 270 assignOps = oldassignOps; … … 328 329 FunctionType *funcType = getFunctionType( appExpr->get_function()->get_results().front() ); 329 330 assert( funcType ); 330 331 331 332 std::list< DeclarationWithType* >::const_iterator fnParm = funcType->get_parameters().begin(); 332 333 std::list< Expression* >::const_iterator fnArg = arg; … … 405 406 appExpr->get_args().push_front( appExpr->get_function() ); 406 407 appExpr->set_function( new NameExpr( adapterName ) ); 407 408 408 409 return ret; 409 410 } … … 528 529 ApplicationExpr *adapteeApp = new ApplicationExpr( new CastExpr( new VariableExpr( adapteeDecl ), new PointerType( Type::Qualifiers(), realType ) ) ); 529 530 Statement *bodyStmt; 530 531 531 532 std::list< TypeDecl *>::iterator tyArg = realType->get_forall().begin(); 532 533 std::list< TypeDecl *>::iterator tyParam = adapterType->get_forall().begin(); … … 542 543 } // for 543 544 } // for 544 545 545 546 std::list< DeclarationWithType *>::iterator arg = realType->get_parameters().begin(); 546 547 std::list< DeclarationWithType *>::iterator param = adapterType->get_parameters().begin(); … … 599 600 if ( adaptersDone.find( mangleName ) == adaptersDone.end() ) { 600 601 adaptersDone.insert( adaptersDone.begin(), mangleName ); 601 602 602 603 // apply substitution to type variables to figure out what the adapter's type should look like 603 604 assert( env ); 604 605 env->apply( realFunction ); 605 mangleName = SymTab::Mangler::mangle( realFunction ); 606 mangleName = SymTab::Mangler::mangle( realFunction ); 606 607 mangleName += makePolyMonoSuffix( originalFunction, exprTyVars ); 607 608 … … 654 655 Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_results().front(), scopeTyVars, env ); 655 656 Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_results().front(), scopeTyVars, env ); 656 assert( ! baseType1 || ! baseType2 ); 657 assert( ! baseType1 || ! baseType2 ); // the arguments cannot both be polymorphic pointers 657 658 UntypedExpr *ret = 0; 658 if ( baseType1 || baseType2 ) { 659 if ( baseType1 || baseType2 ) { // one of the arguments is a polymorphic pointer 659 660 ret = new UntypedExpr( new NameExpr( "?+?" ) ); 660 661 } // if … … 777 778 mutateAll( appExpr->get_args(), *this ); 778 779 useRetval = oldUseRetval; 779 780 780 781 assert( ! appExpr->get_function()->get_results().empty() ); 781 782 PointerType *pointer = dynamic_cast< PointerType *>( appExpr->get_function()->get_results().front() ); … … 783 784 FunctionType *function = dynamic_cast< FunctionType *>( pointer->get_base() ); 784 785 assert( function ); 785 786 786 787 if ( Expression *newExpr = handleIntrinsics( appExpr ) ) { 787 788 return newExpr; 788 789 } // if 789 790 790 791 Expression *ret = appExpr; 791 792 792 793 std::list< Expression *>::iterator arg = appExpr->get_args().begin(); 793 794 std::list< Expression *>::iterator paramBegin = appExpr->get_args().begin(); 794 795 795 796 std::string typeName; 796 797 if ( isPolyRet( function, typeName ) ) { … … 806 807 } // if 807 808 arg = appExpr->get_args().begin(); 808 809 809 810 TyVarMap exprTyVars; 810 811 makeTyVarMap( function, exprTyVars ); 811 812 812 813 passTypeVars( appExpr, arg, exprTyVars ); 813 814 addInferredParams( appExpr, function, arg, exprTyVars ); 814 815 815 816 arg = paramBegin; 816 817 817 818 boxParams( appExpr, function, arg, exprTyVars ); 818 819 … … 874 875 // ***** Code Removal ***** After introducing a temporary variable for all return expressions, the following code appears superfluous. 875 876 // if ( returnStmt->get_expr()->get_results().front()->get_isLvalue() ) { 876 // a cast expr on a polymorphic return value is either redundant or invalid877 // by this point, a cast expr on a polymorphic return value is redundant 877 878 while ( CastExpr *castExpr = dynamic_cast< CastExpr *>( returnStmt->get_expr() ) ) { 878 879 returnStmt->set_expr( castExpr->get_arg() ); … … 909 910 TyVarMap oldtyVars = scopeTyVars; 910 911 makeTyVarMap( pointerType, scopeTyVars ); 911 912 912 913 Type *ret = Mutator::mutate( pointerType ); 913 914 914 915 scopeTyVars = oldtyVars; 915 916 return ret; … … 919 920 TyVarMap oldtyVars = scopeTyVars; 920 921 makeTyVarMap( functionType, scopeTyVars ); 921 922 922 923 Type *ret = Mutator::mutate( functionType ); 923 924 924 925 scopeTyVars = oldtyVars; 925 926 return ret; … … 988 989 TyVarMap oldtyVars = scopeTyVars; 989 990 makeTyVarMap( pointerType, scopeTyVars ); 990 991 991 992 Type *ret = Mutator::mutate( pointerType ); 992 993 993 994 scopeTyVars = oldtyVars; 994 995 return ret; … … 1018 1019 if ( (*tyParm)->get_kind() == TypeDecl::Any ) { 1019 1020 TypeInstType parmType( Type::Qualifiers(), (*tyParm)->get_name(), *tyParm ); 1020 1021 1021 1022 sizeParm = newObj.clone(); 1022 1023 sizeParm->set_name( sizeofName( &parmType ) ); … … 1044 1045 std::string sizeName = sizeofName( parmType ); 1045 1046 if ( seenTypes.count( sizeName ) ) continue; 1046 1047 1047 1048 ObjectDecl *sizeParm, *alignParm; 1048 1049 sizeParm = newObj.clone(); … … 1065 1066 mutateAll( funcType->get_returnVals(), *this ); 1066 1067 mutateAll( funcType->get_parameters(), *this ); 1067 1068 1068 1069 scopeTyVars = oldtyVars; 1069 1070 return funcType; … … 1076 1077 TyVarMap oldtyVars = scopeTyVars; 1077 1078 makeTyVarMap( type, scopeTyVars ); 1078 1079 1079 1080 DeclClass *ret = static_cast< DeclClass *>( Mutator::mutate( decl ) ); 1080 1081 ScrubTyVars::scrub( decl, scopeTyVars ); … … 1112 1113 TyVarMap oldtyVars = scopeTyVars; 1113 1114 makeTyVarMap( pointerType, scopeTyVars ); 1114 1115 1115 1116 Type *ret = Mutator::mutate( pointerType ); 1116 1117 1117 1118 scopeTyVars = oldtyVars; 1118 1119 return ret; … … 1122 1123 TyVarMap oldtyVars = scopeTyVars; 1123 1124 makeTyVarMap( functionType, scopeTyVars ); 1124 1125 1125 1126 Type *ret = Mutator::mutate( functionType ); 1126 1127 1127 1128 scopeTyVars = oldtyVars; 1128 1129 return ret; -
src/GenPoly/PolyMutator.h
r261fd34 r8762501 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri Aug 14 15:27:38201513 // Update Count : 412 // Last Modified On : Tue Dec 08 15:19:05 2015 13 // Update Count : 5 14 14 // 15 15 … … 51 51 virtual void doBeginScope() {} 52 52 virtual void doEndScope() {} 53 54 static void makeTyVarMap( Type *type, TyVarMap &tyVarMap ); 53 55 protected: 54 56 void mutateStatementList( std::list< Statement* > &statements ); 55 57 Statement* mutateStatement( Statement *stmt ); 56 58 Expression* mutateExpression( Expression *expr ); 57 static void makeTyVarMap( Type *type, TyVarMap &tyVarMap );58 59 59 60 TyVarMap scopeTyVars; -
src/SynTree/Declaration.cc
r261fd34 r8762501 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Mon Jul 13 17:58:38201513 // Update Count : 1 011 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Dec 09 14:08:29 2015 13 // Update Count : 12 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 57 63 // Local Variables: // 58 64 // tab-width: 4 // -
src/SynTree/Declaration.h
r261fd34 r8762501 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Mon Jul 13 18:15:59201513 // Update Count : 2811 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Dec 09 14:08:22 2015 13 // Update Count : 32 14 14 // 15 15 … … 259 259 }; 260 260 261 std::ostream & operator<<( std::ostream & out, Declaration * decl ); 262 261 263 #endif // DECLARATION_H 262 264 -
src/SynTree/Expression.cc
r261fd34 r8762501 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Sep 02 12:07:10201513 // Update Count : 3 312 // Last Modified On : Wed Dec 09 14:10:29 2015 13 // Update Count : 34 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 378 383 // Local Variables: // 379 384 // tab-width: 4 // -
src/SynTree/Expression.h
r261fd34 r8762501 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Jul 24 13:49:28201513 // Update Count : 1 811 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Dec 09 14:10:21 2015 13 // Update Count : 19 14 14 // 15 15 … … 512 512 }; 513 513 514 std::ostream & operator<<( std::ostream & out, Expression * expr ); 515 514 516 #endif // EXPRESSION_H 515 517 -
src/SynTree/Statement.cc
r261fd34 r8762501 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sat Jul 25 12:19:50201513 // Update Count : 5 311 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Dec 09 14:09:34 2015 13 // Update Count : 54 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 339 344 // Local Variables: // 340 345 // tab-width: 4 // -
src/SynTree/Statement.h
r261fd34 r8762501 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sat Jul 25 18:25:37201513 // Update Count : 4 411 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Dec 09 14:09:24 2015 13 // Update Count : 46 14 14 // 15 15 … … 396 396 }; 397 397 398 std::ostream & operator<<( std::ostream & out, Statement * statement ); 399 398 400 #endif // STATEMENT_H 399 401 -
src/SynTree/Type.cc
r261fd34 r8762501 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Thu Jul 9 16:45:13201513 // Update Count : 311 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Dec 09 14:08:48 2015 13 // Update Count : 4 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 82 87 // Local Variables: // 83 88 // tab-width: 4 // -
src/SynTree/Type.h
r261fd34 r8762501 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 : Peter A. Buhr12 // Last Modified On : Fri Nov 27 17:54:31201513 // Update Count : 1 611 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri Dec 18 14:46:18 2015 13 // Update Count : 18 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 465 467 #endif // TYPE_H 466 468
Note: See TracChangeset
for help on using the changeset viewer.