commit bb11aed3fe91f10503b24b619478e33e407db0df from: Benjamin Stürz date: Wed Oct 02 23:09:00 2024 UTC irc: implement IR_{READ,WRITE} for float types commit - 89082e58f236c93cdcf2079dfe5cd3203972ace2 commit + bb11aed3fe91f10503b24b619478e33e407db0df blob - 16b670eaf3c178d6436b29425d3291f06dfff768 blob + 744ee87454f31e3f248f8b16e82b88116864b584 --- cc/irc/irc.c +++ cc/irc/irc.c @@ -1487,7 +1487,6 @@ struct reg *src; return 0; } -// TODO: use src->dt.type loadf (instr, src) char *instr; struct reg *src; @@ -2199,10 +2198,14 @@ struct expr *e; printf ("\tmov cx, word [%s + %d * 8 + 6]\n", s, e->read.off); break; case DT_FLOAT: + printf ("\tfld dword [%s + %d * 4]\n", s, e->read.off); + break; case DT_DOUBLE: + printf ("\tfld qword [%s + %d * 8]\n", s, e->read.off); + break; case DT_LDOUBLE: - // TODO - error ("EX_READ not implemented for floats"); + printf ("\tfld tword [%s + %d * 10]\n", s, e->read.off); + break; } break; case EX_CALL: @@ -2492,10 +2495,14 @@ struct ir *ir; printf ("\tmov word [%s + %d * 8 + 6], cx\n", reg, ir->write.off); break; case DT_FLOAT: + printf ("\tfstp dword [%s + %d * 4]\n", reg, ir->write.off); + break; case DT_DOUBLE: + printf ("\tfstp qword [%s + %d * 8]\n", reg, ir->write.off); + break; case DT_LDOUBLE: - // TODO: floats - error ("IR_WRITE not implemented for floats"); + printf ("\tfstp tword [%s + %d * 10]\n", reg, ir->write.off); + break; } break; case IR_RET: blob - e8f82398186bfa8a8918662626893d6053c87ed9 blob + dfb0074af5ead8ecf334031ce9837db67e2cb4c8 --- cc/irc/test.ir +++ cc/irc/test.ir @@ -200,7 +200,10 @@ fn floats (): float { let $4: float = mul $0, $1; let $5: float = sdiv $0, $1; let $6: float = $5; - ret $0; + let $7: ^float = alloca 1; + write $7, $6; + let $8: float = read $7; + ret $8; } fn cmp (): word {