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.
This commit is contained in:
Jonas Maebe 2023-01-01 12:06:31 +01:00
parent 0b6942de8a
commit ee0ad3ff86

View File

@ -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;