Skip to content

Conversation

@phorcys
Copy link
Contributor

@phorcys phorcys commented Nov 5, 2025

  • Add LOCK_8_ALIGNED_4BYTE, LOCK_8_IN_4BYTE macro.
  • F0 00 LOCK ADD Eb, Gb

if (cpuext.lam_bh) {
AMADD_DB_B(x1, gd, wback);
} else {
if (!ALIGNED_ATOMICxw) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This doesn't make sense. Byte atomic can never be unaligned.

Copy link
Contributor Author

@phorcys phorcys Nov 5, 2025

Choose a reason for hiding this comment

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

#define ALIGNED_ATOMICxw ((fixedaddress && !(fixedaddress & (((1 << (2 + rex.w)) - 1)))) || BOX64ENV(dynarec_aligned_atomics))

Byte lock opcodes has no "nature alignment"
But LoongArch has only ll.w/sc.w ( amcas_db.b is exceptional)

So I create two macro:
LOCK_8_ALIGNED_4BYTE for 4-byte aligned 8-bits
LOCK_8_IN_4BYTE for 4-byte offset 1/2/3

ALIGNED_ATOMICxw here is to test addr is 4byte aligned or BOX64_DYNAREC_ALIGNED_ATOMICS is turned on.
It's will not emit LOCK_8_IN_4BYTE macro or addr ANDI test.

Else if addr is not 4-byte aligned and BOX64_DYNAREC_ALIGNED_ATOMICS is not turned on ,emit LOCK_8_IN_4BYTE related.

Indeed it looks quite strange, but it should work properly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My bad, BOX64_DYNAREC_ALIGNED_ATOMICS should not be tested.

@ksco
Copy link
Collaborator

ksco commented Nov 5, 2025

By the way, how were these opcodes tested?

Repository owner deleted a comment from phorcys Nov 5, 2025
  *  Add LOCK_8_ALIGNED_4BYTE, LOCK_8_IN_4BYTE macro.
  *  F0 00 LOCK ADD Eb, Gb
@ptitSeb ptitSeb merged commit a96f2dc into ptitSeb:main Nov 7, 2025
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants