• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 {
20 public:
21   AlignFragment(unsigned int pAlignment, int64_t pValue, unsigned int pValueSize,
22                 unsigned int pMaxBytesToEmit, SectionData *pSD = NULL);
23 
getAlignment()24   unsigned int getAlignment() const { return m_Alignment; }
25 
getValue()26   int64_t getValue() const { return m_Value; }
27 
getValueSize()28   unsigned int getValueSize() const { return m_ValueSize; }
29 
getMaxBytesToEmit()30   unsigned int getMaxBytesToEmit() const { return m_MaxBytesToEmit; }
31 
hasEmitNops()32   bool hasEmitNops() const { return m_bEmitNops; }
33 
setEmitNops(bool pValue)34   void setEmitNops(bool pValue) { m_bEmitNops = pValue; }
35 
classof(const Fragment * F)36   static bool classof(const Fragment *F)
37   { return F->getKind() == Fragment::Alignment; }
classof(const AlignFragment *)38   static bool classof(const AlignFragment *) { return true; }
39 
40   size_t size() const;
41 
42 private:
43   /// Alignment - The alignment to ensure, in bytes.
44   unsigned int m_Alignment;
45 
46   /// Value - Value to use for filling padding bytes.
47   int64_t m_Value;
48 
49   /// ValueSize - The size of the integer (in bytes) of \arg Value.
50   unsigned int m_ValueSize;
51 
52   /// MaxBytesToEmit - The maximum number of bytes to emit; if the alignment
53   /// cannot be satisfied in this width then this fragment is ignored.
54   unsigned int m_MaxBytesToEmit;
55 
56   /// EmitNops - Flag to indicate that (optimal) NOPs should be emitted instead
57   /// of using the provided value. The exact interpretation of this flag is
58   /// target dependent.
59   bool m_bEmitNops : 1;
60 
61 };
62 
63 } // namespace of mcld
64 
65 #endif
66 
67