Changeset 461


Ignore:
Timestamp:
Jan 19, 2011, 6:23:28 PM (7 years ago)
Author:
campbell
Message:

Handle null pointer constants properly for generic pointers (introducing a 24-bit quantity for them).

Location:
Deliverables/D2.3/8051-memoryspaces-branch
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • Deliverables/D2.3/8051-memoryspaces-branch/cparser/C.mli

    r460 r461  
    5050  | FLongDouble (** [long double] *)
    5151
     52(** 8051 memory spaces *)
     53
     54type memory_space =
     55  | Any
     56  | Data
     57  | IData
     58  | PData
     59  | XData
     60  | Code
     61
    5262
    5363(** Constants *)
     
    5565type constant =
    5666  | CInt of int64 * ikind * string      (* as it appeared in the source *)
     67  | CNull of memory_space
    5768  | CFloat of float * fkind * string    (* as it appeared in the source *)
    5869  | CStr of string
     
    125136(** Types *)
    126137
    127 type memory_space =
    128   | Any
    129   | Data
    130   | IData
    131   | PData
    132   | XData
    133   | Code
    134 
    135138type typ =
    136139  | TVoid of attributes
  • Deliverables/D2.3/8051-memoryspaces-branch/cparser/Ceval.ml

    r460 r461  
    7272let constant = function
    7373  | CInt(v, ik, _) -> I (normalize_int v ik)
     74  | CNull _ -> I 0L
    7475  | CFloat(v, fk, _) -> F (normalize_float v fk)
    7576  | CStr s -> S s
     
    271272    | TInt(ik, _), I n -> Some(CInt(n, ik, ""))
    272273    | TFloat(fk, _), F n -> Some(CFloat(n, fk, ""))
    273     | TPtr(_, _, _), I 0L -> Some(CInt(0L, IInt, ""))
     274    | TPtr(sp, _, _), I 0L -> Some(CNull sp)
    274275    | TPtr(_, _, _), S s -> Some(CStr s)
    275276    | TPtr(_, _, _), WS s -> Some(CWStr s)
  • Deliverables/D2.3/8051-memoryspaces-branch/cparser/Cprint.ml

    r460 r461  
    129129        | _ -> ()
    130130      end
     131  | CNull _ -> fprintf pp "0"
    131132  | CFloat(v, fk, s) ->
    132133      if s <> "" then
  • Deliverables/D2.3/8051-memoryspaces-branch/cparser/Cutil.ml

    r460 r461  
    584584let type_of_constant = function
    585585  | CInt(_, ik, _) -> TInt(ik, [])
     586  | CNull _ -> TInt(IInt, []) (* FIXME? *)
    586587  | CFloat(_, fk, _) -> TFloat(fk, [])
    587588  | CStr _ -> TPtr(Code, TInt(IChar, []), [])          (* XXX or array? const? *)
  • Deliverables/D2.3/8051-memoryspaces-branch/src/clight/clight.mli

    r460 r461  
    194194  | Init_int8 of int
    195195  | Init_int16 of int
     196  | Init_int24 of int
    196197  | Init_int32 of int
    197198  | Init_float32 of float
  • Deliverables/D2.3/8051-memoryspaces-branch/src/clight/clightFromC.ml

    r460 r461  
    283283  | C.EConst(C.CInt(i, _, _)) ->
    284284      Expr(Econst_int( convertInt i), ty)
     285  | C.EConst(C.CNull _) ->
     286      Expr(Econst_int( convertInt 0L), ty)
    285287  | C.EConst(C.CFloat(f, _, _)) ->
    286288      Expr(Econst_float f, ty)
     
    649651              emit 4 (Init_int32(convertInt v))
    650652          end
     653      | Some(C.CNull sp) ->
     654          let z = convertInt 0L in
     655          begin match sp with
     656          | C.Any   -> emit 3 (Init_int24 z)
     657          | C.Data
     658          | C.IData
     659          | C.PData -> emit 1 (Init_int8 z)
     660          | C.XData
     661          | C.Code  -> emit 2 (Init_int16 z)
     662          end
    651663      | Some(C.CFloat(v, fk, _)) ->
    652664          begin match convertFkind fk with
  • Deliverables/D2.3/8051-memoryspaces-branch/src/clight/clightInterpret.ml

    r460 r461  
    635635  | Init_int8 i         -> Data_int8 i
    636636  | Init_int16 i        -> Data_int16 i
     637  | Init_int24 i        -> Data_int24 i
    637638  | Init_int32 i        -> Data_int32 i
    638639  | Init_float32 f      -> assert false (* Not supported *)
     
    648649    | Init_int16 i -> (Mem.store m Memory.MQ_int16signed ptr (Value.of_int i)
    649650                       ,Value.add ptr (Value.of_int 2))
     651    | Init_int24 i -> (Mem.store m Memory.MQ_int24 ptr (Value.of_int i)
     652                       ,Value.add ptr (Value.of_int 3))
    650653    | Init_int32 i -> (Mem.store m Memory.MQ_int32 ptr (Value.of_int i)
    651654                       ,Value.add ptr (Value.of_int 4))
  • Deliverables/D2.3/8051-memoryspaces-branch/src/clight/clightPrintMatita.ml

    r460 r461  
    364364  | Init_int8 n -> fprintf p "(Init_int8 (repr %d))@ " n
    365365  | Init_int16 n -> fprintf p "(Init_int16 (repr %d))@ " n
     366  | Init_int24 n -> fprintf p "(Init_int24 (repr %d))@ " n
    366367  | Init_int32 n -> fprintf p "(Init_int32 (repr %d))@ " n
    367368  | Init_float32 n -> fprintf p "(Init_float32 %F)@ " n
  • Deliverables/D2.3/8051-memoryspaces-branch/src/clight/clightPrinter.ml

    r460 r461  
    384384  | Init_int8 n -> fprintf p "%ld,@ " (Int32.of_int n)
    385385  | Init_int16 n -> fprintf p "%ld,@ " (Int32.of_int n)
     386  | Init_int24 n -> fprintf p "%ld,@ " (Int32.of_int n)
    386387  | Init_int32 n -> fprintf p "%ld,@ " (Int32.of_int n)
    387388  | Init_float32 n -> fprintf p "%F,@ " n
     
    397398  | Init_int8 n -> fprintf p "%ld" (Int32.of_int n)
    398399  | Init_int16 n -> fprintf p "%ld" (Int32.of_int n)
     400  | Init_int24 n -> fprintf p "%ld" (Int32.of_int n)
    399401  | Init_int32 n -> fprintf p "%ld" (Int32.of_int n)
    400402  | Init_float32 n -> fprintf p "%F" n
  • Deliverables/D2.3/8051-memoryspaces-branch/src/clight/clightToCminor.ml

    r460 r461  
    5353    | Init_int8 i       -> Data_int8 i
    5454    | Init_int16 i      -> Data_int16 i
     55    | Init_int24 i      -> Data_int24 i
    5556    | Init_int32 i      -> Data_int32 i
    5657    | Init_float32 _
  • Deliverables/D2.3/8051-memoryspaces-branch/src/cminor/cminorPrinter.ml

    r453 r461  
    2323  | Data_int8 i -> Printf.sprintf "(int8) %d" i
    2424  | Data_int16 i -> Printf.sprintf "(int16) %d" i
     25  | Data_int24 i -> Printf.sprintf "%d" i
    2526  | Data_int32 i -> Printf.sprintf "%d" i
    2627  | Data_float32 f -> Printf.sprintf "%f" f
  • Deliverables/D2.3/8051-memoryspaces-branch/src/common/AST.mli

    r453 r461  
    7373  | Data_int8 of int
    7474  | Data_int16 of int
     75  | Data_int24 of int
    7576  | Data_int32 of int
    7677  | Data_float32 of float
  • Deliverables/D2.3/8051-memoryspaces-branch/src/common/intValue.ml

    r453 r461  
    262262end)
    263263
     264module Int24 : S = Make
     265(struct
     266  let size = 3
     267  let is_signed = false
     268end)
     269
    264270module Int32 : S = Make
    265271(struct
     
    280286type int16s  = Int16s.t
    281287type int16u  = Int16u.t
     288type int24   = Int24.t
    282289type int32   = Int32.t
    283290type integer = Integer.t
  • Deliverables/D2.3/8051-memoryspaces-branch/src/common/intValue.mli

    r453 r461  
    7979module Int16s  : S
    8080module Int16u  : S
     81module Int24   : S
    8182module Int32   : S
    8283
     
    8889type int16s  = Int16s.t
    8990type int16u  = Int16u.t
     91type int24   = Int32.t
    9092type int32   = Int32.t
    9193type integer = Integer.t
  • Deliverables/D2.3/8051-memoryspaces-branch/src/common/memory.ml

    r453 r461  
    1616type memory_q =
    1717  | MQ_int8signed | MQ_int8unsigned | MQ_int16signed | MQ_int16unsigned
    18   | MQ_int32 | MQ_float32 | MQ_float64 | MQ_pointer | MQ_chunk
     18  | MQ_int24 | MQ_int32 | MQ_float32 | MQ_float64 | MQ_pointer | MQ_chunk
    1919
    2020let string_of_memory_q = function
     
    2323  | MQ_int16signed -> "int16s"
    2424  | MQ_int16unsigned -> "int16u"
     25  | MQ_int24 -> "int24"
    2526  | MQ_int32 -> "int32"
    2627  | MQ_float32 -> "float"
     
    3334  | AST.Data_int8 _ -> MQ_int8signed
    3435  | AST.Data_int16 _ -> MQ_int16signed
     36  | AST.Data_int24 _ -> MQ_int24
    3537  | AST.Data_int32 _ -> MQ_int32
    3638  | AST.Data_float32 _ -> MQ_float32
     
    3941let type_of_memory_q = function
    4042  | MQ_int8signed | MQ_int8unsigned | MQ_int16signed | MQ_int16unsigned
    41   | MQ_int32 -> AST.Sig_int
     43  | MQ_int24 | MQ_int32 -> AST.Sig_int
    4244  | MQ_float32 | MQ_float64 -> AST.Sig_float
    4345  | MQ_pointer -> AST.Sig_ptr
     
    256258    | MQ_int8unsigned | MQ_int8signed -> 1
    257259    | MQ_int16unsigned | MQ_int16signed -> 2
     260    | MQ_int24 -> 3
    258261    | MQ_int32 | MQ_float32 -> 4
    259262    | MQ_float64 -> 8
     
    266269    | MQ_int16unsigned -> Value.cast16unsigned
    267270    | MQ_int16signed -> Value.cast16signed
     271    | MQ_int24 -> Value.cast24
    268272    | MQ_int32 -> Value.cast32
    269273    | MQ_float32 | MQ_float64 -> error "float not supported."
     
    410414  let value_of_data = function
    411415    | AST.Data_reserve _ -> Value.undef
    412     | AST.Data_int8 i | AST.Data_int16 i | AST.Data_int32 i -> Value.of_int i
     416    | AST.Data_int8 i | AST.Data_int16 i | AST.Data_int24 i | AST.Data_int32 i -> Value.of_int i
    413417    | AST.Data_float32 f | AST.Data_float64 f -> Value.of_float f
    414418
  • Deliverables/D2.3/8051-memoryspaces-branch/src/common/memory.mli

    r453 r461  
    1010type memory_q =
    1111  | MQ_int8signed | MQ_int8unsigned | MQ_int16signed | MQ_int16unsigned
    12   | MQ_int32 | MQ_float32 | MQ_float64 | MQ_pointer | MQ_chunk
     12  | MQ_int24 | MQ_int32 | MQ_float32 | MQ_float64 | MQ_pointer | MQ_chunk
    1313
    1414val string_of_memory_q : memory_q -> string
  • Deliverables/D2.3/8051-memoryspaces-branch/src/common/value.ml

    r453 r461  
    6262  val cast16unsigned : t -> t
    6363  val cast16signed   : t -> t   
     64  val cast24         : t -> t
    6465  val cast32         : t -> t
    6566
     
    273274  let cast16unsigned = cast Int16u.cast
    274275  let cast16signed = cast Int16s.cast
     276  let cast24 = cast Int24.cast
    275277  let cast32 = cast Int32.cast
    276278
  • Deliverables/D2.3/8051-memoryspaces-branch/src/common/value.mli

    r453 r461  
    5656  val cast16unsigned : t -> t
    5757  val cast16signed   : t -> t
     58  val cast24         : t -> t
    5859  val cast32         : t -> t
    5960
Note: See TracChangeset for help on using the changeset viewer.