Skip to content

[mlir][DLTI] Make getPreferredAlignment default to getABIAlignment #128754

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.td
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class LLVMType<string typeName, string typeMnemonic, list<Trait> traits = []>
//===----------------------------------------------------------------------===//

def LLVMArrayType : LLVMType<"LLVMArray", "array", [
DeclareTypeInterfaceMethods<DataLayoutTypeInterface, ["getTypeSize"]>,
DeclareTypeInterfaceMethods<DataLayoutTypeInterface,
["getTypeSize", "getPreferredAlignment"]>,
DeclareTypeInterfaceMethods<DestructurableTypeInterface>]> {
let summary = "LLVM array type";
let description = [{
Expand Down Expand Up @@ -124,7 +125,7 @@ def LLVMFunctionType : LLVMType<"LLVMFunction", "func"> {
def LLVMStructType : LLVMType<"LLVMStruct", "struct", [
MutableType,
DeclareTypeInterfaceMethods<DataLayoutTypeInterface,
["areCompatible", "verifyEntries"]>,
["areCompatible", "verifyEntries", "getPreferredAlignment"]>,
DeclareTypeInterfaceMethods<DestructurableTypeInterface,
["getSubelementIndexMap", "getTypeAtIndex"]>
]> {
Expand Down Expand Up @@ -257,7 +258,8 @@ def LLVMStructType : LLVMType<"LLVMStruct", "struct", [

def LLVMPointerType : LLVMType<"LLVMPointer", "ptr", [
DeclareTypeInterfaceMethods<DataLayoutTypeInterface, [
"getIndexBitwidth", "areCompatible", "verifyEntries"]>]> {
"getIndexBitwidth", "areCompatible", "verifyEntries",
"getPreferredAlignment"]>]> {
let summary = "LLVM pointer type";
let description = [{
The `!llvm.ptr` type is an LLVM pointer type. This type typically represents
Expand Down
3 changes: 2 additions & 1 deletion mlir/include/mlir/Dialect/Ptr/IR/PtrDialect.td
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ class Ptr_Type<string name, string typeMnemonic, list<Trait> traits = []>
def Ptr_PtrType : Ptr_Type<"Ptr", "ptr", [
MemRefElementTypeInterface,
DeclareTypeInterfaceMethods<DataLayoutTypeInterface, [
"areCompatible", "getIndexBitwidth", "verifyEntries"]>
"areCompatible", "getIndexBitwidth", "verifyEntries",
"getPreferredAlignment"]>
]> {
let summary = "pointer type";
let description = [{
Expand Down
6 changes: 5 additions & 1 deletion mlir/include/mlir/Interfaces/DataLayoutInterfaces.td
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,11 @@ def DataLayoutTypeInterface : TypeInterface<"DataLayoutTypeInterface"> {
/*retTy=*/"uint64_t",
/*methodName=*/"getPreferredAlignment",
/*args=*/(ins "const ::mlir::DataLayout &":$dataLayout,
"::mlir::DataLayoutEntryListRef":$params)
"::mlir::DataLayoutEntryListRef":$params),
/*methodBody=*/"",
/*defaultImplementation=*/[{
return $_type.getABIAlignment(dataLayout, params);
}]
>,
InterfaceMethod<
/*description=*/"Returns the bitwidth that should be used when "
Expand Down
4 changes: 2 additions & 2 deletions mlir/test/lib/Dialect/Test/TestTypeDefs.td
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ def TestType : Test_Type<"Test", [
}

def TestTypeWithLayoutType : Test_Type<"TestTypeWithLayout", [
DeclareTypeInterfaceMethods<DataLayoutTypeInterface, ["getIndexBitwidth",
"areCompatible"]>
DeclareTypeInterfaceMethods<DataLayoutTypeInterface,
["getIndexBitwidth", "areCompatible", "getPreferredAlignment"]>
]> {
let mnemonic = "test_type_with_layout";
let parameters = (ins "unsigned":$key);
Expand Down