[llvm] [Cygwin] Cygwin X86ISelDAGToDAG.cpp (PR #76284)
εΎζζ Xu Chiheng via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 4 03:28:55 PST 2024
https://github.com/xu-chiheng updated https://github.com/llvm/llvm-project/pull/76284
>From 25497274dfddcaeddbd85ac5fe0da59dd6f256a6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
<chiheng.xu at gmail.com>
Date: Thu, 4 Jan 2024 16:12:05 +0800
Subject: [PATCH 1/7] 1
---
llvm/lib/Target/X86/X86ISelDAGToDAG.cpp | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
index 77a997588c4fee..c478f1c3fd30c8 100644
--- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
+++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
@@ -2944,6 +2944,18 @@ bool X86DAGToDAGISel::selectMOV64Imm32(SDValue N, SDValue &Imm) {
return false;
Imm = N;
+ if (Subtarget->isTargetWindowsCygwin() && Subtarget->is64Bit()) {
+ if (N->getOpcode() != ISD::TargetGlobalAddress)
+ return TM.getCodeModel() == CodeModel::Small;
+
+ std::optional<ConstantRange> CR =
+ cast<GlobalAddressSDNode>(N)->getGlobal()->getAbsoluteSymbolRange();
+ if (!CR)
+ return TM.getCodeModel() == CodeModel::Small;
+
+ return CR->getUnsignedMax().ult(1ull << 32);
+ }
+
// Small/medium code model can reference non-TargetGlobalAddress objects with
// 32 bit constants.
if (N->getOpcode() != ISD::TargetGlobalAddress) {
>From 88f721e19b59be2881fbc85c75daa47559ef508d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
<chiheng.xu at gmail.com>
Date: Thu, 4 Jan 2024 18:18:50 +0800
Subject: [PATCH 2/7] 1
---
llvm/lib/Target/X86/X86ISelDAGToDAG.cpp | 24 ++++++------------------
1 file changed, 6 insertions(+), 18 deletions(-)
diff --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
index c478f1c3fd30c8..66acb07f0a2826 100644
--- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
+++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
@@ -2944,30 +2944,18 @@ bool X86DAGToDAGISel::selectMOV64Imm32(SDValue N, SDValue &Imm) {
return false;
Imm = N;
- if (Subtarget->isTargetWindowsCygwin() && Subtarget->is64Bit()) {
- if (N->getOpcode() != ISD::TargetGlobalAddress)
- return TM.getCodeModel() == CodeModel::Small;
-
- std::optional<ConstantRange> CR =
- cast<GlobalAddressSDNode>(N)->getGlobal()->getAbsoluteSymbolRange();
- if (!CR)
- return TM.getCodeModel() == CodeModel::Small;
-
- return CR->getUnsignedMax().ult(1ull << 32);
- }
-
// Small/medium code model can reference non-TargetGlobalAddress objects with
// 32 bit constants.
if (N->getOpcode() != ISD::TargetGlobalAddress) {
return TM.getCodeModel() == CodeModel::Small ||
- TM.getCodeModel() == CodeModel::Medium;
+ (!(Subtarget->isTargetWindowsCygwin() && Subtarget->is64Bit()) && TM.getCodeModel() == CodeModel::Medium );
}
+ std::optional<ConstantRange> CR =
+ cast<GlobalAddressSDNode>(N)->getGlobal()->getAbsoluteSymbolRange();
+ if (!CR)
+ return TM.getCodeModel() == CodeModel::Small;
- const GlobalValue *GV = cast<GlobalAddressSDNode>(N)->getGlobal();
- if (std::optional<ConstantRange> CR = GV->getAbsoluteSymbolRange())
- return CR->getUnsignedMax().ult(1ull << 32);
-
- return !TM.isLargeGlobalValue(GV);
+ return CR->getUnsignedMax().ult(1ull << 32);
}
bool X86DAGToDAGISel::selectLEA64_32Addr(SDValue N, SDValue &Base,
>From aa5679e04a344f20ece425b97f5ea51300bde16c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
<chiheng.xu at gmail.com>
Date: Thu, 4 Jan 2024 18:24:30 +0800
Subject: [PATCH 3/7] 1
---
llvm/lib/Target/X86/X86ISelDAGToDAG.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
index 66acb07f0a2826..0384e541ad2c07 100644
--- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
+++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
@@ -2948,7 +2948,8 @@ bool X86DAGToDAGISel::selectMOV64Imm32(SDValue N, SDValue &Imm) {
// 32 bit constants.
if (N->getOpcode() != ISD::TargetGlobalAddress) {
return TM.getCodeModel() == CodeModel::Small ||
- (!(Subtarget->isTargetWindowsCygwin() && Subtarget->is64Bit()) && TM.getCodeModel() == CodeModel::Medium );
+ (!(Subtarget->isTargetWindowsCygwin() && Subtarget->is64Bit()) &&
+ TM.getCodeModel() == CodeModel::Medium);
}
std::optional<ConstantRange> CR =
cast<GlobalAddressSDNode>(N)->getGlobal()->getAbsoluteSymbolRange();
>From 02e52e8fe0299e30bfe0ff52f5de033e52eabfc0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
<chiheng.xu at gmail.com>
Date: Thu, 4 Jan 2024 18:45:20 +0800
Subject: [PATCH 4/7] 1
---
llvm/lib/Target/X86/X86ISelDAGToDAG.cpp | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
index 0384e541ad2c07..b7fb3f3a214982 100644
--- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
+++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
@@ -2951,12 +2951,19 @@ bool X86DAGToDAGISel::selectMOV64Imm32(SDValue N, SDValue &Imm) {
(!(Subtarget->isTargetWindowsCygwin() && Subtarget->is64Bit()) &&
TM.getCodeModel() == CodeModel::Medium);
}
+#if 0
std::optional<ConstantRange> CR =
cast<GlobalAddressSDNode>(N)->getGlobal()->getAbsoluteSymbolRange();
if (!CR)
return TM.getCodeModel() == CodeModel::Small;
return CR->getUnsignedMax().ult(1ull << 32);
+#endif
+ const GlobalValue *GV = cast<GlobalAddressSDNode>(N)->getGlobal();
+ if (std::optional<ConstantRange> CR = GV->getAbsoluteSymbolRange())
+ return CR->getUnsignedMax().ult(1ull << 32);
+
+ return !TM.isLargeGlobalValue(GV);
}
bool X86DAGToDAGISel::selectLEA64_32Addr(SDValue N, SDValue &Base,
>From 3151c9153e7f36ed0d5c1f3806486a9ed6edcbee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
<chiheng.xu at gmail.com>
Date: Thu, 4 Jan 2024 19:05:05 +0800
Subject: [PATCH 5/7] 1
---
llvm/lib/Target/X86/X86ISelDAGToDAG.cpp | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
index b7fb3f3a214982..fa20767441959c 100644
--- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
+++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
@@ -2962,8 +2962,10 @@ bool X86DAGToDAGISel::selectMOV64Imm32(SDValue N, SDValue &Imm) {
const GlobalValue *GV = cast<GlobalAddressSDNode>(N)->getGlobal();
if (std::optional<ConstantRange> CR = GV->getAbsoluteSymbolRange())
return CR->getUnsignedMax().ult(1ull << 32);
-
- return !TM.isLargeGlobalValue(GV);
+ else if (Subtarget->isTargetWindowsCygwin() && Subtarget->is64Bit())
+ return TM.getCodeModel() == CodeModel::Small;
+ else
+ return !TM.isLargeGlobalValue(GV);
}
bool X86DAGToDAGISel::selectLEA64_32Addr(SDValue N, SDValue &Base,
>From 13bfd58ef619f6c4112e4ea879abbcf639372a1a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
<chiheng.xu at gmail.com>
Date: Thu, 4 Jan 2024 19:23:27 +0800
Subject: [PATCH 6/7] 1
---
llvm/lib/Target/X86/X86ISelDAGToDAG.cpp | 8 --------
1 file changed, 8 deletions(-)
diff --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
index fa20767441959c..3af004532d61f4 100644
--- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
+++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
@@ -2951,14 +2951,6 @@ bool X86DAGToDAGISel::selectMOV64Imm32(SDValue N, SDValue &Imm) {
(!(Subtarget->isTargetWindowsCygwin() && Subtarget->is64Bit()) &&
TM.getCodeModel() == CodeModel::Medium);
}
-#if 0
- std::optional<ConstantRange> CR =
- cast<GlobalAddressSDNode>(N)->getGlobal()->getAbsoluteSymbolRange();
- if (!CR)
- return TM.getCodeModel() == CodeModel::Small;
-
- return CR->getUnsignedMax().ult(1ull << 32);
-#endif
const GlobalValue *GV = cast<GlobalAddressSDNode>(N)->getGlobal();
if (std::optional<ConstantRange> CR = GV->getAbsoluteSymbolRange())
return CR->getUnsignedMax().ult(1ull << 32);
>From d68d9e95c12efc65c7bea323bc2a5ff3451a9ce3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
<chiheng.xu at gmail.com>
Date: Thu, 4 Jan 2024 19:28:31 +0800
Subject: [PATCH 7/7] 1
---
llvm/lib/Target/X86/X86ISelDAGToDAG.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
index 3af004532d61f4..fc3cde7fba5368 100644
--- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
+++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
@@ -2951,6 +2951,7 @@ bool X86DAGToDAGISel::selectMOV64Imm32(SDValue N, SDValue &Imm) {
(!(Subtarget->isTargetWindowsCygwin() && Subtarget->is64Bit()) &&
TM.getCodeModel() == CodeModel::Medium);
}
+
const GlobalValue *GV = cast<GlobalAddressSDNode>(N)->getGlobal();
if (std::optional<ConstantRange> CR = GV->getAbsoluteSymbolRange())
return CR->getUnsignedMax().ult(1ull << 32);
More information about the llvm-commits
mailing list