Store default libgcc routine names and allow them to be redefined by target.
[oota-llvm.git] / include / llvm / Target / TargetLowering.h
1 //===-- llvm/Target/TargetLowering.h - Target Lowering Info -----*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file describes how to lower LLVM code to machine code.  This has two
11 // main components:
12 //
13 //  1. Which ValueTypes are natively supported by the target.
14 //  2. Which operations are supported for supported ValueTypes.
15 //  3. Cost thresholds for alternative implementations of certain operations.
16 //
17 // In addition it has a few other components, like information about FP
18 // immediates.
19 //
20 //===----------------------------------------------------------------------===//
21
22 #ifndef LLVM_TARGET_TARGETLOWERING_H
23 #define LLVM_TARGET_TARGETLOWERING_H
24
25 #include "llvm/Type.h"
26 #include "llvm/CodeGen/SelectionDAGNodes.h"
27 #include <map>
28
29 namespace llvm {
30   class Value;
31   class Function;
32   class TargetMachine;
33   class TargetData;
34   class TargetRegisterClass;
35   class SDNode;
36   class SDOperand;
37   class SelectionDAG;
38   class MachineBasicBlock;
39   class MachineInstr;
40
41 namespace RTLIB {
42   /// RTLIB::Libcall enum - This enum defines all of the runtime library calls
43   /// the backend can emit.
44   ///
45   enum Libcall {
46     // Integer
47     SHL_I32,
48     SHL_I64,
49     SRL_I32,
50     SRL_I64,
51     SRA_I32,
52     SRA_I64,
53     MUL_I32,
54     MUL_I64,
55     SDIV_I32,
56     SDIV_I64,
57     UDIV_I32,
58     UDIV_I64,
59     SREM_I32,
60     SREM_I64,
61     UREM_I32,
62     UREM_I64,
63     NEG_I32,
64     NEG_I64,
65
66     // FLOATING POINT
67     ADD_F32,
68     ADD_F64,
69     SUB_F32,
70     SUB_F64,
71     MUL_F32,
72     MUL_F64,
73     DIV_F32,
74     DIV_F64,
75     REM_F32,
76     REM_F64,
77     NEG_F32,
78     NEG_F64,
79     POWI_F32,
80     POWI_F64,
81     SQRT_F32,
82     SQRT_F64,
83     SIN_F32,
84     SIN_F64,
85     COS_F32,
86     COS_F64,
87
88     // CONVERSION
89     FPEXT_F32_F64,
90     FPROUND_F64_F32,
91     FPTOSINT_F32_I32,
92     FPTOSINT_F32_I64,
93     FPTOSINT_F64_I32,
94     FPTOSINT_F64_I64,
95     FPTOUINT_F32_I32,
96     FPTOUINT_F32_I64,
97     FPTOUINT_F64_I32,
98     FPTOUINT_F64_I64,
99     SINTTOFP_I32_F32,
100     SINTTOFP_I32_F64,
101     SINTTOFP_I64_F32,
102     SINTTOFP_I64_F64,
103     UINTTOFP_I32_F32,
104     UINTTOFP_I32_F64,
105     UINTTOFP_I64_F32,
106     UINTTOFP_I64_F64,
107
108     // COMPARISON
109     OEQ_F32,
110     OEQ_F64,
111     UNE_F32,
112     UNE_F64,
113     OGE_F32,
114     OGE_F64,
115     OLT_F32,
116     OLT_F64,
117     OLE_F32,
118     OLE_F64,
119     OGT_F32,
120     OGT_F64,
121     UO_F32,
122     UO_F64,
123
124     UNKNOWN_LIBCALL
125   };
126   }
127
128 //===----------------------------------------------------------------------===//
129 /// TargetLowering - This class defines information used to lower LLVM code to
130 /// legal SelectionDAG operators that the target instruction selector can accept
131 /// natively.
132 ///
133 /// This class also defines callbacks that targets must implement to lower
134 /// target-specific constructs to SelectionDAG operators.
135 ///
136 class TargetLowering {
137 public:
138   /// LegalizeAction - This enum indicates whether operations are valid for a
139   /// target, and if not, what action should be used to make them valid.
140   enum LegalizeAction {
141     Legal,      // The target natively supports this operation.
142     Promote,    // This operation should be executed in a larger type.
143     Expand,     // Try to expand this to other ops, otherwise use a libcall.
144     Custom      // Use the LowerOperation hook to implement custom lowering.
145   };
146
147   enum OutOfRangeShiftAmount {
148     Undefined,  // Oversized shift amounts are undefined (default).
149     Mask,       // Shift amounts are auto masked (anded) to value size.
150     Extend      // Oversized shift pulls in zeros or sign bits.
151   };
152
153   enum SetCCResultValue {
154     UndefinedSetCCResult,          // SetCC returns a garbage/unknown extend.
155     ZeroOrOneSetCCResult,          // SetCC returns a zero extended result.
156     ZeroOrNegativeOneSetCCResult   // SetCC returns a sign extended result.
157   };
158
159   enum SchedPreference {
160     SchedulingForLatency,          // Scheduling for shortest total latency.
161     SchedulingForRegPressure       // Scheduling for lowest register pressure.
162   };
163
164   TargetLowering(TargetMachine &TM);
165   virtual ~TargetLowering();
166
167   TargetMachine &getTargetMachine() const { return TM; }
168   const TargetData *getTargetData() const { return TD; }
169
170   bool isLittleEndian() const { return IsLittleEndian; }
171   MVT::ValueType getPointerTy() const { return PointerTy; }
172   MVT::ValueType getShiftAmountTy() const { return ShiftAmountTy; }
173   OutOfRangeShiftAmount getShiftAmountFlavor() const {return ShiftAmtHandling; }
174
175   /// usesGlobalOffsetTable - Return true if this target uses a GOT for PIC
176   /// codegen.
177   bool usesGlobalOffsetTable() const { return UsesGlobalOffsetTable; }
178   
179   /// isSelectExpensive - Return true if the select operation is expensive for
180   /// this target.
181   bool isSelectExpensive() const { return SelectIsExpensive; }
182   
183   /// isIntDivCheap() - Return true if integer divide is usually cheaper than
184   /// a sequence of several shifts, adds, and multiplies for this target.
185   bool isIntDivCheap() const { return IntDivIsCheap; }
186
187   /// isPow2DivCheap() - Return true if pow2 div is cheaper than a chain of
188   /// srl/add/sra.
189   bool isPow2DivCheap() const { return Pow2DivIsCheap; }
190   
191   /// getSetCCResultTy - Return the ValueType of the result of setcc operations.
192   ///
193   MVT::ValueType getSetCCResultTy() const { return SetCCResultTy; }
194
195   /// getSetCCResultContents - For targets without boolean registers, this flag
196   /// returns information about the contents of the high-bits in the setcc
197   /// result register.
198   SetCCResultValue getSetCCResultContents() const { return SetCCResultContents;}
199
200   /// getSchedulingPreference - Return target scheduling preference.
201   SchedPreference getSchedulingPreference() const {
202     return SchedPreferenceInfo;
203   }
204
205   /// getRegClassFor - Return the register class that should be used for the
206   /// specified value type.  This may only be called on legal types.
207   TargetRegisterClass *getRegClassFor(MVT::ValueType VT) const {
208     TargetRegisterClass *RC = RegClassForVT[VT];
209     assert(RC && "This value type is not natively supported!");
210     return RC;
211   }
212   
213   /// isTypeLegal - Return true if the target has native support for the
214   /// specified value type.  This means that it has a register that directly
215   /// holds it without promotions or expansions.
216   bool isTypeLegal(MVT::ValueType VT) const {
217     return RegClassForVT[VT] != 0;
218   }
219
220   class ValueTypeActionImpl {
221     /// ValueTypeActions - This is a bitvector that contains two bits for each
222     /// value type, where the two bits correspond to the LegalizeAction enum.
223     /// This can be queried with "getTypeAction(VT)".
224     uint32_t ValueTypeActions[2];
225   public:
226     ValueTypeActionImpl() {
227       ValueTypeActions[0] = ValueTypeActions[1] = 0;
228     }
229     ValueTypeActionImpl(const ValueTypeActionImpl &RHS) {
230       ValueTypeActions[0] = RHS.ValueTypeActions[0];
231       ValueTypeActions[1] = RHS.ValueTypeActions[1];
232     }
233     
234     LegalizeAction getTypeAction(MVT::ValueType VT) const {
235       return (LegalizeAction)((ValueTypeActions[VT>>4] >> ((2*VT) & 31)) & 3);
236     }
237     void setTypeAction(MVT::ValueType VT, LegalizeAction Action) {
238       assert(unsigned(VT >> 4) < 
239              sizeof(ValueTypeActions)/sizeof(ValueTypeActions[0]));
240       ValueTypeActions[VT>>4] |= Action << ((VT*2) & 31);
241     }
242   };
243   
244   const ValueTypeActionImpl &getValueTypeActions() const {
245     return ValueTypeActions;
246   }
247   
248   /// getTypeAction - Return how we should legalize values of this type, either
249   /// it is already legal (return 'Legal') or we need to promote it to a larger
250   /// type (return 'Promote'), or we need to expand it into multiple registers
251   /// of smaller integer type (return 'Expand').  'Custom' is not an option.
252   LegalizeAction getTypeAction(MVT::ValueType VT) const {
253     return ValueTypeActions.getTypeAction(VT);
254   }
255
256   /// getTypeToTransformTo - For types supported by the target, this is an
257   /// identity function.  For types that must be promoted to larger types, this
258   /// returns the larger type to promote to.  For integer types that are larger
259   /// than the largest integer register, this contains one step in the expansion
260   /// to get to the smaller register. For illegal floating point types, this
261   /// returns the integer type to transform to.
262   MVT::ValueType getTypeToTransformTo(MVT::ValueType VT) const {
263     return TransformToType[VT];
264   }
265   
266   /// getTypeToExpandTo - For types supported by the target, this is an
267   /// identity function.  For types that must be expanded (i.e. integer types
268   /// that are larger than the largest integer register or illegal floating
269   /// point types), this returns the largest legal type it will be expanded to.
270   MVT::ValueType getTypeToExpandTo(MVT::ValueType VT) const {
271     while (true) {
272       switch (getTypeAction(VT)) {
273       case Legal:
274         return VT;
275       case Expand:
276         VT = TransformToType[VT];
277         break;
278       default:
279         assert(false && "Type is not legal nor is it to be expanded!");
280         return VT;
281       }
282     }
283     return VT;
284   }
285
286   /// getPackedTypeBreakdown - Packed types are broken down into some number of
287   /// legal first class types.  For example, <8 x float> maps to 2 MVT::v4f32
288   /// with Altivec or SSE1, or 8 promoted MVT::f64 values with the X86 FP stack.
289   /// Similarly, <2 x long> turns into 4 MVT::i32 values with both PPC and X86.
290   ///
291   /// This method returns the number of registers needed, and the VT for each
292   /// register.  It also returns the VT of the PackedType elements before they
293   /// are promoted/expanded.
294   ///
295   unsigned getPackedTypeBreakdown(const PackedType *PTy, 
296                                   MVT::ValueType &PTyElementVT,
297                                   MVT::ValueType &PTyLegalElementVT) const;
298   
299   typedef std::vector<double>::const_iterator legal_fpimm_iterator;
300   legal_fpimm_iterator legal_fpimm_begin() const {
301     return LegalFPImmediates.begin();
302   }
303   legal_fpimm_iterator legal_fpimm_end() const {
304     return LegalFPImmediates.end();
305   }
306   
307   /// isShuffleMaskLegal - Targets can use this to indicate that they only
308   /// support *some* VECTOR_SHUFFLE operations, those with specific masks.
309   /// By default, if a target supports the VECTOR_SHUFFLE node, all mask values
310   /// are assumed to be legal.
311   virtual bool isShuffleMaskLegal(SDOperand Mask, MVT::ValueType VT) const {
312     return true;
313   }
314
315   /// isVectorClearMaskLegal - Similar to isShuffleMaskLegal. This is
316   /// used by Targets can use this to indicate if there is a suitable
317   /// VECTOR_SHUFFLE that can be used to replace a VAND with a constant
318   /// pool entry.
319   virtual bool isVectorClearMaskLegal(std::vector<SDOperand> &BVOps,
320                                       MVT::ValueType EVT,
321                                       SelectionDAG &DAG) const {
322     return false;
323   }
324
325   /// getOperationAction - Return how this operation should be treated: either
326   /// it is legal, needs to be promoted to a larger size, needs to be
327   /// expanded to some other code sequence, or the target has a custom expander
328   /// for it.
329   LegalizeAction getOperationAction(unsigned Op, MVT::ValueType VT) const {
330     return (LegalizeAction)((OpActions[Op] >> (2*VT)) & 3);
331   }
332   
333   /// isOperationLegal - Return true if the specified operation is legal on this
334   /// target.
335   bool isOperationLegal(unsigned Op, MVT::ValueType VT) const {
336     return getOperationAction(Op, VT) == Legal ||
337            getOperationAction(Op, VT) == Custom;
338   }
339   
340   /// getLoadXAction - Return how this load with extension should be treated:
341   /// either it is legal, needs to be promoted to a larger size, needs to be
342   /// expanded to some other code sequence, or the target has a custom expander
343   /// for it.
344   LegalizeAction getLoadXAction(unsigned LType, MVT::ValueType VT) const {
345     return (LegalizeAction)((LoadXActions[LType] >> (2*VT)) & 3);
346   }
347   
348   /// isLoadXLegal - Return true if the specified load with extension is legal
349   /// on this target.
350   bool isLoadXLegal(unsigned LType, MVT::ValueType VT) const {
351     return getLoadXAction(LType, VT) == Legal ||
352            getLoadXAction(LType, VT) == Custom;
353   }
354   
355   /// getStoreXAction - Return how this store with truncation should be treated:
356   /// either it is legal, needs to be promoted to a larger size, needs to be
357   /// expanded to some other code sequence, or the target has a custom expander
358   /// for it.
359   LegalizeAction getStoreXAction(MVT::ValueType VT) const {
360     return (LegalizeAction)((StoreXActions >> (2*VT)) & 3);
361   }
362   
363   /// isStoreXLegal - Return true if the specified store with truncation is
364   /// legal on this target.
365   bool isStoreXLegal(MVT::ValueType VT) const {
366     return getStoreXAction(VT) == Legal || getStoreXAction(VT) == Custom;
367   }
368
369   /// getIndexedLoadAction - Return how the indexed load should be treated:
370   /// either it is legal, needs to be promoted to a larger size, needs to be
371   /// expanded to some other code sequence, or the target has a custom expander
372   /// for it.
373   LegalizeAction
374   getIndexedLoadAction(unsigned IdxMode, MVT::ValueType VT) const {
375     return (LegalizeAction)((IndexedModeActions[0][IdxMode] >> (2*VT)) & 3);
376   }
377
378   /// isIndexedLoadLegal - Return true if the specified indexed load is legal
379   /// on this target.
380   bool isIndexedLoadLegal(unsigned IdxMode, MVT::ValueType VT) const {
381     return getIndexedLoadAction(IdxMode, VT) == Legal ||
382            getIndexedLoadAction(IdxMode, VT) == Custom;
383   }
384   
385   /// getIndexedStoreAction - Return how the indexed store should be treated:
386   /// either it is legal, needs to be promoted to a larger size, needs to be
387   /// expanded to some other code sequence, or the target has a custom expander
388   /// for it.
389   LegalizeAction
390   getIndexedStoreAction(unsigned IdxMode, MVT::ValueType VT) const {
391     return (LegalizeAction)((IndexedModeActions[1][IdxMode] >> (2*VT)) & 3);
392   }  
393   
394   /// isIndexedStoreLegal - Return true if the specified indexed load is legal
395   /// on this target.
396   bool isIndexedStoreLegal(unsigned IdxMode, MVT::ValueType VT) const {
397     return getIndexedStoreAction(IdxMode, VT) == Legal ||
398            getIndexedStoreAction(IdxMode, VT) == Custom;
399   }
400   
401   /// getTypeToPromoteTo - If the action for this operation is to promote, this
402   /// method returns the ValueType to promote to.
403   MVT::ValueType getTypeToPromoteTo(unsigned Op, MVT::ValueType VT) const {
404     assert(getOperationAction(Op, VT) == Promote &&
405            "This operation isn't promoted!");
406
407     // See if this has an explicit type specified.
408     std::map<std::pair<unsigned, MVT::ValueType>, 
409              MVT::ValueType>::const_iterator PTTI =
410       PromoteToType.find(std::make_pair(Op, VT));
411     if (PTTI != PromoteToType.end()) return PTTI->second;
412     
413     assert((MVT::isInteger(VT) || MVT::isFloatingPoint(VT)) &&
414            "Cannot autopromote this type, add it with AddPromotedToType.");
415     
416     MVT::ValueType NVT = VT;
417     do {
418       NVT = (MVT::ValueType)(NVT+1);
419       assert(MVT::isInteger(NVT) == MVT::isInteger(VT) && NVT != MVT::isVoid &&
420              "Didn't find type to promote to!");
421     } while (!isTypeLegal(NVT) ||
422               getOperationAction(Op, NVT) == Promote);
423     return NVT;
424   }
425
426   /// getValueType - Return the MVT::ValueType corresponding to this LLVM type.
427   /// This is fixed by the LLVM operations except for the pointer size.
428   MVT::ValueType getValueType(const Type *Ty) const {
429     switch (Ty->getTypeID()) {
430     default: assert(0 && "Unknown type!");
431     case Type::VoidTyID:    return MVT::isVoid;
432     case Type::Int1TyID:    return MVT::i1;
433     case Type::Int8TyID:    return MVT::i8;
434     case Type::Int16TyID:   return MVT::i16;
435     case Type::Int32TyID:   return MVT::i32;
436     case Type::Int64TyID:   return MVT::i64;
437     case Type::FloatTyID:   return MVT::f32;
438     case Type::DoubleTyID:  return MVT::f64;
439     case Type::PointerTyID: return PointerTy;
440     case Type::PackedTyID:  return MVT::Vector;
441     }
442   }
443
444   /// getNumElements - Return the number of registers that this ValueType will
445   /// eventually require.  This is one for any types promoted to live in larger
446   /// registers, but may be more than one for types (like i64) that are split
447   /// into pieces.
448   unsigned getNumElements(MVT::ValueType VT) const {
449     return NumElementsForVT[VT];
450   }
451   
452   /// hasTargetDAGCombine - If true, the target has custom DAG combine
453   /// transformations that it can perform for the specified node.
454   bool hasTargetDAGCombine(ISD::NodeType NT) const {
455     return TargetDAGCombineArray[NT >> 3] & (1 << (NT&7));
456   }
457
458   /// This function returns the maximum number of store operations permitted
459   /// to replace a call to llvm.memset. The value is set by the target at the
460   /// performance threshold for such a replacement.
461   /// @brief Get maximum # of store operations permitted for llvm.memset
462   unsigned getMaxStoresPerMemset() const { return maxStoresPerMemset; }
463
464   /// This function returns the maximum number of store operations permitted
465   /// to replace a call to llvm.memcpy. The value is set by the target at the
466   /// performance threshold for such a replacement.
467   /// @brief Get maximum # of store operations permitted for llvm.memcpy
468   unsigned getMaxStoresPerMemcpy() const { return maxStoresPerMemcpy; }
469
470   /// This function returns the maximum number of store operations permitted
471   /// to replace a call to llvm.memmove. The value is set by the target at the
472   /// performance threshold for such a replacement.
473   /// @brief Get maximum # of store operations permitted for llvm.memmove
474   unsigned getMaxStoresPerMemmove() const { return maxStoresPerMemmove; }
475
476   /// This function returns true if the target allows unaligned memory accesses.
477   /// This is used, for example, in situations where an array copy/move/set is 
478   /// converted to a sequence of store operations. It's use helps to ensure that
479   /// such replacements don't generate code that causes an alignment error 
480   /// (trap) on the target machine. 
481   /// @brief Determine if the target supports unaligned memory accesses.
482   bool allowsUnalignedMemoryAccesses() const {
483     return allowUnalignedMemoryAccesses;
484   }
485   
486   /// usesUnderscoreSetJmp - Determine if we should use _setjmp or setjmp
487   /// to implement llvm.setjmp.
488   bool usesUnderscoreSetJmp() const {
489     return UseUnderscoreSetJmp;
490   }
491
492   /// usesUnderscoreLongJmp - Determine if we should use _longjmp or longjmp
493   /// to implement llvm.longjmp.
494   bool usesUnderscoreLongJmp() const {
495     return UseUnderscoreLongJmp;
496   }
497
498   /// getStackPointerRegisterToSaveRestore - If a physical register, this
499   /// specifies the register that llvm.savestack/llvm.restorestack should save
500   /// and restore.
501   unsigned getStackPointerRegisterToSaveRestore() const {
502     return StackPointerRegisterToSaveRestore;
503   }
504
505   /// getJumpBufSize - returns the target's jmp_buf size in bytes (if never
506   /// set, the default is 200)
507   unsigned getJumpBufSize() const {
508     return JumpBufSize;
509   }
510
511   /// getJumpBufAlignment - returns the target's jmp_buf alignment in bytes
512   /// (if never set, the default is 0)
513   unsigned getJumpBufAlignment() const {
514     return JumpBufAlignment;
515   }
516
517   /// getPreIndexedAddressParts - returns true by value, base pointer and
518   /// offset pointer and addressing mode by reference if the node's address
519   /// can be legally represented as pre-indexed load / store address.
520   virtual bool getPreIndexedAddressParts(SDNode *N, SDOperand &Base,
521                                          SDOperand &Offset,
522                                          ISD::MemIndexedMode &AM,
523                                          SelectionDAG &DAG) {
524     return false;
525   }
526   
527   /// getPostIndexedAddressParts - returns true by value, base pointer and
528   /// offset pointer and addressing mode by reference if this node can be
529   /// combined with a load / store to form a post-indexed load / store.
530   virtual bool getPostIndexedAddressParts(SDNode *N, SDNode *Op,
531                                           SDOperand &Base, SDOperand &Offset,
532                                           ISD::MemIndexedMode &AM,
533                                           SelectionDAG &DAG) {
534     return false;
535   }
536   
537   //===--------------------------------------------------------------------===//
538   // TargetLowering Optimization Methods
539   //
540   
541   /// TargetLoweringOpt - A convenience struct that encapsulates a DAG, and two
542   /// SDOperands for returning information from TargetLowering to its clients
543   /// that want to combine 
544   struct TargetLoweringOpt {
545     SelectionDAG &DAG;
546     SDOperand Old;
547     SDOperand New;
548
549     TargetLoweringOpt(SelectionDAG &InDAG) : DAG(InDAG) {}
550     
551     bool CombineTo(SDOperand O, SDOperand N) { 
552       Old = O; 
553       New = N; 
554       return true;
555     }
556     
557     /// ShrinkDemandedConstant - Check to see if the specified operand of the 
558     /// specified instruction is a constant integer.  If so, check to see if there
559     /// are any bits set in the constant that are not demanded.  If so, shrink the
560     /// constant and return true.
561     bool ShrinkDemandedConstant(SDOperand Op, uint64_t Demanded);
562   };
563                                                 
564   /// MaskedValueIsZero - Return true if 'Op & Mask' is known to be zero.  We
565   /// use this predicate to simplify operations downstream.  Op and Mask are
566   /// known to be the same type.
567   bool MaskedValueIsZero(SDOperand Op, uint64_t Mask, unsigned Depth = 0)
568     const;
569   
570   /// ComputeMaskedBits - Determine which of the bits specified in Mask are
571   /// known to be either zero or one and return them in the KnownZero/KnownOne
572   /// bitsets.  This code only analyzes bits in Mask, in order to short-circuit
573   /// processing.  Targets can implement the computeMaskedBitsForTargetNode 
574   /// method, to allow target nodes to be understood.
575   void ComputeMaskedBits(SDOperand Op, uint64_t Mask, uint64_t &KnownZero,
576                          uint64_t &KnownOne, unsigned Depth = 0) const;
577     
578   /// SimplifyDemandedBits - Look at Op.  At this point, we know that only the
579   /// DemandedMask bits of the result of Op are ever used downstream.  If we can
580   /// use this information to simplify Op, create a new simplified DAG node and
581   /// return true, returning the original and new nodes in Old and New. 
582   /// Otherwise, analyze the expression and return a mask of KnownOne and 
583   /// KnownZero bits for the expression (used to simplify the caller).  
584   /// The KnownZero/One bits may only be accurate for those bits in the 
585   /// DemandedMask.
586   bool SimplifyDemandedBits(SDOperand Op, uint64_t DemandedMask, 
587                             uint64_t &KnownZero, uint64_t &KnownOne,
588                             TargetLoweringOpt &TLO, unsigned Depth = 0) const;
589   
590   /// computeMaskedBitsForTargetNode - Determine which of the bits specified in
591   /// Mask are known to be either zero or one and return them in the 
592   /// KnownZero/KnownOne bitsets.
593   virtual void computeMaskedBitsForTargetNode(const SDOperand Op,
594                                               uint64_t Mask,
595                                               uint64_t &KnownZero, 
596                                               uint64_t &KnownOne,
597                                               unsigned Depth = 0) const;
598
599   /// ComputeNumSignBits - Return the number of times the sign bit of the
600   /// register is replicated into the other bits.  We know that at least 1 bit
601   /// is always equal to the sign bit (itself), but other cases can give us
602   /// information.  For example, immediately after an "SRA X, 2", we know that
603   /// the top 3 bits are all equal to each other, so we return 3.
604   unsigned ComputeNumSignBits(SDOperand Op, unsigned Depth = 0) const;
605   
606   /// ComputeNumSignBitsForTargetNode - This method can be implemented by
607   /// targets that want to expose additional information about sign bits to the
608   /// DAG Combiner.
609   virtual unsigned ComputeNumSignBitsForTargetNode(SDOperand Op,
610                                                    unsigned Depth = 0) const;
611   
612   struct DAGCombinerInfo {
613     void *DC;  // The DAG Combiner object.
614     bool BeforeLegalize;
615   public:
616     SelectionDAG &DAG;
617     
618     DAGCombinerInfo(SelectionDAG &dag, bool bl, void *dc)
619       : DC(dc), BeforeLegalize(bl), DAG(dag) {}
620     
621     bool isBeforeLegalize() const { return BeforeLegalize; }
622     
623     void AddToWorklist(SDNode *N);
624     SDOperand CombineTo(SDNode *N, const std::vector<SDOperand> &To);
625     SDOperand CombineTo(SDNode *N, SDOperand Res);
626     SDOperand CombineTo(SDNode *N, SDOperand Res0, SDOperand Res1);
627   };
628
629   /// PerformDAGCombine - This method will be invoked for all target nodes and
630   /// for any target-independent nodes that the target has registered with
631   /// invoke it for.
632   ///
633   /// The semantics are as follows:
634   /// Return Value:
635   ///   SDOperand.Val == 0   - No change was made
636   ///   SDOperand.Val == N   - N was replaced, is dead, and is already handled.
637   ///   otherwise            - N should be replaced by the returned Operand.
638   ///
639   /// In addition, methods provided by DAGCombinerInfo may be used to perform
640   /// more complex transformations.
641   ///
642   virtual SDOperand PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const;
643   
644   //===--------------------------------------------------------------------===//
645   // TargetLowering Configuration Methods - These methods should be invoked by
646   // the derived class constructor to configure this object for the target.
647   //
648
649 protected:
650   /// setUsesGlobalOffsetTable - Specify that this target does or doesn't use a
651   /// GOT for PC-relative code.
652   void setUsesGlobalOffsetTable(bool V) { UsesGlobalOffsetTable = V; }
653
654   /// setShiftAmountType - Describe the type that should be used for shift
655   /// amounts.  This type defaults to the pointer type.
656   void setShiftAmountType(MVT::ValueType VT) { ShiftAmountTy = VT; }
657
658   /// setSetCCResultType - Describe the type that shoudl be used as the result
659   /// of a setcc operation.  This defaults to the pointer type.
660   void setSetCCResultType(MVT::ValueType VT) { SetCCResultTy = VT; }
661
662   /// setSetCCResultContents - Specify how the target extends the result of a
663   /// setcc operation in a register.
664   void setSetCCResultContents(SetCCResultValue Ty) { SetCCResultContents = Ty; }
665
666   /// setSchedulingPreference - Specify the target scheduling preference.
667   void setSchedulingPreference(SchedPreference Pref) {
668     SchedPreferenceInfo = Pref;
669   }
670
671   /// setShiftAmountFlavor - Describe how the target handles out of range shift
672   /// amounts.
673   void setShiftAmountFlavor(OutOfRangeShiftAmount OORSA) {
674     ShiftAmtHandling = OORSA;
675   }
676
677   /// setUseUnderscoreSetJmp - Indicate whether this target prefers to
678   /// use _setjmp to implement llvm.setjmp or the non _ version.
679   /// Defaults to false.
680   void setUseUnderscoreSetJmp(bool Val) {
681     UseUnderscoreSetJmp = Val;
682   }
683
684   /// setUseUnderscoreLongJmp - Indicate whether this target prefers to
685   /// use _longjmp to implement llvm.longjmp or the non _ version.
686   /// Defaults to false.
687   void setUseUnderscoreLongJmp(bool Val) {
688     UseUnderscoreLongJmp = Val;
689   }
690
691   /// setStackPointerRegisterToSaveRestore - If set to a physical register, this
692   /// specifies the register that llvm.savestack/llvm.restorestack should save
693   /// and restore.
694   void setStackPointerRegisterToSaveRestore(unsigned R) {
695     StackPointerRegisterToSaveRestore = R;
696   }
697   
698   /// SelectIsExpensive - Tells the code generator not to expand operations
699   /// into sequences that use the select operations if possible.
700   void setSelectIsExpensive() { SelectIsExpensive = true; }
701
702   /// setIntDivIsCheap - Tells the code generator that integer divide is
703   /// expensive, and if possible, should be replaced by an alternate sequence
704   /// of instructions not containing an integer divide.
705   void setIntDivIsCheap(bool isCheap = true) { IntDivIsCheap = isCheap; }
706   
707   /// setPow2DivIsCheap - Tells the code generator that it shouldn't generate
708   /// srl/add/sra for a signed divide by power of two, and let the target handle
709   /// it.
710   void setPow2DivIsCheap(bool isCheap = true) { Pow2DivIsCheap = isCheap; }
711   
712   /// addRegisterClass - Add the specified register class as an available
713   /// regclass for the specified value type.  This indicates the selector can
714   /// handle values of that class natively.
715   void addRegisterClass(MVT::ValueType VT, TargetRegisterClass *RC) {
716     AvailableRegClasses.push_back(std::make_pair(VT, RC));
717     RegClassForVT[VT] = RC;
718   }
719
720   /// computeRegisterProperties - Once all of the register classes are added,
721   /// this allows us to compute derived properties we expose.
722   void computeRegisterProperties();
723
724   /// setOperationAction - Indicate that the specified operation does not work
725   /// with the specified type and indicate what to do about it.
726   void setOperationAction(unsigned Op, MVT::ValueType VT,
727                           LegalizeAction Action) {
728     assert(VT < 32 && Op < sizeof(OpActions)/sizeof(OpActions[0]) &&
729            "Table isn't big enough!");
730     OpActions[Op] &= ~(uint64_t(3UL) << VT*2);
731     OpActions[Op] |= (uint64_t)Action << VT*2;
732   }
733   
734   /// setLoadXAction - Indicate that the specified load with extension does not
735   /// work with the with specified type and indicate what to do about it.
736   void setLoadXAction(unsigned ExtType, MVT::ValueType VT,
737                       LegalizeAction Action) {
738     assert(VT < 32 && ExtType < sizeof(LoadXActions)/sizeof(LoadXActions[0]) &&
739            "Table isn't big enough!");
740     LoadXActions[ExtType] &= ~(uint64_t(3UL) << VT*2);
741     LoadXActions[ExtType] |= (uint64_t)Action << VT*2;
742   }
743   
744   /// setStoreXAction - Indicate that the specified store with truncation does
745   /// not work with the with specified type and indicate what to do about it.
746   void setStoreXAction(MVT::ValueType VT, LegalizeAction Action) {
747     assert(VT < 32 && "Table isn't big enough!");
748     StoreXActions &= ~(uint64_t(3UL) << VT*2);
749     StoreXActions |= (uint64_t)Action << VT*2;
750   }
751
752   /// setIndexedLoadAction - Indicate that the specified indexed load does or
753   /// does not work with the with specified type and indicate what to do abort
754   /// it. NOTE: All indexed mode loads are initialized to Expand in
755   /// TargetLowering.cpp
756   void setIndexedLoadAction(unsigned IdxMode, MVT::ValueType VT,
757                             LegalizeAction Action) {
758     assert(VT < 32 && IdxMode <
759            sizeof(IndexedModeActions[0]) / sizeof(IndexedModeActions[0][0]) &&
760            "Table isn't big enough!");
761     IndexedModeActions[0][IdxMode] &= ~(uint64_t(3UL) << VT*2);
762     IndexedModeActions[0][IdxMode] |= (uint64_t)Action << VT*2;
763   }
764   
765   /// setIndexedStoreAction - Indicate that the specified indexed store does or
766   /// does not work with the with specified type and indicate what to do about
767   /// it. NOTE: All indexed mode stores are initialized to Expand in
768   /// TargetLowering.cpp
769   void setIndexedStoreAction(unsigned IdxMode, MVT::ValueType VT,
770                              LegalizeAction Action) {
771     assert(VT < 32 && IdxMode <
772            sizeof(IndexedModeActions[1]) / sizeof(IndexedModeActions[1][0]) &&
773            "Table isn't big enough!");
774     IndexedModeActions[1][IdxMode] &= ~(uint64_t(3UL) << VT*2);
775     IndexedModeActions[1][IdxMode] |= (uint64_t)Action << VT*2;
776   }
777   
778   /// AddPromotedToType - If Opc/OrigVT is specified as being promoted, the
779   /// promotion code defaults to trying a larger integer/fp until it can find
780   /// one that works.  If that default is insufficient, this method can be used
781   /// by the target to override the default.
782   void AddPromotedToType(unsigned Opc, MVT::ValueType OrigVT, 
783                          MVT::ValueType DestVT) {
784     PromoteToType[std::make_pair(Opc, OrigVT)] = DestVT;
785   }
786
787   /// addLegalFPImmediate - Indicate that this target can instruction select
788   /// the specified FP immediate natively.
789   void addLegalFPImmediate(double Imm) {
790     LegalFPImmediates.push_back(Imm);
791   }
792
793   /// setTargetDAGCombine - Targets should invoke this method for each target
794   /// independent node that they want to provide a custom DAG combiner for by
795   /// implementing the PerformDAGCombine virtual method.
796   void setTargetDAGCombine(ISD::NodeType NT) {
797     TargetDAGCombineArray[NT >> 3] |= 1 << (NT&7);
798   }
799   
800   /// setJumpBufSize - Set the target's required jmp_buf buffer size (in
801   /// bytes); default is 200
802   void setJumpBufSize(unsigned Size) {
803     JumpBufSize = Size;
804   }
805
806   /// setJumpBufAlignment - Set the target's required jmp_buf buffer
807   /// alignment (in bytes); default is 0
808   void setJumpBufAlignment(unsigned Align) {
809     JumpBufAlignment = Align;
810   }
811   
812 public:
813
814   //===--------------------------------------------------------------------===//
815   // Lowering methods - These methods must be implemented by targets so that
816   // the SelectionDAGLowering code knows how to lower these.
817   //
818
819   /// LowerArguments - This hook must be implemented to indicate how we should
820   /// lower the arguments for the specified function, into the specified DAG.
821   virtual std::vector<SDOperand>
822   LowerArguments(Function &F, SelectionDAG &DAG);
823
824   /// LowerCallTo - This hook lowers an abstract call to a function into an
825   /// actual call.  This returns a pair of operands.  The first element is the
826   /// return value for the function (if RetTy is not VoidTy).  The second
827   /// element is the outgoing token chain.
828   struct ArgListEntry {
829     SDOperand Node;
830     const Type* Ty;
831     bool isSigned;
832   };
833   typedef std::vector<ArgListEntry> ArgListTy;
834   virtual std::pair<SDOperand, SDOperand>
835   LowerCallTo(SDOperand Chain, const Type *RetTy, bool RetTyIsSigned, 
836               bool isVarArg, unsigned CallingConv, bool isTailCall, 
837               SDOperand Callee, ArgListTy &Args, SelectionDAG &DAG);
838
839   /// LowerFrameReturnAddress - This hook lowers a call to llvm.returnaddress or
840   /// llvm.frameaddress (depending on the value of the first argument).  The
841   /// return values are the result pointer and the resultant token chain.  If
842   /// not implemented, both of these intrinsics will return null.
843   virtual std::pair<SDOperand, SDOperand>
844   LowerFrameReturnAddress(bool isFrameAddr, SDOperand Chain, unsigned Depth,
845                           SelectionDAG &DAG);
846
847   /// LowerOperation - This callback is invoked for operations that are 
848   /// unsupported by the target, which are registered to use 'custom' lowering,
849   /// and whose defined values are all legal.
850   /// If the target has no operations that require custom lowering, it need not
851   /// implement this.  The default implementation of this aborts.
852   virtual SDOperand LowerOperation(SDOperand Op, SelectionDAG &DAG);
853
854   /// CustomPromoteOperation - This callback is invoked for operations that are
855   /// unsupported by the target, are registered to use 'custom' lowering, and
856   /// whose type needs to be promoted.
857   virtual SDOperand CustomPromoteOperation(SDOperand Op, SelectionDAG &DAG);
858   
859   /// getTargetNodeName() - This method returns the name of a target specific
860   /// DAG node.
861   virtual const char *getTargetNodeName(unsigned Opcode) const;
862
863   //===--------------------------------------------------------------------===//
864   // Inline Asm Support hooks
865   //
866   
867   enum ConstraintType {
868     C_Register,            // Constraint represents a single register.
869     C_RegisterClass,       // Constraint represents one or more registers.
870     C_Memory,              // Memory constraint.
871     C_Other,               // Something else.
872     C_Unknown              // Unsupported constraint.
873   };
874   
875   /// getConstraintType - Given a constraint letter, return the type of
876   /// constraint it is for this target.
877   virtual ConstraintType getConstraintType(char ConstraintLetter) const;
878   
879   
880   /// getRegClassForInlineAsmConstraint - Given a constraint letter (e.g. "r"),
881   /// return a list of registers that can be used to satisfy the constraint.
882   /// This should only be used for C_RegisterClass constraints.
883   virtual std::vector<unsigned> 
884   getRegClassForInlineAsmConstraint(const std::string &Constraint,
885                                     MVT::ValueType VT) const;
886
887   /// getRegForInlineAsmConstraint - Given a physical register constraint (e.g.
888   /// {edx}), return the register number and the register class for the
889   /// register.
890   ///
891   /// Given a register class constraint, like 'r', if this corresponds directly
892   /// to an LLVM register class, return a register of 0 and the register class
893   /// pointer.
894   ///
895   /// This should only be used for C_Register constraints.  On error,
896   /// this returns a register number of 0 and a null register class pointer..
897   virtual std::pair<unsigned, const TargetRegisterClass*> 
898     getRegForInlineAsmConstraint(const std::string &Constraint,
899                                  MVT::ValueType VT) const;
900   
901   
902   /// isOperandValidForConstraint - Return the specified operand (possibly
903   /// modified) if the specified SDOperand is valid for the specified target
904   /// constraint letter, otherwise return null.
905   virtual SDOperand 
906     isOperandValidForConstraint(SDOperand Op, char ConstraintLetter,
907                                 SelectionDAG &DAG);
908   
909   //===--------------------------------------------------------------------===//
910   // Scheduler hooks
911   //
912   
913   // InsertAtEndOfBasicBlock - This method should be implemented by targets that
914   // mark instructions with the 'usesCustomDAGSchedInserter' flag.  These
915   // instructions are special in various ways, which require special support to
916   // insert.  The specified MachineInstr is created but not inserted into any
917   // basic blocks, and the scheduler passes ownership of it to this method.
918   virtual MachineBasicBlock *InsertAtEndOfBasicBlock(MachineInstr *MI,
919                                                      MachineBasicBlock *MBB);
920
921   //===--------------------------------------------------------------------===//
922   // Loop Strength Reduction hooks
923   //
924   
925   /// isLegalAddressImmediate - Return true if the integer value or GlobalValue
926   /// can be used as the offset of the target addressing mode.
927   virtual bool isLegalAddressImmediate(int64_t V) const;
928   virtual bool isLegalAddressImmediate(GlobalValue *GV) const;
929
930   typedef std::vector<unsigned>::const_iterator legal_am_scale_iterator;
931   legal_am_scale_iterator legal_am_scale_begin() const {
932     return LegalAddressScales.begin();
933   }
934   legal_am_scale_iterator legal_am_scale_end() const {
935     return LegalAddressScales.end();
936   }
937
938   //===--------------------------------------------------------------------===//
939   // Div utility functions
940   //
941   SDOperand BuildSDIV(SDNode *N, SelectionDAG &DAG, 
942                       std::vector<SDNode*>* Created) const;
943   SDOperand BuildUDIV(SDNode *N, SelectionDAG &DAG, 
944                       std::vector<SDNode*>* Created) const;
945
946
947   //===--------------------------------------------------------------------===//
948   // Runtime Library hooks
949   //
950
951   /// setLibcallName - Rename the default libcall routine name for the specified
952   /// libcall.
953   void setLibcallName(RTLIB::Libcall Call, std::string Name) {
954     LibcallRoutineNames[Call] = Name;
955   }
956
957   /// getLibcallName - Get the libcall routine name for the specified libcall.
958   ///
959   const char *getLibcallName(RTLIB::Libcall Call) const {
960     return LibcallRoutineNames[Call].c_str();
961   }
962
963 protected:
964   /// addLegalAddressScale - Add a integer (> 1) value which can be used as
965   /// scale in the target addressing mode. Note: the ordering matters so the
966   /// least efficient ones should be entered first.
967   void addLegalAddressScale(unsigned Scale) {
968     LegalAddressScales.push_back(Scale);
969   }
970
971 private:
972   std::vector<unsigned> LegalAddressScales;
973   
974   TargetMachine &TM;
975   const TargetData *TD;
976
977   /// IsLittleEndian - True if this is a little endian target.
978   ///
979   bool IsLittleEndian;
980
981   /// PointerTy - The type to use for pointers, usually i32 or i64.
982   ///
983   MVT::ValueType PointerTy;
984
985   /// UsesGlobalOffsetTable - True if this target uses a GOT for PIC codegen.
986   ///
987   bool UsesGlobalOffsetTable;
988   
989   /// ShiftAmountTy - The type to use for shift amounts, usually i8 or whatever
990   /// PointerTy is.
991   MVT::ValueType ShiftAmountTy;
992
993   OutOfRangeShiftAmount ShiftAmtHandling;
994
995   /// SelectIsExpensive - Tells the code generator not to expand operations
996   /// into sequences that use the select operations if possible.
997   bool SelectIsExpensive;
998
999   /// IntDivIsCheap - Tells the code generator not to expand integer divides by
1000   /// constants into a sequence of muls, adds, and shifts.  This is a hack until
1001   /// a real cost model is in place.  If we ever optimize for size, this will be
1002   /// set to true unconditionally.
1003   bool IntDivIsCheap;
1004   
1005   /// Pow2DivIsCheap - Tells the code generator that it shouldn't generate
1006   /// srl/add/sra for a signed divide by power of two, and let the target handle
1007   /// it.
1008   bool Pow2DivIsCheap;
1009   
1010   /// SetCCResultTy - The type that SetCC operations use.  This defaults to the
1011   /// PointerTy.
1012   MVT::ValueType SetCCResultTy;
1013
1014   /// SetCCResultContents - Information about the contents of the high-bits in
1015   /// the result of a setcc comparison operation.
1016   SetCCResultValue SetCCResultContents;
1017
1018   /// SchedPreferenceInfo - The target scheduling preference: shortest possible
1019   /// total cycles or lowest register usage.
1020   SchedPreference SchedPreferenceInfo;
1021   
1022   /// UseUnderscoreSetJmp - This target prefers to use _setjmp to implement
1023   /// llvm.setjmp.  Defaults to false.
1024   bool UseUnderscoreSetJmp;
1025
1026   /// UseUnderscoreLongJmp - This target prefers to use _longjmp to implement
1027   /// llvm.longjmp.  Defaults to false.
1028   bool UseUnderscoreLongJmp;
1029
1030   /// JumpBufSize - The size, in bytes, of the target's jmp_buf buffers
1031   unsigned JumpBufSize;
1032   
1033   /// JumpBufAlignment - The alignment, in bytes, of the target's jmp_buf
1034   /// buffers
1035   unsigned JumpBufAlignment;
1036   
1037   /// StackPointerRegisterToSaveRestore - If set to a physical register, this
1038   /// specifies the register that llvm.savestack/llvm.restorestack should save
1039   /// and restore.
1040   unsigned StackPointerRegisterToSaveRestore;
1041
1042   /// RegClassForVT - This indicates the default register class to use for
1043   /// each ValueType the target supports natively.
1044   TargetRegisterClass *RegClassForVT[MVT::LAST_VALUETYPE];
1045   unsigned char NumElementsForVT[MVT::LAST_VALUETYPE];
1046
1047   /// TransformToType - For any value types we are promoting or expanding, this
1048   /// contains the value type that we are changing to.  For Expanded types, this
1049   /// contains one step of the expand (e.g. i64 -> i32), even if there are
1050   /// multiple steps required (e.g. i64 -> i16).  For types natively supported
1051   /// by the system, this holds the same type (e.g. i32 -> i32).
1052   MVT::ValueType TransformToType[MVT::LAST_VALUETYPE];
1053
1054   /// OpActions - For each operation and each value type, keep a LegalizeAction
1055   /// that indicates how instruction selection should deal with the operation.
1056   /// Most operations are Legal (aka, supported natively by the target), but
1057   /// operations that are not should be described.  Note that operations on
1058   /// non-legal value types are not described here.
1059   uint64_t OpActions[156];
1060   
1061   /// LoadXActions - For each load of load extension type and each value type,
1062   /// keep a LegalizeAction that indicates how instruction selection should deal
1063   /// with the load.
1064   uint64_t LoadXActions[ISD::LAST_LOADX_TYPE];
1065   
1066   /// StoreXActions - For each store with truncation of each value type, keep a
1067   /// LegalizeAction that indicates how instruction selection should deal with
1068   /// the store.
1069   uint64_t StoreXActions;
1070
1071   /// IndexedModeActions - For each indexed mode and each value type, keep a
1072   /// pair of LegalizeAction that indicates how instruction selection should
1073   /// deal with the load / store.
1074   uint64_t IndexedModeActions[2][ISD::LAST_INDEXED_MODE];
1075   
1076   ValueTypeActionImpl ValueTypeActions;
1077
1078   std::vector<double> LegalFPImmediates;
1079
1080   std::vector<std::pair<MVT::ValueType,
1081                         TargetRegisterClass*> > AvailableRegClasses;
1082
1083   /// TargetDAGCombineArray - Targets can specify ISD nodes that they would
1084   /// like PerformDAGCombine callbacks for by calling setTargetDAGCombine(),
1085   /// which sets a bit in this array.
1086   unsigned char TargetDAGCombineArray[156/(sizeof(unsigned char)*8)];
1087   
1088   /// PromoteToType - For operations that must be promoted to a specific type,
1089   /// this holds the destination type.  This map should be sparse, so don't hold
1090   /// it as an array.
1091   ///
1092   /// Targets add entries to this map with AddPromotedToType(..), clients access
1093   /// this with getTypeToPromoteTo(..).
1094   std::map<std::pair<unsigned, MVT::ValueType>, MVT::ValueType> PromoteToType;
1095
1096   /// LibcallRoutineNames - Stores the name each libcall.
1097   ///
1098   std::string LibcallRoutineNames[RTLIB::UNKNOWN_LIBCALL];
1099
1100 protected:
1101   /// When lowering %llvm.memset this field specifies the maximum number of
1102   /// store operations that may be substituted for the call to memset. Targets
1103   /// must set this value based on the cost threshold for that target. Targets
1104   /// should assume that the memset will be done using as many of the largest
1105   /// store operations first, followed by smaller ones, if necessary, per
1106   /// alignment restrictions. For example, storing 9 bytes on a 32-bit machine
1107   /// with 16-bit alignment would result in four 2-byte stores and one 1-byte
1108   /// store.  This only applies to setting a constant array of a constant size.
1109   /// @brief Specify maximum number of store instructions per memset call.
1110   unsigned maxStoresPerMemset;
1111
1112   /// When lowering %llvm.memcpy this field specifies the maximum number of
1113   /// store operations that may be substituted for a call to memcpy. Targets
1114   /// must set this value based on the cost threshold for that target. Targets
1115   /// should assume that the memcpy will be done using as many of the largest
1116   /// store operations first, followed by smaller ones, if necessary, per
1117   /// alignment restrictions. For example, storing 7 bytes on a 32-bit machine
1118   /// with 32-bit alignment would result in one 4-byte store, a one 2-byte store
1119   /// and one 1-byte store. This only applies to copying a constant array of
1120   /// constant size.
1121   /// @brief Specify maximum bytes of store instructions per memcpy call.
1122   unsigned maxStoresPerMemcpy;
1123
1124   /// When lowering %llvm.memmove this field specifies the maximum number of
1125   /// store instructions that may be substituted for a call to memmove. Targets
1126   /// must set this value based on the cost threshold for that target. Targets
1127   /// should assume that the memmove will be done using as many of the largest
1128   /// store operations first, followed by smaller ones, if necessary, per
1129   /// alignment restrictions. For example, moving 9 bytes on a 32-bit machine
1130   /// with 8-bit alignment would result in nine 1-byte stores.  This only
1131   /// applies to copying a constant array of constant size.
1132   /// @brief Specify maximum bytes of store instructions per memmove call.
1133   unsigned maxStoresPerMemmove;
1134
1135   /// This field specifies whether the target machine permits unaligned memory
1136   /// accesses.  This is used, for example, to determine the size of store 
1137   /// operations when copying small arrays and other similar tasks.
1138   /// @brief Indicate whether the target permits unaligned memory accesses.
1139   bool allowUnalignedMemoryAccesses;
1140 };
1141 } // end llvm namespace
1142
1143 #endif