blob: ff7c0d5dc0ac338c1de6d5c630253b61a4419d5b [file] [log] [blame]
NAKAMURA Takumifb3bd712015-05-25 01:43:23 +00001//===-- CoreCLRGC.cpp - CoreCLR Runtime GC Strategy -----------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file contains a GCStrategy for the CoreCLR Runtime.
11// The strategy is similar to Statepoint-example GC, but differs from it in
12// certain aspects, such as:
13// 1) Base-pointers need not be explicitly tracked and reported for
14// interior pointers
15// 2) Uses a different format for encoding stack-maps
16// 3) Location of Safe-point polls: polls are only needed before loop-back edges
17// and before tail-calls (not needed at function-entry)
18//
19// The above differences in behavior are to be implemented in upcoming checkins.
20//
21//===----------------------------------------------------------------------===//
22
23#include "llvm/CodeGen/GCStrategy.h"
24#include "llvm/IR/DerivedTypes.h"
25#include "llvm/IR/Value.h"
26
27using namespace llvm;
28
29namespace {
30class CoreCLRGC : public GCStrategy {
31public:
32 CoreCLRGC() {
33 UseStatepoints = true;
34 // These options are all gc.root specific, we specify them so that the
35 // gc.root lowering code doesn't run.
36 InitRoots = false;
37 NeededSafePoints = 0;
38 UsesMetadata = false;
39 CustomRoots = false;
40 }
Philip Reamesee8f0552015-12-23 01:42:15 +000041 Optional<bool> isGCManagedPointer(const Type *Ty) const override {
NAKAMURA Takumifb3bd712015-05-25 01:43:23 +000042 // Method is only valid on pointer typed values.
Philip Reamesee8f0552015-12-23 01:42:15 +000043 const PointerType *PT = cast<PointerType>(Ty);
NAKAMURA Takumifb3bd712015-05-25 01:43:23 +000044 // We pick addrspace(1) as our GC managed heap.
45 return (1 == PT->getAddressSpace());
46 }
47};
Alexander Kornienkof00654e2015-06-23 09:49:53 +000048}
NAKAMURA Takumifb3bd712015-05-25 01:43:23 +000049
NAKAMURA Takumi5582a6a2015-05-25 01:43:34 +000050static GCRegistry::Add<CoreCLRGC> X("coreclr", "CoreCLR-compatible GC");
NAKAMURA Takumifb3bd712015-05-25 01:43:23 +000051
52namespace llvm {
53void linkCoreCLRGC() {}
54}