| 1 |
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s |
| 2 |
|
| 3 |
; CHECK-DAG: OpName [[FUN:%.+]] "fun" |
| 4 |
; CHECK-DAG: OpName [[FOO:%.+]] "foo" |
| 5 |
; CHECK-DAG: OpName [[GOO:%.+]] "goo" |
| 6 |
|
| 7 |
; CHECK-NOT: DAG-FENCE |
| 8 |
|
| 9 |
; CHECK-DAG: [[I16:%.+]] = OpTypeInt 16 |
| 10 |
; CHECK-DAG: [[I32:%.+]] = OpTypeInt 32 |
| 11 |
; CHECK-DAG: [[I64:%.+]] = OpTypeInt 64 |
| 12 |
; CHECK-DAG: [[FN3:%.+]] = OpTypeFunction [[I32]] [[I32]] [[I16]] [[I64]] |
| 13 |
; CHECK-DAG: [[PAIR:%.+]] = OpTypeStruct [[I32]] [[I16]] |
| 14 |
; CHECK-DAG: [[FN1:%.+]] = OpTypeFunction [[I32]] [[I32]] |
| 15 |
; CHECK-DAG: [[FN2:%.+]] = OpTypeFunction [[I32]] [[PAIR]] [[I64]] |
| 16 |
;; According to the Specification, the OpUndef can be defined in Function. |
| 17 |
;; But the Specification also recommends defining it here. So we enforce that. |
| 18 |
; CHECK-DAG: [[UNDEF:%.+]] = OpUndef [[PAIR]] |
| 19 |
|
| 20 |
|
| 21 |
declare i32 @fun(i32 %value) |
| 22 |
|
| 23 |
;; Check for @fun declaration |
| 24 |
; CHECK: [[FUN]] = OpFunction [[I32]] None [[FN1]] |
| 25 |
; CHECK-NEXT: OpFunctionParameter [[I32]] |
| 26 |
; CHECK-NEXT: OpFunctionEnd |
| 27 |
|
| 28 |
|
| 29 |
define i32 @foo({i32, i16} %in, i64 %unused) { |
| 30 |
%first = extractvalue {i32, i16} %in, 0 |
| 31 |
%bar = call i32 @fun(i32 %first) |
| 32 |
ret i32 %bar |
| 33 |
} |
| 34 |
|
| 35 |
; CHECK: [[GOO]] = OpFunction [[I32]] None [[FN3]] |
| 36 |
; CHECK-NEXT: [[A:%.+]] = OpFunctionParameter [[I32]] |
| 37 |
; CHECK-NEXT: [[B:%.+]] = OpFunctionParameter [[I16]] |
| 38 |
; CHECK-NEXT: [[C:%.+]] = OpFunctionParameter [[I64]] |
| 39 |
; CHECK: [[AGG1:%.+]] = OpCompositeInsert [[PAIR]] [[A]] [[UNDEF]] 0 |
| 40 |
; CHECK: [[AGG2:%.+]] = OpCompositeInsert [[PAIR]] [[B]] [[AGG1]] 1 |
| 41 |
; CHECK: [[RET:%.+]] = OpFunctionCall [[I32]] [[FOO]] [[AGG2]] [[C]] |
| 42 |
; CHECK: OpReturnValue [[RET]] |
| 43 |
; CHECK: OpFunctionEnd |
| 44 |
|
| 45 |
; CHECK: [[FOO]] = OpFunction [[I32]] None [[FN2]] |
| 46 |
; CHECK-NEXT: [[IN:%.+]] = OpFunctionParameter [[PAIR]] |
| 47 |
; CHECK-NEXT: OpFunctionParameter [[I64]] |
| 48 |
; CHECK: [[FIRST:%.+]] = OpCompositeExtract [[I32]] [[IN]] 0 |
| 49 |
; CHECK: [[BAR:%.+]] = OpFunctionCall [[I32]] [[FUN]] [[FIRST]] |
| 50 |
; CHECK: OpReturnValue [[BAR]] |
| 51 |
; CHECK: OpFunctionEnd |
| 52 |
|
| 53 |
define i32 @goo(i32 %a, i16 %b, i64 %c) { |
| 54 |
%agg1 = insertvalue {i32, i16} undef, i32 %a, 0 |
| 55 |
%agg2 = insertvalue {i32, i16} %agg1, i16 %b, 1 |
| 56 |
%ret = call i32 @foo({i32, i16} %agg2, i64 %c) |
| 57 |
ret i32 %ret |
| 58 |
} |
| 59 |
|
| 60 |
;; TODO: test tailcall? |