blob: 913e8615957533f0f34245187f4740b0c7104461 [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
Chris Lattner2fbfdcf2002-04-07 20:49:59 +000014// This annotation (attached only to Function objects) is used to cache useful
15// information about the function, including the number of types present in the
16// function, and the number of values for each type.
Chris Lattner92101ac2001-08-23 17:05:04 +000017//
18// This annotation object is created on demand, and attaches other annotation
Chris Lattner2fbfdcf2002-04-07 20:49:59 +000019// objects to the instructions in the function when it's created.
Chris Lattner92101ac2001-08-23 17:05:04 +000020//
21static AnnotationID MethodInfoAID(
Chris Lattner2fbfdcf2002-04-07 20:49:59 +000022 AnnotationManager::getID("Interpreter::FunctionInfo"));
Chris Lattner92101ac2001-08-23 17:05:04 +000023
24struct MethodInfo : public Annotation {
Chris Lattner2fbfdcf2002-04-07 20:49:59 +000025 MethodInfo(Function *F);
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);
Chris Lattner2fbfdcf2002-04-07 20:49:59 +000034 return new MethodInfo(cast<Function>((Value*)O)); // Simply invoke the ctor
Chris Lattner2e42d3a2001-10-15 05:51:48 +000035 }
36
Chris Lattner92101ac2001-08-23 17:05:04 +000037private:
38 unsigned getValueSlot(const Value *V);
39};
40
Chris Lattner9a3d6962002-03-26 18:02:30 +000041
Chris Lattner92101ac2001-08-23 17:05:04 +000042//===----------------------------------------------------------------------===//
43// Support for the SlotNumber annotation
44//===----------------------------------------------------------------------===//
45
Chris Lattnerb972f952002-04-09 19:40:40 +000046// This annotation (attached only to Argument & Instruction objects) is used to
47// hold the the slot number for the value in its type plane.
Chris Lattner92101ac2001-08-23 17:05:04 +000048//
49// Entities have this annotation attached to them when the containing
Chris Lattner2fbfdcf2002-04-07 20:49:59 +000050// function has it's MethodInfo created (by the MethodInfo ctor).
Chris Lattner92101ac2001-08-23 17:05:04 +000051//
52static AnnotationID SlotNumberAID(
53 AnnotationManager::getID("Interpreter::SlotNumber"));
54
55struct SlotNumber : public Annotation {
56 unsigned SlotNum; // Ranges from 0->
57
58 SlotNumber(unsigned sn) : Annotation(SlotNumberAID),
59 SlotNum(sn) {}
60};
61
62
63
64
65//===----------------------------------------------------------------------===//
66// Support for the InstNumber annotation
67//===----------------------------------------------------------------------===//
68
69// This annotation (attached only to Instruction objects) is used to hold the
70// instruction number of the instruction, and the slot number for the value in
71// its type plane. InstNumber's are used for user interaction, and for
72// calculating which value slot to store the result of the instruction in.
73//
Chris Lattner2fbfdcf2002-04-07 20:49:59 +000074// Instructions have this annotation attached to them when the containing
75// function has it's MethodInfo created (by the MethodInfo ctor).
Chris Lattner92101ac2001-08-23 17:05:04 +000076//
77struct InstNumber : public SlotNumber {
78 unsigned InstNum; // Ranges from 1->
79
80 InstNumber(unsigned in, unsigned sn) : SlotNumber(sn), InstNum(in) {}
81};
82
83
84//===----------------------------------------------------------------------===//
85// Support for the Breakpoint annotation
86//===----------------------------------------------------------------------===//
87
88static AnnotationID BreakpointAID(
89 AnnotationManager::getID("Interpreter::Breakpoint"));
90// Just use an Annotation directly, Breakpoint is currently just a marker
91
Chris Lattner2e42d3a2001-10-15 05:51:48 +000092
93//===----------------------------------------------------------------------===//
94// Support for the GlobalAddress annotation
95//===----------------------------------------------------------------------===//
96
97// This annotation (attached only to GlobalValue objects) is used to hold the
Chris Lattner2fbfdcf2002-04-07 20:49:59 +000098// address of the chunk of memory that represents a global value. For
99// Functions, this pointer is the Function object pointer that represents it.
100// For global variables, this is the dynamically allocated (and potentially
101// initialized) chunk of memory for the global. This annotation is created on
102// demand.
Chris Lattner2e42d3a2001-10-15 05:51:48 +0000103//
104static AnnotationID GlobalAddressAID(
105 AnnotationManager::getID("Interpreter::GlobalAddress"));
106
107struct GlobalAddress : public Annotation {
108 void *Ptr; // The pointer itself
109 bool Delete; // Should I delete them memory on destruction?
110
111 GlobalAddress(void *ptr, bool d) : Annotation(GlobalAddressAID), Ptr(ptr),
112 Delete(d) {}
113 ~GlobalAddress() { if (Delete) free(Ptr); }
114
115 // Create - Factory function to allow GlobalAddress annotations to be
116 // created on demand.
117 //
118 static Annotation *Create(AnnotationID AID, const Annotable *O, void *);
119};
120
Chris Lattner92101ac2001-08-23 17:05:04 +0000121#endif