[RISCV] Codegen for i8, i16, and i32 atomicrmw with RV32A
authorAlex Bradbury <asb@lowrisc.org>
Wed, 19 Sep 2018 10:54:22 +0000 (10:54 +0000)
committerAlex Bradbury <asb@lowrisc.org>
Wed, 19 Sep 2018 10:54:22 +0000 (10:54 +0000)
commit21aea51e71614b15545c69f84310b938520b069c
tree628636b1c733777c5152513fba3c7bc2da48b37a
parente8d8aee537d4c2ecee173a46d14b7720b200bf64
[RISCV] Codegen for i8, i16, and i32 atomicrmw with RV32A

Introduce a new RISCVExpandPseudoInsts pass to expand atomic
pseudo-instructions after register allocation. This is necessary in order to
ensure that register spills aren't introduced between LL and SC, thus breaking
the forward progress guarantee for the operation. AArch64 does something
similar for CmpXchg (though only at O0), and Mips is moving towards this
approach (see D31287). See also [this mailing list
post](http://lists.llvm.org/pipermail/llvm-dev/2016-May/099490.html) from
James Knight, which summarises the issues with lowering to ll/sc in IR or
pre-RA.

See the [accompanying RFC
thread](http://lists.llvm.org/pipermail/llvm-dev/2018-June/123993.html) for an
overview of the lowering strategy.

Differential Revision: https://reviews.llvm.org/D47882

llvm-svn: 342534
13 files changed:
llvm/include/llvm/CodeGen/TargetLowering.h
llvm/include/llvm/IR/Intrinsics.td
llvm/include/llvm/IR/IntrinsicsRISCV.td [new file with mode: 0644]
llvm/lib/CodeGen/AtomicExpandPass.cpp
llvm/lib/Target/RISCV/CMakeLists.txt
llvm/lib/Target/RISCV/RISCV.h
llvm/lib/Target/RISCV/RISCVExpandPseudoInsts.cpp [new file with mode: 0644]
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVISelLowering.h
llvm/lib/Target/RISCV/RISCVInstrInfo.td
llvm/lib/Target/RISCV/RISCVInstrInfoA.td
llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
llvm/test/CodeGen/RISCV/atomic-rmw.ll