![]() | ![]() | ![]() | Code Generation for Expressions |
code to compute the value of expr1 | |
code to compute the value of expr2 | |
move | expr2's-value,location-for-result |
add | expr1's-value,location-for-result |
We will call these attributes operand descriptors.
operand_desc *expr_gen(node * expr) { operand_desc *left_loc, *right_loc, *new_loc; switch (expr->internal.type) { . . case Nplus: left_loc = expr_gen(expr->internal.child[0]); right_loc = expr_gen(expr->internal.child[1]); new_loc = get_temporary(); output ``move left_loc,new_loc''; output ``add right_loc,new_loc''; opFree(left_loc); opFree(right_loc); return new_loc; } . .
![]() | ![]() | ![]() | Code Generation for Expressions |