2010-03-11 08:22:57 +08:00
|
|
|
; RUN: llc < %s -tailcallopt -mtriple=i686-linux-gnu | FileCheck %s
|
|
|
|
|
|
|
|
; Test the GHC call convention works (x86-32)
|
|
|
|
|
2017-11-29 01:15:09 +08:00
|
|
|
@base = external global i32 ; assigned to register: ebx
|
|
|
|
@sp = external global i32 ; assigned to register: ebp
|
|
|
|
@hp = external global i32 ; assigned to register: edi
|
|
|
|
@r1 = external global i32 ; assigned to register: esi
|
2010-03-11 08:22:57 +08:00
|
|
|
|
|
|
|
define void @zap(i32 %a, i32 %b) nounwind {
|
|
|
|
entry:
|
|
|
|
; CHECK: movl {{[0-9]*}}(%esp), %ebx
|
|
|
|
; CHECK-NEXT: movl {{[0-9]*}}(%esp), %ebp
|
2010-09-22 13:49:14 +08:00
|
|
|
; CHECK-NEXT: calll addtwo
|
2014-12-02 05:04:44 +08:00
|
|
|
%0 = call ghccc i32 @addtwo(i32 %a, i32 %b)
|
2010-09-22 13:49:14 +08:00
|
|
|
; CHECK: calll foo
|
2010-03-11 08:22:57 +08:00
|
|
|
call void @foo() nounwind
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-12-02 05:04:44 +08:00
|
|
|
define ghccc i32 @addtwo(i32 %x, i32 %y) nounwind {
|
2010-03-11 08:22:57 +08:00
|
|
|
entry:
|
|
|
|
; CHECK: leal (%ebx,%ebp), %eax
|
|
|
|
%0 = add i32 %x, %y
|
|
|
|
; CHECK-NEXT: ret
|
|
|
|
ret i32 %0
|
|
|
|
}
|
|
|
|
|
2014-12-02 05:04:44 +08:00
|
|
|
define ghccc void @foo() nounwind {
|
2010-03-11 08:22:57 +08:00
|
|
|
entry:
|
2013-10-16 07:33:07 +08:00
|
|
|
; CHECK: movl r1, %esi
|
2013-06-25 10:48:58 +08:00
|
|
|
; CHECK-NEXT: movl hp, %edi
|
2013-10-16 07:33:07 +08:00
|
|
|
; CHECK-NEXT: movl sp, %ebp
|
|
|
|
; CHECK-NEXT: movl base, %ebx
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load i32, i32* @r1
|
|
|
|
%1 = load i32, i32* @hp
|
|
|
|
%2 = load i32, i32* @sp
|
|
|
|
%3 = load i32, i32* @base
|
2010-03-11 08:22:57 +08:00
|
|
|
; CHECK: jmp bar
|
2014-12-02 05:04:44 +08:00
|
|
|
tail call ghccc void @bar( i32 %3, i32 %2, i32 %1, i32 %0 ) nounwind
|
2010-03-11 08:22:57 +08:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-12-02 05:04:44 +08:00
|
|
|
declare ghccc void @bar(i32, i32, i32, i32)
|