blob: 28718f0d91b5742eb57ce12bdb871d7a53167668 (
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef RCC_TARGET_RISCV_RISCVSUBTARGET_H
#define RCC_TARGET_RISCV_RISCVSUBTARGET_H
#include "rcc/Support/Error.h"
#include <cstdint>
#include <memory>
#include <span>
#include <string>
namespace rcc {
class InstructionSelector;
class LegalizerInfo;
class TargetCallLowering;
namespace riscv {
class RISCVRegisterBankInfo;
enum class RISCVExtension : std::uint8_t {
I,
M,
A,
F,
D,
C,
Zicsr,
Zifencei,
Zacas,
Zabha,
Count,
};
class RISCVSubtargetFeatures final {
public:
[[nodiscard]] static Expected<RISCVSubtargetFeatures>
fromFeatureList(std::span<const std::string> Features);
[[nodiscard]] static RISCVSubtargetFeatures rv64gc() noexcept;
[[nodiscard]] bool has(RISCVExtension Extension) const noexcept;
friend bool operator==(const RISCVSubtargetFeatures &Left,
const RISCVSubtargetFeatures &Right) = default;
private:
explicit constexpr RISCVSubtargetFeatures(std::uint16_t Enabled) noexcept : Enabled(Enabled) {}
std::uint16_t Enabled = 0;
};
class RISCVSubtarget final {
public:
explicit RISCVSubtarget(RISCVSubtargetFeatures Features);
RISCVSubtarget(const RISCVSubtarget &) = delete;
RISCVSubtarget &operator=(const RISCVSubtarget &) = delete;
RISCVSubtarget(RISCVSubtarget &&) = delete;
RISCVSubtarget &operator=(RISCVSubtarget &&) = delete;
~RISCVSubtarget();
[[nodiscard]] const RISCVSubtargetFeatures &features() const noexcept {
return Features;
}
[[nodiscard]] const TargetCallLowering *getCallLowering() const;
[[nodiscard]] InstructionSelector *getInstructionSelector() const;
[[nodiscard]] const LegalizerInfo *getLegalizerInfo() const;
[[nodiscard]] const RISCVRegisterBankInfo *getRegBankInfo() const;
private:
RISCVSubtargetFeatures Features;
mutable std::unique_ptr<TargetCallLowering> CallLoweringInfo;
mutable std::unique_ptr<InstructionSelector> InstSelector;
mutable std::unique_ptr<LegalizerInfo> Legalizer;
mutable std::unique_ptr<RISCVRegisterBankInfo> RegBankInfo;
};
} // namespace riscv
} // namespace rcc
#endif // RCC_TARGET_RISCV_RISCVSUBTARGET_H
|