This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Add XL compat __compare_and_swap builtins
ClosedPublic

Authored by jsji on Jun 23 2021, 9:11 PM.

Details

Summary

Prototype
int __compare_and_swap (volatile int* addr, int* old_val_addr, int
new_val);

int __compare_and_swaplp (volatile long* addr, long* old_val_addr, long
new_val);

Refer to
https://www.ibm.com/docs/en/xl-c-and-cpp-aix/16.1?topic=functions-compare-swap-compare-swaplp

Diff Detail

Event Timeline

jsji created this revision.Jun 23 2021, 9:11 PM
jsji requested review of this revision.Jun 23 2021, 9:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 23 2021, 9:11 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
jsji updated this revision to Diff 354360.Jun 24 2021, 2:39 PM

Add {} to case.

w2yehia accepted this revision.Jun 24 2021, 5:19 PM
w2yehia added inline comments.
clang/test/CodeGen/builtins-ppc-xlcompat-cas.c
20

i dont think we need to check for the extractvalue instructions, they can be optimized away in theory.

25

just an FYI that a volatile could have been avoided if the arguments to __compare_and_swap where function parameters

This revision is now accepted and ready to land.Jun 24 2021, 5:19 PM
jsji updated this revision to Diff 354410.Jun 24 2021, 6:08 PM

Address comments.

clang/test/CodeGen/builtins-ppc-xlcompat-cas.c
20

Yes, but this is autogenerated for easier maintenance. Also, clang tests won't turn on optimization by default, so they won't be optimized away.

This revision was landed with ongoing or failed builds.Jun 24 2021, 6:32 PM
This revision was automatically updated to reflect the committed changes.