Commit | Line | Data |
---|---|---|
02cc32c5 DE |
1 | # ARC gas testsuite |
2 | ||
3 | # Test an insn from a template .s/.d. | |
4 | ||
5 | proc test_template_insn { tmpl opcode icode } { | |
6 | global srcdir subdir objdir | |
7 | ||
8 | # Change @OC@ in the template file to $opcode | |
9 | ||
10 | set in_fd [open $srcdir/$subdir/$tmpl.s r] | |
11 | set out_fd [open $objdir/$opcode.s w] | |
12 | # FIXME: check return codes | |
13 | ||
14 | while { [gets $in_fd line] >= 0 } { | |
15 | regsub "@OC@" $line $opcode line | |
16 | puts $out_fd $line | |
17 | } | |
18 | ||
19 | close $in_fd | |
20 | close $out_fd | |
21 | ||
22 | # Create output template. | |
23 | ||
24 | set in_fd [open $srcdir/$subdir/$tmpl.d r] | |
25 | set out_fd [open $objdir/$opcode.d w] | |
26 | # FIXME: check return codes | |
27 | ||
28 | while { [gets $in_fd line] >= 0 } { | |
29 | regsub "@OC@" $line $opcode line | |
30 | #send_user "$line\n" | |
31 | if [string match "*@IC+?@*" $line] { | |
32 | # Insert the opcode. It occupies the top 5 bits. | |
04b8d170 | 33 | regexp "^(.*)@IC\\+(.)@(.*)$" $line junk leftpart n rightpart |
02cc32c5 DE |
34 | set n [expr ($icode << 3) + $n] |
35 | set n [format "%02x" $n] | |
36 | puts $out_fd "$leftpart$n$rightpart" | |
04b8d170 DE |
37 | } elseif [string match "*@I3+??@*" $line] { |
38 | # Insert insn 3 code (register C field) | |
39 | # b15=8/0, b8=1/0 (their respective hex values in the objdump) | |
40 | regexp "^(.*)@I3\\+(.)(.)@(.*)$" $line junk leftpart b15 b8 rightpart | |
41 | set n [expr ($icode << 1) + ($b15 << 4) + ($b8 << 0)] | |
42 | set n [format "%02x" $n] | |
43 | puts $out_fd "$leftpart$n$rightpart" | |
02cc32c5 DE |
44 | } else { |
45 | puts $out_fd $line | |
46 | } | |
47 | } | |
48 | ||
49 | close $in_fd | |
50 | close $out_fd | |
51 | ||
52 | # Finally, run the test. | |
53 | ||
54 | run_dump_test $objdir/$opcode | |
55 | } | |
56 | ||
57 | # Run the tests. | |
58 | ||
59 | if [istarget arc*-*-*] then { | |
60 | ||
61 | test_template_insn math adc 9 | |
62 | test_template_insn math add 8 | |
63 | test_template_insn math and 12 | |
64 | test_template_insn math bic 14 | |
65 | test_template_insn math or 13 | |
66 | test_template_insn math sbc 11 | |
67 | test_template_insn math sub 10 | |
68 | test_template_insn math xor 15 | |
69 | ||
04b8d170 DE |
70 | test_template_insn alias mov 12 |
71 | test_template_insn alias rlc 9 | |
72 | test_template_insn alias asl 8 | |
73 | # `lsl' gets dumped as `asl' so this must be tested elsewhere. | |
74 | # test_template_insn alias lsl 8 | |
02cc32c5 | 75 | |
04b8d170 DE |
76 | test_template_insn sshift asr 1 |
77 | test_template_insn sshift lsr 2 | |
78 | test_template_insn sshift ror 3 | |
79 | test_template_insn sshift rrc 4 | |
80 | ||
81 | test_template_insn branch b 4 | |
82 | test_template_insn branch bl 5 | |
83 | test_template_insn branch lp 6 | |
02cc32c5 DE |
84 | |
85 | run_dump_test "j" | |
86 | ||
87 | # test_special "ext" 3 | |
88 | # test_special "sex" 3 | |
89 | ||
02cc32c5 DE |
90 | run_dump_test "flag" |
91 | # run_dump_test "ld" | |
92 | # run_dump_test "lr" | |
93 | # run_dump_test "nop" | |
94 | # run_dump_test "st" | |
95 | # run_dump_test "sr" | |
96 | ||
97 | } |