24 #ifndef TVM_RUNTIME_RELAX_VM_BYTECODE_H_
25 #define TVM_RUNTIME_RELAX_VM_BYTECODE_H_
28 #include <tvm/runtime/logging.h>
109 LOG(FATAL) <<
"Internal error: "
110 <<
"Invalid ArgKind with integer value " <<
static_cast<int>(kind);
The auxiliary data structure for instruction argument.
Definition: bytecode.h:118
static Arg Register(RegName reg)
construct a register Arg.
Definition: bytecode.h:132
ArgKind kind() const
Get the kind of argument.
Definition: bytecode.h:155
static Arg FuncIdx(Index index)
construct a FuncIdx arg.
Definition: bytecode.h:150
ExecWord data() const
Get the raw data repr of the arg.
Definition: bytecode.h:169
static Arg FromData(ExecWord data)
construct Arg from data.
Definition: bytecode.h:126
static Arg Immediate(int64_t imm_value)
construct a immediate arg.
Definition: bytecode.h:144
ExecWord value() const
Get the value of argument.
Definition: bytecode.h:164
Arg()
Construct a void argument.
Definition: bytecode.h:121
static Arg ConstIdx(Index index)
construct a ConstIdx arg.
Definition: bytecode.h:138
ExecWord RegName
A register name.
Definition: bytecode.h:43
ExecWord Index
An alias for the integer type used ubiquitously in the VM.
Definition: bytecode.h:48
Opcode
An enumeration of Relax's opcodes.
Definition: bytecode.h:56
int64_t ExecWord
The storage type for the bytecode in the VM.
Definition: bytecode.h:40
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
A single virtual machine instruction.
Definition: bytecode.h:72
RegName cond
The register containing the cond value.
Definition: bytecode.h:206
Opcode op
The instruction opcode.
Definition: bytecode.h:184
static constexpr ExecWord kValueMinLimit
Minimum possible value, remove 1 slot to keep things symmetric.
Definition: bytecode.h:82
static constexpr RegName kVMRegister
Random magic number that represents the VM context.
Definition: bytecode.h:88
static Instruction Goto(RegName pc_offset)
Construct a goto instruction.
static constexpr ExecWord kValueBit
The number of bit for storing value.
Definition: bytecode.h:76
Index false_offset
The program counter offset for the false branch.
Definition: bytecode.h:208
Arg * args
The arguments of the packed function.
Definition: bytecode.h:194
RegName dst
The destination register.
Definition: bytecode.h:188
static constexpr ExecWord kValueMask
The bit mask of the value part.
Definition: bytecode.h:78
friend std::ostream & operator<<(std::ostream &os, const ArgKind &kind)
Definition: bytecode.h:94
static constexpr RegName kVoidRegister
Random magic number that represents void argument, indicate null value.
Definition: bytecode.h:86
static constexpr ExecWord kKindBit
The number of bit for storing value.
Definition: bytecode.h:74
static constexpr ExecWord kValueMaxLimit
Maximum possible value, use 1 bit for sign.
Definition: bytecode.h:80
static constexpr RegName kBeginSpecialReg
Beginning of special register section.
Definition: bytecode.h:84
static Instruction Call(Index func_idx, Index num_args, Arg *args, RegName dst)
Construct a Call instruction.
Index func_idx
The index into the packed function table.
Definition: bytecode.h:190
RegName result
The return result.
Definition: bytecode.h:198
ArgKind
The kind of instruction's argument.
Definition: bytecode.h:92
Index num_args
The number of arguments to the packed function.
Definition: bytecode.h:192
static Instruction Ret(RegName result)
Construct a return instruction.
Index pc_offset
The jump offset.
Definition: bytecode.h:202
static Instruction If(RegName cond, Index false_offset)
Construct an If instruction.