mercredi 3 février 2016

Replicate llvm instructions

I'm trying to replicate instruction (addition binary operation for example), and show them in the LLVM IR, but the following code only returns the 1st instruction (add1) that I built.How to return both built instructions ?

        IRBuilder<> builder(op);

        Value *lhs = op->getOperand(0);
        Value *rhs = op->getOperand(1);
        Value *add1 = builder.CreateAdd(lhs, rhs);
        Value *add2 = builder.CreateAdd(lhs, rhs);

        for (auto &U : op->uses()) {
          User *user = U.getUser();  // A User is anything with operands.
          user->setOperand(U.getOperandNo(), add1);
          user->setOperand(U.getOperandNo(), add2);
        }

Aucun commentaire:

Enregistrer un commentaire