This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Implement Load and Reserve and Store Conditional Builtins
ClosedPublic

Authored by Conanap on Jun 30 2021, 3:11 PM.

Details

Summary

This patch implements the load and reserve and store conditional
builtins for the PowerPC target, in order to have feature parity with
xlC on AIX.

Diff Detail

Event Timeline

Conanap created this revision.Jun 30 2021, 3:11 PM
Conanap requested review of this revision.Jun 30 2021, 3:11 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJun 30 2021, 3:11 PM
Conanap added reviewers: nemanjai, Whitney, Restricted Project.Jun 30 2021, 3:12 PM
jsji added a reviewer: lkail.Jun 30 2021, 3:14 PM
lkail added a comment.Jun 30 2021, 6:09 PM

The wording might be inaccurate. It's better to rephrase to 'Load and Reserve and Store Conditional'.

llvm/lib/Target/PowerPC/PPCInstr64Bit.td
1724

IIRC, l(w|d)arx, st(w|d)cx are supported very early and don't need altivec support.

llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-atomicLoadStore-64-only.ll
7 ↗(On Diff #355701)

Is -mcpu=pwr9 necessary?

amyk added a subscriber: amyk.Jul 5 2021, 6:03 AM
amyk added inline comments.
llvm/include/llvm/IR/IntrinsicsPowerPC.td
1536–1537

Is there an unintended change at the end?

llvm/lib/Target/PowerPC/PPCInstrPrefix.td
2841 ↗(On Diff #355701)

Why are these patterns in PPCInstrPrefix.td? Shouldn't they be in PPCInstrInfo.td?
Also, you can probably use ForceXForm instead of xoaddr here.

nemanjai added inline comments.Jul 5 2021, 8:41 AM
llvm/lib/Target/PowerPC/PPCInstr64Bit.td
1724

Agreed. This does not require ISA 2.07 and definitely doesn't require Altivec.

Conanap updated this revision to Diff 356527.Jul 5 2021, 10:26 AM

Moved the pattern definitions and removed unnecessary guard.

Conanap updated this revision to Diff 356528.Jul 5 2021, 10:27 AM

Properly updated the diff with arc.

Conanap retitled this revision from [PowerPC] Implament Atomic Load and Stores Builtins to [PowerPC] Implament Load and Reserve and Store Conditional Builtins.Jul 5 2021, 10:29 AM
Conanap edited the summary of this revision. (Show Details)
Conanap edited the summary of this revision. (Show Details)
Conanap updated this revision to Diff 356532.Jul 5 2021, 10:32 AM

Changed test case file names

Conanap updated this revision to Diff 356533.Jul 5 2021, 10:33 AM

Updated C test case name

Conanap marked 3 inline comments as done.Jul 5 2021, 10:47 AM

Addressed comments

NeHuang added a subscriber: NeHuang.EditedJul 5 2021, 11:29 AM

Please add the 64 bit only sema check & error test case for the two 64 bit only builtins ldarx and stdcx

llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond-64-only.ll
10 ↗(On Diff #356533)

remove local_unnamed_addr #0

22 ↗(On Diff #356533)

remove local_unnamed_addr #0

llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond.ll
13

remove local_unnamed_addr #0

31

remove local_unnamed_addr #0

Conanap updated this revision to Diff 356542.Jul 5 2021, 11:43 AM

Added error test cases and sema checking

Conanap updated this revision to Diff 356545.Jul 5 2021, 11:59 AM

Updated 64 bit error test cases

Overall I think this is fine. I just have a few nits.

clang/test/CodeGen/builtins-ppc-xlcompat-LoadReseve-StoreCond.c
12

Please check that this "entry:" is printed out when asserts are on and when asserts are off you may want to remove it at this point.

I would prefer you check the name of the function instead of "entry". You can use CHECK-LABEL to do that.

clang/test/CodeGen/builtins-ppc-xlcompat-error.c
19

This entire test is for 32 bit Power PC. There is only one run line and that is what is specified.
Why are you checking the macros?

llvm/include/llvm/IR/IntrinsicsPowerPC.td
1529

nit:
Does this go past the 80 char limit?

Conanap updated this revision to Diff 356546.Jul 5 2021, 12:02 PM
Conanap marked 2 inline comments as done.

Updated IR test cases

Conanap updated this revision to Diff 356551.Jul 5 2021, 12:11 PM

Changed to ForceXForm

NeHuang added inline comments.Jul 5 2021, 12:25 PM
clang/test/CodeGen/builtins-ppc-xlcompat-LoadReseve-StoreCond-64bit-only.c
2

-S seems redundant.
Any reason we need -O2 for these tests?

clang/test/CodeGen/builtins-ppc-xlcompat-LoadReseve-StoreCond.c
2

same as above.

12

Agreed. We should first do CHECK-LABEL with the function name.

Conanap updated this revision to Diff 356559.Jul 5 2021, 12:57 PM
Conanap marked 4 inline comments as done.

Updated test cases

Conanap marked an inline comment as done.Jul 5 2021, 12:57 PM

addressed comments

NeHuang accepted this revision as: NeHuang.Jul 5 2021, 1:40 PM

Overall LGTM.

This revision is now accepted and ready to land.Jul 5 2021, 1:40 PM
Conanap updated this revision to Diff 356562.Jul 5 2021, 1:55 PM

Removed entry from check

amyk accepted this revision as: amyk.Jul 5 2021, 2:08 PM

Also LGTM overall.

llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond-64bit-only.ll
3

nit: Add -ppc-asm-full-reg-names.

llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond.ll
4

nit: Add -ppc-asm-full-reg-names.

nemanjai accepted this revision.Jul 5 2021, 2:24 PM

LGTM aside from a small nit.

llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond-64bit-only.ll
3

+1

Conanap marked 3 inline comments as done.Jul 5 2021, 3:21 PM
Conanap added inline comments.
llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond-64bit-only.ll
3

The AIX assembler cannot understand register prefixes, so I'll leave the test cases as is.

hubert.reinterpretcast edited the summary of this revision. (Show Details)Jul 5 2021, 5:13 PM
stevewan retitled this revision from [PowerPC] Implament Load and Reserve and Store Conditional Builtins to [PowerPC] Implement Load and Reserve and Store Conditional Builtins.Jul 5 2021, 5:17 PM
stefanp accepted this revision.Jul 5 2021, 5:31 PM

Thank you!
LGTM.

lkail accepted this revision.Jul 5 2021, 5:52 PM

lgtm,thanks.

thakis added a subscriber: thakis.Jul 5 2021, 7:43 PM

Looks like this breaks tests: http://45.33.8.238/linux/50465/step_7.txt

Please take a look, and revert for now if it takes a while to fix.

Looks like this breaks tests: http://45.33.8.238/linux/50465/step_7.txt

Please take a look, and revert for now if it takes a while to fix.

Hi! I accidentally included a test case meant for a later patch; it's been removed in this patch here: https://reviews.llvm.org/D105454

nemanjai added inline comments.Jul 9 2021, 2:57 AM
llvm/include/llvm/IR/IntrinsicsPowerPC.td
1533

I don't know why I missed this in the review, but this is very wrong! This is a load intrinsic that is marked as one that doesn't touch memory.