[llvm] [NVPTX] Add syncscope support for cmpxchg (PR #140812)
Alex MacLean via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 2 10:07:55 PDT 2025
================
@@ -1836,37 +1896,54 @@ multiclass F_ATOMIC_2<RegTyInfo t, string sem_str, string as_str, string op_str,
}
}
-// has 3 operands
-multiclass F_ATOMIC_3<RegTyInfo t, string sem_str, string as_str, string op_str,
- SDPatternOperator op, list<Predicate> preds> {
- defvar asm_str = "atom" # sem_str # as_str # "." # op_str;
+multiclass F_ATOMIC_3<RegTyInfo t, string op_str> {
+ defvar asm_str = "atom${sem:sem}${scope:scope}${addsp:addsp}" # op_str # "\t$dst, [$addr], $b, $c;";
+
let mayLoad = 1, mayStore = 1, hasSideEffects = 1 in {
- def rr : BasicNVPTXInst<(outs t.RC:$dst),
- (ins ADDR:$addr, t.RC:$b, t.RC:$c),
- asm_str,
- [(set t.Ty:$dst, (op addr:$addr, t.Ty:$b, t.Ty:$c))]>,
- Requires<preds>;
+ def _rr : NVPTXInst<(outs t.RC:$dst),
+ (ins ADDR:$addr, t.RC:$b, t.RC:$c, AtomicCode:$sem, AtomicCode:$scope, AtomicCode:$addsp),
+ asm_str, []>;
- def ir : BasicNVPTXInst<(outs t.RC:$dst),
- (ins ADDR:$addr, t.Imm:$b, t.RC:$c),
- asm_str,
- [(set t.Ty:$dst, (op addr:$addr, (t.Ty t.ImmNode:$b), t.Ty:$c))]>,
- Requires<preds>;
+ def _ir : NVPTXInst<(outs t.RC:$dst),
+ (ins ADDR:$addr, t.Imm:$b, t.RC:$c, AtomicCode:$sem, AtomicCode:$scope, AtomicCode:$addsp),
+ asm_str, []>;
- def ri : BasicNVPTXInst<(outs t.RC:$dst),
- (ins ADDR:$addr, t.RC:$b, t.Imm:$c),
- asm_str,
- [(set t.Ty:$dst, (op addr:$addr, t.Ty:$b, (t.Ty t.ImmNode:$c)))]>,
- Requires<preds>;
+ def _ri : NVPTXInst<(outs t.RC:$dst),
+ (ins ADDR:$addr, t.RC:$b, t.Imm:$c, AtomicCode:$sem, AtomicCode:$scope, AtomicCode:$addsp),
+ asm_str, []>;
- def ii : BasicNVPTXInst<(outs t.RC:$dst),
- (ins ADDR:$addr, t.Imm:$b, t.Imm:$c),
- asm_str,
- [(set t.Ty:$dst, (op addr:$addr, (t.Ty t.ImmNode:$b), (t.Ty t.ImmNode:$c)))]>,
- Requires<preds>;
+ def _ii : NVPTXInst<(outs t.RC:$dst),
+ (ins ADDR:$addr, t.Imm:$b, t.Imm:$c, AtomicCode:$sem, AtomicCode:$scope, AtomicCode:$addsp),
+ asm_str, []>;
}
}
+multiclass F_ATOMIC_3_PATTERN<RegTyInfo t, string InstructionName, SDPatternOperator op, SDNode atomic> {
+ defvar GetSem = SDNodeXForm<atomic, [{
+ return getI32Imm(getMemOrder(cast<MemSDNode>(N)), SDLoc(N));
----------------
AlexMaclean wrote:
Is the cast to MemSDNode required here?
https://github.com/llvm/llvm-project/pull/140812
More information about the llvm-commits
mailing list