Add GT_BT
authorMike Danes <onemihaid@hotmail.com>
Sat, 29 Apr 2017 10:49:20 +0000 (13:49 +0300)
committerMike Danes <onemihaid@hotmail.com>
Wed, 13 Sep 2017 13:05:59 +0000 (16:05 +0300)
src/jit/codegenlinear.h
src/jit/codegenxarch.cpp
src/jit/gtlist.h
src/jit/lsraxarch.cpp

index 40f61bc..f3f6e9d 100644 (file)
@@ -163,6 +163,7 @@ void genCodeForShiftLong(GenTreePtr tree);
 
 #ifdef _TARGET_XARCH_
 void genCodeForShiftRMW(GenTreeStoreInd* storeInd);
+void genCodeForBT(GenTreeOp* bt);
 #endif // _TARGET_XARCH_
 
 void genCodeForCast(GenTreeOp* tree);
index 5128785..8e772e2 100644 (file)
@@ -1475,6 +1475,30 @@ void CodeGen::genCodeForCompare(GenTreeOp* tree)
 }
 
 //------------------------------------------------------------------------
+// genCodeForBT: Generates code for a GT_BT node.
+//
+// Arguments:
+//    tree - The node.
+//
+void CodeGen::genCodeForBT(GenTreeOp* bt)
+{
+    assert(bt->OperIs(GT_BT));
+
+    GenTree*  op1  = bt->gtGetOp1();
+    GenTree*  op2  = bt->gtGetOp2();
+    var_types type = genActualType(op1->TypeGet());
+
+    assert(op1->isUsedFromReg() && op2->isUsedFromReg());
+    assert((genTypeSize(type) >= genTypeSize(TYP_INT)) && (genTypeSize(type) <= genTypeSize(TYP_I_IMPL)));
+
+    genConsumeOperands(bt);
+    // Note that the emitter doesn't fully support INS_bt, it only supports the reg,reg
+    // form and encodes the registers in reverse order. To get the correct order we need
+    // to reverse the operands when calling emitIns_R_R.
+    getEmitter()->emitIns_R_R(INS_bt, emitTypeSize(type), op2->gtRegNum, op1->gtRegNum);
+}
+
+//------------------------------------------------------------------------
 // genCodeForJumpTrue: Generates code for jmpTrue statement.
 //
 // Arguments:
@@ -1875,6 +1899,10 @@ void CodeGen::genCodeForTreeNode(GenTreePtr treeNode)
             genCodeForSetcc(treeNode->AsCC());
             break;
 
+        case GT_BT:
+            genCodeForBT(treeNode->AsOp());
+            break;
+
         case GT_RETURNTRAP:
             genCodeForReturnTrap(treeNode->AsOp());
             break;
index 5440233..314660f 100644 (file)
@@ -225,7 +225,10 @@ GTNODE(JCC              , GenTreeCC          ,0,GTK_LEAF|GTK_NOVALUE)   // Check
                                                                         // by GenTreeCC::gtCondition is true.
 GTNODE(SETCC            , GenTreeCC          ,0,GTK_LEAF)               // Checks the condition flags and produces 1 if the condition specified 
                                                                         // by GenTreeCC::gtCondition is true and 0 otherwise.
-
+#ifdef _TARGET_XARCH_
+GTNODE(BT               , GenTreeOp          ,0,GTK_BINOP|GTK_NOVALUE)  // The XARCH BT instruction. Like CMP, this sets the condition flags (CF
+                                                                        // to be precise) and does not produce a value.
+#endif
 //-----------------------------------------------------------------------------
 //  Other nodes that look like unary/binary operators:
 //-----------------------------------------------------------------------------
index a42d8ec..280e2f3 100644 (file)
@@ -343,6 +343,7 @@ void LinearScan::TreeNodeInfoInit(GenTree* tree)
         case GT_AND:
         case GT_OR:
         case GT_XOR:
+        case GT_BT:
             info->srcCount = GetOperandSourceCount(tree->gtOp.gtOp1);
             info->srcCount += GetOperandSourceCount(tree->gtOp.gtOp2);
             break;