Closed Serentty closed 4 years ago
Looks like you copy/pasted the wrong thing, but the lea
is indeed there:
clang -target z80 -w -S -O3 -xc - -o - <<<"int strlen(const char* str) { int i; for(i = 0; *str; str++); return i; }"
SEGMENT CODE
.file "-"
XDEF _strlen
_strlen:
push ix
ld ix, 0
add ix, sp
push hl
push hl
push hl
ld l, (ix + 4)
ld h, (ix + 5)
ex (sp), hl
pop iy
ld e, 0
ld hl, 0
ld c, 1
ld d, 0
BB0_1:
ld a, (iy)
cp a, e
ld a, c
jp nz, BB0_2
lea iy, iy + 1
bit 0, a
jp z, BB0_1
jp BB0_4
BB0_2:
ld a, d
lea iy, iy + 1
bit 0, a
jp z, BB0_1
BB0_4:
ld sp, ix
pop ix
ret
So is this an actual issue or am I just screwing up here?
The instruction selector uses LEA on Z80 temporarily to represent frame index addresses which are replaced later, but it incorrectly did the same thing for GEP on Z80. This has been fixed.
Great, thanks!
Okay, so sorry to be annoying, but I don't see any new commits. Were you planning to push this later with a bunch of other changes, or am I looking on the wrong branch?
All the commits keep getting rewritten and rebased on top of the (up-to-date) upstream LLVM ones. You can do git pull --rebase
for instance to get them.
Ah, I was just looking at what GitHub showed as the most recent commit. Thanks.
I compiled this code with -O3:
The compiler generated this assembly, which uses the LEA instruction, which as far as I can tell is an eZ80 instruction not present on the original Z80.