1# REQUIRES: mips
2# Check microMIPS thunk generation.
3
4# RUN: echo "SECTIONS { \
5# RUN:         . = 0x20000;  .text ALIGN(0x100) : { *(.text) } \
6# RUN:       }" > %t.script
7
8# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \
9# RUN:         -mcpu=mips32r2 -mattr=micromips %s -o %t-eb.o
10# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \
11# RUN:         -position-independent -mcpu=mips32r2 -mattr=micromips \
12# RUN:         %S/Inputs/mips-micro.s -o %t-eb-pic.o
13# RUN: ld.lld -o %t-eb.exe -script %t.script %t-eb.o %t-eb-pic.o
14# RUN: llvm-objdump -d --mattr=+micromips --no-show-raw-insn %t-eb.exe \
15# RUN:   | FileCheck --check-prefix=R2 %s
16
17# RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux \
18# RUN:         -mcpu=mips32r2 -mattr=micromips %s -o %t-el.o
19# RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux \
20# RUN:         -position-independent -mcpu=mips32r2 -mattr=micromips \
21# RUN:         %S/Inputs/mips-micro.s -o %t-el-pic.o
22# RUN: ld.lld -o %t-el.exe -script %t.script %t-el.o %t-el-pic.o
23# RUN: llvm-objdump -d --mattr=+micromips --no-show-raw-insn %t-el.exe \
24# RUN:   | FileCheck --check-prefix=R2 %s
25
26# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \
27# RUN:         -mcpu=mips32r6 -mattr=micromips %s -o %t-eb-r6.o
28# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \
29# RUN:         -position-independent -mcpu=mips32r6 -mattr=micromips \
30# RUN:         %S/Inputs/mips-micro.s -o %t-eb-pic-r6.o
31# RUN: ld.lld -o %t-eb-r6.exe -script %t.script %t-eb-r6.o %t-eb-pic-r6.o
32# RUN: llvm-objdump -d --mattr=+micromips --no-show-raw-insn %t-eb-r6.exe \
33# RUN:   | FileCheck --check-prefix=R6 %s
34
35# RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux \
36# RUN:         -mcpu=mips32r6 -mattr=micromips %s -o %t-el-r6.o
37# RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux \
38# RUN:         -position-independent -mcpu=mips32r6 -mattr=micromips \
39# RUN:         %S/Inputs/mips-micro.s -o %t-el-pic-r6.o
40# RUN: ld.lld -o %t-el-r6.exe -script %t.script %t-el-r6.o %t-el-pic-r6.o
41# RUN: llvm-objdump -d --mattr=+micromips --no-show-raw-insn %t-el-r6.exe \
42# RUN:   | FileCheck --check-prefix=R6 %s
43
44# R2: <__start>:
45# R2-NEXT:    20100:  jal   131336 <__microLA25Thunk_foo>
46# R2-NEXT:            nop
47
48# R2: <__microLA25Thunk_foo>:
49# R2-NEXT:    20108:  lui   $25, 2
50# R2-NEXT:            j     131360 <foo>
51# R2-NEXT:            addiu $25, $25, 289
52# R2-NEXT:            nop
53
54# R6: <__start>:
55# R6-NEXT:    20100:  balc  0 <__start>
56
57# R6: <__microLA25Thunk_foo>:
58# R6-NEXT:    20104:  lui   $25, 2
59# R6-NEXT:            addiu $25, $25, 273
60# R6-NEXT:            bc    0 <__microLA25Thunk_foo+0x8>
61
62  .text
63  .set micromips
64  .global __start
65__start:
66  jal foo
67