diff --git a/compiler/aasmtai.pas b/compiler/aasmtai.pas index 1a9b12daff..6ce4a5426d 100644 --- a/compiler/aasmtai.pas +++ b/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. diff --git a/compiler/aggas.pas b/compiler/aggas.pas index c24c4a486f..b6ce3d28ad 100644 --- a/compiler/aggas.pas +++ b/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: diff --git a/compiler/wasm32/aasmcpu.pas b/compiler/wasm32/aasmcpu.pas index fe63676287..0d43d1220c 100644 --- a/compiler/wasm32/aasmcpu.pas +++ b/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); diff --git a/compiler/wasm32/agllvmmc.pas b/compiler/wasm32/agllvmmc.pas index 0b44e832b6..80935e4c9d 100644 --- a/compiler/wasm32/agllvmmc.pas +++ b/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 } diff --git a/compiler/wasm32/nwasmutil.pas b/compiler/wasm32/nwasmutil.pas index d74c5b424b..8372671c54 100644 --- a/compiler/wasm32/nwasmutil.pas +++ b/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', []));