core.git: bridges/source
bridges/source/cpp_uno/gcc3_linux_riscv64/abi.cxx | 15 - bridges/source/cpp_uno/gcc3_linux_riscv64/cpp2uno.cxx | 178 -- bridges/source/cpp_uno/gcc3_linux_riscv64/uno2cpp.cxx | 83 ++-- 3 files changed, 80 insertions(+), 196 deletions(-) New commits: commit de0a269a6ed54716e03e1ff3cc52857b745853e2 Author: Sakura286 AuthorDate: Fri Mar 29 11:39:28 2024 +0800 Commit: Stephan Bergmann CommitDate: Tue Apr 2 14:16:01 2024 +0200 riscv64 bridge: replace some preprocessor directives to macros for debugging Change-Id: Ic53d4a462e12e8448b14e750c4ef2824385b8f28 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165502 Tested-by: Jenkins Reviewed-by: Stephan Bergmann diff --git a/bridges/source/cpp_uno/gcc3_linux_riscv64/abi.cxx b/bridges/source/cpp_uno/gcc3_linux_riscv64/abi.cxx index 2f35f0f86455..98c8afa2c028 100644 --- a/bridges/source/cpp_uno/gcc3_linux_riscv64/abi.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_riscv64/abi.cxx @@ -12,11 +12,8 @@ #include #include "types.hxx" #include "abi.hxx" -#include #include -//#define BRIDGE_DEBUG - namespace abi_riscv64 { /* @@ -133,10 +130,8 @@ ReturnKind getReturnKind(const typelib_TypeDescription* pTypeDescr) void fillUNOStruct(const typelib_TypeDescription* pTypeDescr, sal_Int64* gret, double* fret, void* pRegisterReturn) { -#ifdef BRIDGE_DEBUG -printf("In fillStruct, pTypeDescr = %p, gret = %p, fret = %p, pRegisterReturn = %p ", - pTypeDescr, gret, fret, pRegisterReturn); -#endif +BRIDGE_LOG("In fillStruct, pTypeDescr = %p, gret = %p, fret = %p, pRegisterReturn = %p ", + pTypeDescr, gret, fret, pRegisterReturn); ReturnKind returnKind = getReturnKind(pTypeDescr); switch (returnKind) { @@ -186,10 +181,8 @@ void fillUNOStruct(const typelib_TypeDescription* pTypeDescr, sal_Int64* gret, d void splitUNOStruct(const typelib_TypeDescription* pTypeDescr, sal_uInt64* pTarget, sal_uInt64* pSource, sal_Int32& returnType) { -#ifdef BRIDGE_DEBUG -printf("In splitUNOStruct, pTypeDescr = %p, pTarget = %p, pSource = %p ", pTypeDescr, pTarget, - pSource); -#endif +BRIDGE_LOG("In splitUNOStruct, pTypeDescr = %p, pTarget = %p, pSource = %p ", pTypeDescr, + pTarget, pSource); sal_uInt64* pTemp = (sal_uInt64*)calloc(2, sizeof(sal_uInt64)); ReturnKind returnKind = getReturnKind(pTypeDescr); switch (returnKind) diff --git a/bridges/source/cpp_uno/gcc3_linux_riscv64/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_linux_riscv64/cpp2uno.cxx index 6754f23fde16..731eb12cf96d 100644 --- a/bridges/source/cpp_uno/gcc3_linux_riscv64/cpp2uno.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_riscv64/cpp2uno.cxx @@ -29,21 +29,9 @@ #include "share.hxx" #include "abi.hxx" -#include -//#include #include #include -//#define BRIDGE_DEBUG - -#ifdef BRIDGE_DEBUG -#include -#include -using namespace ::std; -using namespace ::osl; -using namespace ::rtl; -#endif - using namespace com::sun::star::uno; namespace CPPU_CURRENT_NAMESPACE @@ -103,20 +91,17 @@ cpp2uno_call(bridges::cpp_uno::shared::CppInterfaceProxy* pThis, sal_Int32 nParams, typelib_MethodParameter* pParams, void** gpreg, void** fpreg, void** ovrflw, sal_uInt64* pRegisterReturn /* space for register return */) { -#ifdef BRIDGE_DEBUG -printf("In cpp2uno_call, pThis = %p, pMemberTypeDescr = %p, pReturnTypeRef = %p ", pThis, - pMemberTypeDescr, pReturnTypeRef); -printf("In cpp2uno_call, nParams = %d, pParams = %p, pRegisterReturn = %p ", nParams, pParams, - pRegisterReturn); -printf("In cpp2uno_call, gpreg = %p, fpreg = %p, ovrflw = %p ", gpreg, fpreg, ovrflw); -#endif +BRIDGE_LOG("In cpp2uno_call, pThis = %p, pMemberTypeDescr = %p, pReturnTypeRef = %p ", pThis, + pMemberTypeDescr, pReturnTypeRef); +BRIDGE_LOG("In cpp2uno_call, nParams = %d, pParams = %p, pRegisterReturn = %p ", nParams, + pParams, pRegisterReturn); +BRIDGE_LOG("In cpp2uno_call, gpreg = %p, fpreg = %p, ovrflw = %p ", gpreg, fpreg, ovrflw); unsigned int nr_gpr = 0; unsigned int nr_fpr = 0; -#ifdef BRIDGE_DEBUG -fprintf(stdout, "cpp2uno_call:begin "); -#endif +BRIDGE_LOG("cpp2uno_call:begin "); + // return typelib_TypeDescription* pReturnTypeDescr = 0; if (pReturnTypeRef) @@ -135,16 +120,12 @@ cpp2uno_call(bridges::cpp_uno::shared::CppInterfaceProxy* pThis, pUnoReturn = (bridges::cpp_uno::shared::relatesToInterfaceType(pReturnTypeDescr) ? alloca(pReturnTypeDescr->nSize) : pCppReturn); // direct way -#ifdef BRIDGE_DEBUG -fprintf(stdout, "cpp2uno_call:complexreturn "); -#endif +BRIDGE_LOG("cpp2uno_call:complexreturn "); } else { pUnoReturn = pRegisterReturn; // direct way for simple
core.git: bridges/source
bridges/source/cpp_uno/gcc3_linux_riscv64/call.s | 72 +++ 1 file changed, 36 insertions(+), 36 deletions(-) New commits: commit 4becdfe1ef8df45c4e1385d51f82fcae7f835e78 Author: Sakura286 AuthorDate: Thu Mar 28 18:33:32 2024 +0800 Commit: Stephan Bergmann CommitDate: Thu Mar 28 21:06:21 2024 +0100 riscv64 bridge: replace tab to space in call.s Change-Id: I357f400050444336e26e73e1099b4b8ab9e8bdd1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165454 Reviewed-by: Stephan Bergmann Tested-by: Jenkins diff --git a/bridges/source/cpp_uno/gcc3_linux_riscv64/call.s b/bridges/source/cpp_uno/gcc3_linux_riscv64/call.s index 4eab63b7eb0a..0c682b5ff065 100644 --- a/bridges/source/cpp_uno/gcc3_linux_riscv64/call.s +++ b/bridges/source/cpp_uno/gcc3_linux_riscv64/call.s @@ -24,56 +24,56 @@ .type privateSnippetExecutor, %function privateSnippetExecutor: .cfi_startproc -addi sp,sp,-160 +addi sp,sp,-160 .cfi_def_cfa_offset 160 -sd ra,152(sp) +sd ra,152(sp) .cfi_offset 1, -8 -fsdfa0,80(sp) -fsdfa1,88(sp) -fsdfa2,96(sp) -fsdfa3,104(sp) -fsdfa4,112(sp) -fsdfa5,120(sp) -fsdfa6,128(sp) -fsdfa7,136(sp) -sd a0,16(sp) -sd a1,24(sp) -sd a2,32(sp) -sd a3,40(sp) -sd a4,48(sp) -sd a5,56(sp) -sd a6,64(sp) -sd a7,72(sp) +fsd fa0,80(sp) +fsd fa1,88(sp) +fsd fa2,96(sp) +fsd fa3,104(sp) +fsd fa4,112(sp) +fsd fa5,120(sp) +fsd fa6,128(sp) +fsd fa7,136(sp) +sd a0,16(sp) +sd a1,24(sp) +sd a2,32(sp) +sd a3,40(sp) +sd a4,48(sp) +sd a5,56(sp) +sd a6,64(sp) +sd a7,72(sp) // a0 = functionIndex // a1 = vtableOffset // a2 = gpreg // a3 = fpreg // a4 = overflw // a5 = pRegisterReturn -adda0,t4,zero -adda1,t5,zero -addi a2,sp,16 -addi a3,sp,80 -addi a4,sp,160 -adda5,sp,zero +add a0,t4,zero +add a1,t5,zero +addi a2,sp,16 +addi a3,sp,80 +addi a4,sp,160 +add a5,sp,zero // jump to cpp_vtable_call -jalr ra,t6,0 +jalr ra,t6,0 -bnea0,zero,.OneFloatOneInt -ld a0,0(sp) -ld a1,8(sp) -fldfa0,0(sp) -fldfa1,8(sp) -jalzero,.EndProgram +bne a0,zero,.OneFloatOneInt +ld a0,0(sp) +ld a1,8(sp) +fld fa0,0(sp) +fld fa1,8(sp) +jal zero,.EndProgram .OneFloatOneInt: -ld a0,0(sp) -fldfa0,8(sp) +ld a0,0(sp) +fld fa0,8(sp) .EndProgram: -ld ra,152(sp) +ld ra,152(sp) .cfi_restore 1 -addi sp,sp,160 +addi sp,sp,160 .cfi_def_cfa_offset 0 -jalr zero,ra,0 +jalr zero,ra,0 .cfi_endproc .size privateSnippetExecutor, .-privateSnippetExecutor .section .note.GNU-stack, "", @progbits
core.git: bridges/source
bridges/source/cpp_uno/gcc3_linux_riscv64/abi.cxx | 608 +++--- bridges/source/cpp_uno/gcc3_linux_riscv64/abi.hxx | 68 +- 2 files changed, 338 insertions(+), 338 deletions(-) New commits: commit 18d989fe1edd33d74e60184fbad82562ec703d74 Author: Sakura286 AuthorDate: Thu Mar 28 18:17:56 2024 +0800 Commit: Stephan Bergmann CommitDate: Thu Mar 28 20:50:51 2024 +0100 riscv64 bridge: switch CRLF to LF in abi.cxx/hxx Change-Id: I810f2681f61336eb823ab1eed89389d18b95dc75 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165452 Tested-by: Jenkins Reviewed-by: Stephan Bergmann diff --git a/bridges/source/cpp_uno/gcc3_linux_riscv64/abi.cxx b/bridges/source/cpp_uno/gcc3_linux_riscv64/abi.cxx index 29b1975a316e..2f35f0f86455 100644 --- a/bridges/source/cpp_uno/gcc3_linux_riscv64/abi.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_riscv64/abi.cxx @@ -1,304 +1,304 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#include -#include -#include -#include "types.hxx" -#include "abi.hxx" -#include -#include - -//#define BRIDGE_DEBUG - -namespace abi_riscv64 -{ -/* - F: floating point reg - G: general purpose reg -*/ -enum class ReturnKind -{ -FF_Align4, -FF_Align8, -FG_Align4, -FG_Align8, -GF_Align4, -GF_Align8, -DEFAULT -}; - -void countnGreg(sal_Int32& nGreg, sal_Int32& nFreg, bool& firstIsGreg, sal_Int32& align, -const typelib_CompoundTypeDescription* pTypeDescr) -{ -for (int i = 0; i < pTypeDescr->nMembers; i++) -{ -typelib_TypeDescriptionReference* pTypeInStruct = pTypeDescr->ppTypeRefs[i]; -switch (pTypeInStruct->eTypeClass) -{ -case typelib_TypeClass_STRUCT: -case typelib_TypeClass_EXCEPTION: -{ -typelib_TypeDescription* childTypeDescr = nullptr; -TYPELIB_DANGER_GET(, pTypeInStruct); -countnGreg( -nGreg, nFreg, firstIsGreg, align, -reinterpret_cast(childTypeDescr)); -TYPELIB_DANGER_RELEASE(childTypeDescr); -} -break; -case typelib_TypeClass_DOUBLE: -// Align to the larger type -align = 8; -[[fallthrough]]; -case typelib_TypeClass_FLOAT: -nFreg++; -break; -case typelib_TypeClass_HYPER: -case typelib_TypeClass_UNSIGNED_HYPER: -align = 8; -[[fallthrough]]; -default: -if (nFreg > 0) -{ -firstIsGreg = false; -} -nGreg++; -break; -} -} -} - -ReturnKind getReturnKind(const typelib_TypeDescription* pTypeDescr) -{ -sal_Int32 nGreg = 0; -sal_Int32 nFreg = 0; -sal_Int32 align = 4; -bool firstIsGreg = true; -countnGreg(nGreg, nFreg, firstIsGreg, align, - reinterpret_cast(pTypeDescr)); -if (nGreg == 0 && nFreg == 2) -{ -if (align == 4) -return ReturnKind::FF_Align4; -else -return ReturnKind::FF_Align8; -} -else if (nGreg == 1 && nFreg == 1) -{ -if (firstIsGreg) -{ -if (align == 4) -return ReturnKind::GF_Align4; -else -return ReturnKind::GF_Align8; -} -else -{ -if (align == 4) -return ReturnKind::FG_Align4; -else -return ReturnKind::FG_Align8; -} -} -else -{ -return ReturnKind::DEFAULT; -} -} - -/* -Transform the returned cpp data to uno. -This happens at the end of uno2cpp, when callee cpp func finished. - - |returned data saved in -default cases | gret[0] and gret[1] -2 float | fret[0] and fret[1] -1 float 1 int | gret[0] and fret[0] - -There is a complex problem -- alignment. For example, 4 byte float and 8 byte -integer take 16 bytes rather than 12 bytes. - -There is also another complex problem. e.g. Two 4 byte integer is compacted -in a0, but two 4 byte float is seperately set in fa0 and fa1. However, return -size is 8 bytes. We need to cut the lower 32bit of fa0 and fa1 seperately and -combine them in 8 bytes. -*/ -void fillUNOStruct(const typelib_TypeDescription* pTypeDescr, sal_Int64* gret, double* fret, - void* pRegisterReturn) -{ -#ifdef BRIDGE_DEBUG -printf("In fillStruct, pTypeDescr = %p, gret = %p, fret = %p, pRegisterReturn = %p ", -
core.git: bridges/source
bridges/source/cpp_uno/gcc3_linux_riscv64/abi.cxx | 263 -- bridges/source/cpp_uno/gcc3_linux_riscv64/abi.hxx | 19 + bridges/source/cpp_uno/gcc3_linux_riscv64/cpp2uno.cxx | 107 +++ bridges/source/cpp_uno/gcc3_linux_riscv64/uno2cpp.cxx | 181 4 files changed, 370 insertions(+), 200 deletions(-) New commits: commit e49653f440d8fced0414df93a85bb8adc6f9ffb4 Author: Sakura286 AuthorDate: Tue Dec 19 08:21:33 2023 + Commit: Stephan Bergmann CommitDate: Fri Jan 26 08:10:52 2024 +0100 (riscv64) Fix Java bridgetest failure * Refactor the code related to struct processing. Fix Java bridge- test failure. Fixed test list: * bridgetest-javaserver * [CUT] smoketest * [JUT] forms_unoapi_1 * [JUT] forms_unoapi_2 * [JUT] forms_unoapi_3 * [JUT] forms_unoapi_4 * Clean higher bit to prevent compiler generate wrong code when pyuno calls functions through UNO environment. This fixes some weired uitest failure. * Reorder the datatype list. Optimize the inserting args section in uno2cpp.cxx. * Remove some unused code. Change-Id: I74330126d31d847485b1d81fc34376b1d020f886 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160970 Tested-by: Jenkins Tested-by: René Engelhard Reviewed-by: Stephan Bergmann diff --git a/bridges/source/cpp_uno/gcc3_linux_riscv64/abi.cxx b/bridges/source/cpp_uno/gcc3_linux_riscv64/abi.cxx index b090953efde9..29b1975a316e 100644 --- a/bridges/source/cpp_uno/gcc3_linux_riscv64/abi.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_riscv64/abi.cxx @@ -19,7 +19,22 @@ namespace abi_riscv64 { -void countnGreg(sal_Int32& nGreg, sal_Int32& nFreg, +/* + F: floating point reg + G: general purpose reg +*/ +enum class ReturnKind +{ +FF_Align4, +FF_Align8, +FG_Align4, +FG_Align8, +GF_Align4, +GF_Align8, +DEFAULT +}; + +void countnGreg(sal_Int32& nGreg, sal_Int32& nFreg, bool& firstIsGreg, sal_Int32& align, const typelib_CompoundTypeDescription* pTypeDescr) { for (int i = 0; i < pTypeDescr->nMembers; i++) @@ -33,63 +48,257 @@ void countnGreg(sal_Int32& nGreg, sal_Int32& nFreg, typelib_TypeDescription* childTypeDescr = nullptr; TYPELIB_DANGER_GET(, pTypeInStruct); countnGreg( -nGreg, nFreg, +nGreg, nFreg, firstIsGreg, align, reinterpret_cast(childTypeDescr)); TYPELIB_DANGER_RELEASE(childTypeDescr); } break; -case typelib_TypeClass_FLOAT: case typelib_TypeClass_DOUBLE: +// Align to the larger type +align = 8; +[[fallthrough]]; +case typelib_TypeClass_FLOAT: nFreg++; break; +case typelib_TypeClass_HYPER: +case typelib_TypeClass_UNSIGNED_HYPER: +align = 8; +[[fallthrough]]; default: +if (nFreg > 0) +{ +firstIsGreg = false; +} nGreg++; break; } } } -void fillStruct(const typelib_TypeDescription* pTypeDescr, sal_Int64* gret, double* fret, -void* pRegisterReturn) +ReturnKind getReturnKind(const typelib_TypeDescription* pTypeDescr) { -#ifdef BRIDGE_DEBUG -printf("In fillStruct, pTypeDescr = %p, gret = %p, fret = %p, pRegisterReturn = %p ", - pTypeDescr, gret, fret, pRegisterReturn); -#endif sal_Int32 nGreg = 0; sal_Int32 nFreg = 0; -countnGreg(nGreg, nFreg, reinterpret_cast(pTypeDescr)); -char* pAdjust = reinterpret_cast(pRegisterReturn); -if (nGreg == 0 && nFreg <= 2) +sal_Int32 align = 4; +bool firstIsGreg = true; +countnGreg(nGreg, nFreg, firstIsGreg, align, + reinterpret_cast(pTypeDescr)); +if (nGreg == 0 && nFreg == 2) { -if (pTypeDescr->nSize <= 8 && nFreg == 2) -{ -std::memcpy(pAdjust, fret, 4); -std::memcpy(pAdjust + 4, fret + 1, 4); -} +if (align == 4) +return ReturnKind::FF_Align4; else -{ -std::memcpy(pAdjust, fret, 16); -} +return ReturnKind::FF_Align8; } -else if (nFreg == 1 && nGreg == 1) +else if (nGreg == 1 && nFreg == 1) { -if (pTypeDescr->nSize > 8) +if (firstIsGreg) { -std::memcpy(pAdjust, gret, 8); -std::memcpy(pAdjust + 8, fret, 8); +if (align == 4) +return ReturnKind::GF_Align4; +else +return ReturnKind::GF_Align8; } else { -std::memcpy(pAdjust, gret, 4); -std::memcpy(pAdjust + 4, fret, 4); +if (align == 4) +return
[Libreoffice-commits] core.git: bridges/source
bridges/source/cpp_uno/gcc3_linux_riscv64/cpp2uno.cxx | 26 +++--- 1 file changed, 23 insertions(+), 3 deletions(-) New commits: commit 2c258079113eae993fdaff113ba082455c920f89 Author: Sakura286 AuthorDate: Mon Jul 24 16:47:16 2023 +0800 Commit: Stephan Bergmann CommitDate: Mon Jul 31 12:59:19 2023 +0200 fix 32 bit int simple return of riscv64 bridge Sometimes we need to return a 32 bit integer into a 64 bit integer. For example, in pyuno.cxx:PyUNO_bool(), an int(32bit) is returned in type Py_ssize_t(64bit). We assume that this 32bit int was put in low 32 bit of register a0. The bridge may return with high 32 bit uncleaned and compiler might directly bind this register to 64 bit variable in error. This bug produces when build pyuno with gcc-12 with -O2. https://bugs.documentfoundation.org/show_bug.cgi?id=155937 https://lists.debian.org/debian-riscv/2023/07/msg00011.html So we need to clean the high 32 bit in bridge. Change-Id: I37aafb03ba9523cfb90912871308921fbeaf5f0c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154837 Tested-by: René Engelhard Reviewed-by: René Engelhard Reviewed-by: Stephan Bergmann diff --git a/bridges/source/cpp_uno/gcc3_linux_riscv64/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_linux_riscv64/cpp2uno.cxx index 16f6ba27c0f4..99965c570081 100644 --- a/bridges/source/cpp_uno/gcc3_linux_riscv64/cpp2uno.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_riscv64/cpp2uno.cxx @@ -357,8 +357,6 @@ cpp2uno_call(bridges::cpp_uno::shared::CppInterfaceProxy* pThis, { case typelib_TypeClass_HYPER: case typelib_TypeClass_UNSIGNED_HYPER: -case typelib_TypeClass_LONG: -case typelib_TypeClass_UNSIGNED_LONG: case typelib_TypeClass_ENUM: case typelib_TypeClass_CHAR: case typelib_TypeClass_SHORT: @@ -367,6 +365,28 @@ cpp2uno_call(bridges::cpp_uno::shared::CppInterfaceProxy* pThis, case typelib_TypeClass_BYTE: std::memcpy(pReturn, pUnoReturn, 8); break; +// Sometimes we need to return a 32 bit integer into a 64 bit integer. +// For example, in pyuno.cxx:PyUNO_bool(), an int(32bit) is returned +// in type Py_ssize_t(64bit) +// We assume that this 32bit int was put in low 32 bit of register a0. +// The bridge may return with high 32 bit uncleaned and compiler might +// directly bind this register to 64 bit variable. +// +// This bug occurs when build pyuno with gcc-12 with -O2. +// https://bugs.documentfoundation.org/show_bug.cgi?id=155937 +// +// So we need to clean the high 32 bit in bridge. +case typelib_TypeClass_UNSIGNED_LONG: +std::memset(pReturn + 4, 0x0, 4); +std::memcpy(pReturn, pUnoReturn, 4); +break; +case typelib_TypeClass_LONG: +if (*reinterpret_cast(pUnoReturn) & 0x8000) +std::memset(pReturn + 4, 0xFF, 4); +else +std::memset(pReturn + 4, 0x0, 4); +std::memcpy(pReturn, pUnoReturn, 4); +break; case typelib_TypeClass_FLOAT: std::memcpy(pReturn, pUnoReturn, 4); std::memset(pReturn + 4, 0xFF, 4); @@ -628,7 +648,7 @@ unsigned char* codeSnippet(unsigned char* code, sal_Int32 functionIndex, sal_Int /* generate this code */ /* - It is complex to load a 64bit address because uou cannot load + It is complex to load a 64bit address because you cannot load an unsigned number to register on RISC-V. # load functionIndex to t4 0eb7 lui t4,0x0
[Libreoffice-commits] core.git: bridges/Library_cpp_uno.mk bridges/source configure.ac jvmfwk/inc m4/ax_boost_base.m4 solenv/gbuild
bridges/Library_cpp_uno.mk|9 bridges/source/cpp_uno/gcc3_linux_riscv64/abi.cxx | 95 ++ bridges/source/cpp_uno/gcc3_linux_riscv64/abi.hxx | 23 bridges/source/cpp_uno/gcc3_linux_riscv64/call.hxx| 33 bridges/source/cpp_uno/gcc3_linux_riscv64/call.s | 81 + bridges/source/cpp_uno/gcc3_linux_riscv64/cpp2uno.cxx | 795 ++ bridges/source/cpp_uno/gcc3_linux_riscv64/except.cxx | 282 ++ bridges/source/cpp_uno/gcc3_linux_riscv64/share.hxx | 85 + bridges/source/cpp_uno/gcc3_linux_riscv64/uno2cpp.cxx | 616 + configure.ac | 10 jvmfwk/inc/vendorbase.hxx |2 m4/ax_boost_base.m4 |2 solenv/gbuild/platform/LINUX_RISCV64_GCC.mk | 15 13 files changed, 2045 insertions(+), 3 deletions(-) New commits: commit bc9487f745befde6534fd46058e119256952323d Author: Sakura286 AuthorDate: Tue Jul 26 02:18:23 2022 + Commit: Stephan Bergmann CommitDate: Thu Nov 10 13:47:06 2022 +0100 Add riscv64 support 1. Configure gbuild 2. Add UNO Bridge for riscv64 Till now base function works well on riscv64. The bridgetest has passed. Test on Debian, Gentoo and openEuler. Credits: - Heiher and Stephan Bergmann The riscv64 bridge implementation refers to mips64 and AArch64 bridges. - Bo Yu configures gbuild for riscv64. - WANG Xuerui provides lots of guiding tips. Change-Id: Ifad3b0de8b2c9e7328627ed03396bbd45a9c71e4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137445 Reviewed-by: Stephan Bergmann Tested-by: Jenkins diff --git a/bridges/Library_cpp_uno.mk b/bridges/Library_cpp_uno.mk index 85dd3ec8daf0..1718202e94d0 100644 --- a/bridges/Library_cpp_uno.mk +++ b/bridges/Library_cpp_uno.mk @@ -123,6 +123,15 @@ bridge_noopt_objects := cpp2uno uno2cpp bridge_exception_objects := except endif +else ifeq ($(CPUNAME),RISCV64) + +ifneq ($(filter LINUX,$(OS)),) +bridges_SELECTED_BRIDGE := gcc3_linux_riscv64 +bridge_asm_objects := call +bridge_noopt_objects := abi cpp2uno uno2cpp +bridge_exception_objects := except +endif + else ifeq ($(CPUNAME),POWERPC) ifneq ($(filter DRAGONFLY FREEBSD LINUX NETBSD OPENBSD,$(OS)),) diff --git a/bridges/source/cpp_uno/gcc3_linux_riscv64/abi.cxx b/bridges/source/cpp_uno/gcc3_linux_riscv64/abi.cxx new file mode 100644 index ..b090953efde9 --- /dev/null +++ b/bridges/source/cpp_uno/gcc3_linux_riscv64/abi.cxx @@ -0,0 +1,95 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include +#include +#include +#include "types.hxx" +#include "abi.hxx" +#include +#include + +//#define BRIDGE_DEBUG + +namespace abi_riscv64 +{ +void countnGreg(sal_Int32& nGreg, sal_Int32& nFreg, +const typelib_CompoundTypeDescription* pTypeDescr) +{ +for (int i = 0; i < pTypeDescr->nMembers; i++) +{ +typelib_TypeDescriptionReference* pTypeInStruct = pTypeDescr->ppTypeRefs[i]; +switch (pTypeInStruct->eTypeClass) +{ +case typelib_TypeClass_STRUCT: +case typelib_TypeClass_EXCEPTION: +{ +typelib_TypeDescription* childTypeDescr = nullptr; +TYPELIB_DANGER_GET(, pTypeInStruct); +countnGreg( +nGreg, nFreg, +reinterpret_cast(childTypeDescr)); +TYPELIB_DANGER_RELEASE(childTypeDescr); +} +break; +case typelib_TypeClass_FLOAT: +case typelib_TypeClass_DOUBLE: +nFreg++; +break; +default: +nGreg++; +break; +} +} +} + +void fillStruct(const typelib_TypeDescription* pTypeDescr, sal_Int64* gret, double* fret, +void* pRegisterReturn) +{ +#ifdef BRIDGE_DEBUG +printf("In fillStruct, pTypeDescr = %p, gret = %p, fret = %p, pRegisterReturn = %p\n", + pTypeDescr, gret, fret, pRegisterReturn); +#endif +sal_Int32 nGreg = 0; +sal_Int32 nFreg = 0; +countnGreg(nGreg, nFreg, reinterpret_cast(pTypeDescr)); +char* pAdjust = reinterpret_cast(pRegisterReturn); +if (nGreg == 0 && nFreg <= 2) +{ +if (pTypeDescr->nSize <= 8 && nFreg == 2) +{ +std::memcpy(pAdjust, fret, 4); +std::memcpy(pAdjust + 4, fret + 1, 4); +} +else +{ +std::memcpy(pAdjust, fret, 16); +} +} +else if (nFreg == 1 && nGreg == 1) +{ +