1# RUN: llvm-mc %s -triple mips-unknown-linux-gnu -show-encoding |\
2# RUN:   FileCheck %s -check-prefix=NORMAL
3
4# RUN: llvm-mc %s -triple mips64-unknown-linux-gnuabin32 -show-encoding |\
5# RUN:   FileCheck %s -check-prefix=NORMAL
6
7# RUN: llvm-mc %s -triple mips64-unknown-linux-gnu -show-encoding |\
8# RUN:   FileCheck %s -check-prefix=NORMAL
9
10# RUN: llvm-mc %s -triple mips-unknown-linux-gnu -mattr=micromips -show-encoding |\
11# RUN:   FileCheck %s -check-prefix=MICRO
12
13# Repeat the tests using ELF output.
14
15# RUN: llvm-mc %s -triple mips-unknown-linux-gnu -filetype=obj | \
16# RUN:   llvm-objdump -d -r - | FileCheck %s --check-prefixes=ELF-O32
17# RUN: llvm-mc %s -triple mips64-unknown-linux-gnuabin32 -filetype=obj | \
18# RUN:   llvm-objdump -d -r - | FileCheck %s --check-prefixes=ELF-NXX,ELF-N32
19# RUN: llvm-mc %s -triple mips64-unknown-linux-gnu -filetype=obj | \
20# RUN:   llvm-objdump -d -r - | FileCheck %s --check-prefixes=ELF-NXX,ELF-N64
21
22  .weak weak_label
23
24  .text
25  .option pic2
26
27  .ent local_label
28local_label:
29  .frame  $sp, 0, $ra
30  .set noreorder
31
32  j local_label
33  nop
34
35# NORMAL: b      local_label      # encoding: [0x10,0x00,A,A]
36# NORMAL:                         #   fixup A - offset: 0, value: local_label-4, kind: fixup_Mips_PC16
37
38# MICRO:  b      local_label      # encoding: [0x94,0x00,A,A]
39# MICRO:                          #   fixup A - offset: 0, value: local_label, kind: fixup_MICROMIPS_PC16_S1
40
41# ELF-O32:      10 00 ff ff     b       0
42
43# ELF-NXX:      10 00 ff ff     b       0
44
45  j weak_label
46  nop
47
48# NORMAL: b      weak_label       # encoding: [0x10,0x00,A,A]
49# NORMAL:                         #   fixup A - offset: 0, value: weak_label-4, kind: fixup_Mips_PC16
50
51# MICRO:  b      weak_label       # encoding: [0x94,0x00,A,A]
52# MICRO:                          #   fixup A - offset: 0, value: weak_label, kind: fixup_MICROMIPS_PC16_S1
53
54# ELF-O32:      10 00 ff ff     b       0
55# ELF-O32-NEXT:                 R_MIPS_PC16  weak_label
56
57# ELF-NXX:      10 00 00 00     b       4
58# ELF-N32-NEXT:                 R_MIPS_PC16  weak_label
59# ELF-N64-NEXT:                 R_MIPS_PC16/R_MIPS_NONE/R_MIPS_NONE  weak_label
60
61  j global_label
62  nop
63
64# NORMAL: b      global_label     # encoding: [0x10,0x00,A,A]
65# NORMAL:                         #   fixup A - offset: 0, value: global_label-4, kind: fixup_Mips_PC16
66
67# MICRO:  b      global_label     # encoding: [0x94,0x00,A,A]
68# MICRO:                          #   fixup A - offset: 0, value: global_label, kind: fixup_MICROMIPS_PC16_S1
69
70# ELF-O32:      10 00 ff ff     b       0
71# ELF-O32-NEXT:         00000010:  R_MIPS_PC16  global_label
72
73# ELF-NXX:      10 00 00 00     b       4
74# ELF-N32-NEXT:                 R_MIPS_PC16 global_label
75# ELF-N64-NEXT:                 R_MIPS_PC16/R_MIPS_NONE/R_MIPS_NONE  global_label
76
77  j .text
78  nop
79
80# NORMAL: b      .text            # encoding: [0x10,0x00,A,A]
81# NORMAL:                         #   fixup A - offset: 0, value: .text-4, kind: fixup_Mips_PC16
82
83# MICRO:  b      .text            # encoding: [0x94,0x00,A,A]
84# MICRO:                          #   fixup A - offset: 0, value: .text, kind: fixup_MICROMIPS_PC16_S1
85
86# ELF-O32:      10 00 ff f9 	b	-24 <local_label>
87# ELF-O32-NEXT: 00 00 00 00 	nop
88
89# ELF-NXX:      10 00 ff f9 	b	-24 <local_label>
90# ELF-NXX-NEXT: 00 00 00 00 	nop
91
92  j 1f
93  nop
94
95# NORMAL: b      {{.*}}tmp0{{.*}} # encoding: [0x10,0x00,A,A]
96# NORMAL:                         #   fixup A - offset: 0, value: {{.*}}tmp0{{.*}}-4, kind: fixup_Mips_PC16
97
98# MICRO:  b      {{.*}}tmp0{{.*}} # encoding: [0x94,0x00,A,A]
99# MICRO:                          #   fixup A - offset: 0, value: {{.*}}tmp0{{.*}}, kind: fixup_MICROMIPS_PC16_S1
100
101# ELF-O32:      10 00 00 04     b       20 <local_label+0x34>
102
103# ELF-NXX:      10 00 00 04     b       20 <local_label+0x34>
104
105  .local forward_local
106  j forward_local
107  nop
108
109# NORMAL: b      forward_local    # encoding: [0x10,0x00,A,A]
110# NORMAL:                         #   fixup A - offset: 0, value: forward_local-4, kind: fixup_Mips_PC16
111
112# MICRO:  b      forward_local    # encoding: [0x94,0x00,A,A]
113# MICRO:                          #   fixup A - offset: 0, value: forward_local, kind: fixup_MICROMIPS_PC16_S1
114
115# ELF-O32:      10 00 00 04     b       20 <forward_local>
116
117# ELF-NXX:      10 00 00 04     b       20 <forward_local>
118
119  j 0x4
120
121# NORMAL: b      4                # encoding: [0x10,0x00,0x00,0x01]
122
123# MICRO:  b      4                # encoding: [0x94,0x00,0x00,0x02]
124
125# ELF-O32:      10 00 00 01     b       8
126
127# ELF-NXX:      10 00 00 01     b       8
128
129  .end local_label
130
1311:
132  nop
133  nop
134forward_local:
135
136