mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-30 15:10:33 +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
48 lines
1.9 KiB
LLVM
48 lines
1.9 KiB
LLVM
; RUN: llc < %s
|
|
|
|
; Test that a negative constant smaller than 64 bits (e.g., int)
|
|
; is correctly implemented with sign-extension.
|
|
; In particular, the current code generated is:
|
|
;
|
|
; main:
|
|
; .L_main_LL_0:
|
|
; save %o6, -224, %o6
|
|
; setx .G_fmtArg_1, %o1, %o0
|
|
; setuw 1, %o1 ! i = 1
|
|
; setuw 4294967295, %o3 ! THE BUG: 0x00000000ffffffff
|
|
; setsw 0, %i0
|
|
; add %i6, 1999, %o2 ! fval
|
|
; add %o1, %g0, %o1
|
|
; add %o0, 0, %o0
|
|
; mulx %o1, %o3, %o1 ! ERROR: 0xffffffff; should be -1
|
|
; add %o1, 3, %o1 ! ERROR: 0x100000002; should be 0x2
|
|
; mulx %o1, 12, %o3 !
|
|
; add %o2, %o3, %o3 ! produces bad address!
|
|
; call printf
|
|
; nop
|
|
; jmpl %i7+8, %g0
|
|
; restore %g0, 0, %g0
|
|
;
|
|
; llc produces:
|
|
; ioff = 2 fval = 0xffffffff7fffec90 &fval[2] = 0xb7fffeca8
|
|
; instead of:
|
|
; ioff = 2 fval = 0xffffffff7fffec90 &fval[2] = 0xffffffff7fffeca8
|
|
;
|
|
%Results = type { float, float, float }
|
|
@fmtArg = internal global [39 x i8] c"ioff = %u\09fval = 0x%p\09&fval[2] = 0x%p\0A\00" ; <[39 x i8]*> [#uses=1]
|
|
|
|
declare i32 @printf(i8*, ...)
|
|
|
|
define i32 @main() {
|
|
%fval = alloca %Results, i32 4 ; <%Results*> [#uses=2]
|
|
%i = add i32 1, 0 ; <i32> [#uses=1]
|
|
%iscale = mul i32 %i, -1 ; <i32> [#uses=1]
|
|
%ioff = add i32 %iscale, 3 ; <i32> [#uses=2]
|
|
%ioff.upgrd.1 = zext i32 %ioff to i64 ; <i64> [#uses=1]
|
|
%fptr = getelementptr %Results, %Results* %fval, i64 %ioff.upgrd.1 ; <%Results*> [#uses=1]
|
|
%castFmt = getelementptr [39 x i8], [39 x i8]* @fmtArg, i64 0, i64 0 ; <i8*> [#uses=1]
|
|
call i32 (i8*, ...) @printf( i8* %castFmt, i32 %ioff, %Results* %fval, %Results* %fptr ) ; <i32>:1 [#uses=0]
|
|
ret i32 0
|
|
}
|
|
|