Skip to content

Commit d25f522

Browse files
AinsleySnowimkiva
authored andcommitted
[LLVM][XTHeadVector] Implement intrinsics for vmin{u}/vmax{u}. (llvm#61)
* [LLVM][XTHeadVector] Define intrinsic functions for vmin{u}/vmax{u}. * [LLVM][XTHeadVector] Define pats and pseudos for vmin{u}/vmax{u}. * [LLVM][XTHeadVector] Add test cases. * [NFC][XTHeadVector] Update README.
1 parent 60e0236 commit d25f522

File tree

7 files changed

+9803
-0
lines changed

7 files changed

+9803
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Any feature not listed below but present in the specification should be consider
4545
- (Done) `vsra.{vv,vx,vi}`
4646
- (Done) `12.6. Vector Narrowing Integer Right Shift Instructions`
4747
- (Done) `12.7 Vector Integer Comparison Instructions`
48+
- (Done) `12.8. Vector Integer Min/Max Instructions`
4849
- (WIP) Clang intrinsics related to the `XTHeadVector` extension:
4950
- (WIP) `6. Configuration-Setting and Utility`
5051
- (Done) `6.1. Set vl and vtype`

llvm/include/llvm/IR/IntrinsicsRISCVXTHeadV.td

+6
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,12 @@ let TargetPrefix = "riscv" in {
681681
defm th_vmsgt : RISCVCompare;
682682
defm th_vmsge: RISCVCompare;
683683
defm th_vmsgeu: RISCVCompare;
684+
685+
// 12.8. Vector Integer Min/Max Instructions
686+
defm th_vminu : XVBinaryAAX;
687+
defm th_vmin : XVBinaryAAX;
688+
defm th_vmaxu : XVBinaryAAX;
689+
defm th_vmax : XVBinaryAAX;
684690
} // TargetPrefix = "riscv"
685691

686692
let TargetPrefix = "riscv" in {

llvm/lib/Target/RISCV/RISCVInstrInfoXTHeadVPseudos.td

+32
Original file line numberDiff line numberDiff line change
@@ -2283,6 +2283,21 @@ multiclass XVPatCompare_VI<string intrinsic, string inst,
22832283
}
22842284
}
22852285

2286+
multiclass XVPseudoVMINMAX_VV_VX {
2287+
foreach m = MxListXTHeadV in {
2288+
defvar mx = m.MX;
2289+
defvar WriteVIMinMaxV_MX = !cast<SchedWrite>("WriteVIMinMaxV_" # mx);
2290+
defvar WriteVIMinMaxX_MX = !cast<SchedWrite>("WriteVIMinMaxX_" # mx);
2291+
defvar ReadVIMinMaxV_MX = !cast<SchedRead>("ReadVIMinMaxV_" # mx);
2292+
defvar ReadVIMinMaxX_MX = !cast<SchedRead>("ReadVIMinMaxX_" # mx);
2293+
2294+
defm "" : XVPseudoBinaryV_VV<m>,
2295+
Sched<[WriteVIMinMaxV_MX, ReadVIMinMaxV_MX, ReadVIMinMaxV_MX, ReadVMask]>;
2296+
defm "" : XVPseudoBinaryV_VX<m>,
2297+
Sched<[WriteVIMinMaxX_MX, ReadVIMinMaxV_MX, ReadVIMinMaxX_MX, ReadVMask]>;
2298+
}
2299+
}
2300+
22862301
multiclass XVPatBinaryV_VV_VX_VI<string intrinsic, string instruction,
22872302
list<VTypeInfo> vtilist, Operand ImmType = simm5>
22882303
: XVPatBinaryV_VV<intrinsic, instruction, vtilist>,
@@ -2577,6 +2592,23 @@ let Predicates = [HasVendorXTHeadV] in {
25772592
defm : XVPatCompare_VI<"int_riscv_th_vmsltu", "PseudoTH_VMSLEU", simm5_plus1_nonzero>;
25782593
} // Predicates = [HasVendorXTHeadV]
25792594

2595+
//===----------------------------------------------------------------------===//
2596+
// 12.8. Vector Integer Min/Max Instructions
2597+
//===----------------------------------------------------------------------===//
2598+
let Predicates = [HasVendorXTHeadV] in {
2599+
defm PseudoTH_VMINU : XVPseudoVMINMAX_VV_VX;
2600+
defm PseudoTH_VMIN : XVPseudoVMINMAX_VV_VX;
2601+
defm PseudoTH_VMAXU : XVPseudoVMINMAX_VV_VX;
2602+
defm PseudoTH_VMAX : XVPseudoVMINMAX_VV_VX;
2603+
} // Predicates = [HasVendorXTHeadV]
2604+
2605+
let Predicates = [HasVendorXTHeadV] in {
2606+
defm : XVPatBinaryV_VV_VX<"int_riscv_th_vminu", "PseudoTH_VMINU", AllIntegerXVectors>;
2607+
defm : XVPatBinaryV_VV_VX<"int_riscv_th_vmin", "PseudoTH_VMIN", AllIntegerXVectors>;
2608+
defm : XVPatBinaryV_VV_VX<"int_riscv_th_vmaxu", "PseudoTH_VMAXU", AllIntegerXVectors>;
2609+
defm : XVPatBinaryV_VV_VX<"int_riscv_th_vmax", "PseudoTH_VMAX", AllIntegerXVectors>;
2610+
}
2611+
25802612
//===----------------------------------------------------------------------===//
25812613
// 12.14. Vector Integer Merge and Move Instructions
25822614
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)