void _mesa_fprint_alu_instruction(FILE *f, const struct prog_instruction *inst, const char *opcode_string, GLuint numRegs, gl_prog_print_mode mode, const struct gl_program *prog) { GLuint j; fprintf(f, "%s", opcode_string); /* frag prog only */ if (inst->Saturate) fprintf(f, "_SAT"); fprintf(f, " "); if (inst->DstReg.File != PROGRAM_UNDEFINED) { fprint_dst_reg(f, &inst->DstReg, mode, prog); } else { fprintf(f, " ???"); } if (numRegs > 0) fprintf(f, ", "); for (j = 0; j < numRegs; j++) { fprint_src_reg(f, inst->SrcReg + j, mode, prog); if (j + 1 < numRegs) fprintf(f, ", "); } fprint_comment(f, inst); }
void fprint_remote(FILE *f, struct ir_remote *rem) { fprint_comment(f,rem); fprint_remote_head(f,rem); fprint_remote_signals(f,rem); fprint_remote_foot(f,rem); }
void fprint_remote(FILE* f, const struct ir_remote* rem, const char* commandline) { fprint_comment(f, rem, commandline); fprint_remote_head(f, rem); fprint_remote_signals(f, rem); fprint_remote_foot(f, rem); }
/** * Print a single vertex/fragment program instruction. */ GLint _mesa_fprint_instruction_opt(FILE *f, const struct prog_instruction *inst, GLint indent, gl_prog_print_mode mode, const struct gl_program *prog) { GLint i; if (inst->Opcode == OPCODE_ELSE || inst->Opcode == OPCODE_ENDIF || inst->Opcode == OPCODE_ENDLOOP || inst->Opcode == OPCODE_ENDSUB) { indent -= 3; } for (i = 0; i < indent; i++) { fprintf(f, " "); } switch (inst->Opcode) { case OPCODE_SWZ: fprintf(f, "SWZ"); if (inst->Saturate) fprintf(f, "_SAT"); fprintf(f, " "); fprint_dst_reg(f, &inst->DstReg, mode, prog); fprintf(f, ", %s[%d], %s", _mesa_register_file_name((gl_register_file) inst->SrcReg[0].File), inst->SrcReg[0].Index, _mesa_swizzle_string(inst->SrcReg[0].Swizzle, inst->SrcReg[0].Negate, GL_TRUE)); fprint_comment(f, inst); break; case OPCODE_TEX: case OPCODE_TXP: case OPCODE_TXL: case OPCODE_TXB: case OPCODE_TXD: fprintf(f, "%s", _mesa_opcode_string(inst->Opcode)); if (inst->Saturate) fprintf(f, "_SAT"); fprintf(f, " "); fprint_dst_reg(f, &inst->DstReg, mode, prog); fprintf(f, ", "); fprint_src_reg(f, &inst->SrcReg[0], mode, prog); if (inst->Opcode == OPCODE_TXD) { fprintf(f, ", "); fprint_src_reg(f, &inst->SrcReg[1], mode, prog); fprintf(f, ", "); fprint_src_reg(f, &inst->SrcReg[2], mode, prog); } fprintf(f, ", texture[%d], ", inst->TexSrcUnit); switch (inst->TexSrcTarget) { case TEXTURE_1D_INDEX: fprintf(f, "1D"); break; case TEXTURE_2D_INDEX: fprintf(f, "2D"); break; case TEXTURE_3D_INDEX: fprintf(f, "3D"); break; case TEXTURE_CUBE_INDEX: fprintf(f, "CUBE"); break; case TEXTURE_RECT_INDEX: fprintf(f, "RECT"); break; case TEXTURE_1D_ARRAY_INDEX: fprintf(f, "1D_ARRAY"); break; case TEXTURE_2D_ARRAY_INDEX: fprintf(f, "2D_ARRAY"); break; default: ; } if (inst->TexShadow) fprintf(f, " SHADOW"); fprint_comment(f, inst); break; case OPCODE_KIL: fprintf(f, "%s", _mesa_opcode_string(inst->Opcode)); fprintf(f, " "); fprint_src_reg(f, &inst->SrcReg[0], mode, prog); fprint_comment(f, inst); break; case OPCODE_ARL: fprintf(f, "ARL "); fprint_dst_reg(f, &inst->DstReg, mode, prog); fprintf(f, ", "); fprint_src_reg(f, &inst->SrcReg[0], mode, prog); fprint_comment(f, inst); break; case OPCODE_IF: fprintf(f, "IF "); fprint_src_reg(f, &inst->SrcReg[0], mode, prog); fprintf(f, "; "); fprintf(f, " # (if false, goto %d)", inst->BranchTarget); fprint_comment(f, inst); return indent + 3; case OPCODE_ELSE: fprintf(f, "ELSE; # (goto %d)\n", inst->BranchTarget); return indent + 3; case OPCODE_ENDIF: fprintf(f, "ENDIF;\n"); break; case OPCODE_BGNLOOP: fprintf(f, "BGNLOOP; # (end at %d)\n", inst->BranchTarget); return indent + 3; case OPCODE_ENDLOOP: fprintf(f, "ENDLOOP; # (goto %d)\n", inst->BranchTarget); break; case OPCODE_BRK: case OPCODE_CONT: fprintf(f, "%s; # (goto %d)", _mesa_opcode_string(inst->Opcode), inst->BranchTarget); fprint_comment(f, inst); break; case OPCODE_BGNSUB: fprintf(f, "BGNSUB"); fprint_comment(f, inst); return indent + 3; case OPCODE_ENDSUB: if (mode == PROG_PRINT_DEBUG) { fprintf(f, "ENDSUB"); fprint_comment(f, inst); } break; case OPCODE_CAL: fprintf(f, "CAL %u", inst->BranchTarget); fprint_comment(f, inst); break; case OPCODE_RET: fprintf(f, "RET"); fprint_comment(f, inst); break; case OPCODE_END: fprintf(f, "END\n"); break; case OPCODE_NOP: if (mode == PROG_PRINT_DEBUG) { fprintf(f, "NOP"); fprint_comment(f, inst); } else if (inst->Comment) { /* ARB/NV extensions don't have NOP instruction */ fprintf(f, "# %s\n", inst->Comment); } break; /* XXX may need other special-case instructions */ default: if (inst->Opcode < MAX_OPCODE) { /* typical alu instruction */ _mesa_fprint_alu_instruction(f, inst, _mesa_opcode_string(inst->Opcode), _mesa_num_inst_src_regs(inst->Opcode), mode, prog); } else { _mesa_fprint_alu_instruction(f, inst, _mesa_opcode_string(inst->Opcode), 3/*_mesa_num_inst_src_regs(inst->Opcode)*/, mode, prog); } break; } return indent; }
/** * Print a single vertex/fragment program instruction. */ static GLint _mesa_fprint_instruction_opt(FILE *f, const struct prog_instruction *inst, GLint indent, gl_prog_print_mode mode, const struct gl_program *prog) { GLint i; if (inst->Opcode == OPCODE_ELSE || inst->Opcode == OPCODE_ENDIF || inst->Opcode == OPCODE_ENDLOOP || inst->Opcode == OPCODE_ENDSUB) { indent -= 3; } for (i = 0; i < indent; i++) { _mesa_fprintf(f, " "); } switch (inst->Opcode) { case OPCODE_PRINT: _mesa_fprintf(f, "PRINT '%s'", inst->Data); if (inst->SrcReg[0].File != PROGRAM_UNDEFINED) { _mesa_fprintf(f, ", "); _mesa_fprintf(f, "%s[%d]%s", file_string((gl_register_file) inst->SrcReg[0].File, mode), inst->SrcReg[0].Index, _mesa_swizzle_string(inst->SrcReg[0].Swizzle, inst->SrcReg[0].Negate, GL_FALSE)); } if (inst->Comment) _mesa_fprintf(f, " # %s", inst->Comment); fprint_comment(f, inst); break; case OPCODE_SWZ: _mesa_fprintf(f, "SWZ"); if (inst->SaturateMode == SATURATE_ZERO_ONE) _mesa_fprintf(f, "_SAT"); _mesa_fprintf(f, " "); fprint_dst_reg(f, &inst->DstReg, mode, prog); _mesa_fprintf(f, ", %s[%d], %s", file_string((gl_register_file) inst->SrcReg[0].File, mode), inst->SrcReg[0].Index, _mesa_swizzle_string(inst->SrcReg[0].Swizzle, inst->SrcReg[0].Negate, GL_TRUE)); fprint_comment(f, inst); break; case OPCODE_TEX: case OPCODE_TXP: case OPCODE_TXL: case OPCODE_TXB: _mesa_fprintf(f, "%s", _mesa_opcode_string(inst->Opcode)); if (inst->SaturateMode == SATURATE_ZERO_ONE) _mesa_fprintf(f, "_SAT"); _mesa_fprintf(f, " "); fprint_dst_reg(f, &inst->DstReg, mode, prog); _mesa_fprintf(f, ", "); fprint_src_reg(f, &inst->SrcReg[0], mode, prog); _mesa_fprintf(f, ", texture[%d], ", inst->TexSrcUnit); switch (inst->TexSrcTarget) { case TEXTURE_1D_INDEX: _mesa_fprintf(f, "1D"); break; case TEXTURE_2D_INDEX: _mesa_fprintf(f, "2D"); break; case TEXTURE_3D_INDEX: _mesa_fprintf(f, "3D"); break; case TEXTURE_CUBE_INDEX: _mesa_fprintf(f, "CUBE"); break; case TEXTURE_RECT_INDEX: _mesa_fprintf(f, "RECT"); break; default: ; } if (inst->TexShadow) _mesa_fprintf(f, " SHADOW"); fprint_comment(f, inst); break; case OPCODE_KIL: _mesa_fprintf(f, "%s", _mesa_opcode_string(inst->Opcode)); _mesa_fprintf(f, " "); fprint_src_reg(f, &inst->SrcReg[0], mode, prog); fprint_comment(f, inst); break; case OPCODE_KIL_NV: _mesa_fprintf(f, "%s", _mesa_opcode_string(inst->Opcode)); _mesa_fprintf(f, " "); _mesa_fprintf(f, "%s.%s", _mesa_condcode_string(inst->DstReg.CondMask), _mesa_swizzle_string(inst->DstReg.CondSwizzle, GL_FALSE, GL_FALSE)); fprint_comment(f, inst); break; case OPCODE_ARL: _mesa_fprintf(f, "ARL "); fprint_dst_reg(f, &inst->DstReg, mode, prog); _mesa_fprintf(f, ", "); fprint_src_reg(f, &inst->SrcReg[0], mode, prog); fprint_comment(f, inst); break; case OPCODE_BRA: _mesa_fprintf(f, "BRA %d (%s%s)", inst->BranchTarget, _mesa_condcode_string(inst->DstReg.CondMask), _mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE)); fprint_comment(f, inst); break; case OPCODE_IF: if (inst->SrcReg[0].File != PROGRAM_UNDEFINED) { /* Use ordinary register */ _mesa_fprintf(f, "IF "); fprint_src_reg(f, &inst->SrcReg[0], mode, prog); _mesa_fprintf(f, "; "); } else { /* Use cond codes */ _mesa_fprintf(f, "IF (%s%s);", _mesa_condcode_string(inst->DstReg.CondMask), _mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE)); } _mesa_fprintf(f, " # (if false, goto %d)", inst->BranchTarget); fprint_comment(f, inst); return indent + 3; case OPCODE_ELSE: _mesa_fprintf(f, "ELSE; # (goto %d)\n", inst->BranchTarget); return indent + 3; case OPCODE_ENDIF: _mesa_fprintf(f, "ENDIF;\n"); break; case OPCODE_BGNLOOP: _mesa_fprintf(f, "BGNLOOP; # (end at %d)\n", inst->BranchTarget); return indent + 3; case OPCODE_ENDLOOP: _mesa_fprintf(f, "ENDLOOP; # (goto %d)\n", inst->BranchTarget); break; case OPCODE_BRK: case OPCODE_CONT: _mesa_fprintf(f, "%s (%s%s); # (goto %d)", _mesa_opcode_string(inst->Opcode), _mesa_condcode_string(inst->DstReg.CondMask), _mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE), inst->BranchTarget); fprint_comment(f, inst); break; case OPCODE_BGNSUB: if (mode == PROG_PRINT_NV) { _mesa_fprintf(f, "%s:\n", inst->Comment); /* comment is label */ return indent; } else { _mesa_fprintf(f, "BGNSUB"); fprint_comment(f, inst); return indent + 3; } case OPCODE_ENDSUB: if (mode == PROG_PRINT_DEBUG) { _mesa_fprintf(f, "ENDSUB"); fprint_comment(f, inst); } break; case OPCODE_CAL: if (mode == PROG_PRINT_NV) { _mesa_fprintf(f, "CAL %s; # (goto %d)\n", inst->Comment, inst->BranchTarget); } else { _mesa_fprintf(f, "CAL %u", inst->BranchTarget); fprint_comment(f, inst); } break; case OPCODE_RET: _mesa_fprintf(f, "RET (%s%s)", _mesa_condcode_string(inst->DstReg.CondMask), _mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE)); fprint_comment(f, inst); break; case OPCODE_END: _mesa_fprintf(f, "END\n"); break; case OPCODE_NOP: if (mode == PROG_PRINT_DEBUG) { _mesa_fprintf(f, "NOP"); fprint_comment(f, inst); } else if (inst->Comment) { /* ARB/NV extensions don't have NOP instruction */ _mesa_fprintf(f, "# %s\n", inst->Comment); } break; /* XXX may need other special-case instructions */ default: if (inst->Opcode < MAX_OPCODE) { /* typical alu instruction */ fprint_alu_instruction(f, inst, _mesa_opcode_string(inst->Opcode), _mesa_num_inst_src_regs(inst->Opcode), mode, prog); } else { _mesa_fprintf(f, "Other opcode %d\n", inst->Opcode); } break; } return indent; }