瀏覽代碼

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.
Jonas Maebe 2 年之前
父節點
當前提交
ee0ad3ff86
共有 1 個文件被更改,包括 15 次插入1 次删除
  1. 15 1
      compiler/hlcgobj.pas

+ 15 - 1
compiler/hlcgobj.pas

@@ -574,8 +574,16 @@ unit hlcgobj;
           { update a reference pointing to the start address of a record/object/
           { update a reference pointing to the start address of a record/object/
             class (contents) so it refers to the indicated field }
             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;
           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
          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);
           procedure g_setup_load_field_by_name(list: TAsmList; recdef: trecorddef; const name: TIDString; const recref: treference; out fref: treference; out fielddef: tdef);
          public
          public
           procedure g_load_reg_field_by_name(list: TAsmList; regsize: tdef; recdef: trecorddef; reg: tregister; const name: TIDString; const recref: treference);
           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;
     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);
   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
     var
       sym: tsym;
       sym: tsym;