...

Source file src/cmd/internal/obj/wasm/a.out.go

Documentation: cmd/internal/obj/wasm

     1  // Copyright 2018 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package wasm
     6  
     7  import "cmd/internal/obj"
     8  
     9  //go:generate go run ../stringer.go -i $GOFILE -o anames.go -p wasm
    10  
    11  const (
    12  	/* mark flags */
    13  	DONE          = 1 << iota
    14  	PRESERVEFLAGS // not allowed to clobber flags
    15  )
    16  
    17  /*
    18   *	wasm
    19   */
    20  const (
    21  	AGet = obj.ABaseWasm + obj.A_ARCHSPECIFIC + iota
    22  	ASet
    23  	ATee
    24  	ANot // alias for I32Eqz
    25  
    26  	// The following are low-level WebAssembly instructions.
    27  	// Their order matters, since it matches the opcode encoding.
    28  	// Gaps in the encoding are indicated by comments.
    29  
    30  	AUnreachable // opcode 0x00
    31  	ANop
    32  	ABlock
    33  	ALoop
    34  	AIf
    35  	AElse
    36  
    37  	AEnd // opcode 0x0B
    38  	ABr
    39  	ABrIf
    40  	ABrTable
    41  	// ACall and AReturn are WebAssembly instructions. obj.ACALL and obj.ARET are higher level instructions
    42  	// with Go semantics, e.g. they manipulate the Go stack on the linear memory.
    43  	AReturn
    44  	ACall
    45  	ACallIndirect
    46  
    47  	ADrop // opcode 0x1A
    48  	ASelect
    49  
    50  	ALocalGet // opcode 0x20
    51  	ALocalSet
    52  	ALocalTee
    53  	AGlobalGet
    54  	AGlobalSet
    55  
    56  	AI32Load // opcode 0x28
    57  	AI64Load
    58  	AF32Load
    59  	AF64Load
    60  	AI32Load8S
    61  	AI32Load8U
    62  	AI32Load16S
    63  	AI32Load16U
    64  	AI64Load8S
    65  	AI64Load8U
    66  	AI64Load16S
    67  	AI64Load16U
    68  	AI64Load32S
    69  	AI64Load32U
    70  	AI32Store
    71  	AI64Store
    72  	AF32Store
    73  	AF64Store
    74  	AI32Store8
    75  	AI32Store16
    76  	AI64Store8
    77  	AI64Store16
    78  	AI64Store32
    79  	ACurrentMemory
    80  	AGrowMemory
    81  
    82  	AI32Const
    83  	AI64Const
    84  	AF32Const
    85  	AF64Const
    86  
    87  	AI32Eqz
    88  	AI32Eq
    89  	AI32Ne
    90  	AI32LtS
    91  	AI32LtU
    92  	AI32GtS
    93  	AI32GtU
    94  	AI32LeS
    95  	AI32LeU
    96  	AI32GeS
    97  	AI32GeU
    98  
    99  	AI64Eqz
   100  	AI64Eq
   101  	AI64Ne
   102  	AI64LtS
   103  	AI64LtU
   104  	AI64GtS
   105  	AI64GtU
   106  	AI64LeS
   107  	AI64LeU
   108  	AI64GeS
   109  	AI64GeU
   110  
   111  	AF32Eq
   112  	AF32Ne
   113  	AF32Lt
   114  	AF32Gt
   115  	AF32Le
   116  	AF32Ge
   117  
   118  	AF64Eq
   119  	AF64Ne
   120  	AF64Lt
   121  	AF64Gt
   122  	AF64Le
   123  	AF64Ge
   124  
   125  	AI32Clz
   126  	AI32Ctz
   127  	AI32Popcnt
   128  	AI32Add
   129  	AI32Sub
   130  	AI32Mul
   131  	AI32DivS
   132  	AI32DivU
   133  	AI32RemS
   134  	AI32RemU
   135  	AI32And
   136  	AI32Or
   137  	AI32Xor
   138  	AI32Shl
   139  	AI32ShrS
   140  	AI32ShrU
   141  	AI32Rotl
   142  	AI32Rotr
   143  
   144  	AI64Clz
   145  	AI64Ctz
   146  	AI64Popcnt
   147  	AI64Add
   148  	AI64Sub
   149  	AI64Mul
   150  	AI64DivS
   151  	AI64DivU
   152  	AI64RemS
   153  	AI64RemU
   154  	AI64And
   155  	AI64Or
   156  	AI64Xor
   157  	AI64Shl
   158  	AI64ShrS
   159  	AI64ShrU
   160  	AI64Rotl
   161  	AI64Rotr
   162  
   163  	AF32Abs
   164  	AF32Neg
   165  	AF32Ceil
   166  	AF32Floor
   167  	AF32Trunc
   168  	AF32Nearest
   169  	AF32Sqrt
   170  	AF32Add
   171  	AF32Sub
   172  	AF32Mul
   173  	AF32Div
   174  	AF32Min
   175  	AF32Max
   176  	AF32Copysign
   177  
   178  	AF64Abs
   179  	AF64Neg
   180  	AF64Ceil
   181  	AF64Floor
   182  	AF64Trunc
   183  	AF64Nearest
   184  	AF64Sqrt
   185  	AF64Add
   186  	AF64Sub
   187  	AF64Mul
   188  	AF64Div
   189  	AF64Min
   190  	AF64Max
   191  	AF64Copysign
   192  
   193  	AI32WrapI64
   194  	AI32TruncF32S
   195  	AI32TruncF32U
   196  	AI32TruncF64S
   197  	AI32TruncF64U
   198  	AI64ExtendI32S
   199  	AI64ExtendI32U
   200  	AI64TruncF32S
   201  	AI64TruncF32U
   202  	AI64TruncF64S
   203  	AI64TruncF64U
   204  	AF32ConvertI32S
   205  	AF32ConvertI32U
   206  	AF32ConvertI64S
   207  	AF32ConvertI64U
   208  	AF32DemoteF64
   209  	AF64ConvertI32S
   210  	AF64ConvertI32U
   211  	AF64ConvertI64S
   212  	AF64ConvertI64U
   213  	AF64PromoteF32
   214  	AI32ReinterpretF32
   215  	AI64ReinterpretF64
   216  	AF32ReinterpretI32
   217  	AF64ReinterpretI64
   218  	AI32Extend8S
   219  	AI32Extend16S
   220  	AI64Extend8S
   221  	AI64Extend16S
   222  	AI64Extend32S
   223  
   224  	AI32TruncSatF32S // opcode 0xFC 0x00
   225  	AI32TruncSatF32U
   226  	AI32TruncSatF64S
   227  	AI32TruncSatF64U
   228  	AI64TruncSatF32S
   229  	AI64TruncSatF32U
   230  	AI64TruncSatF64S
   231  	AI64TruncSatF64U
   232  
   233  	AMemoryInit
   234  	ADataDrop
   235  	AMemoryCopy
   236  	AMemoryFill
   237  	ATableInit
   238  	AElemDrop
   239  	ATableCopy
   240  	ATableGrow
   241  	ATableSize
   242  	ATableFill
   243  
   244  	// WASM Vector instructions 0xFD 0x00 and following
   245  	AV128Load
   246  	AV128Load8x8S
   247  	AV128Load8x8U
   248  	AV128Load16x4S
   249  	AV128Load16x4U
   250  	AV128Load32x2S
   251  	AV128Load32x2U
   252  	AV128Load8Splat
   253  	AV128Load16Splat
   254  	AV128Load32Splat
   255  	AV128Load64Splat
   256  	AV128Store
   257  	AV128Const
   258  	AI8x16Shuffle16
   259  	AI8x16Swizzle
   260  	AI8x16Splat
   261  	AI16x8Splat
   262  	AI32x4Splat
   263  	AI64x2Splat
   264  	AF32x4Splat
   265  	AF64x2Splat
   266  	AI8x16ExtractLaneS
   267  	AI8x16ExtractLaneU
   268  	AI8x16ReplaceLane
   269  	AI16x8ExtractLaneS
   270  	AI16x8ExtractLaneU
   271  	AI16x8ReplaceLane
   272  	AI32x4ExtractLane
   273  	AI32x4ReplaceLane
   274  	AI64x2ExtractLane
   275  	AI64x2ReplaceLane
   276  	AF32x4ExtractLane
   277  	AF32x4ReplaceLane
   278  	AF64x2ExtractLane
   279  	AF64x2ReplaceLane
   280  	AI8x16Eq
   281  	AI8x16Ne
   282  	AI8x16LtS
   283  	AI8x16LtU
   284  	AI8x16GtS
   285  	AI8x16GtU
   286  	AI8x16LeS
   287  	AI8x16LeU
   288  	AI8x16GeS
   289  	AI8x16GeU
   290  	AI16x8Eq
   291  	AI16x8Ne
   292  	AI16x8LtS
   293  	AI16x8LtU
   294  	AI16x8GtS
   295  	AI16x8GtU
   296  	AI16x8LeS
   297  	AI16x8LeU
   298  	AI16x8GeS
   299  	AI16x8GeU
   300  	AI32x4Eq
   301  	AI32x4Ne
   302  	AI32x4LtS
   303  	AI32x4LtU
   304  	AI32x4GtS
   305  	AI32x4GtU
   306  	AI32x4LeS
   307  	AI32x4LeU
   308  	AI32x4GeS
   309  	AI32x4GeU
   310  	AF32x4Eq
   311  	AF32x4Ne
   312  	AF32x4Lt
   313  	AF32x4Gt
   314  	AF32x4Le
   315  	AF32x4Ge
   316  	AF64x2Eq
   317  	AF64x2Ne
   318  	AF64x2Lt
   319  	AF64x2Gt
   320  	AF64x2Le
   321  	AF64x2Ge
   322  	AV128Not
   323  	AV128And
   324  	AV128Andnot
   325  	AV128Or
   326  	AV128Xor
   327  	AV128Bitselect
   328  	AV128AnyTrue
   329  	AV128Load8Lane
   330  	AV128Load16Lane
   331  	AV128Load32Lane
   332  	AV128Load64Lane
   333  	AV128Store8Lane
   334  	AV128Store16Lane
   335  	AV128Store32Lane
   336  	AV128Store64Lane
   337  	AV128Load32Zero
   338  	AV128Load64Zero
   339  	AF32x4DemoteF64x2Zero
   340  	AF64x2PromoteLowF32x4
   341  	AI8x16Abs
   342  	AI8x16Neg
   343  	AI8x16Popcnt
   344  	AI8x16AllTrue
   345  	AI8x16Bitmask
   346  	AI8x16NarrowI16x8S
   347  	AI8x16NarrowI16x8U
   348  	AF32x4Ceil
   349  	AF32x4Floor
   350  	AF32x4Trunc
   351  	AF32x4Nearest
   352  	AI8x16Shl
   353  	AI8x16ShrS
   354  	AI8x16ShrU
   355  	AI8x16Add
   356  	AI8x16AddSatS
   357  	AI8x16AddSatU
   358  	AI8x16Sub
   359  	AI8x16SubSatS
   360  	AI8x16SubSatU
   361  	AF64x2Ceil
   362  	AF64x2Floor
   363  	AI8x16MinS
   364  	AI8x16MinU
   365  	AI8x16MaxS
   366  	AI8x16MaxU
   367  	AF64x2Trunc
   368  	AI8x16AvgrU
   369  	AI16x8ExtaddPairwiseI8x16S
   370  	AI16x8ExtaddPairwiseI8x16U
   371  	AI32x4ExtaddPairwiseI16x8S
   372  	AI32x4ExtaddPairwiseI16x8U
   373  
   374  	// WASM Vector instructions 0xFD 0x80 and following but followed by a 0x01
   375  	// e.g. 0xFD 0x80 0x01, 0xFD  0x81  0x01, etc.
   376  	AI16x8Abs
   377  	AI16x8Neg
   378  	AI16x8Q15MulrSatS
   379  	AI16x8AllTrue
   380  	AI16x8Bitmask
   381  	AI16x8NarrowI32x4S
   382  	AI16x8NarrowI32x4U
   383  	AI16x8ExtendLowI8x16S
   384  	AI16x8ExtendHighI8x16S
   385  	AI16x8ExtendLowI8x16U
   386  	AI16x8ExtendHighI8x16U
   387  	AI16x8Shl
   388  	AI16x8ShrS
   389  	AI16x8ShrU
   390  	AI16x8Add
   391  	AI16x8AddSatS
   392  	AI16x8AddSatU
   393  	AI16x8Sub
   394  	AI16x8SubSatS
   395  	AI16x8SubSatU
   396  	AF64x2Nearest
   397  	AI16x8Mul
   398  	AI16x8MinS
   399  	AI16x8MinU
   400  	AI16x8MaxS
   401  	AI16x8MaxU
   402  	AReservedFD9A01 // 0xFD 0x9A 0x01
   403  	AI16x8AvgrU
   404  	AI16x8ExtmulLowI8x16S
   405  	AI16x8ExtmulHighI8x16S
   406  	AI16x8ExtmulLowI8x16U
   407  	AI16x8ExtmulHighI8x16U
   408  	AI32x4Abs
   409  	AI32x4Neg
   410  	AReservedFDA201
   411  	AI32x4AllTrue
   412  	AI32x4Bitmask
   413  	AReservedFDA501
   414  	AReservedFDA601
   415  	AI32x4ExtendLowI16x8S
   416  	AI32x4ExtendHighI16x8S
   417  	AI32x4ExtendLowI16x8U
   418  	AI32x4ExtendHighI16x8U
   419  	AI32x4Shl
   420  	AI32x4ShrS
   421  	AI32x4ShrU
   422  	AI32x4Add
   423  	AReservedFDAF01
   424  	AReservedFDB001
   425  	AI32x4Sub
   426  	AReservedFDB201
   427  	AReservedFDB301
   428  	AReservedFDB401
   429  	AI32x4Mul
   430  	AI32x4MinS
   431  	AI32x4MinU
   432  	AI32x4MaxS
   433  	AI32x4MaxU
   434  	AI32x4DotI16x8S
   435  	AReservedFDBB01
   436  	AI32x4ExtmulLowI16x8S
   437  	AI32x4ExtmulHighI16x8S
   438  	AI32x4ExtmulLowI16x8U
   439  	AI32x4ExtmulHighI16x8U
   440  	AI64x2Abs
   441  	AI64x2Neg
   442  	AReservedFDC201
   443  	AI64x2AllTrue
   444  	AI64x2Bitmask
   445  	AReservedFDC501
   446  	AReservedFDC601
   447  	AI64x2ExtendLowI32x4S
   448  	AI64x2ExtendHighI32x4S
   449  	AI64x2ExtendLowI32x4U
   450  	AI64x2ExtendHighI32x4U
   451  	AI64x2Shl
   452  	AI64x2ShrS
   453  	AI64x2ShrU
   454  	AI64x2Add
   455  	AReservedFDCF01
   456  	AReservedFDD001
   457  	AI64x2Sub
   458  	AReservedFDD201
   459  	AReservedFDD301
   460  	AReservedFDD401
   461  	AI64x2Mul
   462  	AI64x2Eq
   463  	AI64x2Ne
   464  	AI64x2LtS
   465  	AI64x2GtS
   466  	AI64x2LeS
   467  	AI64x2GeS
   468  	AI64x2ExtmulLowI32x4S
   469  	AI64x2ExtmulHighI32x4S
   470  	AI64x2ExtmulLowI32x4U
   471  	AI64x2ExtmulHighI32x4U
   472  	AF32x4Abs
   473  	AF32x4Neg
   474  	AReservedFDE201
   475  	AF32x4Sqrt
   476  	AF32x4Add
   477  	AF32x4Sub
   478  	AF32x4Mul
   479  	AF32x4Div
   480  	AF32x4Min
   481  	AF32x4Max
   482  	AF32x4Pmin
   483  	AF32x4Pmax
   484  	AF64x2Abs
   485  	AF64x2Neg
   486  	AReservedFDEE01
   487  	AF64x2Sqrt
   488  	AF64x2Add
   489  	AF64x2Sub
   490  	AF64x2Mul
   491  	AF64x2Div
   492  	AF64x2Min
   493  	AF64x2Max
   494  	AF64x2Pmin
   495  	AF64x2Pmax
   496  	AI32x4TruncSatF32x4S
   497  	AI32x4TruncSatF32x4U
   498  	AF32x4ConvertI32x4S
   499  	AF32x4ConvertI32x4U
   500  	AI32x4TruncSatF64x2SZero
   501  	AI32x4TruncSatF64x2UZero
   502  	AF64x2ConvertLowI32x4S
   503  	AF64x2ConvertLowI32x4U
   504  
   505  	// WASM Vector instructions 0xFD 0x80 and following but followed by a 0x02
   506  	// e.g. 0xFD 0x80 0x02, 0xFD 0x81 0x02, etc.
   507  	AI8x16RelaxedSwizzle
   508  	AI32x4RelaxedTruncF32x4S
   509  	AI32x4RelaxedTruncF32x4U
   510  	AI32x4RelaxedTruncF64x2S
   511  	AI32x4RelaxedTruncF64x2U
   512  	AF32x4RelaxedMadd
   513  	AF32x4RelaxedNmadd
   514  	AF64x2RelaxedMadd
   515  	AF64x2RelaxedNmadd
   516  	AI8x16RelaxedLaneselect
   517  	AI16x8RelaxedLaneselect
   518  	AI32x4RelaxedLaneselect
   519  	AI64x2RelaxedLaneselect
   520  	AF32x4RelaxedMin
   521  	AF32x4RelaxedMax
   522  	AF64x2RelaxedMin
   523  	AF64x2RelaxedMax
   524  	AI16x8RelaxedQ15MulrS
   525  	AI16x8RelaxedDotI8x16I7x16S
   526  	AI32x4RelaxedDotI8x16I7x16AddS
   527  
   528  	ALast // Sentinel: End of low-level WebAssembly instructions.
   529  
   530  	ARESUMEPOINT
   531  	// ACALLNORESUME is a call which is not followed by a resume point.
   532  	// It is allowed inside of WebAssembly blocks, whereas obj.ACALL is not.
   533  	// However, it is not allowed to switch goroutines while inside of an ACALLNORESUME call.
   534  	ACALLNORESUME
   535  
   536  	ARETUNWIND
   537  
   538  	AMOVB
   539  	AMOVH
   540  	AMOVW
   541  	AMOVD
   542  
   543  	AWORD
   544  	ALAST
   545  )
   546  
   547  const (
   548  	REG_NONE = 0
   549  )
   550  
   551  const (
   552  	// globals
   553  	REG_SP = obj.RBaseWasm + iota // SP is currently 32-bit, until 64-bit memory operations are available
   554  	REG_CTXT
   555  	REG_g
   556  	// RET* are used by runtime.return0 and runtime.reflectcall. These functions pass return values in registers.
   557  	REG_RET0
   558  	REG_RET1
   559  	REG_RET2
   560  	REG_RET3
   561  	REG_PAUSE
   562  
   563  	// i32 locals
   564  	REG_R0
   565  	REG_R1
   566  	REG_R2
   567  	REG_R3
   568  	REG_R4
   569  	REG_R5
   570  	REG_R6
   571  	REG_R7
   572  	REG_R8
   573  	REG_R9
   574  	REG_R10
   575  	REG_R11
   576  	REG_R12
   577  	REG_R13
   578  	REG_R14
   579  	REG_R15
   580  
   581  	// f32 locals
   582  	REG_F0
   583  	REG_F1
   584  	REG_F2
   585  	REG_F3
   586  	REG_F4
   587  	REG_F5
   588  	REG_F6
   589  	REG_F7
   590  	REG_F8
   591  	REG_F9
   592  	REG_F10
   593  	REG_F11
   594  	REG_F12
   595  	REG_F13
   596  	REG_F14
   597  	REG_F15
   598  
   599  	// f64 locals
   600  	REG_F16
   601  	REG_F17
   602  	REG_F18
   603  	REG_F19
   604  	REG_F20
   605  	REG_F21
   606  	REG_F22
   607  	REG_F23
   608  	REG_F24
   609  	REG_F25
   610  	REG_F26
   611  	REG_F27
   612  	REG_F28
   613  	REG_F29
   614  	REG_F30
   615  	REG_F31
   616  
   617  	// v128 locals
   618  	REG_V0
   619  	REG_V1
   620  	REG_V2
   621  	REG_V3
   622  	REG_V4
   623  	REG_V5
   624  	REG_V6
   625  	REG_V7
   626  	REG_V8
   627  	REG_V9
   628  	REG_V10
   629  	REG_V11
   630  	REG_V12
   631  	REG_V13
   632  	REG_V14
   633  	REG_V15
   634  
   635  	REG_PC_B // also first parameter, i32
   636  
   637  	MAXREG
   638  
   639  	MINREG  = REG_SP
   640  	REGSP   = REG_SP
   641  	REGCTXT = REG_CTXT
   642  	REGG    = REG_g
   643  )
   644  

View as plain text