Project

General

Profile

Revision 5318ad88

View differences:

src/backends/C/c_backend_common.ml
126 126
  else (* Regular behavior: printing a / *)
127 127
    Format.fprintf fmt "(%a / %a)" pp_val v1 pp_val v2
128 128
  
129
let pp_basic_lib_fun i pp_val fmt vl =
129
let pp_basic_lib_fun is_int i pp_val fmt vl =
130 130
  match i, vl with
131 131
  (*  | "ite", [v1; v2; v3] -> Format.fprintf fmt "(%a?(%a):(%a))" pp_val v1 pp_val v2 pp_val v3 *)
132 132
  | "uminus", [v] -> Format.fprintf fmt "(- %a)" pp_val v
......
134 134
  | "impl", [v1; v2] -> Format.fprintf fmt "(!%a || %a)" pp_val v1 pp_val v2
135 135
  | "=", [v1; v2] -> Format.fprintf fmt "(%a == %a)" pp_val v1 pp_val v2
136 136
  | "mod", [v1; v2] ->
137
     let typ = v1.value_type in
138
     if Types.is_int_type v1.value_type then
137
     if is_int then
139 138
       pp_mod pp_val v1 v2 fmt 
140 139
     else
141 140
       Format.fprintf fmt "(%a %% %a)" pp_val v1 pp_val v2
142 141
  | "equi", [v1; v2] -> Format.fprintf fmt "(!%a == !%a)" pp_val v1 pp_val v2
143 142
  | "xor", [v1; v2] -> Format.fprintf fmt "(!%a != !%a)" pp_val v1 pp_val v2
144 143
  | "/", [v1; v2] ->
145
     if Types.is_int_type v1.value_type then
144
     if is_int then
146 145
       pp_div pp_val v1 v2 fmt
147 146
     else
148 147
       Format.fprintf fmt "(%a / %a)" pp_val v1 pp_val v2
......
162 161
     fprintf fmt "((%a)?%a:%a)"
163 162
       pp_c_dimension i pp_c_dimension t pp_c_dimension e
164 163
  | Dimension.Dappl (f, args) ->
165
     fprintf fmt "%a" (pp_basic_lib_fun f pp_c_dimension) args
164
     fprintf fmt "%a" (pp_basic_lib_fun (Basic_library.is_numeric_operator f) f pp_c_dimension) args
166 165
  | Dimension.Dlink dim' -> fprintf fmt "%a" pp_c_dimension dim'
167 166
  | Dimension.Dvar       -> fprintf fmt "_%s" (Utils.name_of_dimension dim.Dimension.dim_id)
168 167
  | Dimension.Dunivar    -> fprintf fmt "'%s" (Utils.name_of_dimension dim.Dimension.dim_id)
......
250 249
    if Types.is_array_type v.var_type && not (Types.is_real_type v.var_type && !Options.mpfr)
251 250
    then fprintf fmt "%a" pp_var v
252 251
    else fprintf fmt "%s->_reg.%a" self pp_var v
253
  | Fun (n, vl)   -> pp_basic_lib_fun n (pp_c_val self pp_var) fmt vl
252
  | Fun (n, vl)   -> pp_basic_lib_fun (Types.is_int_type v.value_type) n (pp_c_val self pp_var) fmt vl
254 253

  
255 254
(* Access to the value of a variable:
256 255
   - if it's not a scalar output, then its name is enough
src/backends/C/c_backend_header.ml
55 55
  match v.value_desc with
56 56
  | Cst c         -> pp_c_const fmt c
57 57
  | LocalVar v    -> pp_var fmt v
58
  | Fun (n, vl)   -> pp_basic_lib_fun n (print_static_val pp_var) fmt vl
58
  | Fun (n, vl)   -> pp_basic_lib_fun (Types.is_int_type v.value_type) n (print_static_val pp_var) fmt vl
59 59
  | _             -> (Format.eprintf "Internal error: C_backend_header.print_static_val"; assert false)
60 60

  
61 61
let print_constant_decl (m, attr, inst) pp_var fmt v =
src/backends/C/c_backend_src.ml
163 163
    | _           :: q, Power (v, n)  ->
164 164
       pp_value_suffix self var_type q pp_value fmt v
165 165
    | _               , Fun (n, vl)   ->
166
       pp_basic_lib_fun n (pp_value_suffix self var_type loop_vars pp_value) fmt vl
166
       pp_basic_lib_fun (Types.is_int_type value.value_type) n (pp_value_suffix self var_type loop_vars pp_value) fmt vl
167 167
    | _               , Access (v, i) ->
168 168
       let var_type = Type_predef.type_array (Dimension.mkdim_var ()) var_type in
169 169
       pp_value_suffix self var_type ((Dimension.mkdim_var (), LAcc i) :: loop_vars) pp_value fmt v

Also available in: Unified diff