aboutsummaryrefslogtreecommitdiff
path: root/backend/utils/TableGen
diff options
context:
space:
mode:
authorRichard-Qin-X <richard.qin.001@gmail.com>2026-08-13 13:21:44 +0800
committerRichard-Qin-X <richard.qin.001@gmail.com>2026-08-13 13:21:44 +0800
commit9f7cd14951ed9b7e04176f68f5c454aa7018b3e3 (patch)
treedba38b5a5f75203d10972ff81754ef76c9bb8857 /backend/utils/TableGen
parent8558f80b4077536d6aa46b97328d6df1210e261f (diff)
downloadrcc-project-9f7cd14951ed9b7e04176f68f5c454aa7018b3e3.tar.gz
rcc-project-9f7cd14951ed9b7e04176f68f5c454aa7018b3e3.tar.xz
[RISCV] Use the generated opcode conversion
Diffstat (limited to 'backend/utils/TableGen')
-rw-r--r--backend/utils/TableGen/InstrInfoEmitter.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/backend/utils/TableGen/InstrInfoEmitter.cpp b/backend/utils/TableGen/InstrInfoEmitter.cpp
index 6c6426d..795a718 100644
--- a/backend/utils/TableGen/InstrInfoEmitter.cpp
+++ b/backend/utils/TableGen/InstrInfoEmitter.cpp
@@ -104,13 +104,16 @@ void emitImmediatePredicate(std::ostream &Output, const NormalizedImmediatePredi
appendQuoted(Output, SourceName);
Output << ". Do not edit it manually.\n\n";
Output << "#ifndef " << Guard << "\n#define " << Guard << "\n\n";
- Output << "#include <cstdint>\n\n";
+ Output << "#include \"rcc/CodeGen/MachineIRTypes.h\"\n\n#include <cstdint>\n\n";
Output << "namespace rcc::" << Model.Target.Namespace << " {\n\n";
Output << "enum class InstructionOpcode : std::uint32_t {\n Invalid = 0,\n";
for (const NormalizedInstruction &Instruction : Model.Instructions)
Output << " " << Instruction.Symbol << " = " << Instruction.ID << ",\n";
Output << "};\n\n";
+ Output << "[[nodiscard]] constexpr Opcode instructionOpcode(InstructionOpcode Value) noexcept {\n"
+ " return Opcode::fromValue(static_cast<std::uint32_t>(Value));\n"
+ "}\n\n";
Output << "enum class ImmediatePredicate : std::uint32_t {\n None = 0,\n";
for (const NormalizedImmediatePredicate &Predicate : Model.ImmediatePredicates)