<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>There seems to be plenty of documentation around on implementing a new primop, much of it needs some tweaking as files have moved and such. &nbsp;I can't seem to find any documentation about how to implement primtypes though.</div><div><br></div><div>For example, I want to experiment with a new primtype "DV#", my assumption that the type was first declared in the primops.txt.pp seems incorrect. &nbsp;So I'm trying to backtrack a bit and see where primtypes first appear, I'm hoping someone can at least give me a pointer :-)</div><div><br></div><div>For example:</div><div>./compiler/prelude/primops.txt.pp</div><div><br></div><div>Add the following:</div><div>primtype DoubleVec# a</div><div><br></div><div>Compiles fine</div><div><br></div><div>Add a primop on the type:</div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">primop ExtractDoubleVecOp "extractDoubleVec#" GenPrimOp</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">&nbsp;&nbsp; DoubleVec# -&gt; Int# -&gt; Double#</div></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">And suddenly it's not as friendly. &nbsp;I expected a compile issue since I hadn't added it to CgPrimOps.hs yet, but this is not that compile problem:</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">make -r --no-print-directory -f ghc.mk phase=1 phase_1_builds</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">/usr/bin/gcc -E &nbsp;-undef -traditional -P -Iincludes &nbsp;-x c compiler/prelude/primops.txt.pp | grep -v '^#pragma GCC' &gt; compiler/prelude/primops.txt</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">"inplace/bin/genprimopcode" --data-decl &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt; compiler/prelude/primops.txt &gt; compiler/primop-data-decl.hs-incl</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">"inplace/bin/genprimopcode" --primop-tag &nbsp; &nbsp; &nbsp; &nbsp; &lt; compiler/prelude/primops.txt &gt; compiler/primop-tag.hs-incl</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">"inplace/bin/genprimopcode" --primop-list &nbsp; &nbsp; &nbsp; &nbsp;&lt; compiler/prelude/primops.txt &gt; compiler/primop-list.hs-incl</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">"inplace/bin/genprimopcode" --has-side-effects &nbsp; &lt; compiler/prelude/primops.txt &gt; compiler/primop-has-side-effects.hs-incl</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">"inplace/bin/genprimopcode" --out-of-line &nbsp; &nbsp; &nbsp; &nbsp;&lt; compiler/prelude/primops.txt &gt; compiler/primop-out-of-line.hs-incl</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">"inplace/bin/genprimopcode" --commutable &nbsp; &nbsp; &nbsp; &nbsp; &lt; compiler/prelude/primops.txt &gt; compiler/primop-commutable.hs-incl</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">"inplace/bin/genprimopcode" --code-size &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt; compiler/prelude/primops.txt &gt; compiler/primop-code-size.hs-incl</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">"inplace/bin/genprimopcode" --can-fail &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt; compiler/prelude/primops.txt &gt; compiler/primop-can-fail.hs-incl</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">"inplace/bin/genprimopcode" --strictness &nbsp; &nbsp; &nbsp; &nbsp; &lt; compiler/prelude/primops.txt &gt; compiler/primop-strictness.hs-incl</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">"inplace/bin/genprimopcode" --primop-primop-info &lt; compiler/prelude/primops.txt &gt; compiler/primop-primop-info.hs-incl</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">genprimopcode: ppType: can't handle: TyApp "DoubleVec#" []</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">make[1]: *** [compiler/primop-primop-info.hs-incl] Error 1</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">make[1]: *** Deleting file `compiler/primop-primop-info.hs-incl'</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">make: *** [all] Error 2</div></div><div><br></div><div><br></div><div>So, I'm thinking the type needs to be better defined but I haven't tracked it down yet (I'm working on it though ;-)</div><div><br></div><div>Any clues?</div><br><div>
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Paul Monday</div><div>Parallel Scientific, LLC.</div><div><a href="mailto:paul.monday@parsci.com">paul.monday@parsci.com</a></div><div><br></div></div><br class="Apple-interchange-newline"><br class="Apple-interchange-newline">
</div>

<br></body></html>