Changeset ed9a1ae


Ignore:
Timestamp:
Aug 31, 2022, 10:57:37 AM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, master, pthread-emulation
Children:
64af7ac
Parents:
dc708c1
Message:

Cfa now distinguishes between thread and _Thread_local.

Location:
src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Print.cpp

    rdc708c1 red9a1ae  
    8686
    8787                static constexpr auto StorageClasses = make_array<const char*>(
    88                         "extern", "static", "auto", "register", "_Thread_local"
     88                        "extern", "static", "auto", "register", "__thread", "_Thread_local"
    8989                );
    9090
     
    215215                        ++indent;
    216216                        ptrToEnum->base->accept( *this );
    217                         --indent; 
     217                        --indent;
    218218                }
    219219
     
    16231623// if the wrong size is specified
    16241624constexpr array<const char*, 3> Printer::Names::FuncSpecifiers;
    1625 constexpr array<const char*, 5> Printer::Names::StorageClasses;
     1625constexpr array<const char*, 6> Printer::Names::StorageClasses;
    16261626constexpr array<const char*, 6> Printer::Names::Qualifiers;
    16271627}
  • src/AST/StorageClasses.hpp

    rdc708c1 red9a1ae  
    2424        /// Bitflags for storage classes
    2525        enum {
    26                 Extern      = 1 << 0,
    27                 Static      = 1 << 1,
    28                 Auto        = 1 << 2,
    29                 Register    = 1 << 3,
    30                 ThreadLocal = 1 << 4,
    31                 NumClasses       = 5
     26                Extern         = 1 << 0,
     27                Static         = 1 << 1,
     28                Auto           = 1 << 2,
     29                Register       = 1 << 3,
     30                ThreadLocalGcc = 1 << 4,
     31                ThreadLocalC11 = 1 << 5,
     32                NumClasses          = 6
    3233        };
    3334
     
    3738                        unsigned int val;
    3839                        struct {
    39                                 bool is_extern      : 1;
    40                                 bool is_static      : 1;
    41                                 bool is_auto        : 1;
    42                                 bool is_register    : 1;
    43                                 bool is_threadlocal : 1;
     40                                bool is_extern         : 1;
     41                                bool is_static         : 1;
     42                                bool is_auto           : 1;
     43                                bool is_register       : 1;
     44                                bool is_threadlocalGcc : 1;
     45                                bool is_threadlocalC11 : 1;
    4446                        };
    4547
     
    4850
    4951                constexpr class_flags( unsigned int val = 0 ) : val(val) {}
     52
     53                bool is_threadlocal_any() { return this->is_threadlocalC11 || this->is_threadlocalGcc; }
    5054        };
    5155
  • src/InitTweak/InitTweak.cc

    rdc708c1 red9a1ae  
    12411241        static const char * const tlsd_section = ".tdata" ASM_COMMENT;
    12421242        void addDataSectionAttribute( ObjectDecl * objDecl ) {
    1243                 const bool is_tls = objDecl->get_storageClasses().is_threadlocal;
     1243                const bool is_tls = objDecl->get_storageClasses().is_threadlocal_any();
    12441244                const char * section = is_tls ? tlsd_section : data_section;
    12451245                objDecl->attributes.push_back(new Attribute("section", {
     
    12491249
    12501250        void addDataSectionAttribute( ast::ObjectDecl * objDecl ) {
    1251                 const bool is_tls = objDecl->storage.is_threadlocal;
     1251                const bool is_tls = objDecl->storage.is_threadlocal_any();
    12521252                const char * section = is_tls ? tlsd_section : data_section;
    12531253                objDecl->attributes.push_back(new ast::Attribute("section", {
  • src/Parser/DeclarationNode.cc

    rdc708c1 red9a1ae  
    262262        newnode->type->enumeration.anon = name == nullptr;
    263263        if ( base && base->type)  {
    264                 newnode->type->base = base->type;       
     264                newnode->type->base = base->type;
    265265        } // if
    266266
     
    505505                        } // for
    506506                        // src is the new item being added and has a single bit
    507                 } else if ( ! src->storageClasses.is_threadlocal ) { // conflict ?
     507                } else if ( ! src->storageClasses.is_threadlocal_any() ) { // conflict ?
    508508                        appendError( error, string( "conflicting " ) + Type::StorageClassesNames[storageClasses.ffs()] +
    509509                                                 " & " + Type::StorageClassesNames[src->storageClasses.ffs()] );
  • src/Parser/lex.ll

    rdc708c1 red9a1ae  
    314314switch                  { KEYWORD_RETURN(SWITCH); }
    315315thread                  { KEYWORD_RETURN(THREAD); }                             // C11
    316 __thread                { KEYWORD_RETURN(THREADLOCAL); }                // GCC
    317 _Thread_local   { KEYWORD_RETURN(THREADLOCAL); }                // C11
     316__thread                { KEYWORD_RETURN(THREADLOCALGCC); }             // GCC
     317_Thread_local   { KEYWORD_RETURN(THREADLOCALC11); }             // C11
    318318throw                   { KEYWORD_RETURN(THROW); }                              // CFA
    319319throwResume             { KEYWORD_RETURN(THROWRESUME); }                // CFA
  • src/Parser/parser.yy

    rdc708c1 red9a1ae  
    293293%token TYPEDEF
    294294%token EXTERN STATIC AUTO REGISTER
    295 %token THREADLOCAL                                                                              // C11
     295%token THREADLOCALGCC THREADLOCALC11                                            // GCC, C11
    296296%token INLINE FORTRAN                                                                   // C99, extension ISO/IEC 9899:1999 Section J.5.9(1)
    297297%token NORETURN                                                                                 // C11
     
    13451345                {
    13461346                        if ( $2 == OperKinds::LThan || $2 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_ANON_FIELD ); $$ = nullptr; }
    1347                         else { SemanticError( yylloc, MISSING_HIGH ); $$ = nullptr; } 
     1347                        else { SemanticError( yylloc, MISSING_HIGH ); $$ = nullptr; }
    13481348                }
    13491349        | comma_expression updowneq comma_expression '~' comma_expression // CFA, anonymous loop-index
     
    13571357                {
    13581358                        if ( $2 == OperKinds::LThan || $2 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_ANON_FIELD ); $$ = nullptr; }
    1359                         else { SemanticError( yylloc, MISSING_HIGH ); $$ = nullptr; } 
     1359                        else { SemanticError( yylloc, MISSING_HIGH ); $$ = nullptr; }
    13601360                }
    13611361        | comma_expression updowneq comma_expression '~' '@' // CFA, error
     
    20822082        | REGISTER
    20832083                { $$ = DeclarationNode::newStorageClass( Type::Register ); }
    2084         | THREADLOCAL                                                                           // C11
    2085                 { $$ = DeclarationNode::newStorageClass( Type::Threadlocal ); }
     2084        | THREADLOCALGCC                                                                                // GCC
     2085                { $$ = DeclarationNode::newStorageClass( Type::ThreadlocalGcc ); }
     2086        | THREADLOCALC11                                                                                // C11
     2087                { $$ = DeclarationNode::newStorageClass( Type::ThreadlocalC11 ); }
    20862088                // Put function specifiers here to simplify parsing rules, but separate them semantically.
    20872089        | INLINE                                                                                        // C99
  • src/SynTree/Type.cc

    rdc708c1 red9a1ae  
    8080// These must remain in the same order as the corresponding bit fields.
    8181const char * Type::FuncSpecifiersNames[] = { "inline", "_Noreturn", "fortran" };
    82 const char * Type::StorageClassesNames[] = { "extern", "static", "auto", "register", "_Thread_local" };
     82const char * Type::StorageClassesNames[] = { "extern", "static", "auto", "register", "__thread", "_Thread_local" };
    8383const char * Type::QualifiersNames[] = { "const", "restrict", "volatile", "mutex", "_Atomic" };
    8484
  • src/SynTree/Type.h

    rdc708c1 red9a1ae  
    8484        }; // FuncSpecifiers
    8585
    86         enum { Extern = 1 << 0, Static = 1 << 1, Auto = 1 << 2, Register = 1 << 3, Threadlocal = 1 << 4, NumStorageClass = 5 };
     86        enum { Extern = 1 << 0, Static = 1 << 1, Auto = 1 << 2, Register = 1 << 3, ThreadlocalGcc = 1 << 4, ThreadlocalC11 = 1 << 5, NumStorageClass = 6 };
    8787        static const char * StorageClassesNames[];
    8888        union StorageClasses {
     
    9393                        bool is_auto : 1;
    9494                        bool is_register : 1;
    95                         bool is_threadlocal : 1;
     95                        bool is_threadlocalGcc : 1;
     96                        bool is_threadlocalC11 : 1;
    9697                };
    9798
     
    100101                // equality (==, !=) works implicitly on first field "val", relational operations are undefined.
    101102                BFCommon( StorageClasses, NumStorageClass )
     103
     104                bool is_threadlocal_any() { return this->is_threadlocalC11 || this->is_threadlocalGcc; }
    102105        }; // StorageClasses
    103106
Note: See TracChangeset for help on using the changeset viewer.