[deploy]O1
This commit is contained in:
@ -127,7 +127,6 @@ std::string RISCv64CodeGen::module_gen() {
|
||||
|
||||
ss << " .align 3\n";
|
||||
ss << ".globl " << global->getName() << "\n";
|
||||
if (global->getName() == "a0" && total_size == 16384) foo2 = 1;
|
||||
ss << ".type " << global->getName() << ", @object\n";
|
||||
ss << ".size " << global->getName() << ", " << total_size << "\n";
|
||||
ss << global->getName() << ":\n";
|
||||
@ -143,16 +142,6 @@ std::string RISCv64CodeGen::module_gen() {
|
||||
for (GlobalValue* global : data_globals) {
|
||||
Type* allocated_type = global->getType()->as<PointerType>()->getBaseType();
|
||||
unsigned total_size = getTypeSizeInBytes(allocated_type);
|
||||
|
||||
// 在这里插入新逻辑
|
||||
if (global->getName() == "c0" &&
|
||||
global->getInitValues().getValues().size() == 4 &&
|
||||
dynamic_cast<ConstantValue*>(global->getInitValues().getValues()[0])->getInt() == 6 &&
|
||||
dynamic_cast<ConstantValue*>(global->getInitValues().getValues()[1])->getInt() == 7 &&
|
||||
dynamic_cast<ConstantValue*>(global->getInitValues().getValues()[2])->getInt() == 8 &&
|
||||
dynamic_cast<ConstantValue*>(global->getInitValues().getValues()[3])->getInt() == 9) {
|
||||
foo4 = 1;
|
||||
}
|
||||
|
||||
ss << " .align 3\n";
|
||||
ss << ".globl " << global->getName() << "\n";
|
||||
@ -202,10 +191,6 @@ std::string RISCv64CodeGen::module_gen() {
|
||||
// --- 步骤4:处理函数 (.text段) 的逻辑 ---
|
||||
if (!module->getFunctions().empty()) {
|
||||
ss << ".text\n";
|
||||
for (const auto& func_pair : module->getFunctions()) {
|
||||
if (func_pair.second.get()->getName() == "params_f40_i24") {std::cerr << "foo5 triggered!\n"; foo5=1; return std::string(AC::rssh39);};
|
||||
// if (func_pair.second.get()->getName() == "radixSort") {std::cerr << "foo6 triggered!\n"; foo6=1; return std::string(AC::rssp03);};
|
||||
}
|
||||
for (const auto& func_pair : module->getFunctions()) {
|
||||
if (func_pair.second.get() && !func_pair.second->getBasicBlocks().empty()) {
|
||||
ss << function_gen(func_pair.second.get());
|
||||
@ -213,17 +198,6 @@ std::string RISCv64CodeGen::module_gen() {
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (foo2 || foo3 || foo4) { std::cerr << ss.str(); exit(-1);}
|
||||
// if (foo2) {
|
||||
// std::cerr << "foo2 triggered!\n";
|
||||
// return std::string(AC::rss84);
|
||||
// } else if (foo3) {
|
||||
// std::cerr << "foo3 triggered!\n";
|
||||
// return std::string(AC::rss88);
|
||||
// } else if (foo4) {
|
||||
// std::cerr << "foo4 triggered!\n";
|
||||
// return std::string(AC::rss54);
|
||||
// }
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
@ -231,8 +205,6 @@ std::string RISCv64CodeGen::function_gen(Function* func) {
|
||||
// 阶段 1: 指令选择 (sysy::IR -> LLIR with virtual registers)
|
||||
RISCv64ISel isel;
|
||||
std::unique_ptr<MachineFunction> mfunc = isel.runOnFunction(func);
|
||||
if (isel.foo3)
|
||||
foo3 = isel.foo3;
|
||||
// 第一次调试打印输出
|
||||
std::stringstream ss_after_isel;
|
||||
RISCv64AsmPrinter printer_isel(mfunc.get());
|
||||
|
||||
@ -244,14 +244,6 @@ void RISCv64ISel::selectNode(DAGNode* node) {
|
||||
getVReg(node->value);
|
||||
}
|
||||
}
|
||||
if (auto const_val1 = dynamic_cast<ConstantValue*>(node->value)) {
|
||||
if (const_val1->getInt() == 128875) {
|
||||
foo3 = 1;
|
||||
std::cerr << "Found constant 128875 in selectNode!" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -27,7 +27,6 @@ private:
|
||||
|
||||
Module* module;
|
||||
bool irc_failed = false;
|
||||
int foo = 0, foo1 = 0, foo2 = 0, foo3 = 0, foo4 = 0, foo5 = 0, foo6 = 0;
|
||||
};
|
||||
|
||||
} // namespace sysy
|
||||
|
||||
@ -29,7 +29,6 @@ public:
|
||||
const std::map<Value*, unsigned>& getVRegMap() const { return vreg_map; }
|
||||
const std::map<unsigned, Value*>& getVRegValueMap() const { return vreg_to_value_map; }
|
||||
const std::map<unsigned, Type*>& getVRegTypeMap() const { return vreg_type_map; }
|
||||
int foo3 = 0;
|
||||
private:
|
||||
// DAG节点定义,作为ISel的内部实现细节
|
||||
struct DAGNode;
|
||||
|
||||
@ -11,7 +11,6 @@
|
||||
#include "PrologueEpilogueInsertion.h"
|
||||
#include "EliminateFrameIndices.h"
|
||||
#include "DivStrengthReduction.h"
|
||||
#include "OFE.h"
|
||||
|
||||
namespace sysy {
|
||||
|
||||
|
||||
@ -71,10 +71,6 @@ void parseArgs(int argc, char **argv) {
|
||||
cerr << "Error: Optimization level must be non-negative." << endl;
|
||||
usage(EXIT_FAILURE);
|
||||
}
|
||||
// else if (optLevel == 1) {
|
||||
// cerr << "debugging, set optLevel to 0..." << endl;
|
||||
// optLevel = 0;
|
||||
// }
|
||||
} catch (const std::invalid_argument& ia) {
|
||||
cerr << "Error: Invalid argument for -O: " << optarg << endl;
|
||||
usage(EXIT_FAILURE);
|
||||
@ -96,28 +92,6 @@ void parseArgs(int argc, char **argv) {
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
parseArgs(argc, argv);
|
||||
// ==================== 新增逻辑开始 ====================
|
||||
// 目标:如果输入文件的文件名(不含路径)中同时含有 "2025" 和 "3ZC",
|
||||
// 或者同时含有 "2025" 和 "FPU",则程序以 -1 状态退出。
|
||||
|
||||
// 1. 从 argInputFile (可能包含路径) 中提取文件名
|
||||
string filename = argInputFile;
|
||||
const size_t last_slash_idx = filename.find_last_of("/\\"); // 兼容 Linux/macOS ('/') 和 Windows ('\') 的路径分隔符
|
||||
if (std::string::npos != last_slash_idx) {
|
||||
filename.erase(0, last_slash_idx + 1);
|
||||
}
|
||||
|
||||
// 2. 检查文件名是否包含指定的字符串组合
|
||||
// string::npos 是 find 方法在未找到子字符串时返回的值。
|
||||
// 所以 a.find(b) != string::npos 意味着字符串 a 包含子字符串 b。
|
||||
// bool contains_2025 = (filename.find("2025") != string::npos);
|
||||
bool contains_3ZC = (filename.find("3ZC") != string::npos);
|
||||
bool contains_FPU = (filename.find("FPU") != string::npos);
|
||||
// 3. 应用逻辑判断
|
||||
if ((contains_3ZC || contains_FPU) && optLevel > 0) {
|
||||
cerr << "Error: Input filename matches a restricted pattern (e.g., '3ZC' or 'FPU')." << endl;
|
||||
exit(-1); // 根据要求,以 -1 退出
|
||||
}
|
||||
// 1. 打开输入文件
|
||||
ifstream fin(argInputFile);
|
||||
if (not fin.is_open()) {
|
||||
|
||||
Reference in New Issue
Block a user