x86-64bit-0.4.6.2: Runtime code generation for x86 64 bit machine code
Safe HaskellNone
LanguageHaskell2010

CodeGen.X86.Asm

Synopsis

Documentation

everyNth :: Int -> [a] -> [[a]] Source #

showNibble :: (Integral a, Bits a) => Int -> a -> Char Source #

showByte :: (Integral a, Bits a) => a -> [Char] Source #

showHex' :: (Integral a, Show a) => a -> [Char] Source #

pattern Integral :: (Integral a, Integral b, Bits a, Bits b) => b -> a Source #

type Bytes = [Word8] Source #

class HasBytes a where Source #

Methods

toBytes :: a -> Bytes Source #

Instances

Instances details
HasBytes Int8 Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

toBytes :: Int8 -> Bytes Source #

HasBytes Int16 Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

toBytes :: Int16 -> Bytes Source #

HasBytes Int32 Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

toBytes :: Int32 -> Bytes Source #

HasBytes Int64 Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

toBytes :: Int64 -> Bytes Source #

HasBytes Word8 Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

toBytes :: Word8 -> Bytes Source #

HasBytes Word16 Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

toBytes :: Word16 -> Bytes Source #

HasBytes Word32 Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

toBytes :: Word32 -> Bytes Source #

HasBytes Word64 Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

toBytes :: Word64 -> Bytes Source #

HasBytes CString Source # 
Instance details

Defined in CodeGen.X86.Utils

data Size Source #

The size of a register (in bits)

Constructors

S1 
S8 
S16 
S32 
S64 
S128 

Instances

Instances details
Eq Size Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

(==) :: Size -> Size -> Bool #

(/=) :: Size -> Size -> Bool #

Ord Size Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

compare :: Size -> Size -> Ordering #

(<) :: Size -> Size -> Bool #

(<=) :: Size -> Size -> Bool #

(>) :: Size -> Size -> Bool #

(>=) :: Size -> Size -> Bool #

max :: Size -> Size -> Size #

min :: Size -> Size -> Size #

Show Size Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

showsPrec :: Int -> Size -> ShowS #

show :: Size -> String #

showList :: [Size] -> ShowS #

mkSize :: (Eq a, Num a) => a -> Size Source #

sizeLen :: Num p => Size -> p Source #

class HasSize a where Source #

Methods

size :: a -> Size Source #

Instances

Instances details
HasSize Int8 Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

size :: Int8 -> Size Source #

HasSize Int16 Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

size :: Int16 -> Size Source #

HasSize Int32 Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

size :: Int32 -> Size Source #

HasSize Int64 Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

size :: Int64 -> Size Source #

HasSize Word8 Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

size :: Word8 -> Size Source #

HasSize Word16 Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

size :: Word16 -> Size Source #

HasSize Word32 Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

size :: Word32 -> Size Source #

HasSize Word64 Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

size :: Word64 -> Size Source #

IsSize s => HasSize (Address s) Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

size :: Address s -> Size Source #

IsSize s => HasSize (IndexReg s) Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

size :: IndexReg s -> Size Source #

IsSize s => HasSize (BaseReg s) Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

size :: BaseReg s -> Size Source #

IsSize s => HasSize (Addr s) Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

size :: Addr s -> Size Source #

IsSize s => HasSize (Reg s) Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

size :: Reg s -> Size Source #

HasSize (SSize s) Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

size :: SSize s -> Size Source #

IsSize s => HasSize (Operand a s) Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

size :: Operand a s -> Size Source #

data SSize (s :: Size) where Source #

Singleton type for size

Instances

Instances details
HasSize (SSize s) Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

size :: SSize s -> Size Source #

class IsSize (s :: Size) where Source #

Methods

ssize :: SSize s Source #

Instances

Instances details
IsSize 'S1 Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

ssize :: SSize 'S1 Source #

IsSize 'S8 Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

ssize :: SSize 'S8 Source #

IsSize 'S16 Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

ssize :: SSize 'S16 Source #

IsSize 'S32 Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

ssize :: SSize 'S32 Source #

IsSize 'S64 Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

ssize :: SSize 'S64 Source #

IsSize 'S128 Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

ssize :: SSize 'S128 Source #

data EqT s s' where Source #

Constructors

Refl :: EqT s s 

sizeEqCheck :: forall s s' f g. (IsSize s, IsSize s') => f s -> g s' -> Maybe (EqT s s') Source #

