|
27 | 27 | #include "llvm/CodeGen/MachineRegisterInfo.h"
|
28 | 28 | #include "llvm/CodeGen/SelectionDAG.h"
|
29 | 29 | #include "llvm/CodeGen/SelectionDAGNodes.h"
|
| 30 | +#include "llvm/CodeGen/TargetLowering.h" |
30 | 31 | #include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
|
31 | 32 | #include "llvm/IR/DerivedTypes.h"
|
32 | 33 | #include "llvm/IR/DiagnosticInfo.h"
|
@@ -1752,8 +1753,7 @@ SparcTargetLowering::SparcTargetLowering(const TargetMachine &TM,
|
1752 | 1753 |
|
1753 | 1754 | setOperationAction(ISD::CTPOP, MVT::i64,
|
1754 | 1755 | Subtarget->usePopc() ? Legal : Expand);
|
1755 |
| - setOperationAction(ISD::CTTZ , MVT::i64, Expand); |
1756 |
| - setOperationAction(ISD::CTLZ , MVT::i64, Expand); |
| 1756 | + setOperationAction(ISD::CTTZ, MVT::i64, Expand); |
1757 | 1757 | setOperationAction(ISD::BSWAP, MVT::i64, Expand);
|
1758 | 1758 | setOperationAction(ISD::ROTL , MVT::i64, Expand);
|
1759 | 1759 | setOperationAction(ISD::ROTR , MVT::i64, Expand);
|
@@ -1814,8 +1814,7 @@ SparcTargetLowering::SparcTargetLowering(const TargetMachine &TM,
|
1814 | 1814 | setOperationAction(ISD::FSINCOS, MVT::f32, Expand);
|
1815 | 1815 | setOperationAction(ISD::FREM , MVT::f32, Expand);
|
1816 | 1816 | setOperationAction(ISD::FMA , MVT::f32, Expand);
|
1817 |
| - setOperationAction(ISD::CTTZ , MVT::i32, Expand); |
1818 |
| - setOperationAction(ISD::CTLZ , MVT::i32, Expand); |
| 1817 | + setOperationAction(ISD::CTTZ, MVT::i32, Expand); |
1819 | 1818 | setOperationAction(ISD::ROTL , MVT::i32, Expand);
|
1820 | 1819 | setOperationAction(ISD::ROTR , MVT::i32, Expand);
|
1821 | 1820 | setOperationAction(ISD::BSWAP, MVT::i32, Expand);
|
@@ -1986,6 +1985,24 @@ SparcTargetLowering::SparcTargetLowering(const TargetMachine &TM,
|
1986 | 1985 | if (Subtarget->hasLeonCycleCounter())
|
1987 | 1986 | setOperationAction(ISD::READCYCLECOUNTER, MVT::i64, Custom);
|
1988 | 1987 |
|
| 1988 | + if (Subtarget->isVIS3()) { |
| 1989 | + setOperationAction(ISD::CTLZ, MVT::i32, Legal); |
| 1990 | + setOperationAction(ISD::CTLZ, MVT::i64, Legal); |
| 1991 | + setOperationAction(ISD::CTLZ_ZERO_UNDEF, MVT::i32, Legal); |
| 1992 | + setOperationAction(ISD::CTLZ_ZERO_UNDEF, MVT::i64, Legal); |
| 1993 | + } else if (Subtarget->usePopc()) { |
| 1994 | + setOperationAction(ISD::CTLZ, MVT::i32, Expand); |
| 1995 | + setOperationAction(ISD::CTLZ, MVT::i64, Expand); |
| 1996 | + setOperationAction(ISD::CTLZ_ZERO_UNDEF, MVT::i32, Expand); |
| 1997 | + setOperationAction(ISD::CTLZ_ZERO_UNDEF, MVT::i64, Expand); |
| 1998 | + } else { |
| 1999 | + setOperationAction(ISD::CTLZ, MVT::i32, Expand); |
| 2000 | + setOperationAction(ISD::CTLZ, MVT::i64, Expand); |
| 2001 | + setOperationAction(ISD::CTLZ_ZERO_UNDEF, MVT::i32, |
| 2002 | + Subtarget->is64Bit() ? Promote : LibCall); |
| 2003 | + setOperationAction(ISD::CTLZ_ZERO_UNDEF, MVT::i64, LibCall); |
| 2004 | + } |
| 2005 | + |
1989 | 2006 | setOperationAction(ISD::INTRINSIC_WO_CHAIN, MVT::Other, Custom);
|
1990 | 2007 |
|
1991 | 2008 | setMinFunctionAlignment(Align(4));
|
@@ -3571,6 +3588,8 @@ bool SparcTargetLowering::isFPImmLegal(const APFloat &Imm, EVT VT,
|
3571 | 3588 | Imm.isZero();
|
3572 | 3589 | }
|
3573 | 3590 |
|
| 3591 | +bool SparcTargetLowering::isCtlzFast() const { return Subtarget->isVIS3(); } |
| 3592 | + |
3574 | 3593 | // Override to disable global variable loading on Linux.
|
3575 | 3594 | void SparcTargetLowering::insertSSPDeclarations(Module &M) const {
|
3576 | 3595 | if (!Subtarget->isTargetLinux())
|
|
0 commit comments