diff options
Diffstat (limited to 'powerpc/eabi')
-rw-r--r-- | powerpc/eabi/CPragmas.ml | 69 |
1 files changed, 34 insertions, 35 deletions
diff --git a/powerpc/eabi/CPragmas.ml b/powerpc/eabi/CPragmas.ml index d4b79b52..4bb7786e 100644 --- a/powerpc/eabi/CPragmas.ml +++ b/powerpc/eabi/CPragmas.ml @@ -16,8 +16,8 @@ (* Platform-dependent handling of pragmas *) open Printf -open Cil open Camlcoq +open Cparser type section_info = { sec_name_init: string; @@ -94,7 +94,7 @@ let process_use_section_pragma classname id = let info = Hashtbl.find section_table classname in Hashtbl.add use_section_table (intern_string id) info with Not_found -> - Cil2Csyntax.error (sprintf "unknown section name `%s'" classname) + C2Clight.error (sprintf "unknown section name `%s'" classname) let default_use_section id classname = if not (Hashtbl.mem use_section_table id) then begin @@ -104,23 +104,25 @@ let default_use_section id classname = Hashtbl.add use_section_table id info end -let define_function id v = +let define_function id d = default_use_section id "CODE" -let define_stringlit id v = +let define_stringlit id = default_use_section id "STRING" -let define_variable id v = - let sz = Cil.bitsSizeOf v.vtype / 8 in +let define_variable id d = + let is_small limit = + match C2Clight.atom_sizeof id with + | None -> false + | Some sz -> sz <= limit in let sect = - if Cil2Csyntax.var_is_readonly v then - if sz <= !Clflags.option_small_const then "SCONST" else "CONST" + if C2Clight.atom_is_readonly id then + if is_small !Clflags.option_small_const then "SCONST" else "CONST" else - if sz <= !Clflags.option_small_data then "SDATA" else "DATA" in + if is_small !Clflags.option_small_data then "SDATA" else "DATA" in default_use_section id sect -(* CIL does not parse the "section" and "use_section" pragmas, which - have irregular syntax, so we parse them using regexps *) +(* Parsing of pragmas using regexps *) let re_start_pragma_section = Str.regexp "section\\b" @@ -142,7 +144,7 @@ let re_pragma_use_section = Str.regexp let re_split_idents = Str.regexp "[ \t,]+" -let process_pragma (Attr(name, _)) = +let process_pragma name = if Str.string_match re_pragma_section name 0 then begin process_section_pragma (Str.matched_group 1 name) (* classname *) @@ -152,44 +154,41 @@ let process_pragma (Attr(name, _)) = (Str.matched_group 5 name); (* accmode *) true end else if Str.string_match re_start_pragma_section name 0 then - Cil2Csyntax.error "ill-formed `section' pragma" + (C2Clight.error "ill-formed `section' pragma"; true) else if Str.string_match re_pragma_use_section name 0 then begin let classname = Str.matched_group 1 name and idents = Str.matched_group 2 name in let identlist = Str.split re_split_idents idents in - if identlist = [] then Cil2Csyntax.warning "vacuous `use_section' pragma"; + if identlist = [] then C2Clight.warning "vacuous `use_section' pragma"; List.iter (process_use_section_pragma classname) identlist; true end else if Str.string_match re_start_pragma_use_section name 0 then - Cil2Csyntax.error "ill-formed `use_section' pragma" + (C2Clight.error "ill-formed `use_section' pragma"; true) else false let initialize () = - Cil2Csyntax.process_pragma_hook := process_pragma; - Cil2Csyntax.define_variable_hook := define_variable; - Cil2Csyntax.define_function_hook := define_function; - Cil2Csyntax.define_stringlit_hook := define_stringlit + C2Clight.process_pragma_hook := process_pragma; + C2Clight.define_variable_hook := define_variable; + C2Clight.define_function_hook := define_function; + C2Clight.define_stringlit_hook := define_stringlit (* PowerPC-specific: say if an atom is in a small data area *) let atom_is_small_data a ofs = - begin try - let v = Hashtbl.find Cil2Csyntax.varinfo_atom a in - let sz = Cil.bitsSizeOf v.vtype / 8 in - let ofs = camlint_of_coqint ofs in - if ofs >= 0l && ofs < Int32.of_int sz then begin - try - (Hashtbl.find use_section_table a).sec_near_access - with Not_found -> - if Cil2Csyntax.var_is_readonly v - then sz <= !Clflags.option_small_const - else sz <= !Clflags.option_small_data - end else - false - with Not_found -> - false - end + match C2Clight.atom_sizeof a with + | None -> false + | Some sz -> + let ofs = camlint_of_coqint ofs in + if ofs >= 0l && ofs < Int32.of_int sz then begin + try + (Hashtbl.find use_section_table a).sec_near_access + with Not_found -> + if C2Clight.atom_is_readonly a + then sz <= !Clflags.option_small_const + else sz <= !Clflags.option_small_data + end else + false (* PowerPC-specific: determine section to use for a particular symbol *) |