|
MXVM 1.8.1
Virtual Machine, Compiler, and Pascal Frontend
|
Complete MXVM program: instruction interpreter and native x64 code generator. More...
#include <icode.hpp>

Public Member Functions | |
| Program () | |
| Default constructor — initializes execution state (pc, flags, etc.). | |
| ~Program () | |
| Destructor — frees any heap-allocated variables. | |
| Program (Program &&other) noexcept | |
| Move constructor — transfers all execution state and child objects. | |
| Program & | operator= (Program &&other) noexcept |
| Move-assignment operator. | |
| void | add_standard () |
| Register standard library runtime functions. | |
| void | stop () |
| Halt the interpreter loop. | |
| int | exec () |
| Execute the program via the interpreter. | |
| void | print (std::ostream &out) |
| Print all instructions and data to an output stream. | |
| void | post (std::ostream &out) |
| Generate native data section (variable declarations) into the output stream. | |
| int | getExitCode () const |
| Get the program's exit code after execution. | |
| std::string | getPlatformSymbolName (const std::string &name) |
| Mangle a symbol name with the platform prefix (e.g. _name for Darwin). | |
| void | generateCode (const Platform &platform, bool obj, std::ostream &out) |
| Generate native x64 assembly for the entire program. | |
| void | memoryDump (std::ostream &out) |
| Dump all variable values to a stream for debugging. | |
| void | setArgs (const std::vector< std::string > &argv) |
| Set the command-line arguments available to the program. | |
| void | setObject (bool obj) |
| Mark this program as an object (no main entry point). | |
| bool | validateNames (Validator &v) |
| Validate all variable and label names against the Validator. | |
| void | flatten (Program *program) |
| Flatten child object programs into the root instruction stream. | |
| void | flatten_inc (Program *root, Instruction &i) |
| Rewrite object-qualified operand references in a single instruction. | |
| void | flatten_label (Program *root, int64_t offset, const std::string &label, bool func) |
| Copy a label from a child object into the root label map with an address offset. | |
| void | flatten_external (Program *root, const std::string &e, RuntimeFunction &r) |
| Copy an external function binding from a child object into the root. | |
| std::string | getMangledName (const std::string &var) |
| Mangle a variable name with its owning object prefix. | |
| std::string | getMangledName (const Operand &op) |
| Mangle an operand's variable reference with its object prefix. | |
| Program * | getObjectByName (const std::string &name) |
| Look up a child object program by name. | |
| bool | isFunctionValid (const std::string &label) |
| Check whether a label exists and is marked as a function entry. | |
| size_t | x64_reserve_call_area (std::ostream &out, size_t spill_bytes) |
| Reserve stack space for a Win64 call frame including spill area. | |
| void | x64_release_call_area (std::ostream &out, size_t frame) |
| Release a Win64 call frame previously reserved. | |
| void | x64_direct_stack_adjust (std::ostream &out, int64_t bytes) |
| Emit a direct stack pointer adjustment. | |
System V ABI (Linux/macOS) x86-64 code generation | |
| void | generateFunctionCall (std::ostream &out, const std::string &name, std::vector< Operand > &op) |
| Generate a System V ABI function call with operands as arguments. | |
| void | generateInvokeCall (std::ostream &out, std::vector< Operand > &op) |
| Generate a dynamic invoke call (runtime-resolved external function). | |
| void | generateInstruction (std::ostream &out, const Instruction &i) |
| Dispatch a single instruction to its System V code generator. | |
| int | generateLoadVar (std::ostream &out, int reg, const Operand &op) |
| Load a variable or constant into a numbered register. | |
| int | generateLoadVar (std::ostream &out, VarType type, std::string reg, const Operand &op) |
| Load a variable or constant into a named register. | |
| std::string | getRegisterByIndex (int index, VarType type) |
| Get the register name for a given index and variable type. | |
| void | gen_print (std::ostream &out, const Instruction &i) |
| void | gen_arth (std::ostream &out, std::string arth, const Instruction &i) |
| void | gen_exit (std::ostream &out, const Instruction &i) |
| void | gen_mov (std::ostream &out, const Instruction &i) |
| void | gen_jmp (std::ostream &out, const Instruction &i) |
| void | gen_cmp (std::ostream &out, const Instruction &i) |
| void | gen_alloc (std::ostream &out, const Instruction &i) |
| void | gen_realloc (std::ostream &out, const Instruction &i) |
| Generate System V x86-64 assembly for the REALLOC instruction (dynamic array resize). | |
| void | gen_free (std::ostream &out, const Instruction &i) |
| void | gen_load (std::ostream &out, const Instruction &i) |
| void | gen_store (std::ostream &out, const Instruction &i) |
| void | gen_ret (std::ostream &out, const Instruction &i) |
| void | gen_call (std::ostream &out, const Instruction &i) |
| void | gen_done (std::ostream &out, const Instruction &i) |
| void | gen_bitop (std::ostream &out, const std::string &opc, const Instruction &i) |
| void | gen_not (std::ostream &out, const Instruction &i) |
| void | gen_push (std::ostream &out, const Instruction &i) |
| Emit x86-64 PUSH for a variable or constant. | |
| void | gen_pop (std::ostream &out, const Instruction &i) |
| Emit x86-64 POP into a variable. | |
| void | gen_stack_load (std::ostream &out, const Instruction &i) |
| void | gen_stack_store (std::ostream &out, const Instruction &i) |
| void | gen_stack_sub (std::ostream &out, const Instruction &i) |
| void | gen_getline (std::ostream &out, const Instruction &i) |
| void | gen_to_int (std::ostream &out, const Instruction &i) |
| void | gen_to_float (std::ostream &out, const Instruction &i) |
| void | gen_invoke (std::ostream &out, const Instruction &i) |
| void | gen_return (std::ostream &out, const Instruction &i) |
| void | gen_neg (std::ostream &out, const Instruction &i) |
| void | gen_lea (std::ostream &out, const Instruction &i) |
| void | gen_fcmp (std::ostream &out, const Instruction &i) |
| void | gen_jae (std::ostream &out, const Instruction &i) |
| void | gen_jbe (std::ostream &out, const Instruction &i) |
| void | gen_jc (std::ostream &out, const Instruction &i) |
| void | gen_jnc (std::ostream &out, const Instruction &i) |
| void | gen_jp (std::ostream &out, const Instruction &i) |
| void | gen_jnp (std::ostream &out, const Instruction &i) |
| void | gen_jo (std::ostream &out, const Instruction &i) |
| void | gen_jno (std::ostream &out, const Instruction &i) |
| void | gen_js (std::ostream &out, const Instruction &i) |
| void | gen_jns (std::ostream &out, const Instruction &i) |
| void | gen_add (std::ostream &out, const Instruction &i) |
| void | gen_sub (std::ostream &out, const Instruction &i) |
| void | gen_mul (std::ostream &out, const Instruction &i) |
| void | gen_div (std::ostream &out, const Instruction &i) |
| void | gen_mod (std::ostream &out, const Instruction &i) |
| std::string | gen_optimize (const std::string &code, const Platform &platform) |
| Peephole optimizer for generated assembly. | |
| std::string | optimize_darwin (const std::string &code) |
| Darwin-specific assembly optimizations. | |
| std::string | optimize_core (const std::string &code) |
| Platform-independent peephole optimizations. | |
Interpreter execution methods | |
| void | exec_mov (const Instruction &instr) |
| void | exec_add (const Instruction &instr) |
| void | exec_sub (const Instruction &instr) |
| void | exec_mul (const Instruction &instr) |
| void | exec_div (const Instruction &instr) |
| void | exec_cmp (const Instruction &instr) |
| void | exec_jmp (const Instruction &instr) |
| void | exec_load (const Instruction &instr) |
| void | exec_store (const Instruction &instr) |
| Execute a STORE instruction — write a value into a pointer at a given offset. | |
| void | exec_or (const Instruction &instr) |
| void | exec_and (const Instruction &instr) |
| void | exec_xor (const Instruction &instr) |
| void | exec_not (const Instruction &instr) |
| void | exec_mod (const Instruction &instr) |
| void | exec_je (const Instruction &instr) |
| void | exec_jne (const Instruction &instr) |
| void | exec_jl (const Instruction &instr) |
| void | exec_jle (const Instruction &instr) |
| void | exec_jg (const Instruction &instr) |
| void | exec_jge (const Instruction &instr) |
| void | exec_jz (const Instruction &instr) |
| void | exec_jnz (const Instruction &instr) |
| void | exec_ja (const Instruction &instr) |
| void | exec_jb (const Instruction &instr) |
| void | exec_print (const Instruction &instr) |
| void | exec_string_print (const Instruction &instr) |
| void | exec_exit (const Instruction &instr) |
| void | exec_alloc (const Instruction &instr) |
| void | exec_free (const Instruction &instr) |
| void | exec_getline (const Instruction &instr) |
| void | exec_push (const Instruction &instr) |
| Execute a PUSH instruction — save a variable or constant onto the VM stack. | |
| void | exec_pop (const Instruction &instr) |
| Execute a POP instruction — restore a value from the VM stack into a variable. | |
| void | exec_stack_load (const Instruction &instr) |
| void | exec_stack_store (const Instruction &instr) |
| void | exec_stack_sub (const Instruction &instr) |
| void | exec_call (const Instruction &instr) |
| void | exec_ret (const Instruction &instr) |
| void | exec_done (const Instruction &instr) |
| void | exec_to_int (const Instruction &instr) |
| void | exec_to_float (const Instruction &instr) |
| void | exec_invoke (const Instruction &instr) |
| void | exec_return (const Instruction &instr) |
| void | exec_lea (const Instruction &instr) |
| void | exec_neg (const Instruction &instr) |
| void | exec_realloc (const Instruction &instr) |
| Execute the REALLOC instruction in the interpreter. | |
| void | exec_fcmp (const Instruction &instr) |
| void | exec_jae (const Instruction &instr) |
| void | exec_jbe (const Instruction &instr) |
| void | exec_jc (const Instruction &instr) |
| void | exec_jnc (const Instruction &instr) |
| void | exec_jp (const Instruction &instr) |
| void | exec_jnp (const Instruction &instr) |
| void | exec_jo (const Instruction &instr) |
| void | exec_jno (const Instruction &instr) |
| void | exec_js (const Instruction &instr) |
| void | exec_jns (const Instruction &instr) |
Interpreter helper methods | |
| Variable & | getVariable (const std::string &name) |
| Look up a variable by name, searching local scope then global. | |
| bool | isVariable (const std::string &name) |
| Check whether a variable exists in local or global scope. | |
| void | setVariableFromString (Variable &var, const std::string &value) |
| Set a variable's value from a string representation, coercing types. | |
| void | addVariables (Variable &dest, Variable &src1, Variable &src2) |
| Add two variables and store the result in dest. | |
| void | subVariables (Variable &dest, Variable &src1, Variable &src2) |
| Subtract src2 from src1 and store the result in dest. | |
| void | mulVariables (Variable &dest, Variable &src1, Variable &src2) |
| Multiply two variables and store the result in dest. | |
| void | divVariables (Variable &dest, Variable &src1, Variable &src2) |
| Divide src1 by src2 and store the result in dest. | |
| std::string | printFormatted (const std::string &format, const std::vector< Variable * > &args, bool output=true) |
| Format and optionally print a printf-style format string with variable arguments. | |
| void | setVariableFromConstant (Variable &var, const std::string &value) |
| Set a variable's value from a constant string (integer, float, or string literal). | |
| Variable | createTempVariable (VarType type, const std::string &value) |
| Create a temporary unnamed variable with the given type and value. | |
| bool | isConstant (const std::string &value) |
| Check whether a string represents a compile-time constant (number or quoted string). | |
| Variable | variableFromOperand (const Operand &op) |
| Resolve an Operand to its corresponding Variable. | |
| Public Member Functions inherited from mxvm::Base | |
| Base ()=default | |
| Base (Base &&other) noexcept | |
| Move constructor. | |
| ~Base ()=default | |
| Base & | operator= (Base &&other) noexcept |
| Move-assignment operator. | |
| void | setMainBase (Base *b) |
| Set the root program base pointer (used for global variable lookup). | |
| void | add_instruction (const Instruction &i) |
| Append an instruction to the instruction stream. | |
| void | add_label (const std::string &name, uint64_t address, bool f) |
| Register a label at the given instruction address. | |
| void | add_variable (const std::string &name, const Variable &v) |
| Declare a local variable in the symbol table. | |
| void | add_global (const std::string &objname, const std::string &name, const Variable &v) |
| Declare a global variable scoped to an object. | |
| void | add_extern (const std::string &mod, const std::string &name, bool module) |
| Register an external function import. | |
| void | add_runtime_extern (const std::string &mod_name, const std::string &mod, const std::string &func_name, const std::string &name) |
| Register and resolve a runtime-loaded external function. | |
| void | add_filename (const std::string &fname) |
| Record a source filename for debug/error reporting. | |
| void | add_allocated (const std::string &name, Variable &v) |
| Track a heap-allocated variable for cleanup. | |
| void | add_object (const std::string &name, Program *prog) |
| Register a child object program. | |
Static Public Member Functions | |
| static std::string | escapeNewLines (const std::string &text) |
| Escape newline characters in a string literal for assembly output. | |
Public Attributes | |
| std::string | name |
| std::string | filename |
| std::vector< std::unique_ptr< Program > > | objects |
| bool | object = false |
| Stack | stack |
| Operand | result |
| return value operand from last invoke | |
| Program * | parent = nullptr |
| parent program (for object programs) | |
| Platform | platform |
| bool | last_call_returns_owned = false |
| VarType | last_call_ret_type = VarType::VAR_INTEGER |
| Public Attributes inherited from mxvm::Base | |
| std::string | name |
| std::vector< Instruction > | inc |
| instruction stream | |
| std::unordered_map< std::string, Variable > | vars |
| variable symbol table | |
| std::unordered_map< std::string, std::pair< uint64_t, bool > > | labels |
| label -> (address, is_function) | |
| std::vector< ExternalFunction > | external |
| declared external function imports | |
| std::unordered_map< std::string, RuntimeFunction > | external_functions |
| resolved runtime function bindings | |
| std::string | assembly_code |
| generated assembly output for objects | |
Private Types | |
| enum | LastCmpType { CMP_NONE , CMP_INTEGER , CMP_FLOAT } |
| Tracks type of last comparison for conditional jumps. More... | |
Private Attributes | |
| size_t | pc |
| program counter | |
| bool | running |
| interpreter running flag | |
| int | exitCode = 0 |
| bool | zero_flag = false |
| comparison zero flag | |
| bool | less_flag = false |
| comparison less-than flag | |
| bool | greater_flag = false |
| comparison greater-than flag | |
| bool | carry_flag = false |
| comparison carry flag | |
| int | xmm_offset = 0 |
| current XMM register allocation offset | |
| std::vector< std::string > | args |
| bool | main_function |
| true if this program has a main entry point | |
| bool | object_external = false |
| LastCmpType | last_cmp_type = CMP_NONE |
| bool | last_call_returns_owned_ptr = false |
| tracks ownership of last call's return value | |
Friends | |
| class | Parser |
Win64 ABI x86-64 code generation | |
| std::unordered_map< std::string, std::string > | x64_reg_vars |
| Win64 variable-to-register mapping. | |
| std::vector< std::string > | x64_reg_save_order |
| void | x64_emit_iob_func (std::ostream &out, int index, const std::string &dstReg) |
| Emit an integer-or-byte function argument load for Win64 ABI. | |
| std::string | x64_getRegisterByIndex (int index, VarType type) |
| Get the Win64 register name for a given index and variable type. | |
| int | x64_generateLoadVar (std::ostream &out, int r, const Operand &op) |
| Load a variable or constant into a numbered Win64 register. | |
| int | x64_generateLoadVar (std::ostream &out, VarType type, std::string reg, const Operand &op) |
| Load a variable or constant into a named Win64 register. | |
| void | x64_generateFunctionCall (std::ostream &out, const std::string &name, std::vector< Operand > &args) |
| Generate a Win64 ABI function call with operands as arguments. | |
| void | x64_generateInvokeCall (std::ostream &out, std::vector< Operand > &op) |
| Generate a Win64 dynamic invoke call. | |
| void | x64_generateCode (const Platform &platform, bool obj, std::ostream &out) |
| Top-level Win64 code generation entry point. | |
| void | x64_generateInstruction (std::ostream &out, const Instruction &i) |
| Dispatch a single instruction to its Win64 code generator. | |
| void | x64_gen_done (std::ostream &out, const Instruction &i) |
| void | x64_gen_ret (std::ostream &out, const Instruction &i) |
| void | x64_gen_return (std::ostream &out, const Instruction &i) |
| void | x64_gen_neg (std::ostream &out, const Instruction &i) |
| void | x64_gen_invoke (std::ostream &out, const Instruction &i) |
| void | x64_gen_call (std::ostream &out, const Instruction &i) |
| void | x64_gen_alloc (std::ostream &out, const Instruction &i) |
| void | x64_gen_realloc (std::ostream &out, const Instruction &i) |
| Generate Win64 x86-64 assembly for the REALLOC instruction (dynamic array resize). | |
| void | x64_gen_free (std::ostream &out, const Instruction &i) |
| void | x64_gen_load (std::ostream &out, const Instruction &i) |
| void | x64_gen_store (std::ostream &out, const Instruction &i) |
| void | x64_gen_to_int (std::ostream &out, const Instruction &i) |
| void | x64_gen_to_float (std::ostream &out, const Instruction &i) |
| void | x64_gen_div (std::ostream &out, const Instruction &i) |
| void | x64_gen_mod (std::ostream &out, const Instruction &i) |
| void | x64_gen_getline (std::ostream &out, const Instruction &i) |
| void | x64_gen_bitop (std::ostream &out, const std::string &opc, const Instruction &i) |
| void | x64_gen_not (std::ostream &out, const Instruction &i) |
| void | x64_gen_push (std::ostream &out, const Instruction &i) |
| void | x64_gen_pop (std::ostream &out, const Instruction &i) |
| void | x64_gen_stack_load (std::ostream &out, const Instruction &i) |
| void | x64_gen_stack_store (std::ostream &out, const Instruction &i) |
| void | x64_gen_stack_sub (std::ostream &out, const Instruction &i) |
| void | x64_gen_print (std::ostream &out, const Instruction &i) |
| void | x64_gen_jmp (std::ostream &out, const Instruction &i) |
| void | x64_gen_cmp (std::ostream &out, const Instruction &i) |
| void | x64_gen_mov (std::ostream &out, const Instruction &i) |
| void | x64_gen_arth (std::ostream &out, std::string arth, const Instruction &i) |
| void | x64_gen_exit (std::ostream &out, const Instruction &i) |
| void | x64_gen_lea (std::ostream &out, const Instruction &i) |
| void | x64_gen_fcmp (std::ostream &out, const Instruction &i) |
| void | x64_gen_jae (std::ostream &out, const Instruction &i) |
| void | x64_gen_jbe (std::ostream &out, const Instruction &i) |
| void | x64_gen_jc (std::ostream &out, const Instruction &i) |
| void | x64_gen_jnc (std::ostream &out, const Instruction &i) |
| void | x64_gen_jp (std::ostream &out, const Instruction &i) |
| void | x64_gen_jnp (std::ostream &out, const Instruction &i) |
| void | x64_gen_jo (std::ostream &out, const Instruction &i) |
| void | x64_gen_jno (std::ostream &out, const Instruction &i) |
| void | x64_gen_js (std::ostream &out, const Instruction &i) |
| void | x64_gen_jns (std::ostream &out, const Instruction &i) |
| void | x64_analyzeRegAlloc (bool uses_std_module) |
| Analyze variable usage and assign Win64 callee-saved registers. | |
| void | x64_emitFlushRegs (std::ostream &out) |
| Write all register-allocated variables back to memory. | |
| void | x64_emitReloadRegs (std::ostream &out) |
| Reload register-allocated variables from memory. | |
| void | x64_emitSaveRegs (std::ostream &out) |
| Save callee-saved registers at function prologue. | |
| void | x64_emitRestoreRegs (std::ostream &out) |
| Restore callee-saved registers at function epilogue. | |
| void | x64_emitStoreVar (std::ostream &out, const std::string &srcReg, const Operand &dest) |
| Store a register value into a variable (register-allocated or memory). | |
| void | x64_emitStoreVarImm (std::ostream &out, const std::string &imm, const Operand &dest) |
| Store an immediate value into a variable. | |
| void | x64_emitLoadVar (std::ostream &out, const std::string &dstReg, const Operand &src) |
| Load a variable into a destination register. | |
System V ABI register allocation | |
| std::unordered_map< std::string, std::string > | sysv_reg_vars |
| SysV variable-to-register mapping. | |
| std::vector< std::string > | sysv_reg_save_order |
| void | sysv_analyzeRegAlloc (bool uses_std_module) |
| Analyze variable usage and assign System V callee-saved registers. | |
| void | sysv_emitFlushRegs (std::ostream &out) |
| Write all register-allocated variables back to memory. | |
| void | sysv_emitReloadRegs (std::ostream &out) |
| Reload register-allocated variables from memory. | |
| void | sysv_emitSaveRegs (std::ostream &out) |
| Save callee-saved registers at function prologue. | |
| void | sysv_emitRestoreRegs (std::ostream &out) |
| Restore callee-saved registers at function epilogue. | |
| void | sysv_emitStoreVar (std::ostream &out, const std::string &srcReg, const Operand &dest) |
| Store a register value into a variable (register-allocated or memory). | |
| void | sysv_emitStoreVarImm (std::ostream &out, const std::string &imm, const Operand &dest) |
| Store an immediate value into a variable. | |
| void | sysv_emitLoadVar (std::ostream &out, const std::string &dstReg, const Operand &src) |
| Load a variable into a destination register. | |
Additional Inherited Members | |
| Static Public Attributes inherited from mxvm::Base | |
| static Base * | base = nullptr |
| pointer to the main program base | |
| static std::string | root_name |
| static std::vector< std::string > | filenames |
| static std::unordered_map< std::string, Variable > | allocated |
| heap-allocated variables | |
| static std::unordered_map< std::string, Program * > | object_map |
| object name -> Program mapping | |
Complete MXVM program: instruction interpreter and native x64 code generator.
Extends Base with execution state (program counter, flags, stack) for interpretation, and a full set of code generation methods targeting x86-64 assembly (System V ABI for Linux/macOS, Win64 ABI for Windows).
|
private |
| mxvm::Program::Program | ( | ) |
Default constructor — initializes execution state (pc, flags, etc.).
Definition at line 96 of file icode.cpp.
References mxvm::Base::add_extern(), pc, and running.
Referenced by Program(), flatten(), flatten_external(), flatten_inc(), flatten_label(), getObjectByName(), isFunctionValid(), memoryDump(), and operator=().
| mxvm::Program::~Program | ( | ) |
Destructor — frees any heap-allocated variables.
Definition at line 144 of file icode.cpp.
References Col(), mxvm::debug_mode, mxvm::RuntimeFunction::handles, name, mx::Color::RED, and mxvm::Base::vars.
|
inlinenoexcept |
| void mxvm::Program::add_standard | ( | ) |
Register standard library runtime functions.
Definition at line 107 of file icode.cpp.
References mxvm::Base::add_variable(), name, and mxvm::Variable::setExtern().
Referenced by exec(), generateCode(), and x64_generateCode().
Add two variables and store the result in dest.
| dest | Destination variable |
| src1 | First operand |
| src2 | Second operand |
Definition at line 787 of file icode_exec.cpp.
References mxvm::Base::base, mxvm::Variable_Value::float_value, mxvm::Variable_Value::int_value, mxvm::Variable_Value::owns, mxvm::Variable_Value::ptr_value, mxvm::Variable::type, mxvm::Variable_Value::type, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, and mxvm::Variable::var_value.
Referenced by exec_add().
Create a temporary unnamed variable with the given type and value.
| type | Variable type |
| value | Initial value as string |
Definition at line 1972 of file icode_exec.cpp.
References mxvm::Variable_Value::float_value, mxvm::Variable_Value::int_value, mxvm::Variable_Value::str_value, mxvm::Variable::type, mxvm::Variable_Value::type, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::Variable::var_name, mxvm::VAR_STRING, and mxvm::Variable::var_value.
Referenced by exec_add(), exec_cmp(), exec_div(), exec_fcmp(), exec_mod(), exec_mul(), exec_print(), exec_string_print(), exec_sub(), mxvm_io_fprintf(), and variableFromOperand().
Divide src1 by src2 and store the result in dest.
Definition at line 841 of file icode_exec.cpp.
References mxvm::Variable_Value::float_value, mxvm::Variable_Value::int_value, mxvm::Variable::type, mxvm::Variable_Value::type, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, and mxvm::Variable::var_value.
Referenced by exec_div().
|
static |
Escape newline characters in a string literal for assembly output.
| text | Raw string |
Definition at line 296 of file icode.cpp.
References result.
Referenced by generateCode(), memoryDump(), mxvm::Parser::printObjectHTML(), and x64_generateCode().
| int mxvm::Program::exec | ( | ) |
Execute the program via the interpreter.
Definition at line 122 of file icode_exec.cpp.
References ADD, add_standard(), ALLOC, AND, CALL, CMP, DIV, DONE, exec_add(), exec_alloc(), exec_and(), exec_call(), exec_cmp(), exec_div(), exec_done(), exec_exit(), exec_fcmp(), exec_free(), exec_getline(), exec_invoke(), exec_ja(), exec_jae(), exec_jb(), exec_jbe(), exec_jc(), exec_je(), exec_jg(), exec_jge(), exec_jl(), exec_jle(), exec_jmp(), exec_jnc(), exec_jne(), exec_jno(), exec_jnp(), exec_jns(), exec_jnz(), exec_jo(), exec_jp(), exec_js(), exec_jz(), exec_lea(), exec_load(), exec_mod(), exec_mov(), exec_mul(), exec_neg(), exec_not(), exec_or(), exec_pop(), exec_print(), exec_push(), exec_realloc(), exec_ret(), exec_return(), exec_stack_load(), exec_stack_store(), exec_stack_sub(), exec_store(), exec_string_print(), exec_sub(), exec_to_float(), exec_to_int(), exec_xor(), EXIT, FCMP, FREE, getExitCode(), GETLINE, mxvm::Base::inc, mxvm::instruct_mode, mxvm::Instruction::instruction, INVOKE, JA, JAE, JB, JBE, JC, JE, JG, JGE, JL, JLE, JMP, JNC, JNE, JNO, JNP, JNS, JNZ, JO, JP, JS, JZ, LEA, LOAD, MOD, MOV, MUL, NEG, NOT, OR, pc, POP, PRINT, PUSH, REALLOC, RET, RETURN, running, STACK_LOAD, STACK_STORE, STACK_SUB, STORE, STRING_PRINT, SUB, TO_FLOAT, TO_INT, and XOR.
| void mxvm::Program::exec_add | ( | const Instruction & | instr | ) |
Definition at line 383 of file icode_exec.cpp.
References addVariables(), createTempVariable(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, mxvm::Variable::type, mxvm::VAR_INTEGER, and mxvm::VAR_POINTER.
Referenced by exec().
| void mxvm::Program::exec_alloc | ( | const Instruction & | instr | ) |
Definition at line 1170 of file icode_exec.cpp.
References getVariable(), mxvm::Variable_Value::int_value, isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, mxvm::Variable_Value::owns, mxvm::Variable_Value::ptr_count, mxvm::Variable_Value::ptr_size, mxvm::Variable_Value::ptr_value, mxvm::releaseOwnedPointer(), mxvm::Variable::type, mxvm::Variable_Value::type, mxvm::VAR_POINTER, and mxvm::Variable::var_value.
Referenced by exec().
| void mxvm::Program::exec_and | ( | const Instruction & | instr | ) |
Definition at line 1119 of file icode_exec.cpp.
References getVariable(), mxvm::Variable_Value::int_value, isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, mxvm::Variable_Value::type, mxvm::VAR_INTEGER, and mxvm::Variable::var_value.
Referenced by exec().
| void mxvm::Program::exec_call | ( | const Instruction & | instr | ) |
Definition at line 1759 of file icode_exec.cpp.
References mxvm::Base::labels, mxvm::Operand::op, mxvm::Instruction::op1, pc, and stack.
Referenced by exec().
| void mxvm::Program::exec_cmp | ( | const Instruction & | instr | ) |
Definition at line 532 of file icode_exec.cpp.
References createTempVariable(), mxvm::Variable_Value::float_value, getVariable(), greater_flag, mxvm::Variable_Value::int_value, isVariable(), less_flag, mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Variable_Value::ptr_value, mxvm::Variable::toString(), mxvm::Variable::type, mxvm::VAR_BYTE, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, mxvm::Variable::var_value, and zero_flag.
Referenced by exec().
| void mxvm::Program::exec_div | ( | const Instruction & | instr | ) |
Definition at line 496 of file icode_exec.cpp.
References createTempVariable(), divVariables(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, and mxvm::Variable::type.
Referenced by exec().
| void mxvm::Program::exec_done | ( | const Instruction & | instr | ) |
Definition at line 1783 of file icode_exec.cpp.
References exitCode, and stop().
Referenced by exec().
| void mxvm::Program::exec_exit | ( | const Instruction & | instr | ) |
Definition at line 668 of file icode_exec.cpp.
References exitCode, getVariable(), mxvm::Variable_Value::int_value, isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, stop(), and mxvm::Variable::var_value.
Referenced by exec().
| void mxvm::Program::exec_fcmp | ( | const Instruction & | instr | ) |
Definition at line 2132 of file icode_exec.cpp.
References createTempVariable(), mxvm::Variable_Value::float_value, getVariable(), greater_flag, mxvm::Variable_Value::int_value, isVariable(), less_flag, mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Variable::type, mxvm::VAR_BYTE, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::Variable::var_value, and zero_flag.
Referenced by exec().
| void mxvm::Program::exec_free | ( | const Instruction & | instr | ) |
Definition at line 1207 of file icode_exec.cpp.
References getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Variable_Value::owns, mxvm::Variable_Value::ptr_count, mxvm::Variable_Value::ptr_size, mxvm::Variable_Value::ptr_value, mxvm::Variable::type, mxvm::VAR_POINTER, mxvm::Variable::var_value, and mxvm::Base::vars.
Referenced by exec().
| void mxvm::Program::exec_getline | ( | const Instruction & | instr | ) |
Definition at line 1561 of file icode_exec.cpp.
References getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Variable_Value::str_value, mxvm::Variable::type, mxvm::Variable_Value::type, mxvm::VAR_STRING, and mxvm::Variable::var_value.
Referenced by exec().
| void mxvm::Program::exec_invoke | ( | const Instruction & | instr | ) |
Definition at line 2056 of file icode_exec.cpp.
References args, mxvm::Base::external_functions, getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, mxvm::OP_CONSTANT, mxvm::Variable_Value::ptr_value, result, mxvm::Variable::type, mxvm::VAR_EXTERN, mxvm::VAR_POINTER, mxvm::Variable::var_value, and mxvm::Instruction::vop.
Referenced by exec().
| void mxvm::Program::exec_ja | ( | const Instruction & | instr | ) |
Definition at line 1384 of file icode_exec.cpp.
References exec_jmp(), greater_flag, and pc.
Referenced by exec().
| void mxvm::Program::exec_jae | ( | const Instruction & | instr | ) |
Definition at line 2180 of file icode_exec.cpp.
References exec_jmp(), greater_flag, pc, and zero_flag.
Referenced by exec().
| void mxvm::Program::exec_jb | ( | const Instruction & | instr | ) |
Definition at line 1391 of file icode_exec.cpp.
References exec_jmp(), less_flag, and pc.
Referenced by exec().
| void mxvm::Program::exec_jbe | ( | const Instruction & | instr | ) |
Definition at line 2187 of file icode_exec.cpp.
References exec_jmp(), less_flag, pc, and zero_flag.
Referenced by exec().
| void mxvm::Program::exec_jc | ( | const Instruction & | instr | ) |
Definition at line 2194 of file icode_exec.cpp.
References carry_flag, exec_jmp(), and pc.
Referenced by exec().
| void mxvm::Program::exec_je | ( | const Instruction & | instr | ) |
Definition at line 1328 of file icode_exec.cpp.
References exec_jmp(), pc, and zero_flag.
Referenced by exec().
| void mxvm::Program::exec_jg | ( | const Instruction & | instr | ) |
Definition at line 1356 of file icode_exec.cpp.
References exec_jmp(), greater_flag, and pc.
Referenced by exec().
| void mxvm::Program::exec_jge | ( | const Instruction & | instr | ) |
Definition at line 1363 of file icode_exec.cpp.
References exec_jmp(), greater_flag, pc, and zero_flag.
Referenced by exec().
| void mxvm::Program::exec_jl | ( | const Instruction & | instr | ) |
Definition at line 1342 of file icode_exec.cpp.
References exec_jmp(), less_flag, and pc.
Referenced by exec().
| void mxvm::Program::exec_jle | ( | const Instruction & | instr | ) |
Definition at line 1349 of file icode_exec.cpp.
References exec_jmp(), less_flag, pc, and zero_flag.
Referenced by exec().
| void mxvm::Program::exec_jmp | ( | const Instruction & | instr | ) |
Definition at line 622 of file icode_exec.cpp.
References mxvm::Base::labels, mxvm::Operand::op, mxvm::Instruction::op1, and pc.
Referenced by exec(), exec_ja(), exec_jae(), exec_jb(), exec_jbe(), exec_jc(), exec_je(), exec_jg(), exec_jge(), exec_jl(), exec_jle(), exec_jnc(), exec_jne(), exec_jno(), exec_jnp(), exec_jns(), exec_jnz(), and exec_jz().
| void mxvm::Program::exec_jnc | ( | const Instruction & | instr | ) |
Definition at line 2201 of file icode_exec.cpp.
References carry_flag, exec_jmp(), and pc.
Referenced by exec().
| void mxvm::Program::exec_jne | ( | const Instruction & | instr | ) |
Definition at line 1335 of file icode_exec.cpp.
References exec_jmp(), pc, and zero_flag.
Referenced by exec().
| void mxvm::Program::exec_jno | ( | const Instruction & | instr | ) |
| void mxvm::Program::exec_jnp | ( | const Instruction & | instr | ) |
| void mxvm::Program::exec_jns | ( | const Instruction & | instr | ) |
| void mxvm::Program::exec_jnz | ( | const Instruction & | instr | ) |
Definition at line 1377 of file icode_exec.cpp.
References exec_jmp(), pc, and zero_flag.
Referenced by exec().
| void mxvm::Program::exec_jo | ( | const Instruction & | instr | ) |
| void mxvm::Program::exec_jp | ( | const Instruction & | instr | ) |
| void mxvm::Program::exec_js | ( | const Instruction & | instr | ) |
| void mxvm::Program::exec_jz | ( | const Instruction & | instr | ) |
Definition at line 1370 of file icode_exec.cpp.
References exec_jmp(), pc, and zero_flag.
Referenced by exec().
| void mxvm::Program::exec_lea | ( | const Instruction & | instr | ) |
Definition at line 1234 of file icode_exec.cpp.
References mxvm::Variable_Value::float_value, getVariable(), mxvm::Variable_Value::int_value, isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Variable_Value::owns, mxvm::Variable_Value::ptr_count, mxvm::Variable_Value::ptr_size, mxvm::Variable_Value::ptr_value, mxvm::Variable::type, mxvm::Variable_Value::type, mxvm::VAR_BYTE, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, and mxvm::Variable::var_value.
Referenced by exec().
| void mxvm::Program::exec_load | ( | const Instruction & | instr | ) |
Definition at line 864 of file icode_exec.cpp.
References mxvm::Base::base, mxvm::Variable_Value::float_value, getVariable(), mxvm::Variable_Value::int_value, isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, mxvm::Variable_Value::owns, mxvm::Variable_Value::ptr_count, mxvm::Variable_Value::ptr_size, mxvm::Variable_Value::ptr_value, mxvm::Variable_Value::str_value, mxvm::Variable::type, mxvm::Variable_Value::type, mxvm::VAR_BYTE, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, mxvm::VAR_STRING, mxvm::Variable::var_value, and mxvm::Instruction::vop.
Referenced by exec().
| void mxvm::Program::exec_mod | ( | const Instruction & | instr | ) |
Definition at line 1281 of file icode_exec.cpp.
References createTempVariable(), mxvm::Variable_Value::float_value, getVariable(), mxvm::Variable_Value::int_value, isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, mxvm::Variable::type, mxvm::Variable_Value::type, mxvm::VAR_BYTE, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, and mxvm::Variable::var_value.
Referenced by exec().
| void mxvm::Program::exec_mov | ( | const Instruction & | instr | ) |
Definition at line 316 of file icode_exec.cpp.
References mxvm::Variable_Value::float_value, getVariable(), mxvm::Variable_Value::int_value, isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Variable_Value::owns, mxvm::Variable_Value::ptr_count, mxvm::Variable_Value::ptr_size, mxvm::Variable_Value::ptr_value, mxvm::releaseOwnedPointer(), setVariableFromConstant(), mxvm::Variable::type, mxvm::Variable_Value::type, mxvm::VAR_EXTERN, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, mxvm::Variable::var_value, and mxvm::Base::vars.
Referenced by exec().
| void mxvm::Program::exec_mul | ( | const Instruction & | instr | ) |
Definition at line 460 of file icode_exec.cpp.
References createTempVariable(), getVariable(), isVariable(), mulVariables(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, and mxvm::Variable::type.
Referenced by exec().
| void mxvm::Program::exec_neg | ( | const Instruction & | instr | ) |
Definition at line 1885 of file icode_exec.cpp.
References mxvm::Variable_Value::float_value, getVariable(), mxvm::Variable_Value::int_value, isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Variable::type, mxvm::VAR_BYTE, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, and mxvm::Variable::var_value.
Referenced by exec().
| void mxvm::Program::exec_not | ( | const Instruction & | instr | ) |
Definition at line 1269 of file icode_exec.cpp.
References getVariable(), mxvm::Variable_Value::int_value, isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Variable_Value::type, mxvm::VAR_INTEGER, and mxvm::Variable::var_value.
Referenced by exec().
| void mxvm::Program::exec_or | ( | const Instruction & | instr | ) |
Definition at line 1136 of file icode_exec.cpp.
References getVariable(), mxvm::Variable_Value::int_value, isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, mxvm::Variable_Value::type, mxvm::VAR_INTEGER, and mxvm::Variable::var_value.
Referenced by exec().
| void mxvm::Program::exec_pop | ( | const Instruction & | instr | ) |
Execute a POP instruction — restore a value from the VM stack into a variable.
Matches the pushed type via std::holds_alternative and writes back into the correct union member. Float variables are restored from std::get<double> to preserve IEEE 754 representation.
| instr | Instruction whose op1 is the destination variable. |
Definition at line 1621 of file icode_exec.cpp.
References mxvm::Variable_Value::float_value, getVariable(), mxvm::Variable_Value::int_value, isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Variable_Value::ptr_value, stack, mxvm::Variable_Value::str_value, mxvm::Variable::type, mxvm::Variable_Value::type, mxvm::VAR_BYTE, mxvm::VAR_EXTERN, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, mxvm::VAR_STRING, and mxvm::Variable::var_value.
Referenced by exec().
| void mxvm::Program::exec_print | ( | const Instruction & | instr | ) |
Definition at line 631 of file icode_exec.cpp.
References args, createTempVariable(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, mxvm::OP_VARIABLE, printFormatted(), mxvm::Variable_Value::str_value, mxvm::Operand::type, mxvm::Variable::type, mxvm::VAR_INTEGER, mxvm::VAR_STRING, mxvm::Variable::var_value, and mxvm::Instruction::vop.
Referenced by exec().
| void mxvm::Program::exec_push | ( | const Instruction & | instr | ) |
Execute a PUSH instruction — save a variable or constant onto the VM stack.
Handles integer/byte, pointer/extern, float, and string variable types. Float variables are pushed as native doubles so that POP can restore them correctly using std::get<double>.
| instr | Instruction whose op1 is the value to push. |
Definition at line 1588 of file icode_exec.cpp.
References mxvm::Variable_Value::float_value, getVariable(), mxvm::Variable_Value::int_value, isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Variable_Value::ptr_value, stack, mxvm::Variable_Value::str_value, mxvm::Variable_Value::type, mxvm::VAR_BYTE, mxvm::VAR_EXTERN, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, mxvm::VAR_STRING, and mxvm::Variable::var_value.
Referenced by exec().
| void mxvm::Program::exec_realloc | ( | const Instruction & | instr | ) |
Execute the REALLOC instruction in the interpreter.
Execute the REALLOC instruction.
Resizes the memory block pointed to by the destination variable. Operands: dest (pointer var), elemSize, count. Zero-initialises any newly allocated bytes beyond the old allocation. A count of zero frees the block.
Resizes the heap block of a pointer variable using C realloc(). Operands: op1 = destination ptr variable, op2 = element size, op3 = new element count. Zero-fills newly allocated bytes. A count of zero frees the block.
Definition at line 1910 of file icode_exec.cpp.
References getVariable(), mxvm::Variable_Value::int_value, isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, mxvm::Variable_Value::owns, mxvm::Variable_Value::ptr_count, mxvm::Variable_Value::ptr_size, mxvm::Variable_Value::ptr_value, mxvm::Variable::type, mxvm::Variable_Value::type, mxvm::VAR_POINTER, and mxvm::Variable::var_value.
Referenced by exec().
| void mxvm::Program::exec_ret | ( | const Instruction & | instr | ) |
| void mxvm::Program::exec_return | ( | const Instruction & | instr | ) |
Definition at line 1872 of file icode_exec.cpp.
References getVariable(), isVariable(), name, mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Variable_Value::owns, mxvm::releaseOwnedPointer(), result, mxvm::Variable::type, mxvm::Variable::var_name, mxvm::VAR_POINTER, and mxvm::Variable::var_value.
Referenced by exec().
| void mxvm::Program::exec_stack_load | ( | const Instruction & | instr | ) |
Definition at line 1661 of file icode_exec.cpp.
References mxvm::Variable_Value::float_value, getVariable(), mxvm::Variable_Value::int_value, isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Variable_Value::ptr_value, stack, mxvm::Variable_Value::str_value, mxvm::Variable::type, mxvm::Variable_Value::type, mxvm::VAR_BYTE, mxvm::VAR_EXTERN, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, mxvm::VAR_STRING, and mxvm::Variable::var_value.
Referenced by exec().
| void mxvm::Program::exec_stack_store | ( | const Instruction & | instr | ) |
Definition at line 1710 of file icode_exec.cpp.
References mxvm::Variable_Value::float_value, getVariable(), mxvm::Variable_Value::int_value, isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Variable_Value::ptr_value, stack, mxvm::Variable_Value::str_value, mxvm::Variable::type, mxvm::VAR_BYTE, mxvm::VAR_EXTERN, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, mxvm::VAR_STRING, and mxvm::Variable::var_value.
Referenced by exec().
| void mxvm::Program::exec_stack_sub | ( | const Instruction & | instr | ) |
Definition at line 1742 of file icode_exec.cpp.
References getVariable(), mxvm::Variable_Value::int_value, isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, stack, and mxvm::Variable::var_value.
Referenced by exec().
| void mxvm::Program::exec_store | ( | const Instruction & | instr | ) |
Execute a STORE instruction — write a value into a pointer at a given offset.
Supports integer, float, pointer, byte, and string source types. For constants the full 8-byte integer representation is always stored, regardless of the stride operand, to prevent partial-write corruption when storing values larger than one byte.
| instr | Instruction with op1 = source, op2 = destination pointer, op3 = index, vop[0] = stride. |
Definition at line 1008 of file icode_exec.cpp.
References mxvm::Base::base, mxvm::Variable_Value::float_value, getVariable(), mxvm::Variable_Value::int_value, isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, mxvm::OP_CONSTANT, mxvm::Variable_Value::owns, mxvm::Variable_Value::ptr_count, mxvm::Variable_Value::ptr_size, mxvm::Variable_Value::ptr_value, mxvm::Variable_Value::str_value, mxvm::Operand::type, mxvm::Variable::type, mxvm::VAR_BYTE, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::Variable::var_name, mxvm::VAR_POINTER, mxvm::VAR_STRING, mxvm::Variable::var_value, and mxvm::Instruction::vop.
Referenced by exec().
| void mxvm::Program::exec_string_print | ( | const Instruction & | instr | ) |
Definition at line 1398 of file icode_exec.cpp.
References args, createTempVariable(), mxvm::Variable_Value::float_value, getVariable(), mxvm::Variable_Value::int_value, isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, mxvm::OP_VARIABLE, mxvm::Variable_Value::ptr_value, mxvm::Variable_Value::str_value, mxvm::Operand::type, mxvm::Variable::type, mxvm::Variable_Value::type, mxvm::VAR_BYTE, mxvm::VAR_EXTERN, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, mxvm::VAR_STRING, mxvm::Variable::var_value, and mxvm::Instruction::vop.
Referenced by exec().
| void mxvm::Program::exec_sub | ( | const Instruction & | instr | ) |
Definition at line 421 of file icode_exec.cpp.
References createTempVariable(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, subVariables(), mxvm::Variable::type, mxvm::VAR_INTEGER, and mxvm::VAR_POINTER.
Referenced by exec().
| void mxvm::Program::exec_to_float | ( | const Instruction & | instr | ) |
Definition at line 1814 of file icode_exec.cpp.
References mxvm::Variable_Value::float_value, getVariable(), mxvm::Variable_Value::int_value, isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Variable_Value::ptr_value, mxvm::Variable_Value::str_value, mxvm::Variable::type, mxvm::Variable_Value::type, mxvm::VAR_BYTE, mxvm::VAR_EXTERN, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, mxvm::VAR_STRING, and mxvm::Variable::var_value.
Referenced by exec().
| void mxvm::Program::exec_to_int | ( | const Instruction & | instr | ) |
Definition at line 1788 of file icode_exec.cpp.
References mxvm::Variable_Value::float_value, getVariable(), mxvm::Variable_Value::int_value, isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Variable_Value::str_value, mxvm::Variable::type, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_STRING, and mxvm::Variable::var_value.
Referenced by exec().
| void mxvm::Program::exec_xor | ( | const Instruction & | instr | ) |
Definition at line 1153 of file icode_exec.cpp.
References getVariable(), mxvm::Variable_Value::int_value, isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, mxvm::Variable_Value::type, mxvm::VAR_INTEGER, and mxvm::Variable::var_value.
Referenced by exec().
| void mxvm::Program::flatten | ( | Program * | program | ) |
Flatten child object programs into the root instruction stream.
| program | Root program to merge into |
Definition at line 102 of file icode_exec.cpp.
References Program(), mxvm::Base::external_functions, flatten_external(), flatten_inc(), flatten_label(), mxvm::Base::inc, mxvm::Base::labels, and objects.
| void mxvm::Program::flatten_external | ( | Program * | root, |
| const std::string & | e, | ||
| RuntimeFunction & | r ) |
Copy an external function binding from a child object into the root.
| root | Root program |
| e | External function name |
| r | Resolved RuntimeFunction binding |
Definition at line 96 of file icode_exec.cpp.
References Program(), and mxvm::Base::external_functions.
Referenced by flatten().
| void mxvm::Program::flatten_inc | ( | Program * | root, |
| Instruction & | i ) |
Rewrite object-qualified operand references in a single instruction.
| root | Root program owning the merged instruction stream |
| i | Instruction to rewrite (modified in place) |
Definition at line 27 of file icode_exec.cpp.
References Program(), mxvm::Base::add_instruction(), CALL, mxvm::Instruction::instruction, JA, JB, JE, JG, JGE, JL, JLE, JMP, JNE, JNZ, JZ, mxvm::Base::labels, name, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, mxvm::OP_VARIABLE, mxvm::Base::vars, and mxvm::Instruction::vop.
Referenced by flatten().
| void mxvm::Program::flatten_label | ( | Program * | root, |
| int64_t | offset, | ||
| const std::string & | label, | ||
| bool | func ) |
Copy a label from a child object into the root label map with an address offset.
| root | Root program |
| offset | Instruction index offset |
| label | Label name |
| func | true if the label is a function entry |
Definition at line 87 of file icode_exec.cpp.
References Program(), mxvm::Base::add_label(), and name.
Referenced by flatten().
| void mxvm::Program::gen_add | ( | std::ostream & | out, |
| const Instruction & | i ) |
| void mxvm::Program::gen_alloc | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 661 of file icode_gen.cpp.
References mxvm::error_label_count, getMangledName(), getPlatformSymbolName(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, mxvm::OP_CONSTANT, mxvm::Variable_Value::owns, sysv_emitLoadVar(), mxvm::Operand::type, mxvm::Variable::type, mxvm::VAR_POINTER, and mxvm::Variable::var_value.
Referenced by generateInstruction().
| void mxvm::Program::gen_arth | ( | std::ostream & | out, |
| std::string | arth, | ||
| const Instruction & | i ) |
Definition at line 1944 of file icode_gen.cpp.
References generateLoadVar(), getMangledName(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, mxvm::OP_CONSTANT, sysv_emitStoreVar(), sysv_reg_vars, mxvm::Variable::type, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, and mxvm::VAR_POINTER.
Referenced by generateInstruction().
| void mxvm::Program::gen_bitop | ( | std::ostream & | out, |
| const std::string & | opc, | ||
| const Instruction & | i ) |
Definition at line 1302 of file icode_gen.cpp.
References generateLoadVar(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, sysv_emitStoreVar(), mxvm::Variable::type, and mxvm::VAR_INTEGER.
Referenced by generateInstruction().
| void mxvm::Program::gen_call | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 638 of file icode_gen.cpp.
References getMangledName(), getPlatformSymbolName(), getVariable(), isFunctionValid(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, sysv_emitFlushRegs(), sysv_emitLoadVar(), sysv_emitReloadRegs(), and mxvm::VAR_INTEGER.
Referenced by generateInstruction().
| void mxvm::Program::gen_cmp | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1749 of file icode_gen.cpp.
References CMP_FLOAT, CMP_INTEGER, generateLoadVar(), getMangledName(), getVariable(), isVariable(), last_cmp_type, mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::OP_CONSTANT, sysv_reg_vars, mxvm::Operand::type, mxvm::Variable::type, mxvm::VAR_BYTE, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, and mxvm::VAR_POINTER.
Referenced by generateInstruction().
| void mxvm::Program::gen_div | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1155 of file icode_gen.cpp.
References generateLoadVar(), getMangledName(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, sysv_emitStoreVar(), mxvm::Variable::type, mxvm::VAR_FLOAT, and mxvm::VAR_INTEGER.
Referenced by generateInstruction().
| void mxvm::Program::gen_done | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 475 of file icode_gen.cpp.
References mxvm::Base::external, getPlatformSymbolName(), sysv_emitFlushRegs(), and sysv_emitRestoreRegs().
Referenced by generateInstruction().
| void mxvm::Program::gen_exit | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 2002 of file icode_gen.cpp.
References mxvm::Base::external, generateFunctionCall(), getPlatformSymbolName(), mxvm::Operand::op, and mxvm::Instruction::op1.
Referenced by generateInstruction().
| void mxvm::Program::gen_fcmp | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1793 of file icode_gen.cpp.
References CMP_FLOAT, generateLoadVar(), last_cmp_type, mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, and mxvm::VAR_FLOAT.
Referenced by generateInstruction().
| void mxvm::Program::gen_free | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1013 of file icode_gen.cpp.
References getMangledName(), getPlatformSymbolName(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Variable_Value::owns, mxvm::Variable::type, mxvm::VAR_POINTER, and mxvm::Variable::var_value.
Referenced by generateInstruction().
| void mxvm::Program::gen_getline | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1271 of file icode_gen.cpp.
References mxvm::Variable_Value::buffer_size, getMangledName(), getPlatformSymbolName(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Variable::type, mxvm::VAR_STRING, and mxvm::Variable::var_value.
Referenced by generateInstruction().
| void mxvm::Program::gen_invoke | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 574 of file icode_gen.cpp.
References generateInvokeCall(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, and mxvm::Instruction::vop.
Referenced by generateInstruction().
| void mxvm::Program::gen_jae | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1804 of file icode_gen.cpp.
References mxvm::Operand::op, and mxvm::Instruction::op1.
Referenced by generateInstruction().
| void mxvm::Program::gen_jbe | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1808 of file icode_gen.cpp.
References mxvm::Operand::op, and mxvm::Instruction::op1.
Referenced by generateInstruction().
| void mxvm::Program::gen_jc | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1812 of file icode_gen.cpp.
References mxvm::Operand::op, and mxvm::Instruction::op1.
Referenced by generateInstruction().
| void mxvm::Program::gen_jmp | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1698 of file icode_gen.cpp.
References CMP_FLOAT, mxvm::Instruction::instruction, JA, JB, JE, JG, JGE, JL, JLE, JMP, JNE, JNZ, JZ, mxvm::Base::labels, last_cmp_type, mxvm::Operand::op, mxvm::Instruction::op1, and pos().
Referenced by generateInstruction().
| void mxvm::Program::gen_jnc | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1816 of file icode_gen.cpp.
References mxvm::Operand::op, and mxvm::Instruction::op1.
Referenced by generateInstruction().
| void mxvm::Program::gen_jno | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1832 of file icode_gen.cpp.
References mxvm::Operand::op, and mxvm::Instruction::op1.
Referenced by generateInstruction().
| void mxvm::Program::gen_jnp | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1824 of file icode_gen.cpp.
References mxvm::Operand::op, and mxvm::Instruction::op1.
Referenced by generateInstruction().
| void mxvm::Program::gen_jns | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1840 of file icode_gen.cpp.
References mxvm::Operand::op, and mxvm::Instruction::op1.
Referenced by generateInstruction().
| void mxvm::Program::gen_jo | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1828 of file icode_gen.cpp.
References mxvm::Operand::op, and mxvm::Instruction::op1.
Referenced by generateInstruction().
| void mxvm::Program::gen_jp | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1820 of file icode_gen.cpp.
References mxvm::Operand::op, and mxvm::Instruction::op1.
Referenced by generateInstruction().
| void mxvm::Program::gen_js | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1836 of file icode_gen.cpp.
References mxvm::Operand::op, and mxvm::Instruction::op1.
Referenced by generateInstruction().
| void mxvm::Program::gen_lea | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 557 of file icode_gen.cpp.
References getMangledName(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Variable_Value::owns, sysv_reg_vars, and mxvm::Variable::var_value.
Referenced by generateInstruction().
| void mxvm::Program::gen_load | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 768 of file icode_gen.cpp.
References getMangledName(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, sysv_emitFlushRegs(), sysv_emitLoadVar(), sysv_emitStoreVar(), mxvm::Variable::type, mxvm::VAR_BYTE, mxvm::VAR_EXTERN, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, mxvm::VAR_STRING, and mxvm::Instruction::vop.
Referenced by generateInstruction().
| void mxvm::Program::gen_mod | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1225 of file icode_gen.cpp.
References generateLoadVar(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, sysv_emitStoreVar(), mxvm::Variable::type, and mxvm::VAR_INTEGER.
Referenced by generateInstruction().
| void mxvm::Program::gen_mov | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1844 of file icode_gen.cpp.
References getMangledName(), getPlatformSymbolName(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::OP_CONSTANT, sysv_emitLoadVar(), sysv_emitStoreVar(), sysv_emitStoreVarImm(), mxvm::Operand::type, mxvm::Variable::type, mxvm::VAR_BYTE, mxvm::VAR_EXTERN, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, and mxvm::VAR_STRING.
Referenced by generateInstruction().
| void mxvm::Program::gen_mul | ( | std::ostream & | out, |
| const Instruction & | i ) |
References platform.
| void mxvm::Program::gen_neg | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 537 of file icode_gen.cpp.
References generateLoadVar(), getMangledName(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, sysv_emitStoreVar(), mxvm::Variable::type, mxvm::VAR_FLOAT, and mxvm::VAR_INTEGER.
Referenced by generateInstruction().
| void mxvm::Program::gen_not | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1334 of file icode_gen.cpp.
References generateLoadVar(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, sysv_emitStoreVar(), mxvm::Variable::type, and mxvm::VAR_INTEGER.
Referenced by generateInstruction().
| std::string mxvm::Program::gen_optimize | ( | const std::string & | code, |
| const Platform & | platform ) |
Peephole optimizer for generated assembly.
Apply peephole optimizations to generated assembly
| code | Raw assembly text |
| platform | Target platform (affects optimization rules) |
Definition at line 496 of file icode_opt.cpp.
References mxvm::DARWIN, mxvm::join_lines(), mxvm::opt_core_lines(), mxvm::opt_darwin_lines(), mxvm::opt_linux_lines(), mxvm::opt_x64_windows_lines(), mxvm::WINX64, and mxvm::x64_opt_core_lines().
| void mxvm::Program::gen_pop | ( | std::ostream & | out, |
| const Instruction & | i ) |
Emit x86-64 POP into a variable.
Handles integer (popq + store), pointer/extern (popq + movq), and float variables. Floating-point values are popped via movsd (rsp), xmm0; addq $8, rsp; movsd xmm0, var(rip) mirroring the SSE push sequence in gen_push().
| out | Assembly output stream. |
| i | Instruction whose op1 is the destination variable. |
Definition at line 1400 of file icode_gen.cpp.
References getMangledName(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, sysv_emitStoreVar(), mxvm::Variable::type, mxvm::VAR_EXTERN, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, and mxvm::VAR_POINTER.
Referenced by generateInstruction().
| void mxvm::Program::gen_print | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1644 of file icode_gen.cpp.
References args, generateLoadVar(), getMangledName(), getPlatformSymbolName(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, mxvm::Variable::type, mxvm::VAR_FLOAT, mxvm::Instruction::vop, and xmm_offset.
Referenced by generateInstruction().
| void mxvm::Program::gen_push | ( | std::ostream & | out, |
| const Instruction & | i ) |
Emit x86-64 PUSH for a variable or constant.
Handles integer/pointer (pushq), string (lea+pushq), and float variables. Floating-point values are pushed via movsd var(rip), xmm0; subq $8, rsp; movsd xmm0, (rsp) since x86 PUSH cannot operate directly on XMM registers.
| out | Assembly output stream. |
| i | Instruction whose op1 is the value to push. |
Definition at line 1365 of file icode_gen.cpp.
References getMangledName(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::OP_CONSTANT, sysv_emitLoadVar(), mxvm::Operand::type, mxvm::Variable::type, mxvm::VAR_EXTERN, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, and mxvm::VAR_STRING.
Referenced by generateInstruction().
| void mxvm::Program::gen_realloc | ( | std::ostream & | out, |
| const Instruction & | i ) |
Generate System V x86-64 assembly for the REALLOC instruction (dynamic array resize).
Generate System V x86-64 native code for REALLOC.
Computes total = count * elemSize, calls C realloc() with the existing pointer and new size, and stores the result back. Stack is 16-byte aligned around the call. Registers are flushed/reloaded via sysv_emitFlushRegs / sysv_emitReloadRegs.
Definition at line 715 of file icode_gen.cpp.
References mxvm::error_label_count, getMangledName(), getPlatformSymbolName(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, mxvm::Variable_Value::owns, sysv_emitFlushRegs(), sysv_emitLoadVar(), sysv_emitReloadRegs(), mxvm::Variable::type, mxvm::VAR_POINTER, and mxvm::Variable::var_value.
Referenced by generateInstruction().
| void mxvm::Program::gen_ret | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 505 of file icode_gen.cpp.
References getVariable(), isVariable(), mxvm::Operand::op, sysv_emitFlushRegs(), sysv_emitLoadVar(), sysv_emitRestoreRegs(), and mxvm::VAR_INTEGER.
Referenced by generateInstruction().
| void mxvm::Program::gen_return | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 518 of file icode_gen.cpp.
References getMangledName(), getVariable(), isVariable(), last_call_returns_owned_ptr, mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Variable_Value::owns, sysv_emitStoreVar(), mxvm::Variable::type, mxvm::VAR_FLOAT, and mxvm::Variable::var_value.
Referenced by generateInstruction().
| void mxvm::Program::gen_stack_load | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1420 of file icode_gen.cpp.
References generateLoadVar(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, sysv_emitStoreVar(), and mxvm::Variable::type.
Referenced by generateInstruction().
| void mxvm::Program::gen_stack_store | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1433 of file icode_gen.cpp.
References generateLoadVar(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, sysv_emitLoadVar(), and mxvm::Variable::type.
Referenced by generateInstruction().
| void mxvm::Program::gen_stack_sub | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1446 of file icode_gen.cpp.
References isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, and sysv_emitLoadVar().
Referenced by generateInstruction().
| void mxvm::Program::gen_store | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 891 of file icode_gen.cpp.
References mxvm::Variable_Value::buffer_size, getMangledName(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, sysv_emitFlushRegs(), sysv_emitLoadVar(), sysv_emitReloadRegs(), mxvm::Variable::type, mxvm::VAR_BYTE, mxvm::VAR_EXTERN, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, mxvm::VAR_STRING, mxvm::Variable::var_value, and mxvm::Instruction::vop.
Referenced by generateInstruction().
| void mxvm::Program::gen_sub | ( | std::ostream & | out, |
| const Instruction & | i ) |
| void mxvm::Program::gen_to_float | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1093 of file icode_gen.cpp.
References getMangledName(), getPlatformSymbolName(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::OP_CONSTANT, sysv_reg_vars, mxvm::Operand::type, mxvm::Variable::type, mxvm::VAR_BYTE, mxvm::VAR_EXTERN, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, and mxvm::VAR_STRING.
Referenced by generateInstruction().
| void mxvm::Program::gen_to_int | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1034 of file icode_gen.cpp.
References getMangledName(), getPlatformSymbolName(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::OP_CONSTANT, sysv_emitStoreVar(), sysv_reg_vars, mxvm::Operand::type, mxvm::Variable::type, mxvm::VAR_BYTE, mxvm::VAR_EXTERN, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, and mxvm::VAR_STRING.
Referenced by generateInstruction().
| void mxvm::Program::generateCode | ( | const Platform & | platform, |
| bool | obj, | ||
| std::ostream & | out ) |
Generate native x64 assembly for the entire program.
| platform | Target platform (Linux, Darwin, WinX64) |
| obj | true if generating as an object (no _start/main) |
| out | Output stream for the assembly |
Definition at line 120 of file icode_gen.cpp.
References add_standard(), mxvm::Base::base, mx::Color::BRIGHT_BLUE, mx::Color::BRIGHT_CYAN, Col(), mxvm::DARWIN, DONE, escapeNewLines(), mxvm::Base::external, generateInstruction(), getMangledName(), getPlatformSymbolName(), getVariable(), mxvm::Base::inc, mxvm::Instruction::instruction, isVariable(), mxvm::Base::labels, mxvm::LINUX, name, mxvm::Operand::op, platform, mxvm::Base::root_name, sysv_analyzeRegAlloc(), sysv_emitReloadRegs(), sysv_emitSaveRegs(), sysv_emitStoreVar(), mxvm::VAR_BYTE, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, mxvm::VAR_STRING, mxvm::Base::vars, mxvm::WINX64, and x64_generateCode().
| void mxvm::Program::generateFunctionCall | ( | std::ostream & | out, |
| const std::string & | name, | ||
| std::vector< Operand > & | op ) |
Generate a System V ABI function call with operands as arguments.
Definition at line 610 of file icode_gen.cpp.
References args, generateLoadVar(), getPlatformSymbolName(), name, mxvm::VAR_INTEGER, and xmm_offset.
Referenced by gen_exit(), and generateInvokeCall().
| void mxvm::Program::generateInstruction | ( | std::ostream & | out, |
| const Instruction & | i ) |
Dispatch a single instruction to its System V code generator.
| out | Assembly output stream |
| i | Instruction to generate code for |
Definition at line 321 of file icode_gen.cpp.
References ADD, ALLOC, AND, CALL, CMP, CMP_NONE, DIV, DONE, EXIT, FCMP, FREE, gen_alloc(), gen_arth(), gen_bitop(), gen_call(), gen_cmp(), gen_div(), gen_done(), gen_exit(), gen_fcmp(), gen_free(), gen_getline(), gen_invoke(), gen_jae(), gen_jbe(), gen_jc(), gen_jmp(), gen_jnc(), gen_jno(), gen_jnp(), gen_jns(), gen_jo(), gen_jp(), gen_js(), gen_lea(), gen_load(), gen_mod(), gen_mov(), gen_neg(), gen_not(), gen_pop(), gen_print(), gen_push(), gen_realloc(), gen_ret(), gen_return(), gen_stack_load(), gen_stack_store(), gen_stack_sub(), gen_store(), gen_to_float(), gen_to_int(), GETLINE, mxvm::Instruction::instruction, INVOKE, JA, JAE, JB, JBE, JC, JE, JG, JGE, JL, JLE, JMP, JNC, JNE, JNO, JNP, JNS, JNZ, JO, JP, JS, JZ, last_cmp_type, LEA, LOAD, MOD, MOV, MUL, NEG, NOT, OR, POP, PRINT, PUSH, REALLOC, RET, RETURN, STACK_LOAD, STACK_STORE, STACK_SUB, STORE, SUB, TO_FLOAT, TO_INT, and XOR.
Referenced by generateCode().
| void mxvm::Program::generateInvokeCall | ( | std::ostream & | out, |
| std::vector< Operand > & | op ) |
Generate a dynamic invoke call (runtime-resolved external function).
| out | Assembly output stream |
| op | Operand list: first is the function name, rest are arguments |
Definition at line 591 of file icode_gen.cpp.
References args, generateFunctionCall(), mxvm::isFunctionReturningOwnedPtr(), last_call_returns_owned_ptr, and name.
Referenced by gen_invoke().
| int mxvm::Program::generateLoadVar | ( | std::ostream & | out, |
| int | reg, | ||
| const Operand & | op ) |
Load a variable or constant into a numbered register.
| out | Assembly output stream |
| reg | Register index (0-based) |
| op | Operand to load |
Definition at line 1460 of file icode_gen.cpp.
References getMangledName(), getPlatformSymbolName(), getRegisterByIndex(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::OP_CONSTANT, mxvm::OP_VARIABLE, sysv_reg_vars, mxvm::Operand::type, mxvm::Variable::type, mxvm::VAR_BYTE, mxvm::VAR_EXTERN, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, and mxvm::VAR_STRING.
Referenced by gen_arth(), gen_bitop(), gen_cmp(), gen_div(), gen_fcmp(), gen_mod(), gen_neg(), gen_not(), gen_print(), gen_stack_load(), gen_stack_store(), and generateFunctionCall().
| int mxvm::Program::generateLoadVar | ( | std::ostream & | out, |
| VarType | type, | ||
| std::string | reg, | ||
| const Operand & | op ) |
Load a variable or constant into a named register.
| out | Assembly output stream |
| type | Expected variable type |
| reg | Target register name (e.g. "rax") |
| op | Operand to load |
Definition at line 1507 of file icode_gen.cpp.
References getMangledName(), getPlatformSymbolName(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::OP_CONSTANT, mxvm::OP_VARIABLE, sysv_reg_vars, mxvm::Operand::type, mxvm::Variable::type, mxvm::VAR_BYTE, mxvm::VAR_EXTERN, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, and mxvm::VAR_STRING.
|
inline |
| std::string mxvm::Program::getMangledName | ( | const Operand & | op | ) |
Mangle an operand's variable reference with its object prefix.
| op | Operand containing the variable reference |
Definition at line 55 of file icode.cpp.
References mxvm::Base::base, mxvm::DARWIN, getMangledName(), mxvm::Operand::label, mxvm::Base::labels, name, mxvm::Operand::object, mxvm::Operand::op, and platform.
| std::string mxvm::Program::getMangledName | ( | const std::string & | var | ) |
Mangle a variable name with its owning object prefix.
| var | Raw variable name |
Definition at line 22 of file icode.cpp.
References mxvm::DARWIN, getVariable(), isVariable(), mxvm::Variable::obj_name, and platform.
Referenced by gen_alloc(), gen_arth(), gen_call(), gen_cmp(), gen_div(), gen_free(), gen_getline(), gen_lea(), gen_load(), gen_mov(), gen_neg(), gen_pop(), gen_print(), gen_push(), gen_realloc(), gen_return(), gen_store(), gen_to_float(), gen_to_int(), generateCode(), generateLoadVar(), generateLoadVar(), getMangledName(), sysv_emitFlushRegs(), sysv_emitLoadVar(), sysv_emitReloadRegs(), sysv_emitStoreVar(), sysv_emitStoreVarImm(), x64_emitFlushRegs(), x64_emitLoadVar(), x64_emitReloadRegs(), x64_emitStoreVar(), x64_emitStoreVarImm(), x64_gen_alloc(), x64_gen_arth(), x64_gen_call(), x64_gen_cmp(), x64_gen_div(), x64_gen_free(), x64_gen_getline(), x64_gen_lea(), x64_gen_load(), x64_gen_mov(), x64_gen_neg(), x64_gen_push(), x64_gen_realloc(), x64_gen_store(), x64_gen_to_float(), x64_gen_to_int(), x64_generateCode(), x64_generateLoadVar(), and x64_generateLoadVar().
| Program * mxvm::Program::getObjectByName | ( | const std::string & | name | ) |
| std::string mxvm::Program::getPlatformSymbolName | ( | const std::string & | name | ) |
Mangle a symbol name with the platform prefix (e.g. _name for Darwin).
| name | Original symbol name |
Definition at line 14 of file icode_gen.cpp.
References mxvm::DARWIN, name, and platform.
Referenced by gen_alloc(), gen_call(), gen_done(), gen_exit(), gen_free(), gen_getline(), gen_mov(), gen_print(), gen_realloc(), gen_to_float(), gen_to_int(), generateCode(), generateFunctionCall(), generateLoadVar(), and generateLoadVar().
| std::string mxvm::Program::getRegisterByIndex | ( | int | index, |
| VarType | type ) |
Get the register name for a given index and variable type.
| index | Register index |
| type | Variable type (determines integer vs. XMM register) |
Definition at line 1634 of file icode_gen.cpp.
References mxvm::VAR_BYTE, mxvm::VAR_EXTERN, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, mxvm::VAR_STRING, and xmm_offset.
Referenced by generateLoadVar().
| Variable & mxvm::Program::getVariable | ( | const std::string & | name | ) |
Look up a variable by name, searching local scope then global.
| mx::Exception | if the variable is not found |
Definition at line 681 of file icode_exec.cpp.
References mxvm::Base::base, name, mxvm::Base::object_map, pos(), and mxvm::Base::vars.
Referenced by exec_add(), exec_alloc(), exec_and(), exec_cmp(), exec_div(), exec_exit(), exec_fcmp(), exec_free(), exec_getline(), exec_invoke(), exec_lea(), exec_load(), exec_mod(), exec_mov(), exec_mul(), exec_neg(), exec_not(), exec_or(), exec_pop(), exec_print(), exec_push(), exec_realloc(), exec_return(), exec_stack_load(), exec_stack_store(), exec_stack_sub(), exec_store(), exec_string_print(), exec_sub(), exec_to_float(), exec_to_int(), exec_xor(), gen_alloc(), gen_arth(), gen_bitop(), gen_call(), gen_cmp(), gen_div(), gen_free(), gen_getline(), gen_lea(), gen_load(), gen_mod(), gen_mov(), gen_neg(), gen_not(), gen_pop(), gen_print(), gen_push(), gen_realloc(), gen_ret(), gen_return(), gen_stack_load(), gen_stack_store(), gen_store(), gen_to_float(), gen_to_int(), generateCode(), generateLoadVar(), generateLoadVar(), getMangledName(), getStringFromVar(), mxvm_io_fclose(), mxvm_io_feof(), mxvm_io_fopen(), mxvm_io_fprintf(), mxvm_io_fputs(), mxvm_io_fread(), mxvm_io_fseek(), mxvm_io_fsize(), mxvm_io_fwrite(), mxvm_io_mxvm_fgets(), mxvm_io_rand_number(), mxvm_sdl_blit_surface(), mxvm_sdl_clear(), mxvm_sdl_create_render_target(), mxvm_sdl_create_renderer(), mxvm_sdl_create_rgb_surface(), mxvm_sdl_create_texture(), mxvm_sdl_create_window(), mxvm_sdl_delay(), mxvm_sdl_destroy_render_target(), mxvm_sdl_destroy_renderer(), mxvm_sdl_destroy_texture(), mxvm_sdl_destroy_window(), mxvm_sdl_draw_line(), mxvm_sdl_draw_point(), mxvm_sdl_draw_rect(), mxvm_sdl_draw_text(), mxvm_sdl_fill_rect(), mxvm_sdl_free_surface(), mxvm_sdl_free_wav(), mxvm_sdl_get_keyboard_state(), mxvm_sdl_get_mouse_state(), mxvm_sdl_get_relative_mouse_state(), mxvm_sdl_get_renderer_output_size(), mxvm_sdl_get_window_size(), mxvm_sdl_is_key_pressed(), mxvm_sdl_load_font(), mxvm_sdl_load_texture(), mxvm_sdl_load_texture_color_key(), mxvm_sdl_load_texture_color_key_rgb(), mxvm_sdl_load_wav(), mxvm_sdl_lock_texture(), mxvm_sdl_open_audio(), mxvm_sdl_pause_audio(), mxvm_sdl_present(), mxvm_sdl_present_scaled(), mxvm_sdl_present_stretched(), mxvm_sdl_queue_audio(), mxvm_sdl_render_texture(), mxvm_sdl_set_clipboard_text(), mxvm_sdl_set_draw_color(), mxvm_sdl_set_render_target(), mxvm_sdl_set_window_fullscreen(), mxvm_sdl_set_window_icon(), mxvm_sdl_set_window_position(), mxvm_sdl_set_window_title(), mxvm_sdl_show_cursor(), mxvm_sdl_unlock_texture(), mxvm_sdl_update_texture(), mxvm_std_abs(), mxvm_std_acos(), mxvm_std_argv(), mxvm_std_asin(), mxvm_std_atan(), mxvm_std_atan2(), mxvm_std_atof(), mxvm_std_atoi(), mxvm_std_calloc(), mxvm_std_ceil(), mxvm_std_cos(), mxvm_std_cosh(), mxvm_std_exit(), mxvm_std_exp(), mxvm_std_exp2(), mxvm_std_fabs(), mxvm_std_float_to_int(), mxvm_std_floor(), mxvm_std_fmod(), mxvm_std_hypot(), mxvm_std_int_to_float(), mxvm_std_isalpha(), mxvm_std_isdigit(), mxvm_std_isspace(), mxvm_std_log(), mxvm_std_log10(), mxvm_std_log2(), mxvm_std_malloc(), mxvm_std_memcmp(), mxvm_std_memcpy(), mxvm_std_memmove(), mxvm_std_memset(), mxvm_std_pow(), mxvm_std_release(), mxvm_std_round(), mxvm_std_set_program_args(), mxvm_std_sin(), mxvm_std_sinh(), mxvm_std_sqrt(), mxvm_std_srand(), mxvm_std_system(), mxvm_std_tan(), mxvm_std_tanh(), mxvm_std_tolower(), mxvm_std_toupper(), mxvm_std_trunc(), mxvm_string_copy(), mxvm_string_delete(), mxvm_string_insert(), mxvm_string_inttostr(), mxvm_string_snprintf(), mxvm_string_strat(), mxvm_string_strcmp(), mxvm_string_strfind(), mxvm_string_strlen(), mxvm_string_strncat(), mxvm_string_strncpy(), mxvm_string_substr(), sysv_analyzeRegAlloc(), variableFromOperand(), x64_analyzeRegAlloc(), x64_gen_alloc(), x64_gen_arth(), x64_gen_bitop(), x64_gen_call(), x64_gen_cmp(), x64_gen_div(), x64_gen_free(), x64_gen_getline(), x64_gen_lea(), x64_gen_load(), x64_gen_mod(), x64_gen_mov(), x64_gen_neg(), x64_gen_not(), x64_gen_pop(), x64_gen_push(), x64_gen_realloc(), x64_gen_ret(), x64_gen_return(), x64_gen_store(), x64_generateCode(), x64_generateFunctionCall(), x64_generateLoadVar(), and x64_generateLoadVar().
| bool mxvm::Program::isConstant | ( | const std::string & | value | ) |
Check whether a string represents a compile-time constant (number or quoted string).
| value | String to test |
| bool mxvm::Program::isFunctionValid | ( | const std::string & | label | ) |
Check whether a label exists and is marked as a function entry.
| label | Label name to check |
Definition at line 175 of file icode.cpp.
References Program(), mxvm::Base::labels, and mxvm::Base::object_map.
Referenced by gen_call(), and x64_gen_call().
| bool mxvm::Program::isVariable | ( | const std::string & | name | ) |
Check whether a variable exists in local or global scope.
Definition at line 724 of file icode_exec.cpp.
References mxvm::Base::base, name, mxvm::Base::object_map, and mxvm::Base::vars.
Referenced by exec_add(), exec_alloc(), exec_and(), exec_cmp(), exec_div(), exec_exit(), exec_fcmp(), exec_free(), exec_getline(), exec_invoke(), exec_lea(), exec_load(), exec_mod(), exec_mov(), exec_mul(), exec_neg(), exec_not(), exec_or(), exec_pop(), exec_print(), exec_push(), exec_realloc(), exec_return(), exec_stack_load(), exec_stack_store(), exec_stack_sub(), exec_store(), exec_string_print(), exec_sub(), exec_to_float(), exec_to_int(), exec_xor(), gen_alloc(), gen_arth(), gen_bitop(), gen_call(), gen_cmp(), gen_div(), gen_free(), gen_getline(), gen_lea(), gen_load(), gen_mod(), gen_mov(), gen_neg(), gen_not(), gen_pop(), gen_print(), gen_push(), gen_realloc(), gen_ret(), gen_return(), gen_stack_load(), gen_stack_store(), gen_stack_sub(), gen_store(), gen_to_float(), gen_to_int(), generateCode(), generateLoadVar(), generateLoadVar(), getMangledName(), getStringFromVar(), mxvm_io_fclose(), mxvm_io_feof(), mxvm_io_fopen(), mxvm_io_fprintf(), mxvm_io_fputs(), mxvm_io_fread(), mxvm_io_fseek(), mxvm_io_fsize(), mxvm_io_fwrite(), mxvm_io_mxvm_fgets(), mxvm_io_rand_number(), mxvm_sdl_blit_surface(), mxvm_sdl_clear(), mxvm_sdl_create_render_target(), mxvm_sdl_create_renderer(), mxvm_sdl_create_rgb_surface(), mxvm_sdl_create_texture(), mxvm_sdl_create_window(), mxvm_sdl_delay(), mxvm_sdl_destroy_render_target(), mxvm_sdl_destroy_renderer(), mxvm_sdl_destroy_texture(), mxvm_sdl_destroy_window(), mxvm_sdl_draw_line(), mxvm_sdl_draw_point(), mxvm_sdl_draw_rect(), mxvm_sdl_draw_text(), mxvm_sdl_fill_rect(), mxvm_sdl_free_surface(), mxvm_sdl_free_wav(), mxvm_sdl_get_keyboard_state(), mxvm_sdl_get_mouse_state(), mxvm_sdl_get_relative_mouse_state(), mxvm_sdl_get_renderer_output_size(), mxvm_sdl_get_window_size(), mxvm_sdl_is_key_pressed(), mxvm_sdl_load_font(), mxvm_sdl_load_texture(), mxvm_sdl_load_texture_color_key(), mxvm_sdl_load_texture_color_key_rgb(), mxvm_sdl_load_wav(), mxvm_sdl_lock_texture(), mxvm_sdl_open_audio(), mxvm_sdl_pause_audio(), mxvm_sdl_present(), mxvm_sdl_present_scaled(), mxvm_sdl_present_stretched(), mxvm_sdl_queue_audio(), mxvm_sdl_render_texture(), mxvm_sdl_set_clipboard_text(), mxvm_sdl_set_draw_color(), mxvm_sdl_set_render_target(), mxvm_sdl_set_window_fullscreen(), mxvm_sdl_set_window_icon(), mxvm_sdl_set_window_position(), mxvm_sdl_set_window_title(), mxvm_sdl_show_cursor(), mxvm_sdl_unlock_texture(), mxvm_sdl_update_texture(), mxvm_std_abs(), mxvm_std_acos(), mxvm_std_argv(), mxvm_std_asin(), mxvm_std_atan(), mxvm_std_atan2(), mxvm_std_atof(), mxvm_std_atoi(), mxvm_std_calloc(), mxvm_std_ceil(), mxvm_std_cos(), mxvm_std_cosh(), mxvm_std_exit(), mxvm_std_exp(), mxvm_std_exp2(), mxvm_std_fabs(), mxvm_std_float_to_int(), mxvm_std_floor(), mxvm_std_fmod(), mxvm_std_hypot(), mxvm_std_int_to_float(), mxvm_std_isalpha(), mxvm_std_isdigit(), mxvm_std_isspace(), mxvm_std_log(), mxvm_std_log10(), mxvm_std_log2(), mxvm_std_malloc(), mxvm_std_memcmp(), mxvm_std_memcpy(), mxvm_std_memmove(), mxvm_std_memset(), mxvm_std_pow(), mxvm_std_release(), mxvm_std_round(), mxvm_std_set_program_args(), mxvm_std_sin(), mxvm_std_sinh(), mxvm_std_sqrt(), mxvm_std_srand(), mxvm_std_system(), mxvm_std_tan(), mxvm_std_tanh(), mxvm_std_tolower(), mxvm_std_toupper(), mxvm_std_trunc(), mxvm_string_snprintf(), mxvm_string_strat(), mxvm_string_strcmp(), mxvm_string_strfind(), mxvm_string_strlen(), mxvm_string_strncat(), mxvm_string_strncpy(), mxvm_string_substr(), sysv_analyzeRegAlloc(), variableFromOperand(), x64_analyzeRegAlloc(), x64_gen_alloc(), x64_gen_arth(), x64_gen_bitop(), x64_gen_call(), x64_gen_cmp(), x64_gen_div(), x64_gen_free(), x64_gen_getline(), x64_gen_lea(), x64_gen_load(), x64_gen_mod(), x64_gen_mov(), x64_gen_neg(), x64_gen_not(), x64_gen_pop(), x64_gen_push(), x64_gen_realloc(), x64_gen_ret(), x64_gen_return(), x64_gen_stack_load(), x64_gen_stack_store(), x64_gen_stack_sub(), x64_gen_store(), x64_gen_to_float(), x64_generateCode(), x64_generateFunctionCall(), x64_generateLoadVar(), and x64_generateLoadVar().
| void mxvm::Program::memoryDump | ( | std::ostream & | out | ) |
Dump all variable values to a stream for debugging.
| out | Destination stream |
Definition at line 316 of file icode.cpp.
References Program(), escapeNewLines(), mxvm::Base::labels, name, objects, mxvm::VAR_ARRAY, mxvm::VAR_BYTE, mxvm::VAR_EXTERN, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_LABEL, mxvm::VAR_POINTER, mxvm::VAR_STRING, and mxvm::Base::vars.
Multiply two variables and store the result in dest.
Definition at line 827 of file icode_exec.cpp.
References mxvm::Variable_Value::float_value, mxvm::Variable_Value::int_value, mxvm::Variable::type, mxvm::Variable_Value::type, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, and mxvm::Variable::var_value.
Referenced by exec_mul().
Move-assignment operator.
Definition at line 250 of file icode.hpp.
References Program(), args, carry_flag, exitCode, filename, greater_flag, less_flag, main_function, name, object_external, objects, mxvm::Base::operator=(), parent, pc, platform, result, running, stack, mxvm::Base::vars, xmm_offset, and zero_flag.
| std::string mxvm::Program::optimize_core | ( | const std::string & | code | ) |
| std::string mxvm::Program::optimize_darwin | ( | const std::string & | code | ) |
Darwin-specific assembly optimizations.
| code | Assembly text |
| void mxvm::Program::post | ( | std::ostream & | out | ) |
Generate native data section (variable declarations) into the output stream.
| out | Destination stream |
Definition at line 2093 of file icode_exec.cpp.
References stack.
| void mxvm::Program::print | ( | std::ostream & | out | ) |
Print all instructions and data to an output stream.
| out | Destination stream |
Definition at line 2013 of file icode_exec.cpp.
References mxvm::Base::inc, and IncType.
| std::string mxvm::Program::printFormatted | ( | const std::string & | format, |
| const std::vector< Variable * > & | args, | ||
| bool | output = true ) |
Format and optionally print a printf-style format string with variable arguments.
| format | Format string with % specifiers |
| args | Variables corresponding to format specifiers |
| output | true to print, false to only return the string |
Definition at line 1501 of file icode_exec.cpp.
References args, mxvm::Variable_Value::float_value, mxvm::Variable_Value::int_value, mxvm::Variable_Value::ptr_value, mxvm::Variable_Value::str_value, mxvm::Variable::type, mxvm::Variable_Value::type, mxvm::VAR_BYTE, mxvm::VAR_EXTERN, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, mxvm::VAR_STRING, and mxvm::Variable::var_value.
Referenced by exec_print(), and mxvm_io_fprintf().
| void mxvm::Program::setArgs | ( | const std::vector< std::string > & | argv | ) |
| void mxvm::Program::setObject | ( | bool | obj | ) |
| void mxvm::Program::setVariableFromConstant | ( | Variable & | var, |
| const std::string & | value ) |
Set a variable's value from a constant string (integer, float, or string literal).
| var | Variable to modify |
| value | Constant string to parse |
Definition at line 1991 of file icode_exec.cpp.
References mxvm::Variable_Value::float_value, mxvm::Variable_Value::int_value, mxvm::Variable_Value::owns, mxvm::Variable_Value::ptr_value, mxvm::Variable_Value::str_value, mxvm::Variable::type, mxvm::Variable_Value::type, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, mxvm::VAR_STRING, and mxvm::Variable::var_value.
Referenced by exec_mov().
| void mxvm::Program::setVariableFromString | ( | Variable & | var, |
| const std::string & | value ) |
Set a variable's value from a string representation, coercing types.
| var | Variable to modify |
| value | String to parse |
Definition at line 771 of file icode_exec.cpp.
References mxvm::Variable_Value::float_value, mxvm::Variable_Value::int_value, mxvm::Variable_Value::str_value, mxvm::Variable::type, mxvm::Variable_Value::type, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_STRING, and mxvm::Variable::var_value.
| void mxvm::Program::stop | ( | ) |
Halt the interpreter loop.
Definition at line 23 of file icode_exec.cpp.
References running.
Referenced by exec_done(), and exec_exit().
Subtract src2 from src1 and store the result in dest.
Definition at line 807 of file icode_exec.cpp.
References mxvm::Base::base, mxvm::Variable_Value::float_value, mxvm::Variable_Value::int_value, mxvm::Variable_Value::owns, mxvm::Variable_Value::ptr_value, mxvm::Variable::type, mxvm::Variable_Value::type, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, and mxvm::Variable::var_value.
Referenced by exec_sub().
| void mxvm::Program::sysv_analyzeRegAlloc | ( | bool | uses_std_module | ) |
Analyze variable usage and assign System V callee-saved registers.
| uses_std_module | true if the program uses the std module |
Definition at line 24 of file icode_gen.cpp.
References getVariable(), mxvm::Base::inc, mxvm::Variable::is_global, isVariable(), sysv_reg_save_order, sysv_reg_vars, mxvm::Variable::type, and mxvm::VAR_INTEGER.
Referenced by generateCode().
| void mxvm::Program::sysv_emitFlushRegs | ( | std::ostream & | out | ) |
Write all register-allocated variables back to memory.
Definition at line 67 of file icode_gen.cpp.
References getMangledName(), and sysv_reg_vars.
Referenced by gen_call(), gen_done(), gen_load(), gen_realloc(), gen_ret(), and gen_store().
| void mxvm::Program::sysv_emitLoadVar | ( | std::ostream & | out, |
| const std::string & | dstReg, | ||
| const Operand & | src ) |
Load a variable into a destination register.
| out | Assembly output stream |
| dstReg | Destination register name |
| src | Source operand |
Definition at line 110 of file icode_gen.cpp.
References getMangledName(), mxvm::Operand::op, and sysv_reg_vars.
Referenced by gen_alloc(), gen_call(), gen_load(), gen_mov(), gen_push(), gen_realloc(), gen_ret(), gen_stack_store(), gen_stack_sub(), and gen_store().
| void mxvm::Program::sysv_emitReloadRegs | ( | std::ostream & | out | ) |
Reload register-allocated variables from memory.
Definition at line 73 of file icode_gen.cpp.
References getMangledName(), and sysv_reg_vars.
Referenced by gen_call(), gen_realloc(), gen_store(), and generateCode().
| void mxvm::Program::sysv_emitRestoreRegs | ( | std::ostream & | out | ) |
Restore callee-saved registers at function epilogue.
Definition at line 85 of file icode_gen.cpp.
References sysv_reg_save_order.
Referenced by gen_done(), and gen_ret().
| void mxvm::Program::sysv_emitSaveRegs | ( | std::ostream & | out | ) |
Save callee-saved registers at function prologue.
Definition at line 79 of file icode_gen.cpp.
References sysv_reg_save_order.
Referenced by generateCode().
| void mxvm::Program::sysv_emitStoreVar | ( | std::ostream & | out, |
| const std::string & | srcReg, | ||
| const Operand & | dest ) |
Store a register value into a variable (register-allocated or memory).
| out | Assembly output stream |
| srcReg | Source register name |
| dest | Destination operand |
Definition at line 91 of file icode_gen.cpp.
References getMangledName(), mxvm::Operand::op, and sysv_reg_vars.
Referenced by gen_arth(), gen_bitop(), gen_div(), gen_load(), gen_mod(), gen_mov(), gen_neg(), gen_not(), gen_pop(), gen_return(), gen_stack_load(), gen_to_int(), and generateCode().
| void mxvm::Program::sysv_emitStoreVarImm | ( | std::ostream & | out, |
| const std::string & | imm, | ||
| const Operand & | dest ) |
Store an immediate value into a variable.
| out | Assembly output stream |
| imm | Immediate value string |
| dest | Destination operand |
Definition at line 101 of file icode_gen.cpp.
References getMangledName(), mxvm::Operand::op, and sysv_reg_vars.
Referenced by gen_mov().
| bool mxvm::Program::validateNames | ( | Validator & | v | ) |
Validate all variable and label names against the Validator.
| v | Validator reference |
Definition at line 754 of file icode_exec.cpp.
References objects, mxvm::Validator::var_names, and mxvm::Base::vars.
Resolve an Operand to its corresponding Variable.
| op | Operand to resolve |
Definition at line 2123 of file icode_exec.cpp.
References createTempVariable(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::OP_CONSTANT, mxvm::Operand::type, and mxvm::VAR_INTEGER.
Referenced by mxvm_io_fread(), mxvm_io_fseek(), and mxvm_io_fwrite().
| void mxvm::Program::x64_analyzeRegAlloc | ( | bool | uses_std_module | ) |
Analyze variable usage and assign Win64 callee-saved registers.
| uses_std_module | true if the program uses the std module (affects register choices) |
Definition at line 39 of file icode_gen_x64.cpp.
References getVariable(), mxvm::Base::inc, mxvm::Variable::is_global, mxvm::is_stdio_name(), isVariable(), mxvm::Variable::type, mxvm::VAR_INTEGER, x64_reg_save_order, and x64_reg_vars.
Referenced by x64_generateCode().
| void mxvm::Program::x64_direct_stack_adjust | ( | std::ostream & | out, |
| int64_t | bytes ) |
Emit a direct stack pointer adjustment.
| out | Assembly output stream |
| bytes | Positive = allocate, negative = deallocate |
| void mxvm::Program::x64_emit_iob_func | ( | std::ostream & | out, |
| int | index, | ||
| const std::string & | dstReg ) |
Emit an integer-or-byte function argument load for Win64 ABI.
| out | Assembly output stream |
| index | Argument index (determines register) |
| dstReg | Destination register name |
Definition at line 151 of file icode_gen_x64.cpp.
References x64_release_call_area(), and x64_reserve_call_area().
Referenced by x64_generateLoadVar(), and x64_generateLoadVar().
| void mxvm::Program::x64_emitFlushRegs | ( | std::ostream & | out | ) |
Write all register-allocated variables back to memory.
Definition at line 80 of file icode_gen_x64.cpp.
References getMangledName(), and x64_reg_vars.
Referenced by x64_gen_call(), x64_gen_done(), x64_gen_load(), x64_gen_realloc(), x64_gen_ret(), and x64_gen_store().
| void mxvm::Program::x64_emitLoadVar | ( | std::ostream & | out, |
| const std::string & | dstReg, | ||
| const Operand & | src ) |
Load a variable into a destination register.
| out | Assembly output stream |
| dstReg | Destination register name |
| src | Source operand |
Definition at line 125 of file icode_gen_x64.cpp.
References getMangledName(), mxvm::Operand::op, and x64_reg_vars.
Referenced by x64_gen_alloc(), x64_gen_call(), x64_gen_load(), x64_gen_mov(), x64_gen_push(), x64_gen_realloc(), x64_gen_ret(), x64_gen_stack_store(), x64_gen_stack_sub(), and x64_gen_store().
| void mxvm::Program::x64_emitReloadRegs | ( | std::ostream & | out | ) |
Reload register-allocated variables from memory.
Definition at line 86 of file icode_gen_x64.cpp.
References getMangledName(), and x64_reg_vars.
Referenced by x64_gen_call(), x64_gen_realloc(), x64_gen_store(), and x64_generateCode().
| void mxvm::Program::x64_emitRestoreRegs | ( | std::ostream & | out | ) |
Restore callee-saved registers at function epilogue.
Definition at line 99 of file icode_gen_x64.cpp.
References x64_reg_save_order, and mxvm::x64_sp_mod16.
Referenced by x64_gen_done(), and x64_gen_ret().
| void mxvm::Program::x64_emitSaveRegs | ( | std::ostream & | out | ) |
Save callee-saved registers at function prologue.
Definition at line 92 of file icode_gen_x64.cpp.
References x64_reg_save_order, and mxvm::x64_sp_mod16.
Referenced by x64_generateCode().
| void mxvm::Program::x64_emitStoreVar | ( | std::ostream & | out, |
| const std::string & | srcReg, | ||
| const Operand & | dest ) |
Store a register value into a variable (register-allocated or memory).
| out | Assembly output stream |
| srcReg | Source register name |
| dest | Destination operand |
Definition at line 106 of file icode_gen_x64.cpp.
References getMangledName(), mxvm::Operand::op, and x64_reg_vars.
Referenced by x64_gen_arth(), x64_gen_bitop(), x64_gen_div(), x64_gen_load(), x64_gen_mod(), x64_gen_mov(), x64_gen_neg(), x64_gen_not(), x64_gen_pop(), x64_gen_return(), x64_gen_stack_load(), x64_gen_to_int(), and x64_generateCode().
| void mxvm::Program::x64_emitStoreVarImm | ( | std::ostream & | out, |
| const std::string & | imm, | ||
| const Operand & | dest ) |
Store an immediate value into a variable.
| out | Assembly output stream |
| imm | Immediate value string |
| dest | Destination operand |
Definition at line 116 of file icode_gen_x64.cpp.
References getMangledName(), mxvm::Operand::op, and x64_reg_vars.
Referenced by x64_gen_mov().
| void mxvm::Program::x64_gen_alloc | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 751 of file icode_gen_x64.cpp.
References mxvm::error_label_count, getMangledName(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, mxvm::Variable_Value::owns, mxvm::Variable::type, mxvm::VAR_POINTER, mxvm::Variable::var_value, x64_emitLoadVar(), x64_release_call_area(), and x64_reserve_call_area().
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_arth | ( | std::ostream & | out, |
| std::string | arth, | ||
| const Instruction & | i ) |
Definition at line 1611 of file icode_gen_x64.cpp.
References getMangledName(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, mxvm::OP_CONSTANT, mxvm::Variable::type, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, x64_emitStoreVar(), x64_generateLoadVar(), and x64_reg_vars.
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_bitop | ( | std::ostream & | out, |
| const std::string & | opc, | ||
| const Instruction & | i ) |
Definition at line 1380 of file icode_gen_x64.cpp.
References getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, mxvm::Variable::type, mxvm::VAR_INTEGER, x64_emitStoreVar(), and x64_generateLoadVar().
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_call | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 732 of file icode_gen_x64.cpp.
References getMangledName(), getVariable(), isFunctionValid(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::VAR_INTEGER, x64_emitFlushRegs(), x64_emitLoadVar(), x64_emitReloadRegs(), x64_release_call_area(), and x64_reserve_call_area().
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_cmp | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1562 of file icode_gen_x64.cpp.
References CMP_FLOAT, CMP_INTEGER, getMangledName(), getVariable(), isVariable(), last_cmp_type, mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::OP_CONSTANT, mxvm::Operand::type, mxvm::Variable::type, mxvm::VAR_BYTE, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, x64_generateLoadVar(), and x64_reg_vars.
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_div | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1235 of file icode_gen_x64.cpp.
References getMangledName(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, mxvm::Variable::type, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, x64_emitStoreVar(), and x64_generateLoadVar().
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_done | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 476 of file icode_gen_x64.cpp.
References mxvm::Base::external, x64_emitFlushRegs(), x64_emitRestoreRegs(), x64_release_call_area(), and x64_reserve_call_area().
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_exit | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1663 of file icode_gen_x64.cpp.
References mxvm::Base::external, mxvm::Operand::op, mxvm::Instruction::op1, x64_generateFunctionCall(), x64_release_call_area(), and x64_reserve_call_area().
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_fcmp | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1688 of file icode_gen_x64.cpp.
References CMP_FLOAT, last_cmp_type, mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::VAR_FLOAT, and x64_generateLoadVar().
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_free | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 856 of file icode_gen_x64.cpp.
References getMangledName(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Variable_Value::owns, mxvm::Variable::type, mxvm::VAR_POINTER, mxvm::Variable::var_value, x64_release_call_area(), and x64_reserve_call_area().
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_getline | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1343 of file icode_gen_x64.cpp.
References mxvm::Variable_Value::buffer_size, getMangledName(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Variable::type, mxvm::VAR_STRING, mxvm::Variable::var_value, x64_release_call_area(), and x64_reserve_call_area().
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_invoke | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 717 of file icode_gen_x64.cpp.
References mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, mxvm::Instruction::vop, and x64_generateInvokeCall().
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_jae | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1699 of file icode_gen_x64.cpp.
References mxvm::Operand::op, and mxvm::Instruction::op1.
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_jbe | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1703 of file icode_gen_x64.cpp.
References mxvm::Operand::op, and mxvm::Instruction::op1.
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_jc | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1707 of file icode_gen_x64.cpp.
References mxvm::Operand::op, and mxvm::Instruction::op1.
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_jmp | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1514 of file icode_gen_x64.cpp.
References CMP_FLOAT, mxvm::Instruction::instruction, JA, JB, JE, JG, JGE, JL, JLE, JMP, JNE, JNZ, JZ, mxvm::Base::labels, last_cmp_type, mxvm::Operand::op, mxvm::Instruction::op1, and pos().
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_jnc | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1711 of file icode_gen_x64.cpp.
References mxvm::Operand::op, and mxvm::Instruction::op1.
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_jno | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1727 of file icode_gen_x64.cpp.
References mxvm::Operand::op, and mxvm::Instruction::op1.
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_jnp | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1719 of file icode_gen_x64.cpp.
References mxvm::Operand::op, and mxvm::Instruction::op1.
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_jns | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1735 of file icode_gen_x64.cpp.
References mxvm::Operand::op, and mxvm::Instruction::op1.
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_jo | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1723 of file icode_gen_x64.cpp.
References mxvm::Operand::op, and mxvm::Instruction::op1.
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_jp | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1715 of file icode_gen_x64.cpp.
References mxvm::Operand::op, and mxvm::Instruction::op1.
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_js | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1731 of file icode_gen_x64.cpp.
References mxvm::Operand::op, and mxvm::Instruction::op1.
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_lea | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 544 of file icode_gen_x64.cpp.
References getMangledName(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Variable_Value::owns, mxvm::Variable::var_value, and x64_reg_vars.
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_load | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 952 of file icode_gen_x64.cpp.
References mxvm::Variable_Value::buffer_size, mxvm::error_label_count, getMangledName(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, mxvm::Variable::type, mxvm::VAR_BYTE, mxvm::VAR_EXTERN, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, mxvm::VAR_STRING, mxvm::Variable::var_value, mxvm::Instruction::vop, x64_emitFlushRegs(), x64_emitLoadVar(), and x64_emitStoreVar().
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_mod | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1301 of file icode_gen_x64.cpp.
References getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, mxvm::Variable::type, mxvm::VAR_INTEGER, x64_emitStoreVar(), and x64_generateLoadVar().
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_mov | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 874 of file icode_gen_x64.cpp.
References getMangledName(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Variable_Value::owns, mxvm::Variable::type, mxvm::VAR_BYTE, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, mxvm::VAR_STRING, mxvm::Variable::var_value, x64_emitLoadVar(), x64_emitStoreVar(), x64_emitStoreVarImm(), and x64_generateLoadVar().
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_neg | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 526 of file icode_gen_x64.cpp.
References getMangledName(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Variable::type, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, x64_emitStoreVar(), and x64_generateLoadVar().
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_not | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1408 of file icode_gen_x64.cpp.
References getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Variable::type, mxvm::VAR_INTEGER, x64_emitStoreVar(), and x64_generateLoadVar().
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_pop | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1448 of file icode_gen_x64.cpp.
References getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Variable::type, mxvm::VAR_EXTERN, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, x64_emitStoreVar(), and mxvm::x64_sp_mod16.
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_print | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1500 of file icode_gen_x64.cpp.
References args, mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, mxvm::Instruction::vop, x64_generateFunctionCall(), and xmm_offset.
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_push | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1425 of file icode_gen_x64.cpp.
References getMangledName(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::OP_CONSTANT, mxvm::Operand::type, mxvm::Variable::type, mxvm::VAR_EXTERN, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, mxvm::VAR_STRING, x64_emitLoadVar(), and mxvm::x64_sp_mod16.
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_realloc | ( | std::ostream & | out, |
| const Instruction & | i ) |
Generate Win64 x86-64 assembly for the REALLOC instruction (dynamic array resize).
Generate Win64 x86-64 native code for REALLOC.
Uses the Win64 calling convention (rcx = ptr, rdx = size) for the C realloc() call. Shadow space is reserved. Registers are flushed/reloaded around the call.
Definition at line 804 of file icode_gen_x64.cpp.
References mxvm::error_label_count, getMangledName(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, mxvm::Variable_Value::owns, mxvm::Variable::type, mxvm::VAR_POINTER, mxvm::Variable::var_value, x64_emitFlushRegs(), x64_emitLoadVar(), x64_emitReloadRegs(), x64_release_call_area(), and x64_reserve_call_area().
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_ret | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 502 of file icode_gen_x64.cpp.
References getVariable(), isVariable(), mxvm::Operand::op, mxvm::VAR_INTEGER, x64_emitFlushRegs(), x64_emitLoadVar(), and x64_emitRestoreRegs().
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_return | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 514 of file icode_gen_x64.cpp.
References getVariable(), isVariable(), last_call_returns_owned_ptr, mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Variable_Value::owns, mxvm::Variable::var_value, and x64_emitStoreVar().
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_stack_load | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1480 of file icode_gen_x64.cpp.
References isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::VAR_INTEGER, x64_emitStoreVar(), and x64_generateLoadVar().
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_stack_store | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1490 of file icode_gen_x64.cpp.
References isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::VAR_INTEGER, x64_emitLoadVar(), and x64_generateLoadVar().
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_stack_sub | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1461 of file icode_gen_x64.cpp.
References isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, x64_emitLoadVar(), and mxvm::x64_sp_mod16.
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_store | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1087 of file icode_gen_x64.cpp.
References mxvm::Variable_Value::buffer_size, mxvm::error_label_count, getMangledName(), getVariable(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, mxvm::Variable::type, mxvm::VAR_BYTE, mxvm::VAR_EXTERN, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, mxvm::VAR_STRING, mxvm::Variable::var_value, mxvm::Instruction::vop, x64_emitFlushRegs(), x64_emitLoadVar(), and x64_emitReloadRegs().
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_to_float | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1226 of file icode_gen_x64.cpp.
References getMangledName(), isVariable(), mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::VAR_INTEGER, and x64_generateLoadVar().
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_gen_to_int | ( | std::ostream & | out, |
| const Instruction & | i ) |
Definition at line 1218 of file icode_gen_x64.cpp.
References getMangledName(), mxvm::Instruction::op1, mxvm::Instruction::op2, x64_emitStoreVar(), x64_release_call_area(), and x64_reserve_call_area().
Referenced by x64_generateInstruction().
| void mxvm::Program::x64_generateCode | ( | const Platform & | platform, |
| bool | obj, | ||
| std::ostream & | out ) |
Top-level Win64 code generation entry point.
| platform | Target platform |
| obj | true if generating as an object |
| out | Assembly output stream |
Definition at line 314 of file icode_gen_x64.cpp.
References add_standard(), mxvm::Base::base, mx::Color::BRIGHT_BLUE, mx::Color::BRIGHT_CYAN, Col(), DONE, escapeNewLines(), mxvm::Base::external, getMangledName(), getVariable(), mxvm::Base::inc, mxvm::Instruction::instruction, isVariable(), mxvm::Base::labels, name, mxvm::Operand::op, mxvm::Base::root_name, mxvm::VAR_BYTE, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, mxvm::VAR_STRING, mxvm::Base::vars, x64_analyzeRegAlloc(), x64_emitReloadRegs(), x64_emitSaveRegs(), x64_emitStoreVar(), x64_generateInstruction(), x64_release_call_area(), x64_reserve_call_area(), and mxvm::x64_sp_mod16.
Referenced by generateCode().
| void mxvm::Program::x64_generateFunctionCall | ( | std::ostream & | out, |
| const std::string & | name, | ||
| std::vector< Operand > & | args ) |
Generate a Win64 ABI function call with operands as arguments.
Definition at line 257 of file icode_gen_x64.cpp.
References args, getVariable(), isVariable(), name, mxvm::Variable::type, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, x64_generateLoadVar(), x64_release_call_area(), x64_reserve_call_area(), and xmm_offset.
Referenced by x64_gen_exit(), x64_gen_print(), and x64_generateInvokeCall().
| void mxvm::Program::x64_generateInstruction | ( | std::ostream & | out, |
| const Instruction & | i ) |
Dispatch a single instruction to its Win64 code generator.
| out | Assembly output stream |
| i | Instruction to generate code for |
Definition at line 561 of file icode_gen_x64.cpp.
References ADD, ALLOC, AND, CALL, CMP, CMP_NONE, DIV, DONE, EXIT, FCMP, FREE, GETLINE, mxvm::Instruction::instruction, INVOKE, JA, JAE, JB, JBE, JC, JE, JG, JGE, JL, JLE, JMP, JNC, JNE, JNO, JNP, JNS, JNZ, JO, JP, JS, JZ, last_cmp_type, LEA, LOAD, MOD, MOV, MUL, NEG, NOT, OR, POP, PRINT, PUSH, REALLOC, RET, RETURN, STACK_LOAD, STACK_STORE, STACK_SUB, STORE, SUB, TO_FLOAT, TO_INT, x64_gen_alloc(), x64_gen_arth(), x64_gen_bitop(), x64_gen_call(), x64_gen_cmp(), x64_gen_div(), x64_gen_done(), x64_gen_exit(), x64_gen_fcmp(), x64_gen_free(), x64_gen_getline(), x64_gen_invoke(), x64_gen_jae(), x64_gen_jbe(), x64_gen_jc(), x64_gen_jmp(), x64_gen_jnc(), x64_gen_jno(), x64_gen_jnp(), x64_gen_jns(), x64_gen_jo(), x64_gen_jp(), x64_gen_js(), x64_gen_lea(), x64_gen_load(), x64_gen_mod(), x64_gen_mov(), x64_gen_neg(), x64_gen_not(), x64_gen_pop(), x64_gen_print(), x64_gen_push(), x64_gen_realloc(), x64_gen_ret(), x64_gen_return(), x64_gen_stack_load(), x64_gen_stack_store(), x64_gen_stack_sub(), x64_gen_store(), x64_gen_to_float(), x64_gen_to_int(), and XOR.
Referenced by x64_generateCode().
| void mxvm::Program::x64_generateInvokeCall | ( | std::ostream & | out, |
| std::vector< Operand > & | op ) |
Generate a Win64 dynamic invoke call.
| out | Assembly output stream |
| op | Operand list |
Definition at line 296 of file icode_gen_x64.cpp.
References mxvm::isFunctionReturningOwnedPtr(), last_call_returns_owned_ptr, and x64_generateFunctionCall().
Referenced by x64_gen_invoke().
| int mxvm::Program::x64_generateLoadVar | ( | std::ostream & | out, |
| int | r, | ||
| const Operand & | op ) |
Load a variable or constant into a numbered Win64 register.
| out | Assembly output stream |
| r | Register index |
| op | Operand to load |
Definition at line 205 of file icode_gen_x64.cpp.
References getMangledName(), getVariable(), mxvm::is_stdio_name(), isVariable(), mxvm::Operand::op, mxvm::OP_CONSTANT, mxvm::stdio_index(), mxvm::Operand::type, mxvm::Variable::type, mxvm::VAR_BYTE, mxvm::VAR_EXTERN, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, mxvm::VAR_STRING, x64_emit_iob_func(), x64_getRegisterByIndex(), and x64_reg_vars.
Referenced by x64_gen_arth(), x64_gen_bitop(), x64_gen_cmp(), x64_gen_div(), x64_gen_fcmp(), x64_gen_mod(), x64_gen_mov(), x64_gen_neg(), x64_gen_not(), x64_gen_stack_load(), x64_gen_stack_store(), x64_gen_to_float(), and x64_generateFunctionCall().
| int mxvm::Program::x64_generateLoadVar | ( | std::ostream & | out, |
| VarType | type, | ||
| std::string | reg, | ||
| const Operand & | op ) |
Load a variable or constant into a named Win64 register.
| out | Assembly output stream |
| type | Expected variable type |
| reg | Target register name |
| op | Operand to load |
Definition at line 160 of file icode_gen_x64.cpp.
References getMangledName(), getVariable(), mxvm::is_stdio_name(), isVariable(), mxvm::Operand::op, mxvm::OP_CONSTANT, mxvm::stdio_index(), mxvm::Operand::type, mxvm::Variable::type, mxvm::VAR_BYTE, mxvm::VAR_EXTERN, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, mxvm::VAR_STRING, x64_emit_iob_func(), and x64_reg_vars.
| std::string mxvm::Program::x64_getRegisterByIndex | ( | int | index, |
| VarType | type ) |
Get the Win64 register name for a given index and variable type.
| index | Register index |
| type | Variable type (determines integer vs. XMM register) |
Definition at line 20 of file icode_gen_x64.cpp.
References mxvm::VAR_FLOAT.
Referenced by x64_generateLoadVar().
| void mxvm::Program::x64_release_call_area | ( | std::ostream & | out, |
| size_t | frame ) |
Release a Win64 call frame previously reserved.
| out | Assembly output stream |
| frame | Frame size to release |
Definition at line 147 of file icode_gen_x64.cpp.
References mxvm::x64_sp_mod16.
Referenced by x64_emit_iob_func(), x64_gen_alloc(), x64_gen_call(), x64_gen_done(), x64_gen_exit(), x64_gen_free(), x64_gen_getline(), x64_gen_realloc(), x64_gen_to_int(), x64_generateCode(), and x64_generateFunctionCall().
| size_t mxvm::Program::x64_reserve_call_area | ( | std::ostream & | out, |
| size_t | spill_bytes ) |
Reserve stack space for a Win64 call frame including spill area.
| out | Assembly output stream |
| spill_bytes | Additional spill bytes needed |
Definition at line 135 of file icode_gen_x64.cpp.
References mxvm::x64_sp_mod16.
Referenced by x64_emit_iob_func(), x64_gen_alloc(), x64_gen_call(), x64_gen_done(), x64_gen_exit(), x64_gen_free(), x64_gen_getline(), x64_gen_realloc(), x64_gen_to_int(), x64_generateCode(), and x64_generateFunctionCall().
|
friend |
|
private |
Definition at line 407 of file icode.hpp.
Referenced by exec_invoke(), exec_print(), exec_string_print(), gen_print(), generateFunctionCall(), generateInvokeCall(), operator=(), optimize_core(), printFormatted(), setArgs(), x64_gen_print(), and x64_generateFunctionCall().
|
private |
comparison carry flag
Definition at line 405 of file icode.hpp.
Referenced by exec_jc(), exec_jnc(), and operator=().
|
private |
Definition at line 401 of file icode.hpp.
Referenced by exec_done(), exec_exit(), getExitCode(), and operator=().
| std::string mxvm::Program::filename |
Definition at line 307 of file icode.hpp.
Referenced by operator=().
|
private |
comparison greater-than flag
Definition at line 404 of file icode.hpp.
Referenced by exec_cmp(), exec_fcmp(), exec_ja(), exec_jae(), exec_jg(), exec_jge(), and operator=().
| VarType mxvm::Program::last_call_ret_type = VarType::VAR_INTEGER |
|
private |
tracks ownership of last call's return value
Definition at line 418 of file icode.hpp.
Referenced by gen_return(), generateInvokeCall(), x64_gen_return(), and x64_generateInvokeCall().
|
private |
Definition at line 417 of file icode.hpp.
Referenced by gen_cmp(), gen_fcmp(), gen_jmp(), generateInstruction(), x64_gen_cmp(), x64_gen_fcmp(), x64_gen_jmp(), and x64_generateInstruction().
|
private |
comparison less-than flag
Definition at line 403 of file icode.hpp.
Referenced by exec_cmp(), exec_fcmp(), exec_jb(), exec_jbe(), exec_jl(), exec_jle(), and operator=().
|
private |
true if this program has a main entry point
Definition at line 408 of file icode.hpp.
Referenced by operator=().
| std::string mxvm::Program::name |
Definition at line 306 of file icode.hpp.
Referenced by Program(), ~Program(), add_standard(), exec_return(), flatten_inc(), flatten_label(), generateCode(), generateFunctionCall(), generateInvokeCall(), getMangledName(), getObjectByName(), getPlatformSymbolName(), getVariable(), isVariable(), memoryDump(), operator=(), optimize_core(), x64_generateCode(), and x64_generateFunctionCall().
|
private |
Definition at line 409 of file icode.hpp.
Referenced by operator=().
| std::vector<std::unique_ptr<Program> > mxvm::Program::objects |
Definition at line 340 of file icode.hpp.
Referenced by flatten(), getObjectByName(), memoryDump(), operator=(), and validateNames().
| Program* mxvm::Program::parent = nullptr |
parent program (for object programs)
Definition at line 860 of file icode.hpp.
Referenced by operator=().
|
private |
program counter
Definition at line 399 of file icode.hpp.
Referenced by Program(), Program(), exec(), exec_call(), exec_ja(), exec_jae(), exec_jb(), exec_jbe(), exec_jc(), exec_je(), exec_jg(), exec_jge(), exec_jl(), exec_jle(), exec_jmp(), exec_jnc(), exec_jne(), exec_jnz(), exec_jo(), exec_jp(), exec_js(), exec_jz(), exec_ret(), and operator=().
| Platform mxvm::Program::platform |
Definition at line 861 of file icode.hpp.
Referenced by gen_mul(), generateCode(), getMangledName(), getMangledName(), getPlatformSymbolName(), operator=(), and optimize_core().
| Operand mxvm::Program::result |
return value operand from last invoke
Definition at line 859 of file icode.hpp.
Referenced by escapeNewLines(), exec_invoke(), exec_return(), and operator=().
|
private |
| Stack mxvm::Program::stack |
Definition at line 858 of file icode.hpp.
Referenced by exec_call(), exec_pop(), exec_push(), exec_ret(), exec_stack_load(), exec_stack_store(), exec_stack_sub(), operator=(), and post().
| std::vector<std::string> mxvm::Program::sysv_reg_save_order |
Definition at line 678 of file icode.hpp.
Referenced by sysv_analyzeRegAlloc(), sysv_emitRestoreRegs(), and sysv_emitSaveRegs().
| std::unordered_map<std::string, std::string> mxvm::Program::sysv_reg_vars |
SysV variable-to-register mapping.
Definition at line 677 of file icode.hpp.
Referenced by gen_arth(), gen_cmp(), gen_lea(), gen_to_float(), gen_to_int(), generateLoadVar(), generateLoadVar(), sysv_analyzeRegAlloc(), sysv_emitFlushRegs(), sysv_emitLoadVar(), sysv_emitReloadRegs(), sysv_emitStoreVar(), and sysv_emitStoreVarImm().
| std::vector<std::string> mxvm::Program::x64_reg_save_order |
Definition at line 634 of file icode.hpp.
Referenced by x64_analyzeRegAlloc(), x64_emitRestoreRegs(), and x64_emitSaveRegs().
| std::unordered_map<std::string, std::string> mxvm::Program::x64_reg_vars |
Win64 variable-to-register mapping.
Definition at line 633 of file icode.hpp.
Referenced by x64_analyzeRegAlloc(), x64_emitFlushRegs(), x64_emitLoadVar(), x64_emitReloadRegs(), x64_emitStoreVar(), x64_emitStoreVarImm(), x64_gen_arth(), x64_gen_cmp(), x64_gen_lea(), x64_generateLoadVar(), and x64_generateLoadVar().
|
private |
current XMM register allocation offset
Definition at line 406 of file icode.hpp.
Referenced by gen_print(), generateFunctionCall(), getRegisterByIndex(), operator=(), x64_gen_print(), and x64_generateFunctionCall().
|
private |
comparison zero flag
Definition at line 402 of file icode.hpp.
Referenced by exec_cmp(), exec_fcmp(), exec_jae(), exec_jbe(), exec_je(), exec_jge(), exec_jle(), exec_jne(), exec_jnz(), exec_jz(), and operator=().