nv50/ir: add lock/unlock subops for load/store
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 25 Jan 2016 20:43:13 +0000 (21:43 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Sun, 21 Feb 2016 09:42:02 +0000 (10:42 +0100)
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
src/gallium/drivers/nouveau/codegen/nv50_ir.h
src/gallium/drivers/nouveau/codegen/nv50_ir_emit_nvc0.cpp
src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp

index 9d7becf27d49689a01a91886eeb4153666f46ac3..97ebed455b6297fa20d8cc1b5a048ca74f10050b 100644 (file)
@@ -232,6 +232,8 @@ enum operation
 #define NV50_IR_SUBOP_SHFL_UP   1
 #define NV50_IR_SUBOP_SHFL_DOWN 2
 #define NV50_IR_SUBOP_SHFL_BFLY 3
+#define NV50_IR_SUBOP_LOAD_LOCKED    1
+#define NV50_IR_SUBOP_STORE_UNLOCKED 2
 #define NV50_IR_SUBOP_MADSP_SD     0xffff
 // Yes, we could represent those with DataType.
 // Or put the type into operation and have a couple 1000 values in that enum.
index 650044d93f7a03a0b4c7b7378ebe0a53de46203e..a7c49a24efb947f31ab080252580cfe8a78e5033 100644 (file)
@@ -1773,7 +1773,13 @@ CodeEmitterNVC0::emitSTORE(const Instruction *i)
    switch (i->src(0).getFile()) {
    case FILE_MEMORY_GLOBAL: opc = 0x90000000; break;
    case FILE_MEMORY_LOCAL:  opc = 0xc8000000; break;
-   case FILE_MEMORY_SHARED: opc = 0xc9000000; break;
+   case FILE_MEMORY_SHARED:
+      opc = 0xc8000000;
+      if (i->subOp == NV50_IR_SUBOP_STORE_UNLOCKED)
+         opc |= (1 << 26);
+      else
+         opc |= (1 << 24);
+      break;
    default:
       assert(!"invalid memory file");
       opc = 0;
@@ -1804,7 +1810,13 @@ CodeEmitterNVC0::emitLOAD(const Instruction *i)
    switch (i->src(0).getFile()) {
    case FILE_MEMORY_GLOBAL: opc = 0x80000000; break;
    case FILE_MEMORY_LOCAL:  opc = 0xc0000000; break;
-   case FILE_MEMORY_SHARED: opc = 0xc1000000; break;
+   case FILE_MEMORY_SHARED:
+      opc = 0xc0000000;
+      if (i->subOp == NV50_IR_SUBOP_LOAD_LOCKED)
+         opc |= (1 << 26);
+      else
+         opc |= (1 << 24);
+      break;
    case FILE_MEMORY_CONST:
       if (!i->src(0).isIndirect(0) && typeSizeof(i->dType) == 4) {
          emitMOV(i); // not sure if this is any better
index 47285a25c33e495748a3ab28b43ab61bd0a10f1f..85f77047c5cc89f10be560d90b0448385067730f 100644 (file)
@@ -198,6 +198,11 @@ static const char *atomSubOpStr[] =
    "add", "min", "max", "inc", "dec", "and", "or", "xor", "cas", "exch"
 };
 
+static const char *ldstSubOpStr[] =
+{
+   "", "lock", "unlock"
+};
+
 static const char *DataTypeStr[] =
 {
    "-",
@@ -537,6 +542,11 @@ void Instruction::print() const
          if (subOp < Elements(atomSubOpStr))
             PRINT("%s ", atomSubOpStr[subOp]);
          break;
+      case OP_LOAD:
+      case OP_STORE:
+         if (subOp < Elements(ldstSubOpStr))
+            PRINT("%s ", ldstSubOpStr[subOp]);
+         break;
       default:
          if (subOp)
             PRINT("(SUBOP:%u) ", subOp);