swr/rast: Add MEM_ADD helper function to Builder.
authorGeorge Kyriazis <george.kyriazis@intel.com>
Thu, 15 Mar 2018 17:08:00 +0000 (12:08 -0500)
committerGeorge Kyriazis <george.kyriazis@intel.com>
Wed, 18 Apr 2018 15:51:38 +0000 (10:51 -0500)
mem[offset] += value

This function will be heavily used by all stats intrinsics.

Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
src/gallium/drivers/swr/rasterizer/jitter/builder_mem.cpp
src/gallium/drivers/swr/rasterizer/jitter/builder_mem.h

index a825434de73ed0ed1025291a3e7d6429bab5598c..dee08b81693147caac2205613bcb187de2e8c37f 100644 (file)
@@ -134,6 +134,13 @@ namespace SwrJit
         return GEP(base, offset);
     }
 
+    Value* Builder::MEM_ADD(Value* i32Incr, Value* basePtr, const std::initializer_list<uint32_t> &indices, const llvm::Twine& name)
+    {
+        Value* i32Value = LOAD(GEP(basePtr, indices), name);
+        Value* i32Result = ADD(i32Value, i32Incr);
+        return STORE(i32Result, GEP(basePtr, indices));
+    }
+
     //////////////////////////////////////////////////////////////////////////
     /// @brief Generate a masked gather operation in LLVM IR.  If not  
     /// supported on the underlying platform, emulate it with loads
index b5383421465e740196d786a2a567266ecd427213..59b45c1b41861485438798b4d974c3c241b2569d 100644 (file)
@@ -60,6 +60,8 @@ LoadInst *LOADV(Value *BasePtr, const std::initializer_list<Value*> &offset, con
 StoreInst *STORE(Value *Val, Value *BasePtr, const std::initializer_list<uint32_t> &offset);
 StoreInst *STOREV(Value *Val, Value *BasePtr, const std::initializer_list<Value*> &offset);
 
+Value* MEM_ADD(Value* i32Incr, Value* basePtr, const std::initializer_list<uint32_t> &indices, const llvm::Twine& name = "");
+
 void Gather4(const SWR_FORMAT format, Value* pSrcBase, Value* byteOffsets,
     Value* mask, Value* vGatherComponents[], bool bPackedOutput, JIT_MEM_CLIENT usage = MEM_CLIENT_INTERNAL);