aboutsummaryrefslogtreecommitdiff
path: root/backend/lib/Target/Description
diff options
context:
space:
mode:
authorRichard-Qin-X <richard.qin.001@gmail.com>2026-08-09 04:40:17 +0800
committerRichard-Qin-X <richard.qin.001@gmail.com>2026-08-09 04:40:17 +0800
commite5fdceb9b869f010a2a75638fd38aaf1867f3008 (patch)
tree023d3e18960956f5ce369739c68aaa2a3e8400e7 /backend/lib/Target/Description
parent6c7cecc81a4c7e06e26027e21edd2cfd95a37a0b (diff)
downloadrcc-project-e5fdceb9b869f010a2a75638fd38aaf1867f3008.tar.gz
rcc-project-e5fdceb9b869f010a2a75638fd38aaf1867f3008.tar.xz
[CodeGen] Complete register allocation infrastructure
Diffstat (limited to 'backend/lib/Target/Description')
-rw-r--r--backend/lib/Target/Description/TargetDescriptionGenerator.cpp27
-rw-r--r--backend/lib/Target/Description/TargetDescriptionGenerator.h4
2 files changed, 18 insertions, 13 deletions
diff --git a/backend/lib/Target/Description/TargetDescriptionGenerator.cpp b/backend/lib/Target/Description/TargetDescriptionGenerator.cpp
index 3c5e817..9d6b8e1 100644
--- a/backend/lib/Target/Description/TargetDescriptionGenerator.cpp
+++ b/backend/lib/Target/Description/TargetDescriptionGenerator.cpp
@@ -1364,7 +1364,7 @@ private:
const auto Value = unsignedInteger32(*Tie, "instruction operand default_tied_operand");
if (!Value)
return std::nullopt;
- Result.DefaultTiedOperand = *Value;
+ Result.DefaultTiedOperand = Value;
}
if (const yaml::Node *EarlyClobber = optionalNode(Node, "early_clobber")) {
const auto Value = boolean(*EarlyClobber, "instruction operand early_clobber");
@@ -1614,7 +1614,7 @@ operandKindEnumerator(std::string_view Value) noexcept {
{"debug_instr_ref", "DebugInstrRef"},
{"lane_mask", "LaneMask"},
}};
- const auto Position = std::ranges::find(Kinds, Value, &decltype(Kinds)::value_type::first);
+ const auto *const Position = std::ranges::find(Kinds, Value, &decltype(Kinds)::value_type::first);
if (Position == Kinds.end())
return std::nullopt;
return Position->second;
@@ -1675,7 +1675,7 @@ instructionFlagEnumerator(std::string_view Value) noexcept {
{"generic", "Generic"},
{"terminal_emission", "TerminalEmission"},
}};
- const auto Position = std::ranges::find(Flags, Value, &decltype(Flags)::value_type::first);
+ const auto *const Position = std::ranges::find(Flags, Value, &decltype(Flags)::value_type::first);
if (Position == Flags.end())
return std::nullopt;
return Position->second;
@@ -1698,7 +1698,8 @@ pseudoOwnerEnumerator(std::string_view Value) noexcept {
}};
if (Value == "asm_printer")
return "AsmPrinter";
- const auto Position = std::ranges::find(Owners, Value, &decltype(Owners)::value_type::first);
+ const auto *const Position =
+ std::ranges::find(Owners, Value, &decltype(Owners)::value_type::first);
if (Position == Owners.end())
return std::nullopt;
return Position->second;
@@ -1718,7 +1719,8 @@ pipelineStageEnumerator(std::string_view Value) noexcept {
{"post_ra_finalized", "PostRAFinalized"},
{"emission", "Emission"},
}};
- const auto Position = std::ranges::find(Stages, Value, &decltype(Stages)::value_type::first);
+ const auto *const Position =
+ std::ranges::find(Stages, Value, &decltype(Stages)::value_type::first);
if (Position == Stages.end())
return std::nullopt;
return Position->second;
@@ -2066,7 +2068,7 @@ private:
fail(Convention.Range, "calling convention register classes must resolve");
return false;
}
- const auto normalizeRegisterList = [this,
+ const auto NormalizeRegisterList = [this,
&Convention](const std::vector<std::string> &Symbols,
const NormalizedRegisterClass &RegisterClass,
std::vector<std::uint32_t> &Output) {
@@ -2101,13 +2103,13 @@ private:
.SupportsVarArgs = Convention.SupportsVarArgs,
.SupportsTailCalls = Convention.SupportsTailCalls,
};
- if (!normalizeRegisterList(Convention.IntegerArgumentRegisterSymbols,
+ if (!NormalizeRegisterList(Convention.IntegerArgumentRegisterSymbols,
*IntegerClassDescription, Normalized.IntegerArgumentRegisters) ||
- !normalizeRegisterList(Convention.FloatingArgumentRegisterSymbols,
+ !NormalizeRegisterList(Convention.FloatingArgumentRegisterSymbols,
*FloatingClassDescription, Normalized.FloatingArgumentRegisters) ||
- !normalizeRegisterList(Convention.IntegerReturnRegisterSymbols, *IntegerClassDescription,
+ !NormalizeRegisterList(Convention.IntegerReturnRegisterSymbols, *IntegerClassDescription,
Normalized.IntegerReturnRegisters) ||
- !normalizeRegisterList(Convention.FloatingReturnRegisterSymbols,
+ !NormalizeRegisterList(Convention.FloatingReturnRegisterSymbols,
*FloatingClassDescription, Normalized.FloatingReturnRegisters)) {
return false;
}
@@ -3004,8 +3006,9 @@ void emitImmediatePredicate(std::ostream &Output, const NormalizedImmediatePredi
} // namespace
-DescriptionGenerationResult generateDescription(std::string SourceName, std::string SourceText) {
- yaml::ParseResult YAMLResult = yaml::parse(SourceName, SourceText);
+DescriptionGenerationResult generateDescription(const std::string &SourceName,
+ std::string SourceText) {
+ yaml::ParseResult YAMLResult = yaml::parse(SourceName, std::move(SourceText));
if (!YAMLResult.succeeded()) {
DescriptionGenerationResult Result;
for (const TextDiagnostic &Diagnostic : YAMLResult.diagnostics())
diff --git a/backend/lib/Target/Description/TargetDescriptionGenerator.h b/backend/lib/Target/Description/TargetDescriptionGenerator.h
index c0d8ed5..9a03aa0 100644
--- a/backend/lib/Target/Description/TargetDescriptionGenerator.h
+++ b/backend/lib/Target/Description/TargetDescriptionGenerator.h
@@ -1,5 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later
+// The private header has no stable include-root-relative guard name.
+// NOLINTNEXTLINE(llvm-header-guard)
#ifndef RCC_TARGET_DESCRIPTION_TARGETDESCRIPTIONGENERATOR_H
#define RCC_TARGET_DESCRIPTION_TARGETDESCRIPTIONGENERATOR_H
@@ -27,7 +29,7 @@ struct DescriptionGenerationResult final {
}
};
-[[nodiscard]] DescriptionGenerationResult generateDescription(std::string SourceName,
+[[nodiscard]] DescriptionGenerationResult generateDescription(const std::string &SourceName,
std::string SourceText);
} // namespace rcc::targetgen