Changeset 7d55e4d


Ignore:
Timestamp:
Oct 30, 2023, 4:59:34 PM (14 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
4ac402d
Parents:
36e6f10
Message:

Simple rework to BasicTypes?-gen.cc to avoid refering to the old ast. No larger rework at this time.

Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/BasicTypes-gen.cc

    r36e6f10 r7d55e4d  
    117117        // { LongDoubleImaginary, "LongDoubleImaginary", "LDI", "long double _Imaginary", "Ie", false, LongDoubleComplex, -1, -1, 17 },
    118118
    119         { uFloat128x, "uFloat128x", "_FBX", "_Float128x", "DF128x_", Floating, uFloat128xComplex, -1, -1, 18 }, 
     119        { uFloat128x, "uFloat128x", "_FBX", "_Float128x", "DF128x_", Floating, uFloat128xComplex, -1, -1, 18 },
    120120        { uFloat128xComplex, "uFloat128xComplex", "_FLDXC", "_Float128x _Complex", "CDF128x_", Floating, -1, -1, -1, 18 }
    121121}; // graph
     
    127127void generateCosts( int row ) {
    128128        bool seen[NUMBER_OF_BASIC_TYPES] = { false /*, ... */ };
    129        
     129
    130130        struct el_cost {
    131131                int i;
    132132                int path;
    133133                int sign;
    134                
     134
    135135                el_cost( int i = 0, int p = 0, int s = 0 ) : i(i), path(p), sign(s) {}
    136                
     136
    137137                // reverse the sense for use in largest-on-top priority queue
    138138                bool operator< (const el_cost& o) const {
     
    195195                        return;
    196196                } // if
    197                
     197
    198198                i = graph[col].middle;
    199199                if ( i == -1 ) assert("invalid ancestor assumption");
     
    284284        for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) {
    285285                code << "\t\t" << graph[r].name << "," << endl;
    286         } // for       
     286        } // for
    287287        code << "\t\tNUMBER_OF_BASIC_TYPES" << endl;
    288288        code << "\t} kind;" << endl;
     
    307307        for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) {
    308308                code << "\t\"" << graph[r].type << "\"," << endl;
    309         } // for       
     309        } // for
    310310        code << "};" << endl;
    311311
     
    329329        for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) {
    330330                code << "\t\t" << graph[r].name << "," << endl;
    331         } // for       
     331        } // for
    332332        code << "\t\tNUMBER_OF_BASIC_TYPES" << endl;
    333333        code << "\t} kind;" << endl;
     
    352352        for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) {
    353353                code << "\t\"" << graph[r].type << "\"," << endl;
    354         } // for       
     354        } // for
    355355        code << "};" << endl;
    356356
     
    391391        end += sizeof( STARTMK );
    392392        code << str.substr( start, end - start );
    393        
     393
    394394        code << "\t" << BYMK << endl;
    395         code << "\tstatic const int costMatrix[BasicType::NUMBER_OF_BASIC_TYPES][BasicType::NUMBER_OF_BASIC_TYPES] = { // path length from root to node" << endl
     395        code << "\tstatic const int costMatrix[ast::BasicType::NUMBER_OF_BASIC_TYPES][ast::BasicType::NUMBER_OF_BASIC_TYPES] = { // path length from root to node" << endl
    396396                 << "\t\t/*           ";
    397397        for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { // titles
     
    411411        code << "\tstatic const int maxIntCost = " << *max_element(costMatrix[SignedInt], costMatrix[SignedInt] + NUMBER_OF_BASIC_TYPES) << ";" << endl;
    412412        code << "\t";                                                                           // indentation for end marker
    413        
     413
    414414        if ( (start = str.find( ENDMK, start + 1 )) == string::npos ) Abort( "end", ConversionCost );
    415415        if ( (end = str.find( STARTMK, start + 1 )) == string::npos ) Abort( "start", ConversionCost );
     
    418418
    419419        code << "\t" << BYMK << endl;
    420         code << "\tstatic const int signMatrix[BasicType::NUMBER_OF_BASIC_TYPES][BasicType::NUMBER_OF_BASIC_TYPES] = { // number of sign changes in safe conversion" << endl
     420        code << "\tstatic const int signMatrix[ast::BasicType::NUMBER_OF_BASIC_TYPES][ast::BasicType::NUMBER_OF_BASIC_TYPES] = { // number of sign changes in safe conversion" << endl
    421421                 << "\t\t/*           ";
    422422        for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { // titles
     
    450450        enum { PER_ROW = 6 };
    451451        code << "\t" << BYMK << endl;
    452         code << "\t#define BT BasicType::" << endl;
    453         code << "\tstatic const BasicType::Kind commonTypes[BasicType::NUMBER_OF_BASIC_TYPES][BasicType::NUMBER_OF_BASIC_TYPES] = { // nearest common ancestor" << endl
     452        code << "\t#define BT ast::BasicType::" << endl;
     453        code << "\tstatic const BT Kind commonTypes[BT NUMBER_OF_BASIC_TYPES][BT NUMBER_OF_BASIC_TYPES] = { // nearest common ancestor" << endl
    454454             << "\t\t/*\t\t ";
    455455        for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { // titles
     
    505505                "\t\t\t//   - \"Di\" char32_t\n"
    506506                "\t\t\t//   - \"Ds\" char16_t\n";
    507                
    508         code << "\t\t\tconst std::string basicTypes[BasicType::NUMBER_OF_BASIC_TYPES] = {" << endl;
     507
     508        code << "\t\t\tconst std::string basicTypes[ast::BasicType::NUMBER_OF_BASIC_TYPES] = {" << endl;
    509509        for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) {
    510510                code << "\t\t\t\t\"" << graph[r].mangled << "\"," << setw(9 - strlen(graph[r].mangled)) << ' ' << "// " << graph[r].type << endl;
    511         } // for       
     511        } // for
    512512        code << "\t\t\t}; // basicTypes" << endl;
    513513        code << "\t\t\t";                                                                       // indentation for end marker
  • src/ResolvExpr/CommonType.cc

    r36e6f10 r7d55e4d  
    184184        // GENERATED START, DO NOT EDIT
    185185        // GENERATED BY BasicTypes-gen.cc
    186         #define BT BasicType::
    187         static const BasicType::Kind commonTypes[BasicType::NUMBER_OF_BASIC_TYPES][BasicType::NUMBER_OF_BASIC_TYPES] = { // nearest common ancestor
     186        #define BT ast::BasicType::
     187        static const BT Kind commonTypes[BT NUMBER_OF_BASIC_TYPES][BT NUMBER_OF_BASIC_TYPES] = { // nearest common ancestor
    188188                /*                                      B                       C                      SC                      UC                      SI                     SUI
    189189                                                        I                      UI                      LI                     LUI                     LLI                    LLUI
     
    497497        void CommonType_old::postvisit( BasicType * basicType ) {
    498498                if ( BasicType * otherBasic = dynamic_cast< BasicType * >( type2 ) ) {
    499                         BasicType::Kind newType = commonTypes[ basicType->get_kind() ][ otherBasic->get_kind() ];
     499                        BasicType::Kind newType = (BasicType::Kind)(int)commonTypes[ (ast::BasicType::Kind)(int)basicType->get_kind() ][ (ast::BasicType::Kind)(int)otherBasic->get_kind() ];
    500500                        if ( ( ( newType == basicType->get_kind() && basicType->tq >= otherBasic->tq ) || widenFirst ) && ( ( newType == otherBasic->get_kind() && basicType->tq <= otherBasic->tq ) || widenSecond ) ) {
    501501                                result = new BasicType( basicType->tq | otherBasic->tq, newType );
     
    503503                } else if (  dynamic_cast< ZeroType * >( type2 ) || dynamic_cast< OneType * >( type2 ) ) {
    504504                        // use signed int in lieu of the enum/zero/one type
    505                         BasicType::Kind newType = commonTypes[ basicType->get_kind() ][ BasicType::SignedInt ];
     505                        BasicType::Kind newType = (BasicType::Kind)(int)commonTypes[ (ast::BasicType::Kind)(int)basicType->get_kind() ][ ast::BasicType::SignedInt ];
    506506                        if ( ( ( newType == basicType->get_kind() && basicType->tq >= type2->tq ) || widenFirst ) && ( ( newType != basicType->get_kind() && basicType->tq <= type2->tq ) || widenSecond ) ) {
    507507                                result = new BasicType( basicType->tq | type2->tq, newType );
     
    512512                                result = baseType->clone();
    513513                        } else {
    514                                 BasicType::Kind newType = commonTypes[ basicType->get_kind() ][ BasicType::SignedInt ];
     514                                BasicType::Kind newType = (BasicType::Kind)(int)commonTypes[ (ast::BasicType::Kind)(int)basicType->get_kind() ][ ast::BasicType::SignedInt ];
    515515                                if ( ( ( newType == basicType->get_kind() && basicType->tq >= type2->tq ) || widenFirst ) && ( ( newType != basicType->get_kind() && basicType->tq <= type2->tq ) || widenSecond ) ) {
    516516                                        result = new BasicType( basicType->tq | type2->tq, newType );
     
    700700                                else if (!widen.first) kind = basic->kind; // widen.second
    701701                                else if (!widen.second) kind = basic2->kind;
    702                                 else kind = (ast::BasicType::Kind)(int)commonTypes[ (BasicType::Kind)(int)basic->kind ][ (BasicType::Kind)(int)basic2->kind ];
     702                                else kind = commonTypes[ basic->kind ][ basic2->kind ];
    703703                                // xxx - what does qualifiers even do here??
    704704                                if ( (basic->qualifiers >= basic2->qualifiers || widen.first)
     
    719719                                } else {
    720720                                        #warning remove casts when `commonTypes` moved to new AST
    721                                         ast::BasicType::Kind kind = (ast::BasicType::Kind)(int)commonTypes[ (BasicType::Kind)(int)basic->kind ][ (BasicType::Kind)(int)ast::BasicType::SignedInt ];
     721                                        ast::BasicType::Kind kind = commonTypes[ basic->kind ][ ast::BasicType::SignedInt ];
    722722                                        if (
    723723                                                ( ( kind == basic->kind && basic->qualifiers >= type2->qualifiers )
  • src/ResolvExpr/ConversionCost.cc

    r36e6f10 r7d55e4d  
    226226        // GENERATED START, DO NOT EDIT
    227227        // GENERATED BY BasicTypes-gen.cc
    228         static const int costMatrix[BasicType::NUMBER_OF_BASIC_TYPES][BasicType::NUMBER_OF_BASIC_TYPES] = { // path length from root to node
     228        static const int costMatrix[ast::BasicType::NUMBER_OF_BASIC_TYPES][ast::BasicType::NUMBER_OF_BASIC_TYPES] = { // path length from root to node
    229229                /*               B    C   SC   UC   SI  SUI    I   UI   LI  LUI  LLI LLUI   IB  UIB  _FH  _FH   _F  _FC    F   FC  _FX _FXC   FD _FDC    D   DC F80X_FDXC  F80  _FB_FLDC   FB   LD  LDC _FBX_FLDXC */
    230230                /*      B */ {   0,   1,   1,   2,   2,   3,   3,   4,   4,   5,   5,   6,   6,   7,   7,   8,   8,   9,   9,  10,  10,  11,  11,  12,  12,  13,  13,  14,  14,  15,  15,  16,  17,  16,  18,  17, },
     
    274274        // GENERATED START, DO NOT EDIT
    275275        // GENERATED BY BasicTypes-gen.cc
    276         static const int signMatrix[BasicType::NUMBER_OF_BASIC_TYPES][BasicType::NUMBER_OF_BASIC_TYPES] = { // number of sign changes in safe conversion
     276        static const int signMatrix[ast::BasicType::NUMBER_OF_BASIC_TYPES][ast::BasicType::NUMBER_OF_BASIC_TYPES] = { // number of sign changes in safe conversion
    277277                /*               B    C   SC   UC   SI  SUI    I   UI   LI  LUI  LLI LLUI   IB  UIB  _FH  _FH   _F  _FC    F   FC  _FX _FXC   FD _FDC    D   DC F80X_FDXC  F80  _FB_FLDC   FB   LD  LDC _FBX_FLDXC */
    278278                /*      B */ {   0,   0,   0,   1,   0,   1,   0,   1,   0,   1,   0,   1,   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
  • src/SymTab/ManglerCommon.cc

    r36e6f10 r7d55e4d  
    3939                        //   - "Di" char32_t
    4040                        //   - "Ds" char16_t
    41                         const std::string basicTypes[BasicType::NUMBER_OF_BASIC_TYPES] = {
     41                        const std::string basicTypes[ast::BasicType::NUMBER_OF_BASIC_TYPES] = {
    4242                                "b",        // _Bool
    4343                                "c",        // char
Note: See TracChangeset for help on using the changeset viewer.