xref: /llvm-project/mlir/test/Target/LLVMIR/test.mlir (revision 9519e3ecbf6ed251c5ab7c74549fe86df1efc14c)
1// RUN: mlir-translate -test-to-llvmir -split-input-file %s | FileCheck %s
2
3module {
4  "test.symbol"() <{sym_name = "foo"}> : () -> ()
5}
6
7// CHECK-NOT: @sym_from_attr
8// CHECK: @foo = external global i32
9// CHECK-NOT: @sym_from_attr
10
11// -----
12
13// Make sure that the module attribute is processed before its body, so that the
14// `test.symbol` that is created as a result of the `test.discardable_mod_attr`
15// attribute is later picked up and translated to LLVM IR.
16module attributes {test.discardable_mod_attr = true} {}
17
18// CHECK: @sym_from_attr = external global i32
19
20// -----
21
22// CHECK-LABEL: @dialect_attr_translation
23llvm.func @dialect_attr_translation() {
24  // CHECK: ret void, !annotation ![[MD_ID:.+]]
25  llvm.return {test.add_annotation}
26}
27// CHECK: ![[MD_ID]] = !{!"annotation_from_test"}
28
29// -----
30
31// CHECK-LABEL: @dialect_attr_translation_multi
32llvm.func @dialect_attr_translation_multi(%a: i64, %b: i64, %c: i64) -> i64 {
33  // CHECK: add {{.*}}, !annotation ![[MD_ID_ADD:.+]]
34  // CHECK: mul {{.*}}, !annotation ![[MD_ID_MUL:.+]]
35  // CHECK: ret {{.*}}, !annotation ![[MD_ID_RET:.+]]
36  %ab = llvm.add %a, %b {test.add_annotation = "add"} : i64
37  %r = llvm.mul %ab, %c {test.add_annotation = "mul"} : i64
38  llvm.return {test.add_annotation = "ret"} %r : i64
39}
40// CHECK-DAG: ![[MD_ID_ADD]] = !{!"annotation_from_test: add"}
41// CHECK-DAG: ![[MD_ID_MUL]] = !{!"annotation_from_test: mul"}
42// CHECK-DAG: ![[MD_ID_RET]] = !{!"annotation_from_test: ret"}
43