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 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410
|
// z_AIX_asm.S: - microtasking routines specifically
// written for Power platforms running AIX OS
//
////===----------------------------------------------------------------------===//
////
//// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
//// See https://llvm.org/LICENSE.txt for license information.
//// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
////
////===----------------------------------------------------------------------===//
//
// -----------------------------------------------------------------------
// macros
// -----------------------------------------------------------------------
#include "kmp_config.h"
#if KMP_OS_AIX
//------------------------------------------------------------------------
// int
// __kmp_invoke_microtask( void (*pkfn) (int *gtid, int *tid, ...),
// int gtid, int tid,
// int argc, void *p_argv[]
// #if OMPT_SUPPORT
// ,
// void **exit_frame_ptr
// #endif
// ) {
// #if OMPT_SUPPORT
// *exit_frame_ptr = OMPT_GET_FRAME_ADDRESS(0);
// #endif
//
// (*pkfn)( & gtid, & tid, p_argv[0], ... );
//
// // FIXME: This is done at call-site and can be removed here.
// #if OMPT_SUPPORT
// *exit_frame_ptr = 0;
// #endif
//
// return 1;
// }
//
// parameters:
// r3: pkfn
// r4: gtid
// r5: tid
// r6: argc
// r7: p_argv
// r8: &exit_frame
//
// return: r3 (always 1/TRUE)
//
#if KMP_ARCH_PPC64_XCOFF
.globl __kmp_invoke_microtask[DS]
.globl .__kmp_invoke_microtask
.align 4
.csect __kmp_invoke_microtask[DS],3
.vbyte 8, .__kmp_invoke_microtask
.vbyte 8, TOC[TC0]
.vbyte 8, 0
.csect .text[PR],2
.machine "pwr7"
.__kmp_invoke_microtask:
// -- Begin __kmp_invoke_microtask
// mark_begin;
// We need to allocate a stack frame large enough to hold all of the parameters
// on the stack for the microtask plus what this function needs. That's 48
// bytes under the XCOFF64 ABI, plus max(64, 8*(2 + argc)) for
// the parameters to the microtask (gtid, tid, argc elements of p_argv),
// plus 8 bytes to store the values of r4 and r5, and 8 bytes to store r31.
// With OMP-T support, we need an additional 8 bytes to save r30 to hold
// a copy of r8.
// Stack offsets relative to stack pointer:
// r31: -8, r30: -16, gtid: -20, tid: -24
mflr 0
std 31, -8(1) # Save r31 to the stack
std 0, 16(1) # Save LR to the linkage area
// This is unusual because normally we'd set r31 equal to r1 after the stack
// frame is established. In this case, however, we need to dynamically compute
// the stack frame size, and so we keep a direct copy of r1 to access our
// register save areas and restore the r1 value before returning.
mr 31, 1
// Compute the size of the "argc" portion of the parameter save area.
// The parameter save area is always at least 64 bytes long (i.e. 8 regs)
// The microtask has (2 + argc) parameters, so if argc <= 6, we need to
// to allocate 8*6 bytes, not 8*argc.
li 0, 6
cmpwi 0, 6, 6
iselgt 0, 6, 0 # r0 = (argc > 6)? argc : 6
sldi 0, 0, 3 # r0 = 8 * max(argc, 6)
// Compute the size necessary for the local stack frame.
// 88 = 48 + 4 (for r4) + 4 (for r5) + 8 (for r31) + 8 (for OMP-T r30) +
// 8 (parameter gtid) + 8 (parameter tid)
li 12, 88
add 12, 0, 12
neg 12, 12
// We need to make sure that the stack frame stays aligned (to 16 bytes).
li 0, -16
and 12, 0, 12
// Establish the local stack frame.
stdux 1, 1, 12
#if OMPT_SUPPORT
std 30, -16(31) # Save r30 to the stack
std 1, 0(8)
mr 30, 8
#endif
// Store gtid and tid to the stack because they're passed by reference to the microtask.
stw 4, -20(31) # Save gtid to the stack
stw 5, -24(31) # Save tid to the stack
mr 12, 6 # r12 = argc
mr 4, 7 # r4 = p_argv
cmpwi 0, 12, 1
blt 0, .Lcall # if (argc < 1) goto .Lcall
ld 5, 0(4) # r5 = p_argv[0]
cmpwi 0, 12, 2
blt 0, .Lcall # if (argc < 2) goto .Lcall
ld 6, 8(4) # r6 = p_argv[1]
cmpwi 0, 12, 3
blt 0, .Lcall # if (argc < 3) goto .Lcall
ld 7, 16(4) # r7 = p_argv[2]
cmpwi 0, 12, 4
blt 0, .Lcall # if (argc < 4) goto .Lcall
ld 8, 24(4) # r8 = p_argv[3]
cmpwi 0, 12, 5
blt 0, .Lcall # if (argc < 5) goto .Lcall
ld 9, 32(4) # r9 = p_argv[4]
cmpwi 0, 12, 6
blt 0, .Lcall # if (argc < 6) goto .Lcall
ld 10, 40(4) # r10 = p_argv[5]
cmpwi 0, 12, 7
blt 0, .Lcall # if (argc < 7) goto .Lcall
// There are more than 6 microtask parameters, so we need to store the
// remainder to the stack.
addi 12, 12, -6 # argc -= 6
mtctr 12
// These are set to 8 bytes before the first desired store address (we're using
// pre-increment loads and stores in the loop below). The parameter save area
// for the microtask begins 48 + 8*8 == 112 bytes above r1 for XCOFF64.
addi 4, 4, 40 # p_argv = p_argv + 5
# (i.e. skip the 5 elements we already processed)
addi 12, 1, 104 # r12 = stack offset (112 - 8)
.Lnext:
ldu 0, 8(4)
stdu 0, 8(12)
bdnz .Lnext
.Lcall:
std 2, 40(1) # Save the TOC pointer to the linkage area
// Load the actual function address from the function descriptor.
ld 12, 0(3) # Function address
ld 2, 8(3) # TOC pointer
ld 11, 16(3) # Environment pointer
addi 3, 31, -20 # r3 = >id
addi 4, 31, -24 # r4 = &tid
mtctr 12 # CTR = function address
bctrl # Branch to CTR
ld 2, 40(1) # Restore TOC pointer from linkage area
#if OMPT_SUPPORT
li 3, 0
std 3, 0(30)
#endif
li 3, 1
#if OMPT_SUPPORT
ld 30, -16(31) # Restore r30 from the saved value on the stack
#endif
mr 1, 31
ld 31, -8(1) # Restore r31 from the saved value on the stack
ld 0, 16(1)
mtlr 0 # Restore LR from the linkage area
blr # Branch to LR
#else // KMP_ARCH_PPC_XCOFF
.globl __kmp_invoke_microtask[DS]
.globl .__kmp_invoke_microtask
.align 4
.csect __kmp_invoke_microtask[DS],2
.vbyte 4, .__kmp_invoke_microtask
.vbyte 4, TOC[TC0]
.vbyte 4, 0
.csect .text[PR],2
.machine "pwr7"
.__kmp_invoke_microtask:
// -- Begin __kmp_invoke_microtask
// mark_begin;
// We need to allocate a stack frame large enough to hold all of the parameters
// on the stack for the microtask plus what this function needs. That's 24
// bytes under the XCOFF ABI, plus max(32, 8*(2 + argc)) for
// the parameters to the microtask (gtid, tid, argc elements of p_argv),
// plus 8 bytes to store the values of r4 and r5, and 4 bytes to store r31.
// With OMP-T support, we need an additional 4 bytes to save r30 to hold
// a copy of r8.
// Stack offsets relative to stack pointer:
// r31: -4, r30: -8, gtid: -12, tid: -16
mflr 0
stw 31, -4(1) # Save r31 to the stack
stw 0, 8(1) # Save LR to the linkage area
// This is unusual because normally we'd set r31 equal to r1 after the stack
// frame is established. In this case, however, we need to dynamically compute
// the stack frame size, and so we keep a direct copy of r1 to access our
// register save areas and restore the r1 value before returning.
mr 31, 1
// Compute the size of the "argc" portion of the parameter save area.
// The parameter save area is always at least 32 bytes long (i.e. 8 regs)
// The microtask has (2 + argc) parameters, so if argc <= 6, we need to
// to allocate 4*6 bytes, not 4*argc.
li 0, 6
cmpwi 0, 6, 6
iselgt 0, 6, 0 # r0 = (argc > 6)? argc : 6
slwi 0, 0, 2 # r0 = 4 * max(argc, 6)
// Compute the size necessary for the local stack frame.
// 56 = 32 + 4 (for r4) + 4 (for r5) + 4 (for r31) + 4 (for OMP-T r30) +
// 4 (parameter gtid) + 4 (parameter tid)
li 12, 56
add 12, 0, 12
neg 12, 12
// We need to make sure that the stack frame stays aligned (to 16 bytes).
li 0, -16
and 12, 0, 12
// Establish the local stack frame.
stwux 1, 1, 12
#if OMPT_SUPPORT
stw 30, -8(31) # Save r30 to the stack
stw 1, 0(8)
mr 30, 8
#endif
// Store gtid and tid to the stack because they're passed by reference to the microtask.
stw 4, -12(31) # Save gtid to the stack
stw 5, -16(31) # Save tid to the stack
mr 12, 6 # r12 = argc
mr 4, 7 # r4 = p_argv
cmpwi 0, 12, 1
blt 0, .Lcall # if (argc < 1) goto .Lcall
lwz 5, 0(4) # r5 = p_argv[0]
cmpwi 0, 12, 2
blt 0, .Lcall # if (argc < 2) goto .Lcall
lwz 6, 4(4) # r6 = p_argv[1]
cmpwi 0, 12, 3
blt 0, .Lcall # if (argc < 3) goto .Lcall
lwz 7, 8(4) # r7 = p_argv[2]
cmpwi 0, 12, 4
blt 0, .Lcall # if (argc < 4) goto .Lcall
lwz 8, 12(4) # r8 = p_argv[3]
cmpwi 0, 12, 5
blt 0, .Lcall # if (argc < 5) goto .Lcall
lwz 9, 16(4) # r9 = p_argv[4]
cmpwi 0, 12, 6
blt 0, .Lcall # if (argc < 6) goto .Lcall
lwz 10, 20(4) # r10 = p_argv[5]
cmpwi 0, 12, 7
blt 0, .Lcall # if (argc < 7) goto .Lcall
// There are more than 6 microtask parameters, so we need to store the
// remainder to the stack.
addi 12, 12, -6 # argc -= 6
mtctr 12
// These are set to 4 bytes before the first desired store address (we're using
// pre-increment loads and stores in the loop below). The parameter save area
// for the microtask begins 24 + 4*8 == 56 bytes above r1 for XCOFF.
addi 4, 4, 20 # p_argv = p_argv + 5
# (i.e. skip the 5 elements we already processed)
addi 12, 1, 52 # r12 = stack offset (56 - 4)
.Lnext:
lwzu 0, 4(4)
stwu 0, 4(12)
bdnz .Lnext
.Lcall:
stw 2, 20(1) # Save the TOC pointer to the linkage area
// Load the actual function address from the function descriptor.
lwz 12, 0(3) # Function address
lwz 2, 4(3) # TOC pointer
lwz 11, 8(3) # Environment pointer
addi 3, 31, -12 # r3 = >id
addi 4, 31, -16 # r4 = &tid
mtctr 12 # CTR = function address
bctrl # Branch to CTR
lwz 2, 20(1) # Restore TOC pointer from linkage area
#if OMPT_SUPPORT
li 3, 0
stw 3, 0(30)
#endif
li 3, 1
#if OMPT_SUPPORT
lwz 30, -8(31) # Restore r30 from the saved value on the stack
#endif
mr 1, 31
lwz 31, -4(1) # Restore r31 from the saved value on the stack
lwz 0, 8(1)
mtlr 0 # Restore LR from the linkage area
blr # Branch to LR
#endif // KMP_ARCH_PPC64_XCOFF
.Lfunc_end0:
.vbyte 4, 0x00000000 # Traceback table begin
.byte 0x00 # Version = 0
.byte 0x09 # Language = CPlusPlus
.byte 0x20 # -IsGlobaLinkage, -IsOutOfLineEpilogOrPrologue
# +HasTraceBackTableOffset, -IsInternalProcedure
# -HasControlledStorage, -IsTOCless
# -IsFloatingPointPresent
# -IsFloatingPointOperationLogOrAbortEnabled
.byte 0x61 # -IsInterruptHandler, +IsFunctionNamePresent, +IsAllocaUsed
# OnConditionDirective = 0, -IsCRSaved, +IsLRSaved
.byte 0x80 # +IsBackChainStored, -IsFixup, NumOfFPRsSaved = 0
#if OMPT_SUPPORT
.byte 0x02 # -HasExtensionTable, -HasVectorInfo, NumOfGPRsSaved = 2
.byte 0x06 # NumberOfFixedParms = 6
#else
.byte 0x01 # -HasExtensionTable, -HasVectorInfo, NumOfGPRsSaved = 1
.byte 0x05 # NumberOfFixedParms = 5
#endif
.byte 0x01 # NumberOfFPParms = 0, +HasParmsOnStack
.vbyte 4, 0x00000000 # Parameter type = i, i, i, i, i
.vbyte 4, .Lfunc_end0-.__kmp_invoke_microtask # Function size
.vbyte 2, 0x0016 # Function name len = 22
.byte "__kmp_invoke_microtask" # Function Name
.byte 0x1f # AllocaRegister = 31
# -- End function
// -- End __kmp_invoke_microtask
// Support for unnamed common blocks.
.comm .gomp_critical_user_, 32, 3
#if KMP_ARCH_PPC64_XCOFF
.csect __kmp_unnamed_critical_addr[RW],3
#else
.csect __kmp_unnamed_critical_addr[RW],2
#endif
.globl __kmp_unnamed_critical_addr[RW]
.ptr .gomp_critical_user_
// -- End unnamed common block
.toc
#endif // KMP_OS_AIX
|