Rename "symbol_addr" to "value" in relocations
MODIFY
src/assembler/relocation.h
src/assembler/relocation.h
@@ -23,13 +23,11 @@ class Relocation {
static_assert(std::numeric_limits<Instr_T>::is_integer, "Instruction type must be integer");
public:
- using RelocationHandler = std::function<HandleRelocationRes<Reg_T>(const Reg_T symbol_addr, const Reg_T reloc_pos)>;
+ using RelocationHandler = std::function<HandleRelocationRes<Reg_T>(const Reg_T value, const Reg_T reloc_pos)>;
Relocation(const QString& relocation, const RelocationHandler& handler)
: m_relocation(relocation), m_handler(handler) {}
- HandleRelocationRes<Reg_T> handle(const Reg_T symbol_addr, const Reg_T reloc_pos) {
- return m_handler(symbol_addr, reloc_pos);
- }
+ HandleRelocationRes<Reg_T> handle(const Reg_T value, const Reg_T reloc_pos) { return m_handler(value, reloc_pos); }
const QString& name() const { return m_relocation; }
private:

MODIFY
src/assembler/rvrelocations.h
src/assembler/rvrelocations.h
@@ -7,15 +7,15 @@ namespace Ripes {
namespace Assembler {
// pcrel_lo/hi are restricted to 32-bit absolute addresses, so keep computations in this base.
-inline uint32_t hi20(const uint32_t symbol_address, const uint32_t reloc_addr) {
- return ((symbol_address - (reloc_addr % 0xFFFFF000) + 0x800) >> 12);
+inline uint32_t pcrel_hi20(const uint32_t val, const uint32_t reloc_addr) {
+ return ((val - (reloc_addr % 0xFFFFF000) + 0x800) >> 12);
}
template <typename Reg_T, typename Instr_T>
Relocation<Reg_T, Instr_T> rv_pcrel_hi() {
- return Relocation<Reg_T, Instr_T>(
- "%pcrel_hi", [](const Reg_T symbol_address, const Reg_T reloc_addr) -> HandleRelocationRes<Reg_T> {
- const uint32_t _hi20 = hi20(symbol_address, reloc_addr);
+ return Relocation<Reg_T, Instr_T>("%pcrel_hi",
+ [](const Reg_T val, const Reg_T reloc_addr) -> HandleRelocationRes<Reg_T> {
+ const uint32_t _hi20 = pcrel_hi20(val, reloc_addr);
return {_hi20};
});
}
@@ -23,10 +23,10 @@ Relocation<Reg_T, Instr_T> rv_pcrel_hi() {
template <typename Reg_T, typename Instr_T>
Relocation<Reg_T, Instr_T> rv_pcrel_lo() {
return Relocation<Reg_T, Instr_T>(
- "%pcrel_lo", [](const Reg_T symbol_address, const Reg_T reloc_addr) -> HandleRelocationRes<Reg_T> {
+ "%pcrel_lo", [](const Reg_T val, const Reg_T reloc_addr) -> HandleRelocationRes<Reg_T> {
using Reg_T_S = typename std::make_signed<Reg_T>::type;
- const uint32_t _hi20 = hi20(symbol_address, reloc_addr);
- const uint32_t lo12 = symbol_address - (reloc_addr % 0xFFFFF000) - (_hi20 << 12);
+ const uint32_t _hi20 = pcrel_hi20(val, reloc_addr);
+ const uint32_t lo12 = val - (reloc_addr % 0xFFFFF000) - (_hi20 << 12);
return {static_cast<Reg_T>(static_cast<Reg_T_S>(vsrtl::signextend(lo12, 12)))};
});
}

Rename "symbol_addr" to "value" in relocations