summaryrefslogtreecommitdiff
path: root/ghc/driver
diff options
context:
space:
mode:
authorsimonmar <unknown>2005-02-01 15:55:00 +0000
committersimonmar <unknown>2005-02-01 15:55:00 +0000
commit3c7db0d06bee69140a6898ab78c84952ea73a4f7 (patch)
tree73d790e0820aecda48078f1778b044a2c99dd6db /ghc/driver
parentc9ba9f57aba0f91918d292ee3d05763791bcf5db (diff)
downloadhaskell-3c7db0d06bee69140a6898ab78c84952ea73a4f7.tar.gz
[project @ 2005-02-01 15:55:00 by simonmar]
Generate some sensible code when presented with the output from gcc -O2
Diffstat (limited to 'ghc/driver')
-rw-r--r--ghc/driver/mangler/ghc-asm.lprl14
1 files changed, 11 insertions, 3 deletions
diff --git a/ghc/driver/mangler/ghc-asm.lprl b/ghc/driver/mangler/ghc-asm.lprl
index 06446e49a0..e616a6cf72 100644
--- a/ghc/driver/mangler/ghc-asm.lprl
+++ b/ghc/driver/mangler/ghc-asm.lprl
@@ -146,7 +146,7 @@ sub init_TARGET_STUFF {
$T_X86_PRE_LLBL = 'L';
$T_X86_BADJMP = '^\tjmp [^L\*]';
- $T_MOVE_DIRVS = '^(\s*(\.(p2)?align\s+\d+(,0x90)?|\.globl\s+\S+|\.text|\.data|\.stab[^n].*|\.type\s+.*|\.size\s+.*|\.lcomm.*)\n)';
+ $T_MOVE_DIRVS = '^(\s*(\.(p2)?align\s.*|\.globl\s+\S+|\.text|\.data|\.stab[^n].*|\.type\s+.*|\.size\s+.*|\.lcomm.*)\n)';
$T_COPY_DIRVS = '\.(globl|stab|lcomm)';
$T_DOT_WORD = '\.(long|word|value|byte|space)';
$T_DOT_GLOBAL = '\.globl';
@@ -172,7 +172,7 @@ sub init_TARGET_STUFF {
$T_X86_PRE_LLBL = '.L';
$T_X86_BADJMP = '^\tjmp\s+[^\.\*]';
- $T_MOVE_DIRVS = '^(\s*(\.(p2)?align\s+\d+(,\s*0x90)?|\.globl\s+\S+|\.text|\.data|\.section\s+.*|\.type\s+.*|\.size\s+\S+\s*,\s*\d+|\.ident.*|\.local.*)\n)';
+ $T_MOVE_DIRVS = '^(\s*(\.(p2)?align\s.*|\.globl\s+\S+|\.text|\.data|\.section\s+.*|\.type\s+.*|\.size\s+\S+\s*,\s*\d+|\.ident.*|\.local.*)\n)';
$T_COPY_DIRVS = '^\s*\.(globl|type|size|local)';
$T_DOT_WORD = '\.(long|value|word|byte|zero)';
@@ -1362,8 +1362,16 @@ sub print_doctored {
# movl $_blah,<bad-reg>
# jmp *<bad-reg>
#
+ s/^\tmovl\s+\$${T_US}(.*),\s*(\%e[acd]x)\n\tjmp\s+\*\2/\tjmp $T_US$1/g;
- s/^\tmovl\s+\$${T_US}(.*),\s*(\%e[abcd]x)\n\tjmp\s+\*\2/\tjmp $T_US$1/g;
+ # Catch things like
+ #
+ # movl -4(%ebx), %eax
+ # jmp *%eax
+ #
+ # and optimise:
+ #
+ s/^\tmovl\s+(-?\d*\(\%e(bx|si)\)),\s*(\%e[acd]x)\n\tjmp\s+\*\3/\tjmp\t\*$1/g;
if ($StolenX86Regs <= 2 ) { # YURGH! spurious uses of esi?
s/^\tmovl\s+(.*),\s*\%esi\n\tjmp\s+\*%esi\n/\tmovl $1,\%eax\n\tjmp \*\%eax\n/g;