Initial revision
[binutils.git] / gas / testsuite / gas / arc / arc.exp
blobb0984535e2e70723f80645da30f9eb44aff0b047
1 # ARC gas testsuite
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.
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.
17 proc test_template_insn { cpu tmpl opcode icode } {
18 global srcdir subdir objdir
20 # Change @OC@ in the template file to $opcode
22 set in_fd [open $srcdir/$subdir/$tmpl.s r]
23 set out_fd [open $objdir/$opcode.s w]
24 # FIXME: check return codes
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
32 close $in_fd
33 close $out_fd
35 # Create output template.
37 set in_fd [open $srcdir/$subdir/$tmpl.d r]
38 set out_fd [open $objdir/$opcode.d w]
39 # FIXME: check return codes
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
62 close $in_fd
63 close $out_fd
65 # Finally, run the test.
67 run_dump_test $objdir/$opcode
69 # "make clean" won't delete these, so for now we must.
70 catch "exec rm -f $objdir/$opcode.s $objdir/$opcode.d"
73 # Run the tests.
75 if [istarget arc*-*-*] then {
77 test_template_insn base math adc 9
78 test_template_insn base math add 8
79 test_template_insn base math and 12
80 test_template_insn base math bic 14
81 test_template_insn base math or 13
82 test_template_insn base math sbc 11
83 test_template_insn base math sub 10
84 test_template_insn base math xor 15
86 test_template_insn base alias mov 12
87 test_template_insn base alias rlc 9
88 test_template_insn base alias asl 8
89 # `lsl' gets dumped as `asl' so this must be tested elsewhere.
90 # test_template_insn base alias lsl 8
92 test_template_insn base sshift asr 1
93 test_template_insn base sshift lsr 2
94 test_template_insn base sshift ror 3
95 test_template_insn base sshift rrc 4
97 test_template_insn base branch b 4
98 test_template_insn base branch bl 5
99 test_template_insn base branch lp 6
101 run_dump_test "j"
103 test_template_insn base insn3 sexb 5
104 test_template_insn base insn3 sexw 6
105 test_template_insn base insn3 extb 7
106 test_template_insn base insn3 extw 8
108 run_dump_test "flag"
109 # run_dump_test "nop"
111 run_dump_test "ld"
112 run_dump_test "st"