From 8a4bb6e3b0bffa0ed79b51347b12ee4293b622a7 Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Sat, 22 Aug 2026 18:49:08 +0800 Subject: [CodeGen] Generate RISC-V macro fusion rules --- backend/utils/TableGen/rcc-tblgen.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'backend/utils/TableGen/rcc-tblgen.cpp') diff --git a/backend/utils/TableGen/rcc-tblgen.cpp b/backend/utils/TableGen/rcc-tblgen.cpp index 5a5a419..47f0de4 100644 --- a/backend/utils/TableGen/rcc-tblgen.cpp +++ b/backend/utils/TableGen/rcc-tblgen.cpp @@ -23,6 +23,7 @@ struct CommandLine final { std::string TablesPath; std::string GlobalISelPath; std::string GlobalISelCombinerPath; + std::string MacroFusionPath; }; [[nodiscard]] bool parseCommandLine(int ArgumentCount, char *Arguments[], CommandLine &Result) { @@ -38,7 +39,7 @@ struct CommandLine final { } if (Argument == "--register-header" || Argument == "--instruction-header" || Argument == "--tables" || Argument == "--global-isel" || - Argument == "--global-isel-combiner") { + Argument == "--global-isel-combiner" || Argument == "--macro-fusion") { if (Index + 1 >= ArgumentCount) { std::cerr << "rcc-tblgen: missing value for " << Argument << '\n'; return false; @@ -52,6 +53,8 @@ struct CommandLine final { Destination = &Result.GlobalISelPath; else if (Argument == "--global-isel-combiner") Destination = &Result.GlobalISelCombinerPath; + else if (Argument == "--macro-fusion") + Destination = &Result.MacroFusionPath; else Destination = &Result.TablesPath; *Destination = Arguments[++Index]; @@ -62,12 +65,13 @@ struct CommandLine final { } if (!Result.InputPaths.empty() && !Result.RegisterHeaderPath.empty() && !Result.InstructionHeaderPath.empty() && !Result.TablesPath.empty() && - !Result.GlobalISelPath.empty() && !Result.GlobalISelCombinerPath.empty()) { + !Result.GlobalISelPath.empty() && !Result.GlobalISelCombinerPath.empty() && + !Result.MacroFusionPath.empty()) { return true; } std::cerr << "usage: rcc-tblgen --input [--input ]... --register-header " "--instruction-header --tables --global-isel " - "--global-isel-combiner \n"; + "--global-isel-combiner --macro-fusion \n"; return false; } @@ -233,7 +237,8 @@ int main(int ArgumentCount, char *Arguments[]) { writeFile(Command.InstructionHeaderPath, Output.InstructionHeader) && writeFile(Command.TablesPath, Output.TargetTables) && writeFile(Command.GlobalISelPath, Output.GlobalISel) && - writeFile(Command.GlobalISelCombinerPath, Output.GlobalISelCombiner) + writeFile(Command.GlobalISelCombinerPath, Output.GlobalISelCombiner) && + writeFile(Command.MacroFusionPath, Output.MacroFusion) ? 0 : 1; } -- cgit v1.2.3