mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-27 16:56:06 +00:00

When importing from LLVM IR the data layout of all pointer types contains an index bitwidth that should be used for index computations. This revision adds a getter to the DataLayout that provides access to the already stored bitwidth. The function returns an optional since only pointer-like types have an index bitwidth. Querying the bitwidth of a non-pointer type returns std::nullopt. The new function works for the built-in Index type and, using a type interface, for the LLVMPointerType.
18 lines
626 B
MLIR
18 lines
626 B
MLIR
// RUN: mlir-opt --test-data-layout-query %s | FileCheck %s
|
|
|
|
module attributes { dlti.dl_spec = #dlti.dl_spec<
|
|
#dlti.dl_entry<!test.test_type_with_layout<10>, ["size", 12]>,
|
|
#dlti.dl_entry<!test.test_type_with_layout<20>, ["alignment", 32]>,
|
|
#dlti.dl_entry<!test.test_type_with_layout<30>, ["index", 7]>>} {
|
|
// CHECK-LABEL: @module_level_layout
|
|
func.func @module_level_layout() {
|
|
// CHECK: alignment = 32
|
|
// CHECK: bitsize = 12
|
|
// CHECK: index = 7
|
|
// CHECK: preferred = 1
|
|
// CHECK: size = 2
|
|
"test.data_layout_query"() : () -> !test.test_type_with_layout<10>
|
|
return
|
|
}
|
|
}
|