Changeset fd642d2
- Timestamp:
- Jul 22, 2019, 2:19:57 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 8fc15cf, c60a664
- Parents:
- 884f1409
- Location:
- src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/Alternative.h
r884f1409 rfd642d2 29 29 /// One assertion to resolve 30 30 struct AssertionItem { 31 DeclarationWithType* decl;31 const DeclarationWithType* decl; 32 32 AssertionSetValue info; 33 33 34 34 AssertionItem() = default; 35 AssertionItem( DeclarationWithType* decl, const AssertionSetValue& info )35 AssertionItem( const DeclarationWithType* decl, const AssertionSetValue& info ) 36 36 : decl(decl), info(info) {} 37 37 AssertionItem( const AssertionSet::value_type& e ) : decl(e.first), info(e.second) {} -
src/ResolvExpr/TypeEnvironment.cc
r884f1409 rfd642d2 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 12:19:47 2015 11 // Last Modified By : A aron B. Moss12 // Last Modified On : Mon Jun 18 11:58:00 201813 // Update Count : 411 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Jun 18 14:27:00 2019 13 // Update Count : 5 14 14 // 15 15 … … 315 315 } 316 316 317 bool isFtype( const Type * type ) {317 bool isFtype( const Type * type ) { 318 318 if ( dynamic_cast< const FunctionType * >( type ) ) { 319 319 return true; … … 324 324 } 325 325 326 bool tyVarCompatible( const TypeDecl::Data & data, Type *type ) {326 bool tyVarCompatible( const TypeDecl::Data & data, const Type * type ) { 327 327 switch ( data.kind ) { 328 328 case TypeDecl::Dtype: … … 336 336 case TypeDecl::Ttype: 337 337 // ttype unifies with any tuple type 338 return dynamic_cast< TupleType * >( type ) || Tuples::isTtype( type );338 return dynamic_cast< const TupleType * >( type ) || Tuples::isTtype( type ); 339 339 default: 340 340 assertf(false, "Unhandled tyvar kind: %d", data.kind); … … 343 343 } 344 344 345 bool TypeEnvironment::bindVar( TypeInstType *typeInst, Type *bindTo, const TypeDecl::Data & data, AssertionSet &need, AssertionSet &have, const OpenVarSet &openVars, WidenMode widen, const SymTab::Indexer &indexer ) {345 bool TypeEnvironment::bindVar( const TypeInstType *typeInst, Type *bindTo, const TypeDecl::Data & data, AssertionSet &need, AssertionSet &have, const OpenVarSet &openVars, WidenMode widen, const SymTab::Indexer &indexer ) { 346 346 347 347 // remove references from other, so that type variables can only bind to value types … … 361 361 // attempt to unify equivalence class type (which has qualifiers stripped, so they must be restored) with the type to bind to 362 362 std::unique_ptr< Type > newType( curClass->type->clone() ); 363 newType-> get_qualifiers() = typeInst->get_qualifiers();363 newType->tq = typeInst->tq; 364 364 if ( unifyInexact( newType.get(), bindTo, *this, need, have, openVars, widen & WidenMode( curClass->allowWidening, true ), indexer, common ) ) { 365 365 if ( common ) { … … 386 386 } 387 387 388 bool TypeEnvironment::bindVarToVar( TypeInstType *var1, TypeInstType *var2,389 TypeDecl::Data && data, AssertionSet &need, AssertionSet &have, 388 bool TypeEnvironment::bindVarToVar( const TypeInstType * var1, const TypeInstType * var2, 389 TypeDecl::Data && data, AssertionSet &need, AssertionSet &have, 390 390 const OpenVarSet &openVars, WidenMode widen, const SymTab::Indexer &indexer ) { 391 391 -
src/ResolvExpr/TypeEnvironment.h
r884f1409 rfd642d2 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 12:24:58 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Tue Apr 30 23:04:10 201913 // Update Count : 911 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Jul 19 17:00:10 2019 13 // Update Count : 10 14 14 // 15 15 … … 40 40 // declarations. 41 41 // 42 // I've seen a TU go from 54 minutes to 1 minute 34 seconds with the addition of this 42 // I've seen a TU go from 54 minutes to 1 minute 34 seconds with the addition of this 43 43 // comparator. 44 44 // … … 46 46 // memory layout can alter compilation time in unpredictable ways. For example, the placement 47 47 // of a line directive can reorder type pointers with respect to each other so that assertions 48 // are seen in different orders, causing a potentially different number of unification calls 49 // when resolving assertions. I've seen a TU go from 36 seconds to 27 seconds by reordering 50 // line directives alone, so it would be nice to fix this comparison so that assertions compare 51 // more consistently. I've tried to modify this to compare on mangle name instead of type as 52 // the second comparator, but this causes some assertions to never be recorded. More 48 // are seen in different orders, causing a potentially different number of unification calls 49 // when resolving assertions. I've seen a TU go from 36 seconds to 27 seconds by reordering 50 // line directives alone, so it would be nice to fix this comparison so that assertions compare 51 // more consistently. I've tried to modify this to compare on mangle name instead of type as 52 // the second comparator, but this causes some assertions to never be recorded. More 53 53 // investigation is needed. 54 54 struct AssertCompare { 55 bool operator()( DeclarationWithType * d1,DeclarationWithType * d2 ) const {55 bool operator()( const DeclarationWithType * d1, const DeclarationWithType * d2 ) const { 56 56 int cmp = d1->get_name().compare( d2->get_name() ); 57 57 return cmp < 0 || … … 65 65 AssertionSetValue() : isUsed(false), resnSlot(0) {} 66 66 }; 67 typedef std::map< DeclarationWithType *, AssertionSetValue, AssertCompare > AssertionSet;67 typedef std::map< const DeclarationWithType *, AssertionSetValue, AssertCompare > AssertionSet; 68 68 typedef std::unordered_map< std::string, TypeDecl::Data > OpenVarSet; 69 69 … … 78 78 struct EqvClass { 79 79 std::set< std::string > vars; 80 Type * type;80 Type * type; 81 81 bool allowWidening; 82 82 TypeDecl::Data data; … … 111 111 bool isEmpty() const { return env.empty(); } 112 112 void print( std::ostream &os, Indenter indent = {} ) const; 113 113 114 114 /// Simply concatenate the second environment onto this one; no safety checks performed 115 115 void simpleCombine( const TypeEnvironment &second ); … … 126 126 /// Returns false if fails, but does NOT roll back partial changes. 127 127 bool combine( const TypeEnvironment& second, OpenVarSet& openVars, const SymTab::Indexer& indexer ); 128 128 129 129 void extractOpenVars( OpenVarSet &openVars ) const; 130 130 TypeEnvironment *clone() const { return new TypeEnvironment( *this ); } … … 134 134 void addActual( const TypeEnvironment& actualEnv, OpenVarSet& openVars ); 135 135 136 /// Binds the type class represented by `typeInst` to the type `bindTo`; will add 136 /// Binds the type class represented by `typeInst` to the type `bindTo`; will add 137 137 /// the class if needed. Returns false on failure. 138 bool bindVar( TypeInstType *typeInst, Type *bindTo, const TypeDecl::Data & data, AssertionSet &need, AssertionSet &have, const OpenVarSet &openVars, WidenMode widen, const SymTab::Indexer &indexer );139 140 /// Binds the type classes represented by `var1` and `var2` together; will add 138 bool bindVar( const TypeInstType * typeInst, Type * bindTo, const TypeDecl::Data & data, AssertionSet &need, AssertionSet &have, const OpenVarSet &openVars, WidenMode widen, const SymTab::Indexer &indexer ); 139 140 /// Binds the type classes represented by `var1` and `var2` together; will add 141 141 /// one or both classes if needed. Returns false on failure. 142 bool bindVarToVar( TypeInstType *var1, TypeInstType *var2, TypeDecl::Data && data, AssertionSet &need, AssertionSet &have, const OpenVarSet &openVars, WidenMode widen, const SymTab::Indexer &indexer );142 bool bindVarToVar( const TypeInstType * var1, const TypeInstType * var2, TypeDecl::Data && data, AssertionSet &need, AssertionSet &have, const OpenVarSet &openVars, WidenMode widen, const SymTab::Indexer &indexer ); 143 143 144 144 /// Disallows widening for all bindings in the environment … … 151 151 private: 152 152 ClassList env; 153 153 154 154 ClassList::iterator internal_lookup( const std::string &var ); 155 155 }; -
src/Tuples/TupleExpansion.cc
r884f1409 rfd642d2 350 350 } 351 351 352 const TypeInstType * isTtype( const Type * type ) { 353 if ( const TypeInstType * inst = dynamic_cast< const TypeInstType * >( type ) ) { 354 if ( inst->baseType && inst->baseType->kind == TypeDecl::Ttype ) { 355 return inst; 356 } 357 } 358 return nullptr; 359 } 360 352 361 const ast::TypeInstType * isTtype( const ast::Type * type ) { 353 362 if ( const ast::TypeInstType * inst = dynamic_cast< const ast::TypeInstType * >( type ) ) { -
src/Tuples/Tuples.h
r884f1409 rfd642d2 52 52 /// returns a TypeInstType if `type` is a ttype, nullptr otherwise 53 53 TypeInstType * isTtype( Type * type ); 54 const TypeInstType * isTtype( const Type * type ); 54 55 const ast::TypeInstType * isTtype( const ast::Type * type ); 55 56
Note: See TracChangeset
for help on using the changeset viewer.