Hi llvmdev,<br><br>I've noticed that there is no unary operator in LLVM. For unary operator such as Neg or Or operator, the IR builder just creates a binary operation with one dummy operand,<br><font size="2"><br></font><pre class="fragment">
<font size="2"><a class="code" href="http://llvm.org/doxygen/classllvm_1_1BinaryOperator.html#a073c092ce74a122e898e435e60e84599">01823</a> <a class="code" href="http://llvm.org/doxygen/classllvm_1_1BinaryOperator.html">BinaryOperator</a> *<a class="code" href="http://llvm.org/doxygen/classllvm_1_1BinaryOperator.html#a073c092ce74a122e898e435e60e84599">BinaryOperator::CreateNeg</a>(<a class="code" href="http://llvm.org/doxygen/classllvm_1_1Value.html" title="LLVM Value Representation.">Value</a> *Op, <span class="keyword">const</span> <a class="code" href="http://llvm.org/doxygen/classllvm_1_1Twine.html">Twine</a> &Name,
<a name="l01824"></a>01824                                           <a class="code" href="http://llvm.org/doxygen/classllvm_1_1BasicBlock.html" title="LLVM Basic Block Representation.">BasicBlock</a> *InsertAtEnd) {
<a name="l01825"></a>01825   <a class="code" href="http://llvm.org/doxygen/classllvm_1_1Value.html" title="LLVM Value Representation.">Value</a> *zero = <a class="code" href="http://llvm.org/doxygen/classllvm_1_1ConstantFP.html#ab4d218c572245abd0b1c895d603cba36">ConstantFP::getZeroValueForNegation</a>(Op-><a class="code" href="http://llvm.org/doxygen/classllvm_1_1Value.html#a0cf3748dba54f931bb1241ae4adc76bc">getType</a>());
<a name="l01826"></a>01826   <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="http://llvm.org/doxygen/classllvm_1_1BinaryOperator.html#acf242c32d995c5276931f545aa2bdd9c">BinaryOperator</a>(Instruction::Sub,
<a name="l01827"></a>01827                             zero, Op,
<a name="l01828"></a>01828                             Op-><a class="code" href="http://llvm.org/doxygen/classllvm_1_1Value.html#a0cf3748dba54f931bb1241ae4adc76bc">getType</a>(), <a class="code" href="http://llvm.org/doxygen/classllvm_1_1BinaryOperator.html#a274586caf47dcc28ed878ad21af28152">Name</a>, InsertAtEnd);
</font></pre><br><br>However, I think it's more natural to describe this as unary operation, and may bring benefits to the optimiser and code generator.<br><br>Can anyone tell me the reason? <br><br>Thanks!   <br><br>