1 //===- AlignFragment.h ----------------------------------------------------===//
2 //
3 //                     The MCLinker Project
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 #ifndef MCLD_FRAGMENT_ALIGNFRAGMENT_H_
10 #define MCLD_FRAGMENT_ALIGNFRAGMENT_H_
11 
12 #include "mcld/Fragment/Fragment.h"
13 
14 namespace mcld {
15 
16 class SectionData;
17 
18 class AlignFragment : public Fragment {
19  public:
20   AlignFragment(unsigned int pAlignment,
21                 int64_t pValue,
22                 unsigned int pValueSize,
23                 unsigned int pMaxBytesToEmit,
24                 SectionData* pSD = NULL);
25 
getAlignment()26   unsigned int getAlignment() const { return m_Alignment; }
27 
getValue()28   int64_t getValue() const { return m_Value; }
29 
getValueSize()30   unsigned int getValueSize() const { return m_ValueSize; }
31 
getMaxBytesToEmit()32   unsigned int getMaxBytesToEmit() const { return m_MaxBytesToEmit; }
33 
hasEmitNops()34   bool hasEmitNops() const { return m_bEmitNops; }
35 
setEmitNops(bool pValue)36   void setEmitNops(bool pValue) { m_bEmitNops = pValue; }
37 
classof(const Fragment * F)38   static bool classof(const Fragment* F) {
39     return F->getKind() == Fragment::Alignment;
40   }
41 
classof(const AlignFragment *)42   static bool classof(const AlignFragment*) { return true; }
43 
44   size_t size() const;
45 
46  private:
47   /// Alignment - The alignment to ensure, in bytes.
48   unsigned int m_Alignment;
49 
50   /// Value - Value to use for filling padding bytes.
51   int64_t m_Value;
52 
53   /// ValueSize - The size of the integer (in bytes) of \arg Value.
54   unsigned int m_ValueSize;
55 
56   /// MaxBytesToEmit - The maximum number of bytes to emit; if the alignment
57   /// cannot be satisfied in this width then this fragment is ignored.
58   unsigned int m_MaxBytesToEmit;
59 
60   /// EmitNops - Flag to indicate that (optimal) NOPs should be emitted instead
61   /// of using the provided value. The exact interpretation of this flag is
62   /// target dependent.
63   bool m_bEmitNops : 1;
64 };
65 
66 }  // namespace mcld
67 
68 #endif  // MCLD_FRAGMENT_ALIGNFRAGMENT_H_
69