aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2017-02-08 16:07:16 +0100
committerBernhard Schommer <bernhardschommer@gmail.com>2017-02-08 16:07:16 +0100
commit42adde29c69ea99256a4303503dd5b30f978f172 (patch)
tree83f6da1e73ce032ab611fc7139d5142a0bd5f46a
parent6b0dbab6d1315ae3b0df26d034bce771f743af85 (diff)
downloadcompcert-kvx-42adde29c69ea99256a4303503dd5b30f978f172.tar.gz
compcert-kvx-42adde29c69ea99256a4303503dd5b30f978f172.zip
Revert broken change to Cutil.
The optional hex parameter only worked if the intconstant was also of unsigned kind. Hence it is better to have one function in Bitfields for this.
-rw-r--r--cparser/Bitfields.ml8
-rw-r--r--cparser/Cutil.ml8
-rw-r--r--cparser/Cutil.mli4
3 files changed, 10 insertions, 10 deletions
diff --git a/cparser/Bitfields.ml b/cparser/Bitfields.ml
index 2431a0bd..35da5d4e 100644
--- a/cparser/Bitfields.ml
+++ b/cparser/Bitfields.ml
@@ -195,13 +195,17 @@ let right_shift_count bf =
(Int64.of_int (8 * !config.sizeof_int - bf.bf_size))
IInt
+let uintconst_hex v =
+ { edesc = EConst(CInt(v, IUInt, Printf.sprintf "0x%LXU" v));
+ etyp = TInt(IUInt, []) }
+
let insertion_mask bf =
let m =
Int64.shift_left
(Int64.pred (Int64.shift_left 1L bf.bf_size))
bf.bf_pos in
(* Give the mask an hexadecimal string representation, nicer to read *)
- intconst ~hex:true m IUInt
+ uintconst_hex m
let eshift env op a b =
let ty = unary_conversion env a.etyp in
@@ -283,7 +287,7 @@ let bitfield_initializer bf i =
let m = Int64.pred (Int64.shift_left 1L bf.bf_size) in
let e_cast =
if bf.bf_bool then ecast (TInt(IBool,[])) e else e in
- let e_mask = intconst ~hex:true m IUInt in
+ let e_mask = uintconst_hex m in
let e_and =
{edesc = EBinop(Oand, e_cast, e_mask, TInt(IUInt,[]));
etyp = TInt(IUInt,[])} in
diff --git a/cparser/Cutil.ml b/cparser/Cutil.ml
index 8a59c147..2334966c 100644
--- a/cparser/Cutil.ml
+++ b/cparser/Cutil.ml
@@ -1007,12 +1007,8 @@ let int_pointer_conversion env tfrom tto =
(* Construct an integer constant *)
-let intconst ?hex v ik =
- let ist = match hex with
- | Some hex when hex ->
- Printf.sprintf "0x%LXU" v
- | _ -> "" in
- { edesc = EConst(CInt(v, ik, ist)); etyp = TInt(ik, []) }
+let intconst v ik =
+ { edesc = EConst(CInt(v, ik, "")); etyp = TInt(ik, []) }
(* Construct the 0 float constant of double type *)
diff --git a/cparser/Cutil.mli b/cparser/Cutil.mli
index 4eaa9e4a..9d053717 100644
--- a/cparser/Cutil.mli
+++ b/cparser/Cutil.mli
@@ -238,8 +238,8 @@ val field_of_arrow_access: Env.t -> typ -> string -> field
(* Constructors *)
-val intconst : ?hex:bool -> int64 -> ikind -> exp
- (* Build expression for given integer constant with optional hex string. *)
+val intconst : int64 -> ikind -> exp
+ (* Build expression for given integer constant. *)
val floatconst0 : exp
(* Build expression for (double)0. *)
val nullconst : exp