LegalizeTypes.h revision b5508e423727b2c56a136cb1a20647f831d53982
1//===-- LegalizeTypes.h - Definition of the DAG Type Legalizer class ------===//
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 SELECTIONDAG_LEGALIZETYPES_H
17#define SELECTIONDAG_LEGALIZETYPES_H
18
19#define DEBUG_TYPE "legalize-types"
20#include "llvm/CodeGen/SelectionDAG.h"
21#include "llvm/Target/TargetLowering.h"
22#include "llvm/ADT/DenseMap.h"
23#include "llvm/Support/Compiler.h"
24#include "llvm/Support/Debug.h"
25
26namespace llvm {
27
28//===----------------------------------------------------------------------===//
29/// DAGTypeLegalizer - This takes an arbitrary SelectionDAG as input and
30/// hacks on it until the target machine can handle it.  This involves
31/// eliminating value sizes the machine cannot handle (promoting small sizes to
32/// large sizes or splitting up large values into small values) as well as
33/// eliminating operations the machine cannot handle.
34///
35/// This code also does a small amount of optimization and recognition of idioms
36/// as part of its processing.  For example, if a target does not support a
37/// 'setcc' instruction efficiently, but does support 'brcc' instruction, this
38/// will attempt merge setcc and brc instructions into brcc's.
39///
40class VISIBILITY_HIDDEN DAGTypeLegalizer {
41  TargetLowering &TLI;
42  SelectionDAG &DAG;
43public:
44  // NodeIDFlags - This pass uses the NodeID on the SDNodes to hold information
45  // about the state of the node.  The enum has all the values.
46  enum NodeIDFlags {
47    /// ReadyToProcess - All operands have been processed, so this node is ready
48    /// to be handled.
49    ReadyToProcess = 0,
50
51    /// NewNode - This is a new node that was created in the process of
52    /// legalizing some other node.
53    NewNode = -1,
54
55    /// Processed - This is a node that has already been processed.
56    Processed = -2
57
58    // 1+ - This is a node which has this many unlegalized operands.
59  };
60private:
61  enum LegalizeAction {
62    Legal,          // The target natively supports this type.
63    PromoteInteger, // Replace this integer type with a larger one.
64    ExpandInteger,  // Split this integer type into two of half the size.
65    SoftenFloat,    // Convert this float type to a same size integer type.
66    ExpandFloat,    // Split this float type into two of half the size.
67    Scalarize,      // Replace this one-element vector type with its element type.
68    Split           // This vector type should be split into smaller vectors.
69  };
70
71  /// ValueTypeActions - This is a bitvector that contains two bits for each
72  /// simple value type, where the two bits correspond to the LegalizeAction
73  /// enum from TargetLowering.  This can be queried with "getTypeAction(VT)".
74  TargetLowering::ValueTypeActionImpl ValueTypeActions;
75
76  /// getTypeAction - Return how we should legalize values of this type, either
77  /// it is already legal, or we need to promote it to a larger integer type, or
78  /// we need to expand it into multiple registers of a smaller integer type, or
79  /// we need to scalarize a one-element vector type into the element type, or
80  /// we need to split a vector type into smaller vector types.
81  LegalizeAction getTypeAction(MVT VT) const {
82    switch (ValueTypeActions.getTypeAction(VT)) {
83    default:
84      assert(false && "Unknown legalize action!");
85    case TargetLowering::Legal:
86      return Legal;
87    case TargetLowering::Promote:
88      return PromoteInteger;
89    case TargetLowering::Expand:
90      // Expand can mean
91      // 1) split scalar in half, 2) convert a float to an integer,
92      // 3) scalarize a single-element vector, 4) split a vector in two.
93      if (!VT.isVector()) {
94        if (VT.isInteger())
95          return ExpandInteger;
96        else if (VT.getSizeInBits() ==
97                 TLI.getTypeToTransformTo(VT).getSizeInBits())
98          return SoftenFloat;
99        else
100          return ExpandFloat;
101      } else if (VT.getVectorNumElements() == 1) {
102        return Scalarize;
103      } else {
104        return Split;
105      }
106    }
107  }
108
109  /// isTypeLegal - Return true if this type is legal on this target.
110  bool isTypeLegal(MVT VT) const {
111    return ValueTypeActions.getTypeAction(VT) == TargetLowering::Legal;
112  }
113
114  /// PromotedIntegers - For integer nodes that are below legal width, this map
115  /// indicates what promoted value to use.
116  DenseMap<SDOperand, SDOperand> PromotedIntegers;
117
118  /// ExpandedIntegers - For integer nodes that need to be expanded this map
119  /// indicates which operands are the expanded version of the input.
120  DenseMap<SDOperand, std::pair<SDOperand, SDOperand> > ExpandedIntegers;
121
122  /// SoftenedFloats - For floating point nodes converted to integers of
123  /// the same size, this map indicates the converted value to use.
124  DenseMap<SDOperand, SDOperand> SoftenedFloats;
125
126  /// ExpandedFloats - For float nodes that need to be expanded this map
127  /// indicates which operands are the expanded version of the input.
128  DenseMap<SDOperand, std::pair<SDOperand, SDOperand> > ExpandedFloats;
129
130  /// ScalarizedVectors - For nodes that are <1 x ty>, this map indicates the
131  /// scalar value of type 'ty' to use.
132  DenseMap<SDOperand, SDOperand> ScalarizedVectors;
133
134  /// SplitVectors - For nodes that need to be split this map indicates
135  /// which operands are the expanded version of the input.
136  DenseMap<SDOperand, std::pair<SDOperand, SDOperand> > SplitVectors;
137
138  /// ReplacedNodes - For nodes that have been replaced with another,
139  /// indicates the replacement node to use.
140  DenseMap<SDOperand, SDOperand> ReplacedNodes;
141
142  /// Worklist - This defines a worklist of nodes to process.  In order to be
143  /// pushed onto this worklist, all operands of a node must have already been
144  /// processed.
145  SmallVector<SDNode*, 128> Worklist;
146
147public:
148  explicit DAGTypeLegalizer(SelectionDAG &dag)
149    : TLI(dag.getTargetLoweringInfo()), DAG(dag),
150    ValueTypeActions(TLI.getValueTypeActions()) {
151    assert(MVT::LAST_VALUETYPE <= 32 &&
152           "Too many value types for ValueTypeActions to hold!");
153  }
154
155  void run();
156
157  /// ReanalyzeNode - Recompute the NodeID and correct processed operands
158  /// for the specified node, adding it to the worklist if ready.
159  void ReanalyzeNode(SDNode *N) {
160    N->setNodeId(NewNode);
161    AnalyzeNewNode(N);
162  }
163
164  void NoteDeletion(SDNode *Old, SDNode *New) {
165    ExpungeNode(Old);
166    ExpungeNode(New);
167    for (unsigned i = 0, e = Old->getNumValues(); i != e; ++i)
168      ReplacedNodes[SDOperand(Old, i)] = SDOperand(New, i);
169  }
170
171private:
172  void AnalyzeNewNode(SDNode *&N);
173
174  void ReplaceValueWith(SDOperand From, SDOperand To);
175  void ReplaceNodeWith(SDNode *From, SDNode *To);
176
177  void RemapNode(SDOperand &N);
178  void ExpungeNode(SDNode *N);
179
180  // Common routines.
181  SDOperand CreateStackStoreLoad(SDOperand Op, MVT DestVT);
182  SDOperand MakeLibCall(RTLIB::Libcall LC, MVT RetVT,
183                        const SDOperand *Ops, unsigned NumOps, bool isSigned);
184
185  SDOperand BitConvertToInteger(SDOperand Op);
186  SDOperand JoinIntegers(SDOperand Lo, SDOperand Hi);
187  void SplitInteger(SDOperand Op, SDOperand &Lo, SDOperand &Hi);
188  void SplitInteger(SDOperand Op, MVT LoVT, MVT HiVT,
189                    SDOperand &Lo, SDOperand &Hi);
190
191  SDOperand GetVectorElementPointer(SDOperand VecPtr, MVT EltVT,
192                                    SDOperand Index);
193
194  //===--------------------------------------------------------------------===//
195  // Integer Promotion Support: LegalizeIntegerTypes.cpp
196  //===--------------------------------------------------------------------===//
197
198  SDOperand GetPromotedInteger(SDOperand Op) {
199    SDOperand &PromotedOp = PromotedIntegers[Op];
200    RemapNode(PromotedOp);
201    assert(PromotedOp.Val && "Operand wasn't promoted?");
202    return PromotedOp;
203  }
204  void SetPromotedInteger(SDOperand Op, SDOperand Result);
205
206  /// ZExtPromotedInteger - Get a promoted operand and zero extend it to the
207  /// final size.
208  SDOperand ZExtPromotedInteger(SDOperand Op) {
209    MVT OldVT = Op.getValueType();
210    Op = GetPromotedInteger(Op);
211    return DAG.getZeroExtendInReg(Op, OldVT);
212  }
213
214  // Integer Result Promotion.
215  void PromoteIntegerResult(SDNode *N, unsigned ResNo);
216  SDOperand PromoteIntRes_BIT_CONVERT(SDNode *N);
217  SDOperand PromoteIntRes_BUILD_PAIR(SDNode *N);
218  SDOperand PromoteIntRes_Constant(SDNode *N);
219  SDOperand PromoteIntRes_CTLZ(SDNode *N);
220  SDOperand PromoteIntRes_CTPOP(SDNode *N);
221  SDOperand PromoteIntRes_CTTZ(SDNode *N);
222  SDOperand PromoteIntRes_EXTRACT_VECTOR_ELT(SDNode *N);
223  SDOperand PromoteIntRes_FP_ROUND(SDNode *N);
224  SDOperand PromoteIntRes_FP_TO_XINT(SDNode *N);
225  SDOperand PromoteIntRes_INT_EXTEND(SDNode *N);
226  SDOperand PromoteIntRes_LOAD(LoadSDNode *N);
227  SDOperand PromoteIntRes_SDIV(SDNode *N);
228  SDOperand PromoteIntRes_SELECT   (SDNode *N);
229  SDOperand PromoteIntRes_SELECT_CC(SDNode *N);
230  SDOperand PromoteIntRes_SETCC(SDNode *N);
231  SDOperand PromoteIntRes_SHL(SDNode *N);
232  SDOperand PromoteIntRes_SimpleIntBinOp(SDNode *N);
233  SDOperand PromoteIntRes_SRA(SDNode *N);
234  SDOperand PromoteIntRes_SRL(SDNode *N);
235  SDOperand PromoteIntRes_TRUNCATE(SDNode *N);
236  SDOperand PromoteIntRes_UDIV(SDNode *N);
237  SDOperand PromoteIntRes_UNDEF(SDNode *N);
238  SDOperand PromoteIntRes_VAARG(SDNode *N);
239
240  // Integer Operand Promotion.
241  bool PromoteIntegerOperand(SDNode *N, unsigned OperandNo);
242  SDOperand PromoteIntOp_ANY_EXTEND(SDNode *N);
243  SDOperand PromoteIntOp_BUILD_PAIR(SDNode *N);
244  SDOperand PromoteIntOp_BR_CC(SDNode *N, unsigned OpNo);
245  SDOperand PromoteIntOp_BRCOND(SDNode *N, unsigned OpNo);
246  SDOperand PromoteIntOp_BUILD_VECTOR(SDNode *N);
247  SDOperand PromoteIntOp_FP_EXTEND(SDNode *N);
248  SDOperand PromoteIntOp_FP_ROUND(SDNode *N);
249  SDOperand PromoteIntOp_INT_TO_FP(SDNode *N);
250  SDOperand PromoteIntOp_INSERT_VECTOR_ELT(SDNode *N, unsigned OpNo);
251  SDOperand PromoteIntOp_MEMBARRIER(SDNode *N);
252  SDOperand PromoteIntOp_SELECT(SDNode *N, unsigned OpNo);
253  SDOperand PromoteIntOp_SELECT_CC(SDNode *N, unsigned OpNo);
254  SDOperand PromoteIntOp_SETCC(SDNode *N, unsigned OpNo);
255  SDOperand PromoteIntOp_SIGN_EXTEND(SDNode *N);
256  SDOperand PromoteIntOp_STORE(StoreSDNode *N, unsigned OpNo);
257  SDOperand PromoteIntOp_TRUNCATE(SDNode *N);
258  SDOperand PromoteIntOp_ZERO_EXTEND(SDNode *N);
259
260  void PromoteSetCCOperands(SDOperand &LHS,SDOperand &RHS, ISD::CondCode Code);
261
262  //===--------------------------------------------------------------------===//
263  // Integer Expansion Support: LegalizeIntegerTypes.cpp
264  //===--------------------------------------------------------------------===//
265
266  void GetExpandedInteger(SDOperand Op, SDOperand &Lo, SDOperand &Hi);
267  void SetExpandedInteger(SDOperand Op, SDOperand Lo, SDOperand Hi);
268
269  // Integer Result Expansion.
270  void ExpandIntegerResult(SDNode *N, unsigned ResNo);
271  void ExpandIntRes_ANY_EXTEND        (SDNode *N, SDOperand &Lo, SDOperand &Hi);
272  void ExpandIntRes_AssertZext        (SDNode *N, SDOperand &Lo, SDOperand &Hi);
273  void ExpandIntRes_Constant          (SDNode *N, SDOperand &Lo, SDOperand &Hi);
274  void ExpandIntRes_CTLZ              (SDNode *N, SDOperand &Lo, SDOperand &Hi);
275  void ExpandIntRes_CTPOP             (SDNode *N, SDOperand &Lo, SDOperand &Hi);
276  void ExpandIntRes_CTTZ              (SDNode *N, SDOperand &Lo, SDOperand &Hi);
277  void ExpandIntRes_LOAD          (LoadSDNode *N, SDOperand &Lo, SDOperand &Hi);
278  void ExpandIntRes_SIGN_EXTEND       (SDNode *N, SDOperand &Lo, SDOperand &Hi);
279  void ExpandIntRes_SIGN_EXTEND_INREG (SDNode *N, SDOperand &Lo, SDOperand &Hi);
280  void ExpandIntRes_TRUNCATE          (SDNode *N, SDOperand &Lo, SDOperand &Hi);
281  void ExpandIntRes_ZERO_EXTEND       (SDNode *N, SDOperand &Lo, SDOperand &Hi);
282  void ExpandIntRes_FP_TO_SINT        (SDNode *N, SDOperand &Lo, SDOperand &Hi);
283  void ExpandIntRes_FP_TO_UINT        (SDNode *N, SDOperand &Lo, SDOperand &Hi);
284
285  void ExpandIntRes_Logical           (SDNode *N, SDOperand &Lo, SDOperand &Hi);
286  void ExpandIntRes_ADDSUB            (SDNode *N, SDOperand &Lo, SDOperand &Hi);
287  void ExpandIntRes_ADDSUBC           (SDNode *N, SDOperand &Lo, SDOperand &Hi);
288  void ExpandIntRes_ADDSUBE           (SDNode *N, SDOperand &Lo, SDOperand &Hi);
289  void ExpandIntRes_BSWAP             (SDNode *N, SDOperand &Lo, SDOperand &Hi);
290  void ExpandIntRes_MUL               (SDNode *N, SDOperand &Lo, SDOperand &Hi);
291  void ExpandIntRes_SDIV              (SDNode *N, SDOperand &Lo, SDOperand &Hi);
292  void ExpandIntRes_SREM              (SDNode *N, SDOperand &Lo, SDOperand &Hi);
293  void ExpandIntRes_UDIV              (SDNode *N, SDOperand &Lo, SDOperand &Hi);
294  void ExpandIntRes_UREM              (SDNode *N, SDOperand &Lo, SDOperand &Hi);
295  void ExpandIntRes_Shift             (SDNode *N, SDOperand &Lo, SDOperand &Hi);
296
297  void ExpandShiftByConstant(SDNode *N, unsigned Amt,
298                             SDOperand &Lo, SDOperand &Hi);
299  bool ExpandShiftWithKnownAmountBit(SDNode *N, SDOperand &Lo, SDOperand &Hi);
300
301  // Integer Operand Expansion.
302  bool ExpandIntegerOperand(SDNode *N, unsigned OperandNo);
303  SDOperand ExpandIntOp_BIT_CONVERT(SDNode *N);
304  SDOperand ExpandIntOp_BR_CC(SDNode *N);
305  SDOperand ExpandIntOp_BUILD_VECTOR(SDNode *N);
306  SDOperand ExpandIntOp_EXTRACT_ELEMENT(SDNode *N);
307  SDOperand ExpandIntOp_SELECT_CC(SDNode *N);
308  SDOperand ExpandIntOp_SETCC(SDNode *N);
309  SDOperand ExpandIntOp_SINT_TO_FP(SDOperand Source, MVT DestTy);
310  SDOperand ExpandIntOp_STORE(StoreSDNode *N, unsigned OpNo);
311  SDOperand ExpandIntOp_TRUNCATE(SDNode *N);
312  SDOperand ExpandIntOp_UINT_TO_FP(SDOperand Source, MVT DestTy);
313
314  void IntegerExpandSetCCOperands(SDOperand &NewLHS, SDOperand &NewRHS,
315                                  ISD::CondCode &CCCode);
316
317  //===--------------------------------------------------------------------===//
318  // Float to Integer Conversion Support: LegalizeFloatTypes.cpp
319  //===--------------------------------------------------------------------===//
320
321  SDOperand GetSoftenedFloat(SDOperand Op) {
322    SDOperand &SoftenedOp = SoftenedFloats[Op];
323    RemapNode(SoftenedOp);
324    assert(SoftenedOp.Val && "Operand wasn't converted to integer?");
325    return SoftenedOp;
326  }
327  void SetSoftenedFloat(SDOperand Op, SDOperand Result);
328
329  // Result Float to Integer Conversion.
330  void SoftenFloatResult(SDNode *N, unsigned OpNo);
331  SDOperand SoftenFloatRes_BIT_CONVERT(SDNode *N);
332  SDOperand SoftenFloatRes_BUILD_PAIR(SDNode *N);
333  SDOperand SoftenFloatRes_ConstantFP(ConstantFPSDNode *N);
334  SDOperand SoftenFloatRes_FADD(SDNode *N);
335  SDOperand SoftenFloatRes_FCOPYSIGN(SDNode *N);
336  SDOperand SoftenFloatRes_FMUL(SDNode *N);
337  SDOperand SoftenFloatRes_FP_EXTEND(SDNode *N);
338  SDOperand SoftenFloatRes_FP_ROUND(SDNode *N);
339  SDOperand SoftenFloatRes_FPOWI(SDNode *N);
340  SDOperand SoftenFloatRes_FSUB(SDNode *N);
341  SDOperand SoftenFloatRes_LOAD(SDNode *N);
342  SDOperand SoftenFloatRes_SELECT(SDNode *N);
343  SDOperand SoftenFloatRes_SELECT_CC(SDNode *N);
344  SDOperand SoftenFloatRes_SINT_TO_FP(SDNode *N);
345  SDOperand SoftenFloatRes_UINT_TO_FP(SDNode *N);
346
347  // Operand Float to Integer Conversion.
348  bool SoftenFloatOperand(SDNode *N, unsigned OpNo);
349  SDOperand SoftenFloatOp_BIT_CONVERT(SDNode *N);
350  SDOperand SoftenFloatOp_BR_CC(SDNode *N);
351  SDOperand SoftenFloatOp_FP_TO_SINT(SDNode *N);
352  SDOperand SoftenFloatOp_FP_TO_UINT(SDNode *N);
353  SDOperand SoftenFloatOp_SELECT_CC(SDNode *N);
354  SDOperand SoftenFloatOp_SETCC(SDNode *N);
355  SDOperand SoftenFloatOp_STORE(SDNode *N, unsigned OpNo);
356
357  void SoftenSetCCOperands(SDOperand &NewLHS, SDOperand &NewRHS,
358                           ISD::CondCode &CCCode);
359
360  //===--------------------------------------------------------------------===//
361  // Float Expansion Support: LegalizeFloatTypes.cpp
362  //===--------------------------------------------------------------------===//
363
364  void GetExpandedFloat(SDOperand Op, SDOperand &Lo, SDOperand &Hi);
365  void SetExpandedFloat(SDOperand Op, SDOperand Lo, SDOperand Hi);
366
367  // Float Result Expansion.
368  void ExpandFloatResult(SDNode *N, unsigned ResNo);
369  void ExpandFloatRes_ConstantFP(SDNode *N, SDOperand &Lo, SDOperand &Hi);
370  void ExpandFloatRes_FADD      (SDNode *N, SDOperand &Lo, SDOperand &Hi);
371  void ExpandFloatRes_FDIV      (SDNode *N, SDOperand &Lo, SDOperand &Hi);
372  void ExpandFloatRes_FMUL      (SDNode *N, SDOperand &Lo, SDOperand &Hi);
373  void ExpandFloatRes_FSUB      (SDNode *N, SDOperand &Lo, SDOperand &Hi);
374  void ExpandFloatRes_LOAD      (SDNode *N, SDOperand &Lo, SDOperand &Hi);
375  void ExpandFloatRes_XINT_TO_FP(SDNode *N, SDOperand &Lo, SDOperand &Hi);
376
377  // Float Operand Expansion.
378  bool ExpandFloatOperand(SDNode *N, unsigned OperandNo);
379  SDOperand ExpandFloatOp_BR_CC(SDNode *N);
380  SDOperand ExpandFloatOp_FP_ROUND(SDNode *N);
381  SDOperand ExpandFloatOp_FP_TO_SINT(SDNode *N);
382  SDOperand ExpandFloatOp_FP_TO_UINT(SDNode *N);
383  SDOperand ExpandFloatOp_SELECT_CC(SDNode *N);
384  SDOperand ExpandFloatOp_SETCC(SDNode *N);
385  SDOperand ExpandFloatOp_STORE(SDNode *N, unsigned OpNo);
386
387  void FloatExpandSetCCOperands(SDOperand &NewLHS, SDOperand &NewRHS,
388                                ISD::CondCode &CCCode);
389
390  //===--------------------------------------------------------------------===//
391  // Scalarization Support: LegalizeVectorTypes.cpp
392  //===--------------------------------------------------------------------===//
393
394  SDOperand GetScalarizedVector(SDOperand Op) {
395    SDOperand &ScalarizedOp = ScalarizedVectors[Op];
396    RemapNode(ScalarizedOp);
397    assert(ScalarizedOp.Val && "Operand wasn't scalarized?");
398    return ScalarizedOp;
399  }
400  void SetScalarizedVector(SDOperand Op, SDOperand Result);
401
402  // Vector Result Scalarization: <1 x ty> -> ty.
403  void ScalarizeResult(SDNode *N, unsigned OpNo);
404  SDOperand ScalarizeVecRes_BinOp(SDNode *N);
405  SDOperand ScalarizeVecRes_UnaryOp(SDNode *N);
406
407  SDOperand ScalarizeVecRes_BIT_CONVERT(SDNode *N);
408  SDOperand ScalarizeVecRes_FPOWI(SDNode *N);
409  SDOperand ScalarizeVecRes_INSERT_VECTOR_ELT(SDNode *N);
410  SDOperand ScalarizeVecRes_LOAD(LoadSDNode *N);
411  SDOperand ScalarizeVecRes_SELECT(SDNode *N);
412  SDOperand ScalarizeVecRes_UNDEF(SDNode *N);
413  SDOperand ScalarizeVecRes_VECTOR_SHUFFLE(SDNode *N);
414
415  // Vector Operand Scalarization: <1 x ty> -> ty.
416  bool ScalarizeOperand(SDNode *N, unsigned OpNo);
417  SDOperand ScalarizeVecOp_BIT_CONVERT(SDNode *N);
418  SDOperand ScalarizeVecOp_EXTRACT_VECTOR_ELT(SDNode *N);
419  SDOperand ScalarizeVecOp_STORE(StoreSDNode *N, unsigned OpNo);
420
421  //===--------------------------------------------------------------------===//
422  // Vector Splitting Support: LegalizeVectorTypes.cpp
423  //===--------------------------------------------------------------------===//
424
425  void GetSplitVector(SDOperand Op, SDOperand &Lo, SDOperand &Hi);
426  void SetSplitVector(SDOperand Op, SDOperand Lo, SDOperand Hi);
427
428  // Vector Result Splitting: <128 x ty> -> 2 x <64 x ty>.
429  void SplitResult(SDNode *N, unsigned OpNo);
430
431  void SplitVecRes_UNDEF(SDNode *N, SDOperand &Lo, SDOperand &Hi);
432  void SplitVecRes_LOAD(LoadSDNode *N, SDOperand &Lo, SDOperand &Hi);
433  void SplitVecRes_BUILD_PAIR(SDNode *N, SDOperand &Lo, SDOperand &Hi);
434  void SplitVecRes_INSERT_VECTOR_ELT(SDNode *N, SDOperand &Lo, SDOperand &Hi);
435  void SplitVecRes_VECTOR_SHUFFLE(SDNode *N, SDOperand &Lo, SDOperand &Hi);
436
437  void SplitVecRes_BUILD_VECTOR(SDNode *N, SDOperand &Lo, SDOperand &Hi);
438  void SplitVecRes_CONCAT_VECTORS(SDNode *N, SDOperand &Lo, SDOperand &Hi);
439  void SplitVecRes_BIT_CONVERT(SDNode *N, SDOperand &Lo, SDOperand &Hi);
440  void SplitVecRes_UnOp(SDNode *N, SDOperand &Lo, SDOperand &Hi);
441  void SplitVecRes_BinOp(SDNode *N, SDOperand &Lo, SDOperand &Hi);
442  void SplitVecRes_FPOWI(SDNode *N, SDOperand &Lo, SDOperand &Hi);
443
444  // Vector Operand Splitting: <128 x ty> -> 2 x <64 x ty>.
445  bool SplitOperand(SDNode *N, unsigned OpNo);
446
447  SDOperand SplitVecOp_BIT_CONVERT(SDNode *N);
448  SDOperand SplitVecOp_EXTRACT_SUBVECTOR(SDNode *N);
449  SDOperand SplitVecOp_EXTRACT_VECTOR_ELT(SDNode *N);
450  SDOperand SplitVecOp_RET(SDNode *N, unsigned OpNo);
451  SDOperand SplitVecOp_STORE(StoreSDNode *N, unsigned OpNo);
452  SDOperand SplitVecOp_VECTOR_SHUFFLE(SDNode *N, unsigned OpNo);
453
454  //===--------------------------------------------------------------------===//
455  // Generic Splitting: LegalizeTypesGeneric.cpp
456  //===--------------------------------------------------------------------===//
457
458  // Legalization methods which only use that the illegal type is split into two
459  // not necessarily identical types.  As such they can be used for splitting
460  // vectors and expanding integers and floats.
461
462  void GetSplitOp(SDOperand Op, SDOperand &Lo, SDOperand &Hi) {
463    if (Op.getValueType().isVector())
464      GetSplitVector(Op, Lo, Hi);
465    else if (Op.getValueType().isInteger())
466      GetExpandedInteger(Op, Lo, Hi);
467    else
468      GetExpandedFloat(Op, Lo, Hi);
469  }
470
471  /// GetSplitDestVTs - Compute the VTs needed for the low/hi parts of a type
472  /// which is split (or expanded) into two not necessarily identical pieces.
473  void GetSplitDestVTs(MVT InVT, MVT &LoVT, MVT &HiVT);
474
475  // Generic Result Splitting.
476  void SplitRes_MERGE_VALUES(SDNode *N, SDOperand &Lo, SDOperand &Hi);
477  void SplitRes_SELECT      (SDNode *N, SDOperand &Lo, SDOperand &Hi);
478  void SplitRes_SELECT_CC   (SDNode *N, SDOperand &Lo, SDOperand &Hi);
479  void SplitRes_UNDEF       (SDNode *N, SDOperand &Lo, SDOperand &Hi);
480
481  //===--------------------------------------------------------------------===//
482  // Generic Expansion: LegalizeTypesGeneric.cpp
483  //===--------------------------------------------------------------------===//
484
485  // Legalization methods which only use that the illegal type is split into two
486  // identical types of half the size, and that the Lo/Hi part is stored first
487  // in memory on little/big-endian machines, followed by the Hi/Lo part.  As
488  // such they can be used for expanding integers and floats.
489
490  void GetExpandedOp(SDOperand Op, SDOperand &Lo, SDOperand &Hi) {
491    if (Op.getValueType().isInteger())
492      GetExpandedInteger(Op, Lo, Hi);
493    else
494      GetExpandedFloat(Op, Lo, Hi);
495  }
496
497  // Generic Result Expansion.
498  void ExpandRes_BIT_CONVERT       (SDNode *N, SDOperand &Lo, SDOperand &Hi);
499  void ExpandRes_BUILD_PAIR        (SDNode *N, SDOperand &Lo, SDOperand &Hi);
500  void ExpandRes_EXTRACT_ELEMENT   (SDNode *N, SDOperand &Lo, SDOperand &Hi);
501  void ExpandRes_EXTRACT_VECTOR_ELT(SDNode *N, SDOperand &Lo, SDOperand &Hi);
502  void ExpandRes_NormalLoad        (SDNode *N, SDOperand &Lo, SDOperand &Hi);
503
504  // Generic Operand Expansion.
505  SDOperand ExpandOp_BIT_CONVERT    (SDNode *N);
506  SDOperand ExpandOp_BUILD_VECTOR   (SDNode *N);
507  SDOperand ExpandOp_EXTRACT_ELEMENT(SDNode *N);
508  SDOperand ExpandOp_NormalStore    (SDNode *N, unsigned OpNo);
509
510};
511
512} // end namespace llvm.
513
514#endif
515