aboutsummaryrefslogtreecommitdiff
path: root/backend/include/rcc/CodeGen/LiveRangeEdit.h
blob: 66696dfb24e7f4ed2af93b2303689dd561533cc5 (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
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef RCC_CODEGEN_LIVERANGEEDIT_H
#define RCC_CODEGEN_LIVERANGEEDIT_H

#include "rcc/CodeGen/VirtRegMap.h"

#include <optional>

namespace rcc {

class TargetDescription;

class LiveRangeEdit final {
public:
  LiveRangeEdit(MachineFunction &Function, const TargetDescription &Target, VirtRegMap &Mapping)
      : Function(&Function), Target(&Target), Mapping(&Mapping) {}

  [[nodiscard]] Expected<Register> createFrom(Register Parent, bool Spillable,
                                              std::optional<Register> Origin = std::nullopt);
  [[nodiscard]] Expected<FrameIndex> getOrCreateSpillSlot(Register VirtualReg);
  [[nodiscard]] Expected<void> eraseVirtualRegister(Register VirtualReg);

private:
  MachineFunction *Function;
  const TargetDescription *Target;
  VirtRegMap *Mapping;
};

} // namespace rcc

#endif // RCC_CODEGEN_LIVERANGEEDIT_H