-primRetUnboxedTuple :: StgOp -> [StgArg] -> Type -> Code
-primRetUnboxedTuple op args res_ty
- = getArgAmodes args `thenFC` \ arg_amodes1 ->
- {-
- For a foreign call, we might need to fiddle with some of the args:
- for example, when passing a ByteArray#, we pass a ptr to the goods
- rather than the heap object.
- -}
- let
- arg_amodes
- | StgFCallOp{} <- op = zipWith shimFCallArg args arg_amodes1
- | otherwise = arg_amodes1
- in
- {-
- put all the arguments in temporaries so they don't get stomped when
- we push the return address.
- -}
- let
- n_args = length args
- arg_uniqs = map mkBuiltinUnique [0 .. n_args-1]
- arg_reps = map getAmodeRep arg_amodes
- arg_temps = zipWith CTemp arg_uniqs arg_reps
- in
- absC (mkAbstractCs (zipWith CAssign arg_temps arg_amodes)) `thenC`
- {-
- allocate some temporaries for the return values.
- -}
- let
- ty_args = tyConAppArgs (repType res_ty)
- prim_reps = map typePrimRep ty_args
- temp_uniqs = map mkBuiltinUnique [ n_args .. n_args + length ty_args - 1]
- temp_amodes = zipWith CTemp temp_uniqs prim_reps
- in
- ccallReturnUnboxedTuple temp_amodes
- (absC (COpStmt temp_amodes op arg_temps []))
-
-
-shimFCallArg arg amode
- | tycon == foreignObjPrimTyCon
- = CMacroExpr AddrRep ForeignObj_CLOSURE_DATA [amode]
- | tycon == arrayPrimTyCon || tycon == mutableArrayPrimTyCon
- = CMacroExpr PtrRep PTRS_ARR_CTS [amode]
- | tycon == byteArrayPrimTyCon || tycon == mutableByteArrayPrimTyCon
- = CMacroExpr AddrRep BYTE_ARR_CTS [amode]
- | otherwise = amode
- where
- -- should be a tycon app, since this is a foreign call
- tycon = tyConAppTyCon (repType (stgArgType arg))
+newUnboxedTupleRegs :: Type -> FCode ([CgRep], [CmmReg], [MachHint])
+newUnboxedTupleRegs res_ty =
+ let
+ ty_args = tyConAppArgs (repType res_ty)
+ (reps,hints) = unzip [ (rep, typeHint ty) | ty <- ty_args,
+ let rep = typeCgRep ty,
+ nonVoidArg rep ]
+ in do
+ regs <- mapM (newTemp . argMachRep) reps
+ return (reps,regs,hints)