Просмотр исходного кода

* leb128 gets always a 64bit int
* fixed sleb128 encode

git-svn-id: trunk@3060 -

peter 19 лет назад
Родитель
Сommit
dfd84c6fd3
3 измененных файлов с 19 добавлено и 18 удалено
  1. 11 10
      compiler/aasmbase.pas
  2. 6 6
      compiler/aggas.pas
  3. 2 2
      compiler/dbgdwarf.pas

+ 11 - 10
compiler/aasmbase.pas

@@ -107,10 +107,10 @@ interface
     function  use_smartlink_section:boolean;
     function  maybe_smartlink_symbol:boolean;
 
-    function LengthUleb128(a: aword) : byte;
-    function LengthSleb128(a: aint) : byte;
-    function EncodeUleb128(a: aword;out buf) : byte;
-    function EncodeSleb128(a: aint;out buf) : byte;
+    function LengthUleb128(a: qword) : byte;
+    function LengthSleb128(a: int64) : byte;
+    function EncodeUleb128(a: qword;out buf) : byte;
+    function EncodeSleb128(a: int64;out buf) : byte;
 
 
 implementation
@@ -134,7 +134,7 @@ implementation
       end;
 
 
-    function LengthUleb128(a: aword) : byte;
+    function LengthUleb128(a: qword) : byte;
       begin
         result:=0;
         repeat
@@ -146,10 +146,10 @@ implementation
       end;
 
 
-    function LengthSleb128(a: aint) : byte;
+    function LengthSleb128(a: int64) : byte;
       var
         b, size: byte;
-        asign : aint;
+        asign : int64;
         neg, more: boolean;
       begin
         more := true;
@@ -178,7 +178,7 @@ implementation
       end;
 
 
-    function EncodeUleb128(a: aword;out buf) : byte;
+    function EncodeUleb128(a: qword;out buf) : byte;
       var
         b: byte;
         pbuf : pbyte;
@@ -199,10 +199,10 @@ implementation
       end;
 
 
-    function EncodeSleb128(a: aint;out buf) : byte;
+    function EncodeSleb128(a: int64;out buf) : byte;
       var
         b, size: byte;
-        asign : aint;
+        asign : int64;
         neg, more: boolean;
         pbuf : pbyte;
       begin
@@ -229,6 +229,7 @@ implementation
           else
             b := b or $80;
           pbuf^:=b;
+          inc(pbuf);
           inc(result);
           if not(more) then
             break;

+ 6 - 6
compiler/aggas.pas

@@ -57,8 +57,8 @@ interface
         destructor destroy; override;
        private
         setcount: longint;
-        procedure WriteDecodedSleb128(a: aint);
-        procedure WriteDecodedUleb128(a: aword);
+        procedure WriteDecodedSleb128(a: int64);
+        procedure WriteDecodedUleb128(a: qword);
         function NextSetLabel: string;
        protected
         InstrWriter: TCPUInstrWriter;
@@ -326,7 +326,7 @@ implementation
       end;
 
 
-    procedure TGNUAssembler.WriteDecodedUleb128(a: aword);
+    procedure TGNUAssembler.WriteDecodedUleb128(a: qword);
       var
         i,len : longint;
         buf   : array[0..63] of byte;
@@ -341,7 +341,7 @@ implementation
       end;
 
 
-    procedure TGNUAssembler.WriteDecodedSleb128(a: aint);
+    procedure TGNUAssembler.WriteDecodedSleb128(a: int64);
       var
         i,len : longint;
         buf   : array[0..255] of byte;
@@ -631,9 +631,9 @@ implementation
                          AsmWrite(ait_const2str[aitconst_8bit]);
                          case tai_const(hp).consttype of
                            aitconst_uleb128bit:
-                             WriteDecodedUleb128(aword(tai_const(hp).value));
+                             WriteDecodedUleb128(qword(tai_const(hp).value));
                            aitconst_sleb128bit:
-                             WriteDecodedSleb128(aint(tai_const(hp).value));
+                             WriteDecodedSleb128(int64(tai_const(hp).value));
                          end
                        end
                      else

+ 2 - 2
compiler/dbgdwarf.pas

@@ -930,8 +930,8 @@ implementation
               finish_entry;
               { to simplify things, we don't write a multidimensional array here }
               append_entry(DW_TAG_subrange_type,false,[
-                DW_AT_lower_bound,DW_FORM_udata,def.lowrange,
-                DW_AT_upper_bound,DW_FORM_udata,def.highrange
+                DW_AT_lower_bound,DW_FORM_sdata,def.lowrange,
+                DW_AT_upper_bound,DW_FORM_sdata,def.highrange
                 ]);
               append_labelentry_ref(DW_AT_type,def_dwarf_lab(def.rangetype.def));
               finish_entry;