Changeset b46e3bd


Ignore:
Timestamp:
Jul 17, 2017, 1:59:53 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
89be1c68
Parents:
a493682
Message:

Update Cost structure to include static unsafe, poly, safe members

Location:
src/ResolvExpr
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/ConversionCost.cc

    ra493682 rb46e3bd  
    2323        const Cost Cost::zero = Cost( 0, 0, 0 );
    2424        const Cost Cost::infinity = Cost( -1, -1, -1 );
     25        const Cost Cost::unsafe = Cost( 1, 0, 0 );
     26        const Cost Cost::poly = Cost( 0, 1, 0 );
     27        const Cost Cost::safe = Cost( 0, 0, 1 );
     28
    2529
    2630        Cost conversionCost( Type *src, Type *dest, const SymTab::Indexer &indexer, const TypeEnvironment &env ) {
  • src/ResolvExpr/Cost.h

    ra493682 rb46e3bd  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Cost.h -- 
     7// Cost.h --
    88//
    99// Author           : Richard C. Bilson
     
    2323          public:
    2424                Cost();
    25                 Cost( int unsafe, int poly, int safe );
    26  
     25                Cost( int unsafeCost, int polyCost, int safeCost );
     26
    2727                void incUnsafe( int inc = 1 );
    2828                void incPoly( int inc = 1 );
    2929                void incSafe( int inc = 1 );
    30  
     30
    3131                Cost operator+( const Cost &other ) const;
    3232                Cost operator-( const Cost &other ) const;
     
    3636                bool operator!=( const Cost &other ) const;
    3737                friend std::ostream &operator<<( std::ostream &os, const Cost &cost );
    38  
     38
    3939                static const Cost zero;
    4040                static const Cost infinity;
     41                static const Cost unsafe;
     42                static const Cost poly;
     43                static const Cost safe;
    4144          private:
    4245                int compare( const Cost &other ) const;
    4346
    44                 int unsafe;
    45                 int poly;
    46                 int safe;
     47                int unsafeCost;
     48                int polyCost;
     49                int safeCost;
    4750        };
    4851
    49         inline Cost::Cost() : unsafe( 0 ), poly( 0 ), safe( 0 ) {}
     52        inline Cost::Cost() : unsafeCost( 0 ), polyCost( 0 ), safeCost( 0 ) {}
    5053
    51         inline Cost::Cost( int unsafe, int poly, int safe ) : unsafe( unsafe ), poly( poly ), safe( safe ) {}
     54        inline Cost::Cost( int unsafeCost, int polyCost, int safeCost ) : unsafeCost( unsafeCost ), polyCost( polyCost ), safeCost( safeCost ) {}
    5255
    5356        inline void Cost::incUnsafe( int inc ) {
    54                 unsafe += inc;
     57                unsafeCost += inc;
    5558        }
    5659
    5760        inline void Cost::incPoly( int inc ) {
    58                 poly += inc;
     61                polyCost += inc;
    5962        }
    6063
    6164        inline void Cost::incSafe( int inc ) {
    62                 safe += inc;
     65                safeCost += inc;
    6366        }
    6467
    6568        inline Cost Cost::operator+( const Cost &other ) const {
    66                 return Cost( unsafe + other.unsafe, poly + other.poly, safe + other.safe );
     69                return Cost( unsafeCost + other.unsafeCost, polyCost + other.polyCost, safeCost + other.safeCost );
    6770        }
    6871
    6972        inline Cost Cost::operator-( const Cost &other ) const {
    70                 return Cost( unsafe - other.unsafe, poly - other.poly, safe - other.safe );
     73                return Cost( unsafeCost - other.unsafeCost, polyCost - other.polyCost, safeCost - other.safeCost );
    7174        }
    7275
    7376        inline Cost &Cost::operator+=( const Cost &other ) {
    74                 unsafe += other.unsafe;
    75                 poly += other.poly;
    76                 safe += other.safe;
     77                unsafeCost += other.unsafeCost;
     78                polyCost += other.polyCost;
     79                safeCost += other.safeCost;
    7780                return *this;
    7881        }
    7982
    8083        inline bool Cost::operator<( const Cost &other ) const {
    81             if ( *this == infinity ) return false;
    82             if ( other == infinity ) return true;
    83             if ( unsafe > other.unsafe ) {
     84                if ( *this == infinity ) return false;
     85                if ( other == infinity ) return true;
     86
     87                if ( unsafeCost > other.unsafeCost ) {
    8488                        return false;
    85             } else if ( unsafe < other.unsafe ) {
     89                } else if ( unsafeCost < other.unsafeCost ) {
    8690                        return true;
    87             } else if ( poly > other.poly ) {
     91                } else if ( polyCost > other.polyCost ) {
    8892                        return false;
    89             } else if ( poly < other.poly ) {
     93                } else if ( polyCost < other.polyCost ) {
    9094                        return true;
    91             } else if ( safe > other.safe ) {
     95                } else if ( safeCost > other.safeCost ) {
    9296                        return false;
    93             } else if ( safe < other.safe ) {
     97                } else if ( safeCost < other.safeCost ) {
    9498                        return true;
    95             } else {
     99                } else {
    96100                        return false;
    97             } // if
     101                } // if
    98102        }
    99103
    100104        inline bool Cost::operator==( const Cost &other ) const {
    101                 return unsafe == other.unsafe
    102                         && poly == other.poly
    103                         && safe == other.safe;
     105                return unsafeCost == other.unsafeCost
     106                        && polyCost == other.polyCost
     107                        && safeCost == other.safeCost;
    104108        }
    105109
     
    109113
    110114        inline std::ostream &operator<<( std::ostream &os, const Cost &cost ) {
    111                 os << "( " << cost.unsafe << ", " << cost.poly << ", " << cost.safe << " )";
     115                os << "( " << cost.unsafeCost << ", " << cost.polyCost << ", " << cost.safeCost << " )";
    112116                return os;
    113117        }
Note: See TracChangeset for help on using the changeset viewer.