Changeset d150ea2
- Timestamp:
- Feb 19, 2017, 10:23:23 AM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- a98b2cc, bd9bcc8
- Parents:
- e7cc8cb (diff), 0ca9dea (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. - Location:
- src
- Files:
-
- 1 added
- 9 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/Generate.cc
re7cc8cb rd150ea2 22 22 #include "SynTree/Declaration.h" 23 23 #include "CodeGenerator.h" 24 #include "Tuples/Tuples.h" 24 25 25 26 using namespace std; … … 28 29 void generate( std::list< Declaration* > translationUnit, std::ostream &os, bool doIntrinsics, bool pretty ) { 29 30 CodeGen::CodeGenerator cgv( os, pretty ); 30 31 for ( std::list<Declaration *>::iterator i = translationUnit.begin(); i != translationUnit.end(); i++ ) { 32 if ( LinkageSpec::isGeneratable( (*i)->get_linkage() ) && (doIntrinsics || ! LinkageSpec::isBuiltin( (*i)->get_linkage() ) ) ) { 33 (*i)->accept(cgv); 34 if ( doSemicolon( *i ) ) { 31 for ( auto & dcl : translationUnit ) { 32 if ( LinkageSpec::isGeneratable( dcl->get_linkage() ) && (doIntrinsics || ! LinkageSpec::isBuiltin( dcl->get_linkage() ) ) ) { 33 dcl->accept(cgv); 34 if ( doSemicolon( dcl ) ) { 35 35 os << ";"; 36 36 } // if -
src/InitTweak/FixInit.cc
re7cc8cb rd150ea2 1116 1116 // xxx - is the size check necessary? 1117 1117 assert( ctorExpr->has_result() && ctorExpr->get_result()->size() == 1 ); 1118 1119 // xxx - ideally we would reuse the temporary generated from the copy constructor passes from within firstArg if it exists and not generate a temporary if it's unnecessary. 1118 1120 ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, nullptr, ctorExpr->get_result()->clone(), nullptr ); 1119 1121 addDeclaration( tmp ); -
src/InitTweak/InitTweak.cc
re7cc8cb rd150ea2 332 332 return nullptr; 333 333 } 334 } 335 336 DeclarationWithType * getFunction( Expression * expr ) { 337 if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( expr ) ) { 338 return getCalledFunction( appExpr->get_function() ); 339 } else if ( UntypedExpr * untyped = dynamic_cast< UntypedExpr * > ( expr ) ) { 340 return getCalledFunction( untyped->get_function() ); 341 } 342 assertf( false, "getFunction received unknown expression: %s", toString( expr ).c_str() ); 334 343 } 335 344 -
src/InitTweak/InitTweak.h
re7cc8cb rd150ea2 51 51 bool checkInitDepth( ObjectDecl * objDecl ); 52 52 53 /// Non-Null if expr is a call expression whose target function is intrinsic 54 ApplicationExpr * isIntrinsicCallExpr( Expression * expr ); 53 /// returns the declaration of the function called by the expr (must be ApplicationExpr or UntypedExpr) 54 DeclarationWithType * getFunction( Expression * expr ); 55 56 /// Non-Null if expr is a call expression whose target function is intrinsic 57 ApplicationExpr * isIntrinsicCallExpr( Expression * expr ); 55 58 56 59 /// True if stmt is a call statement where the function called is intrinsic and takes one parameter. -
src/ResolvExpr/AlternativeFinder.cc
re7cc8cb rd150ea2 1044 1044 1045 1045 void AlternativeFinder::visit( ConditionalExpr *conditionalExpr ) { 1046 // find alternatives for condition 1046 1047 AlternativeFinder firstFinder( indexer, env ); 1047 1048 firstFinder.findWithAdjustment( conditionalExpr->get_arg1() ); 1048 1049 for ( AltList::const_iterator first = firstFinder.alternatives.begin(); first != firstFinder.alternatives.end(); ++first ) { 1050 // find alternatives for true expression 1049 1051 AlternativeFinder secondFinder( indexer, first->env ); 1050 1052 secondFinder.findWithAdjustment( conditionalExpr->get_arg2() ); 1051 1053 for ( AltList::const_iterator second = secondFinder.alternatives.begin(); second != secondFinder.alternatives.end(); ++second ) { 1054 // find alterantives for false expression 1052 1055 AlternativeFinder thirdFinder( indexer, second->env ); 1053 1056 thirdFinder.findWithAdjustment( conditionalExpr->get_arg3() ); 1054 1057 for ( AltList::const_iterator third = thirdFinder.alternatives.begin(); third != thirdFinder.alternatives.end(); ++third ) { 1058 // unify true and false types, then infer parameters to produce new alternatives 1055 1059 OpenVarSet openVars; 1056 1060 AssertionSet needAssertions, haveAssertions; … … 1079 1083 } 1080 1084 1085 void AlternativeFinder::visit( RangeExpr * rangeExpr ) { 1086 // resolve low and high, accept alternatives whose low and high types unify 1087 AlternativeFinder firstFinder( indexer, env ); 1088 firstFinder.findWithAdjustment( rangeExpr->get_low() ); 1089 for ( AltList::const_iterator first = firstFinder.alternatives.begin(); first != firstFinder.alternatives.end(); ++first ) { 1090 AlternativeFinder secondFinder( indexer, first->env ); 1091 secondFinder.findWithAdjustment( rangeExpr->get_high() ); 1092 for ( AltList::const_iterator second = secondFinder.alternatives.begin(); second != secondFinder.alternatives.end(); ++second ) { 1093 OpenVarSet openVars; 1094 AssertionSet needAssertions, haveAssertions; 1095 Alternative newAlt( 0, second->env, first->cost + second->cost ); 1096 Type* commonType = nullptr; 1097 if ( unify( first->expr->get_result(), second->expr->get_result(), newAlt.env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) { 1098 RangeExpr *newExpr = new RangeExpr( first->expr->clone(), second->expr->clone() ); 1099 newExpr->set_result( commonType ? commonType : first->expr->get_result()->clone() ); 1100 newAlt.expr = newExpr; 1101 inferParameters( needAssertions, haveAssertions, newAlt, openVars, back_inserter( alternatives ) ); 1102 } // if 1103 } // for 1104 } // for 1105 } 1106 1081 1107 void AlternativeFinder::visit( UntypedTupleExpr *tupleExpr ) { 1082 1108 std::list< AlternativeFinder > subExprAlternatives; -
src/ResolvExpr/AlternativeFinder.h
re7cc8cb rd150ea2 66 66 virtual void visit( ImplicitCopyCtorExpr * impCpCtorExpr ); 67 67 virtual void visit( ConstructorExpr * ctorExpr ); 68 virtual void visit( RangeExpr * rangeExpr ); 68 69 virtual void visit( UntypedTupleExpr *tupleExpr ); 69 70 virtual void visit( TupleExpr *tupleExpr ); -
src/ResolvExpr/Resolver.cc
re7cc8cb rd150ea2 302 302 } 303 303 304 template< typename SwitchClass >305 void handleSwitchStmt( SwitchClass *switchStmt, SymTab::Indexer &visitor ) {304 void Resolver::visit( SwitchStmt *switchStmt ) { 305 ValueGuard< Type * > oldInitContext( initContext ); 306 306 Expression *newExpr; 307 newExpr = findIntegralExpression( switchStmt->get_condition(), visitor);307 newExpr = findIntegralExpression( switchStmt->get_condition(), *this ); 308 308 delete switchStmt->get_condition(); 309 309 switchStmt->set_condition( newExpr ); 310 310 311 visitor.Visitor::visit( switchStmt ); 312 } 313 314 void Resolver::visit( SwitchStmt *switchStmt ) { 315 handleSwitchStmt( switchStmt, *this ); 311 initContext = newExpr->get_result(); 312 Parent::visit( switchStmt ); 316 313 } 317 314 318 315 void Resolver::visit( CaseStmt *caseStmt ) { 316 if ( caseStmt->get_condition() ) { 317 assert( initContext ); 318 CastExpr * castExpr = new CastExpr( caseStmt->get_condition(), initContext->clone() ); 319 Expression * newExpr = findSingleExpression( castExpr, *this ); 320 castExpr = safe_dynamic_cast< CastExpr * >( newExpr ); 321 caseStmt->set_condition( castExpr->get_arg() ); 322 castExpr->set_arg( nullptr ); 323 delete castExpr; 324 } 319 325 Parent::visit( caseStmt ); 320 326 } -
src/Tuples/TupleExpansion.cc
re7cc8cb rd150ea2 29 29 #include "ResolvExpr/typeops.h" 30 30 #include "InitTweak/GenInit.h" 31 #include "InitTweak/InitTweak.h" 31 32 32 33 namespace Tuples { … … 78 79 } 79 80 private: 80 ScopedMap< std::string, StructDecl * > typeMap;81 ScopedMap< int, StructDecl * > typeMap; 81 82 }; 82 83 … … 213 214 214 215 Type * TupleTypeReplacer::mutate( TupleType * tupleType ) { 215 std::string mangleName = SymTab::Mangler::mangleType( tupleType );216 216 tupleType = safe_dynamic_cast< TupleType * > ( Parent::mutate( tupleType ) ); 217 if ( ! typeMap.count( mangleName ) ) {218 // generate struct type to replace tuple type219 // xxx - should fix this to only generate one tuple struct for each number of type parameters220 StructDecl * decl = new StructDecl( "_tuple_type_" + mangleName);217 unsigned tupleSize = tupleType->size(); 218 if ( ! typeMap.count( tupleSize ) ) { 219 // generate struct type to replace tuple type based on the number of components in the tuple 220 StructDecl * decl = new StructDecl( toString( "_tuple_type_", tupleSize ) ); 221 221 decl->set_body( true ); 222 for ( size_t i = 0; i < tuple Type->size(); ++i ) {222 for ( size_t i = 0; i < tupleSize; ++i ) { 223 223 TypeDecl * tyParam = new TypeDecl( toString("tuple_param_", i), DeclarationNode::NoStorageClass, nullptr, TypeDecl::Any ); 224 224 decl->get_members().push_back( new ObjectDecl( toString("field_", i), DeclarationNode::NoStorageClass, LinkageSpec::C, nullptr, new TypeInstType( Type::Qualifiers(), tyParam->get_name(), tyParam ), nullptr ) ); 225 225 decl->get_parameters().push_back( tyParam ); 226 226 } 227 if ( tuple Type->size()== 0 ) {227 if ( tupleSize == 0 ) { 228 228 // empty structs are not standard C. Add a dummy field to empty tuples to silence warnings when a compound literal Tuple0 is created. 229 229 decl->get_members().push_back( new ObjectDecl( "dummy", DeclarationNode::NoStorageClass, LinkageSpec::C, nullptr, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) ); 230 230 } 231 typeMap[ mangleName] = decl;231 typeMap[tupleSize] = decl; 232 232 addDeclaration( decl ); 233 233 } 234 234 Type::Qualifiers qualifiers = tupleType->get_qualifiers(); 235 235 236 StructDecl * decl = typeMap[ mangleName];236 StructDecl * decl = typeMap[tupleSize]; 237 237 StructInstType * newType = new StructInstType( qualifiers, decl ); 238 238 for ( Type * t : *tupleType ) { … … 337 337 public: 338 338 typedef Visitor Parent; 339 virtual void visit( ApplicationExpr * appExpr ) { maybeImpure = true; } 339 virtual void visit( ApplicationExpr * appExpr ) { 340 if ( DeclarationWithType * function = InitTweak::getFunction( appExpr ) ) { 341 if ( function->get_linkage() == LinkageSpec::Intrinsic ) { 342 if ( function->get_name() == "*?" || function->get_name() == "?[?]" ) { 343 // intrinsic dereference, subscript are pure, but need to recursively look for impurity 344 Parent::visit( appExpr ); 345 return; 346 } 347 } 348 } 349 maybeImpure = true; 350 } 340 351 virtual void visit( UntypedExpr * untypedExpr ) { maybeImpure = true; } 341 352 bool maybeImpure = false; -
src/tests/dtor-early-exit.c
re7cc8cb rd150ea2 1 // 1 // 2 2 // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo 3 3 // 4 4 // The contents of this file are covered under the licence agreement in the 5 5 // file "LICENCE" distributed with Cforall. 6 // 7 // dtor-early-exit.c -- 8 // 6 // 7 // dtor-early-exit.c -- 8 // 9 9 // Author : Rob Schluntz 10 10 // Created On : Wed Aug 17 08:26:25 2016 … … 12 12 // Last Modified On : Wed Aug 17 08:29:37 2016 13 13 // Update Count : 2 14 // 14 // 15 15 16 16 #include <fstream> … … 213 213 // S_G-S_L = {} 214 214 } 215 #ifdef ERR2 215 216 // S_G = {} 216 #ifdef ERR2217 217 if (i == 5) goto L2; // this is an error in g++ because it skips initialization of y, x 218 218 // S_L-S_G = { y, x } => non-empty, so error
Note: See TracChangeset
for help on using the changeset viewer.