mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-30 05:29:47 +00:00
Similar to gep (r230786) and load (r230794) changes. Similar migration script can be used to update test cases, which successfully migrated all of LLVM and Polly, but about 4 test cases needed manually changes in Clang. (this script will read the contents of stdin and massage it into stdout - wrap it in the 'apply.sh' script shown in previous commits + xargs to apply it over a large set of test cases) import fileinput import sys import re rep = re.compile(r"(getelementptr(?:\s+inbounds)?\s*\()((<\d*\s+x\s+)?([^@]*?)(|\s*addrspace\(\d+\))\s*\*(?(3)>)\s*)(?=$|%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|zeroinitializer|<|\[\[[a-zA-Z]|\{\{)", re.MULTILINE | re.DOTALL) def conv(match): line = match.group(1) line += match.group(4) line += ", " line += match.group(2) return line line = sys.stdin.read() off = 0 for match in re.finditer(rep, line): sys.stdout.write(line[off:match.start()]) sys.stdout.write(conv(match)) off = match.end() sys.stdout.write(line[off:]) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232184 91177308-0d34-0410-b5e6-96231b3b80d8
47 lines
2.1 KiB
LLVM
47 lines
2.1 KiB
LLVM
; RUN: llc < %s -march=bpf | FileCheck %s
|
|
|
|
%struct.bpf_context = type { i64, i64, i64, i64, i64, i64, i64 }
|
|
%struct.sk_buff = type { i64, i64, i64, i64, i64, i64, i64 }
|
|
%struct.net_device = type { i64, i64, i64, i64, i64, i64, i64 }
|
|
|
|
@bpf_prog1.devname = private unnamed_addr constant [3 x i8] c"lo\00", align 1
|
|
@bpf_prog1.fmt = private unnamed_addr constant [15 x i8] c"skb %x dev %x\0A\00", align 1
|
|
|
|
; Function Attrs: nounwind uwtable
|
|
define i32 @bpf_prog1(%struct.bpf_context* nocapture %ctx) #0 section "events/net/netif_receive_skb" {
|
|
%devname = alloca [3 x i8], align 1
|
|
%fmt = alloca [15 x i8], align 1
|
|
%1 = getelementptr inbounds [3 x i8], [3 x i8]* %devname, i64 0, i64 0
|
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @bpf_prog1.devname, i64 0, i64 0), i64 3, i32 1, i1 false)
|
|
%2 = getelementptr inbounds %struct.bpf_context, %struct.bpf_context* %ctx, i64 0, i32 0
|
|
%3 = load i64, i64* %2, align 8
|
|
%4 = inttoptr i64 %3 to %struct.sk_buff*
|
|
%5 = getelementptr inbounds %struct.sk_buff, %struct.sk_buff* %4, i64 0, i32 2
|
|
%6 = bitcast i64* %5 to i8*
|
|
%7 = call i8* inttoptr (i64 4 to i8* (i8*)*)(i8* %6) #1
|
|
%8 = call i32 inttoptr (i64 9 to i32 (i8*, i8*, i32)*)(i8* %7, i8* %1, i32 2) #1
|
|
%9 = icmp eq i32 %8, 0
|
|
br i1 %9, label %10, label %13
|
|
|
|
; <label>:10 ; preds = %0
|
|
%11 = getelementptr inbounds [15 x i8], [15 x i8]* %fmt, i64 0, i64 0
|
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %11, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @bpf_prog1.fmt, i64 0, i64 0), i64 15, i32 1, i1 false)
|
|
%12 = call i32 (i8*, i32, ...)* inttoptr (i64 11 to i32 (i8*, i32, ...)*)(i8* %11, i32 15, %struct.sk_buff* %4, i8* %7) #1
|
|
; CHECK-LABEL: bpf_prog1:
|
|
; CHECK: call 4
|
|
; CHECK: call 9
|
|
; CHECK: jnei r0, 0
|
|
; CHECK: mov r1, 622884453
|
|
; CHECK: ld_64 r1, 7214898703899978611
|
|
; CHECK: call 11
|
|
; CHECK: mov r0, 0
|
|
; CHECK: ret
|
|
br label %13
|
|
|
|
; <label>:13 ; preds = %10, %0
|
|
ret i32 0
|
|
}
|
|
|
|
; Function Attrs: nounwind
|
|
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) #1
|