diff options
author | Brian Sullivan <briansul@microsoft.com> | 2019-01-10 16:29:42 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-10 16:29:42 -0800 |
commit | 459b58a7766707fb059a5762c7d72cb0af42a6ff (patch) | |
tree | d6023ccf22ceab28229b1c26d151a62d96c9db44 /src/jit/codegenlinear.cpp | |
parent | a2e33937c7cbff1e5eebb7848d8ce7c039812749 (diff) | |
parent | 12cfc7fbc6f7f44ba4f32fdfe9168057fc8da5ea (diff) | |
download | coreclr-459b58a7766707fb059a5762c7d72cb0af42a6ff.tar.gz coreclr-459b58a7766707fb059a5762c7d72cb0af42a6ff.tar.bz2 coreclr-459b58a7766707fb059a5762c7d72cb0af42a6ff.zip |
Merge pull request #17733 from mikedn/cc-cond2
Expand GT_JCC/SETCC condition support
Diffstat (limited to 'src/jit/codegenlinear.cpp')
-rw-r--r-- | src/jit/codegenlinear.cpp | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/src/jit/codegenlinear.cpp b/src/jit/codegenlinear.cpp index 7da1896589..33108f1904 100644 --- a/src/jit/codegenlinear.cpp +++ b/src/jit/codegenlinear.cpp @@ -2132,3 +2132,81 @@ void CodeGen::genStoreLongLclVar(GenTree* treeNode) } } #endif // !defined(_TARGET_64BIT_) + +//------------------------------------------------------------------------ +// genCodeForJumpTrue: Generate code for a GT_JTRUE node. +// +// Arguments: +// jtrue - The node +// +void CodeGen::genCodeForJumpTrue(GenTreeOp* jtrue) +{ + assert(compiler->compCurBB->bbJumpKind == BBJ_COND); + assert(jtrue->OperIs(GT_JTRUE)); + + GenCondition condition = GenCondition::FromRelop(jtrue->gtGetOp1()); + + if (condition.PreferSwap()) + { + condition = GenCondition::Swap(condition); + } + + inst_JCC(condition, compiler->compCurBB->bbJumpDest); +} + +//------------------------------------------------------------------------ +// genCodeForJcc: Generate code for a GT_JCC node. +// +// Arguments: +// jcc - The node +// +void CodeGen::genCodeForJcc(GenTreeCC* jcc) +{ + assert(compiler->compCurBB->bbJumpKind == BBJ_COND); + assert(jcc->OperIs(GT_JCC)); + + inst_JCC(jcc->gtCondition, compiler->compCurBB->bbJumpDest); +} + +//------------------------------------------------------------------------ +// inst_JCC: Generate a conditional branch instruction sequence. +// +// Arguments: +// condition - The branch condition +// target - The basic block to jump to when the condition is true +// +void CodeGen::inst_JCC(GenCondition condition, BasicBlock* target) +{ + const GenConditionDesc& desc = GenConditionDesc::Get(condition); + + if (desc.oper == GT_NONE) + { + inst_JMP(desc.jumpKind1, target); + } + else if (desc.oper == GT_OR) + { + inst_JMP(desc.jumpKind1, target); + inst_JMP(desc.jumpKind2, target); + } + else // if (desc.oper == GT_AND) + { + BasicBlock* labelNext = genCreateTempLabel(); + inst_JMP(emitter::emitReverseJumpKind(desc.jumpKind1), labelNext); + inst_JMP(desc.jumpKind2, target); + genDefineTempLabel(labelNext); + } +} + +//------------------------------------------------------------------------ +// genCodeForSetcc: Generate code for a GT_SETCC node. +// +// Arguments: +// setcc - The node +// +void CodeGen::genCodeForSetcc(GenTreeCC* setcc) +{ + assert(setcc->OperIs(GT_SETCC)); + + inst_SETCC(setcc->gtCondition, setcc->TypeGet(), setcc->gtRegNum); + genProduceReg(setcc); +} |