@@ -1881,29 +1881,27 @@ multiclass F_ATOMIC_2<RegTyInfo t, string sem_str, string as_str, string op_str,
18811881 }
18821882}
18831883
1884- multiclass F_ATOMIC_3<RegTyInfo t, string op_str> {
1885- defvar asm_str = "atom${sem:sem}${scope:scope}${addsp:addsp}" # op_str # "\t$dst, [$addr], $b, $c;" ;
1884+ multiclass F_ATOMIC_3<RegTyInfo t, string op_str, SDPatternOperator op, SDNode atomic > {
1885+ defvar asm_str = "atom${sem:sem}${scope:scope}${addsp:addsp}" # op_str;
18861886
18871887 let mayLoad = 1, mayStore = 1, hasSideEffects = 1 in {
1888- def _rr : NVPTXInst <(outs t.RC:$dst),
1889- (ins ADDR:$addr, t.RC:$b, t.RC:$c, AtomicCode:$sem, AtomicCode:$scope, AtomicCode:$addsp),
1888+ def _rr : BasicFlagsNVPTXInst <(outs t.RC:$dst),
1889+ (ins ADDR:$addr, t.RC:$b, t.RC:$c), (ins AtomicCode:$sem, AtomicCode:$scope, AtomicCode:$addsp),
18901890 asm_str, []>;
18911891
1892- def _ir : NVPTXInst <(outs t.RC:$dst),
1893- (ins ADDR:$addr, t.Imm:$b, t.RC:$c, AtomicCode:$sem, AtomicCode:$scope, AtomicCode:$addsp),
1892+ def _ir : BasicFlagsNVPTXInst <(outs t.RC:$dst),
1893+ (ins ADDR:$addr, t.Imm:$b, t.RC:$c), (ins AtomicCode:$sem, AtomicCode:$scope, AtomicCode:$addsp),
18941894 asm_str, []>;
18951895
1896- def _ri : NVPTXInst <(outs t.RC:$dst),
1897- (ins ADDR:$addr, t.RC:$b, t.Imm:$c, AtomicCode:$sem, AtomicCode:$scope, AtomicCode:$addsp),
1896+ def _ri : BasicFlagsNVPTXInst <(outs t.RC:$dst),
1897+ (ins ADDR:$addr, t.RC:$b, t.Imm:$c), (ins AtomicCode:$sem, AtomicCode:$scope, AtomicCode:$addsp),
18981898 asm_str, []>;
18991899
1900- def _ii : NVPTXInst <(outs t.RC:$dst),
1901- (ins ADDR:$addr, t.Imm:$b, t.Imm:$c, AtomicCode:$sem, AtomicCode:$scope, AtomicCode:$addsp),
1900+ def _ii : BasicFlagsNVPTXInst <(outs t.RC:$dst),
1901+ (ins ADDR:$addr, t.Imm:$b, t.Imm:$c), (ins AtomicCode:$sem, AtomicCode:$scope, AtomicCode:$addsp),
19021902 asm_str, []>;
19031903 }
1904- }
19051904
1906- multiclass F_ATOMIC_3_PATTERN<RegTyInfo t, string InstructionName, SDPatternOperator op, SDNode atomic> {
19071905 defvar GetSem = SDNodeXForm<atomic, [{
19081906 return getI32Imm(getMemOrder(cast<MemSDNode>(N)), SDLoc(N));
19091907 }]>;
@@ -1917,16 +1915,16 @@ multiclass F_ATOMIC_3_PATTERN<RegTyInfo t, string InstructionName, SDPatternOper
19171915 }]>;
19181916
19191917 def : Pat<(op:$this addr:$addr, t.Ty:$b, t.Ty:$c),
1920- (!cast<Instruction>(InstructionName# _rr) ADDR:$addr, t.Ty:$b, t.Ty:$c, (GetSem $this), (GetScope $this), (GetAddSp $this))>;
1918+ (!cast<Instruction>(NAME # _rr) ADDR:$addr, t.Ty:$b, t.Ty:$c, (GetSem $this), (GetScope $this), (GetAddSp $this))>;
19211919
19221920 def : Pat<(op:$this addr:$addr, (t.Ty t.ImmNode:$b), t.Ty:$c),
1923- (!cast<Instruction>(InstructionName# _ir) ADDR:$addr, (t.Ty t.ImmNode:$b), t.Ty:$c, (GetSem $this), (GetScope $this), (GetAddSp $this))>;
1921+ (!cast<Instruction>(NAME # _ir) ADDR:$addr, (t.Ty t.ImmNode:$b), t.Ty:$c, (GetSem $this), (GetScope $this), (GetAddSp $this))>;
19241922
19251923 def : Pat<(op:$this addr:$addr, t.Ty:$b, (t.Ty t.ImmNode:$c)),
1926- (!cast<Instruction>(InstructionName# _#ri) ADDR:$addr, t.Ty:$b, (t.Ty t.ImmNode:$c), (GetSem $this), (GetScope $this), (GetAddSp $this))>;
1924+ (!cast<Instruction>(NAME # _#ri) ADDR:$addr, t.Ty:$b, (t.Ty t.ImmNode:$c), (GetSem $this), (GetScope $this), (GetAddSp $this))>;
19271925
19281926 def : Pat<(op:$this addr:$addr, (t.Ty t.ImmNode:$b), (t.Ty t.ImmNode:$c)),
1929- (!cast<Instruction>(InstructionName# _#ii) ADDR:$addr, (t.Ty t.ImmNode:$b), (t.Ty t.ImmNode:$c), (GetSem $this), (GetScope $this), (GetAddSp $this))>;
1927+ (!cast<Instruction>(NAME # _#ii) ADDR:$addr, (t.Ty t.ImmNode:$b), (t.Ty t.ImmNode:$c), (GetSem $this), (GetScope $this), (GetAddSp $this))>;
19301928}
19311929
19321930multiclass F_ATOMIC_2_AS<RegTyInfo t, SDPatternOperator frag, string op_str, list<Predicate> preds = []> {
@@ -1984,9 +1982,7 @@ defm INT_PTX_ATOM_XOR_64 : F_ATOMIC_2_AS<I64RT, atomic_load_xor_i64, "xor.b64",
19841982foreach t = [I16RT, I32RT, I64RT] in {
19851983 defvar atomic_cmp_swap_pat = !cast<PatFrag>("atomic_cmp_swap_i"#t.Size);
19861984 defm INT_PTX_ATOM_CAS_#t.Size
1987- : F_ATOMIC_3<t, ".cas.b"#t.Size>;
1988-
1989- defm INT_PTX_ATOM_CAS_PAT_#t.Size : F_ATOMIC_3_PATTERN<t, "INT_PTX_ATOM_CAS_"#t.Size, atomic_cmp_swap_pat, atomic_cmp_swap>;
1985+ : F_ATOMIC_3<t, ".cas.b"#t.Size, atomic_cmp_swap_pat, atomic_cmp_swap>;
19901986}
19911987
19921988// Support for scoped atomic operations. Matches
@@ -2027,10 +2023,10 @@ multiclass ATOM2S_impl<string OpStr, string IntTypeStr, string TypeStr,
20272023 }
20282024}
20292025
2030- multiclass F_ATOMIC_3_INTRINSIC_PATTERN<RegTyInfo t, string OpStr, string InstructionName, string IntTypeStr > {
2026+ multiclass F_ATOMIC_3_INTRINSIC_PATTERN<RegTyInfo t, string OpStr, string InstructionName> {
20312027 foreach scope = ["cta", "sys"] in {
20322028 foreach space = ["gen"] in {
2033- defvar intrinsic = !cast<SDPatternOperator>("int_nvvm_atomic_" # OpStr # "_" # space # "_" # IntTypeStr # "_ " # scope);
2029+ defvar intrinsic = !cast<SDPatternOperator>("int_nvvm_atomic_" # OpStr # "_" # space # "_i_ " # scope);
20342030 def : Pat<(t.Ty (intrinsic addr:$addr, t.Ty:$b, t.Ty:$c)),
20352031 (!cast<Instruction>(InstructionName # "_rr") ADDR:$addr, t.Ty:$b, t.Ty:$c, Ordering_not_atomic, !cast<PatLeaf>("Scope_" # scope), !cast<PatLeaf>("AddrSpace_" # space))>;
20362032
@@ -2084,9 +2080,9 @@ multiclass ATOM2_incdec_impl<string OpStr> {
20842080
20852081// atom.cas
20862082multiclass ATOM3_cas_impl<string OpStr> {
2087- defm _b16 : F_ATOMIC_3_INTRINSIC_PATTERN<I16RT, OpStr, "INT_PTX_ATOM_CAS_16", "i" >;
2088- defm _b32 : F_ATOMIC_3_INTRINSIC_PATTERN<I32RT, OpStr, "INT_PTX_ATOM_CAS_32", "i" >;
2089- defm _b64 : F_ATOMIC_3_INTRINSIC_PATTERN<I64RT, OpStr, "INT_PTX_ATOM_CAS_64", "i" >;
2083+ defm _b16 : F_ATOMIC_3_INTRINSIC_PATTERN<I16RT, OpStr, "INT_PTX_ATOM_CAS_16">;
2084+ defm _b32 : F_ATOMIC_3_INTRINSIC_PATTERN<I32RT, OpStr, "INT_PTX_ATOM_CAS_32">;
2085+ defm _b64 : F_ATOMIC_3_INTRINSIC_PATTERN<I64RT, OpStr, "INT_PTX_ATOM_CAS_64">;
20902086}
20912087
20922088defm INT_PTX_SATOM_ADD : ATOM2_add_impl<"add">;
0 commit comments