]> granicus.if.org Git - clang/commitdiff
Add getTargetPrefix to TargetInfo, to be used with target specific intrinsics.
authorAnders Carlsson <andersca@mac.com>
Sat, 8 Dec 2007 19:32:57 +0000 (19:32 +0000)
committerAnders Carlsson <andersca@mac.com>
Sat, 8 Dec 2007 19:32:57 +0000 (19:32 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44712 91177308-0d34-0410-b5e6-96231b3b80d8

Basic/TargetInfo.cpp
Driver/Targets.cpp
include/clang/Basic/TargetInfo.h

index 6038e614a5386343a504292b210145d452ca5ed5..fcaeccffc0ef3fe26396191864271cca0aed3fd4 100644 (file)
@@ -56,6 +56,10 @@ const char* TargetInfo::getTargetTriple() const {
   return PrimaryTarget->getTargetTriple();
 }
 
+const char *TargetInfo::getTargetPrefix() const {
+ return PrimaryTarget->getTargetPrefix();
+}
+
 /// DiagnoseNonPortability - When a use of a non-portable target feature is
 /// used, this method emits the diagnostic and marks the translation unit as
 /// non-portable.
@@ -417,6 +421,9 @@ bool TargetInfo::validateInputConstraint(const char *Name,
         // Eventually, an unknown constraint should just be treated as 'g'.
         assert(0 && "Unknown input constraint type!");
       }        
+    case '%': // commutative
+      // FIXME: Fail if % is used with the last operand.
+      break;
     case 'i': // immediate integer.
       break;
     case 'r': // general register.
index 63df5d48c88d59cc128bcf9f4152735f7d778605..400090871c84e4f5d224afea432b074469ee8cfb 100644 (file)
@@ -402,6 +402,10 @@ namespace PPC {
     return 0;
   }
 
+  const char *getTargetPrefix() {
+    return "ppc";
+  }
+  
 } // End namespace PPC
 
 
@@ -480,6 +484,10 @@ namespace X86 {
     return "~{dirflag},~{fpsr},~{flags}";
   }
   
+  const char *getTargetPrefix() {
+    return "x86";
+  }
+  
 } // End namespace X86
 
 //===----------------------------------------------------------------------===//
@@ -503,6 +511,9 @@ public:
   virtual const char *getVAListDeclaration() const {
     return getPPCVAListDeclaration();
   }
+  virtual const char *getTargetPrefix() const {
+    return PPC::getTargetPrefix();
+  }
   virtual void getGCCRegNames(const char * const *&Names, 
                               unsigned &NumNames) const {
     PPC::getGCCRegNames(Names, NumNames);
@@ -537,6 +548,9 @@ public:
   virtual const char *getVAListDeclaration() const {
     return getPPCVAListDeclaration();
   }  
+  virtual const char *getTargetPrefix() const {
+    return PPC::getTargetPrefix();
+  }  
   virtual void getGCCRegNames(const char * const *&Names, 
                                    unsigned &NumNames) const {
     PPC::getGCCRegNames(Names, NumNames);
@@ -571,6 +585,9 @@ public:
   virtual const char *getVAListDeclaration() const {
     return getI386VAListDeclaration();
   }  
+  virtual const char *getTargetPrefix() const {
+    return X86::getTargetPrefix();
+  }  
   virtual void getGCCRegNames(const char * const *&Names, 
                                    unsigned &NumNames) const {
     X86::getGCCRegNames(Names, NumNames);
@@ -605,6 +622,9 @@ public:
   virtual const char *getVAListDeclaration() const {
     return getX86_64VAListDeclaration();
   }
+  virtual const char *getTargetPrefix() const {
+    return X86::getTargetPrefix();
+  }
   virtual void getGCCRegNames(const char * const *&Names, 
                                    unsigned &NumNames) const {
     X86::getGCCRegNames(Names, NumNames);
@@ -643,6 +663,9 @@ public:
   virtual const char *getVAListDeclaration() const {
     return getI386VAListDeclaration();
   }
+  virtual const char *getTargetPrefix() const {
+    return X86::getTargetPrefix();
+  }  
   virtual void getGCCRegNames(const char * const *&Names, 
                                    unsigned &NumNames) const {
     X86::getGCCRegNames(Names, NumNames);
index 07292f78ce14177a310b93c201f0d0bb05896840..d02af435fc614550171fbcea4049e9c93a1346b0 100644 (file)
@@ -245,6 +245,10 @@ public:
     return static_cast<unsigned>(Size);
   }
 
+  /// getTargetPrefix - Return the target prefix used for identifying
+  /// llvm intrinsics.
+  const char *getTargetPrefix() const;
+    
   /// getTargetTriple - Return the target triple of the primary target.
   const char *getTargetTriple() const;
   
@@ -280,6 +284,8 @@ public:
   ///  TargetInfoImpl object was created from.
   const char* getTargetTriple() const { return Triple.c_str(); }
   
+  virtual const char *getTargetPrefix() const = 0;
+
   /// getTargetDefines - Return a list of the target-specific #define values set
   /// when compiling to this target.  Each string should be of the form
   /// "#define X Y\n".