-
- if (ctx->transform_instruction)
- ctx->transform_instruction(ctx, fullinst);
- else
+ enum tgsi_opcode opcode = fullinst->Instruction.Opcode;
+
+ if (first_instruction && ctx->prolog) {
+ ctx->prolog(ctx);
+ }
+
+ /*
+ * XXX Note: we handle the case of ret in main.
+ * However, the output redirections done by transform
+ * have their limits with control flow and will generally
+ * not work correctly. e.g.
+ * if (cond) {
+ * oColor = x;
+ * ret;
+ * }
+ * oColor = y;
+ * end;
+ * If the color output is redirected to a temp and modified
+ * by a transform, this will not work (the oColor assignment
+ * in the conditional will never make it to the actual output).
+ */
+ if ((opcode == TGSI_OPCODE_END || opcode == TGSI_OPCODE_RET) &&
+ call_stack == 0 && ctx->epilog && !epilog_emitted) {
+ if (opcode == TGSI_OPCODE_RET && cond_stack != 0) {
+ assert(!"transform ignoring RET in main");
+ } else {
+ assert(cond_stack == 0);
+ /* Emit caller's epilog */
+ ctx->epilog(ctx);
+ epilog_emitted = TRUE;
+ }
+ /* Emit END (or RET) */