9b9cdf2c8d914d1902b5f2f46a264811be31a7b4
[oota-llvm.git] / include / llvm / MC / MCAsmLayout.h
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
13 namespace llvm {
14 class MCAssembler;
15 class MCFragment;
16 class MCSectionData;
17 class 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.
26 class MCAsmLayout {
27 private:
28   MCAssembler &Assembler;
29
30 public:
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