From 97e5fbaa55b4672db36123c2425d05a4738452ab Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Fri, 14 Aug 2026 20:35:54 +0800 Subject: [GlobalISel] Match LLVM legalization value tracking --- backend/include/rcc/CodeGen/MachineIRBuilder.h | 51 ++++++++++++++++++-------- 1 file changed, 36 insertions(+), 15 deletions(-) (limited to 'backend/include/rcc/CodeGen/MachineIRBuilder.h') diff --git a/backend/include/rcc/CodeGen/MachineIRBuilder.h b/backend/include/rcc/CodeGen/MachineIRBuilder.h index 01cd648..70a313a 100644 --- a/backend/include/rcc/CodeGen/MachineIRBuilder.h +++ b/backend/include/rcc/CodeGen/MachineIRBuilder.h @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -178,17 +179,20 @@ public: } [[nodiscard]] Expected buildInstr(Opcode InstructionOpcode) const; + [[nodiscard]] Expected buildInstr(Opcode InstructionOpcode, + std::initializer_list Destinations, + std::initializer_list Sources) const; [[nodiscard]] Expected buildTrunc(Register Destination, Register Source) const; [[nodiscard]] Expected buildCopy(Register Destination, Register Source) const; [[nodiscard]] Expected buildImplicitDef(Register Destination) const; - [[nodiscard]] Expected buildAnyExt(Register Destination, - Register Source) const; + [[nodiscard]] Expected buildAnyExt(Register Destination, Register Source) const; [[nodiscard]] Expected buildZExt(Register Destination, Register Source) const; [[nodiscard]] Expected buildSExt(Register Destination, Register Source) const; + [[nodiscard]] Expected buildUndef(Register Destination) const; [[nodiscard]] Expected buildAnyExtOrTrunc(Register Destination, Register Source) const; [[nodiscard]] Expected buildSExtOrTrunc(Register Destination, - Register Source) const; + Register Source) const; [[nodiscard]] Expected buildConstant(Register Destination, APInt Value) const; [[nodiscard]] Expected buildConstant(Register Destination, std::int64_t Value) const; @@ -196,23 +200,40 @@ public: std::uint32_t Width) const; [[nodiscard]] Expected buildAnd(Register Destination, Register Left, Register Right) const; - [[nodiscard]] Expected buildMergeValues( - Register Destination, const std::vector &Sources) const; - [[nodiscard]] Expected buildUnmergeValues( - const std::vector &Destinations, Register Source) const; + [[nodiscard]] Expected buildOr(Register Destination, Register Left, + Register Right) const; + [[nodiscard]] Expected buildAdd(Register Destination, Register Left, + Register Right) const; + [[nodiscard]] Expected buildSub(Register Destination, Register Left, + Register Right) const; + [[nodiscard]] Expected buildShl(Register Destination, Register Left, + Register Right) const; + [[nodiscard]] Expected buildLShr(Register Destination, Register Left, + Register Right) const; + [[nodiscard]] Expected buildAShr(Register Destination, Register Left, + Register Right) const; + [[nodiscard]] Expected buildPtrToInt(Register Destination, Register Source) const; + [[nodiscard]] Expected buildIntToPtr(Register Destination, Register Source) const; + [[nodiscard]] Expected buildICmp(IntegerPredicate Predicate, Register Destination, + Register Left, Register Right) const; + [[nodiscard]] Expected + buildMergeLikeInstr(Register Destination, const std::vector &Sources) const; + [[nodiscard]] Expected + buildMergeValues(Register Destination, const std::vector &Sources) const; + [[nodiscard]] Expected + buildUnmergeValues(const std::vector &Destinations, Register Source) const; [[nodiscard]] Expected buildExtract(Register Destination, Register Source, std::uint64_t Offset) const; + [[nodiscard]] Expected buildInsert(Register Destination, Register Source, + Register Inserted, std::uint64_t Offset) const; private: - [[nodiscard]] Expected buildUnary(Opcode InstructionOpcode, - Register Destination, + [[nodiscard]] Expected buildUnary(Opcode InstructionOpcode, Register Destination, Register Source) const; - [[nodiscard]] Expected buildBinary(Opcode InstructionOpcode, - Register Destination, Register Left, - Register Right) const; - [[nodiscard]] Expected buildExtOrTrunc(Opcode ExtensionOpcode, - Register Destination, - Register Source) const; + [[nodiscard]] Expected buildBinary(Opcode InstructionOpcode, Register Destination, + Register Left, Register Right) const; + [[nodiscard]] Expected + buildExtOrTrunc(Opcode ExtensionOpcode, Register Destination, Register Source) const; [[nodiscard]] Expected registerType(Register Reg) const; [[nodiscard]] Expected validateBlock(const MachineBasicBlock &Block) const; [[nodiscard]] Expected validateInstruction(const MachineInstr &Instruction) const; -- cgit v1.2.3