blob: 8d4464bbbed77a55035aec93704a35d2173c7363 [file] [log] [blame]
Zoran Jovanovic10e06da2014-05-27 12:55:40 +00001# RUN: llvm-mc %s -triple=mips-unknown-linux -show-encoding -mcpu=mips32r6 \
2# RUN: | FileCheck %s -check-prefix=CHECK-FIXUP
3# RUN: llvm-mc %s -filetype=obj -triple=mips-unknown-linux -mcpu=mips32r6 \
Elvina Yakubovab36a3e62020-07-20 08:39:14 +01004# RUN: | llvm-readobj -r - | FileCheck %s -check-prefix=CHECK-ELF
Zoran Jovanovic10e06da2014-05-27 12:55:40 +00005#------------------------------------------------------------------------------
6# Check that the assembler can handle the documented syntax for fixups.
7#------------------------------------------------------------------------------
Petar Jovanovicd4f37232017-09-11 18:34:04 +00008# CHECK-FIXUP: lapc $2, bar # encoding: [0xec,0b01000AAA,A,A]
Zoran Jovanovicb9c07f32014-06-12 12:40:00 +00009# CHECK-FIXUP: # fixup A - offset: 0,
10# CHECK-FIXUP: value: bar, kind: fixup_MIPS_PC19_S2
Zoran Jovanovic10e06da2014-05-27 12:55:40 +000011# CHECK-FIXUP: beqc $5, $6, bar # encoding: [0x20,0xa6,A,A]
12# CHECK-FIXUP: # fixup A - offset: 0,
Petar Jovanovicb7915a12015-06-23 13:54:42 +000013# CHECK-FIXUP: value: bar-4, kind: fixup_Mips_PC16
Zoran Jovanovic10e06da2014-05-27 12:55:40 +000014# CHECK-FIXUP: bnec $5, $6, bar # encoding: [0x60,0xa6,A,A]
15# CHECK-FIXUP: # fixup A - offset: 0,
Petar Jovanovicb7915a12015-06-23 13:54:42 +000016# CHECK-FIXUP: value: bar-4, kind: fixup_Mips_PC16
Zoran Jovanovic10e06da2014-05-27 12:55:40 +000017# CHECK-FIXUP: beqzc $9, bar # encoding: [0xd9,0b001AAAAA,A,A]
18# CHECK-FIXUP: # fixup A - offset: 0,
Petar Jovanovicb7915a12015-06-23 13:54:42 +000019# CHECK-FIXUP: value: bar-4, kind: fixup_MIPS_PC21_S2
Zoran Jovanovic10e06da2014-05-27 12:55:40 +000020# CHECK-FIXUP: bnezc $9, bar # encoding: [0xf9,0b001AAAAA,A,A]
21# CHECK-FIXUP: # fixup A - offset: 0,
Petar Jovanovicb7915a12015-06-23 13:54:42 +000022# CHECK-FIXUP: value: bar-4, kind: fixup_MIPS_PC21_S2
Zoran Jovanovic10e06da2014-05-27 12:55:40 +000023# CHECK-FIXUP: balc bar # encoding: [0b111010AA,A,A,A]
24# CHECK-FIXUP: # fixup A - offset: 0,
Petar Jovanovicb7915a12015-06-23 13:54:42 +000025# CHECK-FIXUP: value: bar-4, kind: fixup_MIPS_PC26_S2
Zoran Jovanovic10e06da2014-05-27 12:55:40 +000026# CHECK-FIXUP: bc bar # encoding: [0b110010AA,A,A,A]
27# CHECK-FIXUP: # fixup A - offset: 0,
Petar Jovanovicb7915a12015-06-23 13:54:42 +000028# CHECK-FIXUP: value: bar-4, kind: fixup_MIPS_PC26_S2
Zoran Jovanovicb355e8f2014-05-27 14:58:51 +000029# CHECK-FIXUP: aluipc $2, %pcrel_hi(bar) # encoding: [0xec,0x5f,A,A]
30# CHECK-FIXUP: # fixup A - offset: 0,
Daniel Sandersfe98b2f2016-05-03 13:35:44 +000031# CHECK-FIXUP: value: %pcrel_hi(bar),
Zoran Jovanovicb355e8f2014-05-27 14:58:51 +000032# CHECK-FIXUP: kind: fixup_MIPS_PCHI16
33# CHECK-FIXUP: addiu $2, $2, %pcrel_lo(bar) # encoding: [0x24,0x42,A,A]
34# CHECK-FIXUP: # fixup A - offset: 0,
Daniel Sandersfe98b2f2016-05-03 13:35:44 +000035# CHECK-FIXUP: value: %pcrel_lo(bar),
Zoran Jovanovicb355e8f2014-05-27 14:58:51 +000036# CHECK-FIXUP: kind: fixup_MIPS_PCLO16
Petar Jovanovicd4f37232017-09-11 18:34:04 +000037# CHECK-FIXUP: lapc $2, bar # encoding: [0xec,0b01000AAA,A,A]
38# CHECK-FIXUP: # fixup A - offset: 0,
39# CHECK-FIXUP: value: bar, kind: fixup_MIPS_PC19_S2
Zoran Jovanovicb9c07f32014-06-12 12:40:00 +000040# CHECK-FIXUP: lwpc $2, bar # encoding: [0xec,0b01001AAA,A,A]
41# CHECK-FIXUP: # fixup A - offset: 0,
42# CHECK-FIXUP: value: bar, kind: fixup_MIPS_PC19_S2
Simon Atanasyanf6551dd2019-10-03 12:08:26 +000043# CHECK-FIXUP: jialc $5, bar # encoding: [0xf8,0x05,A,A]
44# CHECK-FIXUP: # fixup A - offset: 0,
45# CHECK-FIXUP: value: bar, kind: fixup_Mips_LO16
46# CHECK-FIXUP: jic $5, bar # encoding: [0xd8,0x05,A,A]
47# CHECK-FIXUP: # fixup A - offset: 0,
48# CHECK-FIXUP: value: bar, kind: fixup_Mips_LO16
Zoran Jovanovic10e06da2014-05-27 12:55:40 +000049#------------------------------------------------------------------------------
50# Check that the appropriate relocations were created.
51#------------------------------------------------------------------------------
52# CHECK-ELF: Relocations [
Georgii Rymar98a42892020-12-10 16:12:26 +030053# CHECK-ELF: 0x0 R_MIPS_PC19_S2 bar
54# CHECK-ELF: 0x4 R_MIPS_PC16 bar
yingopqe2182a62024-02-24 15:13:43 +080055# CHECK-ELF: 0xC R_MIPS_PC16 bar
56# CHECK-ELF: 0x14 R_MIPS_PC21_S2 bar
57# CHECK-ELF: 0x1C R_MIPS_PC21_S2 bar
58# CHECK-ELF: 0x24 R_MIPS_PC26_S2 bar
59# CHECK-ELF: 0x28 R_MIPS_PC26_S2 bar
60# CHECK-ELF: 0x2C R_MIPS_PCHI16 bar
61# CHECK-ELF: 0x30 R_MIPS_PCLO16 bar
62# CHECK-ELF: 0x34 R_MIPS_PC19_S2 bar
63# CHECK-ELF: 0x38 R_MIPS_PC19_S2 bar
64# CHECK-ELF: 0x3C R_MIPS_LO16 bar
65# CHECK-ELF: 0x40 R_MIPS_LO16 bar
Zoran Jovanovic10e06da2014-05-27 12:55:40 +000066# CHECK-ELF: ]
67
Zoran Jovanovicb9c07f32014-06-12 12:40:00 +000068 addiupc $2,bar
Zoran Jovanovic10e06da2014-05-27 12:55:40 +000069 beqc $5, $6, bar
70 bnec $5, $6, bar
71 beqzc $9, bar
72 bnezc $9, bar
73 balc bar
74 bc bar
Zoran Jovanovicb355e8f2014-05-27 14:58:51 +000075 aluipc $2, %pcrel_hi(bar)
76 addiu $2, $2, %pcrel_lo(bar)
Petar Jovanovicd4f37232017-09-11 18:34:04 +000077 lapc $2,bar
Zoran Jovanovicb9c07f32014-06-12 12:40:00 +000078 lwpc $2,bar
Simon Atanasyanf6551dd2019-10-03 12:08:26 +000079 jialc $5, bar
80 jic $5, bar