blob: 66214a409b323e34e250933f3ed5db074d16653c [file] [log] [blame]
Jia Liub22310f2012-02-18 12:03:15 +00001//===-- HexagonISelLowering.h - Hexagon DAG Lowering Interface --*- C++ -*-===//
Tony Linthicum1213a7a2011-12-12 21:14:40 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines the interfaces that Hexagon uses to lower LLVM code into a
11// selection DAG.
12//
13//===----------------------------------------------------------------------===//
14
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000015#ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONISELLOWERING_H
16#define LLVM_LIB_TARGET_HEXAGON_HEXAGONISELLOWERING_H
Tony Linthicum1213a7a2011-12-12 21:14:40 +000017
Craig Topperb25fda92012-03-17 18:46:09 +000018#include "Hexagon.h"
Eugene Zelenko58655bb2016-12-17 01:09:05 +000019#include "llvm/ADT/StringRef.h"
20#include "llvm/CodeGen/ISDOpcodes.h"
21#include "llvm/CodeGen/MachineValueType.h"
22#include "llvm/CodeGen/SelectionDAGNodes.h"
David Blaikieb3bde2e2017-11-17 01:07:10 +000023#include "llvm/CodeGen/TargetLowering.h"
Eugene Zelenko58655bb2016-12-17 01:09:05 +000024#include "llvm/CodeGen/ValueTypes.h"
Chandler Carruth9fb823b2013-01-02 11:36:10 +000025#include "llvm/IR/CallingConv.h"
Eugene Zelenko58655bb2016-12-17 01:09:05 +000026#include "llvm/IR/InlineAsm.h"
Eugene Zelenko58655bb2016-12-17 01:09:05 +000027#include <cstdint>
28#include <utility>
Tony Linthicum1213a7a2011-12-12 21:14:40 +000029
30namespace llvm {
Eugene Zelenko58655bb2016-12-17 01:09:05 +000031
32namespace HexagonISD {
33
Matthias Braund04893f2015-05-07 21:33:59 +000034 enum NodeType : unsigned {
Krzysztof Parzyszek952d9512015-04-22 21:17:00 +000035 OP_BEGIN = ISD::BUILTIN_OP_END,
Tony Linthicum1213a7a2011-12-12 21:14:40 +000036
Krzysztof Parzyszek952d9512015-04-22 21:17:00 +000037 CONST32 = OP_BEGIN,
Tony Linthicum1213a7a2011-12-12 21:14:40 +000038 CONST32_GP, // For marking data present in GP.
Krzysztof Parzyszek4fa2a9f2015-04-22 16:43:53 +000039 ALLOCA,
Tony Linthicum1213a7a2011-12-12 21:14:40 +000040
Krzysztof Parzyszek21dc8bd2015-12-18 20:19:30 +000041 AT_GOT, // Index in GOT.
42 AT_PCREL, // Offset relative to PC.
Colin LeMahieu60a99e62015-03-10 20:04:44 +000043
Krzysztof Parzyszekbe976d42016-08-12 11:12:02 +000044 CALL, // Function call.
45 CALLnr, // Function call that does not return.
Colin LeMahieu2e3a26d2015-01-16 17:05:27 +000046 CALLR,
47
Tony Linthicum1213a7a2011-12-12 21:14:40 +000048 RET_FLAG, // Return with a flag operand.
Krzysztof Parzyszek42113342015-03-19 16:33:08 +000049 BARRIER, // Memory barrier.
50 JT, // Jump table.
51 CP, // Constant pool.
Krzysztof Parzyszek952d9512015-04-22 21:17:00 +000052
Colin LeMahieu383c36e2014-12-05 18:24:06 +000053 COMBINE,
Krzysztof Parzyszekf85dd9f2017-07-10 20:16:44 +000054 VSPLAT,
55 VASL,
56 VASR,
57 VLSR,
Krzysztof Parzyszek952d9512015-04-22 21:17:00 +000058
59 INSERT,
Krzysztof Parzyszek952d9512015-04-22 21:17:00 +000060 EXTRACTU,
Krzysztof Parzyszekc168c012015-12-03 16:47:20 +000061 VCOMBINE,
Krzysztof Parzyszek302a9d42017-07-14 19:02:32 +000062 VPACKE,
63 VPACKO,
Krzysztof Parzyszek7d37dd82017-12-06 16:40:37 +000064 VEXTRACTW,
65 VINSERTW0,
66 VROR,
Jyotsna Verma5ed51812013-05-01 21:37:34 +000067 TC_RETURN,
Colin LeMahieu68b2e052015-01-06 19:03:20 +000068 EH_RETURN,
Krzysztof Parzyszek952d9512015-04-22 21:17:00 +000069 DCFETCH,
Krzysztof Parzyszekab57c2b2017-02-22 22:28:47 +000070 READCYCLE,
Krzysztof Parzyszeke4ce92c2017-12-20 20:49:43 +000071 VZERO,
Krzysztof Parzyszek952d9512015-04-22 21:17:00 +000072
73 OP_END
Tony Linthicum1213a7a2011-12-12 21:14:40 +000074 };
Eugene Zelenko58655bb2016-12-17 01:09:05 +000075
76} // end namespace HexagonISD
Tony Linthicum1213a7a2011-12-12 21:14:40 +000077
Eric Christopherd737b762015-02-02 22:11:36 +000078 class HexagonSubtarget;
79
Tony Linthicum1213a7a2011-12-12 21:14:40 +000080 class HexagonTargetLowering : public TargetLowering {
81 int VarArgsFrameOffset; // Frame offset to start of varargs area.
Eugene Zelenko58655bb2016-12-17 01:09:05 +000082 const HexagonTargetMachine &HTM;
83 const HexagonSubtarget &Subtarget;
Tony Linthicum1213a7a2011-12-12 21:14:40 +000084
Krzysztof Parzyszek952d9512015-04-22 21:17:00 +000085 bool CanReturnSmallStruct(const Function* CalleeFn, unsigned& RetSize)
86 const;
Craig Topper18e69f42016-04-15 06:20:21 +000087 void promoteLdStType(MVT VT, MVT PromotedLdStVT);
Krzysztof Parzyszek42113342015-03-19 16:33:08 +000088
Tony Linthicum1213a7a2011-12-12 21:14:40 +000089 public:
Eric Christopherd737b762015-02-02 22:11:36 +000090 explicit HexagonTargetLowering(const TargetMachine &TM,
Krzysztof Parzyszek952d9512015-04-22 21:17:00 +000091 const HexagonSubtarget &ST);
Tony Linthicum1213a7a2011-12-12 21:14:40 +000092
Krzysztof Parzyszek7d37dd82017-12-06 16:40:37 +000093 bool isHVXVectorType(MVT Ty) const;
94
Tony Linthicum1213a7a2011-12-12 21:14:40 +000095 /// IsEligibleForTailCallOptimization - Check whether the call is eligible
96 /// for tail call optimization. Targets which want to do tail call
97 /// optimization should implement this function.
Krzysztof Parzyszek952d9512015-04-22 21:17:00 +000098 bool IsEligibleForTailCallOptimization(SDValue Callee,
99 CallingConv::ID CalleeCC, bool isVarArg, bool isCalleeStructRet,
100 bool isCallerStructRet, const SmallVectorImpl<ISD::OutputArg> &Outs,
101 const SmallVectorImpl<SDValue> &OutVals,
102 const SmallVectorImpl<ISD::InputArg> &Ins, SelectionDAG& DAG) const;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000103
Krzysztof Parzyszeka8ab1b72017-12-11 18:57:54 +0000104 bool getTgtMemIntrinsic(IntrinsicInfo &Info, const CallInst &I,
Matt Arsenault7d7adf42017-12-14 22:34:10 +0000105 MachineFunction &MF,
Krzysztof Parzyszeka8ab1b72017-12-11 18:57:54 +0000106 unsigned Intrinsic) const override;
107
Craig Topper906c2cd2014-04-29 07:58:16 +0000108 bool isTruncateFree(Type *Ty1, Type *Ty2) const override;
109 bool isTruncateFree(EVT VT1, EVT VT2) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000110
Craig Topper906c2cd2014-04-29 07:58:16 +0000111 bool allowTruncateForTailCall(Type *Ty1, Type *Ty2) const override;
Tim Northovera4415852013-08-06 09:12:35 +0000112
Krzysztof Parzyszekbd8ef4b2016-08-19 13:34:31 +0000113 /// Return true if an FMA operation is faster than a pair of mul and add
114 /// instructions. fmuladd intrinsics will be expanded to FMAs when this
115 /// method returns true (and FMAs are legal), otherwise fmuladd is
116 /// expanded to mul + add.
117 bool isFMAFasterThanFMulAndFAdd(EVT) const override;
118
Krzysztof Parzyszek42113342015-03-19 16:33:08 +0000119 // Should we expand the build vector with shuffles?
120 bool shouldExpandBuildVectorWithShuffles(EVT VT,
Krzysztof Parzyszek952d9512015-04-22 21:17:00 +0000121 unsigned DefinedValues) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000122
Zvi Rackover1b736822017-07-26 08:06:58 +0000123 bool isShuffleMaskLegal(ArrayRef<int> Mask, EVT VT) const override;
Krzysztof Parzyszek5439a702017-12-18 18:21:01 +0000124 TargetLoweringBase::LegalizeTypeAction getPreferredVectorAction(EVT VT)
125 const override;
Krzysztof Parzyszekd19d0502016-09-13 21:16:07 +0000126
Krzysztof Parzyszek42113342015-03-19 16:33:08 +0000127 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
Craig Topper906c2cd2014-04-29 07:58:16 +0000128 const char *getTargetNodeName(unsigned Opcode) const override;
Krzysztof Parzyszek6a8e5f42017-11-29 19:58:10 +0000129
130 SDValue LowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek42113342015-03-19 16:33:08 +0000131 SDValue LowerCONCAT_VECTORS(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek6a8e5f42017-11-29 19:58:10 +0000132 SDValue LowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
133 SDValue LowerEXTRACT_SUBVECTOR(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek6a8e5f42017-11-29 19:58:10 +0000134 SDValue LowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek7d37dd82017-12-06 16:40:37 +0000135 SDValue LowerINSERT_SUBVECTOR(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek0bd55a72016-07-29 16:44:27 +0000136 SDValue LowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG) const;
137 SDValue LowerVECTOR_SHIFT(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek6a8e5f42017-11-29 19:58:10 +0000138
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000139 SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const;
140 SDValue LowerINLINEASM(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek6895b2c2016-02-18 13:58:38 +0000141 SDValue LowerPREFETCH(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszekab57c2b2017-02-22 22:28:47 +0000142 SDValue LowerREADCYCLECOUNTER(SDValue Op, SelectionDAG &DAG) const;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000143 SDValue LowerEH_LABEL(SDValue Op, SelectionDAG &DAG) const;
Jyotsna Verma5ed51812013-05-01 21:37:34 +0000144 SDValue LowerEH_RETURN(SDValue Op, SelectionDAG &DAG) const;
Benjamin Kramerbdc49562016-06-12 15:39:02 +0000145 SDValue
146 LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
147 const SmallVectorImpl<ISD::InputArg> &Ins,
148 const SDLoc &dl, SelectionDAG &DAG,
149 SmallVectorImpl<SDValue> &InVals) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000150 SDValue LowerGLOBALADDRESS(SDValue Op, SelectionDAG &DAG) const;
Jyotsna Verma2ba0c0b2013-03-07 19:10:28 +0000151 SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek7a737d12016-02-18 15:42:57 +0000152 SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
153 SDValue LowerToTLSGeneralDynamicModel(GlobalAddressSDNode *GA,
154 SelectionDAG &DAG) const;
155 SDValue LowerToTLSInitialExecModel(GlobalAddressSDNode *GA,
156 SelectionDAG &DAG) const;
157 SDValue LowerToTLSLocalExecModel(GlobalAddressSDNode *GA,
158 SelectionDAG &DAG) const;
159 SDValue GetDynamicTLSAddr(SelectionDAG &DAG, SDValue Chain,
Krzysztof Parzyszek1aaf41a2017-02-17 22:14:51 +0000160 GlobalAddressSDNode *GA, SDValue InFlag, EVT PtrVT,
Krzysztof Parzyszek7a737d12016-02-18 15:42:57 +0000161 unsigned ReturnReg, unsigned char OperandFlags) const;
Krzysztof Parzyszek21dc8bd2015-12-18 20:19:30 +0000162 SDValue LowerGLOBAL_OFFSET_TABLE(SDValue Op, SelectionDAG &DAG) const;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000163
Justin Holewinskiaa583972012-05-25 16:35:28 +0000164 SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI,
Krzysztof Parzyszek952d9512015-04-22 21:17:00 +0000165 SmallVectorImpl<SDValue> &InVals) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000166 SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
Benjamin Kramerbdc49562016-06-12 15:39:02 +0000167 CallingConv::ID CallConv, bool isVarArg,
168 const SmallVectorImpl<ISD::InputArg> &Ins,
169 const SDLoc &dl, SelectionDAG &DAG,
170 SmallVectorImpl<SDValue> &InVals,
171 const SmallVectorImpl<SDValue> &OutVals,
172 SDValue Callee) const;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000173
Krzysztof Parzyszek42113342015-03-19 16:33:08 +0000174 SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG) const;
175 SDValue LowerVSELECT(SDValue Op, SelectionDAG &DAG) const;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000176 SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000177 SDValue LowerATOMIC_FENCE(SDValue Op, SelectionDAG& DAG) const;
178 SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
179
Krzysztof Parzyszek56199522017-04-13 15:05:51 +0000180 bool CanLowerReturn(CallingConv::ID CallConv,
181 MachineFunction &MF, bool isVarArg,
182 const SmallVectorImpl<ISD::OutputArg> &Outs,
183 LLVMContext &Context) const override;
184
Benjamin Kramerbdc49562016-06-12 15:39:02 +0000185 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
186 const SmallVectorImpl<ISD::OutputArg> &Outs,
187 const SmallVectorImpl<SDValue> &OutVals,
188 const SDLoc &dl, SelectionDAG &DAG) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000189
Matt Arsenault31380752017-04-18 21:16:46 +0000190 bool mayBeEmittedAsTailCall(const CallInst *CI) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000191
Joseph Tremouletf748c892015-11-07 01:11:31 +0000192 /// If a physical register, this returns the register that receives the
193 /// exception address on entry to an EH pad.
194 unsigned
195 getExceptionPointerRegister(const Constant *PersonalityFn) const override {
196 return Hexagon::R0;
197 }
198
199 /// If a physical register, this returns the register that receives the
200 /// exception typeid on entry to a landing pad.
201 unsigned
202 getExceptionSelectorRegister(const Constant *PersonalityFn) const override {
203 return Hexagon::R1;
204 }
205
Krzysztof Parzyszek952d9512015-04-22 21:17:00 +0000206 SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const;
207 SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek21dc8bd2015-12-18 20:19:30 +0000208 SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
Eugene Zelenko58655bb2016-12-17 01:09:05 +0000209
Mehdi Amini44ede332015-07-09 02:09:04 +0000210 EVT getSetCCResultType(const DataLayout &, LLVMContext &C,
211 EVT VT) const override {
Juergen Ributzka34c652d2013-11-13 01:57:54 +0000212 if (!VT.isVector())
213 return MVT::i1;
214 else
215 return EVT::getVectorVT(C, MVT::i1, VT.getVectorNumElements());
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000216 }
217
Craig Topper906c2cd2014-04-29 07:58:16 +0000218 bool getPostIndexedAddressParts(SDNode *N, SDNode *Op,
219 SDValue &Base, SDValue &Offset,
220 ISD::MemIndexedMode &AM,
221 SelectionDAG &DAG) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000222
Krzysztof Parzyszekca3b5322016-05-18 14:34:51 +0000223 ConstraintType getConstraintType(StringRef Constraint) const override;
224
Eric Christopher11e4df72015-02-26 22:38:43 +0000225 std::pair<unsigned, const TargetRegisterClass *>
226 getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
Benjamin Kramer9bfb6272015-07-05 19:29:18 +0000227 StringRef Constraint, MVT VT) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000228
Benjamin Kramer9bfb6272015-07-05 19:29:18 +0000229 unsigned
230 getInlineAsmMemConstraint(StringRef ConstraintCode) const override {
Daniel Sanders49f643c2015-03-17 14:37:39 +0000231 if (ConstraintCode == "o")
232 return InlineAsm::Constraint_o;
Daniel Sanders49f643c2015-03-17 14:37:39 +0000233 return TargetLowering::getInlineAsmMemConstraint(ConstraintCode);
Daniel Sandersbf5b80f2015-03-16 13:13:41 +0000234 }
235
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000236 // Intrinsics
Craig Topper906c2cd2014-04-29 07:58:16 +0000237 SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek6895b2c2016-02-18 13:58:38 +0000238 SDValue LowerINTRINSIC_VOID(SDValue Op, SelectionDAG &DAG) const;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000239 /// isLegalAddressingMode - Return true if the addressing mode represented
240 /// by AM is legal for this target, for a load/store of the specified type.
241 /// The type may be VoidTy, in which case only return true if the addressing
242 /// mode is legal for a load/store of any legal type.
243 /// TODO: Handle pre/postinc as well.
Mehdi Amini0cdec1e2015-07-09 02:09:40 +0000244 bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM,
Jonas Paulsson024e3192017-07-21 11:59:37 +0000245 Type *Ty, unsigned AS,
246 Instruction *I = nullptr) const override;
Krzysztof Parzyszek21dc8bd2015-12-18 20:19:30 +0000247 /// Return true if folding a constant offset with the given GlobalAddress
248 /// is legal. It is frequently not legal in PIC relocation models.
249 bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
250
Craig Topper906c2cd2014-04-29 07:58:16 +0000251 bool isFPImmLegal(const APFloat &Imm, EVT VT) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000252
253 /// isLegalICmpImmediate - Return true if the specified immediate is legal
254 /// icmp immediate, that is the target has icmp instructions which can
255 /// compare a register against the immediate without having to materialize
256 /// the immediate into a register.
Craig Topper906c2cd2014-04-29 07:58:16 +0000257 bool isLegalICmpImmediate(int64_t Imm) const override;
Krzysztof Parzyszekfeaf7b82015-07-09 14:51:21 +0000258
Krzysztof Parzyszek3e409e12016-08-02 18:34:31 +0000259 EVT getOptimalMemOpType(uint64_t Size, unsigned DstAlign,
260 unsigned SrcAlign, bool IsMemset, bool ZeroMemset, bool MemcpyStrSrc,
261 MachineFunction &MF) const override;
262
Krzysztof Parzyszek2d65ea72016-03-28 15:43:03 +0000263 bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AddrSpace,
264 unsigned Align, bool *Fast) const override;
265
Krzysztof Parzyszek21dc8bd2015-12-18 20:19:30 +0000266 /// Returns relocation base for the given PIC jumptable.
267 SDValue getPICJumpTableRelocBase(SDValue Table, SelectionDAG &DAG)
268 const override;
269
Krzysztof Parzyszekfeaf7b82015-07-09 14:51:21 +0000270 // Handling of atomic RMW instructions.
Krzysztof Parzyszekfeaf7b82015-07-09 14:51:21 +0000271 Value *emitLoadLinked(IRBuilder<> &Builder, Value *Addr,
272 AtomicOrdering Ord) const override;
273 Value *emitStoreConditional(IRBuilder<> &Builder, Value *Val,
274 Value *Addr, AtomicOrdering Ord) const override;
Ahmed Bougacha52468672015-09-11 17:08:28 +0000275 AtomicExpansionKind shouldExpandAtomicLoadInIR(LoadInst *LI) const override;
Krzysztof Parzyszekfeaf7b82015-07-09 14:51:21 +0000276 bool shouldExpandAtomicStoreInIR(StoreInst *SI) const override;
Krzysztof Parzyszekf228c952016-06-22 16:07:10 +0000277 bool shouldExpandAtomicCmpXchgInIR(AtomicCmpXchgInst *AI) const override;
278
Ahmed Bougacha9d677132015-09-11 17:08:17 +0000279 AtomicExpansionKind
280 shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const override {
281 return AtomicExpansionKind::LLSC;
Krzysztof Parzyszekfeaf7b82015-07-09 14:51:21 +0000282 }
Krzysztof Parzyszek08ff8882015-11-26 18:38:27 +0000283
Krzysztof Parzyszek6a8e5f42017-11-29 19:58:10 +0000284 private:
Krzysztof Parzyszeke4ce92c2017-12-20 20:49:43 +0000285 bool getBuildVectorConstInts(ArrayRef<SDValue> Values, MVT VecTy,
286 SelectionDAG &DAG,
287 MutableArrayRef<ConstantInt*> Consts) const;
Krzysztof Parzyszek039d4d92017-12-07 17:37:28 +0000288 SDValue buildVector32(ArrayRef<SDValue> Elem, const SDLoc &dl, MVT VecTy,
289 SelectionDAG &DAG) const;
290 SDValue buildVector64(ArrayRef<SDValue> Elem, const SDLoc &dl, MVT VecTy,
291 SelectionDAG &DAG) const;
292 SDValue extractVector(SDValue VecV, SDValue IdxV, const SDLoc &dl,
293 MVT ValTy, MVT ResTy, SelectionDAG &DAG) const;
294 SDValue insertVector(SDValue VecV, SDValue ValV, SDValue IdxV,
295 const SDLoc &dl, MVT ValTy, SelectionDAG &DAG) const;
296 bool isUndef(SDValue Op) const {
297 if (Op.isMachineOpcode())
298 return Op.getMachineOpcode() == TargetOpcode::IMPLICIT_DEF;
299 return Op.getOpcode() == ISD::UNDEF;
300 }
301 SDValue getNode(unsigned MachineOpc, const SDLoc &dl, MVT Ty,
302 ArrayRef<SDValue> Ops, SelectionDAG &DAG) const {
303 SDNode *N = DAG.getMachineNode(MachineOpc, dl, Ty, Ops);
304 return SDValue(N, 0);
305 }
Krzysztof Parzyszeke4ce92c2017-12-20 20:49:43 +0000306 SDValue getZero(const SDLoc &dl, MVT Ty, SelectionDAG &DAG) const;
Krzysztof Parzyszek039d4d92017-12-07 17:37:28 +0000307
308 using VectorPair = std::pair<SDValue, SDValue>;
309 using TypePair = std::pair<MVT, MVT>;
310
311 SDValue getInt(unsigned IntId, MVT ResTy, ArrayRef<SDValue> Ops,
312 const SDLoc &dl, SelectionDAG &DAG) const;
313
Krzysztof Parzyszek6a8e5f42017-11-29 19:58:10 +0000314 MVT ty(SDValue Op) const {
315 return Op.getValueType().getSimpleVT();
316 }
Krzysztof Parzyszek039d4d92017-12-07 17:37:28 +0000317 TypePair ty(const VectorPair &Ops) const {
318 return { Ops.first.getValueType().getSimpleVT(),
319 Ops.second.getValueType().getSimpleVT() };
320 }
Krzysztof Parzyszek6a8e5f42017-11-29 19:58:10 +0000321 MVT tyScalar(MVT Ty) const {
322 if (!Ty.isVector())
323 return Ty;
324 return MVT::getIntegerVT(Ty.getSizeInBits());
325 }
Krzysztof Parzyszek7d37dd82017-12-06 16:40:37 +0000326 MVT tyVector(MVT Ty, MVT ElemTy) const {
327 if (Ty.isVector() && Ty.getVectorElementType() == ElemTy)
328 return Ty;
329 unsigned TyWidth = Ty.getSizeInBits(), ElemWidth = ElemTy.getSizeInBits();
330 assert((TyWidth % ElemWidth) == 0);
331 return MVT::getVectorVT(ElemTy, TyWidth/ElemWidth);
332 }
Krzysztof Parzyszek6a8e5f42017-11-29 19:58:10 +0000333
Krzysztof Parzyszek7d37dd82017-12-06 16:40:37 +0000334 MVT typeJoin(const TypePair &Tys) const;
335 TypePair typeSplit(MVT Ty) const;
Krzysztof Parzyszek7d37dd82017-12-06 16:40:37 +0000336 MVT typeExtElem(MVT VecTy, unsigned Factor) const;
337 MVT typeTruncElem(MVT VecTy, unsigned Factor) const;
338
339 SDValue opJoin(const VectorPair &Ops, const SDLoc &dl,
340 SelectionDAG &DAG) const;
341 VectorPair opSplit(SDValue Vec, const SDLoc &dl, SelectionDAG &DAG) const;
342 SDValue opCastElem(SDValue Vec, MVT ElemTy, SelectionDAG &DAG) const;
343
344 SDValue convertToByteIndex(SDValue ElemIdx, MVT ElemTy,
345 SelectionDAG &DAG) const;
346 SDValue getIndexInWord32(SDValue Idx, MVT ElemTy, SelectionDAG &DAG) const;
Krzysztof Parzyszek039d4d92017-12-07 17:37:28 +0000347 SDValue getByteShuffle(const SDLoc &dl, SDValue Op0, SDValue Op1,
348 ArrayRef<int> Mask, SelectionDAG &DAG) const;
Krzysztof Parzyszek7d37dd82017-12-06 16:40:37 +0000349
Krzysztof Parzyszeke4ce92c2017-12-20 20:49:43 +0000350 MVT getVecBoolVT() const;
351
352 SDValue buildHvxVectorSingle(ArrayRef<SDValue> Values, const SDLoc &dl,
353 MVT VecTy, SelectionDAG &DAG) const;
354 SDValue buildHvxVectorPred(ArrayRef<SDValue> Values, const SDLoc &dl,
355 MVT VecTy, SelectionDAG &DAG) const;
356
Krzysztof Parzyszek7d37dd82017-12-06 16:40:37 +0000357 SDValue LowerHvxBuildVector(SDValue Op, SelectionDAG &DAG) const;
358 SDValue LowerHvxExtractElement(SDValue Op, SelectionDAG &DAG) const;
359 SDValue LowerHvxInsertElement(SDValue Op, SelectionDAG &DAG) const;
360 SDValue LowerHvxExtractSubvector(SDValue Op, SelectionDAG &DAG) const;
361 SDValue LowerHvxInsertSubvector(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek039d4d92017-12-07 17:37:28 +0000362 SDValue LowerHvxMul(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek47076052017-12-14 21:28:48 +0000363 SDValue LowerHvxSetCC(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek6b589e52017-12-18 18:32:27 +0000364 SDValue LowerHvxExtend(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek7d37dd82017-12-06 16:40:37 +0000365
Krzysztof Parzyszek08ff8882015-11-26 18:38:27 +0000366 std::pair<const TargetRegisterClass*, uint8_t>
367 findRepresentativeClass(const TargetRegisterInfo *TRI, MVT VT)
368 const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000369 };
Eugene Zelenko58655bb2016-12-17 01:09:05 +0000370
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000371} // end namespace llvm
372
Eugene Zelenko58655bb2016-12-17 01:09:05 +0000373#endif // LLVM_LIB_TARGET_HEXAGON_HEXAGONISELLOWERING_H