Skip to content

Commit

Permalink
[Hexagon] Add instruction definitions for Hexagon v71, v71t, and v73
Browse files Browse the repository at this point in the history
This includes instruction formats, definitions, encodings, scheduling
classes, and builtins/intrinsics.
  • Loading branch information
Krzysztof Parzyszek committed Nov 17, 2022
1 parent 35cc9bc commit 7665369
Show file tree
Hide file tree
Showing 25 changed files with 5,675 additions and 169 deletions.
33 changes: 33 additions & 0 deletions clang/include/clang/Basic/BuiltinsHexagonDep.def
Expand Up @@ -1890,3 +1890,36 @@ TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrvwuhsat, "V16iV32iV16i", "", HVXV69)
TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrvwuhsat_128B, "V32iV64iV32i", "", HVXV69)
TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuhvs, "V16iV16iV16i", "", HVXV69)
TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuhvs_128B, "V32iV32iV32i", "", HVXV69)

// V73 HVX Instructions.

TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_sf_bf, "V32iV16iV16i", "", HVXV73)
TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_sf_bf_128B, "V64iV32iV32i", "", HVXV73)
TARGET_BUILTIN(__builtin_HEXAGON_V6_vconv_h_hf, "V16iV16i", "", HVXV73)
TARGET_BUILTIN(__builtin_HEXAGON_V6_vconv_h_hf_128B, "V32iV32i", "", HVXV73)
TARGET_BUILTIN(__builtin_HEXAGON_V6_vconv_hf_h, "V16iV16i", "", HVXV73)
TARGET_BUILTIN(__builtin_HEXAGON_V6_vconv_hf_h_128B, "V32iV32i", "", HVXV73)
TARGET_BUILTIN(__builtin_HEXAGON_V6_vconv_sf_w, "V16iV16i", "", HVXV73)
TARGET_BUILTIN(__builtin_HEXAGON_V6_vconv_sf_w_128B, "V32iV32i", "", HVXV73)
TARGET_BUILTIN(__builtin_HEXAGON_V6_vconv_w_sf, "V16iV16i", "", HVXV73)
TARGET_BUILTIN(__builtin_HEXAGON_V6_vconv_w_sf_128B, "V32iV32i", "", HVXV73)
TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_bf_sf, "V16iV16iV16i", "", HVXV73)
TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_bf_sf_128B, "V32iV32iV32i", "", HVXV73)
TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtbf, "V64bV16iV16i", "", HVXV73)
TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtbf_128B, "V128bV32iV32i", "", HVXV73)
TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtbf_and, "V64bV64bV16iV16i", "", HVXV73)
TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtbf_and_128B, "V128bV128bV32iV32i", "", HVXV73)
TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtbf_or, "V64bV64bV16iV16i", "", HVXV73)
TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtbf_or_128B, "V128bV128bV32iV32i", "", HVXV73)
TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtbf_xor, "V64bV64bV16iV16i", "", HVXV73)
TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtbf_xor_128B, "V128bV128bV32iV32i", "", HVXV73)
TARGET_BUILTIN(__builtin_HEXAGON_V6_vmax_bf, "V16iV16iV16i", "", HVXV73)
TARGET_BUILTIN(__builtin_HEXAGON_V6_vmax_bf_128B, "V32iV32iV32i", "", HVXV73)
TARGET_BUILTIN(__builtin_HEXAGON_V6_vmin_bf, "V16iV16iV16i", "", HVXV73)
TARGET_BUILTIN(__builtin_HEXAGON_V6_vmin_bf_128B, "V32iV32iV32i", "", HVXV73)
TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_sf_bf, "V32iV16iV16i", "", HVXV73)
TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_sf_bf_128B, "V64iV32iV32i", "", HVXV73)
TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_sf_bf_acc, "V32iV32iV16iV16i", "", HVXV73)
TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_sf_bf_acc_128B, "V64iV64iV32iV32i", "", HVXV73)
TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_sf_bf, "V32iV16iV16i", "", HVXV73)
TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_sf_bf_128B, "V64iV32iV32i", "", HVXV73)
98 changes: 95 additions & 3 deletions llvm/include/llvm/IR/IntrinsicsHexagonDep.td
Expand Up @@ -316,7 +316,7 @@ class Hexagon_v32i32_v64i32_Intrinsic<string GCCIntSuffix,
[llvm_v32i32_ty], [llvm_v64i32_ty],
intr_properties>;

