aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.arch/thumb2-it.S
blob: a5aab8cb1be5c96f1479b040ac10373bcf13c84e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/* Thumb-2 IT blocks test program.

   Copyright 2010 Free Software Foundation, Inc.

   This file is part of GDB.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

	.syntax unified
	.text
	.p2align 2
	.code 16

#ifndef __thumb2__

	.type main,%function
	.thumb_func
	.globl main
main:
	mov	r0, #0
	bx	lr	@ No Thumb-2

#else

	.type main,%function
	.thumb_func
	.globl main
main:
	mov	r0, #0
	bx	lr	@ Thumb-2 OK

	@ One conditional instruction, executed.
	.type it_1,%function
	.thumb_func
it_1:
	mov	r0, #0	@ Setup
	cmp	r0, #0	@ Setup
	it	eq	@ IT instruction, Expected == 1
	addeq	r0, #1	@ Reached
	bx	lr	@ Done

	@ One conditional instruction, skipped.
	.type it_2,%function
	.thumb_func
it_2:
	mov	r0, #0	@ Setup
	cmp	r0, #0	@ Setup
	it	ne	@ IT instruction, Expected == 0
	addne	r0, #1	@ Not reached
	bx	lr	@ Done, Check $r0 == 0

	@ Block of four, alternating, starting with executed.
	.type it_3,%function
	.thumb_func
it_3:
	mov	r0, #0	@ Setup
	cmp	r0, #0	@ Setup
	itete	ge	@ IT instruction, Expected == 2
	addge	r0, #1	@ Reached
	addlt	r0, #2	@ Not reached
	addge	r0, #4	@ Reached
	addlt	r0, #8	@ Not reached
	bx	lr	@ Done, Check $r0 == 5

	@ Block of four, changing flags.
	.type it_4,%function
	.thumb_func
it_4:
	mov	r0, #0	@ Setup
	cmp	r0, #0	@ Setup
	itttt	ge	@ IT instruction, Expected == 2
	addge	r0, #1	@ Reached
	cmpge	r0, #10	@ Reached
	addge	r0, #4	@ Not reached
	addge	r0, #8	@ Not reached
	bx	lr	@ Done, Check $r0 == 1

	@ Block of two, ending with taken branch.
	.type it_5,%function
	.thumb_func
it_5:
	mov	r0, #0	@ Setup
	cmp	r0, #0	@ Setup
	itt	ge	@ IT instruction, Expected == 2
	addge	r0, #1	@ Reached
	bge	.L5	@ Reached
	add	r0, #2	@ Never reached
.L5:	bx	lr	@ Done, Check $r0 == 1

	@ Block of two, ending with untaken branch.
	.type it_6,%function
	.thumb_func
it_6:
	mov	r0, #0	@ Setup
	cmp	r0, #0	@ Setup
	ite	ge	@ IT instruction, Expected == 2
	addge	r0, #1	@ Reached
	blt	.L6	@ Not reached
	add	r0, #2	@ Reached
.L6:	bx	lr	@ Done, Check $r0 == 3

	@ Block of four, taken, of different sizes
	.type it_7,%function
	.thumb_func
it_7:
	mov	r0, #0	@ Setup
	cmp	r0, #0	@ Setup
	itttt	ge	@ IT instruction, Expected == 4
	addge.n	r0, #1	@ Reached
	addge.w	r0, #2	@ Reached
	addge.n	r0, #4	@ Reached
	addge.w	r0, #8	@ Reached
	bx	lr	@ Done, Check $r0 == 15

	@ Block of four, only first executed.
	.type it_3,%function
	.thumb_func
it_8:
	mov	r0, #0	@ Setup
	cmp	r0, #0	@ Setup
	iteee	ge	@ IT instruction, Expected == 1
	addge	r0, #1	@ Reached
	addlt	r0, #2	@ Not reached
	addlt	r0, #4	@ Not reached
	addlt	r0, #8	@ Not reached
	bx	lr	@ Done, Check $r0 == 1

#endif /* __thumb2__ */