This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Add codegen support for RV64A
ClosedPublic

Authored by asb on Oct 12 2018, 5:38 PM.

Details

Summary

In order to support codegen RV64A, this patch:

  • Introduces masked atomics intrinsics for atomicrmw operations and cmpxchg that use the i64 type. These are ultimately lowered to masked operations using lr.w/sc.w, but we need to use these alternate intrinsics for RV64 because i32 is not legal
  • Modifies RISCVExpandPseudoInsts.cpp to handle PseudoAtomicLoadNand64 and PseudoCmpXchg64
  • Modifies the AtomicExpandPass hooks in RISCVTargetLowering sext/trunc as needed for RV64 and to select the i64 intrinsic IDs when necessary
  • Adds appropriate patterns to RISCVInstrInfoA.td
  • Updates test/CodeGen/RISCV/atomic-*.ll to show RV64A support

This ends up being a fairly mechanical change, as the logic for RV32A is effectively reused.

Diff Detail

Event Timeline

asb created this revision.Oct 12 2018, 5:38 PM
asb updated this revision to Diff 174201.Nov 15 2018, 6:28 AM

Refreshing patch, no changes.

asb planned changes to this revision.Nov 30 2018, 7:14 PM

I'll update this to include cmpxchg support now D48131 landed.

jrtc27 added a subscriber: jrtc27.Dec 7 2018, 8:42 AM
asb updated this revision to Diff 181370.Jan 11 2019, 2:34 PM
asb retitled this revision from [RISCV] Add codegen support for 64-bit atomic load/store and atomicrmw to [RISCV] Add codegen support RV64A.
asb edited the summary of this revision. (Show Details)

Updated. Now handles cmpxchg, supporting all RV64A. The code changes are actually pretty minimal so I hope this is fairly straight-forward to review.

@jyknight: might you find time to look at this?

asb retitled this revision from [RISCV] Add codegen support RV64A to [RISCV] Add codegen support for RV64A.Jan 11 2019, 2:34 PM
jyknight accepted this revision.Jan 15 2019, 8:02 PM
In D53233#1354863, @asb wrote:

Updated. Now handles cmpxchg, supporting all RV64A. The code changes are actually pretty minimal so I hope this is fairly straight-forward to review.

Indeed. LGTM!

This revision is now accepted and ready to land.Jan 15 2019, 8:02 PM
This revision was automatically updated to reflect the committed changes.
test/CodeGen/RISCV/atomic-load-store.ll