@@ -2159,7 +2159,7 @@ multiclass ATOM2S_impl<string OpStr, string IntTypeStr, string TypeStr,
21592159
21602160multiclass F_ATOMIC_3_INTRINSIC_PATTERN<RegTyInfo t, string OpStr, string InstructionName> {
21612161 foreach scope = ["cta", "sys"] in {
2162- foreach space = ["gen"] in {
2162+ foreach space = ["gen", "global", "shared" ] in {
21632163 defvar intrinsic = !cast<SDPatternOperator>("int_nvvm_atomic_" # OpStr # "_" # space # "_i_" # scope);
21642164 def : Pat<(t.Ty (intrinsic addr:$addr, t.Ty:$b, t.Ty:$c)),
21652165 (!cast<Instruction>(InstructionName # "_rr") ADDR:$addr, t.Ty:$b, t.Ty:$c, Ordering_not_atomic, !cast<PatLeaf>("Scope_" # scope), !cast<PatLeaf>("AddrSpace_" # space))>;
@@ -2174,6 +2174,46 @@ multiclass F_ATOMIC_3_INTRINSIC_PATTERN<RegTyInfo t, string OpStr, string Instru
21742174 (!cast<Instruction>(InstructionName # "_ii") ADDR:$addr, (t.Ty t.ImmNode:$b), (t.Ty t.ImmNode:$c), Ordering_not_atomic, !cast<PatLeaf>("Scope_" # scope), !cast<PatLeaf>("AddrSpace_" # space))>;
21752175 }
21762176 }
2177+
2178+ // Handle intrinsics without explicit scope (defaulting to gpu scope)
2179+ foreach space = ["gen", "global", "shared"] in {
2180+ defvar intrinsic = !cast<SDPatternOperator>("int_nvvm_atomic_" # OpStr # "_" # space # "_i");
2181+ def : Pat<(t.Ty (intrinsic addr:$addr, t.Ty:$b, t.Ty:$c)),
2182+ (!cast<Instruction>(InstructionName # "_rr") ADDR:$addr, t.Ty:$b, t.Ty:$c, Ordering_not_atomic, Scope_device, !cast<PatLeaf>("AddrSpace_" # space))>;
2183+
2184+ def : Pat<(t.Ty (intrinsic addr:$addr, (t.Ty t.ImmNode:$b), t.Ty:$c)),
2185+ (!cast<Instruction>(InstructionName # "_ir") ADDR:$addr, (t.Ty t.ImmNode:$b), t.Ty:$c, Ordering_not_atomic, Scope_device, !cast<PatLeaf>("AddrSpace_" # space))>;
2186+
2187+ def : Pat<(t.Ty (intrinsic addr:$addr, t.Ty:$b, (t.Ty t.ImmNode:$c))),
2188+ (!cast<Instruction>(InstructionName # "_ri") ADDR:$addr, t.Ty:$b, (t.Ty t.ImmNode:$c), Ordering_not_atomic, Scope_device, !cast<PatLeaf>("AddrSpace_" # space))>;
2189+
2190+ def : Pat<(t.Ty (intrinsic addr:$addr, (t.Ty t.ImmNode:$b), (t.Ty t.ImmNode:$c))),
2191+ (!cast<Instruction>(InstructionName # "_ii") ADDR:$addr, (t.Ty t.ImmNode:$b), (t.Ty t.ImmNode:$c), Ordering_not_atomic, Scope_device, !cast<PatLeaf>("AddrSpace_" # space))>;
2192+ }
2193+
2194+ // Handle intrinsics with memory ordering semantics
2195+ foreach sem = ["acquire", "release", "acq_rel"] in {
2196+ foreach scope = ["gpu", "cta", "sys"] in {
2197+ foreach space = ["gen", "global", "shared"] in {
2198+ defvar intrinsic = !cast<SDPatternOperator>("int_nvvm_atomic_" # OpStr # "_" # space # "_i_" # sem # !if(!eq(scope, "gpu"), "", "_" # scope));
2199+ defvar ordering = !cast<PatLeaf>("Ordering_" # !subst("acq_rel", "acquire_release", sem));
2200+ defvar scopeLeaf = !cast<PatLeaf>("Scope_" # !if(!eq(scope, "gpu"), "device", scope));
2201+ defvar addrSpaceLeaf = !cast<PatLeaf>("AddrSpace_" # space);
2202+
2203+ def : Pat<(t.Ty (intrinsic addr:$addr, t.Ty:$b, t.Ty:$c)),
2204+ (!cast<Instruction>(InstructionName # "_rr") ADDR:$addr, t.Ty:$b, t.Ty:$c, ordering, scopeLeaf, addrSpaceLeaf)>;
2205+
2206+ def : Pat<(t.Ty (intrinsic addr:$addr, (t.Ty t.ImmNode:$b), t.Ty:$c)),
2207+ (!cast<Instruction>(InstructionName # "_ir") ADDR:$addr, (t.Ty t.ImmNode:$b), t.Ty:$c, ordering, scopeLeaf, addrSpaceLeaf)>;
2208+
2209+ def : Pat<(t.Ty (intrinsic addr:$addr, t.Ty:$b, (t.Ty t.ImmNode:$c))),
2210+ (!cast<Instruction>(InstructionName # "_ri") ADDR:$addr, t.Ty:$b, (t.Ty t.ImmNode:$c), ordering, scopeLeaf, addrSpaceLeaf)>;
2211+
2212+ def : Pat<(t.Ty (intrinsic addr:$addr, (t.Ty t.ImmNode:$b), (t.Ty t.ImmNode:$c))),
2213+ (!cast<Instruction>(InstructionName # "_ii") ADDR:$addr, (t.Ty t.ImmNode:$b), (t.Ty t.ImmNode:$c), ordering, scopeLeaf, addrSpaceLeaf)>;
2214+ }
2215+ }
2216+ }
21772217}
21782218
21792219// atom.add
0 commit comments