Don't relax function calls
This commit is contained in:
@ -280,7 +280,7 @@ namespace elna::riscv
|
||||
instructions.push_back(instruction(base_opcode::branch));
|
||||
statement->body().accept(this);
|
||||
instructions[before_branch]
|
||||
.b((instructions.size() - before_branch) * 4 - 4, funct3_t::beq, x_register::zero, free_register);
|
||||
.b((instructions.size() - before_branch) * 4, funct3_t::beq, x_register::zero, free_register);
|
||||
}
|
||||
|
||||
void visitor::visit(source::while_statement *statement)
|
||||
@ -400,13 +400,24 @@ namespace elna::riscv
|
||||
|
||||
void visitor::visit(source::unary_expression *expression)
|
||||
{
|
||||
const auto free_register = this->register_in_use ? x_register::a0 : x_register::t0;
|
||||
auto operand_identifier = dynamic_cast<source::variable_expression&>(expression->operand()).name();
|
||||
auto variable_symbol =
|
||||
std::dynamic_pointer_cast<source::variable_info>(this->table->lookup(operand_identifier));
|
||||
switch (expression->operation())
|
||||
{
|
||||
case source::unary_operator::dereference:
|
||||
expression->operand().accept(this);
|
||||
|
||||
this->instructions.push_back(instruction(base_opcode::opImm)
|
||||
.i(free_register, funct3_t::addi, x_register::s0, variable_symbol->offset));
|
||||
this->instructions.push_back(instruction(base_opcode::load)
|
||||
.i(x_register::a0, funct3_t::lw, x_register::a0, 0));
|
||||
break;
|
||||
case source::unary_operator::reference:
|
||||
const auto free_register = this->register_in_use ? x_register::a0 : x_register::t0;
|
||||
auto operand_identifier = dynamic_cast<source::variable_expression&>(expression->operand()).name();
|
||||
auto variable_symbol =
|
||||
std::dynamic_pointer_cast<source::variable_info>(this->table->lookup(operand_identifier));
|
||||
|
||||
this->instructions.push_back(instruction(base_opcode::opImm)
|
||||
.i(free_register, funct3_t::addi, x_register::s0, variable_symbol->offset));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void visitor::visit(source::integer_literal *number)
|
||||
|
@ -211,15 +211,15 @@ namespace elna::riscv
|
||||
{
|
||||
case address_t::high20:
|
||||
rela.add_entry(reference.offset, relocated_symbol, 26 /* ELFIO::R_RISCV_HI20 */);
|
||||
rela.add_entry(reference.offset, relocated_symbol, 51 /* ELFIO::R_RISCV_RELAX */);
|
||||
// rela.add_entry(reference.offset, relocated_symbol, 51 /* ELFIO::R_RISCV_RELAX */);
|
||||
break;
|
||||
case address_t::lower12i:
|
||||
rela.add_entry(reference.offset, relocated_symbol, 27 /* ELFIO::R_RISCV_LO12_I */);
|
||||
rela.add_entry(reference.offset, relocated_symbol, 51 /* ELFIO::R_RISCV_RELAX */);
|
||||
// rela.add_entry(reference.offset, relocated_symbol, 51 /* ELFIO::R_RISCV_RELAX */);
|
||||
break;
|
||||
case address_t::text:
|
||||
rela.add_entry(reference.offset, relocated_symbol, 18 /* ELFIO::R_RISCV_CALL */);
|
||||
rela.add_entry(reference.offset, relocated_symbol, 51 /* ELFIO::R_RISCV_RELAX */);
|
||||
// rela.add_entry(reference.offset, relocated_symbol, 51 /* ELFIO::R_RISCV_RELAX */);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user