Exemplo n.º 1
0
static void
LOOP_END(State &state, const ControlFlowInst &cf)
{
   // TODO: LOOP_END has different behaviour depending on which LOOP_START
   // instruction started the loop, currently we only handle LOOP_START_DX10
   auto &loopState = state.loopStack.top();
   auto loopIndex = state.loopStack.size() - 1;

   // Sanity check to ensure we are at the cfPC
   decaf_check(state.cfPC == loopState.endPC);
   decaf_check((cf.word0.ADDR - 1) == loopState.startPC);

   state.loopStack.pop();

   // If breakMask is set, lets break from the while
   insertLineStart(state);
   state.out << "if (activeMask == InactiveBreak) {";
   insertLineEnd(state);

   increaseIndent(state);
   insertLineStart(state);
   state.out << "break;";
   insertLineEnd(state);
   decreaseIndent(state);

   insertLineStart(state);
   state.out << "}";
   insertLineEnd(state);

   // If ContinueMask is set, lets break from the while
   insertLineStart(state);
   state.out << "if (activeMask == InactiveContinue) {";
   insertLineEnd(state);

   increaseIndent(state);
   insertLineStart(state);
   state.out << "activeMask = Active;";
   insertLineEnd(state);
   decreaseIndent(state);

   insertLineStart(state);
   state.out << "}";
   insertLineEnd(state);

   // Check the while condition but without checking loop masks
   decreaseIndent(state);
   insertLineStart(state);
   state.out << "} while (";
   insertCond(state, cf.word1.COND());
   state.out << ");";
   insertLineEnd(state);

   insertPop(state);
   condEnd(state);
}
Exemplo n.º 2
0
void
condStart(State &state,
          SQ_CF_COND cond)
{
   insertLineStart(state);

   fmt::format_to(state.out, "if (");
   insertCond(state, cond);
   fmt::format_to(state.out, ") {{");

   insertLineEnd(state);
   increaseIndent(state);
}