Error X86Compiler::_newStack(BaseMem* mem, uint32_t size, uint32_t alignment, const char* name) { if (size == 0) return kErrorInvalidArgument; if (alignment > 64) alignment = 64; VarData* vd = _newVd(kInvalidVar, size, kInvalidReg, name); if (vd == NULL) { static_cast<X86Mem*>(mem)->reset(); return getLastError(); } vd->_isStack = true; vd->_alignment = static_cast<uint8_t>(alignment); static_cast<X86Mem*>(mem)->_init(kMemTypeStackIndex, vd->getId(), 0, 0); return kErrorOk; }
Error X86Compiler::_newVar(Var* var, uint32_t vType, const char* name, va_list ap) { ASMJIT_ASSERT(vType < kX86VarTypeCount); vType = _targetVarMapping[vType]; ASMJIT_ASSERT(vType != kInvalidVar); // The assertion won't be compiled in release build, however, we want to check // this anyway. if (vType == kInvalidVar) { static_cast<X86Var*>(var)->reset(); return kErrorInvalidArgument; } const X86VarInfo& vInfo = _x86VarInfo[vType]; char buf[64]; // Format the name if `ap` is given. if (ap) { vsnprintf(buf, ASMJIT_ARRAY_SIZE(buf), name, ap); buf[ASMJIT_ARRAY_SIZE(buf) - 1] = '\0'; name = buf; } VarData* vd = _newVd(vType, vInfo.getSize(), vInfo.getClass(), name); if (vd == NULL) { static_cast<X86Var*>(var)->reset(); return getLastError(); } var->_init_packed_op_sz_w0_id(kOperandTypeVar, vInfo.getSize(), vInfo.getReg() << 8, vd->getId()); var->_vreg.vType = vType; return kErrorOk; }
Error X86Compiler::_newVar(Var* var, uint32_t vType, const char* name) noexcept { ASMJIT_ASSERT(vType < kX86VarTypeCount); vType = _targetVarMapping[vType]; ASMJIT_ASSERT(vType != kInvalidVar); // The assertion won't be compiled in release build, however, we want to check // this anyway. if (vType == kInvalidVar) { static_cast<X86Var*>(var)->reset(); return kErrorInvalidArgument; } const VarInfo& vInfo = _x86VarInfo[vType]; VarData* vd = _newVd(vInfo, name); if (vd == nullptr) { static_cast<X86Var*>(var)->reset(); return getLastError(); } var->_init_packed_op_sz_w0_id(Operand::kTypeVar, vInfo.getSize(), vInfo.getRegType() << 8, vd->getId()); var->_vreg.vType = vType; return kErrorOk; }