Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 6 additions & 1 deletion mlir/include/mlir/IR/CommonAttrConstraints.td
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,12 @@ class AnyAttrOf<list<Attr> allowedAttrs, string summary = "",
}

def LocationAttr : Attr<CPred<"::llvm::isa<::mlir::LocationAttr>($_self)">,
"location attribute">;
"location attribute"> {
let storageType = [{ ::mlir::LocationAttr }];
let returnType = [{ ::mlir::Location }];
let convertFromStorage = "::mlir::Location($_self)";
let constBuilderCall = "(::mlir::LocationAttr)$0";
}

def BoolAttr : Attr<CPred<"::llvm::isa<::mlir::BoolAttr>($_self)">, "bool attribute"> {
let storageType = [{ ::mlir::BoolAttr }];
Expand Down
7 changes: 7 additions & 0 deletions mlir/test/IR/locations.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,10 @@ func.func @dialect_location() {
test.attr_with_loc("dialectLoc" loc(#test.custom_location<"foo.mlir"*32>))
return
}

// CHECK-LABEL: @location_attr
// CHECK: test.op_with_loc_attr loc("cheetos":10:20)
func.func @location_attr() {
test.op_with_loc_attr loc("cheetos":10:20)
return
}
6 changes: 6 additions & 0 deletions mlir/test/lib/Dialect/Test/TestOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -1192,6 +1192,12 @@ def TestLocationDstNoResOp : TEST_Op<"loc_dst_no_res"> {
let results = (outs);
}

def TestLocationAttrOp : TEST_Op<"op_with_loc_attr"> {
let arguments = (ins LocationAttr:$loc_attr);
let results = (outs );
let assemblyFormat = "$loc_attr attr-dict";
}

//===----------------------------------------------------------------------===//
// Test Patterns
//===----------------------------------------------------------------------===//
Expand Down
Loading