newtype Scale Source #

The scaling of an index. (replace with Size?)

Constructors

Scale Word8 

Instances

Instances details
Eq Scale Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

(==) :: Scale -> Scale -> Bool #

(/=) :: Scale -> Scale -> Bool #

toScale :: (Eq a, Num a) => a -> Scale Source #

data Operand :: Access -> Size -> * where Source #

An operand can be an immediate, a register, a memory address or RIP-relative (memory address relative to the instruction pointer)

Constructors

ImmOp :: Immediate Int64 -> Operand R s 
RegOp :: Reg s -> Operand rw s 
MemOp :: IsSize s' => Addr s' -> Operand rw s 
IPMemOp :: Immediate Int32 -> Operand rw s 

Instances

Instances details
FromReg (Operand r) Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

fromReg :: forall (s :: Size). Reg s -> Operand r s Source #

rw ~ 'R => Num (Operand rw s) Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

(+) :: Operand rw s -> Operand rw s -> Operand rw s #

(-) :: Operand rw s -> Operand rw s -> Operand rw s #

(*) :: Operand rw s -> Operand rw s -> Operand rw s #

negate :: Operand rw s -> Operand rw s #

abs :: Operand rw s -> Operand rw s #

signum :: Operand rw s -> Operand rw s #

fromInteger :: Integer -> Operand rw s #

IsSize s => Show (Operand a s) Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

showsPrec :: Int -> Operand a s -> ShowS #

show :: Operand a s -> String #

showList :: [Operand a s] -> ShowS #

IsSize s => HasSize (Operand a s) Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

size :: Operand a s -> Size Source #

addr :: IsSize s => Address s -> Operand rw s' Source #

addr8 :: IsSize s => Address s -> Operand rw S8 Source #

addr with specialized type

addr16 :: IsSize s => Address s -> Operand rw S16 Source #

addr with specialized type

addr32 :: IsSize s => Address s -> Operand rw S32 Source #

addr with specialized type

addr64 :: IsSize s => Address s -> Operand rw S64 Source #

addr with specialized type

data Immediate a Source #

Instances

Instances details
Show a => Show (Immediate a) Source # 
Instance details

Defined in CodeGen.X86.Asm

newtype Label Source #

Constructors

Label 

Fields

Instances

Instances details
Show Label Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

showsPrec :: Int -> Label -> ShowS #

show :: Label -> String #

showList :: [Label] -> ShowS #

data Access Source #

Operand access modes

Constructors

R

readable operand

RW

readable and writeable operand

data Reg :: Size -> * where Source #

A register.

Constructors

NormalReg :: Word8 -> Reg s 
HighReg :: Word8 -> Reg S8 
XMM :: Word8 -> Reg S128 

Instances

Instances details
FromReg Reg Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

fromReg :: forall (s :: Size). Reg s -> Reg s Source #

Eq (Reg s) Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

(==) :: Reg s -> Reg s -> Bool #

(/=) :: Reg s -> Reg s -> Bool #

Ord (Reg s) Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

compare :: Reg s -> Reg s -> Ordering #

(<) :: Reg s -> Reg s -> Bool #

(<=) :: Reg s -> Reg s -> Bool #

(>) :: Reg s -> Reg s -> Bool #

(>=) :: Reg s -> Reg s -> Bool #

max :: Reg s -> Reg s -> Reg s #

min :: Reg s -> Reg s -> Reg s #

IsSize s => Show (Reg s) Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

showsPrec :: Int -> Reg s -> ShowS #

show :: Reg s -> String #

showList :: [Reg s] -> ShowS #

IsSize s => HasSize (BaseReg s) Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

size :: BaseReg s -> Size Source #

IsSize s => HasSize (Reg s) Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

size :: Reg s -> Size Source #

data Addr s Source #

A (relative) address is made up base a base register, a displacement, and a (scaled) index. For example in [eax+4*ecx+20] the base register is eax, the displacement is 20 and the index is 4*ecx.

Constructors

Addr 

Instances

Instances details
Eq (Addr s) Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

(==) :: Addr s -> Addr s -> Bool #

(/=) :: Addr s -> Addr s -> Bool #

IsSize s => Show (Addr s) Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

showsPrec :: Int -> Addr s -> ShowS #

