[llvm] e09a1dc - [SystemZ][z/OS] Add GOFF Support to the DataLayout
Anirudh Prasad via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 24 11:09:08 PDT 2021
Author: Anirudh Prasad
Date: 2021-09-24T14:09:01-04:00
New Revision: e09a1dc47515d27ba5ca572a225208bb0d79fb3f
URL: https://github.com/llvm/llvm-project/commit/e09a1dc47515d27ba5ca572a225208bb0d79fb3f
DIFF: https://github.com/llvm/llvm-project/commit/e09a1dc47515d27ba5ca572a225208bb0d79fb3f.diff
LOG: [SystemZ][z/OS] Add GOFF Support to the DataLayout
- This patch adds in the GOFF mangling support to the LLVM data layout string. A corresponding additional line has been added into the data layout section in the language reference documentation.
- Furthermore, this patch also sets the right data layout string for the z/OS target in the SystemZ backend.
Reviewed By: uweigand, Kai, abhina.sreeskantharajan, MaskRay
Differential Revision: https://reviews.llvm.org/D109362
Added:
Modified:
clang/lib/Basic/Targets/SystemZ.h
clang/test/CodeGen/target-data.c
llvm/docs/LangRef.rst
llvm/include/llvm/IR/DataLayout.h
llvm/lib/IR/DataLayout.cpp
llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
llvm/unittests/IR/ManglerTest.cpp
Removed:
################################################################################
diff --git a/clang/lib/Basic/Targets/SystemZ.h b/clang/lib/Basic/Targets/SystemZ.h
index b749c3f75d188..d3e3ed50dd477 100644
--- a/clang/lib/Basic/Targets/SystemZ.h
+++ b/clang/lib/Basic/Targets/SystemZ.h
@@ -46,7 +46,17 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo {
LongDoubleFormat = &llvm::APFloat::IEEEquad();
DefaultAlignForAttributeAligned = 64;
MinGlobalAlign = 16;
- resetDataLayout("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64");
+ if (Triple.isOSzOS()) {
+ // All vector types are default aligned on an 8-byte boundary, even if the
+ // vector facility is not available. That is
diff erent from Linux.
+ MaxVectorAlign = 64;
+ // Compared to Linux/ELF, the data layout
diff ers only in some details:
+ // - name mangling is GOFF
+ // - 128 bit vector types are 64 bit aligned
+ resetDataLayout(
+ "E-m:l-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64");
+ } else
+ resetDataLayout("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64");
MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
HasStrictFP = true;
}
@@ -129,7 +139,7 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo {
HasVector &= !SoftFloat;
// If we use the vector ABI, vector types are 64-bit aligned.
- if (HasVector) {
+ if (HasVector && !getTriple().isOSzOS()) {
MaxVectorAlign = 64;
resetDataLayout("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64"
"-v128:64-a:8:16-n32:64");
diff --git a/clang/test/CodeGen/target-data.c b/clang/test/CodeGen/target-data.c
index 10f35f54b1420..0749493d788f3 100644
--- a/clang/test/CodeGen/target-data.c
+++ b/clang/test/CodeGen/target-data.c
@@ -219,40 +219,24 @@
// RUN: FileCheck %s -check-prefix=HEXAGON
// HEXAGON: target datalayout = "e-m:e-p:32:32:32-a:0-n16:32-i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048"
-// RUN: %clang_cc1 -triple s390x-unknown -o - -emit-llvm %s | \
-// RUN: FileCheck %s -check-prefix=SYSTEMZ
// RUN: %clang_cc1 -triple s390x-unknown -target-cpu z10 -o - -emit-llvm %s | \
// RUN: FileCheck %s -check-prefix=SYSTEMZ
-// RUN: %clang_cc1 -triple s390x-unknown -target-cpu arch8 -o - -emit-llvm %s | \
-// RUN: FileCheck %s -check-prefix=SYSTEMZ
-// RUN: %clang_cc1 -triple s390x-unknown -target-cpu z196 -o - -emit-llvm %s | \
-// RUN: FileCheck %s -check-prefix=SYSTEMZ
-// RUN: %clang_cc1 -triple s390x-unknown -target-cpu arch9 -o - -emit-llvm %s | \
-// RUN: FileCheck %s -check-prefix=SYSTEMZ
-// RUN: %clang_cc1 -triple s390x-unknown -target-cpu zEC12 -o - -emit-llvm %s | \
-// RUN: FileCheck %s -check-prefix=SYSTEMZ
-// RUN: %clang_cc1 -triple s390x-unknown -target-cpu arch10 -o - -emit-llvm %s | \
-// RUN: FileCheck %s -check-prefix=SYSTEMZ
// RUN: %clang_cc1 -triple s390x-unknown -target-cpu z13 -target-feature +soft-float -o - -emit-llvm %s | \
// RUN: FileCheck %s -check-prefix=SYSTEMZ
// SYSTEMZ: target datalayout = "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64"
// RUN: %clang_cc1 -triple s390x-unknown -target-cpu z13 -o - -emit-llvm %s | \
// RUN: FileCheck %s -check-prefix=SYSTEMZ-VECTOR
-// RUN: %clang_cc1 -triple s390x-unknown -target-cpu arch11 -o - -emit-llvm %s | \
-// RUN: FileCheck %s -check-prefix=SYSTEMZ-VECTOR
-// RUN: %clang_cc1 -triple s390x-unknown -target-cpu z14 -o - -emit-llvm %s | \
-// RUN: FileCheck %s -check-prefix=SYSTEMZ-VECTOR
-// RUN: %clang_cc1 -triple s390x-unknown -target-cpu arch12 -o - -emit-llvm %s | \
-// RUN: FileCheck %s -check-prefix=SYSTEMZ-VECTOR
-// RUN: %clang_cc1 -triple s390x-unknown -target-cpu z15 -o - -emit-llvm %s | \
-// RUN: FileCheck %s -check-prefix=SYSTEMZ-VECTOR
-// RUN: %clang_cc1 -triple s390x-unknown -target-cpu arch13 -o - -emit-llvm %s | \
-// RUN: FileCheck %s -check-prefix=SYSTEMZ-VECTOR
-// RUN: %clang_cc1 -triple s390x-unknown -target-cpu arch14 -o - -emit-llvm %s | \
-// RUN: FileCheck %s -check-prefix=SYSTEMZ-VECTOR
// SYSTEMZ-VECTOR: target datalayout = "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64"
+// RUN: %clang_cc1 -triple s390x-none-zos -target-cpu z10 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=ZOS
+// RUN: %clang_cc1 -triple s390x-none-zos -target-cpu z13 -target-feature +soft-float -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=ZOS
+// RUN: %clang_cc1 -triple s390x-none-zos -target-cpu z13 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=ZOS
+// ZOS: target datalayout = "E-m:l-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64"
+
// RUN: %clang_cc1 -triple msp430-unknown -o - -emit-llvm %s | \
// RUN: FileCheck %s -check-prefix=MSP430
// MSP430: target datalayout = "e-m:e-p:16:16-i32:16-i64:16-f32:16-f64:16-a:8-n8:16-S16"
diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 765f17edb2bac..8240b8d3597a1 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -2605,6 +2605,7 @@ as follows:
options are
* ``e``: ELF mangling: Private symbols get a ``.L`` prefix.
+ * ``l``: GOFF mangling: Private symbols get a ``@`` prefix.
* ``m``: Mips mangling: Private symbols get a ``$`` prefix.
* ``o``: Mach-O mangling: Private symbols get ``L`` prefix. Other
symbols get a ``_`` prefix.
diff --git a/llvm/include/llvm/IR/DataLayout.h b/llvm/include/llvm/IR/DataLayout.h
index ec618bcaad441..8c37aebc2c4e1 100644
--- a/llvm/include/llvm/IR/DataLayout.h
+++ b/llvm/include/llvm/IR/DataLayout.h
@@ -135,6 +135,7 @@ class DataLayout {
MM_MachO,
MM_WinCOFF,
MM_WinCOFFX86,
+ MM_GOFF,
MM_Mips,
MM_XCOFF
};
@@ -316,6 +317,7 @@ class DataLayout {
switch (ManglingMode) {
case MM_None:
case MM_ELF:
+ case MM_GOFF:
case MM_Mips:
case MM_WinCOFF:
case MM_XCOFF:
@@ -334,6 +336,8 @@ class DataLayout {
case MM_ELF:
case MM_WinCOFF:
return ".L";
+ case MM_GOFF:
+ return "@";
case MM_Mips:
return "$";
case MM_MachO:
diff --git a/llvm/lib/IR/DataLayout.cpp b/llvm/lib/IR/DataLayout.cpp
index 4f6140e636288..5de47b8625b37 100644
--- a/llvm/lib/IR/DataLayout.cpp
+++ b/llvm/lib/IR/DataLayout.cpp
@@ -151,6 +151,8 @@ PointerAlignElem::operator==(const PointerAlignElem &rhs) const {
//===----------------------------------------------------------------------===//
const char *DataLayout::getManglingComponent(const Triple &T) {
+ if (T.isOSBinFormatGOFF())
+ return "-m:l";
if (T.isOSBinFormatMachO())
return "-m:o";
if (T.isOSWindows() && T.isOSBinFormatCOFF())
@@ -500,6 +502,9 @@ Error DataLayout::parseSpecifier(StringRef Desc) {
case 'e':
ManglingMode = MM_ELF;
break;
+ case 'l':
+ ManglingMode = MM_GOFF;
+ break;
case 'o':
ManglingMode = MM_MachO;
break;
diff --git a/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp b/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
index a886f9b9d8149..0a565d33b1867 100644
--- a/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
@@ -84,8 +84,9 @@ static std::string computeDataLayout(const Triple &TT, StringRef CPU,
// 128-bit floats are aligned only to 64 bits.
Ret += "-f128:64";
- // When using the vector ABI, 128-bit vectors are also aligned to 64 bits.
- if (VectorABI)
+ // When using the vector ABI on Linux, 128-bit vectors are also aligned to 64
+ // bits. On z/OS, vector types are always aligned to 64 bits.
+ if (VectorABI || TT.isOSzOS())
Ret += "-v128:64";
// We prefer 16 bits of aligned for all globals; see above.
diff --git a/llvm/unittests/IR/ManglerTest.cpp b/llvm/unittests/IR/ManglerTest.cpp
index 641e34628f5e0..8ad95a83b6928 100644
--- a/llvm/unittests/IR/ManglerTest.cpp
+++ b/llvm/unittests/IR/ManglerTest.cpp
@@ -156,4 +156,22 @@ TEST(ManglerTest, XCOFF) {
"L..foo");
}
+TEST(ManglerTest, GOFF) {
+ LLVMContext Ctx;
+ DataLayout DL("m:l"); // GOFF
+ Module Mod("test", Ctx);
+ Mod.setDataLayout(DL);
+ Mangler Mang;
+
+ EXPECT_EQ(mangleStr("foo", Mang, DL), "foo");
+ EXPECT_EQ(mangleStr("\01foo", Mang, DL), "foo");
+ EXPECT_EQ(mangleStr("?foo", Mang, DL), "?foo");
+ EXPECT_EQ(mangleFunc("foo", llvm::GlobalValue::ExternalLinkage,
+ llvm::CallingConv::C, Mod, Mang),
+ "foo");
+ EXPECT_EQ(mangleFunc("foo", llvm::GlobalValue::PrivateLinkage,
+ llvm::CallingConv::C, Mod, Mang),
+ "@foo");
+}
+
} // end anonymous namespace
More information about the llvm-commits
mailing list