harpy-0.6.0.0: Runtime code generation for x86 machine code

Copyright(c) 2006-2015 Martin Grabmueller and Dirk Kleeblatt
LicenseBSD3
Maintainermartin@grabmueller.de
Stabilityquite experimental
Portabilityportable (but generated code non-portable)
Safe HaskellNone
LanguageHaskell98

Harpy.X86CGCombinators

Contents

Description

This module exports several combinators for writing loops, conditionals and function prolog/epilog code.

Note: this module is under heavy development and the exported API is definitely not yet stable.

Synopsis

Types

data UserState Source

User state is used to maintain bitmask of registers currently in use.

Constructors

UserState 

data UserEnv Source

User environment stores code generators for accessing specific variables as well as the current data and control destinations

data CtrlDest Source

Destination for control transfers

Constructors

FallThrough

Go to next instruction

Return

Return from current functio

Goto Label

Go to specific label

Branch CtrlDest CtrlDest

Go to one of the given labels depending on outcome of test

data DataDest Source

Destination for a calculated value.

Constructors

RegDest Reg32

Store into specific register

StackDest

Push onto stack

MemBaseDest Reg32 Word32

Store at memory address

Ignore

Throw result away.

Combinators

saveRegs :: [Reg32] -> CodeGen UserEnv s r -> CodeGen UserEnv s () Source

Save a number of registers on the stack, perform the given code generation, and restore the registers.

function :: CodeGen UserEnv s r -> CodeGen UserEnv s r Source

Emit the necessary function prolog and epilog code and invoke the given code generator for the code inbetween.

withDataDest :: DataDest -> CodeGen UserEnv s r -> CodeGen UserEnv s r Source

Set the data destinations to the given values while running the code generator.

withCtrlDest :: CtrlDest -> CodeGen UserEnv s r -> CodeGen UserEnv s r Source

Set the control destinations to the given values while running the code generator.

withDest :: DataDest -> CtrlDest -> CodeGen UserEnv s r -> CodeGen UserEnv s r Source

Set the data and control destinations to the given values while running the code generator.