| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
package org.apache.commons.nabla.automatic.arithmetic; |
| 18 | |
|
| 19 | |
import org.apache.commons.nabla.automatic.analysis.InstructionsTransformer; |
| 20 | |
import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator; |
| 21 | |
import org.apache.commons.nabla.core.DifferentiationException; |
| 22 | |
import org.objectweb.asm.Opcodes; |
| 23 | |
import org.objectweb.asm.tree.AbstractInsnNode; |
| 24 | |
import org.objectweb.asm.tree.InsnList; |
| 25 | |
import org.objectweb.asm.tree.InsnNode; |
| 26 | |
import org.objectweb.asm.tree.VarInsnNode; |
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | 1 | public class DMulTransformer12 implements InstructionsTransformer { |
| 36 | |
|
| 37 | |
|
| 38 | 8 | private static class LazyHolder { |
| 39 | |
|
| 40 | 1 | private static final InstructionsTransformer INSTANCE = new DMulTransformer12(); |
| 41 | |
} |
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | 1 | private DMulTransformer12() { |
| 46 | 1 | } |
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
public static InstructionsTransformer getInstance() { |
| 53 | 8 | return LazyHolder.INSTANCE; |
| 54 | |
} |
| 55 | |
|
| 56 | |
|
| 57 | |
public InsnList getReplacement(final AbstractInsnNode insn, |
| 58 | |
final MethodDifferentiator methodDifferentiator) |
| 59 | |
throws DifferentiationException { |
| 60 | |
|
| 61 | 8 | final int tmp1 = methodDifferentiator.getTmp(1); |
| 62 | 8 | final int tmp2 = methodDifferentiator.getTmp(2); |
| 63 | 8 | final int tmp3 = methodDifferentiator.getTmp(3); |
| 64 | 8 | final InsnList list = new InsnList(); |
| 65 | |
|
| 66 | |
|
| 67 | 8 | list.add(new VarInsnNode(Opcodes.DSTORE, tmp1)); |
| 68 | 8 | list.add(new InsnNode(Opcodes.DUP2)); |
| 69 | 8 | list.add(new VarInsnNode(Opcodes.DSTORE, tmp2)); |
| 70 | 8 | list.add(new InsnNode(Opcodes.DMUL)); |
| 71 | 8 | list.add(new VarInsnNode(Opcodes.DSTORE, tmp3)); |
| 72 | 8 | list.add(new InsnNode(Opcodes.DUP2)); |
| 73 | 8 | list.add(new VarInsnNode(Opcodes.DLOAD, tmp1)); |
| 74 | 8 | list.add(new InsnNode(Opcodes.DMUL)); |
| 75 | 8 | list.add(new VarInsnNode(Opcodes.DLOAD, tmp3)); |
| 76 | 8 | list.add(new InsnNode(Opcodes.DADD)); |
| 77 | 8 | list.add(new VarInsnNode(Opcodes.DSTORE, tmp1)); |
| 78 | 8 | list.add(new VarInsnNode(Opcodes.DLOAD, tmp2)); |
| 79 | 8 | list.add(new InsnNode(Opcodes.DMUL)); |
| 80 | 8 | list.add(new VarInsnNode(Opcodes.DLOAD, tmp1)); |
| 81 | |
|
| 82 | 8 | return list; |
| 83 | |
|
| 84 | |
} |
| 85 | |
|
| 86 | |
} |