Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions llvm/include/llvm/IR/IntrinsicsRISCVXsf.td
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ let TargetPrefix = "riscv" in {
defm "" : RISCVSFCustomVC_XVV<["x", "i", "v", "f"]>;
defm "" : RISCVSFCustomVC_XVW<["x", "i", "v", "f"]>;

// XSfvfexp* and XSfvfexpa*
defm sf_vfexp : RISCVUnaryAA;
defm sf_vfexpa : RISCVUnaryAA;

// XSfvqmaccdod
def int_riscv_sf_vqmaccu_2x8x2 : RISCVSFCustomVMACC;
def int_riscv_sf_vqmacc_2x8x2 : RISCVSFCustomVMACC;
Expand Down
81 changes: 79 additions & 2 deletions llvm/lib/Target/RISCV/RISCVInstrInfoXSf.td
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,13 @@ let Predicates = [HasVendorXSfvcp], mayLoad = 0, mayStore = 0,
}

let Predicates = [HasVendorXSfvfexpAny], DecoderNamespace = "XSfvector" in {
def SF_VFEXP_V : VALUVs2<0b010011, 0b00111, OPFVV, "sf.vfexp.v">;
def SF_VFEXP_V : VALUVs2<0b010011, 0b00111, OPFVV, "sf.vfexp.v">,
SchedUnaryMC<"WriteSF_VFExp", "ReadSF_VFExp">;
}

let Predicates = [HasVendorXSfvfexpa], DecoderNamespace = "XSfvector" in {
def SF_VFEXPA_V : VALUVs2<0b010011, 0b00110, OPFVV, "sf.vfexpa.v">;
def SF_VFEXPA_V : VALUVs2<0b010011, 0b00110, OPFVV, "sf.vfexpa.v">,
SchedUnaryMC<"WriteSF_VFExpa", "ReadSF_VFExpa">;
}

let Predicates = [HasVendorXSfvqmaccdod], DecoderNamespace = "XSfvector",
Expand Down Expand Up @@ -487,6 +489,48 @@ let Predicates = [HasVendorXSfvfnrclipxfqf] in {
defm SF_VFNRCLIP_X_F_QF : VPseudoSiFiveVFNRCLIP;
}

class VFExpSchedSEWSet<string mx, bit IsBF16, bit IsApprox> {
defvar BaseSet = SchedSEWSet<mx, isF=1>.val;
list<int> val = !if(IsBF16, !listremove(BaseSet, [32, 64]),
!if(IsApprox, BaseSet, !listremove(BaseSet, [64])));
}
multiclass VPseudoVFExp_V<bit IsBF16 = false, bit IsApprox = false> {
defvar SchedSuffix = !if(IsApprox, "VFExpa", "VFExp");

foreach m = MxListF in {
defvar mx = m.MX;
foreach e = VFExpSchedSEWSet<mx, IsBF16, IsApprox>.val in {
let VLMul = m.value in {
def "_V_" # mx # "_E" # e
: VPseudoUnaryNoMask<m.vrclass, m.vrclass>,
SchedUnary<"WriteSF_" # SchedSuffix, "ReadSF_" # SchedSuffix,
mx, e, forcePassthruRead=true>;
def "_V_" # mx # "_E" # e # "_MASK"
: VPseudoUnaryMask<m.vrclass, m.vrclass>,
RISCVMaskedPseudo<MaskIdx = 2>,
SchedUnary<"WriteSF_" # SchedSuffix, "ReadSF_" # SchedSuffix,
mx, e, forcePassthruRead=true>;
}
}
}
}

let Predicates = [HasVendorXSfvfbfexp16e], hasSideEffects = 0 in {
let AltFmtType = IS_ALTFMT in {
defm PseudoSF_VFEXP_ALT : VPseudoVFExp_V<IsBF16=true>;
}
}

let Predicates = [HasVendorXSfvfexpAnyFloat], hasSideEffects = 0 in {
let AltFmtType = IS_NOT_ALTFMT in {
defm PseudoSF_VFEXP : VPseudoVFExp_V;
}
}

let Predicates = [HasVendorXSfvfexpa], AltFmtType = IS_NOT_ALTFMT in {
defm PseudoSF_VFEXPA : VPseudoVFExp_V<IsApprox=true>;
}

// SDNode
def SDT_SF_VC_V_X : SDTypeProfile<1, 4, [SDTCisVec<0>,
SDTCisVT<1, XLenVT>,
Expand Down Expand Up @@ -893,3 +937,36 @@ let Predicates = [HasVendorXSfcease] in {
let rs2 = 0b00101;
}
}

let Predicates = [HasVendorXSfvfbfexp16e] in {
defm : VPatUnaryV_V<"int_riscv_sf_vfexp", "PseudoSF_VFEXP_ALT",
AllBF16Vectors,
isSEWAware=1>;
}

