[llvm] [M68k] implement large code model (PR #106381)
Janis Heims via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 28 07:10:05 PDT 2024
https://github.com/TechnoElf updated https://github.com/llvm/llvm-project/pull/106381
>From 4fc8e38dc6e8e9e0a61be4b6f3a67332489cecfd Mon Sep 17 00:00:00 2001
From: TechnoElf <technoelf at undertheprinter.com>
Date: Wed, 28 Aug 2024 14:13:27 +0200
Subject: [PATCH] [M68k] implement large code model
---
llvm/lib/Target/M68k/M68kSubtarget.cpp | 31 ++++++++++++++++++++++
llvm/lib/Target/M68k/M68kTargetMachine.cpp | 2 --
2 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/Target/M68k/M68kSubtarget.cpp b/llvm/lib/Target/M68k/M68kSubtarget.cpp
index cacdbf559faa2d..00b20966924277 100644
--- a/llvm/lib/Target/M68k/M68kSubtarget.cpp
+++ b/llvm/lib/Target/M68k/M68kSubtarget.cpp
@@ -127,6 +127,24 @@ M68kSubtarget &M68kSubtarget::initializeSubtargetDependencies(
// ---------------------+------------+------------+------------+-------------
// data global big* | pc-rel | @GOTPCREL | absolute | @GOTPCREL
// ---------------------+------------+------------+------------+-------------
+// | Large |
+// +-------------------------+
+// | Static | PIC |
+// ---------------------+------------+------------+
+// branch | pc-rel | pc-rel |
+// ---------------------+------------+------------+
+// call global | @PLT | @PLT |
+// ---------------------+------------+------------+
+// call internal | pc-rel | pc-rel |
+// ---------------------+------------+------------+
+// data local | absolute | @GOTOFF |
+// ---------------------+------------+------------+
+// data local big* | absolute | @GOTOFF |
+// ---------------------+------------+------------+
+// data global | absolute | @GOTPCREL |
+// ---------------------+------------+------------+
+// data global big* | absolute | @GOTPCREL |
+// ---------------------+------------+------------+
//
// * Big data potentially cannot be reached within 16 bit offset and requires
// special handling for old(x00 and x10) CPUs. Normally these symbols go into
@@ -171,6 +189,13 @@ M68kSubtarget::classifyLocalReference(const GlobalValue *GV) const {
return M68kII::MO_ABSOLUTE_ADDRESS;
}
}
+ case CodeModel::Large: {
+ if (isPositionIndependent()) {
+ return M68kII::MO_GOTOFF;
+ } else {
+ return M68kII::MO_ABSOLUTE_ADDRESS;
+ }
+ }
}
}
@@ -212,6 +237,12 @@ unsigned char M68kSubtarget::classifyGlobalReference(const GlobalValue *GV,
return M68kII::MO_ABSOLUTE_ADDRESS;
}
+ case CodeModel::Large: {
+ if (isPositionIndependent())
+ return M68kII::MO_GOTPCREL;
+
+ return M68kII::MO_ABSOLUTE_ADDRESS;
+ }
}
}
diff --git a/llvm/lib/Target/M68k/M68kTargetMachine.cpp b/llvm/lib/Target/M68k/M68kTargetMachine.cpp
index b65de5e177b53e..2248837e6ca61b 100644
--- a/llvm/lib/Target/M68k/M68kTargetMachine.cpp
+++ b/llvm/lib/Target/M68k/M68kTargetMachine.cpp
@@ -87,8 +87,6 @@ CodeModel::Model getEffectiveCodeModel(std::optional<CodeModel::Model> CM,
bool JIT) {
if (!CM) {
return CodeModel::Small;
- } else if (CM == CodeModel::Large) {
- llvm_unreachable("Large code model is not supported");
} else if (CM == CodeModel::Kernel) {
llvm_unreachable("Kernel code model is not implemented yet");
}
More information about the llvm-commits
mailing list