The Ivory toolchain is made up of 4 packages found in the Ivory repository:
Module type is the unit of compilation. There are no tools for user introspection of a
The Ivory C-language compiler is defined in the
Most users will want to use the
compile function from the
compile has type
[Module] -> IO (): it takes a collection of Ivory modules and writes the compiled C sources to the disk according to command line options (i.e.
If you are building the Ivory compiler into some other sort of Haskell application, lower level primitives are exported by the
compileWith function from the
Ivory.Compile.C.CmdlineFrontend module extends
compile with two additional optional arguments, a
SizeMap (defined by
Ivory.Opts.CFG) which may aid in static analysis passes, and a
[IO FilePath] which specifies the search path for additional C source dependencies.
Some Ivory libraries require external definitions given by C source files. Such a library should give a
SearchDir module exporting a value
searchDir :: IO FilePath.
For example, the commonly used
ivory-hw package requires a C header, which is installed as a cabal data-file. The directory to find the installed support file is given by
searchDir in the module
The command line arguments expected by
Ivory.Compile.C.CmdlineFrontend.compile can be found by running a compile program with the –help flag.
Support for verifying user- and compiler- inserted assertions in Ivory programs is provided by the
Ivory optimization passes are implemented in the
Optimization passes are used by default by the
Ivory.Compile.C.CmdlineFrontend.compile compiler. Command line flags are available to disable passes individually.
One of the downsides of embedded DSLs like Ivory is that tools like the above generally do not have access to the original source information for error reporting. To address this issue, we have implemented a plugin for GHC (>= 7.8) that adds references to the original Haskell source in the Ivory code. The granularity is only at the level of individual Ivory statements, but nonetheless very helpful in discovering the source of an error.
The source location plugin can be enabled by compiling your Ivory program with
-fplugin=Ivory.Language.Plugin. You also need to tell GHC to retain the source locations for our plugin to see, which can be done in three ways:
-fprof-auto-callsfor maximum granularity), or