blob: fca48d4cca6c792aa18d0c08fd089678f167c600 [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,
60 INSERTRP,
61 EXTRACTU,
62 EXTRACTURP,
Krzysztof Parzyszekc168c012015-12-03 16:47:20 +000063 VCOMBINE,
Krzysztof Parzyszek302a9d42017-07-14 19:02:32 +000064 VPACKE,
65 VPACKO,
Krzysztof Parzyszek7d37dd82017-12-06 16:40:37 +000066 VEXTRACTW,
67 VINSERTW0,
68 VROR,
Jyotsna Verma5ed51812013-05-01 21:37:34 +000069 TC_RETURN,
Colin LeMahieu68b2e052015-01-06 19:03:20 +000070 EH_RETURN,
Krzysztof Parzyszek952d9512015-04-22 21:17:00 +000071 DCFETCH,
Krzysztof Parzyszekab57c2b2017-02-22 22:28:47 +000072 READCYCLE,
Krzysztof Parzyszek952d9512015-04-22 21:17:00 +000073
74 OP_END
Tony Linthicum1213a7a2011-12-12 21:14:40 +000075 };
Eugene Zelenko58655bb2016-12-17 01:09:05 +000076
77} // end namespace HexagonISD
Tony Linthicum1213a7a2011-12-12 21:14:40 +000078
Eric Christopherd737b762015-02-02 22:11:36 +000079 class HexagonSubtarget;
80
Tony Linthicum1213a7a2011-12-12 21:14:40 +000081 class HexagonTargetLowering : public TargetLowering {
82 int VarArgsFrameOffset; // Frame offset to start of varargs area.
Eugene Zelenko58655bb2016-12-17 01:09:05 +000083 const HexagonTargetMachine &HTM;
84 const HexagonSubtarget &Subtarget;
Tony Linthicum1213a7a2011-12-12 21:14:40 +000085
Krzysztof Parzyszek952d9512015-04-22 21:17:00 +000086 bool CanReturnSmallStruct(const Function* CalleeFn, unsigned& RetSize)
87 const;
Craig Topper18e69f42016-04-15 06:20:21 +000088 void promoteLdStType(MVT VT, MVT PromotedLdStVT);
Krzysztof Parzyszek42113342015-03-19 16:33:08 +000089
Tony Linthicum1213a7a2011-12-12 21:14:40 +000090 public:
Eric Christopherd737b762015-02-02 22:11:36 +000091 explicit HexagonTargetLowering(const TargetMachine &TM,
Krzysztof Parzyszek952d9512015-04-22 21:17:00 +000092 const HexagonSubtarget &ST);
Tony Linthicum1213a7a2011-12-12 21:14:40 +000093
Krzysztof Parzyszek7d37dd82017-12-06 16:40:37 +000094 bool isHVXVectorType(MVT Ty) const;
95
Tony Linthicum1213a7a2011-12-12 21:14:40 +000096 /// IsEligibleForTailCallOptimization - Check whether the call is eligible
97 /// for tail call optimization. Targets which want to do tail call
98 /// optimization should implement this function.
Krzysztof Parzyszek952d9512015-04-22 21:17:00 +000099 bool IsEligibleForTailCallOptimization(SDValue Callee,
100 CallingConv::ID CalleeCC, bool isVarArg, bool isCalleeStructRet,
101 bool isCallerStructRet, const SmallVectorImpl<ISD::OutputArg> &Outs,
102 const SmallVectorImpl<SDValue> &OutVals,
103 const SmallVectorImpl<ISD::InputArg> &Ins, SelectionDAG& DAG) const;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000104
Krzysztof Parzyszeka8ab1b72017-12-11 18:57:54 +0000105 bool getTgtMemIntrinsic(IntrinsicInfo &Info, const CallInst &I,
106 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 Parzyszekd19d0502016-09-13 21:16:07 +0000124
Krzysztof Parzyszek42113342015-03-19 16:33:08 +0000125 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
Craig Topper906c2cd2014-04-29 07:58:16 +0000126 const char *getTargetNodeName(unsigned Opcode) const override;
Krzysztof Parzyszek6a8e5f42017-11-29 19:58:10 +0000127
128 SDValue LowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek42113342015-03-19 16:33:08 +0000129 SDValue LowerCONCAT_VECTORS(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek6a8e5f42017-11-29 19:58:10 +0000130 SDValue LowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
131 SDValue LowerEXTRACT_SUBVECTOR(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek6a8e5f42017-11-29 19:58:10 +0000132 SDValue LowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek7d37dd82017-12-06 16:40:37 +0000133 SDValue LowerINSERT_SUBVECTOR(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek0bd55a72016-07-29 16:44:27 +0000134 SDValue LowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG) const;
135 SDValue LowerVECTOR_SHIFT(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek6a8e5f42017-11-29 19:58:10 +0000136
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000137 SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const;
138 SDValue LowerINLINEASM(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek6895b2c2016-02-18 13:58:38 +0000139 SDValue LowerPREFETCH(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszekab57c2b2017-02-22 22:28:47 +0000140 SDValue LowerREADCYCLECOUNTER(SDValue Op, SelectionDAG &DAG) const;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000141 SDValue LowerEH_LABEL(SDValue Op, SelectionDAG &DAG) const;
Jyotsna Verma5ed51812013-05-01 21:37:34 +0000142 SDValue LowerEH_RETURN(SDValue Op, SelectionDAG &DAG) const;
Benjamin Kramerbdc49562016-06-12 15:39:02 +0000143 SDValue
144 LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
145 const SmallVectorImpl<ISD::InputArg> &Ins,
146 const SDLoc &dl, SelectionDAG &DAG,
147 SmallVectorImpl<SDValue> &InVals) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000148 SDValue LowerGLOBALADDRESS(SDValue Op, SelectionDAG &DAG) const;
Jyotsna Verma2ba0c0b2013-03-07 19:10:28 +0000149 SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek7a737d12016-02-18 15:42:57 +0000150 SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
151 SDValue LowerToTLSGeneralDynamicModel(GlobalAddressSDNode *GA,
152 SelectionDAG &DAG) const;
153 SDValue LowerToTLSInitialExecModel(GlobalAddressSDNode *GA,
154 SelectionDAG &DAG) const;
155 SDValue LowerToTLSLocalExecModel(GlobalAddressSDNode *GA,
156 SelectionDAG &DAG) const;
157 SDValue GetDynamicTLSAddr(SelectionDAG &DAG, SDValue Chain,
Krzysztof Parzyszek1aaf41a2017-02-17 22:14:51 +0000158 GlobalAddressSDNode *GA, SDValue InFlag, EVT PtrVT,
Krzysztof Parzyszek7a737d12016-02-18 15:42:57 +0000159 unsigned ReturnReg, unsigned char OperandFlags) const;
Krzysztof Parzyszek21dc8bd2015-12-18 20:19:30 +0000160 SDValue LowerGLOBAL_OFFSET_TABLE(SDValue Op, SelectionDAG &DAG) const;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000161
Justin Holewinskiaa583972012-05-25 16:35:28 +0000162 SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI,
Krzysztof Parzyszek952d9512015-04-22 21:17:00 +0000163 SmallVectorImpl<SDValue> &InVals) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000164 SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
Benjamin Kramerbdc49562016-06-12 15:39:02 +0000165 CallingConv::ID CallConv, bool isVarArg,
166 const SmallVectorImpl<ISD::InputArg> &Ins,
167 const SDLoc &dl, SelectionDAG &DAG,
168 SmallVectorImpl<SDValue> &InVals,
169 const SmallVectorImpl<SDValue> &OutVals,
170 SDValue Callee) const;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000171
Krzysztof Parzyszek42113342015-03-19 16:33:08 +0000172 SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG) const;
173 SDValue LowerVSELECT(SDValue Op, SelectionDAG &DAG) const;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000174 SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000175 SDValue LowerATOMIC_FENCE(SDValue Op, SelectionDAG& DAG) const;
176 SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
177
Krzysztof Parzyszek56199522017-04-13 15:05:51 +0000178 bool CanLowerReturn(CallingConv::ID CallConv,
179 MachineFunction &MF, bool isVarArg,
180 const SmallVectorImpl<ISD::OutputArg> &Outs,
181 LLVMContext &Context) const override;
182
Benjamin Kramerbdc49562016-06-12 15:39:02 +0000183 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
184 const SmallVectorImpl<ISD::OutputArg> &Outs,
185 const SmallVectorImpl<SDValue> &OutVals,
186 const SDLoc &dl, SelectionDAG &DAG) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000187
Matt Arsenault31380752017-04-18 21:16:46 +0000188 bool mayBeEmittedAsTailCall(const CallInst *CI) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000189
Joseph Tremouletf748c892015-11-07 01:11:31 +0000190 /// If a physical register, this returns the register that receives the
191 /// exception address on entry to an EH pad.
192 unsigned
193 getExceptionPointerRegister(const Constant *PersonalityFn) const override {
194 return Hexagon::R0;
195 }
196
197 /// If a physical register, this returns the register that receives the
198 /// exception typeid on entry to a landing pad.
199 unsigned
200 getExceptionSelectorRegister(const Constant *PersonalityFn) const override {
201 return Hexagon::R1;
202 }
203
Krzysztof Parzyszek952d9512015-04-22 21:17:00 +0000204 SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const;
205 SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek21dc8bd2015-12-18 20:19:30 +0000206 SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
Eugene Zelenko58655bb2016-12-17 01:09:05 +0000207
Mehdi Amini44ede332015-07-09 02:09:04 +0000208 EVT getSetCCResultType(const DataLayout &, LLVMContext &C,
209 EVT VT) const override {
Juergen Ributzka34c652d2013-11-13 01:57:54 +0000210 if (!VT.isVector())
211 return MVT::i1;
212 else
213 return EVT::getVectorVT(C, MVT::i1, VT.getVectorNumElements());
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000214 }
215
Craig Topper906c2cd2014-04-29 07:58:16 +0000216 bool getPostIndexedAddressParts(SDNode *N, SDNode *Op,
217 SDValue &Base, SDValue &Offset,
218 ISD::MemIndexedMode &AM,
219 SelectionDAG &DAG) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000220
Krzysztof Parzyszekca3b5322016-05-18 14:34:51 +0000221 ConstraintType getConstraintType(StringRef Constraint) const override;
222
Eric Christopher11e4df72015-02-26 22:38:43 +0000223 std::pair<unsigned, const TargetRegisterClass *>
224 getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
Benjamin Kramer9bfb6272015-07-05 19:29:18 +0000225 StringRef Constraint, MVT VT) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000226
Benjamin Kramer9bfb6272015-07-05 19:29:18 +0000227 unsigned
228 getInlineAsmMemConstraint(StringRef ConstraintCode) const override {
Daniel Sanders49f643c2015-03-17 14:37:39 +0000229 if (ConstraintCode == "o")
230 return InlineAsm::Constraint_o;
Daniel Sanders49f643c2015-03-17 14:37:39 +0000231 return TargetLowering::getInlineAsmMemConstraint(ConstraintCode);
Daniel Sandersbf5b80f2015-03-16 13:13:41 +0000232 }
233
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000234 // Intrinsics
Craig Topper906c2cd2014-04-29 07:58:16 +0000235 SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek6895b2c2016-02-18 13:58:38 +0000236 SDValue LowerINTRINSIC_VOID(SDValue Op, SelectionDAG &DAG) const;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000237 /// isLegalAddressingMode - Return true if the addressing mode represented
238 /// by AM is legal for this target, for a load/store of the specified type.
239 /// The type may be VoidTy, in which case only return true if the addressing
240 /// mode is legal for a load/store of any legal type.
241 /// TODO: Handle pre/postinc as well.
Mehdi Amini0cdec1e2015-07-09 02:09:40 +0000242 bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM,
Jonas Paulsson024e3192017-07-21 11:59:37 +0000243 Type *Ty, unsigned AS,
244 Instruction *I = nullptr) const override;
Krzysztof Parzyszek21dc8bd2015-12-18 20:19:30 +0000245 /// Return true if folding a constant offset with the given GlobalAddress
246 /// is legal. It is frequently not legal in PIC relocation models.
247 bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
248
Craig Topper906c2cd2014-04-29 07:58:16 +0000249 bool isFPImmLegal(const APFloat &Imm, EVT VT) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000250
251 /// isLegalICmpImmediate - Return true if the specified immediate is legal
252 /// icmp immediate, that is the target has icmp instructions which can
253 /// compare a register against the immediate without having to materialize
254 /// the immediate into a register.
Craig Topper906c2cd2014-04-29 07:58:16 +0000255 bool isLegalICmpImmediate(int64_t Imm) const override;
Krzysztof Parzyszekfeaf7b82015-07-09 14:51:21 +0000256
Krzysztof Parzyszek3e409e12016-08-02 18:34:31 +0000257 EVT getOptimalMemOpType(uint64_t Size, unsigned DstAlign,
258 unsigned SrcAlign, bool IsMemset, bool ZeroMemset, bool MemcpyStrSrc,
259 MachineFunction &MF) const override;
260
Krzysztof Parzyszek2d65ea72016-03-28 15:43:03 +0000261 bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AddrSpace,
262 unsigned Align, bool *Fast) const override;
263
Krzysztof Parzyszek21dc8bd2015-12-18 20:19:30 +0000264 /// Returns relocation base for the given PIC jumptable.
265 SDValue getPICJumpTableRelocBase(SDValue Table, SelectionDAG &DAG)
266 const override;
267
Krzysztof Parzyszekfeaf7b82015-07-09 14:51:21 +0000268 // Handling of atomic RMW instructions.
Krzysztof Parzyszekfeaf7b82015-07-09 14:51:21 +0000269 Value *emitLoadLinked(IRBuilder<> &Builder, Value *Addr,
270 AtomicOrdering Ord) const override;
271 Value *emitStoreConditional(IRBuilder<> &Builder, Value *Val,
272 Value *Addr, AtomicOrdering Ord) const override;
Ahmed Bougacha52468672015-09-11 17:08:28 +0000273 AtomicExpansionKind shouldExpandAtomicLoadInIR(LoadInst *LI) const override;
Krzysztof Parzyszekfeaf7b82015-07-09 14:51:21 +0000274 bool shouldExpandAtomicStoreInIR(StoreInst *SI) const override;
Krzysztof Parzyszekf228c952016-06-22 16:07:10 +0000275 bool shouldExpandAtomicCmpXchgInIR(AtomicCmpXchgInst *AI) const override;
276
Ahmed Bougacha9d677132015-09-11 17:08:17 +0000277 AtomicExpansionKind
278 shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const override {
279 return AtomicExpansionKind::LLSC;
Krzysztof Parzyszekfeaf7b82015-07-09 14:51:21 +0000280 }
Krzysztof Parzyszek08ff8882015-11-26 18:38:27 +0000281
Krzysztof Parzyszek6a8e5f42017-11-29 19:58:10 +0000282 private:
Krzysztof Parzyszek039d4d92017-12-07 17:37:28 +0000283 SDValue buildVector32(ArrayRef<SDValue> Elem, const SDLoc &dl, MVT VecTy,
284 SelectionDAG &DAG) const;
285 SDValue buildVector64(ArrayRef<SDValue> Elem, const SDLoc &dl, MVT VecTy,
286 SelectionDAG &DAG) const;
287 SDValue extractVector(SDValue VecV, SDValue IdxV, const SDLoc &dl,
288 MVT ValTy, MVT ResTy, SelectionDAG &DAG) const;
289 SDValue insertVector(SDValue VecV, SDValue ValV, SDValue IdxV,
290 const SDLoc &dl, MVT ValTy, SelectionDAG &DAG) const;
291 bool isUndef(SDValue Op) const {
292 if (Op.isMachineOpcode())
293 return Op.getMachineOpcode() == TargetOpcode::IMPLICIT_DEF;
294 return Op.getOpcode() == ISD::UNDEF;
295 }
296 SDValue getNode(unsigned MachineOpc, const SDLoc &dl, MVT Ty,
297 ArrayRef<SDValue> Ops, SelectionDAG &DAG) const {
298 SDNode *N = DAG.getMachineNode(MachineOpc, dl, Ty, Ops);
299 return SDValue(N, 0);
300 }
301
302 using VectorPair = std::pair<SDValue, SDValue>;
303 using TypePair = std::pair<MVT, MVT>;
304
305 SDValue getInt(unsigned IntId, MVT ResTy, ArrayRef<SDValue> Ops,
306 const SDLoc &dl, SelectionDAG &DAG) const;
307
Krzysztof Parzyszek6a8e5f42017-11-29 19:58:10 +0000308 MVT ty(SDValue Op) const {
309 return Op.getValueType().getSimpleVT();
310 }
Krzysztof Parzyszek039d4d92017-12-07 17:37:28 +0000311 TypePair ty(const VectorPair &Ops) const {
312 return { Ops.first.getValueType().getSimpleVT(),
313 Ops.second.getValueType().getSimpleVT() };
314 }
Krzysztof Parzyszek6a8e5f42017-11-29 19:58:10 +0000315 MVT tyScalar(MVT Ty) const {
316 if (!Ty.isVector())
317 return Ty;
318 return MVT::getIntegerVT(Ty.getSizeInBits());
319 }
Krzysztof Parzyszek7d37dd82017-12-06 16:40:37 +0000320 MVT tyVector(MVT Ty, MVT ElemTy) const {
321 if (Ty.isVector() && Ty.getVectorElementType() == ElemTy)
322 return Ty;
323 unsigned TyWidth = Ty.getSizeInBits(), ElemWidth = ElemTy.getSizeInBits();
324 assert((TyWidth % ElemWidth) == 0);
325 return MVT::getVectorVT(ElemTy, TyWidth/ElemWidth);
326 }
Krzysztof Parzyszek6a8e5f42017-11-29 19:58:10 +0000327
Krzysztof Parzyszek7d37dd82017-12-06 16:40:37 +0000328 MVT typeJoin(const TypePair &Tys) const;
329 TypePair typeSplit(MVT Ty) const;
Krzysztof Parzyszek7d37dd82017-12-06 16:40:37 +0000330 MVT typeExtElem(MVT VecTy, unsigned Factor) const;
331 MVT typeTruncElem(MVT VecTy, unsigned Factor) const;
332
333 SDValue opJoin(const VectorPair &Ops, const SDLoc &dl,
334 SelectionDAG &DAG) const;
335 VectorPair opSplit(SDValue Vec, const SDLoc &dl, SelectionDAG &DAG) const;
336 SDValue opCastElem(SDValue Vec, MVT ElemTy, SelectionDAG &DAG) const;
337
338 SDValue convertToByteIndex(SDValue ElemIdx, MVT ElemTy,
339 SelectionDAG &DAG) const;
340 SDValue getIndexInWord32(SDValue Idx, MVT ElemTy, SelectionDAG &DAG) const;
Krzysztof Parzyszek039d4d92017-12-07 17:37:28 +0000341 SDValue getByteShuffle(const SDLoc &dl, SDValue Op0, SDValue Op1,
342 ArrayRef<int> Mask, SelectionDAG &DAG) const;
Krzysztof Parzyszek7d37dd82017-12-06 16:40:37 +0000343
344 SDValue LowerHvxBuildVector(SDValue Op, SelectionDAG &DAG) const;
345 SDValue LowerHvxExtractElement(SDValue Op, SelectionDAG &DAG) const;
346 SDValue LowerHvxInsertElement(SDValue Op, SelectionDAG &DAG) const;
347 SDValue LowerHvxExtractSubvector(SDValue Op, SelectionDAG &DAG) const;
348 SDValue LowerHvxInsertSubvector(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek039d4d92017-12-07 17:37:28 +0000349 SDValue LowerHvxMul(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek7d37dd82017-12-06 16:40:37 +0000350
Krzysztof Parzyszek08ff8882015-11-26 18:38:27 +0000351 std::pair<const TargetRegisterClass*, uint8_t>
352 findRepresentativeClass(const TargetRegisterInfo *TRI, MVT VT)
353 const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000354 };
Eugene Zelenko58655bb2016-12-17 01:09:05 +0000355
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000356} // end namespace llvm
357
Eugene Zelenko58655bb2016-12-17 01:09:05 +0000358#endif // LLVM_LIB_TARGET_HEXAGON_HEXAGONISELLOWERING_H