fixed everything breaking i think
This commit is contained in:
@ -85,6 +85,7 @@ int generate() {
|
||||
break;
|
||||
case E_FUNC_DEC:
|
||||
generateFunctionDec(i);
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
i = i->next;
|
||||
@ -388,10 +389,10 @@ int generateOr(Instruction *inst) {
|
||||
|
||||
int label = label_gen();
|
||||
|
||||
fprintf(cg_flag, "\tcmpl\t$0, %d(%%rbp)\t#start or\n", getAddress(op1CG));
|
||||
fprintf(cg_flag, "\tcmpb\t$0, %d(%%rbp)\t#start or\n", getAddress(op1CG));
|
||||
fprintf(cg_flag, "\tjne\t.L%dor2\n", label);
|
||||
|
||||
fprintf(cg_flag, "\tcmpl\t$0, %d(%%rbp)\n", getAddress(op2CG));
|
||||
fprintf(cg_flag, "\tcmpb\t$0, %d(%%rbp)\n", getAddress(op2CG));
|
||||
fprintf(cg_flag, "\tje\t.L%dor3\n", label);
|
||||
|
||||
fprintf(cg_flag, ".L%dor2:\n", label);
|
||||
@ -439,10 +440,10 @@ int generateAnd(Instruction *inst) {
|
||||
}
|
||||
int label = label_gen();
|
||||
|
||||
fprintf(cg_flag, "\tcmpl\t$0, %d(%%rbp)\t#start and\n", getAddress(op1CG));
|
||||
fprintf(cg_flag, "\tcmpb\t$0, %d(%%rbp)\t#start and\n", getAddress(op1CG));
|
||||
fprintf(cg_flag, "\tje\t.L%dor2\n", label);
|
||||
|
||||
fprintf(cg_flag, "\tcmpl\t$0, %d(%%rbp)\n", getAddress(op2CG));
|
||||
fprintf(cg_flag, "\tcmpb\t$0, %d(%%rbp)\n", getAddress(op2CG));
|
||||
fprintf(cg_flag, "\tje\t.L%dor2\n", label);
|
||||
|
||||
fprintf(cg_flag, "\tmovl\t$1, %%eax\n");
|
||||
@ -534,7 +535,7 @@ int generateAssign(Instruction *inst) {
|
||||
printdebug("generateAssign failed, %s is not constant but not in CGlist", getName(getTN(op1)));
|
||||
return -1;
|
||||
}
|
||||
if (getAdInfoType(getTN(op1)) != TYPE_FUNCTION_DECLARATION || !isAnActualFunction(getTN(op1))){
|
||||
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));
|
||||
fprintf(cg_flag, "\tmovl\t%%eax, %d(%%rbp)\t#assign end\n", getAddress(cg));
|
||||
} else {
|
||||
@ -724,7 +725,7 @@ int generateReturn(Instruction *inst) {
|
||||
printdebug("generateReturn failed, trying to return %s not in CGList", getName(getTN(op1)));
|
||||
return -1;
|
||||
}
|
||||
if (isAnActualFunction(getTN(op1))) {
|
||||
if (table_lookup(getAncestor(cur), getName(getTN(op1))) != undefined) {
|
||||
fprintf(cg_flag, "\tmovl\t$%s,%%eax\t#return a function\n", getName(getTN(op1)));
|
||||
} else {
|
||||
fprintf(cg_flag, "\tmovl\t%d(%%rbp), %%eax\t#return %s\n", getAddress(cg), getName(getTN(op1)));
|
||||
@ -851,7 +852,7 @@ int generateFunctionStart(Instruction *inst) {
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp(getName(funDecTN), "entry") == 0) {
|
||||
/* if (strcmp(getName(funDecTN), "entry") == 0) {
|
||||
if (funList == NULL) {
|
||||
return -1;
|
||||
}
|
||||
@ -862,6 +863,6 @@ int generateFunctionStart(Instruction *inst) {
|
||||
fprintf(cg_flag, "\tmovq\t$%s, %d(%%rbp)\t#storing function declaration\n", getName(funDec), getAddress(cg));
|
||||
funList = funList->next;
|
||||
}
|
||||
}
|
||||
} */
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user