OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-binutils/] [binutils-2.19.1/] [cgen/] [gas-test.scm] - Rev 6

Compare with Previous | Blame | View Log

; CPU description file generator for the GNU assembler testsuite.
; Copyright (C) 2000, 2001, 2009 Red Hat, Inc.
; This file is part of CGEN.
; See file COPYING.CGEN for details.
; This is invoked to build allinsn.exp and a script to run to
; generate allinsn.s and allinsn.d.
; Specify which application.
; Called before/after the .cpu file has been read.
; Called after .cpu file has been read and global error checks are done.
; We use the `tmp' member to record the syntax split up into its components.
; Methods to compute test data.
; The result is a list of strings to be inserted in the assembler
; in the operand's position.
; For a general assembler operand, just turn the value into a string.
"""unsupported assembler operand"; For a keyword operand, choose the appropriate keyword.
; OPS is a list of values, e.g. from an ifield.
;; If an ifield has, e.g., 2 bits (values 0,1,2,3) and the keyword
;; only has two values, e.g. (foo 0) (bar 1), then we can get
;; invalid requests, i.e. for ifield values of 2 and 3.
;; It's not clear what to do here, but it seems like this is an
;; error in the description file.
;; So it seems like we should flag an error for invalid requests.
;; OTOH, we're just generating testcases.  So instead we just
;; flag a warning and cope by returning the first keyword in the
;; list.
"WARNING: Invalid test data request for keyword "": "".\n""         Compensating by picking a different value.\n""""\\""""foodata""4""footext""-4""footext""4""foodata""-4"; Test data for a field is chosen firstly out of some bit patterns,
; then randomly.  It is then interpreted based on whether there 
; is a decode method.
; FIXME: need to run the decoder.
; no decode method
"unsupported mode class";; Return N values for assembler test data, or nil if there are none
;; (e.g. scalars).
;; ??? This also returns nil for str-expr and rtx.
;; ???
"invalid hw-index type"; Given an operand, return a set of N test data.
; e.g. For a keyword operand, return a random subset.
; For a number, return N numbers.
; Given the broken out assembler syntax string, return the list of operand
; objects.
; Collate a list of operands into a test test.
; Input is a list of operand lists. Returns a collated set of test
; inputs. For example:
; ((r0 r1 r2) (r3 r4 r5) (2 3 8)) => ((r0 r3 2) (r1 r4 3) (r2 r5 8))
; L is a list of lists.  All elements must have the same length.
; Given a list of operands for an instruction, return the test set
; (all possible combinations).
; N is the number of testcases for each operand.
; The result has N to-the-power (length OP-LIST) elements.
; Given an assembler expression and a set of operands build a testcase.
; TEST-DATA is a list of strings, one element per operand.
;(display (list result sl td "\n"))
"\t""\n"; Generate the testsuite for INSN.
; FIXME: make the number of cases an argument to this application.
"Generating gas test data for "" ...\n""\t.text\n""\t.global ""\n"":\n"; Generate the shell script that builds the .d file.
; .d files contain the objdump result that is used to see whether the
; testcase passed.
; We do this by running gas and objdump.
; Obviously this isn't quite right - bugs in gas or
; objdump - the things we're testing - will cause an incorrect testsuite to
; be built and thus the bugs will be missed.  It is *not* intended that this
; be run immediately before running the testsuite!  Rather, this is run to
; generate the testsuite which is then inspected for accuracy and checked
; into CVS.  As bugs in the testsuite are found they are corrected by hand.
; Or if they're due to bugs in the generator the generator can be rerun and
; the output diff'd to ensure no errors have crept back in.
; The point of doing things this way is TO SAVE A HELL OF A LOT OF TYPING!
; Clearly some hand generated testcases will also be needed, but this
; provides a good test for each instruction.
"Generating gas-build.sh ...\n""\
#/bin/sh
# Generate test result data for "" GAS testing.
# This script is machine generated.
# It is intended to be run in the testsuite source directory.
#
# Syntax: build.sh /path/to/build/gas
 
if [ $# = 0 ] ; then
  if [ ! -x ../gas/as-new ] ; then
    echo \"Usage: $0 [/path/to/gas/build]\"
  else
    BUILD=`pwd`/../gas
  fi
else
  BUILD=$1
fi
 
if [ ! -x $BUILD/as-new ] ; then
  echo \"$BUILD is not a gas build directory\"
  exit 1
fi
 
# Put results here, so we preserve the existing set for comparison.
rm -rf tmpdir
mkdir tmpdir
cd tmpdir
 
function gentest {
    rm -f a.out
    $BUILD/as-new ${1}.s -o a.out
    echo \"#as:\" >${1}.d
    echo \"#objdump: -dr\" >>${1}.d
    echo \"#name: $1\" >>${1}.d
    $BUILD/../binutils/objdump -dr a.out | \
	sed -e 's/(/\\\\(/g' \
            -e 's/)/\\\\)/g' \
            -e 's/\\$/\\\\$/g' \
            -e 's/\\[/\\\\\\[/g' \
            -e 's/\\]/\\\\\\]/g' \
            -e 's/[+]/\\\\+/g' \
            -e 's/[.]/\\\\./g' \
            -e 's/[*]/\\\\*/g' | \
	sed -e 's/^.*file format.*$/.*: +file format .*/' \
	>>${1}.d
    rm -f a.out
}
 
# Now come all the testcases.
cat > allinsn.s <<EOF
 .data
foodata: .word 42
 .text
footext:\n""EOF\n""\n""# Finally, generate the .d file.\n""gentest allinsn\n"; Generate the dejagnu allinsn.exp file that drives the tests.
"Generating allinsn.exp ...\n""\
# "" assembler testsuite. -*- Tcl -*-
 
if [istarget ""*-*-*] {
    run_dump_test \"allinsn\"
}\n"

Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.