MCAsmLayout.h revision 432cd5fd9b4c97f1e4a53fcf45e16f7dd6bc085e
1//===- MCAsmLayout.h - Assembly Layout Object -------------------*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef LLVM_MC_MCASMLAYOUT_H
11#define LLVM_MC_MCASMLAYOUT_H
12
13namespace llvm {
14class MCAssembler;
15class MCFragment;
16class MCSectionData;
17class MCSymbolData;
18
19/// Encapsulates the layout of an assembly file at a particular point in time.
20///
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.
26class MCAsmLayout {
27private:
28  MCAssembler &Assembler;
29
30public:
31  MCAsmLayout(MCAssembler &_Assembler) : Assembler(_Assembler) {}
32
33  /// Get the assembler object this is a layout for.
34  MCAssembler &getAssembler() const { return Assembler; }
35
36  uint64_t getFragmentAddress(const MCFragment *F) const;
37
38  uint64_t getFragmentEffectiveSize(const MCFragment *F) const;
39  void setFragmentEffectiveSize(MCFragment *F, uint64_t Value);
40
41  uint64_t getFragmentOffset(const MCFragment *F) const;
42  void setFragmentOffset(MCFragment *F, uint64_t Value);
43
44  uint64_t getSectionAddress(const MCSectionData *SD) const;
45
46  uint64_t getSymbolAddress(const MCSymbolData *SD) const;
47
48  void setSectionAddress(MCSectionData *SD, uint64_t Value);
49};
50
51} // end namespace llvm
52
53#endif
54