blob: 41fdd53714a67050394a66680b9ef1900fbd19ef [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
Craig Topper906c2cd2014-04-29 07:58:16 +0000105 bool isTruncateFree(Type *Ty1, Type *Ty2) const override;
106 bool isTruncateFree(EVT VT1, EVT VT2) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000107
Craig Topper906c2cd2014-04-29 07:58:16 +0000108 bool allowTruncateForTailCall(Type *Ty1, Type *Ty2) const override;
Tim Northovera4415852013-08-06 09:12:35 +0000109
Krzysztof Parzyszekbd8ef4b2016-08-19 13:34:31 +0000110 /// Return true if an FMA operation is faster than a pair of mul and add
111 /// instructions. fmuladd intrinsics will be expanded to FMAs when this
112 /// method returns true (and FMAs are legal), otherwise fmuladd is
113 /// expanded to mul + add.
114 bool isFMAFasterThanFMulAndFAdd(EVT) const override;
115
Krzysztof Parzyszek42113342015-03-19 16:33:08 +0000116 // Should we expand the build vector with shuffles?
117 bool shouldExpandBuildVectorWithShuffles(EVT VT,
Krzysztof Parzyszek952d9512015-04-22 21:17:00 +0000118 unsigned DefinedValues) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000119
Zvi Rackover1b736822017-07-26 08:06:58 +0000120 bool isShuffleMaskLegal(ArrayRef<int> Mask, EVT VT) const override;
Krzysztof Parzyszekd19d0502016-09-13 21:16:07 +0000121
Krzysztof Parzyszek42113342015-03-19 16:33:08 +0000122 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
Craig Topper906c2cd2014-04-29 07:58:16 +0000123 const char *getTargetNodeName(unsigned Opcode) const override;
Krzysztof Parzyszek6a8e5f42017-11-29 19:58:10 +0000124
125 SDValue LowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek42113342015-03-19 16:33:08 +0000126 SDValue LowerCONCAT_VECTORS(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek6a8e5f42017-11-29 19:58:10 +0000127 SDValue LowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
128 SDValue LowerEXTRACT_SUBVECTOR(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek6a8e5f42017-11-29 19:58:10 +0000129 SDValue LowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek7d37dd82017-12-06 16:40:37 +0000130 SDValue LowerINSERT_SUBVECTOR(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek0bd55a72016-07-29 16:44:27 +0000131 SDValue LowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG) const;
132 SDValue LowerVECTOR_SHIFT(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek6a8e5f42017-11-29 19:58:10 +0000133
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000134 SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const;
135 SDValue LowerINLINEASM(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek6895b2c2016-02-18 13:58:38 +0000136 SDValue LowerPREFETCH(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszekab57c2b2017-02-22 22:28:47 +0000137 SDValue LowerREADCYCLECOUNTER(SDValue Op, SelectionDAG &DAG) const;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000138 SDValue LowerEH_LABEL(SDValue Op, SelectionDAG &DAG) const;
Jyotsna Verma5ed51812013-05-01 21:37:34 +0000139 SDValue LowerEH_RETURN(SDValue Op, SelectionDAG &DAG) const;
Benjamin Kramerbdc49562016-06-12 15:39:02 +0000140 SDValue
141 LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
142 const SmallVectorImpl<ISD::InputArg> &Ins,
143 const SDLoc &dl, SelectionDAG &DAG,
144 SmallVectorImpl<SDValue> &InVals) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000145 SDValue LowerGLOBALADDRESS(SDValue Op, SelectionDAG &DAG) const;
Jyotsna Verma2ba0c0b2013-03-07 19:10:28 +0000146 SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek7a737d12016-02-18 15:42:57 +0000147 SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
148 SDValue LowerToTLSGeneralDynamicModel(GlobalAddressSDNode *GA,
149 SelectionDAG &DAG) const;
150 SDValue LowerToTLSInitialExecModel(GlobalAddressSDNode *GA,
151 SelectionDAG &DAG) const;
152 SDValue LowerToTLSLocalExecModel(GlobalAddressSDNode *GA,
153 SelectionDAG &DAG) const;
154 SDValue GetDynamicTLSAddr(SelectionDAG &DAG, SDValue Chain,
Krzysztof Parzyszek1aaf41a2017-02-17 22:14:51 +0000155 GlobalAddressSDNode *GA, SDValue InFlag, EVT PtrVT,
Krzysztof Parzyszek7a737d12016-02-18 15:42:57 +0000156 unsigned ReturnReg, unsigned char OperandFlags) const;
Krzysztof Parzyszek21dc8bd2015-12-18 20:19:30 +0000157 SDValue LowerGLOBAL_OFFSET_TABLE(SDValue Op, SelectionDAG &DAG) const;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000158
Justin Holewinskiaa583972012-05-25 16:35:28 +0000159 SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI,
Krzysztof Parzyszek952d9512015-04-22 21:17:00 +0000160 SmallVectorImpl<SDValue> &InVals) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000161 SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
Benjamin Kramerbdc49562016-06-12 15:39:02 +0000162 CallingConv::ID CallConv, bool isVarArg,
163 const SmallVectorImpl<ISD::InputArg> &Ins,
164 const SDLoc &dl, SelectionDAG &DAG,
165 SmallVectorImpl<SDValue> &InVals,
166 const SmallVectorImpl<SDValue> &OutVals,
167 SDValue Callee) const;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000168
Krzysztof Parzyszek42113342015-03-19 16:33:08 +0000169 SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG) const;
170 SDValue LowerVSELECT(SDValue Op, SelectionDAG &DAG) const;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000171 SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000172 SDValue LowerATOMIC_FENCE(SDValue Op, SelectionDAG& DAG) const;
173 SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
174
Krzysztof Parzyszek56199522017-04-13 15:05:51 +0000175 bool CanLowerReturn(CallingConv::ID CallConv,
176 MachineFunction &MF, bool isVarArg,
177 const SmallVectorImpl<ISD::OutputArg> &Outs,
178 LLVMContext &Context) const override;
179
Benjamin Kramerbdc49562016-06-12 15:39:02 +0000180 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
181 const SmallVectorImpl<ISD::OutputArg> &Outs,
182 const SmallVectorImpl<SDValue> &OutVals,
183 const SDLoc &dl, SelectionDAG &DAG) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000184
Matt Arsenault31380752017-04-18 21:16:46 +0000185 bool mayBeEmittedAsTailCall(const CallInst *CI) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000186
Joseph Tremouletf748c892015-11-07 01:11:31 +0000187 /// If a physical register, this returns the register that receives the
188 /// exception address on entry to an EH pad.
189 unsigned
190 getExceptionPointerRegister(const Constant *PersonalityFn) const override {
191 return Hexagon::R0;
192 }
193
194 /// If a physical register, this returns the register that receives the
195 /// exception typeid on entry to a landing pad.
196 unsigned
197 getExceptionSelectorRegister(const Constant *PersonalityFn) const override {
198 return Hexagon::R1;
199 }
200
Krzysztof Parzyszek952d9512015-04-22 21:17:00 +0000201 SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const;
202 SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek21dc8bd2015-12-18 20:19:30 +0000203 SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
Eugene Zelenko58655bb2016-12-17 01:09:05 +0000204
Mehdi Amini44ede332015-07-09 02:09:04 +0000205 EVT getSetCCResultType(const DataLayout &, LLVMContext &C,
206 EVT VT) const override {
Juergen Ributzka34c652d2013-11-13 01:57:54 +0000207 if (!VT.isVector())
208 return MVT::i1;
209 else
210 return EVT::getVectorVT(C, MVT::i1, VT.getVectorNumElements());
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000211 }
212
Craig Topper906c2cd2014-04-29 07:58:16 +0000213 bool getPostIndexedAddressParts(SDNode *N, SDNode *Op,
214 SDValue &Base, SDValue &Offset,
215 ISD::MemIndexedMode &AM,
216 SelectionDAG &DAG) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000217
Krzysztof Parzyszekca3b5322016-05-18 14:34:51 +0000218 ConstraintType getConstraintType(StringRef Constraint) const override;
219
Eric Christopher11e4df72015-02-26 22:38:43 +0000220 std::pair<unsigned, const TargetRegisterClass *>
221 getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
Benjamin Kramer9bfb6272015-07-05 19:29:18 +0000222 StringRef Constraint, MVT VT) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000223
Benjamin Kramer9bfb6272015-07-05 19:29:18 +0000224 unsigned
225 getInlineAsmMemConstraint(StringRef ConstraintCode) const override {
Daniel Sanders49f643c2015-03-17 14:37:39 +0000226 if (ConstraintCode == "o")
227 return InlineAsm::Constraint_o;
Daniel Sanders49f643c2015-03-17 14:37:39 +0000228 return TargetLowering::getInlineAsmMemConstraint(ConstraintCode);
Daniel Sandersbf5b80f2015-03-16 13:13:41 +0000229 }
230
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000231 // Intrinsics
Craig Topper906c2cd2014-04-29 07:58:16 +0000232 SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek6895b2c2016-02-18 13:58:38 +0000233 SDValue LowerINTRINSIC_VOID(SDValue Op, SelectionDAG &DAG) const;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000234 /// isLegalAddressingMode - Return true if the addressing mode represented
235 /// by AM is legal for this target, for a load/store of the specified type.
236 /// The type may be VoidTy, in which case only return true if the addressing
237 /// mode is legal for a load/store of any legal type.
238 /// TODO: Handle pre/postinc as well.
Mehdi Amini0cdec1e2015-07-09 02:09:40 +0000239 bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM,
Jonas Paulsson024e3192017-07-21 11:59:37 +0000240 Type *Ty, unsigned AS,
241 Instruction *I = nullptr) const override;
Krzysztof Parzyszek21dc8bd2015-12-18 20:19:30 +0000242 /// Return true if folding a constant offset with the given GlobalAddress
243 /// is legal. It is frequently not legal in PIC relocation models.
244 bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
245
Craig Topper906c2cd2014-04-29 07:58:16 +0000246 bool isFPImmLegal(const APFloat &Imm, EVT VT) const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000247
248 /// isLegalICmpImmediate - Return true if the specified immediate is legal
249 /// icmp immediate, that is the target has icmp instructions which can
250 /// compare a register against the immediate without having to materialize
251 /// the immediate into a register.
Craig Topper906c2cd2014-04-29 07:58:16 +0000252 bool isLegalICmpImmediate(int64_t Imm) const override;
Krzysztof Parzyszekfeaf7b82015-07-09 14:51:21 +0000253
Krzysztof Parzyszek3e409e12016-08-02 18:34:31 +0000254 EVT getOptimalMemOpType(uint64_t Size, unsigned DstAlign,
255 unsigned SrcAlign, bool IsMemset, bool ZeroMemset, bool MemcpyStrSrc,
256 MachineFunction &MF) const override;
257
Krzysztof Parzyszek2d65ea72016-03-28 15:43:03 +0000258 bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AddrSpace,
259 unsigned Align, bool *Fast) const override;
260
Krzysztof Parzyszek21dc8bd2015-12-18 20:19:30 +0000261 /// Returns relocation base for the given PIC jumptable.
262 SDValue getPICJumpTableRelocBase(SDValue Table, SelectionDAG &DAG)
263 const override;
264
Krzysztof Parzyszekfeaf7b82015-07-09 14:51:21 +0000265 // Handling of atomic RMW instructions.
Krzysztof Parzyszekfeaf7b82015-07-09 14:51:21 +0000266 Value *emitLoadLinked(IRBuilder<> &Builder, Value *Addr,
267 AtomicOrdering Ord) const override;
268 Value *emitStoreConditional(IRBuilder<> &Builder, Value *Val,
269 Value *Addr, AtomicOrdering Ord) const override;
Ahmed Bougacha52468672015-09-11 17:08:28 +0000270 AtomicExpansionKind shouldExpandAtomicLoadInIR(LoadInst *LI) const override;
Krzysztof Parzyszekfeaf7b82015-07-09 14:51:21 +0000271 bool shouldExpandAtomicStoreInIR(StoreInst *SI) const override;
Krzysztof Parzyszekf228c952016-06-22 16:07:10 +0000272 bool shouldExpandAtomicCmpXchgInIR(AtomicCmpXchgInst *AI) const override;
273
Ahmed Bougacha9d677132015-09-11 17:08:17 +0000274 AtomicExpansionKind
275 shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const override {
276 return AtomicExpansionKind::LLSC;
Krzysztof Parzyszekfeaf7b82015-07-09 14:51:21 +0000277 }
Krzysztof Parzyszek08ff8882015-11-26 18:38:27 +0000278
Krzysztof Parzyszek6a8e5f42017-11-29 19:58:10 +0000279 private:
Krzysztof Parzyszek039d4d92017-12-07 17:37:28 +0000280 SDValue buildVector32(ArrayRef<SDValue> Elem, const SDLoc &dl, MVT VecTy,
281 SelectionDAG &DAG) const;
282 SDValue buildVector64(ArrayRef<SDValue> Elem, const SDLoc &dl, MVT VecTy,
283 SelectionDAG &DAG) const;
284 SDValue extractVector(SDValue VecV, SDValue IdxV, const SDLoc &dl,
285 MVT ValTy, MVT ResTy, SelectionDAG &DAG) const;
286 SDValue insertVector(SDValue VecV, SDValue ValV, SDValue IdxV,
287 const SDLoc &dl, MVT ValTy, SelectionDAG &DAG) const;
288 bool isUndef(SDValue Op) const {
289 if (Op.isMachineOpcode())
290 return Op.getMachineOpcode() == TargetOpcode::IMPLICIT_DEF;
291 return Op.getOpcode() == ISD::UNDEF;
292 }
293 SDValue getNode(unsigned MachineOpc, const SDLoc &dl, MVT Ty,
294 ArrayRef<SDValue> Ops, SelectionDAG &DAG) const {
295 SDNode *N = DAG.getMachineNode(MachineOpc, dl, Ty, Ops);
296 return SDValue(N, 0);
297 }
298
299 using VectorPair = std::pair<SDValue, SDValue>;
300 using TypePair = std::pair<MVT, MVT>;
301
302 SDValue getInt(unsigned IntId, MVT ResTy, ArrayRef<SDValue> Ops,
303 const SDLoc &dl, SelectionDAG &DAG) const;
304
Krzysztof Parzyszek6a8e5f42017-11-29 19:58:10 +0000305 MVT ty(SDValue Op) const {
306 return Op.getValueType().getSimpleVT();
307 }
Krzysztof Parzyszek039d4d92017-12-07 17:37:28 +0000308 TypePair ty(const VectorPair &Ops) const {
309 return { Ops.first.getValueType().getSimpleVT(),
310 Ops.second.getValueType().getSimpleVT() };
311 }
Krzysztof Parzyszek6a8e5f42017-11-29 19:58:10 +0000312 MVT tyScalar(MVT Ty) const {
313 if (!Ty.isVector())
314 return Ty;
315 return MVT::getIntegerVT(Ty.getSizeInBits());
316 }
Krzysztof Parzyszek7d37dd82017-12-06 16:40:37 +0000317 MVT tyVector(MVT Ty, MVT ElemTy) const {
318 if (Ty.isVector() && Ty.getVectorElementType() == ElemTy)
319 return Ty;
320 unsigned TyWidth = Ty.getSizeInBits(), ElemWidth = ElemTy.getSizeInBits();
321 assert((TyWidth % ElemWidth) == 0);
322 return MVT::getVectorVT(ElemTy, TyWidth/ElemWidth);
323 }
Krzysztof Parzyszek6a8e5f42017-11-29 19:58:10 +0000324
Krzysztof Parzyszek7d37dd82017-12-06 16:40:37 +0000325 MVT typeJoin(const TypePair &Tys) const;
326 TypePair typeSplit(MVT Ty) const;
Krzysztof Parzyszek7d37dd82017-12-06 16:40:37 +0000327 MVT typeExtElem(MVT VecTy, unsigned Factor) const;
328 MVT typeTruncElem(MVT VecTy, unsigned Factor) const;
329
330 SDValue opJoin(const VectorPair &Ops, const SDLoc &dl,
331 SelectionDAG &DAG) const;
332 VectorPair opSplit(SDValue Vec, const SDLoc &dl, SelectionDAG &DAG) const;
333 SDValue opCastElem(SDValue Vec, MVT ElemTy, SelectionDAG &DAG) const;
334
335 SDValue convertToByteIndex(SDValue ElemIdx, MVT ElemTy,
336 SelectionDAG &DAG) const;
337 SDValue getIndexInWord32(SDValue Idx, MVT ElemTy, SelectionDAG &DAG) const;
Krzysztof Parzyszek039d4d92017-12-07 17:37:28 +0000338 SDValue getByteShuffle(const SDLoc &dl, SDValue Op0, SDValue Op1,
339 ArrayRef<int> Mask, SelectionDAG &DAG) const;
Krzysztof Parzyszek7d37dd82017-12-06 16:40:37 +0000340
341 SDValue LowerHvxBuildVector(SDValue Op, SelectionDAG &DAG) const;
342 SDValue LowerHvxExtractElement(SDValue Op, SelectionDAG &DAG) const;
343 SDValue LowerHvxInsertElement(SDValue Op, SelectionDAG &DAG) const;
344 SDValue LowerHvxExtractSubvector(SDValue Op, SelectionDAG &DAG) const;
345 SDValue LowerHvxInsertSubvector(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek039d4d92017-12-07 17:37:28 +0000346 SDValue LowerHvxMul(SDValue Op, SelectionDAG &DAG) const;
Krzysztof Parzyszek7d37dd82017-12-06 16:40:37 +0000347
Krzysztof Parzyszek08ff8882015-11-26 18:38:27 +0000348 std::pair<const TargetRegisterClass*, uint8_t>
349 findRepresentativeClass(const TargetRegisterInfo *TRI, MVT VT)
350 const override;
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000351 };
Eugene Zelenko58655bb2016-12-17 01:09:05 +0000352
Tony Linthicum1213a7a2011-12-12 21:14:40 +0000353} // end namespace llvm
354
Eugene Zelenko58655bb2016-12-17 01:09:05 +0000355#endif // LLVM_LIB_TARGET_HEXAGON_HEXAGONISELLOWERING_H