blob: 12717ec48e0cd0484d746e2def69c936927e0a5b [file] [log] [blame]
Chris Lattner92101ac2001-08-23 17:05:04 +00001//===-- ExecutionAnnotations.h ---------------------------------*- C++ -*--===//
2//
3// This header file defines annotations used by the execution engine.
4//
5//===----------------------------------------------------------------------===//
6
7#ifndef LLI_EXECUTION_ANNOTATIONS_H
8#define LLI_EXECUTION_ANNOTATIONS_H
9
10//===----------------------------------------------------------------------===//
11// Support for MethodInfo annotations
12//===----------------------------------------------------------------------===//
13
14// This annotation (attached only to Method objects) is used to cache useful
15// information about the method, including the number of types present in the
16// method, and the number of values for each type.
17//
18// This annotation object is created on demand, and attaches other annotation
19// objects to the instructions in the method when it's created.
20//
21static AnnotationID MethodInfoAID(
22 AnnotationManager::getID("Interpreter::MethodInfo"));
23
24struct MethodInfo : public Annotation {
25 MethodInfo(Method *M);
Chris Lattner697954c2002-01-20 22:54:45 +000026 std::vector<unsigned> NumPlaneElements;
Chris Lattner92101ac2001-08-23 17:05:04 +000027
Chris Lattner2e42d3a2001-10-15 05:51:48 +000028
29 // Create - Factory function to allow MethodInfo annotations to be
30 // created on demand.
31 //
32 static Annotation *Create(AnnotationID AID, const Annotable *O, void *) {
33 assert(AID == MethodInfoAID);
34 return new MethodInfo(cast<Method>((Value*)O)); // Simply invoke the ctor
35 }
36
Chris Lattner92101ac2001-08-23 17:05:04 +000037private:
38 unsigned getValueSlot(const Value *V);
39};
40
Chris Lattner92101ac2001-08-23 17:05:04 +000041//===----------------------------------------------------------------------===//
42// Support for the SlotNumber annotation
43//===----------------------------------------------------------------------===//
44
45// This annotation (attached only to MethodArgument & Instruction objects) is
46// used to hold the the slot number for the value in its type plane.
47//
48// Entities have this annotation attached to them when the containing
49// method has it's MethodInfo created (by the MethodInfo ctor).
50//
51static AnnotationID SlotNumberAID(
52 AnnotationManager::getID("Interpreter::SlotNumber"));
53
54struct SlotNumber : public Annotation {
55 unsigned SlotNum; // Ranges from 0->
56
57 SlotNumber(unsigned sn) : Annotation(SlotNumberAID),
58 SlotNum(sn) {}
59};
60
61
62
63
64//===----------------------------------------------------------------------===//
65// Support for the InstNumber annotation
66//===----------------------------------------------------------------------===//
67
68// This annotation (attached only to Instruction objects) is used to hold the
69// instruction number of the instruction, and the slot number for the value in
70// its type plane. InstNumber's are used for user interaction, and for
71// calculating which value slot to store the result of the instruction in.
72//
73// Instructions have this annotation attached to them when the containing method
74// has it's MethodInfo created (by the MethodInfo ctor).
75//
76struct InstNumber : public SlotNumber {
77 unsigned InstNum; // Ranges from 1->
78
79 InstNumber(unsigned in, unsigned sn) : SlotNumber(sn), InstNum(in) {}
80};
81
82
83//===----------------------------------------------------------------------===//
84// Support for the Breakpoint annotation
85//===----------------------------------------------------------------------===//
86
87static AnnotationID BreakpointAID(
88 AnnotationManager::getID("Interpreter::Breakpoint"));
89// Just use an Annotation directly, Breakpoint is currently just a marker
90
Chris Lattner2e42d3a2001-10-15 05:51:48 +000091
92//===----------------------------------------------------------------------===//
93// Support for the GlobalAddress annotation
94//===----------------------------------------------------------------------===//
95
96// This annotation (attached only to GlobalValue objects) is used to hold the
97// address of the chunk of memory that represents a global value. For Method's,
98// this pointer is the Method object pointer that represents it. For global
99// variables, this is the dynamically allocated (and potentially initialized)
100// chunk of memory for the global. This annotation is created on demand.
101//
102static AnnotationID GlobalAddressAID(
103 AnnotationManager::getID("Interpreter::GlobalAddress"));
104
105struct GlobalAddress : public Annotation {
106 void *Ptr; // The pointer itself
107 bool Delete; // Should I delete them memory on destruction?
108
109 GlobalAddress(void *ptr, bool d) : Annotation(GlobalAddressAID), Ptr(ptr),
110 Delete(d) {}
111 ~GlobalAddress() { if (Delete) free(Ptr); }
112
113 // Create - Factory function to allow GlobalAddress annotations to be
114 // created on demand.
115 //
116 static Annotation *Create(AnnotationID AID, const Annotable *O, void *);
117};
118
Chris Lattner92101ac2001-08-23 17:05:04 +0000119#endif