add upstream orcjit patch and support loongarch64 orcjit
Signed-off-by: zhaojiale <zhaojiale@loongson.cn> (cherry picked from commit 09b726c437a2f710ca6d2d46aa3cadbd6a0c0846)
This commit is contained in:
parent
b8a7e5a5d7
commit
467b32d553
2464
0001-changed_by_upstream_26018_orcjit_patch.patch
Normal file
2464
0001-changed_by_upstream_26018_orcjit_patch.patch
Normal file
File diff suppressed because it is too large
Load Diff
134
0001-llvmpipe-add-loongarch64-basic-support.patch
Normal file
134
0001-llvmpipe-add-loongarch64-basic-support.patch
Normal file
@ -0,0 +1,134 @@
|
||||
From 7e21e1bfc1e9cf8031c55df2cc1f334deedce159 Mon Sep 17 00:00:00 2001
|
||||
From: zhaojiale <zhaojiale@loongson.cn>
|
||||
Date: Thu, 7 Dec 2023 06:21:08 +0800
|
||||
Subject: [PATCH 1/2] llvmpipe: add loongarch64 basic support
|
||||
|
||||
Signed-off-by: zhaojiale <zhaojiale@loongson.cn>
|
||||
---
|
||||
.../auxiliary/gallivm/lp_bld_debug.cpp | 6 ++++++
|
||||
src/gallium/auxiliary/gallivm/lp_bld_debug.h | 6 ++++++
|
||||
src/gallium/auxiliary/gallivm/lp_bld_init.c | 20 +++++++++++++++++--
|
||||
src/util/detect_arch.h | 14 +++++++++++++
|
||||
5 files changed, 48 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
|
||||
index 2918d38..eeed17d 100644
|
||||
--- a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
|
||||
+++ b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
|
||||
@@ -171,6 +171,12 @@ disassemble(const void* func, std::ostream &buffer)
|
||||
}
|
||||
#endif
|
||||
|
||||
+#if DETECT_ARCH_LOONGARCH64
|
||||
+ if (Size == 4 && (*(uint32_t *)(bytes+pc) >> 26) == 0x13) {
|
||||
+ break;
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
/*
|
||||
* Advance.
|
||||
*/
|
||||
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_debug.h b/src/gallium/auxiliary/gallivm/lp_bld_debug.h
|
||||
index a8db59b..30100aa 100644
|
||||
--- a/src/gallium/auxiliary/gallivm/lp_bld_debug.h
|
||||
+++ b/src/gallium/auxiliary/gallivm/lp_bld_debug.h
|
||||
@@ -49,6 +49,12 @@
|
||||
#define GALLIVM_PERF_NO_OPT (1 << 3)
|
||||
#define GALLIVM_PERF_NO_AOS_SAMPLING (1 << 4)
|
||||
|
||||
+#if DETECT_ARCH_LOONGARCH64
|
||||
+#define GALLIVM_PERF_OPT_O1 (1 << 5)
|
||||
+#define GALLIVM_PERF_OPT_O2 (1 << 6)
|
||||
+#define GALLIVM_PERF_OPT_O3 (1 << 7)
|
||||
+#endif
|
||||
+
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c
|
||||
index 9750cf7..3c67c11 100644
|
||||
--- a/src/gallium/auxiliary/gallivm/lp_bld_init.c
|
||||
+++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c
|
||||
@@ -50,7 +50,7 @@
|
||||
#if LLVM_VERSION_MAJOR >= 7
|
||||
#include <llvm-c/Transforms/Utils.h>
|
||||
#endif
|
||||
-#if LLVM_VERSION_MAJOR <= 8 && (DETECT_ARCH_AARCH64 || DETECT_ARCH_ARM || DETECT_ARCH_S390 || DETECT_ARCH_MIPS64)
|
||||
+#if LLVM_VERSION_MAJOR <= 8 && (DETECT_ARCH_AARCH64 || DETECT_ARCH_ARM || DETECT_ARCH_S390 || DETECT_ARCH_MIPS64 || DETECT_ARCH_LOONGARCH64)
|
||||
#include <llvm-c/Transforms/IPO.h>
|
||||
#endif
|
||||
#include <llvm-c/Transforms/Coroutines.h>
|
||||
@@ -64,6 +64,11 @@ static const struct debug_named_value lp_bld_perf_flags[] = {
|
||||
{ "no_quad_lod", GALLIVM_PERF_NO_QUAD_LOD, "disable quad_lod optimization" },
|
||||
{ "no_aos_sampling", GALLIVM_PERF_NO_AOS_SAMPLING, "disable aos sampling optimization" },
|
||||
{ "nopt", GALLIVM_PERF_NO_OPT, "disable optimization passes to speed up shader compilation" },
|
||||
+#if DETECT_ARCH_LOONGARCH64
|
||||
+ { "o3", GALLIVM_PERF_OPT_O3, "enable aggressive optimization passes" },
|
||||
+ { "o2", GALLIVM_PERF_OPT_O2, "enable medium optimization passes" },
|
||||
+ { "o1", GALLIVM_PERF_OPT_O1, "enable less optimization passes" },
|
||||
+#endif
|
||||
DEBUG_NAMED_VALUE_END
|
||||
};
|
||||
|
||||
@@ -141,7 +146,7 @@ create_pass_manager(struct gallivm_state *gallivm)
|
||||
}
|
||||
|
||||
#if GALLIVM_HAVE_CORO == 1
|
||||
-#if LLVM_VERSION_MAJOR <= 8 && (DETECT_ARCH_AARCH64 || DETECT_ARCH_ARM || DETECT_ARCH_S390 || DETECT_ARCH_MIPS64)
|
||||
+#if LLVM_VERSION_MAJOR <= 8 && (DETECT_ARCH_AARCH64 || DETECT_ARCH_ARM || DETECT_ARCH_S390 || DETECT_ARCH_MIPS64 || DETECT_ARCH_LOONGARCH64)
|
||||
LLVMAddArgumentPromotionPass(gallivm->cgpassmgr);
|
||||
LLVMAddFunctionAttrsPass(gallivm->cgpassmgr);
|
||||
#endif
|
||||
@@ -281,6 +286,17 @@ init_gallivm_engine(struct gallivm_state *gallivm)
|
||||
optlevel = Default;
|
||||
}
|
||||
|
||||
+#if DETECT_ARCH_LOONGARCH64
|
||||
+ if (gallivm_perf & GALLIVM_PERF_OPT_O3)
|
||||
+ optlevel = Aggressive;
|
||||
+ else if (gallivm_perf & GALLIVM_PERF_OPT_O2)
|
||||
+ optlevel = Default;
|
||||
+ else if (gallivm_perf & GALLIVM_PERF_OPT_O1)
|
||||
+ optlevel = Less;
|
||||
+ else
|
||||
+ optlevel = Default;
|
||||
+#endif
|
||||
+
|
||||
ret = lp_build_create_jit_compiler_for_module(&gallivm->engine,
|
||||
&gallivm->code,
|
||||
gallivm->cache,
|
||||
diff --git a/src/util/detect_arch.h b/src/util/detect_arch.h
|
||||
index 75fa7ed..c0f8cdb 100644
|
||||
--- a/src/util/detect_arch.h
|
||||
+++ b/src/util/detect_arch.h
|
||||
@@ -97,6 +97,12 @@
|
||||
#define DETECT_ARCH_HPPA 1
|
||||
#endif
|
||||
|
||||
+#if defined(__loongarch_lp64) || defined(__loongarch64)
|
||||
+#define DETECT_ARCH_LOONGARCH64 1
|
||||
+#elif defined(__loongarch__)
|
||||
+#define DETECT_ARCH_LOONGARCH 1
|
||||
+#endif
|
||||
+
|
||||
#if defined(__riscv)
|
||||
#define DETECT_ARCH_RISCV 1
|
||||
#if __riscv_xlen == 64
|
||||
@@ -148,6 +154,14 @@
|
||||
#define DETECT_ARCH_HPPA 0
|
||||
#endif
|
||||
|
||||
+#ifndef DETECT_ARCH_LOONGARCH
|
||||
+#define DETECT_ARCH_LOONGARCH 0
|
||||
+#endif
|
||||
+
|
||||
+#ifndef DETECT_ARCH_LOONGARCH64
|
||||
+#define DETECT_ARCH_LOONGARCH64 0
|
||||
+#endif
|
||||
+
|
||||
#ifndef DETECT_ARCH_RISCV
|
||||
#define DETECT_ARCH_RISCV 0
|
||||
#endif
|
||||
--
|
||||
2.43.0
|
||||
|
||||
35
0002-llvmpipe-support-loongarch64-orcjit.patch
Normal file
35
0002-llvmpipe-support-loongarch64-orcjit.patch
Normal file
@ -0,0 +1,35 @@
|
||||
From 486ff712babd672bdaa8830e250653f12879f1da Mon Sep 17 00:00:00 2001
|
||||
From: zhaojiale <zhaojiale@loongson.cn>
|
||||
Date: Sun, 12 May 2024 00:17:10 +0800
|
||||
Subject: [PATCH 2/2] llvmpipe: support loongarch64 orcjit
|
||||
|
||||
Signed-off-by: zhaojiale <zhaojiale@loongson.cn>
|
||||
---
|
||||
src/gallium/auxiliary/gallivm/lp_bld_init_orc.cpp | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init_orc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_init_orc.cpp
|
||||
index 797c9e1..17767f4 100644
|
||||
--- a/src/gallium/auxiliary/gallivm/lp_bld_init_orc.cpp
|
||||
+++ b/src/gallium/auxiliary/gallivm/lp_bld_init_orc.cpp
|
||||
@@ -52,7 +52,7 @@
|
||||
/* conflict with ObjectLinkingLayer.h */
|
||||
#include "util/u_memory.h"
|
||||
|
||||
-#if DETECT_ARCH_RISCV64 == 1 || DETECT_ARCH_RISCV32 == 1 || (defined(_WIN32) && LLVM_VERSION_MAJOR >= 15)
|
||||
+#if DETECT_ARCH_RISCV64 == 1 || DETECT_ARCH_RISCV32 == 1 || DETECT_ARCH_LOONGARCH64 == 1 || (defined(_WIN32) && LLVM_VERSION_MAJOR >= 15)
|
||||
/* use ObjectLinkingLayer (JITLINK backend) */
|
||||
#define USE_JITLINK
|
||||
#endif
|
||||
@@ -570,7 +570,7 @@ llvm::orc::JITTargetMachineBuilder LPJit::create_jtdb() {
|
||||
|
||||
std::vector<std::string> MAttrs;
|
||||
|
||||
-#if LLVM_VERSION_MAJOR >= 4 && (DETECT_ARCH_X86 == 1 || DETECT_ARCH_X86_64 == 1 || DETECT_ARCH_ARM == 1)
|
||||
+#if LLVM_VERSION_MAJOR >= 4 && (DETECT_ARCH_X86 == 1 || DETECT_ARCH_X86_64 == 1 || DETECT_ARCH_ARM == 1 || DETECT_ARCH_LOONGARCH64 == 1)
|
||||
/* llvm-3.3+ implements sys::getHostCPUFeatures for Arm
|
||||
* and llvm-3.7+ for x86, which allows us to enable/disable
|
||||
* code generation based on the results of cpuid on these
|
||||
--
|
||||
2.43.0
|
||||
|
||||
@ -52,13 +52,16 @@
|
||||
Name: mesa
|
||||
Summary: Mesa graphics libraries
|
||||
Version: 24.0.3
|
||||
Release: 1
|
||||
Release: 2
|
||||
|
||||
License: MIT
|
||||
URL: http://www.mesa3d.org
|
||||
Source0: https://archive.mesa3d.org/%{name}-%{version}.tar.xz
|
||||
|
||||
Patch1: backport-fix-build-err-on-arm.patch
|
||||
Patch2: 0001-changed_by_upstream_26018_orcjit_patch.patch
|
||||
Patch3: 0001-llvmpipe-add-loongarch64-basic-support.patch
|
||||
Patch4: 0002-llvmpipe-support-loongarch64-orcjit.patch
|
||||
|
||||
BuildRequires: gcc
|
||||
BuildRequires: gcc-c++
|
||||
@ -337,6 +340,7 @@ export ASFLAGS="--generate-missing-build-notes=yes"
|
||||
-Dglx=dri \
|
||||
-Degl=enabled \
|
||||
-Dglvnd=true \
|
||||
-Dllvm-orcjit=true \
|
||||
-Dmicrosoft-clc=disabled \
|
||||
-Dllvm=enabled \
|
||||
-Dshared-llvm=enabled \
|
||||
@ -576,6 +580,9 @@ done
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Mon May 20 2024 zhaojiale <zhaojiale@loongson.cn> - 24.0.3-2
|
||||
- add upstream orcjit patch and support loongarch64 orcjit
|
||||
|
||||
* Mon Mar 18 2024 liweigang <liweiganga@uniontech.com> - 24.0.3-1
|
||||
- update to version 24.0.3
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user