tvm
|
A single virtual machine instruction. More...
#include <bytecode.h>
Classes | |
class | Arg |
The auxiliary data structure for instruction argument. More... | |
Public Types | |
enum class | ArgKind : int { kRegister = 0 , kImmediate = 1 , kConstIdx = 2 , kFuncIdx = 3 } |
The kind of instruction's argument. More... | |
Static Public Member Functions | |
static Instruction | Call (Index func_idx, Index num_args, Arg *args, RegName dst) |
Construct a Call instruction. More... | |
static Instruction | Ret (RegName result) |
Construct a return instruction. More... | |
static Instruction | Goto (RegName pc_offset) |
Construct a goto instruction. More... | |
static Instruction | If (RegName cond, Index false_offset) |
Construct an If instruction. More... | |
Public Attributes | |
Opcode | op |
The instruction opcode. More... | |
union { | |
struct { | |
RegName dst | |
The destination register. More... | |
Index func_idx | |
The index into the packed function table. More... | |
Index num_args | |
The number of arguments to the packed function. More... | |
Arg * args | |
The arguments of the packed function. More... | |
} | |
struct { | |
RegName result | |
The return result. More... | |
} | |
struct { | |
Index pc_offset | |
The jump offset. More... | |
} | |
struct { | |
RegName cond | |
The register containing the cond value. More... | |
Index false_offset | |
The program counter offset for the false branch. More... | |
} | |
}; | |
Static Public Attributes | |
static constexpr ExecWord | kKindBit = 8 |
The number of bit for storing value. More... | |
static constexpr ExecWord | kValueBit = sizeof(ExecWord) * 8 - kKindBit |
The number of bit for storing value. More... | |
static constexpr ExecWord | kValueMask = (static_cast<ExecWord>(1) << kValueBit) - 1 |
The bit mask of the value part. More... | |
static constexpr ExecWord | kValueMaxLimit = (static_cast<ExecWord>(1) << (kValueBit - 1)) - 1 |
Maximum possible value, use 1 bit for sign. More... | |
static constexpr ExecWord | kValueMinLimit = -kValueMaxLimit |
Minimum possible value, remove 1 slot to keep things symmetric. More... | |
static constexpr RegName | kBeginSpecialReg = static_cast<ExecWord>(1) << 54 |
Beginning of special register section. More... | |
static constexpr RegName | kVoidRegister = kBeginSpecialReg + 0 |
Random magic number that represents void argument, indicate null value. More... | |
static constexpr RegName | kVMRegister = kBeginSpecialReg + 1 |
Random magic number that represents the VM context. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const ArgKind &kind) |
A single virtual machine instruction.
The representation of the instruction is as a tagged union.
The first field represents which instruction, and by extension which field of the union is active.
|
strong |
|
static |
Construct a Call instruction.
func_idx | The index of the function to call. |
num_args | The number of arguments. |
args | The input arguments. |
dst | The destination register. |
|
static |
Construct a goto instruction.
pc_offset | The register containing the jump offset. |
|
static |
Construct an If instruction.
cond | The register containing the cond value. |
false_offset | The program counter offset for the false branch. |
|
static |
Construct a return instruction.
result | The register containing the return value. |
|
friend |
union { ... } |
Arg* tvm::runtime::relax_vm::Instruction::args |
The arguments of the packed function.
RegName tvm::runtime::relax_vm::Instruction::cond |
The register containing the cond value.
RegName tvm::runtime::relax_vm::Instruction::dst |
The destination register.
Index tvm::runtime::relax_vm::Instruction::false_offset |
The program counter offset for the false branch.
Index tvm::runtime::relax_vm::Instruction::func_idx |
The index into the packed function table.
|
staticconstexpr |
Beginning of special register section.
|
staticconstexpr |
The number of bit for storing value.
|
staticconstexpr |
The number of bit for storing value.
|
staticconstexpr |
The bit mask of the value part.
|
staticconstexpr |
Maximum possible value, use 1 bit for sign.
|
staticconstexpr |
Minimum possible value, remove 1 slot to keep things symmetric.
|
staticconstexpr |
Random magic number that represents the VM context.
|
staticconstexpr |
Random magic number that represents void argument, indicate null value.
Index tvm::runtime::relax_vm::Instruction::num_args |
The number of arguments to the packed function.
Opcode tvm::runtime::relax_vm::Instruction::op |
The instruction opcode.
Index tvm::runtime::relax_vm::Instruction::pc_offset |
The jump offset.
RegName tvm::runtime::relax_vm::Instruction::result |
The return result.