mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-01 15:11:24 +00:00
32b845d223
See r230786 and r230794 for similar changes to gep and load respectively. Call is a bit different because it often doesn't have a single explicit type - usually the type is deduced from the arguments, and just the return type is explicit. In those cases there's no need to change the IR. When that's not the case, the IR usually contains the pointer type of the first operand - but since typed pointers are going away, that representation is insufficient so I'm just stripping the "pointerness" of the explicit type away. This does make the IR a bit weird - it /sort of/ reads like the type of the first operand: "call void () %x(" but %x is actually of type "void ()*" and will eventually be just of type "ptr". But this seems not too bad and I don't think it would benefit from repeating the type ("void (), void () * %x(" and then eventually "void (), ptr %x(") as has been done with gep and load. This also has a side benefit: since the explicit type is no longer a pointer, there's no ambiguity between an explicit type and a function that returns a function pointer. Previously this case needed an explicit type (eg: a function returning a void() function was written as "call void () () * @x(" rather than "call void () * @x(" because of the ambiguity between a function returning a pointer to a void() function and a function returning void). No ambiguity means even function pointer return types can just be written alone, without writing the whole function's type. This leaves /only/ the varargs case where the explicit type is required. Given the special type syntax in call instructions, the regex-fu used for migration was a bit more involved in its own unique way (as every one of these is) so here it is. Use it in conjunction with the apply.sh script and associated find/xargs commands I've provided in rr230786 to migrate your out of tree tests. Do let me know if any of this doesn't cover your cases & we can iterate on a more general script/regexes to help others with out of tree tests. About 9 test cases couldn't be automatically migrated - half of those were functions returning function pointers, where I just had to manually delete the function argument types now that we didn't need an explicit function type there. The other half were typedefs of function types used in calls - just had to manually drop the * from those. import fileinput import sys import re pat = re.compile(r'((?:=|:|^|\s)call\s(?:[^@]*?))(\s*$|\s*(?:(?:\[\[[a-zA-Z0-9_]+\]\]|[@%](?:(")?[\\\?@a-zA-Z0-9_.]*?(?(3)"|)|{{.*}}))(?:\(|$)|undef|inttoptr|bitcast|null|asm).*$)') addrspace_end = re.compile(r"addrspace\(\d+\)\s*\*$") func_end = re.compile("(?:void.*|\)\s*)\*$") def conv(match, line): if not match or re.search(addrspace_end, match.group(1)) or not re.search(func_end, match.group(1)): return line return line[:match.start()] + match.group(1)[:match.group(1).rfind('*')].rstrip() + match.group(2) + line[match.end():] for line in sys.stdin: sys.stdout.write(conv(re.search(pat, line), line)) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235145 91177308-0d34-0410-b5e6-96231b3b80d8
123 lines
3.9 KiB
LLVM
123 lines
3.9 KiB
LLVM
; RUN: llc < %s -march=arm -mtriple=armv6-apple-darwin9
|
|
|
|
@nn = external global i32 ; <i32*> [#uses=1]
|
|
@al_len = external global i32 ; <i32*> [#uses=2]
|
|
@no_mat = external global i32 ; <i32*> [#uses=2]
|
|
@no_mis = external global i32 ; <i32*> [#uses=2]
|
|
@"\01LC12" = external constant [29 x i8], align 1 ; <[29 x i8]*> [#uses=1]
|
|
@"\01LC16" = external constant [33 x i8], align 1 ; <[33 x i8]*> [#uses=1]
|
|
@"\01LC17" = external constant [47 x i8], align 1 ; <[47 x i8]*> [#uses=1]
|
|
|
|
declare i32 @printf(i8* nocapture, ...) nounwind
|
|
|
|
declare void @diff(i8*, i8*, i32, i32, i32, i32) nounwind
|
|
|
|
define void @SIM(i8* %A, i8* %B, i32 %M, i32 %N, i32 %K, [256 x i32]* %V, i32 %Q, i32 %R, i32 %nseq) nounwind {
|
|
entry:
|
|
br i1 undef, label %bb5, label %bb
|
|
|
|
bb: ; preds = %bb, %entry
|
|
br label %bb
|
|
|
|
bb5: ; preds = %entry
|
|
br i1 undef, label %bb6, label %bb8
|
|
|
|
bb6: ; preds = %bb6, %bb5
|
|
br i1 undef, label %bb8, label %bb6
|
|
|
|
bb8: ; preds = %bb6, %bb5
|
|
br label %bb15
|
|
|
|
bb9: ; preds = %bb15
|
|
br i1 undef, label %bb10, label %bb11
|
|
|
|
bb10: ; preds = %bb9
|
|
unreachable
|
|
|
|
bb11: ; preds = %bb9
|
|
%0 = load i32, i32* undef, align 4 ; <i32> [#uses=2]
|
|
%1 = add i32 %0, 1 ; <i32> [#uses=2]
|
|
store i32 %1, i32* undef, align 4
|
|
%2 = load i32, i32* undef, align 4 ; <i32> [#uses=1]
|
|
store i32 %2, i32* @nn, align 4
|
|
store i32 0, i32* @al_len, align 4
|
|
store i32 0, i32* @no_mat, align 4
|
|
store i32 0, i32* @no_mis, align 4
|
|
%3 = getelementptr i8, i8* %B, i32 %0 ; <i8*> [#uses=1]
|
|
tail call void @diff(i8* undef, i8* %3, i32 undef, i32 undef, i32 undef, i32 undef) nounwind
|
|
%4 = sitofp i32 undef to double ; <double> [#uses=1]
|
|
%5 = fdiv double %4, 1.000000e+01 ; <double> [#uses=1]
|
|
%6 = tail call i32 (i8*, ...) @printf(i8* getelementptr ([29 x i8], [29 x i8]* @"\01LC12", i32 0, i32 0), double %5) nounwind ; <i32> [#uses=0]
|
|
%7 = load i32, i32* @al_len, align 4 ; <i32> [#uses=1]
|
|
%8 = load i32, i32* @no_mat, align 4 ; <i32> [#uses=1]
|
|
%9 = load i32, i32* @no_mis, align 4 ; <i32> [#uses=1]
|
|
%10 = sub i32 %7, %8 ; <i32> [#uses=1]
|
|
%11 = sub i32 %10, %9 ; <i32> [#uses=1]
|
|
%12 = tail call i32 (i8*, ...) @printf(i8* getelementptr ([33 x i8], [33 x i8]* @"\01LC16", i32 0, i32 0), i32 %11) nounwind ; <i32> [#uses=0]
|
|
%13 = tail call i32 (i8*, ...) @printf(i8* getelementptr ([47 x i8], [47 x i8]* @"\01LC17", i32 0, i32 0), i32 undef, i32 %1, i32 undef, i32 undef) nounwind ; <i32> [#uses=0]
|
|
br i1 undef, label %bb15, label %bb12
|
|
|
|
bb12: ; preds = %bb11
|
|
br label %bb228.i
|
|
|
|
bb74.i: ; preds = %bb228.i
|
|
br i1 undef, label %bb138.i, label %bb145.i
|
|
|
|
bb138.i: ; preds = %bb74.i
|
|
br label %bb145.i
|
|
|
|
bb145.i: ; preds = %bb228.i, %bb138.i, %bb74.i
|
|
br i1 undef, label %bb146.i, label %bb151.i
|
|
|
|
bb146.i: ; preds = %bb145.i
|
|
br i1 undef, label %bb228.i, label %bb151.i
|
|
|
|
bb151.i: ; preds = %bb146.i, %bb145.i
|
|
br i1 undef, label %bb153.i, label %bb228.i
|
|
|
|
bb153.i: ; preds = %bb151.i
|
|
br i1 undef, label %bb220.i, label %bb.nph.i98
|
|
|
|
bb.nph.i98: ; preds = %bb153.i
|
|
br label %bb158.i
|
|
|
|
bb158.i: ; preds = %bb218.i, %bb.nph.i98
|
|
br i1 undef, label %bb168.i, label %bb160.i
|
|
|
|
bb160.i: ; preds = %bb158.i
|
|
br i1 undef, label %bb161.i, label %bb168.i
|
|
|
|
bb161.i: ; preds = %bb160.i
|
|
br i1 undef, label %bb168.i, label %bb163.i
|
|
|
|
bb163.i: ; preds = %bb161.i
|
|
br i1 undef, label %bb167.i, label %bb168.i
|
|
|
|
bb167.i: ; preds = %bb163.i
|
|
br label %bb168.i
|
|
|
|
bb168.i: ; preds = %bb167.i, %bb163.i, %bb161.i, %bb160.i, %bb158.i
|
|
br i1 undef, label %bb211.i, label %bb218.i
|
|
|
|
bb211.i: ; preds = %bb168.i
|
|
br label %bb218.i
|
|
|
|
bb218.i: ; preds = %bb211.i, %bb168.i
|
|
br i1 undef, label %bb220.i, label %bb158.i
|
|
|
|
bb220.i: ; preds = %bb218.i, %bb153.i
|
|
br i1 undef, label %bb221.i, label %bb228.i
|
|
|
|
bb221.i: ; preds = %bb220.i
|
|
br label %bb228.i
|
|
|
|
bb228.i: ; preds = %bb221.i, %bb220.i, %bb151.i, %bb146.i, %bb12
|
|
br i1 undef, label %bb74.i, label %bb145.i
|
|
|
|
bb15: ; preds = %bb11, %bb8
|
|
br i1 undef, label %return, label %bb9
|
|
|
|
return: ; preds = %bb15
|
|
ret void
|
|
}
|