]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gas/testsuite/gas/arc/arc.exp
(test_template_insn): Document usage.
[thirdparty/binutils-gdb.git] / gas / testsuite / gas / arc / arc.exp
1 # ARC gas testsuite
2
3 # Test an insn from a template .s/.d.
4 # The best way to create the .d file is to run the tests without it, let
5 # dejagnu crash, run as.new on the just built .s file, run objdump -dr on
6 # the result of that, copy the result into the .d file, and edit in the
7 # necessary patterns (@OC@, etc.). Sounds complicated but it's easy. The
8 # catch is that we assume a working assembler is used to build it. That's
9 # obviously not entirely kosher, but once the .d file is created one can
10 # verify it's contents over time.
11 #
12 # Template patterns:
13 # @OC@ - placeholder for the opcode
14 # @IC+?@ - place holder for the insn code
15 # @I3+??@ - place holder for the operation code of code 3 insns.
16
17 proc test_template_insn { cpu tmpl opcode icode } {
18 global srcdir subdir objdir
19
20 # Change @OC@ in the template file to $opcode
21
22 set in_fd [open $srcdir/$subdir/$tmpl.s r]
23 set out_fd [open $objdir/$opcode.s w]
24 # FIXME: check return codes
25
26 puts $out_fd "\t.cpu $cpu\n"
27 while { [gets $in_fd line] >= 0 } {
28 regsub "@OC@" $line $opcode line
29 puts $out_fd $line
30 }
31
32 close $in_fd
33 close $out_fd
34
35 # Create output template.
36
37 set in_fd [open $srcdir/$subdir/$tmpl.d r]
38 set out_fd [open $objdir/$opcode.d w]
39 # FIXME: check return codes
40
41 while { [gets $in_fd line] >= 0 } {
42 regsub "@OC@" $line $opcode line
43 #send_user "$line\n"
44 if [string match "*@IC+?@*" $line] {
45 # Insert the opcode. It occupies the top 5 bits.
46 regexp "^(.*)@IC\\+(.)@(.*)$" $line junk leftpart n rightpart
47 set n [expr ($icode << 3) + $n]
48 set n [format "%02x" $n]
49 puts $out_fd "$leftpart$n$rightpart"
50 } elseif [string match "*@I3+??@*" $line] {
51 # Insert insn 3 code (register C field)
52 # b15=8/0, b8=1/0 (their respective hex values in the objdump)
53 regexp "^(.*)@I3\\+(.)(.)@(.*)$" $line junk leftpart b15 b8 rightpart
54 set n [expr ($icode << 1) + ($b15 << 4) + ($b8 << 0)]
55 set n [format "%02x" $n]
56 puts $out_fd "$leftpart$n$rightpart"
57 } else {
58 puts $out_fd $line
59 }
60 }
61
62 close $in_fd
63 close $out_fd
64
65 # Finally, run the test.
66
67 run_dump_test $objdir/$opcode
68 }
69
70 # Run the tests.
71
72 if [istarget arc*-*-*] then {
73
74 test_template_insn base math adc 9
75 test_template_insn base math add 8
76 test_template_insn base math and 12
77 test_template_insn base math bic 14
78 test_template_insn base math or 13
79 test_template_insn base math sbc 11
80 test_template_insn base math sub 10
81 test_template_insn base math xor 15
82
83 test_template_insn base alias mov 12
84 test_template_insn base alias rlc 9
85 test_template_insn base alias asl 8
86 # `lsl' gets dumped as `asl' so this must be tested elsewhere.
87 # test_template_insn base alias lsl 8
88
89 test_template_insn base sshift asr 1
90 test_template_insn base sshift lsr 2
91 test_template_insn base sshift ror 3
92 test_template_insn base sshift rrc 4
93
94 test_template_insn base branch b 4
95 test_template_insn base branch bl 5
96 test_template_insn base branch lp 6
97
98 run_dump_test "j"
99
100 test_template_insn base insn3 sexb 5
101 test_template_insn base insn3 sexw 6
102 test_template_insn base insn3 extb 7
103 test_template_insn base insn3 extw 8
104
105 run_dump_test "flag"
106
107 # run_dump_test "ld"
108 # run_dump_test "lr"
109 # run_dump_test "nop"
110 # run_dump_test "st"
111 # run_dump_test "sr"
112
113 # Host extension instructions
114 test_template_insn host math mul64 20
115 test_template_insn host math mulu64 21
116
117 # Graphics extension instructions
118 test_template_insn graphics math mul64 20
119 test_template_insn graphics math mulu64 21
120 test_template_insn graphics math padc 25
121 test_template_insn graphics math padd 24
122 test_template_insn graphics math pand 28
123 test_template_insn graphics math psbc 27
124 test_template_insn graphics math psub 26
125 test_template_insn graphics alias pmov 28
126
127 # Audio extension instructions
128 test_template_insn audio math mac 24
129 test_template_insn audio math macu 25
130 test_template_insn audio math mac.s 26
131 test_template_insn audio math macu.s 27
132 test_template_insn audio math mul 28
133 test_template_insn audio math mulu 29
134 test_template_insn audio insn3 swap 9
135
136 }