1 ; RUN: llc < %s -march=bpf -verify-machineinstrs | FileCheck %s
6 ;load_byte(void *skb, unsigned long long off) asm("llvm.bpf.load.byte");
8 ;load_half(void *skb, unsigned long long off) asm("llvm.bpf.load.half");
9 ;typedef unsigned char uint8_t;
10 ;typedef unsigned short uint16_t;
12 ;int func_b(struct __sk_buff *skb)
14 ; uint8_t t = load_byte(skb, 0);
18 ;int func_h(struct __sk_buff *skb)
20 ; uint16_t t = load_half(skb, 0);
24 ;int func_w(struct __sk_buff *skb)
26 ; uint32_t t = load_word(skb, 0);
30 %struct.__sk_buff = type opaque
32 ; Function Attrs: nounwind readonly
33 define i32 @func_b(%struct.__sk_buff* %skb) local_unnamed_addr #0 {
35 %0 = bitcast %struct.__sk_buff* %skb to i8*
36 %call = tail call i64 @llvm.bpf.load.byte(i8* %0, i64 0)
37 %conv = trunc i64 %call to i32
38 %conv1 = and i32 %conv, 255
39 ; CHECK-NOT: r0 &= 255
43 ; Function Attrs: nounwind readonly
44 declare i64 @llvm.bpf.load.byte(i8*, i64) #1
46 ; Function Attrs: nounwind readonly
47 define i32 @func_h(%struct.__sk_buff* %skb) local_unnamed_addr #0 {
49 %0 = bitcast %struct.__sk_buff* %skb to i8*
50 %call = tail call i64 @llvm.bpf.load.half(i8* %0, i64 0)
51 %conv = trunc i64 %call to i32
52 %conv1 = and i32 %conv, 65535
53 ; CHECK-NOT: r0 &= 65535
57 ; Function Attrs: nounwind readonly
58 declare i64 @llvm.bpf.load.half(i8*, i64) #1