-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[mlir] Add FileRange location type. #80213
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
Changes from 1 commit
9fc9ed3
b6c89f4
defb45c
fd1103a
744b2ec
381b3ce
e1a6e4d
ce7de0c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,46 +60,97 @@ def CallSiteLoc : Builtin_LocationAttr<"CallSiteLoc"> { | |
| } | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // FileLineColLoc | ||
| // FileLineColRange | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| def FileLineColLoc : Builtin_LocationAttr<"FileLineColLoc"> { | ||
| let summary = "A file:line:column source location"; | ||
| def FileLineColRange : Builtin_LocationAttr<"FileLineColRange"> { | ||
| let summary = "A file:line:column source location range"; | ||
| let description = [{ | ||
| Syntax: | ||
|
|
||
| ``` | ||
| filelinecol-location ::= string-literal `:` integer-literal `:` | ||
| integer-literal | ||
| (`to` (integer-literal ?) `:` integer-literal ?) | ||
| ``` | ||
|
|
||
| An instance of this location represents a tuple of file, line number, and | ||
| column number. This is similar to the type of location that you get from | ||
| most source languages. | ||
| An instance of this location represents a tuple of file, start and end line | ||
| number, and start and end column number. It allows for the following | ||
| configurations: | ||
|
|
||
| * A single file line location: `file:line`; | ||
| * A single file line col location: `file:line:column`; | ||
| * A single line range: `file:line:column to :column`; | ||
| * A single file range: `file:line:column to line:column`; | ||
|
|
||
| Example: | ||
|
|
||
| ```mlir | ||
| loc("mysource.cc":10:8) | ||
| loc("mysource.cc":10:8 to 12:18) | ||
| ``` | ||
| }]; | ||
| let parameters = (ins "StringAttr":$filename, "unsigned":$line, | ||
| "unsigned":$column); | ||
|
|
||
| // Note: this only shows the parameters for which accessors are generated. The | ||
| // locations are only set in storage. | ||
| let parameters = (ins "StringAttr":$filename); | ||
| let builders = [ | ||
|
|
||
| AttrBuilderWithInferredContext<(ins "StringAttr":$filename), [{ | ||
jpienaar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return $_get(filename.getContext(), filename, ArrayRef<unsigned>{}); | ||
| }]>, | ||
| AttrBuilderWithInferredContext<(ins "StringAttr":$filename, | ||
| "unsigned":$line), [{ | ||
| return $_get(filename.getContext(), filename, | ||
| ArrayRef<unsigned>{line}); | ||
| }]>, | ||
| AttrBuilderWithInferredContext<(ins "StringAttr":$filename, | ||
| "unsigned":$line, | ||
| "unsigned":$column), [{ | ||
| return $_get(filename.getContext(), filename, line, column); | ||
| return $_get(filename.getContext(), filename, | ||
| ArrayRef<unsigned>{line, column}); | ||
| }]>, | ||
| AttrBuilder<(ins "StringRef":$filename, "unsigned":$line, | ||
| "unsigned":$column), [{ | ||
| AttrBuilder<(ins "::llvm::StringRef":$filename, | ||
| "unsigned":$start_line, | ||
| "unsigned":$start_column), [{ | ||
| return $_get($_ctxt, | ||
| StringAttr::get($_ctxt, filename.empty() ? "-" : filename), | ||
| line, column); | ||
| }]> | ||
| StringAttr::get($_ctxt, filename.empty() ? "-" : filename), | ||
| ArrayRef<unsigned>{start_line, start_column}); | ||
| }]>, | ||
| AttrBuilderWithInferredContext<(ins "::mlir::StringAttr":$filename, | ||
| "unsigned":$line, | ||
| "unsigned":$start_column, | ||
| "unsigned":$end_column), [{ | ||
| return $_get(filename.getContext(), filename, | ||
| ArrayRef<unsigned>{line, start_column, end_column}); | ||
| }]>, | ||
| AttrBuilderWithInferredContext<(ins "::mlir::StringAttr":$filename, | ||
| "unsigned":$start_line, | ||
| "unsigned":$start_column, | ||
| "unsigned":$end_line, | ||
| "unsigned":$end_column), [{ | ||
| return $_get(filename.getContext(), filename, | ||
| ArrayRef<unsigned>{start_line, start_column, end_column, end_line}); | ||
| }]>, | ||
| AttrBuilder<(ins "::llvm::StringRef":$filename, | ||
| "unsigned":$start_line, | ||
| "unsigned":$start_column, | ||
| "unsigned":$end_line, | ||
| "unsigned":$end_column), [{ | ||
| return $_get($_ctxt, | ||
| StringAttr::get($_ctxt, filename.empty() ? "-" : filename), | ||
| ArrayRef<unsigned>{start_line, start_column, end_column, end_line}); | ||
| }]>, | ||
| ]; | ||
|
|
||
| let extraClassDeclaration = [{ | ||
| std::optional<unsigned> getStartLine() const; | ||
| std::optional<unsigned> getStartColumn() const; | ||
| std::optional<unsigned> getEndColumn() const; | ||
| std::optional<unsigned> getEndLine() const; | ||
|
||
| }]; | ||
| let skipDefaultBuilders = 1; | ||
| let attrName = "builtin.file_line_loc"; | ||
| let genStorageClass = 0; | ||
| let attrName = "builtin.file_line_range"; | ||
| } | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.