+
+-- Sizes in bytes. (used in some settings to figure out how many
+-- bytes we have to push onto the stack when calling external entry
+-- points (e.g., stdcalling on win32)
+
+-- Note: the "size in bytes" is also the scaling factor used when we
+-- have an array of these things. For example, a ByteArray# of
+-- Int16Rep will use a scaling factor of 2 when accessing the
+-- elements.
+
+getPrimRepSizeInBytes :: PrimRep -> Int
+getPrimRepSizeInBytes PtrRep = wORD_SIZE
+getPrimRepSizeInBytes CodePtrRep = wORD_SIZE
+getPrimRepSizeInBytes DataPtrRep = wORD_SIZE
+getPrimRepSizeInBytes RetRep = wORD_SIZE
+getPrimRepSizeInBytes CostCentreRep = wORD_SIZE
+getPrimRepSizeInBytes CharRep = 4
+getPrimRepSizeInBytes IntRep = wORD_SIZE
+getPrimRepSizeInBytes WordRep = wORD_SIZE
+getPrimRepSizeInBytes AddrRep = wORD_SIZE
+getPrimRepSizeInBytes FloatRep = wORD_SIZE
+getPrimRepSizeInBytes DoubleRep = dOUBLE_SIZE * wORD_SIZE
+getPrimRepSizeInBytes Int8Rep = 1
+getPrimRepSizeInBytes Int16Rep = 2
+getPrimRepSizeInBytes Int32Rep = 4
+getPrimRepSizeInBytes Int64Rep = 8
+getPrimRepSizeInBytes Word8Rep = 1
+getPrimRepSizeInBytes Word16Rep = 2
+getPrimRepSizeInBytes Word32Rep = 4
+getPrimRepSizeInBytes Word64Rep = 8
+getPrimRepSizeInBytes StablePtrRep = wORD_SIZE
+getPrimRepSizeInBytes other = pprPanic "getPrimRepSizeInBytes" (ppr other)
+\end{code}
+
+%************************************************************************
+%* *
+\subsection{ArgReps}
+%* *
+%************************************************************************
+
+An ArgRep is similar to a PrimRep, except that it is slightly
+narrower. It corresponds to the distinctions we make between
+different type of function arguments for the purposes of a function's
+calling convention. These reps are used to decide which of the RTS's
+generic apply functions to call when applying an unknown function.
+
+All 64-bit PrimReps map to the same ArgRep, because they're passed in
+the same register, but a PtrRep is still different from an IntRep
+(RepP vs. RepN respectively) because the function's entry convention
+has to take into account the pointer-hood of arguments for the
+purposes of describing the stack on entry to the garbage collector.
+
+\begin{code}
+data ArgRep = RepV | RepP | RepN | RepF | RepD | RepL
+
+primRepToArgRep VoidRep = RepV
+primRepToArgRep FloatRep = RepF
+primRepToArgRep DoubleRep = RepD
+primRepToArgRep r
+ | isFollowableRep r = RepP
+ | is64BitRep r = RepL
+ | otherwise = ASSERT(getPrimRepSize r == 1) RepN