llvm-project/llvm/test/CodeGen/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
..
BTF BPF: make __builtin_btf_type_id() return 64bit int 2020-11-16 07:08:41 -08:00
CORE BPF: make __builtin_btf_type_id() return 64bit int 2020-11-16 07:08:41 -08:00
32-bit-subreg-alu.ll
32-bit-subreg-cond-select.ll [BPF] simplify zero extension with MOV_32_64 2020-05-27 11:26:39 -07:00
32-bit-subreg-load-store.ll
32-bit-subreg-peephole-phi-1.ll [BPF] simplify zero extension with MOV_32_64 2020-05-27 11:26:39 -07:00
32-bit-subreg-peephole-phi-2.ll [BPF] simplify zero extension with MOV_32_64 2020-05-27 11:26:39 -07:00
32-bit-subreg-peephole-phi-3.ll [BPF] simplify zero extension with MOV_32_64 2020-05-27 11:26:39 -07:00
32-bit-subreg-peephole.ll [BPF] simplify zero extension with MOV_32_64 2020-05-27 11:26:39 -07:00
32-bit-subreg-zext.ll [BPF] simplify zero extension with MOV_32_64 2020-05-27 11:26:39 -07:00
adjust-opt-icmp1.ll [BPF][NewPM] Port bpf-adjust-opt to NPM and add it to pipeline 2020-11-26 10:11:26 -08:00
adjust-opt-icmp2.ll BPF: add AdjustOpt IR pass to generate verifier friendly codes 2020-10-07 08:49:10 -07:00
adjust-opt-speculative1.ll BPF: add AdjustOpt IR pass to generate verifier friendly codes 2020-10-07 08:49:10 -07:00
adjust-opt-speculative2.ll BPF: add AdjustOpt IR pass to generate verifier friendly codes 2020-10-07 08:49:10 -07:00
alu8.ll
atomics.ll [BPF] support atomic instructions 2020-12-03 07:38:00 -08:00
atomics_2.ll [BPF] support atomic instructions 2020-12-03 07:38:00 -08:00
basictest.ll
byval.ll OpaquePtr: Bulk update tests to use typed byval 2020-11-20 14:00:46 -05:00
callx.ll
cc_args.ll
cc_args_be.ll
cc_ret.ll
cmp.ll
dwarfdump.ll
elf-symbol-information.ll [llvm-readobj] Update tests because of changes in llvm-readobj behavior 2020-07-20 10:39:04 +01:00
ex1.ll
fi_ri.ll
i128.ll [BPF] support 128bit int explicitly in layout spec 2020-03-28 11:46:29 -07:00
inline_asm.ll
inlineasm-output-template.ll
intrinsics.ll
is_trunc_free.ll [BPF] implement isTruncateFree and isZExtFree in BPFTargetLowering 2020-02-11 09:59:19 -08:00
is_zext_free.ll [BPF] implement isTruncateFree and isZExtFree in BPFTargetLowering 2020-02-11 09:59:19 -08:00
lit.local.cfg
load.ll
loops.ll
many_args1.ll
many_args2.ll
mem_offset.ll
mem_offset_be.ll
memcpy-expand-in-order.ll
objdump_atomics.ll
objdump_cond_op.ll [llvm-objdump] -d: print `00000000 <foo>:` instead of `00000000 foo:` 2020-03-05 18:05:28 -08:00
objdump_cond_op_2.ll [llvm-objdump] -d: print `00000000 <foo>:` instead of `00000000 foo:` 2020-03-05 18:05:28 -08:00
objdump_dis_all.ll [BPF] Return fail if disassembled insn registers out of range 2020-05-18 18:53:23 -07:00
objdump_imm_hex.ll [test] llvm/test/: change llvm-objdump single-dash long options to double-dash options 2020-03-15 17:46:23 -07:00
objdump_intrinsics.ll
objdump_nop.ll [BPF] Prevent disassembly segfault for NOP insn 2020-05-18 17:40:18 -07:00
objdump_static_var.ll
objdump_trivial.ll
objdump_two_funcs.ll [llvm-objdump] -d: print `00000000 <foo>:` instead of `00000000 foo:` 2020-03-05 18:05:28 -08:00
optnone-1.ll
optnone-2.ll BPF: make __builtin_btf_type_id() return 64bit int 2020-11-16 07:08:41 -08:00
reloc-btf-2.ll [llvm-objdump] Print file format in lowercase to match GNU output. 2020-02-12 08:17:01 -08:00
reloc-btf.ll [llvm-objdump] Print file format in lowercase to match GNU output. 2020-02-12 08:17:01 -08:00
reloc.ll [llvm-objdump] Print file format in lowercase to match GNU output. 2020-02-12 08:17:01 -08:00
remove_truncate_1.ll
remove_truncate_2.ll
remove_truncate_3.ll
remove_truncate_4.ll
remove_truncate_5.ll
remove_truncate_6.ll
remove_truncate_7.ll [BPF] Remove unnecessary MOV_32_64 instructions 2020-06-03 08:14:54 -07:00
rodata_1.ll
rodata_2.ll
rodata_3.ll
rodata_4.ll [llvm] Fix missing FileCheck directive colons 2020-04-06 09:59:08 -06:00
rodata_5.ll [BPF] fix incorrect type in BPFISelDAGToDAG readonly load optimization 2020-06-11 19:31:06 -07:00
rodata_6.ll BPF: fix incorrect DAG2DAG load optimization 2020-10-07 19:08:40 -07:00
rodata_7.ll BPF: fix incorrect DAG2DAG load optimization 2020-10-07 19:08:40 -07:00
sanity.ll
sdiv_error.ll Revert "Revert "Reland "[Support] make report_fatal_error `abort` instead of `exit`""" 2020-02-13 10:16:06 -08:00
select_ri.ll
selectiondag-bug.ll BPF: add a test for selectiondag alias analysis w.r.t. lifetime 2020-12-02 22:27:17 -08:00
setcc.ll
shifts.ll
simplifycfg.ll BPF: add a SimplifyCFG IR pass during generic Scalar/IPO optimization 2020-08-06 13:16:00 -07:00
sockex2.ll
struct_ret1.ll
struct_ret2.ll
undef.ll
vararg1.ll
warn-call.ll
warn-stack.ll
xadd.ll [BPF] support atomic instructions 2020-12-03 07:38:00 -08:00
xadd_legal.ll