Changeset View
Changeset View
Standalone View
Standalone View
mlir/examples/toy/Ch7/mlir/Dialect.cpp
Show First 20 Lines • Show All 469 Lines • ▼ Show 20 Lines | |||||
/// Create an instance of a `StructType` with the given element types. There | /// Create an instance of a `StructType` with the given element types. There | ||||
/// *must* be at least one element type. | /// *must* be at least one element type. | ||||
StructType StructType::get(llvm::ArrayRef<mlir::Type> elementTypes) { | StructType StructType::get(llvm::ArrayRef<mlir::Type> elementTypes) { | ||||
assert(!elementTypes.empty() && "expected at least 1 element type"); | assert(!elementTypes.empty() && "expected at least 1 element type"); | ||||
// Call into a helper 'get' method in 'TypeBase' to get a uniqued instance | // Call into a helper 'get' method in 'TypeBase' to get a uniqued instance | ||||
// of this type. The first parameter is the context to unique in. The | // of this type. The first parameter is the context to unique in. The | ||||
// parameters after the type kind are forwarded to the storage instance. | // parameters after the context are forwarded to the storage instance. | ||||
mlir::MLIRContext *ctx = elementTypes.front().getContext(); | mlir::MLIRContext *ctx = elementTypes.front().getContext(); | ||||
return Base::get(ctx, elementTypes); | return Base::get(ctx, elementTypes); | ||||
} | } | ||||
/// Returns the element types of this struct type. | /// Returns the element types of this struct type. | ||||
llvm::ArrayRef<mlir::Type> StructType::getElementTypes() { | llvm::ArrayRef<mlir::Type> StructType::getElementTypes() { | ||||
// 'getImpl' returns a pointer to the internal storage instance. | // 'getImpl' returns a pointer to the internal storage instance. | ||||
return getImpl()->elementTypes; | return getImpl()->elementTypes; | ||||
▲ Show 20 Lines • Show All 61 Lines • Show Last 20 Lines |