Skip to content

Commit fe252b5

Browse files
committed
[RISCV][Clang] Add more RVV Integer intrinsic functions.
Support below instructions. 1. Vector Integer Add-with-Carry / Subtract-with-Borrow Instructions 2. Vector Integer Comparison Instructions 3. Vector Widening Integer Multiply-Add Instructions Reviewed By: HsiangKai Authored-by: Roger Ferrer Ibanez <[email protected]> Co-Authored-by: Zakk Chen <[email protected]> Differential Revision: https://reviews.llvm.org/D99528
1 parent f720c22 commit fe252b5

File tree

21 files changed

+45329
-3
lines changed

21 files changed

+45329
-3
lines changed

clang/include/clang/Basic/riscv_vector.td

Lines changed: 75 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,16 @@ multiclass RVVOutOp1BuiltinSet<string intrinsic_name, string type_range,
228228
defm "" : RVVBuiltinSet<intrinsic_name, type_range, suffixes_prototypes, [-1, 1]>;
229229
}
230230

231+
multiclass RVVOp0Op1BuiltinSet<string intrinsic_name, string type_range,
232+
list<list<string>> suffixes_prototypes> {
233+
defm "" : RVVBuiltinSet<intrinsic_name, type_range, suffixes_prototypes, [0, 1]>;
234+
}
235+
236+
multiclass RVVOutOp1Op2BuiltinSet<string intrinsic_name, string type_range,
237+
list<list<string>> suffixes_prototypes> {
238+
defm "" : RVVBuiltinSet<intrinsic_name, type_range, suffixes_prototypes, [-1, 1, 2]>;
239+
}
240+
231241
multiclass RVVSignedBinBuiltinSet {
232242
defm "" : RVVOutOp1BuiltinSet<NAME, "csil",
233243
[["vv", "v", "vvv"],
@@ -253,6 +263,39 @@ multiclass RVVIntTerBuiltinSet {
253263
["vx", "Uv", "UvUvUeUv"]]>;
254264
}
255265

266+
multiclass RVVCarryinBuiltinSet {
267+
defm "" : RVVOutOp1BuiltinSet<NAME, "csil",
268+
[["vvm", "v", "vvvm"],
269+
["vxm", "v", "vvem"],
270+
["vvm", "Uv", "UvUvUvm"],
271+
["vxm", "Uv", "UvUvUem"]]>;
272+
}
273+
274+
multiclass RVVCarryOutInBuiltinSet<string intrinsic_name> {
275+
defm "" : RVVOp0Op1BuiltinSet<intrinsic_name, "csil",
276+
[["vvm", "vm", "mvvm"],
277+
["vxm", "vm", "mvem"],
278+
["vvm", "Uvm", "mUvUvm"],
279+
["vxm", "Uvm", "mUvUem"]]>;
280+
}
281+
282+
multiclass RVVSignedMaskOutBuiltinSet {
283+
defm "" : RVVOp0Op1BuiltinSet<NAME, "csil",
284+
[["vv", "vm", "mvv"],
285+
["vx", "vm", "mve"]]>;
286+
}
287+
288+
multiclass RVVUnsignedMaskOutBuiltinSet {
289+
defm "" : RVVOp0Op1BuiltinSet<NAME, "csil",
290+
[["vv", "Uvm", "mUvUv"],
291+
["vx", "Uvm", "mUvUe"]]>;
292+
}
293+
294+
multiclass RVVIntMaskOutBuiltinSet {
295+
defm "" : RVVSignedMaskOutBuiltinSet;
296+
defm "" : RVVUnsignedMaskOutBuiltinSet;
297+
}
298+
256299
multiclass RVVFloatingBinBuiltinSet {
257300
defm "" : RVVOutOp1BuiltinSet<NAME, "fd",
258301
[["vv", "v", "vvv"],
@@ -460,7 +503,14 @@ let Log2LMUL = [-3, -2, -1, 0] in {
460503
}
461504

462505
// 12.4. Vector Integer Add-with-Carry / Subtract-with-Borrow Instructions
463-
// TODO
506+
let HasMask = false in {
507+
defm vadc : RVVCarryinBuiltinSet;
508+
defm vmadc : RVVCarryOutInBuiltinSet<"vmadc_carry_in">;
509+
defm vmadc : RVVIntMaskOutBuiltinSet;
510+
defm vsbc : RVVCarryinBuiltinSet;
511+
defm vmsbc : RVVCarryOutInBuiltinSet<"vmsbc_borrow_in">;
512+
defm vmsbc : RVVIntMaskOutBuiltinSet;
513+
}
464514

465515
// 12.5. Vector Bitwise Logical Instructions
466516
defm vand : RVVIntBinBuiltinSet;
@@ -491,7 +541,16 @@ defm vnsra : RVVOutOp0Op1BuiltinSet<"vnsra", "csi",
491541
}
492542

493543
// 12.8. Vector Integer Comparison Instructions
494-
// TODO
544+
defm vmseq : RVVIntMaskOutBuiltinSet;
545+
defm vmsne : RVVIntMaskOutBuiltinSet;
546+
defm vmsltu : RVVUnsignedMaskOutBuiltinSet;
547+
defm vmslt : RVVSignedMaskOutBuiltinSet;
548+
defm vmsleu : RVVUnsignedMaskOutBuiltinSet;
549+
defm vmsle : RVVSignedMaskOutBuiltinSet;
550+
defm vmsgtu : RVVOp0Op1BuiltinSet<"vmsgtu", "csil",
551+
[["vx", "Uvm", "mUvUe"]]>;
552+
defm vmsgt : RVVOp0Op1BuiltinSet<"vmsgt", "csil",
553+
[["vx", "vm", "mve"]]>;
495554

496555
// 12.9. Vector Integer Min/Max Instructions
497556
defm vminu : RVVUnsignedBinBuiltinSet;
@@ -535,7 +594,20 @@ let HasMaskedOffOperand = false in {
535594
}
536595

537596
// 12.14. Vector Widening Integer Multiply-Add Instructions
538-
// TODO
597+
let HasMaskedOffOperand = false,
598+
Log2LMUL = [-3, -2, -1, 0, 1, 2] in {
599+
defm vwmaccu : RVVOutOp1Op2BuiltinSet<"vwmaccu", "csi",
600+
[["vv", "Uw", "UwUwUvUv"],
601+
["vx", "Uw", "UwUwUeUv"]]>;
602+
defm vwmacc : RVVOutOp1Op2BuiltinSet<"vwmacc", "csi",
603+
[["vv", "w", "wwvv"],
604+
["vx", "w", "wwev"]]>;
605+
defm vwmaccsu : RVVOutOp1Op2BuiltinSet<"vwmaccsu", "csi",
606+
[["vv", "w", "wwvUv"],
607+
["vx", "w", "wweUv"]]>;
608+
defm vwmaccus : RVVOutOp1Op2BuiltinSet<"vwmaccus", "csi",
609+
[["vx", "w", "wwUev"]]>;
610+
}
539611

540612
// 12.15. Vector Integer Merge Instructions
541613
// TODO

clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vadc.c

Lines changed: 1328 additions & 0 deletions
Large diffs are not rendered by default.

clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmadc.c

Lines changed: 2566 additions & 0 deletions
Large diffs are not rendered by default.

clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmsbc.c

Lines changed: 2566 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)