Skip to content

[LoongArch64] Add atomic instruction implementation for LoongArch64 - #129683

Open
lawn123 wants to merge 25 commits into
dotnet:mainfrom
lawn123:LoongArch64_Atomic
Open

lawn123 wants to merge 25 commits into
dotnet:mainfrom
lawn123:LoongArch64_Atomic

Conversation

@lawn123

@lawn123 lawn123 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Add atomic instruction for LoongArch64. Supports atomic instructions on ISA1.0 and ISA1.1
Implementation of #122745.

@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 22, 2026
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Jun 22, 2026
@lawn123

lawn123 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Hi @shushanhf @LuckyXu-HF @jakobbotsch @jkotas could you please review this PR? Thanks.

Comment thread src/coreclr/inc/clrconfigvalues.h Outdated
Comment thread src/coreclr/jit/codegenloongarch64.cpp Outdated
Comment thread src/coreclr/jit/codegenloongarch64.cpp Outdated
@dotnet-policy-service dotnet-policy-service Bot added the linkable-framework Issues associated with delivering a linker friendly framework label Jul 2, 2026
Comment thread src/coreclr/inc/clrconfigvalues.h Outdated
Comment thread src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs Outdated
Comment thread src/coreclr/jit/importercalls.cpp
Comment thread src/coreclr/inc/corinfoinstructionset.h Outdated
/// <para>AMSWAP[_DB].H rd, rk, rj</para>
/// <para>This is the newly added atomic instruction on ISA1.1</para>
/// </summary>
internal static ushort Exchange(ref ushort location1, ushort value) => Exchange(ref location1, value);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does Exchange work for int and long that it is missing here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For int and long types Exchange supports both V1.0 and V1.1.

lawn123 added 9 commits July 3, 2026 16:28
Change-Id: I3b7757ecfeff9aba28407508b196d55b4e21b69d
Change-Id: Ib826fc3ffb9057835357b68a51e20da66f9cebd5
Change-Id: Id3be930d58440bbc39b307a211a9fcb444f1e3ca
…on and opportunistics light-up for NAOT

Change-Id: I419341c499d0c4e955a60e5f4ad6fdeef74f9277
…rmatting issues

Change-Id: I1b3d1010ac3642624ec1f66eb26dc11220460d7a
…efault and revert System.Runtime.Intrinsics.cs changes.

Change-Id: If9f10ec7908aaf706b1d2ad9f2e34db073543d36
Change-Id: I2c1e8d43106616da47e231670e557f508330e3d8
…n.sh

Change-Id: I3240c5d2413950981b4f1446d837d9c0de4e9a65
Change-Id: I51fe7faac05749bc38344e2068bb2efccc1ce99a

@jakobbotsch jakobbotsch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JIT codegen/import looks ok to me. @tannergooding can you give a final approval for all the intrinsic-related changes in the different layers?

Change-Id: I5604be377c6451c96da56b8f55c6d126fe8f6a9d
@lawn123

lawn123 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

The JIT codegen/import looks ok to me. @tannergooding can you give a final approval for all the intrinsic-related changes in the different layers?

@jakobbotsch Thank you. I have updated according to your suggestion. @tannergooding Could you please take a look when you have a chance? Thanks!

Change-Id: Ie26a7a659ca6087ee06972364d727fbe58650662
@lawn123

lawn123 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

#129683 (review)
@tannergooding Could you please take a look when you have a chance? Thanks!

@lawn123

lawn123 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

Hi @tannergooding,
As mentioned above, the JIT codegen and import logic have been reviewed and look ok to @jakobbotsch . Could you please take a look at the intrinsic-related changes across the different layers and provide a final review/approval when you have a chance? Thanks!

Change-Id: I4d33b5ea6b8fae5a3cd7c620fb8563726269f1f1
Change-Id: Ic95bd9d0954006d3d23663e636c40dda445febfa
@lawn123

