20struct LLVMPointerPointerLikeModel
21 :
public PointerLikeType::ExternalModel<LLVMPointerPointerLikeModel,
22 LLVM::LLVMPointerType> {
25 mlir::Value
genLoad(Type pointer, OpBuilder &builder, Location loc,
27 Type valueType)
const {
32 return LLVM::LoadOp::create(builder, loc, valueType, srcPtr);
35 bool genStore(Type pointer, OpBuilder &builder, Location loc,
37 LLVM::StoreOp::create(builder, loc, valueToStore, destPtr);
41 Value
genCast(Type, OpBuilder &builder, Location loc, Value value,
42 Type resultType)
const {
43 if (value.
getType() == resultType)
46 auto srcPtrTy = dyn_cast<LLVM::LLVMPointerType>(value.
getType());
47 auto dstPtrTy = dyn_cast<LLVM::LLVMPointerType>(resultType);
48 if (srcPtrTy && dstPtrTy) {
49 if (srcPtrTy.getAddressSpace() != dstPtrTy.getAddressSpace())
50 return LLVM::AddrSpaceCastOp::create(builder, loc, resultType, value);
54 if (srcPtrTy && isa<IntegerType>(resultType))
55 return LLVM::PtrToIntOp::create(builder, loc, resultType, value);
59 if (isa<IndexType>(value.
getType()))
60 intVal = arith::IndexCastUIOp::create(builder, loc,
62 if (isa<IntegerType>(intVal.
getType()))
63 return LLVM::IntToPtrOp::create(builder, loc, resultType, intVal);
66 if (
auto resPtrLike = dyn_cast<PointerLikeType>(resultType))
67 if (!isa<LLVM::LLVMPointerType>(resPtrLike))
68 if (Value v = resPtrLike.genCast(builder, loc, value, resultType))
70 if (
auto valPtrLike = dyn_cast<PointerLikeType>(value.
getType()))
71 if (!isa<LLVM::LLVMPointerType>(valPtrLike))
72 if (Value v = valPtrLike.genCast(builder, loc, value, resultType))
75 return UnrealizedConversionCastOp::create(builder, loc,
81struct LLVMAddressOfGlobalModel
82 :
public AddressOfGlobalOpInterface::ExternalModel<LLVMAddressOfGlobalModel,
84 SymbolRefAttr getSymbol(Operation *op)
const {
85 auto addressOfOp = cast<LLVM::AddressOfOp>(op);
86 return addressOfOp.getGlobalNameAttr();
95 LLVM::LLVMPointerType::attachInterface<LLVMPointerPointerLikeModel>(*ctx);
96 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.