1 ; RUN: llc -mtriple=bpfel -filetype=obj -o - %s | llvm-objdump --no-print-imm-hex -d - | FileCheck --check-prefix=CHECK-EL %s
2 ; RUN: llc -mtriple=bpfeb -filetype=obj -o - %s | llvm-objdump --no-print-imm-hex -d - | FileCheck --check-prefix=CHECK-EB %s
4 ; Function Attrs: nounwind uwtable
5 define i32 @ld_b(i64 %foo, ptr nocapture %bar, ptr %ctx, ptr %ctx2) #0 {
6 %1 = tail call i64 @llvm.bpf.load.byte(ptr %ctx, i64 123) #2
8 %3 = load volatile i64, ptr %bar, align 8
10 %5 = tail call i64 @llvm.bpf.load.byte(ptr %ctx2, i64 %foo) #2
12 %7 = load volatile i64, ptr %bar, align 8
14 %9 = trunc i64 %8 to i32
17 ; CHECK-EL: r0 = *(u8 *)skb[123]
18 ; CHECK-EL: r0 = *(u8 *)skb[r
19 ; CHECK-EB: r0 = *(u8 *)skb[123]
20 ; CHECK-EB: r0 = *(u8 *)skb[r
23 declare i64 @llvm.bpf.load.byte(ptr, i64) #1
25 ; Function Attrs: nounwind uwtable
26 define i32 @ld_h(ptr %ctx, ptr %ctx2, i32 %foo) #0 {
27 %1 = tail call i64 @llvm.bpf.load.half(ptr %ctx, i64 123) #2
28 %2 = sext i32 %foo to i64
29 %3 = tail call i64 @llvm.bpf.load.half(ptr %ctx2, i64 %2) #2
31 %5 = trunc i64 %4 to i32
34 ; CHECK-EL: r0 = *(u16 *)skb[r
35 ; CHECK-EL: r0 = *(u16 *)skb[123]
36 ; CHECK-EB: r0 = *(u16 *)skb[r
37 ; CHECK-EB: r0 = *(u16 *)skb[123]
40 declare i64 @llvm.bpf.load.half(ptr, i64) #1
42 ; Function Attrs: nounwind uwtable
43 define i32 @ld_w(ptr %ctx, ptr %ctx2, i32 %foo) #0 {
44 %1 = tail call i64 @llvm.bpf.load.word(ptr %ctx, i64 123) #2
45 %2 = sext i32 %foo to i64
46 %3 = tail call i64 @llvm.bpf.load.word(ptr %ctx2, i64 %2) #2
48 %5 = trunc i64 %4 to i32
51 ; CHECK-EL: r0 = *(u32 *)skb[r
52 ; CHECK-EL: r0 = *(u32 *)skb[123]
53 ; CHECK-EB: r0 = *(u32 *)skb[r
54 ; CHECK-EB: r0 = *(u32 *)skb[123]
57 declare i64 @llvm.bpf.load.word(ptr, i64) #1
59 define i32 @ld_pseudo() #0 {
61 %call = tail call i64 @llvm.bpf.pseudo(i64 2, i64 3)
62 tail call void inttoptr (i64 4 to ptr)(i64 %call, i32 4) #2
64 ; CHECK-LABEL: ld_pseudo:
65 ; CHECK-EL: ld_pseudo r1, 2, 3
66 ; CHECK-EB: ld_pseudo r1, 2, 3
69 declare i64 @llvm.bpf.pseudo(i64, i64) #2
71 define i32 @bswap(i64 %a, i64 %b, i64 %c) #0 {
73 %0 = tail call i64 @llvm.bswap.i64(i64 %a)
74 %conv = trunc i64 %b to i32
75 %1 = tail call i32 @llvm.bswap.i32(i32 %conv)
76 %conv1 = zext i32 %1 to i64
77 %add = add i64 %conv1, %0
78 %conv2 = trunc i64 %c to i16
79 %2 = tail call i16 @llvm.bswap.i16(i16 %conv2)
80 %conv3 = zext i16 %2 to i64
81 %add4 = add i64 %add, %conv3
82 %conv5 = trunc i64 %add4 to i32
85 ; CHECK-EL: r1 = be64 r1
86 ; CHECK-EL: r0 = be32 r0
88 ; CHECK-EL: r3 = be16 r3
90 ; CHECK-EB: r1 = le64 r1
91 ; CHECK-EB: r0 = le32 r0
93 ; CHECK-EB: r3 = le16 r3
97 declare i64 @llvm.bswap.i64(i64) #1
98 declare i32 @llvm.bswap.i32(i32) #1
99 declare i16 @llvm.bswap.i16(i16) #1