diff --git a/llvm/include/llvm/CodeGen/ISDOpcodes.h b/llvm/include/llvm/CodeGen/ISDOpcodes.h --- a/llvm/include/llvm/CodeGen/ISDOpcodes.h +++ b/llvm/include/llvm/CodeGen/ISDOpcodes.h @@ -281,12 +281,25 @@ /// Carry-using nodes for multiple precision addition and subtraction. /// These nodes take three operands: The first two are the normal lhs and - /// rhs to the add or sub, and the third is a boolean indicating if there - /// is an incoming carry. These nodes produce two results: the normal - /// result of the add or sub, and the output carry so they can be chained - /// together. The use of this opcode is preferable to adde/sube if the - /// target supports it, as the carry is a regular value rather than a - /// glue, which allows further optimisation. + /// rhs to the add or sub, and the third is a boolean value that is 1 if and + /// only if there is an incoming carry/borrow. These nodes produce two + /// results: the normal result of the add or sub, and a boolean value that is + /// 1 if and only if there is an outgoing carry/borrow. + /// + /// Care must be taken if these opcodes are lowered to hardware instructions + /// that use the inverse logic -- 0 if and only if there is an + /// incoming/outgoing carry/borrow. In such cases, you must preserve the + /// semantics of these opcodes by inverting the incoming carry/borrow, feeding + /// it to the add/sub hardware instruction, and then inverting the outgoing + /// carry/borrow. + /// + /// The use of these opcodes is preferable to adde/sube if the target supports + /// it, as the carry is a regular value rather than a glue, which allows + /// further optimisation. + /// + /// These opcodes are different from [US]{ADD,SUB}O in that ADDCARRY/SUBCARRY + /// consume and produce a carry/borrow, whereas [US]{ADD,SUB}O produce an + /// overflow. ADDCARRY, SUBCARRY,