[MIPS] Expose the ZERO register as a constant physical register
authorGuozhi Wei <carrot@google.com>
Tue, 2 Aug 2022 17:04:52 +0000 (17:04 +0000)
committerGuozhi Wei <carrot@google.com>
Tue, 2 Aug 2022 17:04:52 +0000 (17:04 +0000)
The ZERO register should be exposed as a constant physical register through the interface TargetRegisterInfo::isConstantPhysReg.

Differential Revision: https://reviews.llvm.org/D130932

llvm/lib/Target/Mips/MipsRegisterInfo.cpp
llvm/lib/Target/Mips/MipsRegisterInfo.h

index 390ab9d..6aa5610 100644 (file)
@@ -318,3 +318,7 @@ bool MipsRegisterInfo::canRealignStack(const MachineFunction &MF) const {
   // sized objects.
   return MF.getRegInfo().canReserveReg(BP);
 }
+
+bool MipsRegisterInfo::isConstantPhysReg(MCRegister PhysReg) const {
+  return PhysReg == Mips::ZERO_64 || PhysReg == Mips::ZERO;
+}
index 06f214c..1f45f6a 100644 (file)
@@ -69,6 +69,8 @@ public:
   /// Debug information queries.
   Register getFrameRegister(const MachineFunction &MF) const override;
 
+  bool isConstantPhysReg(MCRegister PhysReg) const override;
+
   /// Return GPR register class.
   virtual const TargetRegisterClass *intRegClass(unsigned Size) const = 0;