Changes in / [77a45e9:58560d2]


Ignore:
Location:
src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Decl.hpp

    r77a45e9 r58560d2  
    99// Author           : Aaron B. Moss
    1010// Created On       : Thu May 9 10:00:00 2019
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Jun 28 21:54:18 2026
    13 // Update Count     : 36
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Apr  5 10:42:00 2023
     13// Update Count     : 35
    1414//
    1515
     
    108108          init( init ), bitfieldWidth( bitWd ) {}
    109109
    110         const Type * get_type() const override { return type; }
     110        const Type* get_type() const override { return type; }
    111111        void set_type( const Type * ty ) override { type = ty; }
    112112
  • src/Common/Eval.cpp

    r77a45e9 r58560d2  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Jun 28 21:50:29 2026
    13 // Update Count     : 121
     12// Last Modified On : Sat Aug  6 12:11:59 2022
     13// Update Count     : 119
    1414//
    1515
     
    200200Evaluation eval( const ast::Expr * expr ) {
    201201        if ( expr ) {
     202
    202203                return ast::Pass<EvalNew>::read(expr);
    203204                // Evaluation ret = ast::Pass<EvalNew>::read(expr);
    204205                // ret.knownValue = 777;
    205206                // return ret;
     207
    206208        } else {
    207209                return { 0, false, false };
  • src/GenPoly/GenPoly.cpp

    r77a45e9 r58560d2  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Jun 28 21:49:48 2026
    13 // Update Count     : 18
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Mon Oct 24 15:19:00 2022
     13// Update Count     : 17
    1414//
    1515
     
    252252bool typesPolyCompatible( ast::Type const * lhs, ast::Type const * rhs );
    253253
    254 static bool exprsPolyCompatibleByStaticValue( const ast::Expr * e1, const ast::Expr * e2 ) {
     254static bool exprsPolyCompatibleByStaticValue(
     255                const ast::Expr * e1, const ast::Expr * e2 ) {
    255256        Evaluation r1 = eval(e1);
    256257        Evaluation r2 = eval(e2);
  • src/InitTweak/FixGlobalInit.cpp

    r77a45e9 r58560d2  
    1010// Created On       : Mon May 04 15:14:56 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul  2 16:39:52 2026
    13 // Update Count     : 35
     12// Last Modified On : Fri Dec 13 23:41:10 2019
     13// Update Count     : 19
    1414//
    1515
    1616#include "FixGlobalInit.hpp"
    1717
    18 #include <set>
    1918#include <cassert>                 // for assert
    2019#include <stddef.h>                // for NULL
     
    4140        void previsit(const ast::TypeDecl *) { visit_children = false; }
    4241
    43         bool pass = false;
    4442        std::list< ast::ptr<ast::Stmt> > initStmts;
    4543        std::list< ast::ptr<ast::Stmt> > destroyStmts;
    46         std::set< std::string > constDeclsMnames;
    4744};
    4845
     
    5047        auto mutDecl = mutate(objDecl);
    5148        assertf(mutDecl == objDecl, "Global object decl must be unique");
    52         if ( ! pass ) {                                                                         // pass 1
    53                 auto ctorInit = objDecl->init.as<ast::ConstructorInit>();
    54                 if ( nullptr == ctorInit ) return;
     49        auto ctorInit = objDecl->init.as<ast::ConstructorInit>();
     50        if ( nullptr == ctorInit ) return;
    5551
    56                 // a decision should have been made by the resolver, so ctor and init are not both non-NULL
    57                 assert( !ctorInit->ctor || !ctorInit->init );
     52        // a decision should have been made by the resolver, so ctor and init are not both non-NULL
     53        assert( !ctorInit->ctor || !ctorInit->init );
    5854
    59                 const ast::Stmt * dtor = ctorInit->dtor;
    60                 if ( dtor && !isIntrinsicSingleArgCallStmt( dtor ) ) {
    61                         // don't need to call intrinsic dtor, because it does nothing, but
    62                         // non-intrinsic dtors must be called
    63                         destroyStmts.push_front( dtor );
    64                 } // if
    65                 if ( const ast::Stmt * ctor = ctorInit->ctor ) {
    66                         if ( mutDecl->type->is_const() ) {
    67                                 // Store names of all declarations with const qualifier and initializer for second pass.
    68                                 constDeclsMnames.emplace( mutDecl->mangleName );
    69                         }
    70                         initStmts.push_back( ctor );
    71                         mutDecl->init = nullptr;
    72                 } else if ( const ast::Init * init = ctorInit->init ) {
    73                         mutDecl->init = init;
    74                 } else {
    75                         // no constructor and no initializer, which is okay
    76                         mutDecl->init = nullptr;
    77                 }
    78         } else {                                                                                // pass 2
    79                 // Remove const qualifier from matching names, covering all forward declaration(s) and definition.
    80                 if ( constDeclsMnames.find( objDecl->mangleName ) != constDeclsMnames.end() ) {
    81                         ast::Type * fred = const_cast<ast::Type *>(mutDecl->get_type());
    82                         fred->set_const( false );
    83                 } // if
     55        const ast::Stmt * dtor = ctorInit->dtor;
     56        if ( dtor && !isIntrinsicSingleArgCallStmt( dtor ) ) {
     57                // don't need to call intrinsic dtor, because it does nothing, but
     58                // non-intrinsic dtors must be called
     59                destroyStmts.push_front( dtor );
     60        } // if
     61        if ( const ast::Stmt * ctor = ctorInit->ctor ) {
     62                addDataSectionAttribute(mutDecl);
     63                initStmts.push_back( ctor );
     64                mutDecl->init = nullptr;
     65        } else if ( const ast::Init * init = ctorInit->init ) {
     66                mutDecl->init = init;
     67        } else {
     68                // no constructor and no initializer, which is okay
     69                mutDecl->init = nullptr;
    8470        }
    8571}
     
    8975void fixGlobalInit(ast::TranslationUnit & translationUnit, bool inLibrary) {
    9076        ast::Pass<GlobalFixer> fixer;
    91 
    92         // First pass fixes global initialization.
    93         accept_all( translationUnit, fixer );
     77        accept_all(translationUnit, fixer);
    9478
    9579        // Say these magic declarations come at the end of the file.
     
    119103                translationUnit.decls.emplace_back(destroyFunction);
    120104        } // if
    121 
    122         fixer.core.pass = ! fixer.core.pass;
    123         // Second pass, removes const qualifiers so declarations appear in mutable .data section.
    124         // Note, the resolver has already checked for const-ness, so C only has to get the initialization correct.
    125         accept_all(translationUnit, fixer);
    126105}
    127106
  • src/InitTweak/FixInit.cpp

    r77a45e9 r58560d2  
    816816        if ( const ast::Stmt * ctor = ctorInit->ctor ) {
    817817                if ( objDecl->storage.is_static ) {
    818                         // Remove const qualifier from definition and there can be no forward declarations.
    819                         if ( objDecl->type->is_const() ) {
    820                                 ast::Type * fred = const_cast<ast::Type *>(objDecl->get_type());
    821                                 fred->set_const( false );
    822                         }
     818                        addDataSectionAttribute(objDecl);
    823819                        // originally wanted to take advantage of gcc nested functions, but
    824820                        // we get memory errors with this approach. To remedy this, the static
  • src/InitTweak/InitTweak.cpp

    r77a45e9 r58560d2  
    99// Author           : Rob Schluntz
    1010// Created On       : Fri May 13 11:26:36 2016
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul  2 16:47:11 2026
    13 // Update Count     : 44
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Sep 22  9:50:00 2022
     13// Update Count     : 21
    1414//
    1515
     
    428428}
    429429
     430#if defined( __x86_64 ) || defined( __i386 ) // assembler comment to prevent assembler warning message
     431        #define ASM_COMMENT "#"
     432#else // defined( __ARM_ARCH )
     433        #define ASM_COMMENT "//"
     434#endif
     435static const char * const data_section =  ".data" ASM_COMMENT;
     436static const char * const tlsd_section = ".tdata" ASM_COMMENT;
     437
     438void addDataSectionAttribute( ast::ObjectDecl * objDecl ) {
     439        const bool is_tls = objDecl->storage.is_threadlocal_any();
     440        const char * section = is_tls ? tlsd_section : data_section;
     441        objDecl->attributes.push_back(new ast::Attribute("section", {
     442                ast::ConstantExpr::from_string(objDecl->location, section)
     443        }));
     444}
     445
    430446InitExpander::InitExpander( const ast::Init * init )
    431447: expander( new InitImpl{ init } ), crnt(), indices() {}
  • src/InitTweak/InitTweak.hpp

    r77a45e9 r58560d2  
    99// Author           : Rob Schluntz
    1010// Created On       : Fri May 13 11:26:36 2016
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul  2 16:45:44 2026
    13 // Update Count     : 12
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Sep 22  9:21:00 2022
     13// Update Count     : 9
    1414//
    1515
     
    6969bool isConstExpr( const ast::Init * init );
    7070
     71/// Modifies objDecl to have:
     72///    __attribute__((section (".data#")))
     73/// which makes gcc put the declared variable in the data section,
     74/// which is helpful for global constants on newer gcc versions,
     75/// so that CFA's generated initialization won't segfault when writing it via a const cast.
     76/// The trailing # is an injected assembly comment, to suppress the "a" in
     77///    .section .data,"a"
     78///    .section .data#,"a"
     79/// to avoid assembler warning "ignoring changed section attributes for .data"
     80void addDataSectionAttribute( ast::ObjectDecl * objDecl );
     81
    7182class InitExpander final {
    7283public:
  • src/main.cpp

    r77a45e9 r58560d2  
    1010// Created On       : Fri May 15 23:12:02 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jun 23 13:56:23 2026
    13 // Update Count     : 712
     12// Last Modified On : Fri Mar 20 08:10:38 2026
     13// Update Count     : 710
    1414//
    1515
     
    281281
    282282                // Currently not working due to unresolved issues with UniqueExpr
    283 
    284                 // xxx - is this the right place for this? Want to expand ASAP so that, sequent passes don't need to worry about
    285                 // double-visiting a unique expr - needs to go after InitTweak::fix so that copy constructed return declarations
    286                 // are reused
    287                 PASS( "Expand Unique Expr", Tuples::expandUniqueExpr, transUnit );
     283                PASS( "Expand Unique Expr", Tuples::expandUniqueExpr, transUnit ); // xxx - is this the right place for this? want to expand ASAP so tha, sequent passes don't need to worry about double-visiting a unique expr - needs to go after InitTweak::fix so that copy constructed return declarations are reused
    288284
    289285                PASS( "Translate Tries", ControlStruct::translateTries, transUnit );
Note: See TracChangeset for help on using the changeset viewer.