[Mesa-dev] [PATCH 3/3] nv50/ir: use range-based for loops in Target*::initOpInfo()

Rhys Perry pendingchaos02 at gmail.com
Fri Jun 29 10:57:58 UTC 2018


Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
---
 .../nouveau/codegen/nv50_ir_target_nv50.cpp        | 54 +++++++++++-----------
 .../nouveau/codegen/nv50_ir_target_nvc0.cpp        | 16 +++----
 2 files changed, 34 insertions(+), 36 deletions(-)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.cpp
index 478013f139..084686fc1e 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.cpp
@@ -162,36 +162,34 @@ void TargetNV50::initOpInfo()
       opInfo[i].flow = (i >= OP_BRA && i <= OP_JOIN);
       opInfo[i].minEncSize = 8;
    }
-   for (i = 0; i < sizeof(commutativeList) / sizeof(commutativeList[0]); ++i)
-      opInfo[commutativeList[i]].commutative = true;
-   for (i = 0; i < sizeof(shortFormList) / sizeof(shortFormList[0]); ++i)
-      opInfo[shortFormList[i]].minEncSize = 4;
-   for (i = 0; i < sizeof(noDestList) / sizeof(noDestList[0]); ++i)
-      opInfo[noDestList[i]].hasDest = 0;
-   for (i = 0; i < sizeof(noPredList) / sizeof(noPredList[0]); ++i)
-      opInfo[noPredList[i]].predicate = 0;
-
-   for (i = 0; i < sizeof(_initProps) / sizeof(_initProps[0]); ++i) {
-      const struct opProperties *prop = &_initProps[i];
-
+   for (const operation &op : commutativeList)
+      opInfo[op].commutative = true;
+   for (const operation &op : shortFormList)
+      opInfo[op].minEncSize = 4;
+   for (const operation &op : noDestList)
+      opInfo[op].hasDest = 0;
+   for (const operation &op : noPredList)
+      opInfo[op].predicate = 0;
+
+   for (const struct opProperties &prop : _initProps) {
       for (int s = 0; s < 3; ++s) {
-         if (prop->mNeg & (1 << s))
-            opInfo[prop->op].srcMods[s] |= NV50_IR_MOD_NEG;
-         if (prop->mAbs & (1 << s))
-            opInfo[prop->op].srcMods[s] |= NV50_IR_MOD_ABS;
-         if (prop->mNot & (1 << s))
-            opInfo[prop->op].srcMods[s] |= NV50_IR_MOD_NOT;
-         if (prop->fConst & (1 << s))
-            opInfo[prop->op].srcFiles[s] |= 1 << (int)FILE_MEMORY_CONST;
-         if (prop->fShared & (1 << s))
-            opInfo[prop->op].srcFiles[s] |= 1 << (int)FILE_MEMORY_SHARED;
-         if (prop->fAttrib & (1 << s))
-            opInfo[prop->op].srcFiles[s] |= 1 << (int)FILE_SHADER_INPUT;
-         if (prop->fImm & (1 << s))
-            opInfo[prop->op].srcFiles[s] |= 1 << (int)FILE_IMMEDIATE;
+         if (prop.mNeg & (1 << s))
+            opInfo[prop.op].srcMods[s] |= NV50_IR_MOD_NEG;
+         if (prop.mAbs & (1 << s))
+            opInfo[prop.op].srcMods[s] |= NV50_IR_MOD_ABS;
+         if (prop.mNot & (1 << s))
+            opInfo[prop.op].srcMods[s] |= NV50_IR_MOD_NOT;
+         if (prop.fConst & (1 << s))
+            opInfo[prop.op].srcFiles[s] |= 1 << (int)FILE_MEMORY_CONST;
+         if (prop.fShared & (1 << s))
+            opInfo[prop.op].srcFiles[s] |= 1 << (int)FILE_MEMORY_SHARED;
+         if (prop.fAttrib & (1 << s))
+            opInfo[prop.op].srcFiles[s] |= 1 << (int)FILE_SHADER_INPUT;
+         if (prop.fImm & (1 << s))
+            opInfo[prop.op].srcFiles[s] |= 1 << (int)FILE_IMMEDIATE;
       }
-      if (prop->mSat & 8)
-         opInfo[prop->op].dstMods = NV50_IR_MOD_SAT;
+      if (prop.mSat & 8)
+         opInfo[prop.op].dstMods = NV50_IR_MOD_SAT;
    }
 
    if (chipset >= 0xa0)
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp
index 2be090634f..f82a57fe7b 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp
@@ -244,14 +244,14 @@ void TargetNVC0::initOpInfo()
       opInfo[i].flow = (i >= OP_BRA && i <= OP_JOIN);
       opInfo[i].minEncSize = 8;
    }
-   for (i = 0; i < sizeof(commutative) / sizeof(commutative[0]); ++i)
-      opInfo[commutative[i]].commutative = true;
-   for (i = 0; i < sizeof(shortForm) / sizeof(shortForm[0]); ++i)
-      opInfo[shortForm[i]].minEncSize = 4;
-   for (i = 0; i < sizeof(noDest) / sizeof(noDest[0]); ++i)
-      opInfo[noDest[i]].hasDest = 0;
-   for (i = 0; i < sizeof(noPred) / sizeof(noPred[0]); ++i)
-      opInfo[noPred[i]].predicate = 0;
+   for (const operation &op : commutative)
+      opInfo[op].commutative = true;
+   for (const operation &op : shortForm)
+      opInfo[op].minEncSize = 4;
+   for (const operation &op : noDest)
+      opInfo[op].hasDest = 0;
+   for (const operation &op : noPred)
+      opInfo[op].predicate = 0;
 
    initProps(_initProps, ARRAY_SIZE(_initProps));
    if (chipset >= NVISA_GM107_CHIPSET)
-- 
2.14.4



More information about the mesa-dev mailing list