Added casting methods to X86GpReg, X86XmmReg, X86YmmReg, and X86ZmmReg.

This commit is contained in:
kobalicek
2015-01-18 22:10:36 +01:00
parent 8b4c4ae739
commit 85c406c2ba
2 changed files with 78 additions and 13 deletions

View File

@@ -710,6 +710,10 @@ struct X86GpVar : public X86Var {
// [Construction / Destruction] // [Construction / Destruction]
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
protected:
ASMJIT_INLINE X86GpVar(const X86GpVar& other, uint32_t reg, uint32_t size) : X86Var(other, reg, size) {}
public:
//! Create a new uninitialized `X86GpVar` instance. //! Create a new uninitialized `X86GpVar` instance.
ASMJIT_INLINE X86GpVar() : X86Var() {} ASMJIT_INLINE X86GpVar() : X86Var() {}
@@ -742,18 +746,18 @@ struct X86GpVar : public X86Var {
// [X86GpVar Cast] // [X86GpVar Cast]
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
//! Cast this variable to 8-bit (LO) part of variable //! Cast this variable to 8-bit (LO) part of variable.
ASMJIT_INLINE X86GpVar r8() const { return X86GpVar(*this, kX86RegTypeGpbLo, 1); } ASMJIT_INLINE X86GpVar r8() const { return X86GpVar(*this, kX86RegTypeGpbLo, 1); }
//! Cast this variable to 8-bit (LO) part of variable //! Cast this variable to 8-bit (LO) part of variable.
ASMJIT_INLINE X86GpVar r8Lo() const { return X86GpVar(*this, kX86RegTypeGpbLo, 1); } ASMJIT_INLINE X86GpVar r8Lo() const { return X86GpVar(*this, kX86RegTypeGpbLo, 1); }
//! Cast this variable to 8-bit (HI) part of variable //! Cast this variable to 8-bit (HI) part of variable.
ASMJIT_INLINE X86GpVar r8Hi() const { return X86GpVar(*this, kX86RegTypeGpbHi, 1); } ASMJIT_INLINE X86GpVar r8Hi() const { return X86GpVar(*this, kX86RegTypeGpbHi, 1); }
//! Cast this variable to 16-bit part of variable //! Cast this variable to 16-bit part of variable.
ASMJIT_INLINE X86GpVar r16() const { return X86GpVar(*this, kX86RegTypeGpw, 2); } ASMJIT_INLINE X86GpVar r16() const { return X86GpVar(*this, kX86RegTypeGpw, 2); }
//! Cast this variable to 32-bit part of variable //! Cast this variable to 32-bit part of variable.
ASMJIT_INLINE X86GpVar r32() const { return X86GpVar(*this, kX86RegTypeGpd, 4); } ASMJIT_INLINE X86GpVar r32() const { return X86GpVar(*this, kX86RegTypeGpd, 4); }
//! Cast this variable to 64-bit part of variable //! Cast this variable to 64-bit part of variable.
ASMJIT_INLINE X86GpVar r64() const { return X86GpVar(*this, kX86RegTypeGpq, 8); } ASMJIT_INLINE X86GpVar r64() const { return X86GpVar(*this, kX86RegTypeGpq, 8); }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
@@ -764,13 +768,6 @@ struct X86GpVar : public X86Var {
ASMJIT_INLINE bool operator==(const X86GpVar& other) const { return X86Var::operator==(other); } ASMJIT_INLINE bool operator==(const X86GpVar& other) const { return X86Var::operator==(other); }
ASMJIT_INLINE bool operator!=(const X86GpVar& other) const { return X86Var::operator!=(other); } ASMJIT_INLINE bool operator!=(const X86GpVar& other) const { return X86Var::operator!=(other); }
// --------------------------------------------------------------------------
// [Private]
// --------------------------------------------------------------------------
protected:
ASMJIT_INLINE X86GpVar(const X86GpVar& other, uint32_t reg, uint32_t size) : X86Var(other, reg, size) {}
}; };
// ============================================================================ // ============================================================================
@@ -857,6 +854,12 @@ struct X86XmmVar : public X86Var {
X86Var::reset(); X86Var::reset();
} }
// --------------------------------------------------------------------------
// [X86XmmVar Cast]
// --------------------------------------------------------------------------
// TODO:
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// [Operator Overload] // [Operator Overload]
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
@@ -904,6 +907,12 @@ struct X86YmmVar : public X86Var {
X86Var::reset(); X86Var::reset();
} }
// --------------------------------------------------------------------------
// [X86YmmVar Cast]
// --------------------------------------------------------------------------
// TODO:
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// [Operator Overload] // [Operator Overload]
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------

View File