// tag : V6_lvsplatw
// tag : V6_lvsplatb
class Hexagon_v16i32_i32_Intrinsic<string GCCIntSuffix,
list<IntrinsicProperty> intr_properties = [IntrNoMem]>
: Hexagon_Intrinsic<GCCIntSuffix,
Expand Down Expand Up @@ -442,14 +442,14 @@ class Hexagon_v32i32_v32i32v32i32_Intrinsic<string GCCIntSuffix,
[llvm_v32i32_ty], [llvm_v32i32_ty,llvm_v32i32_ty],
intr_properties>;

// tag : V6_vadd_sf_hf
// tag : V6_vadd_sf_bf
class Hexagon_v32i32_v16i32v16i32_Intrinsic<string GCCIntSuffix,
list<IntrinsicProperty> intr_properties = [IntrNoMem]>
: Hexagon_Intrinsic<GCCIntSuffix,
[llvm_v32i32_ty], [llvm_v16i32_ty,llvm_v16i32_ty],
intr_properties>;

// tag : V6_vadd_sf_hf
// tag : V6_vadd_sf_bf
class Hexagon_v64i32_v32i32v32i32_Intrinsic<string GCCIntSuffix,
list<IntrinsicProperty> intr_properties = [IntrNoMem]>
: Hexagon_Intrinsic<GCCIntSuffix,
Expand Down Expand Up @@ -6613,3 +6613,95 @@ Hexagon_v16i32_v16i32v16i32_Intrinsic<"HEXAGON_V6_vmpyuhvs">;
def int_hexagon_V6_vmpyuhvs_128B :
Hexagon_v32i32_v32i32v32i32_Intrinsic<"HEXAGON_V6_vmpyuhvs_128B">;

// V73 HVX Instructions.

def int_hexagon_V6_vadd_sf_bf :
Hexagon_v32i32_v16i32v16i32_Intrinsic<"HEXAGON_V6_vadd_sf_bf">;

def int_hexagon_V6_vadd_sf_bf_128B :
Hexagon_v64i32_v32i32v32i32_Intrinsic<"HEXAGON_V6_vadd_sf_bf_128B">;

def int_hexagon_V6_vconv_h_hf :
Hexagon_v16i32_v16i32_Intrinsic<"HEXAGON_V6_vconv_h_hf">;

def int_hexagon_V6_vconv_h_hf_128B :
Hexagon_v32i32_v32i32_Intrinsic<"HEXAGON_V6_vconv_h_hf_128B">;

def int_hexagon_V6_vconv_hf_h :
Hexagon_v16i32_v16i32_Intrinsic<"HEXAGON_V6_vconv_hf_h">;

def int_hexagon_V6_vconv_hf_h_128B :
Hexagon_v32i32_v32i32_Intrinsic<"HEXAGON_V6_vconv_hf_h_128B">;

def int_hexagon_V6_vconv_sf_w :
Hexagon_v16i32_v16i32_Intrinsic<"HEXAGON_V6_vconv_sf_w">;

def int_hexagon_V6_vconv_sf_w_128B :
Hexagon_v32i32_v32i32_Intrinsic<"HEXAGON_V6_vconv_sf_w_128B">;

def int_hexagon_V6_vconv_w_sf :
Hexagon_v16i32_v16i32_Intrinsic<"HEXAGON_V6_vconv_w_sf">;

def int_hexagon_V6_vconv_w_sf_128B :
Hexagon_v32i32_v32i32_Intrinsic<"HEXAGON_V6_vconv_w_sf_128B">;

def int_hexagon_V6_vcvt_bf_sf :
Hexagon_v16i32_v16i32v16i32_Intrinsic<"HEXAGON_V6_vcvt_bf_sf">;

def int_hexagon_V6_vcvt_bf_sf_128B :
Hexagon_v32i32_v32i32v32i32_Intrinsic<"HEXAGON_V6_vcvt_bf_sf_128B">;

