[lab2]now 01_add.ll generated by sysy can be compiled to executable by clang
This commit is contained in:
@@ -136,7 +136,8 @@ std::any SysYIRGenerator::visitFuncDef(SysYParser::FuncDefContext* ctx) {
|
||||
irStream << " " << allocaName << " = alloca " << llvmType << ", align 4\n";
|
||||
irStream << " store " << llvmType << " " << symbolTable[varName].first << ", " << llvmType
|
||||
<< "* " << allocaName << ", align 4\n";
|
||||
|
||||
|
||||
symbolTable[varName] = {allocaName, llvmType};
|
||||
}
|
||||
}
|
||||
ctx->blockStmt()->accept(this);
|
||||
@@ -175,7 +176,7 @@ std::any SysYIRGenerator::visitStmt(SysYParser::StmtContext* ctx) {
|
||||
throw std::runtime_error("Invalid float literal: " + rhs);
|
||||
}
|
||||
}
|
||||
irStream << " store1 " << lhsType << " " << rhs << ", " << lhsType
|
||||
irStream << " store " << lhsType << " " << rhs << ", " << lhsType
|
||||
<< "* " << lhsAlloca << ", align 4\n";
|
||||
} else if (ctx->RETURN()) {
|
||||
hasReturn = true;
|
||||
|
||||
Reference in New Issue
Block a user