2016-06-24 20:23:17 +08:00
|
|
|
; RUN: llc -march=mipsel --disable-machine-licm -mcpu=mips32 -relocation-model=pic < %s | \
|
|
|
|
; RUN: FileCheck %s -check-prefixes=ALL,MIPS32-ANY,NO-SEB-SEH,CHECK-EL,NOT-MICROMIPS
|
|
|
|
; RUN: llc -march=mipsel --disable-machine-licm -mcpu=mips32r2 -relocation-model=pic -verify-machineinstrs < %s | \
|
|
|
|
; RUN: FileCheck %s -check-prefixes=ALL,MIPS32-ANY,HAS-SEB-SEH,CHECK-EL,NOT-MICROMIPS
|
|
|
|
; RUN: llc -march=mipsel --disable-machine-licm -mcpu=mips32r6 -relocation-model=pic -verify-machineinstrs < %s | \
|
|
|
|
; RUN: FileCheck %s -check-prefixes=ALL,MIPS32-ANY,HAS-SEB-SEH,CHECK-EL,MIPSR6
|
|
|
|
; RUN: llc -march=mips64el --disable-machine-licm -mcpu=mips4 -relocation-model=pic < %s | \
|
|
|
|
; RUN: FileCheck %s -check-prefixes=ALL,MIPS64-ANY,NO-SEB-SEH,CHECK-EL,NOT-MICROMIPS
|
|
|
|
; RUN: llc -march=mips64el --disable-machine-licm -mcpu=mips64 -relocation-model=pic < %s | \
|
|
|
|
; RUN: FileCheck %s -check-prefixes=ALL,MIPS64-ANY,NO-SEB-SEH,CHECK-EL,NOT-MICROMIPS
|
|
|
|
; RUN: llc -march=mips64el --disable-machine-licm -mcpu=mips64r2 -relocation-model=pic -verify-machineinstrs < %s | \
|
|
|
|
; RUN: FileCheck %s -check-prefixes=ALL,MIPS64-ANY,HAS-SEB-SEH,CHECK-EL,NOT-MICROMIPS
|
|
|
|
; RUN: llc -march=mips64el --disable-machine-licm -mcpu=mips64r6 -relocation-model=pic < %s | \
|
|
|
|
; RUN: FileCheck %s -check-prefixes=ALL,MIPS64-ANY,HAS-SEB-SEH,CHECK-EL,MIPSR6
|
|
|
|
; RUN: llc -march=mips64 -O0 -mcpu=mips64r6 -relocation-model=pic -verify-machineinstrs < %s | \
|
|
|
|
; RUN: FileCheck %s -check-prefixes=ALL-LABEL,MIPS64-ANY,O0
|
|
|
|
; RUN: llc -march=mipsel --disable-machine-licm -mcpu=mips32r2 -mattr=micromips -relocation-model=pic < %s | \
|
|
|
|
; RUN: FileCheck %s -check-prefixes=ALL,MIPS32-ANY,HAS-SEB-SEH,CHECK-EL,MICROMIPS
|
2014-06-16 21:13:03 +08:00
|
|
|
|
|
|
|
; Keep one big-endian check so that we don't reduce testing, but don't add more
|
|
|
|
; since endianness doesn't affect the body of the atomic operations.
|
2016-06-24 20:23:17 +08:00
|
|
|
; RUN: llc -march=mips --disable-machine-licm -mcpu=mips32 -relocation-model=pic < %s | \
|
|
|
|
; RUN: FileCheck %s -check-prefixes=ALL,MIPS32-ANY,NO-SEB-SEH,CHECK-EB,NOT-MICROMIPS
|
2011-05-31 10:54:07 +08:00
|
|
|
|
|
|
|
@x = common global i32 0, align 4
|
|
|
|
|
2014-11-08 00:54:21 +08:00
|
|
|
define i32 @AtomicLoadAdd32(i32 signext %incr) nounwind {
|
2011-05-31 10:54:07 +08:00
|
|
|
entry:
|
2011-09-27 04:27:49 +08:00
|
|
|
%0 = atomicrmw add i32* @x, i32 %incr monotonic
|
2011-05-31 10:54:07 +08:00
|
|
|
ret i32 %0
|
|
|
|
|
2014-06-16 18:25:17 +08:00
|
|
|
; ALL-LABEL: AtomicLoadAdd32:
|
|
|
|
|
2014-06-16 21:13:03 +08:00
|
|
|
; MIPS32-ANY: lw $[[R0:[0-9]+]], %got(x)
|
|
|
|
; MIPS64-ANY: ld $[[R0:[0-9]+]], %got_disp(x)(
|
|
|
|
|
2016-07-19 18:49:03 +08:00
|
|
|
; O0: [[BB0:(\$|\.L)[A-Z_0-9]+]]:
|
2016-04-29 00:26:43 +08:00
|
|
|
; O0: ld $[[R1:[0-9]+]]
|
|
|
|
; O0-NEXT: ll $[[R2:[0-9]+]], 0($[[R1]])
|
|
|
|
|
2016-07-19 18:49:03 +08:00
|
|
|
; ALL: [[BB0:(\$|\.L)[A-Z_0-9]+]]:
|
2016-04-29 00:26:43 +08:00
|
|
|
; ALL: ll $[[R3:[0-9]+]], 0($[[R0]])
|
|
|
|
; ALL: addu $[[R4:[0-9]+]], $[[R3]], $4
|
|
|
|
; ALL: sc $[[R4]], 0($[[R0]])
|
2016-07-19 18:49:03 +08:00
|
|
|
; NOT-MICROMIPS: beqz $[[R4]], [[BB0]]
|
|
|
|
; MICROMIPS: beqzc $[[R4]], [[BB0]]
|
|
|
|
; MIPSR6: beqzc $[[R4]], [[BB0]]
|
2011-05-31 10:54:07 +08:00
|
|
|
}
|
|
|
|
|
2014-11-08 00:54:21 +08:00
|
|
|
define i32 @AtomicLoadNand32(i32 signext %incr) nounwind {
|
2011-05-31 10:54:07 +08:00
|
|
|
entry:
|
2011-09-27 04:27:49 +08:00
|
|
|
%0 = atomicrmw nand i32* @x, i32 %incr monotonic
|
2011-05-31 10:54:07 +08:00
|
|
|
ret i32 %0
|
|
|
|
|
2014-06-16 18:25:17 +08:00
|
|
|
; ALL-LABEL: AtomicLoadNand32:
|
|
|
|
|
2014-06-16 21:13:03 +08:00
|
|
|
; MIPS32-ANY: lw $[[R0:[0-9]+]], %got(x)
|
|
|
|
; MIPS64-ANY: ld $[[R0:[0-9]+]], %got_disp(x)(
|
|
|
|
|
2016-04-29 00:26:43 +08:00
|
|
|
|
|
|
|
|
2016-07-19 18:49:03 +08:00
|
|
|
; ALL: [[BB0:(\$|\.L)[A-Z_0-9]+]]:
|
2014-06-16 18:25:17 +08:00
|
|
|
; ALL: ll $[[R1:[0-9]+]], 0($[[R0]])
|
|
|
|
; ALL: and $[[R3:[0-9]+]], $[[R1]], $4
|
|
|
|
; ALL: nor $[[R2:[0-9]+]], $zero, $[[R3]]
|
|
|
|
; ALL: sc $[[R2]], 0($[[R0]])
|
2016-07-19 18:49:03 +08:00
|
|
|
; NOT-MICROMIPS: beqz $[[R2]], [[BB0]]
|
|
|
|
; MICROMIPS: beqzc $[[R2]], [[BB0]]
|
|
|
|
; MIPSR6: beqzc $[[R2]], [[BB0]]
|
2011-05-31 10:54:07 +08:00
|
|
|
}
|
|
|
|
|
2014-11-08 00:54:21 +08:00
|
|
|
define i32 @AtomicSwap32(i32 signext %newval) nounwind {
|
2011-05-31 10:54:07 +08:00
|
|
|
entry:
|
2011-07-19 02:52:12 +08:00
|
|
|
%newval.addr = alloca i32, align 4
|
|
|
|
store i32 %newval, i32* %newval.addr, align 4
|
2015-02-28 05:17:42 +08:00
|
|
|
%tmp = load i32, i32* %newval.addr, align 4
|
2011-09-27 04:27:49 +08:00
|
|
|
%0 = atomicrmw xchg i32* @x, i32 %tmp monotonic
|
2011-05-31 10:54:07 +08:00
|
|
|
ret i32 %0
|
|
|
|
|
2014-06-16 18:25:17 +08:00
|
|
|
; ALL-LABEL: AtomicSwap32:
|
|
|
|
|
2014-06-16 21:13:03 +08:00
|
|
|
; MIPS32-ANY: lw $[[R0:[0-9]+]], %got(x)
|
|
|
|
; MIPS64-ANY: ld $[[R0:[0-9]+]], %got_disp(x)
|
|
|
|
|
2016-07-19 18:49:03 +08:00
|
|
|
; ALL: [[BB0:(\$|\.L)[A-Z_0-9]+]]:
|
2014-06-16 18:25:17 +08:00
|
|
|
; ALL: ll ${{[0-9]+}}, 0($[[R0]])
|
|
|
|
; ALL: sc $[[R2:[0-9]+]], 0($[[R0]])
|
2016-07-19 18:49:03 +08:00
|
|
|
; NOT-MICROMIPS: beqz $[[R2]], [[BB0]]
|
|
|
|
; MICROMIPS: beqzc $[[R2]], [[BB0]]
|
|
|
|
; MIPSR6: beqzc $[[R2]], [[BB0]]
|
2011-05-31 10:54:07 +08:00
|
|
|
}
|
|
|
|
|
2014-11-08 00:54:21 +08:00
|
|
|
define i32 @AtomicCmpSwap32(i32 signext %oldval, i32 signext %newval) nounwind {
|
2011-05-31 10:54:07 +08:00
|
|
|
entry:
|
2011-07-19 02:52:12 +08:00
|
|
|
%newval.addr = alloca i32, align 4
|
|
|
|
store i32 %newval, i32* %newval.addr, align 4
|
2015-02-28 05:17:42 +08:00
|
|
|
%tmp = load i32, i32* %newval.addr, align 4
|
2014-03-11 18:48:52 +08:00
|
|
|
%0 = cmpxchg i32* @x, i32 %oldval, i32 %tmp monotonic monotonic
|
IR: add "cmpxchg weak" variant to support permitted failure.
This commit adds a weak variant of the cmpxchg operation, as described
in C++11. A cmpxchg instruction with this modifier is permitted to
fail to store, even if the comparison indicated it should.
As a result, cmpxchg instructions must return a flag indicating
success in addition to their original iN value loaded. Thus, for
uniformity *all* cmpxchg instructions now return "{ iN, i1 }". The
second flag is 1 when the store succeeded.
At the DAG level, a new ATOMIC_CMP_SWAP_WITH_SUCCESS node has been
added as the natural representation for the new cmpxchg instructions.
It is a strong cmpxchg.
By default this gets Expanded to the existing ATOMIC_CMP_SWAP during
Legalization, so existing backends should see no change in behaviour.
If they wish to deal with the enhanced node instead, they can call
setOperationAction on it. Beware: as a node with 2 results, it cannot
be selected from TableGen.
Currently, no use is made of the extra information provided in this
patch. Test updates are almost entirely adapting the input IR to the
new scheme.
Summary for out of tree users:
------------------------------
+ Legacy Bitcode files are upgraded during read.
+ Legacy assembly IR files will be invalid.
+ Front-ends must adapt to different type for "cmpxchg".
+ Backends should be unaffected by default.
llvm-svn: 210903
2014-06-13 22:24:07 +08:00
|
|
|
%1 = extractvalue { i32, i1 } %0, 0
|
|
|
|
ret i32 %1
|
2011-05-31 10:54:07 +08:00
|
|
|
|
2014-06-16 18:25:17 +08:00
|
|
|
; ALL-LABEL: AtomicCmpSwap32:
|
|
|
|
|
2014-06-16 21:13:03 +08:00
|
|
|
; MIPS32-ANY: lw $[[R0:[0-9]+]], %got(x)
|
|
|
|
; MIPS64-ANY: ld $[[R0:[0-9]+]], %got_disp(x)(
|
|
|
|
|
2016-07-19 18:49:03 +08:00
|
|
|
; ALL: [[BB0:(\$|\.L)[A-Z_0-9]+]]:
|
2014-06-16 18:25:17 +08:00
|
|
|
; ALL: ll $2, 0($[[R0]])
|
2016-07-19 18:49:03 +08:00
|
|
|
; NOT-MICROMIPS: bne $2, $4, [[BB1:(\$|\.L)[A-Z_0-9]+]]
|
|
|
|
; MICROMIPS: bne $2, $4, [[BB1:(\$|\.L)[A-Z_0-9]+]]
|
|
|
|
; MIPSR6: bnec $2, $4, [[BB1:(\$|\.L)[A-Z_0-9]+]]
|
2014-06-16 18:25:17 +08:00
|
|
|
; ALL: sc $[[R2:[0-9]+]], 0($[[R0]])
|
2016-07-19 18:49:03 +08:00
|
|
|
; NOT-MICROMIPS: beqz $[[R2]], [[BB0]]
|
|
|
|
; MICROMIPS: beqzc $[[R2]], [[BB0]]
|
|
|
|
; MIPSR6: beqzc $[[R2]], [[BB0]]
|
|
|
|
; ALL: [[BB1]]:
|
2011-05-31 10:54:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@y = common global i8 0, align 1
|
|
|
|
|
|
|
|
define signext i8 @AtomicLoadAdd8(i8 signext %incr) nounwind {
|
|
|
|
entry:
|
2011-09-27 04:27:49 +08:00
|
|
|
%0 = atomicrmw add i8* @y, i8 %incr monotonic
|
2011-05-31 10:54:07 +08:00
|
|
|
ret i8 %0
|
|
|
|
|
2014-06-16 18:25:17 +08:00
|
|
|
; ALL-LABEL: AtomicLoadAdd8:
|
|
|
|
|
2014-06-16 21:13:03 +08:00
|
|
|
; MIPS32-ANY: lw $[[R0:[0-9]+]], %got(y)
|
|
|
|
; MIPS64-ANY: ld $[[R0:[0-9]+]], %got_disp(y)(
|
|
|
|
|
2014-06-16 18:25:17 +08:00
|
|
|
; ALL: addiu $[[R1:[0-9]+]], $zero, -4
|
|
|
|
; ALL: and $[[R2:[0-9]+]], $[[R0]], $[[R1]]
|
|
|
|
; ALL: andi $[[R3:[0-9]+]], $[[R0]], 3
|
|
|
|
; CHECK-EB: xori $[[R4:[0-9]+]], $[[R3]], 3
|
|
|
|
; CHECK-EB: sll $[[R5:[0-9]+]], $[[R4]], 3
|
|
|
|
; CHECK-EL: sll $[[R5:[0-9]+]], $[[R3]], 3
|
|
|
|
; ALL: ori $[[R6:[0-9]+]], $zero, 255
|
|
|
|
; ALL: sllv $[[R7:[0-9]+]], $[[R6]], $[[R5]]
|
|
|
|
; ALL: nor $[[R8:[0-9]+]], $zero, $[[R7]]
|
|
|
|
; ALL: sllv $[[R9:[0-9]+]], $4, $[[R5]]
|
|
|
|
|
2016-07-19 18:49:03 +08:00
|
|
|
; O0: [[BB0:(\$|\.L)[A-Z_0-9]+]]:
|
2016-04-29 00:26:43 +08:00
|
|
|
; O0: ld $[[R10:[0-9]+]]
|
|
|
|
; O0-NEXT: ll $[[R11:[0-9]+]], 0($[[R10]])
|
|
|
|
|
2016-07-19 18:49:03 +08:00
|
|
|
; ALL: [[BB0:(\$|\.L)[A-Z_0-9]+]]:
|
2016-04-29 00:26:43 +08:00
|
|
|
; ALL: ll $[[R12:[0-9]+]], 0($[[R2]])
|
|
|
|
; ALL: addu $[[R13:[0-9]+]], $[[R12]], $[[R9]]
|
|
|
|
; ALL: and $[[R14:[0-9]+]], $[[R13]], $[[R7]]
|
|
|
|
; ALL: and $[[R15:[0-9]+]], $[[R12]], $[[R8]]
|
|
|
|
; ALL: or $[[R16:[0-9]+]], $[[R15]], $[[R14]]
|
|
|
|
; ALL: sc $[[R16]], 0($[[R2]])
|
2016-07-19 18:49:03 +08:00
|
|
|
; NOT-MICROMIPS: beqz $[[R16]], [[BB0]]
|
|
|
|
; MICROMIPS: beqzc $[[R16]], [[BB0]]
|
|
|
|
; MIPSR6: beqzc $[[R16]], [[BB0]]
|
2014-06-16 18:25:17 +08:00
|
|
|
|
2016-04-29 00:26:43 +08:00
|
|
|
; ALL: and $[[R17:[0-9]+]], $[[R12]], $[[R7]]
|
|
|
|
; ALL: srlv $[[R18:[0-9]+]], $[[R17]], $[[R5]]
|
2014-06-16 21:13:03 +08:00
|
|
|
|
2016-04-29 00:26:43 +08:00
|
|
|
; NO-SEB-SEH: sll $[[R19:[0-9]+]], $[[R18]], 24
|
|
|
|
; NO-SEB-SEH: sra $2, $[[R19]], 24
|
2014-06-16 21:13:03 +08:00
|
|
|
|
2016-04-29 00:26:43 +08:00
|
|
|
; HAS-SEB-SEH: seb $2, $[[R18]]
|
2011-05-31 10:54:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define signext i8 @AtomicLoadSub8(i8 signext %incr) nounwind {
|
|
|
|
entry:
|
2011-09-27 04:27:49 +08:00
|
|
|
%0 = atomicrmw sub i8* @y, i8 %incr monotonic
|
2011-05-31 10:54:07 +08:00
|
|
|
ret i8 %0
|
|
|
|
|
2014-06-16 18:25:17 +08:00
|
|
|
; ALL-LABEL: AtomicLoadSub8:
|
|
|
|
|
2014-06-16 21:13:03 +08:00
|
|
|
; MIPS32-ANY: lw $[[R0:[0-9]+]], %got(y)
|
|
|
|
; MIPS64-ANY: ld $[[R0:[0-9]+]], %got_disp(y)(
|
|
|
|
|
2014-06-16 18:25:17 +08:00
|
|
|
; ALL: addiu $[[R1:[0-9]+]], $zero, -4
|
|
|
|
; ALL: and $[[R2:[0-9]+]], $[[R0]], $[[R1]]
|
|
|
|
; ALL: andi $[[R3:[0-9]+]], $[[R0]], 3
|
|
|
|
; CHECK-EL: sll $[[R5:[0-9]+]], $[[R3]], 3
|
2013-05-31 11:25:44 +08:00
|
|
|
; CHECK-EB: xori $[[R4:[0-9]+]], $[[R3]], 3
|
|
|
|
; CHECK-EB: sll $[[R5:[0-9]+]], $[[R4]], 3
|
2014-06-16 18:25:17 +08:00
|
|
|
; ALL: ori $[[R6:[0-9]+]], $zero, 255
|
|
|
|
; ALL: sllv $[[R7:[0-9]+]], $[[R6]], $[[R5]]
|
|
|
|
; ALL: nor $[[R8:[0-9]+]], $zero, $[[R7]]
|
|
|
|
; ALL: sllv $[[R9:[0-9]+]], $4, $[[R5]]
|
|
|
|
|
2016-07-19 18:49:03 +08:00
|
|
|
; O0: [[BB0:(\$|\.L)[A-Z_0-9]+]]:
|
2016-04-29 00:26:43 +08:00
|
|
|
; O0: ld $[[R10:[0-9]+]]
|
|
|
|
; O0-NEXT: ll $[[R11:[0-9]+]], 0($[[R10]])
|
|
|
|
|
2016-07-19 18:49:03 +08:00
|
|
|
; ALL: [[BB0:(\$|\.L)[A-Z_0-9]+]]:
|
2016-04-29 00:26:43 +08:00
|
|
|
; ALL: ll $[[R12:[0-9]+]], 0($[[R2]])
|
|
|
|
; ALL: subu $[[R13:[0-9]+]], $[[R12]], $[[R9]]
|
|
|
|
; ALL: and $[[R14:[0-9]+]], $[[R13]], $[[R7]]
|
|
|
|
; ALL: and $[[R15:[0-9]+]], $[[R12]], $[[R8]]
|
|
|
|
; ALL: or $[[R16:[0-9]+]], $[[R15]], $[[R14]]
|
|
|
|
; ALL: sc $[[R16]], 0($[[R2]])
|
2016-07-19 18:49:03 +08:00
|
|
|
; NOT-MICROMIPS: beqz $[[R16]], [[BB0]]
|
|
|
|
; MICROMIPS: beqzc $[[R16]], [[BB0]]
|
|
|
|
; MIPSR6: beqzc $[[R16]], [[BB0]]
|
2014-06-16 18:25:17 +08:00
|
|
|
|
2016-04-29 00:26:43 +08:00
|
|
|
; ALL: and $[[R17:[0-9]+]], $[[R12]], $[[R7]]
|
|
|
|
; ALL: srlv $[[R18:[0-9]+]], $[[R17]], $[[R5]]
|
2014-06-16 21:13:03 +08:00
|
|
|
|
2016-04-29 00:26:43 +08:00
|
|
|
; NO-SEB-SEH: sll $[[R19:[0-9]+]], $[[R18]], 24
|
|
|
|
; NO-SEB-SEH: sra $2, $[[R19]], 24
|
2014-06-16 21:13:03 +08:00
|
|
|
|
2016-04-29 00:26:43 +08:00
|
|
|
; HAS-SEB-SEH:seb $2, $[[R18]]
|
2011-05-31 10:54:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define signext i8 @AtomicLoadNand8(i8 signext %incr) nounwind {
|
|
|
|
entry:
|
2011-09-27 04:27:49 +08:00
|
|
|
%0 = atomicrmw nand i8* @y, i8 %incr monotonic
|
2011-05-31 10:54:07 +08:00
|
|
|
ret i8 %0
|
|
|
|
|
2014-06-16 18:25:17 +08:00
|
|
|
; ALL-LABEL: AtomicLoadNand8:
|
|
|
|
|
2014-06-16 21:13:03 +08:00
|
|
|
; MIPS32-ANY: lw $[[R0:[0-9]+]], %got(y)
|
|
|
|
; MIPS64-ANY: ld $[[R0:[0-9]+]], %got_disp(y)(
|
|
|
|
|
2014-06-16 18:25:17 +08:00
|
|
|
; ALL: addiu $[[R1:[0-9]+]], $zero, -4
|
|
|
|
; ALL: and $[[R2:[0-9]+]], $[[R0]], $[[R1]]
|
|
|
|
; ALL: andi $[[R3:[0-9]+]], $[[R0]], 3
|
|
|
|
; CHECK-EL: sll $[[R5:[0-9]+]], $[[R3]], 3
|
|
|
|
; CHECK-EB: xori $[[R4:[0-9]+]], $[[R3]], 3
|
|
|
|
; CHECK-EB: sll $[[R5:[0-9]+]], $[[R4]], 3
|
|
|
|
; ALL: ori $[[R6:[0-9]+]], $zero, 255
|
|
|
|
; ALL: sllv $[[R7:[0-9]+]], $[[R6]], $[[R5]]
|
|
|
|
; ALL: nor $[[R8:[0-9]+]], $zero, $[[R7]]
|
|
|
|
; ALL: sllv $[[R9:[0-9]+]], $4, $[[R5]]
|
|
|
|
|
2016-07-19 18:49:03 +08:00
|
|
|
; O0: [[BB0:(\$|\.L)[A-Z_0-9]+]]:
|
2016-04-29 00:26:43 +08:00
|
|
|
; O0: ld $[[R10:[0-9]+]]
|
|
|
|
; O0-NEXT: ll $[[R11:[0-9]+]], 0($[[R10]])
|
2014-06-16 21:13:03 +08:00
|
|
|
|
2016-07-19 18:49:03 +08:00
|
|
|
; ALL: [[BB0:(\$|\.L)[A-Z_0-9]+]]:
|
2016-04-29 00:26:43 +08:00
|
|
|
; ALL: ll $[[R12:[0-9]+]], 0($[[R2]])
|
|
|
|
; ALL: and $[[R13:[0-9]+]], $[[R12]], $[[R9]]
|
|
|
|
; ALL: nor $[[R14:[0-9]+]], $zero, $[[R13]]
|
|
|
|
; ALL: and $[[R15:[0-9]+]], $[[R14]], $[[R7]]
|
|
|
|
; ALL: and $[[R16:[0-9]+]], $[[R12]], $[[R8]]
|
|
|
|
; ALL: or $[[R17:[0-9]+]], $[[R16]], $[[R15]]
|
|
|
|
; ALL: sc $[[R17]], 0($[[R2]])
|
2016-07-19 18:49:03 +08:00
|
|
|
; NOT-MICROMIPS: beqz $[[R17]], [[BB0]]
|
|
|
|
; MICROMIPS: beqzc $[[R17]], [[BB0]]
|
|
|
|
; MIPSR6: beqzc $[[R17]], [[BB0]]
|
2016-04-29 00:26:43 +08:00
|
|
|
|
|
|
|
; ALL: and $[[R18:[0-9]+]], $[[R12]], $[[R7]]
|
|
|
|
; ALL: srlv $[[R19:[0-9]+]], $[[R18]], $[[R5]]
|
|
|
|
|
|
|
|
; NO-SEB-SEH: sll $[[R20:[0-9]+]], $[[R19]], 24
|
|
|
|
; NO-SEB-SEH: sra $2, $[[R20]], 24
|
|
|
|
|
|
|
|
; HAS-SEB-SEH: seb $2, $[[R19]]
|
2011-05-31 10:54:07 +08:00
|
|
|
}
|
|
|
|
|
2011-07-19 02:52:12 +08:00
|
|
|
define signext i8 @AtomicSwap8(i8 signext %newval) nounwind {
|
2011-05-31 10:54:07 +08:00
|
|
|
entry:
|
2011-09-27 04:27:49 +08:00
|
|
|
%0 = atomicrmw xchg i8* @y, i8 %newval monotonic
|
2011-05-31 10:54:07 +08:00
|
|
|
ret i8 %0
|
|
|
|
|
2014-06-16 18:25:17 +08:00
|
|
|
; ALL-LABEL: AtomicSwap8:
|
|
|
|
|
2014-06-16 21:13:03 +08:00
|
|
|
; MIPS32-ANY: lw $[[R0:[0-9]+]], %got(y)
|
|
|
|
; MIPS64-ANY: ld $[[R0:[0-9]+]], %got_disp(y)(
|
|
|
|
|
2014-06-16 18:25:17 +08:00
|
|
|
; ALL: addiu $[[R1:[0-9]+]], $zero, -4
|
|
|
|
; ALL: and $[[R2:[0-9]+]], $[[R0]], $[[R1]]
|
|
|
|
; ALL: andi $[[R3:[0-9]+]], $[[R0]], 3
|
|
|
|
; CHECK-EL: sll $[[R5:[0-9]+]], $[[R3]], 3
|
|
|
|
; CHECK-EB: xori $[[R4:[0-9]+]], $[[R3]], 3
|
|
|
|
; CHECK-EB: sll $[[R5:[0-9]+]], $[[R4]], 3
|
|
|
|
; ALL: ori $[[R6:[0-9]+]], $zero, 255
|
|
|
|
; ALL: sllv $[[R7:[0-9]+]], $[[R6]], $[[R5]]
|
|
|
|
; ALL: nor $[[R8:[0-9]+]], $zero, $[[R7]]
|
|
|
|
; ALL: sllv $[[R9:[0-9]+]], $4, $[[R5]]
|
|
|
|
|
2016-07-19 18:49:03 +08:00
|
|
|
; ALL: [[BB0:(\$|\.L)[A-Z_0-9]+]]:
|
2014-06-16 18:25:17 +08:00
|
|
|
; ALL: ll $[[R10:[0-9]+]], 0($[[R2]])
|
|
|
|
; ALL: and $[[R18:[0-9]+]], $[[R9]], $[[R7]]
|
|
|
|
; ALL: and $[[R13:[0-9]+]], $[[R10]], $[[R8]]
|
|
|
|
; ALL: or $[[R14:[0-9]+]], $[[R13]], $[[R18]]
|
|
|
|
; ALL: sc $[[R14]], 0($[[R2]])
|
2016-07-19 18:49:03 +08:00
|
|
|
; NOT-MICROMIPS: beqz $[[R14]], [[BB0]]
|
|
|
|
; MICROMIPS: beqzc $[[R14]], [[BB0]]
|
|
|
|
; MIPSR6: beqzc $[[R14]], [[BB0]]
|
2014-06-16 18:25:17 +08:00
|
|
|
|
|
|
|
; ALL: and $[[R15:[0-9]+]], $[[R10]], $[[R7]]
|
|
|
|
; ALL: srlv $[[R16:[0-9]+]], $[[R15]], $[[R5]]
|
2014-06-16 21:13:03 +08:00
|
|
|
|
|
|
|
; NO-SEB-SEH: sll $[[R17:[0-9]+]], $[[R16]], 24
|
|
|
|
; NO-SEB-SEH: sra $2, $[[R17]], 24
|
|
|
|
|
|
|
|
; HAS-SEB-SEH: seb $2, $[[R16]]
|
Replace the result usages while legalizing cmpxchg.
We should update the usages to all of the results;
otherwise, we might get assertion failure or SEGV during
the type legalization of ATOMIC_CMP_SWAP_WITH_SUCCESS
with two or more illegal types.
For example, in the following sequence, both i8 and i1
might be illegal in some target, e.g. armv5, mipsel, mips64el,
%0 = cmpxchg i8* %ptr, i8 %desire, i8 %new monotonic monotonic
%1 = extractvalue { i8, i1 } %0, 1
Since both i8 and i1 should be legalized, the corresponding
ATOMIC_CMP_SWAP_WITH_SUCCESS dag will be checked/replaced/updated
twice.
If we don't update the usage to *ALL* of the results in the
first round, the DAG for extractvalue might be processed earlier.
The GetPromotedInteger() will result in assertion failure,
because its operand (i.e. the success bit of cmpxchg) is not
promoted beforehand.
llvm-svn: 213569
2014-07-22 01:33:44 +08:00
|
|
|
|
2011-05-31 10:54:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define signext i8 @AtomicCmpSwap8(i8 signext %oldval, i8 signext %newval) nounwind {
|
|
|
|
entry:
|
IR: add "cmpxchg weak" variant to support permitted failure.
This commit adds a weak variant of the cmpxchg operation, as described
in C++11. A cmpxchg instruction with this modifier is permitted to
fail to store, even if the comparison indicated it should.
As a result, cmpxchg instructions must return a flag indicating
success in addition to their original iN value loaded. Thus, for
uniformity *all* cmpxchg instructions now return "{ iN, i1 }". The
second flag is 1 when the store succeeded.
At the DAG level, a new ATOMIC_CMP_SWAP_WITH_SUCCESS node has been
added as the natural representation for the new cmpxchg instructions.
It is a strong cmpxchg.
By default this gets Expanded to the existing ATOMIC_CMP_SWAP during
Legalization, so existing backends should see no change in behaviour.
If they wish to deal with the enhanced node instead, they can call
setOperationAction on it. Beware: as a node with 2 results, it cannot
be selected from TableGen.
Currently, no use is made of the extra information provided in this
patch. Test updates are almost entirely adapting the input IR to the
new scheme.
Summary for out of tree users:
------------------------------
+ Legacy Bitcode files are upgraded during read.
+ Legacy assembly IR files will be invalid.
+ Front-ends must adapt to different type for "cmpxchg".
+ Backends should be unaffected by default.
llvm-svn: 210903
2014-06-13 22:24:07 +08:00
|
|
|
%pair0 = cmpxchg i8* @y, i8 %oldval, i8 %newval monotonic monotonic
|
|
|
|
%0 = extractvalue { i8, i1 } %pair0, 0
|
2011-05-31 10:54:07 +08:00
|
|
|
ret i8 %0
|
|
|
|
|
2014-06-16 18:25:17 +08:00
|
|
|
; ALL-LABEL: AtomicCmpSwap8:
|
|
|
|
|
2014-06-16 21:13:03 +08:00
|
|
|
; MIPS32-ANY: lw $[[R0:[0-9]+]], %got(y)
|
|
|
|
; MIPS64-ANY: ld $[[R0:[0-9]+]], %got_disp(y)(
|
|
|
|
|
2014-06-16 18:25:17 +08:00
|
|
|
; ALL: addiu $[[R1:[0-9]+]], $zero, -4
|
|
|
|
; ALL: and $[[R2:[0-9]+]], $[[R0]], $[[R1]]
|
|
|
|
; ALL: andi $[[R3:[0-9]+]], $[[R0]], 3
|
|
|
|
; CHECK-EL: sll $[[R5:[0-9]+]], $[[R3]], 3
|
|
|
|
; CHECK-EB: xori $[[R4:[0-9]+]], $[[R3]], 3
|
|
|
|
; CHECK-EB: sll $[[R5:[0-9]+]], $[[R4]], 3
|
|
|
|
; ALL: ori $[[R6:[0-9]+]], $zero, 255
|
|
|
|
; ALL: sllv $[[R7:[0-9]+]], $[[R6]], $[[R5]]
|
|
|
|
; ALL: nor $[[R8:[0-9]+]], $zero, $[[R7]]
|
|
|
|
; ALL: andi $[[R9:[0-9]+]], $4, 255
|
|
|
|
; ALL: sllv $[[R10:[0-9]+]], $[[R9]], $[[R5]]
|
|
|
|
; ALL: andi $[[R11:[0-9]+]], $5, 255
|
|
|
|
; ALL: sllv $[[R12:[0-9]+]], $[[R11]], $[[R5]]
|
|
|
|
|
2016-07-19 18:49:03 +08:00
|
|
|
; ALL: [[BB0:(\$|\.L)[A-Z_0-9]+]]:
|
2014-06-16 18:25:17 +08:00
|
|
|
; ALL: ll $[[R13:[0-9]+]], 0($[[R2]])
|
|
|
|
; ALL: and $[[R14:[0-9]+]], $[[R13]], $[[R7]]
|
2016-07-19 18:49:03 +08:00
|
|
|
; NOT-MICROMIPS: bne $[[R14]], $[[R10]], [[BB1:(\$|\.L)[A-Z_0-9]+]]
|
|
|
|
; MICROMIPS: bne $[[R14]], $[[R10]], [[BB1:(\$|\.L)[A-Z_0-9]+]]
|
|
|
|
; MIPSR6: bnec $[[R14]], $[[R10]], [[BB1:(\$|\.L)[A-Z_0-9]+]]
|
2014-06-16 18:25:17 +08:00
|
|
|
|
|
|
|
; ALL: and $[[R15:[0-9]+]], $[[R13]], $[[R8]]
|
|
|
|
; ALL: or $[[R16:[0-9]+]], $[[R15]], $[[R12]]
|
|
|
|
; ALL: sc $[[R16]], 0($[[R2]])
|
2016-07-19 18:49:03 +08:00
|
|
|
; NOT-MICROMIPS: beqz $[[R16]], [[BB0]]
|
|
|
|
; MICROMIPS: beqzc $[[R16]], [[BB0]]
|
|
|
|
; MIPSR6: beqzc $[[R16]], [[BB0]]
|
2014-06-16 18:25:17 +08:00
|
|
|
|
2016-07-19 18:49:03 +08:00
|
|
|
; ALL: [[BB1]]:
|
2014-06-16 18:25:17 +08:00
|
|
|
; ALL: srlv $[[R17:[0-9]+]], $[[R14]], $[[R5]]
|
2014-06-16 21:13:03 +08:00
|
|
|
|
|
|
|
; NO-SEB-SEH: sll $[[R18:[0-9]+]], $[[R17]], 24
|
|
|
|
; NO-SEB-SEH: sra $2, $[[R18]], 24
|
|
|
|
|
|
|
|
; HAS-SEB-SEH: seb $2, $[[R17]]
|
2011-05-31 10:54:07 +08:00
|
|
|
}
|
2011-07-20 07:30:50 +08:00
|
|
|
|
2014-11-08 00:54:21 +08:00
|
|
|
define i1 @AtomicCmpSwapRes8(i8* %ptr, i8 signext %oldval, i8 signext %newval) nounwind {
|
Replace the result usages while legalizing cmpxchg.
We should update the usages to all of the results;
otherwise, we might get assertion failure or SEGV during
the type legalization of ATOMIC_CMP_SWAP_WITH_SUCCESS
with two or more illegal types.
For example, in the following sequence, both i8 and i1
might be illegal in some target, e.g. armv5, mipsel, mips64el,
%0 = cmpxchg i8* %ptr, i8 %desire, i8 %new monotonic monotonic
%1 = extractvalue { i8, i1 } %0, 1
Since both i8 and i1 should be legalized, the corresponding
ATOMIC_CMP_SWAP_WITH_SUCCESS dag will be checked/replaced/updated
twice.
If we don't update the usage to *ALL* of the results in the
first round, the DAG for extractvalue might be processed earlier.
The GetPromotedInteger() will result in assertion failure,
because its operand (i.e. the success bit of cmpxchg) is not
promoted beforehand.
llvm-svn: 213569
2014-07-22 01:33:44 +08:00
|
|
|
entry:
|
|
|
|
%0 = cmpxchg i8* %ptr, i8 %oldval, i8 %newval monotonic monotonic
|
|
|
|
%1 = extractvalue { i8, i1 } %0, 1
|
|
|
|
ret i1 %1
|
|
|
|
; ALL-LABEL: AtomicCmpSwapRes8
|
|
|
|
|
|
|
|
; ALL: addiu $[[R1:[0-9]+]], $zero, -4
|
|
|
|
; ALL: and $[[R2:[0-9]+]], $4, $[[R1]]
|
|
|
|
; ALL: andi $[[R3:[0-9]+]], $4, 3
|
|
|
|
; CHECK-EL: sll $[[R5:[0-9]+]], $[[R3]], 3
|
|
|
|
; CHECK-EB: xori $[[R4:[0-9]+]], $[[R3]], 3
|
|
|
|
; CHECK-EB: sll $[[R5:[0-9]+]], $[[R4]], 3
|
|
|
|
; ALL: ori $[[R6:[0-9]+]], $zero, 255
|
|
|
|
; ALL: sllv $[[R7:[0-9]+]], $[[R6]], $[[R5]]
|
|
|
|
; ALL: nor $[[R8:[0-9]+]], $zero, $[[R7]]
|
|
|
|
; ALL: andi $[[R9:[0-9]+]], $5, 255
|
|
|
|
; ALL: sllv $[[R10:[0-9]+]], $[[R9]], $[[R5]]
|
|
|
|
; ALL: andi $[[R11:[0-9]+]], $6, 255
|
|
|
|
; ALL: sllv $[[R12:[0-9]+]], $[[R11]], $[[R5]]
|
|
|
|
|
2016-07-19 18:49:03 +08:00
|
|
|
; ALL: [[BB0:(\$|\.L)[A-Z_0-9]+]]:
|
Replace the result usages while legalizing cmpxchg.
We should update the usages to all of the results;
otherwise, we might get assertion failure or SEGV during
the type legalization of ATOMIC_CMP_SWAP_WITH_SUCCESS
with two or more illegal types.
For example, in the following sequence, both i8 and i1
might be illegal in some target, e.g. armv5, mipsel, mips64el,
%0 = cmpxchg i8* %ptr, i8 %desire, i8 %new monotonic monotonic
%1 = extractvalue { i8, i1 } %0, 1
Since both i8 and i1 should be legalized, the corresponding
ATOMIC_CMP_SWAP_WITH_SUCCESS dag will be checked/replaced/updated
twice.
If we don't update the usage to *ALL* of the results in the
first round, the DAG for extractvalue might be processed earlier.
The GetPromotedInteger() will result in assertion failure,
because its operand (i.e. the success bit of cmpxchg) is not
promoted beforehand.
llvm-svn: 213569
2014-07-22 01:33:44 +08:00
|
|
|
; ALL: ll $[[R13:[0-9]+]], 0($[[R2]])
|
|
|
|
; ALL: and $[[R14:[0-9]+]], $[[R13]], $[[R7]]
|
2016-07-19 18:49:03 +08:00
|
|
|
; NOT-MICROMIPS: bne $[[R14]], $[[R10]], [[BB1:(\$|\.L)[A-Z_0-9]+]]
|
|
|
|
; MICROMIPS: bne $[[R14]], $[[R10]], [[BB1:(\$|\.L)[A-Z_0-9]+]]
|
|
|
|
; MIPSR6: bnec $[[R14]], $[[R10]], [[BB1:(\$|\.L)[A-Z_0-9]+]]
|
Replace the result usages while legalizing cmpxchg.
We should update the usages to all of the results;
otherwise, we might get assertion failure or SEGV during
the type legalization of ATOMIC_CMP_SWAP_WITH_SUCCESS
with two or more illegal types.
For example, in the following sequence, both i8 and i1
might be illegal in some target, e.g. armv5, mipsel, mips64el,
%0 = cmpxchg i8* %ptr, i8 %desire, i8 %new monotonic monotonic
%1 = extractvalue { i8, i1 } %0, 1
Since both i8 and i1 should be legalized, the corresponding
ATOMIC_CMP_SWAP_WITH_SUCCESS dag will be checked/replaced/updated
twice.
If we don't update the usage to *ALL* of the results in the
first round, the DAG for extractvalue might be processed earlier.
The GetPromotedInteger() will result in assertion failure,
because its operand (i.e. the success bit of cmpxchg) is not
promoted beforehand.
llvm-svn: 213569
2014-07-22 01:33:44 +08:00
|
|
|
|
|
|
|
; ALL: and $[[R15:[0-9]+]], $[[R13]], $[[R8]]
|
|
|
|
; ALL: or $[[R16:[0-9]+]], $[[R15]], $[[R12]]
|
|
|
|
; ALL: sc $[[R16]], 0($[[R2]])
|
2016-07-19 18:49:03 +08:00
|
|
|
; NOT-MICROMIPS: beqz $[[R16]], [[BB0]]
|
|
|
|
; MICROMIPS: beqzc $[[R16]], [[BB0]]
|
|
|
|
; MIPSR6: beqzc $[[R16]], [[BB0]]
|
Replace the result usages while legalizing cmpxchg.
We should update the usages to all of the results;
otherwise, we might get assertion failure or SEGV during
the type legalization of ATOMIC_CMP_SWAP_WITH_SUCCESS
with two or more illegal types.
For example, in the following sequence, both i8 and i1
might be illegal in some target, e.g. armv5, mipsel, mips64el,
%0 = cmpxchg i8* %ptr, i8 %desire, i8 %new monotonic monotonic
%1 = extractvalue { i8, i1 } %0, 1
Since both i8 and i1 should be legalized, the corresponding
ATOMIC_CMP_SWAP_WITH_SUCCESS dag will be checked/replaced/updated
twice.
If we don't update the usage to *ALL* of the results in the
first round, the DAG for extractvalue might be processed earlier.
The GetPromotedInteger() will result in assertion failure,
because its operand (i.e. the success bit of cmpxchg) is not
promoted beforehand.
llvm-svn: 213569
2014-07-22 01:33:44 +08:00
|
|
|
|
2016-07-19 18:49:03 +08:00
|
|
|
; ALL: [[BB1]]:
|
Replace the result usages while legalizing cmpxchg.
We should update the usages to all of the results;
otherwise, we might get assertion failure or SEGV during
the type legalization of ATOMIC_CMP_SWAP_WITH_SUCCESS
with two or more illegal types.
For example, in the following sequence, both i8 and i1
might be illegal in some target, e.g. armv5, mipsel, mips64el,
%0 = cmpxchg i8* %ptr, i8 %desire, i8 %new monotonic monotonic
%1 = extractvalue { i8, i1 } %0, 1
Since both i8 and i1 should be legalized, the corresponding
ATOMIC_CMP_SWAP_WITH_SUCCESS dag will be checked/replaced/updated
twice.
If we don't update the usage to *ALL* of the results in the
first round, the DAG for extractvalue might be processed earlier.
The GetPromotedInteger() will result in assertion failure,
because its operand (i.e. the success bit of cmpxchg) is not
promoted beforehand.
llvm-svn: 213569
2014-07-22 01:33:44 +08:00
|
|
|
; ALL: srlv $[[R17:[0-9]+]], $[[R14]], $[[R5]]
|
|
|
|
|
|
|
|
; NO-SEB-SEH: sll $[[R18:[0-9]+]], $[[R17]], 24
|
|
|
|
; NO-SEB-SEH: sra $[[R19:[0-9]+]], $[[R18]], 24
|
|
|
|
|
2016-03-24 23:38:38 +08:00
|
|
|
; FIXME: -march=mips produces a redundant sign extension here...
|
|
|
|
; NO-SEB-SEH: sll $[[R20:[0-9]+]], $5, 24
|
|
|
|
; NO-SEB-SEH: sra $[[R20]], $[[R20]], 24
|
|
|
|
|
Replace the result usages while legalizing cmpxchg.
We should update the usages to all of the results;
otherwise, we might get assertion failure or SEGV during
the type legalization of ATOMIC_CMP_SWAP_WITH_SUCCESS
with two or more illegal types.
For example, in the following sequence, both i8 and i1
might be illegal in some target, e.g. armv5, mipsel, mips64el,
%0 = cmpxchg i8* %ptr, i8 %desire, i8 %new monotonic monotonic
%1 = extractvalue { i8, i1 } %0, 1
Since both i8 and i1 should be legalized, the corresponding
ATOMIC_CMP_SWAP_WITH_SUCCESS dag will be checked/replaced/updated
twice.
If we don't update the usage to *ALL* of the results in the
first round, the DAG for extractvalue might be processed earlier.
The GetPromotedInteger() will result in assertion failure,
because its operand (i.e. the success bit of cmpxchg) is not
promoted beforehand.
llvm-svn: 213569
2014-07-22 01:33:44 +08:00
|
|
|
; HAS-SEB-SEH: seb $[[R19:[0-9]+]], $[[R17]]
|
|
|
|
|
2016-03-24 23:38:38 +08:00
|
|
|
; FIXME: ...Leading to this split check.
|
|
|
|
; NO-SEB-SEH: xor $[[R21:[0-9]+]], $[[R19]], $[[R20]]
|
|
|
|
; HAS-SEB-SEH: xor $[[R21:[0-9]+]], $[[R19]], $5
|
|
|
|
|
|
|
|
; ALL: sltiu $2, $[[R21]], 1
|
Replace the result usages while legalizing cmpxchg.
We should update the usages to all of the results;
otherwise, we might get assertion failure or SEGV during
the type legalization of ATOMIC_CMP_SWAP_WITH_SUCCESS
with two or more illegal types.
For example, in the following sequence, both i8 and i1
might be illegal in some target, e.g. armv5, mipsel, mips64el,
%0 = cmpxchg i8* %ptr, i8 %desire, i8 %new monotonic monotonic
%1 = extractvalue { i8, i1 } %0, 1
Since both i8 and i1 should be legalized, the corresponding
ATOMIC_CMP_SWAP_WITH_SUCCESS dag will be checked/replaced/updated
twice.
If we don't update the usage to *ALL* of the results in the
first round, the DAG for extractvalue might be processed earlier.
The GetPromotedInteger() will result in assertion failure,
because its operand (i.e. the success bit of cmpxchg) is not
promoted beforehand.
llvm-svn: 213569
2014-07-22 01:33:44 +08:00
|
|
|
}
|
|
|
|
|
2014-06-16 21:13:03 +08:00
|
|
|
; Check one i16 so that we cover the seh sign extend
|
|
|
|
@z = common global i16 0, align 1
|
|
|
|
|
|
|
|
define signext i16 @AtomicLoadAdd16(i16 signext %incr) nounwind {
|
|
|
|
entry:
|
|
|
|
%0 = atomicrmw add i16* @z, i16 %incr monotonic
|
|
|
|
ret i16 %0
|
|
|
|
|
|
|
|
; ALL-LABEL: AtomicLoadAdd16:
|
|
|
|
|
|
|
|
; MIPS32-ANY: lw $[[R0:[0-9]+]], %got(z)
|
|
|
|
; MIPS64-ANY: ld $[[R0:[0-9]+]], %got_disp(z)(
|
|
|
|
|
|
|
|
; ALL: addiu $[[R1:[0-9]+]], $zero, -4
|
|
|
|
; ALL: and $[[R2:[0-9]+]], $[[R0]], $[[R1]]
|
|
|
|
; ALL: andi $[[R3:[0-9]+]], $[[R0]], 3
|
|
|
|
; CHECK-EB: xori $[[R4:[0-9]+]], $[[R3]], 2
|
|
|
|
; CHECK-EB: sll $[[R5:[0-9]+]], $[[R4]], 3
|
|
|
|
; CHECK-EL: sll $[[R5:[0-9]+]], $[[R3]], 3
|
|
|
|
; ALL: ori $[[R6:[0-9]+]], $zero, 65535
|
|
|
|
; ALL: sllv $[[R7:[0-9]+]], $[[R6]], $[[R5]]
|
|
|
|
; ALL: nor $[[R8:[0-9]+]], $zero, $[[R7]]
|
|
|
|
; ALL: sllv $[[R9:[0-9]+]], $4, $[[R5]]
|
|
|
|
|
2016-07-19 18:49:03 +08:00
|
|
|
; O0: [[BB0:(\$|\.L)[A-Z_0-9]+]]:
|
2016-04-29 00:26:43 +08:00
|
|
|
; O0: ld $[[R10:[0-9]+]]
|
|
|
|
; O0-NEXT: ll $[[R11:[0-9]+]], 0($[[R10]])
|
|
|
|
|
2016-07-19 18:49:03 +08:00
|
|
|
; ALL: [[BB0:(\$|\.L)[A-Z_0-9]+]]:
|
2016-04-29 00:26:43 +08:00
|
|
|
; ALL: ll $[[R12:[0-9]+]], 0($[[R2]])
|
|
|
|
; ALL: addu $[[R13:[0-9]+]], $[[R12]], $[[R9]]
|
|
|
|
; ALL: and $[[R14:[0-9]+]], $[[R13]], $[[R7]]
|
|
|
|
; ALL: and $[[R15:[0-9]+]], $[[R12]], $[[R8]]
|
|
|
|
; ALL: or $[[R16:[0-9]+]], $[[R15]], $[[R14]]
|
|
|
|
; ALL: sc $[[R16]], 0($[[R2]])
|
2016-07-19 18:49:03 +08:00
|
|
|
; NOT-MICROMIPS: beqz $[[R16]], [[BB0]]
|
|
|
|
; MICROMIPS: beqzc $[[R16]], [[BB0]]
|
|
|
|
; MIPSR6: beqzc $[[R16]], [[BB0]]
|
2014-06-16 21:13:03 +08:00
|
|
|
|
2016-04-29 00:26:43 +08:00
|
|
|
; ALL: and $[[R17:[0-9]+]], $[[R12]], $[[R7]]
|
|
|
|
; ALL: srlv $[[R18:[0-9]+]], $[[R17]], $[[R5]]
|
2014-06-16 21:13:03 +08:00
|
|
|
|
2016-04-29 00:26:43 +08:00
|
|
|
; NO-SEB-SEH: sll $[[R19:[0-9]+]], $[[R18]], 16
|
|
|
|
; NO-SEB-SEH: sra $2, $[[R19]], 16
|
2014-06-16 21:13:03 +08:00
|
|
|
|
2016-04-29 00:26:43 +08:00
|
|
|
; MIPS32R2: seh $2, $[[R18]]
|
2014-06-16 21:13:03 +08:00
|
|
|
}
|
|
|
|
|
2016-03-24 23:38:38 +08:00
|
|
|
; Test that the i16 return value from cmpxchg is recognised as signed,
|
|
|
|
; so that setCC doesn't end up comparing an unsigned value to a signed
|
|
|
|
; value.
|
|
|
|
; The rest of the functions here are testing the atomic expansion, so
|
|
|
|
; we just match the end of the function.
|
|
|
|
define {i16, i1} @foo(i16* %addr, i16 %l, i16 %r, i16 %new) {
|
|
|
|
%desired = add i16 %l, %r
|
|
|
|
%res = cmpxchg i16* %addr, i16 %desired, i16 %new seq_cst seq_cst
|
|
|
|
ret {i16, i1} %res
|
|
|
|
|
|
|
|
; ALL-LABEL: foo
|
|
|
|
; MIPSR6: addu $[[R2:[0-9]+]], $[[R1:[0-9]+]], $[[R0:[0-9]+]]
|
|
|
|
; NOT-MICROMIPS: addu $[[R2:[0-9]+]], $[[R1:[0-9]+]], $[[R0:[0-9]+]]
|
|
|
|
; MICROMIPS: addu16 $[[R2:[0-9]+]], $[[R1:[0-9]+]], $[[R0:[0-9]+]]
|
|
|
|
|
|
|
|
; ALL: sync
|
|
|
|
|
|
|
|
; ALL: andi $[[R3:[0-9]+]], $[[R2]], 65535
|
2016-07-19 18:49:03 +08:00
|
|
|
; ALL: [[BB0:(\$|\.L)[A-Z_0-9]+]]:
|
2016-03-24 23:38:38 +08:00
|
|
|
; ALL: ll $[[R4:[0-9]+]], 0($[[R5:[0-9]+]])
|
|
|
|
; ALL: and $[[R6:[0-9]+]], $[[R4]], $
|
|
|
|
; ALL: and $[[R7:[0-9]+]], $[[R4]], $
|
|
|
|
; ALL: or $[[R8:[0-9]+]], $[[R7]], $
|
|
|
|
; ALL: sc $[[R8]], 0($[[R5]])
|
2016-07-19 18:49:03 +08:00
|
|
|
; NOT-MICROMIPS: beqz $[[R8]], [[BB0]]
|
|
|
|
; MICROMIPS: beqzc $[[R8]], [[BB0]]
|
|
|
|
; MIPSR6: beqzc $[[R8]], [[BB0]]
|
2016-03-24 23:38:38 +08:00
|
|
|
|
|
|
|
; ALL: srlv $[[R9:[0-9]+]], $[[R6]], $
|
|
|
|
|
|
|
|
; NO-SEB-SEH: sll $[[R10:[0-9]+]], $[[R9]], 16
|
|
|
|
; NO-SEB-SEH: sra $[[R11:[0-9]+]], $[[R10]], 16
|
|
|
|
|
|
|
|
; NO-SEB-SEH: sll $[[R12:[0-9]+]], $[[R2]], 16
|
|
|
|
; NO-SEB-SEH: sra $[[R13:[0-9]+]], $[[R12]], 16
|
|
|
|
|
|
|
|
; HAS-SEB-SEH: seh $[[R11:[0-9]+]], $[[R9]]
|
|
|
|
; HAS-SEB-SEH: seh $[[R13:[0-9]+]], $[[R2]]
|
|
|
|
|
|
|
|
; ALL: xor $[[R12:[0-9]+]], $[[R11]], $[[R13]]
|
|
|
|
; ALL: sltiu $3, $[[R12]], 1
|
|
|
|
; ALL: sync
|
|
|
|
}
|
2014-06-16 21:13:03 +08:00
|
|
|
|
2011-07-20 07:30:50 +08:00
|
|
|
@countsint = common global i32 0, align 4
|
|
|
|
|
2014-11-08 00:54:21 +08:00
|
|
|
define i32 @CheckSync(i32 signext %v) nounwind noinline {
|
2011-07-20 07:30:50 +08:00
|
|
|
entry:
|
2011-09-27 04:27:49 +08:00
|
|
|
%0 = atomicrmw add i32* @countsint, i32 %v seq_cst
|
2011-07-20 07:30:50 +08:00
|
|
|
ret i32 %0
|
|
|
|
|
2014-06-16 18:25:17 +08:00
|
|
|
; ALL-LABEL: CheckSync:
|
|
|
|
|
2014-06-19 01:10:30 +08:00
|
|
|
; ALL: sync
|
2014-06-16 18:25:17 +08:00
|
|
|
; ALL: ll
|
|
|
|
; ALL: sc
|
|
|
|
; ALL: beq
|
2014-06-19 01:10:30 +08:00
|
|
|
; ALL: sync
|
2011-07-20 07:30:50 +08:00
|
|
|
}
|
|
|
|
|
2012-05-12 07:22:18 +08:00
|
|
|
; make sure that this assertion in
|
|
|
|
; TwoAddressInstructionPass::TryInstructionTransform does not fail:
|
|
|
|
;
|
|
|
|
; line 1203: assert(TargetRegisterInfo::isVirtualRegister(regB) &&
|
|
|
|
;
|
|
|
|
; it failed when MipsDAGToDAGISel::ReplaceUsesWithZeroReg replaced an
|
|
|
|
; operand of an atomic instruction with register $zero.
|
|
|
|
@a = external global i32
|
|
|
|
|
|
|
|
define i32 @zeroreg() nounwind {
|
|
|
|
entry:
|
IR: add "cmpxchg weak" variant to support permitted failure.
This commit adds a weak variant of the cmpxchg operation, as described
in C++11. A cmpxchg instruction with this modifier is permitted to
fail to store, even if the comparison indicated it should.
As a result, cmpxchg instructions must return a flag indicating
success in addition to their original iN value loaded. Thus, for
uniformity *all* cmpxchg instructions now return "{ iN, i1 }". The
second flag is 1 when the store succeeded.
At the DAG level, a new ATOMIC_CMP_SWAP_WITH_SUCCESS node has been
added as the natural representation for the new cmpxchg instructions.
It is a strong cmpxchg.
By default this gets Expanded to the existing ATOMIC_CMP_SWAP during
Legalization, so existing backends should see no change in behaviour.
If they wish to deal with the enhanced node instead, they can call
setOperationAction on it. Beware: as a node with 2 results, it cannot
be selected from TableGen.
Currently, no use is made of the extra information provided in this
patch. Test updates are almost entirely adapting the input IR to the
new scheme.
Summary for out of tree users:
------------------------------
+ Legacy Bitcode files are upgraded during read.
+ Legacy assembly IR files will be invalid.
+ Front-ends must adapt to different type for "cmpxchg".
+ Backends should be unaffected by default.
llvm-svn: 210903
2014-06-13 22:24:07 +08:00
|
|
|
%pair0 = cmpxchg i32* @a, i32 1, i32 0 seq_cst seq_cst
|
|
|
|
%0 = extractvalue { i32, i1 } %pair0, 0
|
2012-05-12 07:22:18 +08:00
|
|
|
%1 = icmp eq i32 %0, 1
|
|
|
|
%conv = zext i1 %1 to i32
|
|
|
|
ret i32 %conv
|
|
|
|
}
|
2014-06-16 21:13:03 +08:00
|
|
|
|
|
|
|
; Check that MIPS32R6 has the correct offset range.
|
|
|
|
; FIXME: At the moment, we don't seem to do addr+offset for any atomic load/store.
|
2014-11-08 00:54:21 +08:00
|
|
|
define i32 @AtomicLoadAdd32_OffGt9Bit(i32 signext %incr) nounwind {
|
2014-06-16 21:13:03 +08:00
|
|
|
entry:
|
2015-03-14 02:20:45 +08:00
|
|
|
%0 = atomicrmw add i32* getelementptr(i32, i32* @x, i32 256), i32 %incr monotonic
|
2014-06-16 21:13:03 +08:00
|
|
|
ret i32 %0
|
|
|
|
|
|
|
|
; ALL-LABEL: AtomicLoadAdd32_OffGt9Bit:
|
|
|
|
|
|
|
|
; MIPS32-ANY: lw $[[R0:[0-9]+]], %got(x)
|
|
|
|
; MIPS64-ANY: ld $[[R0:[0-9]+]], %got_disp(x)(
|
|
|
|
|
|
|
|
; ALL: addiu $[[PTR:[0-9]+]], $[[R0]], 1024
|
2016-07-19 18:49:03 +08:00
|
|
|
; ALL: [[BB0:(\$|\.L)[A-Z_0-9]+]]:
|
2014-06-16 21:13:03 +08:00
|
|
|
; ALL: ll $[[R1:[0-9]+]], 0($[[PTR]])
|
|
|
|
; ALL: addu $[[R2:[0-9]+]], $[[R1]], $4
|
|
|
|
; ALL: sc $[[R2]], 0($[[PTR]])
|
2016-07-19 18:49:03 +08:00
|
|
|
; NOT-MICROMIPS: beqz $[[R2]], [[BB0]]
|
|
|
|
; MICROMIPS: beqzc $[[R2]], [[BB0]]
|
|
|
|
; MIPSR6: beqzc $[[R2]], [[BB0]]
|
2014-06-16 21:13:03 +08:00
|
|
|
}
|