1	.bundle_align_mode 5
2
3# We use these macros to test each pattern at every offset from
4# bundle alignment, i.e. [0,31].
5
6.macro offset_insn insn_name, offset
7	.p2align 5
8\insn_name\()_offset_\offset\():
9	.if \offset
10	.space \offset, 0xf4
11	.endif
12	\insn_name
13.endm
14
15.macro test_offsets insn_name
16	offset_insn \insn_name, 0
17	offset_insn \insn_name, 1
18	offset_insn \insn_name, 2
19	offset_insn \insn_name, 3
20	offset_insn \insn_name, 4
21	offset_insn \insn_name, 5
22	offset_insn \insn_name, 6
23	offset_insn \insn_name, 7
24	offset_insn \insn_name, 8
25	offset_insn \insn_name, 9
26	offset_insn \insn_name, 10
27	offset_insn \insn_name, 11
28	offset_insn \insn_name, 12
29	offset_insn \insn_name, 13
30	offset_insn \insn_name, 14
31	offset_insn \insn_name, 15
32	offset_insn \insn_name, 16
33	offset_insn \insn_name, 17
34	offset_insn \insn_name, 18
35	offset_insn \insn_name, 19
36	offset_insn \insn_name, 20
37	offset_insn \insn_name, 21
38	offset_insn \insn_name, 22
39	offset_insn \insn_name, 23
40	offset_insn \insn_name, 24
41	offset_insn \insn_name, 25
42	offset_insn \insn_name, 26
43	offset_insn \insn_name, 27
44	offset_insn \insn_name, 28
45	offset_insn \insn_name, 29
46	offset_insn \insn_name, 30
47	offset_insn \insn_name, 31
48.endm
49
50# These are vanilla (non-relaxed) instructions of each length.
51.macro test_1
52	inc %eax
53.endm
54.macro test_2
55	add %eax,%eax
56.endm
57.macro test_3
58	and $3,%eax
59.endm
60.macro test_4
61	lock andl $3,(%eax)
62.endm
63.macro test_5
64	mov $0xaabbccdd,%eax
65.endm
66.macro test_6
67	movl %eax,0xaabbccdd(%esi)
68.endm
69.macro test_7
70	movl $0xaabbccdd,0x7f(%esi)
71.endm
72.macro test_8
73	lock addl $0xaabbccdd,0x10(%esi)
74.endm
75.macro test_9
76	lock addl $0xaabbccdd,%fs:0x10(%esi)
77.endm
78.macro test_10
79	movl $0xaabbccdd,0x7ff(%esi)
80.endm
81.macro test_11
82	lock addl $0xaabbccdd,0x7ff(%esi)
83.endm
84.macro test_12
85	lock addl $0xaabbccdd,%fs:0x7ff(%esi)
86.endm
87
88test_offsets test_1
89test_offsets test_2
90test_offsets test_3
91test_offsets test_4
92test_offsets test_5
93test_offsets test_6
94test_offsets test_7
95test_offsets test_8
96test_offsets test_9
97test_offsets test_10
98test_offsets test_11
99test_offsets test_12
100
101# The only relaxation cases are the jump instructions.
102# For each of the three flavors of jump (unconditional, conditional,
103# and conditional with prediction), we test a case that can be relaxed
104# to its shortest form, and one that must use the long form.
105.macro jmp_2
106	jmp jmp_2_\@
107	movl $0xdeadbeef,%eax
108jmp_2_\@\():
109	movl $0xb00b,%eax
110.endm
111.macro jmp_5
112	jmp jmp_5_\@
113	.rept 128
114	inc %eax
115	.endr
116jmp_5_\@\():
117	movl $0xb00b,%eax
118.endm
119
120.macro cjmp_2
121	jz cjmp_2_\@
122	movl $0xdeadbeef,%eax
123cjmp_2_\@\():
124	movl $0xb00b,%eax
125.endm
126.macro cjmp_6
127	jz cjmp_6_\@
128	.rept 128
129	inc %eax
130	.endr
131cjmp_6_\@\():
132	movl $0xb00b,%eax
133.endm
134
135.macro pjmp_3
136	jz,pt pjmp_3_\@
137	movl $0xdeadbeef,%eax
138pjmp_3_\@\():
139	movl $0xb00b,%eax
140.endm
141.macro pjmp_7
142	jz,pt pjmp_7_\@
143	.rept 128
144	inc %eax
145	.endr
146pjmp_7_\@\():
147	movl $0xb00b,%eax
148.endm
149
150test_offsets jmp_2
151test_offsets cjmp_2
152test_offsets pjmp_3
153test_offsets jmp_5
154test_offsets cjmp_6
155test_offsets pjmp_7
156
157.p2align 5
158	hlt
159