swr/rast: autogenerate named structs instead of literal structs
authorTim Rowley <timothy.o.rowley@intel.com>
Thu, 28 Dec 2017 23:56:03 +0000 (17:56 -0600)
committerTim Rowley <timothy.o.rowley@intel.com>
Wed, 10 Jan 2018 15:44:07 +0000 (09:44 -0600)
Results in far smaller and useful IR output.

Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
src/gallium/drivers/swr/rasterizer/codegen/templates/gen_llvm.hpp

index 18ea781713760a56f7b3f22d38a3ec35d3827d6b..574ee5aaa7906521a8de2603149fee21fe0adcb1 100644 (file)
@@ -40,15 +40,22 @@ namespace SwrJit
     INLINE static StructType *Gen_${type['name']}(JitManager* pJitMgr)
     {
         LLVMContext& ctx = pJitMgr->mContext;
-        std::vector<Type*> members;
-        <%
-            (max_type_len, max_name_len) = calc_max_len(type['members'])
-        %>
-        %for member in type['members']:
-        /* ${member['name']} ${pad(len(member['name']), max_name_len)}*/ members.push_back( ${member['type']} );
-        %endfor
 
-        return StructType::get(ctx, members, false);
+        StructType* pRetType = pJitMgr->mpCurrentModule->getTypeByName("${type['name']}");
+        if (pRetType == nullptr)
+        {
+            std::vector<Type*> members;
+            <%
+                (max_type_len, max_name_len) = calc_max_len(type['members'])
+            %>
+            %for member in type['members']:
+            /* ${member['name']} ${pad(len(member['name']), max_name_len)}*/ members.push_back(${ member['type'] });
+            %endfor
+
+            pRetType = StructType::create(members, "${type['name']}", false);
+        }
+
+        return pRetType;
     }
 
     %for member in type['members']: