Skip to content

[RISCV][WIP] Add support for the Zcmt Extension#981

Draft
svs-quic wants to merge 4 commits intoqualcomm:mainfrom
svs-quic:zcmt
Draft

[RISCV][WIP] Add support for the Zcmt Extension#981
svs-quic wants to merge 4 commits intoqualcomm:mainfrom
svs-quic:zcmt

Conversation

@svs-quic
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown
Member

@lenary lenary left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments here, I'm not sure if any of these are a surprise but maybe they point at the next steps.

Comment on lines +62 to +65
def relax_tbljal
: Flag<["--"], "relax-tbljal">,
HelpText<"Enable conversion of call/jump instructions to Zcmt table jump instructions (cm.jt/cm.jalt)">,
Group<grp_riscv_linker>;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have both positive and negative versions of this flag for users? That allows us to change the default in the future (this is what I did for the xqci relaxation flag)

m_Module.getInternalInput(Module::InternalInputType::Sections),
JvtName, ResolveInfo::NoType, ResolveInfo::Define,
ResolveInfo::Global,
0x0, // size
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if we should be setting the size here. It might help people trying to debug things, i don't think loaders will look at this information.

Comment on lines +1137 to +1138
if (relaxation_pass == RELAXATION_CALL)
initTableJump();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that initTableJump() does a full scan, can we make it explicitly a different phase, before RELAXATION_CALL? maybe RELAXATION_TABLE_JUMP?

}

static int64_t getCallDisplace(RISCVLDBackend &Backend, const Relocation &R) {
int64_t S = static_cast<int64_t>(Backend.getSymbolValuePLT(R));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we have to jump to the PLT entry if there is one (including e.g. for patching), but it would be good to confirm that this code is right.

The jump table is sort-of like a PLT, but it cannot be lazy and there's no preemption for its addresses.

Comment on lines +78 to +79
uint32_t Jalr = 0;
R->targetRef()->memcpy(&Jalr, sizeof(Jalr), 4);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why this side uses a local Jalr uint32 variable, when the other side uses Insn. Both could use something local or Insn?

Comment on lines +58 to +60
if (R->type() != llvm::ELF::R_RISCV_JAL &&
R->type() != llvm::ELF::R_RISCV_CALL &&
R->type() != llvm::ELF::R_RISCV_CALL_PLT)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about R_RISCV_QC_E_CALL_PLT? :) A planned follow-up or an oversight?

Comment on lines +185 to +187
llvm::sort(Entries, [](const auto &A, const auto &B) {
return A.second.Index < B.second.Index;
});
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, we may want these sorted in a specific order. We should confirm with the architects if there's a performance implication.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants