Honor the command line specification for machine type.
authorJim Laskey <jlaskey@mac.com>
Tue, 12 Dec 2006 16:07:33 +0000 (16:07 +0000)
committerJim Laskey <jlaskey@mac.com>
Tue, 12 Dec 2006 16:07:33 +0000 (16:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32483 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Target/SubtargetFeature.h
include/llvm/Target/TargetSubtarget.h
lib/Target/PowerPC/PPCAsmPrinter.cpp
utils/TableGen/SubtargetEmitter.cpp

index 89e6efef37664228de13e6de0a68d51f471a2259..70315df484b7cbfd1846915a588e630b0b6d5925 100644 (file)
@@ -81,6 +81,9 @@ public:
   /// 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);
   
index 3b174c2ee4630c911cc3604d99db649b0088f161..875008deaf6c7cd09f7d0e2f523b88e8b9ef249b 100644 (file)
@@ -14,6 +14,8 @@
 #ifndef LLVM_TARGET_TARGETSUBTARGET_H
 #define LLVM_TARGET_TARGETSUBTARGET_H
 
+#include <string>
+
 namespace llvm {
 
 //===----------------------------------------------------------------------===//
@@ -25,10 +27,13 @@ namespace llvm {
 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
index 032782b8ceba5594bb3e1cbc80f4ae9fa80eed46..c84c6fb15986bb9a39742120e6a46608ce4f2db6 100644 (file)
@@ -542,8 +542,19 @@ bool DarwinAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
 
 
 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.
index a70dbc972878020476b70d9ce442655f96054012..caff55c4e308dc37912576a266b40052e60d065c 100644 (file)
@@ -460,6 +460,7 @@ void SubtargetEmitter::ParseFeaturesFunction(std::ostream &OS) {
         "                                  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";