may have function calls, need to merge other stuff to check
This commit is contained in:
@ -663,19 +663,20 @@ int generateParam(Instruction *inst){
|
||||
}
|
||||
|
||||
fprintf(cg_flag, "\tmovl\t%d(%%rbp), %%eax\t#adding param start\n", getAddress(op1CG));
|
||||
fprintf(cg_flag, "\tmovl\t%%eax, %d(%%rbp)\t#adding param end\n", offset += 8);
|
||||
fprintf(cg_flag, "\tmovl\t%%eax, %d(%%rbp)\t#adding param end\n", getPrimSize(getTypeEntry(tn)));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int generateFunctionStart(Instruction *inst) {
|
||||
|
||||
TNodeOrConst *op1 = getOperand1(inst);
|
||||
TNodeOrConst *op1 = getResult(inst);
|
||||
|
||||
if (op1 == NULL) {
|
||||
printdebug("%sgenerateFunctionStart failed, NULL operand", COLOR_RED);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
TableNode *funDecTN = getTN(op1);
|
||||
if (getTN(op1) == NULL) {
|
||||
printdebug("generateFunctionStart failed, NULL tablenode");
|
||||
return -1;
|
||||
@ -686,6 +687,30 @@ int generateFunctionStart(Instruction *inst) {
|
||||
fprintf(cg_flag, "\tpushq\t%%rbp\n");
|
||||
fprintf(cg_flag, "\tmovq\t%%rsp, %%rbp\n");
|
||||
|
||||
//now we need to add the CGs of nodes to the CG list by doing assign from the
|
||||
//now we need to add the CGs of nodes to the CG list by doing assign from the
|
||||
// have function declararation node
|
||||
//declaration ->getType: if record, go through each element and load param from stack and store to correct tn cg
|
||||
// if not, go get one element of type of param
|
||||
//declaration ->getType->getDefinitionScope?: go through first n entries to get table nodes for params
|
||||
|
||||
TableNode *paramTN = getParameter(funDecTN);
|
||||
SymbolTable *st = getFunScope(funDecTN);
|
||||
int paramOffset = -16;
|
||||
if (getAdInfoType(paramTN) != TYPE_RECORD) {
|
||||
CGNode *paramCG = addCG(tn, currentsp);
|
||||
fprintf(cg_flag, "\tmovl\t%d(%%rbp), %%eax\t#FunctionStart1Param start\n", paramOffset);
|
||||
fprintf(cg_flag, "\tmovl\t%%eax, %d(%%rbp)\t#FunctionStart1param end\n", getPrimSize(getTypeEntry(paramTN)));
|
||||
} else {
|
||||
int numParams = getRecLength(paramTN);
|
||||
TableNode *tnToAdd = getFirstEntry(st);
|
||||
for (int i = 0; i < numParams; i++) {
|
||||
CGNode *paramCG = addCG(tnTooAdd, currentsp);
|
||||
fprintf(cg_flag, "\tmovl\t%d(%%rbp), %%eax\t#FunctionStart1Param start\n", paramOffset);
|
||||
fprintf(cg_flag, "\tmovl\t%%eax, %d(%%rbp)\t#FunctionStart1param end\n", getPrimSize(getTypeEntry(paramTN)));
|
||||
paramoffset -= getPrimSize(getTypeEntry(tnToAdd));
|
||||
tnToAdd = getNextEntry(tnToAdd);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user