Safe Haskell | Safe |
---|---|
Language | Haskell98 |
Names used in the Disciple Core Salt language profile.
- data Name
- = NameVar !String
- | NameCon !String
- | NameExt !Name !String
- | NameObjTyCon
- | NamePrimTyCon !PrimTyCon
- | NamePrimVal !PrimVal
- data PrimTyCon
- pprPrimTyConStem :: PrimTyCon -> Doc
- readPrimTyCon :: String -> Maybe PrimTyCon
- readPrimTyConStem :: String -> Maybe PrimTyCon
- primTyConIsIntegral :: PrimTyCon -> Bool
- primTyConIsFloating :: PrimTyCon -> Bool
- primTyConIsUnsigned :: PrimTyCon -> Bool
- primTyConIsSigned :: PrimTyCon -> Bool
- primTyConWidth :: Platform -> PrimTyCon -> Maybe Integer
- data PrimVal
- = PrimValOp !PrimOp
- | PrimValLit !PrimLit
- readPrimVal :: String -> Maybe PrimVal
- pattern NamePrimOp :: PrimOp -> Name
- pattern NamePrimLit :: PrimLit -> Name
- data PrimOp
- readPrimOp :: String -> Maybe PrimOp
- data PrimArith
- readPrimArith :: String -> Maybe PrimArith
- data PrimCall
- readPrimCall :: String -> Maybe PrimCall
- data PrimCast
- readPrimCast :: String -> Maybe PrimCast
- primCastPromoteIsValid :: Platform -> PrimTyCon -> PrimTyCon -> Bool
- primCastTruncateIsValid :: Platform -> PrimTyCon -> PrimTyCon -> Bool
- data PrimControl
- readPrimControl :: String -> Maybe PrimControl
- data PrimStore
- = PrimStoreSize
- | PrimStoreSize2
- | PrimStoreCreate
- | PrimStoreCheck
- | PrimStoreRecover
- | PrimStoreAlloc
- | PrimStoreRead
- | PrimStoreWrite
- | PrimStorePlusAddr
- | PrimStoreMinusAddr
- | PrimStorePeek
- | PrimStorePeekBounded
- | PrimStorePoke
- | PrimStorePokeBounded
- | PrimStorePlusPtr
- | PrimStoreMinusPtr
- | PrimStoreMakePtr
- | PrimStoreTakePtr
- | PrimStoreCastPtr
- readPrimStore :: String -> Maybe PrimStore
- data PrimVec
- = PrimVecNeg {
- primVecMulti :: Int
- | PrimVecAdd {
- primVecMulti :: Int
- | PrimVecSub {
- primVecMulti :: Int
- | PrimVecMul {
- primVecMulti :: Int
- | PrimVecDiv {
- primVecMulti :: Int
- | PrimVecRep {
- primVecMulti :: Int
- | PrimVecPack {
- primVecMulti :: Int
- | PrimVecProj {
- primVecMulti :: Int
- primVecIndex :: Int
- | PrimVecGather {
- primVecMulti :: Int
- | PrimVecScatter {
- primVecMulti :: Int
- = PrimVecNeg {
- readPrimVec :: String -> Maybe PrimVec
- multiOfPrimVec :: PrimVec -> Maybe Int
- liftPrimArithToVec :: Int -> PrimArith -> Maybe PrimVec
- lowerPrimVecToArith :: PrimVec -> Maybe PrimArith
- data PrimLit
- = PrimLitVoid
- | PrimLitBool !Bool
- | PrimLitNat !Integer
- | PrimLitInt !Integer
- | PrimLitSize !Integer
- | PrimLitWord !Integer !Int
- | PrimLitFloat !Double !Int
- | PrimLitChar !Char
- | PrimLitTextLit !Text
- | PrimLitTag !Integer
- readPrimLit :: String -> Maybe PrimLit
- readLitInteger :: String -> Maybe Integer
- readLitNat :: String -> Maybe Integer
- readLitInt :: String -> Maybe Integer
- readLitSize :: String -> Maybe Integer
- readLitWordOfBits :: String -> Maybe (Integer, Int)
- readLitFloatOfBits :: String -> Maybe (Double, Int)
- pattern NameLitVoid :: Name
- pattern NameLitBool :: Bool -> Name
- pattern NameLitNat :: Integer -> Name
- pattern NameLitInt :: Integer -> Name
- pattern NameLitSize :: Integer -> Name
- pattern NameLitWord :: Integer -> Int -> Name
- pattern NameLitFloat :: Double -> Int -> Name
- pattern NameLitChar :: Char -> Name
- pattern NameLitTextLit :: Text -> Name
- pattern NameLitTag :: Integer -> Name
- readName :: String -> Maybe Name
- takeNameVar :: Name -> Maybe String
Documentation
Names of things used in Disciple Core Salt.
NameVar !String | A type or value variable. |
NameCon !String | Constructor names. |
NameExt !Name !String | An extended name. |
NameObjTyCon | The abstract heap object type constructor. |
NamePrimTyCon !PrimTyCon | A primitive type constructor. |
NamePrimVal !PrimVal | A primitive value. |
Eq Name Source # | |
Ord Name Source # | |
Show Name Source # | |
Pretty Name Source # | |
CompoundName Name Source # | |
NFData Name Source # | |
FromAnnot (Pat Name) Pat Source # | |
FromAnnot (WiCon Name) WiCon Source # | |
FromAnnot (Bind Name) (Bind Name) Source # | |
FromAnnot (Bound Name) (Bound Name) Source # | |
FromAnnot (Type Name) (Type Name) Source # | |
FromAnnot (Exp a Name) Exp Source # | |
FromAnnot (Lets a Name) Lets Source # | |
FromAnnot (Alt a Name) Alt Source # | |
FromAnnot (Cast a Name) Cast Source # | |
FromAnnot (Witness a Name) Witness Source # | |
FromAnnot (DaCon Name (Type Name)) (DaCon Name (Type Name)) Source # | |
type GAnnot Name # | |
type GBind Name # | |
type GBound Name # | |
type GPrim Name # | |
Primitive Type Constructors
Primitive type constructors.
PrimTyConVoid |
|
PrimTyConBool |
|
PrimTyConNat |
|
PrimTyConInt |
|
PrimTyConSize |
|
PrimTyConWord Int |
|
PrimTyConFloat Int |
|
PrimTyConVec Int |
|
PrimTyConAddr |
|
PrimTyConPtr |
|
PrimTyConTextLit |
|
PrimTyConTag |
|
pprPrimTyConStem :: PrimTyCon -> Doc Source #
Pretty print a primitive type constructor,
without the #
suffix.
readPrimTyCon :: String -> Maybe PrimTyCon Source #
Read a primitive type constructor.
Words are limited to 8, 16, 32, or 64 bits.
Floats are limited to 32 or 64 bits.
readPrimTyConStem :: String -> Maybe PrimTyCon Source #
Read a primitive type constructor, without the #
suffix.
primTyConIsIntegral :: PrimTyCon -> Bool Source #
Integral constructors are the ones that we can reasonably convert from integers of the same size.
These are Bool#
, Nat#
, Int#
, Size
, WordN#
and Tag#
.
primTyConIsFloating :: PrimTyCon -> Bool Source #
Floating point types.
These are FloatN#
.
primTyConIsUnsigned :: PrimTyCon -> Bool Source #
Unsigned types.
These are Bool#
Nat#
Size#
WordN
Tag
.
primTyConIsSigned :: PrimTyCon -> Bool Source #
Signed integral constructors.
This is just Int
.
primTyConWidth :: Platform -> PrimTyCon -> Maybe Integer Source #
Get the representation width of a primitive type constructor, in bits. This is how much space it takes up in an object payload.
Bools are representable with a single bit, but we unpack them into a whole word.
The constructors Void
and VecN#
and String
have no width.
Primitive Values
Primitive values, meaning both operators and literals.
pattern NamePrimOp :: PrimOp -> Name Source #
pattern NamePrimLit :: PrimLit -> Name Source #
Primitive Operators
Primitive operators implemented directly by the machine or runtime system.
PrimArith !PrimArith | Arithmetic, logic, comparison and bit-wise operators. |
PrimCast !PrimCast | Casting between numeric types. |
PrimStore !PrimStore | Raw store access. |
PrimCall !PrimCall | Special function calling conventions. |
PrimControl !PrimControl | Non-functional control flow. |
Primitive Arithmetic
Primitive arithmetic, logic, and comparison opretors. We expect the backend/machine to be able to implement these directly.
For the Shift Right operator, the type that it is used at determines whether it is an arithmetic (with sign-extension) or logical (no sign-extension) shift.
PrimArithNeg | Negation |
PrimArithAdd | Addition |
PrimArithSub | Subtraction |
PrimArithMul | Multiplication |
PrimArithDiv | Division |
PrimArithMod | Modulus |
PrimArithRem | Remainder |
PrimArithEq | Equality |
PrimArithNeq | Negated Equality |
PrimArithGt | Greater Than |
PrimArithGe | Greater Than or Equal |
PrimArithLt | Less Than |
PrimArithLe | Less Than or Equal |
PrimArithAnd | Boolean And |
PrimArithOr | Boolean Or |
PrimArithShl | Shift Left |
PrimArithShr | Shift Right |
PrimArithBAnd | Bit-wise And |
PrimArithBOr | Bit-wise Or |
PrimArithBXOr | Bit-wise eXclusive Or |
Primitive Calls
Primitive ways of invoking a function, where control flow returns back to the caller.
PrimCallStd Int | Perform a standard function call where the address is not statically known. All the arguments are boxed heap objects. |
PrimCallTail Int | Tailcall a statically known functions, where the arguments can be boxed or unboxed. |
Primitive Casts
Primitive cast between two types.
The exact set of available casts is determined by the target platform.
For example, you can only promote a Nat#
to a Word32#
on a 32-bit
system. On a 64-bit system the Nat#
type is 64-bits wide, so casting it
to a Word32#
would be a truncation.
PrimCastConvert | Convert a value to a new representation with the same precision. |
PrimCastPromote | Promote a value to one of similar or larger width, without loss of precision. |
PrimCastTruncate | Truncate a value to a new width, possibly losing precision. |
primCastPromoteIsValid Source #
Check for a valid promotion primop.
primCastTruncateIsValid Source #
Check for valid truncation primop.
Primitive Control
data PrimControl Source #
Primitive non-returning control flow.
PrimControlFail | Ungraceful failure -- just abort the program. This is called on internal errors in the runtime system. There is no further debugging info provided, so you'll need to look at the stack trace to debug it. |
PrimControlReturn | Return from the enclosing function with the given value. |
readPrimControl :: String -> Maybe PrimControl Source #
Primitive Store
Raw access to the store.
PrimStoreSize | Number of bytes needed to store a value of a primitive type. |
PrimStoreSize2 | Log2 of number of bytes need to store a value of a primitive type. |
PrimStoreCreate | Create a heap of the given size.
This must be called before |
PrimStoreCheck | Check whether there are at least this many bytes still available on the heap. |
PrimStoreRecover | Force a garbage collection to recover at least this many bytes. |
PrimStoreAlloc | Allocate some space on the heap. There must be enough space available, else undefined. |
PrimStoreRead | Read a value from the store at the given address and offset. |
PrimStoreWrite | Write a value to the store at the given address and offset. |
PrimStorePlusAddr | Add an offset in bytes to an address. |
PrimStoreMinusAddr | Subtract an offset in bytes from an address. |
PrimStorePeek | Read a value from a pointer plus offset. |
PrimStorePeekBounded | Read a value from a pointer plus offset, with an integrated bounds check. |
PrimStorePoke | Write a value to a pointer plus given offset. |
PrimStorePokeBounded | Write a value to a pointer plus offset, with an integrated bounds check. |
PrimStorePlusPtr | Add an offset in bytes to a pointer. |
PrimStoreMinusPtr | Subtract an offset in bytes from a pointer. |
PrimStoreMakePtr | Convert an raw address to a pointer. |
PrimStoreTakePtr | Convert a pointer to a raw address. |
PrimStoreCastPtr | Cast between pointer types. |
Primitive Vector
Primitive fixed-length SIMD vector operators.
PrimVecNeg | Negate elements of a vector. |
| |
PrimVecAdd | Add elements of a vector. |
| |
PrimVecSub | Subtract elements of a vector. |
| |
PrimVecMul | Multiply elements of a vector. |
| |
PrimVecDiv | Divide elements of a vector. |
| |
PrimVecRep | Replicate a scalar into a vector. |
| |
PrimVecPack | Pack multiple scalars into a vector |
| |
PrimVecProj | Extract a single element from a vector. |
| |
PrimVecGather | Read multiple elements from memory. |
| |
PrimVecScatter | Write multiple elements to memory. |
|
liftPrimArithToVec :: Int -> PrimArith -> Maybe PrimVec Source #
Yield the PrimVector
that corresponds to a PrimArith
of the
given multiplicity, if any.
lowerPrimVecToArith :: PrimVec -> Maybe PrimArith Source #
Yield the PrimArith
that corresponds to a PrimVector
, if any.
Primitive Literals
Primitive literals.
PrimLitVoid | The void literal. |
PrimLitBool !Bool | A boolean literal. |
PrimLitNat !Integer | A natural number literal. |
PrimLitInt !Integer | An integer number literal. |
PrimLitSize !Integer | A size literal. |
PrimLitWord !Integer !Int | A word literal, of the given width. |
PrimLitFloat !Double !Int | A floating point literal, of the given width. |
PrimLitChar !Char | A character literal. |
PrimLitTextLit !Text | A text literal. |
PrimLitTag !Integer | A constructor tag literal. |
readLitInteger :: String -> Maybe Integer #
Read a signed integer.
readLitNat :: String -> Maybe Integer #
Read an integer with an explicit format specifier like 1234i
.
readLitInt :: String -> Maybe Integer #
Read an integer literal with an explicit format specifier like 1234i
.
readLitSize :: String -> Maybe Integer #
Read an size literal with an explicit format specifier like 1234s
.
readLitFloatOfBits :: String -> Maybe (Double, Int) #
Read a float literal with an explicit format specifier like 123.00f32#
.
pattern NameLitVoid :: Name Source #
pattern NameLitBool :: Bool -> Name Source #
pattern NameLitNat :: Integer -> Name Source #
pattern NameLitInt :: Integer -> Name Source #
pattern NameLitSize :: Integer -> Name Source #
pattern NameLitChar :: Char -> Name Source #
pattern NameLitTextLit :: Text -> Name Source #
pattern NameLitTag :: Integer -> Name Source #