}
+static slang_ir_node *
+new_not(slang_ir_node *n)
+{
+ return new_node1(IR_NOT, n);
+}
+
+
/**
* Inlined subroutine.
*/
/**
- * Make new IR_BREAK_IF_TRUE or IR_BREAK_IF_FALSE node.
+ * Make new IR_BREAK_IF_TRUE.
*/
static slang_ir_node *
-new_break_if(slang_ir_node *loopNode, slang_ir_node *cond, GLboolean breakTrue)
+new_break_if_true(slang_ir_node *loopNode, slang_ir_node *cond)
{
slang_ir_node *n;
assert(loopNode);
assert(loopNode->Opcode == IR_LOOP);
- n = new_node1(breakTrue ? IR_BREAK_IF_TRUE : IR_BREAK_IF_FALSE, cond);
+ n = new_node1(IR_BREAK_IF_TRUE, cond);
if (n) {
/* insert this node at head of linked list */
n->List = loopNode->List;
}
else {
slang_ir_node *cond
- = new_cond(_slang_gen_operation(A, &oper->children[0]));
- breakIf = new_break_if(A->CurLoop, cond, GL_FALSE);
+ = new_cond(new_not(_slang_gen_operation(A, &oper->children[0])));
+ breakIf = new_break_if_true(A->CurLoop, cond);
}
body = _slang_gen_operation(A, &oper->children[1]);
loop->Children[0] = new_seq(breakIf, body);
}
else {
slang_ir_node *cond
- = new_cond(_slang_gen_operation(A, &oper->children[1]));
- loop->Children[1] = new_break_if(A->CurLoop, cond, GL_FALSE);
+ = new_cond(new_not(_slang_gen_operation(A, &oper->children[1])));
+ loop->Children[1] = new_break_if_true(A->CurLoop, cond);
}
/* XXX we should do infinite loop detection, as above */
prevLoop = A->CurLoop;
A->CurLoop = loop;
- cond = new_cond(_slang_gen_operation(A, &oper->children[1]));
- breakIf = new_break_if(A->CurLoop, cond, GL_FALSE);
+ cond = new_cond(new_not(_slang_gen_operation(A, &oper->children[1])));
+ breakIf = new_break_if_true(A->CurLoop, cond);
body = _slang_gen_operation(A, &oper->children[3]);
incr = _slang_gen_operation(A, &oper->children[2]);
if (is_operation_type(&oper->children[1], SLANG_OPER_BREAK)) {
/* Special case: generate a conditional break */
- ifBody = new_break_if(A->CurLoop, cond, GL_TRUE);
+ ifBody = new_break_if_true(A->CurLoop, cond);
if (haveElseClause) {
elseBody = _slang_gen_operation(A, &oper->children[2]);
return new_seq(ifBody, elseBody);