i965: fixes for JMPI
[mesa.git] / src / mesa / shader / nvvertparse.c
index 24882a289797c8606818ee8e815eb6ed88007450..f5e2df267081dbe2cc41cbe4e2c22c1142b9298b 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.3
+ * Version:  6.5.2
  *
- * Copyright (C) 1999-2004  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
  * including any use thereof or modifications thereto.
  */
 
-#include "glheader.h"
-#include "context.h"
-#include "hash.h"
-#include "imports.h"
-#include "macros.h"
-#include "mtypes.h"
+#include "main/glheader.h"
+#include "main/context.h"
+#include "main/imports.h"
+#include "main/macros.h"
 #include "nvprogram.h"
 #include "nvvertparse.h"
-#include "nvvertprog.h"
+#include "prog_instruction.h"
+#include "prog_print.h"
 #include "program.h"
 
 
@@ -62,8 +61,8 @@ struct parse_state {
    GLboolean isStateProgram;
    GLboolean isPositionInvariant;
    GLboolean isVersion1_1;
-   GLuint inputsRead;
-   GLuint outputsWritten;
+   GLbitfield inputsRead;
+   GLbitfield outputsWritten;
    GLboolean anyProgRegsWritten;
    GLuint numInst;                 /* number of instructions parsed */
 };
@@ -293,18 +292,6 @@ static const char *OutputRegisters[MAX_NV_VERTEX_PROGRAM_OUTPUTS + 1] = {
    "PSIZ", "BFC0", "BFC1", NULL
 };
 
-/* NOTE: the order here must match opcodes in nvvertprog.h */
-static const char *Opcodes[] = {
-   "MOV", "LIT", "RCP", "RSQ", "EXP", "LOG", "MUL", "ADD", "DP3", "DP4",
-   "DST", "MIN", "MAX", "SLT", "SGE", "MAD", "ARL", "DPH", "RCC", "SUB",
-   "ABS", "END",
-   /* GL_ARB_vertex_program */
-   "FLR", "FRC", "EX2", "LG2", "POW", "XPD", "SWZ",
-   /* Mesa-specific */
-   "PRINT",
-   NULL
-};
-
 
 
 /**
@@ -393,7 +380,7 @@ Parse_AbsParamReg(struct parse_state *parseState, GLint *regNum)
 
 
 static GLboolean
-Parse_ParamReg(struct parse_state *parseState, struct vp_src_register *srcReg)
+Parse_ParamReg(struct parse_state *parseState, struct prog_src_register *srcReg)
 {
    GLubyte token[100];
 
@@ -561,7 +548,7 @@ Parse_OutputReg(struct parse_state *parseState, GLint *outputRegNum)
 
 
 static GLboolean
-Parse_MaskedDstReg(struct parse_state *parseState, struct vp_dst_register *dstReg)
+Parse_MaskedDstReg(struct parse_state *parseState, struct prog_dst_register *dstReg)
 {
    GLubyte token[100];
    GLint idx;
@@ -642,7 +629,7 @@ Parse_MaskedDstReg(struct parse_state *parseState, struct vp_dst_register *dstRe
 
 
 static GLboolean
-Parse_SwizzleSrcReg(struct parse_state *parseState, struct vp_src_register *srcReg)
+Parse_SwizzleSrcReg(struct parse_state *parseState, struct prog_src_register *srcReg)
 {
    GLubyte token[100];
    GLint idx;
@@ -654,12 +641,12 @@ Parse_SwizzleSrcReg(struct parse_state *parseState, struct vp_src_register *srcR
       RETURN_ERROR;
    if (token[0] == '-') {
       (void) Parse_String(parseState, "-");
-      srcReg->Negate = GL_TRUE;
+      srcReg->Negate = NEGATE_XYZW;
       if (!Peek_Token(parseState, token))
          RETURN_ERROR;
    }
    else {
-      srcReg->Negate = GL_FALSE;
+      srcReg->Negate = NEGATE_NONE;
    }
 
    /* Src reg can be R<n>, c[n], c[n +/- offset], or a named vertex attrib */
