commit 89a3dc1caab57953b019b1c86f4e1ca69d5fec05 from: Benjamin Stürz date: Wed Oct 02 21:49:40 2024 UTC irc: remove EX_F{ADD,SUB,MUL,DIV} commit - 1ee10934936c2c6167c18c1553df440a463b8585 commit + 89a3dc1caab57953b019b1c86f4e1ca69d5fec05 blob - 036a435815a2c7df563af0ef0aeac11f18e9200f blob + 68bce4bb61646119f26610f4fa88cab1a79f2501 --- cc/irc/irc.c +++ cc/irc/irc.c @@ -298,10 +298,6 @@ enum expr_type { EX_MUL, // .bin EX_UDIV, // .bin EX_SDIV, // .bin - EX_FADD, // .fbin - EX_FSUB, // .fbin - EX_FMUL, // .fbin - EX_FDIV, // .fbin }; struct call { @@ -328,9 +324,6 @@ struct expr { int l; struct regimm r; } bin; - struct { - int l, r; - } fbin; struct call *call; struct phi *phi; struct { @@ -649,26 +642,6 @@ enum expr_type t; assert_dt_is_int (dt); assert_dt_is_int (&fn->regs[e->reg].dt); - return 0; -} - -expr_fbin (fn, dt, e, t) -struct func *fn; -struct dtype *dt; -struct expr *e; -enum expr_type t; -{ - e->type = t; - expect (TK_REG); - e->fbin.l = lval.i; - expect (','); - expect (TK_REG); - e->fbin.r = lval.i; - expect (';'); - - assert_dt_is_float (dt); - assert_dt_eq (dt, &fn->regs[e->fbin.l].dt); - assert_dt_eq (dt, &fn->regs[e->fbin.r].dt); return 0; } @@ -846,14 +819,6 @@ struct expr *e; assert_dt_is_ptr (&fn->regs[e->reg].dt); if (dt->type != fn->regs[e->reg].dt.type) error ("pcast cannot be used to cast between different types of pointers (eg. SPTR -> FPTR)"); - } else if (strcmp (lval.s, "fadd") == 0) { - expr_fbin (fn, dt, e, EX_FADD); - } else if (strcmp (lval.s, "fsub") == 0) { - expr_fbin (fn, dt, e, EX_FSUB); - } else if (strcmp (lval.s, "fmul") == 0) { - expr_fbin (fn, dt, e, EX_FMUL); - } else if (strcmp (lval.s, "fdiv") == 0) { - expr_fbin (fn, dt, e, EX_FDIV); } else { err: error ("expected expr"); @@ -1252,18 +1217,6 @@ struct expr *e; printf ("asr $%d, ", e->bin.l); print_ri (&e->bin.r); break; - case EX_FADD: - printf ("fadd $%d, $%d", e->fbin.l, e->fbin.r); - break; - case EX_FSUB: - printf ("fsub $%d, $%d", e->fbin.l, e->fbin.r); - break; - case EX_FMUL: - printf ("fmul $%d, $%d", e->fbin.l, e->fbin.r); - break; - case EX_FDIV: - printf ("fdiv $%d, $%d", e->fbin.l, e->fbin.r); - break; } return 0; } @@ -1813,32 +1766,6 @@ struct expr *e; error ("cannot use immediate values for floating-point operations"); load (NULL, acc); load ("fdiv", &fn->regs[ri->reg]); - break; - } - return 0; -} - -fbin (instr, fn, dt, e) -char *instr; -struct func *fn; -struct dtype *dt; -struct expr *e; -{ - switch (dt->type) { - case DT_FLOAT: - printf ("\tfld dword [ss:bp + %d]\n", fn->regs[e->fbin.l].off); - printf ("\t%s dword [ss:bp + %d]\n", instr, fn->regs[e->fbin.r].off); - break; - case DT_NONE: - case DT_LABEL: - case DT_DPTR: - case DT_FPTR: - case DT_SPTR: - case DT_BYTE: - case DT_WORD: - case DT_DWORD: - case DT_QWORD: - abort (); break; } return 0; @@ -2178,19 +2105,7 @@ struct expr *e; break; case EX_ASR: shift (fn, "sar", &fn->regs[e->bin.l], &e->bin.r); - break; - case EX_FADD: - fbin ("fadd", fn, dt, e); break; - case EX_FSUB: - fbin ("fsub", fn, dt, e); - break; - case EX_FMUL: - fbin ("fmul", fn, dt, e); - break; - case EX_FDIV: - fbin ("fdiv", fn, dt, e); - break; } return 0; } blob - 432a4c70acf5e0d518e99f8713e6c2cb56f068fc blob + ffe0840484c6e653a8fd2862aa41252da61d608a --- cc/irc/test.ir +++ cc/irc/test.ir @@ -195,14 +195,10 @@ pub section ".text.custom" fn custom_section (): qword fn floats (): float { let $0: float = 1.2; let $1: float = 42; - let $2: float = fadd $0, $1; - let $3: float = fsub $0, $1; - let $4: float = fmul $0, $1; - let $5: float = fdiv $0, $1; + let $2: float = add $0, $1; + let $3: float = sub $0, $1; + let $4: float = mul $0, $1; + let $5: float = sdiv $0, $1; let $6: float = $5; - let $7: float = add $0, $1; - let $8: float = sub $0, $1; - let $9: float = mul $0, $1; - let $10: float = sdiv $0, $1; ret $0; }