blob: 3abdf785b113bb38ae5345ba0cfd17300b2b7bdb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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
|