You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.5 KiB

#include "mir/MIR.h"
#include <cstdlib>
namespace mir {
void RunMIRPreRegAllocPassPipeline(MachineModule& module) {
const char* disable_spill_reduction = std::getenv("NUDTC_DISABLE_MIR_SPILL_REDUCTION");
const bool run_spill_reduction =
disable_spill_reduction == nullptr || disable_spill_reduction[0] == '\0' ||
disable_spill_reduction[0] == '0';
const char* disable_cfg_cleanup = std::getenv("NUDTC_DISABLE_MIR_CFG_CLEANUP");
const bool run_cfg_cleanup =
disable_cfg_cleanup == nullptr || disable_cfg_cleanup[0] == '\0' ||
disable_cfg_cleanup[0] == '0';
if (run_spill_reduction) {
RunSpillReduction(module);
}
RunAddressHoisting(module);
constexpr int kMaxIterations = 4;
for (int iteration = 0; iteration < kMaxIterations; ++iteration) {
bool changed = false;
changed |= RunPeephole(module);
if (run_cfg_cleanup) {
changed |= RunCFGCleanup(module);
}
if (!changed) {
break;
}
}
}
void RunMIRPostRegAllocPassPipeline(MachineModule& module) {
const char* disable_cfg_cleanup = std::getenv("NUDTC_DISABLE_MIR_CFG_CLEANUP");
const bool run_cfg_cleanup =
disable_cfg_cleanup == nullptr || disable_cfg_cleanup[0] == '\0' ||
disable_cfg_cleanup[0] == '0';
constexpr int kMaxIterations = 2;
for (int iteration = 0; iteration < kMaxIterations; ++iteration) {
bool changed = false;
changed |= RunPeephole(module);
if (run_cfg_cleanup) {
changed |= RunCFGCleanup(module);
}
if (!changed) {
break;
}
}
}
} // namespace mir