<div dir="ltr">Sorry, %id is a register! so I need <span style="font-size:12.8px"><b style="font-style:italic">@llvm.nvvm.read.ptx.sreg.tid.* </b>I guess.</span></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 21, 2016 at 2:53 PM, Gurunath Kadam <span dir="ltr"><<a href="mailto:gurunath.kadam@gmail.com" target="_blank">gurunath.kadam@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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="m_-5110949205201696906gmail-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="m_-5110949205201696906gmail-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="m_-5110949205201696906gmail-docutils m_-5110949205201696906gmail-literal" style="font-family:consolas,"deja vu sans mono","bitstream vera sans mono",monospace;font-size:0.95em"><span class="m_-5110949205201696906gmail-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="m_-5110949205201696906gmail-docutils m_-5110949205201696906gmail-literal" style="font-family:consolas,"deja vu sans mono","bitstream vera sans mono",monospace;font-size:0.95em"><span class="m_-5110949205201696906gmail-pre">@llvm.nvvm.read.ptx.sreg.tid.*</span></code></td></tr><tr class="m_-5110949205201696906gmail-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="m_-5110949205201696906gmail-c" style="color:rgb(96,160,176);font-style:italic">; What is my ID?</span>
<span class="m_-5110949205201696906gmail-nv" style="color:rgb(187,96,213)">%id</span> <span class="m_-5110949205201696906gmail-p">=</span> <span class="m_-5110949205201696906gmail-k" style="color:rgb(0,112,32);font-weight:bold">tail</span> <span class="m_-5110949205201696906gmail-k" style="color:rgb(0,112,32);font-weight:bold">call</span> <span class="m_-5110949205201696906gmail-k" style="color:rgb(0,112,32);font-weight:bold">i32</span> <span class="m_-5110949205201696906gmail-vg" style="color:rgb(187,96,213)">@llvm.nvvm.read.ptx.sreg.tid.x</span><span class="m_-5110949205201696906gmail-p"><wbr>()</span> <span class="m_-5110949205201696906gmail-k" style="color:rgb(0,112,32);font-weight:bold">readnone</span> <span class="m_-5110949205201696906gmail-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>
</blockquote></div><br></div>