reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
  104
  105
  106
  107
  108
  109
  110
  111
  112
  113
  114
  115
  116
  117
  118
  119
  120
  121
  122
  123
  124
  125
  126
  127
  128
  129
  130
  131
  132
  133
  134
  135
  136
  137
  138
  139
  140
  141
  142
  143
  144
  145
  146
  147
  148
  149
  150
  151
  152
  153
  154
  155
  156
! Testing Sparc TLS relocations emission
! (for now a couple local ones).
!
! RUN: llvm-mc %s -arch=sparc -show-encoding | FileCheck %s --check-prefix=ASM
! RUN: llvm-mc %s -arch=sparcv9 -show-encoding | FileCheck %s --check-prefix=ASM
! RUN: llvm-mc %s -arch=sparc -filetype=obj | llvm-readobj -r | FileCheck %s --check-prefix=REL
! RUN: llvm-mc %s -arch=sparcv9 -filetype=obj | llvm-readobj -r | FileCheck %s --check-prefix=REL
! RUN: llvm-mc %s -arch=sparc -filetype=obj | llvm-objdump -r -d - | FileCheck %s --check-prefix=OBJDUMP
! RUN: llvm-mc %s -arch=sparcv9 -filetype=obj | llvm-objdump -r -d - | FileCheck %s --check-prefix=OBJDUMP

! REL: Arch: sparc
! REL: Relocations [
! REL: 0x{{[0-9,A-F]+}} R_SPARC_TLS_LE_HIX22 Local 0x0
! REL: 0x{{[0-9,A-F]+}} R_SPARC_TLS_LE_LOX10 Local 0x0
! REL: 0x{{[0-9,A-F]+}} R_SPARC_TLS_LDO_HIX22 Local 0x0
! REL: 0x{{[0-9,A-F]+}} R_SPARC_TLS_LDM_HI22  Local 0x0
! REL: 0x{{[0-9,A-F]+}} R_SPARC_TLS_LDM_LO10  Local 0x0
! REL: 0x{{[0-9,A-F]+}} R_SPARC_TLS_LDO_LOX10 Local 0x0
! REL: ]


! OBJDUMP: foo:
foo:
! Here we use two different sequences to get the address of a static TLS variable 'Local'
! (note - there is no intent to have valid assembler function here,
!  we just check how TLS relocations are emitted)
!
! Sequence for Local Executable model:
!     LE_HIX22/LE_LOX10

! OBJDUMP: {{[0-9,a-f]+}}:  31 00 00 00  sethi 0, %i0
! OBJDUMP: {{[0-9,a-f]+}}:     R_SPARC_TLS_LE_HIX22 Local
! ASM: sethi %tle_hix22(Local), %i0 ! encoding: [0x31,0x00,0x00,0x00]
! ASM:                             !   fixup A - offset: 0, value: %tle_hix22(Local), kind: fixup_sparc_tls_le_hix22
        sethi %tle_hix22(Local), %i0

! OBJDUMP: {{[0-9,a-f]+}}:  b0 1e 20 00  xor %i0, 0, %i0
! OBJDUMP: {{[0-9,a-f]+}}:     R_SPARC_TLS_LE_LOX10 Local
! ASM: xor %i0, %tle_lox10(Local), %i0 ! encoding: [0xb0,0x1e,0x20,0x00]
! ASM:                                !   fixup A - offset: 0, value: %tle_lox10(Local), kind: fixup_sparc_tls_le_lox10
        xor %i0, %tle_lox10(Local), %i0


! Second sequence is for PIC, so it is more complicated.
! Local Dynamic model:
!     LDO_HIX22/LDO_LOX10/LDO_ADD/LDM_HI22/LDM_LO10/LDM_ADD/LDM_CALL

! OBJDUMP: {{[0-9,a-f]+}}:  33 00 00 00  sethi 0, %i1
! OBJDUMP: {{[0-9,a-f]+}}:     R_SPARC_TLS_LDO_HIX22 Local
! ASM: sethi %tldo_hix22(Local), %i1 ! encoding: [0x33,0b00AAAAAA,A,A]
! ASM:                              !   fixup A - offset: 0, value: %tldo_hix22(Local), kind: fixup_sparc_tls_ldo_hix22
        sethi %tldo_hix22(Local), %i1

