aboutsummaryrefslogtreecommitdiff
path: root/backend/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
diff options
context:
space:
mode:
authorRichard-Qin-X <richard.qin.001@gmail.com>2026-08-13 06:52:15 +0800
committerRichard-Qin-X <richard.qin.001@gmail.com>2026-08-13 06:52:15 +0800
commitaa7c85ca71859aab15bdf1e6dc1ea3a5aa5d1e28 (patch)
tree20d94c4debfe4900e362c6c7f8443bcfbd58ec28 /backend/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
parentd62f022c92fcc3ebe2269273628943a0089683fd (diff)
downloadrcc-project-aa7c85ca71859aab15bdf1e6dc1ea3a5aa5d1e28.tar.gz
rcc-project-aa7c85ca71859aab15bdf1e6dc1ea3a5aa5d1e28.tar.xz
[Support] Split APInt and APFloat ownership
Diffstat (limited to 'backend/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp')
-rw-r--r--backend/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/backend/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp b/backend/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
index e9d72fd..da8d687 100644
--- a/backend/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
+++ b/backend/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
@@ -99,9 +99,8 @@ namespace {
Destination.scalarBitWidth() <= 64;
}
-[[nodiscard]] Expected<IntegerImmediate> extendIntegerImmediate(const IntegerImmediate &Value,
- std::uint32_t DestinationWidth,
- bool SignExtend) {
+[[nodiscard]] Expected<APInt>
+extendIntegerImmediate(const APInt &Value, std::uint32_t DestinationWidth, bool SignExtend) {
if (DestinationWidth == 0 || DestinationWidth > 64)
return makeUnexpected(ErrorCode::Unsupported,
"RISC-V constant extension requires a destination no wider than 64 bits");
@@ -112,7 +111,7 @@ namespace {
Raw |= ~std::uint64_t{0} << SourceWidth;
if (DestinationWidth < 64)
Raw &= (std::uint64_t{1} << DestinationWidth) - 1U;
- return IntegerImmediate::create(DestinationWidth, std::span<const std::uint64_t>(&Raw, 1));
+ return APInt::create(DestinationWidth, std::span<const std::uint64_t>(&Raw, 1));
}
[[nodiscard]] Expected<void>
@@ -271,9 +270,8 @@ wideConstantUnmergePlan(const MachineInstr &Constant, const MachineFunction &Fun
return Plan;
}
-[[nodiscard]] Expected<IntegerImmediate> wideConstantWord(const IntegerImmediate &Value,
- std::size_t WordIndex,
- std::uint32_t Width, bool SignExtend) {
+[[nodiscard]] Expected<APInt> wideConstantWord(const APInt &Value, std::size_t WordIndex,
+ std::uint32_t Width, bool SignExtend) {
std::uint64_t Raw = 0;
if (WordIndex < Value.words().size())
Raw = Value.words()[WordIndex];
@@ -287,7 +285,7 @@ wideConstantUnmergePlan(const MachineInstr &Constant, const MachineFunction &Fun
}
if (Width < 64)
Raw &= (std::uint64_t{1} << Width) - 1U;
- return IntegerImmediate::create(Width, std::span<const std::uint64_t>(&Raw, 1));
+ return APInt::create(Width, std::span<const std::uint64_t>(&Raw, 1));
}
[[nodiscard]] Expected<void> foldWideConstant(MachineInstr &Instruction, MachineFunction &Function,
@@ -303,7 +301,7 @@ wideConstantUnmergePlan(const MachineInstr &Constant, const MachineFunction &Fun
return makeUnexpected(ErrorCode::VerificationError,
"RISC-V wide constant has no integer immediate");
- std::vector<IntegerImmediate> Words;
+ std::vector<APInt> Words;
Words.reserve(Plan->Outputs.size());
for (std::size_t Index = 0; Index < Plan->Outputs.size(); ++Index) {
const auto Info = Function.registerInfo().virtualRegisterInfo(Plan->Outputs[Index]);
@@ -1240,7 +1238,7 @@ void eraseDeadArtifacts(std::span<MachineInstr *const> Candidates,
auto Result = Builder.function().registerInfo().createVirtualRegister(*Type);
if (!Result)
return std::unexpected(Result.error());
- auto Immediate = IntegerImmediate::fromUnsigned(Width, Value);
+ auto Immediate = APInt::fromUnsigned(Width, Value);
if (!Immediate)
return std::unexpected(Immediate.error());
auto Point = Builder.setInsertPointBefore(Anchor);