aboutsummaryrefslogtreecommitdiff
path: root/backend/include
diff options
context:
space:
mode:
Diffstat (limited to 'backend/include')
-rw-r--r--backend/include/rcc/CodeGen/MachineFunctionCloner.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/backend/include/rcc/CodeGen/MachineFunctionCloner.h b/backend/include/rcc/CodeGen/MachineFunctionCloner.h
new file mode 100644
index 0000000..3abdf78
--- /dev/null
+++ b/backend/include/rcc/CodeGen/MachineFunctionCloner.h
@@ -0,0 +1,49 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#ifndef RCC_CODEGEN_MACHINEFUNCTIONCLONER_H
+#define RCC_CODEGEN_MACHINEFUNCTIONCLONER_H
+
+#include "rcc/CodeGen/MachineIRTypes.h"
+#include "rcc/CodeGen/Register.h"
+#include "rcc/CodeGen/StableID.h"
+#include "rcc/Support/Error.h"
+
+#include <memory>
+#include <optional>
+#include <string>
+#include <unordered_map>
+
+namespace rcc {
+
+class InstructionSet;
+class MachineFunction;
+
+struct MachineFunctionCloneOptions final {
+ MachineFunctionStableID NewStableID;
+ std::optional<std::string> NewName;
+};
+
+struct MachineFunctionCloneResult final {
+ MachineFunctionCloneResult();
+ MachineFunctionCloneResult(const MachineFunctionCloneResult &) = delete;
+ MachineFunctionCloneResult &operator=(const MachineFunctionCloneResult &) = delete;
+ MachineFunctionCloneResult(MachineFunctionCloneResult &&) noexcept;
+ MachineFunctionCloneResult &operator=(MachineFunctionCloneResult &&) noexcept;
+ ~MachineFunctionCloneResult();
+
+ std::unique_ptr<MachineFunction> ClonedFunction;
+ std::unordered_map<MachineBlockStableID, MachineBlockStableID> BlockStableIDs;
+ std::unordered_map<MachineInstrStableID, MachineInstrStableID> InstructionStableIDs;
+ std::unordered_map<Register, Register> VirtualRegisters;
+ std::unordered_map<FrameIndex, FrameIndex> FrameIndices;
+ std::unordered_map<ConstantPoolIndex, ConstantPoolIndex> ConstantPoolIndices;
+ std::unordered_map<JumpTableIndex, JumpTableIndex> JumpTableIndices;
+};
+
+[[nodiscard]] Expected<MachineFunctionCloneResult>
+cloneMachineFunction(const MachineFunction &Source, const InstructionSet &Instructions,
+ MachineFunctionCloneOptions Options);
+
+} // namespace rcc
+
+#endif // RCC_CODEGEN_MACHINEFUNCTIONCLONER_H