diff options
| author | Scott Mansell <phire@gmail.com> | 2015-03-16 22:58:40 +1300 |
|---|---|---|
| committer | Scott Mansell <phire@gmail.com> | 2015-03-17 18:49:26 +1300 |
| commit | 6262a9bcbecf802d73bd85ef6e5d02f10f21324b (patch) | |
| tree | 6ae6bb315c6736dcae89744db5e5666a1d6463a7 /Source/Core/Common | |
| parent | 4b7748f3c0e9dc9f2e6796d6d2ab30e37f6e6d86 (diff) | |
Make immediates more explicit
Instead of just casting OpArg::offset when needed, add some
accessor functions.
Also add some safety asserts to catch any mistakes.
Diffstat (limited to 'Source/Core/Common')
| -rw-r--r-- | Source/Core/Common/x64Emitter.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Source/Core/Common/x64Emitter.h b/Source/Core/Common/x64Emitter.h index 1c32c54969..2376f48b0f 100644 --- a/Source/Core/Common/x64Emitter.h +++ b/Source/Core/Common/x64Emitter.h @@ -149,9 +149,19 @@ struct OpArg void WriteFloatModRM(XEmitter *emit, FloatOp op); void WriteSingleByteOp(XEmitter *emit, u8 op, X64Reg operandReg, int bits); // This one is public - must be written to - u64 offset; // use RIP-relative as much as possible - 64-bit immediates are not available. + u64 offset; // use RIP-relative as much as possible - Also used to store immediates. u16 operandReg; + u64 Imm64() const { _dbg_assert_(DYNA_REC, scale == SCALE_IMM64); return (u64)offset; } + u32 Imm32() const { _dbg_assert_(DYNA_REC, scale == SCALE_IMM32); return (u32)offset; } + u16 Imm16() const { _dbg_assert_(DYNA_REC, scale == SCALE_IMM16); return (u16)offset; } + u8 Imm8() const { _dbg_assert_(DYNA_REC, scale == SCALE_IMM8); return (u8)offset; } + + s64 SImm64() const { _dbg_assert_(DYNA_REC, scale == SCALE_IMM64); return (s64)offset; } + s32 SImm32() const { _dbg_assert_(DYNA_REC, scale == SCALE_IMM32); return (s32)offset; } + s16 SImm16() const { _dbg_assert_(DYNA_REC, scale == SCALE_IMM16); return (s16)offset; } + s8 SImm8() const { _dbg_assert_(DYNA_REC, scale == SCALE_IMM8); return (s8)offset; } + void WriteNormalOp(XEmitter *emit, bool toRM, NormalOp op, const OpArg &operand, int bits) const; bool IsImm() const {return scale == SCALE_IMM8 || scale == SCALE_IMM16 || scale == SCALE_IMM32 || scale == SCALE_IMM64;} bool IsSimpleReg() const {return scale == SCALE_NONE;} |