let Predicates = [HasVendorXSfvfexp16e] in {
defm : VPatUnaryV_V<"int_riscv_sf_vfexp", "PseudoSF_VFEXP",
[VF16MF4, VF16MF2, VF16M1, VF16M2, VF16M4, VF16M8],
isSEWAware=1>;
}

let Predicates = [HasVendorXSfvfexp32e] in {
defm : VPatUnaryV_V<"int_riscv_sf_vfexp", "PseudoSF_VFEXP",
[VF32MF2, VF32M1, VF32M2, VF32M4, VF32M8], isSEWAware=1>;
}

let Predicates = [HasVendorXSfvfexpa] in {
defm : VPatUnaryV_V<"int_riscv_sf_vfexpa", "PseudoSF_VFEXPA",
[VF32MF2, VF32M1, VF32M2, VF32M4, VF32M8], isSEWAware=1>;
}

let Predicates = [HasVendorXSfvfexpa, HasVInstructionsF16] in {
defm : VPatUnaryV_V<"int_riscv_sf_vfexpa", "PseudoSF_VFEXPA",
[VF16MF4, VF16MF2, VF16M1, VF16M2, VF16M4, VF16M8],
isSEWAware=1>;
}

let Predicates = [HasVendorXSfvfexpa64e] in {
defm : VPatUnaryV_V<"int_riscv_sf_vfexpa", "PseudoSF_VFEXPA",
[VF64M1, VF64M2, VF64M4, VF64M8], isSEWAware=1>;
}
4 changes: 4 additions & 0 deletions llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
Original file line number Diff line number Diff line change
Expand Up @@ -1588,6 +1588,10 @@ multiclass SiFive7SchedResources<int vlen, bit dualVALU,
//===----------------------------------------------------------------------===//
// Unsupported extensions
defm : UnsupportedSchedQ;
// TODO: scheduling info of XSfvfexp* and XSfvfexpa*
// for SiFive7 will be added in follow-up patches.
defm : UnsupportedSchedXSfvfexp;
defm : UnsupportedSchedXSfvfexpa;
defm : UnsupportedSchedZabha;
defm : UnsupportedSchedZbc;
defm : UnsupportedSchedZbkb;
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/RISCV/RISCVSchedule.td
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,8 @@ include "RISCVScheduleZvk.td"
// Vendor Extensions
multiclass UnsupportedSchedXsf {
defm : UnsupportedSchedXsfvcp;
defm : UnsupportedSchedXSfvfexp;
defm : UnsupportedSchedXSfvfexpa;
defm : UnsupportedSchedXSfvfnrclipxfqf;
defm : UnsupportedSchedXSfvfwmaccqqq;
defm : UnsupportedSchedXSfvqmaccdod;
Expand Down
20 changes: 20 additions & 0 deletions llvm/lib/Target/RISCV/RISCVScheduleXSf.td
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,23 @@ defm : LMULWriteRes<"WriteSF_VFWMACC_QQQ", []>;
defm : LMULReadAdvance<"ReadSF_VFWMACC_QQQ", 0>;
} // Unsupported = true
}

defm "" : LMULSEWSchedWritesF<"WriteSF_VFExp">;
defm "" : LMULSEWSchedReadsF<"ReadSF_VFExp">;

multiclass UnsupportedSchedXSfvfexp {
let Unsupported = true in {
defm : LMULSEWWriteResF<"WriteSF_VFExp", []>;
defm : LMULSEWReadAdvanceF<"ReadSF_VFExp", 0>;
} // Unsupported = true
}

defm "" : LMULSEWSchedWritesF<"WriteSF_VFExpa">;
defm "" : LMULSEWSchedReadsF<"ReadSF_VFExpa">;

multiclass UnsupportedSchedXSfvfexpa {
let Unsupported = true in {
defm : LMULSEWWriteResF<"WriteSF_VFExpa", []>;
defm : LMULSEWReadAdvanceF<"ReadSF_VFExpa", 0>;
} // Unsupported = true
}
191 changes: 191 additions & 0 deletions llvm/test/CodeGen/RISCV/rvv/sf_vfbfexp16e.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
; RUN: sed 's/iXLen/i32/g' %s | llc -mtriple=riscv32 -mattr=+v,+zvfbfmin,+xsfvfbfexp16e \
; RUN: -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK
; RUN: sed 's/iXLen/i64/g' %s | llc -mtriple=riscv64 -mattr=+v,+zvfbfmin,+xsfvfbfexp16e \
; RUN: -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK

