[sledge] Add sledge llvm disassemble subcommand

Summary: To translate LLVM to textual LLAIR in one step.

Reviewed By: ngorogiannis

Differential Revision: D23459507

fbshipit-source-id: 4992002a9
master
Josh Berdine 4 years ago committed by Facebook GitHub Bot
parent ca02dbd4aa
commit 6f435a74d7

@ -146,6 +146,33 @@ let analyze_cmd =
in
command ~summary ~readme param
let disassemble =
let%map_open llair_txt_output =
flag "llair-txt-output" (optional string)
~doc:
"<file> write generated textual LLAIR to <file>, or to standard \
output if omitted"
in
fun program () ->
let pgm = program () in
match llair_txt_output with
| None -> Format.printf "%a@." Llair.Program.pp pgm
| Some file ->
Out_channel.with_file file ~f:(fun oc ->
let fs = Format.formatter_of_out_channel oc in
Format.fprintf fs "%a@." Llair.Program.pp pgm )
let disassemble_cmd =
let summary = "print LLAIR code in textual form" in
let readme () =
"The <input> file must be LLAIR code, as produced by `sledge llvm \
translate`."
in
let param =
Command.Param.(anon ("<input>" %: string) >>| unmarshal |*> disassemble)
in
command ~summary ~readme param
let translate =
let%map_open llair_output =
flag "llair-output" (optional string)
@ -195,6 +222,14 @@ let llvm_grp =
let param = translate_inputs in
command ~summary ~readme param
in
let disassemble_cmd =
let summary =
"translate LLVM bitcode to LLAIR and print in textual form"
in
let readme () = "The <input> file must be LLVM bitcode." in
let param = translate_inputs |*> disassemble in
command ~summary ~readme param
in
let analyze_cmd =
let summary = "analyze LLVM bitcode" in
let readme () =
@ -210,32 +245,9 @@ let llvm_grp =
"Code can be provided by one or more LLVM bitcode files."
in
Command.group ~summary ~readme ~preserve_subcommand_order:()
[("analyze", analyze_cmd); ("translate", translate_cmd)]
let disassemble_cmd =
let summary = "print LLAIR code in textual form" in
let readme () =
"The <input> file must be LLAIR code, as produced by `sledge llvm \
translate`."
in
let param =
let%map_open input = anon ("<input>" %: string)
and llair_txt_output =
flag "llair-txt-output" (optional string)
~doc:
"<file> write generated textual LLAIR to <file>, or to standard \
output if omitted"
in
fun () ->
let program = unmarshal input () in
match llair_txt_output with
| None -> Format.printf "%a@." Llair.Program.pp program
| Some file ->
Out_channel.with_file file ~f:(fun oc ->
let fs = Format.formatter_of_out_channel oc in
Format.fprintf fs "%a@." Llair.Program.pp program )
in
command ~summary ~readme param
[ ("analyze", analyze_cmd)
; ("translate", translate_cmd)
; ("disassemble", disassemble_cmd) ]
let smt_cmd =
let summary = "process SMT-LIB benchmarks" in

@ -13,6 +13,7 @@ The [-trace <spec>] argument of each subcommand enables debug tracing according
llvm integration with LLVM
. analyze analyze LLVM bitcode
. translate translate LLVM bitcode to LLAIR
. disassemble translate LLVM bitcode to LLAIR and print in textual form
analyze analyze LLAIR code
disassemble print LLAIR code in textual form
smt process SMT-LIB benchmarks
@ -122,6 +123,7 @@ Code can be provided by one or more LLVM bitcode files.
analyze analyze LLVM bitcode
translate translate LLVM bitcode to LLAIR
disassemble translate LLVM bitcode to LLAIR and print in textual form
help explain a given subcommand (perhaps recursively)
@ -180,6 +182,31 @@ Translate one or more LLVM bitcode files to LLAIR. Each <input> filename may be
(alias: -?)
====== sledge llvm disassemble ======
translate LLVM bitcode to LLAIR and print in textual form
sledge llvm disassemble <input> [<input> ...]
The <input> file must be LLVM bitcode.
=== flags ===
[-colors] enable printing in colors
[-fuzzer] add a harness for libFuzzer targets
[-llair-output <file>] write generated LLAIR to <file>
[-llair-txt-output <file>] write generated textual LLAIR to <file>, or to
standard output if omitted
[-margin <cols>] wrap debug tracing at <cols> columns
[-no-internalize] do not internalize all functions except the entry
points specified in the config file
[-no-models] do not add models for C/C++ runtime and standard
libraries
[-trace <spec>] enable debug tracing
[-help] print this help text and exit
(alias: -?)
====== sledge analyze ======
analyze LLAIR code

Loading…
Cancel
Save