package p.studio.compiler.backend.irvm;

public record IRVMOp(
        String name,
        int opcode,
        int immediateSize,
        int pops,
        int pushes,
        boolean branch,
        boolean terminator,
        boolean internal) {

    public static final IRVMOp HALT = new IRVMOp("HALT", 0x01, 0, 0, 0, false, true, false);
    public static final IRVMOp RET = new IRVMOp("RET", 0x51, 0, 0, 0, false, true, false);
    public static final IRVMOp PUSH_CONST = new IRVMOp("PUSH_CONST", 0x10, 4, 0, 1, false, false, false);
    public static final IRVMOp POP = new IRVMOp("POP", 0x11, 0, 1, 0, false, false, false);
    public static final IRVMOp CALL = new IRVMOp("CALL", 0x50, 4, 0, 0, false, false, false);
    public static final IRVMOp JMP = new IRVMOp("JMP", 0x02, 4, 0, 0, true, true, false);
    public static final IRVMOp JMP_IF_TRUE = new IRVMOp("JMP_IF_TRUE", 0x04, 4, 1, 0, true, false, false);
    public static final IRVMOp JMP_IF_FALSE = new IRVMOp("JMP_IF_FALSE", 0x03, 4, 1, 0, true, false, false);
    public static final IRVMOp HOSTCALL = new IRVMOp("HOSTCALL", 0x71, 4, 0, 0, false, false, false);
    public static final IRVMOp INTRINSIC = new IRVMOp("INTRINSIC", 0x72, 4, 0, 0, false, false, false);
    public static final IRVMOp PUSH_BOOL = new IRVMOp("PUSH_BOOL", 0x16, 1, 0, 1, false, false, false);
    public static final IRVMOp PUSH_I32 = new IRVMOp("PUSH_I32", 0x17, 4, 0, 1, false, false, false);
    public static final IRVMOp ADD = new IRVMOp("ADD", 0x20, 0, 2, 1, false, false, false);
    public static final IRVMOp SUB = new IRVMOp("SUB", 0x21, 0, 2, 1, false, false, false);
    public static final IRVMOp MUL = new IRVMOp("MUL", 0x22, 0, 2, 1, false, false, false);
    public static final IRVMOp DIV = new IRVMOp("DIV", 0x23, 0, 2, 1, false, false, false);
    public static final IRVMOp MOD = new IRVMOp("MOD", 0x24, 0, 2, 1, false, false, false);
    public static final IRVMOp EQ = new IRVMOp("EQ", 0x30, 0, 2, 1, false, false, false);
    public static final IRVMOp NEQ = new IRVMOp("NEQ", 0x31, 0, 2, 1, false, false, false);
    public static final IRVMOp LT = new IRVMOp("LT", 0x32, 0, 2, 1, false, false, false);
    public static final IRVMOp GT = new IRVMOp("GT", 0x33, 0, 2, 1, false, false, false);
    public static final IRVMOp AND = new IRVMOp("AND", 0x34, 0, 2, 1, false, false, false);
    public static final IRVMOp OR = new IRVMOp("OR", 0x35, 0, 2, 1, false, false, false);
    public static final IRVMOp NOT = new IRVMOp("NOT", 0x36, 0, 1, 1, false, false, false);
    public static final IRVMOp LTE = new IRVMOp("LTE", 0x3C, 0, 2, 1, false, false, false);
    public static final IRVMOp GTE = new IRVMOp("GTE", 0x3D, 0, 2, 1, false, false, false);
    public static final IRVMOp NEG = new IRVMOp("NEG", 0x3E, 0, 1, 1, false, false, false);
    public static final IRVMOp GET_GLOBAL = new IRVMOp("GET_GLOBAL", 0x40, 4, 0, 1, false, false, false);
    public static final IRVMOp SET_GLOBAL = new IRVMOp("SET_GLOBAL", 0x41, 4, 1, 0, false, false, false);
    public static final IRVMOp GET_LOCAL = new IRVMOp("GET_LOCAL", 0x42, 4, 0, 1, false, false, false);
    public static final IRVMOp SET_LOCAL = new IRVMOp("SET_LOCAL", 0x43, 4, 1, 0, false, false, false);
    public static final IRVMOp INTERNAL_EXT = new IRVMOp("IRVM_EXT_NOP", 0xFFFF, 0, 0, 0, false, false, true);
}
