aboutsummaryrefslogtreecommitdiffstats
path: root/powerpc/AsmToJSON.ml
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2015-07-06 15:58:26 +0200
committerBernhard Schommer <bernhardschommer@gmail.com>2015-07-06 15:58:26 +0200
commit0a4cf6562122684811db5ed3dd059769ca1a06d9 (patch)
tree34a812758978efa8198239c4651f79b52d90e413 /powerpc/AsmToJSON.ml
parente30aa60a06817ed67c14a80430a7275defc41e76 (diff)
downloadcompcert-kvx-0a4cf6562122684811db5ed3dd059769ca1a06d9.tar.gz
compcert-kvx-0a4cf6562122684811db5ed3dd059769ca1a06d9.zip
Use the functions from C2C to extract the information for the atoms. Simplified printing of storage class.
Diffstat (limited to 'powerpc/AsmToJSON.ml')
-rw-r--r--powerpc/AsmToJSON.ml35
1 files changed, 18 insertions, 17 deletions
diff --git a/powerpc/AsmToJSON.ml b/powerpc/AsmToJSON.ml
index 36960821..520bc1ed 100644
--- a/powerpc/AsmToJSON.ml
+++ b/powerpc/AsmToJSON.ml
@@ -297,13 +297,11 @@ let p_instruction oc ic =
| Pcfi_adjust _ (* Only debug relevant *)
| Pcfi_rel_offset _ -> () (* Only debug relevant *)
-let p_storage oc sto =
- let storage = match sto with
- | C.Storage_default -> "Default"
- | C.Storage_extern -> "Extern"
- | C.Storage_static -> "Static"
- | C.Storage_register -> "" (* This should not occur *) in
- fprintf oc "\"%s\"" storage
+let p_storage oc static =
+ if static then
+ fprintf oc "\"Static\""
+ else
+ fprintf oc "\"Extern\""
let p_section oc = function
| Section_text -> fprintf oc "{\"Section Name\":\"Text\"}"
@@ -324,12 +322,14 @@ let p_int_opt oc = function
let p_fundef oc (name,f) =
- let info = Hashtbl.find C2C.decl_atom name in
- let instr = List.filter (function Pannot _ | Pcfi_adjust _ | Pcfi_rel_offset _ -> false | _ -> true) f.fn_code in
- let c_section,l_section,j_section = match info.a_sections with [a;b;c] -> a,b,c | _ -> assert false in
+ let alignment = atom_alignof name
+ and inline = atom_is_inline name
+ and static = atom_is_static name
+ and instr = List.filter (function Pannot _ | Pcfi_adjust _ | Pcfi_rel_offset _ -> false | _ -> true) f.fn_code in
+ let c_section,l_section,j_section = match (atom_sections name) with [a;b;c] -> a,b,c | _ -> assert false in
fprintf oc "{\"Fun Name\":%a,\n\"Fun Storage Class\":%a,\n\"Fun Alignment\":%a,\n\"Fun Section Code\":%a,\"Fun Section Literals\":%a,\"Fun Section Jumptable\":%a,\n\"Fun Inline\":%B,\n\"Fun Code\":%a}\n"
- p_atom name p_storage info.a_storage p_int_opt info.a_alignment
- p_section c_section p_section l_section p_section j_section info.a_inline
+ p_atom name p_storage static p_int_opt alignment
+ p_section c_section p_section l_section p_section j_section inline
(p_list p_instruction) instr
let p_init_data oc = function
@@ -342,12 +342,13 @@ let p_init_data oc = function
| Init_space z -> fprintf oc "{\"Init_space\":%a}" p_z z
| Init_addrof (p,i) -> fprintf oc "{\"Init_addrof\":{\"Addr\":%a,\"Offset\":%a}}" p_atom p p_int i
-let p_vardef oc (ident,v) =
- let info = Hashtbl.find C2C.decl_atom ident in
- let section = match info.a_sections with [s] -> s | _ -> assert false (* Should only have one section *) in
+let p_vardef oc (name,v) =
+ let alignment = atom_alignof name
+ and static = atom_is_static name
+ and section = match (atom_sections name) with [s] -> s | _ -> assert false (* Should only have one section *) in
fprintf oc "{\"Var Name\":%a,\"Var Readonly\":%B,\"Var Volatile\":%B,\n\"Var Storage Class\":%a,\n\"Var Alignment\":%a,\n\"Var Section\":%a,\n\"Var Init\":%a}\n"
- p_atom ident v.gvar_readonly v.gvar_volatile
- p_storage info.a_storage p_int_opt info.a_alignment p_section section
+ p_atom name v.gvar_readonly v.gvar_volatile
+ p_storage static p_int_opt alignment p_section section
(p_list p_init_data) v.gvar_init
let p_program oc prog =