blob: 6351b983a06f21f2a521eaed3d687d5c17f75336 (
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
|
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef RCC_CODEGEN_REGISTERSCAVENGER_H
#define RCC_CODEGEN_REGISTERSCAVENGER_H
#include "rcc/CodeGen/Register.h"
#include "rcc/Support/Error.h"
#include <span>
namespace rcc {
class MachineFunction;
class MachineInstr;
class TargetDescription;
struct ScavengedRegister final {
PhysicalRegister Reg;
bool RequiresSpill = false;
};
class RegisterScavenger final {
public:
RegisterScavenger(const MachineFunction &Function, const TargetDescription &Target) noexcept
: Function(&Function), Target(&Target) {}
[[nodiscard]] Expected<ScavengedRegister>
scavenge(const MachineInstr &Instruction, std::span<const PhysicalRegister> Candidates) const;
private:
[[nodiscard]] Expected<bool> isLiveBefore(const MachineInstr &Instruction,
PhysicalRegister Reg) const;
[[nodiscard]] bool instructionUses(const MachineInstr &Instruction,
PhysicalRegister Reg) const noexcept;
const MachineFunction *Function;
const TargetDescription *Target;
};
} // namespace rcc
#endif // RCC_CODEGEN_REGISTERSCAVENGER_H
|