aboutsummaryrefslogtreecommitdiffstats
path: root/mppa_k1c/PostpassSchedulingOracle.ml
diff options
context:
space:
mode:
authorCyril SIX <cyril.six@kalray.eu>2019-03-08 15:15:59 +0100
committerCyril SIX <cyril.six@kalray.eu>2019-03-08 15:15:59 +0100
commit147c0ec814867d38edab86bbf1fd05e7fd23a68b (patch)
treef41b082a6e6291218d9290e561bb74c79a6bcc10 /mppa_k1c/PostpassSchedulingOracle.ml
parentfdc5df430f2823004d2506cf579f7126d46d3a26 (diff)
downloadcompcert-kvx-147c0ec814867d38edab86bbf1fd05e7fd23a68b.tar.gz
compcert-kvx-147c0ec814867d38edab86bbf1fd05e7fd23a68b.zip
Fix for the compw immediate problem
Diffstat (limited to 'mppa_k1c/PostpassSchedulingOracle.ml')
-rw-r--r--mppa_k1c/PostpassSchedulingOracle.ml24
1 files changed, 17 insertions, 7 deletions
diff --git a/mppa_k1c/PostpassSchedulingOracle.ml b/mppa_k1c/PostpassSchedulingOracle.ml
index 89ec34e2..7b632144 100644
--- a/mppa_k1c/PostpassSchedulingOracle.ml
+++ b/mppa_k1c/PostpassSchedulingOracle.ml
@@ -249,14 +249,24 @@ let signed_length (i:int64) =
in if (within i interv) then n else f i (n+1)
in f i 1
+let unsigned_length (i:int64) = (signed_length i) - 1
+
let encode_imm (imm:int64) =
- let length = signed_length imm
- in if length <= 7 then U6 (* Unsigned -> 1 bit less needed *)
- else if length <= 10 then S10
- else if length <= 32 then U27L5 (* Upper 27 Lower 5 is signed *)
- else if length <= 37 then U27L10
- else if length <= 64 then E27U27L10
- else failwith @@ sprintf "encode_imm: integer too big! (%Ld)" imm
+ if (Int64.compare imm Int64.zero < 0) then
+ let length = signed_length imm
+ in if length <= 10 then S10
+ else if length <= 32 then U27L5
+ else if length <= 37 then U27L10
+ else if length <= 64 then E27U27L10
+ else failwith @@ sprintf "encode_imm: integer too big! (%Ld)" imm
+ else
+ let length = unsigned_length imm
+ in if length <= 6 then U6
+ else if length <= 10 then S10
+ else if length <= 32 then U27L5
+ else if length <= 37 then U27L10
+ else if length <= 64 then E27U27L10
+ else failwith @@ sprintf "encode_imm: integer too big! (%Ld)" imm
(** Resources *)
let resource_names = ["ISSUE"; "TINY"; "LITE"; "ALU"; "LSU"; "MAU"; "BCU"; "ACC"; "DATA"; "TCA"; "BRE"; "BRO"; "NOP"]