blob: c2a6dfbbd4958e7c3c1c99fd8e9b45c83c6411b6 [file] [log] [blame]
Eugene Zelenko076468c2017-09-20 21:35:51 +00001//===- ARMISelLowering.h - ARM DAG Lowering Interface -----------*- C++ -*-===//
Evan Cheng10043e22007-01-19 07:51:42 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Evan Cheng10043e22007-01-19 07:51:42 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file defines the interfaces that ARM 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_ARM_ARMISELLOWERING_H
16#define LLVM_LIB_TARGET_ARM_ARMISELLOWERING_H
Evan Cheng10043e22007-01-19 07:51:42 +000017
Craig Toppera9253262014-03-22 23:51:00 +000018#include "MCTargetDesc/ARMBaseInfo.h"
Eugene Zelenkoc4ad1ce2017-01-11 01:45:03 +000019#include "llvm/ADT/SmallVector.h"
20#include "llvm/ADT/StringRef.h"
Chandler Carruth802d7552012-12-04 07:12:27 +000021#include "llvm/CodeGen/CallingConvLower.h"
Eugene Zelenko076468c2017-09-20 21:35:51 +000022#include "llvm/CodeGen/ISDOpcodes.h"
Eugene Zelenkoc4ad1ce2017-01-11 01:45:03 +000023#include "llvm/CodeGen/MachineFunction.h"
Eugene Zelenkoc4ad1ce2017-01-11 01:45:03 +000024#include "llvm/CodeGen/SelectionDAGNodes.h"
David Blaikieb3bde2e2017-11-17 01:07:10 +000025#include "llvm/CodeGen/TargetLowering.h"
Craig Topper2fa14362018-03-29 17:21:10 +000026#include "llvm/CodeGen/ValueTypes.h"
Eugene Zelenko076468c2017-09-20 21:35:51 +000027#include "llvm/IR/Attributes.h"
Eugene Zelenkoc4ad1ce2017-01-11 01:45:03 +000028#include "llvm/IR/CallingConv.h"
Eugene Zelenko076468c2017-09-20 21:35:51 +000029#include "llvm/IR/Function.h"
Eugene Zelenkoc4ad1ce2017-01-11 01:45:03 +000030#include "llvm/IR/IRBuilder.h"
31#include "llvm/IR/InlineAsm.h"
32#include "llvm/Support/CodeGen.h"
David Blaikie13e77db2018-03-23 23:58:25 +000033#include "llvm/Support/MachineValueType.h"
Eugene Zelenkoc4ad1ce2017-01-11 01:45:03 +000034#include <utility>
Evan Cheng10043e22007-01-19 07:51:42 +000035
36namespace llvm {
Eugene Zelenkoc4ad1ce2017-01-11 01:45:03 +000037
38class ARMSubtarget;
Eugene Zelenko076468c2017-09-20 21:35:51 +000039class DataLayout;
40class FastISel;
41class FunctionLoweringInfo;
42class GlobalValue;
Eugene Zelenkoc4ad1ce2017-01-11 01:45:03 +000043class InstrItineraryData;
Eugene Zelenko076468c2017-09-20 21:35:51 +000044class Instruction;
45class MachineBasicBlock;
46class MachineInstr;
47class SelectionDAG;
48class TargetLibraryInfo;
49class TargetMachine;
50class TargetRegisterInfo;
51class VectorType;
Evan Cheng10043e22007-01-19 07:51:42 +000052
53 namespace ARMISD {
Eugene Zelenkoc4ad1ce2017-01-11 01:45:03 +000054
Evan Cheng10043e22007-01-19 07:51:42 +000055 // ARM Specific DAG Nodes
Matthias Braund04893f2015-05-07 21:33:59 +000056 enum NodeType : unsigned {
Jim Grosbach91fa7812009-05-13 22:32:43 +000057 // Start the numbering where the builtin ops and target ops leave off.
Dan Gohmaned1cf1a2008-09-23 18:42:32 +000058 FIRST_NUMBER = ISD::BUILTIN_OP_END,
Evan Cheng10043e22007-01-19 07:51:42 +000059
60 Wrapper, // Wrapper - A wrapper node for TargetConstantPool,
61 // TargetExternalSymbol, and TargetGlobalAddress.
Evan Chengdfce83c2011-01-17 08:03:18 +000062 WrapperPIC, // WrapperPIC - A wrapper node for TargetGlobalAddress in
63 // PIC mode.
Evan Cheng10043e22007-01-19 07:51:42 +000064 WrapperJT, // WrapperJT - A wrapper node for TargetJumpTable
Jim Grosbach91fa7812009-05-13 22:32:43 +000065
Manman Ren9f911162012-06-01 02:44:42 +000066 // Add pseudo op to model memcpy for struct byval.
67 COPY_STRUCT_BYVAL,
68
Evan Cheng10043e22007-01-19 07:51:42 +000069 CALL, // Function call.
Evan Chengc3c949b42007-06-19 21:05:09 +000070 CALL_PRED, // Function call that's predicable.
Evan Cheng10043e22007-01-19 07:51:42 +000071 CALL_NOLINK, // Function call with branch not branch-and-link.
Evan Cheng10043e22007-01-19 07:51:42 +000072 BRCOND, // Conditional branch.
73 BR_JT, // Jumptable branch.
Evan Chengc6d70ae2009-07-29 02:18:14 +000074 BR2_JT, // Jumptable branch (2 level - jumptable entry is a jump).
Evan Cheng10043e22007-01-19 07:51:42 +000075 RET_FLAG, // Return with a flag operand.
Tim Northoverd8407452013-10-01 14:33:28 +000076 INTRET_FLAG, // Interrupt return with an LR-offset and a flag operand.
Evan Cheng10043e22007-01-19 07:51:42 +000077
78 PIC_ADD, // Add with a PC operand and a PIC label.
79
80 CMP, // ARM compare instructions.
Bill Wendling4b796472012-06-11 08:07:26 +000081 CMN, // ARM CMN instructions.
David Goodwindbf11ba2009-06-29 15:33:01 +000082 CMPZ, // ARM compare that sets only Z flag.
Evan Cheng10043e22007-01-19 07:51:42 +000083 CMPFP, // ARM VFP compare instruction, sets FPSCR.
84 CMPFPw0, // ARM VFP compare against zero instruction, sets FPSCR.
85 FMSTAT, // ARM fmstat instruction.
Evan Chenge87681c2012-02-23 01:19:06 +000086
Evan Cheng10043e22007-01-19 07:51:42 +000087 CMOV, // ARM conditional move instructions.
Jim Grosbach91fa7812009-05-13 22:32:43 +000088
Pablo Barrio7a643462016-06-23 16:53:49 +000089 SSAT, // Signed saturation
Florian Hahnc3aa6d82017-12-20 11:13:57 +000090 USAT, // Unsigned saturation
Pablo Barrio7a643462016-06-23 16:53:49 +000091
Evan Cheng0cc4ad92010-07-13 19:27:42 +000092 BCC_i64,
93
Evan Cheng10043e22007-01-19 07:51:42 +000094 SRL_FLAG, // V,Flag = srl_flag X -> srl X, 1 + save carry out.
95 SRA_FLAG, // V,Flag = sra_flag X -> sra X, 1 + save carry out.
96 RRX, // V = RRX X, Flag -> srl X, 1 + shift in carry flag.
Jim Grosbach91fa7812009-05-13 22:32:43 +000097
Evan Chenge8916542011-08-30 01:34:54 +000098 ADDC, // Add with carry
99 ADDE, // Add using carry
100 SUBC, // Sub with carry
101 SUBE, // Sub using carry
102
Jim Grosbachd7cf55c2009-11-09 00:11:35 +0000103 VMOVRRD, // double to two gprs.
104 VMOVDRR, // Two gprs to double.
Christof Douma4a025cc2018-03-23 13:02:03 +0000105 VMOVSR, // move gpr to single, used for f32 literal constructed in a gpr
Lauro Ramos Venancioc39c12a2007-04-27 13:54:47 +0000106
Jim Grosbachbbdc5d22010-10-19 23:27:08 +0000107 EH_SJLJ_SETJMP, // SjLj exception handling setjmp.
108 EH_SJLJ_LONGJMP, // SjLj exception handling longjmp.
Matthias Braun3cd00c12015-07-16 22:34:16 +0000109 EH_SJLJ_SETUP_DISPATCH, // SjLj exception handling setup_dispatch.
Jim Grosbachaeca45d2009-05-12 23:59:14 +0000110
Dale Johannesend679ff72010-06-03 21:09:53 +0000111 TC_RETURN, // Tail call return pseudo.
112
Bob Wilson2e076c42009-06-22 23:27:02 +0000113 THREAD_POINTER,
114
Evan Chengb972e562009-08-07 00:34:42 +0000115 DYN_ALLOC, // Dynamic allocation on the stack.
116
Bob Wilson7ed59712010-10-30 00:54:37 +0000117 MEMBARRIER_MCR, // Memory barrier (MCR)
Evan Cheng8740ee32010-11-03 06:34:55 +0000118
119 PRELOAD, // Preload
Andrew Trick1a1f8d42011-04-23 03:24:11 +0000120
Saleem Abdulrasoolabac6e92014-06-09 20:18:42 +0000121 WIN__CHKSTK, // Windows' __chkstk call to do stack probing.
Saleem Abdulrasoolfe83b502015-09-25 05:15:46 +0000122 WIN__DBZCHK, // Windows' divide by zero check
Saleem Abdulrasoolabac6e92014-06-09 20:18:42 +0000123
Bob Wilson2e076c42009-06-22 23:27:02 +0000124 VCEQ, // Vector compare equal.
Owen Andersonc7baee32010-11-08 23:21:22 +0000125 VCEQZ, // Vector compare equal to zero.
Bob Wilson2e076c42009-06-22 23:27:02 +0000126 VCGE, // Vector compare greater than or equal.
Owen Andersonc7baee32010-11-08 23:21:22 +0000127 VCGEZ, // Vector compare greater than or equal to zero.
128 VCLEZ, // Vector compare less than or equal to zero.
Bob Wilson2e076c42009-06-22 23:27:02 +0000129 VCGEU, // Vector compare unsigned greater than or equal.
130 VCGT, // Vector compare greater than.
Owen Andersonc7baee32010-11-08 23:21:22 +0000131 VCGTZ, // Vector compare greater than zero.
132 VCLTZ, // Vector compare less than zero.
Bob Wilson2e076c42009-06-22 23:27:02 +0000133 VCGTU, // Vector compare unsigned greater than.
134 VTST, // Vector test bits.
135
136 // Vector shift by immediate:
137 VSHL, // ...left
138 VSHRs, // ...right (signed)
139 VSHRu, // ...right (unsigned)
Bob Wilson2e076c42009-06-22 23:27:02 +0000140
141 // Vector rounding shift by immediate:
142 VRSHRs, // ...right (signed)
143 VRSHRu, // ...right (unsigned)
144 VRSHRN, // ...right narrow
145
146 // Vector saturating shift by immediate:
147 VQSHLs, // ...left (signed)
148 VQSHLu, // ...left (unsigned)
149 VQSHLsu, // ...left (signed to unsigned)
150 VQSHRNs, // ...right narrow (signed)
151 VQSHRNu, // ...right narrow (unsigned)
152 VQSHRNsu, // ...right narrow (signed to unsigned)
153
154 // Vector saturating rounding shift by immediate:
155 VQRSHRNs, // ...right narrow (signed)
156 VQRSHRNu, // ...right narrow (unsigned)
157 VQRSHRNsu, // ...right narrow (signed to unsigned)
158
159 // Vector shift and insert:
160 VSLI, // ...left
161 VSRI, // ...right
162
163 // Vector get lane (VMOV scalar to ARM core register)
164 // (These are used for 8- and 16-bit element types only.)
165 VGETLANEu, // zero-extend vector extract element
166 VGETLANEs, // sign-extend vector extract element
167
Bob Wilsonbad47f62010-07-14 06:31:50 +0000168 // Vector move immediate and move negated immediate:
Bob Wilsona3f19012010-07-13 21:16:48 +0000169 VMOVIMM,
Bob Wilsonbad47f62010-07-14 06:31:50 +0000170 VMVNIMM,
171
Evan Cheng7ca4b6e2011-11-15 02:12:34 +0000172 // Vector move f32 immediate:
173 VMOVFPIMM,
174
Sjoerd Meijer98d53592018-01-31 10:18:29 +0000175 // Move H <-> R, clearing top 16 bits
176 VMOVrh,
177 VMOVhr,
178
Bob Wilsonbad47f62010-07-14 06:31:50 +0000179 // Vector duplicate:
Bob Wilsoneb54d512009-08-14 05:13:08 +0000180 VDUP,
Bob Wilsoncce31f62009-08-14 05:08:32 +0000181 VDUPLANE,
Bob Wilsonf45dee32009-08-04 00:36:16 +0000182
Bob Wilsonea3a4022009-08-12 22:31:50 +0000183 // Vector shuffles:
Bob Wilson32cd8552009-08-19 17:03:43 +0000184 VEXT, // extract
Bob Wilsonea3a4022009-08-12 22:31:50 +0000185 VREV64, // reverse elements within 64-bit doublewords
186 VREV32, // reverse elements within 32-bit words
Anton Korobeynikov9a232f42009-08-21 12:41:24 +0000187 VREV16, // reverse elements within 16-bit halfwords
Bob Wilsona7062312009-08-21 20:54:19 +0000188 VZIP, // zip (interleave)
189 VUZP, // unzip (deinterleave)
Bob Wilsonc6c13a32010-02-18 06:05:53 +0000190 VTRN, // transpose
Bill Wendlinge1fd78f2011-03-14 23:02:38 +0000191 VTBL1, // 1-register shuffle with mask
192 VTBL2, // 2-register shuffle with mask
Bob Wilsonc6c13a32010-02-18 06:05:53 +0000193
Bob Wilson38ab35a2010-09-01 23:50:19 +0000194 // Vector multiply long:
195 VMULLs, // ...signed
196 VMULLu, // ...unsigned
197
Sam Parker916b1ba2017-03-14 09:13:22 +0000198 SMULWB, // Signed multiply word by half word, bottom
199 SMULWT, // Signed multiply word by half word, top
Arnold Schwaighoferf00fb1c2012-09-04 14:37:49 +0000200 UMLAL, // 64bit Unsigned Accumulate Multiply
201 SMLAL, // 64bit Signed Accumulate Multiply
Sam Parkerd616cf02016-06-20 16:47:09 +0000202 UMAAL, // 64-bit Unsigned Accumulate Accumulate Multiply
Sam Parker654cb822017-03-15 08:27:11 +0000203 SMLALBB, // 64-bit signed accumulate multiply bottom, bottom 16
204 SMLALBT, // 64-bit signed accumulate multiply bottom, top 16
205 SMLALTB, // 64-bit signed accumulate multiply top, bottom 16
206 SMLALTT, // 64-bit signed accumulate multiply top, top 16
Sam Parkerdf337702017-05-04 07:31:28 +0000207 SMLALD, // Signed multiply accumulate long dual
208 SMLALDX, // Signed multiply accumulate long dual exchange
209 SMLSLD, // Signed multiply subtract long dual
210 SMLSLDX, // Signed multiply subtract long dual exchange
Andre Vieira5627c212018-01-12 09:24:41 +0000211 SMMLAR, // Signed multiply long, round and add
212 SMMLSR, // Signed multiply long, subtract and round
Arnold Schwaighoferf00fb1c2012-09-04 14:37:49 +0000213
Bob Wilsond8a9a042010-06-04 00:04:02 +0000214 // Operands of the standard BUILD_VECTOR node are not legalized, which
215 // is fine if BUILD_VECTORs are always lowered to shuffles or other
216 // operations, but for ARM some BUILD_VECTORs are legal as-is and their
217 // operands need to be legalized. Define an ARM-specific version of
218 // BUILD_VECTOR for this purpose.
219 BUILD_VECTOR,
220
Jim Grosbach11013ed2010-07-16 23:05:05 +0000221 // Bit-field insert
Owen Anderson07473072010-11-03 22:44:51 +0000222 BFI,
Andrew Trick1a1f8d42011-04-23 03:24:11 +0000223
Owen Anderson07473072010-11-03 22:44:51 +0000224 // Vector OR with immediate
Owen Anderson30c48922010-11-05 19:27:46 +0000225 VORRIMM,
226 // Vector AND with NOT of immediate
Bob Wilson2d790df2010-11-28 06:51:26 +0000227 VBICIMM,
228
Cameron Zwarich53dd03d2011-03-30 23:01:21 +0000229 // Vector bitwise select
230 VBSL,
231
Scott Douglass953f9082015-10-05 14:49:54 +0000232 // Pseudo-instruction representing a memory copy using ldm/stm
233 // instructions.
234 MEMCPY,
235
Bob Wilson2d790df2010-11-28 06:51:26 +0000236 // Vector load N-element structure to all lanes:
Eli Friedmanf624ec22016-12-16 18:44:08 +0000237 VLD1DUP = ISD::FIRST_TARGET_MEMORY_OPCODE,
238 VLD2DUP,
Bob Wilson2d790df2010-11-28 06:51:26 +0000239 VLD3DUP,
Bob Wilson06fce872011-02-07 17:43:21 +0000240 VLD4DUP,
241
242 // NEON loads with post-increment base updates:
243 VLD1_UPD,
244 VLD2_UPD,
245 VLD3_UPD,
246 VLD4_UPD,
247 VLD2LN_UPD,
248 VLD3LN_UPD,
249 VLD4LN_UPD,
Eli Friedmanf624ec22016-12-16 18:44:08 +0000250 VLD1DUP_UPD,
Bob Wilson06fce872011-02-07 17:43:21 +0000251 VLD2DUP_UPD,
252 VLD3DUP_UPD,
253 VLD4DUP_UPD,
254
255 // NEON stores with post-increment base updates:
256 VST1_UPD,
257 VST2_UPD,
258 VST3_UPD,
259 VST4_UPD,
260 VST2LN_UPD,
261 VST3LN_UPD,
Amara Emersonb4ad2f32013-09-26 12:22:36 +0000262 VST4LN_UPD
Evan Cheng10043e22007-01-19 07:51:42 +0000263 };
Eugene Zelenkoc4ad1ce2017-01-11 01:45:03 +0000264
265 } // end namespace ARMISD
Evan Cheng10043e22007-01-19 07:51:42 +0000266
Bob Wilson2e076c42009-06-22 23:27:02 +0000267 /// Define some predicates that are used for node matching.
268 namespace ARM {
Eugene Zelenkoc4ad1ce2017-01-11 01:45:03 +0000269
Jim Grosbach11013ed2010-07-16 23:05:05 +0000270 bool isBitFieldInvertedMask(unsigned v);
Eugene Zelenkoc4ad1ce2017-01-11 01:45:03 +0000271
272 } // end namespace ARM
Bob Wilson2e076c42009-06-22 23:27:02 +0000273
Bob Wilsondd0e2362009-05-20 16:30:25 +0000274 //===--------------------------------------------------------------------===//
Dale Johannesen8447d342007-03-20 00:30:56 +0000275 // ARMTargetLowering - ARM Implementation of the TargetLowering interface
Jim Grosbach91fa7812009-05-13 22:32:43 +0000276
Evan Cheng10043e22007-01-19 07:51:42 +0000277 class ARMTargetLowering : public TargetLowering {
Evan Cheng10043e22007-01-19 07:51:42 +0000278 public:
Eric Christopher1889fdc2015-01-29 00:19:39 +0000279 explicit ARMTargetLowering(const TargetMachine &TM,
280 const ARMSubtarget &STI);
Evan Cheng10043e22007-01-19 07:51:42 +0000281
Craig Topper6bc27bf2014-03-10 02:09:33 +0000282 unsigned getJumpTableEncoding() const override;
Eric Christopher824f42f2015-05-12 01:26:05 +0000283 bool useSoftFloat() const override;
Jim Grosbach8d3ba732010-07-19 17:20:38 +0000284
Craig Topper6bc27bf2014-03-10 02:09:33 +0000285 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
Duncan Sands6ed40142008-12-01 11:39:25 +0000286
287 /// ReplaceNodeResults - Replace the results of node with an illegal result
288 /// type with new values built out of custom code.
Craig Topper6bc27bf2014-03-10 02:09:33 +0000289 void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue>&Results,
290 SelectionDAG &DAG) const override;
Duncan Sands6ed40142008-12-01 11:39:25 +0000291
Craig Topper6bc27bf2014-03-10 02:09:33 +0000292 const char *getTargetNodeName(unsigned Opcode) const override;
Evan Cheng10043e22007-01-19 07:51:42 +0000293
Craig Topper6bc27bf2014-03-10 02:09:33 +0000294 bool isSelectSupported(SelectSupportKind Kind) const override {
Nadav Rotem9d832022012-09-02 12:10:19 +0000295 // ARM does not support scalar condition selects on vectors.
296 return (Kind != ScalarCondVectorVal);
297 }
298
Diana Picus1d101d72017-09-01 10:44:48 +0000299 bool isReadOnly(const GlobalValue *GV) const;
300
Duncan Sandsf2641e12011-09-06 19:07:46 +0000301 /// getSetCCResultType - Return the value type to use for ISD::SETCC.
Mehdi Amini44ede332015-07-09 02:09:04 +0000302 EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context,
303 EVT VT) const override;
Duncan Sandsf2641e12011-09-06 19:07:46 +0000304
Craig Topper6bc27bf2014-03-10 02:09:33 +0000305 MachineBasicBlock *
Duncan P. N. Exon Smithe4f5e4f2016-06-30 22:52:52 +0000306 EmitInstrWithCustomInserter(MachineInstr &MI,
307 MachineBasicBlock *MBB) const override;
Evan Cheng10043e22007-01-19 07:51:42 +0000308
Duncan P. N. Exon Smithe4f5e4f2016-06-30 22:52:52 +0000309 void AdjustInstrPostInstrSelection(MachineInstr &MI,
Craig Topper6bc27bf2014-03-10 02:09:33 +0000310 SDNode *Node) const override;
Evan Chenge6fba772011-08-30 19:09:48 +0000311
Evan Chengf863e3f2011-07-13 00:42:17 +0000312 SDValue PerformCMOVCombine(SDNode *N, SelectionDAG &DAG) const;
Peter Collingbourne86b9fbe2016-03-21 18:00:02 +0000313 SDValue PerformBRCONDCombine(SDNode *N, SelectionDAG &DAG) const;
James Molloy9d55f192015-11-10 14:22:05 +0000314 SDValue PerformCMOVToBFICombine(SDNode *N, SelectionDAG &DAG) const;
Craig Topper6bc27bf2014-03-10 02:09:33 +0000315 SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
Evan Chengd42641c2011-02-02 01:06:55 +0000316
Craig Topper6bc27bf2014-03-10 02:09:33 +0000317 bool isDesirableToTransformToIntegerOp(unsigned Opc, EVT VT) const override;
Evan Chengd42641c2011-02-02 01:06:55 +0000318
Matt Arsenault6f2a5262014-07-27 17:46:40 +0000319 /// allowsMisalignedMemoryAccesses - Returns true if the target allows
Evan Cheng79e2ca92012-12-10 23:21:26 +0000320 /// unaligned memory accesses of the specified type. Returns whether it
321 /// is "fast" by reference in the second argument.
Matt Arsenault6f2a5262014-07-27 17:46:40 +0000322 bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AddrSpace,
323 unsigned Align,
324 bool *Fast) const override;
Bill Wendlingbae6b2c2009-08-15 21:21:19 +0000325
Craig Topper6bc27bf2014-03-10 02:09:33 +0000326 EVT getOptimalMemOpType(uint64_t Size,
327 unsigned DstAlign, unsigned SrcAlign,
328 bool IsMemset, bool ZeroMemset,
329 bool MemcpyStrSrc,
330 MachineFunction &MF) const override;
Lang Hames9929c422011-11-02 22:52:45 +0000331
Sam Parker71efbe42017-09-18 14:28:51 +0000332 bool isTruncateFree(Type *SrcTy, Type *DstTy) const override;
333 bool isTruncateFree(EVT SrcVT, EVT DstVT) const override;
Craig Topper6bc27bf2014-03-10 02:09:33 +0000334 bool isZExtFree(SDValue Val, EVT VT2) const override;
Sjoerd Meijer89ea2642018-02-06 08:43:56 +0000335 bool isFNegFree(EVT VT) const override;
Evan Cheng9ec512d2012-12-06 19:13:27 +0000336
Ahmed Bougacha4200cc92015-03-05 19:37:53 +0000337 bool isVectorLoadExtDesirable(SDValue ExtVal) const override;
338
Craig Topper6bc27bf2014-03-10 02:09:33 +0000339 bool allowTruncateForTailCall(Type *Ty1, Type *Ty2) const override;
Tim Northovercc2e9032013-08-06 13:58:03 +0000340
341
Chris Lattner1eb94d92007-03-30 23:15:24 +0000342 /// isLegalAddressingMode - Return true if the addressing mode represented
343 /// by AM is legal for this target, for a load/store of the specified type.
Mehdi Amini0cdec1e2015-07-09 02:09:40 +0000344 bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM,
Jonas Paulsson024e3192017-07-21 11:59:37 +0000345 Type *Ty, unsigned AS,
346 Instruction *I = nullptr) const override;
Javed Absar85874a92016-10-13 14:57:43 +0000347
348 /// getScalingFactorCost - Return the cost of the scaling used in
349 /// addressing mode represented by AM.
350 /// If the AM is supported, the return value must be >= 0.
351 /// If the AM is not supported, the return value must be negative.
352 int getScalingFactorCost(const DataLayout &DL, const AddrMode &AM, Type *Ty,
353 unsigned AS) const override;
354
Evan Chengdc49a8d2009-08-14 20:09:37 +0000355 bool isLegalT2ScaledAddressingMode(const AddrMode &AM, EVT VT) const;
Jim Grosbach91fa7812009-05-13 22:32:43 +0000356
Adrian Prantl5f8f34e42018-05-01 15:54:18 +0000357 /// Returns true if the addresing mode representing by AM is legal
Evgeny Astigeevich540a39a2017-08-24 10:00:25 +0000358 /// for the Thumb1 target, for a load/store of the specified type.
359 bool isLegalT1ScaledAddressingMode(const AddrMode &AM, EVT VT) const;
360
Evan Cheng3d3c24a2009-11-11 19:05:52 +0000361 /// isLegalICmpImmediate - Return true if the specified immediate is legal
Jim Grosbach84511e12010-06-02 21:53:11 +0000362 /// icmp immediate, that is the target has icmp instructions which can
363 /// compare a register against the immediate without having to materialize
364 /// the immediate into a register.
Craig Topper6bc27bf2014-03-10 02:09:33 +0000365 bool isLegalICmpImmediate(int64_t Imm) const override;
Evan Cheng3d3c24a2009-11-11 19:05:52 +0000366
Dan Gohman6136e942011-05-03 00:46:49 +0000367 /// isLegalAddImmediate - Return true if the specified immediate is legal
368 /// add immediate, that is the target has add instructions which can
369 /// add a register and the immediate without having to materialize
370 /// the immediate into a register.
Craig Topper6bc27bf2014-03-10 02:09:33 +0000371 bool isLegalAddImmediate(int64_t Imm) const override;
Dan Gohman6136e942011-05-03 00:46:49 +0000372
Evan Cheng10043e22007-01-19 07:51:42 +0000373 /// getPreIndexedAddressParts - returns true by value, base pointer and
374 /// offset pointer and addressing mode by reference if the node's address
375 /// can be legally represented as pre-indexed load / store address.
Craig Topper6bc27bf2014-03-10 02:09:33 +0000376 bool getPreIndexedAddressParts(SDNode *N, SDValue &Base, SDValue &Offset,
377 ISD::MemIndexedMode &AM,
378 SelectionDAG &DAG) const override;
Evan Cheng10043e22007-01-19 07:51:42 +0000379
380 /// getPostIndexedAddressParts - returns true by value, base pointer and
381 /// offset pointer and addressing mode by reference if this node can be
382 /// combined with a load / store to form a post-indexed load / store.
Craig Topper6bc27bf2014-03-10 02:09:33 +0000383 bool getPostIndexedAddressParts(SDNode *N, SDNode *Op, SDValue &Base,
384 SDValue &Offset, ISD::MemIndexedMode &AM,
385 SelectionDAG &DAG) const override;
Evan Cheng10043e22007-01-19 07:51:42 +0000386
Craig Topperd0af7e82017-04-28 05:31:46 +0000387 void computeKnownBitsForTargetNode(const SDValue Op, KnownBits &Known,
Simon Pilgrim37b536e2017-03-31 11:24:16 +0000388 const APInt &DemandedElts,
Jay Foada0653a32014-05-14 21:14:37 +0000389 const SelectionDAG &DAG,
390 unsigned Depth) const override;
Bill Wendlingbae6b2c2009-08-15 21:21:19 +0000391
Eli Friedmane1687a892018-08-10 21:21:53 +0000392 bool targetShrinkDemandedConstant(SDValue Op, const APInt &Demanded,
393 TargetLoweringOpt &TLO) const override;
394
Bill Wendlingbae6b2c2009-08-15 21:21:19 +0000395
Craig Topper6bc27bf2014-03-10 02:09:33 +0000396 bool ExpandInlineAsm(CallInst *CI) const override;
Evan Cheng078b0b02011-01-08 01:24:27 +0000397
Benjamin Kramer9bfb6272015-07-05 19:29:18 +0000398 ConstraintType getConstraintType(StringRef Constraint) const override;
John Thompsone8360b72010-10-29 17:29:13 +0000399
400 /// Examine constraint string and operand type and determine a weight value.
401 /// The operand object must already have been set up with the operand type.
402 ConstraintWeight getSingleConstraintMatchWeight(
Craig Topper6bc27bf2014-03-10 02:09:33 +0000403 AsmOperandInfo &info, const char *constraint) const override;
John Thompsone8360b72010-10-29 17:29:13 +0000404
Eric Christopher11e4df72015-02-26 22:38:43 +0000405 std::pair<unsigned, const TargetRegisterClass *>
406 getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
Benjamin Kramer9bfb6272015-07-05 19:29:18 +0000407 StringRef Constraint, MVT VT) const override;
Rafael Espindolafa0df552007-11-05 23:12:20 +0000408
Silviu Baranga82d04262016-04-25 14:29:18 +0000409 const char *LowerXConstraint(EVT ConstraintVT) const override;
410
Bob Wilsoncf1ec2c2009-04-01 17:58:54 +0000411 /// LowerAsmOperandForConstraint - Lower the specified operand into the Ops
412 /// vector. If it is invalid, don't add anything to Ops. If hasMemory is
413 /// true it means one of the asm constraint of the inline asm instruction
414 /// being processed is 'm'.
Craig Topper6bc27bf2014-03-10 02:09:33 +0000415 void LowerAsmOperandForConstraint(SDValue Op, std::string &Constraint,
416 std::vector<SDValue> &Ops,
417 SelectionDAG &DAG) const override;
Jim Grosbach91fa7812009-05-13 22:32:43 +0000418
Benjamin Kramer9bfb6272015-07-05 19:29:18 +0000419 unsigned
420 getInlineAsmMemConstraint(StringRef ConstraintCode) const override {
Daniel Sanders1f58ef72015-06-03 12:33:56 +0000421 if (ConstraintCode == "Q")
422 return InlineAsm::Constraint_Q;
James Molloy72222f52015-10-26 10:04:52 +0000423 else if (ConstraintCode == "o")
424 return InlineAsm::Constraint_o;
Daniel Sanders1f58ef72015-06-03 12:33:56 +0000425 else if (ConstraintCode.size() == 2) {
426 if (ConstraintCode[0] == 'U') {
427 switch(ConstraintCode[1]) {
428 default:
429 break;
430 case 'm':
431 return InlineAsm::Constraint_Um;
432 case 'n':
433 return InlineAsm::Constraint_Un;
434 case 'q':
435 return InlineAsm::Constraint_Uq;
436 case 's':
437 return InlineAsm::Constraint_Us;
438 case 't':
439 return InlineAsm::Constraint_Ut;
440 case 'v':
441 return InlineAsm::Constraint_Uv;
442 case 'y':
443 return InlineAsm::Constraint_Uy;
444 }
445 }
446 }
447 return TargetLowering::getInlineAsmMemConstraint(ConstraintCode);
Daniel Sandersbf5b80f2015-03-16 13:13:41 +0000448 }
449
Dan Gohman4df9d9c2010-05-11 16:21:03 +0000450 const ARMSubtarget* getSubtarget() const {
Dan Gohman544ab2c2008-04-12 04:36:06 +0000451 return Subtarget;
Rafael Espindolafa0df552007-11-05 23:12:20 +0000452 }
453
Evan Cheng4cad68e2010-05-15 02:18:07 +0000454 /// getRegClassFor - Return the register class that should be used for the
455 /// specified value type.
Craig Topper6bc27bf2014-03-10 02:09:33 +0000456 const TargetRegisterClass *getRegClassFor(MVT VT) const override;
Evan Cheng4cad68e2010-05-15 02:18:07 +0000457
James Molloy8a259922013-12-03 11:23:11 +0000458 /// Returns true if a cast between SrcAS and DestAS is a noop.
Craig Topper6bc27bf2014-03-10 02:09:33 +0000459 bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override {
James Molloy8a259922013-12-03 11:23:11 +0000460 // Addrspacecasts are always noops.
461 return true;
462 }
463
John Brawn0dbcd652015-03-18 12:01:59 +0000464 bool shouldAlignPointerArgs(CallInst *CI, unsigned &MinSize,
465 unsigned &PrefAlign) const override;
466
Eric Christopher84bdfd82010-07-21 22:26:11 +0000467 /// createFastISel - This method returns a target specific FastISel object,
468 /// or null if the target does not support "fast" ISel.
Craig Topper6bc27bf2014-03-10 02:09:33 +0000469 FastISel *createFastISel(FunctionLoweringInfo &funcInfo,
470 const TargetLibraryInfo *libInfo) const override;
Eric Christopher84bdfd82010-07-21 22:26:11 +0000471
Craig Topper6bc27bf2014-03-10 02:09:33 +0000472 Sched::Preference getSchedulingPreference(SDNode *N) const override;
Evan Cheng4401f882010-05-20 23:26:43 +0000473
Craig Topper6bc27bf2014-03-10 02:09:33 +0000474 bool
Zvi Rackover1b736822017-07-26 08:06:58 +0000475 isShuffleMaskLegal(ArrayRef<int> M, EVT VT) const override;
Craig Topper6bc27bf2014-03-10 02:09:33 +0000476 bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
Evan Cheng4a609f3c2009-10-28 01:44:26 +0000477
478 /// isFPImmLegal - Returns true if the target can instruction select the
479 /// specified FP immediate natively. If false, the legalizer will
480 /// materialize the FP immediate as a load from a constant pool.
Craig Topper6bc27bf2014-03-10 02:09:33 +0000481 bool isFPImmLegal(const APFloat &Imm, EVT VT) const override;
Evan Cheng4a609f3c2009-10-28 01:44:26 +0000482
Craig Topper6bc27bf2014-03-10 02:09:33 +0000483 bool getTgtMemIntrinsic(IntrinsicInfo &Info,
484 const CallInst &I,
Matt Arsenault7d7adf42017-12-14 22:34:10 +0000485 MachineFunction &MF,
Craig Topper6bc27bf2014-03-10 02:09:33 +0000486 unsigned Intrinsic) const override;
Juergen Ributzka659ce002014-01-28 01:20:14 +0000487
Adrian Prantl5f8f34e42018-05-01 15:54:18 +0000488 /// Returns true if it is beneficial to convert a load of a constant
Juergen Ributzka659ce002014-01-28 01:20:14 +0000489 /// to just the constant itself.
Craig Topper6bc27bf2014-03-10 02:09:33 +0000490 bool shouldConvertConstantLoadToIntImm(const APInt &Imm,
491 Type *Ty) const override;
Juergen Ributzka659ce002014-01-28 01:20:14 +0000492
Eli Friedmand03df812016-12-20 20:05:07 +0000493 /// Return true if EXTRACT_SUBVECTOR is cheap for this result type
494 /// with this index.
Craig Topper2251ef92017-08-13 17:29:07 +0000495 bool isExtractSubvectorCheap(EVT ResVT, EVT SrcVT,
496 unsigned Index) const override;
Eli Friedmand03df812016-12-20 20:05:07 +0000497
Adrian Prantl5f8f34e42018-05-01 15:54:18 +0000498 /// Returns true if an argument of type Ty needs to be passed in a
Oliver Stannardc24f2172014-05-09 14:01:47 +0000499 /// contiguous block of registers in calling convention CallConv.
500 bool functionArgumentNeedsConsecutiveRegisters(
501 Type *Ty, CallingConv::ID CallConv, bool isVarArg) const override;
502
Joseph Tremouletf748c892015-11-07 01:11:31 +0000503 /// If a physical register, this returns the register that receives the
504 /// exception address on entry to an EH pad.
505 unsigned
506 getExceptionPointerRegister(const Constant *PersonalityFn) const override;
507
508 /// If a physical register, this returns the register that receives the
509 /// exception typeid on entry to a landing pad.
510 unsigned
511 getExceptionSelectorRegister(const Constant *PersonalityFn) const override;
512
Robin Morisset5349e8e2014-09-18 18:56:04 +0000513 Instruction *makeDMB(IRBuilder<> &Builder, ARM_MB::MemBOpt Domain) const;
Tim Northover037f26f22014-04-17 18:22:47 +0000514 Value *emitLoadLinked(IRBuilder<> &Builder, Value *Addr,
515 AtomicOrdering Ord) const override;
516 Value *emitStoreConditional(IRBuilder<> &Builder, Value *Val,
517 Value *Addr, AtomicOrdering Ord) const override;
518
Ahmed Bougacha81616a72015-09-22 17:22:58 +0000519 void emitAtomicCmpXchgNoStoreLLBalance(IRBuilder<> &Builder) const override;
520
Tim Shen04de70d2017-05-09 15:27:17 +0000521 Instruction *emitLeadingFence(IRBuilder<> &Builder, Instruction *Inst,
522 AtomicOrdering Ord) const override;
523 Instruction *emitTrailingFence(IRBuilder<> &Builder, Instruction *Inst,
524 AtomicOrdering Ord) const override;
Robin Morisseta47cb412014-09-03 21:01:03 +0000525
Hao Liu2cd34bb2015-06-26 02:45:36 +0000526 unsigned getMaxSupportedInterleaveFactor() const override { return 4; }
527
528 bool lowerInterleavedLoad(LoadInst *LI,
529 ArrayRef<ShuffleVectorInst *> Shuffles,
530 ArrayRef<unsigned> Indices,
531 unsigned Factor) const override;
532 bool lowerInterleavedStore(StoreInst *SI, ShuffleVectorInst *SVI,
533 unsigned Factor) const override;
534
James Y Knightf44fc522016-03-16 22:12:04 +0000535 bool shouldInsertFencesForAtomic(const Instruction *I) const override;
Ahmed Bougacha52468672015-09-11 17:08:28 +0000536 TargetLoweringBase::AtomicExpansionKind
537 shouldExpandAtomicLoadInIR(LoadInst *LI) const override;
Robin Morisseted3d48f2014-09-03 21:29:59 +0000538 bool shouldExpandAtomicStoreInIR(StoreInst *SI) const override;
Ahmed Bougacha9d677132015-09-11 17:08:17 +0000539 TargetLoweringBase::AtomicExpansionKind
JF Bastienf14889e2015-03-04 15:47:57 +0000540 shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const override;
Ahmed Bougacha52468672015-09-11 17:08:28 +0000541 bool shouldExpandAtomicCmpXchgInIR(AtomicCmpXchgInst *AI) const override;
Tim Northover037f26f22014-04-17 18:22:47 +0000542
Akira Hatanakae5b6e0d2014-07-25 19:31:34 +0000543 bool useLoadStackGuardNode() const override;
544
Quentin Colombetc32615d2014-10-31 17:52:53 +0000545 bool canCombineStoreAndExtract(Type *VectorTy, Value *Idx,
546 unsigned &Cost) const override;
547
Nirav Dave4dcad5d2017-07-10 20:25:54 +0000548 bool canMergeStoresTo(unsigned AddressSpace, EVT MemVT,
549 const SelectionDAG &DAG) const override {
Nirav Dave54e22f32017-03-14 00:34:14 +0000550 // Do not merge to larger than i32.
551 return (MemVT.getSizeInBits() <= 32);
552 }
553
Sanjay Patelaf1b48b2015-11-10 19:24:31 +0000554 bool isCheapToSpeculateCttz() const override;
555 bool isCheapToSpeculateCtlz() const override;
556
Sanjay Patelb2f16212017-04-05 14:09:39 +0000557 bool convertSetCCLogicToBitwiseLogic(EVT VT) const override {
558 return VT.isScalarInteger();
559 }
560
Manman Ren57518142016-04-11 21:08:06 +0000561 bool supportSwiftError() const override {
562 return true;
563 }
564
Diana Picus774d1572016-07-18 06:48:25 +0000565 bool hasStandaloneRem(EVT VT) const override {
566 return HasStandaloneRem;
567 }
568
Diana Picus2af9c382016-12-16 10:35:20 +0000569 CCAssignFn *CCAssignFnForCall(CallingConv::ID CC, bool isVarArg) const;
570 CCAssignFn *CCAssignFnForReturn(CallingConv::ID CC, bool isVarArg) const;
571
Matthew Simpson1468d3e2017-04-10 18:34:37 +0000572 /// Returns true if \p VecTy is a legal interleaved access type. This
573 /// function checks the vector element type and the overall width of the
574 /// vector.
575 bool isLegalInterleavedAccessType(VectorType *VecTy,
576 const DataLayout &DL) const;
577
578 /// Returns the number of interleaved accesses that will be generated when
579 /// lowering accesses of the given type.
580 unsigned getNumInterleavedAccesses(VectorType *VecTy,
581 const DataLayout &DL) const;
582
Matthias Braun4682ac62017-05-05 22:04:05 +0000583 void finalizeLowering(MachineFunction &MF) const override;
584
Tim Northover28e0a6f2018-05-03 12:54:25 +0000585 /// Return the correct alignment for the current calling convention.
586 unsigned getABIAlignmentForCallingConv(Type *ArgTy,
587 DataLayout DL) const override;
588
Eli Friedman0d12e902018-08-14 22:10:25 +0000589 bool isDesirableToCommuteWithShift(const SDNode *N,
590 CombineLevel Level) const override;
591
Evan Cheng10f99a32010-07-19 22:15:08 +0000592 protected:
Eric Christopher23a3a7c2015-02-26 00:00:24 +0000593 std::pair<const TargetRegisterClass *, uint8_t>
594 findRepresentativeClass(const TargetRegisterInfo *TRI,
595 MVT VT) const override;
Evan Cheng10f99a32010-07-19 22:15:08 +0000596
Evan Cheng10043e22007-01-19 07:51:42 +0000597 private:
598 /// Subtarget - Keep a pointer to the ARMSubtarget around so that we can
599 /// make the right decision when generating code for different targets.
600 const ARMSubtarget *Subtarget;
601
Evan Chengdf907f42010-07-23 22:39:59 +0000602 const TargetRegisterInfo *RegInfo;
603
Evan Chengbf407072010-09-10 01:29:16 +0000604 const InstrItineraryData *Itins;
605
Bob Wilson844d6c82009-07-13 18:11:36 +0000606 /// ARMPCLabelIndex - Keep track of the number of ARM PC labels created.
Evan Cheng10043e22007-01-19 07:51:42 +0000607 unsigned ARMPCLabelIndex;
608
James Y Knightf44fc522016-03-16 22:12:04 +0000609 // TODO: remove this, and have shouldInsertFencesForAtomic do the proper
610 // check.
611 bool InsertFencesForAtomic;
612
Diana Picus774d1572016-07-18 06:48:25 +0000613 bool HasStandaloneRem = true;
614
Craig Topper4fa625f2012-08-12 03:16:37 +0000615 void addTypeForNEON(MVT VT, MVT PromotedLdStVT, MVT PromotedBitwiseVT);
616 void addDRTypeForNEON(MVT VT);
617 void addQRTypeForNEON(MVT VT);
Louis Gerbarg3342bf12014-05-09 17:02:49 +0000618 std::pair<SDValue, SDValue> getARMXALUOOp(SDValue Op, SelectionDAG &DAG, SDValue &ARMcc) const;
Bob Wilson2e076c42009-06-22 23:27:02 +0000619
Eugene Zelenko076468c2017-09-20 21:35:51 +0000620 using RegsToPassVector = SmallVector<std::pair<unsigned, SDValue>, 8>;
Eugene Zelenkoc4ad1ce2017-01-11 01:45:03 +0000621
Benjamin Kramerbdc49562016-06-12 15:39:02 +0000622 void PassF64ArgInRegs(const SDLoc &dl, SelectionDAG &DAG, SDValue Chain,
623 SDValue &Arg, RegsToPassVector &RegsToPass,
Bob Wilson2e076c42009-06-22 23:27:02 +0000624 CCValAssign &VA, CCValAssign &NextVA,
625 SDValue &StackPtr,
Craig Topperb94011f2013-07-14 04:42:23 +0000626 SmallVectorImpl<SDValue> &MemOpChains,
Dan Gohman21cea8a2010-04-17 15:26:15 +0000627 ISD::ArgFlagsTy Flags) const;
Bob Wilson2e076c42009-06-22 23:27:02 +0000628 SDValue GetF64FormalArgument(CCValAssign &VA, CCValAssign &NextVA,
Dan Gohman21cea8a2010-04-17 15:26:15 +0000629 SDValue &Root, SelectionDAG &DAG,
Benjamin Kramerbdc49562016-06-12 15:39:02 +0000630 const SDLoc &dl) const;
Bob Wilson2e076c42009-06-22 23:27:02 +0000631
Oliver Stannardc24f2172014-05-09 14:01:47 +0000632 CallingConv::ID getEffectiveCallingConv(CallingConv::ID CC,
633 bool isVarArg) const;
Jim Grosbach84511e12010-06-02 21:53:11 +0000634 CCAssignFn *CCAssignFnForNode(CallingConv::ID CC, bool Return,
635 bool isVarArg) const;
Dan Gohmanf9bbcd12009-08-05 01:29:28 +0000636 SDValue LowerMemOpCallTo(SDValue Chain, SDValue StackPtr, SDValue Arg,
Benjamin Kramerbdc49562016-06-12 15:39:02 +0000637 const SDLoc &dl, SelectionDAG &DAG,
Dan Gohmanf9bbcd12009-08-05 01:29:28 +0000638 const CCValAssign &VA,
Dan Gohman21cea8a2010-04-17 15:26:15 +0000639 ISD::ArgFlagsTy Flags) const;
Jim Grosbachc98892f2010-05-26 20:22:18 +0000640 SDValue LowerEH_SJLJ_SETJMP(SDValue Op, SelectionDAG &DAG) const;
Jim Grosbachbd9485d2010-05-22 01:06:18 +0000641 SDValue LowerEH_SJLJ_LONGJMP(SDValue Op, SelectionDAG &DAG) const;
Matthias Braun3cd00c12015-07-16 22:34:16 +0000642 SDValue LowerEH_SJLJ_SETUP_DISPATCH(SDValue Op, SelectionDAG &DAG) const;
Jim Grosbacha570d052010-02-08 23:22:00 +0000643 SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG,
Dan Gohman21cea8a2010-04-17 15:26:15 +0000644 const ARMSubtarget *Subtarget) const;
645 SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
Alexandros Lamprineas2b2b4202017-06-20 07:20:52 +0000646 SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
647 SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
Dan Gohman21cea8a2010-04-17 15:26:15 +0000648 SDValue LowerGlobalAddressDarwin(SDValue Op, SelectionDAG &DAG) const;
649 SDValue LowerGlobalAddressELF(SDValue Op, SelectionDAG &DAG) const;
Saleem Abdulrasool40bca0a2014-05-09 00:58:32 +0000650 SDValue LowerGlobalAddressWindows(SDValue Op, SelectionDAG &DAG) const;
Dan Gohman21cea8a2010-04-17 15:26:15 +0000651 SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
Dan Gohman2ce6f2a2008-07-27 21:46:04 +0000652 SDValue LowerToTLSGeneralDynamicModel(GlobalAddressSDNode *GA,
Dan Gohman21cea8a2010-04-17 15:26:15 +0000653 SelectionDAG &DAG) const;
Dan Gohman2ce6f2a2008-07-27 21:46:04 +0000654 SDValue LowerToTLSExecModels(GlobalAddressSDNode *GA,
Hans Wennborgaea41202012-05-04 09:40:39 +0000655 SelectionDAG &DAG,
656 TLSModel::Model model) const;
Tim Northoverbd41cf82016-01-07 09:03:03 +0000657 SDValue LowerGlobalTLSAddressDarwin(SDValue Op, SelectionDAG &DAG) const;
Saleem Abdulrasoolf36005a2016-02-03 18:21:59 +0000658 SDValue LowerGlobalTLSAddressWindows(SDValue Op, SelectionDAG &DAG) const;
Tim Northoverbd41cf82016-01-07 09:03:03 +0000659 SDValue LowerGLOBAL_OFFSET_TABLE(SDValue Op, SelectionDAG &DAG) const;
Dan Gohman21cea8a2010-04-17 15:26:15 +0000660 SDValue LowerBR_JT(SDValue Op, SelectionDAG &DAG) const;
Roger Ferrer Ibanez5ea0f252017-12-11 12:13:45 +0000661 SDValue LowerSignedALUO(SDValue Op, SelectionDAG &DAG) const;
662 SDValue LowerUnsignedALUO(SDValue Op, SelectionDAG &DAG) const;
Bill Wendling6a981312010-08-11 08:43:16 +0000663 SDValue LowerSELECT(SDValue Op, SelectionDAG &DAG) const;
Dan Gohman21cea8a2010-04-17 15:26:15 +0000664 SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;
Joel Galenson6f4e8272017-12-20 22:25:39 +0000665 SDValue LowerBRCOND(SDValue Op, SelectionDAG &DAG) const;
Dan Gohman21cea8a2010-04-17 15:26:15 +0000666 SDValue LowerBR_CC(SDValue Op, SelectionDAG &DAG) const;
Evan Cheng25f93642010-07-08 02:08:50 +0000667 SDValue LowerFCOPYSIGN(SDValue Op, SelectionDAG &DAG) const;
Evan Cheng168ced92010-05-22 01:47:14 +0000668 SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
Dan Gohman21cea8a2010-04-17 15:26:15 +0000669 SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
Dan Gohman21cea8a2010-04-17 15:26:15 +0000670 SDValue LowerShiftRightParts(SDValue Op, SelectionDAG &DAG) const;
671 SDValue LowerShiftLeftParts(SDValue Op, SelectionDAG &DAG) const;
Nate Begemanb69b1822010-08-03 21:31:55 +0000672 SDValue LowerFLT_ROUNDS_(SDValue Op, SelectionDAG &DAG) const;
Lang Hamesc35ee8b2012-03-15 18:49:02 +0000673 SDValue LowerConstantFP(SDValue Op, SelectionDAG &DAG,
674 const ARMSubtarget *ST) const;
Andrew Trick1a1f8d42011-04-23 03:24:11 +0000675 SDValue LowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG,
Bob Wilson6f2b8962011-01-07 21:37:30 +0000676 const ARMSubtarget *ST) const;
Bob Wilsone7dde0c2013-11-03 06:14:38 +0000677 SDValue LowerFSINCOS(SDValue Op, SelectionDAG &DAG) const;
Renato Golin87610692013-07-16 09:32:17 +0000678 SDValue LowerDivRem(SDValue Op, SelectionDAG &DAG) const;
Martell Maloned1229242015-11-26 15:34:03 +0000679 SDValue LowerDIV_Windows(SDValue Op, SelectionDAG &DAG, bool Signed) const;
680 void ExpandDIV_Windows(SDValue Op, SelectionDAG &DAG, bool Signed,
Saleem Abdulrasoolfe83b502015-09-25 05:15:46 +0000681 SmallVectorImpl<SDValue> &Results) const;
Martell Maloned1229242015-11-26 15:34:03 +0000682 SDValue LowerWindowsDIVLibCall(SDValue Op, SelectionDAG &DAG, bool Signed,
Saleem Abdulrasoolfe83b502015-09-25 05:15:46 +0000683 SDValue &Chain) const;
Scott Douglassbdef6042015-08-24 09:17:18 +0000684 SDValue LowerREM(SDNode *N, SelectionDAG &DAG) const;
Saleem Abdulrasoolabac6e92014-06-09 20:18:42 +0000685 SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const;
Oliver Stannard51b1d462014-08-21 12:50:31 +0000686 SDValue LowerFP_ROUND(SDValue Op, SelectionDAG &DAG) const;
687 SDValue LowerFP_EXTEND(SDValue Op, SelectionDAG &DAG) const;
688 SDValue LowerFP_TO_INT(SDValue Op, SelectionDAG &DAG) const;
689 SDValue LowerINT_TO_FP(SDValue Op, SelectionDAG &DAG) const;
Bob Wilson6f2b8962011-01-07 21:37:30 +0000690
Pat Gavlina717f252015-07-09 17:40:29 +0000691 unsigned getRegisterByName(const char* RegName, EVT VT,
692 SelectionDAG &DAG) const override;
Renato Golinc7aea402014-05-06 16:51:25 +0000693
Stephen Lindd502022013-07-10 01:54:24 +0000694 /// isFMAFasterThanFMulAndFAdd - Return true if an FMA operation is faster
695 /// than a pair of fmul and fadd instructions. fmuladd intrinsics will be
696 /// expanded to FMAs when this method returns true, otherwise fmuladd is
697 /// expanded to fmul + fadd.
698 ///
699 /// ARM supports both fused and unfused multiply-add operations; we already
Stephen Lin2a644732013-07-10 01:57:39 +0000700 /// lower a pair of fmul and fadd to the latter so it's not clear that there
Stephen Lindd502022013-07-10 01:54:24 +0000701 /// would be a gain or that the gain would be worthwhile enough to risk
702 /// correctness bugs.
Craig Topper6bc27bf2014-03-10 02:09:33 +0000703 bool isFMAFasterThanFMulAndFAdd(EVT VT) const override { return false; }
Stephen Lindd502022013-07-10 01:54:24 +0000704
Bob Wilson6f2b8962011-01-07 21:37:30 +0000705 SDValue ReconstructShuffle(SDValue Op, SelectionDAG &DAG) const;
Rafael Espindola18a831d2007-10-19 14:35:17 +0000706
Dan Gohmanf9bbcd12009-08-05 01:29:28 +0000707 SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
Sandeep Patel68c5f472009-09-02 08:44:58 +0000708 CallingConv::ID CallConv, bool isVarArg,
Dan Gohmanf9bbcd12009-08-05 01:29:28 +0000709 const SmallVectorImpl<ISD::InputArg> &Ins,
Benjamin Kramerbdc49562016-06-12 15:39:02 +0000710 const SDLoc &dl, SelectionDAG &DAG,
711 SmallVectorImpl<SDValue> &InVals, bool isThisReturn,
712 SDValue ThisVal) const;
Dan Gohmanf9bbcd12009-08-05 01:29:28 +0000713
Manman Ren5e9e65e2016-01-12 00:47:18 +0000714 bool supportSplitCSR(MachineFunction *MF) const override {
Matthias Braunf1caa282017-12-15 22:22:58 +0000715 return MF->getFunction().getCallingConv() == CallingConv::CXX_FAST_TLS &&
716 MF->getFunction().hasFnAttribute(Attribute::NoUnwind);
Manman Ren5e9e65e2016-01-12 00:47:18 +0000717 }
Eugene Zelenkoc4ad1ce2017-01-11 01:45:03 +0000718
Manman Ren5e9e65e2016-01-12 00:47:18 +0000719 void initializeSplitCSR(MachineBasicBlock *Entry) const override;
720 void insertCopiesSplitCSR(
721 MachineBasicBlock *Entry,
722 const SmallVectorImpl<MachineBasicBlock *> &Exits) const override;
723
Craig Topper6bc27bf2014-03-10 02:09:33 +0000724 SDValue
Benjamin Kramerbdc49562016-06-12 15:39:02 +0000725 LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
726 const SmallVectorImpl<ISD::InputArg> &Ins,
727 const SDLoc &dl, SelectionDAG &DAG,
728 SmallVectorImpl<SDValue> &InVals) const override;
Dan Gohmanf9bbcd12009-08-05 01:29:28 +0000729
Benjamin Kramerbdc49562016-06-12 15:39:02 +0000730 int StoreByValRegs(CCState &CCInfo, SelectionDAG &DAG, const SDLoc &dl,
731 SDValue &Chain, const Value *OrigArg,
732 unsigned InRegsParamRecordIdx, int ArgOffset,
Tim Northover8cda34f2015-03-11 18:54:22 +0000733 unsigned ArgSize) const;
Stepan Dyatkovskiyf5aa83d2013-04-30 07:19:58 +0000734
Stuart Hastings45fe3c32011-04-20 16:47:52 +0000735 void VarArgStyleRegisters(CCState &CCInfo, SelectionDAG &DAG,
Benjamin Kramerbdc49562016-06-12 15:39:02 +0000736 const SDLoc &dl, SDValue &Chain,
737 unsigned ArgOffset, unsigned TotalArgRegsSaveSize,
Stepan Dyatkovskiyf5aa83d2013-04-30 07:19:58 +0000738 bool ForceMutable = false) const;
Stuart Hastings45fe3c32011-04-20 16:47:52 +0000739
Eugene Zelenkoc4ad1ce2017-01-11 01:45:03 +0000740 SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI,
741 SmallVectorImpl<SDValue> &InVals) const override;
Dan Gohmanf9bbcd12009-08-05 01:29:28 +0000742
Stuart Hastings67c5c3e2011-02-28 17:17:53 +0000743 /// HandleByVal - Target-specific cleanup for ByVal support.
Craig Topper6bc27bf2014-03-10 02:09:33 +0000744 void HandleByVal(CCState *, unsigned &, unsigned) const override;
Stuart Hastings67c5c3e2011-02-28 17:17:53 +0000745
Dale Johannesend679ff72010-06-03 21:09:53 +0000746 /// IsEligibleForTailCallOptimization - Check whether the call is eligible
747 /// for tail call optimization. Targets which want to do tail call
748 /// optimization should implement this function.
749 bool IsEligibleForTailCallOptimization(SDValue Callee,
750 CallingConv::ID CalleeCC,
751 bool isVarArg,
752 bool isCalleeStructRet,
753 bool isCallerStructRet,
754 const SmallVectorImpl<ISD::OutputArg> &Outs,
Dan Gohmanfe7532a2010-07-07 15:54:55 +0000755 const SmallVectorImpl<SDValue> &OutVals,
Dale Johannesend679ff72010-06-03 21:09:53 +0000756 const SmallVectorImpl<ISD::InputArg> &Ins,
757 SelectionDAG& DAG) const;
Benjamin Kramerb1996da2012-11-28 20:55:10 +0000758
Craig Topper6bc27bf2014-03-10 02:09:33 +0000759 bool CanLowerReturn(CallingConv::ID CallConv,
760 MachineFunction &MF, bool isVarArg,
761 const SmallVectorImpl<ISD::OutputArg> &Outs,
762 LLVMContext &Context) const override;
Benjamin Kramerb1996da2012-11-28 20:55:10 +0000763
Benjamin Kramerbdc49562016-06-12 15:39:02 +0000764 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
765 const SmallVectorImpl<ISD::OutputArg> &Outs,
766 const SmallVectorImpl<SDValue> &OutVals,
767 const SDLoc &dl, SelectionDAG &DAG) const override;
Evan Cheng15b80e42009-11-12 07:13:11 +0000768
Craig Topper6bc27bf2014-03-10 02:09:33 +0000769 bool isUsedByReturnOnly(SDNode *N, SDValue &Chain) const override;
Evan Chengd4b08732010-11-30 23:55:39 +0000770
Matt Arsenault31380752017-04-18 21:16:46 +0000771 bool mayBeEmittedAsTailCall(const CallInst *CI) const override;
Evan Cheng0663f232011-03-21 01:19:09 +0000772
Benjamin Kramerbdc49562016-06-12 15:39:02 +0000773 SDValue getCMOV(const SDLoc &dl, EVT VT, SDValue FalseVal, SDValue TrueVal,
Oliver Stannard51b1d462014-08-21 12:50:31 +0000774 SDValue ARMcc, SDValue CCR, SDValue Cmp,
775 SelectionDAG &DAG) const;
Evan Cheng15b80e42009-11-12 07:13:11 +0000776 SDValue getARMCmp(SDValue LHS, SDValue RHS, ISD::CondCode CC,
Benjamin Kramerbdc49562016-06-12 15:39:02 +0000777 SDValue &ARMcc, SelectionDAG &DAG, const SDLoc &dl) const;
778 SDValue getVFPCmp(SDValue LHS, SDValue RHS, SelectionDAG &DAG,
James Molloyd5087892017-02-13 12:32:47 +0000779 const SDLoc &dl, bool InvalidOnQNaN) const;
Bob Wilson45acbd02011-03-08 01:17:20 +0000780 SDValue duplicateCmp(SDValue Cmp, SelectionDAG &DAG) const;
Evan Cheng0cc4ad92010-07-13 19:27:42 +0000781
782 SDValue OptimizeVFPBrcond(SDValue Op, SelectionDAG &DAG) const;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000783
Duncan P. N. Exon Smithe4f5e4f2016-06-30 22:52:52 +0000784 void SetupEntryBlockForSjLj(MachineInstr &MI, MachineBasicBlock *MBB,
Bill Wendling030b58e2011-10-06 22:18:16 +0000785 MachineBasicBlock *DispatchBB, int FI) const;
786
Duncan P. N. Exon Smithe4f5e4f2016-06-30 22:52:52 +0000787 void EmitSjLjDispatchBlock(MachineInstr &MI, MachineBasicBlock *MBB) const;
Bill Wendling374ee192011-10-03 21:25:38 +0000788
Duncan P. N. Exon Smithe4f5e4f2016-06-30 22:52:52 +0000789 bool RemapAddSubWithFlags(MachineInstr &MI, MachineBasicBlock *BB) const;
Manman Rene8735522012-06-01 19:33:18 +0000790
Duncan P. N. Exon Smithe4f5e4f2016-06-30 22:52:52 +0000791 MachineBasicBlock *EmitStructByval(MachineInstr &MI,
Manman Rene8735522012-06-01 19:33:18 +0000792 MachineBasicBlock *MBB) const;
Saleem Abdulrasoolabac6e92014-06-09 20:18:42 +0000793
Duncan P. N. Exon Smithe4f5e4f2016-06-30 22:52:52 +0000794 MachineBasicBlock *EmitLowered__chkstk(MachineInstr &MI,
Saleem Abdulrasoolabac6e92014-06-09 20:18:42 +0000795 MachineBasicBlock *MBB) const;
Duncan P. N. Exon Smithe4f5e4f2016-06-30 22:52:52 +0000796 MachineBasicBlock *EmitLowered__dbzchk(MachineInstr &MI,
Saleem Abdulrasoolfe83b502015-09-25 05:15:46 +0000797 MachineBasicBlock *MBB) const;
Evan Cheng10043e22007-01-19 07:51:42 +0000798 };
Andrew Trick1a1f8d42011-04-23 03:24:11 +0000799
Owen Andersona4076922010-11-05 21:57:54 +0000800 enum NEONModImmType {
801 VMOVModImm,
802 VMVNModImm,
803 OtherModImm
804 };
Andrew Trick1a1f8d42011-04-23 03:24:11 +0000805
Eric Christopher84bdfd82010-07-21 22:26:11 +0000806 namespace ARM {
Eugene Zelenkoc4ad1ce2017-01-11 01:45:03 +0000807
Bob Wilson3e6fa462012-08-03 04:06:28 +0000808 FastISel *createFastISel(FunctionLoweringInfo &funcInfo,
809 const TargetLibraryInfo *libInfo);
Evan Cheng10043e22007-01-19 07:51:42 +0000810
Eugene Zelenkoc4ad1ce2017-01-11 01:45:03 +0000811 } // end namespace ARM
812
813} // end namespace llvm
814
815#endif // LLVM_LIB_TARGET_ARM_ARMISELLOWERING_H