22struct LLVMPointerPointerLikeModel
23 :
public PointerLikeType::ExternalModel<LLVMPointerPointerLikeModel,
24 LLVM::LLVMPointerType> {
27 mlir::Value
genLoad(Type pointer, OpBuilder &builder, Location loc,
29 Type valueType)
const {
34 return LLVM::LoadOp::create(builder, loc, valueType, srcPtr);
37 bool genStore(Type pointer, OpBuilder &builder, Location loc,
39 LLVM::StoreOp::create(builder, loc, valueToStore, destPtr);
43 Value
genCast(Type, OpBuilder &builder, Location loc, Value value,
44 Type resultType)
const {
45 if (value.
getType() == resultType)
48 auto srcPtrTy = dyn_cast<LLVM::LLVMPointerType>(value.
getType());
49 auto dstPtrTy = dyn_cast<LLVM::LLVMPointerType>(resultType);
50 if (srcPtrTy && dstPtrTy) {
51 if (srcPtrTy.getAddressSpace() != dstPtrTy.getAddressSpace())
52 return LLVM::AddrSpaceCastOp::create(builder, loc, resultType, value);
56 if (srcPtrTy && isa<IntegerType>(resultType))
57 return LLVM::PtrToIntOp::create(builder, loc, resultType, value);
61 if (isa<IndexType>(value.
getType()))
62 intVal = arith::IndexCastUIOp::create(builder, loc,
64 if (isa<IntegerType>(intVal.
getType()))
65 return LLVM::IntToPtrOp::create(builder, loc, resultType, intVal);
68 if (
auto resPtrLike = dyn_cast<PointerLikeType>(resultType))
69 if (!isa<LLVM::LLVMPointerType>(resPtrLike))
70 if (Value v = resPtrLike.genCast(builder, loc, value, resultType))
72 if (
auto valPtrLike = dyn_cast<PointerLikeType>(value.
getType()))
73 if (!isa<LLVM::LLVMPointerType>(valPtrLike))
74 if (Value v = valPtrLike.genCast(builder, loc, value, resultType))
77 return UnrealizedConversionCastOp::create(builder, loc,
83struct LLVMAddressOfGlobalModel
84 :
public AddressOfGlobalOpInterface::ExternalModel<LLVMAddressOfGlobalModel,
86 SymbolRefAttr getSymbol(Operation *op)
const {
87 auto addressOfOp = cast<LLVM::AddressOfOp>(op);
88 return addressOfOp.getGlobalNameAttr();
97 LLVM::LLVMPointerType::attachInterface<LLVMPointerPointerLikeModel>(*ctx);
98 LLVM::AddressOfOp::attachInterface<LLVMAddressOfGlobalModel>(*ctx);
static Type getElementType(Type type, ArrayRef< int32_t > indices, function_ref< InFlightDiagnostic(StringRef)> emitErrorFn)
Walks the given type hierarchy with the given indices, potentially down to component granularity,...
static void genStore(OpBuilder &builder, Location loc, Value val, Value mem, Value idx)
Generates a store with proper index typing and proper value.
static Value genLoad(OpBuilder &builder, Location loc, Value mem, Value idx)
Generates a load with proper index typing.
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
bool addExtension(TypeID extensionID, std::unique_ptr< DialectExtensionBase > extension)
Add the given extension to the registry.
MLIRContext is the top-level object for a collection of MLIR operations.
T * getOrLoadDialect()
Get (or create) a dialect for the given derived dialect type.
Type getType() const
Return the type of this value.
void registerLLVMInterfaces(DialectRegistry ®istry)
Register OpenACC interfaces for LLVM IR.
Value genCast(OpBuilder &builder, Location loc, Value value, Type dstTy)
Add type casting between arith and index types when needed.
Include the generated interface declarations.
std::conditional_t< std::is_same_v< Ty, mlir::Type >, mlir::Value, detail::TypedValue< Ty > > TypedValue
If Ty is mlir::Type this will select Value instead of having a wrapper around it.