1; FIXME: even under non-pic mode, llvm needs to generate pic code since nld 2; doesn't work with non-pic code. Thefore, we test pic codes for 3; both cases here. 4; llc -mtriple ve < %s | FileCheck %s -check-prefix=LOCAL 5; RUN: llc -mtriple ve < %s | FileCheck %s -check-prefix=GENDYN 6; RUN: llc -mtriple ve -relocation-model=pic < %s | FileCheck %s -check-prefix=GENDYNPIC 7 8@x = external thread_local global i32, align 4 9@y = internal thread_local global i32 0, align 4 10 11; Function Attrs: norecurse nounwind readnone 12define nonnull i32* @get_global() { 13; GENDYN-LABEL: get_global: 14; GENDYN: .LBB{{[0-9]+}}_2: 15; GENDYN-NEXT: lea %s0, x@tls_gd_lo(-24) 16; GENDYN-NEXT: and %s0, %s0, (32)0 17; GENDYN-NEXT: sic %s10 18; GENDYN-NEXT: lea.sl %s0, x@tls_gd_hi(%s10, %s0) 19; GENDYN-NEXT: lea %s12, __tls_get_addr@plt_lo(8) 20; GENDYN-NEXT: and %s12, %s12, (32)0 21; GENDYN-NEXT: lea.sl %s12, __tls_get_addr@plt_hi(%s10, %s12) 22; GENDYN-NEXT: bsic %s10, (, %s12) 23; GENDYN-NEXT: or %s11, 0, %s9 24; 25; GENDYNPIC-LABEL: get_global: 26; GENDYNPIC: .LBB{{[0-9]+}}_2: 27; GENDYNPIC-NEXT: lea %s15, _GLOBAL_OFFSET_TABLE_@pc_lo(-24) 28; GENDYNPIC-NEXT: and %s15, %s15, (32)0 29; GENDYNPIC-NEXT: sic %s16 30; GENDYNPIC-NEXT: lea.sl %s15, _GLOBAL_OFFSET_TABLE_@pc_hi(%s16, %s15) 31; GENDYNPIC-NEXT: lea %s0, x@tls_gd_lo(-24) 32; GENDYNPIC-NEXT: and %s0, %s0, (32)0 33; GENDYNPIC-NEXT: sic %s10 34; GENDYNPIC-NEXT: lea.sl %s0, x@tls_gd_hi(%s10, %s0) 35; GENDYNPIC-NEXT: lea %s12, __tls_get_addr@plt_lo(8) 36; GENDYNPIC-NEXT: and %s12, %s12, (32)0 37; GENDYNPIC-NEXT: lea.sl %s12, __tls_get_addr@plt_hi(%s10, %s12) 38; GENDYNPIC-NEXT: bsic %s10, (, %s12) 39; GENDYNPIC-NEXT: or %s11, 0, %s9 40; 41; LOCAL-LABEL: get_global: 42; LOCAL: .LBB{{[0-9]+}}_2: 43; LOCAL-NEXT: lea %s34, x@tpoff_lo 44; LOCAL-NEXT: and %s34, %s34, (32)0 45; LOCAL-NEXT: lea.sl %s34, x@tpoff_hi(%s34) 46; LOCAL-NEXT: adds.l %s0, %s14, %s34 47; LOCAL-NEXT: or %s11, 0, %s9 48entry: 49 ret i32* @x 50} 51 52; Function Attrs: norecurse nounwind readnone 53define nonnull i32* @get_local() { 54; GENDYN-LABEL: get_local: 55; GENDYN: .LBB{{[0-9]+}}_2: 56; GENDYN-NEXT: lea %s0, y@tls_gd_lo(-24) 57; GENDYN-NEXT: and %s0, %s0, (32)0 58; GENDYN-NEXT: sic %s10 59; GENDYN-NEXT: lea.sl %s0, y@tls_gd_hi(%s10, %s0) 60; GENDYN-NEXT: lea %s12, __tls_get_addr@plt_lo(8) 61; GENDYN-NEXT: and %s12, %s12, (32)0 62; GENDYN-NEXT: lea.sl %s12, __tls_get_addr@plt_hi(%s10, %s12) 63; GENDYN-NEXT: bsic %s10, (, %s12) 64; GENDYN-NEXT: or %s11, 0, %s9 65; 66; GENDYNPIC-LABEL: get_local: 67; GENDYNPIC: .LBB{{[0-9]+}}_2: 68; GENDYNPIC-NEXT: lea %s15, _GLOBAL_OFFSET_TABLE_@pc_lo(-24) 69; GENDYNPIC-NEXT: and %s15, %s15, (32)0 70; GENDYNPIC-NEXT: sic %s16 71; GENDYNPIC-NEXT: lea.sl %s15, _GLOBAL_OFFSET_TABLE_@pc_hi(%s16, %s15) 72; GENDYNPIC-NEXT: lea %s0, y@tls_gd_lo(-24) 73; GENDYNPIC-NEXT: and %s0, %s0, (32)0 74; GENDYNPIC-NEXT: sic %s10 75; GENDYNPIC-NEXT: lea.sl %s0, y@tls_gd_hi(%s10, %s0) 76; GENDYNPIC-NEXT: lea %s12, __tls_get_addr@plt_lo(8) 77; GENDYNPIC-NEXT: and %s12, %s12, (32)0 78; GENDYNPIC-NEXT: lea.sl %s12, __tls_get_addr@plt_hi(%s10, %s12) 79; GENDYNPIC-NEXT: bsic %s10, (, %s12) 80; GENDYNPIC-NEXT: or %s11, 0, %s9 81; 82; LOCAL-LABEL: get_local: 83; LOCAL: .LBB{{[0-9]+}}_2: 84; LOCAL-NEXT: lea %s34, y@tpoff_lo 85; LOCAL-NEXT: and %s34, %s34, (32)0 86; LOCAL-NEXT: lea.sl %s34, y@tpoff_hi(%s34) 87; LOCAL-NEXT: adds.l %s0, %s14, %s34 88; LOCAL-NEXT: or %s11, 0, %s9 89entry: 90 ret i32* @y 91} 92 93; Function Attrs: norecurse nounwind 94define void @set_global(i32 %v) { 95; GENDYN-LABEL: set_global: 96; GENDYN: .LBB{{[0-9]+}}_2: 97; GENDYN-NEXT: st %s18, 288(, %s11) # 8-byte Folded Spill 98; GENDYN-NEXT: or %s18, 0, %s0 99; GENDYN-NEXT: lea %s0, x@tls_gd_lo(-24) 100; GENDYN-NEXT: and %s0, %s0, (32)0 101; GENDYN-NEXT: sic %s10 102; GENDYN-NEXT: lea.sl %s0, x@tls_gd_hi(%s10, %s0) 103; GENDYN-NEXT: lea %s12, __tls_get_addr@plt_lo(8) 104; GENDYN-NEXT: and %s12, %s12, (32)0 105; GENDYN-NEXT: lea.sl %s12, __tls_get_addr@plt_hi(%s10, %s12) 106; GENDYN-NEXT: bsic %s10, (, %s12) 107; GENDYN-NEXT: stl %s18, (, %s0) 108; GENDYN-NEXT: ld %s18, 288(, %s11) # 8-byte Folded Reload 109; GENDYN-NEXT: or %s11, 0, %s9 110; 111; GENDYNPIC-LABEL: set_global: 112; GENDYNPIC: .LBB{{[0-9]+}}_2: 113; GENDYNPIC-NEXT: st %s18, 288(, %s11) # 8-byte Folded Spill 114; GENDYNPIC-NEXT: or %s18, 0, %s0 115; GENDYNPIC-NEXT: lea %s15, _GLOBAL_OFFSET_TABLE_@pc_lo(-24) 116; GENDYNPIC-NEXT: and %s15, %s15, (32)0 117; GENDYNPIC-NEXT: sic %s16 118; GENDYNPIC-NEXT: lea.sl %s15, _GLOBAL_OFFSET_TABLE_@pc_hi(%s16, %s15) 119; GENDYNPIC-NEXT: lea %s0, x@tls_gd_lo(-24) 120; GENDYNPIC-NEXT: and %s0, %s0, (32)0 121; GENDYNPIC-NEXT: sic %s10 122; GENDYNPIC-NEXT: lea.sl %s0, x@tls_gd_hi(%s10, %s0) 123; GENDYNPIC-NEXT: lea %s12, __tls_get_addr@plt_lo(8) 124; GENDYNPIC-NEXT: and %s12, %s12, (32)0 125; GENDYNPIC-NEXT: lea.sl %s12, __tls_get_addr@plt_hi(%s10, %s12) 126; GENDYNPIC-NEXT: bsic %s10, (, %s12) 127; GENDYNPIC-NEXT: stl %s18, (, %s0) 128; GENDYNPIC-NEXT: ld %s18, 288(, %s11) # 8-byte Folded Reload 129; GENDYNPIC-NEXT: or %s11, 0, %s9 130; 131; LOCAL-LABEL: set_global: 132; LOCAL: .LBB{{[0-9]+}}_2: 133; LOCAL-NEXT: lea %s34, x@tpoff_lo 134; LOCAL-NEXT: and %s34, %s34, (32)0 135; LOCAL-NEXT: lea.sl %s34, x@tpoff_hi(%s34) 136; LOCAL-NEXT: adds.l %s34, %s14, %s34 137; LOCAL-NEXT: stl %s0, (, %s34) 138; LOCAL-NEXT: or %s11, 0, %s9 139entry: 140 store i32 %v, i32* @x, align 4 141 ret void 142} 143 144; Function Attrs: norecurse nounwind 145define void @set_local(i32 %v) { 146; GENDYN-LABEL: set_local: 147; GENDYN: .LBB{{[0-9]+}}_2: 148; GENDYN-NEXT: st %s18, 288(, %s11) # 8-byte Folded Spill 149; GENDYN-NEXT: or %s18, 0, %s0 150; GENDYN-NEXT: lea %s0, y@tls_gd_lo(-24) 151; GENDYN-NEXT: and %s0, %s0, (32)0 152; GENDYN-NEXT: sic %s10 153; GENDYN-NEXT: lea.sl %s0, y@tls_gd_hi(%s10, %s0) 154; GENDYN-NEXT: lea %s12, __tls_get_addr@plt_lo(8) 155; GENDYN-NEXT: and %s12, %s12, (32)0 156; GENDYN-NEXT: lea.sl %s12, __tls_get_addr@plt_hi(%s10, %s12) 157; GENDYN-NEXT: bsic %s10, (, %s12) 158; GENDYN-NEXT: stl %s18, (, %s0) 159; GENDYN-NEXT: ld %s18, 288(, %s11) # 8-byte Folded Reload 160; GENDYN-NEXT: or %s11, 0, %s9 161; 162; GENDYNPIC-LABEL: set_local: 163; GENDYNPIC: .LBB{{[0-9]+}}_2: 164; GENDYNPIC-NEXT: st %s18, 288(, %s11) # 8-byte Folded Spill 165; GENDYNPIC-NEXT: or %s18, 0, %s0 166; GENDYNPIC-NEXT: lea %s15, _GLOBAL_OFFSET_TABLE_@pc_lo(-24) 167; GENDYNPIC-NEXT: and %s15, %s15, (32)0 168; GENDYNPIC-NEXT: sic %s16 169; GENDYNPIC-NEXT: lea.sl %s15, _GLOBAL_OFFSET_TABLE_@pc_hi(%s16, %s15) 170; GENDYNPIC-NEXT: lea %s0, y@tls_gd_lo(-24) 171; GENDYNPIC-NEXT: and %s0, %s0, (32)0 172; GENDYNPIC-NEXT: sic %s10 173; GENDYNPIC-NEXT: lea.sl %s0, y@tls_gd_hi(%s10, %s0) 174; GENDYNPIC-NEXT: lea %s12, __tls_get_addr@plt_lo(8) 175; GENDYNPIC-NEXT: and %s12, %s12, (32)0 176; GENDYNPIC-NEXT: lea.sl %s12, __tls_get_addr@plt_hi(%s10, %s12) 177; GENDYNPIC-NEXT: bsic %s10, (, %s12) 178; GENDYNPIC-NEXT: stl %s18, (, %s0) 179; GENDYNPIC-NEXT: ld %s18, 288(, %s11) # 8-byte Folded Reload 180; GENDYNPIC-NEXT: or %s11, 0, %s9 181; 182; LOCAL-LABEL: set_local: 183; LOCAL: .LBB{{[0-9]+}}_2: 184; LOCAL-NEXT: lea %s34, y@tpoff_lo 185; LOCAL-NEXT: and %s34, %s34, (32)0 186; LOCAL-NEXT: lea.sl %s34, y@tpoff_hi(%s34) 187; LOCAL-NEXT: adds.l %s34, %s14, %s34 188; LOCAL-NEXT: stl %s0, (, %s34) 189; LOCAL-NEXT: or %s11, 0, %s9 190entry: 191 store i32 %v, i32* @y, align 4 192 ret void 193} 194