1 ; RUN: llc -O0 -frame-pointer=all -mtriple=powerpc-unknown-linux-gnu -mcpu=g5 < %s | FileCheck %s -check-prefix=PPC32
2 ; RUN: llc -O0 -mtriple=powerpc64-unknown-linux-gnu -mcpu=g5 < %s | FileCheck %s -check-prefix=PPC64
3 ; RUN: llc -O0 -mtriple=powerpc64le-unknown-linux-gnu -verify-machineinstrs < %s | FileCheck %s -check-prefix=PPC64-ELFv2
7 define i32 @test_cr2() nounwind uwtable {
9 %ret = alloca i32, align 4
10 %0 = call i32 asm sideeffect "\0A\09mtcr $4\0A\09cmpw 2,$2,$1\0A\09mfcr $0", "=r,r,r,r,r,~{cr2}"(i32 1, i32 2, i32 3, i32 0) nounwind
11 store i32 %0, ptr %ret, align 4
13 %1 = load i32, ptr %ret, align 4
17 ; PPC32-LABEL: test_cr2:
18 ; PPC32: stwu 1, -32(1)
19 ; PPC32: stw 31, 28(1)
21 ; PPC32-NEXT: stw 12, 24(31)
22 ; PPC32: lwz 12, 24(31)
23 ; PPC32-NEXT: mtocrf 32, 12
25 ; PPC64: .cfi_startproc
28 ; PPC64: stdu 1, -[[AMT:[0-9]+]](1)
29 ; PPC64: .cfi_def_cfa_offset 128
30 ; PPC64: .cfi_offset lr, 16
31 ; PPC64: .cfi_offset cr2, 8
32 ; PPC64: addi 1, 1, [[AMT]]
34 ; PPC64: mtocrf 32, 12
37 define i32 @test_cr234() nounwind {
39 %ret = alloca i32, align 4
40 %0 = call i32 asm sideeffect "\0A\09mtcr $4\0A\09cmpw 2,$2,$1\0A\09cmpw 3,$2,$2\0A\09cmpw 4,$2,$3\0A\09mfcr $0", "=r,r,r,r,r,~{cr2},~{cr3},~{cr4}"(i32 1, i32 2, i32 3, i32 0) nounwind
41 store i32 %0, ptr %ret, align 4
43 %1 = load i32, ptr %ret, align 4
47 ; PPC32-LABEL: test_cr234:
48 ; PPC32: stwu 1, -32(1)
49 ; PPC32: stw 31, 28(1)
51 ; PPC32-NEXT: stw 12, 24(31)
52 ; PPC32: lwz 12, 24(31)
53 ; PPC32-NEXT: mtocrf 32, 12
54 ; PPC32-NEXT: mtocrf 16, 12
55 ; PPC32-NEXT: mtocrf 8, 12
59 ; PPC64: stdu 1, -[[AMT:[0-9]+]](1)
60 ; PPC64: addi 1, 1, [[AMT]]
62 ; PPC64: mtocrf 32, 12
63 ; PPC64: mtocrf 16, 12
66 ; Generate mfocrf in prologue when we need to save 1 nonvolatile CR field
67 define void @cloberOneNvCrField() {
69 tail call void asm sideeffect "# clobbers", "~{cr2}"()
72 ; PPC64-ELFv2-LABEL: @cloberOneNvCrField
73 ; PPC64-ELFv2: mfocrf [[REG1:[0-9]+]], 32
76 ; Generate mfcr in prologue when we need to save all nonvolatile CR field
77 define void @cloberAllNvCrField() {
79 tail call void asm sideeffect "# clobbers", "~{cr2},~{cr3},~{cr4}"()
82 ; PPC64-ELFv2-LABEL: @cloberAllNvCrField
83 ; PPC64-ELFv2: mfcr [[REG1:[0-9]+]]