forked from visoftsolutions/noir_rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(avm): list avm opcodes in a (enum => class) map in TS (AztecPro…
- Loading branch information
Showing
7 changed files
with
127 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
yarn-project/acir-simulator/src/avm/opcodes/instruction_set.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import { | ||
Add, | ||
/*Div,*/ | ||
Mul, | ||
Sub, | ||
} from './arithmetic.js'; | ||
//import { And, Not, Or, Shl, Shr, Xor } from './bitwise.js'; | ||
//import { Eq, Lt, Lte } from './comparators.js'; | ||
import { Return } from './control_flow.js'; | ||
import { Instruction } from './instruction.js'; | ||
import { | ||
CalldataCopy, | ||
/*Cast, Mov*/ | ||
} from './memory.js'; | ||
import { Opcode } from './opcodes.js'; | ||
|
||
/** - */ | ||
type InstructionConstructor = new (...args: any[]) => Instruction; | ||
/** - */ | ||
type InstructionConstructorAndMembers = InstructionConstructor & { | ||
/** - */ | ||
numberOfOperands: number; | ||
}; | ||
|
||
export const INSTRUCTION_SET: Map<Opcode, InstructionConstructorAndMembers> = new Map( | ||
new Array<[Opcode, InstructionConstructorAndMembers]>( | ||
// Compute | ||
// Compute - Arithmetic | ||
[Opcode.ADD, Add], | ||
[Opcode.SUB, Sub], | ||
[Opcode.MUL, Mul], | ||
//[Opcode.DIV, Div], | ||
//// Compute - Comparators | ||
//[Opcode.EQ, Eq], | ||
//[Opcode.LT, Lt], | ||
//[Opcode.LTE, Lte], | ||
//// Compute - Bitwise | ||
//[Opcode.AND, And], | ||
//[Opcode.OR, Or], | ||
//[Opcode.XOR, Xor], | ||
//[Opcode.NOT, Not], | ||
//[Opcode.SHL, Shl], | ||
//[Opcode.SHR, Shr], | ||
//// Compute - Type Conversions | ||
//[Opcode.CAST, Cast], | ||
|
||
//// Execution Environment | ||
//[Opcode.ADDRESS, Address], | ||
//[Opcode.STORAGEADDRESS, Storageaddress], | ||
//[Opcode.ORIGIN, Origin], | ||
//[Opcode.SENDER, Sender], | ||
//[Opcode.PORTAL, Portal], | ||
//[Opcode.FEEPERL1GAS, Feeperl1gas], | ||
//[Opcode.FEEPERL2GAS, Feeperl2gas], | ||
//[Opcode.FEEPERDAGAS, Feeperdagas], | ||
//[Opcode.CONTRACTCALLDEPTH, Contractcalldepth], | ||
//// Execution Environment - Globals | ||
//[Opcode.CHAINID, Chainid], | ||
//[Opcode.VERSION, Version], | ||
//[Opcode.BLOCKNUMBER, Blocknumber], | ||
//[Opcode.TIMESTAMP, Timestamp], | ||
//[Opcode.COINBASE, Coinbase], | ||
//[Opcode.BLOCKL1GASLIMIT, Blockl1gaslimit], | ||
//[Opcode.BLOCKL2GASLIMIT, Blockl2gaslimit], | ||
//[Opcode.BLOCKDAGASLIMIT, Blockdagaslimit], | ||
// Execution Environment - Calldata | ||
[Opcode.CALLDATACOPY, CalldataCopy], | ||
|
||
//// Machine State | ||
// Machine State - Gas | ||
//[Opcode.L1GASLEFT, L1gasleft], | ||
//[Opcode.L2GASLEFT, L2gasleft], | ||
//[Opcode.DAGASLEFT, Dagasleft], | ||
//// Machine State - Internal Control Flow | ||
//[Opcode.JUMP, Jump], | ||
//[Opcode.JUMPI, Jumpi], | ||
//[Opcode.INTERNALCALL, Internalcall], | ||
//[Opcode.INTERNALRETURN, Internalreturn], | ||
//// Machine State - Memory | ||
//[Opcode.SET, Set], | ||
//[Opcode.MOV, Mov], | ||
//[Opcode.CMOV, CMov], | ||
|
||
//// World State | ||
//[Opcode.BLOCKHEADERBYNUMBER, Blockheaderbynumber], | ||
//[Opcode.SLOAD, Sload], // Public Storage | ||
//[Opcode.SSTORE, Sstore], // Public Storage | ||
//[Opcode.READL1TOL2MSG, Readl1tol2msg], // Messages | ||
//[Opcode.SENDL2TOL1MSG, Sendl2tol1msg], // Messages | ||
//[Opcode.EMITNOTEHASH, Emitnotehash], // Notes & Nullifiers | ||
//[Opcode.EMITNULLIFIER, Emitnullifier], // Notes & Nullifiers | ||
|
||
//// Accrued Substate | ||
//[Opcode.EMITUNENCRYPTEDLOG, Emitunencryptedlog], | ||
|
||
//// Control Flow - Contract Calls | ||
//[Opcode.CALL, Call], | ||
//[Opcode.STATICCALL, Staticcall], | ||
[Opcode.RETURN, Return], | ||
//[Opcode.REVERT, Revert], | ||
|
||
//// Gadgets | ||
//[Opcode.KECCAK, Keccak], | ||
//[Opcode.POSEIDON, Poseidon], | ||
), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+3.57 KB
yellow-paper/docs/public-vm/gen/images/bit-formats/INTERNALCALLDEPTH.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.