From 22e5a23311dc90bc47558e24f41da8969a6902d8 Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Wed, 7 Jan 2015 19:13:28 +0000 Subject: [PATCH] Add a missing file from 225365 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225366 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/StatepointExampleGC.cpp | 54 +++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 lib/CodeGen/StatepointExampleGC.cpp diff --git a/lib/CodeGen/StatepointExampleGC.cpp b/lib/CodeGen/StatepointExampleGC.cpp new file mode 100644 index 00000000000..5460c1e7da1 --- /dev/null +++ b/lib/CodeGen/StatepointExampleGC.cpp @@ -0,0 +1,54 @@ +//===-- StatepointDefaultGC.cpp - The default statepoint GC strategy ------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file contains a GCStrategy which serves as an example for the usage +// of a statepoint based lowering strategy. This GCStrategy is intended to +// suitable as a default implementation usable with any collector which can +// consume the standard stackmap format generated by statepoints, uses the +// default addrespace to distinguish between gc managed and non-gc managed +// pointers, and has reasonable relocation semantics. +// +//===----------------------------------------------------------------------===// + +#include "llvm/CodeGen/GCStrategy.h" +#include "llvm/IR/Value.h" +#include "llvm/IR/DerivedTypes.h" + +using namespace llvm; + +namespace { +class StatepointGC : public GCStrategy { +public: + StatepointGC() { + UseStatepoints = true; + // These options are all gc.root specific, we specify them so that the + // gc.root lowering code doesn't run. + InitRoots = false; + NeededSafePoints = 0; + UsesMetadata = false; + CustomRoots = false; + CustomSafePoints = false; + } + Optional isGCManagedPointer(const Value *V) const override { + // Method is only valid on pointer typed values. + PointerType *PT = cast(V->getType()); + // For the sake of this example GC, we arbitrarily pick addrspace(1) as our + // GC managed heap. We know that a pointer into this heap needs to be + // updated and that no other pointer does. + return (1 == PT->getAddressSpace()); + } +}; +} + +static GCRegistry::Add +X("statepoint-example", "an example strategy for statepoint"); + +namespace llvm { +void linkStatepointExampleGC() {} +}