Add a MCObjectFormat class so that code common to all targets that use a
[oota-llvm.git] / lib / MC / MCObjectFormat.cpp
1 //===- lib/MC/MCObjectFormat.cpp - MCObjectFormat implementation ----------===//
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 #include "llvm/MC/MCObjectFormat.h"
11 #include "llvm/MC/MCSymbol.h"
12
13 using namespace llvm;
14
15 bool MCELFObjectFormat::isAbsolute(bool IsSet, const MCSymbol &A,
16                                    const MCSymbol &B) const {
17   // On ELF A - B is absolute if A and B are in the same section.
18   return &A.getSection() == &B.getSection();
19 }
20
21 bool MCMachOObjectFormat::isAbsolute(bool IsSet, const MCSymbol &A,
22                                      const MCSymbol &B) const  {
23   // On MachO A - B is absolute only if in a set.
24   return IsSet;
25 }
26
27 bool MCCOFFObjectFormat::isAbsolute(bool IsSet, const MCSymbol &A,
28                                     const MCSymbol &B) const  {
29   // On COFF A - B is absolute if A and B are in the same section.
30   return &A.getSection() == &B.getSection();
31 }