diff options
author | Zhan Jun Liau <zhanjunl@ca.ibm.com> | 2016-06-10 19:58:10 +0000 |
---|---|---|
committer | Zhan Jun Liau <zhanjunl@ca.ibm.com> | 2016-06-10 19:58:10 +0000 |
commit | ab42cbce9807778d3087454f483dc7266833975a (patch) | |
tree | db74411e2bea60c36ebf25b3c34fdffb38d8c8ae /llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp | |
parent | f3af841462ad6dfc6c2fee5a441400b4bded931c (diff) | |
download | bcm5719-llvm-ab42cbce9807778d3087454f483dc7266833975a.tar.gz bcm5719-llvm-ab42cbce9807778d3087454f483dc7266833975a.zip |
[SystemZ] Support Compare and Traps
Support and generate Compare and Traps like CRT, CIT, etc.
Support Trap as legal DAG opcodes and generate "j .+2" for them by default.
Add support for Conditional Traps and use the If Converter to convert them into
the corresponding compare and trap opcodes.
Differential Revision: http://reviews.llvm.org/D21155
llvm-svn: 272419
Diffstat (limited to 'llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp')
-rw-r--r-- | llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp b/llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp index fa824d01065..463941940bd 100644 --- a/llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp +++ b/llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp @@ -543,6 +543,7 @@ bool SystemZInstrInfo::isPredicable(MachineInstr &MI) const { if (STI.hasLoadStoreOnCond() && getConditionalMove(Opcode)) return true; if (Opcode == SystemZ::Return || + Opcode == SystemZ::Trap || Opcode == SystemZ::CallJG || Opcode == SystemZ::CallBR) return true; @@ -558,7 +559,11 @@ isProfitableToIfCvt(MachineBasicBlock &MBB, // making the loop body longer). This doesn't apply for low-probability // loops (eg. compare-and-swap retry), so just decide based on branch // probability instead of looping structure. - if (MBB.succ_empty() && Probability < BranchProbability(1, 8)) + // However, since Compare and Trap instructions cost the same as a regular + // Compare instruction, we should allow the if conversion to convert this + // into a Conditional Compare regardless of the branch probability. + if (MBB.getLastNonDebugInstr()->getOpcode() != SystemZ::Trap && + MBB.succ_empty() && Probability < BranchProbability(1, 8)) return false; // For now only convert single instructions. return NumCycles == 1; @@ -598,6 +603,13 @@ bool SystemZInstrInfo::PredicateInstruction( return true; } } + if (Opcode == SystemZ::Trap) { + MI.setDesc(get(SystemZ::CondTrap)); + MachineInstrBuilder(*MI.getParent()->getParent(), MI) + .addImm(CCValid).addImm(CCMask) + .addReg(SystemZ::CC, RegState::Implicit); + return true; + } if (Opcode == SystemZ::Return) { MI.setDesc(get(SystemZ::CondReturn)); MachineInstrBuilder(*MI.getParent()->getParent(), MI) @@ -1370,9 +1382,9 @@ bool SystemZInstrInfo::isRxSBGMask(uint64_t Mask, unsigned BitSize, return false; } -unsigned SystemZInstrInfo::getCompareAndBranch(unsigned Opcode, - SystemZII::CompareAndBranchType Type, - const MachineInstr *MI) const { +unsigned SystemZInstrInfo::getFusedCompare(unsigned Opcode, + SystemZII::FusedCompareType Type, + const MachineInstr *MI) const { switch (Opcode) { case SystemZ::CHI: case SystemZ::CGHI: @@ -1448,6 +1460,27 @@ unsigned SystemZInstrInfo::getCompareAndBranch(unsigned Opcode, default: return 0; } + case SystemZII::CompareAndTrap: + switch (Opcode) { + case SystemZ::CR: + return SystemZ::CRT; + case SystemZ::CGR: + return SystemZ::CGRT; + case SystemZ::CHI: + return SystemZ::CIT; + case SystemZ::CGHI: + return SystemZ::CGIT; + case SystemZ::CLR: + return SystemZ::CLRT; + case SystemZ::CLGR: + return SystemZ::CLGRT; + case SystemZ::CLFI: + return SystemZ::CLFIT; + case SystemZ::CLGFI: + return SystemZ::CLGIT; + default: + return 0; + } } return 0; } |