Honor the command line specification for machine type.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32483 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/llvm/Target/SubtargetFeature.h b/include/llvm/Target/SubtargetFeature.h
index 89e6efe..70315df 100644
--- a/include/llvm/Target/SubtargetFeature.h
+++ b/include/llvm/Target/SubtargetFeature.h
@@ -81,6 +81,9 @@
/// Set the CPU string. Replaces previous setting. Setting to "" clears CPU.
void setCPU(const std::string &String);
+ /// Get the CPU string.
+ const std::string &getCPU() const { return Features[0]; }
+
/// Setting CPU string only if no string is set.
void setCPUIfNone(const std::string &String);
diff --git a/include/llvm/Target/TargetSubtarget.h b/include/llvm/Target/TargetSubtarget.h
index 3b174c2..875008d 100644
--- a/include/llvm/Target/TargetSubtarget.h
+++ b/include/llvm/Target/TargetSubtarget.h
@@ -14,6 +14,8 @@
#ifndef LLVM_TARGET_TARGETSUBTARGET_H
#define LLVM_TARGET_TARGETSUBTARGET_H
+#include <string>
+
namespace llvm {
//===----------------------------------------------------------------------===//
@@ -25,10 +27,13 @@
class TargetSubtarget {
TargetSubtarget(const TargetSubtarget&); // DO NOT IMPLEMENT
void operator=(const TargetSubtarget&); // DO NOT IMPLEMENT
+ std::string CPU; // CPU name.
protected: // Can only create subclasses...
TargetSubtarget();
public:
virtual ~TargetSubtarget();
+ void setCPU(const std::string &C) { CPU = C; }
+ const std::string &getCPU() const { return CPU; }
};
} // End llvm namespace
diff --git a/lib/Target/PowerPC/PPCAsmPrinter.cpp b/lib/Target/PowerPC/PPCAsmPrinter.cpp
index 032782b..c84c6fb 100644
--- a/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ b/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -542,8 +542,19 @@
bool DarwinAsmPrinter::doInitialization(Module &M) {
- if (Subtarget.isGigaProcessor())
+ const std::string &CPU = Subtarget.getCPU();
+
+ if (CPU != "generic")
+ O << "\t.machine ppc" << CPU << "\n";
+ else if (Subtarget.isGigaProcessor())
O << "\t.machine ppc970\n";
+ else if (Subtarget.isPPC64())
+ O << "\t.machine ppc64\n";
+ else if (Subtarget.hasAltivec())
+ O << "\t.machine ppc7400\n";
+ else
+ O << "\t.machine ppc\n";
+
AsmPrinter::doInitialization(M);
// Darwin wants symbols to be quoted if they have complex names.
diff --git a/utils/TableGen/SubtargetEmitter.cpp b/utils/TableGen/SubtargetEmitter.cpp
index a70dbc9..caff55c 100644
--- a/utils/TableGen/SubtargetEmitter.cpp
+++ b/utils/TableGen/SubtargetEmitter.cpp
@@ -460,6 +460,7 @@
" const std::string &CPU) {\n"
" SubtargetFeatures Features(FS);\n"
" Features.setCPUIfNone(CPU);\n"
+ " setCPU(Features.getCPU());\n"
" uint32_t Bits = Features.getBits(SubTypeKV, SubTypeKVSize,\n"
" FeatureKV, FeatureKVSize);\n";