Skip to content

Commit e80247a

Browse files
authored
[Profile] Add CFG support for RISC-V (#19)
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.
1 parent d9db435 commit e80247a

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lnt/server/ui/static/lnt_profile.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,16 @@ InstructionSetParser.prototype = {
100100
// TODO: add all control-flow-changing instructions.
101101
],
102102

103+
RISCVJumpTargetRegexps: [
104+
// (regexp, noFallThru?)
105+
// branch conditional:
106+
[new RegExp("^\\s*b[a-z]+\\s+.*(0x[0-9a-f]+)\\s+<.+>"), false],
107+
// jumps:
108+
[new RegExp("^\\s*(?:jal|j|call|tail)\\s+.*(0x[0-9a-f]+)\\s+<.+>"), true],
109+
// indirect jumps:
110+
[new RegExp("^\\s*(?:jalr|jr|ret)"), true]
111+
],
112+
103113
X86_64JumpTargetRegexps: [
104114
// (regexp, noFallThru?)
105115
// branch conditional:
@@ -513,6 +523,9 @@ Profile.prototype = {
513523
else if (this.instructionSet == 'aarch32t32')
514524
instructionParser = new InstructionSetParser(
515525
InstructionSetParser.prototype.AArch32T32JumpTargetRegexps);
526+
if (this.instructionSet == 'riscv')
527+
instructionParser = new InstructionSetParser(
528+
InstructionSetParser.prototype.RISCVJumpTargetRegexps);
516529
else if (this.instructionSet == 'x86_64')
517530
instructionParser = new InstructionSetParser(
518531
InstructionSetParser.prototype.X86_64JumpTargetRegexps);

lnt/server/ui/templates/v4_profile.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ <h3>Performance profile: {{ test.name }}
9393
<option value="cfg-aarch64">Control-Flow Graph (AArch64)</option>
9494
<option value="cfg-aarch32t32">Control-Flow Graph (AArch32-T32)</option>
9595
<option value="cfg-aarch32a32">Control-Flow Graph (AArch32-A32)</option>
96+
<option value="cfg-riscv">Control-Flow Graph (RISC-V)</option>
9697
<option value="cfg-x86_64">Control-Flow Graph (X86-64)</option>
9798
</select>
9899
</div>

0 commit comments

Comments
 (0)