xref: /llvm-project/llvm/test/CodeGen/RISCV/rv32-inline-asm-pairs.ll (revision 33c44074714d1d2f3d5f65c3fb842cddb6b689ac)
14615cc38SSam Elliott; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
24615cc38SSam Elliott; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \
34615cc38SSam Elliott; RUN:   | FileCheck %s
44615cc38SSam Elliott
54615cc38SSam Elliottdefine i64 @test_Pr_wide_scalar_simple(i64 noundef %0) nounwind {
64615cc38SSam Elliott; CHECK-LABEL: test_Pr_wide_scalar_simple:
74615cc38SSam Elliott; CHECK:       # %bb.0: # %entry
84615cc38SSam Elliott; CHECK-NEXT:    #APP
94615cc38SSam Elliott; CHECK-NEXT:    # a2 <- a0
104615cc38SSam Elliott; CHECK-NEXT:    #NO_APP
114615cc38SSam Elliott; CHECK-NEXT:    mv a0, a2
124615cc38SSam Elliott; CHECK-NEXT:    mv a1, a3
134615cc38SSam Elliott; CHECK-NEXT:    ret
144615cc38SSam Elliottentry:
154615cc38SSam Elliott  %1 = call i64 asm sideeffect "/* $0 <- $1 */", "=&R,R"(i64 %0)
164615cc38SSam Elliott  ret i64 %1
174615cc38SSam Elliott}
184615cc38SSam Elliott
194615cc38SSam Elliottdefine i32 @test_Pr_wide_scalar_with_ops(i32 noundef %0) nounwind {
204615cc38SSam Elliott; CHECK-LABEL: test_Pr_wide_scalar_with_ops:
214615cc38SSam Elliott; CHECK:       # %bb.0: # %entry
224615cc38SSam Elliott; CHECK-NEXT:    mv a1, a0
234615cc38SSam Elliott; CHECK-NEXT:    #APP
244615cc38SSam Elliott; CHECK-NEXT:    # a2 <- a0
254615cc38SSam Elliott; CHECK-NEXT:    #NO_APP
264615cc38SSam Elliott; CHECK-NEXT:    or a0, a2, a3
274615cc38SSam Elliott; CHECK-NEXT:    ret
284615cc38SSam Elliottentry:
294615cc38SSam Elliott  %1 = zext i32 %0 to i64
304615cc38SSam Elliott  %2 = shl i64 %1, 32
314615cc38SSam Elliott  %3 = or i64 %1, %2
324615cc38SSam Elliott  %4 = call i64 asm sideeffect "/* $0 <- $1 */", "=&R,R"(i64 %3)
334615cc38SSam Elliott  %5 = trunc i64 %4 to i32
344615cc38SSam Elliott  %6 = lshr i64 %4, 32
354615cc38SSam Elliott  %7 = trunc i64 %6 to i32
364615cc38SSam Elliott  %8 = or i32 %5, %7
374615cc38SSam Elliott  ret i32 %8
384615cc38SSam Elliott}
394615cc38SSam Elliott
404615cc38SSam Elliottdefine i64 @test_Pr_wide_scalar_inout(ptr %0, i64 noundef %1) nounwind {
414615cc38SSam Elliott; CHECK-LABEL: test_Pr_wide_scalar_inout:
424615cc38SSam Elliott; CHECK:       # %bb.0: # %entry
434615cc38SSam Elliott; CHECK-NEXT:    addi sp, sp, -16
444615cc38SSam Elliott; CHECK-NEXT:    mv a3, a2
454615cc38SSam Elliott; CHECK-NEXT:    sw a0, 12(sp)
464615cc38SSam Elliott; CHECK-NEXT:    mv a2, a1
474615cc38SSam Elliott; CHECK-NEXT:    sw a1, 0(sp)
484615cc38SSam Elliott; CHECK-NEXT:    sw a3, 4(sp)
494615cc38SSam Elliott; CHECK-NEXT:    #APP
504615cc38SSam Elliott; CHECK-NEXT:    # a0; a2
514615cc38SSam Elliott; CHECK-NEXT:    #NO_APP
524615cc38SSam Elliott; CHECK-NEXT:    sw a0, 12(sp)
534615cc38SSam Elliott; CHECK-NEXT:    sw a2, 0(sp)
544615cc38SSam Elliott; CHECK-NEXT:    sw a3, 4(sp)
554615cc38SSam Elliott; CHECK-NEXT:    mv a0, a2
564615cc38SSam Elliott; CHECK-NEXT:    mv a1, a3
574615cc38SSam Elliott; CHECK-NEXT:    addi sp, sp, 16
584615cc38SSam Elliott; CHECK-NEXT:    ret
594615cc38SSam Elliottentry:
604615cc38SSam Elliott  %2 = alloca ptr, align 4
614615cc38SSam Elliott  %3 = alloca i64, align 8
624615cc38SSam Elliott  store ptr %0, ptr %2, align 4
634615cc38SSam Elliott  store i64 %1, ptr %3, align 8
644615cc38SSam Elliott  %4 = load ptr, ptr %2, align 4
654615cc38SSam Elliott  %5 = load i64, ptr %3, align 8
664615cc38SSam Elliott  %6 = call { ptr, i64 } asm sideeffect "/* $0; $1 */", "=r,=R,0,1"(ptr %4, i64 %5)
674615cc38SSam Elliott  %7 = extractvalue { ptr, i64} %6, 0
684615cc38SSam Elliott  %8 = extractvalue { ptr, i64 } %6, 1
694615cc38SSam Elliott  store ptr %7, ptr %2, align 4
704615cc38SSam Elliott  store i64 %8, ptr %3, align 8
714615cc38SSam Elliott  %9 = load i64, ptr %3, align 8
724615cc38SSam Elliott  ret i64 %9
734615cc38SSam Elliott}
74*33c44074SSam Elliott
75*33c44074SSam Elliottdefine i64 @test_cR_wide_scalar_simple(i64 noundef %0) nounwind {
76*33c44074SSam Elliott; CHECK-LABEL: test_cR_wide_scalar_simple:
77*33c44074SSam Elliott; CHECK:       # %bb.0: # %entry
78*33c44074SSam Elliott; CHECK-NEXT:    #APP
79*33c44074SSam Elliott; CHECK-NEXT:    # a2 <- a0
80*33c44074SSam Elliott; CHECK-NEXT:    #NO_APP
81*33c44074SSam Elliott; CHECK-NEXT:    mv a0, a2
82*33c44074SSam Elliott; CHECK-NEXT:    mv a1, a3
83*33c44074SSam Elliott; CHECK-NEXT:    ret
84*33c44074SSam Elliottentry:
85*33c44074SSam Elliott  %1 = call i64 asm sideeffect "/* $0 <- $1 */", "=&^cR,^cR"(i64 %0)
86*33c44074SSam Elliott  ret i64 %1
87*33c44074SSam Elliott}
88*33c44074SSam Elliott
89*33c44074SSam Elliottdefine i32 @test_cR_wide_scalar_with_ops(i32 noundef %0) nounwind {
90*33c44074SSam Elliott; CHECK-LABEL: test_cR_wide_scalar_with_ops:
91*33c44074SSam Elliott; CHECK:       # %bb.0: # %entry
92*33c44074SSam Elliott; CHECK-NEXT:    mv a1, a0
93*33c44074SSam Elliott; CHECK-NEXT:    #APP
94*33c44074SSam Elliott; CHECK-NEXT:    # a2 <- a0
95*33c44074SSam Elliott; CHECK-NEXT:    #NO_APP
96*33c44074SSam Elliott; CHECK-NEXT:    or a0, a2, a3
97*33c44074SSam Elliott; CHECK-NEXT:    ret
98*33c44074SSam Elliottentry:
99*33c44074SSam Elliott  %1 = zext i32 %0 to i64
100*33c44074SSam Elliott  %2 = shl i64 %1, 32
101*33c44074SSam Elliott  %3 = or i64 %1, %2
102*33c44074SSam Elliott  %4 = call i64 asm sideeffect "/* $0 <- $1 */", "=&^cR,^cR"(i64 %3)
103*33c44074SSam Elliott  %5 = trunc i64 %4 to i32
104*33c44074SSam Elliott  %6 = lshr i64 %4, 32
105*33c44074SSam Elliott  %7 = trunc i64 %6 to i32
106*33c44074SSam Elliott  %8 = or i32 %5, %7
107*33c44074SSam Elliott  ret i32 %8
108*33c44074SSam Elliott}
109*33c44074SSam Elliott
110*33c44074SSam Elliottdefine i64 @test_cR_wide_scalar_inout(ptr %0, i64 noundef %1) nounwind {
111*33c44074SSam Elliott; CHECK-LABEL: test_cR_wide_scalar_inout:
112*33c44074SSam Elliott; CHECK:       # %bb.0: # %entry
113*33c44074SSam Elliott; CHECK-NEXT:    addi sp, sp, -16
114*33c44074SSam Elliott; CHECK-NEXT:    mv a3, a2
115*33c44074SSam Elliott; CHECK-NEXT:    sw a0, 12(sp)
116*33c44074SSam Elliott; CHECK-NEXT:    mv a2, a1
117*33c44074SSam Elliott; CHECK-NEXT:    sw a1, 0(sp)
118*33c44074SSam Elliott; CHECK-NEXT:    sw a3, 4(sp)
119*33c44074SSam Elliott; CHECK-NEXT:    #APP
120*33c44074SSam Elliott; CHECK-NEXT:    # a0; a2
121*33c44074SSam Elliott; CHECK-NEXT:    #NO_APP
122*33c44074SSam Elliott; CHECK-NEXT:    sw a0, 12(sp)
123*33c44074SSam Elliott; CHECK-NEXT:    sw a2, 0(sp)
124*33c44074SSam Elliott; CHECK-NEXT:    sw a3, 4(sp)
125*33c44074SSam Elliott; CHECK-NEXT:    mv a0, a2
126*33c44074SSam Elliott; CHECK-NEXT:    mv a1, a3
127*33c44074SSam Elliott; CHECK-NEXT:    addi sp, sp, 16
128*33c44074SSam Elliott; CHECK-NEXT:    ret
129*33c44074SSam Elliottentry:
130*33c44074SSam Elliott  %2 = alloca ptr, align 4
131*33c44074SSam Elliott  %3 = alloca i64, align 8
132*33c44074SSam Elliott  store ptr %0, ptr %2, align 4
133*33c44074SSam Elliott  store i64 %1, ptr %3, align 8
134*33c44074SSam Elliott  %4 = load ptr, ptr %2, align 4
135*33c44074SSam Elliott  %5 = load i64, ptr %3, align 8
136*33c44074SSam Elliott  %6 = call { ptr, i64 } asm sideeffect "/* $0; $1 */", "=r,=^cR,0,1"(ptr %4, i64 %5)
137*33c44074SSam Elliott  %7 = extractvalue { ptr, i64} %6, 0
138*33c44074SSam Elliott  %8 = extractvalue { ptr, i64 } %6, 1
139*33c44074SSam Elliott  store ptr %7, ptr %2, align 4
140*33c44074SSam Elliott  store i64 %8, ptr %3, align 8
141*33c44074SSam Elliott  %9 = load i64, ptr %3, align 8
142*33c44074SSam Elliott  ret i64 %9
143*33c44074SSam Elliott}
144