1#!/bin/sh 2# 3# BEGIN LICENSE BLOCK 4# Version: CMPL 1.1 5# 6# The contents of this file are subject to the Cisco-style Mozilla Public 7# License Version 1.1 (the "License"); you may not use this file except 8# in compliance with the License. You may obtain a copy of the License 9# at www.eclipse-clp.org/license. 10# 11# Software distributed under the License is distributed on an "AS IS" 12# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 13# the License for the specific language governing rights and limitations 14# under the License. 15# 16# The Original Code is The ECLiPSe Constraint Logic Programming System. 17# The Initial Developer of the Original Code is Cisco Systems, Inc. 18# Portions created by the Initial Developer are 19# Copyright (C) 1992-2006 Cisco Systems, Inc. All Rights Reserved. 20# 21# Contributor(s): ___________________________________. 22# 23# END LICENSE BLOCK 24# 25# IDENTIFICATION opt_i386_linux.sh 26# 27# AUTHOR Joachim Schimpf 28# 29# DESCRIPTION A postprocessor to optimize the assembler source 30# that gcc 3.x creates for i386_linux. The threaded 31# code is compiled with indirect jumps like: 32# 33# jmplabel: 34# jmp *%eax 35# 36# <code for wam instruction> 37# jmp jmplabel 38# 39# and this postprocessor replaces every 40# jmp jmplabel 41# with 42# jmp *%eax 43# 44# USAGE opt_i386_linux.sh <infile> <outfile> 45# 46 47trap 'rm -f /tmp/opt?.$$' 0 48 49cat > /tmp/opt0.$$ <<\'PASS1a\' 50 51BEGIN { 52 jmplabel = "" 53} 54 55/^\.?L[0-9]+:/ { 56 if (jmplabel == "") { 57 print 58 thislabel = $1 59 getline 60 if ($0 ~ /jmp \*%/) { 61 # found the threaded code jump, remember label and instruction 62 jmplabel = substr(thislabel,1,length(thislabel)-1) 63 jmpinstr = $0 64 } 65 } 66} 67 68/jmp \.?L[0-9]+/ { 69 if ($2 == jmplabel) { 70 # replace indirect by direct jump 71 print jmpinstr 72 next 73 } 74} 75 76{ 77 print 78} 79'PASS1a' 80 81 82awk -f /tmp/opt0.$$ $1 > $2 83