[backend] fix bugs of not
This commit is contained in:
@@ -343,6 +343,7 @@ std::any SysYIRGenerator::visitIfStmt(SysYParser::IfStmtContext *ctx) {
|
|||||||
ctx->stmt(1)->accept(this);
|
ctx->stmt(1)->accept(this);
|
||||||
module->leaveScope();
|
module->leaveScope();
|
||||||
}
|
}
|
||||||
|
builder.createUncondBrInst(exitBlock, {});
|
||||||
BasicBlock::conectBlocks(builder.getBasicBlock(), exitBlock);
|
BasicBlock::conectBlocks(builder.getBasicBlock(), exitBlock);
|
||||||
|
|
||||||
labelstring << "exit.L" << builder.getLabelIndex();
|
labelstring << "exit.L" << builder.getLabelIndex();
|
||||||
|
|||||||
@@ -30,9 +30,9 @@ void SysYPrinter::printIR() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string SysYPrinter::getTypeString(Type *type) {
|
std::string SysYPrinter::getTypeString(Type *type) {
|
||||||
if (type->isVoid()) {
|
if (type->isVoid()) {
|
||||||
return "void";
|
return "void";
|
||||||
} else if (type->isInt()) {
|
} else if (type->isInt()) {
|
||||||
return "i32";
|
return "i32";
|
||||||
} else if (type->isFloat()) {
|
} else if (type->isFloat()) {
|
||||||
return "float";
|
return "float";
|
||||||
@@ -251,7 +251,7 @@ void SysYPrinter::printInst(Instruction *pInst) {
|
|||||||
|
|
||||||
switch (pInst->getKind()) {
|
switch (pInst->getKind()) {
|
||||||
case Kind::kNeg: std::cout << "sub "; break;
|
case Kind::kNeg: std::cout << "sub "; break;
|
||||||
case Kind::kNot: std::cout << "xor "; break;
|
case Kind::kNot: std::cout << "not "; break;
|
||||||
case Kind::kFNeg: std::cout << "fneg "; break;
|
case Kind::kFNeg: std::cout << "fneg "; break;
|
||||||
case Kind::kFNot: std::cout << "fneg "; break; // FNot not standard, map to fneg
|
case Kind::kFNot: std::cout << "fneg "; break; // FNot not standard, map to fneg
|
||||||
case Kind::kFtoI: std::cout << "fptosi "; break;
|
case Kind::kFtoI: std::cout << "fptosi "; break;
|
||||||
|
|||||||
Reference in New Issue
Block a user