Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/eld/Readers/ELFSection.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,10 @@ class ELFSection : public ELFSectionBase {
Relocation *findRelocation(uint64_t Offset, Relocation::Type Type,
bool Reverse = true) const;

// Returns true if R is immediately followed by a relocation of the given
// type in the section's relocation list.
bool hasFollowing(const Relocation *R, Relocation::Type Type) const;

Relocation *createOneReloc();

// Linker Script support for sorting sections.
Expand Down
10 changes: 10 additions & 0 deletions lib/Readers/ELFSection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "eld/Readers/ELFSection.h"
#include "eld/Object/OutputSectionEntry.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/ELF.h"
#include <sstream>

using namespace eld;
Expand Down Expand Up @@ -178,6 +179,15 @@ Relocation *ELFSection::findRelocation(uint64_t Offset, Relocation::Type Type,
return nullptr;
}

bool ELFSection::hasFollowing(const Relocation *R,
Relocation::Type Type) const {
auto It = std::find(Relocations.begin(), Relocations.end(), R);
if (It == Relocations.end())
return false;
++It;
return It != Relocations.end() && (*It)->type() == Type;
}

Fragment *ELFSection::getFirstFragmentInRule() const {
OutputSectionEntry *OE = getOutputSection();
if (!OE || !OE->size())
Expand Down
15 changes: 15 additions & 0 deletions lib/Target/RISCV/RISCVHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,21 @@ template <typename T> T encodeQCEJ(T Result) {
return Result;
}

template <typename T> T encodeQCEI(T Result) {
uint32_t Imm9_0 = extractBits(Result, 9, 0) << 20;
uint64_t Imm25_10 = static_cast<uint64_t>(extractBits(Result, 25, 10)) << 32;
Result = Imm9_0 | Imm25_10;
return Result;
}

template <typename T> T encodeQCES(T Result) {
uint32_t Imm4_0 = extractBits(Result, 4, 0) << 7;
uint32_t Imm9_5 = extractBits(Result, 9, 5) << 25;
uint64_t Imm25_10 = static_cast<uint64_t>(extractBits(Result, 25, 10)) << 32;
Result = Imm4_0 | Imm9_5 | Imm25_10;
return Result;
}

/// --------------------------------------------
/// Fetch Registers and Opcode from Instruction
/// --------------------------------------------
Expand Down
Loading
Loading