Skip to content

Commit

Permalink
[Hexagon] Calling conventions for floating point vectors
Browse files Browse the repository at this point in the history
They are the same as for the other HVX vectors, but types need to be
listed explicitly. Also, add a detailed codegen testcase.

Co-authored-by: Abhikrant Sharma <quic_abhikran@quicinc.com>
  • Loading branch information
Krzysztof Parzyszek and abhikran-quic committed Dec 29, 2021
1 parent ee3f557 commit 4df2aba
Show file tree
Hide file tree
Showing 5 changed files with 1,556 additions and 13 deletions.
12 changes: 6 additions & 6 deletions llvm/lib/Target/Hexagon/HexagonCallingConv.td
Expand Up @@ -126,16 +126,16 @@ def CC_Hexagon_HVX: CallingConv<[

// HVX 128-byte mode
CCIfHvx128<
CCIfType<[v32i32,v64i16,v128i8],
CCIfType<[v32i32,v64i16,v128i8,v32f32,v64f16],
CCAssignToReg<[V0,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11,V12,V13,V14,V15]>>>,
CCIfHvx128<
CCIfType<[v64i32,v128i16,v256i8],
CCIfType<[v64i32,v128i16,v256i8,v64f32,v128f16],
CCAssignToReg<[W0,W1,W2,W3,W4,W5,W6,W7]>>>,
CCIfHvx128<
CCIfType<[v32i32,v64i16,v128i8],
CCIfType<[v32i32,v64i16,v128i8,v32f32,v64f16],
CCAssignToStack<128,128>>>,
CCIfHvx128<
CCIfType<[v64i32,v128i16,v256i8],
CCIfType<[v64i32,v128i16,v256i8,v64f32,v128f16],
CCAssignToStack<256,128>>>,

CCDelegateTo<CC_Hexagon>
Expand All @@ -152,10 +152,10 @@ def RetCC_Hexagon_HVX: CallingConv<[

// HVX 128-byte mode
CCIfHvx128<
CCIfType<[v32i32,v64i16,v128i8],
CCIfType<[v32i32,v64i16,v128i8,v32f32,v64f16],
CCAssignToReg<[V0]>>>,
CCIfHvx128<
CCIfType<[v64i32,v128i16,v256i8],
CCIfType<[v64i32,v128i16,v256i8,v64f32,v128f16],
CCAssignToReg<[W0]>>>,

CCDelegateTo<RetCC_Hexagon>
Expand Down
4 changes: 4 additions & 0 deletions llvm/lib/Target/Hexagon/HexagonISelLoweringHVX.cpp
Expand Up @@ -59,6 +59,7 @@ HexagonTargetLowering::initializeHVXLowering() {
addRegisterClass(MVT::v32f32, &Hexagon::HvxVRRegClass);
addRegisterClass(MVT::v64f16, &Hexagon::HvxVRRegClass);
addRegisterClass(MVT::v64f32, &Hexagon::HvxWRRegClass);
addRegisterClass(MVT::v128f16, &Hexagon::HvxWRRegClass);
}
}

Expand Down Expand Up @@ -104,6 +105,9 @@ HexagonTargetLowering::initializeHVXLowering() {
// independent) handling of it would convert it to a load, which is
// not always the optimal choice.
setOperationAction(ISD::BUILD_VECTOR, MVT::v64f32, Custom);
// Make concat-vectors custom to handle concats of more than 2 vectors.
setOperationAction(ISD::CONCAT_VECTORS, MVT::v128f16, Custom);
setOperationAction(ISD::CONCAT_VECTORS, MVT::v64f32, Custom);
}

for (MVT T : LegalV) {
Expand Down
19 changes: 16 additions & 3 deletions llvm/lib/Target/Hexagon/HexagonPatternsHVX.td
Expand Up @@ -265,9 +265,7 @@ let Predicates = [UseHVX] in {
// These should be preferred over a vsplat of 0.
def: Pat<(VecI8 vzero), (V6_vd0)>;
def: Pat<(VecI16 vzero), (V6_vd0)>;
def: Pat<(VecF16 vzero), (V6_vd0)>;
def: Pat<(VecI32 vzero), (V6_vd0)>;
def: Pat<(VecF32 vzero), (V6_vd0)>;
def: Pat<(VecPI8 vzero), (PS_vdd0)>;
def: Pat<(VecPI16 vzero), (PS_vdd0)>;
def: Pat<(VecPI32 vzero), (PS_vdd0)>;
Expand Down Expand Up @@ -303,7 +301,22 @@ let Predicates = [UseHVX] in {
(V6_vinsertwr HvxVR:$Vu, I32:$Rt)>;
}

let Predicates = [UseHVXFloatingPoint] in {
let Predicates = [UseHVX, UseHVXFloatingPoint] in {
let AddedComplexity = 100 in {
def: Pat<(VecF16 vzero), (V6_vd0)>;
def: Pat<(VecF32 vzero), (V6_vd0)>;
def: Pat<(VecPF16 vzero), (PS_vdd0)>;
def: Pat<(VecPF32 vzero), (PS_vdd0)>;

def: Pat<(concat_vectors (VecF16 vzero), (VecF16 vzero)), (PS_vdd0)>;
def: Pat<(concat_vectors (VecF32 vzero), (VecF32 vzero)), (PS_vdd0)>;
}

def: Pat<(VecPF16 (concat_vectors HVF16:$Vs, HVF16:$Vt)),
(Combinev HvxVR:$Vt, HvxVR:$Vs)>;
def: Pat<(VecPF32 (concat_vectors HVF32:$Vs, HVF32:$Vt)),
(Combinev HvxVR:$Vt, HvxVR:$Vs)>;

def: Pat<(HexagonVINSERTW0 HVF16:$Vu, I32:$Rt),
(V6_vinsertwr HvxVR:$Vu, I32:$Rt)>;
def: Pat<(HexagonVINSERTW0 HVF32:$Vu, I32:$Rt),
Expand Down

0 comments on commit 4df2aba

Please sign in to comment.