From 165082bbec7097bc8385e10a2a6fcb6bdf7be75a Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Wed, 12 Aug 2026 03:36:43 +0800 Subject: [CodeGen] Allow dynamic implicit operands on copies --- backend/lib/CodeGen/GenericOpcodes.cpp | 2 +- backend/unittests/CodeGen/GenericOpcodesTest.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/lib/CodeGen/GenericOpcodes.cpp b/backend/lib/CodeGen/GenericOpcodes.cpp index 73c56f6..0cfd83f 100644 --- a/backend/lib/CodeGen/GenericOpcodes.cpp +++ b/backend/lib/CodeGen/GenericOpcodes.cpp @@ -1028,7 +1028,7 @@ void configureCoreOpcodes(DescriptorRegistry &Registry) { {TransferDef, repeated(TransferUse), repeated(immediate())}, 1, {}, true, 1, false, PseudoOwner::TwoAddressRewrite, PipelineStage::TiedOpsRewritten); Registry.configure({GO::COPY}, {TransferDef, TransferUse}, 1, {}, false, 0, false, - PseudoOwner::PostRAExpansion, PipelineStage::PostRAFinalized); + PseudoOwner::PostRAExpansion, PipelineStage::PostRAFinalized, true); Registry.configure({GO::COPY_LANEMASK}, {RegDef, RegUse, kind(MachineOperand::Kind::LaneMask)}, 1, {}, false, 0, false, PseudoOwner::PostRAExpansion, PipelineStage::PostRAFinalized); diff --git a/backend/unittests/CodeGen/GenericOpcodesTest.cpp b/backend/unittests/CodeGen/GenericOpcodesTest.cpp index 26f7442..6240c6d 100644 --- a/backend/unittests/CodeGen/GenericOpcodesTest.cpp +++ b/backend/unittests/CodeGen/GenericOpcodesTest.cpp @@ -263,11 +263,16 @@ void testCoreOpcodeContracts(TestContext &Context) { const auto InlineAsmBr = std::ranges::find_if(Descriptors, [](const auto &Descriptor) { return Descriptor.InstructionOpcode == rcc::opcode(rcc::GenericOpcode::INLINEASM_BR); }); + const auto Copy = std::ranges::find_if(Descriptors, [](const auto &Descriptor) { + return Descriptor.InstructionOpcode == rcc::opcode(rcc::GenericOpcode::COPY); + }); Context.expect(InlineAsm != Descriptors.end() && InlineAsmBr != Descriptors.end() && !InlineAsm->Flags.has(rcc::InstructionFlag::HasSideEffects) && InlineAsmBr->Flags.has(rcc::InstructionFlag::HasSideEffects), "INLINEASM_BR must be intrinsically side-effecting while INLINEASM uses its " "operand flags"); + Context.expect(Copy != Descriptors.end() && Copy->AllowExtraImplicitOperands, + "COPY must allow dynamic implicit super-register operands"); } void testShapesAndTypes(TestContext &Context) { -- cgit v1.2.3