diff options
| author | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-15 19:04:08 +0800 |
|---|---|---|
| committer | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-15 19:04:08 +0800 |
| commit | 220c9cd426ec0590f6a43550b28fb344d8dfd8fd (patch) | |
| tree | 733b69782971fdd0a88e8f4581900a11a5dbdcbd /backend/utils/TableGen/Common | |
| parent | 2c7a437b066ad243a21af6d2c1ce1550e467f5f5 (diff) | |
| download | rcc-project-220c9cd426ec0590f6a43550b28fb344d8dfd8fd.tar.gz rcc-project-220c9cd426ec0590f6a43550b28fb344d8dfd8fd.tar.xz | |
[RISCV][GlobalISel] Legalize floating-point to integer conversions
Diffstat (limited to 'backend/utils/TableGen/Common')
| -rw-r--r-- | backend/utils/TableGen/Common/CodeGenInstruction.cpp | 13 | ||||
| -rw-r--r-- | backend/utils/TableGen/Common/CodeGenTarget.h | 1 |
2 files changed, 14 insertions, 0 deletions
diff --git a/backend/utils/TableGen/Common/CodeGenInstruction.cpp b/backend/utils/TableGen/Common/CodeGenInstruction.cpp index cabe8d4..c314304 100644 --- a/backend/utils/TableGen/Common/CodeGenInstruction.cpp +++ b/backend/utils/TableGen/Common/CodeGenInstruction.cpp @@ -287,6 +287,10 @@ pipelineStageEnumerator(std::string_view Value) noexcept { fail(InputOperand.Range, "register definition operands must accept only registers"); return false; } + if (InputOperand.TypeIndex && !IsRegisterOnly) { + fail(InputOperand.Range, "instruction operand type_index requires exactly one register kind"); + return false; + } if (!HasRegisterKind && (InputOperand.RegisterClassSymbol || InputOperand.RegisterBankSymbol || InputOperand.EarlyClobber || InputOperand.AllowSubReg)) { fail(InputOperand.Range, "non-register operands cannot have register constraints"); @@ -337,6 +341,7 @@ pipelineStageEnumerator(std::string_view Value) noexcept { Result.Optional = InputOperand.Optional; Result.VariadicGroup = InputOperand.VariadicGroup; Result.AllowSubReg = InputOperand.AllowSubReg; + Result.TypeIndex = InputOperand.TypeIndex; Result.AllowedTargetFlags = InputOperand.AllowedTargetFlags; return true; } @@ -529,6 +534,14 @@ CodeGenTarget::normalizeImplicitRegisters(const std::vector<SourceImplicitRegist return std::ranges::find(Normalized.Flags, Flag) != Normalized.Flags.end(); }; const bool IsTerminator = HasFlag("Terminator"); + if (!HasFlag("Generic") && + std::ranges::any_of(Normalized.Operands, [](const NormalizedOperand &Operand) { + return Operand.TypeIndex.has_value(); + })) { + fail(Instruction.Range, + "instruction type_index operands require the generic instruction flag"); + return false; + } if ((HasFlag("Branch") || HasFlag("Return") || HasFlag("Barrier") || HasFlag("IndirectBranch")) && !IsTerminator) { diff --git a/backend/utils/TableGen/Common/CodeGenTarget.h b/backend/utils/TableGen/Common/CodeGenTarget.h index 139cfc8..cbddd4a 100644 --- a/backend/utils/TableGen/Common/CodeGenTarget.h +++ b/backend/utils/TableGen/Common/CodeGenTarget.h @@ -131,6 +131,7 @@ struct NormalizedOperand final { bool VariadicGroup = false; bool AllowSubReg = false; std::optional<std::uint32_t> Name; + std::optional<std::uint16_t> TypeIndex; std::uint32_t AllowedTargetFlags = 0; }; |
