llvm.org GIT mirror llvm / ec4b6d9
[WebAssembly] Revert type of wake count in atomic.wake to i32 Summary: We decided to revert this from i64 to i32 in Nov 28 CG meeting. Fixes PR38632. Reviewers: dschuff Subscribers: sbc100, jgravelle-google, sunfish, jfb, llvm-commits Differential Revision: https://reviews.llvm.org/D51010 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340234 91177308-0d34-0410-b5e6-96231b3b80d8 Heejin Ahn 1 year, 7 months ago
3 changed file(s) with 48 addition(s) and 48 deletion(s). Raw diff Collapse all Expand all
8282 IntrHasSideEffects],
8383 "", [SDNPMemOperand]>;
8484 def int_wasm_atomic_notify:
85 Intrinsic<[llvm_i64_ty], [LLVMPointerType, llvm_i64_ty],
85 Intrinsic<[llvm_i32_ty], [LLVMPointerType, llvm_i32_ty],
8686 [IntrInaccessibleMemOnly, NoCapture<0>, IntrHasSideEffects], "",
8787 [SDNPMemOperand]>;
8888
906906 let Defs = [ARGUMENTS] in {
907907 let hasSideEffects = 1 in {
908908 defm ATOMIC_NOTIFY :
909 I<(outs I64:$dst),
910 (ins P2Align:$p2align, offset32_op:$off, I32:$addr, I64:$count),
909 I<(outs I32:$dst),
910 (ins P2Align:$p2align, offset32_op:$off, I32:$addr, I32:$count),
911911 (outs), (ins P2Align:$p2align, offset32_op:$off), [],
912912 "atomic.notify \t$dst, ${off}(${addr})${p2align}, $count",
913913 "atomic.notify \t${off}, ${p2align}", 0xfe00>;
931931 let Predicates = [HasAtomics] in {
932932 // Select notifys with no constant offset.
933933 class NotifyPatNoOffset :
934 Pat<(i64 (kind I32:$addr, I64:$count)),
935 (ATOMIC_NOTIFY 0, 0, I32:$addr, I64:$count)>;
934 Pat<(i32 (kind I32:$addr, I32:$count)),
935 (ATOMIC_NOTIFY 0, 0, I32:$addr, I32:$count)>;
936936 def : NotifyPatNoOffset;
937937
938938 // Select notifys with a constant offset.
939939
940940 // Pattern with address + immediate offset
941941 class NotifyPatImmOff :
942 Pat<(i64 (kind (operand I32:$addr, imm:$off), I64:$count)),
943 (ATOMIC_NOTIFY 0, imm:$off, I32:$addr, I64:$count)>;
942 Pat<(i32 (kind (operand I32:$addr, imm:$off), I32:$count)),
943 (ATOMIC_NOTIFY 0, imm:$off, I32:$addr, I32:$count)>;
944944 def : NotifyPatImmOff;
945945 def : NotifyPatImmOff;
946946
947947 class NotifyPatGlobalAddr :
948 Pat<(i64 (kind (regPlusGA I32:$addr, (WebAssemblywrapper tglobaladdr:$off)),
949 I64:$count)),
950 (ATOMIC_NOTIFY 0, tglobaladdr:$off, I32:$addr, I64:$count)>;
948 Pat<(i32 (kind (regPlusGA I32:$addr, (WebAssemblywrapper tglobaladdr:$off)),
949 I32:$count)),
950 (ATOMIC_NOTIFY 0, tglobaladdr:$off, I32:$addr, I32:$count)>;
951951 def : NotifyPatGlobalAddr;
952952
953953 class NotifyPatExternalSym :
954 Pat<(i64 (kind (add I32:$addr, (WebAssemblywrapper texternalsym:$off)),
955 I64:$count)),
956 (ATOMIC_NOTIFY 0, texternalsym:$off, I32:$addr, I64:$count)>;
954 Pat<(i32 (kind (add I32:$addr, (WebAssemblywrapper texternalsym:$off)),
955 I32:$count)),
956 (ATOMIC_NOTIFY 0, texternalsym:$off, I32:$addr, I32:$count)>;
957957 def : NotifyPatExternalSym;
958958
959959 // Select notifys with just a constant offset.
960960 class NotifyPatOffsetOnly :
961 Pat<(i64 (kind imm:$off, I64:$count)),
962 (ATOMIC_NOTIFY 0, imm:$off, (CONST_I32 0), I64:$count)>;
961 Pat<(i32 (kind imm:$off, I32:$count)),
962 (ATOMIC_NOTIFY 0, imm:$off, (CONST_I32 0), I32:$count)>;
963963 def : NotifyPatOffsetOnly;
964964
965965 class NotifyPatGlobalAddrOffOnly :
966 Pat<(i64 (kind (WebAssemblywrapper tglobaladdr:$off), I64:$count)),
967 (ATOMIC_NOTIFY 0, tglobaladdr:$off, (CONST_I32 0), I64:$count)>;
966 Pat<(i32 (kind (WebAssemblywrapper tglobaladdr:$off), I32:$count)),
967 (ATOMIC_NOTIFY 0, tglobaladdr:$off, (CONST_I32 0), I32:$count)>;
968968 def : NotifyPatGlobalAddrOffOnly;
969969
970970 class NotifyPatExternSymOffOnly :
971 Pat<(i64 (kind (WebAssemblywrapper texternalsym:$off), I64:$count)),
972 (ATOMIC_NOTIFY 0, texternalsym:$off, (CONST_I32 0), I64:$count)>;
971 Pat<(i32 (kind (WebAssemblywrapper texternalsym:$off), I32:$count)),
972 (ATOMIC_NOTIFY 0, texternalsym:$off, (CONST_I32 0), I32:$count)>;
973973 def : NotifyPatExternSymOffOnly;
974974
975975 // Select waits with no constant offset.
17001700 ; Notifies
17011701 ;===----------------------------------------------------------------------------
17021702
1703 declare i64 @llvm.wasm.atomic.notify(i32*, i64)
1703 declare i32 @llvm.wasm.atomic.notify(i32*, i32)
17041704
17051705 ; Basic notify.
17061706
17071707 ; CHECK-LABEL: notify_no_offset:
17081708 ; CHECK: atomic.notify $push0=, 0($0), $1{{$}}
17091709 ; CHECK-NEXT: return $pop0{{$}}
1710 define i64 @notify_no_offset(i32* %p, i64 %notify_count) {
1711 %v = call i64 @llvm.wasm.atomic.notify(i32* %p, i64 %notify_count)
1712 ret i64 %v
1710 define i32 @notify_no_offset(i32* %p, i32 %notify_count) {
1711 %v = call i32 @llvm.wasm.atomic.notify(i32* %p, i32 %notify_count)
1712 ret i32 %v
17131713 }
17141714
17151715 ; With an nuw add, we can fold an offset.
17161716
17171717 ; CHECK-LABEL: notify_with_folded_offset:
17181718 ; CHECK: atomic.notify $push0=, 24($0), $1{{$}}
1719 define i64 @notify_with_folded_offset(i32* %p, i64 %notify_count) {
1720 %q = ptrtoint i32* %p to i32
1721 %r = add nuw i32 %q, 24
1722 %s = inttoptr i32 %r to i32*
1723 %t = call i64 @llvm.wasm.atomic.notify(i32* %s, i64 %notify_count)
1724 ret i64 %t
1719 define i32 @notify_with_folded_offset(i32* %p, i32 %notify_count) {
1720 %q = ptrtoint i32* %p to i32
1721 %r = add nuw i32 %q, 24
1722 %s = inttoptr i32 %r to i32*
1723 %t = call i32 @llvm.wasm.atomic.notify(i32* %s, i32 %notify_count)
1724 ret i32 %t
17251725 }
17261726
17271727 ; With an inbounds gep, we can fold an offset.
17281728
17291729 ; CHECK-LABEL: notify_with_folded_gep_offset:
17301730 ; CHECK: atomic.notify $push0=, 24($0), $1{{$}}
1731 define i64 @notify_with_folded_gep_offset(i32* %p, i64 %notify_count) {
1731 define i32 @notify_with_folded_gep_offset(i32* %p, i32 %notify_count) {
17321732 %s = getelementptr inbounds i32, i32* %p, i32 6
1733 %t = call i64 @llvm.wasm.atomic.notify(i32* %s, i64 %notify_count)
1734 ret i64 %t
1733 %t = call i32 @llvm.wasm.atomic.notify(i32* %s, i32 %notify_count)
1734 ret i32 %t
17351735 }
17361736
17371737 ; We can't fold a negative offset though, even with an inbounds gep.
17401740 ; CHECK: i32.const $push0=, -24{{$}}
17411741 ; CHECK: i32.add $push1=, $0, $pop0{{$}}
17421742 ; CHECK: atomic.notify $push2=, 0($pop1), $1{{$}}
1743 define i64 @notify_with_unfolded_gep_negative_offset(i32* %p, i64 %notify_count) {
1743 define i32 @notify_with_unfolded_gep_negative_offset(i32* %p, i32 %notify_count) {
17441744 %s = getelementptr inbounds i32, i32* %p, i32 -6
1745 %t = call i64 @llvm.wasm.atomic.notify(i32* %s, i64 %notify_count)
1746 ret i64 %t
1745 %t = call i32 @llvm.wasm.atomic.notify(i32* %s, i32 %notify_count)
1746 ret i32 %t
17471747 }
17481748
17491749 ; Without nuw, and even with nsw, we can't fold an offset.
17521752 ; CHECK: i32.const $push0=, 24{{$}}
17531753 ; CHECK: i32.add $push1=, $0, $pop0{{$}}
17541754 ; CHECK: atomic.notify $push2=, 0($pop1), $1{{$}}
1755 define i64 @notify_with_unfolded_offset(i32* %p, i64 %notify_count) {
1755 define i32 @notify_with_unfolded_offset(i32* %p, i32 %notify_count) {
17561756 %q = ptrtoint i32* %p to i32
17571757 %r = add nsw i32 %q, 24
17581758 %s = inttoptr i32 %r to i32*
1759 %t = call i64 @llvm.wasm.atomic.notify(i32* %s, i64 %notify_count)
1760 ret i64 %t
1759 %t = call i32 @llvm.wasm.atomic.notify(i32* %s, i32 %notify_count)
1760 ret i32 %t
17611761 }
17621762
17631763 ; Without inbounds, we can't fold a gep offset.
17661766 ; CHECK: i32.const $push0=, 24{{$}}
17671767 ; CHECK: i32.add $push1=, $0, $pop0{{$}}
17681768 ; CHECK: atomic.notify $push2=, 0($pop1), $1{{$}}
1769 define i64 @notify_with_unfolded_gep_offset(i32* %p, i64 %notify_count) {
1769 define i32 @notify_with_unfolded_gep_offset(i32* %p, i32 %notify_count) {
17701770 %s = getelementptr i32, i32* %p, i32 6
1771 %t = call i64 @llvm.wasm.atomic.notify(i32* %s, i64 %notify_count)
1772 ret i64 %t
1771 %t = call i32 @llvm.wasm.atomic.notify(i32* %s, i32 %notify_count)
1772 ret i32 %t
17731773 }
17741774
17751775 ; When notifying from a fixed address, materialize a zero.
17771777 ; CHECK-LABEL: notify_from_numeric_address
17781778 ; CHECK: i32.const $push0=, 0{{$}}
17791779 ; CHECK: atomic.notify $push1=, 42($pop0), $0{{$}}
1780 define i64 @notify_from_numeric_address(i64 %notify_count) {
1780 define i32 @notify_from_numeric_address(i32 %notify_count) {
17811781 %s = inttoptr i32 42 to i32*
1782 %t = call i64 @llvm.wasm.atomic.notify(i32* %s, i64 %notify_count)
1783 ret i64 %t
1782 %t = call i32 @llvm.wasm.atomic.notify(i32* %s, i32 %notify_count)
1783 ret i32 %t
17841784 }
17851785
17861786 ; CHECK-LABEL: notify_from_global_address
17871787 ; CHECK: i32.const $push0=, 0{{$}}
17881788 ; CHECK: atomic.notify $push1=, gv($pop0), $0{{$}}
1789 define i64 @notify_from_global_address(i64 %notify_count) {
1790 %t = call i64 @llvm.wasm.atomic.notify(i32* @gv, i64 %notify_count)
1791 ret i64 %t
1792 }
1789 define i32 @notify_from_global_address(i32 %notify_count) {
1790 %t = call i32 @llvm.wasm.atomic.notify(i32* @gv, i32 %notify_count)
1791 ret i32 %t
1792 }