31struct HexagonInstruction {
44 const HexagonInstruction *Encodings,
46 for (
size_t I = 0;
I < NumInsns; ++
I) {
47 if (((Insn & 0xc000) == 0) && !Encodings[
I].isDuplex)
49 if (((Insn & 0xc000) != 0) && Encodings[
I].isDuplex)
51 if (((Encodings[
I].insnMask) & Insn) == Encodings[
I].insnCmpMask) {
52 return Encodings[
I].insnBitMask;
61 sizeof(HexagonInstruction));
69 for (
size_t Bit = 0; Bit !=
sizeof(
uint32_t) * 8; ++Bit) {
70 const uint32_t ValBit = (Data >> Off) & 1;
71 const bool MaskBit = (Mask >> Bit) & 1;
73 Result |= (ValBit << Bit);
84 case llvm::ELF::R_HEX_B22_PCREL_X:
85 case llvm::ELF::R_HEX_B15_PCREL_X:
86 case llvm::ELF::R_HEX_B13_PCREL_X:
87 case llvm::ELF::R_HEX_B9_PCREL_X:
88 case llvm::ELF::R_HEX_B7_PCREL_X:
89 case llvm::ELF::R_HEX_GD_PLT_B22_PCREL_X:
90 case llvm::ELF::R_HEX_LD_PLT_B22_PCREL_X:
105 if (AppliedBits == 0)
108 T ValueAfterShift = Value >> Reloc.Shift;
114 Instruction &= ~BitMask;
115 EffectiveValue =
applyMask(BitMask, EffectiveValue);
116 return EffectiveValue | Instruction;
144 Info->Name = R->Name;
145 Info->Type = R->Type;
146 Info->EffectiveBits = R->EffectiveBits;
147 Info->BitMask = R->BitMask;
148 Info->Alignment = R->Alignment;
149 Info->Shift = R->Shift;
150 Info->VerifyRange = R->VerifyRange;
151 Info->VerifyAlignment = R->VerifyAlignment;
152 Info->IsSigned = R->IsSigned;
167 return R && (R->Alignment == 0 || Value % R->Alignment == 0);
172 if (!R || R->IsSigned || R->EffectiveBits == 0)
174 return Value &
~llvm::maskTrailingOnes<uint32_t>(R->EffectiveBits);
static const HexagonInstruction InstructionEncodings[]
static uint32_t doRelocHelper(uint32_t RelocType, uint32_t Instruction, T Value)
static uint32_t applyMask(uint32_t Mask, uint32_t Data)
LLVM_ABI bool LLVMHexagonVerifyAlignment(uint32_t RelocType, uint32_t Value)
Return true if Value satisfies the alignment required by RelocType.
LLVM_ABI bool LLVMHexagonIsTruncated(uint32_t RelocType, uint32_t Value)
Return true if applying the unsigned relocation RelocType to Value would lose set bits.
LLVM_ABI uint32_t LLVMHexagonApplyRelocation(uint32_t RelocType, uint32_t Instruction, uint32_t Value)
Apply the ELF relocation RelocType with value Value to Instruction.
static const llvm::Hexagon::HexagonRelocationInfo * getRelocInfo(uint32_t RelocType)
static uint32_t getAppliedBits(uint32_t RelocType)
LLVM_ABI bool LLVMHexagonVerifyRange(uint32_t RelocType, uint32_t Value)
Return true if Value fits the range the ABI specifies for RelocType.
static uint32_t findBitMaskHelper(uint32_t Insn, const HexagonInstruction *Encodings, size_t NumInsns)
LLVM_ABI bool LLVMHexagonGetRelocationInfo(uint32_t RelocType, LLVMHexagonRelocInfo *Info)
Fill Info with the properties of RelocType.
static uint32_t findMask(uint32_t I)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static constexpr HexagonRelocationInfo Relocs[]
This is an optimization pass for GlobalISel generic memory operations.
constexpr bool isUIntN(unsigned N, uint64_t x)
Checks if an unsigned integer fits into the given (dynamic) bit width.
constexpr bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
constexpr T maskTrailingOnes(unsigned N)
Create a bitmask with the N right-most bits set to 1, and all other bits set to 0.
ABI properties of a Hexagon ELF relocation type, as listed in the Hexagon ABI document.