================ @@ -766,30 +802,47 @@ mlir::LogicalResult cir::VectorType::verify( } //===----------------------------------------------------------------------===// -// PointerType Definitions +// TargetAddressSpace definitions //===----------------------------------------------------------------------===// -llvm::TypeSize -PointerType::getTypeSizeInBits(const ::mlir::DataLayout &dataLayout, - ::mlir::DataLayoutEntryListRef params) const { - // FIXME: improve this in face of address spaces - return llvm::TypeSize::getFixed(64); +// Convert from TargetAddressSpaceAttr to the actual integer address space. +unsigned cir::getTargetAddrSpaceFromAttr(cir::TargetAddressSpaceAttr attr) { + if (!attr) + return 0; // Default address space is 0 in LLVM. + return attr.getValue().getUInt(); } -uint64_t -PointerType::getABIAlignment(const ::mlir::DataLayout &dataLayout, - ::mlir::DataLayoutEntryListRef params) const { - // FIXME: improve this in face of address spaces - return 8; -} +mlir::ParseResult parseTargetAddressSpace(mlir::AsmParser &p, + cir::TargetAddressSpaceAttr &attr) { + if (failed(p.parseKeyword("target_address_space"))) + return mlir::failure(); -mlir::LogicalResult -PointerType::verify(llvm::function_ref<mlir::InFlightDiagnostic()> emitError, - mlir::Type pointee) { - // TODO(CIR): Verification of the address space goes here. + if (failed(p.parseLParen())) + return mlir::failure(); + + int64_t targetValue; + if (failed(p.parseInteger(targetValue))) + return p.emitError(p.getCurrentLocation(), + "expected integer address space value"); + + if (failed(p.parseRParen())) + return p.emitError(p.getCurrentLocation(), + "expected ')' after address space value"); + + mlir::MLIRContext *context = p.getBuilder().getContext(); + auto intTy = mlir::IntegerType::get(context, 32); + attr = cir::TargetAddressSpaceAttr::get( + context, mlir::IntegerAttr::get(intTy, targetValue)); ---------------- andykaylor wrote:
```suggestion attr = cir::TargetAddressSpaceAttr::get( context, getUI32IntegerAttr(0)); ``` https://github.com/llvm/llvm-project/pull/161028 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits