#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;
/// 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.
//
/// 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;
/// 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);
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
return Length;
}
-unsigned TargetAsmInfo::PreferredEHDataFormat(unsigned Reason,
+unsigned TargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
bool Global) const {
return dwarf::DW_EH_PE_absptr;
}
/// 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;
// - 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;
} 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;
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;