From 6c90d54f67f0b2b7a4736e119f091e66afbabcce Mon Sep 17 00:00:00 2001
From: dim <dim@FreeBSD.org>
Date: Thu, 25 Dec 2014 18:22:22 +0000
Subject: Pull in r214284 from upstream llvm trunk (by Hal Finkel):

  [PowerPC] Add JMP_SLOT relocation definitions

  This will be required by upcoming patches for LLDB support.

  Patch by Justin Hibbits!

Pull in r221510 from upstream llvm trunk (by Justin Hibbits):

  Add Position-independent Code model Module API.

  Summary:
  This makes PIC levels a Module flag attribute, which can be queried by the
  backend.  The flag is named `PIC Level`, and can have a value of:

    0 - Backend-default
    1 - Small-model (-fpic)
    2 - Large-model (-fPIC)

  These match the `-pic-level' command line argument for clang, and the value of the
  preprocessor macro `__PIC__'.

  Test Plan:
  New flags tests specific for the 'PIC Level' module flag.
  Tests to be added as part of a future commit for PowerPC, which will use this new API.

  Reviewers: rafael, echristo

  Reviewed By: rafael, echristo

  Subscribers: rafael, llvm-commits

  Differential Revision: http://reviews.llvm.org/D5882

Pull in r221791 from upstream llvm trunk (by Justin Hibbits):

  Add support for small-model PIC for PowerPC.

  Summary:
  Large-model was added first.  With the addition of support for multiple PIC
  models in LLVM, now add small-model PIC for 32-bit PowerPC, SysV4 ABI.  This
  generates more optimal code, for shared libraries with less than about 16380
  data objects.

  Test Plan: Test cases added or updated

  Reviewers: joerg, hfinkel

  Reviewed By: hfinkel

  Subscribers: jholewinski, mcrosier, emaste, llvm-commits

  Differential Revision: http://reviews.llvm.org/D5399

Together, these changes implement small-model PIC support for PowerPC.

Thanks to Justin Hibbits and Roman Divacky for their assistance in
getting this working.
---
 contrib/llvm/include/llvm/IR/Module.h       | 10 ++++++++++
 contrib/llvm/include/llvm/MC/MCExpr.h       |  1 +
 contrib/llvm/include/llvm/Support/CodeGen.h |  4 ++++
 contrib/llvm/include/llvm/Support/ELF.h     |  3 +++
 4 files changed, 18 insertions(+)

(limited to 'contrib/llvm/include')

diff --git a/contrib/llvm/include/llvm/IR/Module.h b/contrib/llvm/include/llvm/IR/Module.h
index 26f62db..0b0f4ea 100644
--- a/contrib/llvm/include/llvm/IR/Module.h
+++ b/contrib/llvm/include/llvm/IR/Module.h
@@ -23,6 +23,7 @@
 #include "llvm/IR/GlobalVariable.h"
 #include "llvm/IR/Metadata.h"
 #include "llvm/Support/CBindingWrapping.h"
+#include "llvm/Support/CodeGen.h"
 #include "llvm/Support/DataTypes.h"
 #include <system_error>
 
@@ -620,6 +621,15 @@ public:
   unsigned getDwarfVersion() const;
 
 /// @}
+/// @name Utility functions for querying and setting PIC level
+/// @{
+
+  /// \brief Returns the PIC level (small or large model)
+  PICLevel::Level getPICLevel() const;
+
+  /// \brief Set the PIC level (small or large model)
+  void setPICLevel(PICLevel::Level PL);
+/// @}
 };
 
 /// An raw_ostream inserter for modules.
diff --git a/contrib/llvm/include/llvm/MC/MCExpr.h b/contrib/llvm/include/llvm/MC/MCExpr.h
index e96ecb4..163574e 100644
--- a/contrib/llvm/include/llvm/MC/MCExpr.h
+++ b/contrib/llvm/include/llvm/MC/MCExpr.h
@@ -238,6 +238,7 @@ public:
     VK_PPC_GOT_TLSLD_HI,   // symbol@got@tlsld@h
     VK_PPC_GOT_TLSLD_HA,   // symbol@got@tlsld@ha
     VK_PPC_TLSLD,          // symbol@tlsld
+    VK_PPC_LOCAL,          // symbol@local
 
     VK_Mips_GPREL,
     VK_Mips_GOT_CALL,
diff --git a/contrib/llvm/include/llvm/Support/CodeGen.h b/contrib/llvm/include/llvm/Support/CodeGen.h
index 240eba6..243f2dd 100644
--- a/contrib/llvm/include/llvm/Support/CodeGen.h
+++ b/contrib/llvm/include/llvm/Support/CodeGen.h
@@ -30,6 +30,10 @@ namespace llvm {
     enum Model { Default, JITDefault, Small, Kernel, Medium, Large };
   }
 
+  namespace PICLevel {
+    enum Level { Default=0, Small=1, Large=2 };
+  }
+
   // TLS models.
   namespace TLSModel {
     enum Model {
diff --git a/contrib/llvm/include/llvm/Support/ELF.h b/contrib/llvm/include/llvm/Support/ELF.h
index 13394d3..ddc7ff8 100644
--- a/contrib/llvm/include/llvm/Support/ELF.h
+++ b/contrib/llvm/include/llvm/Support/ELF.h
@@ -459,6 +459,8 @@ enum {
   R_PPC_GOT16_HI              = 16,
   R_PPC_GOT16_HA              = 17,
   R_PPC_PLTREL24              = 18,
+  R_PPC_JMP_SLOT              = 21,
+  R_PPC_LOCAL24PC             = 23,
   R_PPC_REL32                 = 26,
   R_PPC_TLS                   = 67,
   R_PPC_DTPMOD32              = 68,
@@ -547,6 +549,7 @@ enum {
   R_PPC64_GOT16_LO            = 15,
   R_PPC64_GOT16_HI            = 16,
   R_PPC64_GOT16_HA            = 17,
+  R_PPC64_JMP_SLOT            = 21,
   R_PPC64_REL32               = 26,
   R_PPC64_ADDR64              = 38,
   R_PPC64_ADDR16_HIGHER       = 39,
-- 
cgit v1.1