From ee0ad3ff86723cc14eac57aa8f5f625976b557fb Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Sun, 1 Jan 2023 12:06:31 +0100 Subject: [PATCH] thlcgobj.g_undefined_ok: new method Specify that a register's contents may be undefined because of previous operations (e.g. shifting by more bits than the register has, whose result depends on the target architecture), but that the code generator will later on ensure that if this is the case, that result will be overwritten/ masked. --- compiler/hlcgobj.pas | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/compiler/hlcgobj.pas b/compiler/hlcgobj.pas index 750a194da0..eb1d9ea66c 100644 --- a/compiler/hlcgobj.pas +++ b/compiler/hlcgobj.pas @@ -574,8 +574,16 @@ unit hlcgobj; { update a reference pointing to the start address of a record/object/ class (contents) so it refers to the indicated field } procedure g_set_addr_nonbitpacked_field_ref(list: TAsmList; recdef: tabstractrecorddef; field: tfieldvarsym; var recref: treference); virtual; - { load a register/constant into a record field by name } + + { tell the code generator that while this register's contents may be + undefined, it will be masked/cleaned up afterwards before its + contents are used if that is the case. + + Needed for LLVM in case of e.g. a potential shift of more bits + than the width of the register } + procedure g_undefined_ok(list: TAsmList; size: tdef; reg: tregister); virtual; protected + { load a register/constant into a record field by name } procedure g_setup_load_field_by_name(list: TAsmList; recdef: trecorddef; const name: TIDString; const recref: treference; out fref: treference; out fielddef: tdef); public procedure g_load_reg_field_by_name(list: TAsmList; regsize: tdef; recdef: trecorddef; reg: tregister; const name: TIDString; const recref: treference); @@ -4130,6 +4138,12 @@ implementation end; + procedure thlcgobj.g_undefined_ok(list: TAsmList; size: tdef; reg: tregister); + begin + { nothing by default } + end; + + procedure thlcgobj.g_setup_load_field_by_name(list: TAsmList; recdef: trecorddef; const name: TIDString; const recref: treference; out fref: treference; out fielddef: tdef); var sym: tsym;