1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -tailcallopt -mtriple=i686-linux-gnu | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker 3*9880d681SAndroid Build Coastguard Worker; Test the GHC call convention works (x86-32) 4*9880d681SAndroid Build Coastguard Worker 5*9880d681SAndroid Build Coastguard Worker@base = external global i32 ; assigned to register: EBX 6*9880d681SAndroid Build Coastguard Worker@sp = external global i32 ; assigned to register: EBP 7*9880d681SAndroid Build Coastguard Worker@hp = external global i32 ; assigned to register: EDI 8*9880d681SAndroid Build Coastguard Worker@r1 = external global i32 ; assigned to register: ESI 9*9880d681SAndroid Build Coastguard Worker 10*9880d681SAndroid Build Coastguard Workerdefine void @zap(i32 %a, i32 %b) nounwind { 11*9880d681SAndroid Build Coastguard Workerentry: 12*9880d681SAndroid Build Coastguard Worker ; CHECK: movl {{[0-9]*}}(%esp), %ebx 13*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: movl {{[0-9]*}}(%esp), %ebp 14*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: calll addtwo 15*9880d681SAndroid Build Coastguard Worker %0 = call ghccc i32 @addtwo(i32 %a, i32 %b) 16*9880d681SAndroid Build Coastguard Worker ; CHECK: calll foo 17*9880d681SAndroid Build Coastguard Worker call void @foo() nounwind 18*9880d681SAndroid Build Coastguard Worker ret void 19*9880d681SAndroid Build Coastguard Worker} 20*9880d681SAndroid Build Coastguard Worker 21*9880d681SAndroid Build Coastguard Workerdefine ghccc i32 @addtwo(i32 %x, i32 %y) nounwind { 22*9880d681SAndroid Build Coastguard Workerentry: 23*9880d681SAndroid Build Coastguard Worker ; CHECK: leal (%ebx,%ebp), %eax 24*9880d681SAndroid Build Coastguard Worker %0 = add i32 %x, %y 25*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: ret 26*9880d681SAndroid Build Coastguard Worker ret i32 %0 27*9880d681SAndroid Build Coastguard Worker} 28*9880d681SAndroid Build Coastguard Worker 29*9880d681SAndroid Build Coastguard Workerdefine ghccc void @foo() nounwind { 30*9880d681SAndroid Build Coastguard Workerentry: 31*9880d681SAndroid Build Coastguard Worker ; CHECK: movl r1, %esi 32*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: movl hp, %edi 33*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: movl sp, %ebp 34*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: movl base, %ebx 35*9880d681SAndroid Build Coastguard Worker %0 = load i32, i32* @r1 36*9880d681SAndroid Build Coastguard Worker %1 = load i32, i32* @hp 37*9880d681SAndroid Build Coastguard Worker %2 = load i32, i32* @sp 38*9880d681SAndroid Build Coastguard Worker %3 = load i32, i32* @base 39*9880d681SAndroid Build Coastguard Worker ; CHECK: jmp bar 40*9880d681SAndroid Build Coastguard Worker tail call ghccc void @bar( i32 %3, i32 %2, i32 %1, i32 %0 ) nounwind 41*9880d681SAndroid Build Coastguard Worker ret void 42*9880d681SAndroid Build Coastguard Worker} 43*9880d681SAndroid Build Coastguard Worker 44*9880d681SAndroid Build Coastguard Workerdeclare ghccc void @bar(i32, i32, i32, i32) 45