llvm.org GIT mirror llvm / 742f5b5
Only generate the popc instruction for SPARC CPUs that implement it. The popc instruction is defined in the SPARCv9 instruction set architecture, but it was emulated on CPUs older than Niagara 2. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200131 91177308-0d34-0410-b5e6-96231b3b80d8 Jakob Stoklund Olesen 6 years ago
5 changed file(s) with 19 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
3333 : SubtargetFeature<"hard-quad-float", "HasHardQuad", "true",
3434 "Enable quad-word floating point instructions">;
3535
36 def UsePopc : SubtargetFeature<"popc", "UsePopc", "true",
37 "Use the popc (population count) instruction">;
38
3639 //===----------------------------------------------------------------------===//
3740 // Register File, Calling Conv, Instruction Descriptions
3841 //===----------------------------------------------------------------------===//
6871 def : Proc<"ultrasparc", [FeatureV9, FeatureV8Deprecated]>;
6972 def : Proc<"ultrasparc3", [FeatureV9, FeatureV8Deprecated]>;
7073 def : Proc<"niagara", [FeatureV9, FeatureV8Deprecated]>;
71 def : Proc<"niagara2", [FeatureV9, FeatureV8Deprecated]>;
72 def : Proc<"niagara3", [FeatureV9, FeatureV8Deprecated]>;
73 def : Proc<"niagara4", [FeatureV9, FeatureV8Deprecated]>;
74 def : Proc<"niagara2", [FeatureV9, FeatureV8Deprecated, UsePopc]>;
75 def : Proc<"niagara3", [FeatureV9, FeatureV8Deprecated, UsePopc]>;
76 def : Proc<"niagara4", [FeatureV9, FeatureV8Deprecated, UsePopc]>;
7477
7578
7679 //===----------------------------------------------------------------------===//
14621462 setOperationAction(ISD::BR_CC, MVT::i64, Custom);
14631463 setOperationAction(ISD::SELECT_CC, MVT::i64, Custom);
14641464
1465 setOperationAction(ISD::CTPOP, MVT::i64, Legal);
1465 if (Subtarget->usePopc())
1466 setOperationAction(ISD::CTPOP, MVT::i64, Legal);
14661467 setOperationAction(ISD::CTTZ , MVT::i64, Expand);
14671468 setOperationAction(ISD::CTTZ_ZERO_UNDEF, MVT::i64, Expand);
14681469 setOperationAction(ISD::CTLZ , MVT::i64, Expand);
15681569
15691570 setStackPointerRegisterToSaveRestore(SP::O6);
15701571
1571 if (Subtarget->isV9())
1572 if (Subtarget->isV9() && Subtarget->usePopc())
15721573 setOperationAction(ISD::CTPOP, MVT::i32, Legal);
15731574
15741575 if (Subtarget->isV9() && Subtarget->hasHardQuad()) {
3030 V8DeprecatedInsts(false),
3131 IsVIS(false),
3232 Is64Bit(is64Bit),
33 HasHardQuad(false) {
33 HasHardQuad(false),
34 UsePopc(false) {
3435
3536 // Determine default and user specified characteristics
3637 std::string CPUName = CPU;
2929 bool IsVIS;
3030 bool Is64Bit;
3131 bool HasHardQuad;
32 bool UsePopc;
3233
3334 public:
3435 SparcSubtarget(const std::string &TT, const std::string &CPU,
3839 bool isVIS() const { return IsVIS; }
3940 bool useDeprecatedV8Instructions() const { return V8DeprecatedInsts; }
4041 bool hasHardQuad() const { return HasHardQuad; }
42 bool usePopc() const { return UsePopc; }
4143
4244 /// ParseSubtargetFeatures - Parses features string setting specified
4345 /// subtarget options. Definition of function is auto generated by tblgen.
0 ; RUN: llc < %s -march=sparc -mattr=-v9 | FileCheck %s -check-prefix=V8
1 ; RUN: llc < %s -march=sparc -mattr=+v9 | FileCheck %s -check-prefix=V9
2 ; RUN: llc < %s -march=sparc -mcpu=v9 | FileCheck %s -check-prefix=V9
3 ; RUN: llc < %s -march=sparc -mcpu=ultrasparc | FileCheck %s -check-prefix=V9
4 ; RUN: llc < %s -march=sparc -mcpu=ultrasparc3 | FileCheck %s -check-prefix=V9
5 ; RUN: llc < %s -march=sparc -mcpu=niagara | FileCheck %s -check-prefix=V9
1 ; RUN: llc < %s -march=sparc -mattr=+v9,+popc | FileCheck %s -check-prefix=V9
2 ; RUN: llc < %s -march=sparc -mcpu=v9 | FileCheck %s -check-prefix=V8
3 ; RUN: llc < %s -march=sparc -mcpu=ultrasparc | FileCheck %s -check-prefix=V8
4 ; RUN: llc < %s -march=sparc -mcpu=ultrasparc3 | FileCheck %s -check-prefix=V8
5 ; RUN: llc < %s -march=sparc -mcpu=niagara | FileCheck %s -check-prefix=V8
66 ; RUN: llc < %s -march=sparc -mcpu=niagara2 | FileCheck %s -check-prefix=V9
77 ; RUN: llc < %s -march=sparc -mcpu=niagara3 | FileCheck %s -check-prefix=V9
88 ; RUN: llc < %s -march=sparc -mcpu=niagara4 | FileCheck %s -check-prefix=V9
9 ; RUN: llc < %s -march=sparcv9 | FileCheck %s -check-prefix=SPARC64
9 ; RUN: llc < %s -march=sparcv9 -mattr=+popc | FileCheck %s -check-prefix=SPARC64
1010
1111 declare i32 @llvm.ctpop.i32(i32)
1212