1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

Use enumeration for preffered EH dwarf encoding reason

llvm-svn: 47770
This commit is contained in:
Anton Korobeynikov 2008-02-29 22:09:08 +00:00
parent 5beb036eab
commit 875da2420a
6 changed files with 28 additions and 14 deletions

View File

@ -20,6 +20,15 @@
#include "llvm/Support/DataTypes.h"
namespace llvm {
// DWARF encoding query type
namespace DwarfEncoding {
enum Target {
Data = 0,
CodeLabels = 1,
Functions = 2
};
}
class TargetMachine;
class CallInst;
@ -401,7 +410,8 @@ namespace llvm {
/// format used for encoding pointers in exception handling data. Reason is
/// 0 for data, 1 for code labels, 2 for function pointers. Global is true
/// if the symbol can be relocated.
virtual unsigned PreferredEHDataFormat(unsigned Reason, bool Global) const;
virtual unsigned PreferredEHDataFormat(DwarfEncoding::Target Reason,
bool Global) const;
// Accessors.
//

View File

@ -92,11 +92,11 @@ DarwinTargetAsmInfo::DarwinTargetAsmInfo(const PPCTargetMachine &TM)
/// format used for encoding pointers in exception handling data. Reason is
/// 0 for data, 1 for code labels, 2 for function pointers. Global is true
/// if the symbol can be relocated.
unsigned DarwinTargetAsmInfo::PreferredEHDataFormat(unsigned Reason,
unsigned DarwinTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
bool Global) const {
if (Reason == 2 && Global)
if (Reason == DwarfEncoding::Functions && Global)
return (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4);
else if (Reason == 1 || !Global)
else if (Reason == DwarfEncoding::CodeLabels || !Global)
return DW_EH_PE_pcrel;
else
return DW_EH_PE_absptr;
@ -154,7 +154,7 @@ LinuxTargetAsmInfo::LinuxTargetAsmInfo(const PPCTargetMachine &TM)
/// format used for encoding pointers in exception handling data. Reason is
/// 0 for data, 1 for code labels, 2 for function pointers. Global is true
/// if the symbol can be relocated.
unsigned LinuxTargetAsmInfo::PreferredEHDataFormat(unsigned Reason,
unsigned LinuxTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
bool Global) const {
// We really need to write something here.
return TargetAsmInfo::PreferredEHDataFormat(Reason, Global);

View File

@ -27,12 +27,14 @@ namespace llvm {
struct DarwinTargetAsmInfo : public PPCTargetAsmInfo {
explicit DarwinTargetAsmInfo(const PPCTargetMachine &TM);
virtual unsigned PreferredEHDataFormat(unsigned Reason, bool Global) const;
virtual unsigned PreferredEHDataFormat(DwarfEncoding::Target Reason,
bool Global) const;
};
struct LinuxTargetAsmInfo : public PPCTargetAsmInfo {
explicit LinuxTargetAsmInfo(const PPCTargetMachine &TM);
virtual unsigned PreferredEHDataFormat(unsigned Reason, bool Global) const;
virtual unsigned PreferredEHDataFormat(DwarfEncoding::Target Reason,
bool Global) const;
};
} // namespace llvm

View File

@ -136,7 +136,7 @@ unsigned TargetAsmInfo::getInlineAsmLength(const char *Str) const {
return Length;
}
unsigned TargetAsmInfo::PreferredEHDataFormat(unsigned Reason,
unsigned TargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
bool Global) const {
return dwarf::DW_EH_PE_absptr;
}

View File

@ -313,15 +313,15 @@ bool X86TargetAsmInfo::ExpandInlineAsm(CallInst *CI) const {
/// format used for encoding pointers in exception handling data. Reason is
/// 0 for data, 1 for code labels, 2 for function pointers. Global is true
/// if the symbol can be relocated.
unsigned X86TargetAsmInfo::PreferredEHDataFormat(unsigned Reason,
unsigned X86TargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
bool Global) const {
const X86Subtarget *Subtarget = &X86TM->getSubtarget<X86Subtarget>();
switch (Subtarget->TargetType) {
case X86Subtarget::isDarwin:
if (Reason == 2 && Global)
if (Reason == DwarfEncoding::Functions && Global)
return (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4);
else if (Reason == 1 || !Global)
else if (Reason == DwarfEncoding::CodeLabels || !Global)
return DW_EH_PE_pcrel;
else
return DW_EH_PE_absptr;
@ -343,7 +343,8 @@ unsigned X86TargetAsmInfo::PreferredEHDataFormat(unsigned Reason,
// - code model is medium and we're emitting externally visible symbols or
// any code symbols
if (CM == CodeModel::Small ||
(CM == CodeModel::Medium && (Global || Reason)))
(CM == CodeModel::Medium && (Global ||
Reason != DwarfEncoding::Data)))
Format = DW_EH_PE_sdata4;
else
Format = DW_EH_PE_sdata8;
@ -356,7 +357,7 @@ unsigned X86TargetAsmInfo::PreferredEHDataFormat(unsigned Reason,
} else {
if (Subtarget->is64Bit() &&
(CM == CodeModel::Small ||
(CM == CodeModel::Medium && Reason)))
(CM == CodeModel::Medium && Reason != DwarfEncoding::Data)))
return DW_EH_PE_udata4;
else
return DW_EH_PE_absptr;

View File

@ -25,7 +25,8 @@ namespace llvm {
explicit X86TargetAsmInfo(const X86TargetMachine &TM);
virtual bool ExpandInlineAsm(CallInst *CI) const;
virtual unsigned PreferredEHDataFormat(unsigned Reason, bool Global) const;
virtual unsigned PreferredEHDataFormat(DwarfEncoding::Target Reason,
bool Global) const;
private:
const X86TargetMachine* X86TM;