Add relocation types for Hexagon processor; patch by Sidney Manning <sidneym@codeauro...
[oota-llvm.git] / include / llvm / Support / MDBuilder.h
index f6d84526ab2644dd5f88768a52ba1863c4c65564..855e58d699de35ec5db0251108603201ff553d2d 100644 (file)
@@ -26,9 +26,6 @@ namespace llvm {
   class MDBuilder {
     LLVMContext &Context;
 
-    MDString *getFastString() {
-      return createString("fast");
-    }
   public:
     MDBuilder(LLVMContext &context) : Context(context) {}
 
@@ -41,24 +38,40 @@ namespace llvm {
     // FPMath metadata.
     //===------------------------------------------------------------------===//
 
-    /// \brief Return metadata with appropriate settings for 'fast math'.
-    MDNode *createFastFPMath() {
-      return MDNode::get(Context, getFastString());
-    }
-
-    /// \brief Return metadata with the given settings.  Special values for the
-    /// Accuracy parameter are 0.0, which means the default (maximal precision)
-    /// setting; and negative values which all mean 'fast'.
+    /// \brief Return metadata with the given settings.  The special value 0.0
+    /// for the Accuracy parameter indicates the default (maximal precision)
+    /// setting.
     MDNode *createFPMath(float Accuracy) {
       if (Accuracy == 0.0)
         return 0;
-      if (Accuracy < 0.0)
-        return MDNode::get(Context, getFastString());
       assert(Accuracy > 0.0 && "Invalid fpmath accuracy!");
       Value *Op = ConstantFP::get(Type::getFloatTy(Context), Accuracy);
       return MDNode::get(Context, Op);
     }
 
+    //===------------------------------------------------------------------===//
+    // Prof metadata.
+    //===------------------------------------------------------------------===//
+
+    /// \brief Return metadata containing two branch weights.
+    MDNode *createBranchWeights(uint32_t TrueWeight, uint32_t FalseWeight) {
+      uint32_t Weights[] = { TrueWeight, FalseWeight };
+      return createBranchWeights(Weights);
+    }
+
+    /// \brief Return metadata containing a number of branch weights.
+    MDNode *createBranchWeights(ArrayRef<uint32_t> Weights) {
+      assert(Weights.size() >= 2 && "Need at least two branch weights!");
+
+      SmallVector<Value *, 4> Vals(Weights.size()+1);
+      Vals[0] = createString("branch_weights");
+
+      Type *Int32Ty = Type::getInt32Ty(Context);
+      for (unsigned i = 0, e = Weights.size(); i != e; ++i)
+        Vals[i+1] = ConstantInt::get(Int32Ty, Weights[i]);
+
+      return MDNode::get(Context, Vals);
+    }
 
     //===------------------------------------------------------------------===//
     // Range metadata.