Krzysztof Parzyszek | d91a9e2 | 2018-08-02 22:17:53 +0000 | [diff] [blame] | 1 | ; RUN: llc -march=hexagon -enable-save-restore-long -hexagon-initial-cfg-cleanup=0 < %s | FileCheck %s |
Krzysztof Parzyszek | 080bebd | 2016-07-25 14:42:11 +0000 | [diff] [blame] | 2 | |
| 3 | ; Check that the -long-calls feature is supported by the backend. |
| 4 | |
| 5 | ; CHECK: call ##foo |
| 6 | ; CHECK: jump ##__restore |
| 7 | define i64 @test_longcall(i32 %x, i32 %y) #0 { |
| 8 | entry: |
| 9 | %add = add nsw i32 %x, 5 |
Krzysztof Parzyszek | d91a9e2 | 2018-08-02 22:17:53 +0000 | [diff] [blame] | 10 | %call = tail call i64 @foo(i32 %add) #1 |
Krzysztof Parzyszek | 080bebd | 2016-07-25 14:42:11 +0000 | [diff] [blame] | 11 | %conv = sext i32 %y to i64 |
| 12 | %add1 = add nsw i64 %call, %conv |
| 13 | ret i64 %add1 |
| 14 | } |
| 15 | |
| 16 | ; CHECK: jump ##foo |
| 17 | define i64 @test_longtailcall(i32 %x, i32 %y) #1 { |
| 18 | entry: |
| 19 | %add = add nsw i32 %x, 5 |
Krzysztof Parzyszek | d91a9e2 | 2018-08-02 22:17:53 +0000 | [diff] [blame] | 20 | %call = tail call i64 @foo(i32 %add) #1 |
Krzysztof Parzyszek | 080bebd | 2016-07-25 14:42:11 +0000 | [diff] [blame] | 21 | ret i64 %call |
| 22 | } |
| 23 | |
| 24 | ; CHECK: call ##bar |
| 25 | define i64 @test_longnoret(i32 %x, i32 %y) #2 { |
| 26 | entry: |
| 27 | %add = add nsw i32 %x, 5 |
Krzysztof Parzyszek | d91a9e2 | 2018-08-02 22:17:53 +0000 | [diff] [blame] | 28 | %0 = tail call i64 @bar(i32 %add) #6 |
Krzysztof Parzyszek | 080bebd | 2016-07-25 14:42:11 +0000 | [diff] [blame] | 29 | unreachable |
| 30 | } |
| 31 | |
| 32 | ; CHECK: call foo |
| 33 | ; CHECK: jump ##__restore |
| 34 | ; The restore call will still be long because of the enable-save-restore-long |
| 35 | ; option being used. |
| 36 | define i64 @test_shortcall(i32 %x, i32 %y) #3 { |
| 37 | entry: |
| 38 | %add = add nsw i32 %x, 5 |
Krzysztof Parzyszek | d91a9e2 | 2018-08-02 22:17:53 +0000 | [diff] [blame] | 39 | %call = tail call i64 @foo(i32 %add) #1 |
Krzysztof Parzyszek | 080bebd | 2016-07-25 14:42:11 +0000 | [diff] [blame] | 40 | %conv = sext i32 %y to i64 |
| 41 | %add1 = add nsw i64 %call, %conv |
| 42 | ret i64 %add1 |
| 43 | } |
| 44 | |
| 45 | ; CHECK: jump foo |
| 46 | define i64 @test_shorttailcall(i32 %x, i32 %y) #4 { |
| 47 | entry: |
| 48 | %add = add nsw i32 %x, 5 |
Krzysztof Parzyszek | d91a9e2 | 2018-08-02 22:17:53 +0000 | [diff] [blame] | 49 | %call = tail call i64 @foo(i32 %add) #1 |
Krzysztof Parzyszek | 080bebd | 2016-07-25 14:42:11 +0000 | [diff] [blame] | 50 | ret i64 %call |
| 51 | } |
| 52 | |
| 53 | ; CHECK: call bar |
| 54 | define i64 @test_shortnoret(i32 %x, i32 %y) #5 { |
| 55 | entry: |
| 56 | %add = add nsw i32 %x, 5 |
Krzysztof Parzyszek | d91a9e2 | 2018-08-02 22:17:53 +0000 | [diff] [blame] | 57 | %0 = tail call i64 @bar(i32 %add) #6 |
Krzysztof Parzyszek | 080bebd | 2016-07-25 14:42:11 +0000 | [diff] [blame] | 58 | unreachable |
| 59 | } |
| 60 | |
Krzysztof Parzyszek | d91a9e2 | 2018-08-02 22:17:53 +0000 | [diff] [blame] | 61 | declare i64 @foo(i32) #1 |
| 62 | declare i64 @bar(i32) #6 |
Krzysztof Parzyszek | 080bebd | 2016-07-25 14:42:11 +0000 | [diff] [blame] | 63 | |
| 64 | attributes #0 = { minsize nounwind "target-cpu"="hexagonv60" "target-features"="+long-calls" } |
| 65 | attributes #1 = { nounwind "target-cpu"="hexagonv60" "target-features"="+long-calls" } |
| 66 | attributes #2 = { noreturn nounwind "target-cpu"="hexagonv60" "target-features"="+long-calls" } |
| 67 | |
| 68 | attributes #3 = { minsize nounwind "target-cpu"="hexagonv60" "target-features"="-long-calls" } |
| 69 | attributes #4 = { nounwind "target-cpu"="hexagonv60" "target-features"="-long-calls" } |
| 70 | attributes #5 = { noreturn nounwind "target-cpu"="hexagonv60" "target-features"="-long-calls" } |
| 71 | |
Krzysztof Parzyszek | d91a9e2 | 2018-08-02 22:17:53 +0000 | [diff] [blame] | 72 | attributes #6 = { noreturn nounwind "target-cpu"="hexagonv60" } |