More Watcom optimizations.

This commit is contained in:
Markus F.X.J. Oberhumer 2007-02-18 04:41:33 +01:00
parent d3bc84a2f7
commit 0323560b49
6 changed files with 2261 additions and 2425 deletions

File diff suppressed because it is too large Load Diff

View File

@ -121,6 +121,9 @@ def main(argv):
return []
o = olines[pos][1:3]
assert len(m[i]) == 2, (i, m)
if o[1] == "*DEL*":
pos += 1
continue
m0 = match(m[i][0], o[0])
m1 = match(m[i][1], o[1])
if not m0 or not m1:
@ -181,8 +184,13 @@ def main(argv):
if v[:2] == [1, 2]: # external 2-byte
if k in ["__LMUL", "__U4M",]:
s = [
["mov", "bx,word ptr [bx]"],
["xor", "cx,cx"],
]
dpos = omatch(i - 2, s[-2:])
if 0 and dpos:
orewrite_inst(i, "M_LMUL_dxax_00bx_ptr", "", dpos)
continue
dpos = omatch(i - 1, s[-1:])
if dpos:
orewrite_inst(i, "M_LMUL_dxax_00bx", "", dpos)
@ -243,9 +251,35 @@ def main(argv):
dpos2 = omatch(i + 1, s2)
dpos3 = omatch(i + 1, s3)
if dpos1 and (dpos2 or dos3):
m = "M_shld_8_bp %s %s" % (dpos1[-2][2].group(1), dpos1[-1][2].group(1))
bp_dx, bp_ax = dpos1[-1][2].group(1), dpos1[-2][2].group(1)
m = "M_shld_8_bp %s %s" % (bp_dx, bp_ax)
orewrite_inst(i, m, "", dpos1)
continue
s1 = [
["mov", r"^word ptr \[bp([+-]\d+)\],si$"],
["mov", r"^word ptr \[bp([+-]\d+)\],di$"],
["mov", r"^c[lx],0xb$"],
["shr", r"^word ptr \[bp([+-]\d+)\],1$"],
["rcr", r"^word ptr \[bp([+-]\d+)\],1$"],
]
s2 = [
["mov", r"^bx,word ptr"],
["mov", r"^bx,word ptr"],
["mov", r"^ax,word ptr \[bp([+-]\d+)\]$"],
["mov", r"^dx,word ptr \[bp([+-]\d+)\]$"],
]
dpos1 = omatch(i - 5, s1[-5:])
dpos2 = omatch(i + 1, s2)
if dpos1 and dpos2:
bp_dx, bp_ax = dpos1[-2][2].group(1), dpos1[-1][2].group(1)
bp_di, bp_si = dpos1[-4][2].group(1), dpos1[-5][2].group(1)
assert bp_dx == dpos2[-1][2].group(1)
assert bp_ax == dpos2[-2][2].group(1)
assert bp_dx == bp_di
assert bp_ax == bp_si
m = "M_shrd_11_disi_bp %s %s" % (bp_dx, bp_ax)
orewrite_inst(i, m, "", dpos1 + dpos2[-2:])
continue
#
if inst in [
"call", "ja", "jae", "jb", "jbe", "jcxz", "je",

View File

@ -86,13 +86,10 @@
//xor cx, cx // FIXME - do we need this ?
.endm
.macro M_shld_8_bp l h
.macro M_shld_8_bp h l
mov dx, word ptr[bp+h]
mov ax, word ptr[bp+l]
mov dh, dl
mov dl, ah
mov ah, al
xor al, al
M_shld_8
mov word ptr[bp+h], dx
mov word ptr[bp+l], ax
.endm
@ -100,7 +97,7 @@
// shld: dx:ax >>= 11
.macro M_shrd_11
#if 1
#if 0
mov al, ah
mov ah, dl
mov dl, dh
@ -112,6 +109,7 @@
shr dx
rcr ax
#else
// WARNING: this trashes "bx" !
mov cl, 11
mov bx, dx // save dx
shr ax, cl
@ -123,6 +121,22 @@
//xor cx, cx // FIXME - do we need this ?
.endm
.macro M_shrd_11_bp h l
mov dx, word ptr[bp+h]
mov ax, word ptr[bp+l]
M_shrd_11
mov word ptr[bp+h], dx
mov word ptr[bp+l], ax
.endm
.macro M_shrd_11_disi_bp h l
mov dx, di
mov ax, si
M_shrd_11
mov word ptr[bp+h], dx
mov word ptr[bp+l], ax
.endm
// shld: dx:ax <<= cl; trashes cl and register "r1" (bx, di, si or bp)
// REQUIRED: 0 <= cl <= 15
@ -202,7 +216,7 @@ section LZMA_DEC00
push ds
mov bp, sp
#if 1
#if 0
// DEBUG - check for enough stack
lea bx, [bp + lzma_stack_adjust - 256]
cmp bp, bx
@ -286,5 +300,4 @@ section LZMA_DEC31
mov es, ax
// vi:ts=4:et

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -45,26 +45,26 @@ Idx Name Size VMA LMA File off Algn Flags
40 N2E64K02 0000000b 00000000 00000000 00000290 2**0 CONTENTS, READONLY
41 NRV2EEX9 00000004 00000000 00000000 0000029b 2**0 CONTENTS, READONLY
42 LZMA_DEC99 00000000 00000000 00000000 0000029f 2**0 CONTENTS, READONLY
43 LZMA_DEC00 00000043 00000000 00000000 0000029f 2**0 CONTENTS, RELOC, READONLY
44 LZMA_DEC10 00001197 00000000 00000000 000002e2 2**0 CONTENTS, READONLY
45 LZMA_DEC20 00001197 00000000 00000000 00001479 2**0 CONTENTS, READONLY
46 LZMA_DEC30 00000006 00000000 00000000 00002610 2**0 CONTENTS, RELOC, READONLY
47 LZMA_DEC31 00000007 00000000 00000000 00002616 2**0 CONTENTS, RELOC, READONLY
48 EXEMAIN5 00000001 00000000 00000000 0000261d 2**0 CONTENTS, READONLY
49 EXEADJUS 00000007 00000000 00000000 0000261e 2**0 CONTENTS, READONLY
50 EXENOADJ 00000002 00000000 00000000 00002625 2**0 CONTENTS, READONLY
51 EXERELO1 0000001e 00000000 00000000 00002627 2**0 CONTENTS, RELOC, READONLY
52 EXEREL9A 00000012 00000000 00000000 00002645 2**0 CONTENTS, RELOC, READONLY
53 EXERELO2 00000004 00000000 00000000 00002657 2**0 CONTENTS, READONLY
54 EXEREBIG 00000002 00000000 00000000 0000265b 2**0 CONTENTS, RELOC, READONLY
55 EXERELO3 00000002 00000000 00000000 0000265d 2**0 CONTENTS, RELOC, READONLY
56 EXEMAIN8 00000003 00000000 00000000 0000265f 2**0 CONTENTS, READONLY
57 DEVICEEND 00000013 00000000 00000000 00002662 2**0 CONTENTS, READONLY
58 EXESTACK 00000006 00000000 00000000 00002675 2**0 CONTENTS, RELOC, READONLY
59 EXESTASP 00000003 00000000 00000000 0000267b 2**0 CONTENTS, RELOC, READONLY
60 EXEJUMPF 00000005 00000000 00000000 0000267e 2**0 CONTENTS, RELOC, READONLY
61 EXERCSPO 00000004 00000000 00000000 00002683 2**0 CONTENTS, RELOC, READONLY
62 EXERETIP 00000006 00000000 00000000 00002687 2**0 CONTENTS, RELOC, READONLY
43 LZMA_DEC00 0000003b 00000000 00000000 0000029f 2**0 CONTENTS, RELOC, READONLY
44 LZMA_DEC10 000011a4 00000000 00000000 000002da 2**0 CONTENTS, READONLY
45 LZMA_DEC20 000011a4 00000000 00000000 0000147e 2**0 CONTENTS, READONLY
46 LZMA_DEC30 00000006 00000000 00000000 00002622 2**0 CONTENTS, RELOC, READONLY
47 LZMA_DEC31 00000007 00000000 00000000 00002628 2**0 CONTENTS, RELOC, READONLY
48 EXEMAIN5 00000001 00000000 00000000 0000262f 2**0 CONTENTS, READONLY
49 EXEADJUS 00000007 00000000 00000000 00002630 2**0 CONTENTS, READONLY
50 EXENOADJ 00000002 00000000 00000000 00002637 2**0 CONTENTS, READONLY
51 EXERELO1 0000001e 00000000 00000000 00002639 2**0 CONTENTS, RELOC, READONLY
52 EXEREL9A 00000012 00000000 00000000 00002657 2**0 CONTENTS, RELOC, READONLY
53 EXERELO2 00000004 00000000 00000000 00002669 2**0 CONTENTS, READONLY
54 EXEREBIG 00000002 00000000 00000000 0000266d 2**0 CONTENTS, RELOC, READONLY
55 EXERELO3 00000002 00000000 00000000 0000266f 2**0 CONTENTS, RELOC, READONLY
56 EXEMAIN8 00000003 00000000 00000000 00002671 2**0 CONTENTS, READONLY
57 DEVICEEND 00000013 00000000 00000000 00002674 2**0 CONTENTS, READONLY
58 EXESTACK 00000006 00000000 00000000 00002687 2**0 CONTENTS, RELOC, READONLY
59 EXESTASP 00000003 00000000 00000000 0000268d 2**0 CONTENTS, RELOC, READONLY
60 EXEJUMPF 00000005 00000000 00000000 00002690 2**0 CONTENTS, RELOC, READONLY
61 EXERCSPO 00000004 00000000 00000000 00002695 2**0 CONTENTS, RELOC, READONLY
62 EXERETIP 00000006 00000000 00000000 00002699 2**0 CONTENTS, RELOC, READONLY
SYMBOL TABLE:
00000000 l d DEVICEENTRY 00000000 DEVICEENTRY
00000000 l d EXEENTRY 00000000 EXEENTRY
@ -255,15 +255,14 @@ OFFSET TYPE VALUE
RELOCATION RECORDS FOR [LZMA_DEC00]:
OFFSET TYPE VALUE
00000005 R_386_16 lzma_stack_adjust
0000000d R_386_16 lzma_stack_adjust
00000015 R_386_16 lzma_u_len_hi
00000019 R_386_16 lzma_u_len
00000023 R_386_16 lzma_c_len_hi
00000027 R_386_16 lzma_c_len
00000033 R_386_16 lzma_properties_hi
00000039 R_386_16 lzma_properties
0000003e R_386_PC16 LZMA_DEC10
00000041 R_386_PC16 LZMA_DEC30
0000000d R_386_16 lzma_u_len_hi
00000011 R_386_16 lzma_u_len
0000001b R_386_16 lzma_c_len_hi
0000001f R_386_16 lzma_c_len
0000002b R_386_16 lzma_properties_hi
00000031 R_386_16 lzma_properties
00000036 R_386_PC16 LZMA_DEC10
00000039 R_386_PC16 LZMA_DEC30
RELOCATION RECORDS FOR [LZMA_DEC30]:
OFFSET TYPE VALUE