Project

General

Profile

« Previous | Next » 

Revision 4c945dde

Added by Pierre-Loïc Garoche almost 3 years ago

Improved tiny backend

View differences:

src/tools/tiny/tiny_utils.ml
26 26
    expr_type = Ast.BoolT }
27 27

  
28 28
let cst_num loc t q =
29
  let s = Q.to_string q in
30
  let s =  if t = Tiny.Ast.RealT && Z.equal (Q.den q) Z.one then s ^ "."
31
             else s in
29 32
{ Ast.expr_desc =
30
    Ast.Cst(q, Q.to_string q);
33
    Ast.Cst(q, s);
31 34
  expr_loc = loc;
32 35
  expr_type = t }
33 36
  
......
91 94
         | ">=", [v1;v2] ->
92 95
            Ast.Cond (build (Ast.Binop (Ast.Minus, v1, v2)) t_arg, Ast.Loose)
93 96
         | "uminus", [v1] -> Ast.Binop (Ast.Minus, cst_num loc t_arg Q.zero, v1)
94
         | "=", [v1;v2] -> Ast.Binop (Ast.Eq, v1, v2)
97
         (* | "=", [v1;v2] when v1.xxxtype != BoolT (\* if arguments are numerical then basic comparison *\)  
98
          *    Ast.Cond (build (Ast.Binop (Ast.Minus, v1, v2)) t_arg, Ast.Loose)
99
          *    Ast.Binop (Ast.Eq, v1, v2) *)
100
         | "=", [v1;v2] 
95 101
         | "equi", [v1;v2] -> Ast.Binop (Ast.Eq, v1, v2)
96 102
                            
97 103
         | "!=", [v1;v2] -> Ast.Unop (Ast.Not, build (Ast.Binop (Ast.Eq, v1, v2)) Ast.BoolT)
98 104
         | "not", [v1] -> Ast.Unop (Ast.Not, v1)
99 105
         | "&&", [v1;v2] -> Ast.Binop (Ast.And, v1, v2)
100 106
         | "||", [v1;v2] -> Ast.Binop (Ast.Or, v1, v2)
107
         | "impl", [v1;v2] ->
108
            let neg_v1 = Ast.neg_guard v1 in
109
            Ast.Binop (Ast.Or, neg_v1, v2)
101 110
                          
102 111
         | _ -> Format.eprintf "No tiny translation for operator %s@.@?" op; assert false    
103 112
       )
......
210 219
         )
211 220
         | name, _ -> 
212 221
            (
213
              Format.eprintf "No tiny translation for node call  %s@.@?" name;
222
              Format.eprintf "No tiny translation for stateful node call  %s@.@?" name;
214 223
              assert false
215 224
            )
216 225
       else (
217
         Format.eprintf "No tiny translation for node call  %s@.@?" id;
226
         Format.eprintf "No tiny translation for function call  %s@.@?" id;
218 227
         assert false
219 228
       )
220 229
    | MReset id
......
228 237
  let min, max =
229 238
    match bounds_opt with
230 239
      Some (min,max) -> min, max
231
    | None -> (Q.of_int (-1), "-1"), (Q.of_int 1, "1")
240
    | None ->
241
       let one, minus_one =
242
         match Types.is_real_type v.Lustre_types.var_type with
243
         | true -> "1.", "-1."
244
         | false -> "1", "-1"
245
                      
246
       in
247
       (Q.of_int (-1), minus_one), (Q.of_int 1, one)
232 248
  in
233 249
  let range = {
234 250
      Ast.expr_desc = Ast.Rand (min,max);

Also available in: Unified diff