Skip to content

Commit

Permalink
[Profile] Add CFG support for RISC-V (#19)
Browse files Browse the repository at this point in the history
The control transfer instructions are the same for both RV32 and RV64, so we only need one set of regexps.
I think this covers all instructions and pseudo-instructions, although I'm not sure if all of them disassembled by objdump.
  • Loading branch information
lukel97 authored Oct 15, 2024
1 parent d9db435 commit e80247a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lnt/server/ui/static/lnt_profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ InstructionSetParser.prototype = {
// TODO: add all control-flow-changing instructions.
],

RISCVJumpTargetRegexps: [
// (regexp, noFallThru?)
// branch conditional:
[new RegExp("^\\s*b[a-z]+\\s+.*(0x[0-9a-f]+)\\s+<.+>"), false],
// jumps:
[new RegExp("^\\s*(?:jal|j|call|tail)\\s+.*(0x[0-9a-f]+)\\s+<.+>"), true],
// indirect jumps:
[new RegExp("^\\s*(?:jalr|jr|ret)"), true]
],

X86_64JumpTargetRegexps: [
// (regexp, noFallThru?)
// branch conditional:
Expand Down Expand Up @@ -513,6 +523,9 @@ Profile.prototype = {
else if (this.instructionSet == 'aarch32t32')
instructionParser = new InstructionSetParser(
InstructionSetParser.prototype.AArch32T32JumpTargetRegexps);
if (this.instructionSet == 'riscv')
instructionParser = new InstructionSetParser(
InstructionSetParser.prototype.RISCVJumpTargetRegexps);
else if (this.instructionSet == 'x86_64')
instructionParser = new InstructionSetParser(
InstructionSetParser.prototype.X86_64JumpTargetRegexps);
Expand Down
1 change: 1 addition & 0 deletions lnt/server/ui/templates/v4_profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ <h3>Performance profile: {{ test.name }}
<option value="cfg-aarch64">Control-Flow Graph (AArch64)</option>
<option value="cfg-aarch32t32">Control-Flow Graph (AArch32-T32)</option>
<option value="cfg-aarch32a32">Control-Flow Graph (AArch32-A32)</option>
<option value="cfg-riscv">Control-Flow Graph (RISC-V)</option>
<option value="cfg-x86_64">Control-Flow Graph (X86-64)</option>
</select>
</div>
Expand Down

0 comments on commit e80247a

Please sign in to comment.