<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 12/01/2016 04:01 PM, Louis Li via
      llvm-dev wrote:<br>
    </div>
    <blockquote
cite="mid:CADQ-RE-8eZZHQkiEMaQxqT9g5qEdkVH1w4rdhSe=Fub4n0e=hg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>Hi, I'm trying to implement a target-agnostic intrinsic,
          first targeting X86. I'm trying to map the intrinsic SD node
          to an instruction with a certain target opcode that I've
          introduced. The issue that I'm running into is what the
          correct way to lower the argument is. I've done a couple loops
          on the docs so any help would be appreciated!</div>
      </div>
    </blockquote>
    I'm really confused by the way you're asking the question.  Assuming
    you're adding code to SelectionDAGBuilder, handling the argument
    should just be a getValue(Value*) call.  Take a look at the lowering
    for ctlz (or one of many other examples), how are your arguments
    different than what's done here?  Do you need to vary the psuedo op
    emitted depending on the argument or something like that?<br>
    <blockquote
cite="mid:CADQ-RE-8eZZHQkiEMaQxqT9g5qEdkVH1w4rdhSe=Fub4n0e=hg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div><br>
        </div>
        <div>Some options I've explored but have been missing some
          crucial step/concept:</div>
        <div>- tablegen matching?</div>
        <div>- SelectionDAGBuilder.cpp + BuildMI call (but then this
          runs into the issue of lowering the argument correctly - not
          sure if that's feasible at this point in instruction
          selection)</div>
        <div>- X86ISelLowering -- same confusion as above</div>
        <div><br>
        </div>
        <div>Here's how the dag currently looks (before erroring out,
          since I haven't handled the intrinsic)</div>
        <div><a moz-do-not-send="true"
href="https://drive.google.com/file/d/0B5G4m_mQneSjRWQzRVltdDJOQnM/view?usp=sharing">https://drive.google.com/file/d/0B5G4m_mQneSjRWQzRVltdDJOQnM/view?usp=sharing</a><br>
        </div>
        <div>Would it be problematic if I somehow extracted the pointer
          address arg to the intrisic from TargetConstant and passed it
          as MachineOperand to the MachineInstruction?</div>
        <div><br>
        </div>
        <div>Opcode definition (Target/Target.td)<br>
        </div>
        <div>==============</div>
        <div>
          <div>+def PATCHABLE_LOG_CALL : Instruction {</div>
          <div>+  let OutOperandList = (outs);</div>
          <div>+  let InOperandList = (ins unknown:$entry);</div>
          <div>+  let AsmString = "# XRay Custom Log.";</div>
          <div>+  let usesCustomInserter = 1;</div>
          <div>+  let hasSideEffects = 1;</div>
          <div>+}</div>
        </div>
        <div><br>
        </div>
        <div>Example IR for the graph above</div>
        <div>===========</div>
        <div>define i32 @caller() nounwind noinline uwtable
          "function-instrument"="xray-always" {</div>
        <div>    %logentryptr = alloca i8</div>
        <div>    call void @llvm.xray.customlog(i8* %logentryptr)</div>
        <div>    ret i32 0</div>
        <div>}</div>
        <div><br>
        </div>
        <div>declare void @llvm.xray.customlog(i8*)</div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
    </blockquote>
    <p><br>
    </p>
  </body>
</html>