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

Add mnemonic mapping for pseudoinstructions #45

Draft
wants to merge 12 commits into
base: json
Choose a base branch
from
23 changes: 22 additions & 1 deletion src/sail_json_backend/json.ml
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,28 @@ let parse_funcl fcl =
end
| _ -> debug_print "FCL_funcl other"

let get_mnemonic id args_list = None
let map_arg_to_mnemonic arg id = None

let map_param_to_arg id param args_list = None

let get_mnemonic id args_list =
match Hashtbl.find_opt assembly id with
| Some (str :: _) ->
if Str.string_match (Str.regexp ".+(\\(.*\\))") str 0 then (
Copy link
Owner

Choose a reason for hiding this comment

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

Might be nice to describe what this regex is looking for, or make it a variable with a meaningful name.

let param = Str.matched_group 1 str in
debug_print ("param: " ^ param);
match map_param_to_arg id param args_list with Some arg -> map_arg_to_mnemonic arg id | None -> None
)
else (
match Hashtbl.find_opt assembly_clean id with
| Some (mnemonic :: _) when mnemonic = str ->
debug_print ("Mnemonic matched: " ^ str);
Some str
| Some _ -> None
| None -> None
Copy link
Owner

Choose a reason for hiding this comment

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

These could be combined in a catch-all using "_".

)
| Some [] -> None
| None -> None
Copy link
Owner

Choose a reason for hiding this comment

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

These could be combined in a catch-all using "_".


let process_base_instruction () =
let mnemonics =
Expand Down