summaryrefslogtreecommitdiff
path: root/flang/test/Transforms/omp-function-filtering.mlir
blob: 46291e9321f76a2d1dc177135046763bc5623256 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// RUN: fir-opt -split-input-file --omp-function-filtering %s | FileCheck %s

// CHECK: func.func @any
// CHECK: return
// CHECK: func.func @nohost
// CHECK: return
// CHECK-NOT: func.func {{.*}}}} @host
// CHECK-NOT: func.func {{.*}}}} @none
// CHECK: func.func @nohost_target
// CHECK: return
// CHECK: func.func @host_target
// CHECK: return
// CHECK: func.func @none_target
// CHECK: return
// CHECK: func.func @host_target_call
// CHECK-NOT: call @none_target
// CHECK: %[[UNDEF:.*]] = fir.undefined i32
// CHECK: return %[[UNDEF]] : i32
module attributes {omp.is_target_device = true} {
  func.func @any() -> ()
      attributes {
        omp.declare_target =
          #omp.declaretarget<device_type = (any), capture_clause = (to)>
      } {
    func.return
  }
  func.func @nohost() -> ()
      attributes {
        omp.declare_target =
          #omp.declaretarget<device_type = (nohost), capture_clause = (to)>
      } {
    func.return
  }
  func.func @host() -> ()
      attributes {
        omp.declare_target =
          #omp.declaretarget<device_type = (host), capture_clause = (to)>
      } {
    func.return
  }
  func.func @none() -> () {
    func.return
  }
  func.func @nohost_target() -> ()
      attributes {
        omp.declare_target =
          #omp.declaretarget<device_type = (nohost), capture_clause = (to)>
      } {
    omp.target {}
    func.return
  }
  func.func @host_target() -> ()
      attributes {
        omp.declare_target =
          #omp.declaretarget<device_type = (host), capture_clause = (to)>
      } {
    omp.target {}
    func.return
  }
  func.func @none_target() -> i32 {
    omp.target {}
    %0 = arith.constant 25 : i32
    func.return %0 : i32
  }
  func.func @host_target_call() -> i32
      attributes {
        omp.declare_target =
          #omp.declaretarget<device_type = (host), capture_clause = (to)>
      } {
    omp.target {}
    %0 = call @none_target() : () -> i32
    func.return %0 : i32
  }
}

// -----

// CHECK: func.func @any
// CHECK: return
// CHECK: func.func @nohost
// CHECK: return
// CHECK: func.func @host
// CHECK: return
// CHECK: func.func @none
// CHECK: return
// CHECK: func.func @nohost_target
// CHECK: return
// CHECK: func.func @host_target
// CHECK: return
// CHECK: func.func @none_target
// CHECK: return
module attributes {omp.is_target_device = false} {
  func.func @any() -> ()
      attributes {
        omp.declare_target =
          #omp.declaretarget<device_type = (any), capture_clause = (to)>
      } {
    func.return
  }
  func.func @nohost() -> ()
      attributes {
          omp.declare_target =
            #omp.declaretarget<device_type = (nohost), capture_clause = (to)>
      } {
    func.return
  }
  func.func @host() -> ()
      attributes {
        omp.declare_target =
          #omp.declaretarget<device_type = (host), capture_clause = (to)>
      } {
    func.return
  }
  func.func @none() -> () {
    func.return
  }
  func.func @nohost_target() -> ()
      attributes {
        omp.declare_target =
          #omp.declaretarget<device_type = (nohost), capture_clause = (to)>
      } {
    omp.target {}
    func.return
  }
  func.func @host_target() -> ()
      attributes {
        omp.declare_target =
          #omp.declaretarget<device_type = (host), capture_clause = (to)>
      } {
    omp.target {}
    func.return
  }
  func.func @none_target() -> () {
    omp.target {}
    func.return
  }
}