brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · 8b2f142 Raw
61 lines · plain
1; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s2 3; CHECK-DAG: OpName [[FUN:%.+]] "fun"4; CHECK-DAG: OpName [[FOO:%.+]] "foo"5; CHECK-DAG: OpName [[GOO:%.+]] "goo"6 7; CHECK-NOT: DAG-FENCE8 9; CHECK-DAG: [[I16:%.+]] = OpTypeInt 1610; CHECK-DAG: [[I32:%.+]] = OpTypeInt 3211; CHECK-DAG: [[I64:%.+]] = OpTypeInt 6412; 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 21declare i32 @fun(i32 %value)22 23;; Check for @fun declaration24; CHECK:      [[FUN]] = OpFunction [[I32]] None [[FN1]]25; CHECK-NEXT: OpFunctionParameter [[I32]]26; CHECK-NEXT: OpFunctionEnd27 28 29define i32 @foo({i32, i16} %in, i64 %unused) {30  %first = extractvalue {i32, i16} %in, 031  %bar = call i32 @fun(i32 %first)32  ret i32 %bar33}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]] 040; CHECK:      [[AGG2:%.+]] = OpCompositeInsert [[PAIR]] [[B]] [[AGG1]] 141; CHECK:      [[RET:%.+]] = OpFunctionCall [[I32]] [[FOO]] [[AGG2]] [[C]]42; CHECK:      OpReturnValue [[RET]]43; CHECK:      OpFunctionEnd44 45; CHECK:      [[FOO]] = OpFunction [[I32]] None [[FN2]]46; CHECK-NEXT: [[IN:%.+]] = OpFunctionParameter [[PAIR]]47; CHECK-NEXT: OpFunctionParameter [[I64]]48; CHECK:      [[FIRST:%.+]] = OpCompositeExtract [[I32]] [[IN]] 049; CHECK:      [[BAR:%.+]] = OpFunctionCall [[I32]] [[FUN]] [[FIRST]]50; CHECK:      OpReturnValue [[BAR]]51; CHECK:      OpFunctionEnd52 53define i32 @goo(i32 %a, i16 %b, i64 %c) {54  %agg1 = insertvalue {i32, i16} undef, i32 %a, 055  %agg2 = insertvalue {i32, i16} %agg1, i16 %b, 156  %ret = call i32 @foo({i32, i16} %agg2, i64 %c)57  ret i32 %ret58}59 60;; TODO: test tailcall?61