aboutsummaryrefslogtreecommitdiff
path: root/backend/lib/Target/RISCV/GISel/RISCVLegalizerInfo.h
blob: 36d74861d7a7c3a4916f7499f30ab6320e8d3536 (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
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef RCC_LIB_TARGET_RISCV_GISEL_RISCVLEGALIZERINFO_H
#define RCC_LIB_TARGET_RISCV_GISEL_RISCVLEGALIZERINFO_H

#include "rcc/CodeGen/GlobalISel/LegalizerInfo.h"

namespace rcc {
class MachineIRBuilder;
} // namespace rcc

namespace rcc::riscv {

class RISCVSubtarget;

class RISCVLegalizerInfo final : public LegalizerInfo {
public:
  explicit RISCVLegalizerInfo(const RISCVSubtarget &Subtarget);
  [[nodiscard]] Expected<void> legalizeCustom(LegalizerHelper &Helper, MachineInstr &Instruction,
                                              const LegalizationDecision &Decision) const override;
  [[nodiscard]] Expected<bool> legalizeIntrinsic(LegalizerHelper &Helper,
                                                 MachineInstr &Instruction) const override;
  [[nodiscard]] bool isSExtCheaperThanZExt(LowLevelType SourceType,
                                           LowLevelType DestinationType) const override;

private:
  [[nodiscard]] Expected<void> legalizeBRJT(MachineInstr &Instruction,
                                            MachineIRBuilder &MIRBuilder) const;
  [[nodiscard]] Expected<void> legalizeVAStart(MachineInstr &Instruction,
                                               MachineIRBuilder &MIRBuilder) const;

  const RISCVSubtarget &Subtarget;
};

} // namespace rcc::riscv

#endif // RCC_LIB_TARGET_RISCV_GISEL_RISCVLEGALIZERINFO_H