Skip to content

Commit 4480898

Browse files
erifan01cherrymui
authored andcommitted
cmd/asm: add arm64 v8.1 atomic instructions
This change adds several arm64 v8.1 atomic instructions and test cases. They are LDADDAx, LDADDLx, LDANDAx, LDANDALx, LDANDLx, LDEORAx, LDEORALx, LDEORLx, LDORAx, LDORALx, LDORLx, SWPAx and SWPLx. Their form is consistent with the form of the existing atomic instructions. For instructions STXRx, STLXRx, STXPx and STLXPx, the second destination register can't be RSP. This CL also adds a check for this. LDADDx Rs, (Rb), Rt: *Rb -> Rt, Rs + *Rb -> *Rb LDANDx Rs, (Rb), Rt: *Rb -> Rt, Rs AND NOT(*Rb) -> *Rb LDEORx Rs, (Rb), Rt: *Rb -> Rt, Rs EOR *Rb -> *Rb LDORx Rs, (Rb), Rt: *Rb -> Rt, Rs OR *Rb -> *Rb Change-Id: I9f9b0245958cb57ab7d88c66fb9159b23b9017fd Reviewed-on: https://go-review.googlesource.com/c/go/+/157001 Reviewed-by: Cherry Zhang <[email protected]> Run-TryBot: Cherry Zhang <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent 40d8c3d commit 4480898

File tree

6 files changed

+469
-95
lines changed

6 files changed

+469
-95
lines changed

