[flang-commits] [flang] [Flang][MLIR] Add basic initial support for alloca and program address space handling in FIR->LLVMIR codegen (PR #77518)

Kareem Ergawy via flang-commits flang-commits at lists.llvm.org
Wed Jan 10 01:35:57 PST 2024


================
@@ -67,8 +68,41 @@ static constexpr unsigned defaultAlign = 8;
 static constexpr unsigned kAttrPointer = CFI_attribute_pointer;
 static constexpr unsigned kAttrAllocatable = CFI_attribute_allocatable;
 
-static inline mlir::Type getLlvmPtrType(mlir::MLIRContext *context) {
-  return mlir::LLVM::LLVMPointerType::get(context);
+static inline unsigned getAllocaAddressSpace(mlir::ModuleOp module) {
+  if (mlir::Attribute addrSpace =
+          mlir::DataLayout(module).getAllocaMemorySpace())
+    return addrSpace.cast<mlir::IntegerAttr>().getUInt();
----------------
ergawy wrote:

`cast` utils in `mlir::Attribute` are [deprecated](https://github.com/llvm/llvm-project/blob/c69ec700adec315b3daa55742f2ef655242fa297/mlir/include/mlir/IR/Attributes.h#L50C1-L50C1).

https://github.com/llvm/llvm-project/pull/77518


More information about the flang-commits mailing list