<div dir="ltr">Hi,<br><br>I have one more query regarding the LLVM representations. In LLVM Infrastructure, "label" is defined as Primitive type. So, is there any way of using a variable of Type Label in some arithmetic operation or in "bitcast" instruction.<br>
<br>I tried the following code:<br><br><br><br><i>label %X1:<br>X1:<br>   %y = bitcast label %X1 to i32<br>    %tmp1 = add i32 %y,2</i><br><br><br>llvm-as gave me an error that: "Basic block can't be used in line 3" (Bitcast)<br>
<br>Is there any other way to use label in arithmetic operations. I am trying this to represent Program counter in LLVM, since in ARM, we can have various instructions which operate on PC , eg. <br><br>R2 = ADD PC,10 <br>
   <br><br>Thanks<br><br>Regards,<br>Kapil<br><br><div class="gmail_quote">On Mon, Jul 14, 2008 at 8:52 PM, Evan Cheng <<a href="mailto:evan.cheng@apple.com">evan.cheng@apple.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div style=""><br><div><div class="Ih2E3d"><div>On Jul 14, 2008, at 5:10 PM, kapil anand wrote:</div><br><blockquote type="cite">Hi Evan,<br><br>Thanks for the answers. I had few more queries though.<br><br>1. As far as I was able to understand the Codegen infrastructure, ARMInstrInfo.td file has complete description of the instructions which modify the status flags. For example, we have description for both ADD and ADDS. But the problem is that in LLVM, we have a single "ADD" Instruction. Thus when we do getDesc(add), we get the descripiton corresponding to "ADD". When I was reading the code, I got a feeling that if we are able to modify this selection of "ADD" to "ADDS"( provided we somehow determine that we need ADDS here), then everything else related to ARM instruction generation has been handled in current infrastructure. Is this correct or do we need to modify other things also?</blockquote>
<div><br></div></div>The short answer is we'll need to modify other things. It's possible to custom lower setcc / select_cc, etc. to handle some the cases and enable selection of ADDS. But it won't be a very generic fix. The right fix is to add a pass to optimize away the cmp instruction by *folding* it in the preceding add when it's legal. Ideally this will be a target independent pass that x86 and other targets can take advantage of as well.</div>
<div><div class="Ih2E3d"><br><blockquote type="cite"><br> <br>2. In file ARMISelLowering.cpp, inside function FPCCtoARMCC, condition ISD::SETO generates ARMCC::VC ( Overflow clear) condition. Thus, if we are able to appropriately generate ISD::SETO inside SDNode for overflow clear and then map it to ARMCC::VC instruction in IntCCtoARMCC, then will that be enough to generate the an instruction like "addvc"?</blockquote>
<div><br></div></div>addvc means "executing the add when overflow clear"? Then yes, that will happen as a result of if conversion if the incoming instruction selection input looks like that.</div><div><div></div>
<div class="Wj3C7c"><div><br></div><div>Evan</div><div><br></div><div><blockquote type="cite"><br> <br>Thanks<br><br>Regards,<br>Kapil Anand<br><br><div class="gmail_quote">On Mon, Jul 14, 2008 at 6:10 PM, Evan Cheng <<a href="mailto:evan.cheng@apple.com" target="_blank">evan.cheng@apple.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> <div><br><div><div><div>On Jul 14, 2008, at 12:59 PM, kapil anand wrote:</div><br><blockquote type="cite">
Hi all,<br><br>I am using LLVM compiler and CodeGen  for generating ARM binaries. <br><br>I was going through the code for ARM backend. I noticed that the ARM Condition field( Bits 31-28) is generated by converting the conditions used in icmp and branch. For example, if I have following C Code<br>
 <br>int a,b,c,d;<br>c = a+b;<br><br>if(c==0)<br>     d = a + 10;<br><br><br>Then I get ( Assembly Instructions with opcodes only)<br><br>add <br><b>cmp</b><br>addeq<br><br><br>( basically converting branch to the predicate condition field)<br>
 <br>I have a few questions regarding the above operation.<br>1. If I use GCC on above code, then I get following .s output:<br>   adds<br>   addeq<br><br>I don't  get the intermediate compare instruction, which I got when I used LLVM. So, does LLVM ARM Backend assume that only "cmp" and "test" instructions can set the Status flags and not the usual arithmetic instructions. Is there any way of specifying to Backend that add can also modify status flag through "s" bit.</blockquote>
 <div><br></div></div>Right. X86 backend has the same issue. It's not taking advantage of the fact that instructions can set the condition register bits. It's a known codegen deficiency. On x86 it's generally not a *huge* issue but I have no idea what its impact is on various ARM implementations.</div>
 <div><div><br><blockquote type="cite"><br> <br>2. Also, when I looked at ISelLowering file, I noticed that conditions used in "icmp" instructions are converted to ARM Predicate Condition fields. Icmp has only "10" conditions, which map to corresponding "10" conditions in ARM Condition field but ARM can have fourteen conditions. If we consider the mapping shown in ISelLowering File, then following four conditions are left:<br>
 "VS": Overflow Set<br>"VC" : Overflow Clear<br>"MI" : Minus<br>"PL": Plus<br><br>So, does this mean that it is not possible to obtain the above conditions are predicate if we use LLVM Compiler framework.</blockquote>
 <div><br></div></div>It's not clear to me how those are modeled in the llvm level.</div><div><br></div><div>Evan</div><div><br><blockquote type="cite"><br> <br>Thanks<br><br>Regards,<br>Kapil Anand<br><br><br> _______________________________________________<br>
 LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
 </blockquote></div><br></div><br>_______________________________________________<br> LLVM Developers mailing list<br> <a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
 <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br> <br></blockquote></div><br> _______________________________________________<br>LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</blockquote></div><br></div></div></div><br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br></div>