Skip to content

Commit

Permalink
amd64: some progress on handling type conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
bl0ckeduser committed Feb 1, 2018
1 parent 4ca4487 commit ce2f749
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions compiler/codegen_amd64.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,14 @@ char *fixreg(char *r, int siz)
new = malloc(64);
sprintf(new, "%%dil");
return new;
} else if (!strcmp(r, "%r8")) {
new = malloc(64);
sprintf(new, "%%r8b");
return new;
} else if (!strcmp(r, "%r9")) {
new = malloc(64);
sprintf(new, "%%r9b");
return new;
}
} else if (siz == 4) {
if (!strcmp(r, "%r8")) {
Expand Down Expand Up @@ -4713,7 +4721,7 @@ char* codegen(exp_tree_t* tree)
printf("IL%d: \n", lab1);
sto = codegen(tree->child[0]);
/* branch if the conditional is false */
str = registerize(sto);
str = registerize_from(sto, type2siz(tree_typeof(tree->child[0])));
str2 = get_temp_reg_siz(8);
printf("movq $0, %s\n", str2);
printf("cmpq %s, %s\n", str, str2);
Expand Down Expand Up @@ -4846,8 +4854,10 @@ char* cheap_relational(exp_tree_t* tree, char *oppcheck)
{
char *sto, *sto2, *sto3;
char *str, *str2;
str = registerize_freemem(codegen(tree->child[0]));
str = registerize_freemem(codegen(tree->child[0]));
str2 = registerize_freemem(codegen(tree->child[1]));
str = registerize_from(str, type2siz(tree_typeof(tree->child[0])));
str2 = registerize_from(str2, type2siz(tree_typeof(tree->child[1])));
printf("cmpq %s, %s\n", str2, str);
free_temp_reg(str);
free_temp_reg(str2);
Expand Down

0 comments on commit ce2f749

Please sign in to comment.