Changeset 665f432


Ignore:
Timestamp:
Nov 20, 2019, 6:55:39 PM (2 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
arm-eh, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr
Children:
1a69a90, 9802f4c
Parents:
57c764c
Message:

Fixed trac #149 where operand names in asm statements where incorrectly resolved (i.e., should not have been resolved)

Files:
12 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Convert.cpp

    r57c764c r665f432  
    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

    r57c764c r665f432  
    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

    r57c764c r665f432  
    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

    r57c764c r665f432  
    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

    r57c764c r665f432  
    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

    r57c764c r665f432  
    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/Parser/parser.yy

    r57c764c r665f432  
    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

    r57c764c r665f432  
    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

    r57c764c r665f432  
    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

    r57c764c r665f432  
    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 ); }
  • tests/.expect/gccExtensions.x64.txt

    r57c764c r665f432  
    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

    r57c764c r665f432  
    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.