Emitting calls to functions defined in PrimOps.cmm from the code gen

Hi, I'm trying to make allocation of arrays of small, statically-known size inline. For large or unknown size I just want to call the existing stg_newArrayzh function. In code: doNewArrayOp :: DynFlags -> CmmFormal -> CmmExpr -> FCode () doNewArrayOp dflags res_r (CmmLit (CmmInt n _)) | n <= inlineAllocLimit = do -- Do everything inline. doNewArrayOp dflags res_r n = do emitCallTo "stg_newArrayzh" res_r n -- HERE The question is: how do I emit a call to stg_newArrayzh, which is defined in PrimOps.cmm? -- Johan

Have you looked at some of the lowering code for other primops? What info
are you missing?
On Friday, March 7, 2014, Johan Tibell
Hi,
I'm trying to make allocation of arrays of small, statically-known size inline. For large or unknown size I just want to call the existing stg_newArrayzh function. In code:
doNewArrayOp :: DynFlags -> CmmFormal -> CmmExpr -> FCode () doNewArrayOp dflags res_r (CmmLit (CmmInt n _)) | n <= inlineAllocLimit = do -- Do everything inline. doNewArrayOp dflags res_r n = do emitCallTo "stg_newArrayzh" res_r n -- HERE
The question is: how do I emit a call to stg_newArrayzh, which is defined in PrimOps.cmm?
-- Johan

With Simon's help I figured it out. I'm now refactoring StgCmmPrimOp so
it's easier to have primops that have both inline and out-of-line
implementations in the future.
On Fri, Mar 7, 2014 at 3:19 PM, Carter Schonwald wrote: Have you looked at some of the lowering code for other primops? What info
are you missing? On Friday, March 7, 2014, Johan Tibell Hi, I'm trying to make allocation of arrays of small, statically-known size
inline. For large or unknown size I just want to call the existing
stg_newArrayzh function. In code: doNewArrayOp :: DynFlags -> CmmFormal -> CmmExpr -> FCode ()
doNewArrayOp dflags res_r (CmmLit (CmmInt n _)) | n <= inlineAllocLimit =
do
-- Do everything inline.
doNewArrayOp dflags res_r n = do
emitCallTo "stg_newArrayzh" res_r n -- HERE The question is: how do I emit a call to stg_newArrayzh, which is defined
in PrimOps.cmm? -- Johan

Awesome! Please post a link to the new version on devs when it lands! (I'm
not quite at the point where I can keep up with the full commits firehose
yet). This is very relevant for me.
On Friday, March 7, 2014, Johan Tibell
With Simon's help I figured it out. I'm now refactoring StgCmmPrimOp so it's easier to have primops that have both inline and out-of-line implementations in the future.
On Fri, Mar 7, 2014 at 3:19 PM, Carter Schonwald < carter.schonwald@gmail.comjavascript:_e(%7B%7D,'cvml','carter.schonwald@gmail.com');
wrote:
Have you looked at some of the lowering code for other primops? What info are you missing?
On Friday, March 7, 2014, Johan Tibell
javascript:_e(%7B%7D,'cvml','johan.tibell@gmail.com');> wrote: Hi,
I'm trying to make allocation of arrays of small, statically-known size inline. For large or unknown size I just want to call the existing stg_newArrayzh function. In code:
doNewArrayOp :: DynFlags -> CmmFormal -> CmmExpr -> FCode () doNewArrayOp dflags res_r (CmmLit (CmmInt n _)) | n <= inlineAllocLimit = do -- Do everything inline. doNewArrayOp dflags res_r n = do emitCallTo "stg_newArrayzh" res_r n -- HERE
The question is: how do I emit a call to stg_newArrayzh, which is defined in PrimOps.cmm?
-- Johan
participants (2)
-
Carter Schonwald
-
Johan Tibell