Remove the unused TheTarget member.
[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 MCDataFragment;
17 class MCFixup;
18 class MCInst;
19 class MCObjectFormat;
20 class MCObjectWriter;
21 class MCSection;
22 template<typename T>
23 class SmallVectorImpl;
24 class Target;
25 class raw_ostream;
26
27 /// TargetAsmBackend - Generic interface to target specific assembler backends.
28 class TargetAsmBackend {
29   TargetAsmBackend(const TargetAsmBackend &);   // DO NOT IMPLEMENT
30   void operator=(const TargetAsmBackend &);  // DO NOT IMPLEMENT
31 protected: // Can only create subclasses.
32   TargetAsmBackend();
33
34   unsigned HasReliableSymbolDifference : 1;
35   unsigned HasScatteredSymbols : 1;
36
37 public:
38   virtual ~TargetAsmBackend();
39
40   virtual const MCObjectFormat &getObjectFormat() const = 0;
41
42   /// createObjectWriter - Create a new MCObjectWriter instance for use by the
43   /// assembler backend to emit the final object file.
44   virtual MCObjectWriter *createObjectWriter(raw_ostream &OS) const = 0;
45
46   /// hasReliableSymbolDifference - Check whether this target implements
47   /// accurate relocations for differences between symbols. If not, differences
48   /// between symbols will always be relocatable expressions and any references
49   /// to temporary symbols will be assumed to be in the same atom, unless they
50   /// reside in a different section.
51   ///
52   /// This should always be true (since it results in fewer relocations with no
53   /// loss of functionality), but is currently supported as a way to maintain
54   /// exact object compatibility with Darwin 'as' (on non-x86_64). It should
55   /// eventually should be eliminated.
56   bool hasReliableSymbolDifference() const {
57     return HasReliableSymbolDifference;
58   }
59
60   /// hasScatteredSymbols - Check whether this target supports scattered
61   /// symbols. If so, the assembler should assume that atoms can be scattered by
62   /// the linker. In particular, this means that the offsets between symbols
63   /// which are in distinct atoms is not known at link time, and the assembler
64   /// must generate fixups and relocations appropriately.
65   ///
66   /// Note that the assembler currently does not reason about atoms, instead it
67   /// assumes all temporary symbols reside in the "current atom".
68   bool hasScatteredSymbols() const { return HasScatteredSymbols; }
69
70   /// doesSectionRequireSymbols - Check whether the given section requires that
71   /// all symbols (even temporaries) have symbol table entries.
72   virtual bool doesSectionRequireSymbols(const MCSection &Section) const {
73     return false;
74   }
75
76   /// isSectionAtomizable - Check whether the given section can be split into
77   /// atoms.
78   ///
79   /// \see MCAssembler::isSymbolLinkerVisible().
80   virtual bool isSectionAtomizable(const MCSection &Section) const {
81     return true;
82   }
83
84   /// getPointerSize - Get the pointer size in bytes.
85   virtual unsigned getPointerSize() 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 MCFixup &Fixup, MCDataFragment &Fragment,
91                           uint64_t Value) const = 0;
92
93   /// MayNeedRelaxation - Check whether the given instruction may need
94   /// relaxation.
95   ///
96   /// \param Inst - The instruction to test.
97   virtual bool MayNeedRelaxation(const MCInst &Inst) const = 0;
98
99   /// RelaxInstruction - Relax the instruction in the given fragment to the next
100   /// wider instruction.
101   ///
102   /// \param Inst - The instruction to relax, which may be the same as the
103   /// output.
104   /// \parm Res [output] - On return, the relaxed instruction.
105   virtual void RelaxInstruction(const MCInst &Inst, MCInst &Res) const = 0;
106
107   /// WriteNopData - Write an (optimal) nop sequence of Count bytes to the given
108   /// output. If the target cannot generate such a sequence, it should return an
109   /// error.
110   ///
111   /// \return - True on success.
112   virtual bool WriteNopData(uint64_t Count, MCObjectWriter *OW) const = 0;
113 };
114
115 } // End llvm namespace
116
117 #endif