updated number of bytes used
This commit is contained in:
@ -536,8 +536,24 @@ int generateAssign(Instruction *inst) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (getAdInfoType(getTN(op1)) != TYPE_FUNCTION_DECLARATION || table_lookup(getAncestor(cur), getName(getTN(op1))) == undefined){
|
if (getAdInfoType(getTN(op1)) != TYPE_FUNCTION_DECLARATION || table_lookup(getAncestor(cur), getName(getTN(op1))) == undefined){
|
||||||
fprintf(cg_flag, "\tmovl\t%d(%%rbp), %%eax\t#assign start\n", getAddress(op1CG));
|
char *movtype;
|
||||||
fprintf(cg_flag, "\tmovl\t%%eax, %d(%%rbp)\t#assign end\n", getAddress(cg));
|
char *reg;
|
||||||
|
TableNode *typetn = getTypeEntry(getTN(op1));
|
||||||
|
if (typetn == integ) {
|
||||||
|
movtype = "movl";
|
||||||
|
reg = "%eax";
|
||||||
|
} else if (typetn == boo) {
|
||||||
|
movtype = "movb";
|
||||||
|
reg = "%al";
|
||||||
|
} else if (typetn == chara) {
|
||||||
|
movtype = "movb";
|
||||||
|
reg = "%al";
|
||||||
|
} else {
|
||||||
|
movtype = "movq";
|
||||||
|
reg = "%rax";
|
||||||
|
}
|
||||||
|
fprintf(cg_flag, "\t%s\t%d(%%rbp), %s\t#assign start\n",movtype, getAddress(op1CG), reg);
|
||||||
|
fprintf(cg_flag, "\t%s\t%s, %d(%%rbp)\t#assign end\n", movtype,reg,getAddress(cg));
|
||||||
} else {
|
} else {
|
||||||
fprintf(cg_flag, "\tmovl\t$%s,%%eax\t#assign function\n", getName(getTN(op1)));
|
fprintf(cg_flag, "\tmovl\t$%s,%%eax\t#assign function\n", getName(getTN(op1)));
|
||||||
fprintf(cg_flag, "\tmovl\t%%eax, %d(%%rbp)\t#assign function end\n", getAddress(cg));
|
fprintf(cg_flag, "\tmovl\t%%eax, %d(%%rbp)\t#assign function end\n", getAddress(cg));
|
||||||
@ -746,7 +762,7 @@ int generateAddressOf(Instruction *inst) {
|
|||||||
|
|
||||||
int generateParam(Instruction *inst) {
|
int generateParam(Instruction *inst) {
|
||||||
TNodeOrConst *op1 = getOperand1(inst);
|
TNodeOrConst *op1 = getOperand1(inst);
|
||||||
fprintf(stderr, "generate param reached\n");
|
//fprintf(stderr, "generate param reached\n");
|
||||||
if (op1 == NULL) {
|
if (op1 == NULL) {
|
||||||
printdebug("generateParam failed, NULL operand");
|
printdebug("generateParam failed, NULL operand");
|
||||||
return -1;
|
return -1;
|
||||||
|
Reference in New Issue
Block a user