Ignore:
Timestamp:
Jun 12, 2023, 12:05:58 PM (2 years ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
fec8bd1
Parents:
2b78949 (diff), 38e266ca (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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Concurrency/Waituntil.cpp

    r2b78949 r8a930c03  
    1414//
    1515
     16#include "Waituntil.hpp"
     17
    1618#include <string>
    1719
    18 #include "Waituntil.hpp"
     20#include "AST/Copy.hpp"
    1921#include "AST/Expr.hpp"
    2022#include "AST/Pass.hpp"
     
    9395                        case 0:
    9496                            try {
    95                                 if (on_selected( A, clause1 ))
     97                                    on_selected( A, clause1 );
    9698                                    doA();
    9799                            }
     
    120122        // the unregister and on_selected calls are needed to support primitives where the acquire has side effects
    121123        // so the corresponding block MUST be run for those primitives to not lose state (example is channels)
    122         if ( ! has_run(clause_statuses[0]) && whenA && unregister_select(A, clause1) && on_selected( A, clause1 ) )
     124        if ( !has_run(clause_statuses[0]) && whenA && unregister_select(A, clause1) )
     125            on_selected( A, clause1 )
    123126            doA();
    124127        ... repeat if above for B and C ...
     
    617620
    618621// Generates:
    619 /* if ( on_selected( target_1, node_1 )) ... corresponding body of target_1 ...
     622/* on_selected( target_1, node_1 ); ... corresponding body of target_1 ...
    620623*/
    621624CompoundStmt * GenerateWaitUntilCore::genStmtBlock( const WhenClause * clause, const ClauseData * data ) {
     
    623626    return new CompoundStmt( cLoc,
    624627        {
    625             new IfStmt( cLoc,
    626                 genSelectTraitCall( clause, data, "on_selected" ),
    627                 new CompoundStmt( cLoc,
    628                     {
    629                         ast::deepCopy( clause->stmt )
    630                     }
    631                 )
    632             )
     628            new ExprStmt( cLoc,
     629                genSelectTraitCall( clause, data, "on_selected" )
     630            ),
     631            ast::deepCopy( clause->stmt )
    633632        }
    634633    );
     
    642641            case 0:
    643642                try {
    644                     if (on_selected( target1, clause1 ))
    645                         dotarget1stmt();
     643                    on_selected( target1, clause1 );
     644                    dotarget1stmt();
    646645                }
    647646                finally { clause_statuses[i] = __SELECT_RUN; unregister_select(target1, clause1); }
     
    662661        case 0:
    663662            try {
    664                 if (on_selected( target1, clause1 ))
    665                     dotarget1stmt();
     663                on_selected( target1, clause1 );
     664                dotarget1stmt();
    666665            }
    667666            finally { clause_statuses[i] = __SELECT_RUN; unregister_select(target1, clause1); }
     
    938937        }
    939938
    940     // C_TODO: will remove this commented code later. Currently it isn't needed but may switch to a modified version of this later if it has better performance
    941     // std::vector<ptr<CaseClause>> switchCases;
    942 
    943     // int idx = 0;
    944     // for ( const auto & clause: stmt->clauses ) {
    945     //     const CodeLocation & cLoc = clause->location;
    946     //     switchCases.push_back(
    947     //         new CaseClause( cLoc,
    948     //             new CastExpr( cLoc,
    949     //                 new AddressExpr( cLoc, new NameExpr( cLoc, data.at(idx)->targetName ) ),
    950     //                 new BasicType( BasicType::Kind::LongUnsignedInt ), GeneratedFlag::ExplicitCast
    951     //             ),
    952     //             {
    953     //                 new CompoundStmt( cLoc,
    954     //                     {
    955     //                         ast::deepCopy( clause->stmt ),
    956     //                         new BranchStmt( cLoc, BranchStmt::Kind::Break, Label( cLoc ) )
    957     //                     }
    958     //                 )
    959     //             }
    960     //         )
    961     //     );
    962     //     idx++;
    963     // }
    964 
    965939    return new CompoundStmt( loc,
    966940        {
    967941            new ExprStmt( loc, new UntypedExpr( loc, new NameExpr( loc, "park" ) ) ),
    968942            outerIf
    969             // new SwitchStmt( loc,
    970             //     new NameExpr( loc, statusName ),
    971             //     std::move( switchCases )
    972             // )
    973943        }
    974944    );
     
    1013983    const CodeLocation & cLoc = stmt->clauses.at(idx)->location;
    1014984
     985    Expr * baseCond = genSelectTraitCall( stmt->clauses.at(idx), data.at(idx), "register_select" );
    1015986    Expr * ifCond;
    1016987
     
    1023994            ),
    1024995            new CastExpr( cLoc,
    1025                 genSelectTraitCall( stmt->clauses.at(idx), data.at(idx), "register_select" ),
     996                baseCond,
    1026997                new BasicType( BasicType::Kind::Bool ), GeneratedFlag::ExplicitCast
    1027998            ),
    1028999            LogicalFlag::AndExpr
    10291000        );
    1030     } else ifCond = genSelectTraitCall( stmt->clauses.at(idx), data.at(idx), "register_select" );
     1001    } else ifCond = baseCond;
    10311002
    10321003    return new CompoundStmt( cLoc,
     
    10461017                ifCond,
    10471018                genStmtBlock( stmt->clauses.at(idx), data.at(idx) ),
    1048                 // ast::deepCopy( stmt->clauses.at(idx)->stmt ),
    10491019                recursiveOrIfGen( stmt, data, idx + 1, elseWhenName )
    10501020            )
Note: See TracChangeset for help on using the changeset viewer.