The MLRISC Library is a framework for retargetable and optimizing compiler back ends. The MLRISC Library is distributed with SML/NJ. Due to differences between SML/NJ and MLton, this library will not work out-of-the box with MLton.
As of 20250523, MLton includes a port of the MLRISC Library synchronized with SML/NJ version 110.99.8.
Usage
-
You can import a sub-library of the MLRISC Library into an MLB file with:
MLB file Description $(SML_LIB)/mlrisc-lib/mlb/ALPHA.mlbThe ALPHA backend
$(SML_LIB)/mlrisc-lib/mlb/AMD64.mlbThe AMD64 backend
$(SML_LIB)/mlrisc-lib/mlb/AMD64-Peephole.mlbThe AMD64 peephole optimizer
$(SML_LIB)/mlrisc-lib/mlb/CCall.mlb$(SML_LIB)/mlrisc-lib/mlb/CCall-sparc.mlb$(SML_LIB)/mlrisc-lib/mlb/CCall-x86-64.mlb$(SML_LIB)/mlrisc-lib/mlb/CCall-x86.mlb$(SML_LIB)/mlrisc-lib/mlb/Control.mlb$(SML_LIB)/mlrisc-lib/mlb/Graphs.mlb$(SML_LIB)/mlrisc-lib/mlb/HPPA.mlbThe HPPA backend
$(SML_LIB)/mlrisc-lib/mlb/IA32.mlbThe IA32 backend
$(SML_LIB)/mlrisc-lib/mlb/IA32-Peephole.mlbThe IA32 peephole optimizer
$(SML_LIB)/mlrisc-lib/mlb/Lib.mlb$(SML_LIB)/mlrisc-lib/mlb/MLRISC.mlb$(SML_LIB)/mlrisc-lib/mlb/MLTREE.mlb$(SML_LIB)/mlrisc-lib/mlb/Peephole.mlb$(SML_LIB)/mlrisc-lib/mlb/PPC.mlbThe PPC backend
$(SML_LIB)/mlrisc-lib/mlb/RA.mlb$(SML_LIB)/mlrisc-lib/mlb/SPARC.mlbThe Sparc backend
$(SML_LIB)/mlrisc-lib/mlb/StagedAlloc.mlb$(SML_LIB)/mlrisc-lib/mlb/Visual.mlb -
If you are porting a project from SML/NJ’s CompilationManager to MLton’s ML Basis system using
cm2mlb, note that the following map is included by default:# MLRISC Library $SMLNJ-MLRISC $(SML_LIB)/mlrisc-lib/mlb
This will automatically convert a
$SMLNJ-MLRISC/MLRISC.cmimport in an input.cmfile into a$(SML_LIB)/mlrisc-lib/mlb/MLRISC.mlbimport in the output.mlbfile.
Details
The following changes were made to the MLRISC Library, in addition to
deriving the .mlb files from the .cm files:
-
eliminate sequential
withtypeexpansions: Most could be rewritten as a sequence of type definitions and datatype definitions. -
eliminate higher-order functors: Every higher-order functor definition and application could be uncurried in the obvious way.
-
eliminate
where <str> = <str>: Quite painful to expand out all the flexible types in the respective structures. Furthermore, many of the implied type equalities aren’t needed, but it’s too hard to pick out the right ones. -
library/array-noneq.sml(added, not exported): Implementssignature ARRAY_NONEQ, similar tosignature ARRAYfrom the Basis Library, but replacing the latter’seqtype 'a array = 'a arrayandtype 'a vector = 'a Vector.vectorwithtype 'a arrayandtype 'a vector. Thus, array-like containers may matchARRAY_NONEQ, whereas only the pervasive'a arraycontainer may matchARRAY. (SML/NJ’s implementation ofsignature ARRAYomits the type realizations.) -
library/dynamic-array.smlandlibrary/hash-array.sml(modifed): Replaceinclude ARRAYwithinclude ARRAY_NONEQ; see above.