def int_hexagon_V6_vgtbf :
Hexagon_v64i1_v16i32v16i32_Intrinsic<"HEXAGON_V6_vgtbf">;

def int_hexagon_V6_vgtbf_128B :
Hexagon_v128i1_v32i32v32i32_Intrinsic<"HEXAGON_V6_vgtbf_128B">;

def int_hexagon_V6_vgtbf_and :
Hexagon_v64i1_v64i1v16i32v16i32_Intrinsic<"HEXAGON_V6_vgtbf_and">;

def int_hexagon_V6_vgtbf_and_128B :
Hexagon_v128i1_v128i1v32i32v32i32_Intrinsic<"HEXAGON_V6_vgtbf_and_128B">;

def int_hexagon_V6_vgtbf_or :
Hexagon_v64i1_v64i1v16i32v16i32_Intrinsic<"HEXAGON_V6_vgtbf_or">;

def int_hexagon_V6_vgtbf_or_128B :
Hexagon_v128i1_v128i1v32i32v32i32_Intrinsic<"HEXAGON_V6_vgtbf_or_128B">;

def int_hexagon_V6_vgtbf_xor :
Hexagon_v64i1_v64i1v16i32v16i32_Intrinsic<"HEXAGON_V6_vgtbf_xor">;

def int_hexagon_V6_vgtbf_xor_128B :
Hexagon_v128i1_v128i1v32i32v32i32_Intrinsic<"HEXAGON_V6_vgtbf_xor_128B">;

def int_hexagon_V6_vmax_bf :
Hexagon_v16i32_v16i32v16i32_Intrinsic<"HEXAGON_V6_vmax_bf">;

def int_hexagon_V6_vmax_bf_128B :
Hexagon_v32i32_v32i32v32i32_Intrinsic<"HEXAGON_V6_vmax_bf_128B">;

def int_hexagon_V6_vmin_bf :
Hexagon_v16i32_v16i32v16i32_Intrinsic<"HEXAGON_V6_vmin_bf">;

def int_hexagon_V6_vmin_bf_128B :
Hexagon_v32i32_v32i32v32i32_Intrinsic<"HEXAGON_V6_vmin_bf_128B">;

def int_hexagon_V6_vmpy_sf_bf :
Hexagon_v32i32_v16i32v16i32_Intrinsic<"HEXAGON_V6_vmpy_sf_bf">;

def int_hexagon_V6_vmpy_sf_bf_128B :
Hexagon_v64i32_v32i32v32i32_Intrinsic<"HEXAGON_V6_vmpy_sf_bf_128B">;

def int_hexagon_V6_vmpy_sf_bf_acc :
Hexagon_v32i32_v32i32v16i32v16i32_Intrinsic<"HEXAGON_V6_vmpy_sf_bf_acc">;

def int_hexagon_V6_vmpy_sf_bf_acc_128B :
Hexagon_v64i32_v64i32v32i32v32i32_Intrinsic<"HEXAGON_V6_vmpy_sf_bf_acc_128B">;

def int_hexagon_V6_vsub_sf_bf :
Hexagon_v32i32_v16i32v16i32_Intrinsic<"HEXAGON_V6_vsub_sf_bf">;

def int_hexagon_V6_vsub_sf_bf_128B :
Hexagon_v64i32_v32i32v32i32_Intrinsic<"HEXAGON_V6_vsub_sf_bf_128B">;

8 changes: 8 additions & 0 deletions llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp
Expand Up @@ -354,6 +354,11 @@ struct HexagonOperand : public MCParsedAsmOperand {
return false;
return Value == -1;
}
bool issgp10Const() const {
if (!isReg())
return false;
return getReg() == Hexagon::SGP1_0;
}
bool iss11_0Imm() const {
return CheckImmRange(11 + 26, 0, true, true, true);
}
Expand Down Expand Up @@ -400,6 +405,9 @@ struct HexagonOperand : public MCParsedAsmOperand {
void addn1ConstOperands(MCInst &Inst, unsigned N) const {
addImmOperands(Inst, N);
}
void addsgp10ConstOperands(MCInst &Inst, unsigned N) const {
addRegOperands(Inst, N);
}

StringRef getToken() const {
assert(Kind == Token && "Invalid access!");
Expand Down
30 changes: 30 additions & 0 deletions llvm/lib/Target/Hexagon/Hexagon.td
Expand Up @@ -58,6 +58,14 @@ def ExtensionHVXV69: SubtargetFeature<"hvxv69", "HexagonHVXVersion",
"Hexagon::ArchEnum::V69", "Hexagon HVX instructions",
[ExtensionHVXV60, ExtensionHVXV62, ExtensionHVXV65, ExtensionHVXV66,
ExtensionHVXV67, ExtensionHVXV68]>;
def ExtensionHVXV71: SubtargetFeature<"hvxv71", "HexagonHVXVersion",
"Hexagon::ArchEnum::V71", "Hexagon HVX instructions",
[ExtensionHVXV60, ExtensionHVXV62, ExtensionHVXV65, ExtensionHVXV66,
ExtensionHVXV67, ExtensionHVXV68, ExtensionHVXV69]>;
def ExtensionHVXV73: SubtargetFeature<"hvxv73", "HexagonHVXVersion",
"Hexagon::ArchEnum::V73", "Hexagon HVX instructions",
[ExtensionHVXV60, ExtensionHVXV62, ExtensionHVXV65, ExtensionHVXV66,
ExtensionHVXV67, ExtensionHVXV68, ExtensionHVXV69, ExtensionHVXV71]>;

def ExtensionHVX64B: SubtargetFeature<"hvx-length64b", "UseHVX64BOps",
"true", "Hexagon HVX 64B instructions", [ExtensionHVX]>;
Expand Down Expand Up @@ -125,6 +133,10 @@ def UseHVXV68 : Predicate<"HST->useHVXV68Ops()">,
AssemblerPredicate<(all_of ExtensionHVXV68)>;
def UseHVXV69 : Predicate<"HST->useHVXV69Ops()">,
AssemblerPredicate<(all_of ExtensionHVXV69)>;
def UseHVXV71 : Predicate<"HST->useHVXV71Ops()">,
AssemblerPredicate<(all_of ExtensionHVXV71)>;
def UseHVXV73 : Predicate<"HST->useHVXV73Ops()">,
AssemblerPredicate<(all_of ExtensionHVXV73)>;
def UseAudio : Predicate<"HST->useAudioOps()">,
AssemblerPredicate<(all_of ExtensionAudio)>;
def UseZReg : Predicate<"HST->useZRegOps()">,
Expand Down Expand Up @@ -439,6 +451,17 @@ def : Proc<"hexagonv69", HexagonModelV69,
FeatureCompound, FeatureDuplex, FeatureMemNoShuf, FeatureMemops,
FeatureNVJ, FeatureNVS, FeaturePackets, FeatureSmallData,
FeatureCabac]>;
def : Proc<"hexagonv71", HexagonModelV71,
[ArchV5, ArchV55, ArchV60, ArchV62, ArchV65, ArchV66, ArchV67,
ArchV68, ArchV69, ArchV71,
FeatureCompound, FeatureDuplex, FeatureMemNoShuf, FeatureMemops,
FeatureNVJ, FeatureNVS, FeaturePackets, FeatureSmallData,
FeatureCabac]>;
def : Proc<"hexagonv73", HexagonModelV73,
[ArchV5, ArchV55, ArchV60, ArchV62, ArchV65, ArchV66, ArchV67,
ArchV68, ArchV69, ArchV71, ArchV73,
FeatureCompound, FeatureDuplex, FeatureMemNoShuf, FeatureMemops,
FeatureNVJ, FeatureNVS, FeaturePackets, FeatureSmallData]>;
// Need to update the correct features for tiny core.
// Disable NewValueJumps since the packetizer is unable to handle a packet with
// a new value jump and another SLOT0 instruction.
Expand All @@ -448,6 +471,13 @@ def : Proc<"hexagonv67t", HexagonModelV67T,
FeatureCompound, FeatureMemNoShuf, FeatureMemops,
FeatureNVS, FeaturePackets, FeatureSmallData]>;

def : Proc<"hexagonv71t", HexagonModelV71T,
[ArchV5, ArchV55, ArchV60, ArchV62, ArchV65, ArchV66, ArchV67,
ArchV68, ArchV69, ArchV71,
ProcTinyCore, ExtensionAudio,
FeatureCompound, FeatureMemNoShuf, FeatureMemops,
FeatureNVS, FeaturePackets, FeatureSmallData]>;

//===----------------------------------------------------------------------===//
// Declare the target which we are implementing
//===----------------------------------------------------------------------===//
Expand Down
22 changes: 18 additions & 4 deletions llvm/lib/Target/Hexagon/HexagonDepArch.h
Expand Up @@ -5,9 +5,6 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// Automatically generated file, do not edit!
//===----------------------------------------------------------------------===//


#ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONDEPARCH_H
#define LLVM_LIB_TARGET_HEXAGON_HEXAGONDEPARCH_H
Expand All @@ -16,7 +13,21 @@

namespace llvm {
namespace Hexagon {
enum class ArchEnum { NoArch, Generic, V5, V55, V60, V62, V65, V66, V67, V68, V69 };
enum class ArchEnum {
NoArch,
Generic,
V5,
V55,
V60,
V62,
V65,
V66,
V67,
V68,
V69,
V71,
V73
};

inline Optional<Hexagon::ArchEnum> getCpu(StringRef CPU) {
return StringSwitch<Optional<Hexagon::ArchEnum>>(CPU)
Expand All @@ -31,6 +42,9 @@ inline Optional<Hexagon::ArchEnum> getCpu(StringRef CPU) {
.Case("hexagonv67t", Hexagon::ArchEnum::V67)
.Case("hexagonv68", Hexagon::ArchEnum::V68)
.Case("hexagonv69", Hexagon::ArchEnum::V69)
.Case("hexagonv71", Hexagon::ArchEnum::V71)
.Case("hexagonv71t", Hexagon::ArchEnum::V71)
.Case("hexagonv73", Hexagon::ArchEnum::V73)
.Default(None);
}
} // namespace Hexagon
Expand Down
4 changes: 4 additions & 0 deletions llvm/lib/Target/Hexagon/HexagonDepArch.td
Expand Up @@ -26,3 +26,7 @@ def ArchV68: SubtargetFeature<"v68", "HexagonArchVersion", "Hexagon::ArchEnum::V
def HasV68 : Predicate<"HST->hasV68Ops()">, AssemblerPredicate<(all_of ArchV68)>;
def ArchV69: SubtargetFeature<"v69", "HexagonArchVersion", "Hexagon::ArchEnum::V69", "Enable Hexagon V69 architecture">;
def HasV69 : Predicate<"HST->hasV69Ops()">, AssemblerPredicate<(all_of ArchV69)>;
def ArchV71: SubtargetFeature<"v71", "HexagonArchVersion", "Hexagon::ArchEnum::V71", "Enable Hexagon V71 architecture">;
def HasV71 : Predicate<"HST->hasV71Ops()">, AssemblerPredicate<(all_of ArchV71)>;
def ArchV73: SubtargetFeature<"v73", "HexagonArchVersion", "Hexagon::ArchEnum::V73", "Enable Hexagon V73 architecture">;
def HasV73 : Predicate<"HST->hasV73Ops()">, AssemblerPredicate<(all_of ArchV73)>;

3 comments on commit 7665369

@ronlieb
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Krzysztof

been awhile, looks like one/two of your patches have broken our amdgpu hip and openmp buildbots.
https://lab.llvm.org/buildbot/#/builders/193/builds/21976

/work/omp-vega20-0/openmp-offload-amdgpu-runtime/llvm.src/clang/include/clang/Basic/BuiltinsHexagonDep.def:1925:74: error: 'HVXV73' was not declared in this scope
TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_sf_bf_128B, "V64iV32iV32i", "", HVXV73)
^
/work/omp-vega20-0/openmp-offload-amdgpu-runtime/llvm.src/clang/lib/Basic/Targets/Hexagon.cpp:195:46: note: in definition of macro 'TARGET_BUILTIN'
{#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, FEATURE},

thanks,
Ron

@MaskRay
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same error. Reverted in 99f730c

@kparzysz-quic
Copy link

@kparzysz-quic kparzysz-quic commented on 7665369 Nov 17, 2022 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.