File: branch_32.s

package info (click to toggle)
binutils-avr 2.26.20160125+Atmel3.6.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 365,552 kB
  • sloc: ansic: 2,480,046; asm: 892,807; exp: 188,218; cpp: 133,829; makefile: 63,886; sh: 32,212; yacc: 26,783; lisp: 16,709; xml: 7,490; perl: 6,449; python: 4,555; ada: 4,318; pascal: 3,174; lex: 2,250; cs: 879; sed: 334; f90: 298; awk: 168; objc: 134; java: 73; fortran: 43
file content (181 lines) | stat: -rw-r--r-- 3,775 bytes parent folder | download | duplicates (27)
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/*
 * tests for branch instruction relaxation
 *
 * Author: libin
 */

.include "relaxation_macro.h"

.macro _b_op_pattern insn insn1
.balign 2

/*
 * for local label 1, assembler should NOT alter instructions before .skip;
 * but it SHOULD alter instructions afte it.
 */
1:
  insn_16    "\insn! 1b"
  tran_16_32 "\insn! 1b", "\insn 1b"
  insn_16    "\insn1 1b"
.skip 512
  insn_16    "\insn! 1b"
  tran_16_32 "\insn! 1b", "\insn 1b"
  insn_16    "\insn1 1b"

/* 
 * for local label 2, assembler SHOULD alter instructions before .skip;
 * but it should NOT alter instructions after it.
 */
  insn_16    "\insn! 2f"
  tran_16_32 "\insn! 2f", "\insn 2f"
  insn_16    "\insn1 2f"
.skip 511
  insn_16    "\insn! 2f"
  tran_16_32 "\insn! 2f", "\insn 2f"
  insn_16    "\insn1 2f"
2:
  nop!

/* tests for boundary */
3:
.skip 512
  insn_16 "\insn! 3b"
  insn_16 "\insn! 3b"

  insn_16 "\insn! 4f"
  insn_16 "\insn! 4f"
.skip 511
4:
  nop!
.endm

.macro _br_op_pattern insn
.balign 2
  insn_32 "\insn r0"
  insn_32 "\insn r15"

  tran_16_32 "\insn! r0", "\insn r0"

  /* shouldn't alter */
  insn_32 "\insn r16"
  insn_32 "\insn r31"
.endm

.macro _bcmp_op_pattern1 insn
.balign 2

/* as will give "Using temp register(r1)" warning if you using r1 */

/*
 * for local label 1, assembler should NOT alter instructions before .skip;
 * but it SHOULD alter instructions afte it.
 */
1:
  insn_32 "\insn r0,  r15, 1b"
  insn_32 "\insn r15, r16, 1b"
  insn_32 "\insn r15, r31, 1b"
  insn_32 "\insn r16, r31, 1b"
.skip 512
  insn_32 "\insn r0,  r15, 1b"
  insn_32 "\insn r15, r16, 1b"
  insn_32 "\insn r15, r31, 1b"
  insn_32 "\insn r16, r31, 1b"

/* 
 * for local label 2, assembler SHOULD alter instructions before .skip;
 * but it should NOT alter instructions after it.
 */
  insn_32 "\insn r0,  r15, 2f"
  insn_32 "\insn r15, r16, 2f"
  insn_32 "\insn r15, r31, 2f"
  insn_32 "\insn r16, r31, 2f"
.skip 511
  insn_32 "\insn r0,  r15, 2f"
  insn_32 "\insn r15, r16, 2f"
  insn_32 "\insn r15, r31, 2f"
  insn_32 "\insn r16, r31, 2f"
2:
  nop!

/* tests for boundary */
3:
.skip 512
  insn_32 "\insn r0,  r15, 3b"
  insn_32 "\insn r16, r15, 3b"

  insn_32 "\insn r0,  r15, 4f"
  insn_32 "\insn r16, r15, 4f"
.skip 511
4:
.endm 

.macro _bcmp_op_pattern2 insn
.balign 2

/* as will give "Using temp register(r1)" warning if you using r1 */

/*
 * for local label 1, assembler should NOT alter instructions before .skip;
 * but it SHOULD alter instructions afte it.
 */
1:
  insn_32 "\insn r0,  1b"
  insn_32 "\insn r15, 1b"
  insn_32 "\insn r16, 1b"
  insn_32 "\insn r31, 1b"
.skip 512
  insn_32 "\insn r0,  1b"
  insn_32 "\insn r15, 1b"
  insn_32 "\insn r16, 1b"
  insn_32 "\insn r31, 1b"

/* 
 * for local label 2, assembler SHOULD alter instructions before .skip;
 * but it should NOT alter instructions after it.
 */
  insn_32 "\insn r0,  2f"
  insn_32 "\insn r15, 2f"
  insn_32 "\insn r16, 2f"
  insn_32 "\insn r31, 2f"
.skip 511
  insn_32 "\insn r0,  2f"
  insn_32 "\insn r15, 2f"
  insn_32 "\insn r16, 2f"
  insn_32 "\insn r31, 2f"
2:
  nop!

/* tests for boundary */
3:
.skip 512
  insn_32 "\insn r0,  3b"
  insn_32 "\insn r16, 3b"

  insn_32 "\insn r0,  4f"
  insn_32 "\insn r16, 4f"
.skip 511
4:
.endm 

.text
/* b Disp19 <-> b! Disp9 */
_b_op_pattern "bgtu", "bgtul"
_b_op_pattern "bleu", "bleul"
_b_op_pattern "beq",  "beql"
_b_op_pattern "bne",  "bnel"
_b_op_pattern "bgt",  "bgtl"
_b_op_pattern "ble",  "blel"
_b_op_pattern "bcnz", "bcnzl"
_b_op_pattern "b",    "bl"

/* br rD <-> br! rD */
_br_op_pattern "br"
_br_op_pattern "brl"

/* bcmpeq/bcmpne rA,rB,Disp9 -> cmp/cmp! rA, rB; beq/bne Disp19 */
_bcmp_op_pattern1 "bcmpeq"
_bcmp_op_pattern1 "bcmpne"

/* bcmpeqz/bcmpnez rA,Disp9 -> cmpi! rA, 0; beq/bne Disp19 */
_bcmp_op_pattern2 "bcmpeqz"
_bcmp_op_pattern2 "bcmpnez"