Changeset 78a0b88 for src/ResolvExpr
- Timestamp:
- Sep 1, 2017, 3:33:25 PM (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:
- bc3127d
- Parents:
- e8ccca3 (diff), a01f7c94 (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/ResolvExpr
- Files:
-
- 4 edited
-
AlternativeFinder.cc (modified) (2 diffs)
-
RenameVars.cc (modified) (1 diff)
-
TypeEnvironment.cc (modified) (1 diff)
-
TypeEnvironment.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AlternativeFinder.cc
re8ccca3 r78a0b88 749 749 if ( PointerType *pointer = dynamic_cast< PointerType* >( func->expr->get_result()->stripReferences() ) ) { 750 750 if ( FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ) ) { 751 referenceToRvalueConversion( func->expr ); 751 Alternative newFunc( *func ); 752 referenceToRvalueConversion( newFunc.expr ); 752 753 for ( std::list< AltList >::iterator actualAlt = possibilities.begin(); actualAlt != possibilities.end(); ++actualAlt ) { 753 754 // XXX 754 755 //Designators::check_alternative( function, *actualAlt ); 755 makeFunctionAlternatives( *func, function, *actualAlt, std::back_inserter( candidates ) );756 makeFunctionAlternatives( newFunc, function, *actualAlt, std::back_inserter( candidates ) ); 756 757 } 757 758 } 758 759 } else if ( TypeInstType *typeInst = dynamic_cast< TypeInstType* >( func->expr->get_result()->stripReferences() ) ) { // handle ftype (e.g. *? on function pointer) 759 referenceToRvalueConversion( func->expr );760 760 EqvClass eqvClass; 761 761 if ( func->env.lookup( typeInst->get_name(), eqvClass ) && eqvClass.type ) { 762 762 if ( FunctionType *function = dynamic_cast< FunctionType* >( eqvClass.type ) ) { 763 Alternative newFunc( *func ); 764 referenceToRvalueConversion( newFunc.expr ); 763 765 for ( std::list< AltList >::iterator actualAlt = possibilities.begin(); actualAlt != possibilities.end(); ++actualAlt ) { 764 makeFunctionAlternatives( *func, function, *actualAlt, std::back_inserter( candidates ) );766 makeFunctionAlternatives( newFunc, function, *actualAlt, std::back_inserter( candidates ) ); 765 767 } // for 766 768 } // if … … 773 775 if ( PointerType *pointer = dynamic_cast< PointerType* >( funcOp->expr->get_result()->stripReferences() ) ) { 774 776 if ( FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ) ) { 775 referenceToRvalueConversion( funcOp->expr ); 777 Alternative newFunc( *funcOp ); 778 referenceToRvalueConversion( newFunc.expr ); 776 779 for ( std::list< AltList >::iterator actualAlt = possibilities.begin(); actualAlt != possibilities.end(); ++actualAlt ) { 777 780 AltList currentAlt; 778 781 currentAlt.push_back( *func ); 779 782 currentAlt.insert( currentAlt.end(), actualAlt->begin(), actualAlt->end() ); 780 makeFunctionAlternatives( *funcOp, function, currentAlt, std::back_inserter( candidates ) );783 makeFunctionAlternatives( newFunc, function, currentAlt, std::back_inserter( candidates ) ); 781 784 } // for 782 785 } // if -
src/ResolvExpr/RenameVars.cc
re8ccca3 r78a0b88 88 88 typeBefore( aggregateUseType ); 89 89 acceptAll( aggregateUseType->get_parameters(), *this ); 90 acceptAll( aggregateUseType->get_members(), *this );91 90 typeAfter( aggregateUseType ); 92 91 } -
src/ResolvExpr/TypeEnvironment.cc
re8ccca3 r78a0b88 25 25 26 26 namespace ResolvExpr { 27 // adding this comparison operator significantly improves assertion resolution run time for28 // some cases. The current resolution algorithm's speed partially depends on the order of29 // assertions. Assertions which have fewer possible matches should appear before30 // assertions which have more possible matches. This seems to imply that this could31 // be further improved by providing an indexer as an additional argument and ordering based32 // on the number of matches of the same kind (object, function) for the names of the33 // declarations.34 //35 // I've seen a TU go from 54 minutes to 1 minute 34 seconds with the addition of this comparator.36 bool AssertCompare::operator()( DeclarationWithType * d1, DeclarationWithType * d2 ) const {37 // Objects are always less than functions38 if ( ObjectDecl * objectDecl1 = dynamic_cast< ObjectDecl * >( d1 ) ) {39 if ( ObjectDecl * objectDecl2 = dynamic_cast< ObjectDecl * >( d2 ) ) {40 // objects are ordered by name then type pointer, in that order41 int cmp = objectDecl1->get_name().compare( objectDecl2->get_name() );42 return cmp < 0 ||43 ( cmp == 0 && objectDecl1->get_type() < objectDecl2->get_type() );44 } else {45 return true;46 }47 } else if ( FunctionDecl * funcDecl1 = dynamic_cast< FunctionDecl * >( d1 ) ) {48 if ( FunctionDecl * funcDecl2 = dynamic_cast< FunctionDecl * >( d2 ) ) {49 // functions are ordered by name, # parameters, # returnVals, type pointer in that order50 FunctionType * ftype1 = funcDecl1->get_functionType();51 FunctionType * ftype2 = funcDecl2->get_functionType();52 int numThings1 = ftype1->get_parameters().size() + ftype1->get_returnVals().size();53 int numThings2 = ftype2->get_parameters().size() + ftype2->get_returnVals().size();54 if ( numThings1 < numThings2 ) return true;55 if ( numThings1 > numThings2 ) return false;56 57 // if ( ftype1->get_parameters().size() < ftype2->get_parameters().size() ) return true;58 // else if ( ftype1->get_parameters().size() > ftype2->get_parameters().size() ) return false;59 // // same number of parameters60 // if ( ftype1->get_returnVals().size() < ftype2->get_returnVals().size() ) return true;61 // else if ( ftype1->get_returnVals().size() > ftype2->get_returnVals().size() ) return false;62 // same number of return vals63 // int cmp = funcDecl1->get_name().compare( funcDecl2->get_name() );64 // if ( cmp < 0 ) return true;65 // else if ( cmp > 0 ) return false;66 // // same name67 return ftype1 < ftype2;68 } else {69 return false;70 }71 } else {72 assert( false );73 }74 }75 76 27 void printAssertionSet( const AssertionSet &assertions, std::ostream &os, int indent ) { 77 28 for ( AssertionSet::const_iterator i = assertions.begin(); i != assertions.end(); ++i ) { -
src/ResolvExpr/TypeEnvironment.h
re8ccca3 r78a0b88 28 28 29 29 namespace ResolvExpr { 30 // adding this comparison operator significantly improves assertion resolution run time for 31 // some cases. The current resolution algorithm's speed partially depends on the order of 32 // assertions. Assertions which have fewer possible matches should appear before 33 // assertions which have more possible matches. This seems to imply that this could 34 // be further improved by providing an indexer as an additional argument and ordering based 35 // on the number of matches of the same kind (object, function) for the names of the 36 // declarations. 37 // 38 // I've seen a TU go from 54 minutes to 1 minute 34 seconds with the addition of this comparator. 30 39 struct AssertCompare { 31 bool operator()( DeclarationWithType * d1, DeclarationWithType * d2 ) const; 40 bool operator()( DeclarationWithType * d1, DeclarationWithType * d2 ) const { 41 int cmp = d1->get_name().compare( d2->get_name() ); 42 return cmp < 0 || 43 ( cmp == 0 && d1->get_type() < d2->get_type() ); 44 } 32 45 }; 33 46 struct AssertionSetValue {
Note:
See TracChangeset
for help on using the changeset viewer.