[llvm] [JITLink][AArch32] Add explicit visibility macros to functions needed by unittests (PR #116557)
Thomas Fransham via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 17 13:49:47 PST 2024
https://github.com/fsfod created https://github.com/llvm/llvm-project/pull/116557
Without these there will be missing symbol errors when building JITLinkTests for windows shared library builds with explicit symbol visibility macros are enabled.
This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and LLVM plugins on window.
>From f10915efb16aa69444a670e0e79cdbacc963e122 Mon Sep 17 00:00:00 2001
From: Thomas Fransham <tfransham at gmail.com>
Date: Sat, 16 Nov 2024 20:41:05 +0000
Subject: [PATCH] [JITLink][AArch32] Add explicit visibility macros to
functions needed by unittests
Without these there will be missing symbol errors when building JITLinkTests for
windows shared library builds with explicit symbol visibility macros are enabled.
This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and LLVM plugins on window.
---
.../ExecutionEngine/JITLink/ELF_aarch32.cpp | 5 +--
llvm/lib/ExecutionEngine/JITLink/aarch32.cpp | 25 ++++++++-------
.../ExecutionEngine/JITLink/AArch32Tests.cpp | 31 ++++++++++---------
3 files changed, 32 insertions(+), 29 deletions(-)
diff --git a/llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp
index 866de2cb227c35..b8edf7bfbfae05 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp
@@ -17,6 +17,7 @@
#include "llvm/ExecutionEngine/JITLink/aarch32.h"
#include "llvm/Object/ELF.h"
#include "llvm/Object/ELFObjectFile.h"
+#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/TargetParser/ARMTargetParser.h"
@@ -31,7 +32,7 @@ namespace llvm {
namespace jitlink {
/// Translate from ELF relocation type to JITLink-internal edge kind.
-Expected<aarch32::EdgeKind_aarch32>
+LLVM_ABI Expected<aarch32::EdgeKind_aarch32>
getJITLinkEdgeKind(uint32_t ELFType, const aarch32::ArmConfig &ArmCfg) {
switch (ELFType) {
case ELF::R_ARM_ABS32:
@@ -75,7 +76,7 @@ getJITLinkEdgeKind(uint32_t ELFType, const aarch32::ArmConfig &ArmCfg) {
}
/// Translate from JITLink-internal edge kind back to ELF relocation type.
-Expected<uint32_t> getELFRelocationType(Edge::Kind Kind) {
+LLVM_ABI Expected<uint32_t> getELFRelocationType(Edge::Kind Kind) {
switch (static_cast<aarch32::EdgeKind_aarch32>(Kind)) {
case aarch32::Data_Delta32:
return ELF::R_ARM_REL32;
diff --git a/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp b/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp
index 00be2f57d06640..1412ab2361dd34 100644
--- a/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp
@@ -17,6 +17,7 @@
#include "llvm/ExecutionEngine/JITLink/JITLink.h"
#include "llvm/ExecutionEngine/Orc/Shared/MemoryFlags.h"
#include "llvm/Object/ELFObjectFile.h"
+#include "llvm/Support/Compiler.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MathExtras.h"
@@ -62,7 +63,7 @@ int64_t decodeImmBT4BlT1BlxT2(uint32_t Hi, uint32_t Lo) {
///
/// S:I1:I2:Imm10:Imm11:0 -> [ 00000:S:Imm10, 00:J1:0:J2:Imm11 ]
///
-HalfWords encodeImmBT4BlT1BlxT2_J1J2(int64_t Value) {
+LLVM_ABI HalfWords encodeImmBT4BlT1BlxT2_J1J2(int64_t Value) {
uint32_t S = (Value >> 14) & 0x0400;
uint32_t J1 = (((~(Value >> 10)) ^ (Value >> 11)) & 0x2000);
uint32_t J2 = (((~(Value >> 11)) ^ (Value >> 13)) & 0x0800);
@@ -76,7 +77,7 @@ HalfWords encodeImmBT4BlT1BlxT2_J1J2(int64_t Value) {
///
/// [ 00000:S:Imm10, 00:J1:0:J2:Imm11] -> S:I1:I2:Imm10:Imm11:0
///
-int64_t decodeImmBT4BlT1BlxT2_J1J2(uint32_t Hi, uint32_t Lo) {
+LLVM_ABI int64_t decodeImmBT4BlT1BlxT2_J1J2(uint32_t Hi, uint32_t Lo) {
uint32_t S = Hi & 0x0400;
uint32_t I1 = ~((Lo ^ (Hi << 3)) << 10) & 0x00800000;
uint32_t I2 = ~((Lo ^ (Hi << 1)) << 11) & 0x00400000;
@@ -90,7 +91,7 @@ int64_t decodeImmBT4BlT1BlxT2_J1J2(uint32_t Hi, uint32_t Lo) {
///
/// Imm24:00 -> 00000000:Imm24
///
-uint32_t encodeImmBA1BlA1BlxA2(int64_t Value) {
+LLVM_ABI uint32_t encodeImmBA1BlA1BlxA2(int64_t Value) {
return (Value >> 2) & 0x00ffffff;
}
@@ -99,7 +100,7 @@ uint32_t encodeImmBA1BlA1BlxA2(int64_t Value) {
///
/// 00000000:Imm24 -> Imm24:00
///
-int64_t decodeImmBA1BlA1BlxA2(int64_t Value) {
+LLVM_ABI int64_t decodeImmBA1BlA1BlxA2(int64_t Value) {
return SignExtend64<26>((Value & 0x00ffffff) << 2);
}
@@ -108,7 +109,7 @@ int64_t decodeImmBA1BlA1BlxA2(int64_t Value) {
///
/// Imm4:Imm1:Imm3:Imm8 -> [ 00000:i:000000:Imm4, 0:Imm3:0000:Imm8 ]
///
-HalfWords encodeImmMovtT1MovwT3(uint16_t Value) {
+LLVM_ABI HalfWords encodeImmMovtT1MovwT3(uint16_t Value) {
uint32_t Imm4 = (Value >> 12) & 0x0f;
uint32_t Imm1 = (Value >> 11) & 0x01;
uint32_t Imm3 = (Value >> 8) & 0x07;
@@ -121,7 +122,7 @@ HalfWords encodeImmMovtT1MovwT3(uint16_t Value) {
///
/// [ 00000:i:000000:Imm4, 0:Imm3:0000:Imm8 ] -> Imm4:Imm1:Imm3:Imm8
///
-uint16_t decodeImmMovtT1MovwT3(uint32_t Hi, uint32_t Lo) {
+LLVM_ABI uint16_t decodeImmMovtT1MovwT3(uint32_t Hi, uint32_t Lo) {
uint32_t Imm4 = Hi & 0x0f;
uint32_t Imm1 = (Hi >> 10) & 0x01;
uint32_t Imm3 = (Lo >> 12) & 0x07;
@@ -135,7 +136,7 @@ uint16_t decodeImmMovtT1MovwT3(uint32_t Hi, uint32_t Lo) {
///
/// Rd4 -> [0000000000000000, 0000:Rd4:00000000]
///
-HalfWords encodeRegMovtT1MovwT3(int64_t Value) {
+LLVM_ABI HalfWords encodeRegMovtT1MovwT3(int64_t Value) {
uint32_t Rd4 = (Value & 0x0f) << 8;
return HalfWords{0, Rd4};
}
@@ -144,7 +145,7 @@ HalfWords encodeRegMovtT1MovwT3(int64_t Value) {
///
/// [0000000000000000, 0000:Rd4:00000000] -> Rd4
///
-int64_t decodeRegMovtT1MovwT3(uint32_t Hi, uint32_t Lo) {
+LLVM_ABI int64_t decodeRegMovtT1MovwT3(uint32_t Hi, uint32_t Lo) {
uint32_t Rd4 = (Lo >> 8) & 0x0f;
return Rd4;
}
@@ -154,7 +155,7 @@ int64_t decodeRegMovtT1MovwT3(uint32_t Hi, uint32_t Lo) {
///
/// Imm4:Imm12 -> 000000000000:Imm4:0000:Imm12
///
-uint32_t encodeImmMovtA1MovwA2(uint16_t Value) {
+LLVM_ABI uint32_t encodeImmMovtA1MovwA2(uint16_t Value) {
uint32_t Imm4 = (Value >> 12) & 0x0f;
uint32_t Imm12 = Value & 0x0fff;
return (Imm4 << 16) | Imm12;
@@ -165,7 +166,7 @@ uint32_t encodeImmMovtA1MovwA2(uint16_t Value) {
///
/// 000000000000:Imm4:0000:Imm12 -> Imm4:Imm12
///
-uint16_t decodeImmMovtA1MovwA2(uint64_t Value) {
+LLVM_ABI uint16_t decodeImmMovtA1MovwA2(uint64_t Value) {
uint32_t Imm4 = (Value >> 16) & 0x0f;
uint32_t Imm12 = Value & 0x0fff;
return (Imm4 << 12) | Imm12;
@@ -176,7 +177,7 @@ uint16_t decodeImmMovtA1MovwA2(uint64_t Value) {
///
/// Rd4 -> 0000000000000000:Rd4:000000000000
///
-uint32_t encodeRegMovtA1MovwA2(int64_t Value) {
+LLVM_ABI uint32_t encodeRegMovtA1MovwA2(int64_t Value) {
uint32_t Rd4 = (Value & 0x00000f) << 12;
return Rd4;
}
@@ -186,7 +187,7 @@ uint32_t encodeRegMovtA1MovwA2(int64_t Value) {
///
/// 0000000000000000:Rd4:000000000000 -> Rd4
///
-int64_t decodeRegMovtA1MovwA2(uint64_t Value) {
+LLVM_ABI int64_t decodeRegMovtA1MovwA2(uint64_t Value) {
uint32_t Rd4 = (Value >> 12) & 0x00000f;
return Rd4;
}
diff --git a/llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp b/llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp
index b1890d884d1735..dfabb4ab761808 100644
--- a/llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp
+++ b/llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp
@@ -8,6 +8,7 @@
#include <llvm/BinaryFormat/ELF.h>
#include <llvm/ExecutionEngine/JITLink/aarch32.h>
+#include <llvm/Support/Compiler.h>
#include "gtest/gtest.h"
@@ -96,21 +97,21 @@ namespace llvm {
namespace jitlink {
namespace aarch32 {
-HalfWords encodeImmBT4BlT1BlxT2(int64_t Value);
-HalfWords encodeImmBT4BlT1BlxT2_J1J2(int64_t Value);
-uint32_t encodeImmBA1BlA1BlxA2(int64_t Value);
-HalfWords encodeImmMovtT1MovwT3(uint16_t Value);
-HalfWords encodeRegMovtT1MovwT3(int64_t Value);
-uint32_t encodeImmMovtA1MovwA2(uint16_t Value);
-uint32_t encodeRegMovtA1MovwA2(int64_t Value);
-
-int64_t decodeImmBT4BlT1BlxT2(uint32_t Hi, uint32_t Lo);
-int64_t decodeImmBT4BlT1BlxT2_J1J2(uint32_t Hi, uint32_t Lo);
-int64_t decodeImmBA1BlA1BlxA2(int64_t Value);
-uint16_t decodeImmMovtT1MovwT3(uint32_t Hi, uint32_t Lo);
-int64_t decodeRegMovtT1MovwT3(uint32_t Hi, uint32_t Lo);
-uint16_t decodeImmMovtA1MovwA2(uint64_t Value);
-int64_t decodeRegMovtA1MovwA2(uint64_t Value);
+LLVM_ABI HalfWords encodeImmBT4BlT1BlxT2(int64_t Value);
+LLVM_ABI HalfWords encodeImmBT4BlT1BlxT2_J1J2(int64_t Value);
+LLVM_ABI uint32_t encodeImmBA1BlA1BlxA2(int64_t Value);
+LLVM_ABI HalfWords encodeImmMovtT1MovwT3(uint16_t Value);
+LLVM_ABI HalfWords encodeRegMovtT1MovwT3(int64_t Value);
+LLVM_ABI uint32_t encodeImmMovtA1MovwA2(uint16_t Value);
+LLVM_ABI uint32_t encodeRegMovtA1MovwA2(int64_t Value);
+
+LLVM_ABI int64_t decodeImmBT4BlT1BlxT2(uint32_t Hi, uint32_t Lo);
+LLVM_ABI int64_t decodeImmBT4BlT1BlxT2_J1J2(uint32_t Hi, uint32_t Lo);
+LLVM_ABI int64_t decodeImmBA1BlA1BlxA2(int64_t Value);
+LLVM_ABI uint16_t decodeImmMovtT1MovwT3(uint32_t Hi, uint32_t Lo);
+LLVM_ABI int64_t decodeRegMovtT1MovwT3(uint32_t Hi, uint32_t Lo);
+LLVM_ABI uint16_t decodeImmMovtA1MovwA2(uint64_t Value);
+LLVM_ABI int64_t decodeRegMovtA1MovwA2(uint64_t Value);
} // namespace aarch32
} // namespace jitlink
More information about the llvm-commits
mailing list