@@ -602,78 +602,25 @@ def CIR_VTableAttr : CIR_Attr<"VTable", "vtable", [TypedAttrInterface]> {
602602}
603603
604604//===----------------------------------------------------------------------===//
605- // AddressSpaceAttr
605+ // TargetAddressSpaceAttr
606606//===----------------------------------------------------------------------===//
607607
608- def CIR_AddressSpaceAttr : CIR_EnumAttr<CIR_AddressSpace, "address_space"> {
609- let summary = "Attribute representing memory address spaces";
608+ def CIR_TargetAddressSpaceAttr : CIR_Attr< "TargetAddressSpace",
609+ "target_address_space"> {
610+ let summary = "Attribute representing a target-specific numeric address space";
610611 let description = [{
611- Represents different memory address spaces for pointer types.
612- Address spaces distinguish between different types of memory regions,
613- such as global, local, or constant memory.
612+ Represents a target-specific numeric address space for pointer types.
614613
615- The `value` parameter is an extensible enum, which encodes target address
616- space as an offset to the last language address space. For that reason, the
617- attribute is implemented as custom AddressSpaceAttr, which provides custom
618- printer and parser for the `value` parameter.
619-
620- CIR supports two categories:
621- - Language address spaces: Predefined spaces like `offload_global`,
622- `offload_constant`, `offload_private` for offload programming models
623- - Target address spaces: Numeric spaces `target<N>` for target-specific
624- memory regions, where N is the address space number
625-
626- Examples:
614+ Example:
627615 ```mlir
628- // Default address space (implicit)
629- !cir.ptr<!s32i>
630-
631- // Language-defined offload address spaces
632- !cir.ptr<!s32i, addrspace(offload_global)>
633- !cir.ptr<!s32i, addrspace(offload_constant)>
634- !cir.ptr<!s32i, addrspace(offload_private)>
635-
636616 // Target-specific numeric address spaces
637617 !cir.ptr<!s32i, addrspace(target<1>)>
638618 !cir.ptr<!s32i, addrspace(target<10>)>
639619 ```
640620 }];
641- let builders = [
642- AttrBuilder<(ins "clang::LangAS":$langAS), [{
643- return $_get($_ctxt, cir::toCIRAddressSpace(langAS));
644- }]>
645- ];
646-
647- let assemblyFormat = [{
648- `(` custom<AddressSpaceValue>($value) `)`
649- }];
650-
651- let defaultValue = "cir::AddressSpace::Default";
652-
653- let extraClassDeclaration = [{
654- bool isLang() const;
655- bool isTarget() const;
656- unsigned getTargetValue() const;
657- unsigned getAsUnsignedValue() const;
658- }];
659621
660- let extraClassDefinition = [{
661- unsigned $cppClass::getAsUnsignedValue() const {
662- return static_cast<unsigned>(getValue());
663- }
664-
665- bool $cppClass::isLang() const {
666- return cir::isLangAddressSpace(getValue());
667- }
668-
669- bool $cppClass::isTarget() const {
670- return cir::isTargetAddressSpace(getValue());
671- }
672-
673- unsigned $cppClass::getTargetValue() const {
674- return cir::getTargetAddressSpaceValue(getValue());
675- }
676- }];
622+ let parameters = (ins "mlir::IntegerAttr":$value);
623+ let assemblyFormat = "`<` `target` `<` $value `>` `>`";
677624}
678625
679626//===----------------------------------------------------------------------===//
0 commit comments