1
1

* Fix some issues when there was a space in the asm format string

* Extend the generate-asm.pl script to allow for the AIX global
  function format

This commit was SVN r4256.
Этот коммит содержится в:
Brian Barrett 2005-01-31 04:16:54 +00:00
родитель 0931b33123
Коммит cd985bba51
8 изменённых файлов: 165 добавлений и 67 удалений

Просмотреть файл

@ -139,7 +139,7 @@ AC_DEFUN([OMPI_CHECK_ASM_GSYM],[
AC_MSG_CHECKING([prefix for global symbol labels])
ompi_cv_asm_gsym="none"
for sym in "_" "" ; do
for sym in "_" "" "." ; do
asm_result=0
echo "configure: trying $sym" >& AC_FD_CC
cat > conftest_c.c <<EOF
@ -653,15 +653,28 @@ AC_DEFINE_UNQUOTED([OMPI_ASM_SUPPORT_64BIT],
[Whether we can do 64bit assembly operations or not. Should not be used outside of the assembly header files])
AC_SUBST([OMPI_ASM_SUPPORT_64BIT])
#
# figure out if we need any special function start / stop code
#
case $host_os in
aix*)
ompi_asm_arch_config="aix"
;;
*)
ompi_asm_arch_config="default"
;;
esac
# now that we know our architecture, try to inline assemble
OMPI_CHECK_INLINE_GCC([$OMPI_GCC_INLINE_ASSIGN])
OMPI_CHECK_INLINE_DEC
OMPI_CHECK_INLINE_XLC
# format:
# text-global-label_suffix-gsym-lsym-type-size-align_log-ppc_r_reg-64_bit
asm_format="${ompi_cv_asm_text}-${ompi_cv_asm_global}"
# config_file-text-global-label_suffix-gsym-lsym-type-size-align_log-ppc_r_reg-64_bit
asm_format="${ompi_asm_arch_config}"
asm_format="${asm_format}-${ompi_cv_asm_text}-${ompi_cv_asm_global}"
asm_format="${asm_format}-${ompi_cv_asm_label_suffix}-${ompi_cv_asm_gsym}"
asm_format="${asm_format}-${ompi_cv_asm_lsym}"
asm_format="${asm_format}-${ompi_cv_asm_type}-${ompi_cv_asm_size}"
@ -708,7 +721,7 @@ AC_DEFUN([OMPI_ASM_FIND_FILE], [
# see if we have a pre-built one already
AC_MSG_CHECKING([for pre-built assembly file])
ompi_cv_asm_file=""
if grep "$ompi_cv_asm_arch.*$ompi_cv_asm_format" "${top_ompi_srcdir}/src/asm/asm-data.txt" >conftest.out 2>&1 ; then
if grep "$ompi_cv_asm_arch" "${top_ompi_srcdir}/src/asm/asm-data.txt" | grep -F "$ompi_cv_asm_format" >conftest.out 2>&1 ; then
ompi_cv_asm_file="`cut -f3 conftest.out`"
if test ! "$ompi_cv_asm_file" = "" ; then
ompi_cv_asm_file="atomic-${ompi_cv_asm_file}.s"

Просмотреть файл

@ -51,7 +51,9 @@ noinst_LTLIBRARIES = libasm.la
EXTRA_DIST = \
asm-data.txt \
generate-asm.pl \
generate-all-asm.sh \
generate-all-asm.pl \
base/aix.conf \
base/default.conf \
base/AMD64.asm \
base/IA32.asm \
base/POWERPC32.asm \
@ -72,4 +74,4 @@ maintainer-clean-local:
#
dist-hook:
mkdir ${distdir}/generated
sh generate-all-asm.sh "$(PERL)" "$(srcdir)" "$(distdir)"
$(PERL) generate-all-asm.pl "$(PERL)" "$(srcdir)" "$(distdir)"

Просмотреть файл

@ -19,10 +19,13 @@
# FORMAT:
# ARCHITECTURE ASSEMBLY FORMAT BASE FILENAME
#
# Assembly Format field:
# config_file-text-global-label_suffix-gsym-lsym-type-size-align_log-ppc_r_reg-64_bit
AMD64 .text-.globl-:--.L-@-1-0-1-0 amd64-linux
IA32 .text-.globl-:--.L-@-1-0-1-0 ia32-linux
POWERPC32 .text-.globl-:-_-L--0-1-1-0 powerpc32-osx
POWERPC32 .text-.globl-:-_-L--0-1-1-1 powerpc32-64-osx
POWERPC32 .text-.globl-:--.L-@-1-1-0-0 powerpc32-linux
POWERPC64 .text-.globl-:-_-L--0-1-1-1 powerpc64-osx
AMD64 default-.text-.globl-:--.L-@-1-0-1-0 amd64-linux
IA32 default-.text-.globl-:--.L-@-1-0-1-0 ia32-linux
POWERPC32 default-.text-.globl-:-_-L--0-1-1-0 powerpc32-osx
POWERPC32 default-.text-.globl-:-_-L--0-1-1-1 powerpc32-64-osx
POWERPC32 default-.text-.globl-:--.L-@-1-1-0-0 powerpc32-linux
POWERPC32 aix-.csect .text[PR]-.globl-:-.-L--0-0-0-0 powerpc32-aix
POWERPC64 default-.text-.globl-:-_-L--0-1-1-1 powerpc64-osx

41
src/asm/base/aix.conf Обычный файл
Просмотреть файл

@ -0,0 +1,41 @@
sub start_file()
{
my $ret= "\t.toc\n";
if ($IS64BIT == 1) {
$ret .= "\t.machine \"ppc64\"\n";
}
return $ret;
}
sub start_func($)
{
my $func_name = shift;
my $ret = "";
$ret = "\t$GLOBAL $func_name\n";
$ret .= "\t$GLOBAL $GSYM$func_name\n";
$ret .= "\t.csect [DS],3\n";
$ret .= "$func_name$SUFFIX\n";
if ($IS64BIT == 1) {
$ret .= "\t.llong .$1, TOC[tc0], 0\n";
} else {
$ret .= "\t.long .$1, TOC[tc0], 0\n";
}
$ret .= "\t.csect [PR]\n";
$ret .= "\t.align 2\n";
$ret .= "$GSYM$func_name$SUFFIX\n";
return $ret;
}
sub end_func($)
{
return "";
}
1

34
src/asm/base/default.conf Обычный файл
Просмотреть файл

@ -0,0 +1,34 @@
sub start_file
{
return "";
}
sub start_func($)
{
my $func_name = shift;
my $ret = "";
$ret = "\t$GLOBAL $GSYM$func_name\n";
if (! $TYPE eq "") {
$ret .= "\t.type $func_name, $TYPE" . "function\n";
}
$ret .= "$GSYM$func_name$SUFFIX\n";
return $ret;
}
sub end_func($)
{
my $func_name = shift;
my $ret = "";
if ($SIZE != 0) {
$ret = "\t.size $func_name, .-$func_name\n";
}
return $ret;
}
1

27
src/asm/generate-all-asm.pl Обычный файл
Просмотреть файл

@ -0,0 +1,27 @@
#!/usr/bin/perl -w
my $perl = shift;
my $srcdir = shift;
my $destdir = shift;
if (! $perl || ! $srcdir || ! $destdir) {
print "ERROR: invalid argument to generate-all-asm.pl";
print "usage: generate-all-asm.pl [PERL] [SRCDIR] [DESTDIR]";
exit 1;
}
open(DATAFILE, "$srcdir/asm-data.txt") || die "Could not open data file: $!\n";
my $ASMARCH = "";
my $ASMFORMAT = "";
my $ASMFILE = "";
while(<DATAFILE>) {
if (/^#/) { next; }
($ASMARCH, $ASMFORMAT, $ASMFILE) = /(.*)\t(.*)\t(.*)/;
if (! $ASMARCH || ! $ASMFORMAT) { next; }
print "--> Generating assembly for \"$ASMARCH\" \"$ASMFORMAT\"\n";
system("$perl generate-asm.pl \"$ASMARCH\" \"$ASMFORMAT\" \"$srcdir/base\" \"$destdir/generated/atomic-$ASMFILE.s\"");
}

Просмотреть файл

@ -1,31 +0,0 @@
#!/bin/sh
perl="$1"
srcdir="$2"
destdir="$3"
ret=0
if test "$perl" = "" -o "$srcdir" = "" -o "$destdir" = "" ; then
echo "ERROR: invalid argument to generate-all-asm.sh"
echo "usage: generate-all-asm.sh [PERL] [SRCDIR] [DESTDIR]"
exit 1
fi
for asmarch in `grep -v '^#' "$srcdir/asm-data.txt" | cut -f1 | xargs` ; do
if test ! -f "${srcdir}/base/${asmarch}.asm" ; then
echo "WARNING: Skipping missing assembly arch ${asmarch}"
continue
fi
for asmformat in `grep $asmarch "$srcdir/asm-data.txt" | cut -f2 | xargs` ; do
echo "--> Generating assembly for $asmarch $asmformat"
output="`grep \"$asmarch.*$asmformat\" $srcdir/asm-data.txt | cut -f3`"
$perl generate-asm.pl "$asmarch" "$asmformat" "$srcdir/base" "$destdir/generated/atomic-$output.s"
if test "$?" != "0" ; then
echo "WARNING: Failed to generate assembly for $asmarch $asmformat"
ret=1
fi
done
done
exit $ret

Просмотреть файл

@ -15,23 +15,36 @@ open(INPUT, "$basedir/$asmarch.asm") ||
die "Could not open $basedir/$asmarch.asm: $!\n";
open(OUTPUT, ">$output") || die "Could not open $output: $1\n";
my $TEXT = "";
my $GLOBAL = "";
my $SUFFIX = "";
my $GSYM = "";
my $LSYM = "";
my $TYPE = "";
my $SIZE = 0;
my $ALIGN_LOG = 0;
my $DEL_R_REG = 0;
my $IS64BIT = 0;
$CONFIG = "default";
$TEXT = "";
$GLOBAL = "";
$SUFFIX = "";
$GSYM = "";
$LSYM = "";
$TYPE = "";
$SIZE = 0;
$ALIGN_LOG = 0;
$DEL_R_REG = 0;
$IS64BIT = 0;
($TEXT, $GLOBAL, $SUFFIX, $GSYM, $LSYM, $TYPE, $SIZE, $ALIGN_LOG, $DEL_R_REG, $IS64BIT) = (
$asmformat =~ /(.*)\-(.*)\-(.*)\-(.*)\-(.*)\-(.*)\-(.*)\-(.*)\-(.*)\-(.*)/);
($CONFIG, $TEXT, $GLOBAL, $SUFFIX, $GSYM, $LSYM, $TYPE, $SIZE, $ALIGN_LOG, $DEL_R_REG, $IS64BIT) = (
$asmformat =~ /(.*)\-(.*)\-(.*)\-(.*)\-(.*)\-(.*)\-(.*)\-(.*)\-(.*)\-(.*)\-(.*)/);
if (0) {
print "CONFIG: $CONFIG\n";
print "TEXT: $TEXT\n";
print "GLOBAL: $GLOBAL\n";
print "SUFFIX: $SUFFIX\n";
print "GSYM: $GSYM\n";
print "LSYM: $LSYM\n";
}
my $current_func = "";
my $delete = 0;
# load our configuration
do "$basedir/$CONFIG.conf" or die "Could not open config file $basedir/$CONFIG.conf: $!\n";
while (<INPUT>) {
s/TEXT/$TEXT/g;
s/GLOBAL/$GLOBAL/g;
@ -41,22 +54,18 @@ while (<INPUT>) {
s/r([0-9][0-9]?)/$1/g;
}
if (/START_FILE/) {
$_ = start_file();
}
if (/START_FUNC\((.*)\)/) {
$current_func = $1;
$_ = "\t$GLOBAL $GSYM$current_func\n";
if (! $TYPE eq "") {
$_ .= "\t.type $current_func, $TYPE" . "function\n";
}
$_ .= "$GSYM$current_func$SUFFIX\n";
$_ = start_func($current_func);
}
if (/END_FUNC\((.*)\)/) {
s/END_FUNC\((.*)\)//g;
if ($SIZE != 0) {
$_ = "\t.size $current_func, .-$current_func\n";
} else {
chomp;
}
$current_func = $1;
$_ = end_func($current_func);
}
if ($ALIGN_LOG == 0) {