From c759cebef15bdac2ef160065efd116fe6ed540a7 Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Sat, 1 Aug 2026 05:27:13 +0800 Subject: [CodeGen] Build the core MachineIR object model Add arena-owned, address-stable MachineFunction, MachineBasicBlock, and MachineInstr nodes with intrusive layout and instruction lists. Model every required MachineOperand category, reciprocal ties, source state, and immutable per-instruction memory references. Implement physical and virtual register def-use chains whose back-links survive operand vector moves, plus vreg properties, tombstones, live-ins, reserved registers, and atomic CFG updates. Exercise ownership, reallocation, unlink/relink, cross-function rejection, and sanitizer paths. --- backend/include/rcc/CodeGen/MachineCFGUpdater.h | 39 +++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 backend/include/rcc/CodeGen/MachineCFGUpdater.h (limited to 'backend/include/rcc/CodeGen/MachineCFGUpdater.h') diff --git a/backend/include/rcc/CodeGen/MachineCFGUpdater.h b/backend/include/rcc/CodeGen/MachineCFGUpdater.h new file mode 100644 index 0000000..4359538 --- /dev/null +++ b/backend/include/rcc/CodeGen/MachineCFGUpdater.h @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +#ifndef RCC_CODEGEN_MACHINECFGUPDATER_H +#define RCC_CODEGEN_MACHINECFGUPDATER_H + +#include "rcc/CodeGen/MachineIRTypes.h" +#include "rcc/Support/Error.h" + +namespace rcc { + +class MachineBasicBlock; +class MachineFunction; + +class MachineCFGUpdater final { +public: + explicit MachineCFGUpdater(MachineFunction &Function) noexcept : Function(&Function) {} + + [[nodiscard]] Expected + addSuccessor(MachineBasicBlock &From, MachineBasicBlock &To, + BranchProbability Probability = BranchProbability::zero()); + [[nodiscard]] Expected removeSuccessor(MachineBasicBlock &From, MachineBasicBlock &To); + [[nodiscard]] Expected replaceSuccessor(MachineBasicBlock &From, + MachineBasicBlock &OldTarget, + MachineBasicBlock &NewTarget); + [[nodiscard]] Expected updateBranchProbability(MachineBasicBlock &From, + MachineBasicBlock &To, + BranchProbability Probability); + [[nodiscard]] Expected transferSuccessors(MachineBasicBlock &From, MachineBasicBlock &To); + [[nodiscard]] Expected disconnectBlock(MachineBasicBlock &Block); + +private: + [[nodiscard]] Expected verifyOwnership(const MachineBasicBlock &Block) const; + + MachineFunction *Function; +}; + +} // namespace rcc + +#endif // RCC_CODEGEN_MACHINECFGUPDATER_H -- cgit v1.2.3