Skip to content

Commit 36c3ba4

Browse files
committed
Add tests exercising DLTI
1 parent facc907 commit 36c3ba4

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// REQUIRES: target=x86{{.*}}
2+
3+
// RUN: mlir-opt -transform-interpreter -split-input-file %s | FileCheck %s
4+
5+
// Check that processor features, like AVX, are appropriated derived and queryable.
6+
7+
// expected-remark @+2 {{attr associated to ["features", "+avx"] = unit}}
8+
// expected-remark @below {{attr associated to ["features", "avx"] = true}}
9+
module attributes { llvm.target = #llvm.target<triple = "x86_64-unknown-linux",
10+
chip = "skylake">,
11+
test.dl_spec = #dlti.dl_spec<index = 32> } {
12+
func.func private @f()
13+
}
14+
15+
module attributes {transform.with_named_sequence} {
16+
transform.named_sequence @__transform_main(%arg: !transform.any_op) {
17+
%funcs = transform.structured.match ops{["func.func"]} in %arg : (!transform.any_op) -> !transform.any_op
18+
%module = transform.get_parent_op %funcs : (!transform.any_op) -> !transform.any_op
19+
%mod = transform.apply_registered_pass "llvm-target-to-target-features" to %module : (!transform.any_op) -> !transform.any_op
20+
%plus_avx = transform.dlti.query ["features", "+avx"] at %mod : (!transform.any_op) -> !transform.any_param
21+
transform.debug.emit_param_as_remark %plus_avx, "attr associated to [\"features\", \"+avx\"] =" at %mod : !transform.any_param, !transform.any_op
22+
%avx = transform.dlti.query ["features", "avx"] at %mod : (!transform.any_op) -> !transform.any_param
23+
transform.debug.emit_param_as_remark %avx, "attr associated to [\"features\", \"avx\"] =" at %mod : !transform.any_param, !transform.any_op
24+
transform.yield
25+
}
26+
}
27+
28+
// -----
29+
30+
// Check that features that a processor does not have, AVX512f in this case,
31+
// aren't derived and hence that querying for them will fail.
32+
33+
// expected-error @+2 {{target op of failed DLTI query}}
34+
// expected-note @below {{key "+avx512f" has no DLTI-mapping per attr: #llvm.target_features<[}}
35+
module attributes { llvm.target = #llvm.target<triple = "x86_64-unknown-linux",
36+
chip = "skylake">,
37+
test.dl_spec = #dlti.dl_spec<index = 32> } {
38+
func.func private @f()
39+
}
40+
41+
module attributes {transform.with_named_sequence} {
42+
transform.named_sequence @__transform_main(%arg: !transform.any_op) {
43+
%funcs = transform.structured.match ops{["func.func"]} in %arg : (!transform.any_op) -> !transform.any_op
44+
%module = transform.get_parent_op %funcs : (!transform.any_op) -> !transform.any_op
45+
%mod = transform.apply_registered_pass "llvm-target-to-target-features" to %module : (!transform.any_op) -> !transform.any_op
46+
// expected-error @below {{'transform.dlti.query' op failed to apply}}
47+
%param = transform.dlti.query ["features", "+avx512f"] at %mod : (!transform.any_op) -> !transform.any_param
48+
transform.yield
49+
}
50+
}

0 commit comments

Comments
 (0)