[llvm] 2218587 - MIPS: Support isLegalICmpImmediate and isLegalAddImmediate (#133400)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 28 08:03:56 PDT 2025
Author: YunQiang Su
Date: 2025-03-28T23:03:52+08:00
New Revision: 2218587b5b131bb8ed57c3e6c7a5c0c589493300
URL: https://github.com/llvm/llvm-project/commit/2218587b5b131bb8ed57c3e6c7a5c0c589493300
DIFF: https://github.com/llvm/llvm-project/commit/2218587b5b131bb8ed57c3e6c7a5c0c589493300.diff
LOG: MIPS: Support isLegalICmpImmediate and isLegalAddImmediate (#133400)
Set it to true only if isInt<16>.
By default implemention defines them to true always. For most cases,
MIPS uses 16bit IMM, and for microMIPS, ICMP and ADDiu have 16bit IMM
flavors.
Added:
Modified:
llvm/lib/Target/Mips/MipsISelLowering.cpp
llvm/lib/Target/Mips/MipsISelLowering.h
Removed:
################################################################################
diff --git a/llvm/lib/Target/Mips/MipsISelLowering.cpp b/llvm/lib/Target/Mips/MipsISelLowering.cpp
index bd65431b475d0..fa8a4704730cf 100644
--- a/llvm/lib/Target/Mips/MipsISelLowering.cpp
+++ b/llvm/lib/Target/Mips/MipsISelLowering.cpp
@@ -4474,6 +4474,14 @@ bool MipsTargetLowering::isFPImmLegal(const APFloat &Imm, EVT VT,
return Imm.isZero();
}
+bool MipsTargetLowering::isLegalICmpImmediate(int64_t Imm) const {
+ return isInt<16>(Imm);
+}
+
+bool MipsTargetLowering::isLegalAddImmediate(int64_t Imm) const {
+ return isInt<16>(Imm);
+}
+
unsigned MipsTargetLowering::getJumpTableEncoding() const {
if (!isPositionIndependent())
return MachineJumpTableInfo::EK_BlockAddress;
diff --git a/llvm/lib/Target/Mips/MipsISelLowering.h b/llvm/lib/Target/Mips/MipsISelLowering.h
index 5bd7b09ded45b..9885ab894d6f2 100644
--- a/llvm/lib/Target/Mips/MipsISelLowering.h
+++ b/llvm/lib/Target/Mips/MipsISelLowering.h
@@ -706,6 +706,9 @@ class TargetRegisterClass;
bool isFPImmLegal(const APFloat &Imm, EVT VT,
bool ForCodeSize) const override;
+ bool isLegalICmpImmediate(int64_t Imm) const override;
+ bool isLegalAddImmediate(int64_t Imm) const override;
+
unsigned getJumpTableEncoding() const override;
SDValue getPICJumpTableRelocBase(SDValue Table,
SelectionDAG &DAG) const override;
More information about the llvm-commits
mailing list