1 //===-- ExecutionAnnotations.h ---------------------------------*- C++ -*--===//
3 // This header file defines annotations used by the execution engine.
5 //===----------------------------------------------------------------------===//
7 #ifndef LLI_EXECUTION_ANNOTATIONS_H
8 #define LLI_EXECUTION_ANNOTATIONS_H
10 //===----------------------------------------------------------------------===//
11 // Support for MethodInfo annotations
12 //===----------------------------------------------------------------------===//
14 // 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.
18 // This annotation object is created on demand, and attaches other annotation
19 // objects to the instructions in the function when it's created.
21 static AnnotationID MethodInfoAID(
22 AnnotationManager::getID("Interpreter::FunctionInfo"));
24 struct MethodInfo : public Annotation {
25 MethodInfo(Function *F);
26 std::vector<unsigned> NumPlaneElements;
29 // Create - Factory function to allow MethodInfo annotations to be
32 static Annotation *Create(AnnotationID AID, const Annotable *O, void *) {
33 assert(AID == MethodInfoAID);
34 return new MethodInfo(cast<Function>((Value*)O)); // Simply invoke the ctor
38 unsigned getValueSlot(const Value *V);
42 //===----------------------------------------------------------------------===//
43 // Support for the SlotNumber annotation
44 //===----------------------------------------------------------------------===//
46 // This annotation (attached only to Argument & Instruction objects) is used to
47 // hold the the slot number for the value in its type plane.
49 // Entities have this annotation attached to them when the containing
50 // function has it's MethodInfo created (by the MethodInfo ctor).
52 static AnnotationID SlotNumberAID(
53 AnnotationManager::getID("Interpreter::SlotNumber"));
55 struct SlotNumber : public Annotation {
56 unsigned SlotNum; // Ranges from 0->
58 SlotNumber(unsigned sn) : Annotation(SlotNumberAID),
65 //===----------------------------------------------------------------------===//
66 // Support for the InstNumber annotation
67 //===----------------------------------------------------------------------===//
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.
74 // Instructions have this annotation attached to them when the containing
75 // function has it's MethodInfo created (by the MethodInfo ctor).
77 struct InstNumber : public SlotNumber {
78 unsigned InstNum; // Ranges from 1->
80 InstNumber(unsigned in, unsigned sn) : SlotNumber(sn), InstNum(in) {}
84 //===----------------------------------------------------------------------===//
85 // Support for the Breakpoint annotation
86 //===----------------------------------------------------------------------===//
88 static AnnotationID BreakpointAID(
89 AnnotationManager::getID("Interpreter::Breakpoint"));
90 // Just use an Annotation directly, Breakpoint is currently just a marker
93 //===----------------------------------------------------------------------===//
94 // Support for the GlobalAddress annotation
95 //===----------------------------------------------------------------------===//
97 // This annotation (attached only to GlobalValue objects) is used to hold the
98 // 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
104 static AnnotationID GlobalAddressAID(
105 AnnotationManager::getID("Interpreter::GlobalAddress"));
107 struct GlobalAddress : public Annotation {
108 void *Ptr; // The pointer itself
109 bool Delete; // Should I delete them memory on destruction?
111 GlobalAddress(void *ptr, bool d) : Annotation(GlobalAddressAID), Ptr(ptr),
113 ~GlobalAddress() { if (Delete) free(Ptr); }
115 // Create - Factory function to allow GlobalAddress annotations to be
116 // created on demand.
118 static Annotation *Create(AnnotationID AID, const Annotable *O, void *);