informatica:ae:ocamldiplog
Differenze
Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.
Prossima revisione | Revisione precedente | ||
informatica:ae:ocamldiplog [08/04/2011 alle 12:52 (14 anni fa)] – creata Marco Danelutto | informatica:ae:ocamldiplog [15/12/2011 alle 09:08 (13 anni fa)] (versione attuale) – [Esecuzione di codice] Marco Danelutto | ||
---|---|---|---|
Linea 5: | Linea 5: | ||
significative, | significative, | ||
+ | E' disponibile una versione che corregge parte dei problemi della versione originale discussa nel seguito (realizzata da Nicola Corti). La versione include un [[file_asm.ml|asm.ml]] e un [[file_drisc.ml|drisc.ml]] modificati ed espansi. La documentazione di questa versione estesa è disponibile su [[http:// | ||
+ | ==== Documentazione ==== | ||
+ | La documentazione generata con ocamldoc si trova su [[http:// | ||
==== Analisi delle dipendenze ==== | ==== Analisi delle dipendenze ==== | ||
Il codice che segue serve a trovare le dipendenze logiche in codice D-RISC. Il software funziona come dovuto su assembler privo di salti (ovvero non | Il codice che segue serve a trovare le dipendenze logiche in codice D-RISC. Il software funziona come dovuto su assembler privo di salti (ovvero non | ||
Linea 14: | Linea 17: | ||
Per utilizzare il codice, seguite questi passi. | Per utilizzare il codice, seguite questi passi. | ||
- | **Codice D-RISC** | + | **Codice D-RISC** |
- | < | + | < |
let p = [ | let p = [ | ||
LabInstr(LabLab(" | LabInstr(LabLab(" | ||
Linea 26: | Linea 29: | ||
];; | ];; | ||
</ | </ | ||
+ | |||
+ | **Interprete** Lanciate un interprete ocaml da riga di comando. Caricate il file [[asmsource|asm.ml]] con il comando < | ||
+ | |||
+ | **Uso del tool** A questo punto potete: | ||
+ | * stampare il programma in formato leggibile (funzione **pp_prog** con parametri: 1) indirizzo della prima istruzione (normalmente 0) e 2) variabile con la rappresentazione del programma) | ||
+ | * vedere le dipendenze logiche (funzione **data_deps** con 1 parametro: variabile con la rappresentazione del programma) | ||
+ | * stampare le dipendenze logiche in forma leggibile (funzione **pp_deps* con 1 parametro: lista delle dipendenze | ||
+ | |||
+ | Di seguito riportiamo un dump della sessione a terminale che mostra le dipendenze del codice in **prog.ml** | ||
+ | < | ||
+ | marcod@macuntu: | ||
+ | Objective Caml version 3.12.0 | ||
+ | |||
+ | # #use " | ||
+ | type reg = Reg of int | ||
+ | type label = LabOff of int | LabLab of string | ||
+ | type const = Const of int | ||
+ | type asm = | ||
+ | ADD of reg * reg * reg | ||
+ | | SUB of reg * reg * reg | ||
+ | | MUL of reg * reg * reg | ||
+ | | DIV of reg * reg * reg | ||
+ | | ADDI of reg * const * reg | ||
+ | | SUBI of reg * const * reg | ||
+ | | INC of reg | ||
+ | | DEC of reg | ||
+ | | LD of reg * reg * reg | ||
+ | | LDI of reg * const * reg | ||
+ | | ST of reg * reg * reg | ||
+ | | STI of reg * const * reg | ||
+ | | CALL of reg * reg | ||
+ | | GOTOR of reg | ||
+ | | GOTOL of label | ||
+ | | IFLEQ of reg * reg * label | ||
+ | | IFLE of reg * reg * label | ||
+ | | IFGEQ of reg * reg * label | ||
+ | | IFGE of reg * reg * label | ||
+ | | IFEQ of reg * reg * label | ||
+ | | IFNEQ of reg * reg * label | ||
+ | | END | ||
+ | type instruction = Instr of asm | LabInstr of label * asm | ||
+ | val domain : asm -> reg list = <fun> | ||
+ | val codomain : asm -> reg list = <fun> | ||
+ | val intersect : 'a list -> 'a list -> 'a list = <fun> | ||
+ | val iu_instruction : asm -> bool = <fun> | ||
+ | type datadep = | ||
+ | NoDataDep | ||
+ | | DataDep of int * asm * int * asm * reg list * int * int | ||
+ | val delab : instruction -> asm = <fun> | ||
+ | val data_dep_i : | ||
+ | int -> int -> instruction -> instruction -> int -> int -> datadep = <fun> | ||
+ | val loadsinsequence : instruction list -> int -> int -> bool = <fun> | ||
+ | val data_deps : instruction list -> datadep list = <fun> | ||
+ | val bernstein : asm -> asm -> bool = <fun> | ||
+ | val pp_reg : reg -> unit = <fun> | ||
+ | val pp_regs : reg list -> unit = <fun> | ||
+ | val pp_reg_set : int ref array -> unit = <fun> | ||
+ | val pp_mem : int ref array -> unit = <fun> | ||
+ | val pp_lab : label -> unit = <fun> | ||
+ | val pp_const : const -> unit = <fun> | ||
+ | val pp_asm : asm -> unit = <fun> | ||
+ | val pp_instr : int -> instruction -> unit = <fun> | ||
+ | val pp_prog : int -> instruction list -> unit = <fun> | ||
+ | val pp_program : instruction list -> unit = <fun> | ||
+ | val pp_dd : datadep -> unit = <fun> | ||
+ | val pp_deps : datadep list -> unit = <fun> | ||
+ | val prog_to_asm : instruction list -> asm list = <fun> | ||
+ | type assoc = Ass of string * int | ||
+ | val hasKey : string -> assoc list -> bool = <fun> | ||
+ | val valueOfKey : string -> assoc list -> int = <fun> | ||
+ | type penv = Penv of int ref * int ref array * int ref array * assoc list | ||
+ | val dump : penv -> unit = <fun> | ||
+ | val exec_i : asm -> penv -> unit = <fun> | ||
+ | val labels : instruction list -> int -> assoc list = <fun> | ||
+ | # #use " | ||
+ | val p : instruction list = | ||
+ | [LabInstr (LabLab " | ||
+ | Instr (LD (Reg 6, Reg 1, Reg 11)); Instr (ADD (Reg 10, Reg 11, Reg 12)); | ||
+ | Instr (ST (Reg 7, Reg 1, Reg 12)); Instr (INC (Reg 1)); | ||
+ | Instr (IFLE (Reg 1, Reg 2, LabLab " | ||
+ | # pp_prog 0 p;; | ||
+ | 0. loop :LOAD R_5 R_1 R_10 | ||
+ | 1. LOAD | ||
+ | 2. ADD | ||
+ | 3. STORE | ||
+ | 4. INC R_1 | ||
+ | 5. IF< | ||
+ | 6. END | ||
+ | |||
+ | - : unit = () | ||
+ | # data_deps p;; | ||
+ | - : datadep list = | ||
+ | [DataDep (2, ADD (Reg 10, Reg 11, Reg 12), 3, ST (Reg 7, Reg 1, Reg 12), | ||
+ | [Reg 12], 1, 2); | ||
+ | | ||
+ | 1)] | ||
+ | # pp_deps (data_deps p);; | ||
+ | DD:: 2. ADD R_10 R_11 R_12 ==>> 3. STORE R_7 R_1 R_12 (d=1 N=2) due to reg(s) R_12 | ||
+ | DD:: 4. INC R_1 ==>> 5. IF< | ||
+ | - : unit = () | ||
+ | # #quit;; | ||
+ | marcod@macuntu: | ||
+ | exit | ||
+ | |||
+ | Script done on Fri 08 Apr 2011 03:06:31 PM CEST | ||
+ | marcod@macuntu: | ||
+ | </ | ||
+ | |||
+ | ==== Esecuzione di codice ===== | ||
+ | |||
+ | Per eseguire del codice DRISC, utilizzate gli strumenti (New: Dicembre 2011) disponibili su [[http:// | ||
informatica/ae/ocamldiplog.1302267161.txt.gz · Ultima modifica: 08/04/2011 alle 12:52 (14 anni fa) da Marco Danelutto