src/cmd/asm/internal/arch/arm64.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,11 @@ func IsARM64STLXR(op obj.As) bool {
7272
switch op {
7373
case arm64.ASTLXRB, arm64.ASTLXRH, arm64.ASTLXRW, arm64.ASTLXR,
7474
arm64.ASTXRB, arm64.ASTXRH, arm64.ASTXRW, arm64.ASTXR,
75-
arm64.ASTXP, arm64.ASTXPW, arm64.ASTLXP, arm64.ASTLXPW,
76-
arm64.ASWPB, arm64.ASWPH, arm64.ASWPW, arm64.ASWPD,
77-
arm64.ASWPALB, arm64.ASWPALH, arm64.ASWPALW, arm64.ASWPALD,
78-
arm64.ALDADDB, arm64.ALDADDH, arm64.ALDADDW, arm64.ALDADDD,
79-
arm64.ALDANDB, arm64.ALDANDH, arm64.ALDANDW, arm64.ALDANDD,
80-
arm64.ALDEORB, arm64.ALDEORH, arm64.ALDEORW, arm64.ALDEORD,
81-
arm64.ALDORB, arm64.ALDORH, arm64.ALDORW, arm64.ALDORD,
82-
arm64.ALDADDALD, arm64.ALDADDALW, arm64.ALDADDALH, arm64.ALDADDALB:
75+
arm64.ASTXP, arm64.ASTXPW, arm64.ASTLXP, arm64.ASTLXPW:
76+
return true
77+
}
78+
// atomic instructions
79+
if arm64.IsAtomicInstruction(op) {
8380
return true
8481
}
8582
return false

src/cmd/asm/internal/asm/testdata/arm64.s

Lines changed: 120 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -659,14 +659,14 @@ again:
659659
STXP (R1, R2), (RSP), R10 // e10b2ac8
660660
STXPW (R1, R2), (R3), R10 // 61082a88
661661
STXPW (R1, R2), (RSP), R10 // e10b2a88
662-
SWPD R5, (R6), R7 // c78025f8
663-
SWPD R5, (RSP), R7 // e78325f8
664-
SWPW R5, (R6), R7 // c78025b8
665-
SWPW R5, (RSP), R7 // e78325b8
666-
SWPH R5, (R6), R7 // c7802578
667-
SWPH R5, (RSP), R7 // e7832578
668-
SWPB R5, (R6), R7 // c7802538
669-
SWPB R5, (RSP), R7 // e7832538
662+
SWPAD R5, (R6), R7 // c780a5f8
663+
SWPAD R5, (RSP), R7 // e783a5f8
664+
SWPAW R5, (R6), R7 // c780a5b8
665+
SWPAW R5, (RSP), R7 // e783a5b8
666+
SWPAH R5, (R6), R7 // c780a578
667+
SWPAH R5, (RSP), R7 // e783a578
668+
SWPAB R5, (R6), R7 // c780a538
669+
SWPAB R5, (RSP), R7 // e783a538
670670
SWPALD R5, (R6), R7 // c780e5f8
671671
SWPALD R5, (RSP), R7 // e783e5f8
672672
SWPALW R5, (R6), R7 // c780e5b8
@@ -675,6 +675,38 @@ again:
675675
SWPALH R5, (RSP), R7 // e783e578
676676
SWPALB R5, (R6), R7 // c780e538
677677
SWPALB R5, (RSP), R7 // e783e538
678+
SWPD R5, (R6), R7 // c78025f8
679+
SWPD R5, (RSP), R7 // e78325f8
680+
SWPW R5, (R6), R7 // c78025b8
681+
SWPW R5, (RSP), R7 // e78325b8
682+
SWPH R5, (R6), R7 // c7802578
683+
SWPH R5, (RSP), R7 // e7832578
684+
SWPB R5, (R6), R7 // c7802538
685+
SWPB R5, (RSP), R7 // e7832538
686+
SWPLD R5, (R6), R7 // c78065f8
687+
SWPLD R5, (RSP), R7 // e78365f8
688+
SWPLW R5, (R6), R7 // c78065b8
689+
SWPLW R5, (RSP), R7 // e78365b8
690+
SWPLH R5, (R6), R7 // c7806578
691+
SWPLH R5, (RSP), R7 // e7836578
692+
SWPLB R5, (R6), R7 // c7806538
693+
SWPLB R5, (RSP), R7 // e7836538
694+
LDADDAD R5, (R6), R7 // c700a5f8
695+
LDADDAD R5, (RSP), R7 // e703a5f8
696+
LDADDAW R5, (R6), R7 // c700a5b8
697+
LDADDAW R5, (RSP), R7 // e703a5b8
698+
LDADDAH R5, (R6), R7 // c700a578
699+
LDADDAH R5, (RSP), R7 // e703a578
700+
LDADDAB R5, (R6), R7 // c700a538
701+
LDADDAB R5, (RSP), R7 // e703a538
702+
LDADDALD R5, (R6), R7 // c700e5f8
703+
LDADDALD R5, (RSP), R7 // e703e5f8
704+
LDADDALW R5, (R6), R7 // c700e5b8
705+
LDADDALW R5, (RSP), R7 // e703e5b8
706+
LDADDALH R5, (R6), R7 // c700e578
707+
LDADDALH R5, (RSP), R7 // e703e578
708+
LDADDALB R5, (R6), R7 // c700e538
709+
LDADDALB R5, (RSP), R7 // e703e538
678710
LDADDD R5, (R6), R7 // c70025f8
679711
LDADDD R5, (RSP), R7 // e70325f8
680712
LDADDW R5, (R6), R7 // c70025b8
@@ -683,6 +715,30 @@ again:
683715
LDADDH R5, (RSP), R7 // e7032578
684716
LDADDB R5, (R6), R7 // c7002538
685717
LDADDB R5, (RSP), R7 // e7032538
718+
LDADDLD R5, (R6), R7 // c70065f8
719+
LDADDLD R5, (RSP), R7 // e70365f8
720+
LDADDLW R5, (R6), R7 // c70065b8
721+
LDADDLW R5, (RSP), R7 // e70365b8
722+
LDADDLH R5, (R6), R7 // c7006578
723+
LDADDLH R5, (RSP), R7 // e7036578
724+
LDADDLB R5, (R6), R7 // c7006538
725+
LDADDLB R5, (RSP), R7 // e7036538
726+
LDANDAD R5, (R6), R7 // c710a5f8
727+
LDANDAD R5, (RSP), R7 // e713a5f8
728+
LDANDAW R5, (R6), R7 // c710a5b8
729+
LDANDAW R5, (RSP), R7 // e713a5b8
730+
LDANDAH R5, (R6), R7 // c710a578
731+
LDANDAH R5, (RSP), R7 // e713a578
732+
LDANDAB R5, (R6), R7 // c710a538
733+
LDANDAB R5, (RSP), R7 // e713a538
734+
LDANDALD R5, (R6), R7 // c710e5f8
735+
LDANDALD R5, (RSP), R7 // e713e5f8
736+
LDANDALW R5, (R6), R7 // c710e5b8
737+
LDANDALW R5, (RSP), R7 // e713e5b8
738+
LDANDALH R5, (R6), R7 // c710e578
739+
LDANDALH R5, (RSP), R7 // e713e578
740+
LDANDALB R5, (R6), R7 // c710e538
741+
LDANDALB R5, (RSP), R7 // e713e538
686742
LDANDD R5, (R6), R7 // c71025f8
687743
LDANDD R5, (RSP), R7 // e71325f8
688744
LDANDW R5, (R6), R7 // c71025b8
@@ -691,6 +747,30 @@ again:
691747
LDANDH R5, (RSP), R7 // e7132578
692748
LDANDB R5, (R6), R7 // c7102538
693749
LDANDB R5, (RSP), R7 // e7132538
750+
LDANDLD R5, (R6), R7 // c71065f8
751+
LDANDLD R5, (RSP), R7 // e71365f8
752+
LDANDLW R5, (R6), R7 // c71065b8
753+
LDANDLW R5, (RSP), R7 // e71365b8
754+
LDANDLH R5, (R6), R7 // c7106578
755+
LDANDLH R5, (RSP), R7 // e7136578
756+
LDANDLB R5, (R6), R7 // c7106538
757+
LDANDLB R5, (RSP), R7 // e7136538
758+
LDEORAD R5, (R6), R7 // c720a5f8
759+
LDEORAD R5, (RSP), R7 // e723a5f8
760+
LDEORAW R5, (R6), R7 // c720a5b8
761+
LDEORAW R5, (RSP), R7 // e723a5b8
762+
LDEORAH R5, (R6), R7 // c720a578
763+
LDEORAH R5, (RSP), R7 // e723a578
764+
LDEORAB R5, (R6), R7 // c720a538
765+
LDEORAB R5, (RSP), R7 // e723a538
766+
LDEORALD R5, (R6), R7 // c720e5f8
767+
LDEORALD R5, (RSP), R7 // e723e5f8
768+
LDEORALW R5, (R6), R7 // c720e5b8
769+
LDEORALW R5, (RSP), R7 // e723e5b8
770+
LDEORALH R5, (R6), R7 // c720e578
771+
LDEORALH R5, (RSP), R7 // e723e578
772+
LDEORALB R5, (R6), R7 // c720e538
773+
LDEORALB R5, (RSP), R7 // e723e538
694774
LDEORD R5, (R6), R7 // c72025f8
695775
LDEORD R5, (RSP), R7 // e72325f8
696776
LDEORW R5, (R6), R7 // c72025b8
@@ -699,6 +779,30 @@ again:
699779
LDEORH R5, (RSP), R7 // e7232578
700780
LDEORB R5, (R6), R7 // c7202538
701781
LDEORB R5, (RSP), R7 // e7232538
782+
LDEORLD R5, (R6), R7 // c72065f8
783+
LDEORLD R5, (RSP), R7 // e72365f8
784+
LDEORLW R5, (R6), R7 // c72065b8
785+
LDEORLW R5, (RSP), R7 // e72365b8
786+
LDEORLH R5, (R6), R7 // c7206578
787+
LDEORLH R5, (RSP), R7 // e7236578
788+
LDEORLB R5, (R6), R7 // c7206538
789+
LDEORLB R5, (RSP), R7 // e7236538
790+
LDORAD R5, (R6), R7 // c730a5f8
791+
LDORAD R5, (RSP), R7 // e733a5f8
792+
LDORAW R5, (R6), R7 // c730a5b8
793+
LDORAW R5, (RSP), R7 // e733a5b8
794+
LDORAH R5, (R6), R7 // c730a578
795+
LDORAH R5, (RSP), R7 // e733a578
796+
LDORAB R5, (R6), R7 // c730a538
797+
LDORAB R5, (RSP), R7 // e733a538
798+
LDORALD R5, (R6), R7 // c730e5f8
799+
LDORALD R5, (RSP), R7 // e733e5f8
800+
LDORALW R5, (R6), R7 // c730e5b8
801+
LDORALW R5, (RSP), R7 // e733e5b8
802+
LDORALH R5, (R6), R7 // c730e578
803+
LDORALH R5, (RSP), R7 // e733e578
804+
LDORALB R5, (R6), R7 // c730e538
805+
LDORALB R5, (RSP), R7 // e733e538
702806
LDORD R5, (R6), R7 // c73025f8
703807
LDORD R5, (RSP), R7 // e73325f8
704808
LDORW R5, (R6), R7 // c73025b8
@@ -707,11 +811,14 @@ again:
707811
LDORH R5, (RSP), R7 // e7332578
708812
LDORB R5, (R6), R7 // c7302538
709813
LDORB R5, (RSP), R7 // e7332538
710-
LDADDALD R2, (R1), R3 // 2300e2f8
711-
LDADDALW R2, (R1), R3 // 2300e2b8
712-
LDADDALH R2, (R1), R3 // 2300e278
713-
LDADDALB R2, (R1), R3 // 2300e238
714-
814+
LDORLD R5, (R6), R7 // c73065f8
815+
LDORLD R5, (RSP), R7 // e73365f8
816+
LDORLW R5, (R6), R7 // c73065b8
817+
LDORLW R5, (RSP), R7 // e73365b8
818+
LDORLH R5, (R6), R7 // c7306578
819+
LDORLH R5, (RSP), R7 // e7336578
820+
LDORLB R5, (R6), R7 // c7306538
821+
LDORLB R5, (RSP), R7 // e7336538
715822
// RET
716823
//
717824
// LTYPEA comma

0 commit comments

Comments
 (0)