Преглед на файлове

+ introduced tai_import_module and tai_import_name that represent the
.import_module and .import_name assembler directives

Nikolay Nikolov преди 3 години
родител
ревизия
a6e75d52f7
променени са 4 файла, в които са добавени 57 реда и са изтрити 9 реда
  1. 5 1
      compiler/aasmtai.pas
  2. 14 0
      compiler/aggas.pas
  3. 36 0
      compiler/wasm32/aasmcpu.pas
  4. 2 8
      compiler/wasm32/agllvmmc.pas

+ 5 - 1
compiler/aasmtai.pas

@@ -96,6 +96,8 @@ interface
           ait_local,
           ait_functype,
           ait_tagtype,
+          ait_import_module,
+          ait_import_name,
 {$endif}
           { SEH directives used in ARM,MIPS and x86_64 COFF targets }
           ait_seh_directive,
@@ -244,6 +246,8 @@ interface
           'local',
           'functype',
           'tagtype',
+          'import_module',
+          'import_name',
 {$endif}
           'cfi',
           'seh_directive',
@@ -359,7 +363,7 @@ interface
                      ait_llvmmetadatarefoperand,
 {$endif llvm}
 {$ifdef wasm}
-                     ait_importexport,ait_local,ait_functype,ait_tagtype,
+                     ait_importexport,ait_local,ait_functype,ait_tagtype,ait_import_module,ait_import_name,
 {$endif wasm}
                      ait_seh_directive,
                      ait_cfi,

+ 14 - 0
compiler/aggas.pas

@@ -1650,6 +1650,20 @@ implementation
              WriteImportExport(tai_impexp(hp));
            ait_tagtype:
              WriteTagType(tai_tagtype(hp));
+           ait_import_module:
+             begin
+               writer.AsmWrite(#9'.import_module'#9);
+               writer.AsmWrite(tai_import_module(hp).symname);
+               writer.AsmWrite(', ');
+               writer.AsmWriteLn(tai_import_module(hp).importmodule);
+             end;
+           ait_import_name:
+             begin
+               writer.AsmWrite(#9'.import_name'#9);
+               writer.AsmWrite(tai_import_name(hp).symname);
+               writer.AsmWrite(', ');
+               writer.AsmWriteLn(tai_import_name(hp).importname);
+             end;
 {$endif WASM}
 
            else

+ 36 - 0
compiler/wasm32/aasmcpu.pas

@@ -125,6 +125,22 @@ uses
         constructor create(const atagname: string; aparams: TWasmResultType);
       end;
 
+      { tai_import_module }
+
+      tai_import_module = class(tai)
+        symname: string;
+        importmodule: string;
+        constructor create(const asymname, aimportmodule: string);
+      end;
+
+      { tai_import_name }
+
+      tai_import_name = class(tai)
+        symname: string;
+        importname: string;
+        constructor create(const asymname, aimportname: string);
+      end;
+
     procedure InitAsm;
     procedure DoneAsm;
 
@@ -133,6 +149,26 @@ uses
 
 implementation
 
+    { tai_import_name }
+
+    constructor tai_import_name.create(const asymname, aimportname: string);
+      begin
+        inherited Create;
+        typ:=ait_import_name;
+        symname:=asymname;
+        importname:=aimportname;
+      end;
+
+    { tai_import_module }
+
+    constructor tai_import_module.create(const asymname, aimportmodule: string);
+      begin
+        inherited Create;
+        typ:=ait_import_module;
+        symname:=asymname;
+        importmodule:=aimportmodule;
+      end;
+
     { tai_functype }
 
     constructor tai_functype.create(const afuncname: string; afunctype: TWasmFuncType);

+ 2 - 8
compiler/wasm32/agllvmmc.pas

@@ -75,16 +75,10 @@ implementation
         begin
           list:=TAsmList.Create;
           thlcgwasm(hlcg).g_procdef(list,proc);
+          list.Concat(tai_import_module.create(proc.mangledname,proc.import_dll^));
+          list.Concat(tai_import_name.create(proc.mangledname,proc.import_name^));
           WriteTree(list);
           list.free;
-          writer.AsmWrite(#9'.import_module'#9);
-          writer.AsmWrite(proc.mangledname);
-          writer.AsmWrite(', ');
-          writer.AsmWriteLn(proc.import_dll^);
-          writer.AsmWrite(#9'.import_name'#9);
-          writer.AsmWrite(proc.mangledname);
-          writer.AsmWrite(', ');
-          writer.AsmWriteLn(proc.import_name^);
         end;
 
     var