Răsfoiți Sursa

* introduced the tai_globaltype asm directive, use that to declare the stack
pointer global symbol

Nikolay Nikolov 3 ani în urmă
părinte
comite
8226233aa3

+ 11 - 1
compiler/aasmtai.pas

@@ -94,6 +94,7 @@ interface
 {$ifdef wasm}
           ait_export_name,
           ait_local,
+          ait_globaltype,
           ait_functype,
           ait_tagtype,
           ait_import_module,
@@ -244,6 +245,7 @@ interface
 {$ifdef wasm}
           'export_name',
           'local',
+          'globaltype',
           'functype',
           'tagtype',
           'import_module',
@@ -363,7 +365,13 @@ interface
                      ait_llvmmetadatarefoperand,
 {$endif llvm}
 {$ifdef wasm}
-                     ait_export_name,ait_local,ait_functype,ait_tagtype,ait_import_module,ait_import_name,
+                     ait_export_name,
+                     ait_local,
+                     ait_globaltype,
+                     ait_functype,
+                     ait_tagtype,
+                     ait_import_module,
+                     ait_import_name,
 {$endif wasm}
                      ait_seh_directive,
                      ait_cfi,
@@ -3630,9 +3638,11 @@ implementation
 {$endif JVM}
 
 begin
+{$ifndef WASM}
 {$push}{$warnings off}
   { taitype should fit into a 4 byte set for speed reasons }
   if ord(high(taitype))>31 then
     internalerror(201108181);
 {$pop}
+{$endif WASM}
 end.

+ 7 - 0
compiler/aggas.pas

@@ -1635,6 +1635,13 @@ implementation
                if tai_local(hp).last then
                  writer.AsmLn;
              end;
+           ait_globaltype:
+             begin
+               writer.AsmWrite(#9'.globaltype'#9);
+               writer.AsmWrite(tai_globaltype(hp).globalname);
+               writer.AsmWrite(', ');
+               writer.AsmWriteLn(gas_wasm_basic_type_str[tai_globaltype(hp).gtype]);
+             end;
            ait_functype:
              WriteFuncTypeDirective(tai_functype(hp));
            ait_export_name:

+ 18 - 0
compiler/wasm32/aasmcpu.pas

@@ -104,6 +104,14 @@ uses
         constructor create(abasictype: TWasmBasicType; const aname: string = '');
       end;
 
+      { tai_globaltype }
+
+      tai_globaltype = class(tai)
+        globalname: string;
+        gtype: TWasmBasicType;
+        constructor create(const aglobalname:string; atype: TWasmBasicType);
+      end;
+
       { tai_functype }
 
       tai_functype = class(tai)
@@ -148,6 +156,16 @@ implementation
 uses
   ogwasm;
 
+    { tai_globaltype }
+
+    constructor tai_globaltype.create(const aglobalname: string; atype: TWasmBasicType);
+      begin
+        inherited Create;
+        typ:=ait_globaltype;
+        globalname:=aglobalname;
+        gtype:=atype;
+      end;
+
     { tai_import_name }
 
     constructor tai_import_name.create(const asymname, aimportname: string);

+ 0 - 8
compiler/wasm32/agllvmmc.pas

@@ -43,7 +43,6 @@ interface
       function sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;override;
     public
       constructor CreateWithWriter(info: pasminfo; wr: TExternalAssemblerOutputFile; freewriter, smart: boolean); override;
-      procedure WriteAsmList;override;
     end;
 
     { TWASM32InstrWriter }
@@ -80,13 +79,6 @@ implementation
     end;
 
 
-  procedure TLLVMMachineCodePlaygroundAssembler.WriteAsmList;
-    begin
-      writer.AsmWriteLn(#9'.globaltype'#9+STACK_POINTER_SYM+', i32');
-      inherited;
-    end;
-
-
   { TWASM32InstrWriter }
 
 

+ 2 - 0
compiler/wasm32/nwasmutil.pas

@@ -69,6 +69,8 @@ implementation
 
       list:=current_asmdata.asmlists[al_start];
 
+      list.Concat(tai_globaltype.create(STACK_POINTER_SYM,wbt_i32));
+
       if ts_wasm_native_exceptions in current_settings.targetswitches then
         list.Concat(tai_tagtype.create('__FPC_exception', []));