Skip to content

Commit

Permalink
- enhancement: Generate GIMPLE.
Browse files Browse the repository at this point in the history
  • Loading branch information
royqh1979 committed Jan 1, 2025
1 parent 5943a48 commit 35c68bb
Show file tree
Hide file tree
Showing 15 changed files with 1,200 additions and 1,124 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Red Panda C++ Version 3.3
- fix: command line parameter escaping for consolepauser in windows. (by CyanoHao)
- enhancement: Localization for consolepauser.
- fix: Debugger not responding when debugging with gdb > 14.
- enhancement: Run programs in WSL.
- enhancement: Generate GIMPLE.

Red Panda C++ Version 3.2

Expand Down
3 changes: 2 additions & 1 deletion RedPandaIDE/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
enum class CppCompileType {
Normal,
PreprocessOnly,
GenerateAssemblyOnly
GenerateAssemblyOnly,
GenerateGimpleOnly,
};

enum class CompileIssueType {
Expand Down
7 changes: 7 additions & 0 deletions RedPandaIDE/compiler/filecompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ bool FileCompiler::prepareForCompile()
if (pSettings->languages().noDebugDirectivesWhenGenerateASM())
compilerSet()->setCompileOption(CC_CMD_OPT_DEBUG_INFO,COMPILER_OPTION_OFF);
break;
case CppCompileType::GenerateGimpleOnly:
stage = Settings::CompilerSet::CompilationStage::GenerateGimple;
break;
default:
break;
}
Expand Down Expand Up @@ -86,6 +89,10 @@ bool FileCompiler::prepareForCompile()
mOutputFile=changeFileExt(mFilename,compilerSet()->compilationProperSuffix());
mArguments += {"-S", "-fverbose-asm"};
break;
case Settings::CompilerSet::CompilationStage::GenerateGimple:
mOutputFile=changeFileExt(mFilename,compilerSet()->compilationProperSuffix());
mArguments += {"-S", QString("-fdump-tree-gimple=%1").arg(changeFileExt(mFilename,"gimple"))};
break;
case Settings::CompilerSet::CompilationStage::AssemblingOnly:
mOutputFile=changeFileExt(mFilename,compilerSet()->assemblingSuffix());
mArguments << "-c";
Expand Down
22 changes: 22 additions & 0 deletions RedPandaIDE/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2389,6 +2389,9 @@ bool MainWindow::compile(bool rebuild, CppCompileType compileType)
case CppCompileType::GenerateAssemblyOnly:
stage = Settings::CompilerSet::CompilationStage::CompilationProperOnly;
break;
case CppCompileType::GenerateGimpleOnly:
stage = Settings::CompilerSet::CompilationStage::GenerateGimple;
break;
case CppCompileType::PreprocessOnly:
stage = Settings::CompilerSet::CompilationStage::PreprocessingOnly;
break;
Expand Down Expand Up @@ -8433,6 +8436,19 @@ void MainWindow::doGenerateAssembly()
compile(false,CppCompileType::GenerateAssemblyOnly);
}

void MainWindow::doGenerateGimple()
{
CompileTarget target =getCompileTarget();
if (target!= CompileTarget::File
&& target != CompileTarget::Project) {
return;
}
mCompileSuccessionTask = std::make_shared<CompileSuccessionTask>();
//mCompileSuccessionTask->binDirs="";
mCompileSuccessionTask->type = CompileSuccessionTaskType::RunNormal;
compile(false,CppCompileType::GenerateGimpleOnly);
}

void MainWindow::updateProblemCaseOutput(POJProblemCase problemCase)
{
if (problemCase->testState == ProblemCaseTestState::Failed) {
Expand Down Expand Up @@ -10478,3 +10494,9 @@ void MainWindow::on_actionIntel_ASM_triggered()
}
}


void MainWindow::on_actionGenerate_GIMPLE_triggered()
{
doGenerateGimple();
}

3 changes: 3 additions & 0 deletions RedPandaIDE/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ public slots:
void clearIssues();
void doCompileRun(RunType runType);
void doGenerateAssembly();
void doGenerateGimple();
void updateProblemCaseOutput(POJProblemCase problemCase);
void applyCurrentProblemCaseChanges();
void showHideInfosTab(QWidget *widget, bool show);
Expand Down Expand Up @@ -871,6 +872,8 @@ private slots:

void on_actionIntel_ASM_triggered();

void on_actionGenerate_GIMPLE_triggered();

private:
Ui::MainWindow *ui;
bool mFullInitialized;
Expand Down
Loading

0 comments on commit 35c68bb

Please sign in to comment.