@@ -698,19 +685,22 @@ Parse_SwizzleSrcReg(struct parse_state *parseState, struct vp_src_register *srcR
       if (token[1] == 0) {
          /* single letter swizzle */
          if (token[0] == 'x')
-            srcReg->Swizzle = MAKE_SWIZZLE4(0, 0, 0, 0);
+            srcReg->Swizzle = SWIZZLE_XXXX;
          else if (token[0] == 'y')
-            srcReg->Swizzle = MAKE_SWIZZLE4(1, 1, 1, 1);
+            srcReg->Swizzle = SWIZZLE_YYYY;
          else if (token[0] == 'z')
-            srcReg->Swizzle = MAKE_SWIZZLE4(2, 2, 2, 2);
+            srcReg->Swizzle = SWIZZLE_ZZZZ;
          else if (token[0] == 'w')
-            srcReg->Swizzle = MAKE_SWIZZLE4(3, 3, 3, 3);
+            srcReg->Swizzle = SWIZZLE_WWWW;
          else
             RETURN_ERROR1("Expected x, y, z, or w");
       }
       else {
          /* 2, 3 or 4-component swizzle */
          GLint k;
+
+         srcReg->Swizzle = 0;
+
          for (k = 0; token[k] && k < 5; k++) {
             if (token[k] == 'x')
                srcReg->Swizzle |= 0 << (k*3);
@@ -733,7 +723,7 @@ Parse_SwizzleSrcReg(struct parse_state *parseState, struct vp_src_register *srcR
 
 
 static GLboolean
-Parse_ScalarSrcReg(struct parse_state *parseState, struct vp_src_register *srcReg)
+Parse_ScalarSrcReg(struct parse_state *parseState, struct prog_src_register *srcReg)
 {
    GLubyte token[100];
    GLint idx;
@@ -744,13 +734,13 @@ Parse_ScalarSrcReg(struct parse_state *parseState, struct vp_src_register *srcRe
    if (!Peek_Token(parseState, token))
       RETURN_ERROR;
    if (token[0] == '-') {
-      srcReg->Negate = GL_TRUE;
+      srcReg->Negate = NEGATE_XYZW;
       (void) Parse_String(parseState, "-"); /* consume '-' */
       if (!Peek_Token(parseState, token))
          RETURN_ERROR;
    }
    else {
-      srcReg->Negate = GL_FALSE;
+      srcReg->Negate = NEGATE_NONE;
    }
 
    /* Src reg can be R<n>, c[n], c[n +/- offset], or a named vertex attrib */
@@ -803,13 +793,13 @@ Parse_ScalarSrcReg(struct parse_state *parseState, struct vp_src_register *srcRe
 
 static GLint
 Parse_UnaryOpInstruction(struct parse_state *parseState,
-                         struct vp_instruction *inst, enum vp_opcode opcode)
+                         struct prog_instruction *inst,
+                         enum prog_opcode opcode)
 {
-   if (opcode == VP_OPCODE_ABS && !parseState->isVersion1_1)
+   if (opcode == OPCODE_ABS && !parseState->isVersion1_1)
       RETURN_ERROR1("ABS illegal for vertex program 1.0");
 
    inst->Opcode = opcode;
-   inst->StringPos = parseState->curLine - parseState->start;
 
    /* dest reg */
    if (!Parse_MaskedDstReg(parseState, &inst->DstReg))
@@ -833,15 +823,15 @@ Parse_UnaryOpInstruction(struct parse_state *parseState,
 
 static GLboolean
 Parse_BiOpInstruction(struct parse_state *parseState,
-                      struct vp_instruction *inst, enum vp_opcode opcode)
+                      struct prog_instruction *inst,
+                      enum prog_opcode opcode)
 {
-   if (opcode == VP_OPCODE_DPH && !parseState->isVersion1_1)
+   if (opcode == OPCODE_DPH && !parseState->isVersion1_1)
       RETURN_ERROR1("DPH illegal for vertex program 1.0");
-   if (opcode == VP_OPCODE_SUB && !parseState->isVersion1_1)
+   if (opcode == OPCODE_SUB && !parseState->isVersion1_1)
       RETURN_ERROR1("SUB illegal for vertex program 1.0");
 
    inst->Opcode = opcode;
-   inst->StringPos = parseState->curLine - parseState->start;
 
    /* dest reg */
    if (!Parse_MaskedDstReg(parseState, &inst->DstReg))
@@ -885,10 +875,10 @@ Parse_BiOpInstruction(struct parse_state *parseState,
 
 static GLboolean
 Parse_TriOpInstruction(struct parse_state *parseState,
-                       struct vp_instruction *inst, enum vp_opcode opcode)
+                       struct prog_instruction *inst,
+                       enum prog_opcode opcode)
 {
    inst->Opcode = opcode;
-   inst->StringPos = parseState->curLine - parseState->start;
 
    /* dest reg */
    if (!Parse_MaskedDstReg(parseState, &inst->DstReg))
@@ -952,13 +942,13 @@ Parse_TriOpInstruction(struct parse_state *parseState,
 
 static GLboolean
 Parse_ScalarInstruction(struct parse_state *parseState,
-                        struct vp_instruction *inst, enum vp_opcode opcode)
+                        struct prog_instruction *inst,
+                        enum prog_opcode opcode)
 {
-   if (opcode == VP_OPCODE_RCC && !parseState->isVersion1_1)
+   if (opcode == OPCODE_RCC && !parseState->isVersion1_1)
       RETURN_ERROR1("RCC illegal for vertex program 1.0");
 
    inst->Opcode = opcode;
-   inst->StringPos = parseState->curLine - parseState->start;
 
    /* dest reg */
    if (!Parse_MaskedDstReg(parseState, &inst->DstReg))
@@ -981,10 +971,14 @@ Parse_ScalarInstruction(struct parse_state *parseState,
 
 
 static GLboolean
-Parse_AddressInstruction(struct parse_state *parseState, struct vp_instruction *inst)
+Parse_AddressInstruction(struct parse_state *parseState, struct prog_instruction *inst)
 {
-   inst->Opcode = VP_OPCODE_ARL;
-   inst->StringPos = parseState->curLine - parseState->start;
+   inst->Opcode = OPCODE_ARL;
+
+   /* Make ARB_vp backends happy */
+   inst->DstReg.File = PROGRAM_ADDRESS;
+   inst->DstReg.WriteMask = WRITEMASK_X;
+   inst->DstReg.Index = 0;
 
    /* dest A0 reg */
    if (!Parse_AddrReg(parseState))
@@ -1007,12 +1001,11 @@ Parse_AddressInstruction(struct parse_state *parseState, struct vp_instruction *
 
 
 static GLboolean
-Parse_EndInstruction(struct parse_state *parseState, struct vp_instruction *inst)
+Parse_EndInstruction(struct parse_state *parseState, struct prog_instruction *inst)
 {
    GLubyte token[100];
 
-   inst->Opcode = VP_OPCODE_END;
-   inst->StringPos = parseState->curLine - parseState->start;
+   inst->Opcode = OPCODE_END;
 
    /* this should fail! */
    if (Parse_Token(parseState, token))
@@ -1036,17 +1029,16 @@ Parse_EndInstruction(struct parse_state *parseState, struct vp_instruction *inst
  *                         | "PRINT" <string literal> "," <dstReg>
  */
 static GLboolean
-Parse_PrintInstruction(struct parse_state *parseState, struct vp_instruction *inst)
+Parse_PrintInstruction(struct parse_state *parseState, struct prog_instruction *inst)
 {
    const GLubyte *str;
    GLubyte *msg;
    GLuint len;
    GLubyte token[100];
-   struct vp_src_register *srcReg = &inst->SrcReg[0];
+   struct prog_src_register *srcReg = &inst->SrcReg[0];
    GLint idx;
 
-   inst->Opcode = VP_OPCODE_PRINT;
-   inst->StringPos = parseState->curLine - parseState->start;
+   inst->Opcode = OPCODE_PRINT;
 
    /* The first argument is a literal string 'just like this' */
    if (!Parse_String(parseState, "'"))
@@ -1056,7 +1048,7 @@ Parse_PrintInstruction(struct parse_state *parseState, struct vp_instruction *in
    for (len = 0; str[len] != '\''; len++) /* find closing quote */
       ;
    parseState->pos += len + 1;
-   msg = _mesa_malloc(len + 1);
+   msg = (GLubyte*) _mesa_malloc(len + 1);
 
    _mesa_memcpy(msg, str, len);
    msg[len] = 0;
@@ -1070,7 +1062,7 @@ Parse_PrintInstruction(struct parse_state *parseState, struct vp_instruction *in
          RETURN_ERROR;
 
       srcReg->RelAddr = GL_FALSE;
-      srcReg->Negate = GL_FALSE;
+      srcReg->Negate = NEGATE_NONE;
       srcReg->Swizzle = SWIZZLE_NOOP;
 
       /* Register can be R<n>, c[n], c[n +/- offset], a named vertex attrib,
@@ -1117,7 +1109,7 @@ Parse_PrintInstruction(struct parse_state *parseState, struct vp_instruction *in
 
 static GLboolean
 Parse_OptionSequence(struct parse_state *parseState,
-                     struct vp_instruction program[])
+                     struct prog_instruction program[])
 {
    (void) program;
    while (1) {
@@ -1137,92 +1129,92 @@ Parse_OptionSequence(struct parse_state *parseState,
 
 static GLboolean
 Parse_InstructionSequence(struct parse_state *parseState,
-                          struct vp_instruction program[])
+                          struct prog_instruction program[])
 {
    while (1) {
-      struct vp_instruction *inst = program + parseState->numInst;
+      struct prog_instruction *inst = program + parseState->numInst;
 
       /* Initialize the instruction */
-      _mesa_init_vp_instruction(inst);
+      _mesa_init_instructions(inst, 1);
 
       if (Parse_String(parseState, "MOV")) {
-         if (!Parse_UnaryOpInstruction(parseState, inst, VP_OPCODE_MOV))
+         if (!Parse_UnaryOpInstruction(parseState, inst, OPCODE_MOV))
             RETURN_ERROR;
       }
       else if (Parse_String(parseState, "LIT")) {
-         if (!Parse_UnaryOpInstruction(parseState, inst, VP_OPCODE_LIT))
+         if (!Parse_UnaryOpInstruction(parseState, inst, OPCODE_LIT))
             RETURN_ERROR;
       }
       else if (Parse_String(parseState, "ABS")) {
-         if (!Parse_UnaryOpInstruction(parseState, inst, VP_OPCODE_ABS))
+         if (!Parse_UnaryOpInstruction(parseState, inst, OPCODE_ABS))
             RETURN_ERROR;
       }
       else if (Parse_String(parseState, "MUL")) {
-         if (!Parse_BiOpInstruction(parseState, inst, VP_OPCODE_MUL))
+         if (!Parse_BiOpInstruction(parseState, inst, OPCODE_MUL))
             RETURN_ERROR;
       }
       else if (Parse_String(parseState, "ADD")) {
-         if (!Parse_BiOpInstruction(parseState, inst, VP_OPCODE_ADD))
+         if (!Parse_BiOpInstruction(parseState, inst, OPCODE_ADD))
             RETURN_ERROR;
       }
       else if (Parse_String(parseState, "DP3")) {
-         if (!Parse_BiOpInstruction(parseState, inst, VP_OPCODE_DP3))
+         if (!Parse_BiOpInstruction(parseState, inst, OPCODE_DP3))
             RETURN_ERROR;
       }
       else if (Parse_String(parseState, "DP4")) {
-         if (!Parse_BiOpInstruction(parseState, inst, VP_OPCODE_DP4))
+         if (!Parse_BiOpInstruction(parseState, inst, OPCODE_DP4))
             RETURN_ERROR;
       }
       else if (Parse_String(parseState, "DST")) {
-         if (!Parse_BiOpInstruction(parseState, inst, VP_OPCODE_DST))
+         if (!Parse_BiOpInstruction(parseState, inst, OPCODE_DST))
             RETURN_ERROR;
       }
       else if (Parse_String(parseState, "MIN")) {
-         if (!Parse_BiOpInstruction(parseState, inst, VP_OPCODE_MIN))
+         if (!Parse_BiOpInstruction(parseState, inst, OPCODE_MIN))
             RETURN_ERROR;
       }
       else if (Parse_String(parseState, "MAX")) {
-         if (!Parse_BiOpInstruction(parseState, inst, VP_OPCODE_MAX))
+         if (!Parse_BiOpInstruction(parseState, inst, OPCODE_MAX))
             RETURN_ERROR;
       }
       else if (Parse_String(parseState, "SLT")) {
-         if (!Parse_BiOpInstruction(parseState, inst, VP_OPCODE_SLT))
+         if (!Parse_BiOpInstruction(parseState, inst, OPCODE_SLT))
             RETURN_ERROR;
       }
       else if (Parse_String(parseState, "SGE")) {
-         if (!Parse_BiOpInstruction(parseState, inst, VP_OPCODE_SGE))
+         if (!Parse_BiOpInstruction(parseState, inst, OPCODE_SGE))
             RETURN_ERROR;
       }
       else if (Parse_String(parseState, "DPH")) {
-         if (!Parse_BiOpInstruction(parseState, inst, VP_OPCODE_DPH))
+         if (!Parse_BiOpInstruction(parseState, inst, OPCODE_DPH))
             RETURN_ERROR;
       }
       else if (Parse_String(parseState, "SUB")) {
-         if (!Parse_BiOpInstruction(parseState, inst, VP_OPCODE_SUB))
+         if (!Parse_BiOpInstruction(parseState, inst, OPCODE_SUB))
             RETURN_ERROR;
       }
       else if (Parse_String(parseState, "MAD")) {
-         if (!Parse_TriOpInstruction(parseState, inst, VP_OPCODE_MAD))
+         if (!Parse_TriOpInstruction(parseState, inst, OPCODE_MAD))
             RETURN_ERROR;
       }
       else if (Parse_String(parseState, "RCP")) {
-         if (!Parse_ScalarInstruction(parseState, inst, VP_OPCODE_RCP))
+         if (!Parse_ScalarInstruction(parseState, inst, OPCODE_RCP))
             RETURN_ERROR;
       }
       else if (Parse_String(parseState, "RSQ")) {
-         if (!Parse_ScalarInstruction(parseState, inst, VP_OPCODE_RSQ))
+         if (!Parse_ScalarInstruction(parseState, inst, OPCODE_RSQ))
             RETURN_ERROR;
       }
       else if (Parse_String(parseState, "EXP")) {
-         if (!Parse_ScalarInstruction(parseState, inst, VP_OPCODE_EXP))
+         if (!Parse_ScalarInstruction(parseState, inst, OPCODE_EXP))
             RETURN_ERROR;
       }
       else if (Parse_String(parseState, "LOG")) {
-         if (!Parse_ScalarInstruction(parseState, inst, VP_OPCODE_LOG))
+         if (!Parse_ScalarInstruction(parseState, inst, OPCODE_LOG))
             RETURN_ERROR;
       }
       else if (Parse_String(parseState, "RCC")) {
-         if (!Parse_ScalarInstruction(parseState, inst, VP_OPCODE_RCC))
+         if (!Parse_ScalarInstruction(parseState, inst, OPCODE_RCC))
             RETURN_ERROR;
       }
       else if (Parse_String(parseState, "ARL")) {
@@ -1271,7 +1263,7 @@ Parse_InstructionSequence(struct parse_state *parseState,
 
 static GLboolean
 Parse_Program(struct parse_state *parseState,
-              struct vp_instruction instBuffer[])
+              struct prog_instruction instBuffer[])
 {
    if (parseState->isVersion1_1) {
       if (!Parse_OptionSequence(parseState, instBuffer)) {
@@ -1290,11 +1282,11 @@ Parse_Program(struct parse_state *parseState,
 void
 _mesa_parse_nv_vertex_program(GLcontext *ctx, GLenum dstTarget,
                               const GLubyte *str, GLsizei len,
-                              struct vertex_program *program)
+                              struct gl_vertex_program *program)
 {
    struct parse_state parseState;
-   struct vp_instruction instBuffer[MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS];
-   struct vp_instruction *newInst;
+   struct prog_instruction instBuffer[MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS];
+   struct prog_instruction *newInst;
    GLenum target;
    GLubyte *programString;
 
@@ -1364,7 +1356,7 @@ _mesa_parse_nv_vertex_program(GLcontext *ctx, GLenum dstTarget,
       }
       else {
          if (!parseState.isPositionInvariant &&
-             !(parseState.outputsWritten & 1)) {
+             !(parseState.outputsWritten & (1 << VERT_RESULT_HPOS))) {
             /* bit 1 = HPOS register */
             _mesa_error(ctx, GL_INVALID_OPERATION,
                         "glLoadProgramNV(HPOS not written)");
@@ -1374,35 +1366,36 @@ _mesa_parse_nv_vertex_program(GLcontext *ctx, GLenum dstTarget,
 
       /* copy the compiled instructions */
       assert(parseState.numInst <= MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS);
-      newInst = (struct vp_instruction *)
-         MALLOC(parseState.numInst * sizeof(struct vp_instruction));
+      newInst = _mesa_alloc_instructions(parseState.numInst);
       if (!newInst) {
          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV");
-         FREE(programString);
+         _mesa_free(programString);
          return;  /* out of memory */
       }
-      MEMCPY(newInst, instBuffer,
-             parseState.numInst * sizeof(struct vp_instruction));
+      _mesa_copy_instructions(newInst, instBuffer, parseState.numInst);
 
       /* install the program */
       program->Base.Target = target;
       if (program->Base.String) {
-         FREE(program->Base.String);
+         _mesa_free(program->Base.String);
       }
       program->Base.String = programString;
       program->Base.Format = GL_PROGRAM_FORMAT_ASCII_ARB;
-      if (program->Instructions) {
-         FREE(program->Instructions);
+      if (program->Base.Instructions) {
+         _mesa_free(program->Base.Instructions);
       }
-      program->Instructions = newInst;
-      program->InputsRead = parseState.inputsRead;
-      program->OutputsWritten = parseState.outputsWritten;
+      program->Base.Instructions = newInst;
+      program->Base.InputsRead = parseState.inputsRead;
+      if (parseState.isPositionInvariant)
+         program->Base.InputsRead |= VERT_BIT_POS;
+      program->Base.NumInstructions = parseState.numInst;
+      program->Base.OutputsWritten = parseState.outputsWritten;
       program->IsPositionInvariant = parseState.isPositionInvariant;
       program->IsNVProgram = GL_TRUE;
 
 #ifdef DEBUG_foo
       _mesa_printf("--- glLoadProgramNV result ---\n");
-      _mesa_print_nv_vertex_program(program);
+      _mesa_fprint_program_opt(stdout, &program->Base, PROG_PRINT_NV, 0);
       _mesa_printf("------------------------------\n");
 #endif
    }
@@ -1418,172 +1411,6 @@ _mesa_parse_nv_vertex_program(GLcontext *ctx, GLenum dstTarget,
 }
 
 
-static void
-PrintSrcReg(const struct vp_src_register *src)
-{
-   static const char comps[5] = "xyzw";
-   if (src->Negate)
-      _mesa_printf("-");
-   if (src->RelAddr) {
-      if (src->Index > 0)
-         _mesa_printf("c[A0.x + %d]", src->Index);
-      else if (src->Index < 0)
-         _mesa_printf("c[A0.x - %d]", -src->Index);
-      else
-         _mesa_printf("c[A0.x]");
-   }
-   else if (src->File == PROGRAM_OUTPUT) {
-      _mesa_printf("o[%s]", OutputRegisters[src->Index]);
-   }
-   else if (src->File == PROGRAM_INPUT) {
-      _mesa_printf("v[%s]", InputRegisters[src->Index]);
-   }
-   else if (src->File == PROGRAM_ENV_PARAM) {
-      _mesa_printf("c[%d]", src->Index);
-   }
-   else {
-      ASSERT(src->File == PROGRAM_TEMPORARY);
-      _mesa_printf("R%d", src->Index);
-   }
-
-   if (GET_SWZ(src->Swizzle, 0) == GET_SWZ(src->Swizzle, 1) &&
-       GET_SWZ(src->Swizzle, 0) == GET_SWZ(src->Swizzle, 2) &&
-       GET_SWZ(src->Swizzle, 0) == GET_SWZ(src->Swizzle, 3)) {
-      _mesa_printf(".%c", comps[GET_SWZ(src->Swizzle, 0)]);
-   }
-   else if (src->Swizzle != SWIZZLE_NOOP) {
-      _mesa_printf(".%c%c%c%c",
-             comps[GET_SWZ(src->Swizzle, 0)],
-             comps[GET_SWZ(src->Swizzle, 1)],
-             comps[GET_SWZ(src->Swizzle, 2)],
-             comps[GET_SWZ(src->Swizzle, 3)]);
-   }
-}
-
-
-static void
-PrintDstReg(const struct vp_dst_register *dst)
-{
-   if (dst->File == PROGRAM_OUTPUT) {
-      _mesa_printf("o[%s]", OutputRegisters[dst->Index]);
-   }
-   else if (dst->File == PROGRAM_INPUT) {
-      _mesa_printf("v[%s]", InputRegisters[dst->Index]);
-   }
-   else if (dst->File == PROGRAM_ENV_PARAM) {
-      _mesa_printf("c[%d]", dst->Index);
-   }
-   else {
-      ASSERT(dst->File == PROGRAM_TEMPORARY);
-      _mesa_printf("R%d", dst->Index);
-   }
-
-   if (dst->WriteMask != 0 && dst->WriteMask != 0xf) {
-      _mesa_printf(".");
-      if (dst->WriteMask & 0x1)
-         _mesa_printf("x");
-      if (dst->WriteMask & 0x2)
-         _mesa_printf("y");
-      if (dst->WriteMask & 0x4)
-         _mesa_printf("z");
-      if (dst->WriteMask & 0x8)
-         _mesa_printf("w");
-   }
-}
-
-
-/**
- * Print a single NVIDIA vertex program instruction.
- */
-void
-_mesa_print_nv_vertex_instruction(const struct vp_instruction *inst)
-{
-   switch (inst->Opcode) {
-      case VP_OPCODE_MOV:
-      case VP_OPCODE_LIT:
-      case VP_OPCODE_RCP:
-      case VP_OPCODE_RSQ:
-      case VP_OPCODE_EXP:
-      case VP_OPCODE_LOG:
-      case VP_OPCODE_RCC:
-      case VP_OPCODE_ABS:
-         _mesa_printf("%s ", Opcodes[(int) inst->Opcode]);
-         PrintDstReg(&inst->DstReg);
-         _mesa_printf(", ");
-         PrintSrcReg(&inst->SrcReg[0]);
-         _mesa_printf(";\n");
-         break;
-      case VP_OPCODE_MUL:
-      case VP_OPCODE_ADD:
-      case VP_OPCODE_DP3:
-      case VP_OPCODE_DP4:
-      case VP_OPCODE_DST:
-      case VP_OPCODE_MIN:
-      case VP_OPCODE_MAX:
-      case VP_OPCODE_SLT:
-      case VP_OPCODE_SGE:
-      case VP_OPCODE_DPH:
-      case VP_OPCODE_SUB:
-         _mesa_printf("%s ", Opcodes[(int) inst->Opcode]);
-         PrintDstReg(&inst->DstReg);
-         _mesa_printf(", ");
-         PrintSrcReg(&inst->SrcReg[0]);
-         _mesa_printf(", ");
-         PrintSrcReg(&inst->SrcReg[1]);
-         _mesa_printf(";\n");
-         break;
-      case VP_OPCODE_MAD:
-         _mesa_printf("MAD ");
-         PrintDstReg(&inst->DstReg);
-         _mesa_printf(", ");
-         PrintSrcReg(&inst->SrcReg[0]);
-         _mesa_printf(", ");
-         PrintSrcReg(&inst->SrcReg[1]);
-         _mesa_printf(", ");
-         PrintSrcReg(&inst->SrcReg[2]);
-         _mesa_printf(";\n");
-         break;
-      case VP_OPCODE_ARL:
-         _mesa_printf("ARL A0.x, ");
-         PrintSrcReg(&inst->SrcReg[0]);
-         _mesa_printf(";\n");
-         break;
-      case VP_OPCODE_PRINT:
-         _mesa_printf("PRINT '%s'", inst->Data);
-         if (inst->SrcReg[0].File) {
-            _mesa_printf(", ");
-            PrintSrcReg(&inst->SrcReg[0]);
-            _mesa_printf(";\n");
-         }
-         else {
-            _mesa_printf("\n");
-         }
-         break;
-      case VP_OPCODE_END:
-         _mesa_printf("END\n");
-         break;
-      default:
-         _mesa_printf("BAD INSTRUCTION\n");
-   }
-}
-
-
-/**
- * Print (unparse) the given vertex program.  Just for debugging.
- */
-void
-_mesa_print_nv_vertex_program(const struct vertex_program *program)
-{
-   const struct vp_instruction *inst;
-
-   for (inst = program->Instructions; ; inst++) {
-      _mesa_print_nv_vertex_instruction(inst);
-      if (inst->Opcode == VP_OPCODE_END)
-         return;
-   }
-}
-
-
 const char *
 _mesa_nv_vertex_input_register_name(GLuint i)
 {
@@ -1599,21 +1426,3 @@ _mesa_nv_vertex_output_register_name(GLuint i)
    return OutputRegisters[i];
 }
 
-
-/**
- * Initialize vertex program instruction fields to defaults.
- */
-void
-_mesa_init_vp_instruction(struct vp_instruction *inst)
-{
-   _mesa_bzero(inst, sizeof(struct vp_instruction));
-   inst->SrcReg[0].File = PROGRAM_UNDEFINED;
-   inst->SrcReg[0].Swizzle = SWIZZLE_NOOP;
-   inst->SrcReg[1].File = PROGRAM_UNDEFINED;
-   inst->SrcReg[1].Swizzle = SWIZZLE_NOOP;
-   inst->SrcReg[2].File = PROGRAM_UNDEFINED;
-   inst->SrcReg[2].Swizzle = SWIZZLE_NOOP;
-   inst->DstReg.File = PROGRAM_UNDEFINED;
-   inst->DstReg.WriteMask = 0xf;
-}
-