! OBJDUMP: {{[0-9,a-f]+}}:  35 00 00 00  sethi 0, %i2
! OBJDUMP: {{[0-9,a-f]+}}:     R_SPARC_TLS_LDM_HI22 Local
! ASM: sethi %tldm_hi22(Local), %i2 ! encoding: [0x35,0b00AAAAAA,A,A]
! ASM:                             !   fixup A - offset: 0, value: %tldm_hi22(Local), kind: fixup_sparc_tls_ldm_hi22
        sethi %tldm_hi22(Local), %i2

! OBJDUMP: {{[0-9,a-f]+}}:  b4 06 a0 00  add %i2, 0, %i2
! OBJDUMP: {{[0-9,a-f]+}}:     R_SPARC_TLS_LDM_LO10 Local
! ASM: add %i2, %tldm_lo10(Local), %i2 ! encoding: [0xb4,0x06,0b101000AA,A]
! ASM:                                !   fixup A - offset: 0, value: %tldm_lo10(Local), kind: fixup_sparc_tls_ldm_lo10
        add %i2, %tldm_lo10(Local), %i2

! OBJDUMP: {{[0-9,a-f]+}}:  90 06 00 1a add %i0, %i2, %o0
! OBJDUMP: {{[0-9,a-f]+}}:     R_SPARC_TLS_LDM_ADD Local
! ASM: add %i0, %i2, %o0, %tldm_add(Local) ! encoding: [0x90,0x06,0x00,0x1a]
! ASM:                                    !   fixup A - offset: 0, value: %tldm_add(Local), kind: fixup_sparc_tls_ldm_add
	add %i0, %i2, %o0, %tldm_add(Local)

! OBJDUMP: {{[0-9,a-f]+}}:  b0 1e 60 00  xor %i1, 0, %i0
! OBJDUMP: {{[0-9,a-f]+}}:     R_SPARC_TLS_LDO_LOX10 Local
! ASM: xor %i1, %tldo_lox10(Local), %i0 ! encoding: [0xb0,0x1e,0b011000AA,A]
! ASM:                                 !   fixup A - offset: 0, value: %tldo_lox10(Local), kind: fixup_sparc_tls_ldo_lox10
        xor %i1, %tldo_lox10(Local), %i0

! OBJDUMP: {{[0-9,a-f]+}}:  40 00 00 00 call 0
! OBJDUMP: {{[0-9,a-f]+}}:     R_SPARC_TLS_LDM_CALL Local
! ASM: call __tls_get_addr, %tldm_call(Local) ! encoding: [0x40,0x00,0x00,0x00]
! ASM:                                       !   fixup A - offset: 0, value: %tldm_call(Local), kind: fixup_sparc_tls_ldm_call
        call __tls_get_addr, %tldm_call(Local)
        nop

! OBJDUMP: {{[0-9,a-f]+}}:  90 02 00 18 add %o0, %i0, %o0
! OBJDUMP: {{[0-9,a-f]+}}:     R_SPARC_TLS_LDO_ADD Local
! ASM: add %o0, %i0, %o0, %tldo_add(Local) ! encoding: [0x90,0x02,0x00,0x18]
! ASM:                                    !   fixup A - offset: 0, value: %tldo_add(Local), kind: fixup_sparc_tls_ldo_add
        add %o0, %i0, %o0, %tldo_add(Local)

! Next two sequences are for extern symbols.
! Initial Executable model:
!     IE_HI22/IE_LO10/IE_LD (or IE_LDX)/IE_ADD

! OBJDUMP: {{[0-9,a-f]+}}:  33 00 00 00  sethi 0, %i1
! OBJDUMP: {{[0-9,a-f]+}}:     R_SPARC_TLS_IE_HI22 Extern
! ASM: sethi %tie_hi22(Extern), %i1 ! encoding: [0x33,0b00AAAAAA,A,A]
! ASM:                                    !   fixup A - offset: 0, value: %tie_hi22(Extern), kind: fixup_sparc_tls_ie_hi22
	sethi %tie_hi22(Extern), %i1

! OBJDUMP: {{[0-9,a-f]+}}:  b2 06 60 00  add %i1, 0, %i1
! OBJDUMP: {{[0-9,a-f]+}}:     R_SPARC_TLS_IE_LO10 Extern
! ASM: add %i1, %tie_lo10(Extern), %i1 ! encoding: [0xb2,0x06,0b011000AA,A]
! ASM:                                    !   fixup A - offset: 0, value: %tie_lo10(Extern), kind: fixup_sparc_tls_ie_lo10
        add %i1, %tie_lo10(Extern), %i1

