diff --color -Naur mesa-22.1.7/src/gallium/auxiliary/draw/draw_llvm.c mesa-22.1.7-patched/src/gallium/auxiliary/draw/draw_llvm.c
old
|
new
|
|
797 | 797 | llvm->context = context; |
798 | 798 | if (!llvm->context) { |
799 | 799 | llvm->context = LLVMContextCreate(); |
| 800 | |
| 801 | #if LLVM_VERSION_MAJOR >= 15 |
| 802 | LLVMContextSetOpaquePointers(llvm->context, false); |
| 803 | #endif |
| 804 | |
800 | 805 | llvm->context_owned = true; |
801 | 806 | } |
802 | 807 | if (!llvm->context) |
diff --color -Naur mesa-22.1.7/src/gallium/auxiliary/gallivm/lp_bld_arit.c mesa-22.1.7-patched/src/gallium/auxiliary/gallivm/lp_bld_arit.c
old
|
new
|
|
391 | 391 | return LLVMBuildNot(builder, a, ""); |
392 | 392 | } |
393 | 393 | |
394 | | if(LLVMIsConstant(a)) |
395 | | if (type.floating) |
396 | | return LLVMConstFSub(bld->one, a); |
397 | | else |
398 | | return LLVMConstSub(bld->one, a); |
| 394 | if (type.floating) |
| 395 | return LLVMBuildFSub(builder, bld->one, a, ""); |
399 | 396 | else |
400 | | if (type.floating) |
401 | | return LLVMBuildFSub(builder, bld->one, a, ""); |
402 | | else |
403 | | return LLVMBuildSub(builder, bld->one, a, ""); |
| 397 | return LLVMBuildSub(builder, bld->one, a, ""); |
404 | 398 | } |
405 | 399 | |
406 | 400 | |
… |
… |
|
479 | 473 | } |
480 | 474 | } |
481 | 475 | |
482 | | if(LLVMIsConstant(a) && LLVMIsConstant(b)) |
483 | | if (type.floating) |
484 | | res = LLVMConstFAdd(a, b); |
485 | | else |
486 | | res = LLVMConstAdd(a, b); |
| 476 | if (type.floating) |
| 477 | res = LLVMBuildFAdd(builder, a, b, ""); |
487 | 478 | else |
488 | | if (type.floating) |
489 | | res = LLVMBuildFAdd(builder, a, b, ""); |
490 | | else |
491 | | res = LLVMBuildAdd(builder, a, b, ""); |
| 479 | res = LLVMBuildAdd(builder, a, b, ""); |
492 | 480 | |
493 | 481 | /* clamp to ceiling of 1.0 */ |
494 | 482 | if(bld->type.norm && (bld->type.floating || bld->type.fixed)) |
… |
… |
|
815 | 803 | } |
816 | 804 | } |
817 | 805 | |
818 | | if(LLVMIsConstant(a) && LLVMIsConstant(b)) |
819 | | if (type.floating) |
820 | | res = LLVMConstFSub(a, b); |
821 | | else |
822 | | res = LLVMConstSub(a, b); |
| 806 | if (type.floating) |
| 807 | res = LLVMBuildFSub(builder, a, b, ""); |
823 | 808 | else |
824 | | if (type.floating) |
825 | | res = LLVMBuildFSub(builder, a, b, ""); |
826 | | else |
827 | | res = LLVMBuildSub(builder, a, b, ""); |
| 809 | res = LLVMBuildSub(builder, a, b, ""); |
828 | 810 | |
829 | 811 | if(bld->type.norm && (bld->type.floating || bld->type.fixed)) |
830 | 812 | res = lp_build_max_simple(bld, res, bld->zero, GALLIVM_NAN_RETURN_OTHER_SECOND_NONNAN); |
… |
… |
|
980 | 962 | else |
981 | 963 | shift = NULL; |
982 | 964 | |
983 | | if(LLVMIsConstant(a) && LLVMIsConstant(b)) { |
984 | | if (type.floating) |
985 | | res = LLVMConstFMul(a, b); |
986 | | else |
987 | | res = LLVMConstMul(a, b); |
988 | | if(shift) { |
989 | | if(type.sign) |
990 | | res = LLVMConstAShr(res, shift); |
991 | | else |
992 | | res = LLVMConstLShr(res, shift); |
993 | | } |
994 | | } |
995 | | else { |
996 | | if (type.floating) |
997 | | res = LLVMBuildFMul(builder, a, b, ""); |
| 965 | if (type.floating) |
| 966 | res = LLVMBuildFMul(builder, a, b, ""); |
| 967 | else |
| 968 | res = LLVMBuildMul(builder, a, b, ""); |
| 969 | if(shift) { |
| 970 | if(type.sign) |
| 971 | res = LLVMBuildAShr(builder, res, shift, ""); |
998 | 972 | else |
999 | | res = LLVMBuildMul(builder, a, b, ""); |
1000 | | if(shift) { |
1001 | | if(type.sign) |
1002 | | res = LLVMBuildAShr(builder, res, shift, ""); |
1003 | | else |
1004 | | res = LLVMBuildLShr(builder, res, shift, ""); |
1005 | | } |
| 973 | res = LLVMBuildLShr(builder, res, shift, ""); |
1006 | 974 | } |
1007 | 975 | |
1008 | 976 | return res; |
… |
… |
|
1288 | 1256 | if(a == bld->undef || b == bld->undef) |
1289 | 1257 | return bld->undef; |
1290 | 1258 | |
1291 | | if(LLVMIsConstant(a) && LLVMIsConstant(b)) { |
1292 | | if (type.floating) |
1293 | | return LLVMConstFDiv(a, b); |
1294 | | else if (type.sign) |
1295 | | return LLVMConstSDiv(a, b); |
1296 | | else |
1297 | | return LLVMConstUDiv(a, b); |
1298 | | } |
1299 | | |
1300 | 1259 | /* fast rcp is disabled (just uses div), so makes no sense to try that */ |
1301 | 1260 | if(FALSE && |
1302 | 1261 | ((util_get_cpu_caps()->has_sse && type.width == 32 && type.length == 4) || |
… |
… |
|
2645 | 2604 | |
2646 | 2605 | assert(type.floating); |
2647 | 2606 | |
2648 | | if(LLVMIsConstant(a)) |
2649 | | return LLVMConstFDiv(bld->one, a); |
2650 | | |
2651 | 2607 | /* |
2652 | 2608 | * We don't use RCPPS because: |
2653 | 2609 | * - it only has 10bits of precision |
diff --color -Naur mesa-22.1.7/src/gallium/auxiliary/gallivm/lp_bld.h mesa-22.1.7-patched/src/gallium/auxiliary/gallivm/lp_bld.h
old
|
new
|
|
82 | 82 | #define LLVMCreateBuilder ILLEGAL_LLVM_FUNCTION |
83 | 83 | |
84 | 84 | #if LLVM_VERSION_MAJOR >= 8 |
| 85 | #if LLVM_VERSION_MAJOR >= 15 |
| 86 | #define GALLIVM_HAVE_CORO 0 |
| 87 | #define GALLIVM_USE_NEW_PASS 1 |
| 88 | #elif LLVM_VERSION_MAJOR >= 8 |
85 | 89 | #define GALLIVM_HAVE_CORO 1 |
| 90 | #define GALLIVM_USE_NEW_PASS 0 |
86 | 91 | #else |
87 | 92 | #define GALLIVM_HAVE_CORO 0 |
| 93 | #define GALLIVM_USE_NEW_PASS 0 |
| 94 | #endif |
88 | 95 | #endif |
| 96 | |
| 97 | #define GALLIVM_COROUTINES (GALLIVM_HAVE_CORO || GALLIVM_USE_NEW_PASS) |
89 | 98 | |
90 | 99 | #endif /* LP_BLD_H */ |
diff --color -Naur mesa-22.1.7/src/gallium/auxiliary/gallivm/lp_bld_init.c mesa-22.1.7-patched/src/gallium/auxiliary/gallivm/lp_bld_init.c
old
|
new
|
|
45 | 45 | #include <llvm-c/Transforms/Utils.h> |
46 | 46 | #endif |
47 | 47 | #include <llvm-c/BitWriter.h> |
48 | | #if GALLIVM_HAVE_CORO |
| 48 | #if GALLIVM_USE_NEW_PASS == 1 |
| 49 | #include <llvm-c/Transforms/PassBuilder.h> |
| 50 | #elif GALLIVM_HAVE_CORO == 1 |
49 | 51 | #if LLVM_VERSION_MAJOR <= 8 && (defined(PIPE_ARCH_AARCH64) || defined (PIPE_ARCH_ARM) || defined(PIPE_ARCH_S390) || defined(PIPE_ARCH_MIPS64)) |
50 | 52 | #include <llvm-c/Transforms/IPO.h> |
51 | 53 | #endif |
… |
… |
|
110 | 112 | static boolean |
111 | 113 | create_pass_manager(struct gallivm_state *gallivm) |
112 | 114 | { |
| 115 | #if GALLIVM_USE_NEW_PASS == 0 |
113 | 116 | assert(!gallivm->passmgr); |
114 | 117 | assert(gallivm->target); |
115 | 118 | |
… |
… |
|
117 | 120 | if (!gallivm->passmgr) |
118 | 121 | return FALSE; |
119 | 122 | |
120 | | #if GALLIVM_HAVE_CORO |
| 123 | #if GALLIVM_HAVE_CORO == 1 |
121 | 124 | gallivm->cgpassmgr = LLVMCreatePassManager(); |
122 | 125 | #endif |
123 | 126 | /* |
… |
… |
|
134 | 137 | free(td_str); |
135 | 138 | } |
136 | 139 | |
137 | | #if GALLIVM_HAVE_CORO |
| 140 | #if GALLIVM_HAVE_CORO == 1 |
138 | 141 | #if LLVM_VERSION_MAJOR <= 8 && (defined(PIPE_ARCH_AARCH64) || defined (PIPE_ARCH_ARM) || defined(PIPE_ARCH_S390) || defined(PIPE_ARCH_MIPS64)) |
139 | 142 | LLVMAddArgumentPromotionPass(gallivm->cgpassmgr); |
140 | 143 | LLVMAddFunctionAttrsPass(gallivm->cgpassmgr); |
… |
… |
|
181 | 184 | */ |
182 | 185 | LLVMAddPromoteMemoryToRegisterPass(gallivm->passmgr); |
183 | 186 | } |
184 | | #if GALLIVM_HAVE_CORO |
| 187 | #if GALLIVM_HAVE_CORO == 1 |
185 | 188 | LLVMAddCoroCleanupPass(gallivm->passmgr); |
186 | 189 | #endif |
187 | | |
| 190 | #endif |
188 | 191 | return TRUE; |
189 | 192 | } |
190 | 193 | |
191 | | |
192 | 194 | /** |
193 | 195 | * Free gallivm object's LLVM allocations, but not any generated code |
194 | 196 | * nor the gallivm object itself. |
… |
… |
|
196 | 198 | void |
197 | 199 | gallivm_free_ir(struct gallivm_state *gallivm) |
198 | 200 | { |
| 201 | #if GALLIVM_USE_NEW_PASS == 0 |
199 | 202 | if (gallivm->passmgr) { |
200 | 203 | LLVMDisposePassManager(gallivm->passmgr); |
201 | 204 | } |
202 | 205 | |
203 | | #if GALLIVM_HAVE_CORO |
| 206 | #if GALLIVM_HAVE_CORO == 1 |
204 | 207 | if (gallivm->cgpassmgr) { |
205 | 208 | LLVMDisposePassManager(gallivm->cgpassmgr); |
206 | 209 | } |
207 | 210 | #endif |
| 211 | #endif |
208 | 212 | |
209 | 213 | if (gallivm->engine) { |
210 | 214 | /* This will already destroy any associated module */ |
… |
… |
|
232 | 236 | gallivm->target = NULL; |
233 | 237 | gallivm->module = NULL; |
234 | 238 | gallivm->module_name = NULL; |
| 239 | #if GALLIVM_USE_NEW_PASS == 0 |
| 240 | #if GALLIVM_HAVE_CORO == 1 |
235 | 241 | gallivm->cgpassmgr = NULL; |
| 242 | #endif |
236 | 243 | gallivm->passmgr = NULL; |
| 244 | #endif |
237 | 245 | gallivm->context = NULL; |
238 | 246 | gallivm->builder = NULL; |
239 | 247 | gallivm->cache = NULL; |
… |
… |
|
571 | 579 | void |
572 | 580 | gallivm_compile_module(struct gallivm_state *gallivm) |
573 | 581 | { |
574 | | LLVMValueRef func; |
575 | 582 | int64_t time_begin = 0; |
576 | 583 | |
577 | 584 | assert(!gallivm->compiled); |
… |
… |
|
581 | 588 | gallivm->builder = NULL; |
582 | 589 | } |
583 | 590 | |
| 591 | LLVMSetDataLayout(gallivm->module, ""); |
| 592 | assert(!gallivm->engine); |
| 593 | if (!init_gallivm_engine(gallivm)) { |
| 594 | assert(0); |
| 595 | } |
| 596 | assert(gallivm->engine); |
| 597 | |
584 | 598 | if (gallivm->cache && gallivm->cache->data_size) { |
585 | 599 | goto skip_cached; |
586 | 600 | } |
… |
… |
|
604 | 618 | if (gallivm_debug & GALLIVM_DEBUG_PERF) |
605 | 619 | time_begin = os_time_get(); |
606 | 620 | |
607 | | #if GALLIVM_HAVE_CORO |
| 621 | #if GALLIVM_USE_NEW_PASS == 1 |
| 622 | char passes[1024]; |
| 623 | passes[0] = 0; |
| 624 | |
| 625 | /* |
| 626 | * there should be some way to combine these two pass runs but I'm not seeing it, |
| 627 | * at the time of writing. |
| 628 | */ |
| 629 | strcpy(passes, "default<O0>"); |
| 630 | |
| 631 | LLVMPassBuilderOptionsRef opts = LLVMCreatePassBuilderOptions(); |
| 632 | LLVMRunPasses(gallivm->module, passes, LLVMGetExecutionEngineTargetMachine(gallivm->engine), opts); |
| 633 | |
| 634 | if (!(gallivm_perf & GALLIVM_PERF_NO_OPT)) |
| 635 | strcpy(passes, "sroa,early-cse,simplifycfg,reassociate,mem2reg,constprop,instcombine,"); |
| 636 | else |
| 637 | strcpy(passes, "mem2reg"); |
| 638 | |
| 639 | LLVMRunPasses(gallivm->module, passes, LLVMGetExecutionEngineTargetMachine(gallivm->engine), opts); |
| 640 | LLVMDisposePassBuilderOptions(opts); |
| 641 | #else |
| 642 | #if GALLIVM_HAVE_CORO == 1 |
608 | 643 | LLVMRunPassManager(gallivm->cgpassmgr, gallivm->module); |
609 | 644 | #endif |
610 | 645 | /* Run optimization passes */ |
611 | 646 | LLVMInitializeFunctionPassManager(gallivm->passmgr); |
| 647 | LLVMValueRef func; |
612 | 648 | func = LLVMGetFirstFunction(gallivm->module); |
613 | 649 | while (func) { |
614 | 650 | if (0) { |
… |
… |
|
626 | 662 | func = LLVMGetNextFunction(func); |
627 | 663 | } |
628 | 664 | LLVMFinalizeFunctionPassManager(gallivm->passmgr); |
629 | | |
| 665 | #endif |
630 | 666 | if (gallivm_debug & GALLIVM_DEBUG_PERF) { |
631 | 667 | int64_t time_end = os_time_get(); |
632 | 668 | int time_msec = (int)((time_end - time_begin) / 1000); |
… |
… |
|
653 | 689 | * lp_build_create_jit_compiler_for_module() |
654 | 690 | */ |
655 | 691 | skip_cached: |
656 | | LLVMSetDataLayout(gallivm->module, ""); |
657 | | assert(!gallivm->engine); |
658 | | if (!init_gallivm_engine(gallivm)) { |
659 | | assert(0); |
660 | | } |
661 | | assert(gallivm->engine); |
662 | 692 | |
663 | 693 | ++gallivm->compiled; |
664 | 694 | |
diff --color -Naur mesa-22.1.7/src/gallium/auxiliary/gallivm/lp_bld_init.h mesa-22.1.7-patched/src/gallium/auxiliary/gallivm/lp_bld_init.h
old
|
new
|
|
46 | 46 | LLVMModuleRef module; |
47 | 47 | LLVMExecutionEngineRef engine; |
48 | 48 | LLVMTargetDataRef target; |
| 49 | #if GALLIVM_USE_NEW_PASS == 0 |
49 | 50 | LLVMPassManagerRef passmgr; |
| 51 | #if GALLIVM_HAVE_CORO == 1 |
50 | 52 | LLVMPassManagerRef cgpassmgr; |
| 53 | #endif |
| 54 | #endif |
51 | 55 | LLVMContextRef context; |
52 | 56 | LLVMBuilderRef builder; |
53 | 57 | LLVMMCJITMemoryManagerRef memorymgr; |
diff --color -Naur mesa-22.1.7/src/gallium/drivers/llvmpipe/lp_context.c mesa-22.1.7-patched/src/gallium/drivers/llvmpipe/lp_context.c
old
|
new
|
|
250 | 250 | if (!llvmpipe->context) |
251 | 251 | goto fail; |
252 | 252 | |
| 253 | #if LLVM_VERSION_MAJOR >= 15 |
| 254 | LLVMContextSetOpaquePointers(llvmpipe->context, false); |
| 255 | #endif |
| 256 | |
253 | 257 | /* |
254 | 258 | * Create drawing context and plug our rendering stage into it. |
255 | 259 | */ |
diff --color -Naur mesa-22.1.7/src/gallium/drivers/llvmpipe/lp_screen.c mesa-22.1.7-patched/src/gallium/drivers/llvmpipe/lp_screen.c
old
|
new
|
|
215 | 215 | return lscreen->use_tgsi ? 330 : 450; |
216 | 216 | } |
217 | 217 | case PIPE_CAP_COMPUTE: |
218 | | return GALLIVM_HAVE_CORO; |
| 218 | return GALLIVM_COROUTINES; |
219 | 219 | case PIPE_CAP_USER_VERTEX_BUFFERS: |
220 | 220 | return 1; |
221 | 221 | case PIPE_CAP_TGSI_TEXCOORD: |
… |
… |
|
394 | 394 | case PIPE_SHADER_TESS_CTRL: |
395 | 395 | case PIPE_SHADER_TESS_EVAL: |
396 | 396 | /* Tessellation shader needs llvm coroutines support */ |
397 | | if (!GALLIVM_HAVE_CORO || lscreen->use_tgsi) |
| 397 | if (!GALLIVM_COROUTINES || lscreen->use_tgsi) |
398 | 398 | return 0; |
399 | 399 | FALLTHROUGH; |
400 | 400 | case PIPE_SHADER_VERTEX: |
diff --color -Naur mesa-22.1.7/src/gallium/drivers/llvmpipe/lp_test_arit.c mesa-22.1.7-patched/src/gallium/drivers/llvmpipe/lp_test_arit.c
old
|
new
|
|
438 | 438 | } |
439 | 439 | |
440 | 440 | context = LLVMContextCreate(); |
| 441 | #if LLVM_VERSION_MAJOR >= 15 |
| 442 | LLVMContextSetOpaquePointers(context, false); |
| 443 | #endif |
441 | 444 | gallivm = gallivm_create("test_module", context, NULL); |
442 | 445 | |
443 | 446 | test_func = build_unary_test_func(gallivm, test, length, test_name); |
diff --color -Naur mesa-22.1.7/src/gallium/drivers/llvmpipe/lp_test_blend.c mesa-22.1.7-patched/src/gallium/drivers/llvmpipe/lp_test_blend.c
old
|
new
|
|
452 | 452 | dump_blend_type(stdout, blend, type); |
453 | 453 | |
454 | 454 | context = LLVMContextCreate(); |
| 455 | #if LLVM_VERSION_MAJOR >= 15 |
| 456 | LLVMContextSetOpaquePointers(context, false); |
| 457 | #endif |
455 | 458 | gallivm = gallivm_create("test_module", context, NULL); |
456 | 459 | |
457 | 460 | func = add_blend_test(gallivm, blend, type); |
diff --color -Naur mesa-22.1.7/src/gallium/drivers/llvmpipe/lp_test_conv.c mesa-22.1.7-patched/src/gallium/drivers/llvmpipe/lp_test_conv.c
old
|
new
|
|
221 | 221 | } |
222 | 222 | |
223 | 223 | context = LLVMContextCreate(); |
| 224 | #if LLVM_VERSION_MAJOR >= 15 |
| 225 | LLVMContextSetOpaquePointers(context, false); |
| 226 | #endif |
224 | 227 | gallivm = gallivm_create("test_module", context, NULL); |
225 | 228 | |
226 | 229 | func = add_conv_test(gallivm, src_type, num_srcs, dst_type, num_dsts); |
diff --color -Naur mesa-22.1.7/src/gallium/drivers/llvmpipe/lp_test_format.c mesa-22.1.7-patched/src/gallium/drivers/llvmpipe/lp_test_format.c
old
|
new
|
|
150 | 150 | unsigned i, j, k, l; |
151 | 151 | |
152 | 152 | context = LLVMContextCreate(); |
| 153 | #if LLVM_VERSION_MAJOR >= 15 |
| 154 | LLVMContextSetOpaquePointers(context, false); |
| 155 | #endif |
153 | 156 | gallivm = gallivm_create("test_module_float", context, NULL); |
154 | 157 | |
155 | 158 | fetch = add_fetch_rgba_test(gallivm, verbose, desc, |
… |
… |
|
251 | 254 | unsigned i, j, k, l; |
252 | 255 | |
253 | 256 | context = LLVMContextCreate(); |
| 257 | #if LLVM_VERSION_MAJOR >= 15 |
| 258 | LLVMContextSetOpaquePointers(context, false); |
| 259 | #endif |
254 | 260 | gallivm = gallivm_create("test_module_unorm8", context, NULL); |
255 | 261 | |
256 | 262 | fetch = add_fetch_rgba_test(gallivm, verbose, desc, |
diff --color -Naur mesa-22.1.7/src/gallium/drivers/llvmpipe/lp_test_printf.c mesa-22.1.7-patched/src/gallium/drivers/llvmpipe/lp_test_printf.c
old
|
new
|
|
96 | 96 | boolean success = TRUE; |
97 | 97 | |
98 | 98 | context = LLVMContextCreate(); |
| 99 | #if LLVM_VERSION_MAJOR >= 15 |
| 100 | LLVMContextSetOpaquePointers(context, false); |
| 101 | #endif |
99 | 102 | gallivm = gallivm_create("test_module", context, NULL); |
100 | 103 | |
101 | 104 | test = add_printf_test(gallivm); |