define <vscale x 1 x bfloat> @intrinsic_sf_vfexp_v_nxv1bf16(<vscale x 1 x bfloat> %0, iXLen %1) nounwind {
; CHECK-LABEL: intrinsic_sf_vfexp_v_nxv1bf16:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: vsetvli zero, a0, e16alt, mf4, ta, ma
; CHECK-NEXT: sf.vfexp.v v8, v8
; CHECK-NEXT: ret
entry:
%a = call <vscale x 1 x bfloat> @llvm.riscv.sf.vfexp.nxv1bf16(
<vscale x 1 x bfloat> undef,
<vscale x 1 x bfloat> %0,
iXLen %1)

ret <vscale x 1 x bfloat> %a
}

define <vscale x 2 x bfloat> @intrinsic_sf_vfexp_v_nxv2bf16(<vscale x 2 x bfloat> %0, iXLen %1) nounwind {
; CHECK-LABEL: intrinsic_sf_vfexp_v_nxv2bf16:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: vsetvli zero, a0, e16alt, mf2, ta, ma
; CHECK-NEXT: sf.vfexp.v v8, v8
; CHECK-NEXT: ret
entry:
%a = call <vscale x 2 x bfloat> @llvm.riscv.sf.vfexp.nxv2bf16(
<vscale x 2 x bfloat> undef,
<vscale x 2 x bfloat> %0,
iXLen %1)

ret <vscale x 2 x bfloat> %a
}

define <vscale x 4 x bfloat> @intrinsic_sf_vfexp_v_nxv4bf16(<vscale x 4 x bfloat> %0, iXLen %1) nounwind {
; CHECK-LABEL: intrinsic_sf_vfexp_v_nxv4bf16:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: vsetvli zero, a0, e16alt, m1, ta, ma
; CHECK-NEXT: sf.vfexp.v v8, v8
; CHECK-NEXT: ret
entry:
%a = call <vscale x 4 x bfloat> @llvm.riscv.sf.vfexp.nxv4bf16(
<vscale x 4 x bfloat> undef,
<vscale x 4 x bfloat> %0,
iXLen %1)

ret <vscale x 4 x bfloat> %a
}

define <vscale x 8 x bfloat> @intrinsic_sf_vfexp_v_nxv8bf16(<vscale x 8 x bfloat> %0, iXLen %1) nounwind {
; CHECK-LABEL: intrinsic_sf_vfexp_v_nxv8bf16:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: vsetvli zero, a0, e16alt, m2, ta, ma
; CHECK-NEXT: sf.vfexp.v v8, v8
; CHECK-NEXT: ret
entry:
%a = call <vscale x 8 x bfloat> @llvm.riscv.sf.vfexp.nxv8bf16(
<vscale x 8 x bfloat> undef,
<vscale x 8 x bfloat> %0,
iXLen %1)

ret <vscale x 8 x bfloat> %a
}

define <vscale x 16 x bfloat> @intrinsic_sf_vfexp_v_nxv16bf16(<vscale x 16 x bfloat> %0, iXLen %1) nounwind {
; CHECK-LABEL: intrinsic_sf_vfexp_v_nxv16bf16:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: vsetvli zero, a0, e16alt, m4, ta, ma
; CHECK-NEXT: sf.vfexp.v v8, v8
; CHECK-NEXT: ret
entry:
%a = call <vscale x 16 x bfloat> @llvm.riscv.sf.vfexp.nxv16bf16(
<vscale x 16 x bfloat> undef,
<vscale x 16 x bfloat> %0,
iXLen %1)

ret <vscale x 16 x bfloat> %a
}

define <vscale x 32 x bfloat> @intrinsic_sf_vfexp_v_nxv32bf16(<vscale x 32 x bfloat> %0, iXLen %1) nounwind {
; CHECK-LABEL: intrinsic_sf_vfexp_v_nxv32bf16:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: vsetvli zero, a0, e16alt, m8, ta, ma
; CHECK-NEXT: sf.vfexp.v v8, v8
; CHECK-NEXT: ret
entry:
%a = call <vscale x 32 x bfloat> @llvm.riscv.sf.vfexp.nxv32bf16(
<vscale x 32 x bfloat> undef,
<vscale x 32 x bfloat> %0,
iXLen %1)

ret <vscale x 32 x bfloat> %a
}

define <vscale x 1 x bfloat> @intrinsic_sf_vfexp_mask_v_nxv1bf16(<vscale x 1 x bfloat> %0, <vscale x 1 x bfloat> %1, <vscale x 1 x i1> %m, iXLen %2) nounwind {
; CHECK-LABEL: intrinsic_sf_vfexp_mask_v_nxv1bf16:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: vsetvli zero, a0, e16alt, mf4, tu, mu
; CHECK-NEXT: sf.vfexp.v v8, v9, v0.t
; CHECK-NEXT: ret
entry:
%a = call <vscale x 1 x bfloat> @llvm.riscv.sf.vfexp.mask.nxv1bf16(
<vscale x 1 x bfloat> %0,
<vscale x 1 x bfloat> %1,
<vscale x 1 x i1> %m,
iXLen %2, iXLen 0)

ret <vscale x 1 x bfloat> %a
}

