llvm.org GIT mirror llvm / 87c06d6
add support for the sparcv9-*-* target triple to turn on 64-bit sparc codegen. Patch by Nathan Keynes! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95293 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 10 years ago
10 changed file(s) with 78 addition(s) and 34 deletion(s). Raw diff Collapse all Expand all
6565 ppc, // PPC: powerpc
6666 ppc64, // PPC64: powerpc64, ppu
6767 sparc, // Sparc: sparc
68 sparcv9, // Sparcv9: Sparcv9
6869 systemz, // SystemZ: s390x
6970 tce, // TCE (http://tce.cs.tut.fi/): tce
7071 thumb, // Thumb: thumb, thumbv.*
3232 case ppc64: return "powerpc64";
3333 case ppc: return "powerpc";
3434 case sparc: return "sparc";
35 case sparcv9: return "sparcv9";
3536 case systemz: return "s390x";
3637 case tce: return "tce";
3738 case thumb: return "thumb";
6061 case ppc64:
6162 case ppc: return "ppc";
6263
64 case sparcv9:
6365 case sparc: return "sparc";
6466
6567 case x86:
126128 return ppc;
127129 if (Name == "sparc")
128130 return sparc;
131 if (Name == "sparcv9")
132 return sparcv9;
129133 if (Name == "systemz")
130134 return systemz;
131135 if (Name == "tce")
249253 Arch = mipsel;
250254 else if (ArchName == "sparc")
251255 Arch = sparc;
256 else if (ArchName == "sparcv9")
257 Arch = sparcv9;
252258 else if (ArchName == "s390x")
253259 Arch = systemz;
254260 else if (ArchName == "tce")
198198 // Force static initialization.
199199 extern "C" void LLVMInitializeSparcAsmPrinter() {
200200 RegisterAsmPrinter X(TheSparcTarget);
201 }
201 RegisterAsmPrinter Y(TheSparcV9Target);
202 }
2828 FunctionPass *createSparcFPMoverPass(TargetMachine &TM);
2929
3030 extern Target TheSparcTarget;
31 extern Target TheSparcV9Target;
3132
3233 } // end namespace llvm;
3334
1414 #include "SparcGenSubtarget.inc"
1515 using namespace llvm;
1616
17 // FIXME: temporary.
18 #include "llvm/Support/CommandLine.h"
19 namespace {
20 cl::opt EnableV9("enable-sparc-v9-insts", cl::Hidden,
21 cl::desc("Enable V9 instructions in the V8 target"));
22 }
23
24 SparcSubtarget::SparcSubtarget(const std::string &TT, const std::string &FS) {
25 // Set the default features.
26 IsV9 = false;
27 V8DeprecatedInsts = false;
28 IsVIS = false;
17 SparcSubtarget::SparcSubtarget(const std::string &TT, const std::string &FS,
18 bool is64Bit) :
19 IsV9(false),
20 V8DeprecatedInsts(false),
21 IsVIS(false),
22 Is64Bit(is64Bit) {
2923
3024 // Determine default and user specified characteristics
31 std::string CPU = "generic";
25 const char *CPU = "v8";
26 if (is64Bit) {
27 CPU = "v9";
28 IsV9 = true;
29 }
3230
33 // FIXME: autodetect host here!
34 CPU = "v9"; // What is a good way to detect V9?
35
3631 // Parse features string.
3732 ParseSubtargetFeatures(FS, CPU);
38
39 // Unless explicitly enabled, disable the V9 instructions.
40 if (!EnableV9)
41 IsV9 = false;
4233 }
2222 bool IsV9;
2323 bool V8DeprecatedInsts;
2424 bool IsVIS;
25 bool Is64Bit;
26
2527 public:
26 SparcSubtarget(const std::string &TT, const std::string &FS);
28 SparcSubtarget(const std::string &TT, const std::string &FS, bool is64bit);
2729
2830 bool isV9() const { return IsV9; }
2931 bool isVIS() const { return IsVIS; }
3335 /// subtarget options. Definition of function is auto generated by tblgen.
3436 std::string ParseSubtargetFeatures(const std::string &FS,
3537 const std::string &CPU);
36
38
39 bool is64Bit() const { return Is64Bit; }
40 std::string getDataLayout() const {
41 const char *p;
42 if (is64Bit()) {
43 p = "E-p:64:64:64-i64:64:64-f64:64:64-f128:128:128-n32:64";
44 } else {
45 p = "E-p:32:32:32-i64:64:64-f64:64:64-f128:64:64-n32";
46 }
47 return std::string(p);
48 }
3749 };
3850
3951 } // end namespace llvm
1818
1919 extern "C" void LLVMInitializeSparcTarget() {
2020 // Register the target.
21 RegisterTargetMachine X(TheSparcTarget);
22 RegisterAsmInfo Y(TheSparcTarget);
21 RegisterTargetMachine X(TheSparcTarget);
22 RegisterTargetMachine Y(TheSparcV9Target);
23
24 RegisterAsmInfo A(TheSparcTarget);
25 RegisterAsmInfo B(TheSparcV9Target);
2326
2427 }
2528
2629 /// SparcTargetMachine ctor - Create an ILP32 architecture model
2730 ///
2831 SparcTargetMachine::SparcTargetMachine(const Target &T, const std::string &TT,
29 const std::string &FS)
32 const std::string &FS, bool is64bit)
3033 : LLVMTargetMachine(T, TT),
31 DataLayout("E-p:32:32-f128:128:128-n32"),
32 Subtarget(TT, FS), TLInfo(*this), InstrInfo(Subtarget),
34 Subtarget(TT, FS, is64bit),
35 DataLayout(Subtarget.getDataLayout()),
36 TLInfo(*this), InstrInfo(Subtarget),
3337 FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0) {
3438 }
3539
4852 PM.add(createSparcDelaySlotFillerPass(*this));
4953 return true;
5054 }
55
56 SparcV8TargetMachine::SparcV8TargetMachine(const Target &T,
57 const std::string &TT,
58 const std::string &FS)
59 : SparcTargetMachine(T, TT, FS, false) {
60 }
61
62 SparcV9TargetMachine::SparcV9TargetMachine(const Target &T,
63 const std::string &TT,
64 const std::string &FS)
65 : SparcTargetMachine(T, TT, FS, true) {
66 }
2323 namespace llvm {
2424
2525 class SparcTargetMachine : public LLVMTargetMachine {
26 SparcSubtarget Subtarget;
2627 const TargetData DataLayout; // Calculates type size & alignment
27 SparcSubtarget Subtarget;
2828 SparcTargetLowering TLInfo;
2929 SparcInstrInfo InstrInfo;
3030 TargetFrameInfo FrameInfo;
3131 public:
3232 SparcTargetMachine(const Target &T, const std::string &TT,
33 const std::string &FS);
33 const std::string &FS, bool is64bit);
3434
3535 virtual const SparcInstrInfo *getInstrInfo() const { return &InstrInfo; }
3636 virtual const TargetFrameInfo *getFrameInfo() const { return &FrameInfo; }
4848 virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
4949 };
5050
51 /// SparcV8TargetMachine - Sparc 32-bit target machine
52 ///
53 class SparcV8TargetMachine : public SparcTargetMachine {
54 public:
55 SparcV8TargetMachine(const Target &T, const std::string &TT,
56 const std::string &FS);
57 };
58
59 /// SparcV9TargetMachine - Sparc 64-bit target machine
60 ///
61 class SparcV9TargetMachine : public SparcTargetMachine {
62 public:
63 SparcV9TargetMachine(const Target &T, const std::string &TT,
64 const std::string &FS);
65 };
66
5167 } // end namespace llvm
5268
5369 #endif
1212 using namespace llvm;
1313
1414 Target llvm::TheSparcTarget;
15 Target llvm::TheSparcV9Target;
1516
1617 extern "C" void LLVMInitializeSparcTargetInfo() {
1718 RegisterTarget X(TheSparcTarget, "sparc", "Sparc");
19 RegisterTarget Y(TheSparcV9Target, "sparcv9", "Sparc V9");
1820 }
None ; RUN: llc < %s -march=sparc -mattr=v9 -enable-sparc-v9-insts
1 ; RUN: llc < %s -march=sparc -mattr=-v9 | \
2 ; RUN: not grep popc
3 ; RUN: llc < %s -march=sparc -mattr=v9 -enable-sparc-v9-insts | grep popc
0 ; RUN: llc < %s -march=sparc -mattr=-v9 | not grep popc
1 ; RUN: llc < %s -march=sparcv9 -mattr=v9 | grep popc
42
53 declare i32 @llvm.ctpop.i32(i32)
64