]> granicus.if.org Git - llvm/commitdiff
[IRTranslator] Support the translation of or.
authorQuentin Colombet <qcolombet@apple.com>
Fri, 10 Jun 2016 20:50:35 +0000 (20:50 +0000)
committerQuentin Colombet <qcolombet@apple.com>
Fri, 10 Jun 2016 20:50:35 +0000 (20:50 +0000)
Now or instructions get translated into G_OR.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272433 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/GlobalISel/IRTranslator.cpp
test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll

index ea11b3162550bd81558a5ab90c356ebbc58e7c40..f4f1906be817dfc90ede393ad957179a42cdbeea 100644 (file)
@@ -104,6 +104,8 @@ bool IRTranslator::translate(const Instruction &Inst) {
   switch(Inst.getOpcode()) {
   case Instruction::Add:
     return translateBinaryOp(TargetOpcode::G_ADD, Inst);
+  case Instruction::Or:
+    return translateBinaryOp(TargetOpcode::G_OR, Inst);
   case Instruction::Br:
     return translateBr(Inst);
   case Instruction::Ret:
index 8baa64df9d8d0ee5e8e71193621f7e6ee6f639ec..2ce035e1dc0b4811f5a9c298b2d819a6c61b702a 100644 (file)
@@ -38,3 +38,26 @@ define void @uncondbr() {
 end:
   ret void
 }
+
+; Tests for or.
+; CHECK: name: ori64
+; CHECK: [[ARG1:%[0-9]+]](64) = COPY %x0
+; CHECK-NEXT: [[ARG2:%[0-9]+]](64) = COPY %x1
+; CHECK-NEXT: [[RES:%[0-9]+]](64) = G_OR i64 [[ARG1]], [[ARG2]]
+; CHECK-NEXT: %x0 = COPY [[RES]]
+; CHECK-NEXT: RET_ReallyLR implicit %x0
+define i64 @ori64(i64 %arg1, i64 %arg2) {
+  %res = or i64 %arg1, %arg2
+  ret i64 %res
+}
+
+; CHECK: name: ori32
+; CHECK: [[ARG1:%[0-9]+]](32) = COPY %w0
+; CHECK-NEXT: [[ARG2:%[0-9]+]](32) = COPY %w1
+; CHECK-NEXT: [[RES:%[0-9]+]](32) = G_OR i32 [[ARG1]], [[ARG2]]
+; CHECK-NEXT: %w0 = COPY [[RES]]
+; CHECK-NEXT: RET_ReallyLR implicit %w0
+define i32 @ori32(i32 %arg1, i32 %arg2) {
+  %res = or i32 %arg1, %arg2
+  ret i32 %res
+}