15#include "llvm/IR/IntrinsicsHexagon.h"
21 MVT::v4096i8, MVT::v2048i16, MVT::v1024i32};
26void HexagonTargetLowering::initializeHLXLowering() {
30 MVT HalfWordPairTy = MVT::v2048i16;
45 static const unsigned UnsupportedOnByteAndSingleWord[] = {
53 for (MVT
T : AllTypes)
59 for (MVT
T : UnsupportedTypes) {
70 for (MVT
T : UnsupportedTypes) {
83 for (MVT
T : LegalTypes) {
98 for (MVT
T : AllTypes) {
111 for (MVT
T : LegalTypes) {
128 for (MVT
T : LegalPredTypes)
131 for (MVT
T : LegalTypes) {
140 MVT HalfWordSingleTy = MVT::v1024i16;
141 MVT WordPairTy = MVT::v1024i32;
142 for (MVT
T : {HalfWordSingleTy, WordPairTy}) {
155 for (MVT
T : LegalTypes)
176bool HexagonTargetLowering::isHlxSingleTy(
MVT Ty)
const {
177 return Subtarget.isHLXVectorType(Ty) &&
181bool HexagonTargetLowering::isHlxPairTy(
MVT Ty)
const {
182 return Subtarget.isHLXVectorType(Ty) &&
187 if (!Subtarget.useHLXOps())
191 auto IsHLXTy = [
this](EVT Ty) {
192 return Ty.isSimple() && Subtarget.isHLXVectorType(Ty.getSimpleVT());
195 return Op.getValueType().isSimple() && Subtarget.isHLXVectorType(ty(
Op));
204bool HexagonTargetLowering::allowsHlxMemoryAccess(
208 if (VecTy.
getSizeInBits() > 8 * Subtarget.getHLXVectorLength())
210 if (!Subtarget.isHLXVectorType(VecTy))
217HexagonTargetLowering::TypePair
218HexagonTargetLowering::typeHlxSplit(
MVT VecTy)
const {
221 assert((NumElem % 2) == 0 &&
"Expecting even-sized vector type");
224 if (ElemTy == MVT::i32)
228 return {HalfTy, HalfTy};
234SDValue HexagonTargetLowering::splitHlxPairArgLoad(
237 unsigned HlxVLen = Subtarget.getHLXVectorLength();
238 MVT SingleTy =
PairTy.changeVectorElementType(MVT::i16);
245 MachineMemOperand *MOp1 =
250 return DAG.
getNode(HexagonISD::COMBINELL, dl,
PairTy, Load1, Load0);
256void HexagonTargetLowering::splitHlxPairArgStore(
260 unsigned HlxVLen = Subtarget.getHLXVectorLength();
282 unsigned HlxVLen = ST.getHLXVectorLength();
284 PairTy.getVectorElementType() == MVT::i32 &&
285 "Expected HLX vector pair type");
286 MVT SingleTy =
PairTy.changeVectorElementType(MVT::i16);
314 {DAG.
getNode(HexagonISD::COMBINELL, dl,
PairTy, Load1, Load0),
324 unsigned IntNo =
Op.getConstantOperandVal(1);
326 case Intrinsic::hexagon_LX_LL16b_tmp:
328 case Intrinsic::hexagon_LX_SS16b_new:
355 unsigned HwLen = Subtarget.getHLXVectorLength();
362 if (MaskN->isVolatile() || !MaskN->getMemOperand()->isUnordered()) {
364 "Volatile or atomic masked load/store of HLX vector type is not "
369 if (MaskN->getAlign().value() % HwLen != 0) {
371 "Masked load/store of HLX vector type, requires alignment of " +
372 Twine(HwLen) +
" bytes for lowering to HLX");
379 SDValue Chain = MaskN->getChain();
381 MachineMemOperand *MemOp =
382 MaskN->getMemOperand()
386 unsigned Opc =
Op->getOpcode();
400 auto PtrInfo = (MemOp && MemOp->getValue())
401 ? MachinePointerInfo(MemOp->getValue())
402 : MachinePointerInfo();
412 [[maybe_unused]] std::string
Name =
413 "Unexpected masked operation: " +
Op->getOperationName(&DAG);
436 if (ty(CondVec) == MVT::i1) {
441 if (!isHlxPairTy(ValTy))
444 TypePair HalfTys = typeHlxSplit(ValTy);
445 MVT SingleTy = HalfTys.first;
461 return DAG.
getNode(HexagonISD::COMBINELL, dl, ValTy, HiSelect, LoSelect);
466 unsigned Opc =
Op.getOpcode();
472 return LowerHlxPairIntrinsic(
Op, DAG);
477 return LowerHlxMaskedOp(
Op, DAG);
479 return LowerHlxSelect(
Op, DAG);
506 "HLX does not support '" +
Op->getOperationName(&DAG) +
507 "' on vector type " + EVT(VT).getEVTString() +
508 "; 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