define <vscale x 2 x bfloat> @intrinsic_sf_vfexp_mask_v_nxv2bf16(<vscale x 2 x bfloat> %0, <vscale x 2 x bfloat> %1, <vscale x 2 x i1> %m, iXLen %2) nounwind {
; CHECK-LABEL: intrinsic_sf_vfexp_mask_v_nxv2bf16:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: vsetvli zero, a0, e16alt, mf2, tu, mu
; CHECK-NEXT: sf.vfexp.v v8, v9, v0.t
; CHECK-NEXT: ret
entry:
%a = call <vscale x 2 x bfloat> @llvm.riscv.sf.vfexp.mask.nxv2bf16(
<vscale x 2 x bfloat> %0,
<vscale x 2 x bfloat> %1,
<vscale x 2 x i1> %m,
iXLen %2, iXLen 0)

ret <vscale x 2 x bfloat> %a
}

define <vscale x 4 x bfloat> @intrinsic_sf_vfexp_mask_v_nxv4bf16(<vscale x 4 x bfloat> %0, <vscale x 4 x bfloat> %1, <vscale x 4 x i1> %m, iXLen %2) nounwind {
; CHECK-LABEL: intrinsic_sf_vfexp_mask_v_nxv4bf16:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: vsetvli zero, a0, e16alt, m1, tu, mu
; CHECK-NEXT: sf.vfexp.v v8, v9, v0.t
; CHECK-NEXT: ret
entry:
%a = call <vscale x 4 x bfloat> @llvm.riscv.sf.vfexp.mask.nxv4bf16(
<vscale x 4 x bfloat> %0,
<vscale x 4 x bfloat> %1,
<vscale x 4 x i1> %m,
iXLen %2, iXLen 0)

ret <vscale x 4 x bfloat> %a
}

define <vscale x 8 x bfloat> @intrinsic_sf_vfexp_mask_v_nxv8bf16(<vscale x 8 x bfloat> %0, <vscale x 8 x bfloat> %1, <vscale x 8 x i1> %m, iXLen %2) nounwind {
; CHECK-LABEL: intrinsic_sf_vfexp_mask_v_nxv8bf16:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: vsetvli zero, a0, e16alt, m2, tu, mu
; CHECK-NEXT: sf.vfexp.v v8, v10, v0.t
; CHECK-NEXT: ret
entry:
%a = call <vscale x 8 x bfloat> @llvm.riscv.sf.vfexp.mask.nxv8bf16(
<vscale x 8 x bfloat> %0,
<vscale x 8 x bfloat> %1,
<vscale x 8 x i1> %m,
iXLen %2, iXLen 0)

ret <vscale x 8 x bfloat> %a
}

define <vscale x 16 x bfloat> @intrinsic_sf_vfexp_mask_v_nxv16bf16(<vscale x 16 x bfloat> %0, <vscale x 16 x bfloat> %1, <vscale x 16 x i1> %m, iXLen %2) nounwind {
; CHECK-LABEL: intrinsic_sf_vfexp_mask_v_nxv16bf16:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: vsetvli zero, a0, e16alt, m4, tu, mu
; CHECK-NEXT: sf.vfexp.v v8, v12, v0.t
; CHECK-NEXT: ret
entry:
%a = call <vscale x 16 x bfloat> @llvm.riscv.sf.vfexp.mask.nxv16bf16(
<vscale x 16 x bfloat> %0,
<vscale x 16 x bfloat> %1,
<vscale x 16 x i1> %m,
iXLen %2, iXLen 0)

ret <vscale x 16 x bfloat> %a
}

define <vscale x 32 x bfloat> @intrinsic_sf_vfexp_mask_v_nxv32bf16(<vscale x 32 x bfloat> %0, <vscale x 32 x bfloat> %1, <vscale x 32 x i1> %m, iXLen %2) nounwind {
; CHECK-LABEL: intrinsic_sf_vfexp_mask_v_nxv32bf16:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: vsetvli zero, a0, e16alt, m8, tu, mu
; CHECK-NEXT: sf.vfexp.v v8, v16, v0.t
; CHECK-NEXT: ret
entry:
%a = call <vscale x 32 x bfloat> @llvm.riscv.sf.vfexp.mask.nxv32bf16(
<vscale x 32 x bfloat> %0,
<vscale x 32 x bfloat> %1,
<vscale x 32 x i1> %m,
iXLen %2, iXLen 0)

ret <vscale x 32 x bfloat> %a
}
Loading
Loading