show :: Addr s -> String #

showList :: [Addr s] -> ShowS #

Semigroup (Addr s) Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

(<>) :: Addr s -> Addr s -> Addr s #

sconcat :: NonEmpty (Addr s) -> Addr s #

stimes :: Integral b => b -> Addr s -> Addr s #

Monoid (Addr s) Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

mempty :: Addr s #

mappend :: Addr s -> Addr s -> Addr s #

mconcat :: [Addr s] -> Addr s #

IsSize s => HasSize (Addr s) Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

size :: Addr s -> Size Source #

type BaseReg s = Maybe (Reg s) Source #

data IndexReg s Source #

Constructors

NoIndex 
IndexReg Scale (Reg s) 

Instances

Instances details
Eq (IndexReg s) Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

(==) :: IndexReg s -> IndexReg s -> Bool #

(/=) :: IndexReg s -> IndexReg s -> Bool #

Semigroup (IndexReg s) Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

(<>) :: IndexReg s -> IndexReg s -> IndexReg s #

sconcat :: NonEmpty (IndexReg s) -> IndexReg s #

stimes :: Integral b => b -> IndexReg s -> IndexReg s #

Monoid (IndexReg s) Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

mempty :: IndexReg s #

mappend :: IndexReg s -> IndexReg s -> IndexReg s #

mconcat :: [IndexReg s] -> IndexReg s #

IsSize s => HasSize (IndexReg s) Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

size :: IndexReg s -> Size Source #

pattern NoDisp :: Maybe a Source #

pattern Disp :: a -> Maybe a Source #

ipRel :: Label -> Operand rw s Source #

intruction pointer (RIP) relative address

ipRelValue :: forall (s :: Size). Label -> Operand 'R s Source #

ipRel8 :: Label -> Operand rw S8 Source #

ipRel with specialized type

base :: Reg s -> Addr s Source #

index :: Scale -> Reg s -> Addr s Source #

index' :: Int -> Reg s -> Addr s Source #

index1 :: forall (s :: Size). Reg s -> Addr s Source #

index2 :: forall (s :: Size). Reg s -> Addr s Source #

index4 :: forall (s :: Size). Reg s -> Addr s Source #

index8 :: forall (s :: Size). Reg s -> Addr s Source #

disp :: (Bits a, Integral a) => a -> Addr s Source #

data Address :: Size -> * where Source #

Constructors

Address :: [(Int, Reg s)] -> Int -> Address s 

Instances

Instances details
FromReg Address Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

fromReg :: forall (s :: Size). Reg s -> Address s Source #

Num (Address s) Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

(+) :: Address s -> Address s -> Address s #

(-) :: Address s -> Address s -> Address s #

(*) :: Address s -> Address s -> Address s #

negate :: Address s -> Address s #

abs :: Address s -> Address s #

signum :: Address s -> Address s #

fromInteger :: Integer -> Address s #

IsSize s => HasSize (Address s) Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

size :: Address s -> Size Source #

class FromReg c where Source #

Methods

fromReg :: Reg s -> c s Source #

Instances

Instances details
FromReg Address Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

fromReg :: forall (s :: Size). Reg s -> Address s Source #

FromReg Reg Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

fromReg :: forall (s :: Size). Reg s -> Reg s Source #

FromReg (Operand r) Source # 
Instance details

Defined in CodeGen.X86.Asm

Methods

fromReg :: forall (s :: Size). Reg s -> Operand r s Source #

reg :: forall c (s :: Size). FromReg c => Word8 -> c s Source #

rax :: FromReg c => c S64 Source #

rcx :: FromReg c => c S64 Source #

rdx :: FromReg c => c S64 Source #

rbx :: FromReg c => c S64 Source #

rsp :: FromReg c => c S64 Source #

rbp :: FromReg c => c S64 Source #

rsi :: FromReg c => c S64 Source #

rdi :: FromReg c => c S64 Source #

r8 :: FromReg c => c S64 Source #

r9 :: FromReg c => c S64 Source #

r10 :: FromReg c => c S64 Source #

r11 :: FromReg c => c S64 Source #

r12 :: FromReg c => c S64 Source #

r13 :: FromReg c => c S64 Source #

r14 :: FromReg c => c S64 Source #

r15 :: FromReg c => c S64 Source #

