44 ------------------------------------------------------------------------------
55 The MIT License (MIT)
66
7- Copyright (c) 2021-2024 Aarno Labs, LLC
7+ Copyright (c) 2021-2025 Aarno Labs, LLC
88
99 Permission is hereby granted, free of charge, to any person obtaining a copy
1010 of this software and associated documentation files (the "Software"), to deal
@@ -475,12 +475,31 @@ object (self:'a)
475475 floc#get_memory_variable_numoffset ~size ~align rvar memoff)
476476 numoffset_r
477477
478+ | ARMIndexOffset (ri , i ) ->
479+ let rvar = env#mk_arm_register_variable r in
480+ let ivar = env#mk_arm_register_variable ri in
481+ if isadd then
482+ let rx = floc#inv#rewrite_expr (XVar rvar) in
483+ let ivax = floc#inv#rewrite_expr (XVar ivar) in
484+ let xoffset = simplify_xpr (XOp (XPlus , [rx; ivax])) in
485+ (match (xoffset, i) with
486+ | (XConst (IntConst n ), 0 ) ->
487+ floc#env#mk_global_variable ~size n
488+ | _ ->
489+ floc#get_memory_variable_varoffset
490+ ~size rvar ivar (mkNumerical i))
491+ else
492+ Error [__FILE__ ^ " :" ^ (string_of_int __LINE__) ^ " : "
493+ ^ " Index offset with is_add false not yet supported: "
494+ ^ (p2s self#toPretty)]
495+
478496 | ARMShiftedIndexOffset _ ->
479497 let rvar = env#mk_arm_register_variable r in
480498 (match (offset, isadd) with
481499 | (ARMShiftedIndexOffset (ivar , srt , i ), true ) ->
482500 let optscale =
483501 match srt with
502+ | ARMImmSRT (SRType LSL, 3 ) -> Some 8
484503 | ARMImmSRT (SRType_LSL, 2 ) -> Some 4
485504 | ARMImmSRT (SRType_LSL, 0 ) -> Some 1
486505 | _ -> None in
@@ -491,8 +510,8 @@ object (self:'a)
491510 let rx = floc#inv#rewrite_expr (XVar rvar) in
492511 let ivax = floc#inv#rewrite_expr (XVar ivar) in
493512 let xoffset = simplify_xpr (XOp (XPlus , [rx; ivax])) in
494- (match xoffset with
495- | XConst (IntConst n ) ->
513+ (match ( xoffset, i) with
514+ | ( XConst (IntConst n ), 0 ) ->
496515 floc#env#mk_global_variable ~size n
497516 | _ ->
498517 floc#get_memory_variable_varoffset
@@ -509,12 +528,7 @@ object (self:'a)
509528 Error [__FILE__ ^ " :" ^ (string_of_int __LINE__) ^ " : "
510529 ^ " Shifted Index Offset with isadd: false: "
511530 ^ (p2s self#toPretty)
512- ^ " not yet supported" ])
513-
514- | _ ->
515- Error [__FILE__ ^ " :" ^ (string_of_int __LINE__) ^ " : "
516- ^ " Index Offset address: " ^ (p2s self#toPretty)
517- ^ " not yet supported" ])
531+ ^ " not yet supported" ]))
518532
519533 | ARMShiftedReg (r , ARMImmSRT (SRType_LSL, 0 )) ->
520534 Ok (env#mk_arm_register_variable r)
0 commit comments