MLIR  20.0.0git
Functions | Variables
DataLayoutInterfaces.cpp File Reference
#include "mlir/Interfaces/DataLayoutInterfaces.h"
#include "mlir/IR/BuiltinDialect.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Operation.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/MathExtras.h"
#include "mlir/Interfaces/DataLayoutAttrInterface.cpp.inc"
#include "mlir/Interfaces/DataLayoutOpInterface.cpp.inc"
#include "mlir/Interfaces/DataLayoutTypeInterface.cpp.inc"

Go to the source code of this file.

Functions

static void reportMissingDataLayout (Type type)
 Reports that the given type is missing the data layout information and exits. More...
 
static uint64_t getIndexBitwidth (DataLayoutEntryListRef params)
 Returns the bitwidth of the index type if specified in the param list. More...
 
static DataLayoutEntryInterface findEntryForIntegerType (IntegerType intType, ArrayRef< DataLayoutEntryInterface > params)
 
static uint64_t extractABIAlignment (DataLayoutEntryInterface entry)
 
static uint64_t getIntegerTypeABIAlignment (IntegerType intType, ArrayRef< DataLayoutEntryInterface > params)
 
static uint64_t getFloatTypeABIAlignment (FloatType fltType, const DataLayout &dataLayout, ArrayRef< DataLayoutEntryInterface > params)
 
static uint64_t extractPreferredAlignment (DataLayoutEntryInterface entry)
 
static uint64_t getIntegerTypePreferredAlignment (IntegerType intType, const DataLayout &dataLayout, ArrayRef< DataLayoutEntryInterface > params)
 
static uint64_t getFloatTypePreferredAlignment (FloatType fltType, const DataLayout &dataLayout, ArrayRef< DataLayoutEntryInterface > params)
 
static DataLayoutSpecInterface getSpec (Operation *operation)
 
static TargetSystemSpecInterface getTargetSystemSpec (Operation *operation)
 
static void collectParentLayouts (Operation *leaf, SmallVectorImpl< DataLayoutSpecInterface > &specs, SmallVectorImpl< Location > *opLocations=nullptr)
 Populates opsWithLayout with the list of proper ancestors of leaf that are either modules or implement the DataLayoutOpInterface. More...
 
static DataLayoutSpecInterface getCombinedDataLayout (Operation *leaf)
 Returns a layout spec that is a combination of the layout specs attached to the given operation and all its ancestors. More...
 
template<typename OpTy >
void checkMissingLayout (DataLayoutSpecInterface originalLayout, OpTy op)
 
template<typename T >
static T cachedLookup (Type t, DenseMap< Type, T > &cache, function_ref< T(Type)> compute)
 Looks up the value for the given type key in the given cache. More...
 

Variables

constexpr static const uint64_t kDefaultBitsInByte = 8u
 

Function Documentation

◆ cachedLookup()

template<typename T >
static T cachedLookup ( Type  t,
DenseMap< Type, T > &  cache,
function_ref< T(Type)>  compute 
)
static

Looks up the value for the given type key in the given cache.

If there is no such value in the cache, compute it using the given callback and put it in the cache before returning.

Definition at line 513 of file DataLayoutInterfaces.cpp.

◆ checkMissingLayout()

template<typename OpTy >
void checkMissingLayout ( DataLayoutSpecInterface  originalLayout,
OpTy  op 
)

Definition at line 443 of file DataLayoutInterfaces.cpp.

Referenced by mlir::DataLayout::DataLayout().

◆ collectParentLayouts()

static void collectParentLayouts ( Operation leaf,
SmallVectorImpl< DataLayoutSpecInterface > &  specs,
SmallVectorImpl< Location > *  opLocations = nullptr 
)
static

Populates opsWithLayout with the list of proper ancestors of leaf that are either modules or implement the DataLayoutOpInterface.

Definition at line 348 of file DataLayoutInterfaces.cpp.

References mlir::Operation::getParentOp().

Referenced by mlir::DataLayout::DataLayout(), getCombinedDataLayout(), and mlir::detail::verifyDataLayoutOp().

◆ extractABIAlignment()

static uint64_t extractABIAlignment ( DataLayoutEntryInterface  entry)
static

Definition at line 109 of file DataLayoutInterfaces.cpp.

References kDefaultBitsInByte.

Referenced by getFloatTypeABIAlignment(), and getIntegerTypeABIAlignment().

◆ extractPreferredAlignment()

static uint64_t extractPreferredAlignment ( DataLayoutEntryInterface  entry)
static

◆ findEntryForIntegerType()

static DataLayoutEntryInterface findEntryForIntegerType ( IntegerType  intType,
ArrayRef< DataLayoutEntryInterface >  params 
)
static

◆ getCombinedDataLayout()

static DataLayoutSpecInterface getCombinedDataLayout ( Operation leaf)
static

Returns a layout spec that is a combination of the layout specs attached to the given operation and all its ancestors.

Definition at line 379 of file DataLayoutInterfaces.cpp.

References collectParentLayouts(), and getSpec().

Referenced by mlir::detail::verifyDataLayoutOp().

◆ getFloatTypeABIAlignment()

static uint64_t getFloatTypeABIAlignment ( FloatType  fltType,
const DataLayout dataLayout,
ArrayRef< DataLayoutEntryInterface >  params 
)
static

◆ getFloatTypePreferredAlignment()

static uint64_t getFloatTypePreferredAlignment ( FloatType  fltType,
const DataLayout dataLayout,
ArrayRef< DataLayoutEntryInterface >  params 
)
static

◆ getIndexBitwidth()

static uint64_t getIndexBitwidth ( DataLayoutEntryListRef  params)
static

Returns the bitwidth of the index type if specified in the param list.

Assumes 64-bit index otherwise.

Definition at line 37 of file DataLayoutInterfaces.cpp.

Referenced by mlir::detail::getDefaultABIAlignment(), mlir::detail::getDefaultIndexBitwidth(), mlir::detail::getDefaultPreferredAlignment(), and mlir::detail::getDefaultTypeSizeInBits().

◆ getIntegerTypeABIAlignment()

static uint64_t getIntegerTypeABIAlignment ( IntegerType  intType,
ArrayRef< DataLayoutEntryInterface >  params 
)
static

◆ getIntegerTypePreferredAlignment()

static uint64_t getIntegerTypePreferredAlignment ( IntegerType  intType,
const DataLayout dataLayout,
ArrayRef< DataLayoutEntryInterface >  params 
)
static

◆ getSpec()

static DataLayoutSpecInterface getSpec ( Operation operation)
static

◆ getTargetSystemSpec()

static TargetSystemSpecInterface getTargetSystemSpec ( Operation operation)
static

Definition at line 335 of file DataLayoutInterfaces.cpp.

References mlir::Operation::getParentOfType().

◆ reportMissingDataLayout()

static void reportMissingDataLayout ( Type  type)
static

Reports that the given type is missing the data layout information and exits.

Definition at line 26 of file DataLayoutInterfaces.cpp.

Referenced by mlir::detail::getDefaultABIAlignment(), mlir::detail::getDefaultPreferredAlignment(), and mlir::detail::getDefaultTypeSizeInBits().

Variable Documentation

◆ kDefaultBitsInByte

constexpr static const uint64_t kDefaultBitsInByte = 8u
staticconstexpr