1 //===-- llvm/Target/TargetAsmBackend.h - Target Asm Backend -----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_TARGET_TARGETASMBACKEND_H
11 #define LLVM_TARGET_TARGETASMBACKEND_H
13 #include "llvm/System/DataTypes.h"
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 &);
28 /// TheTarget - The Target that this machine was created for.
29 const Target &TheTarget;
31 unsigned HasAbsolutizedSet : 1;
32 unsigned HasReliableSymbolDifference : 1;
33 unsigned HasScatteredSymbols : 1;
36 virtual ~TargetAsmBackend();
38 const Target &getTarget() const { return TheTarget; }
40 /// hasAbsolutizedSet - Check whether this target "absolutizes"
41 /// assignments. That is, given code like:
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; }
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.
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;
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.
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; }
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 {
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;
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;
94 } // End llvm namespace