xref: /llvm-project/mlir/test/Target/LLVMIR/data-layout.mlir (revision adda597388dc148ac235e755b3e8bbd0a12a3e15)
1// RUN: mlir-translate -mlir-to-llvmir %s -split-input-file -verify-diagnostics | FileCheck %s
2
3// CHECK: target datalayout
4// CHECK: E-
5// CHECK: A4-
6// CHECK: S128-
7// CHECK: i64:64:128
8// CHECK: f80:128:256
9// CHECK: p0:32:64:128:32
10// CHECK: p1:32:32:32:16
11module attributes {dlti.dl_spec = #dlti.dl_spec<
12#dlti.dl_entry<"dlti.endianness", "big">,
13#dlti.dl_entry<"dlti.alloca_memory_space", 4 : ui32>,
14#dlti.dl_entry<"dlti.stack_alignment", 128 : i32>,
15#dlti.dl_entry<index, 64>,
16#dlti.dl_entry<i64, dense<[64,128]> : vector<2xi64>>,
17#dlti.dl_entry<f80, dense<[128,256]> : vector<2xi64>>,
18#dlti.dl_entry<!llvm.ptr, dense<[32,64,128]> : vector<3xi64>>,
19#dlti.dl_entry<!llvm.ptr<1>, dense<[32,32,32,16]> : vector<4xi64>>
20>} {
21  llvm.func @foo() {
22    llvm.return
23  }
24}
25
26// -----
27
28// CHECK: target datalayout
29// CHECK: e
30// CHECK-NOT: A0
31// CHECK-NOT: S0
32module attributes {dlti.dl_spec = #dlti.dl_spec<
33#dlti.dl_entry<"dlti.endianness", "little">,
34#dlti.dl_entry<"dlti.alloca_memory_space", 0 : ui32>,
35#dlti.dl_entry<"dlti.stack_alignment", 0 : i32>
36>} {
37  llvm.func @bar() {
38    llvm.return
39  }
40}
41
42// -----
43
44// expected-error@below {{unsupported data layout for non-signless integer 'ui64'}}
45module attributes {dlti.dl_spec = #dlti.dl_spec<
46#dlti.dl_entry<ui64, dense<[64,128]> : vector<2xi64>>>
47} {}
48
49// -----
50
51// expected-error@below {{unsupported type in data layout: 'bf16'}}
52module attributes {dlti.dl_spec = #dlti.dl_spec<
53#dlti.dl_entry<bf16, dense<[64,128]> : vector<2xi64>>>
54} {}
55
56// -----
57
58// expected-error@below {{unsupported data layout key "foo"}}
59module attributes {dlti.dl_spec = #dlti.dl_spec<
60#dlti.dl_entry<"foo", dense<[64,128]> : vector<2xi64>>>
61} {}
62