Changeset 68fe946e for src


Ignore:
Timestamp:
Oct 8, 2021, 11:38:22 AM (3 years ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
Children:
fe8c31e
Parents:
237df76
Message:

Updated DeclStats? for the new ast. Also fixed a bug in the old implementation (apparently it hasn't been used since gcc-builtins were added).

Location:
src
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • src/AST/porting.md

    r237df76 r68fe946e  
    9898        * `Initializer` => `ast::Init`
    9999    * `Statement` => `ast::Stmt`
     100    * `ReferenceToType` => `ast::BaseInstType`
    100101        * any field names should follow a similar renaming
    101102  * because they don't really belong to `Type` (and for consistency with `Linkage::Spec`):
  • src/CodeTools/DeclStats.cc

    r237df76 r68fe946e  
    156156                /// number of counting bins for linkages
    157157                static const unsigned n_named_specs = 8;
    158                 /// map from total number of specs to bins
    159                 static const unsigned ind_for_linkage[16];
     158                /// Mapping function from linkage to bin.
     159                static unsigned linkage_index( LinkageSpec::Spec spec ) {
     160                        switch ( spec ) {
     161                        case LinkageSpec::Intrinsic:  return 0;
     162                        case LinkageSpec::C:          return 1;
     163                        case LinkageSpec::Cforall:    return 2;
     164                        case LinkageSpec::AutoGen:    return 3;
     165                        case LinkageSpec::Compiler:   return 4;
     166                        case LinkageSpec::BuiltinCFA: return 5;
     167                        case LinkageSpec::BuiltinC:   return 6;
     168                        default:                      return 7;
     169                        }
     170                }
    160171
    161172                Stats for_linkage[n_named_specs];            ///< Stores separate stats per linkage
     
    366377                        const std::string& mangleName = decl->get_mangleName().empty() ? decl->name : decl->get_mangleName();
    367378                        if ( seen_names.insert( mangleName ).second ) {
    368                                 Stats& stats = for_linkage[ ind_for_linkage[ decl->linkage ] ];
     379                                Stats& stats = for_linkage[ linkage_index( decl->linkage ) ];
    369380
    370381                                ++stats.n_decls;
     
    527538        };
    528539
    529         const unsigned DeclStats::ind_for_linkage[]
    530                 = { 7, 7, 2, 1,   7, 7, 7, 3,   4, 7, 6, 5,   7, 7, 7, 0 };
    531 
    532540        void printDeclStats( std::list< Declaration * > &translationUnit ) {
    533541                PassVisitor<DeclStats> stats;
  • src/Common/module.mk

    r237df76 r68fe946e  
    2222      Common/CompilerError.h \
    2323      Common/Debug.h \
     24      Common/DeclStats.hpp \
     25      Common/DeclStats.cpp \
    2426      Common/ErrorObjects.h \
    2527      Common/Eval.cc \
  • src/main.cc

    r237df76 r68fe946e  
    99// Author           : Peter Buhr and Rob Schluntz
    1010// Created On       : Fri May 15 23:12:02 2015
    11 // Last Modified By : Henry Xue
    12 // Last Modified On : Mon Aug 23 15:42:08 2021
    13 // Update Count     : 650
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Oct  8 11:22:00 2021
     13// Update Count     : 651
    1414//
    1515
     
    4343#include "Common/CodeLocationTools.hpp"     // for forceFillCodeLocations
    4444#include "Common/CompilerError.h"           // for CompilerError
     45#include "Common/DeclStats.hpp"
    4546#include "Common/Stats.h"
    4647#include "Common/PassVisitor.h"
     
    341342                } // if
    342343
    343                 if ( declstatsp ) {
    344                         CodeTools::printDeclStats( translationUnit );
    345                         deleteAll( translationUnit );
    346                         return EXIT_SUCCESS;
    347                 } // if
    348 
    349                 if ( bresolvep ) {
    350                         dump( translationUnit );
    351                         return EXIT_SUCCESS;
    352                 } // if
    353 
    354344                CodeTools::fillLocations( translationUnit );
    355 
    356                 if ( resolvprotop ) {
    357                         CodeTools::dumpAsResolvProto( translationUnit );
    358                         return EXIT_SUCCESS;
    359                 } // if
    360345
    361346                if( useNewAST ) {
     
    366351                        auto transUnit = convert( move( translationUnit ) );
    367352
     353                        forceFillCodeLocations( transUnit );
     354
    368355                        PASS( "Expand Member Tuples" , Tuples::expandMemberTuples( transUnit ) );
    369                        
     356
     357                        // LibCfa::makeLibCfa
     358
     359                        if ( declstatsp ) {
     360                                printDeclStats( transUnit );
     361                                return EXIT_SUCCESS;
     362                        } // if
     363
     364                        if ( bresolvep ) {
     365                                dump( move( transUnit ) );
     366                                return EXIT_SUCCESS;
     367                        } // if
     368
     369                        if ( resolvprotop ) {
     370                                // TODO: Better error message.
     371                                assert(false);
     372                                return EXIT_SUCCESS;
     373                        } // if
     374
    370375                        PASS( "Resolve", ResolvExpr::resolve( transUnit ) );
    371376                        if ( exprp ) {
     
    380385                } else {
    381386                        PASS( "Expand Member Tuples" , Tuples::expandMemberTuples( translationUnit ) );
     387
     388                        // LibCfa::makeLibCfa
     389
     390                        if ( declstatsp ) {
     391                                CodeTools::printDeclStats( translationUnit );
     392                                deleteAll( translationUnit );
     393                                return EXIT_SUCCESS;
     394                        } // if
     395
     396                        if ( bresolvep ) {
     397                                dump( translationUnit );
     398                                return EXIT_SUCCESS;
     399                        } // if
     400
     401                        CodeTools::fillLocations( translationUnit );
     402
     403                        if ( resolvprotop ) {
     404                                CodeTools::dumpAsResolvProto( translationUnit );
     405                                return EXIT_SUCCESS;
     406                        } // if
    382407
    383408                        PASS( "Resolve", ResolvExpr::resolve( translationUnit ) );
Note: See TracChangeset for help on using the changeset viewer.