! OBJDUMP: {{[0-9,a-f]+}}:  f0 06 00 19  ld [%i0+%i1], %i0
! OBJDUMP: {{[0-9,a-f]+}}:     R_SPARC_TLS_IE_LD Extern
! ASM: ld [%i0+%i1], %i0, %tie_ld(Extern) ! encoding: [0xf0,0x06,0x00,0x19]
! ASM:                                    !   fixup A - offset: 0, value: %tie_ld(Extern), kind: fixup_sparc_tls_ie_ld
        ld [%i0+%i1], %i0, %tie_ld(Extern)

! OBJDUMP: {{[0-9,a-f]+}}:  f0 5e 00 19  ldx [%i0+%i1], %i0
! OBJDUMP: {{[0-9,a-f]+}}:     R_SPARC_TLS_IE_LDX Extern
! ASM: ldx [%i0+%i1], %i0, %tie_ldx(Extern) ! encoding: [0xf0,0x5e,0x00,0x19]
! ASM:                                      !   fixup A - offset: 0, value: %tie_ldx(Extern), kind: fixup_sparc_tls_ie_ldx
        ldx [%i0+%i1], %i0, %tie_ldx(Extern)

! OBJDUMP: {{[0-9,a-f]+}}:  90 01 c0 18  add %g7, %i0, %o0
! OBJDUMP: {{[0-9,a-f]+}}:     R_SPARC_TLS_IE_ADD Extern
! ASM: add %g7, %i0, %o0, %tie_add(Extern) ! encoding: [0x90,0x01,0xc0,0x18]
! ASM:                                    !   fixup A - offset: 0, value: %tie_add(Extern), kind: fixup_sparc_tls_ie_add
        add %g7, %i0, %o0, %tie_add(Extern)

! General Dynamic model
!     GD_HI22/GD_LO10/GD_ADD/GD_CALL

! OBJDUMP: {{[0-9,a-f]+}}:  33 00 00 00  sethi 0, %i1
! OBJDUMP: {{[0-9,a-f]+}}:     R_SPARC_TLS_GD_HI22 Extern
! ASM:  sethi %tgd_hi22(Extern), %i1    ! encoding: [0x33,0b00AAAAAA,A,A]
! ASM:                                    !   fixup A - offset: 0, value: %tgd_hi22(Extern), kind: fixup_sparc_tls_gd_hi22
        sethi %tgd_hi22(Extern), %i1

! OBJDUMP: {{[0-9,a-f]+}}:  b2 06 60 00  add %i1, 0, %i1
! OBJDUMP: {{[0-9,a-f]+}}:     R_SPARC_TLS_GD_LO10 Extern
! ASM: add %i1, %tgd_lo10(Extern), %i1 ! encoding: [0xb2,0x06,0b011000AA,A]
! ASM:                                 !   fixup A - offset: 0, value: %tgd_lo10(Extern), kind: fixup_sparc_tls_gd_lo10
        add %i1, %tgd_lo10(Extern), %i1

! OBJDUMP: {{[0-9,a-f]+}}:  90 06 00 19  add %i0, %i1, %o0
! OBJDUMP: {{[0-9,a-f]+}}:     R_SPARC_TLS_GD_ADD Extern
! ASM: add %i0, %i1, %o0, %tgd_add(Extern) ! encoding: [0x90,0x06,0x00,0x19]
! ASM:                                    !   fixup A - offset: 0, value: %tgd_add(Extern), kind: fixup_sparc_tls_gd_add
        add %i0, %i1, %o0, %tgd_add(Extern)

! OBJDUMP: {{[0-9,a-f]+}}:  40 00 00 00 call 0
! OBJDUMP: {{[0-9,a-f]+}}:     R_SPARC_TLS_GD_CALL Extern
! ASM: call __tls_get_addr, %tgd_call(Extern) ! encoding: [0x40,0x00,0x00,0x00]
! ASM:                                        !   fixup A - offset: 0, value: %tgd_call(Extern), kind: fixup_sparc_tls_gd_call
        call __tls_get_addr, %tgd_call(Extern)

        .type  Local,@object
        .section      .tbss,#alloc,#write,#tls
Local:
        .word  0
        .size  Local, 4