Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unsupported instructions #393

Merged
merged 6 commits into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,10 @@ The RISC-V core supports the RV32I, RV64I, RV32M, RV64M, RV32F, and RV64F extens
- sll
- slt
- sltu
- cor
- srl
- sra
- or
- and
- fence
- fence.i
- csrrw
- csrrs
- csrrc
Expand All @@ -157,11 +154,6 @@ The RISC-V core supports the RV32I, RV64I, RV32M, RV64M, RV32F, and RV64F extens
- csrrci
- ecall
- ebreak
- uret
- sret
- mret
- wfi
- sfence.vma
- lb
- lh
- lw
Expand Down
80 changes: 0 additions & 80 deletions src/parser/parser_assembler_main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2542,86 +2542,6 @@ pub fn read_instructions_riscv(
monaco_line_info[instruction.line_number].mouse_hover_string = info.to_string();
}
}
"uret" => {
// uret instruction encoding does not change
instruction.binary = 0b00000000001000000000000001110011;

//Pseudo-instructions already have text in mouse_hover_string so we check if there's text there already before adding in the blurb
if monaco_line_info[instruction.line_number]
.mouse_hover_string
.is_empty()
{
let info = InstructionDescription{
syntax: "uret".to_string(),
description: "Return from traps in U-mode, and URET copies UPIE into UIE, then sets UPIE.".to_string(),
};
monaco_line_info[instruction.line_number].mouse_hover_string = info.to_string();
}
}
"sret" => {
// uret instruction encoding does not change
instruction.binary = 0b00010000001000000000000001110011;

//Pseudo-instructions already have text in mouse_hover_string so we check if there's text there already before adding in the blurb
if monaco_line_info[instruction.line_number]
.mouse_hover_string
.is_empty()
{
let info = InstructionDescription{
syntax: "uret".to_string(),
description: "Return from traps in U-mode, and URET copies UPIE into UIE, then sets UPIE.".to_string(),
};
monaco_line_info[instruction.line_number].mouse_hover_string = info.to_string();
}
}
"mret" => {
// uret instruction encoding does not change
instruction.binary = 0b00110000001000000000000001110011;

//Pseudo-instructions already have text in mouse_hover_string so we check if there's text there already before adding in the blurb
if monaco_line_info[instruction.line_number]
.mouse_hover_string
.is_empty()
{
let info = InstructionDescription{
syntax: "mret".to_string(),
description: "Return from traps in M-mode, and MRET copies MPIE into MIE, then sets MPIE.".to_string(),
};
monaco_line_info[instruction.line_number].mouse_hover_string = info.to_string();
}
}
"wfi" => {
// uret instruction encoding does not change
instruction.binary = 0b00010000010100000000000001110011;

//Pseudo-instructions already have text in mouse_hover_string so we check if there's text there already before adding in the blurb
if monaco_line_info[instruction.line_number]
.mouse_hover_string
.is_empty()
{
let info = InstructionDescription{
syntax: "wfi".to_string(),
description: "Provides a hint to the implementation that the current hart can be stalled until an interrupt might need servicing.\n\nExecution of the WFI instruction can also be used to inform the hardware platform that suitable interrupts should preferentially be routed to this hart.\n\nWFI is available in all privileged modes, and optionally available to U-mode.\n\nThis instruction may raise an illegal instruction exception when TW=1 in mstatus.".to_string(),
};
monaco_line_info[instruction.line_number].mouse_hover_string = info.to_string();
}
}
"fence.i" => {
// fence.i instruction encoding does not change
instruction.binary = 0b00000000000000000001000000001111;

//Pseudo-instructions already have text in mouse_hover_string so we check if there's text there already before adding in the blurb
if monaco_line_info[instruction.line_number]
.mouse_hover_string
.is_empty()
{
let info = InstructionDescription{
syntax: "fence.i".to_string(),
description: "Provides explicit synchronization between writes to instruction memory and instruction fetches on the same hart.".to_string(),
};
monaco_line_info[instruction.line_number].mouse_hover_string = info.to_string();
}
}
"lui" => {
read_operands_riscv(
instruction,
Expand Down
16 changes: 6 additions & 10 deletions src/parser/parser_structs_and_enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ pub const SUPPORTED_INSTRUCTIONS_MIPS: [&str; 64] = [
"sll", "slt", "sltu", "sub", "sub.d", "sub.s", "sw", "swc1",
];

pub const SUPPORTED_INSTRUCTIONS_RISCV: [&str; 131] = [
pub const SUPPORTED_INSTRUCTIONS_RISCV: [&str; 123] = [
// RV32I
"lui",
"auipc",
Expand All @@ -286,13 +286,10 @@ pub const SUPPORTED_INSTRUCTIONS_RISCV: [&str; 131] = [
"sll",
"slt",
"sltu",
"cor",
"srl",
"sra",
"or",
"and",
"fence",
"fence.i",
"csrrw",
"csrrs",
"csrrc",
Expand All @@ -301,11 +298,6 @@ pub const SUPPORTED_INSTRUCTIONS_RISCV: [&str; 131] = [
"csrrci",
"ecall",
"ebreak",
"uret",
"sret",
"mret",
"wfi",
"sfence.vma",
"lb",
"lh",
"lw",
Expand Down Expand Up @@ -820,7 +812,11 @@ pub const UNSUPPORTED_INSTRUCTIONS_MIPS: [&str; 408] = [
"xori",
];

pub const UNSUPPORTED_INSTRUCTIONS_RISCV: [&str; 69] = [
pub const UNSUPPORTED_INSTRUCTIONS_RISCV: [&str; 73] = [
"fence",
"fence.i",
"sfence.vma",
"uret",
"lr.w",
"sc.w",
"amoswap.w",
Expand Down
60 changes: 0 additions & 60 deletions src/tests/parser/parser_assembler_main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,66 +475,6 @@ mod read_riscv_instructions_tests {
);
}

#[test]
fn read_instructions_uret() {
let file_string = "uret".to_string();

let instruction_list = instruction_parser_riscv(file_string);

assert_eq!(
instruction_list[0].binary,
0b00000000001000000000000001110011
);
}

#[test]
fn read_instructions_sret() {
let file_string = "sret".to_string();

let instruction_list = instruction_parser_riscv(file_string);

assert_eq!(
instruction_list[0].binary,
0b00010000001000000000000001110011
);
}

#[test]
fn read_instructions_mret() {
let file_string = "mret".to_string();

let instruction_list = instruction_parser_riscv(file_string);

assert_eq!(
instruction_list[0].binary,
0b00110000001000000000000001110011
);
}

#[test]
fn read_instructions_wfi() {
let file_string = "wfi".to_string();

let instruction_list = instruction_parser_riscv(file_string);

assert_eq!(
instruction_list[0].binary,
0b00010000010100000000000001110011
);
}

#[test]
fn read_instructions_fencei() {
let file_string = "fence.i".to_string();

let instruction_list = instruction_parser_riscv(file_string);

assert_eq!(
instruction_list[0].binary,
0b00000000000000000001000000001111
);
}

#[test]
fn read_instructions_lui() {
let file_string = "lui x16, 4096".to_string();
Expand Down
Loading