Add materialization of virtual base registers for frame indices allocated into
[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 MCObjectWriter;
20 class MCSection;
21 template<typename T>
22 class SmallVectorImpl;
23 class Target;
24 class raw_ostream;
25
26 /// TargetAsmBackend - Generic interface to target specific assembler backends.
27 class TargetAsmBackend {
28   TargetAsmBackend(const TargetAsmBackend &);   // DO NOT IMPLEMENT
29   void operator=(const TargetAsmBackend &);  // DO NOT IMPLEMENT
30 protected: // Can only create subclasses.
31   TargetAsmBackend(const Target &);
32
33   /// TheTarget - The Target that this machine was created for.
34   const Target &TheTarget;
35
36   unsigned HasAbsolutizedSet : 1;
37   unsigned HasReliableSymbolDifference : 1;
38   unsigned HasScatteredSymbols : 1;
39
40 public:
41   virtual ~TargetAsmBackend();
42
43   const Target &getTarget() const { return TheTarget; }
44
45   /// createObjectWriter - Create a new MCObjectWriter instance for use by the
46   /// assembler backend to emit the final object file.
47   virtual MCObjectWriter *createObjectWriter(raw_ostream &OS) const = 0;
48
49   /// hasAbsolutizedSet - Check whether this target "absolutizes"
50   /// assignments. That is, given code like:
51   ///   a:
52   ///   ...
53   ///   b:
54   ///   tmp = a - b
55   ///       .long tmp
56   /// will the value of 'tmp' be a relocatable expression, or the assembly time
57   /// value of L0 - L1. This distinction is only relevant for platforms that
58   /// support scattered symbols, since in the absence of scattered symbols (a -
59   /// b) cannot change after assembly.
60   bool hasAbsolutizedSet() const { return HasAbsolutizedSet; }
61
62   /// hasReliableSymbolDifference - Check whether this target implements
63   /// accurate relocations for differences between symbols. If not, differences
64   /// between symbols will always be relocatable expressions and any references
65   /// to temporary symbols will be assumed to be in the same atom, unless they
66   /// reside in a different section.
67   ///
68   /// This should always be true (since it results in fewer relocations with no
69   /// loss of functionality), but is currently supported as a way to maintain
70   /// exact object compatibility with Darwin 'as' (on non-x86_64). It should
71   /// eventually should be eliminated. See also \see hasAbsolutizedSet.
72   bool hasReliableSymbolDifference() const {
73     return HasReliableSymbolDifference;
74   }
75
76   /// hasScatteredSymbols - Check whether this target supports scattered
77   /// symbols. If so, the assembler should assume that atoms can be scattered by
78   /// the linker. In particular, this means that the offsets between symbols
79   /// which are in distinct atoms is not known at link time, and the assembler
80   /// must generate fixups and relocations appropriately.
81   ///
82   /// Note that the assembler currently does not reason about atoms, instead it
83   /// assumes all temporary symbols reside in the "current atom".
84   bool hasScatteredSymbols() const { return HasScatteredSymbols; }
85
86   /// doesSectionRequireSymbols - Check whether the given section requires that
87   /// all symbols (even temporaries) have symbol table entries.
88   virtual bool doesSectionRequireSymbols(const MCSection &Section) const {
89     return false;
90   }
91
92   /// isSectionAtomizable - Check whether the given section can be split into
93   /// atoms.
94   ///
95   /// \see MCAssembler::isSymbolLinkerVisible().
96   virtual bool isSectionAtomizable(const MCSection &Section) const {
97     return true;
98   }
99
100   /// isVirtualSection - Check whether the given section is "virtual", that is
101   /// has no actual object file contents.
102   virtual bool isVirtualSection(const MCSection &Section) const = 0;
103
104   /// ApplyFixup - Apply the \arg Value for given \arg Fixup into the provided
105   /// data fragment, at the offset specified by the fixup and following the
106   /// fixup kind as appropriate.
107   virtual void ApplyFixup(const MCFixup &Fixup, MCDataFragment &Fragment,
108                           uint64_t Value) const = 0;
109
110   /// MayNeedRelaxation - Check whether the given instruction may need
111   /// relaxation.
112   ///
113   /// \param Inst - The instruction to test.
114   virtual bool MayNeedRelaxation(const MCInst &Inst) const = 0;
115
116   /// RelaxInstruction - Relax the instruction in the given fragment to the next
117   /// wider instruction.
118   ///
119   /// \param Inst - The instruction to relax, which may be the same as the
120   /// output.
121   /// \parm Res [output] - On return, the relaxed instruction.
122   virtual void RelaxInstruction(const MCInst &Inst, MCInst &Res) const = 0;
123
124   /// WriteNopData - Write an (optimal) nop sequence of Count bytes to the given
125   /// output. If the target cannot generate such a sequence, it should return an
126   /// error.
127   ///
128   /// \return - True on success.
129   virtual bool WriteNopData(uint64_t Count, MCObjectWriter *OW) const = 0;
130 };
131
132 } // End llvm namespace
133
134 #endif