Skip to content

Commit

Permalink
make FL a ubyte (#15457)
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Jul 25, 2023
1 parent c3c46ff commit 7ba1b40
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions compiler/src/dmd/backend/cc.d
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,7 @@ struct Symbol
//#endif

SC Sclass; // storage class (SCxxxx)
char Sfl; // flavor (FLxxxx)
FL Sfl; // flavor (FLxxxx)
SYMFLGS Sflags; // flag bits (SFLxxxx)

vec_t Srange; // live range, if any
Expand Down Expand Up @@ -1344,7 +1344,7 @@ void param_debug(const param_t *p)
* These should be combined with storage classes.
*/

alias FL = int;
alias FL = ubyte;
enum
{
// Change this, update debug.c too
Expand Down
7 changes: 4 additions & 3 deletions compiler/src/dmd/backend/cod1.d
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,8 @@ void getlvalue_lsw(code *c)
@trusted
void getlvalue(ref CodeBuilder cdb,code *pcs,elem *e,regm_t keepmsk)
{
uint fl, f, opsave;
FL fl;
uint f, opsave;
elem* e1, e11, e12;
bool e1isadd, e1free;
reg_t reg;
Expand Down Expand Up @@ -1658,7 +1659,7 @@ void getlvalue(ref CodeBuilder cdb,code *pcs,elem *e,regm_t keepmsk)
break;

default:
WRFL(cast(FL)fl);
WRFL(fl);
symbol_print(s);
assert(0);
}
Expand Down Expand Up @@ -3915,7 +3916,7 @@ private void funccall(ref CodeBuilder cdb, elem* e, uint numpara, uint numalign,
// Function calls may throw Errors
funcsym_p.Sfunc.Fflags3 &= ~Fnothrow;

if (e1.Eoper != OPind) { WRFL(cast(FL)el_fl(e1)); printf("e1.Eoper: %s\n", oper_str(e1.Eoper)); }
if (e1.Eoper != OPind) { WRFL(el_fl(e1)); printf("e1.Eoper: %s\n", oper_str(e1.Eoper)); }
save87(cdb); // assume 8087 regs are all trashed
assert(e1.Eoper == OPind);
elem *e11 = e1.EV.E1;
Expand Down
25 changes: 12 additions & 13 deletions compiler/src/dmd/backend/cod3.d
Original file line number Diff line number Diff line change
Expand Up @@ -5611,7 +5611,7 @@ targ_size_t cod3_bpoffset(Symbol *s)
break;

default:
WRFL(cast(FL)s.Sfl);
WRFL(s.Sfl);
symbol_print(s);
assert(0);
}
Expand Down Expand Up @@ -6180,7 +6180,7 @@ void pinholeopt(code *c,block *b)
break;

default:
WRFL(cast(FL)c.IFL2);
WRFL(c.IFL2);
assert(0);
}
break;
Expand Down Expand Up @@ -7186,7 +7186,7 @@ uint codout(int seg, code *c, Barray!ubyte* disasmBuf)
goto ptr1632;

case 0x68: // PUSH immed32
if (cast(FL)c.IFL2 == FLblock)
if (c.IFL2 == FLblock)
{
c.IFL2 = FLblockoff;
goto do32;
Expand Down Expand Up @@ -7253,7 +7253,7 @@ uint codout(int seg, code *c, Barray!ubyte* disasmBuf)
break;

case 0x68: // PUSH immed16
if (cast(FL)c.IFL2 == FLblock)
if (c.IFL2 == FLblock)
{ c.IFL2 = FLblockoff;
goto do16;
}
Expand Down Expand Up @@ -7690,25 +7690,24 @@ private void do16bit(ref MiniCodeBuf pbuf, FL fl, ref evc uev,int flags)
@trusted
private void do8bit(ref MiniCodeBuf pbuf, FL fl, ref evc uev)
{
char c;
targ_ptrdiff_t delta;
ubyte c;

switch (fl)
{
case FLconst:
c = cast(char)uev.Vuns;
c = cast(ubyte)uev.Vuns;
break;

case FLblock:
delta = uev.Vblock.Boffset - pbuf.getOffset() - 1;
targ_ptrdiff_t delta = uev.Vblock.Boffset - pbuf.getOffset() - 1;
if (cast(byte)delta != delta)
{
if (uev.Vblock.Bsrcpos.Slinnum)
printf("%s(%d): ", uev.Vblock.Bsrcpos.Sfilename, uev.Vblock.Bsrcpos.Slinnum);
printf("block displacement of %lld exceeds the maximum offset of -128 to 127.\n", cast(long)delta);
err_exit();
}
c = cast(char)delta;
c = cast(ubyte)delta;
debug assert(uev.Vblock.Boffset > pbuf.getOffset() || c != 0x7F);
break;

Expand Down Expand Up @@ -7847,22 +7846,22 @@ extern (C) void code_print(scope code* c)
case FLtlsdata:
case FLextern:
printf(" ");
WRFL(cast(FL)c.IFL1);
WRFL(c.IFL1);
printf(" sym='%s'",c.IEV1.Vsym.Sident.ptr);
if (c.IEV1.Voffset)
printf(".%d", cast(int)c.IEV1.Voffset);
break;

default:
WRFL(cast(FL)c.IFL1);
WRFL(c.IFL1);
break;
}
}
}
if (ins & T)
{
printf(" ");
WRFL(cast(FL)c.IFL2);
WRFL(c.IFL2);
switch (c.IFL2)
{
case FLconst:
Expand Down Expand Up @@ -7901,7 +7900,7 @@ extern (C) void code_print(scope code* c)
break;

default:
WRFL(cast(FL)c.IFL2);
WRFL(c.IFL2);
break;
}
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dmd/backend/code_x86.d
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module dmd.backend.code_x86;
// Online documentation: https://dlang.org/phobos/dmd_backend_code_x86.html

import dmd.backend.cdef;
import dmd.backend.cc : config;
import dmd.backend.cc : config, FL;
import dmd.backend.code;
import dmd.backend.codebuilder : CodeBuilder;
import dmd.backend.el : elem;
Expand Down Expand Up @@ -370,7 +370,7 @@ struct code
* operand, usually for immediate instructions.
*/

ubyte IFL1,IFL2; // FLavors of 1st, 2nd operands
FL IFL1,IFL2; // FLavors of 1st, 2nd operands
evc IEV1; // 1st operand, if any
evc IEV2; // 2nd operand, if any

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dmd/backend/el.d
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void elem_debug(const elem* e)
}

@trusted
FL el_fl(const elem* e) { return cast(FL)e.EV.Vsym.Sfl; }
FL el_fl(const elem* e) { return e.EV.Vsym.Sfl; }

//#define Eoffset EV.sp.Voffset
//#define Esymnum EV.sp.Vsymnum
Expand Down

0 comments on commit 7ba1b40

Please sign in to comment.