Lib/Source/Translate.cpp
/**
 * Handle general boolean expressions.
 *
 * Boolean conditions var's are used, to unify the differing approaches
 * to flag checking in `v3d` and `vc4`.
 *
 * The condition result is stored as booleans (with 0/1) in `v`, indicating the truth
 * value of the flag tests.
 *
 * The condition is reset to always use Z. Checks should be on ZC (zero clear) for 1 == true.
 *
 * 
 * @param seq    instruction sequence to which the instructions to evaluate the
 *               expression are appended
 * @param bexpr  the boolean expression to evaluate;
 * @param v      condVar 'v' to which the evaluated expression will be written to
 *
 * @return the condition to use when checking the flags for this comparison
 */
Handle general boolean expressions.
Boolean conditions var's are used, to unify the differing approaches
to flag checking in `v3d` and `vc4`.

The condition result is stored as booleans (with 0/1) in `v`, indicating the truth
value of the flag tests.

The condition is reset to always use Z. Checks should be on ZC (zero clear) for 1 == true.

@param seq    instruction sequence to which the instructions to evaluate the
expression are appended
@param bexpr  the boolean expression to evaluate;
@param v      condVar 'v' to which the evaluated expression will be written to

@return the condition to use when checking the flags for this comparison
Handle general boolean expressions . Boolean conditions var ' s are used to unify the differing approaches to flag checking in ` v3d ` and ` vc4 ` . The condition result is stored as booleans ( with 0 / 1 ) in ` v ` indicating the truth value of the flag tests . The condition is reset to always use Z . Checks should be on ZC ( zero clear ) for 1 == true . @param seq instruction sequence to which the instructions to evaluate the expression are appended @param bexpr the boolean expression to evaluate ; @param v condVar ' v ' to which the evaluated expression will be written to @return the condition to use when checking the flags for this comparison
AssignCond boolExp(Instr::List *seq, BExpr::Ptr bexpr, Var v) {
  using namespace V3DLib::Target::instr;
  BExpr b = *bexpr;
  switch (b.tag()) {
    case CMP:
      cmpExp(seq, bexpr, v);
    break;
    case NOT: {          
      boolExp(seq, b.neg(), v);
      *seq << bxor(v, v, 1).setCondFlag(Flag::ZC);
    }
    break;
    case OR:             
    case AND:            
      boolVarExp(*seq, b, v);
      break;
    default:
      assert(false);
      break;
  }
  return AssignCond(CmpOp(CmpOp::NEQ, INT32));  
}
AssignCond boolExp ( Instr :: List * seq , BExpr :: Ptr bexpr , Var v ) { using namespace V3DLib :: Target :: instr ; BExpr b = * bexpr ; switch ( b . tag ( ) ) { case CMP : cmpExp ( seq , bexpr , v ) ; break ; case NOT : { boolExp ( seq , b . neg ( ) , v ) ; * seq << bxor ( v , v , 1 ) . setCondFlag ( Flag :: ZC ) ; } break ; case OR : case AND : boolVarExp ( * seq , b , v ) ; break ; default : assert ( false ) ; break ; } return AssignCond ( CmpOp ( CmpOp :: NEQ , INT32 ) ) ; }
Handle general boolean expressions.
Handle general boolean expressions .
// '!b', where b is a boolean expression // 'a || b', where a, b are boolean expressions // 'a && b', where a, b are boolean expressions // Wonky syntax to get the flags right