MC: Add TargetAsmBackend::isVirtualSection hook.
[oota-llvm.git] / include / llvm / Target / TargetAsmBackend.h
1 //===-- llvm/Target/TargetAsmBackend.h - Target Asm Backend -----*- 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_TARGET_TARGETASMBACKEND_H
11 #define LLVM_TARGET_TARGETASMBACKEND_H
12
13 #include "llvm/System/DataTypes.h"
14
15 namespace llvm {
16 class MCAsmFixup;
17 class MCDataFragment;
18 class MCSection;
19 class Target;
20
21 /// TargetAsmBackend - Generic interface to target specific assembler backends.
22 class TargetAsmBackend {
23   TargetAsmBackend(const TargetAsmBackend &);   // DO NOT IMPLEMENT
24   void operator=(const TargetAsmBackend &);  // DO NOT IMPLEMENT
25 protected: // Can only create subclasses.
26   TargetAsmBackend(const Target &);
27
28   /// TheTarget - The Target that this machine was created for.
29   const Target &TheTarget;
30
31   unsigned HasAbsolutizedSet : 1;
32   unsigned HasReliableSymbolDifference : 1;
33   unsigned HasScatteredSymbols : 1;
34
35 public:
36   virtual ~TargetAsmBackend();
37
38   const Target &getTarget() const { return TheTarget; }
39
40   /// hasAbsolutizedSet - Check whether this target "absolutizes"
41   /// assignments. That is, given code like:
42   ///   a:
43   ///   ...
44   ///   b:
45   ///   tmp = a - b
46   ///       .long tmp
47   /// will the value of 'tmp' be a relocatable expression, or the assembly time
48   /// value of L0 - L1. This distinction is only relevant for platforms that
49   /// support scattered symbols, since in the absence of scattered symbols (a -
50   /// b) cannot change after assembly.
51   bool hasAbsolutizedSet() const { return HasAbsolutizedSet; }
52
53   /// hasReliableSymbolDifference - Check whether this target implements
54   /// accurate relocations for differences between symbols. If not, differences
55   /// between symbols will always be relocatable expressions and any references
56   /// to temporary symbols will be assumed to be in the same atom, unless they
57   /// reside in a different section.
58   ///
59   /// This should always be true (since it results in fewer relocations with no
60   /// loss of functionality), but is currently supported as a way to maintain
61   /// exact object compatibility with Darwin 'as' (on non-x86_64). It should
62   /// eventually should be eliminated. See also \see hasAbsolutizedSet.
63   bool hasReliableSymbolDifference() const {
64     return HasReliableSymbolDifference;
65   }
66
67   /// hasScatteredSymbols - Check whether this target supports scattered
68   /// symbols. If so, the assembler should assume that atoms can be scattered by
69   /// the linker. In particular, this means that the offsets between symbols
70   /// which are in distinct atoms is not known at link time, and the assembler
71   /// must generate fixups and relocations appropriately.
72   ///
73   /// Note that the assembler currently does not reason about atoms, instead it
74   /// assumes all temporary symbols reside in the "current atom".
75   bool hasScatteredSymbols() const { return HasScatteredSymbols; }
76
77   /// doesSectionRequireSymbols - Check whether the given section requires that
78   /// all symbols (even temporaries) have symbol table entries.
79   virtual bool doesSectionRequireSymbols(const MCSection &Section) const {
80     return false;
81   }
82
83   /// isVirtualSection - Check whether the given section is "virtual", that is
84   /// has no actual object file contents.
85   virtual bool isVirtualSection(const MCSection &Section) const = 0;
86
87   /// ApplyFixup - Apply the \arg Value for given \arg Fixup into the provided
88   /// data fragment, at the offset specified by the fixup and following the
89   /// fixup kind as appropriate.
90   virtual void ApplyFixup(const MCAsmFixup &Fixup, MCDataFragment &Fragment,
91                           uint64_t Value) const = 0;
92 };
93
94 } // End llvm namespace
95
96 #endif