swr: [rasterizer core/common/jitter] gl_double support
[mesa.git] / src / gallium / drivers / swr / rasterizer / jitter / scripts / gen_llvm_ir_macros.py
index a8b101a30a2130109055fd8f8a1f77b0f9e06caf..70d35762bc5f92de71ab7d05442d9f3760d6310f 100644 (file)
@@ -84,6 +84,7 @@ inst_aliases = {
 }
 
 intrinsics = [
+        ["VGATHERPD", "x86_avx2_gather_d_pd_256", ["src", "pBase", "indices", "mask", "scale"]],
         ["VGATHERPS", "x86_avx2_gather_d_ps_256", ["src", "pBase", "indices", "mask", "scale"]],
         ["VGATHERDD", "x86_avx2_gather_d_d_256", ["src", "pBase", "indices", "mask", "scale"]],
         ["VSQRTPS", "x86_avx_sqrt_ps_256", ["a"]],
@@ -91,26 +92,23 @@ intrinsics = [
         ["VRCPPS", "x86_avx_rcp_ps_256", ["a"]],
         ["VMINPS", "x86_avx_min_ps_256", ["a", "b"]],
         ["VMAXPS", "x86_avx_max_ps_256", ["a", "b"]],
-        ["VPMINSD", "x86_avx2_pmins_d", ["a", "b"]],
-        ["VPMAXSD", "x86_avx2_pmaxs_d", ["a", "b"]],
         ["VROUND", "x86_avx_round_ps_256", ["a", "rounding"]],
         ["VCMPPS", "x86_avx_cmp_ps_256", ["a", "b", "cmpop"]],
         ["VBLENDVPS", "x86_avx_blendv_ps_256", ["a", "b", "mask"]],
         ["BEXTR_32", "x86_bmi_bextr_32", ["src", "control"]],
         ["VMASKLOADD", "x86_avx2_maskload_d_256", ["src", "mask"]],
         ["VMASKMOVPS", "x86_avx_maskload_ps_256", ["src", "mask"]],
+        ["VMASKSTOREPS", "x86_avx_maskstore_ps_256", ["src", "mask", "val"]],
         ["VPSHUFB", "x86_avx2_pshuf_b", ["a", "b"]],
-        ["VPMOVSXBD", "x86_avx2_pmovsxbd", ["a"]],  # sign extend packed 8bit components
-        ["VPMOVSXWD", "x86_avx2_pmovsxwd", ["a"]],  # sign extend packed 16bit components
-        ["VPERMD", "x86_avx2_permd", ["idx", "a"]],
+        ["VPERMD", "x86_avx2_permd", ["a", "idx"]],
         ["VPERMPS", "x86_avx2_permps", ["idx", "a"]],
+        ["VCVTPD2PS", "x86_avx_cvt_pd2_ps_256", ["a"]],
         ["VCVTPH2PS", "x86_vcvtph2ps_256", ["a"]],
         ["VCVTPS2PH", "x86_vcvtps2ph_256", ["a", "round"]],
         ["VHSUBPS", "x86_avx_hsub_ps_256", ["a", "b"]],
         ["VPTESTC", "x86_avx_ptestc_256", ["a", "b"]],
         ["VPTESTZ", "x86_avx_ptestz_256", ["a", "b"]],
         ["VFMADDPS", "x86_fma_vfmadd_ps_256", ["a", "b", "c"]],
-        ["VCVTTPS2DQ", "x86_avx_cvtt_ps2dq_256", ["a"]],
         ["VMOVMSKPS", "x86_avx_movmsk_ps_256", ["a"]],
         ["INTERRUPT", "x86_int", ["a"]],
     ]
@@ -263,7 +261,11 @@ def generate_gen_cpp(functions, output_file):
 
     output_lines += [
         '#include \"builder.h\"',
-        ''
+        '',
+        'namespace SwrJit',
+        '{',
+        '    using namespace llvm;',
+        '',
     ]
 
     for func in functions:
@@ -281,14 +283,14 @@ def generate_gen_cpp(functions, output_file):
             first_arg = False
 
         output_lines += [
-            '//////////////////////////////////////////////////////////////////////////',
-            '%sBuilder::%s(%s)' % (func['return'], name, func['args_nodefs']),
-            '{',
-            '   return IRB()->%s(%s);' % (func['name'], func_args),
-            '}',
+            '    //////////////////////////////////////////////////////////////////////////',
+            '    %sBuilder::%s(%s)' % (func['return'], name, func['args_nodefs']),
+            '    {',
+            '       return IRB()->%s(%s);' % (func['name'], func_args),
+            '    }',
             '',
         ]
-
+    output_lines.append('}')
     output_file.write('\n'.join(output_lines) + '\n')
 
 """
@@ -330,7 +332,11 @@ def generate_x86_cpp(output_file):
 
     output_lines += [
         '#include \"builder.h\"',
-        ''
+        '',
+        'namespace SwrJit',
+        '{',
+        '    using namespace llvm;',
+        '',
     ]
 
     for inst in intrinsics:
@@ -348,15 +354,38 @@ def generate_x86_cpp(output_file):
             first = False
 
         output_lines += [
-            '//////////////////////////////////////////////////////////////////////////',
-            'Value *Builder::%s(%s)' % (inst[0], args),
-            '{',
-            '    Function *func = Intrinsic::getDeclaration(JM()->mpCurrentModule, Intrinsic::%s);' % inst[1],
-            '    return CALL(func, std::initializer_list<Value*>{%s});' % pass_args,
-            '}',
+            '    //////////////////////////////////////////////////////////////////////////',
+            '    Value *Builder::%s(%s)' % (inst[0], args),
+            '    {',
+            '        Function *func = Intrinsic::getDeclaration(JM()->mpCurrentModule, Intrinsic::%s);' % inst[1],
+        ]
+        if inst[0] == "VPERMD":
+            rev_args = ''
+            first = True
+            for arg in reversed(inst[2]):
+                if not first:
+                    rev_args += ', '
+                rev_args += arg
+                first = False
+
+            output_lines += [
+                '#if (HAVE_LLVM == 0x306) && (LLVM_VERSION_PATCH == 0)',
+                '        return CALL(func, std::initializer_list<Value*>{%s});' % rev_args,
+                '#else',
+            ]
+        output_lines += [
+            '        return CALL(func, std::initializer_list<Value*>{%s});' % pass_args,
+        ]
+        if inst[0] == "VPERMD":
+            output_lines += [
+                '#endif',
+            ]
+        output_lines += [
+            '    }',
             '',
         ]
 
+    output_lines.append('}')
     output_file.write('\n'.join(output_lines) + '\n')
 
 """