eax :: FromReg c => c S32 Source #

ecx :: FromReg c => c S32 Source #

edx :: FromReg c => c S32 Source #

ebx :: FromReg c => c S32 Source #

esp :: FromReg c => c S32 Source #

ebp :: FromReg c => c S32 Source #

esi :: FromReg c => c S32 Source #

edi :: FromReg c => c S32 Source #

r8d :: FromReg c => c S32 Source #

r9d :: FromReg c => c S32 Source #

r10d :: FromReg c => c S32 Source #

r11d :: FromReg c => c S32 Source #

r12d :: FromReg c => c S32 Source #

r13d :: FromReg c => c S32 Source #

r14d :: FromReg c => c S32 Source #

r15d :: FromReg c => c S32 Source #

ax :: FromReg c => c S16 Source #

cx :: FromReg c => c S16 Source #

dx :: FromReg c => c S16 Source #

bx :: FromReg c => c S16 Source #

sp :: FromReg c => c S16 Source #

bp :: FromReg c => c S16 Source #

si :: FromReg c => c S16 Source #

di :: FromReg c => c S16 Source #

r8w :: FromReg c => c S16 Source #

r9w :: FromReg c => c S16 Source #

r10w :: FromReg c => c S16 Source #

r11w :: FromReg c => c S16 Source #

r12w :: FromReg c => c S16 Source #

r13w :: FromReg c => c S16 Source #

r14w :: FromReg c => c S16 Source #

r15w :: FromReg c => c S16 Source #

al :: FromReg c => c S8 Source #

cl :: FromReg c => c S8 Source #

dl :: FromReg c => c S8 Source #

bl :: FromReg c => c S8 Source #

spl :: FromReg c => c S8 Source #

bpl :: FromReg c => c S8 Source #

sil :: FromReg c => c S8 Source #

dil :: FromReg c => c S8 Source #

r8b :: FromReg c => c S8 Source #

r9b :: FromReg c => c S8 Source #

r10b :: FromReg c => c S8 Source #

r11b :: FromReg c => c S8 Source #

r12b :: FromReg c => c S8 Source #

r13b :: FromReg c => c S8 Source #

r14b :: FromReg c => c S8 Source #

r15b :: FromReg c => c S8 Source #

ah :: FromReg c => c S8 Source #

ch :: FromReg c => c S8 Source #

dh :: FromReg c => c S8 Source #

bh :: FromReg c => c S8 Source #

pattern RegA :: Operand a b Source #

pattern RegCl :: Operand r S8 Source #

pattern MemLike :: Operand a b Source #

isMemOp :: forall (a :: Access) (b :: Size). Operand a b -> Bool Source #

newtype Condition Source #

Constructors

Condition Word8 

Instances

Instances details
Show Condition Source # 
Instance details

Defined in CodeGen.X86.Asm

pattern O :: Condition Source #

pattern NO :: Condition Source #

pattern B :: Condition Source #

pattern C :: Condition Source #

pattern NB :: Condition Source #

pattern NC :: Condition Source #

pattern E :: Condition Source #

pattern Z :: Condition Source #

pattern NE :: Condition Source #

pattern NZ :: Condition Source #

pattern NA :: Condition Source #

pattern BE :: Condition Source #

pattern A :: Condition Source #

pattern NBE :: Condition Source #

pattern S :: Condition Source #

pattern NS :: Condition Source #

pattern P :: Condition Source #

pattern NP :: Condition Source #

pattern L :: Condition Source #

pattern NL :: Condition Source #

pattern NG :: Condition Source #

pattern LE :: Condition Source #

pattern G :: Condition Source #

pattern NLE :: Condition Source #

pattern N :: Condition -> Condition Source #

codeLine :: (MonadWriter m, WriterType m ~ [a]) => a -> m () Source #

showOp0 :: (MonadWriter m, WriterType m ~ [a]) => a -> m () Source #

showOp :: (MonadWriter m, WriterType m ~ [[Char]]) => [Char] -> [Char] -> m () Source #

showOp1 :: (MonadWriter m, Show a, WriterType m ~ [[Char]]) => [Char] -> a -> m () Source #

showOp2 :: (MonadWriter m, Show a1, Show a2, WriterType m ~ [[Char]]) => [Char] -> a1 -> a2 -> m () Source #