Add a framework for eliminating instructions that produces undemanded bits.
[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/ValueTypes.h"
27 #include "llvm/Support/DataTypes.h"
28 #include <vector>
29
30 namespace llvm {
31   class Value;
32   class Function;
33   class TargetMachine;
34   class TargetData;
35   class TargetRegisterClass;
36   class SDNode;
37   class SDOperand;
38   class SelectionDAG;
39   class MachineBasicBlock;
40   class MachineInstr;
41
42 //===----------------------------------------------------------------------===//
43 /// TargetLowering - This class defines information used to lower LLVM code to
44 /// legal SelectionDAG operators that the target instruction selector can accept
45 /// natively.
46 ///
47 /// This class also defines callbacks that targets must implement to lower
48 /// target-specific constructs to SelectionDAG operators.
49 ///
50 class TargetLowering {
51 public:
52   /// LegalizeAction - This enum indicates whether operations are valid for a
53   /// target, and if not, what action should be used to make them valid.
54   enum LegalizeAction {
55     Legal,      // The target natively supports this operation.
56     Promote,    // This operation should be executed in a larger type.
57     Expand,     // Try to expand this to other ops, otherwise use a libcall.
58     Custom,     // Use the LowerOperation hook to implement custom lowering.
59   };
60
61   enum OutOfRangeShiftAmount {
62     Undefined,  // Oversized shift amounts are undefined (default).
63     Mask,       // Shift amounts are auto masked (anded) to value size.
64     Extend,     // Oversized shift pulls in zeros or sign bits.
65   };
66
67   enum SetCCResultValue {
68     UndefinedSetCCResult,          // SetCC returns a garbage/unknown extend.
69     ZeroOrOneSetCCResult,          // SetCC returns a zero extended result.
70     ZeroOrNegativeOneSetCCResult,  // SetCC returns a sign extended result.
71   };
72
73   enum SchedPreference {
74     SchedulingForLatency,          // Scheduling for shortest total latency.
75     SchedulingForRegPressure,      // Scheduling for lowest register pressure.
76   };
77
78   TargetLowering(TargetMachine &TM);
79   virtual ~TargetLowering();
80
81   TargetMachine &getTargetMachine() const { return TM; }
82   const TargetData &getTargetData() const { return TD; }
83
84   bool isLittleEndian() const { return IsLittleEndian; }
85   MVT::ValueType getPointerTy() const { return PointerTy; }
86   MVT::ValueType getShiftAmountTy() const { return ShiftAmountTy; }
87   OutOfRangeShiftAmount getShiftAmountFlavor() const {return ShiftAmtHandling; }
88
89   /// isSetCCExpensive - Return true if the setcc operation is expensive for
90   /// this target.
91   bool isSetCCExpensive() const { return SetCCIsExpensive; }
92   
93   /// isIntDivCheap() - Return true if integer divide is usually cheaper than
94   /// a sequence of several shifts, adds, and multiplies for this target.
95   bool isIntDivCheap() const { return IntDivIsCheap; }
96
97   /// isPow2DivCheap() - Return true if pow2 div is cheaper than a chain of
98   /// srl/add/sra.
99   bool isPow2DivCheap() const { return Pow2DivIsCheap; }
100   
101   /// getSetCCResultTy - Return the ValueType of the result of setcc operations.
102   ///
103   MVT::ValueType getSetCCResultTy() const { return SetCCResultTy; }
104
105   /// getSetCCResultContents - For targets without boolean registers, this flag
106   /// returns information about the contents of the high-bits in the setcc
107   /// result register.
108   SetCCResultValue getSetCCResultContents() const { return SetCCResultContents;}
109
110   /// getSchedulingPreference - Return target scheduling preference.
111   SchedPreference getSchedulingPreference() const {
112     return SchedPreferenceInfo;
113   }
114
115   /// getRegClassFor - Return the register class that should be used for the
116   /// specified value type.  This may only be called on legal types.
117   TargetRegisterClass *getRegClassFor(MVT::ValueType VT) const {
118     TargetRegisterClass *RC = RegClassForVT[VT];
119     assert(RC && "This value type is not natively supported!");
120     return RC;
121   }
122   
123   /// isTypeLegal - Return true if the target has native support for the
124   /// specified value type.  This means that it has a register that directly
125   /// holds it without promotions or expansions.
126   bool isTypeLegal(MVT::ValueType VT) const {
127     return RegClassForVT[VT] != 0;
128   }
129
130   class ValueTypeActionImpl {
131     /// ValueTypeActions - This is a bitvector that contains two bits for each
132     /// value type, where the two bits correspond to the LegalizeAction enum.
133     /// This can be queried with "getTypeAction(VT)".
134     uint32_t ValueTypeActions[2];
135   public:
136     ValueTypeActionImpl() {
137       ValueTypeActions[0] = ValueTypeActions[1] = 0;
138     }
139     ValueTypeActionImpl(const ValueTypeActionImpl &RHS) {
140       ValueTypeActions[0] = RHS.ValueTypeActions[0];
141       ValueTypeActions[1] = RHS.ValueTypeActions[1];
142     }
143     
144     LegalizeAction getTypeAction(MVT::ValueType VT) const {
145       return (LegalizeAction)((ValueTypeActions[VT>>4] >> ((2*VT) & 31)) & 3);
146     }
147     void setTypeAction(MVT::ValueType VT, LegalizeAction Action) {
148       assert(unsigned(VT >> 4) < 
149              sizeof(ValueTypeActions)/sizeof(ValueTypeActions[0]));
150       ValueTypeActions[VT>>4] |= Action << ((VT*2) & 31);
151     }
152   };
153   
154   const ValueTypeActionImpl &getValueTypeActions() const {
155     return ValueTypeActions;
156   }
157   
158   /// getTypeAction - Return how we should legalize values of this type, either
159   /// it is already legal (return 'Legal') or we need to promote it to a larger
160   /// type (return 'Promote'), or we need to expand it into multiple registers
161   /// of smaller integer type (return 'Expand').  'Custom' is not an option.
162   LegalizeAction getTypeAction(MVT::ValueType VT) const {
163     return ValueTypeActions.getTypeAction(VT);
164   }
165
166   /// getTypeToTransformTo - For types supported by the target, this is an
167   /// identity function.  For types that must be promoted to larger types, this
168   /// returns the larger type to promote to.  For types that are larger than the
169   /// largest integer register, this contains one step in the expansion to get
170   /// to the smaller register.
171   MVT::ValueType getTypeToTransformTo(MVT::ValueType VT) const {
172     return TransformToType[VT];
173   }
174
175   typedef std::vector<double>::const_iterator legal_fpimm_iterator;
176   legal_fpimm_iterator legal_fpimm_begin() const {
177     return LegalFPImmediates.begin();
178   }
179   legal_fpimm_iterator legal_fpimm_end() const {
180     return LegalFPImmediates.end();
181   }
182
183   /// getOperationAction - Return how this operation should be treated: either
184   /// it is legal, needs to be promoted to a larger size, needs to be
185   /// expanded to some other code sequence, or the target has a custom expander
186   /// for it.
187   LegalizeAction getOperationAction(unsigned Op, MVT::ValueType VT) const {
188     return (LegalizeAction)((OpActions[Op] >> (2*VT)) & 3);
189   }
190   
191   /// isOperationLegal - Return true if the specified operation is legal on this
192   /// target.
193   bool isOperationLegal(unsigned Op, MVT::ValueType VT) const {
194     return getOperationAction(Op, VT) == Legal;
195   }
196
197   /// getTypeToPromoteTo - If the action for this operation is to promote, this
198   /// method returns the ValueType to promote to.
199   MVT::ValueType getTypeToPromoteTo(unsigned Op, MVT::ValueType VT) const {
200     assert(getOperationAction(Op, VT) == Promote &&
201            "This operation isn't promoted!");
202     MVT::ValueType NVT = VT;
203     do {
204       NVT = (MVT::ValueType)(NVT+1);
205       assert(MVT::isInteger(NVT) == MVT::isInteger(VT) && NVT != MVT::isVoid &&
206              "Didn't find type to promote to!");
207     } while (!isTypeLegal(NVT) ||
208               getOperationAction(Op, NVT) == Promote);
209     return NVT;
210   }
211
212   /// getValueType - Return the MVT::ValueType corresponding to this LLVM type.
213   /// This is fixed by the LLVM operations except for the pointer size.
214   MVT::ValueType getValueType(const Type *Ty) const {
215     switch (Ty->getTypeID()) {
216     default: assert(0 && "Unknown type!");
217     case Type::VoidTyID:    return MVT::isVoid;
218     case Type::BoolTyID:    return MVT::i1;
219     case Type::UByteTyID:
220     case Type::SByteTyID:   return MVT::i8;
221     case Type::ShortTyID:
222     case Type::UShortTyID:  return MVT::i16;
223     case Type::IntTyID:
224     case Type::UIntTyID:    return MVT::i32;
225     case Type::LongTyID:
226     case Type::ULongTyID:   return MVT::i64;
227     case Type::FloatTyID:   return MVT::f32;
228     case Type::DoubleTyID:  return MVT::f64;
229     case Type::PointerTyID: return PointerTy;
230     case Type::PackedTyID:  return MVT::Vector;
231     }
232   }
233
234   /// getNumElements - Return the number of registers that this ValueType will
235   /// eventually require.  This is always one for all non-integer types, is
236   /// one for any types promoted to live in larger registers, but may be more
237   /// than one for types (like i64) that are split into pieces.
238   unsigned getNumElements(MVT::ValueType VT) const {
239     return NumElementsForVT[VT];
240   }
241
242   /// This function returns the maximum number of store operations permitted
243   /// to replace a call to llvm.memset. The value is set by the target at the
244   /// performance threshold for such a replacement.
245   /// @brief Get maximum # of store operations permitted for llvm.memset
246   unsigned getMaxStoresPerMemSet() const { return maxStoresPerMemSet; }
247
248   /// This function returns the maximum number of store operations permitted
249   /// to replace a call to llvm.memcpy. The value is set by the target at the
250   /// performance threshold for such a replacement.
251   /// @brief Get maximum # of store operations permitted for llvm.memcpy
252   unsigned getMaxStoresPerMemCpy() const { return maxStoresPerMemCpy; }
253
254   /// This function returns the maximum number of store operations permitted
255   /// to replace a call to llvm.memmove. The value is set by the target at the
256   /// performance threshold for such a replacement.
257   /// @brief Get maximum # of store operations permitted for llvm.memmove
258   unsigned getMaxStoresPerMemMove() const { return maxStoresPerMemMove; }
259
260   /// This function returns true if the target allows unaligned memory accesses.
261   /// This is used, for example, in situations where an array copy/move/set is 
262   /// converted to a sequence of store operations. It's use helps to ensure that
263   /// such replacements don't generate code that causes an alignment error 
264   /// (trap) on the target machine. 
265   /// @brief Determine if the target supports unaligned memory accesses.
266   bool allowsUnalignedMemoryAccesses() const {
267     return allowUnalignedMemoryAccesses;
268   }
269   
270   /// usesUnderscoreSetJmpLongJmp - Determine if we should use _setjmp or setjmp
271   /// to implement llvm.setjmp.
272   bool usesUnderscoreSetJmpLongJmp() const {
273     return UseUnderscoreSetJmpLongJmp;
274   }
275   
276   /// getStackPointerRegisterToSaveRestore - If a physical register, this
277   /// specifies the register that llvm.savestack/llvm.restorestack should save
278   /// and restore.
279   unsigned getStackPointerRegisterToSaveRestore() const {
280     return StackPointerRegisterToSaveRestore;
281   }
282
283   //===--------------------------------------------------------------------===//
284   // TargetLowering Optimization Methods
285   //
286   
287   /// MaskedValueIsZero - Return true if 'Op & Mask' is known to be zero.  We
288   /// use this predicate to simplify operations downstream.  Op and Mask are
289   /// known to be the same type.  Targets can implement the 
290   /// isMaskedValueZeroForTargetNode method, to allow target nodes to be
291   /// understood.
292   bool MaskedValueIsZero(const SDOperand &Op, uint64_t Mask) const;
293   
294   /// DemandedBitsAreZero - Return true if 'Op & Mask' demands no bits from a 
295   /// bit set operation such as a sign extend or or/xor with constant whose only
296   /// use is Op.  If it returns true, the old node that sets bits which are
297   /// not demanded is returned in Old, and its replacement node is returned in
298   /// New, such that callers of SetBitsAreZero may call CombineTo on them if
299   /// desired.
300   bool DemandedBitsAreZero(const SDOperand &Op, uint64_t Mask, SDOperand &Old,
301                            SDOperand &New, SelectionDAG &DAG);
302
303   //===--------------------------------------------------------------------===//
304   // TargetLowering Configuration Methods - These methods should be invoked by
305   // the derived class constructor to configure this object for the target.
306   //
307
308 protected:
309
310   /// setShiftAmountType - Describe the type that should be used for shift
311   /// amounts.  This type defaults to the pointer type.
312   void setShiftAmountType(MVT::ValueType VT) { ShiftAmountTy = VT; }
313
314   /// setSetCCResultType - Describe the type that shoudl be used as the result
315   /// of a setcc operation.  This defaults to the pointer type.
316   void setSetCCResultType(MVT::ValueType VT) { SetCCResultTy = VT; }
317
318   /// setSetCCResultContents - Specify how the target extends the result of a
319   /// setcc operation in a register.
320   void setSetCCResultContents(SetCCResultValue Ty) { SetCCResultContents = Ty; }
321
322   /// setSchedulingPreference - Specify the target scheduling preference.
323   void setSchedulingPreference(SchedPreference Pref) {
324     SchedPreferenceInfo = Pref;
325   }
326
327   /// setShiftAmountFlavor - Describe how the target handles out of range shift
328   /// amounts.
329   void setShiftAmountFlavor(OutOfRangeShiftAmount OORSA) {
330     ShiftAmtHandling = OORSA;
331   }
332
333   /// setUseUnderscoreSetJmpLongJmp - Indicate whether this target prefers to
334   /// use _setjmp and _longjmp to or implement llvm.setjmp/llvm.longjmp or
335   /// the non _ versions.  Defaults to false.
336   void setUseUnderscoreSetJmpLongJmp(bool Val) {
337     UseUnderscoreSetJmpLongJmp = Val;
338   }
339   
340   /// setStackPointerRegisterToSaveRestore - If set to a physical register, this
341   /// specifies the register that llvm.savestack/llvm.restorestack should save
342   /// and restore.
343   void setStackPointerRegisterToSaveRestore(unsigned R) {
344     StackPointerRegisterToSaveRestore = R;
345   }
346   
347   /// setSetCCIxExpensive - This is a short term hack for targets that codegen
348   /// setcc as a conditional branch.  This encourages the code generator to fold
349   /// setcc operations into other operations if possible.
350   void setSetCCIsExpensive() { SetCCIsExpensive = true; }
351
352   /// setIntDivIsCheap - Tells the code generator that integer divide is
353   /// expensive, and if possible, should be replaced by an alternate sequence
354   /// of instructions not containing an integer divide.
355   void setIntDivIsCheap(bool isCheap = true) { IntDivIsCheap = isCheap; }
356   
357   /// setPow2DivIsCheap - Tells the code generator that it shouldn't generate
358   /// srl/add/sra for a signed divide by power of two, and let the target handle
359   /// it.
360   void setPow2DivIsCheap(bool isCheap = true) { Pow2DivIsCheap = isCheap; }
361   
362   /// addRegisterClass - Add the specified register class as an available
363   /// regclass for the specified value type.  This indicates the selector can
364   /// handle values of that class natively.
365   void addRegisterClass(MVT::ValueType VT, TargetRegisterClass *RC) {
366     AvailableRegClasses.push_back(std::make_pair(VT, RC));
367     RegClassForVT[VT] = RC;
368   }
369
370   /// computeRegisterProperties - Once all of the register classes are added,
371   /// this allows us to compute derived properties we expose.
372   void computeRegisterProperties();
373
374   /// setOperationAction - Indicate that the specified operation does not work
375   /// with the specified type and indicate what to do about it.
376   void setOperationAction(unsigned Op, MVT::ValueType VT,
377                           LegalizeAction Action) {
378     assert(VT < 32 && Op < sizeof(OpActions)/sizeof(OpActions[0]) &&
379            "Table isn't big enough!");
380     OpActions[Op] &= ~(3ULL << VT*2);
381     OpActions[Op] |= Action << VT*2;
382   }
383
384   /// addLegalFPImmediate - Indicate that this target can instruction select
385   /// the specified FP immediate natively.
386   void addLegalFPImmediate(double Imm) {
387     LegalFPImmediates.push_back(Imm);
388   }
389
390 public:
391
392   //===--------------------------------------------------------------------===//
393   // Lowering methods - These methods must be implemented by targets so that
394   // the SelectionDAGLowering code knows how to lower these.
395   //
396
397   /// LowerArguments - This hook must be implemented to indicate how we should
398   /// lower the arguments for the specified function, into the specified DAG.
399   virtual std::vector<SDOperand>
400   LowerArguments(Function &F, SelectionDAG &DAG) = 0;
401
402   /// LowerCallTo - This hook lowers an abstract call to a function into an
403   /// actual call.  This returns a pair of operands.  The first element is the
404   /// return value for the function (if RetTy is not VoidTy).  The second
405   /// element is the outgoing token chain.
406   typedef std::vector<std::pair<SDOperand, const Type*> > ArgListTy;
407   virtual std::pair<SDOperand, SDOperand>
408   LowerCallTo(SDOperand Chain, const Type *RetTy, bool isVarArg,
409               unsigned CallingConv, bool isTailCall, SDOperand Callee,
410               ArgListTy &Args, SelectionDAG &DAG) = 0;
411
412   /// LowerFrameReturnAddress - This hook lowers a call to llvm.returnaddress or
413   /// llvm.frameaddress (depending on the value of the first argument).  The
414   /// return values are the result pointer and the resultant token chain.  If
415   /// not implemented, both of these intrinsics will return null.
416   virtual std::pair<SDOperand, SDOperand>
417   LowerFrameReturnAddress(bool isFrameAddr, SDOperand Chain, unsigned Depth,
418                           SelectionDAG &DAG);
419
420   /// LowerOperation - This callback is invoked for operations that are 
421   /// unsupported by the target, which are registered to use 'custom' lowering,
422   /// and whose defined values are all legal.
423   /// If the target has no operations that require custom lowering, it need not
424   /// implement this.  The default implementation of this aborts.
425   virtual SDOperand LowerOperation(SDOperand Op, SelectionDAG &DAG);
426
427   /// CustomPromoteOperation - This callback is invoked for operations that are
428   /// unsupported by the target, are registered to use 'custom' lowering, and
429   /// whose type needs to be promoted.
430   virtual SDOperand CustomPromoteOperation(SDOperand Op, SelectionDAG &DAG);
431   
432   /// getTargetNodeName() - This method returns the name of a target specific
433   /// DAG node.
434   virtual const char *getTargetNodeName(unsigned Opcode) const;
435
436   /// isMaskedValueZeroForTargetNode - Return true if 'Op & Mask' is known to
437   /// be zero. Op is expected to be a target specific node.
438   virtual bool isMaskedValueZeroForTargetNode(const SDOperand &Op,
439                                               uint64_t Mask) const;
440
441   //===--------------------------------------------------------------------===//
442   // Inline Asm Support hooks
443   //
444   
445   /// getRegForInlineAsmConstraint - Given a constraint letter or register
446   /// name (e.g. "r" or "edx"), return a list of registers that can be used to
447   /// satisfy the constraint.  If the constraint isn't supported, or isn't a
448   /// register constraint, return an empty list.
449   virtual std::vector<unsigned> 
450   getRegForInlineAsmConstraint(const std::string &Constraint) const;
451   
452   //===--------------------------------------------------------------------===//
453   // Scheduler hooks
454   //
455   
456   // InsertAtEndOfBasicBlock - This method should be implemented by targets that
457   // mark instructions with the 'usesCustomDAGSchedInserter' flag.  These
458   // instructions are special in various ways, which require special support to
459   // insert.  The specified MachineInstr is created but not inserted into any
460   // basic blocks, and the scheduler passes ownership of it to this method.
461   virtual MachineBasicBlock *InsertAtEndOfBasicBlock(MachineInstr *MI,
462                                                      MachineBasicBlock *MBB);
463
464 private:
465   TargetMachine &TM;
466   const TargetData &TD;
467
468   /// IsLittleEndian - True if this is a little endian target.
469   ///
470   bool IsLittleEndian;
471
472   /// PointerTy - The type to use for pointers, usually i32 or i64.
473   ///
474   MVT::ValueType PointerTy;
475
476   /// ShiftAmountTy - The type to use for shift amounts, usually i8 or whatever
477   /// PointerTy is.
478   MVT::ValueType ShiftAmountTy;
479
480   OutOfRangeShiftAmount ShiftAmtHandling;
481
482   /// SetCCIsExpensive - This is a short term hack for targets that codegen
483   /// setcc as a conditional branch.  This encourages the code generator to fold
484   /// setcc operations into other operations if possible.
485   bool SetCCIsExpensive;
486
487   /// IntDivIsCheap - Tells the code generator not to expand integer divides by
488   /// constants into a sequence of muls, adds, and shifts.  This is a hack until
489   /// a real cost model is in place.  If we ever optimize for size, this will be
490   /// set to true unconditionally.
491   bool IntDivIsCheap;
492   
493   /// Pow2DivIsCheap - Tells the code generator that it shouldn't generate
494   /// srl/add/sra for a signed divide by power of two, and let the target handle
495   /// it.
496   bool Pow2DivIsCheap;
497   
498   /// SetCCResultTy - The type that SetCC operations use.  This defaults to the
499   /// PointerTy.
500   MVT::ValueType SetCCResultTy;
501
502   /// SetCCResultContents - Information about the contents of the high-bits in
503   /// the result of a setcc comparison operation.
504   SetCCResultValue SetCCResultContents;
505
506   /// SchedPreferenceInfo - The target scheduling preference: shortest possible
507   /// total cycles or lowest register usage.
508   SchedPreference SchedPreferenceInfo;
509   
510   /// UseUnderscoreSetJmpLongJmp - This target prefers to use _setjmp and
511   /// _longjmp to implement llvm.setjmp/llvm.longjmp.  Defaults to false.
512   bool UseUnderscoreSetJmpLongJmp;
513   
514   /// StackPointerRegisterToSaveRestore - If set to a physical register, this
515   /// specifies the register that llvm.savestack/llvm.restorestack should save
516   /// and restore.
517   unsigned StackPointerRegisterToSaveRestore;
518
519   /// RegClassForVT - This indicates the default register class to use for
520   /// each ValueType the target supports natively.
521   TargetRegisterClass *RegClassForVT[MVT::LAST_VALUETYPE];
522   unsigned char NumElementsForVT[MVT::LAST_VALUETYPE];
523
524   /// TransformToType - For any value types we are promoting or expanding, this
525   /// contains the value type that we are changing to.  For Expanded types, this
526   /// contains one step of the expand (e.g. i64 -> i32), even if there are
527   /// multiple steps required (e.g. i64 -> i16).  For types natively supported
528   /// by the system, this holds the same type (e.g. i32 -> i32).
529   MVT::ValueType TransformToType[MVT::LAST_VALUETYPE];
530
531   /// OpActions - For each operation and each value type, keep a LegalizeAction
532   /// that indicates how instruction selection should deal with the operation.
533   /// Most operations are Legal (aka, supported natively by the target), but
534   /// operations that are not should be described.  Note that operations on
535   /// non-legal value types are not described here.
536   uint64_t OpActions[128];
537   
538   ValueTypeActionImpl ValueTypeActions;
539
540   std::vector<double> LegalFPImmediates;
541
542   std::vector<std::pair<MVT::ValueType,
543                         TargetRegisterClass*> > AvailableRegClasses;
544
545 protected:
546   /// When lowering %llvm.memset this field specifies the maximum number of
547   /// store operations that may be substituted for the call to memset. Targets
548   /// must set this value based on the cost threshold for that target. Targets
549   /// should assume that the memset will be done using as many of the largest
550   /// store operations first, followed by smaller ones, if necessary, per
551   /// alignment restrictions. For example, storing 9 bytes on a 32-bit machine
552   /// with 16-bit alignment would result in four 2-byte stores and one 1-byte
553   /// store.  This only applies to setting a constant array of a constant size.
554   /// @brief Specify maximum number of store instructions per memset call.
555   unsigned maxStoresPerMemSet;
556
557   /// When lowering %llvm.memcpy this field specifies the maximum number of
558   /// store operations that may be substituted for a call to memcpy. Targets
559   /// must set this value based on the cost threshold for that target. Targets
560   /// should assume that the memcpy will be done using as many of the largest
561   /// store operations first, followed by smaller ones, if necessary, per
562   /// alignment restrictions. For example, storing 7 bytes on a 32-bit machine
563   /// with 32-bit alignment would result in one 4-byte store, a one 2-byte store
564   /// and one 1-byte store. This only applies to copying a constant array of
565   /// constant size.
566   /// @brief Specify maximum bytes of store instructions per memcpy call.
567   unsigned maxStoresPerMemCpy;
568
569   /// When lowering %llvm.memmove this field specifies the maximum number of
570   /// store instructions that may be substituted for a call to memmove. Targets
571   /// must set this value based on the cost threshold for that target. Targets
572   /// should assume that the memmove will be done using as many of the largest
573   /// store operations first, followed by smaller ones, if necessary, per
574   /// alignment restrictions. For example, moving 9 bytes on a 32-bit machine
575   /// with 8-bit alignment would result in nine 1-byte stores.  This only
576   /// applies to copying a constant array of constant size.
577   /// @brief Specify maximum bytes of store instructions per memmove call.
578   unsigned maxStoresPerMemMove;
579
580   /// This field specifies whether the target machine permits unaligned memory
581   /// accesses.  This is used, for example, to determine the size of store 
582   /// operations when copying small arrays and other similar tasks.
583   /// @brief Indicate whether the target permits unaligned memory accesses.
584   bool allowUnalignedMemoryAccesses;
585 };
586 } // end llvm namespace
587
588 #endif