wok diff linld/stuff/src/pipehole.awk @ rev 20520

Up sshguard (2.2.0)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Nov 05 11:52:27 2018 +0100 (2018-11-05)
parents f5088c165f51
children f0d71e920c5a
line diff
     1.1 --- a/linld/stuff/src/pipehole.awk	Tue Oct 23 08:25:49 2018 +0200
     1.2 +++ b/linld/stuff/src/pipehole.awk	Mon Nov 05 11:52:27 2018 +0100
     1.3 @@ -4,6 +4,7 @@
     1.4  	if (hold == 0) {
     1.5  		s=$0
     1.6  		if (/^	mov	.x,bx$/ || /^	mov	.x,.i$/) {
     1.7 +			r=$2
     1.8  			hold=1; split($2,regs,","); next
     1.9  		}
    1.10  		if (/^	inc	e?.[ix]/ || /^	dec	e?.[ix]/) {
    1.11 @@ -13,11 +14,10 @@
    1.12  			hold=3; split($2,regs,","); next
    1.13  		}
    1.14  		if (/^	movzx	eax,ax$/) { hold=4; next }
    1.15 -if (0) {
    1.16 -		if (/^	cmp	dx,-1$/) { hold=10; next }
    1.17 -}
    1.18 +		if (/^	mov	cl,4$/)   { hold=8; next }
    1.19  	}
    1.20  	else if (hold == 1) {
    1.21 +		if (/^   ;/) { print; next }
    1.22  		hold=0; split($2,args,","); op=""
    1.23  		if ($1 == "add") op="+"
    1.24  		if ($1 == "sub") op="-"
    1.25 @@ -25,7 +25,10 @@
    1.26  			print "\tlea\t" regs[1] ",[" regs[2] op args[2] "]"
    1.27  			next
    1.28  		}
    1.29 -		print "\tmov\t" regs[1] "," regs[2]
    1.30 +		if (/^	pop	[ds]i/ && regs[2] ~ /^[ds]i$/) {
    1.31 +			print "	xchg	" r
    1.32 +		}
    1.33 +		else print "\tmov\t" regs[1] "," regs[2]
    1.34  	}
    1.35  	else if (hold == 2) {
    1.36  		hold=0; split($2,args,","); print s
    1.37 @@ -49,19 +52,14 @@
    1.38  			print "	push	0"; print "	push	ax"; next
    1.39  		} else { print s }
    1.40  	}
    1.41 -	else if (hold == 10) {
    1.42 -		if ($1 == "je" || $1 == "jne") { s2=$0; cmp=$1; hold++; next }
    1.43 -		hold=0; print s
    1.44 -	}
    1.45 -	else if (hold == 11) {
    1.46 -		if (/^	cmp	ax,-1$/) { s3=$0; hold++; next }
    1.47 -		hold=0; print s; print s2
    1.48 -	}
    1.49 -	else if (hold == 12) {
    1.50 -		if (($1 == "je" || $1 == "jne") && $1 != cmp) {
    1.51 -			print "	and	ax,dx"; print "	inc	ax"
    1.52 -		} else { print s; print s2; print s3 }
    1.53 +	else if (hold == 8) {
    1.54  		hold=0
    1.55 +		if (/^	call	near ptr N_LXURSH@$/) {
    1.56 +			print "	extrn	N_LXURSH@4:near"
    1.57 +			print "	call	near ptr N_LXURSH@4"
    1.58 +			next
    1.59 +		}
    1.60 +		print s
    1.61  	}
    1.62  	s=$0
    1.63  	# These optimisation may break ZF or CF