Changeset 2909b515


Ignore:
Timestamp:
Nov 21, 2019, 9:38:54 PM (6 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
0a25c34, f1397d14
Parents:
1c40091 (diff), 49d3128 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Files:
20 edited

Legend:

Unmodified
Added
Removed
  • driver/cc1.cc

    r1c40091 r2909b515  
    335335        #endif // __DEBUG_H__
    336336
     337        enum {
     338                Color_Auto   = 0,
     339                Color_Always = 1,
     340                Color_Never  = 2,
     341        } color_arg = Color_Auto;
     342
     343        const char * color_names[3] = { "--colors=auto", "--colors=always", "--colors=never" };
     344
    337345        // process all the arguments
    338346
     
    341349                if ( prefix( arg, "-" ) ) {
    342350                        // strip inappropriate flags
     351
     352                        if ( prefix( arg, "-fdiagnostics-color=" ) ) {
     353                                string choice = arg.substr(20);
     354                                     if(choice == "always") color_arg = Color_Always;
     355                                else if(choice == "never" ) color_arg = Color_Never;
     356                                else if(choice == "auto"  ) color_arg = Color_Auto;
     357                        } else if ( arg == "-fno-diagnostics-color" ) {
     358                                color_arg = Color_Auto;
     359                        }
    343360
    344361                        if ( arg == "-quiet" || arg == "-version" || arg == "-fpreprocessed" ||
     
    440457                        cargs[ncargs++] = cfa_cpp_out.c_str();
    441458                } // if
     459
     460                cargs[ncargs++] = color_names[color_arg];
     461
    442462                cargs[ncargs] = nullptr;                                                // terminate argument list
    443463
  • libcfa/src/bits/defs.hfa

    r1c40091 r2909b515  
    4747#define OPTIONAL_THREAD __attribute__((weak))
    4848#endif
     49
     50static inline long long rdtscl(void) {
     51    unsigned int lo, hi;
     52    __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
     53    return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 );
     54}
  • libcfa/src/concurrency/invoke.h

    r1c40091 r2909b515  
    4646        #ifdef __cforall
    4747        extern "Cforall" {
    48                 extern thread_local struct KernelThreadData {
     48                extern __attribute__((aligned(128))) thread_local struct KernelThreadData {
    4949                        struct thread_desc    * volatile this_thread;
    5050                        struct processor      * volatile this_processor;
     
    5555                                volatile bool in_progress;
    5656                        } preemption_state;
     57
     58                        uint32_t rand_seed;
    5759                } kernelTLS __attribute__ ((tls_model ( "initial-exec" )));
    5860        }
  • libcfa/src/concurrency/kernel.cfa

    r1c40091 r2909b515  
    133133        NULL,
    134134        NULL,
    135         { 1, false, false }
     135        { 1, false, false },
     136        6u //this should be seeded better but due to a bug calling rdtsc doesn't work
    136137};
    137138
     
    260261//Main of the processor contexts
    261262void main(processorCtx_t & runner) {
     263        // Because of a bug, we couldn't initialized the seed on construction
     264        // Do it here
     265        kernelTLS.rand_seed ^= rdtscl();
     266
    262267        processor * this = runner.proc;
    263268        verify(this);
  • libcfa/src/concurrency/kernel_private.hfa

    r1c40091 r2909b515  
    101101#define KERNEL_STORAGE(T,X) static char storage_##X[sizeof(T)]
    102102
     103static inline uint32_t tls_rand() {
     104        kernelTLS.rand_seed ^= kernelTLS.rand_seed << 6;
     105        kernelTLS.rand_seed ^= kernelTLS.rand_seed >> 21;
     106        kernelTLS.rand_seed ^= kernelTLS.rand_seed << 7;
     107        return kernelTLS.rand_seed;
     108}
     109
    103110
    104111void doregister( struct cluster & cltr );
  • src/AST/Convert.cpp

    r1c40091 r2909b515  
    887887                auto expr = visitBaseExpr( node,
    888888                        new AsmExpr(
    889                                 get<Expression>().accept1(node->inout),
     889                                new std::string(node->inout),
    890890                                get<Expression>().accept1(node->constraint),
    891891                                get<Expression>().accept1(node->operand)
     
    22582258                        new ast::AsmExpr(
    22592259                                old->location,
    2260                                 GET_ACCEPT_1(inout, Expr),
     2260                                old->inout,
    22612261                                GET_ACCEPT_1(constraint, Expr),
    22622262                                GET_ACCEPT_1(operand, Expr)
  • src/AST/Expr.hpp

    r1c40091 r2909b515  
    556556class AsmExpr final : public Expr {
    557557public:
    558         ptr<Expr> inout;
     558        std::string inout;
    559559        ptr<Expr> constraint;
    560560        ptr<Expr> operand;
    561561
    562         AsmExpr( const CodeLocation & loc, const Expr * io, const Expr * con, const Expr * op )
     562        AsmExpr( const CodeLocation & loc, const std::string & io, const Expr * con, const Expr * op )
    563563        : Expr( loc ), inout( io ), constraint( con ), operand( op ) {}
    564564
  • src/AST/Pass.impl.hpp

    r1c40091 r2909b515  
    13001300                        maybe_accept( node, &AsmExpr::result );
    13011301                }
    1302                 maybe_accept( node, &AsmExpr::inout      );
    13031302                maybe_accept( node, &AsmExpr::constraint );
    13041303                maybe_accept( node, &AsmExpr::operand    );
  • src/AST/Print.cpp

    r1c40091 r2909b515  
    10111011                os << "Asm Expression:" << endl;
    10121012                ++indent;
    1013                 if ( node->inout ) node->inout->accept( *this );
     1013                if ( !node->inout.empty() ) os << "[" << node->inout << "] ";
    10141014                if ( node->constraint ) node->constraint->accept( *this );
    10151015                if ( node->operand ) node->operand->accept( *this );
  • src/CodeGen/CodeGenerator.cc

    r1c40091 r2909b515  
    786786
    787787        void CodeGenerator::postvisit( AsmExpr * asmExpr ) {
    788                 if ( asmExpr->get_inout() ) {
     788                if ( !asmExpr->inout.empty() ) {
    789789                        output << "[ ";
    790                         asmExpr->get_inout()->accept( *visitor );
     790                        output << asmExpr->inout;
    791791                        output << " ] ";
    792792                } // if
    793                 asmExpr->get_constraint()->accept( *visitor );
     793                asmExpr->constraint->accept( *visitor );
    794794                output << " ( ";
    795                 asmExpr->get_operand()->accept( *visitor );
     795                asmExpr->operand->accept( *visitor );
    796796                output << " )";
    797797        }
  • src/Common/PassVisitor.impl.h

    r1c40091 r2909b515  
    24522452
    24532453        indexerScopedAccept( node->result    , *this );
    2454         maybeAccept_impl   ( node->inout     , *this );
    24552454        maybeAccept_impl   ( node->constraint, *this );
    24562455        maybeAccept_impl   ( node->operand   , *this );
     
    24642463
    24652464        indexerScopedAccept( node->result    , *this );
    2466         maybeAccept_impl   ( node->inout     , *this );
    24672465        maybeAccept_impl   ( node->constraint, *this );
    24682466        maybeAccept_impl   ( node->operand   , *this );
     
    24772475        indexerScopedMutate( node->env       , *this );
    24782476        indexerScopedMutate( node->result    , *this );
    2479         maybeMutate_impl   ( node->inout     , *this );
    24802477        maybeMutate_impl   ( node->constraint, *this );
    24812478        maybeMutate_impl   ( node->operand   , *this );
  • src/Common/SemanticError.cc

    r1c40091 r2909b515  
    149149// Helpers
    150150namespace ErrorHelpers {
     151        Colors colors = Colors::Auto;
     152
     153        static inline bool with_colors() {
     154                return colors == Colors::Auto ? isatty( STDERR_FILENO ) : bool(colors);
     155        }
     156
    151157        const std::string & error_str() {
    152                 static std::string str = isatty( STDERR_FILENO ) ? "\e[31merror:\e[39m " : "error: ";
     158                static std::string str = with_colors() ? "\e[31merror:\e[39m " : "error: ";
    153159                return str;
    154160        }
    155161
    156162        const std::string & warning_str() {
    157                 static std::string str = isatty( STDERR_FILENO ) ? "\e[95mwarning:\e[39m " : "warning: ";
     163                static std::string str = with_colors() ? "\e[95mwarning:\e[39m " : "warning: ";
    158164                return str;
    159165        }
    160166
    161167        const std::string & bold_ttycode() {
    162                 static std::string str = isatty( STDERR_FILENO ) ? "\e[1m" : "";
     168                static std::string str = with_colors() ? "\e[1m" : "";
    163169                return str;
    164170        }
    165171
    166172        const std::string & reset_font_ttycode() {
    167                 static std::string str = isatty( STDERR_FILENO ) ? "\e[0m" : "";
     173                static std::string str = with_colors() ? "\e[0m" : "";
    168174                return str;
    169175        }
  • src/Common/SemanticError.h

    r1c40091 r2909b515  
    9797// Helpers
    9898namespace ErrorHelpers {
     99        enum class Colors {
     100                Never = false,
     101                Always = true,
     102                Auto,
     103        };
     104
     105        extern Colors colors;
     106
    99107        const std::string & error_str();
    100108        const std::string & warning_str();
  • src/Parser/parser.yy

    r1c40091 r2909b515  
    14231423asm_operand:                                                                                    // GCC
    14241424        string_literal '(' constant_expression ')'
    1425                 { $$ = new ExpressionNode( new AsmExpr( maybeMoveBuild< Expression >( (ExpressionNode *)nullptr ), $1, maybeMoveBuild< Expression >( $3 ) ) ); }
    1426         | '[' constant_expression ']' string_literal '(' constant_expression ')'
    1427                 { $$ = new ExpressionNode( new AsmExpr( maybeMoveBuild< Expression >( $2 ), $4, maybeMoveBuild< Expression >( $6 ) ) ); }
     1425                { $$ = new ExpressionNode( new AsmExpr( nullptr, $1, maybeMoveBuild< Expression >( $3 ) ) ); }
     1426        | '[' IDENTIFIER ']' string_literal '(' constant_expression ')'
     1427                { $$ = new ExpressionNode( new AsmExpr( $2, $4, maybeMoveBuild< Expression >( $6 ) ) ); }
    14281428        ;
    14291429
  • src/ResolvExpr/Resolver.cc

    r1c40091 r2909b515  
    485485                visit_children = false;
    486486                findVoidExpression( asmExpr->operand, indexer );
    487                 if ( asmExpr->get_inout() ) {
    488                         findVoidExpression( asmExpr->inout, indexer );
    489                 } // if
    490487        }
    491488
     
    13651362                asmExpr = ast::mutate_field(
    13661363                        asmExpr, &ast::AsmExpr::operand, findVoidExpression( asmExpr->operand, symtab ) );
    1367 
    1368                 if ( asmExpr->inout ) {
    1369                         asmExpr = ast::mutate_field(
    1370                                 asmExpr, &ast::AsmExpr::inout, findVoidExpression( asmExpr->inout, symtab ) );
    1371                 }
    13721364
    13731365                return asmExpr;
  • src/SynTree/Expression.cc

    r1c40091 r2909b515  
    527527}
    528528
    529 AsmExpr::AsmExpr( const AsmExpr & other ) : Expression( other ), inout( maybeClone( other.inout ) ), constraint( maybeClone( other.constraint ) ), operand( maybeClone( other.operand ) ) {}
     529AsmExpr::AsmExpr( const AsmExpr & other ) : Expression( other ), inout( other.inout ), constraint( maybeClone( other.constraint ) ), operand( maybeClone( other.operand ) ) {}
    530530
    531531
    532532void AsmExpr::print( std::ostream & os, Indenter indent ) const {
    533533        os << "Asm Expression: " << std::endl;
    534         if ( inout ) inout->print( os, indent+1 );
     534        if ( !inout.empty() ) os <<  "[" << inout << "] ";
    535535        if ( constraint ) constraint->print( os, indent+1 );
    536536        if ( operand ) operand->print( os, indent+1 );
  • src/SynTree/Expression.h

    r1c40091 r2909b515  
    575575class AsmExpr : public Expression {
    576576  public:
    577         Expression * inout;
     577        std::string inout;
    578578        Expression * constraint;
    579579        Expression * operand;
    580580
    581         AsmExpr( Expression * inout, Expression * constraint, Expression * operand ) : inout( inout ), constraint( constraint ), operand( operand ) {}
     581        AsmExpr( const std::string * _inout, Expression * constraint, Expression * operand ) : inout( _inout ? *_inout : "" ), constraint( constraint ), operand( operand ) { delete _inout; }
    582582        AsmExpr( const AsmExpr & other );
    583         virtual ~AsmExpr() { delete inout; delete constraint; delete operand; };
    584 
    585         Expression * get_inout() const { return inout; }
    586         void set_inout( Expression * newValue ) { inout = newValue; }
    587 
    588         Expression * get_constraint() const { return constraint; }
    589         void set_constraint( Expression * newValue ) { constraint = newValue; }
    590 
    591         Expression * get_operand() const { return operand; }
    592         void set_operand( Expression * newValue ) { operand = newValue; }
     583        virtual ~AsmExpr() { delete constraint; delete operand; };
    593584
    594585        virtual AsmExpr * clone() const override { return new AsmExpr( * this ); }
  • src/main.cc

    r1c40091 r2909b515  
    407407
    408408
    409 static const char optstring[] = ":hlLmNnpP:S:twW:D:";
     409static const char optstring[] = ":c:ghlLmNnpP:S:twW:D:";
    410410
    411411enum { PreludeDir = 128 };
    412412static struct option long_opts[] = {
     413        { "colors", required_argument, nullptr, 'c' },
     414        { "gdb", no_argument, nullptr, 'g' },
    413415        { "help", no_argument, nullptr, 'h' },
    414416        { "libcfa", no_argument, nullptr, 'l' },
     
    422424        { "statistics", required_argument, nullptr, 'S' },
    423425        { "tree", no_argument, nullptr, 't' },
    424         { "gdb", no_argument, nullptr, 'g' },
    425426        { "", no_argument, nullptr, 0 },                                        // -w
    426427        { "", no_argument, nullptr, 0 },                                        // -W
     
    430431
    431432static const char * description[] = {
    432         "print help message",                                                           // -h
    433         "generate libcfa.c",                                                            // -l
    434         "generate line marks",                                                          // -L
    435         "do not replace main",                                                          // -m
    436         "do not generate line marks",                                           // -N
    437         "do not read prelude",                                                          // -n
     433        "diagnostic color: never, always, or auto.",          // -c
     434        "wait for gdb to attach",                             // -g
     435        "print help message",                                 // -h
     436        "generate libcfa.c",                                  // -l
     437        "generate line marks",                                // -L
     438        "do not replace main",                                // -m
     439        "do not generate line marks",                         // -N
     440        "do not read prelude",                                // -n
    438441        "generate prototypes for prelude functions",            // -p
    439         "print",                                                                                        // -P
     442        "print",                                              // -P
    440443        "<directory> prelude directory for debug/nodebug",      // no flag
    441444        "<option-list> enable profiling information:\n          counters,heap,time,all,none", // -S
    442         "building cfa standard lib",                                                                    // -t
    443         "wait for gdb to attach",                                                                       // -g
    444         "",                                                                                                     // -w
    445         "",                                                                                                     // -W
    446         "",                                                                                                     // -D
     445        "building cfa standard lib",                          // -t
     446        "",                                                   // -w
     447        "",                                                   // -W
     448        "",                                                   // -D
    447449}; // description
    448450
     
    512514        while ( (c = getopt_long( argc, argv, optstring, long_opts, nullptr )) != -1 ) {
    513515                switch ( c ) {
     516                  case 'c':                                                                             // diagnostic colors
     517                        if ( strcmp( optarg, "always" ) == 0 ) {
     518                                ErrorHelpers::colors = ErrorHelpers::Colors::Always;
     519                        } else if ( strcmp( optarg, "never" ) == 0 ) {
     520                                ErrorHelpers::colors = ErrorHelpers::Colors::Never;
     521                        } else if ( strcmp( optarg, "auto" ) == 0 ) {
     522                                ErrorHelpers::colors = ErrorHelpers::Colors::Auto;
     523                        } // if
     524                        break;
    514525                  case 'h':                                                                             // help message
    515526                        usage( argv );                                                          // no return
  • tests/.expect/gccExtensions.x64.txt

    r1c40091 r2909b515  
    1212    asm volatile ( "mov %1, %0\n\t" "add $1, %0" : "=" "r" ( _X3dsti_2 ) :  :  );
    1313    asm volatile ( "mov %1, %0\n\t" "add $1, %0" : "=r" ( _X3dsti_2 ) : "r" ( _X3srci_2 ) :  );
    14     asm ( "mov %1, %0\n\t" "add $1, %0" : "=r" ( _X3dsti_2 ), "=r" ( _X3srci_2 ) : [ _X3srci_2 ] "r" ( _X3dsti_2 ) : "r0" );
     14    asm ( "mov %1, %0\n\t" "add $1, %0" : "=r" ( _X3dsti_2 ), "=r" ( _X3srci_2 ) : [ src ] "r" ( _X3dsti_2 ) : "r0" );
    1515    L2: L1: asm goto ( "frob %%r5, %1; jc %l[L1]; mov (%2), %%r5" :  : "r" ( _X3srci_2 ), "r" ( (&_X3dsti_2) ) : "r5", "memory" : L1, L2 );
    1616    double _Complex _X2c1Cd_2;
  • tests/.expect/gccExtensions.x86.txt

    r1c40091 r2909b515  
    1212    asm volatile ( "mov %1, %0\n\t" "add $1, %0" : "=" "r" ( _X3dsti_2 ) :  :  );
    1313    asm volatile ( "mov %1, %0\n\t" "add $1, %0" : "=r" ( _X3dsti_2 ) : "r" ( _X3srci_2 ) :  );
    14     asm ( "mov %1, %0\n\t" "add $1, %0" : "=r" ( _X3dsti_2 ), "=r" ( _X3srci_2 ) : [ _X3srci_2 ] "r" ( _X3dsti_2 ) : "r0" );
     14    asm ( "mov %1, %0\n\t" "add $1, %0" : "=r" ( _X3dsti_2 ), "=r" ( _X3srci_2 ) : [ src ] "r" ( _X3dsti_2 ) : "r0" );
    1515    L2: L1: asm goto ( "frob %%r5, %1; jc %l[L1]; mov (%2), %%r5" :  : "r" ( _X3srci_2 ), "r" ( (&_X3dsti_2) ) : "r5", "memory" : L1, L2 );
    1616    double _Complex _X2c1Cd_2;
Note: See TracChangeset for help on using the changeset viewer.