mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-10 16:45:56 +02:00
+ started working on the WebAssembly internal assembler
This commit is contained in:
parent
f10fae66df
commit
cc314e61a2
130
compiler/ogwasm.pas
Normal file
130
compiler/ogwasm.pas
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
{
|
||||||
|
Copyright (c) 2021 by Nikolay Nikolov
|
||||||
|
|
||||||
|
Contains the WebAssembly binary module format reader and writer
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
|
||||||
|
****************************************************************************
|
||||||
|
}
|
||||||
|
unit ogwasm;
|
||||||
|
|
||||||
|
{$i fpcdefs.inc}
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
{ common }
|
||||||
|
globtype,
|
||||||
|
{ target }
|
||||||
|
systems,
|
||||||
|
{ assembler }
|
||||||
|
aasmbase,assemble,
|
||||||
|
{ output }
|
||||||
|
ogbase,
|
||||||
|
owbase;
|
||||||
|
|
||||||
|
type
|
||||||
|
|
||||||
|
{ TWasmObjData }
|
||||||
|
|
||||||
|
TWasmObjData = class(TObjData)
|
||||||
|
public
|
||||||
|
function sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;override;
|
||||||
|
procedure writeReloc(Data:TRelocDataInt;len:aword;p:TObjSymbol;Reloctype:TObjRelocationType);override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TWasmObjOutput }
|
||||||
|
|
||||||
|
TWasmObjOutput = class(tObjOutput)
|
||||||
|
protected
|
||||||
|
function writeData(Data:TObjData):boolean;override;
|
||||||
|
public
|
||||||
|
constructor create(AWriter:TObjectWriter);override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TWasmAssembler }
|
||||||
|
|
||||||
|
TWasmAssembler = class(tinternalassembler)
|
||||||
|
constructor create(info: pasminfo; smart:boolean);override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
{****************************************************************************
|
||||||
|
TWasmObjData
|
||||||
|
****************************************************************************}
|
||||||
|
|
||||||
|
function TWasmObjData.sectionname(atype: TAsmSectiontype;
|
||||||
|
const aname: string; aorder: TAsmSectionOrder): string;
|
||||||
|
begin
|
||||||
|
result:='todosectionname';
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TWasmObjData.writeReloc(Data: TRelocDataInt; len: aword;
|
||||||
|
p: TObjSymbol; Reloctype: TObjRelocationType);
|
||||||
|
begin
|
||||||
|
end;
|
||||||
|
|
||||||
|
{****************************************************************************
|
||||||
|
TWasmObjOutput
|
||||||
|
****************************************************************************}
|
||||||
|
|
||||||
|
function TWasmObjOutput.writeData(Data:TObjData):boolean;
|
||||||
|
begin
|
||||||
|
result:=false;
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TWasmObjOutput.create(AWriter: TObjectWriter);
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
cobjdata:=TWasmObjData;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{****************************************************************************
|
||||||
|
TWasmAssembler
|
||||||
|
****************************************************************************}
|
||||||
|
|
||||||
|
constructor TWasmAssembler.Create(info: pasminfo; smart:boolean);
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
CObjOutput:=TWasmObjOutput;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{*****************************************************************************
|
||||||
|
Initialize
|
||||||
|
*****************************************************************************}
|
||||||
|
{$ifdef wasm32}
|
||||||
|
const
|
||||||
|
as_wasm32_wasm_info : tasminfo =
|
||||||
|
(
|
||||||
|
id : as_wasm32_wasm;
|
||||||
|
idtxt : 'OMF';
|
||||||
|
asmbin : '';
|
||||||
|
asmcmd : '';
|
||||||
|
supported_targets : [system_wasm32_embedded,system_wasm32_wasi];
|
||||||
|
flags : [af_outputbinary,af_smartlink_sections];
|
||||||
|
labelprefix : '..@';
|
||||||
|
labelmaxlen : -1;
|
||||||
|
comment : '; ';
|
||||||
|
dollarsign: '$';
|
||||||
|
);
|
||||||
|
{$endif wasm32}
|
||||||
|
|
||||||
|
initialization
|
||||||
|
{$ifdef wasm32}
|
||||||
|
RegisterAssembler(as_wasm32_wasm_info,TWasmAssembler);
|
||||||
|
{$endif wasm32}
|
||||||
|
end.
|
@ -268,6 +268,7 @@
|
|||||||
,as_wasm32_wabt
|
,as_wasm32_wabt
|
||||||
,as_wasm32_llvm_mc { WebAssembly code assembled by llvm-mc (llvm machine code playground) }
|
,as_wasm32_llvm_mc { WebAssembly code assembled by llvm-mc (llvm machine code playground) }
|
||||||
,as_arm_vasm
|
,as_arm_vasm
|
||||||
|
,as_wasm32_wasm
|
||||||
);
|
);
|
||||||
|
|
||||||
tlink = (ld_none,
|
tlink = (ld_none,
|
||||||
|
@ -821,7 +821,11 @@ unit i_embed;
|
|||||||
Cprefix : '';
|
Cprefix : '';
|
||||||
newline : #10;
|
newline : #10;
|
||||||
dirsep : '/';
|
dirsep : '/';
|
||||||
|
{$ifdef WASM32_INTERNALASM}
|
||||||
|
assem : as_wasm32_wasm;
|
||||||
|
{$else WASM32_INTERNALASM}
|
||||||
assem : as_wasm32_llvm_mc;
|
assem : as_wasm32_llvm_mc;
|
||||||
|
{$endif WASM32_INTERNALASM}
|
||||||
assemextern : as_wasm32_llvm_mc;
|
assemextern : as_wasm32_llvm_mc;
|
||||||
link : ld_none;
|
link : ld_none;
|
||||||
linkextern : ld_embedded;
|
linkextern : ld_embedded;
|
||||||
|
@ -77,7 +77,11 @@ unit i_wasi;
|
|||||||
Cprefix : '';
|
Cprefix : '';
|
||||||
newline : #10;
|
newline : #10;
|
||||||
dirsep : '/';
|
dirsep : '/';
|
||||||
|
{$ifdef WASM32_INTERNALASM}
|
||||||
|
assem : as_wasm32_wasm;
|
||||||
|
{$else WASM32_INTERNALASM}
|
||||||
assem : as_wasm32_llvm_mc;
|
assem : as_wasm32_llvm_mc;
|
||||||
|
{$endif WASM32_INTERNALASM}
|
||||||
assemextern : as_wasm32_llvm_mc;
|
assemextern : as_wasm32_llvm_mc;
|
||||||
link : ld_none;
|
link : ld_none;
|
||||||
linkextern : ld_wasi; // there's no linker, only object files for WASM
|
linkextern : ld_wasi; // there's no linker, only object files for WASM
|
||||||
|
@ -48,6 +48,7 @@ implementation
|
|||||||
,agwat
|
,agwat
|
||||||
,agbinaryen
|
,agbinaryen
|
||||||
,agllvmmc
|
,agllvmmc
|
||||||
|
,ogwasm
|
||||||
|
|
||||||
{**************************************
|
{**************************************
|
||||||
Assembler Readers
|
Assembler Readers
|
||||||
|
Loading…
Reference in New Issue
Block a user