Changeset 102962 in vbox for trunk/include/iprt/asm.h
- Timestamp:
- Jan 18, 2024 10:36:04 PM (11 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/asm.h
r102961 r102962 5171 5171 5172 5172 # elif defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32) 5173 # if defined(RTASM_ARM64_USE_FEAT_LSE) 5174 # if defined(RTASM_ARM64_USE_FEAT_LSE_WITHOUT_DMB) 5175 uint32_t u32Spill; 5176 __asm__ __volatile__("Lstart_ASMAtomicOrU32_%=:\n\t" 5177 "ldsetal %w[fBitsToSet], %w[uSpill], %[pMem]\n\t" 5178 : [pMem] "+Q" (*pu32) 5179 , [uSpill] "=&r" (u32Spill) 5180 : [fBitsToSet] "r" (u32) 5181 : ); 5182 # else 5183 __asm__ __volatile__("Lstart_ASMAtomicOrU32_%=:\n\t" 5184 RTASM_ARM_DMB_SY 5185 "stset %w[fBitsToSet], %[pMem]\n\t" 5186 : [pMem] "+Q" (*pu32) 5187 : [fBitsToSet] "r" (u32) 5188 : ); 5189 # endif 5190 # else 5173 5191 /* For more on Orr see https://en.wikipedia.org/wiki/Orr_(Catch-22) ;-) */ 5174 5192 RTASM_ARM_LOAD_MODIFY_STORE_RET_NEW_32(ASMAtomicOr32, pu32, DMB_SY, … … 5177 5195 [uVal] "r" (u32)); 5178 5196 5197 # endif 5179 5198 # else 5180 5199 # error "Port me" … … 5195 5214 { 5196 5215 #if defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32) 5216 # if defined(RTASM_ARM64_USE_FEAT_LSE) 5217 uint32_t u32OldRet; 5218 __asm__ __volatile__("Lstart_ASMAtomicOrExU32_%=:\n\t" 5219 # if defined(RTASM_ARM64_USE_FEAT_LSE_WITHOUT_DMB) 5220 "ldsetal %w[fBitsToSet], %w[uOldRet], %[pMem]\n\t" 5221 # else 5222 RTASM_ARM_DMB_SY 5223 "ldset %w[fBitsToSet], %w[uOldRet], %[pMem]\n\t" 5224 # endif 5225 : [pMem] "+Q" (*pu32) 5226 , [uOldRet] "=&r" (u32OldRet) 5227 : [fBitsToSet] "r" (u32) 5228 : ); 5229 # else 5197 5230 RTASM_ARM_LOAD_MODIFY_STORE_RET_OLD_32(ASMAtomicOrEx32, pu32, DMB_SY, 5198 5231 "orr %w[uNew], %w[uOld], %w[uVal]\n\t", 5199 5232 "orr %[uNew], %[uOld], %[uVal]\n\t", 5200 5233 [uVal] "r" (u32)); 5234 # endif 5201 5235 return u32OldRet; 5202 5236 … … 5250 5284 5251 5285 # elif defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32) 5286 # if defined(RTASM_ARM64_USE_FEAT_LSE) 5287 # if defined(RTASM_ARM64_USE_FEAT_LSE_WITHOUT_DMB) 5288 uint64_t u64Spill; 5289 __asm__ __volatile__("Lstart_ASMAtomicOrU64_%=:\n\t" 5290 "ldsetal %[fBitsToSet], %[uSpill], %[pMem]\n\t" 5291 : [pMem] "+Q" (*pu64) 5292 , [uSpill] "=&r" (u64Spill) 5293 : [fBitsToSet] "r" (u64) 5294 : ); 5295 # else 5296 __asm__ __volatile__("Lstart_ASMAtomicOrU64_%=:\n\t" 5297 RTASM_ARM_DMB_SY 5298 "stset %[fBitsToSet], %[pMem]\n\t" 5299 : [pMem] "+Q" (*pu64) 5300 : [fBitsToSet] "r" (u64) 5301 : ); 5302 # endif 5303 # else 5252 5304 RTASM_ARM_LOAD_MODIFY_STORE_RET_NEW_64(ASMAtomicOrU64, pu64, DMB_SY, 5253 5305 "orr %[uNew], %[uNew], %[uVal]\n\t" … … 5256 5308 "orr %H[uNew], %H[uNew], %H[uVal]\n\t", 5257 5309 [uVal] "r" (u64)); 5310 # endif 5258 5311 5259 5312 # else … … 5323 5376 5324 5377 # elif defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32) 5378 # if defined(RTASM_ARM64_USE_FEAT_LSE) 5379 # if defined(RTASM_ARM64_USE_FEAT_LSE_WITHOUT_DMB) 5380 uint32_t u32Spill; 5381 __asm__ __volatile__("Lstart_ASMAtomicAndU32_%=:\n\t" 5382 "ldclral %w[fBitsToClear], %w[uSpill], %[pMem]\n\t" 5383 : [pMem] "+Q" (*pu32) 5384 , [uSpill] "=&r" (u32Spill) 5385 : [fBitsToClear] "r" (~u32) 5386 : ); 5387 # else 5388 __asm__ __volatile__("Lstart_ASMAtomicAndU32_%=:\n\t" 5389 RTASM_ARM_DMB_SY 5390 "stclr %w[fBitsToClear], %[pMem]\n\t" 5391 : [pMem] "+Q" (*pu32) 5392 : [fBitsToClear] "r" (~u32) 5393 : ); 5394 # endif 5395 # else 5325 5396 RTASM_ARM_LOAD_MODIFY_STORE_RET_NEW_32(ASMAtomicAnd32, pu32, DMB_SY, 5326 5397 "and %w[uNew], %w[uNew], %w[uVal]\n\t", … … 5328 5399 [uVal] "r" (u32)); 5329 5400 5401 # endif 5330 5402 # else 5331 5403 # error "Port me" … … 5345 5417 { 5346 5418 #if defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32) 5419 # if defined(RTASM_ARM64_USE_FEAT_LSE) 5420 uint32_t u32OldRet; 5421 __asm__ __volatile__("Lstart_ASMAtomicAndExU32_%=:\n\t" 5422 # if defined(RTASM_ARM64_USE_FEAT_LSE_WITHOUT_DMB) 5423 "ldclral %w[fBitsToClear], %w[uOldRet], %[pMem]\n\t" 5424 # else 5425 RTASM_ARM_DMB_SY 5426 "ldclr %w[fBitsToClear], %w[uOldRet], %[pMem]\n\t" 5427 # endif 5428 : [pMem] "+Q" (*pu32) 5429 , [uOldRet] "=&r" (u32OldRet) 5430 : [fBitsToClear] "r" (~u32) 5431 : ); 5432 # else 5347 5433 RTASM_ARM_LOAD_MODIFY_STORE_RET_OLD_32(ASMAtomicAndEx32, pu32, DMB_SY, 5348 5434 "and %w[uNew], %w[uOld], %w[uVal]\n\t", 5349 5435 "and %[uNew], %[uOld], %[uVal]\n\t", 5350 5436 [uVal] "r" (u32)); 5437 # endif 5351 5438 return u32OldRet; 5352 5439 … … 5400 5487 5401 5488 # elif defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32) 5489 # if defined(RTASM_ARM64_USE_FEAT_LSE) 5490 # if defined(RTASM_ARM64_USE_FEAT_LSE_WITHOUT_DMB) 5491 uint64_t u64Spill; 5492 __asm__ __volatile__("Lstart_ASMAtomicAndU64_%=:\n\t" 5493 "ldclral %[fBitsToClear], %[uSpill], %[pMem]\n\t" 5494 : [pMem] "+Q" (*pu64) 5495 , [uSpill] "=&r" (u64Spill) 5496 : [fBitsToClear] "r" (~u64) 5497 : ); 5498 # else 5499 __asm__ __volatile__("Lstart_ASMAtomicAndU64_%=:\n\t" 5500 RTASM_ARM_DMB_SY 5501 "stclr %[fBitsToClear], %[pMem]\n\t" 5502 : [pMem] "+Q" (*pu64) 5503 : [fBitsToClear] "r" (~u64) 5504 : ); 5505 # endif 5506 # else 5402 5507 RTASM_ARM_LOAD_MODIFY_STORE_RET_NEW_64(ASMAtomicAndU64, pu64, DMB_SY, 5403 5508 "and %[uNew], %[uNew], %[uVal]\n\t" … … 5406 5511 "and %H[uNew], %H[uNew], %H[uVal]\n\t", 5407 5512 [uVal] "r" (u64)); 5513 # endif 5408 5514 5409 5515 # else … … 5473 5579 5474 5580 # elif defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32) 5581 # if defined(RTASM_ARM64_USE_FEAT_LSE) 5582 # if defined(RTASM_ARM64_USE_FEAT_LSE_WITHOUT_DMB) 5583 uint32_t u32Spill; 5584 __asm__ __volatile__("Lstart_ASMAtomicXorU32_%=:\n\t" 5585 "ldeoral %w[fBitMask], %w[uSpill], %[pMem]\n\t" 5586 : [pMem] "+Q" (*pu32) 5587 , [uSpill] "=&r" (u32Spill) 5588 : [fBitMask] "r" (u32) 5589 : ); 5590 # else 5591 __asm__ __volatile__("Lstart_ASMAtomicXorU32_%=:\n\t" 5592 RTASM_ARM_DMB_SY 5593 "steor %w[fBitMask], %[pMem]\n\t" 5594 : [pMem] "+Q" (*pu32) 5595 : [fBitMask] "r" (u32) 5596 : ); 5597 # endif 5598 # else 5475 5599 RTASM_ARM_LOAD_MODIFY_STORE_RET_NEW_32(ASMAtomicXor32, pu32, DMB_SY, 5476 5600 "eor %w[uNew], %w[uNew], %w[uVal]\n\t", 5477 5601 "eor %[uNew], %[uNew], %[uVal]\n\t", 5478 5602 [uVal] "r" (u32)); 5603 # endif 5479 5604 5480 5605 # else … … 5496 5621 { 5497 5622 #if defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32) 5623 # if defined(RTASM_ARM64_USE_FEAT_LSE) 5624 uint32_t u32OldRet; 5625 __asm__ __volatile__("Lstart_ASMAtomicXorExU32_%=:\n\t" 5626 # if defined(RTASM_ARM64_USE_FEAT_LSE_WITHOUT_DMB) 5627 "ldeoral %w[fBitMask], %w[uOldRet], %[pMem]\n\t" 5628 # else 5629 RTASM_ARM_DMB_SY 5630 "ldeor %w[fBitMask], %w[uOldRet], %[pMem]\n\t" 5631 # endif 5632 : [pMem] "+Q" (*pu32) 5633 , [uOldRet] "=&r" (u32OldRet) 5634 : [fBitMask] "r" (u32) 5635 : ); 5636 # else 5498 5637 RTASM_ARM_LOAD_MODIFY_STORE_RET_OLD_32(ASMAtomicXorEx32, pu32, DMB_SY, 5499 5638 "eor %w[uNew], %w[uOld], %w[uVal]\n\t", 5500 5639 "eor %[uNew], %[uOld], %[uVal]\n\t", 5501 5640 [uVal] "r" (u32)); 5641 # endif 5502 5642 return u32OldRet; 5503 5643 … … 5562 5702 5563 5703 # elif defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32) 5704 /* M1 benchmark: stset=1974 vs non-lse=6271 */ 5705 # if defined(RTASM_ARM64_USE_FEAT_LSE) 5706 __asm__ __volatile__("Lstart_ASMAtomicUoOrU32_%=:\n\t" 5707 "stset %w[fBitsToSet], %[pMem]\n\t" 5708 : [pMem] "+Q" (*pu32) 5709 : [fBitsToSet] "r" (u32) 5710 : ); 5711 # else 5564 5712 RTASM_ARM_LOAD_MODIFY_STORE_RET_NEW_32(ASMAtomicUoOrU32, pu32, NO_BARRIER, 5565 5713 "orr %w[uNew], %w[uNew], %w[uVal]\n\t", 5566 5714 "orr %[uNew], %[uNew], %[uVal]\n\t", 5567 5715 [uVal] "r" (u32)); 5716 # endif 5568 5717 5569 5718 # else … … 5585 5734 { 5586 5735 #if defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32) 5736 # if defined(RTASM_ARM64_USE_FEAT_LSE) 5737 uint32_t u32OldRet; 5738 __asm__ __volatile__("Lstart_ASMAtomicOrExU32_%=:\n\t" 5739 "ldset %w[fBitsToSet], %w[uOldRet], %[pMem]\n\t" 5740 : [pMem] "+Q" (*pu32) 5741 , [uOldRet] "=&r" (u32OldRet) 5742 : [fBitsToSet] "r" (u32) 5743 : ); 5744 # else 5587 5745 RTASM_ARM_LOAD_MODIFY_STORE_RET_OLD_32(ASMAtomicUoOrExU32, pu32, NO_BARRIER, 5588 5746 "orr %w[uNew], %w[uOld], %w[uVal]\n\t", 5589 5747 "orr %[uNew], %[uOld], %[uVal]\n\t", 5590 5748 [uVal] "r" (u32)); 5749 # endif 5591 5750 return u32OldRet; 5592 5751 … … 5632 5791 5633 5792 # elif defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32) 5793 # if defined(RTASM_ARM64_USE_FEAT_LSE) 5794 __asm__ __volatile__("Lstart_ASMAtomicUoOrU64_%=:\n\t" 5795 "stset %[fBitsToSet], %[pMem]\n\t" 5796 : [pMem] "+Q" (*pu64) 5797 : [fBitsToSet] "r" (u64) 5798 : ); 5799 # else 5634 5800 RTASM_ARM_LOAD_MODIFY_STORE_RET_NEW_64(ASMAtomicUoOrU64, pu64, NO_BARRIER, 5635 5801 "orr %[uNew], %[uNew], %[uVal]\n\t" … … 5638 5804 "orr %H[uNew], %H[uNew], %H[uVal]\n\t", 5639 5805 [uVal] "r" (u64)); 5806 # endif 5640 5807 5641 5808 # else … … 5702 5869 5703 5870 # elif defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32) 5871 /* M1 benchmark: stclr=1884 vs non-lse=6299 (ps/call) */ 5872 # if defined(RTASM_ARM64_USE_FEAT_LSE) 5873 __asm__ __volatile__("Lstart_ASMAtomicUoAndU32_%=:\n\t" 5874 "stclr %w[fBitsToClear], %[pMem]\n\t" 5875 : [pMem] "+Q" (*pu32) 5876 : [fBitsToClear] "r" (~u32) 5877 : ); 5878 # else 5704 5879 RTASM_ARM_LOAD_MODIFY_STORE_RET_NEW_32(ASMAtomicUoAnd32, pu32, NO_BARRIER, 5705 5880 "and %w[uNew], %w[uNew], %w[uVal]\n\t", 5706 5881 "and %[uNew], %[uNew], %[uVal]\n\t", 5707 5882 [uVal] "r" (u32)); 5883 # endif 5708 5884 5709 5885 # else … … 5725 5901 { 5726 5902 #if defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32) 5903 # if defined(RTASM_ARM64_USE_FEAT_LSE) 5904 uint32_t u32OldRet; 5905 __asm__ __volatile__("Lstart_ASMAtomicAndExU32_%=:\n\t" 5906 "ldclr %w[fBitsToClear], %w[uOldRet], %[pMem]\n\t" 5907 : [pMem] "+Q" (*pu32) 5908 , [uOldRet] "=&r" (u32OldRet) 5909 : [fBitsToClear] "r" (~u32) 5910 : ); 5911 # else 5727 5912 RTASM_ARM_LOAD_MODIFY_STORE_RET_OLD_32(ASMAtomicUoAndEx32, pu32, NO_BARRIER, 5728 5913 "and %w[uNew], %w[uOld], %w[uVal]\n\t", 5729 5914 "and %[uNew], %[uOld], %[uVal]\n\t", 5730 5915 [uVal] "r" (u32)); 5916 # endif 5731 5917 return u32OldRet; 5732 5918 … … 5772 5958 5773 5959 # elif defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32) 5960 # if defined(RTASM_ARM64_USE_FEAT_LSE) 5961 __asm__ __volatile__("Lstart_ASMAtomicUoAndU64_%=:\n\t" 5962 "stclr %[fBitsToClear], %[pMem]\n\t" 5963 : [pMem] "+Q" (*pu64) 5964 : [fBitsToClear] "r" (~u64) 5965 : ); 5966 # else 5774 5967 RTASM_ARM_LOAD_MODIFY_STORE_RET_NEW_64(ASMAtomicUoAndU64, pu64, NO_BARRIER, 5775 5968 "and %[uNew], %[uNew], %[uVal]\n\t" … … 5778 5971 "and %H[uNew], %H[uNew], %H[uVal]\n\t", 5779 5972 [uVal] "r" (u64)); 5973 # endif 5780 5974 5781 5975 # else … … 5842 6036 5843 6037 # elif defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32) 6038 # if defined(RTASM_ARM64_USE_FEAT_LSE) 6039 __asm__ __volatile__("Lstart_ASMAtomicUoXorU32_%=:\n\t" 6040 "steor %w[fBitMask], %[pMem]\n\t" 6041 : [pMem] "+Q" (*pu32) 6042 : [fBitMask] "r" (u32) 6043 : ); 6044 # else 5844 6045 RTASM_ARM_LOAD_MODIFY_STORE_RET_NEW_32(ASMAtomicUoXorU32, pu32, NO_BARRIER, 5845 6046 "eor %w[uNew], %w[uNew], %w[uVal]\n\t", 5846 6047 "eor %[uNew], %[uNew], %[uVal]\n\t", 5847 6048 [uVal] "r" (u32)); 6049 # endif 5848 6050 5849 6051 # else … … 5865 6067 { 5866 6068 #if defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32) 6069 # if defined(RTASM_ARM64_USE_FEAT_LSE) 6070 uint32_t u32OldRet; 6071 __asm__ __volatile__("Lstart_ASMAtomicUoXorExU32_%=:\n\t" 6072 "ldeor %w[fBitMask], %w[uOldRet], %[pMem]\n\t" 6073 : [pMem] "+Q" (*pu32) 6074 , [uOldRet] "=&r" (u32OldRet) 6075 : [fBitMask] "r" (u32) 6076 : ); 6077 # else 5867 6078 RTASM_ARM_LOAD_MODIFY_STORE_RET_OLD_32(ASMAtomicUoXorExU32, pu32, NO_BARRIER, 5868 6079 "eor %w[uNew], %w[uOld], %w[uVal]\n\t", 5869 6080 "eor %[uNew], %[uOld], %[uVal]\n\t", 5870 6081 [uVal] "r" (u32)); 6082 # endif 5871 6083 return u32OldRet; 5872 6084
Note:
See TracChangeset
for help on using the changeset viewer.