<div dir="ltr">Hi,<div><br></div><div>I am writing my first pass in LLVM.</div><div><br></div><div>I need to collect the threadId in each kernel call and then associate that with the corresponding load/store calls.</div><div><br></div><div>I am stuck at extracting the threadId.</div><div><br></div><div>LLVM intrinsic for thread ID declaration:</div><div><br></div><div><table border="1" class="gmail-docutils" style="border-collapse:collapse;border:0px;color:rgb(0,0,0);font-family:"lucida grande","lucida sans unicode",geneva,verdana,sans-serif;font-size:14px"><tbody valign="top"><tr class="gmail-row-even"><td style="padding:1px 8px 1px 5px;border-width:0px 0px 1px;border-top-style:initial;border-top-color:initial;border-left-style:initial;border-left-color:initial;border-right-style:initial;border-right-color:initial;border-bottom-style:solid;border-bottom-color:rgb(170,170,170)"><code class="gmail-docutils gmail-literal" style="font-family:consolas,"deja vu sans mono","bitstream vera sans mono",monospace;font-size:0.95em"><span class="gmail-pre">threadId</span></code></td><td style="padding:1px 8px 1px 5px;border-width:0px 0px 1px;border-top-style:initial;border-top-color:initial;border-left-style:initial;border-left-color:initial;border-right-style:initial;border-right-color:initial;border-bottom-style:solid;border-bottom-color:rgb(170,170,170)"><code class="gmail-docutils gmail-literal" style="font-family:consolas,"deja vu sans mono","bitstream vera sans mono",monospace;font-size:0.95em"><span class="gmail-pre">@llvm.nvvm.read.ptx.sreg.tid.*</span></code></td></tr><tr class="gmail-row-odd"></tr></tbody></table><br></div><div>Actual call:</div><div><pre style="overflow-x:auto;overflow-y:hidden;font-family:consolas,"deja vu sans mono","bitstream vera sans mono",monospace;font-size:0.95em;line-height:15.96px;padding:0.5em;border:1px solid rgb(204,204,204);background-color:rgb(248,248,248);color:rgb(0,0,0)"><span class="gmail-c" style="color:rgb(96,160,176);font-style:italic">; What is my ID?</span>
<span class="gmail-nv" style="color:rgb(187,96,213)">%id</span> <span class="gmail-p">=</span> <span class="gmail-k" style="color:rgb(0,112,32);font-weight:bold">tail</span> <span class="gmail-k" style="color:rgb(0,112,32);font-weight:bold">call</span> <span class="gmail-k" style="color:rgb(0,112,32);font-weight:bold">i32</span> <span class="gmail-vg" style="color:rgb(187,96,213)">@llvm.nvvm.read.ptx.sreg.tid.x</span><span class="gmail-p">()</span> <span class="gmail-k" style="color:rgb(0,112,32);font-weight:bold">readnone</span> <span class="gmail-k" style="color:rgb(0,112,32);font-weight:bold">nounwind</span></pre></div><div><br></div><div>So in the above LLVM IR instruction <b><i>@llvm.nvvm.read.ptx.sreg.tid.*</i></b> is the operand 1, is that right? And then is <b><i>%id</i></b> operand 0?</div><div><br></div><div>So I need to check for an instruction with the operand type matching above expression and then extract operand 0.</div><div><br></div><div>Is my understanding right?</div><div><br></div><div>Thank you.</div><div><br></div><div>Regards,</div><div>Gurunath</div></div>