Changeset View
Changeset View
Standalone View
Standalone View
llvm/trunk/include/llvm/MC/MCFixup.h
Show All 35 Lines | enum MCFixupKind { | ||||
FK_DTPRel_4, ///< A four-byte dtp relative fixup. | FK_DTPRel_4, ///< A four-byte dtp relative fixup. | ||||
FK_DTPRel_8, ///< A eight-byte dtp relative fixup. | FK_DTPRel_8, ///< A eight-byte dtp relative fixup. | ||||
FK_TPRel_4, ///< A four-byte tp relative fixup. | FK_TPRel_4, ///< A four-byte tp relative fixup. | ||||
FK_TPRel_8, ///< A eight-byte tp relative fixup. | FK_TPRel_8, ///< A eight-byte tp relative fixup. | ||||
FK_SecRel_1, ///< A one-byte section relative fixup. | FK_SecRel_1, ///< A one-byte section relative fixup. | ||||
FK_SecRel_2, ///< A two-byte section relative fixup. | FK_SecRel_2, ///< A two-byte section relative fixup. | ||||
FK_SecRel_4, ///< A four-byte section relative fixup. | FK_SecRel_4, ///< A four-byte section relative fixup. | ||||
FK_SecRel_8, ///< A eight-byte section relative fixup. | FK_SecRel_8, ///< A eight-byte section relative fixup. | ||||
FK_Data_Add_1, ///< A one-byte add fixup. | |||||
FK_Data_Add_2, ///< A two-byte add fixup. | |||||
FK_Data_Add_4, ///< A four-byte add fixup. | |||||
FK_Data_Add_8, ///< A eight-byte add fixup. | |||||
FK_Data_Sub_1, ///< A one-byte sub fixup. | |||||
FK_Data_Sub_2, ///< A two-byte sub fixup. | |||||
FK_Data_Sub_4, ///< A four-byte sub fixup. | |||||
FK_Data_Sub_8, ///< A eight-byte sub fixup. | |||||
FirstTargetFixupKind = 128, | FirstTargetFixupKind = 128, | ||||
// Limit range of target fixups, in case we want to pack more efficiently | // Limit range of target fixups, in case we want to pack more efficiently | ||||
// later. | // later. | ||||
MaxTargetFixupKind = (1 << 8) | MaxTargetFixupKind = (1 << 8) | ||||
}; | }; | ||||
Show All 33 Lines | static MCFixup create(uint32_t Offset, const MCExpr *Value, | ||||
MCFixup FI; | MCFixup FI; | ||||
FI.Value = Value; | FI.Value = Value; | ||||
FI.Offset = Offset; | FI.Offset = Offset; | ||||
FI.Kind = unsigned(Kind); | FI.Kind = unsigned(Kind); | ||||
FI.Loc = Loc; | FI.Loc = Loc; | ||||
return FI; | return FI; | ||||
} | } | ||||
/// Return a fixup corresponding to the add half of a add/sub fixup pair for | |||||
/// the given Fixup. | |||||
static MCFixup createAddFor(const MCFixup &Fixup) { | |||||
MCFixup FI; | |||||
FI.Value = Fixup.getValue(); | |||||
FI.Offset = Fixup.getOffset(); | |||||
FI.Kind = (unsigned)getAddKindForKind(Fixup.getKind()); | |||||
FI.Loc = Fixup.getLoc(); | |||||
return FI; | |||||
} | |||||
/// Return a fixup corresponding to the sub half of a add/sub fixup pair for | |||||
/// the given Fixup. | |||||
static MCFixup createSubFor(const MCFixup &Fixup) { | |||||
MCFixup FI; | |||||
FI.Value = Fixup.getValue(); | |||||
FI.Offset = Fixup.getOffset(); | |||||
FI.Kind = (unsigned)getSubKindForKind(Fixup.getKind()); | |||||
FI.Loc = Fixup.getLoc(); | |||||
return FI; | |||||
} | |||||
MCFixupKind getKind() const { return MCFixupKind(Kind); } | MCFixupKind getKind() const { return MCFixupKind(Kind); } | ||||
uint32_t getOffset() const { return Offset; } | uint32_t getOffset() const { return Offset; } | ||||
void setOffset(uint32_t Value) { Offset = Value; } | void setOffset(uint32_t Value) { Offset = Value; } | ||||
const MCExpr *getValue() const { return Value; } | const MCExpr *getValue() const { return Value; } | ||||
/// Return the generic fixup kind for a value with the given size. It | /// Return the generic fixup kind for a value with the given size. It | ||||
/// is an error to pass an unsupported size. | /// is an error to pass an unsupported size. | ||||
static MCFixupKind getKindForSize(unsigned Size, bool isPCRel) { | static MCFixupKind getKindForSize(unsigned Size, bool isPCRel) { | ||||
switch (Size) { | switch (Size) { | ||||
default: llvm_unreachable("Invalid generic fixup size!"); | default: llvm_unreachable("Invalid generic fixup size!"); | ||||
case 1: return isPCRel ? FK_PCRel_1 : FK_Data_1; | case 1: return isPCRel ? FK_PCRel_1 : FK_Data_1; | ||||
case 2: return isPCRel ? FK_PCRel_2 : FK_Data_2; | case 2: return isPCRel ? FK_PCRel_2 : FK_Data_2; | ||||
case 4: return isPCRel ? FK_PCRel_4 : FK_Data_4; | case 4: return isPCRel ? FK_PCRel_4 : FK_Data_4; | ||||
case 8: return isPCRel ? FK_PCRel_8 : FK_Data_8; | case 8: return isPCRel ? FK_PCRel_8 : FK_Data_8; | ||||
} | } | ||||
} | } | ||||
/// Return the generic fixup kind for an addition with a given size. It | |||||
/// is an error to pass an unsupported size. | |||||
static MCFixupKind getAddKindForKind(unsigned Kind) { | |||||
switch (Kind) { | |||||
default: llvm_unreachable("Unknown type to convert!"); | |||||
case FK_Data_1: return FK_Data_Add_1; | |||||
case FK_Data_2: return FK_Data_Add_2; | |||||
case FK_Data_4: return FK_Data_Add_4; | |||||
case FK_Data_8: return FK_Data_Add_8; | |||||
} | |||||
} | |||||
/// Return the generic fixup kind for an subtraction with a given size. It | |||||
/// is an error to pass an unsupported size. | |||||
static MCFixupKind getSubKindForKind(unsigned Kind) { | |||||
switch (Kind) { | |||||
default: llvm_unreachable("Unknown type to convert!"); | |||||
case FK_Data_1: return FK_Data_Sub_1; | |||||
case FK_Data_2: return FK_Data_Sub_2; | |||||
case FK_Data_4: return FK_Data_Sub_4; | |||||
case FK_Data_8: return FK_Data_Sub_8; | |||||
} | |||||
} | |||||
SMLoc getLoc() const { return Loc; } | SMLoc getLoc() const { return Loc; } | ||||
}; | }; | ||||
} // End llvm namespace | } // End llvm namespace | ||||
#endif | #endif |