Copyright | (c) 2006-2015 Martin Grabmueller and Dirk Kleeblatt |
---|---|
License | BSD3 |
Maintainer | martin@grabmueller.de |
Stability | provisional |
Portability | portable (but generated code non-portable) |
Safe Haskell | None |
Language | Haskell98 |
- Types
- Constants
- Functions
- Utility functions
- Code emission
- Call instructions
- Function prologue and epilogue
- Jump and branch
- Stack operations
- Data movement
- Arithmetic
- Exchange
- String operations
- Bitwise shift
- Conditional move
- Conditional set
- Address calculation
- Conversion
- Floating point
- SSE instructions
- Prefetch instructions
- Miscellaneous
- Other utilities
Functions for generating x86 machine code instructions. The functions make use of the code generation monad in module Harpy.CodeGenMonad for emitting binary code into a code buffer.
This module is very low-level, since there are different functions for different addressing modes. A more convenient interface is provided in module Harpy.X86Assembler, which uses the operand types to determine the correct addressing modes for all supported instructions.
Note: this file does not (yet) provide the complete x86 instruction set, not even all user-mode instructions. For some operations, some addressing modes are missing as well.
Copyright notice:
The information in this file is based on the header file x86-codegen.h from the mono distribution, which has the following copyright information:
* x86-codegen.h: Macros for generating x86 code * * Authors: * Paolo Molaro (lupus@ximian.com) * Intel Corporation (ORP Project) * Sergey Chaban (serge@wildwestsoftware.com) * Dietmar Maurer (dietmar@ximian.com) * Patrik Torstensson * * Copyright (C) 2000 Intel Corporation. All rights reserved. * Copyright (C) 2001, 2002 Ximian, Inc. *
- data X86_SSE_PFX
- x86_dword_size :: Int
- x86_qword_size :: Int
- x86_max_instruction_bytes :: Int
- x86_eax :: Word8
- x86_ecx :: Word8
- x86_edx :: Word8
- x86_ebx :: Word8
- x86_esp :: Word8
- x86_ebp :: Word8
- x86_esi :: Word8
- x86_edi :: Word8
- x86_nobasereg :: Word8
- x86_eax_mask :: Int
- x86_ecx_mask :: Int
- x86_edx_mask :: Int
- x86_ebx_mask :: Int
- x86_esi_mask :: Int
- x86_edi_mask :: Int
- x86_ebp_mask :: Int
- x86_callee_regs :: Int
- x86_caller_regs :: Int
- x86_byte_regs :: Int
- x86_add :: Word8
- x86_or :: Word8
- x86_adc :: Word8
- x86_sbb :: Word8
- x86_and :: Word8
- x86_sub :: Word8
- x86_xor :: Word8
- x86_cmp :: Word8
- x86_rol :: Word8
- x86_ror :: Word8
- x86_rcl :: Word8
- x86_rcr :: Word8
- x86_shl :: Word8
- x86_shr :: Word8
- x86_sar :: Word8
- x86_shld :: Word8
- x86_shlr :: Word8
- x86_fadd :: Word8
- x86_fmul :: Word8
- x86_fcom :: Word8
- x86_fcomp :: Word8
- x86_fsub :: Word8
- x86_fsubr :: Word8
- x86_fdiv :: Word8
- x86_fdivr :: Word8
- x86_fp_c0 :: Word32
- x86_fp_c1 :: Word32
- x86_fp_c2 :: Word32
- x86_fp_c3 :: Word32
- x86_fp_cc_mask :: Word32
- x86_fpcw_invopex_mask :: Word32
- x86_fpcw_denopex_mask :: Word32
- x86_fpcw_zerodiv_mask :: Word32
- x86_fpcw_ovfex_mask :: Word32
- x86_fpcw_undfex_mask :: Word32
- x86_fpcw_precex_mask :: Word32
- x86_fpcw_precc_mask :: Word32
- x86_fpcw_roundc_mask :: Word32
- x86_fpcw_prec_single :: Word32
- x86_fpcw_prec_double :: Word32
- x86_fpcw_prec_extended :: Word32
- x86_fpcw_round_nearest :: Word32
- x86_fpcw_round_down :: Word32
- x86_fpcw_round_up :: Word32
- x86_fpcw_round_tozero :: Word32
- x86_cc_eq :: Int
- x86_cc_e :: Int
- x86_cc_z :: Int
- x86_cc_ne :: Int
- x86_cc_nz :: Int
- x86_cc_lt :: Int
- x86_cc_b :: Int
- x86_cc_c :: Int
- x86_cc_nae :: Int
- x86_cc_le :: Int
- x86_cc_be :: Int
- x86_cc_na :: Int
- x86_cc_gt :: Int
- x86_cc_a :: Int
- x86_cc_nbe :: Int
- x86_cc_ge :: Int
- x86_cc_ae :: Int
- x86_cc_nb :: Int
- x86_cc_nc :: Int
- x86_cc_lz :: Int
- x86_cc_s :: Int
- x86_cc_gez :: Int
- x86_cc_ns :: Int
- x86_cc_p :: Int
- x86_cc_np :: Int
- x86_cc_pe :: Int
- x86_cc_po :: Int
- x86_cc_o :: Int
- x86_cc_no :: Int
- x86_lock_prefix :: Word8
- x86_repnz_prefix :: Word8
- x86_repz_prefix :: Word8
- x86_rep_prefix :: Word8
- x86_cs_prefix :: Word8
- x86_ss_prefix :: Word8
- x86_ds_prefix :: Word8
- x86_es_prefix :: Word8
- x86_fs_prefix :: Word8
- x86_gs_prefix :: Word8
- x86_unlikely_prefix :: Word8
- x86_likely_prefix :: Word8
- x86_operand_prefix :: Word8
- x86_address_prefix :: Word8
- x86_is_scratch :: Int -> Bool
- x86_is_callee :: Int -> Bool
- x86_imm_emit16 :: Word16 -> CodeGen e s ()
- x86_imm_emit8 :: Word8 -> CodeGen e s ()
- x86_imm_emit32 :: Word32 -> CodeGen e s ()
- x86_membase_emit :: Word8 -> Word8 -> Word32 -> CodeGen e s ()
- x86_alu_reg_imm :: Word8 -> Word8 -> Int -> CodeGen e s ()
- x86_call_hs :: FunPtr a -> CodeGen e s ()
- x86_call_membase :: Word8 -> Word32 -> CodeGen s e ()
- x86_call_mem :: Word32 -> CodeGen s e ()
- x86_call_reg :: Word8 -> CodeGen s e ()
- x86_call_code :: Int -> CodeGen s e ()
- x86_call_imm :: Word32 -> CodeGen s e ()
- x86_prolog :: Int -> Int -> CodeGen e s ()
- x86_epilog :: Int -> CodeGen e s ()
- x86_enter :: Word16 -> CodeGen s e ()
- x86_leave :: CodeGen s e ()
- x86_ret :: CodeGen s e ()
- x86_ret_imm :: Word16 -> CodeGen s e ()
- x86_jecxz :: Word8 -> CodeGen e s ()
- x86_branch :: Int -> Int -> Bool -> CodeGen e s ()
- x86_branch_pointer :: Int -> Ptr a -> Bool -> CodeGen e s ()
- x86_branch32 :: Int -> Word32 -> Bool -> CodeGen e s ()
- x86_branch8 :: Int -> Word8 -> Bool -> CodeGen e s ()
- x86_jump_membase :: Word8 -> Word32 -> CodeGen e s ()
- x86_jump_pointer :: Ptr a -> CodeGen e s ()
- x86_jump_mem :: Word32 -> CodeGen e s ()
- x86_jump_reg :: Word8 -> CodeGen e s ()
- x86_jump32 :: Word32 -> CodeGen e s ()
- x86_jump8 :: Word8 -> CodeGen e s ()
- x86_loopne :: Word8 -> CodeGen e s ()
- x86_loope :: Word8 -> CodeGen e s ()
- x86_loop :: Word8 -> CodeGen e s ()
- x86_push_reg :: Word8 -> CodeGen e s ()
- x86_push_regp :: Word8 -> CodeGen e s ()
- x86_push_mem :: Word32 -> CodeGen e s ()
- x86_push_membase :: Word8 -> Word32 -> CodeGen e s ()
- x86_push_imm :: Word32 -> CodeGen e s ()
- x86_push_imm_template :: CodeGen e s ()
- x86_push_memindex :: Word8 -> Word32 -> Word8 -> Word8 -> CodeGen e s ()
- x86_pop_membase :: Word8 -> Word32 -> CodeGen e s ()
- x86_pop_mem :: Word32 -> CodeGen e s ()
- x86_pop_reg :: Word8 -> CodeGen e s ()
- x86_popfd :: CodeGen e s ()
- x86_pushfd :: CodeGen e s ()
- x86_popad :: CodeGen e s ()
- x86_pushad :: CodeGen e s ()
- x86_mov_reg_reg :: (Eq t, Num t) => Word8 -> Word8 -> t -> CodeGen e s ()
- x86_mov_reg_imm :: Word8 -> Word32 -> CodeGen e s ()
- x86_mov_mem_imm :: (Eq a, Num a) => Word32 -> Word32 -> a -> CodeGen e s ()
- x86_mov_membase_imm :: (Eq a, Num a) => Word8 -> Word32 -> Word32 -> a -> CodeGen e s ()
- x86_mov_memindex_imm :: (Eq a, Num a) => Word8 -> Word32 -> Word8 -> Word8 -> Word32 -> a -> CodeGen e s ()
- x86_mov_mem_reg :: (Eq t, Num t) => Word32 -> Word8 -> t -> CodeGen e s ()
- x86_mov_reg_mem :: (Eq t, Num t) => Word8 -> Word32 -> t -> CodeGen e s ()
- x86_mov_regp_reg :: (Eq t, Num t) => Word8 -> Word8 -> t -> CodeGen e s ()
- x86_mov_reg_regp :: (Eq t, Num t) => Word8 -> Word8 -> t -> CodeGen e s ()
- x86_mov_membase_reg :: (Eq t, Num t) => Word8 -> Word32 -> Word8 -> t -> CodeGen e s ()
- x86_mov_reg_membase :: (Eq t, Num t) => Word8 -> Word8 -> Word32 -> t -> CodeGen e s ()
- x86_mov_memindex_reg :: (Eq t, Num t) => Word8 -> Word32 -> Word8 -> Word8 -> Word8 -> t -> CodeGen e s ()
- x86_mov_reg_memindex :: (Eq t, Num t) => Word8 -> Word8 -> Word32 -> Word8 -> Word8 -> t -> CodeGen e s ()
- x86_xadd_reg_reg :: (Eq a, Num a) => Word8 -> Word8 -> a -> CodeGen e s ()
- x86_xadd_mem_reg :: (Eq a, Num a) => Word32 -> Word8 -> a -> CodeGen e s ()
- x86_xadd_membase_reg :: (Eq a, Num a) => Word8 -> Word32 -> Word8 -> a -> CodeGen e s ()
- x86_inc_mem :: Word32 -> CodeGen e s ()
- x86_inc_membase :: Word8 -> Word32 -> CodeGen e s ()
- x86_inc_reg :: Word8 -> CodeGen e s ()
- x86_dec_mem :: Word32 -> CodeGen e s ()
- x86_dec_membase :: Word8 -> Word32 -> CodeGen e s ()
- x86_dec_reg :: Word8 -> CodeGen e s ()
- x86_not_mem :: Word32 -> CodeGen e s ()
- x86_not_membase :: Word8 -> Word32 -> CodeGen e s ()
- x86_not_reg :: Word8 -> CodeGen e s ()
- x86_neg_mem :: Word32 -> CodeGen e s ()
- x86_neg_membase :: Word8 -> Word32 -> CodeGen e s ()
- x86_neg_reg :: Word8 -> CodeGen e s ()
- x86_alu_mem_imm :: Word8 -> Word32 -> Word32 -> CodeGen e s ()
- x86_alu_membase_imm :: Word8 -> Word8 -> Word32 -> Word32 -> CodeGen e s ()
- x86_alu_membase8_imm :: Word8 -> Word8 -> Word32 -> Word8 -> CodeGen e s ()
- x86_alu_mem_reg :: Word8 -> Word32 -> Word8 -> CodeGen e s ()
- x86_alu_membase_reg :: Word8 -> Word8 -> Word32 -> Word8 -> CodeGen e s ()
- x86_alu_reg_reg :: Word8 -> Word8 -> Word8 -> CodeGen e s ()
- x86_alu_reg8_reg8 :: Word8 -> Word8 -> Word8 -> Bool -> Bool -> CodeGen e s ()
- x86_alu_reg_mem :: Word8 -> Word8 -> Word32 -> CodeGen e s ()
- x86_alu_reg_membase :: Word8 -> Word8 -> Word8 -> Word32 -> CodeGen e s ()
- x86_mul_reg :: Word8 -> Bool -> CodeGen e s ()
- x86_mul_mem :: Word32 -> Bool -> CodeGen e s ()
- x86_mul_membase :: Word8 -> Word32 -> Bool -> CodeGen e s ()
- x86_imul_reg_reg :: Word8 -> Word8 -> CodeGen e s ()
- x86_imul_reg_membase :: Word8 -> Word8 -> Word32 -> CodeGen e s ()
- x86_imul_reg_reg_imm :: Word8 -> Word8 -> Word32 -> CodeGen e s ()
- x86_imul_reg_mem :: Word8 -> Word32 -> CodeGen e s ()
- x86_imul_reg_mem_imm :: Word8 -> Word32 -> Word32 -> CodeGen e s ()
- x86_imul_reg_membase_imm :: Word8 -> Word8 -> Word32 -> Word32 -> CodeGen e s ()
- x86_div_reg :: Word8 -> Bool -> CodeGen e s ()
- x86_div_mem :: Word32 -> Bool -> CodeGen e s ()
- x86_div_membase :: Word8 -> Word32 -> Bool -> CodeGen e s ()
- x86_test_reg_imm :: Word8 -> Word32 -> CodeGen e s ()
- x86_test_mem_imm :: Word32 -> Word32 -> CodeGen e s ()
- x86_test_membase_imm :: Word8 -> Word32 -> Word32 -> CodeGen e s ()
- x86_test_reg_reg :: Word8 -> Word8 -> CodeGen e s ()
- x86_test_mem_reg :: Word32 -> Word8 -> CodeGen e s ()
- x86_test_membase_reg :: Word8 -> Word32 -> Word8 -> CodeGen e s ()
- x86_cmpxchg_reg_reg :: Word8 -> Word8 -> CodeGen e s ()
- x86_cmpxchg_mem_reg :: Word32 -> Word8 -> CodeGen e s ()
- x86_cmpxchg_membase_reg :: Word8 -> Word32 -> Word8 -> CodeGen e s ()
- x86_xchg_reg_reg :: (Eq a, Num a) => Word8 -> Word8 -> a -> CodeGen e s ()
- x86_xchg_mem_reg :: (Eq a, Num a) => Word32 -> Word8 -> a -> CodeGen e s ()
- x86_xchg_membase_reg :: (Eq a, Num a) => Word8 -> Word32 -> Word8 -> a -> CodeGen e s ()
- x86_stosb :: CodeGen s e ()
- x86_stosl :: CodeGen s e ()
- x86_stosd :: CodeGen s e ()
- x86_movsb :: CodeGen s e ()
- x86_movsl :: CodeGen s e ()
- x86_movsd :: CodeGen s e ()
- x86_shift_reg_imm :: Word8 -> Word8 -> Word8 -> CodeGen e s ()
- x86_shift_mem_imm :: Word8 -> Word32 -> Word8 -> CodeGen e s ()
- x86_shift_membase_imm :: Word8 -> Word8 -> Word32 -> Word8 -> CodeGen e s ()
- x86_shift_reg :: Word8 -> Word8 -> CodeGen e s ()
- x86_shift_mem :: Word8 -> Word32 -> CodeGen e s ()
- x86_shift_membase :: Word8 -> Word8 -> Word32 -> CodeGen e s ()
- x86_shrd_reg :: Word8 -> Word8 -> CodeGen e s ()
- x86_shrd_reg_imm :: Word8 -> Word8 -> Word8 -> CodeGen e s ()
- x86_shld_reg :: Word8 -> Word8 -> CodeGen e s ()
- x86_shld_reg_imm :: Word8 -> Word8 -> Word8 -> CodeGen e s ()
- x86_cmov_membase :: Int -> Bool -> Word8 -> Word8 -> Word32 -> CodeGen e s ()
- x86_cmov_mem :: Int -> Bool -> Word8 -> Word32 -> CodeGen e s ()
- x86_cmov_reg :: Int -> Bool -> Word8 -> Word8 -> CodeGen e s ()
- x86_set_membase :: Int -> Word8 -> Word32 -> Bool -> CodeGen e s ()
- x86_set_mem :: Int -> Word32 -> Bool -> CodeGen e s ()
- x86_set_reg :: Int -> Word8 -> Bool -> CodeGen e s ()
- x86_lea_mem :: Word8 -> Word32 -> CodeGen e s ()
- x86_lea_membase :: Word8 -> Word8 -> Word32 -> CodeGen e s ()
- x86_lea_memindex :: Word8 -> Word8 -> Word32 -> Word8 -> Word8 -> CodeGen e s ()
- x86_cdq :: CodeGen s e ()
- x86_widen_memindex :: Word8 -> Word8 -> Word32 -> Word8 -> Word8 -> Bool -> Bool -> CodeGen e s ()
- x86_widen_membase :: Word8 -> Word8 -> Word32 -> Bool -> Bool -> CodeGen e s ()
- x86_widen_mem :: Word8 -> Word32 -> Bool -> Bool -> CodeGen e s ()
- x86_widen_reg :: Word8 -> Word8 -> Bool -> Bool -> CodeGen e s ()
- x86_fp_op_mem :: Word8 -> Word32 -> Bool -> CodeGen e s ()
- x86_fp_op_membase :: Word8 -> Word8 -> Word32 -> Bool -> CodeGen e s ()
- x86_fp_op :: Word8 -> Word8 -> CodeGen e s ()
- x86_fp_op_reg :: Word8 -> Word8 -> Bool -> CodeGen e s ()
- x86_fp_int_op_membase :: Word8 -> Word8 -> Word32 -> Bool -> CodeGen e s ()
- x86_fstp :: Word8 -> CodeGen e s ()
- x86_fcompp :: CodeGen e s ()
- x86_fucompp :: CodeGen e s ()
- x86_fnstsw :: CodeGen e s ()
- x86_fnstcw :: Word32 -> CodeGen e s ()
- x86_fnstcw_membase :: Word8 -> Word32 -> CodeGen e s ()
- x86_fldcw :: Word32 -> CodeGen e s ()
- x86_fldcw_membase :: Word8 -> Word32 -> CodeGen e s ()
- x86_fchs :: CodeGen e s ()
- x86_frem :: CodeGen e s ()
- x86_fxch :: Word8 -> CodeGen e s ()
- x86_fcomi :: Word8 -> CodeGen e s ()
- x86_fcomip :: Word8 -> CodeGen e s ()
- x86_fucomi :: Word8 -> CodeGen e s ()
- x86_fucomip :: Word8 -> CodeGen e s ()
- x86_fld :: Word32 -> Bool -> CodeGen e s ()
- x86_fld_membase :: Word8 -> Word32 -> Bool -> CodeGen e s ()
- x86_fld80_mem :: Word32 -> CodeGen e s ()
- x86_fld80_membase :: Word8 -> Word32 -> CodeGen e s ()
- x86_fld_reg :: Word8 -> CodeGen e s ()
- x86_fldz :: CodeGen e s ()
- x86_fld1 :: CodeGen e s ()
- x86_fldpi :: CodeGen e s ()
- x86_fst :: Word32 -> Bool -> Bool -> CodeGen e s ()
- x86_fst_membase :: Word8 -> Word32 -> Bool -> Bool -> CodeGen e s ()
- x86_fst80_mem :: Word32 -> CodeGen e s ()
- x86_fst80_membase :: Word8 -> Word32 -> CodeGen e s ()
- data FIntSize
- x86_fist_pop :: Word32 -> FIntSize -> CodeGen e s ()
- x86_fist_pop_membase :: Word8 -> Word32 -> FIntSize -> CodeGen e s ()
- x86_fstsw :: CodeGen e s ()
- x86_fist_membase :: Word8 -> Word32 -> FIntSize -> CodeGen e s ()
- x86_fild :: Word32 -> FIntSize -> CodeGen e s ()
- x86_fild_membase :: Word8 -> Word32 -> FIntSize -> CodeGen e s ()
- x86_fsin :: CodeGen s e ()
- x86_fcos :: CodeGen s e ()
- x86_fabs :: CodeGen s e ()
- x86_ftst :: CodeGen s e ()
- x86_fxam :: CodeGen s e ()
- x86_fpatan :: CodeGen s e ()
- x86_fprem :: CodeGen s e ()
- x86_fprem1 :: CodeGen s e ()
- x86_frndint :: CodeGen s e ()
- x86_fsqrt :: CodeGen s e ()
- x86_fptan :: CodeGen s e ()
- x86_fincstp :: CodeGen e s ()
- x86_fdecstp :: CodeGen e s ()
- x86_sse_ps :: X86_SSE_PFX
- x86_sse_pd :: X86_SSE_PFX
- x86_sse_ss :: X86_SSE_PFX
- x86_sse_sd :: X86_SSE_PFX
- x86_add_sse_reg_reg :: X86_SSE_PFX -> Word8 -> Word8 -> CodeGen e s ()
- x86_add_sse_reg_mem :: X86_SSE_PFX -> Word8 -> Word32 -> CodeGen e s ()
- x86_add_sse_reg_membase :: X86_SSE_PFX -> Word8 -> Word8 -> Word32 -> CodeGen e s ()
- x86_sub_sse_reg_reg :: X86_SSE_PFX -> Word8 -> Word8 -> CodeGen e s ()
- x86_sub_sse_reg_mem :: X86_SSE_PFX -> Word8 -> Word32 -> CodeGen e s ()
- x86_sub_sse_reg_membase :: X86_SSE_PFX -> Word8 -> Word8 -> Word32 -> CodeGen e s ()
- x86_mul_sse_reg_reg :: X86_SSE_PFX -> Word8 -> Word8 -> CodeGen e s ()
- x86_mul_sse_reg_mem :: X86_SSE_PFX -> Word8 -> Word32 -> CodeGen e s ()
- x86_mul_sse_reg_membase :: X86_SSE_PFX -> Word8 -> Word8 -> Word32 -> CodeGen e s ()
- x86_div_sse_reg_reg :: X86_SSE_PFX -> Word8 -> Word8 -> CodeGen e s ()
- x86_div_sse_reg_mem :: X86_SSE_PFX -> Word8 -> Word32 -> CodeGen e s ()
- x86_div_sse_reg_membase :: X86_SSE_PFX -> Word8 -> Word8 -> Word32 -> CodeGen e s ()
- x86_max_sse_reg_reg :: X86_SSE_PFX -> Word8 -> Word8 -> CodeGen e s ()
- x86_max_sse_reg_mem :: X86_SSE_PFX -> Word8 -> Word32 -> CodeGen e s ()
- x86_max_sse_reg_membase :: X86_SSE_PFX -> Word8 -> Word8 -> Word32 -> CodeGen e s ()
- x86_min_sse_reg_reg :: X86_SSE_PFX -> Word8 -> Word8 -> CodeGen e s ()
- x86_min_sse_reg_mem :: X86_SSE_PFX -> Word8 -> Word32 -> CodeGen e s ()
- x86_min_sse_reg_membase :: X86_SSE_PFX -> Word8 -> Word8 -> Word32 -> CodeGen e s ()
- x86_sqrt_sse_reg_reg :: X86_SSE_PFX -> Word8 -> Word8 -> CodeGen e s ()
- x86_sqrt_sse_reg_mem :: X86_SSE_PFX -> Word8 -> Word32 -> CodeGen e s ()
- x86_sqrt_sse_reg_membase :: X86_SSE_PFX -> Word8 -> Word8 -> Word32 -> CodeGen e s ()
- x86_mov_sse_reg_reg :: X86_SSE_PFX -> Word8 -> Word8 -> CodeGen e s ()
- x86_mov_sse_reg_mem :: X86_SSE_PFX -> Word8 -> Word32 -> CodeGen e s ()
- x86_mov_sse_reg_membase :: X86_SSE_PFX -> Word8 -> Word8 -> Word32 -> CodeGen e s ()
- x86_mov_sse_mem_reg :: X86_SSE_PFX -> Word32 -> Word8 -> CodeGen e s ()
- x86_mov_sse_membase_reg :: X86_SSE_PFX -> Word8 -> Word32 -> Word8 -> CodeGen e s ()
- x86_ucomisd_reg_reg :: Word8 -> Word8 -> CodeGen e s ()
- x86_ucomisd_reg_mem :: Word8 -> Word32 -> CodeGen e s ()
- x86_ucomisd_reg_membase :: Word8 -> Word8 -> Word32 -> CodeGen e s ()
- x86_ucomiss_reg_reg :: Word8 -> Word8 -> CodeGen e s ()
- x86_ucomiss_reg_mem :: Word8 -> Word32 -> CodeGen e s ()
- x86_ucomiss_reg_membase :: Word8 -> Word8 -> Word32 -> CodeGen e s ()
- x86_comisd_reg_reg :: Word8 -> Word8 -> CodeGen e s ()
- x86_comisd_reg_mem :: Word8 -> Word32 -> CodeGen e s ()
- x86_comisd_reg_membase :: Word8 -> Word8 -> Word32 -> CodeGen e s ()
- x86_comiss_reg_reg :: Word8 -> Word8 -> CodeGen e s ()
- x86_comiss_reg_mem :: Word8 -> Word32 -> CodeGen e s ()
- x86_comiss_reg_membase :: Word8 -> Word8 -> Word32 -> CodeGen e s ()
- newtype XMMReg = XMMReg Word8
- newtype Mem = Mem Word32
- data MemBase = MemBase Word8 Word32
- class XMMLocation xmm where
- xmm_location_emit :: Word8 -> xmm -> CodeGen e s ()
- x86_movss_to_reg :: XMMLocation xmm => Word8 -> xmm -> CodeGen e s ()
- x86_movss_from_reg :: XMMLocation xmm => Word8 -> xmm -> CodeGen e s ()
- x86_movsd_to_reg :: XMMLocation xmm => Word8 -> xmm -> CodeGen e s ()
- x86_movsd_from_reg :: XMMLocation xmm => Word8 -> xmm -> CodeGen e s ()
- x86_movlps_to_reg :: XMMLocation xmm => Word8 -> xmm -> CodeGen e s ()
- x86_movlps_from_reg :: XMMLocation xmm => Word8 -> xmm -> CodeGen e s ()
- x86_movlpd_to_reg :: XMMLocation xmm => Word8 -> xmm -> CodeGen e s ()
- x86_movlpd_from_reg :: XMMLocation xmm => Word8 -> xmm -> CodeGen e s ()
- x86_movups_to_reg :: XMMLocation xmm => Word8 -> xmm -> CodeGen e s ()
- x86_movups_from_reg :: XMMLocation xmm => Word8 -> xmm -> CodeGen e s ()
- x86_movupd_to_reg :: XMMLocation xmm => Word8 -> xmm -> CodeGen e s ()
- x86_movupd_from_reg :: XMMLocation xmm => Word8 -> xmm -> CodeGen e s ()
- x86_haddps :: XMMLocation xmm => Word8 -> xmm -> CodeGen e s ()
- x86_haddpd :: XMMLocation xmm => Word8 -> xmm -> CodeGen e s ()
- x86_shufps :: XMMLocation xmm => Word8 -> xmm -> Word8 -> CodeGen e s ()
- x86_shufpd :: XMMLocation xmm => Word8 -> xmm -> Word8 -> CodeGen e s ()
- x86_cvtdq2ps :: XMMLocation xmm => Word8 -> xmm -> CodeGen e s ()
- x86_cvttps2dq :: XMMLocation xmm => Word8 -> xmm -> CodeGen e s ()
- x86_prefetch0_mem :: Word32 -> CodeGen e s ()
- x86_prefetch1_mem :: Word32 -> CodeGen e s ()
- x86_prefetch2_mem :: Word32 -> CodeGen e s ()
- x86_prefetchnta_mem :: Word32 -> CodeGen e s ()
- x86_prefetch0_membase :: Word8 -> Word32 -> CodeGen e s ()
- x86_prefetch1_membase :: Word8 -> Word32 -> CodeGen e s ()
- x86_prefetch2_membase :: Word8 -> Word32 -> CodeGen e s ()
- x86_prefetchnta_membase :: Word8 -> Word32 -> CodeGen e s ()
- x86_prefetch0_regp :: Word8 -> CodeGen e s ()
- x86_prefetch1_regp :: Word8 -> CodeGen e s ()
- x86_prefetch2_regp :: Word8 -> CodeGen e s ()
- x86_prefetchnta_regp :: Word8 -> CodeGen e s ()
- x86_sahf :: CodeGen s e ()
- x86_wait :: CodeGen s e ()
- x86_nop :: CodeGen s e ()
- x86_breakpoint :: CodeGen s e ()
- x86_rdtsc :: CodeGen s e ()
- x86_cld :: CodeGen s e ()
- x86_prefix :: Word8 -> CodeGen s e ()
- x86_padding :: (Eq t, Num t) => t -> CodeGen e s ()
- negateCC :: Int -> Int
Types
data X86_SSE_PFX Source
Constants
Machine characteristics
Sizes of various machine data types in bytes.
x86_max_instruction_bytes :: Int Source
Maximal length of an x86 instruction in bytes.
Register numbers
x86 general-purpose register numbers
Used to encode the fact that no base register is used in an instruction.
Register masks and predicates
Bitvector masks for general-purpose registers
Bitvector mask for callee-saved registers
Bitvector mask for caller-saved registers
Bitvector mask for byte-adressable registers
ALU operations
Opcodes for ALU instructions
Shift operations
Opcodes for shift instructions
FP operations
Opcodes for floating-point instructions
FP conditions and control codes
FP status word codes
x86_fp_cc_mask :: Word32 Source
FP status
FP control word codes
x86_fpcw_invopex_mask :: Word32 Source
FP control word
x86_fpcw_denopex_mask :: Word32 Source
FP control word
x86_fpcw_zerodiv_mask :: Word32 Source
FP control word
x86_fpcw_ovfex_mask :: Word32 Source
FP control word
x86_fpcw_undfex_mask :: Word32 Source
FP control word
x86_fpcw_precex_mask :: Word32 Source
FP control word
x86_fpcw_precc_mask :: Word32 Source
FP control word
x86_fpcw_roundc_mask :: Word32 Source
FP control word
x86_fpcw_prec_single :: Word32 Source
Values for precision control
x86_fpcw_prec_double :: Word32 Source
Values for precision control
x86_fpcw_prec_extended :: Word32 Source
Values for precision control
x86_fpcw_round_nearest :: Word32 Source
Values for rounding control
x86_fpcw_round_down :: Word32 Source
Values for rounding control
x86_fpcw_round_up :: Word32 Source
Values for rounding control
x86_fpcw_round_tozero :: Word32 Source
Values for rounding control
Condition codes
Integer conditions codes
x86_cc_nae :: Int Source
x86_cc_nbe :: Int Source
x86_cc_gez :: Int Source
Instruction prefix codes
x86_lock_prefix :: Word8 Source
Prefix codes
x86_repnz_prefix :: Word8 Source
Prefix codes
x86_repz_prefix :: Word8 Source
Prefix codes
x86_rep_prefix :: Word8 Source
Prefix codes
Prefix codes
Prefix codes
Prefix codes
Prefix codes
Prefix codes
Prefix codes
x86_unlikely_prefix :: Word8 Source
Prefix codes
x86_likely_prefix :: Word8 Source
Prefix codes
x86_operand_prefix :: Word8 Source
Prefix codes
x86_address_prefix :: Word8 Source
Prefix codes
Functions
Utility functions
x86_is_scratch :: Int -> Bool Source
Returns true when the given register is caller-saved.
x86_is_callee :: Int -> Bool Source
Returns true when the given register is caller-saved.
Code emission
These functions are used to emit parts of instructions, such as constants or operand descriptions.
x86_imm_emit16 :: Word16 -> CodeGen e s () Source
Emit a 16-bit constant to the instruction stream.
x86_imm_emit8 :: Word8 -> CodeGen e s () Source
Emit a 8-bit constant to the instruction stream.
x86_imm_emit32 :: Word32 -> CodeGen e s () Source
Emit a 32-bit constant to the instruction stream.
x86_membase_emit :: Word8 -> Word8 -> Word32 -> CodeGen e s () Source
Emit a mem+base address encoding
Call instructions
x86_call_hs :: FunPtr a -> CodeGen e s () Source
x86_call_membase :: Word8 -> Word32 -> CodeGen s e () Source
x86_call_mem :: Word32 -> CodeGen s e () Source
x86_call_reg :: Word8 -> CodeGen s e () Source
x86_call_code :: Int -> CodeGen s e () Source
x86_call_imm :: Word32 -> CodeGen s e () Source
Function prologue and epilogue
x86_prolog :: Int -> Int -> CodeGen e s () Source
x86_epilog :: Int -> CodeGen e s () Source
x86_ret_imm :: Word16 -> CodeGen s e () Source
Jump and branch
x86_jump_membase :: Word8 -> Word32 -> CodeGen e s () Source
x86_jump_pointer :: Ptr a -> CodeGen e s () Source
x86_jump_mem :: Word32 -> CodeGen e s () Source
x86_jump_reg :: Word8 -> CodeGen e s () Source
x86_jump32 :: Word32 -> CodeGen e s () Source
x86_loopne :: Word8 -> CodeGen e s () Source
Stack operations
x86_push_reg :: Word8 -> CodeGen e s () Source
x86_push_regp :: Word8 -> CodeGen e s () Source
x86_push_mem :: Word32 -> CodeGen e s () Source
x86_push_membase :: Word8 -> Word32 -> CodeGen e s () Source
x86_push_imm :: Word32 -> CodeGen e s () Source
x86_push_imm_template :: CodeGen e s () Source
x86_pop_membase :: Word8 -> Word32 -> CodeGen e s () Source
x86_pop_mem :: Word32 -> CodeGen e s () Source
x86_pop_reg :: Word8 -> CodeGen e s () Source
x86_pushfd :: CodeGen e s () Source
x86_pushad :: CodeGen e s () Source
Data movement
x86_mov_reg_imm :: Word8 -> Word32 -> CodeGen e s () Source
x86_mov_memindex_imm :: (Eq a, Num a) => Word8 -> Word32 -> Word8 -> Word8 -> Word32 -> a -> CodeGen e s () Source
x86_mov_memindex_reg :: (Eq t, Num t) => Word8 -> Word32 -> Word8 -> Word8 -> Word8 -> t -> CodeGen e s () Source
x86_mov_reg_memindex :: (Eq t, Num t) => Word8 -> Word8 -> Word32 -> Word8 -> Word8 -> t -> CodeGen e s () Source
Arithmetic
x86_inc_mem :: Word32 -> CodeGen e s () Source
x86_inc_membase :: Word8 -> Word32 -> CodeGen e s () Source
x86_inc_reg :: Word8 -> CodeGen e s () Source
x86_dec_mem :: Word32 -> CodeGen e s () Source
x86_dec_membase :: Word8 -> Word32 -> CodeGen e s () Source
x86_dec_reg :: Word8 -> CodeGen e s () Source
x86_not_mem :: Word32 -> CodeGen e s () Source
x86_not_membase :: Word8 -> Word32 -> CodeGen e s () Source
x86_not_reg :: Word8 -> CodeGen e s () Source
x86_neg_mem :: Word32 -> CodeGen e s () Source
x86_neg_membase :: Word8 -> Word32 -> CodeGen e s () Source
x86_neg_reg :: Word8 -> CodeGen e s () Source
x86_mul_reg :: Word8 -> Bool -> CodeGen e s () Source
x86_mul_mem :: Word32 -> Bool -> CodeGen e s () Source
x86_imul_reg_reg :: Word8 -> Word8 -> CodeGen e s () Source
x86_imul_reg_mem :: Word8 -> Word32 -> CodeGen e s () Source
x86_div_reg :: Word8 -> Bool -> CodeGen e s () Source
x86_div_mem :: Word32 -> Bool -> CodeGen e s () Source
x86_test_reg_imm :: Word8 -> Word32 -> CodeGen e s () Source
x86_test_mem_imm :: Word32 -> Word32 -> CodeGen e s () Source
x86_test_reg_reg :: Word8 -> Word8 -> CodeGen e s () Source
x86_test_mem_reg :: Word32 -> Word8 -> CodeGen e s () Source
Exchange
x86_cmpxchg_reg_reg :: Word8 -> Word8 -> CodeGen e s () Source
x86_cmpxchg_mem_reg :: Word32 -> Word8 -> CodeGen e s () Source
String operations
Bitwise shift
x86_shift_reg :: Word8 -> Word8 -> CodeGen e s () Source
x86_shift_mem :: Word8 -> Word32 -> CodeGen e s () Source
x86_shrd_reg :: Word8 -> Word8 -> CodeGen e s () Source
x86_shld_reg :: Word8 -> Word8 -> CodeGen e s () Source
Conditional move
Conditional set
Address calculation
x86_lea_mem :: Word8 -> Word32 -> CodeGen e s () Source
Conversion
x86_widen_memindex :: Word8 -> Word8 -> Word32 -> Word8 -> Word8 -> Bool -> Bool -> CodeGen e s () Source
Floating point
x86_fcompp :: CodeGen e s () Source
x86_fucompp :: CodeGen e s () Source
x86_fnstsw :: CodeGen e s () Source
x86_fnstcw :: Word32 -> CodeGen e s () Source
x86_fnstcw_membase :: Word8 -> Word32 -> CodeGen e s () Source
x86_fldcw_membase :: Word8 -> Word32 -> CodeGen e s () Source
x86_fcomip :: Word8 -> CodeGen e s () Source
x86_fucomi :: Word8 -> CodeGen e s () Source
x86_fucomip :: Word8 -> CodeGen e s () Source
x86_fld80_mem :: Word32 -> CodeGen e s () Source
x86_fld80_membase :: Word8 -> Word32 -> CodeGen e s () Source
x86_fld_reg :: Word8 -> CodeGen e s () Source
x86_fst80_mem :: Word32 -> CodeGen e s () Source
x86_fst80_membase :: Word8 -> Word32 -> CodeGen e s () Source
x86_fist_pop :: Word32 -> FIntSize -> CodeGen e s () Source
x86_fpatan :: CodeGen s e () Source
x86_fprem1 :: CodeGen s e () Source
x86_frndint :: CodeGen s e () Source
x86_fincstp :: CodeGen e s () Source
x86_fdecstp :: CodeGen e s () Source
SSE instructions
x86_add_sse_reg_reg :: X86_SSE_PFX -> Word8 -> Word8 -> CodeGen e s () Source
x86_add_sse_reg_mem :: X86_SSE_PFX -> Word8 -> Word32 -> CodeGen e s () Source
x86_add_sse_reg_membase :: X86_SSE_PFX -> Word8 -> Word8 -> Word32 -> CodeGen e s () Source
x86_sub_sse_reg_reg :: X86_SSE_PFX -> Word8 -> Word8 -> CodeGen e s () Source
x86_sub_sse_reg_mem :: X86_SSE_PFX -> Word8 -> Word32 -> CodeGen e s () Source
x86_sub_sse_reg_membase :: X86_SSE_PFX -> Word8 -> Word8 -> Word32 -> CodeGen e s () Source
x86_mul_sse_reg_reg :: X86_SSE_PFX -> Word8 -> Word8 -> CodeGen e s () Source
x86_mul_sse_reg_mem :: X86_SSE_PFX -> Word8 -> Word32 -> CodeGen e s () Source
x86_mul_sse_reg_membase :: X86_SSE_PFX -> Word8 -> Word8 -> Word32 -> CodeGen e s () Source
x86_div_sse_reg_reg :: X86_SSE_PFX -> Word8 -> Word8 -> CodeGen e s () Source
x86_div_sse_reg_mem :: X86_SSE_PFX -> Word8 -> Word32 -> CodeGen e s () Source
x86_div_sse_reg_membase :: X86_SSE_PFX -> Word8 -> Word8 -> Word32 -> CodeGen e s () Source
x86_max_sse_reg_reg :: X86_SSE_PFX -> Word8 -> Word8 -> CodeGen e s () Source
x86_max_sse_reg_mem :: X86_SSE_PFX -> Word8 -> Word32 -> CodeGen e s () Source
x86_max_sse_reg_membase :: X86_SSE_PFX -> Word8 -> Word8 -> Word32 -> CodeGen e s () Source
x86_min_sse_reg_reg :: X86_SSE_PFX -> Word8 -> Word8 -> CodeGen e s () Source
x86_min_sse_reg_mem :: X86_SSE_PFX -> Word8 -> Word32 -> CodeGen e s () Source
x86_min_sse_reg_membase :: X86_SSE_PFX -> Word8 -> Word8 -> Word32 -> CodeGen e s () Source
x86_sqrt_sse_reg_reg :: X86_SSE_PFX -> Word8 -> Word8 -> CodeGen e s () Source
x86_sqrt_sse_reg_mem :: X86_SSE_PFX -> Word8 -> Word32 -> CodeGen e s () Source
x86_sqrt_sse_reg_membase :: X86_SSE_PFX -> Word8 -> Word8 -> Word32 -> CodeGen e s () Source
x86_mov_sse_reg_reg :: X86_SSE_PFX -> Word8 -> Word8 -> CodeGen e s () Source
x86_mov_sse_reg_mem :: X86_SSE_PFX -> Word8 -> Word32 -> CodeGen e s () Source
x86_mov_sse_reg_membase :: X86_SSE_PFX -> Word8 -> Word8 -> Word32 -> CodeGen e s () Source
x86_mov_sse_mem_reg :: X86_SSE_PFX -> Word32 -> Word8 -> CodeGen e s () Source
x86_mov_sse_membase_reg :: X86_SSE_PFX -> Word8 -> Word32 -> Word8 -> CodeGen e s () Source
x86_ucomisd_reg_reg :: Word8 -> Word8 -> CodeGen e s () Source
x86_ucomisd_reg_mem :: Word8 -> Word32 -> CodeGen e s () Source
x86_ucomiss_reg_reg :: Word8 -> Word8 -> CodeGen e s () Source
x86_ucomiss_reg_mem :: Word8 -> Word32 -> CodeGen e s () Source
x86_comisd_reg_reg :: Word8 -> Word8 -> CodeGen e s () Source
x86_comisd_reg_mem :: Word8 -> Word32 -> CodeGen e s () Source
x86_comiss_reg_reg :: Word8 -> Word8 -> CodeGen e s () Source
x86_comiss_reg_mem :: Word8 -> Word32 -> CodeGen e s () Source
class XMMLocation xmm where Source
xmm_location_emit :: Word8 -> xmm -> CodeGen e s () Source
x86_movss_to_reg :: XMMLocation xmm => Word8 -> xmm -> CodeGen e s () Source
x86_movss_from_reg :: XMMLocation xmm => Word8 -> xmm -> CodeGen e s () Source
x86_movsd_to_reg :: XMMLocation xmm => Word8 -> xmm -> CodeGen e s () Source
x86_movsd_from_reg :: XMMLocation xmm => Word8 -> xmm -> CodeGen e s () Source
x86_movlps_to_reg :: XMMLocation xmm => Word8 -> xmm -> CodeGen e s () Source
xmm must not be a register
x86_movlps_from_reg :: XMMLocation xmm => Word8 -> xmm -> CodeGen e s () Source
xmm must not be a register
x86_movlpd_to_reg :: XMMLocation xmm => Word8 -> xmm -> CodeGen e s () Source
xmm must not be a register
x86_movlpd_from_reg :: XMMLocation xmm => Word8 -> xmm -> CodeGen e s () Source
xmm must not be a register
x86_movups_to_reg :: XMMLocation xmm => Word8 -> xmm -> CodeGen e s () Source
x86_movups_from_reg :: XMMLocation xmm => Word8 -> xmm -> CodeGen e s () Source
x86_movupd_to_reg :: XMMLocation xmm => Word8 -> xmm -> CodeGen e s () Source
x86_movupd_from_reg :: XMMLocation xmm => Word8 -> xmm -> CodeGen e s () Source
x86_haddps :: XMMLocation xmm => Word8 -> xmm -> CodeGen e s () Source
x86_haddpd :: XMMLocation xmm => Word8 -> xmm -> CodeGen e s () Source
x86_shufps :: XMMLocation xmm => Word8 -> xmm -> Word8 -> CodeGen e s () Source
x86_shufpd :: XMMLocation xmm => Word8 -> xmm -> Word8 -> CodeGen e s () Source
x86_cvtdq2ps :: XMMLocation xmm => Word8 -> xmm -> CodeGen e s () Source
x86_cvttps2dq :: XMMLocation xmm => Word8 -> xmm -> CodeGen e s () Source
Prefetch instructions
x86_prefetch0_mem :: Word32 -> CodeGen e s () Source
x86_prefetch1_mem :: Word32 -> CodeGen e s () Source
x86_prefetch2_mem :: Word32 -> CodeGen e s () Source
x86_prefetchnta_mem :: Word32 -> CodeGen e s () Source
x86_prefetch0_membase :: Word8 -> Word32 -> CodeGen e s () Source
x86_prefetch1_membase :: Word8 -> Word32 -> CodeGen e s () Source
x86_prefetch2_membase :: Word8 -> Word32 -> CodeGen e s () Source
x86_prefetchnta_membase :: Word8 -> Word32 -> CodeGen e s () Source
x86_prefetch0_regp :: Word8 -> CodeGen e s () Source
x86_prefetch1_regp :: Word8 -> CodeGen e s () Source
x86_prefetch2_regp :: Word8 -> CodeGen e s () Source
x86_prefetchnta_regp :: Word8 -> CodeGen e s () Source
Miscellaneous
x86_breakpoint :: CodeGen s e () Source
x86_prefix :: Word8 -> CodeGen s e () Source
x86_padding :: (Eq t, Num t) => t -> CodeGen e s () Source