From 7ca448e47965005b24d107aff6fab4644b8b81b4 Mon Sep 17 00:00:00 2001 From: hev Date: Thu, 18 Sep 2025 10:06:33 +0800 Subject: [LoongArch] Fix MergeBaseOffset for constant pool index operand (#159336) Fixes #159200 --- llvm/lib/CodeGen/MachineOperand.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'llvm/lib/CodeGen/MachineOperand.cpp') diff --git a/llvm/lib/CodeGen/MachineOperand.cpp b/llvm/lib/CodeGen/MachineOperand.cpp index c612f8de..bb9c76f 100644 --- a/llvm/lib/CodeGen/MachineOperand.cpp +++ b/llvm/lib/CodeGen/MachineOperand.cpp @@ -218,6 +218,19 @@ void MachineOperand::ChangeToBA(const BlockAddress *BA, int64_t Offset, setTargetFlags(TargetFlags); } +void MachineOperand::ChangeToCPI(unsigned Idx, int Offset, + unsigned TargetFlags) { + assert((!isReg() || !isTied()) && + "Cannot change a tied operand into a constant pool index"); + + removeRegFromUses(); + + OpKind = MO_ConstantPoolIndex; + setIndex(Idx); + setOffset(Offset); + setTargetFlags(TargetFlags); +} + void MachineOperand::ChangeToMCSymbol(MCSymbol *Sym, unsigned TargetFlags) { assert((!isReg() || !isTied()) && "Cannot change a tied operand into an MCSymbol"); -- cgit v1.1