github.com/go-asm/go@v1.21.1-0.20240213172139-40c5ead50c48/cmd/obj/wasm/a.out.go (about)

     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 "github.com/go-asm/go/cmd/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  	ALast // Sentinel: End of low-level WebAssembly instructions.
   245  
   246  	ARESUMEPOINT
   247  	// ACALLNORESUME is a call which is not followed by a resume point.
   248  	// It is allowed inside of WebAssembly blocks, whereas obj.ACALL is not.
   249  	// However, it is not allowed to switch goroutines while inside of an ACALLNORESUME call.
   250  	ACALLNORESUME
   251  
   252  	ARETUNWIND
   253  
   254  	AMOVB
   255  	AMOVH
   256  	AMOVW
   257  	AMOVD
   258  
   259  	AWORD
   260  	ALAST
   261  )
   262  
   263  const (
   264  	REG_NONE = 0
   265  )
   266  
   267  const (
   268  	// globals
   269  	REG_SP = obj.RBaseWasm + iota // SP is currently 32-bit, until 64-bit memory operations are available
   270  	REG_CTXT
   271  	REG_g
   272  	// RET* are used by runtime.return0 and runtime.reflectcall. These functions pass return values in registers.
   273  	REG_RET0
   274  	REG_RET1
   275  	REG_RET2
   276  	REG_RET3
   277  	REG_PAUSE
   278  
   279  	// i32 locals
   280  	REG_R0
   281  	REG_R1
   282  	REG_R2
   283  	REG_R3
   284  	REG_R4
   285  	REG_R5
   286  	REG_R6
   287  	REG_R7
   288  	REG_R8
   289  	REG_R9
   290  	REG_R10
   291  	REG_R11
   292  	REG_R12
   293  	REG_R13
   294  	REG_R14
   295  	REG_R15
   296  
   297  	// f32 locals
   298  	REG_F0
   299  	REG_F1
   300  	REG_F2
   301  	REG_F3
   302  	REG_F4
   303  	REG_F5
   304  	REG_F6
   305  	REG_F7
   306  	REG_F8
   307  	REG_F9
   308  	REG_F10
   309  	REG_F11
   310  	REG_F12
   311  	REG_F13
   312  	REG_F14
   313  	REG_F15
   314  
   315  	// f64 locals
   316  	REG_F16
   317  	REG_F17
   318  	REG_F18
   319  	REG_F19
   320  	REG_F20
   321  	REG_F21
   322  	REG_F22
   323  	REG_F23
   324  	REG_F24
   325  	REG_F25
   326  	REG_F26
   327  	REG_F27
   328  	REG_F28
   329  	REG_F29
   330  	REG_F30
   331  	REG_F31
   332  
   333  	REG_PC_B // also first parameter, i32
   334  
   335  	MAXREG
   336  
   337  	MINREG  = REG_SP
   338  	REGSP   = REG_SP
   339  	REGCTXT = REG_CTXT
   340  	REGG    = REG_g
   341  )