llvm-project/llvm/lib/Target/BPF
Yonghong Song 286daafd65 [BPF] support atomic instructions
Implement fetch_<op>/fetch_and_<op>/exchange/compare-and-exchange
instructions for BPF.  Specially, the following gcc intrinsics
are implemented.
  __sync_fetch_and_add (32, 64)
  __sync_fetch_and_sub (32, 64)
  __sync_fetch_and_and (32, 64)
  __sync_fetch_and_or  (32, 64)
  __sync_fetch_and_xor (32, 64)
  __sync_lock_test_and_set (32, 64)
  __sync_val_compare_and_swap (32, 64)

For __sync_fetch_and_sub, internally, it is implemented as
a negation followed by __sync_fetch_and_add.
For __sync_lock_test_and_set, despite its name, it actually
does an atomic exchange and return the old content.
  https://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Atomic-Builtins.html

For intrinsics like __sync_{add,sub}_and_fetch and
__sync_bool_compare_and_swap, the compiler is able to generate
codes using __sync_fetch_and_{add,sub} and __sync_val_compare_and_swap.

Similar to xadd, atomic xadd, xor and xxor (atomic_<op>)
instructions are added for atomic operations which do not
have return values. LLVM will check the return value for
__sync_fetch_and_{add,and,or,xor}.
If the return value is used, instructions atomic_fetch_<op>
will be used. Otherwise, atomic_<op> instructions will be used.

All new instructions only support 64bit and 32bit with alu32 mode.
old xadd instruction still supports 32bit without alu32 mode.

For encoding, please take a look at test atomics_2.ll.

Differential Revision: https://reviews.llvm.org/D72184
2020-12-03 07:38:00 -08:00
..
AsmParser llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
Disassembler [BPF] support atomic instructions 2020-12-03 07:38:00 -08:00
MCTargetDesc [BPF] support atomic instructions 2020-12-03 07:38:00 -08:00
TargetInfo llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
BPF.h [BPF][NewPM] Port bpf-adjust-opt to NPM and add it to pipeline 2020-11-26 10:11:26 -08:00
BPF.td
BPFAbstractMemberAccess.cpp BPF: avoid duplicated globals for CORE relocations 2020-10-06 22:37:49 -07:00
BPFAdjustOpt.cpp [BPF][NewPM] Port bpf-adjust-opt to NPM and add it to pipeline 2020-11-26 10:11:26 -08:00
BPFAsmPrinter.cpp
BPFCORE.h BPF: move AbstractMemberAccess and PreserveDIType passes to EP_EarlyAsPossible 2020-09-28 16:56:22 -07:00
BPFCallingConv.td
BPFCheckAndAdjustIR.cpp BPF: move AbstractMemberAccess and PreserveDIType passes to EP_EarlyAsPossible 2020-09-28 16:56:22 -07:00
BPFFrameLowering.cpp
BPFFrameLowering.h
BPFISelDAGToDAG.cpp BPF: fix incorrect DAG2DAG load optimization 2020-10-07 19:08:40 -07:00
BPFISelLowering.cpp [NFC] remove unused includes of SelectionDAGISel.h 2020-07-20 10:43:29 -07:00
BPFISelLowering.h
BPFInstrFormats.td [BPF] support atomic instructions 2020-12-03 07:38:00 -08:00
BPFInstrInfo.cpp
BPFInstrInfo.h
BPFInstrInfo.td [BPF] support atomic instructions 2020-12-03 07:38:00 -08:00
BPFMCInstLower.cpp
BPFMCInstLower.h
BPFMIChecking.cpp [BPF] support atomic instructions 2020-12-03 07:38:00 -08:00
BPFMIPeephole.cpp
BPFMISimplifyPatchable.cpp
BPFPreserveDIType.cpp BPF: make __builtin_btf_type_id() return 64bit int 2020-11-16 07:08:41 -08:00
BPFRegisterInfo.cpp
BPFRegisterInfo.h
BPFRegisterInfo.td
BPFSelectionDAGInfo.cpp [Alignment][NFC] Migrate SelectionDAGTargetInfo::EmitTargetCodeForMemcpy to Align 2020-06-30 13:12:31 +00:00
BPFSelectionDAGInfo.h [Alignment][NFC] Migrate SelectionDAGTargetInfo::EmitTargetCodeForMemcpy to Align 2020-06-30 13:12:31 +00:00
BPFSubtarget.cpp [X86][MC][Target] Initial backend support a tune CPU to support -mtune 2020-08-14 15:31:50 -07:00
BPFSubtarget.h [X86][MC][Target] Initial backend support a tune CPU to support -mtune 2020-08-14 15:31:50 -07:00
BPFTargetMachine.cpp [BPF][NewPM] Port bpf-adjust-opt to NPM and add it to pipeline 2020-11-26 10:11:26 -08:00
BPFTargetMachine.h [BPF][NewPM] Make BPFTargetMachine properly adjust NPM optimizer pipeline 2020-10-06 07:42:32 -07:00
BTF.def
BTF.h
BTFDebug.cpp BPF: make __builtin_btf_type_id() return 64bit int 2020-11-16 07:08:41 -08:00
BTFDebug.h BTFDebug.h - reduce MachineInstr.h include to forward declaration. NFCI. 2020-09-07 17:51:13 +01:00
CMakeLists.txt llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00