e121e3bc6fa866cc114a3d85e529ab60b1b7555a
[oota-llvm.git] / lib / CodeGen / SelectionDAG / LegalizeTypes.h
1 //===-- LegalizeTypes.h - DAG Type Legalizer class definition ---*- C++ -*-===//
2 //
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 DAGTypeLegalizer class.  This is a private interface
11 // shared between the code that implements the SelectionDAG::LegalizeTypes
12 // method.
13 //
14 //===----------------------------------------------------------------------===//
15
16 #ifndef LLVM_LIB_CODEGEN_SELECTIONDAG_LEGALIZETYPES_H
17 #define LLVM_LIB_CODEGEN_SELECTIONDAG_LEGALIZETYPES_H
18
19 #include "llvm/ADT/DenseMap.h"
20 #include "llvm/ADT/DenseSet.h"
21 #include "llvm/CodeGen/SelectionDAG.h"
22 #include "llvm/Support/Compiler.h"
23 #include "llvm/Support/Debug.h"
24 #include "llvm/Target/TargetLowering.h"
25
26 namespace llvm {
27
28 //===----------------------------------------------------------------------===//
29 /// DAGTypeLegalizer - This takes an arbitrary SelectionDAG as input and hacks
30 /// on it until only value types the target machine can handle are left.  This
31 /// involves promoting small sizes to large sizes or splitting up large values
32 /// into small values.
33 ///
34 class LLVM_LIBRARY_VISIBILITY DAGTypeLegalizer {
35   const TargetLowering &TLI;
36   SelectionDAG &DAG;
37 public:
38   // NodeIdFlags - This pass uses the NodeId on the SDNodes to hold information
39   // about the state of the node.  The enum has all the values.
40   enum NodeIdFlags {
41     /// ReadyToProcess - All operands have been processed, so this node is ready
42     /// to be handled.
43     ReadyToProcess = 0,
44
45     /// NewNode - This is a new node, not before seen, that was created in the
46     /// process of legalizing some other node.
47     NewNode = -1,
48
49     /// Unanalyzed - This node's ID needs to be set to the number of its
50     /// unprocessed operands.
51     Unanalyzed = -2,
52
53     /// Processed - This is a node that has already been processed.
54     Processed = -3
55
56     // 1+ - This is a node which has this many unprocessed operands.
57   };
58 private:
59
60   /// ValueTypeActions - This is a bitvector that contains two bits for each
61   /// simple value type, where the two bits correspond to the LegalizeAction
62   /// enum from TargetLowering.  This can be queried with "getTypeAction(VT)".
63   TargetLowering::ValueTypeActionImpl ValueTypeActions;
64
65   /// getTypeAction - Return how we should legalize values of this type.
66   TargetLowering::LegalizeTypeAction getTypeAction(EVT VT) const {
67     return TLI.getTypeAction(*DAG.getContext(), VT);
68   }
69
70   /// isTypeLegal - Return true if this type is legal on this target.
71   bool isTypeLegal(EVT VT) const {
72     return TLI.getTypeAction(*DAG.getContext(), VT) == TargetLowering::TypeLegal;
73   }
74
75   /// isSimpleLegalType - Return true if this is a simple legal type.
76   bool isSimpleLegalType(EVT VT) const {
77     return VT.isSimple() && TLI.isTypeLegal(VT);
78   }
79
80   /// isLegalInHWReg - Return true if this type can be passed in registers.
81   /// For example, x86_64's f128, should to be legally in registers
82   /// and only some operations converted to library calls or integer
83   /// bitwise operations.
84   bool isLegalInHWReg(EVT VT) const {
85     EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
86     return VT == NVT && isSimpleLegalType(VT);
87   }
88
89   EVT getSetCCResultType(EVT VT) const {
90     return TLI.getSetCCResultType(DAG.getDataLayout(), *DAG.getContext(), VT);
91   }
92
93   /// IgnoreNodeResults - Pretend all of this node's results are legal.
94   bool IgnoreNodeResults(SDNode *N) const {
95     return N->getOpcode() == ISD::TargetConstant;
96   }
97
98   /// PromotedIntegers - For integer nodes that are below legal width, this map
99   /// indicates what promoted value to use.
100   SmallDenseMap<SDValue, SDValue, 8> PromotedIntegers;
101
102   /// ExpandedIntegers - For integer nodes that need to be expanded this map
103   /// indicates which operands are the expanded version of the input.
104   SmallDenseMap<SDValue, std::pair<SDValue, SDValue>, 8> ExpandedIntegers;
105
106   /// SoftenedFloats - For floating point nodes converted to integers of
107   /// the same size, this map indicates the converted value to use.
108   SmallDenseMap<SDValue, SDValue, 8> SoftenedFloats;
109
110   /// PromotedFloats - For floating point nodes that have a smaller precision
111   /// than the smallest supported precision, this map indicates what promoted
112   /// value to use.
113   SmallDenseMap<SDValue, SDValue, 8> PromotedFloats;
114
115   /// ExpandedFloats - For float nodes that need to be expanded this map
116   /// indicates which operands are the expanded version of the input.
117   SmallDenseMap<SDValue, std::pair<SDValue, SDValue>, 8> ExpandedFloats;
118
119   /// ScalarizedVectors - For nodes that are <1 x ty>, this map indicates the
120   /// scalar value of type 'ty' to use.
121   SmallDenseMap<SDValue, SDValue, 8> ScalarizedVectors;
122
123   /// SplitVectors - For nodes that need to be split this map indicates
124   /// which operands are the expanded version of the input.
125   SmallDenseMap<SDValue, std::pair<SDValue, SDValue>, 8> SplitVectors;
126
127   /// WidenedVectors - For vector nodes that need to be widened, indicates
128   /// the widened value to use.
129   SmallDenseMap<SDValue, SDValue, 8> WidenedVectors;
130
131   /// ReplacedValues - For values that have been replaced with another,
132   /// indicates the replacement value to use.
133   SmallDenseMap<SDValue, SDValue, 8> ReplacedValues;
134
135   /// Worklist - This defines a worklist of nodes to process.  In order to be
136   /// pushed onto this worklist, all operands of a node must have already been
137   /// processed.
138   SmallVector<SDNode*, 128> Worklist;
139
140 public:
141   explicit DAGTypeLegalizer(SelectionDAG &dag)
142     : TLI(dag.getTargetLoweringInfo()), DAG(dag),
143     ValueTypeActions(TLI.getValueTypeActions()) {
144     static_assert(MVT::LAST_VALUETYPE <= MVT::MAX_ALLOWED_VALUETYPE,
145                   "Too many value types for ValueTypeActions to hold!");
146   }
147
148   /// run - This is the main entry point for the type legalizer.  This does a
149   /// top-down traversal of the dag, legalizing types as it goes.  Returns
150   /// "true" if it made any changes.
151   bool run();
152
153   void NoteDeletion(SDNode *Old, SDNode *New) {
154     ExpungeNode(Old);
155     ExpungeNode(New);
156     for (unsigned i = 0, e = Old->getNumValues(); i != e; ++i)
157       ReplacedValues[SDValue(Old, i)] = SDValue(New, i);
158   }
159
160   SelectionDAG &getDAG() const { return DAG; }
161
162 private:
163   SDNode *AnalyzeNewNode(SDNode *N);
164   void AnalyzeNewValue(SDValue &Val);
165   void ExpungeNode(SDNode *N);
166   void PerformExpensiveChecks();
167   void RemapValue(SDValue &N);
168
169   // Common routines.
170   SDValue BitConvertToInteger(SDValue Op);
171   SDValue BitConvertVectorToIntegerVector(SDValue Op);
172   SDValue CreateStackStoreLoad(SDValue Op, EVT DestVT);
173   bool CustomLowerNode(SDNode *N, EVT VT, bool LegalizeResult);
174   bool CustomWidenLowerNode(SDNode *N, EVT VT);
175
176   /// DisintegrateMERGE_VALUES - Replace each result of the given MERGE_VALUES
177   /// node with the corresponding input operand, except for the result 'ResNo',
178   /// for which the corresponding input operand is returned.
179   SDValue DisintegrateMERGE_VALUES(SDNode *N, unsigned ResNo);
180
181   SDValue GetVectorElementPointer(SDValue VecPtr, EVT EltVT, SDValue Index);
182   SDValue JoinIntegers(SDValue Lo, SDValue Hi);
183   SDValue LibCallify(RTLIB::Libcall LC, SDNode *N, bool isSigned);
184
185   std::pair<SDValue, SDValue> ExpandChainLibCall(RTLIB::Libcall LC,
186                                                  SDNode *Node, bool isSigned);
187   std::pair<SDValue, SDValue> ExpandAtomic(SDNode *Node);
188
189   SDValue PromoteTargetBoolean(SDValue Bool, EVT ValVT);
190
191   /// Modify Bit Vector to match SetCC result type of ValVT.
192   /// The bit vector is widened with zeroes when WithZeroes is true.
193   SDValue WidenTargetBoolean(SDValue Bool, EVT ValVT, bool WithZeroes = false);
194
195   void ReplaceValueWith(SDValue From, SDValue To);
196   void SplitInteger(SDValue Op, SDValue &Lo, SDValue &Hi);
197   void SplitInteger(SDValue Op, EVT LoVT, EVT HiVT,
198                     SDValue &Lo, SDValue &Hi);
199
200   //===--------------------------------------------------------------------===//
201   // Integer Promotion Support: LegalizeIntegerTypes.cpp
202   //===--------------------------------------------------------------------===//
203
204   /// GetPromotedInteger - Given a processed operand Op which was promoted to a
205   /// larger integer type, this returns the promoted value.  The low bits of the
206   /// promoted value corresponding to the original type are exactly equal to Op.
207   /// The extra bits contain rubbish, so the promoted value may need to be zero-
208   /// or sign-extended from the original type before it is usable (the helpers
209   /// SExtPromotedInteger and ZExtPromotedInteger can do this for you).
210   /// For example, if Op is an i16 and was promoted to an i32, then this method
211   /// returns an i32, the lower 16 bits of which coincide with Op, and the upper
212   /// 16 bits of which contain rubbish.
213   SDValue GetPromotedInteger(SDValue Op) {
214     SDValue &PromotedOp = PromotedIntegers[Op];
215     RemapValue(PromotedOp);
216     assert(PromotedOp.getNode() && "Operand wasn't promoted?");
217     return PromotedOp;
218   }
219   void SetPromotedInteger(SDValue Op, SDValue Result);
220
221   /// SExtPromotedInteger - Get a promoted operand and sign extend it to the
222   /// final size.
223   SDValue SExtPromotedInteger(SDValue Op) {
224     EVT OldVT = Op.getValueType();
225     SDLoc dl(Op);
226     Op = GetPromotedInteger(Op);
227     return DAG.getNode(ISD::SIGN_EXTEND_INREG, dl, Op.getValueType(), Op,
228                        DAG.getValueType(OldVT));
229   }
230
231   /// ZExtPromotedInteger - Get a promoted operand and zero extend it to the
232   /// final size.
233   SDValue ZExtPromotedInteger(SDValue Op) {
234     EVT OldVT = Op.getValueType();
235     SDLoc dl(Op);
236     Op = GetPromotedInteger(Op);
237     return DAG.getZeroExtendInReg(Op, dl, OldVT.getScalarType());
238   }
239
240   // Integer Result Promotion.
241   void PromoteIntegerResult(SDNode *N, unsigned ResNo);
242   SDValue PromoteIntRes_MERGE_VALUES(SDNode *N, unsigned ResNo);
243   SDValue PromoteIntRes_AssertSext(SDNode *N);
244   SDValue PromoteIntRes_AssertZext(SDNode *N);
245   SDValue PromoteIntRes_Atomic0(AtomicSDNode *N);
246   SDValue PromoteIntRes_Atomic1(AtomicSDNode *N);
247   SDValue PromoteIntRes_AtomicCmpSwap(AtomicSDNode *N, unsigned ResNo);
248   SDValue PromoteIntRes_EXTRACT_SUBVECTOR(SDNode *N);
249   SDValue PromoteIntRes_VECTOR_SHUFFLE(SDNode *N);
250   SDValue PromoteIntRes_BUILD_VECTOR(SDNode *N);
251   SDValue PromoteIntRes_SCALAR_TO_VECTOR(SDNode *N);
252   SDValue PromoteIntRes_INSERT_VECTOR_ELT(SDNode *N);
253   SDValue PromoteIntRes_CONCAT_VECTORS(SDNode *N);
254   SDValue PromoteIntRes_BITCAST(SDNode *N);
255   SDValue PromoteIntRes_BSWAP(SDNode *N);
256   SDValue PromoteIntRes_BITREVERSE(SDNode *N);
257   SDValue PromoteIntRes_BUILD_PAIR(SDNode *N);
258   SDValue PromoteIntRes_Constant(SDNode *N);
259   SDValue PromoteIntRes_CONVERT_RNDSAT(SDNode *N);
260   SDValue PromoteIntRes_CTLZ(SDNode *N);
261   SDValue PromoteIntRes_CTPOP(SDNode *N);
262   SDValue PromoteIntRes_CTTZ(SDNode *N);
263   SDValue PromoteIntRes_EXTRACT_VECTOR_ELT(SDNode *N);
264   SDValue PromoteIntRes_FP_TO_XINT(SDNode *N);
265   SDValue PromoteIntRes_FP_TO_FP16(SDNode *N);
266   SDValue PromoteIntRes_INT_EXTEND(SDNode *N);
267   SDValue PromoteIntRes_LOAD(LoadSDNode *N);
268   SDValue PromoteIntRes_MLOAD(MaskedLoadSDNode *N);
269   SDValue PromoteIntRes_MGATHER(MaskedGatherSDNode *N);
270   SDValue PromoteIntRes_Overflow(SDNode *N);
271   SDValue PromoteIntRes_SADDSUBO(SDNode *N, unsigned ResNo);
272   SDValue PromoteIntRes_SDIV(SDNode *N);
273   SDValue PromoteIntRes_SELECT(SDNode *N);
274   SDValue PromoteIntRes_VSELECT(SDNode *N);
275   SDValue PromoteIntRes_SELECT_CC(SDNode *N);
276   SDValue PromoteIntRes_SETCC(SDNode *N);
277   SDValue PromoteIntRes_SHL(SDNode *N);
278   SDValue PromoteIntRes_SimpleIntBinOp(SDNode *N);
279   SDValue PromoteIntRes_SExtOrZExtIntBinOp(SDNode *N, bool Signed);
280   SDValue PromoteIntRes_SIGN_EXTEND_INREG(SDNode *N);
281   SDValue PromoteIntRes_SRA(SDNode *N);
282   SDValue PromoteIntRes_SRL(SDNode *N);
283   SDValue PromoteIntRes_TRUNCATE(SDNode *N);
284   SDValue PromoteIntRes_UADDSUBO(SDNode *N, unsigned ResNo);
285   SDValue PromoteIntRes_UDIV(SDNode *N);
286   SDValue PromoteIntRes_UNDEF(SDNode *N);
287   SDValue PromoteIntRes_VAARG(SDNode *N);
288   SDValue PromoteIntRes_XMULO(SDNode *N, unsigned ResNo);
289
290   // Integer Operand Promotion.
291   bool PromoteIntegerOperand(SDNode *N, unsigned OperandNo);
292   SDValue PromoteIntOp_ANY_EXTEND(SDNode *N);
293   SDValue PromoteIntOp_ATOMIC_STORE(AtomicSDNode *N);
294   SDValue PromoteIntOp_BITCAST(SDNode *N);
295   SDValue PromoteIntOp_BUILD_PAIR(SDNode *N);
296   SDValue PromoteIntOp_BR_CC(SDNode *N, unsigned OpNo);
297   SDValue PromoteIntOp_BRCOND(SDNode *N, unsigned OpNo);
298   SDValue PromoteIntOp_BUILD_VECTOR(SDNode *N);
299   SDValue PromoteIntOp_CONVERT_RNDSAT(SDNode *N);
300   SDValue PromoteIntOp_INSERT_VECTOR_ELT(SDNode *N, unsigned OpNo);
301   SDValue PromoteIntOp_EXTRACT_VECTOR_ELT(SDNode *N);
302   SDValue PromoteIntOp_EXTRACT_SUBVECTOR(SDNode *N);
303   SDValue PromoteIntOp_CONCAT_VECTORS(SDNode *N);
304   SDValue PromoteIntOp_SCALAR_TO_VECTOR(SDNode *N);
305   SDValue PromoteIntOp_SELECT(SDNode *N, unsigned OpNo);
306   SDValue PromoteIntOp_SELECT_CC(SDNode *N, unsigned OpNo);
307   SDValue PromoteIntOp_SETCC(SDNode *N, unsigned OpNo);
308   SDValue PromoteIntOp_Shift(SDNode *N);
309   SDValue PromoteIntOp_SIGN_EXTEND(SDNode *N);
310   SDValue PromoteIntOp_SINT_TO_FP(SDNode *N);
311   SDValue PromoteIntOp_STORE(StoreSDNode *N, unsigned OpNo);
312   SDValue PromoteIntOp_TRUNCATE(SDNode *N);
313   SDValue PromoteIntOp_UINT_TO_FP(SDNode *N);
314   SDValue PromoteIntOp_ZERO_EXTEND(SDNode *N);
315   SDValue PromoteIntOp_MSTORE(MaskedStoreSDNode *N, unsigned OpNo);
316   SDValue PromoteIntOp_MLOAD(MaskedLoadSDNode *N, unsigned OpNo);
317   SDValue PromoteIntOp_MSCATTER(MaskedScatterSDNode *N, unsigned OpNo);
318   SDValue PromoteIntOp_MGATHER(MaskedGatherSDNode *N, unsigned OpNo);
319
320   void PromoteSetCCOperands(SDValue &LHS,SDValue &RHS, ISD::CondCode Code);
321
322   //===--------------------------------------------------------------------===//
323   // Integer Expansion Support: LegalizeIntegerTypes.cpp
324   //===--------------------------------------------------------------------===//
325
326   /// GetExpandedInteger - Given a processed operand Op which was expanded into
327   /// two integers of half the size, this returns the two halves.  The low bits
328   /// of Op are exactly equal to the bits of Lo; the high bits exactly equal Hi.
329   /// For example, if Op is an i64 which was expanded into two i32's, then this
330   /// method returns the two i32's, with Lo being equal to the lower 32 bits of
331   /// Op, and Hi being equal to the upper 32 bits.
332   void GetExpandedInteger(SDValue Op, SDValue &Lo, SDValue &Hi);
333   void SetExpandedInteger(SDValue Op, SDValue Lo, SDValue Hi);
334
335   // Integer Result Expansion.
336   void ExpandIntegerResult(SDNode *N, unsigned ResNo);
337   void ExpandIntRes_ANY_EXTEND        (SDNode *N, SDValue &Lo, SDValue &Hi);
338   void ExpandIntRes_AssertSext        (SDNode *N, SDValue &Lo, SDValue &Hi);
339   void ExpandIntRes_AssertZext        (SDNode *N, SDValue &Lo, SDValue &Hi);
340   void ExpandIntRes_Constant          (SDNode *N, SDValue &Lo, SDValue &Hi);
341   void ExpandIntRes_CTLZ              (SDNode *N, SDValue &Lo, SDValue &Hi);
342   void ExpandIntRes_CTPOP             (SDNode *N, SDValue &Lo, SDValue &Hi);
343   void ExpandIntRes_CTTZ              (SDNode *N, SDValue &Lo, SDValue &Hi);
344   void ExpandIntRes_LOAD          (LoadSDNode *N, SDValue &Lo, SDValue &Hi);
345   void ExpandIntRes_READCYCLECOUNTER  (SDNode *N, SDValue &Lo, SDValue &Hi);
346   void ExpandIntRes_SIGN_EXTEND       (SDNode *N, SDValue &Lo, SDValue &Hi);
347   void ExpandIntRes_SIGN_EXTEND_INREG (SDNode *N, SDValue &Lo, SDValue &Hi);
348   void ExpandIntRes_TRUNCATE          (SDNode *N, SDValue &Lo, SDValue &Hi);
349   void ExpandIntRes_ZERO_EXTEND       (SDNode *N, SDValue &Lo, SDValue &Hi);
350   void ExpandIntRes_FP_TO_SINT        (SDNode *N, SDValue &Lo, SDValue &Hi);
351   void ExpandIntRes_FP_TO_UINT        (SDNode *N, SDValue &Lo, SDValue &Hi);
352
353   void ExpandIntRes_Logical           (SDNode *N, SDValue &Lo, SDValue &Hi);
354   void ExpandIntRes_ADDSUB            (SDNode *N, SDValue &Lo, SDValue &Hi);
355   void ExpandIntRes_ADDSUBC           (SDNode *N, SDValue &Lo, SDValue &Hi);
356   void ExpandIntRes_ADDSUBE           (SDNode *N, SDValue &Lo, SDValue &Hi);
357   void ExpandIntRes_BITREVERSE        (SDNode *N, SDValue &Lo, SDValue &Hi);
358   void ExpandIntRes_BSWAP             (SDNode *N, SDValue &Lo, SDValue &Hi);
359   void ExpandIntRes_MUL               (SDNode *N, SDValue &Lo, SDValue &Hi);
360   void ExpandIntRes_SDIV              (SDNode *N, SDValue &Lo, SDValue &Hi);
361   void ExpandIntRes_SREM              (SDNode *N, SDValue &Lo, SDValue &Hi);
362   void ExpandIntRes_UDIV              (SDNode *N, SDValue &Lo, SDValue &Hi);
363   void ExpandIntRes_UREM              (SDNode *N, SDValue &Lo, SDValue &Hi);
364   void ExpandIntRes_Shift             (SDNode *N, SDValue &Lo, SDValue &Hi);
365
366   void ExpandIntRes_SADDSUBO          (SDNode *N, SDValue &Lo, SDValue &Hi);
367   void ExpandIntRes_UADDSUBO          (SDNode *N, SDValue &Lo, SDValue &Hi);
368   void ExpandIntRes_XMULO             (SDNode *N, SDValue &Lo, SDValue &Hi);
369
370   void ExpandIntRes_ATOMIC_LOAD       (SDNode *N, SDValue &Lo, SDValue &Hi);
371
372   void ExpandShiftByConstant(SDNode *N, const APInt &Amt,
373                              SDValue &Lo, SDValue &Hi);
374   bool ExpandShiftWithKnownAmountBit(SDNode *N, SDValue &Lo, SDValue &Hi);
375   bool ExpandShiftWithUnknownAmountBit(SDNode *N, SDValue &Lo, SDValue &Hi);
376
377   // Integer Operand Expansion.
378   bool ExpandIntegerOperand(SDNode *N, unsigned OperandNo);
379   SDValue ExpandIntOp_BR_CC(SDNode *N);
380   SDValue ExpandIntOp_SELECT_CC(SDNode *N);
381   SDValue ExpandIntOp_SETCC(SDNode *N);
382   SDValue ExpandIntOp_SETCCE(SDNode *N);
383   SDValue ExpandIntOp_Shift(SDNode *N);
384   SDValue ExpandIntOp_SINT_TO_FP(SDNode *N);
385   SDValue ExpandIntOp_STORE(StoreSDNode *N, unsigned OpNo);
386   SDValue ExpandIntOp_TRUNCATE(SDNode *N);
387   SDValue ExpandIntOp_UINT_TO_FP(SDNode *N);
388   SDValue ExpandIntOp_RETURNADDR(SDNode *N);
389   SDValue ExpandIntOp_ATOMIC_STORE(SDNode *N);
390
391   void IntegerExpandSetCCOperands(SDValue &NewLHS, SDValue &NewRHS,
392                                   ISD::CondCode &CCCode, SDLoc dl);
393
394   //===--------------------------------------------------------------------===//
395   // Float to Integer Conversion Support: LegalizeFloatTypes.cpp
396   //===--------------------------------------------------------------------===//
397
398   /// GetSoftenedFloat - Given an operand Op of Float type, returns the integer
399   /// if the Op is not supported in target HW and converted to the integer.
400   /// The integer contains exactly the same bits as Op - only the type changed.
401   /// For example, if Op is an f32 which was softened to an i32, then this method
402   /// returns an i32, the bits of which coincide with those of Op.
403   /// If the Op can be efficiently supported in target HW or the operand must
404   /// stay in a register, the Op is not converted to an integer.
405   /// In that case, the given op is returned.
406   SDValue GetSoftenedFloat(SDValue Op) {
407     SDValue &SoftenedOp = SoftenedFloats[Op];
408     if (!SoftenedOp.getNode() &&
409         isSimpleLegalType(Op.getValueType()))
410       return Op;
411     RemapValue(SoftenedOp);
412     assert(SoftenedOp.getNode() && "Operand wasn't converted to integer?");
413     return SoftenedOp;
414   }
415   void SetSoftenedFloat(SDValue Op, SDValue Result);
416
417   // Call ReplaceValueWith(SDValue(N, ResNo), Res) if necessary.
418   void ReplaceSoftenFloatResult(SDNode *N, unsigned ResNo, SDValue &NewRes) {
419     // When the result type can be kept in HW registers, the converted
420     // NewRes node could have the same type. We can save the effort in
421     // cloning every user of N in SoftenFloatOperand or other legalization functions,
422     // by calling ReplaceValueWith here to update all users.
423     if (NewRes.getNode() != N && isLegalInHWReg(N->getValueType(ResNo)))
424       ReplaceValueWith(SDValue(N, ResNo), NewRes);
425   }
426
427   // Convert Float Results to Integer for Non-HW-supported Operations.
428   bool SoftenFloatResult(SDNode *N, unsigned ResNo);
429   SDValue SoftenFloatRes_MERGE_VALUES(SDNode *N, unsigned ResNo);
430   SDValue SoftenFloatRes_BITCAST(SDNode *N, unsigned ResNo);
431   SDValue SoftenFloatRes_BUILD_PAIR(SDNode *N);
432   SDValue SoftenFloatRes_ConstantFP(SDNode *N, unsigned ResNo);
433   SDValue SoftenFloatRes_EXTRACT_VECTOR_ELT(SDNode *N);
434   SDValue SoftenFloatRes_FABS(SDNode *N, unsigned ResNo);
435   SDValue SoftenFloatRes_FMINNUM(SDNode *N);
436   SDValue SoftenFloatRes_FMAXNUM(SDNode *N);
437   SDValue SoftenFloatRes_FADD(SDNode *N);
438   SDValue SoftenFloatRes_FCEIL(SDNode *N);
439   SDValue SoftenFloatRes_FCOPYSIGN(SDNode *N, unsigned ResNo);
440   SDValue SoftenFloatRes_FCOS(SDNode *N);
441   SDValue SoftenFloatRes_FDIV(SDNode *N);
442   SDValue SoftenFloatRes_FEXP(SDNode *N);
443   SDValue SoftenFloatRes_FEXP2(SDNode *N);
444   SDValue SoftenFloatRes_FFLOOR(SDNode *N);
445   SDValue SoftenFloatRes_FLOG(SDNode *N);
446   SDValue SoftenFloatRes_FLOG2(SDNode *N);
447   SDValue SoftenFloatRes_FLOG10(SDNode *N);
448   SDValue SoftenFloatRes_FMA(SDNode *N);
449   SDValue SoftenFloatRes_FMUL(SDNode *N);
450   SDValue SoftenFloatRes_FNEARBYINT(SDNode *N);
451   SDValue SoftenFloatRes_FNEG(SDNode *N, unsigned ResNo);
452   SDValue SoftenFloatRes_FP_EXTEND(SDNode *N);
453   SDValue SoftenFloatRes_FP16_TO_FP(SDNode *N);
454   SDValue SoftenFloatRes_FP_ROUND(SDNode *N);
455   SDValue SoftenFloatRes_FPOW(SDNode *N);
456   SDValue SoftenFloatRes_FPOWI(SDNode *N);
457   SDValue SoftenFloatRes_FREM(SDNode *N);
458   SDValue SoftenFloatRes_FRINT(SDNode *N);
459   SDValue SoftenFloatRes_FROUND(SDNode *N);
460   SDValue SoftenFloatRes_FSIN(SDNode *N);
461   SDValue SoftenFloatRes_FSQRT(SDNode *N);
462   SDValue SoftenFloatRes_FSUB(SDNode *N);
463   SDValue SoftenFloatRes_FTRUNC(SDNode *N);
464   SDValue SoftenFloatRes_LOAD(SDNode *N, unsigned ResNo);
465   SDValue SoftenFloatRes_SELECT(SDNode *N, unsigned ResNo);
466   SDValue SoftenFloatRes_SELECT_CC(SDNode *N, unsigned ResNo);
467   SDValue SoftenFloatRes_UNDEF(SDNode *N);
468   SDValue SoftenFloatRes_VAARG(SDNode *N);
469   SDValue SoftenFloatRes_XINT_TO_FP(SDNode *N);
470
471   // Return true if we can skip softening the given operand or SDNode because
472   // it was soften before by SoftenFloatResult and references to the operand
473   // were replaced by ReplaceValueWith.
474   bool CanSkipSoftenFloatOperand(SDNode *N, unsigned OpNo);
475
476   // Convert Float Operand to Integer for Non-HW-supported Operations.
477   bool SoftenFloatOperand(SDNode *N, unsigned OpNo);
478   SDValue SoftenFloatOp_BITCAST(SDNode *N);
479   SDValue SoftenFloatOp_BR_CC(SDNode *N);
480   SDValue SoftenFloatOp_FP_EXTEND(SDNode *N);
481   SDValue SoftenFloatOp_FP_ROUND(SDNode *N);
482   SDValue SoftenFloatOp_FP_TO_XINT(SDNode *N);
483   SDValue SoftenFloatOp_SELECT_CC(SDNode *N);
484   SDValue SoftenFloatOp_SETCC(SDNode *N);
485   SDValue SoftenFloatOp_STORE(SDNode *N, unsigned OpNo);
486
487   //===--------------------------------------------------------------------===//
488   // Float Expansion Support: LegalizeFloatTypes.cpp
489   //===--------------------------------------------------------------------===//
490
491   /// GetExpandedFloat - Given a processed operand Op which was expanded into
492   /// two floating point values of half the size, this returns the two halves.
493   /// The low bits of Op are exactly equal to the bits of Lo; the high bits
494   /// exactly equal Hi.  For example, if Op is a ppcf128 which was expanded
495   /// into two f64's, then this method returns the two f64's, with Lo being
496   /// equal to the lower 64 bits of Op, and Hi to the upper 64 bits.
497   void GetExpandedFloat(SDValue Op, SDValue &Lo, SDValue &Hi);
498   void SetExpandedFloat(SDValue Op, SDValue Lo, SDValue Hi);
499
500   // Float Result Expansion.
501   void ExpandFloatResult(SDNode *N, unsigned ResNo);
502   void ExpandFloatRes_ConstantFP(SDNode *N, SDValue &Lo, SDValue &Hi);
503   void ExpandFloatRes_FABS      (SDNode *N, SDValue &Lo, SDValue &Hi);
504   void ExpandFloatRes_FMINNUM   (SDNode *N, SDValue &Lo, SDValue &Hi);
505   void ExpandFloatRes_FMAXNUM   (SDNode *N, SDValue &Lo, SDValue &Hi);
506   void ExpandFloatRes_FADD      (SDNode *N, SDValue &Lo, SDValue &Hi);
507   void ExpandFloatRes_FCEIL     (SDNode *N, SDValue &Lo, SDValue &Hi);
508   void ExpandFloatRes_FCOPYSIGN (SDNode *N, SDValue &Lo, SDValue &Hi);
509   void ExpandFloatRes_FCOS      (SDNode *N, SDValue &Lo, SDValue &Hi);
510   void ExpandFloatRes_FDIV      (SDNode *N, SDValue &Lo, SDValue &Hi);
511   void ExpandFloatRes_FEXP      (SDNode *N, SDValue &Lo, SDValue &Hi);
512   void ExpandFloatRes_FEXP2     (SDNode *N, SDValue &Lo, SDValue &Hi);
513   void ExpandFloatRes_FFLOOR    (SDNode *N, SDValue &Lo, SDValue &Hi);
514   void ExpandFloatRes_FLOG      (SDNode *N, SDValue &Lo, SDValue &Hi);
515   void ExpandFloatRes_FLOG2     (SDNode *N, SDValue &Lo, SDValue &Hi);
516   void ExpandFloatRes_FLOG10    (SDNode *N, SDValue &Lo, SDValue &Hi);
517   void ExpandFloatRes_FMA       (SDNode *N, SDValue &Lo, SDValue &Hi);
518   void ExpandFloatRes_FMUL      (SDNode *N, SDValue &Lo, SDValue &Hi);
519   void ExpandFloatRes_FNEARBYINT(SDNode *N, SDValue &Lo, SDValue &Hi);
520   void ExpandFloatRes_FNEG      (SDNode *N, SDValue &Lo, SDValue &Hi);
521   void ExpandFloatRes_FP_EXTEND (SDNode *N, SDValue &Lo, SDValue &Hi);
522   void ExpandFloatRes_FPOW      (SDNode *N, SDValue &Lo, SDValue &Hi);
523   void ExpandFloatRes_FPOWI     (SDNode *N, SDValue &Lo, SDValue &Hi);
524   void ExpandFloatRes_FREM      (SDNode *N, SDValue &Lo, SDValue &Hi);
525   void ExpandFloatRes_FRINT     (SDNode *N, SDValue &Lo, SDValue &Hi);
526   void ExpandFloatRes_FROUND    (SDNode *N, SDValue &Lo, SDValue &Hi);
527   void ExpandFloatRes_FSIN      (SDNode *N, SDValue &Lo, SDValue &Hi);
528   void ExpandFloatRes_FSQRT     (SDNode *N, SDValue &Lo, SDValue &Hi);
529   void ExpandFloatRes_FSUB      (SDNode *N, SDValue &Lo, SDValue &Hi);
530   void ExpandFloatRes_FTRUNC    (SDNode *N, SDValue &Lo, SDValue &Hi);
531   void ExpandFloatRes_LOAD      (SDNode *N, SDValue &Lo, SDValue &Hi);
532   void ExpandFloatRes_XINT_TO_FP(SDNode *N, SDValue &Lo, SDValue &Hi);
533
534   // Float Operand Expansion.
535   bool ExpandFloatOperand(SDNode *N, unsigned OperandNo);
536   SDValue ExpandFloatOp_BR_CC(SDNode *N);
537   SDValue ExpandFloatOp_FCOPYSIGN(SDNode *N);
538   SDValue ExpandFloatOp_FP_ROUND(SDNode *N);
539   SDValue ExpandFloatOp_FP_TO_SINT(SDNode *N);
540   SDValue ExpandFloatOp_FP_TO_UINT(SDNode *N);
541   SDValue ExpandFloatOp_SELECT_CC(SDNode *N);
542   SDValue ExpandFloatOp_SETCC(SDNode *N);
543   SDValue ExpandFloatOp_STORE(SDNode *N, unsigned OpNo);
544
545   void FloatExpandSetCCOperands(SDValue &NewLHS, SDValue &NewRHS,
546                                 ISD::CondCode &CCCode, SDLoc dl);
547
548
549   //===--------------------------------------------------------------------===//
550   // Float promotion support: LegalizeFloatTypes.cpp
551   //===--------------------------------------------------------------------===//
552
553   SDValue GetPromotedFloat(SDValue Op) {
554     SDValue &PromotedOp = PromotedFloats[Op];
555     RemapValue(PromotedOp);
556     assert(PromotedOp.getNode() && "Operand wasn't promoted?");
557     return PromotedOp;
558   }
559   void SetPromotedFloat(SDValue Op, SDValue Result);
560
561   void PromoteFloatResult(SDNode *N, unsigned ResNo);
562   SDValue PromoteFloatRes_BITCAST(SDNode *N);
563   SDValue PromoteFloatRes_BinOp(SDNode *N);
564   SDValue PromoteFloatRes_ConstantFP(SDNode *N);
565   SDValue PromoteFloatRes_EXTRACT_VECTOR_ELT(SDNode *N);
566   SDValue PromoteFloatRes_FCOPYSIGN(SDNode *N);
567   SDValue PromoteFloatRes_FMAD(SDNode *N);
568   SDValue PromoteFloatRes_FPOWI(SDNode *N);
569   SDValue PromoteFloatRes_FP_ROUND(SDNode *N);
570   SDValue PromoteFloatRes_LOAD(SDNode *N);
571   SDValue PromoteFloatRes_SELECT(SDNode *N);
572   SDValue PromoteFloatRes_SELECT_CC(SDNode *N);
573   SDValue PromoteFloatRes_UnaryOp(SDNode *N);
574   SDValue PromoteFloatRes_UNDEF(SDNode *N);
575   SDValue PromoteFloatRes_XINT_TO_FP(SDNode *N);
576
577   bool PromoteFloatOperand(SDNode *N, unsigned ResNo);
578   SDValue PromoteFloatOp_BITCAST(SDNode *N, unsigned OpNo);
579   SDValue PromoteFloatOp_FCOPYSIGN(SDNode *N, unsigned OpNo);
580   SDValue PromoteFloatOp_FP_EXTEND(SDNode *N, unsigned OpNo);
581   SDValue PromoteFloatOp_FP_TO_XINT(SDNode *N, unsigned OpNo);
582   SDValue PromoteFloatOp_STORE(SDNode *N, unsigned OpNo);
583   SDValue PromoteFloatOp_SELECT_CC(SDNode *N, unsigned OpNo);
584   SDValue PromoteFloatOp_SETCC(SDNode *N, unsigned OpNo);
585
586   //===--------------------------------------------------------------------===//
587   // Scalarization Support: LegalizeVectorTypes.cpp
588   //===--------------------------------------------------------------------===//
589
590   /// GetScalarizedVector - Given a processed one-element vector Op which was
591   /// scalarized to its element type, this returns the element.  For example,
592   /// if Op is a v1i32, Op = < i32 val >, this method returns val, an i32.
593   SDValue GetScalarizedVector(SDValue Op) {
594     SDValue &ScalarizedOp = ScalarizedVectors[Op];
595     RemapValue(ScalarizedOp);
596     assert(ScalarizedOp.getNode() && "Operand wasn't scalarized?");
597     return ScalarizedOp;
598   }
599   void SetScalarizedVector(SDValue Op, SDValue Result);
600
601   // Vector Result Scalarization: <1 x ty> -> ty.
602   void ScalarizeVectorResult(SDNode *N, unsigned OpNo);
603   SDValue ScalarizeVecRes_MERGE_VALUES(SDNode *N, unsigned ResNo);
604   SDValue ScalarizeVecRes_BinOp(SDNode *N);
605   SDValue ScalarizeVecRes_TernaryOp(SDNode *N);
606   SDValue ScalarizeVecRes_UnaryOp(SDNode *N);
607   SDValue ScalarizeVecRes_InregOp(SDNode *N);
608
609   SDValue ScalarizeVecRes_BITCAST(SDNode *N);
610   SDValue ScalarizeVecRes_BUILD_VECTOR(SDNode *N);
611   SDValue ScalarizeVecRes_CONVERT_RNDSAT(SDNode *N);
612   SDValue ScalarizeVecRes_EXTRACT_SUBVECTOR(SDNode *N);
613   SDValue ScalarizeVecRes_FP_ROUND(SDNode *N);
614   SDValue ScalarizeVecRes_FPOWI(SDNode *N);
615   SDValue ScalarizeVecRes_INSERT_VECTOR_ELT(SDNode *N);
616   SDValue ScalarizeVecRes_LOAD(LoadSDNode *N);
617   SDValue ScalarizeVecRes_SCALAR_TO_VECTOR(SDNode *N);
618   SDValue ScalarizeVecRes_VSELECT(SDNode *N);
619   SDValue ScalarizeVecRes_SELECT(SDNode *N);
620   SDValue ScalarizeVecRes_SELECT_CC(SDNode *N);
621   SDValue ScalarizeVecRes_SETCC(SDNode *N);
622   SDValue ScalarizeVecRes_UNDEF(SDNode *N);
623   SDValue ScalarizeVecRes_VECTOR_SHUFFLE(SDNode *N);
624   SDValue ScalarizeVecRes_VSETCC(SDNode *N);
625
626   // Vector Operand Scalarization: <1 x ty> -> ty.
627   bool ScalarizeVectorOperand(SDNode *N, unsigned OpNo);
628   SDValue ScalarizeVecOp_BITCAST(SDNode *N);
629   SDValue ScalarizeVecOp_UnaryOp(SDNode *N);
630   SDValue ScalarizeVecOp_CONCAT_VECTORS(SDNode *N);
631   SDValue ScalarizeVecOp_EXTRACT_VECTOR_ELT(SDNode *N);
632   SDValue ScalarizeVecOp_VSELECT(SDNode *N);
633   SDValue ScalarizeVecOp_STORE(StoreSDNode *N, unsigned OpNo);
634   SDValue ScalarizeVecOp_FP_ROUND(SDNode *N, unsigned OpNo);
635
636   //===--------------------------------------------------------------------===//
637   // Vector Splitting Support: LegalizeVectorTypes.cpp
638   //===--------------------------------------------------------------------===//
639
640   /// GetSplitVector - Given a processed vector Op which was split into vectors
641   /// of half the size, this method returns the halves.  The first elements of
642   /// Op coincide with the elements of Lo; the remaining elements of Op coincide
643   /// with the elements of Hi: Op is what you would get by concatenating Lo and
644   /// Hi.  For example, if Op is a v8i32 that was split into two v4i32's, then
645   /// this method returns the two v4i32's, with Lo corresponding to the first 4
646   /// elements of Op, and Hi to the last 4 elements.
647   void GetSplitVector(SDValue Op, SDValue &Lo, SDValue &Hi);
648   void SetSplitVector(SDValue Op, SDValue Lo, SDValue Hi);
649
650   // Vector Result Splitting: <128 x ty> -> 2 x <64 x ty>.
651   void SplitVectorResult(SDNode *N, unsigned OpNo);
652   void SplitVecRes_BinOp(SDNode *N, SDValue &Lo, SDValue &Hi);
653   void SplitVecRes_TernaryOp(SDNode *N, SDValue &Lo, SDValue &Hi);
654   void SplitVecRes_UnaryOp(SDNode *N, SDValue &Lo, SDValue &Hi);
655   void SplitVecRes_ExtendOp(SDNode *N, SDValue &Lo, SDValue &Hi);
656   void SplitVecRes_InregOp(SDNode *N, SDValue &Lo, SDValue &Hi);
657
658   void SplitVecRes_BITCAST(SDNode *N, SDValue &Lo, SDValue &Hi);
659   void SplitVecRes_BUILD_VECTOR(SDNode *N, SDValue &Lo, SDValue &Hi);
660   void SplitVecRes_CONCAT_VECTORS(SDNode *N, SDValue &Lo, SDValue &Hi);
661   void SplitVecRes_EXTRACT_SUBVECTOR(SDNode *N, SDValue &Lo, SDValue &Hi);
662   void SplitVecRes_INSERT_SUBVECTOR(SDNode *N, SDValue &Lo, SDValue &Hi);
663   void SplitVecRes_FPOWI(SDNode *N, SDValue &Lo, SDValue &Hi);
664   void SplitVecRes_FCOPYSIGN(SDNode *N, SDValue &Lo, SDValue &Hi);
665   void SplitVecRes_INSERT_VECTOR_ELT(SDNode *N, SDValue &Lo, SDValue &Hi);
666   void SplitVecRes_LOAD(LoadSDNode *N, SDValue &Lo, SDValue &Hi);
667   void SplitVecRes_MLOAD(MaskedLoadSDNode *N, SDValue &Lo, SDValue &Hi);
668   void SplitVecRes_MGATHER(MaskedGatherSDNode *N, SDValue &Lo, SDValue &Hi);
669   void SplitVecRes_SCALAR_TO_VECTOR(SDNode *N, SDValue &Lo, SDValue &Hi);
670   void SplitVecRes_SETCC(SDNode *N, SDValue &Lo, SDValue &Hi);
671   void SplitVecRes_VECTOR_SHUFFLE(ShuffleVectorSDNode *N, SDValue &Lo,
672                                   SDValue &Hi);
673
674   // Vector Operand Splitting: <128 x ty> -> 2 x <64 x ty>.
675   bool SplitVectorOperand(SDNode *N, unsigned OpNo);
676   SDValue SplitVecOp_VSELECT(SDNode *N, unsigned OpNo);
677   SDValue SplitVecOp_UnaryOp(SDNode *N);
678   SDValue SplitVecOp_TruncateHelper(SDNode *N);
679
680   SDValue SplitVecOp_BITCAST(SDNode *N);
681   SDValue SplitVecOp_EXTRACT_SUBVECTOR(SDNode *N);
682   SDValue SplitVecOp_EXTRACT_VECTOR_ELT(SDNode *N);
683   SDValue SplitVecOp_STORE(StoreSDNode *N, unsigned OpNo);
684   SDValue SplitVecOp_MSTORE(MaskedStoreSDNode *N, unsigned OpNo);
685   SDValue SplitVecOp_MSCATTER(MaskedScatterSDNode *N, unsigned OpNo);
686   SDValue SplitVecOp_MGATHER(MaskedGatherSDNode *N, unsigned OpNo);
687   SDValue SplitVecOp_CONCAT_VECTORS(SDNode *N);
688   SDValue SplitVecOp_VSETCC(SDNode *N);
689   SDValue SplitVecOp_FP_ROUND(SDNode *N);
690   SDValue SplitVecOp_FCOPYSIGN(SDNode *N);
691
692   //===--------------------------------------------------------------------===//
693   // Vector Widening Support: LegalizeVectorTypes.cpp
694   //===--------------------------------------------------------------------===//
695
696   /// GetWidenedVector - Given a processed vector Op which was widened into a
697   /// larger vector, this method returns the larger vector.  The elements of
698   /// the returned vector consist of the elements of Op followed by elements
699   /// containing rubbish.  For example, if Op is a v2i32 that was widened to a
700   /// v4i32, then this method returns a v4i32 for which the first two elements
701   /// are the same as those of Op, while the last two elements contain rubbish.
702   SDValue GetWidenedVector(SDValue Op) {
703     SDValue &WidenedOp = WidenedVectors[Op];
704     RemapValue(WidenedOp);
705     assert(WidenedOp.getNode() && "Operand wasn't widened?");
706     return WidenedOp;
707   }
708   void SetWidenedVector(SDValue Op, SDValue Result);
709
710   // Widen Vector Result Promotion.
711   void WidenVectorResult(SDNode *N, unsigned ResNo);
712   SDValue WidenVecRes_MERGE_VALUES(SDNode* N, unsigned ResNo);
713   SDValue WidenVecRes_BITCAST(SDNode* N);
714   SDValue WidenVecRes_BUILD_VECTOR(SDNode* N);
715   SDValue WidenVecRes_CONCAT_VECTORS(SDNode* N);
716   SDValue WidenVecRes_CONVERT_RNDSAT(SDNode* N);
717   SDValue WidenVecRes_EXTRACT_SUBVECTOR(SDNode* N);
718   SDValue WidenVecRes_INSERT_VECTOR_ELT(SDNode* N);
719   SDValue WidenVecRes_LOAD(SDNode* N);
720   SDValue WidenVecRes_MLOAD(MaskedLoadSDNode* N);
721   SDValue WidenVecRes_MGATHER(MaskedGatherSDNode* N);
722   SDValue WidenVecRes_SCALAR_TO_VECTOR(SDNode* N);
723   SDValue WidenVecRes_SELECT(SDNode* N);
724   SDValue WidenVecRes_SELECT_CC(SDNode* N);
725   SDValue WidenVecRes_SETCC(SDNode* N);
726   SDValue WidenVecRes_UNDEF(SDNode *N);
727   SDValue WidenVecRes_VECTOR_SHUFFLE(ShuffleVectorSDNode *N);
728   SDValue WidenVecRes_VSETCC(SDNode* N);
729
730   SDValue WidenVecRes_Ternary(SDNode *N);
731   SDValue WidenVecRes_Binary(SDNode *N);
732   SDValue WidenVecRes_BinaryCanTrap(SDNode *N);
733   SDValue WidenVecRes_Convert(SDNode *N);
734   SDValue WidenVecRes_FCOPYSIGN(SDNode *N);
735   SDValue WidenVecRes_POWI(SDNode *N);
736   SDValue WidenVecRes_Shift(SDNode *N);
737   SDValue WidenVecRes_Unary(SDNode *N);
738   SDValue WidenVecRes_InregOp(SDNode *N);
739
740   // Widen Vector Operand.
741   bool WidenVectorOperand(SDNode *N, unsigned OpNo);
742   SDValue WidenVecOp_BITCAST(SDNode *N);
743   SDValue WidenVecOp_CONCAT_VECTORS(SDNode *N);
744   SDValue WidenVecOp_EXTEND(SDNode *N);
745   SDValue WidenVecOp_EXTRACT_VECTOR_ELT(SDNode *N);
746   SDValue WidenVecOp_EXTRACT_SUBVECTOR(SDNode *N);
747   SDValue WidenVecOp_STORE(SDNode* N);
748   SDValue WidenVecOp_MSTORE(SDNode* N, unsigned OpNo);
749   SDValue WidenVecOp_MSCATTER(SDNode* N, unsigned OpNo);
750   SDValue WidenVecOp_SETCC(SDNode* N);
751
752   SDValue WidenVecOp_Convert(SDNode *N);
753   SDValue WidenVecOp_FCOPYSIGN(SDNode *N);
754
755   //===--------------------------------------------------------------------===//
756   // Vector Widening Utilities Support: LegalizeVectorTypes.cpp
757   //===--------------------------------------------------------------------===//
758
759   /// Helper GenWidenVectorLoads - Helper function to generate a set of
760   /// loads to load a vector with a resulting wider type. It takes
761   ///   LdChain: list of chains for the load to be generated.
762   ///   Ld:      load to widen
763   SDValue GenWidenVectorLoads(SmallVectorImpl<SDValue> &LdChain,
764                               LoadSDNode *LD);
765
766   /// GenWidenVectorExtLoads - Helper function to generate a set of extension
767   /// loads to load a ector with a resulting wider type.  It takes
768   ///   LdChain: list of chains for the load to be generated.
769   ///   Ld:      load to widen
770   ///   ExtType: extension element type
771   SDValue GenWidenVectorExtLoads(SmallVectorImpl<SDValue> &LdChain,
772                                  LoadSDNode *LD, ISD::LoadExtType ExtType);
773
774   /// Helper genWidenVectorStores - Helper function to generate a set of
775   /// stores to store a widen vector into non-widen memory
776   ///   StChain: list of chains for the stores we have generated
777   ///   ST:      store of a widen value
778   void GenWidenVectorStores(SmallVectorImpl<SDValue> &StChain, StoreSDNode *ST);
779
780   /// Helper genWidenVectorTruncStores - Helper function to generate a set of
781   /// stores to store a truncate widen vector into non-widen memory
782   ///   StChain: list of chains for the stores we have generated
783   ///   ST:      store of a widen value
784   void GenWidenVectorTruncStores(SmallVectorImpl<SDValue> &StChain,
785                                  StoreSDNode *ST);
786
787   /// Modifies a vector input (widen or narrows) to a vector of NVT.  The
788   /// input vector must have the same element type as NVT.
789   /// When FillWithZeroes is "on" the vector will be widened with
790   /// zeroes.
791   /// By default, the vector will be widened with undefined values.
792   SDValue ModifyToType(SDValue InOp, EVT NVT, bool FillWithZeroes = false);
793
794   //===--------------------------------------------------------------------===//
795   // Generic Splitting: LegalizeTypesGeneric.cpp
796   //===--------------------------------------------------------------------===//
797
798   // Legalization methods which only use that the illegal type is split into two
799   // not necessarily identical types.  As such they can be used for splitting
800   // vectors and expanding integers and floats.
801
802   void GetSplitOp(SDValue Op, SDValue &Lo, SDValue &Hi) {
803     if (Op.getValueType().isVector())
804       GetSplitVector(Op, Lo, Hi);
805     else if (Op.getValueType().isInteger())
806       GetExpandedInteger(Op, Lo, Hi);
807     else
808       GetExpandedFloat(Op, Lo, Hi);
809   }
810
811   /// GetPairElements - Use ISD::EXTRACT_ELEMENT nodes to extract the low and
812   /// high parts of the given value.
813   void GetPairElements(SDValue Pair, SDValue &Lo, SDValue &Hi);
814
815   // Generic Result Splitting.
816   void SplitRes_MERGE_VALUES(SDNode *N, unsigned ResNo,
817                              SDValue &Lo, SDValue &Hi);
818   void SplitRes_SELECT      (SDNode *N, SDValue &Lo, SDValue &Hi);
819   void SplitRes_SELECT_CC   (SDNode *N, SDValue &Lo, SDValue &Hi);
820   void SplitRes_UNDEF       (SDNode *N, SDValue &Lo, SDValue &Hi);
821
822   //===--------------------------------------------------------------------===//
823   // Generic Expansion: LegalizeTypesGeneric.cpp
824   //===--------------------------------------------------------------------===//
825
826   // Legalization methods which only use that the illegal type is split into two
827   // identical types of half the size, and that the Lo/Hi part is stored first
828   // in memory on little/big-endian machines, followed by the Hi/Lo part.  As
829   // such they can be used for expanding integers and floats.
830
831   void GetExpandedOp(SDValue Op, SDValue &Lo, SDValue &Hi) {
832     if (Op.getValueType().isInteger())
833       GetExpandedInteger(Op, Lo, Hi);
834     else
835       GetExpandedFloat(Op, Lo, Hi);
836   }
837
838
839   /// This function will split the integer \p Op into \p NumElements
840   /// operations of type \p EltVT and store them in \p Ops.
841   void IntegerToVector(SDValue Op, unsigned NumElements,
842                        SmallVectorImpl<SDValue> &Ops, EVT EltVT);
843
844   // Generic Result Expansion.
845   void ExpandRes_MERGE_VALUES      (SDNode *N, unsigned ResNo,
846                                     SDValue &Lo, SDValue &Hi);
847   void ExpandRes_BITCAST           (SDNode *N, SDValue &Lo, SDValue &Hi);
848   void ExpandRes_BUILD_PAIR        (SDNode *N, SDValue &Lo, SDValue &Hi);
849   void ExpandRes_EXTRACT_ELEMENT   (SDNode *N, SDValue &Lo, SDValue &Hi);
850   void ExpandRes_EXTRACT_VECTOR_ELT(SDNode *N, SDValue &Lo, SDValue &Hi);
851   void ExpandRes_NormalLoad        (SDNode *N, SDValue &Lo, SDValue &Hi);
852   void ExpandRes_VAARG             (SDNode *N, SDValue &Lo, SDValue &Hi);
853
854   // Generic Operand Expansion.
855   SDValue ExpandOp_BITCAST          (SDNode *N);
856   SDValue ExpandOp_BUILD_VECTOR     (SDNode *N);
857   SDValue ExpandOp_EXTRACT_ELEMENT  (SDNode *N);
858   SDValue ExpandOp_INSERT_VECTOR_ELT(SDNode *N);
859   SDValue ExpandOp_SCALAR_TO_VECTOR (SDNode *N);
860   SDValue ExpandOp_NormalStore      (SDNode *N, unsigned OpNo);
861 };
862
863 } // end namespace llvm.
864
865 #endif