From de51429073ca2469fd7e54ee00f82e1557591e5c Mon Sep 17 00:00:00 2001 From: Odeinjul Date: Fri, 15 Dec 2023 21:48:00 +0800 Subject: [PATCH] Pass all test --- .gitignore | 6 +++--- src/SysYFIRBuilder/IRBuilder.cpp | 24 ++++++++++++------------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 5eaade7..4df9afe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ - .vscode - build - \ No newline at end of file +.DS_STORE +cmake-build-debug/ +build/ \ No newline at end of file diff --git a/src/SysYFIRBuilder/IRBuilder.cpp b/src/SysYFIRBuilder/IRBuilder.cpp index a0f94bf..02e913f 100644 --- a/src/SysYFIRBuilder/IRBuilder.cpp +++ b/src/SysYFIRBuilder/IRBuilder.cpp @@ -385,8 +385,8 @@ void IRBuilder::visit(SyntaxTree::FuncDef &node) { scope.push(node.name, func); scope.enter(); - auto entryBlock = BasicBlock::create(module, "funcEntry", func); - retBB = BasicBlock::create(module, "ret", func); + auto entryBlock = BasicBlock::create(module, "", func); + retBB = BasicBlock::create(module, "", func); builder->set_insert_point(entryBlock); @@ -648,8 +648,8 @@ void IRBuilder::visit(SyntaxTree::BinaryCondExpr &node) { Ptr cond; switch (node.op) { case SyntaxTree::BinaryCondOp::LAND: - trueBB = BasicBlock::create(module, "trueBB_and", curFunc); - falseBB = BasicBlock::create(module, "falseBB_and", curFunc); + trueBB = BasicBlock::create(module, "", curFunc); + falseBB = BasicBlock::create(module, "", curFunc); node.lhs->accept(*this); TypeConvert(tmpInst, INT1_T); builder->create_cond_br(tmpInst, trueBB, falseBB); @@ -665,8 +665,8 @@ void IRBuilder::visit(SyntaxTree::BinaryCondExpr &node) { break; case SyntaxTree::BinaryCondOp::LOR: - trueBB = BasicBlock::create(module, "trueBB_and", curFunc); - falseBB = BasicBlock::create(module, "falseBB_and", curFunc); + trueBB = BasicBlock::create(module, "", curFunc); + falseBB = BasicBlock::create(module, "", curFunc); node.lhs->accept(*this); TypeConvert(tmpInst, INT1_T); builder->create_cond_br(tmpInst, trueBB, falseBB); @@ -744,9 +744,9 @@ void IRBuilder::visit(SyntaxTree::FuncCallStmt &node) { // FINISH void IRBuilder::visit(SyntaxTree::IfStmt &node) { auto curFunc = builder->get_insert_block()->get_parent(); - auto trueBB = BasicBlock::create(module, "trueBB_if", curFunc); - auto falseBB = BasicBlock::create(module, "falseBB_if", curFunc); - auto afterBB = node.else_statement == nullptr ? falseBB : BasicBlock::create(module, "afterBB_if", curFunc); + auto trueBB = BasicBlock::create(module, "", curFunc); + auto falseBB = BasicBlock::create(module, "", curFunc); + auto afterBB = node.else_statement == nullptr ? falseBB : BasicBlock::create(module, "", curFunc); node.cond_exp->accept(*this); @@ -771,9 +771,9 @@ void IRBuilder::visit(SyntaxTree::IfStmt &node) { //FINISH void IRBuilder::visit(SyntaxTree::WhileStmt &node) { auto curFunc = builder->get_insert_block()->get_parent(); - auto condBB = BasicBlock::create(module, "condBB_while", curFunc); - auto bodyBB = BasicBlock::create(module, "bodyBB_while", curFunc); - auto afterBB = BasicBlock::create(module, "afterBB_while", curFunc); + auto condBB = BasicBlock::create(module, "", curFunc); + auto bodyBB = BasicBlock::create(module, "", curFunc); + auto afterBB = BasicBlock::create(module, "", curFunc); auto tmpWhileBlock = curWhileBlock; curWhileBlock = WhileBlock{condBB, bodyBB, afterBB};