12#ifndef CLANG_CIR_DIALECT_IR_CIRDATALAYOUT_H
13#define CLANG_CIR_DIALECT_IR_CIRDATALAYOUT_H
15#include "mlir/Dialect/DLTI/DLTI.h"
16#include "mlir/IR/BuiltinOps.h"
26 bool bigEndian =
false;
28 unsigned programAddrSpace = 0;
39 mlir::ModuleOp module;
48 void reset(mlir::DataLayoutSpecInterface spec);
55 llvm::Align
getAlignment(mlir::Type ty,
bool useABIAlign)
const;
77 return {llvm::divideCeil(baseSize.getKnownMinValue(), 8),
78 baseSize.isScalable()};
91 llvm::alignToPowerOf2(baseSize.getKnownMinValue(), 8);
92 return {alignedSizeInBits, baseSize.isScalable()};
123 assert(mlir::isa<cir::PointerType>(ty) &&
124 "This should only be called with a pointer type");
125 return layout.getTypeSizeInBits(ty);
129 assert(mlir::isa<cir::PointerType>(ty) &&
"Expected pointer type");
142 mlir::ptr::MemorySpaceAttrInterface
144 auto allocaASAttr = mlir::dyn_cast_if_present<mlir::IntegerAttr>(
145 layout.getAllocaMemorySpace());
148 return cir::TargetAddressSpaceAttr::get(ctx, allocaASAttr.getUInt());
151 mlir::ptr::MemorySpaceAttrInterface
153 auto globalsASAttr = mlir::dyn_cast_if_present<mlir::IntegerAttr>(
154 layout.getGlobalMemorySpace());
155 if (!globalsASAttr || globalsASAttr.getUInt() == 0)
157 return cir::TargetAddressSpaceAttr::get(ctx, globalsASAttr.getUInt());
mlir::ptr::MemorySpaceAttrInterface getAllocaAddrSpace(mlir::MLIRContext *ctx)
uint64_t getTypeLanguageAlignment(mlir::Type ty) const
Returns the alignment, in bytes, that the source language requires for an object of type ty.
mlir::ptr::MemorySpaceAttrInterface getDefaultGlobalsAddrSpace(mlir::MLIRContext *ctx) const
void reset(mlir::DataLayoutSpecInterface spec)
Parse a data layout string (with fallback to default values).
CIRDataLayout(mlir::ModuleOp modOp)
Constructs a DataLayout the module's data layout attribute.
llvm::TypeSize getPointerTypeSizeInBits(mlir::Type ty) const
llvm::TypeSize getTypeAllocSize(mlir::Type ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
llvm::TypeSize getTypeStoreSizeInBits(mlir::Type ty) const
Returns the maximum number of bits that may be overwritten by storing the specified type; always a mu...
unsigned getProgramAddressSpace() const
llvm::Align getABITypeAlign(mlir::Type ty) const
mlir::Type getIntPtrType(mlir::Type ty) const
llvm::Align getAlignment(mlir::Type ty, bool useABIAlign) const
Internal helper method that returns requested alignment for type.
llvm::TypeSize getTypeAllocSizeInBits(mlir::Type ty) const
Returns the offset in bits between successive objects of the specified type, including alignment padd...
bool typeSizeEqualsStoreSize(mlir::Type ty) const
Returns true if no extra padding bits are needed when storing the specified type.
llvm::TypeSize getTypeSizeInBits(mlir::Type ty) const
llvm::TypeSize getTypeStoreSize(mlir::Type ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type.
__builtin_elementwise_add_sat __builtin_elementwise_sub_sat uint32_t uint64_t __builtin_riscv_ssha_i32 __builtin_riscv_sshl_u32 uint64_t