Skip to content

Commit dbef79c

Browse files
Add missing LLVM test
1 parent f06ddf7 commit dbef79c

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2+
# See https://llvm.org/LICENSE.txt for license information.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
from textwrap import dedent
5+
6+
import mlir.extras.types as T
7+
import pytest
8+
9+
from mlir.extras.dialects import llvm
10+
from mlir.extras.dialects.func import func
11+
12+
# noinspection PyUnresolvedReferences
13+
from mlir.extras.testing import MLIRContext, filecheck, mlir_ctx as ctx
14+
from util import llvm_bindings_not_installed, llvm_amdgcn_bindings_not_installed
15+
16+
# needed since the fix isn't defined here nor conftest.py
17+
pytest.mark.usefixtures("ctx")
18+
19+
20+
@pytest.mark.skipif(
21+
llvm_bindings_not_installed() or llvm_amdgcn_bindings_not_installed(),
22+
reason="llvm bindings not installed or llvm_amdgcn bindings not installed",
23+
)
24+
def test_call_instrinsic(ctx: MLIRContext):
25+
@func(emit=True)
26+
def sum(a: T.i32(), b: T.i32(), c: T.f32()):
27+
e = llvm.amdgcn.cvt_pk_i16(a, b)
28+
f = llvm.amdgcn.frexp_mant(c)
29+
30+
correct = dedent(
31+
"""
32+
module {
33+
func.func @sum(%arg0: i32, %arg1: i32, %arg2: f32) {
34+
%0 = llvm.call_intrinsic "llvm.amdgcn.cvt.pk.i16"(%arg0, %arg1) : (i32, i32) -> vector<2xi16>
35+
%1 = llvm.call_intrinsic "llvm.amdgcn.frexp.mant"(%arg2) : (f32) -> f32
36+
return
37+
}
38+
}
39+
"""
40+
)
41+
filecheck(correct, ctx.module)

0 commit comments

Comments
 (0)