summaryrefslogtreecommitdiffstats
path: root/llvm/include
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/include')
-rw-r--r--llvm/include/llvm/CodeGen/GCMetadata.h26
-rw-r--r--llvm/include/llvm/CodeGen/GCMetadataPrinter.h2
-rw-r--r--llvm/include/llvm/IR/Function.h5
-rw-r--r--llvm/include/llvm/IR/GCStrategy.h (renamed from llvm/include/llvm/CodeGen/GCStrategy.h)32
-rw-r--r--llvm/include/llvm/Support/Registry.h4
5 files changed, 38 insertions, 31 deletions
diff --git a/llvm/include/llvm/CodeGen/GCMetadata.h b/llvm/include/llvm/CodeGen/GCMetadata.h
index c7f1ab87fcb..6922b70bd9a 100644
--- a/llvm/include/llvm/CodeGen/GCMetadata.h
+++ b/llvm/include/llvm/CodeGen/GCMetadata.h
@@ -36,26 +36,15 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/IR/DebugLoc.h"
+#include "llvm/IR/GCStrategy.h"
#include "llvm/Pass.h"
#include <memory>
namespace llvm {
class AsmPrinter;
- class GCStrategy;
class Constant;
class MCSymbol;
- namespace GC {
- /// PointKind - The type of a collector-safe point.
- ///
- enum PointKind {
- Loop, ///< Instr is a loop (backwards branch).
- Return, ///< Instr is a return instruction.
- PreCall, ///< Instr is a call instruction.
- PostCall ///< Instr is the return address of a call.
- };
- }
-
/// GCPoint - Metadata for a collector-safe point in machine code.
///
struct GCPoint {
@@ -163,14 +152,9 @@ namespace llvm {
/// Records both the function level information used by GCRoots and a
/// cache of the 'active' gc strategy objects for the current Module.
class GCModuleInfo : public ImmutablePass {
- typedef StringMap<GCStrategy*> strategy_map_type;
- typedef std::vector<std::unique_ptr<GCStrategy>> list_type;
-
- strategy_map_type StrategyMap;
- list_type StrategyList;
-
- GCStrategy *getOrCreateStrategy(const Module *M, const std::string &Name);
-
+ /// A list of GCStrategies which are active in this Module. These are
+ /// not owning pointers.
+ std::vector<GCStrategy*> StrategyList;
public:
/// List of per function info objects. In theory, Each of these
/// may be associated with a different GC.
@@ -190,7 +174,7 @@ namespace llvm {
finfo_map_type FInfoMap;
public:
- typedef list_type::const_iterator iterator;
+ typedef std::vector<GCStrategy*>::const_iterator iterator;
static char ID;
diff --git a/llvm/include/llvm/CodeGen/GCMetadataPrinter.h b/llvm/include/llvm/CodeGen/GCMetadataPrinter.h
index 25fafba93f8..6010cb8a4f3 100644
--- a/llvm/include/llvm/CodeGen/GCMetadataPrinter.h
+++ b/llvm/include/llvm/CodeGen/GCMetadataPrinter.h
@@ -21,7 +21,7 @@
#define LLVM_CODEGEN_GCMETADATAPRINTER_H
#include "llvm/CodeGen/GCMetadata.h"
-#include "llvm/CodeGen/GCStrategy.h"
+#include "llvm/IR/GCStrategy.h"
#include "llvm/Support/Registry.h"
namespace llvm {
diff --git a/llvm/include/llvm/IR/Function.h b/llvm/include/llvm/IR/Function.h
index 51403281e96..e9d0806eadd 100644
--- a/llvm/include/llvm/IR/Function.h
+++ b/llvm/include/llvm/IR/Function.h
@@ -29,6 +29,7 @@
namespace llvm {
class FunctionType;
+class GCStrategy;
class LLVMContext;
// Traits for intrusive list of basic blocks...
@@ -225,6 +226,10 @@ public:
void setGC(const char *Str);
void clearGC();
+ /// Returns the GCStrategy associated with the specified garbage collector
+ /// algorithm or nullptr if one is not set.
+ GCStrategy *getGCStrategy() const;
+
/// @brief adds the attribute to the list of attributes.
void addAttribute(unsigned i, Attribute::AttrKind attr);
diff --git a/llvm/include/llvm/CodeGen/GCStrategy.h b/llvm/include/llvm/IR/GCStrategy.h
index bdd14463e00..1cd107b3bca 100644
--- a/llvm/include/llvm/CodeGen/GCStrategy.h
+++ b/llvm/include/llvm/IR/GCStrategy.h
@@ -1,4 +1,4 @@
-//===-- llvm/CodeGen/GCStrategy.h - Garbage collection ----------*- C++ -*-===//
+//===-- llvm/IR/GCStrategy.h - Garbage collection ----------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -47,25 +47,39 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CODEGEN_GCSTRATEGY_H
-#define LLVM_CODEGEN_GCSTRATEGY_H
+#ifndef LLVM_IR_GCSTRATEGY_H
+#define LLVM_IR_GCSTRATEGY_H
#include "llvm/ADT/Optional.h"
-#include "llvm/CodeGen/GCMetadata.h"
-#include "llvm/CodeGen/MachineFunction.h"
+#include "llvm/IR/Value.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/Module.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Registry.h"
#include <string>
namespace llvm {
+ namespace GC {
+ /// PointKind - The type of a collector-safe point.
+ ///
+ enum PointKind {
+ Loop, ///< Instr is a loop (backwards branch).
+ Return, ///< Instr is a return instruction.
+ PreCall, ///< Instr is a call instruction.
+ PostCall ///< Instr is the return address of a call.
+ };
+ }
+
+
/// GCStrategy describes a garbage collector algorithm's code generation
/// requirements, and provides overridable hooks for those needs which cannot
- /// be abstractly described. GCStrategy objects currently must be looked up
- /// through the GCModuleInfo analysis pass. They are owned by the analysis
- /// pass and recreated every time that pass is invalidated.
+ /// be abstractly described. GCStrategy objects must be looked up through
+ /// the Function. The objects themselves are owned by the Context and must
+ /// be immutable.
class GCStrategy {
private:
std::string Name;
- friend class GCModuleInfo;
+ friend class LLVMContextImpl;
protected:
bool UseStatepoints; /// Uses gc.statepoints as opposed to gc.roots,
diff --git a/llvm/include/llvm/Support/Registry.h b/llvm/include/llvm/Support/Registry.h
index e21269b2f1d..51db8cfb15b 100644
--- a/llvm/include/llvm/Support/Registry.h
+++ b/llvm/include/llvm/Support/Registry.h
@@ -120,6 +120,10 @@ namespace llvm {
static iterator begin() { return iterator(Head); }
static iterator end() { return iterator(nullptr); }
+ static iterator_range<iterator> entries() {
+ return iterator_range<iterator>(begin(), end());
+ }
+
/// Abstract base class for registry listeners, which are informed when new
/// entries are added to the registry. Simply subclass and instantiate:
OpenPOWER on IntegriCloud