1# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+relax %s \
2# RUN:     | llvm-readobj -r | FileCheck -check-prefix=RELAX %s
3# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=-relax %s \
4# RUN:     | llvm-readobj -r | FileCheck -check-prefix=NORELAX %s
5
6# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+relax %s \
7# RUN:     | llvm-readobj -r | FileCheck -check-prefix=RELAX %s
8# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=-relax %s \
9# RUN:     | llvm-readobj -r | FileCheck -check-prefix=NORELAX %s
10
11# Check that subtraction expressions are emitted as two relocations
12# only when relaxation is enabled
13
14.globl G1
15.globl G2
16.L1:
17G1:
18addi a0, a0, 0
19.L2:
20G2:
21
22.data
23.dword .L2-.L1
24.dword G2-G1
25.word .L2-.L1
26.word G2-G1
27.half .L2-.L1
28.half G2-G1
29.byte .L2-.L1
30.byte G2-G1
31# RELAX: 0x0 R_RISCV_ADD64 .L2 0x0
32# RELAX: 0x0 R_RISCV_SUB64 .L1 0x0
33# RELAX: 0x8 R_RISCV_ADD64 G2 0x0
34# RELAX: 0x8 R_RISCV_SUB64 G1 0x0
35# RELAX: 0x10 R_RISCV_ADD32 .L2 0x0
36# RELAX: 0x10 R_RISCV_SUB32 .L1 0x0
37# RELAX: 0x14 R_RISCV_ADD32 G2 0x0
38# RELAX: 0x14 R_RISCV_SUB32 G1 0x0
39# RELAX: 0x18 R_RISCV_ADD16 .L2 0x0
40# RELAX: 0x18 R_RISCV_SUB16 .L1 0x0
41# RELAX: 0x1A R_RISCV_ADD16 G2 0x0
42# RELAX: 0x1A R_RISCV_SUB16 G1 0x0
43# RELAX: 0x1C R_RISCV_ADD8 .L2 0x0
44# RELAX: 0x1C R_RISCV_SUB8 .L1 0x0
45# RELAX: 0x1D R_RISCV_ADD8 G2 0x0
46# RELAX: 0x1D R_RISCV_SUB8 G1 0x0
47# NORELAX-NOT: R_RISCV
48