mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 21:21:48 +03:00
carith and more branch logic (#21002)
* carith() function in exe1.c tests * more branch logic
This commit is contained in:
parent
142d509af2
commit
7d3293c45d
1 changed files with 14 additions and 10 deletions
|
@ -109,7 +109,8 @@ void REGSAVE_restore(const ref REGSAVE regsave, ref CodeBuilder cdb, reg_t reg,
|
||||||
|
|
||||||
|
|
||||||
// https://www.scs.stanford.edu/~zyedidia/arm64/b_cond.html
|
// https://www.scs.stanford.edu/~zyedidia/arm64/b_cond.html
|
||||||
bool isBranch(uint ins) { return (ins & ((0xFF << 24) | (1 << 4))) == ((0x54 << 24) | (0 << 4)); }
|
// https://www.scs.stanford.edu/~zyedidia/arm64/bc_cond.html
|
||||||
|
bool isBranch(uint ins) { return (ins & 0xFF00_0000) == 0x5400_0000; }
|
||||||
|
|
||||||
enum MARS = true;
|
enum MARS = true;
|
||||||
|
|
||||||
|
@ -1496,7 +1497,7 @@ printf("offset: %lld localsize: %lld REGSIZE*2: %d\n", offset, localsize, REGSIZ
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (0) printf("FL: %s\n", fl_str(c.IFL1));
|
if (1) printf("FL: %s\n", fl_str(c.IFL1));
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1517,10 +1518,10 @@ printf("offset: %lld localsize: %lld REGSIZE*2: %d\n", offset, localsize, REGSIZ
|
||||||
@trusted
|
@trusted
|
||||||
void jmpaddr(code* c)
|
void jmpaddr(code* c)
|
||||||
{
|
{
|
||||||
code* ci,cn,ctarg,cstart;
|
|
||||||
targ_size_t ad;
|
|
||||||
|
|
||||||
//printf("jmpaddr()\n");
|
//printf("jmpaddr()\n");
|
||||||
|
|
||||||
|
code* ci,cn,ctarg,cstart;
|
||||||
|
uint ad;
|
||||||
cstart = c; /* remember start of code */
|
cstart = c; /* remember start of code */
|
||||||
while (c)
|
while (c)
|
||||||
{
|
{
|
||||||
|
@ -1538,7 +1539,7 @@ void jmpaddr(code* c)
|
||||||
}
|
}
|
||||||
if (!ci)
|
if (!ci)
|
||||||
goto Lbackjmp; // couldn't find it
|
goto Lbackjmp; // couldn't find it
|
||||||
c.Iop |= cast(uint)(ad >> 2) << 5;
|
c.Iop |= (ad >> 2) << 5;
|
||||||
c.IFL1 = FL.unde;
|
c.IFL1 = FL.unde;
|
||||||
}
|
}
|
||||||
if (op == LOOP && c.IFL1 == FL.code) /* backwards refs */
|
if (op == LOOP && c.IFL1 == FL.code) /* backwards refs */
|
||||||
|
@ -1555,7 +1556,7 @@ void jmpaddr(code* c)
|
||||||
ad += calccodsize(ci);
|
ad += calccodsize(ci);
|
||||||
ci = code_next(ci);
|
ci = code_next(ci);
|
||||||
}
|
}
|
||||||
c.Iop = cast(uint)(-(ad >> 2)) << 5;
|
c.Iop = (-(ad >> 2)) << 5;
|
||||||
c.IFL1 = FL.unde;
|
c.IFL1 = FL.unde;
|
||||||
}
|
}
|
||||||
c = code_next(c);
|
c = code_next(c);
|
||||||
|
@ -1605,8 +1606,7 @@ uint calccodsize(code* c)
|
||||||
@trusted
|
@trusted
|
||||||
uint codout(int seg, code* c, Barray!ubyte* disasmBuf, ref targ_size_t framehandleroffset)
|
uint codout(int seg, code* c, Barray!ubyte* disasmBuf, ref targ_size_t framehandleroffset)
|
||||||
{
|
{
|
||||||
code* cn;
|
//printf("codout()\n");
|
||||||
uint flags;
|
|
||||||
|
|
||||||
debug
|
debug
|
||||||
if (debugc) printf("codout(%p), Coffset = x%llx\n",c,cast(ulong)Offset(seg));
|
if (debugc) printf("codout(%p), Coffset = x%llx\n",c,cast(ulong)Offset(seg));
|
||||||
|
@ -1618,6 +1618,9 @@ uint codout(int seg, code* c, Barray!ubyte* disasmBuf, ref targ_size_t framehand
|
||||||
ggen.framehandleroffset = framehandleroffset;
|
ggen.framehandleroffset = framehandleroffset;
|
||||||
ggen.disasmBuf = disasmBuf;
|
ggen.disasmBuf = disasmBuf;
|
||||||
|
|
||||||
|
code* cn;
|
||||||
|
uint flags;
|
||||||
|
|
||||||
for (; c; c = code_next(c))
|
for (; c; c = code_next(c))
|
||||||
{
|
{
|
||||||
debug
|
debug
|
||||||
|
@ -1681,7 +1684,8 @@ uint codout(int seg, code* c, Barray!ubyte* disasmBuf, ref targ_size_t framehand
|
||||||
if (ggen.available() < 4)
|
if (ggen.available() < 4)
|
||||||
ggen.flush();
|
ggen.flush();
|
||||||
|
|
||||||
if (c.IFL1 == FL.block) // branch to a block - compute offset
|
if (isBranch(op) && c.IFL1 == FL.block)
|
||||||
|
|
||||||
{
|
{
|
||||||
ggen.flush();
|
ggen.flush();
|
||||||
int ad = cast(int)(c.IEV1.Vblock.Boffset - ggen.offset);
|
int ad = cast(int)(c.IEV1.Vblock.Boffset - ggen.offset);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue