let isCommutable = 0;
}
+// Generic subtraction.
+def G_MUL : Instruction {
+ let OutOperandList = (outs unknown:$dst);
+ let InOperandList = (ins unknown:$src1, unknown:$src2);
+ let hasSideEffects = 0;
+ let isCommutable = 1;
+}
+
// Generic addition consuming and producing a carry flag.
def G_ADDE : Instruction {
let OutOperandList = (outs unknown:$dst, unknown:$carry_out);
/// Generic SUB instruction. This is an integer sub.
HANDLE_TARGET_OPCODE(G_SUB)
-/// Generic Bitwise-AND instruction.
+// Generic multiply instruction.
+HANDLE_TARGET_OPCODE(G_MUL)
+
+/// Generic bitwise and instruction.
HANDLE_TARGET_OPCODE(G_AND)
/// Generic bitwise or instruction.
/// Generic bitwise exclusive-or instruction.
HANDLE_TARGET_OPCODE(G_XOR)
+
/// Generic instruction to materialize the address of an alloca or other
/// stack-based object.
HANDLE_TARGET_OPCODE(G_FRAME_INDEX)
/// Generic extension allowing rubbish in high bits.
HANDLE_TARGET_OPCODE(G_ANYEXTEND)
-/// Generic truncation.
+/// Generic instruction to discard the high bits of a register. This differs
+/// from (G_EXTRACT val, 0) on its action on vectors: G_TRUNC will truncate
+/// each element individually, G_EXTRACT will typically discard the high
+/// elements of the vector.
HANDLE_TARGET_OPCODE(G_TRUNC)
/// Generic integer constant.
// Bitwise operations.
case Instruction::And:
return translateBinaryOp(TargetOpcode::G_AND, cast<BinaryOperator>(Inst));
+ case Instruction::Mul:
+ return translateBinaryOp(TargetOpcode::G_MUL, cast<BinaryOperator>(Inst));
case Instruction::Or:
return translateBinaryOp(TargetOpcode::G_OR, cast<BinaryOperator>(Inst));
case Instruction::Xor:
ret i64 %res
}
+; CHECK-LABEL: name: muli64
+; CHECK: [[ARG1:%[0-9]+]](64) = COPY %x0
+; CHECK-NEXT: [[ARG2:%[0-9]+]](64) = COPY %x1
+; CHECK-NEXT: [[RES:%[0-9]+]](64) = G_MUL s64 [[ARG1]], [[ARG2]]
+; CHECK-NEXT: %x0 = COPY [[RES]]
+; CHECK-NEXT: RET_ReallyLR implicit %x0
+define i64 @muli64(i64 %arg1, i64 %arg2) {
+ %res = mul i64 %arg1, %arg2
+ ret i64 %res
+}
+
; Tests for alloca
; CHECK-LABEL: name: allocai64
; CHECK: stack: