1 # RUN: llvm-mc %s -arch=mips -mcpu=mips32 -relocation-model=pic -show-encoding | \ 2 # RUN: FileCheck %s 3 4 # RUN: llvm-mc %s -arch=mips -mcpu=mips32 -relocation-model=pic -filetype=obj -o -| \ 5 # RUN: llvm-objdump -d -r -arch=mips - | \ 6 # RUN: FileCheck %s -check-prefix=CHECK-FOR-STORE 7 8 # RUN: llvm-mc %s -arch=mips -mcpu=mips32 -mattr=+micromips -relocation-model=pic -show-encoding | \ 9 # RUN: FileCheck %s -check-prefix=MICROMIPS 10 11 # RUN: llvm-mc %s -arch=mips -mcpu=mips32 -relocation-model=static -show-encoding | \ 12 # RUN: FileCheck %s -check-prefix=NO-PIC 13 14 # RUN: llvm-mc %s -arch=mips -mcpu=mips64 -target-abi n32 -relocation-model=pic -show-encoding | \ 15 # RUN: FileCheck %s -check-prefix=BAD-ABI -check-prefix=BAD-ABI-N32 16 17 # RUN: llvm-mc %s -arch=mips64 -mcpu=mips64 -target-abi n64 -relocation-model=pic -show-encoding | \ 18 # RUN: FileCheck %s -check-prefix=BAD-ABI -check-prefix=BAD-ABI-N64 19 20 .text 21 .ent foo 22 foo: 23 .frame $sp, 0, $ra 24 .set noreorder 25 .cpload $25 26 .set reorder 27 28 .cprestore 8 29 30 jal $25 31 jal $4, $25 32 jal foo 33 34 .end foo 35 36 # CHECK-FOR-STORE: sw $gp, 8($sp) 37 38 # CHECK: .cprestore 8 39 # CHECK: jalr $25 # encoding: [0x03,0x20,0xf8,0x09] 40 # CHECK: nop # encoding: [0x00,0x00,0x00,0x00] 41 # CHECK: lw $gp, 8($sp) # encoding: [0x8f,0xbc,0x00,0x08] 42 43 # CHECK: jalr $4, $25 # encoding: [0x03,0x20,0x20,0x09] 44 # CHECK: nop # encoding: [0x00,0x00,0x00,0x00] 45 # CHECK: lw $gp, 8($sp) # encoding: [0x8f,0xbc,0x00,0x08] 46 47 # CHECK: lw $25, %got(foo)($gp) # encoding: [0x8f,0x99,A,A] 48 # CHECK: # fixup A - offset: 0, value: foo@GOT, kind: fixup_Mips_GOT_Local 49 # CHECK: addiu $25, $25, %lo(foo) # encoding: [0x27,0x39,A,A] 50 # CHECK: # fixup A - offset: 0, value: foo@ABS_LO, kind: fixup_Mips_LO16 51 # CHECK: jalr $25 # encoding: [0x03,0x20,0xf8,0x09] 52 # CHECK: nop # encoding: [0x00,0x00,0x00,0x00] 53 # CHECK: lw $gp, 8($sp) # encoding: [0x8f,0xbc,0x00,0x08] 54 # CHECK: .end foo 55 56 # MICROMIPS: .cprestore 8 57 # MICROMIPS: jalrs16 $25 # encoding: [0x45,0xf9] 58 # MICROMIPS: nop # encoding: [0x0c,0x00] 59 # MICROMIPS: lw $gp, 8($sp) # encoding: [0xff,0x9d,0x00,0x08] 60 61 # MICROMIPS: jalrs $4, $25 # encoding: [0x00,0x99,0x4f,0x3c] 62 # MICROMIPS: nop # encoding: [0x0c,0x00] 63 # MICROMIPS: lw $gp, 8($sp) # encoding: [0xff,0x9d,0x00,0x08] 64 65 # MICROMIPS: lw $25, %got(foo)($gp) # encoding: [0xff,0x3c,A,A] 66 # MICROMIPS: # fixup A - offset: 0, value: foo@GOT, kind: fixup_MICROMIPS_GOT16 67 # MICROMIPS: addiu $25, $25, %lo(foo) # encoding: [0x33,0x39,A,A] 68 # MICROMIPS: # fixup A - offset: 0, value: foo@ABS_LO, kind: fixup_MICROMIPS_LO16 69 # MICROMIPS: jalrs $ra, $25 # encoding: [0x03,0xf9,0x4f,0x3c] 70 # MICROMIPS: nop # encoding: [0x0c,0x00] 71 # MICROMIPS: lw $gp, 8($sp) # encoding: [0xff,0x9d,0x00,0x08] 72 # MICROMIPS: .end foo 73 74 # NO-PIC: .cprestore 8 75 # NO-PIC: jalr $25 # encoding: [0x03,0x20,0xf8,0x09] 76 # NO-PIC-NOT: lw $gp, 8($sp) # encoding: [0x8f,0xbc,0x00,0x08] 77 78 # NO-PIC: jalr $4, $25 # encoding: [0x03,0x20,0x20,0x09] 79 # NO-PIC-NOT: lw $gp, 8($sp) # encoding: [0x8f,0xbc,0x00,0x08] 80 81 # NO-PIC: jal foo # encoding: [0b000011AA,A,A,A] 82 # NO-PIC: # fixup A - offset: 0, value: foo, kind: fixup_Mips_26 83 # NO-PIC-NOT: lw $gp, 8($sp) # encoding: [0x8f,0xbc,0x00,0x08] 84 # NO-PIC: .end foo 85 86 # BAD-ABI: .cprestore 8 87 # BAD-ABI: jalr $25 # encoding: [0x03,0x20,0xf8,0x09] 88 # BAD-ABI-NOT: lw $gp, 8($sp) # encoding: [0x8f,0xbc,0x00,0x08] 89 90 # BAD-ABI: jalr $4, $25 # encoding: [0x03,0x20,0x20,0x09] 91 # BAD-ABI-NOT: lw $gp, 8($sp) # encoding: [0x8f,0xbc,0x00,0x08] 92 93 # BAD-ABI-N32: lw $25, %got_disp(foo)($gp) # encoding: [0x8f,0x99,A,A] 94 # BAD-ABI-N64: ld $25, %got_disp(foo)($gp) # encoding: [0xdf,0x99,A,A] 95 # BAD-ABI: # fixup A - offset: 0, value: foo@GOT_DISP, kind: fixup_Mips_GOT_DISP 96 # BAD-ABI: jalr $25 # encoding: [0x03,0x20,0xf8,0x09] 97 # BAD-ABI-NOT: lw $gp, 8($sp) # encoding: [0x8f,0xbc,0x00,0x08] 98 # BAD-ABI: .end foo 99