1 //===- MCAsmLayout.h - Assembly Layout Object -------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_MC_MCASMLAYOUT_H
11 #define LLVM_MC_MCASMLAYOUT_H
19 /// Encapsulates the layout of an assembly file at a particular point in time.
21 /// Assembly may requiring compute multiple layouts for a particular assembly
22 /// file as part of the relaxation process. This class encapsulates the layout
23 /// at a single point in time in such a way that it is always possible to
24 /// efficiently compute the exact addresses of any symbol in the assembly file,
25 /// even during the relaxation process.
28 MCAssembler &Assembler;
31 MCAsmLayout(MCAssembler &_Assembler) : Assembler(_Assembler) {}
33 /// Get the assembler object this is a layout for.
34 MCAssembler &getAssembler() const { return Assembler; }
36 /// @name Fragment Layout Data
39 /// \brief Get the effective size of the given fragment, as computed in the
41 uint64_t getFragmentEffectiveSize(const MCFragment *F) const;
43 /// \brief Set the effective size of the given fragment.
44 void setFragmentEffectiveSize(MCFragment *F, uint64_t Value);
46 /// \brief Get the offset of the given fragment inside its containing section.
47 uint64_t getFragmentOffset(const MCFragment *F) const;
49 /// \brief Set the offset of the given fragment inside its containing section.
50 void setFragmentOffset(MCFragment *F, uint64_t Value);
53 /// @name Section Layout Data
56 /// \brief Get the computed address of the given section.
57 uint64_t getSectionAddress(const MCSectionData *SD) const;
59 /// \brief Set the computed address of the given section.
60 void setSectionAddress(MCSectionData *SD, uint64_t Value);
62 /// \brief Get the data size of the given section, as emitted to the object
63 /// file. This may include additional padding, or be 0 for virtual sections.
64 uint64_t getSectionFileSize(const MCSectionData *SD) const;
66 /// \brief Set the data size of the given section.
67 void setSectionFileSize(MCSectionData *SD, uint64_t Value);
69 /// \brief Get the actual data size of the given section.
70 uint64_t getSectionSize(const MCSectionData *SD) const;
72 /// \brief Set the actual data size of the given section.
73 void setSectionSize(MCSectionData *SD, uint64_t Value);
76 /// @name Utility Functions
79 /// \brief Get the address of the given fragment, as computed in the current
81 uint64_t getFragmentAddress(const MCFragment *F) const;
83 /// \brief Get the address of the given symbol, as computed in the current
85 uint64_t getSymbolAddress(const MCSymbolData *SD) const;
90 } // end namespace llvm