2c26ff02964403f2463562dfb49232c25f66907c
[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 getSectionAddress(const MCSectionData *SD) const;
39
40   uint64_t getSymbolAddress(const MCSymbolData *SD) const;
41
42   void setSectionAddress(MCSectionData *SD, uint64_t Value);
43 };
44
45 } // end namespace llvm
46
47 #endif