Lib/Target/Emulator.cpp
/**
 * Given a branch condition, determine if it evaluates to true using
 * the implicit condition flags.
 */
Given a branch condition, determine if it evaluates to true using
the implicit condition flags.
Given a branch condition determine if it evaluates to true using the implicit condition flags .
inline bool checkBranchCond(QPUState* s, BranchCond cond) {
  bool bools[NUM_LANES];
  auto set_bools = [&bools] (QPUState *s, BranchCond const &cond) {
    for (int i = 0; i < NUM_LANES; i++)
      switch (cond.flag) {
        case ZS: bools[i] =  s->zeroFlags[i]; break;
        case ZC: bools[i] = !s->zeroFlags[i]; break;
        case NS: bools[i] =  s->negFlags[i];  break;
        case NC: bools[i] = !s->negFlags[i];  break;
        default: assert(false); break;
      }
  };
  switch (cond.tag) {
    case BranchCond::COND_ALWAYS: return true;
    case BranchCond::COND_NEVER: return false;
    case BranchCond::COND_ALL:
      set_bools(s, cond);
      for (int i = 0; i < NUM_LANES; i++)
        if (!bools[i]) return false;
      return true;
    case BranchCond::COND_ANY:
      set_bools(s, cond);
      for (int i = 0; i < NUM_LANES; i++)
        if (bools[i]) return true;
      return false;
    default:
      assertq(false, "checkBranchCond(): unexpected value");
      return false;
  }
}
inline bool checkBranchCond ( QPUState * s , BranchCond cond ) { bool bools [ NUM_LANES ] ; auto set_bools = [ & bools ] ( QPUState * s , BranchCond const & cond ) { for ( int i = 0 ; i < NUM_LANES ; i ++ ) switch ( cond . flag ) { case ZS : bools [ i ] = s -> zeroFlags [ i ] ; break ; case ZC : bools [ i ] = ! s -> zeroFlags [ i ] ; break ; case NS : bools [ i ] = s -> negFlags [ i ] ; break ; case NC : bools [ i ] = ! s -> negFlags [ i ] ; break ; default : assert ( false ) ; break ; } } ; switch ( cond . tag ) { case BranchCond :: COND_ALWAYS : return true ; case BranchCond :: COND_NEVER : return false ; case BranchCond :: COND_ALL : set_bools ( s , cond ) ; for ( int i = 0 ; i < NUM_LANES ; i ++ ) if ( ! bools [ i ] ) return false ; return true ; case BranchCond :: COND_ANY : set_bools ( s , cond ) ; for ( int i = 0 ; i < NUM_LANES ; i ++ ) if ( bools [ i ] ) return true ; return false ; default : assertq ( false , " " ) ; return false ; } }
Given a branch condition, determine if it evaluates to true using
 the implicit condition flags.
Given a branch condition determine if it evaluates to true using the implicit condition flags .