blob: bdcffd800c5bc55812653c17508302d9f57d0f37 [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);
26 vector<unsigned> NumPlaneElements;
27
28private:
29 unsigned getValueSlot(const Value *V);
30};
31
32// CreateMethodInfo - Factory function to allow MethodInfo annotations to be
33// created on demand.
34//
Chris Lattner454bd1f2001-09-07 16:59:15 +000035inline static Annotation *CreateMethodInfo(AnnotationID AID, const Annotable *O,
Chris Lattner86660982001-08-27 05:16:50 +000036 void *) {
Chris Lattner92101ac2001-08-23 17:05:04 +000037 assert(AID == MethodInfoAID);
38 return new MethodInfo((Method*)O); // Simply invoke the ctor
39}
40
41
42//===----------------------------------------------------------------------===//
43// Support for the SlotNumber annotation
44//===----------------------------------------------------------------------===//
45
46// This annotation (attached only to MethodArgument & Instruction objects) is
47// used to hold the the slot number for the value in its type plane.
48//
49// Entities have this annotation attached to them when the containing
50// method has it's MethodInfo created (by the MethodInfo ctor).
51//
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//
74// Instructions have this annotation attached to them when the containing method
75// has it's MethodInfo created (by the MethodInfo ctor).
76//
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
92#endif