@@ -789,6 +789,24 @@ struct X86GpReg : public X86Reg {
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
ASMJIT_REG_OP(X86GpReg) ASMJIT_REG_OP(X86GpReg)
// --------------------------------------------------------------------------
// [X86GpReg Cast]
// --------------------------------------------------------------------------
//! Cast this register to 8-bit (LO) part.
ASMJIT_INLINE X86GpReg r8() const { return X86GpReg(kX86RegTypeGpbLo, getRegIndex(), 1); }
//! Cast this register to 8-bit (LO) part.
ASMJIT_INLINE X86GpReg r8Lo() const { return X86GpReg(kX86RegTypeGpbLo, getRegIndex(), 1); }
//! Cast this register to 8-bit (HI) part.
ASMJIT_INLINE X86GpReg r8Hi() const { return X86GpReg(kX86RegTypeGpbHi, getRegIndex(), 1); }
//! Cast this register to 16-bit.
ASMJIT_INLINE X86GpReg r16() const { return X86GpReg(kX86RegTypeGpw, getRegIndex(), 2); }
//! Cast this register to 32-bit.
ASMJIT_INLINE X86GpReg r32() const { return X86GpReg(kX86RegTypeGpd, getRegIndex(), 4); }
//! Cast this register to 64-bit.
ASMJIT_INLINE X86GpReg r64() const { return X86GpReg(kX86RegTypeGpq, getRegIndex(), 8); }
}; };
// ============================================================================ // ============================================================================
@@ -979,6 +997,17 @@ struct X86XmmReg : public X86Reg {
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
ASMJIT_REG_OP(X86XmmReg) ASMJIT_REG_OP(X86XmmReg)
// --------------------------------------------------------------------------
// [X86XmmReg Cast]
// --------------------------------------------------------------------------
//! Cast this register to Xmm (clone).
ASMJIT_INLINE X86XmmReg xmm() const { return X86XmmReg(kX86RegTypeXmm, getRegIndex(), 16); }
//! Cast this register to Ymm.
ASMJIT_INLINE X86YmmReg ymm() const;
//! Cast this register to Zmm.
ASMJIT_INLINE X86ZmmReg zmm() const;
}; };
// ============================================================================ // ============================================================================
@@ -1029,8 +1058,21 @@ struct X86YmmReg : public X86Reg {
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
ASMJIT_REG_OP(X86YmmReg) ASMJIT_REG_OP(X86YmmReg)
// --------------------------------------------------------------------------
// [X86YmmReg Cast]
// --------------------------------------------------------------------------
//! Cast this register to Xmm.
ASMJIT_INLINE X86XmmReg xmm() const { return X86XmmReg(kX86RegTypeXmm, getRegIndex(), 16); }
//! Cast this register to Ymm (clone).
ASMJIT_INLINE X86YmmReg ymm() const { return X86YmmReg(kX86RegTypeYmm, getRegIndex(), 32); }
//! Cast this register to Zmm.
ASMJIT_INLINE X86ZmmReg zmm() const;
}; };
ASMJIT_INLINE X86YmmReg X86XmmReg::ymm() const { return X86YmmReg(kX86RegTypeYmm, getRegIndex(), 32); }
// ============================================================================ // ============================================================================
// [asmjit::X86ZmmReg] // [asmjit::X86ZmmReg]
// ============================================================================ // ============================================================================
@@ -1057,8 +1099,22 @@ struct X86ZmmReg : public X86Reg {
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
ASMJIT_REG_OP(X86ZmmReg) ASMJIT_REG_OP(X86ZmmReg)
// --------------------------------------------------------------------------
// [X86ZmmReg Cast]
// --------------------------------------------------------------------------
//! Cast this register to Xmm.
ASMJIT_INLINE X86XmmReg xmm() const { return X86XmmReg(kX86RegTypeXmm, getRegIndex(), 16); }
//! Cast this register to Ymm.
ASMJIT_INLINE X86YmmReg ymm() const { return X86YmmReg(kX86RegTypeYmm, getRegIndex(), 32); }
//! Cast this register to Zmm (clone).
ASMJIT_INLINE X86ZmmReg zmm() const { return X86ZmmReg(kX86RegTypeZmm, getRegIndex(), 64); }
}; };
ASMJIT_INLINE X86ZmmReg X86XmmReg::zmm() const { return X86ZmmReg(kX86RegTypeZmm, getRegIndex(), 64); }
ASMJIT_INLINE X86ZmmReg X86YmmReg::zmm() const { return X86ZmmReg(kX86RegTypeZmm, getRegIndex(), 64); }
// ============================================================================ // ============================================================================
// [asmjit::X86Mem] // [asmjit::X86Mem]
// ============================================================================ // ============================================================================