lawn123 commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author
Time [secs] | Total | Passed | Failed | Skipped | ActiveIssue | Assembly Execution Summary
===========================================================================================
    449.248 |   100 |    100 |      0 |       0 |           0 | JIT.Performance.JIT.performance
      1.182 |   290 |    281 |      0 |       9 |           0 | JIT.Regression.Regression_6
     41.343 |   110 |    110 |      0 |       0 |           0 | async.async
      4.257 |   250 |    250 |      0 |       0 |           0 | JIT.Generics.JIT.Generics
      3.062 |    39 |      9 |      0 |      30 |           0 | tracing.tracing
      4.697 |   309 |    307 |      0 |       2 |           1 | JIT.Methodical.Methodical_d2
    317.455 |   536 |    526 |      0 |      10 |           1 | JIT.opt.JIT.opt
      1.307 |    13 |     13 |      0 |       0 |           0 | ilasm.ilasm_tests
      0.605 |   123 |    123 |      0 |       0 |           0 | JIT.Regression.Regression_PdbOnly_r_1
     26.037 |    28 |     28 |      0 |       0 |           0 | profiler.profiler
     38.210 |    42 |     28 |      0 |      14 |          12 | baseservices.baseservices
     24.263 |    89 |     88 |      0 |       1 |           0 | Regressions.Regressions
      1.165 |     2 |      2 |      0 |       0 |           0 | Exceptions.Exceptions
     14.024 |    88 |     88 |      0 |       0 |           0 | JIT.Regression.Regression_4
     27.369 |   107 |     97 |      0 |      10 |           0 | JIT.Regression.Regression_2
      0.000 |     0 |      0 |      0 |       0 |           0 | StandaloneRunnerTests
      7.568 |   275 |    274 |      0 |       1 |           1 | JIT.Methodical.Methodical_do
      1.515 |   114 |    114 |      0 |       0 |           0 | Loader.classloader.regressions.LoaderClassloaderRegressions
      0.466 |    19 |     19 |      0 |       0 |           0 | JIT.Regression.Regression_do
      2.970 |   118 |    114 |      0 |       4 |           0 | JIT.Regression.Regression_3
      0.290 |     1 |      1 |      0 |       0 |           0 | JIT.Regression.Regression_PdbOnly_r
      0.329 |    29 |      9 |      0 |      20 |           0 | JIT.Regression.Regression_9
    312.150 |    44 |     43 |      0 |       1 |           1 | GC.Features.GC-features
     12.301 |   245 |    233 |      0 |      12 |           5 | JIT.Directed.Directed_3
     26.828 |  2551 |   2551 |      0 |       0 |           0 | JIT.HardwareIntrinsics.HardwareIntrinsics_General_ro
      0.478 |    23 |     23 |      0 |       0 |           0 | JIT.Regression.Regression_PdbOnly_ro
     18.975 |   207 |    207 |      0 |       0 |           0 | JIT.Directed.Directed_2
      0.830 |   160 |    160 |      0 |       0 |           0 | JIT.CodeGenBringUpTests.JIT.CodeGenBringUpTests_d
    147.430 |   143 |    143 |      0 |       0 |           0 | JIT.jit64.jit64_3
     64.268 |    75 |     74 |      0 |       1 |           0 | baseservices.threading.threading_group1
      1.167 |   343 |    343 |      0 |       0 |           0 | JIT.jit64.jit64_4
     23.805 |   170 |    151 |      0 |      19 |           1 | baseservices.exceptions.baseservices-exceptions
     11.646 |   399 |    399 |      0 |       0 |           0 | JIT.Methodical.Methodical_r1
      0.302 |    13 |     13 |      0 |       0 |           0 | JIT.Regression.Regression_8
      4.234 |   116 |    116 |      0 |       0 |           0 | JIT.SIMD.JIT.SIMD
      4.429 |   161 |    158 |      0 |       3 |           0 | JIT.Regression.Regression_o_1
      0.651 |    30 |     30 |      0 |       0 |           0 | JIT.JIT_r
      0.637 |    30 |     30 |      0 |       0 |           0 | JIT.JIT_ro
      2.443 |   170 |    157 |      0 |      13 |           0 | JIT.Regression.Regression_o_3
      8.965 |   275 |    274 |      0 |       1 |           1 | JIT.Methodical.Methodical_ro
     58.362 |    88 |     88 |      0 |       0 |           0 | baseservices.threading.threading_group2
    148.762 |   232 |    230 |      0 |       2 |           0 | JIT.jit64.jit64_5
      0.853 |   170 |    163 |      0 |       7 |           0 | JIT.Regression.Regression_7
      0.451 |    17 |     17 |      0 |       0 |           0 | JIT.Regression.Regression_NoOptimize_r_1
      1.863 |    19 |     19 |      0 |       0 |           0 | JIT.Regression.Regression_NoOptimize_d
    110.279 |     1 |      1 |      0 |       0 |           0 | readytorun.coreroot_determinism.readytorun_coreroot_determinism
      2.805 |   123 |    123 |      0 |       0 |           0 | JIT.Regression.Regression_PdbOnly_r_3
      0.798 |   160 |    160 |      0 |       0 |           0 | JIT.CodeGenBringUpTests.JIT.CodeGenBringUpTests_do
     12.623 |   217 |    217 |      0 |       0 |           0 | JIT.Directed.Directed_1
    510.419 |   110 |    106 |      0 |       4 |           2 | GC.GC
      3.392 |   216 |    216 |      0 |       0 |           0 | Loader.classloader.generics.LoaderClassloaderGenerics
     10.498 |   280 |    247 |      0 |      33 |           5 | Interop.Interop
      5.810 |   311 |    309 |      0 |       2 |           1 | JIT.Methodical.Methodical_r2
    118.039 |   123 |    122 |      0 |       1 |           0 | JIT.Regression.Regression_PdbOnly_r_2
      0.326 |    29 |      9 |      0 |      20 |           0 | JIT.Regression.Regression_10
      1.678 |   405 |    405 |      0 |       0 |           0 | JIT.IL_Conformance.IL_Conformance
      0.575 |     3 |      3 |      0 |       0 |           0 | JIT.JIT_do
     30.981 |  2584 |   2584 |      0 |       0 |           0 | JIT.HardwareIntrinsics.HardwareIntrinsics_General_r
      0.609 |     2 |      2 |      0 |       0 |           0 | JIT.JIT_d
      1.013 |   161 |    161 |      0 |       0 |           0 | JIT.CodeGenBringUpTests.JIT.CodeGenBringUpTests_r
      6.827 |   113 |    108 |      0 |       5 |           0 | JIT.Regression.Regression_1
      1.322 |   109 |    107 |      0 |       2 |           0 | JIT.Methodical.Methodical_others
    119.948 |    50 |     50 |      0 |       0 |           0 | GC.Scenarios.GC-scenarios1
      5.206 |    90 |     87 |      0 |       3 |           0 | JIT.Regression.Regression_ro_1
      4.476 |   233 |    223 |      0 |      10 |           0 | JIT.Regression.Regression_ro_2
      0.428 |     1 |      1 |      0 |       0 |           0 | JIT.Regression.Regression_PdbOnly_r_4
     86.282 |    20 |     18 |      0 |       2 |           1 | readytorun.readytorun
     70.173 |   395 |    395 |      0 |       0 |           0 | Loader.Loader
      0.416 |     3 |      3 |      0 |       0 |           0 | JIT.Regression.Regression_r_1
      0.265 |     0 |      0 |      0 |       0 |           0 | managed.Managed
      1.246 |    81 |     81 |      0 |       0 |           0 | JIT.jit64.jit64_1
      9.332 |     2 |      2 |      0 |       0 |           0 | JIT.Regression.Regression_d
      2.958 |    18 |     18 |      0 |       0 |           0 | reflection.reflection
    144.938 |    13 |     12 |      0 |       1 |           0 | JIT.JIT_others
      7.840 |    55 |     54 |      0 |       1 |           0 | CoreMangLib.CoreMangLib
      9.512 |   395 |    395 |      0 |       0 |           0 | JIT.Methodical.Methodical_d1
      0.936 |   160 |    160 |      0 |       0 |           0 | JIT.CodeGenBringUpTests.JIT.CodeGenBringUpTests_ro
      0.413 |    17 |     17 |      0 |       0 |           0 | JIT.Regression.Regression_5
      2.043 |   165 |     97 |      0 |      68 |           0 | JIT.Regression.Regression_o_2
-------------------------------------------------------------------------------------------
   3103.599 | 15008 |  14696 |      0 |     312 |          32 | (total)

Hi @tannergooding,
Sorry to bother you again. I've run the latest tests locally, and everything passed successfully. Could you please take a look at the intrinsic-related changes when you have a moment? Thanks!

@tannergooding

Copy link
Copy Markdown
Member

Sorry for the delay, this is on my backlog but I've been busy working on things that must make the .NET 11 P7 snap.

@lawn123

lawn123 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

Sorry for the delay, this is on my backlog but I've been busy working on things that must make the .NET 11 P7 snap.

Understood, thanks for letting me know! I'll wait for your review when things settle down.

Change-Id: I445a3af8d984bd2c3157581265a7bee9f100207d
Change-Id: I74c2e911371743ea60169fead09bc10ca89513e2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-loongarch64 area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI community-contribution Indicates that the PR has been added by a community member linkable-framework Issues associated with delivering a linker friendly framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants