14#include "llvm/IR/IntrinsicsHexagon.h"
20 MVT::v4096i8, MVT::v2048i16, MVT::v1024i32};
25void HexagonTargetLowering::initializeHLXLowering() {
29 MVT HalfWordPairTy = MVT::v2048i16;
44 static const unsigned UnsupportedOnByteAndSingleWord[] = {
52 for (MVT
T : AllTypes)
58 for (MVT
T : UnsupportedTypes) {
69 for (MVT
T : UnsupportedTypes) {
82 for (MVT
T : LegalTypes) {
97 for (MVT
T : AllTypes) {
110 for (MVT
T : LegalTypes) {
127 for (MVT
T : LegalPredTypes)
130 for (MVT
T : LegalTypes) {
139 MVT HalfWordSingleTy = MVT::v1024i16;
140 MVT WordPairTy = MVT::v1024i32;
141 for (MVT
T : {HalfWordSingleTy, WordPairTy}) {
154 for (MVT
T : LegalTypes)
175bool HexagonTargetLowering::isHlxSingleTy(
MVT Ty)
const {
176 return Subtarget.isHLXVectorType(Ty) &&
180bool HexagonTargetLowering::isHlxPairTy(
MVT Ty)
const {
181 return Subtarget.isHLXVectorType(Ty) &&
186 if (!Subtarget.useHLXOps())
190 auto IsHLXTy = [
this](EVT Ty) {
191 return Ty.isSimple() && Subtarget.isHLXVectorType(Ty.getSimpleVT());
194 return Op.getValueType().isSimple() && Subtarget.isHLXVectorType(ty(
Op));
203bool HexagonTargetLowering::allowsHlxMemoryAccess(
207 if (VecTy.
getSizeInBits() > 8 * Subtarget.getHLXVectorLength())
209 if (!Subtarget.isHLXVectorType(VecTy))
216HexagonTargetLowering::TypePair
217HexagonTargetLowering::typeHlxSplit(
MVT VecTy)
const {
220 assert((NumElem % 2) == 0 &&
"Expecting even-sized vector type");
223 if (ElemTy == MVT::i32)
227 return {HalfTy, HalfTy};
233SDValue HexagonTargetLowering::splitHlxPairArgLoad(
236 unsigned HlxVLen = Subtarget.getHLXVectorLength();
237 MVT SingleTy = typeHlxSplit(
PairTy).first;
244 MachineMemOperand *MOp1 =
249 return DAG.
getNode(HexagonISD::COMBINELL, dl,
PairTy, Load1, Load0);
255void HexagonTargetLowering::splitHlxPairArgStore(
259 unsigned HlxVLen = Subtarget.getHLXVectorLength();
260 MVT SingleTy = typeHlxSplit(
PairTy).first;
281 unsigned HlxVLen = ST.getHLXVectorLength();
283 PairTy.getVectorElementType() == MVT::i32 &&
284 "Expected HLX vector pair type");
285 MVT SingleTy =
PairTy.changeVectorElementType(MVT::i16);
313 {DAG.
getNode(HexagonISD::COMBINELL, dl,
PairTy, Load1, Load0),
323 unsigned IntNo =
Op.getConstantOperandVal(1);
325 case Intrinsic::hexagon_LX_LL16b_tmp:
327 case Intrinsic::hexagon_LX_SS16b_new:
354 unsigned HwLen = Subtarget.getHLXVectorLength();
361 if (MaskN->isVolatile() || !MaskN->getMemOperand()->isUnordered()) {
363 "Volatile or atomic masked load/store of HLX vector type is not "
368 if (MaskN->getAlign().value() % HwLen != 0) {
370 "Masked load/store of HLX vector type, requires alignment of " +
371 Twine(HwLen) +
" bytes for lowering to HLX");
378 SDValue Chain = MaskN->getChain();
380 MachineMemOperand *MemOp =
381 MaskN->getMemOperand()
385 unsigned Opc =
Op->getOpcode();
399 auto PtrInfo = (MemOp && MemOp->getValue())
400 ? MachinePointerInfo(MemOp->getValue())
401 : MachinePointerInfo();
411 [[maybe_unused]] std::string
Name =
412 "Unexpected masked operation: " +
Op->getOperationName(&DAG);
435 if (ty(CondVec) == MVT::i1) {
440 if (!isHlxPairTy(ValTy))
443 TypePair HalfTys = typeHlxSplit(ValTy);
444 MVT SingleTy = HalfTys.first;
460 return DAG.
getNode(HexagonISD::COMBINELL, dl, ValTy, HiSelect, LoSelect);
465 unsigned Opc =
Op.getOpcode();
471 return LowerHlxPairIntrinsic(
Op, DAG);
476 return LowerHlxMaskedOp(
Op, DAG);
478 return LowerHlxSelect(
Op, DAG);
505 "HLX does not support '" +
Op->getOperationName(&DAG) +
506 "' on vector type " + EVT(VT).getEVTString() +
507 "; use an element type and vector length supported by the HLX ISA");
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static const MVT LegalPredTypes2048B[]
static const MVT LegalTypes2048B[]
static SDValue SplitHlxPairMemHelper(SDValue Op, SelectionDAG &DAG, const HexagonSubtarget &ST, SDValue BaseAddr, SDValue StoreVal=SDValue())
static const MVT AllTypes2048B[]
std::pair< MCSymbol *, MachineModuleInfoImpl::StubValueTy > PairTy
This file defines the SmallVector class.
LLVM_ABI void emitError(const Instruction *I, const Twine &ErrorStr)
emitError - Emit an error message to the currently installed error handler with optional location inf...
MVT changeVectorElementType(MVT EltVT) const
Return a VT for a vector type whose attributes match ourselves with the exception of the element type...
unsigned getVectorNumElements() const
bool isVector() const
Return true if this is a vector value type.
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
static MVT getVectorVT(MVT VT, unsigned NumElements)
MVT getVectorElementType() const
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags F, LLT MemTy, Align BaseAlignment, const MMOMetadata &Metadata=MMOMetadata(), SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
A description of a memory reference used in the backend.
Flags
Flags values. These may be or'd together.
@ MOLoad
The memory access reads data.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
SDValue getValue(unsigned R) const
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
LLVM_ABI SDValue getMergeValues(ArrayRef< SDValue > Ops, const SDLoc &dl)
Create a MERGE_VALUES node from the given operands.
LLVM_ABI Align getEVTAlign(EVT MemoryVT) const
Compute the default alignment value for the given type.
SDValue getUNDEF(EVT VT)
Return an UNDEF node. UNDEF does not have a useful SDLoc.
LLVM_ABI SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, Align Alignment, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const MMOMetadata &Metadata=MMOMetadata())
Helper function to build ISD::STORE nodes.
LLVM_ABI SDValue getMemBasePlusOffset(SDValue Base, TypeSize Offset, const SDLoc &DL, const SDNodeFlags Flags=SDNodeFlags())
Returns sum of the base pointer and offset.
LLVM_ABI SDValue getTargetExtractSubreg(int SRIdx, const SDLoc &DL, EVT VT, SDValue Operand)
A convenience function for creating TargetInstrInfo::EXTRACT_SUBREG nodes.
LLVM_ABI SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, MaybeAlign Alignment=MaybeAlign(), MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const MMOMetadata &Metadata=MMOMetadata())
Loads are not normal binary operators: their result type is not determined by their operands,...
LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
MachineFunction & getMachineFunction() const
LLVMContext * getContext() const
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
void setOperationAction(unsigned Op, MVT VT, LegalizeAction Action)
Indicate that the specified operation does not work with the specified type and indicate what to do a...
void addRegisterClass(MVT VT, const TargetRegisterClass *RC)
Add the specified register class as an available regclass for the specified value type.
void setCondCodeAction(ArrayRef< ISD::CondCode > CCs, MVT VT, LegalizeAction Action)
Indicate that the specified condition code is or isn't supported on the target and indicate what to d...
static constexpr TypeSize getFixed(ScalarTy ExactSize)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
@ SETCC
SetCC operator - This evaluates to a true value iff the condition is true.
@ MLOAD
Masked load and store - consecutive vector load and store operations with additional mask operand tha...
@ ADD
Simple integer binary arithmetic operators.
@ LOAD
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
@ INTRINSIC_VOID
OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...) This node represents a target intrin...
@ ABS
ABS - Determine the unsigned absolute value of a signed integer value of the same bitwidth.
@ SIGN_EXTEND
Conversion operators.
@ AVGCEILS
AVGCEILS/AVGCEILU - Rounding averaging add - Add two integers using an integer of type i[N+2],...
@ SSUBSAT
RESULT = [US]SUBSAT(LHS, RHS) - Perform saturation subtraction on 2 integers with the same bit width ...
@ SELECT
Select(COND, TRUEVAL, FALSEVAL).
@ SPLAT_VECTOR
SPLAT_VECTOR(VAL) - Returns a vector with the scalar value VAL duplicated in all lanes.
@ MULHU
MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing an unsigned/signed value of...
@ SHL
Shift and rotation operations.
@ ZERO_EXTEND
ZERO_EXTEND - Used for integer types, zeroing the new bits.
@ SMIN
[US]{MIN/MAX} - Binary minimum or maximum of signed or unsigned integers.
@ VSELECT
Select with a vector condition (op #0) and two vector operands (ops #1 and #2), returning a vector re...
@ AND
Bitwise operators - logical and, logical or, logical xor.
@ INTRINSIC_WO_CHAIN
RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) This node represents a target intrinsic fun...
@ AVGFLOORS
AVGFLOORS/AVGFLOORU - Averaging add - Add two integers using an integer of type i[N+1],...
@ TokenFactor
TokenFactor - This node takes multiple tokens as input and produces a single token result.
@ TRUNCATE
TRUNCATE - Completely drop the high bits.
@ SADDSAT
RESULT = [US]ADDSAT(LHS, RHS) - Perform saturation addition on 2 integers with the same bit width (W)...
@ ABDS
ABDS/ABDU - Absolute difference - Return the absolute difference between two numbers interpreted as s...
@ INTRINSIC_W_CHAIN
RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) This node represents a target in...
This is an optimization pass for GlobalISel generic memory operations.
@ Load
The value being inserted comes from a load (InsertElement only).
@ Store
The extracted value is stored (ExtractElement only).
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
@ Fast
Assign the register banks as fast as possible (default).
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
This class contains a discriminated union of information about pointers in memory operands,...
MachinePointerInfo getWithOffset(int64_t O) const