gallium: remove TGSI_OPCODE_ABS
[mesa.git] / src / gallium / drivers / nouveau / codegen / nv50_ir_target.cpp
index afc8ff1374f7125419af909c8d8a89292ef638d3..273ec34fd3bf0287931751b2bb4028cc12fb91a8 100644 (file)
@@ -30,7 +30,7 @@ const uint8_t Target::operationSrcNr[] =
    0, 0,                   // NOP, PHI
    0, 0, 0, 0,             // UNION, SPLIT, MERGE, CONSTRAINT
    1, 1, 2,                // MOV, LOAD, STORE
-   2, 2, 2, 2, 2, 3, 3, 3, // ADD, SUB, MUL, DIV, MOD, MAD, FMA, SAD
+   2, 2, 2, 2, 2, 3, 3, 3, 3, // ADD, SUB, MUL, DIV, MOD, MAD, FMA, SAD, SHLADD
    1, 1, 1,                // ABS, NEG, NOT
    2, 2, 2, 2, 2,          // AND, OR, XOR, SHL, SHR
    2, 2, 1,                // MAX, MIN, SAT
@@ -46,7 +46,7 @@ const uint8_t Target::operationSrcNr[] =
    1, 1, 1,                // TEX, TXB, TXL,
    1, 1, 1, 1, 1, 1, 2,    // TXF, TXQ, TXD, TXG, TXLQ, TEXCSAA, TEXPREP
    1, 1, 2, 2, 2, 2, 2,    // SULDB, SULDP, SUSTB, SUSTP, SUREDB, SUREDP, SULEA
-   3, 3, 3, 3,             // SUBFM, SUCLAMP, SUEAU, MADSP
+   3, 3, 3, 1, 3,          // SUBFM, SUCLAMP, SUEAU, SUQ, MADSP
    0,                      // TEXBAR
    1, 1,                   // DFDX, DFDY
    1, 2, 1, 2, 0, 0,       // RDSV, WRSV, PIXLD, QUADOP, QUADON, QUADPOP
@@ -55,6 +55,8 @@ const uint8_t Target::operationSrcNr[] =
    2, 2, 2, 2, 3, 2,       // VADD, VAVG, VMIN, VMAX, VSAD, VSET,
    2, 2, 2, 1,             // VSHR, VSHL, VSEL, CCTL
    3,                      // SHFL
+   1,                      // VOTE
+   1,                      // BUFQ
    0
 };
 
@@ -68,10 +70,10 @@ const OpClass Target::operationClass[] =
    OPCLASS_MOVE,
    OPCLASS_LOAD,
    OPCLASS_STORE,
-   // ADD, SUB, MUL; DIV, MOD; MAD, FMA, SAD
+   // ADD, SUB, MUL; DIV, MOD; MAD, FMA, SAD, SHLADD
    OPCLASS_ARITH, OPCLASS_ARITH, OPCLASS_ARITH,
    OPCLASS_ARITH, OPCLASS_ARITH,
-   OPCLASS_ARITH, OPCLASS_ARITH, OPCLASS_ARITH,
+   OPCLASS_ARITH, OPCLASS_ARITH, OPCLASS_ARITH, OPCLASS_ARITH,
    // ABS, NEG; NOT, AND, OR, XOR; SHL, SHR
    OPCLASS_CONVERT, OPCLASS_CONVERT,
    OPCLASS_LOGIC, OPCLASS_LOGIC, OPCLASS_LOGIC, OPCLASS_LOGIC,
@@ -109,8 +111,8 @@ const OpClass Target::operationClass[] =
    // SULDB, SULDP, SUSTB, SUSTP; SUREDB, SUREDP, SULEA
    OPCLASS_SURFACE, OPCLASS_SURFACE, OPCLASS_ATOMIC, OPCLASS_SURFACE,
    OPCLASS_SURFACE, OPCLASS_SURFACE, OPCLASS_SURFACE,
-   // SUBFM, SUCLAMP, SUEAU, MADSP
-   OPCLASS_OTHER, OPCLASS_OTHER, OPCLASS_OTHER, OPCLASS_ARITH,
+   // SUBFM, SUCLAMP, SUEAU, SUQ, MADSP
+   OPCLASS_OTHER, OPCLASS_OTHER, OPCLASS_OTHER, OPCLASS_OTHER, OPCLASS_ARITH,
    // TEXBAR
    OPCLASS_OTHER,
    // DFDX, DFDY, RDSV, WRSV; PIXLD, QUADOP, QUADON, QUADPOP
@@ -129,6 +131,10 @@ const OpClass Target::operationClass[] =
    OPCLASS_VECTOR, OPCLASS_CONTROL,
    // SHFL
    OPCLASS_OTHER,
+   // VOTE
+   OPCLASS_OTHER,
+   // BUFQ
+   OPCLASS_OTHER,
    OPCLASS_PSEUDO // LAST
 };
 
