F diff --git a/src/backend/asm/intel/intel_asm.c b/src/backend/asm/intel/intel_asm.c --- a/src/backend/asm/intel/intel_asm.c +++ b/src/backend/asm/intel/intel_asm.c}}+ void lvalue_to_register(struct Compile_Data_Intel_Asm *compile_data,struct Expression_Value *value,enum Intel_Asm_Registers reg)+ {+ size_t value_size;+ value_size=get_expression_value_size(value);+ wonky_assert(value_size<=8 && value->type==VALUE_LVALUE);++ push_intel_asm_instruction(compile_data,intel_asm_get_pop(reg));+ }void release_value_from_stack(struct Compile_Data_Intel_Asm *compile_data,struct Expression_Value *value){release_stack_space(compile_data,get_expression_value_size(value));F diff --git a/src/backend/asm/intel/intel_asm.h b/src/backend/asm/intel/intel_asm.h --- a/src/backend/asm/intel/intel_asm.h +++ b/src/backend/asm/intel/intel_asm.hstruct Intel_Asm_Memory_Location* reserve_space_for_value_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct Expression_Value *value);void rvalue_to_register(struct Compile_Data_Intel_Asm *compile_data,struct Expression_Value *value,enum Intel_Asm_Registers reg);+ void lvalue_to_register(struct Compile_Data_Intel_Asm *compile_data,struct Expression_Value *value,enum Intel_Asm_Registers reg);void release_value_from_stack(struct Compile_Data_Intel_Asm *compile_data,struct Expression_Value *value);struct Intel_Asm_Memory_Location* reserve_stack_space_for_object(struct Compile_Data_Intel_Asm *compile_data,struct Object *object);F diff --git a/src/backend/asm/intel/intel_compile.c b/src/backend/asm/intel/intel_compile.c --- a/src/backend/asm/intel/intel_compile.c +++ b/src/backend/asm/intel/intel_compile.c}void compile_postfix_inc_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Unary_Expression *unary){- push_intel_asm_instruction(compile_data,get_intel_asm_simple_instruction(INTEL_ASM_OP_NOP));+ compile_postfix_inc_dec_inner(compile_data,unary,INTEL_ASM_OP_INC);}void compile_postfix_dec_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Unary_Expression *unary){- push_intel_asm_instruction(compile_data,get_intel_asm_simple_instruction(INTEL_ASM_OP_NOP));+ compile_postfix_inc_dec_inner(compile_data,unary,INTEL_ASM_OP_DEC);}void compile_prefix_inc_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Unary_Expression *unary){- push_intel_asm_instruction(compile_data,get_intel_asm_simple_instruction(INTEL_ASM_OP_NOP));+ compile_prefix_inc_dec_inner(compile_data,unary,INTEL_ASM_OP_INC);}void compile_prefix_dec_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Unary_Expression *unary){- push_intel_asm_instruction(compile_data,get_intel_asm_simple_instruction(INTEL_ASM_OP_NOP));+ compile_prefix_inc_dec_inner(compile_data,unary,INTEL_ASM_OP_DEC);}void compile_unary_plus_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Unary_Expression *unary){- push_intel_asm_instruction(compile_data,get_intel_asm_simple_instruction(INTEL_ASM_OP_NOP));+ compile_ast_to_intel_asm(compile_data,(struct AST*)unary->operand);}void compile_unary_minus_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Unary_Expression *unary){- push_intel_asm_instruction(compile_data,get_intel_asm_simple_instruction(INTEL_ASM_OP_NOP));+ compile_ast_to_intel_asm(compile_data,(struct AST*)unary->operand);+ rvalue_to_register(compile_data,unary->operand->value,INTEL_ASM_REGISTER_RAX);+ push_intel_asm_instruction(compile_data,get_intel_asm_unary_instruction(get_intel_asm_register(INTEL_ASM_REGISTER_RAX),INTEL_ASM_OP_NEG));+ push_intel_asm_instruction(compile_data,intel_asm_get_push(INTEL_ASM_REGISTER_RAX));}void compile_cast_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Unary_Expression *unary){push_intel_asm_instruction(compile_data,intel_asm_get_push(INTEL_ASM_REGISTER_RAX));}+ void compile_prefix_inc_dec_inner(struct Compile_Data_Intel_Asm *compile_data,struct AST_Unary_Expression *unary,enum Intel_Asm_Instruction_Type op)+ {+ compile_ast_to_intel_asm(compile_data,(struct AST*)unary->operand);+ lvalue_to_register(compile_data,unary->operand->value,INTEL_ASM_REGISTER_RAX);+ push_intel_asm_instruction(compile_data,get_intel_asm_unary_instruction(get_intel_asm_by_register(INTEL_ASM_REGISTER_RAX),op));+ push_intel_asm_instruction(compile_data,get_intel_asm_binary_instruction(get_intel_asm_register(INTEL_ASM_REGISTER_RDX),get_intel_asm_by_register(INTEL_ASM_REGISTER_RAX),INTEL_ASM_OP_MOV));+ push_intel_asm_instruction(compile_data,intel_asm_get_push(INTEL_ASM_REGISTER_RDX));++ }+ void compile_postfix_inc_dec_inner(struct Compile_Data_Intel_Asm *compile_data,struct AST_Unary_Expression *unary,enum Intel_Asm_Instruction_Type op)+ {+ compile_ast_to_intel_asm(compile_data,(struct AST*)unary->operand);+ lvalue_to_register(compile_data,unary->operand->value,INTEL_ASM_REGISTER_RAX);+ push_intel_asm_instruction(compile_data,get_intel_asm_binary_instruction(get_intel_asm_register(INTEL_ASM_REGISTER_RDX),get_intel_asm_by_register(INTEL_ASM_REGISTER_RAX),INTEL_ASM_OP_MOV));+ push_intel_asm_instruction(compile_data,get_intel_asm_unary_instruction(get_intel_asm_by_register(INTEL_ASM_REGISTER_RAX),op));+ push_intel_asm_instruction(compile_data,intel_asm_get_push(INTEL_ASM_REGISTER_RDX));+ }#endifF diff --git a/src/backend/asm/intel/intel_compile.h b/src/backend/asm/intel/intel_compile.h --- a/src/backend/asm/intel/intel_compile.h +++ b/src/backend/asm/intel/intel_compile.hvoid compile_equal_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Binary_Expression *bin);void compile_not_equal_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Binary_Expression *bin);+ void compile_prefix_inc_dec_inner(struct Compile_Data_Intel_Asm *compile_data,struct AST_Unary_Expression *unary,enum Intel_Asm_Instruction_Type op);+ void compile_postfix_inc_dec_inner(struct Compile_Data_Intel_Asm *compile_data,struct AST_Unary_Expression *unary,enum Intel_Asm_Instruction_Type op);+#endifF diff --git a/src/backend/asm/intel/intel_instruction.c b/src/backend/asm/intel/intel_instruction.c --- a/src/backend/asm/intel/intel_instruction.c +++ b/src/backend/asm/intel/intel_instruction.c[INTEL_ASM_OP_SAL]=(map_entry)save_intel_asm_binary_instruction,[INTEL_ASM_OP_SAR]=(map_entry)save_intel_asm_binary_instruction,[INTEL_ASM_OP_PUSH]=(map_entry)save_intel_asm_unary_instruction,+ [INTEL_ASM_OP_NEG]=(map_entry)save_intel_asm_unary_instruction,+ [INTEL_ASM_OP_INC]=(map_entry)save_intel_asm_unary_instruction,+ [INTEL_ASM_OP_DEC]=(map_entry)save_intel_asm_unary_instruction,[INTEL_ASM_OP_DEFINE_BYTES]=(map_entry)save_intel_asm_define_bytes,};wonky_assert(map[instruction->type]!=NULL);[INTEL_ASM_OP_SETG]="SETG",[INTEL_ASM_OP_SETAE]="SETAE",[INTEL_ASM_OP_SETBE]="SETBE",+ [INTEL_ASM_OP_NEG]="NEG",+ [INTEL_ASM_OP_INC]="INC",+ [INTEL_ASM_OP_DEC]="DEC",};wonky_assert(map[unary->type]!=NULL);fprintf(out,"%s ",map[unary->type]);F diff --git a/src/backend/asm/intel/intel_instruction.hh b/src/backend/asm/intel/intel_instruction.hh --- a/src/backend/asm/intel/intel_instruction.hh +++ b/src/backend/asm/intel/intel_instruction.hhINTEL_ASM_OP_SAL,INTEL_ASM_OP_SAR,INTEL_ASM_OP_PUSH,+ INTEL_ASM_OP_NEG,+ INTEL_ASM_OP_INC,+ INTEL_ASM_OP_DEC,INTEL_ASM_OP_DEFINE_BYTES,INTEL_ASM_OP_EXPORT,INTEL_ASM_OP_IMPORT,F diff --git a/src/backend/asm/intel/intel_location.c b/src/backend/asm/intel/intel_location.c --- a/src/backend/asm/intel/intel_location.c +++ b/src/backend/asm/intel/intel_location.c}void save_intel_asm_by_stack_offset_location(struct Intel_Asm_Memory_Location_By_Stack_Offset *sp,FILE *out){- fprintf(out,"[RBP-%d]",sp->offset);+ fprintf(out,"QWORD [RBP-%d]",sp->offset);}void save_intel_asm_stack_offset_location(struct Intel_Asm_Memory_Location_By_Stack_Offset *sp,FILE *out){- fprintf(out,"[RBP-%d]",sp->offset);+ fprintf(out,"QWORD [RBP-%d]",sp->offset);}void save_intel_asm_by_register_location(struct Intel_Asm_Memory_Location_By_Register *reg,FILE *out){wonky_assert(register_map[reg->reg]!=NULL);- fprintf(out,"[%s]",register_map[reg->reg]);+ fprintf(out,"QWORD[%s]",register_map[reg->reg]);}void save_intel_asm_register_location(struct Intel_Asm_Memory_Location_Register *reg,FILE *out){