Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GDB prettyprinters for a few more MLIR types.
Reviewed By: dblaikie, jpienaar Differential Revision: https://reviews.llvm.org/D87159
- Loading branch information
Showing
8 changed files
with
417 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include "mlir/IR/Identifier.h" | ||
#include "mlir/IR/Location.h" | ||
#include "mlir/IR/MLIRContext.h" | ||
#include "mlir/IR/OperationSupport.h" | ||
#include "mlir/IR/StandardTypes.h" | ||
|
||
mlir::MLIRContext Context; | ||
|
||
auto Identifier = mlir::Identifier::get("foo", &Context); | ||
mlir::OperationName OperationName("FooOp", &Context); | ||
mlir::Value Value({reinterpret_cast<void *>(0x8), | ||
mlir::Value::Kind::TrailingOpResult}); | ||
|
||
mlir::Type Type(nullptr); | ||
mlir::Type IndexType = mlir::IndexType::get(&Context); | ||
mlir::Type IntegerType = | ||
mlir::IntegerType::get(3, mlir::IntegerType::Unsigned, &Context); | ||
mlir::Type FloatType = mlir::Float32Type::get(&Context); | ||
mlir::Type MemRefType = mlir::MemRefType::get({4, 5}, FloatType); | ||
mlir::Type UnrankedMemRefType = mlir::UnrankedMemRefType::get(IntegerType, 6); | ||
mlir::Type VectorType = mlir::VectorType::get({1, 2}, FloatType); | ||
mlir::Type TupleType = | ||
mlir::TupleType::get(mlir::TypeRange({IndexType, FloatType}), &Context); | ||
|
||
auto UnknownLoc = mlir::UnknownLoc::get(&Context); | ||
auto FileLineColLoc = mlir::FileLineColLoc::get("file", 7, 8, &Context); | ||
auto OpaqueLoc = mlir::OpaqueLoc::get<uintptr_t>(9, &Context); | ||
auto NameLoc = mlir::NameLoc::get(Identifier, &Context); | ||
auto CallSiteLoc = mlir::CallSiteLoc::get(FileLineColLoc, OpaqueLoc); | ||
auto FusedLoc = mlir::FusedLoc::get({FileLineColLoc, NameLoc}, &Context); | ||
|
||
mlir::Attribute UnitAttr = mlir::UnitAttr::get(&Context); | ||
mlir::Attribute FloatAttr = mlir::FloatAttr::get(FloatType, 1.0); | ||
mlir::Attribute IntegerAttr = mlir::IntegerAttr::get(IntegerType, 10); | ||
mlir::Attribute TypeAttr = mlir::TypeAttr::get(IndexType); | ||
mlir::Attribute ArrayAttr = mlir::ArrayAttr::get({UnitAttr}, &Context); | ||
mlir::Attribute StringAttr = mlir::StringAttr::get("foo", &Context); | ||
mlir::Attribute ElementsAttr = mlir::DenseElementsAttr::get( | ||
VectorType.cast<mlir::ShapedType>(), llvm::ArrayRef<float>{2.0f, 3.0f}); | ||
|
||
int main() { return 0; } |
112 changes: 112 additions & 0 deletions
112
debuginfo-tests/llvm-prettyprinters/gdb/mlir-support.gdb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
# RUN: gdb -q -batch -n -iex 'source %mlir_src_root/utils/gdb-scripts/prettyprinters.py' -iex 'source %llvm_src_root/utils/gdb-scripts/prettyprinters.py' -x %s %llvm_tools_dir/check-gdb-mlir-support | FileCheck %s | ||
# REQUIRES: debug-info | ||
# REQUIRES: mlir | ||
|
||
break main | ||
run | ||
|
||
# CHECK: "foo" | ||
p Identifier | ||
|
||
# CHECK: "FooOp" | ||
p OperationName | ||
|
||
# CHECK: 0x8 | ||
# CHECK: TrailingOpResult | ||
p Value | ||
|
||
# CHECK: impl = 0x0 | ||
p Type | ||
|
||
# CHECK: cast<mlir::IndexType> | ||
p IndexType | ||
|
||
# CHECK: cast<mlir::IntegerType> | ||
# CHECK: width = 3 | ||
# CHECK: Unsigned | ||
p IntegerType | ||
|
||
# CHECK: cast<mlir::Float32Type> | ||
p FloatType | ||
|
||
# CHECK: cast<mlir::MemRefType> | ||
# CHECK: shapeSize = 2 | ||
# CHECK: shapeElements[0] = 4 | ||
# CHECK: shapeElements[1] = 5 | ||
p MemRefType | ||
|
||
# CHECK: cast<mlir::UnrankedMemRefType> | ||
# CHECK: memorySpace = 6 | ||
p UnrankedMemRefType | ||
|
||
# CHECK: cast<mlir::VectorType> | ||
# CHECK: shapeSize = 2 | ||
# CHECK: shapeElements[0] = 1 | ||
# CHECK: shapeElements[1] = 2 | ||
p VectorType | ||
|
||
# CHECK: cast<mlir::TupleType> | ||
# CHECK: numElements = 2 | ||
# CHECK: elements[0] | ||
# CHECK: mlir::IndexType | ||
# CHECK: elements[1] | ||
# CHECK: mlir::Float32Type | ||
p TupleType | ||
|
||
# CHECK: cast<mlir::UnknownLoc> | ||
p UnknownLoc | ||
|
||
# CHECK: cast<mlir::FileLineColLoc> | ||
# CHECK: filename = "file" | ||
# CHECK: line = 7 | ||
# CHECK: column = 8 | ||
p FileLineColLoc | ||
|
||
# CHECK: cast<mlir::OpaqueLoc> | ||
# CHECK: underlyingLocation = 9 | ||
p OpaqueLoc | ||
|
||
# CHECK: cast<mlir::NameLoc> | ||
# CHECK: name = "foo" | ||
# CHECK: mlir::UnknownLoc | ||
p NameLoc | ||
|
||
# CHECK: cast<mlir::CallSiteLoc> | ||
# CHECK: callee | ||
# CHECK: mlir::FileLineColLoc | ||
# CHECK: caller | ||
# CHECK: mlir::OpaqueLoc | ||
p CallSiteLoc | ||
|
||
# CHECK: cast<mlir::FusedLoc> | ||
# CHECK: numLocs = 2 | ||
# CHECK: locs[0] | ||
# CHECK: mlir::FileLineColLoc | ||
# CHECK: locs[1] | ||
# CHECK: mlir::NameLoc | ||
p FusedLoc | ||
|
||
# CHECK: cast<mlir::UnitAttr> | ||
p UnitAttr | ||
|
||
# CHECK: cast<mlir::FloatAttr> | ||
p FloatAttr | ||
|
||
# CHECK: cast<mlir::IntegerAttr> | ||
p IntegerAttr | ||
|
||
# CHECK: cast<mlir::TypeAttr> | ||
# CHECK: mlir::IndexType | ||
p TypeAttr | ||
|
||
# CHECK: cast<mlir::ArrayAttr> | ||
# CHECK: llvm::ArrayRef of length 1 | ||
# CHECK: mlir::UnitAttr | ||
p ArrayAttr | ||
|
||
# CHECK: cast<mlir::StringAttr> | ||
# CHECK: value = "foo" | ||
p StringAttr | ||
|
||
# CHECK: cast<mlir::DenseIntOrFPElementsAttr> | ||
p ElementsAttr |
Oops, something went wrong.