@@ -139,10 +145,12 @@ extern Target *getTargetNV50(unsigned int chipset);
 
 Target *Target::create(unsigned int chipset)
 {
-   STATIC_ASSERT(Elements(operationSrcNr) == OP_LAST + 1);
-   STATIC_ASSERT(Elements(operationClass) == OP_LAST + 1);
+   STATIC_ASSERT(ARRAY_SIZE(operationSrcNr) == OP_LAST + 1);
+   STATIC_ASSERT(ARRAY_SIZE(operationClass) == OP_LAST + 1);
    switch (chipset & ~0xf) {
    case 0x110:
+   case 0x120:
+   case 0x130:
       return getTargetGM107(chipset);
    case 0xc0:
    case 0xd0:
@@ -166,7 +174,7 @@ void Target::destroy(Target *targ)
    delete targ;
 }
 
-CodeEmitter::CodeEmitter(const Target *target) : targ(target), interpInfo(NULL)
+CodeEmitter::CodeEmitter(const Target *target) : targ(target), fixupInfo(NULL)
 {
 }
 
@@ -373,6 +381,7 @@ Program::emitBinary(struct nv50_ir_prog_info *info)
    if (!code)
       return false;
    emit->setCodeLocation(code, binSize);
+   info->bin.instructions = 0;
 
    for (ArrayList::Iterator fi = allFuncs.iterator(); !fi.end(); fi.next()) {
       Function *fn = reinterpret_cast<Function *>(fi.get());
@@ -382,13 +391,14 @@ Program::emitBinary(struct nv50_ir_prog_info *info)
       for (int b = 0; b < fn->bbCount; ++b) {
          for (Instruction *i = fn->bbArray[b]->getEntry(); i; i = i->next) {
             emit->emitInstruction(i);
+            info->bin.instructions++;
             if (i->sType == TYPE_F64 || i->dType == TYPE_F64)
                info->io.fp64 = true;
          }
       }
    }
    info->bin.relocData = emit->getRelocInfo();
-   info->bin.interpData = emit->getInterpInfo();
+   info->bin.fixupData = emit->getFixupInfo();
 
    emitSymbolTable(info);
 
@@ -430,24 +440,23 @@ CodeEmitter::addReloc(RelocEntry::Type ty, int w, uint32_t data, uint32_t m,
 }
 
 bool
-CodeEmitter::addInterp(int ipa, int reg, InterpApply apply)
+CodeEmitter::addInterp(int ipa, int reg, FixupApply apply)
 {
-   unsigned int n = interpInfo ? interpInfo->count : 0;
+   unsigned int n = fixupInfo ? fixupInfo->count : 0;
 
    if (!(n % RELOC_ALLOC_INCREMENT)) {
-      size_t size = sizeof(InterpInfo) + n * sizeof(InterpEntry);
-      interpInfo = reinterpret_cast<InterpInfo *>(
-         REALLOC(interpInfo, n ? size : 0,
-                 size + RELOC_ALLOC_INCREMENT * sizeof(InterpEntry)));
-      if (!interpInfo)
+      size_t size = sizeof(FixupInfo) + n * sizeof(FixupEntry);
+      fixupInfo = reinterpret_cast<FixupInfo *>(
+         REALLOC(fixupInfo, n ? size : 0,
+                 size + RELOC_ALLOC_INCREMENT * sizeof(FixupEntry)));
+      if (!fixupInfo)
          return false;
       if (n == 0)
-         memset(interpInfo, 0, sizeof(InterpInfo));
+         memset(fixupInfo, 0, sizeof(FixupInfo));
    }
-   ++interpInfo->count;
+   ++fixupInfo->count;
 
-   interpInfo->entry[n] = InterpEntry(ipa, reg, codeSize >> 2);
-   interpInfo->apply = apply;
+   fixupInfo->entry[n] = FixupEntry(apply, ipa, reg, codeSize >> 2);
 
    return true;
 }
@@ -496,16 +505,19 @@ nv50_ir_relocate_code(void *relocData, uint32_t *code,
 }
 
 void
-nv50_ir_change_interp(void *interpData, uint32_t *code,
-                      bool force_persample_interp, bool flatshade)
+nv50_ir_apply_fixups(void *fixupData, uint32_t *code,
+                     bool force_persample_interp, bool flatshade,
+                     uint8_t alphatest)
 {
-   nv50_ir::InterpInfo *info = reinterpret_cast<nv50_ir::InterpInfo *>(
-      interpData);
+   nv50_ir::FixupInfo *info = reinterpret_cast<nv50_ir::FixupInfo *>(
+      fixupData);
 
    // force_persample_interp: all non-flat -> per-sample
    // flatshade: all color -> flat
+   // alphatest: PIPE_FUNC_* to use with alphatest
+   nv50_ir::FixupData data(force_persample_interp, flatshade, alphatest);
    for (unsigned i = 0; i < info->count; ++i)
-      info->apply(&info->entry[i], code, force_persample_interp, flatshade);
+      info->entry[i].apply(&info->entry[i], code, data);
 }
 
 void