1 |
6 |
jlechner |
; CPU description file generator for the GNU assembler testsuite.
|
2 |
|
|
; Copyright (C) 2000, 2001, 2009 Red Hat, Inc.
|
3 |
|
|
; This file is part of CGEN.
|
4 |
|
|
; See file COPYING.CGEN for details.
|
5 |
|
|
|
6 |
|
|
; generate allinsn.s and allinsn.d.
|
7 |
|
|
; Specify which application.
|
8 |
|
|
|
9 |
|
|
; Called after .cpu file has been read and global error checks are done.
|
10 |
|
|
; We use the `tmp' member to record the syntax split up into its components.
|
11 |
|
|
|
12 |
|
|
; The result is a list of strings to be inserted in the assembler
|
13 |
|
|
|
14 |
|
|
; For a general assembler operand, just turn the value into a string.
|
15 |
|
|
"""unsupported assembler operand"; For a keyword operand, choose the appropriate keyword.
|
16 |
|
|
|
17 |
|
|
;; If an ifield has, e.g., 2 bits (values 0,1,2,3) and the keyword
|
18 |
|
|
;; only has two values, e.g. (foo 0) (bar 1), then we can get
|
19 |
|
|
|
20 |
|
|
;; It's not clear what to do here, but it seems like this is an
|
21 |
|
|
;; error in the description file.
|
22 |
|
|
;; So it seems like we should flag an error for invalid requests.
|
23 |
|
|
;; OTOH, we're just generating testcases. So instead we just
|
24 |
|
|
;; flag a warning and cope by returning the first keyword in the
|
25 |
|
|
;; list.
|
26 |
|
|
"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,
|
27 |
|
|
|
28 |
|
|
; is a decode method.
|
29 |
|
|
; FIXME: need to run the decoder.
|
30 |
|
|
; no decode method
|
31 |
|
|
|
32 |
|
|
;; (e.g. scalars).
|
33 |
|
|
|
34 |
|
|
;; ???
|
35 |
|
|
"invalid hw-index type"; Given an operand, return a set of N test data.
|
36 |
|
|
; e.g. For a keyword operand, return a random subset.
|
37 |
|
|
; For a number, return N numbers.
|
38 |
|
|
; Given the broken out assembler syntax string, return the list of operand
|
39 |
|
|
; objects.
|
40 |
|
|
; Collate a list of operands into a test test.
|
41 |
|
|
; Input is a list of operand lists. Returns a collated set of test
|
42 |
|
|
; inputs. For example:
|
43 |
|
|
|
44 |
|
|
; L is a list of lists. All elements must have the same length.
|
45 |
|
|
; Given a list of operands for an instruction, return the test set
|
46 |
|
|
|
47 |
|
|
; N is the number of testcases for each operand.
|
48 |
|
|
; The result has N to-the-power (length OP-LIST) elements.
|
49 |
|
|
; Given an assembler expression and a set of operands build a testcase.
|
50 |
|
|
; TEST-DATA is a list of strings, one element per operand.
|
51 |
|
|
;(display (list result sl td "\n"))
|
52 |
|
|
"\t""\n"; Generate the testsuite for INSN.
|
53 |
|
|
; FIXME: make the number of cases an argument to this application.
|
54 |
|
|
"Generating gas test data for "" ...\n""\t.text\n""\t.global ""\n"":\n"; Generate the shell script that builds the .d file.
|
55 |
|
|
; .d files contain the objdump result that is used to see whether the
|
56 |
|
|
; testcase passed.
|
57 |
|
|
; We do this by running gas and objdump.
|
58 |
|
|
; Obviously this isn't quite right - bugs in gas or
|
59 |
|
|
; objdump - the things we're testing - will cause an incorrect testsuite to
|
60 |
|
|
; be built and thus the bugs will be missed. It is *not* intended that this
|
61 |
|
|
; be run immediately before running the testsuite! Rather, this is run to
|
62 |
|
|
; generate the testsuite which is then inspected for accuracy and checked
|
63 |
|
|
; into CVS. As bugs in the testsuite are found they are corrected by hand.
|
64 |
|
|
; Or if they're due to bugs in the generator the generator can be rerun and
|
65 |
|
|
; the output diff'd to ensure no errors have crept back in.
|
66 |
|
|
; The point of doing things this way is TO SAVE A HELL OF A LOT OF TYPING!
|
67 |
|
|
; Clearly some hand generated testcases will also be needed, but this
|
68 |
|
|
; provides a good test for each instruction.
|
69 |
|
|
"Generating gas-build.sh ...\n""\
|
70 |
|
|
#/bin/sh
|
71 |
|
|
# Generate test result data for "" GAS testing.
|
72 |
|
|
# This script is machine generated.
|
73 |
|
|
# It is intended to be run in the testsuite source directory.
|
74 |
|
|
#
|
75 |
|
|
# Syntax: build.sh /path/to/build/gas
|
76 |
|
|
|
77 |
|
|
if [ $# = 0 ] ; then
|
78 |
|
|
if [ ! -x ../gas/as-new ] ; then
|
79 |
|
|
echo \"Usage: $0 [/path/to/gas/build]\"
|
80 |
|
|
else
|
81 |
|
|
BUILD=`pwd`/../gas
|
82 |
|
|
|
83 |
|
|
else
|
84 |
|
|
BUILD=$1
|
85 |
|
|
fi
|
86 |
|
|
|
87 |
|
|
if [ ! -x $BUILD/as-new ] ; then
|
88 |
|
|
echo \"$BUILD is not a gas build directory\"
|
89 |
|
|
exit 1
|
90 |
|
|
fi
|
91 |
|
|
|
92 |
|
|
|
93 |
|
|
rm -rf tmpdir
|
94 |
|
|
mkdir tmpdir
|
95 |
|
|
cd tmpdir
|
96 |
|
|
|
97 |
|
|
function gentest {
|
98 |
|
|
rm -f a.out
|
99 |
|
|
$BUILD/as-new ${1}.s -o a.out
|
100 |
|
|
echo \"#as:\" >${1}.d
|
101 |
|
|
echo \"#objdump: -dr\" >>${1}.d
|
102 |
|
|
|
103 |
|
|
$BUILD/../binutils/objdump -dr a.out | \
|
104 |
|
|
sed -e 's/(/\\\\(/g' \
|
105 |
|
|
|
106 |
|
|
-e 's/\\$/\\\\$/g' \
|
107 |
|
|
-e 's/\\[/\\\\\\[/g' \
|
108 |
|
|
-e 's/\\]/\\\\\\]/g' \
|
109 |
|
|
|
110 |
|
|
-e 's/[.]/\\\\./g' \
|
111 |
|
|
-e 's/[*]/\\\\*/g' | \
|
112 |
|
|
sed -e 's/^.*file format.*$/.*: +file format .*/' \
|
113 |
|
|
>>${1}.d
|
114 |
|
|
rm -f a.out
|
115 |
|
|
}
|
116 |
|
|
|
117 |
|
|
# Now come all the testcases.
|
118 |
|
|
cat > allinsn.s <<EOF
|
119 |
|
|
.data
|
120 |
|
|
foodata: .word 42
|
121 |
|
|
.text
|
122 |
|
|
footext:\n""EOF\n""\n""# Finally, generate the .d file.\n""gentest allinsn\n"; Generate the dejagnu allinsn.exp file that drives the tests.
|
123 |
|
|
"Generating allinsn.exp ...\n""\
|
124 |
|
|
# "" assembler testsuite. -*- Tcl -*-
|
125 |
|
|
|
126 |
|
|
if [istarget ""*-*-*] {
|
127 |
|
|
run_dump_test \"allinsn\"
|
128 |
|
|
}\n"
|