Chris Lattner | 92101ac | 2001-08-23 17:05:04 +0000 | [diff] [blame] | 1 | //===-- 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 | // |
| 21 | static AnnotationID MethodInfoAID( |
| 22 | AnnotationManager::getID("Interpreter::MethodInfo")); |
| 23 | |
| 24 | struct MethodInfo : public Annotation { |
| 25 | MethodInfo(Method *M); |
Chris Lattner | 697954c | 2002-01-20 22:54:45 +0000 | [diff] [blame] | 26 | std::vector<unsigned> NumPlaneElements; |
Chris Lattner | 92101ac | 2001-08-23 17:05:04 +0000 | [diff] [blame] | 27 | |
Chris Lattner | 2e42d3a | 2001-10-15 05:51:48 +0000 | [diff] [blame] | 28 | |
| 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 Lattner | 92101ac | 2001-08-23 17:05:04 +0000 | [diff] [blame] | 37 | private: |
| 38 | unsigned getValueSlot(const Value *V); |
| 39 | }; |
| 40 | |
Chris Lattner | 9a3d696 | 2002-03-26 18:02:30 +0000 | [diff] [blame] | 41 | |
Chris Lattner | 92101ac | 2001-08-23 17:05:04 +0000 | [diff] [blame] | 42 | //===----------------------------------------------------------------------===// |
| 43 | // Support for the SlotNumber annotation |
| 44 | //===----------------------------------------------------------------------===// |
| 45 | |
Chris Lattner | 9a3d696 | 2002-03-26 18:02:30 +0000 | [diff] [blame] | 46 | // This annotation (attached only to FunctionArgument & Instruction objects) is |
Chris Lattner | 92101ac | 2001-08-23 17:05:04 +0000 | [diff] [blame] | 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 | // |
| 52 | static AnnotationID SlotNumberAID( |
| 53 | AnnotationManager::getID("Interpreter::SlotNumber")); |
| 54 | |
| 55 | struct 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 | // |
| 77 | struct 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 | |
| 88 | static AnnotationID BreakpointAID( |
| 89 | AnnotationManager::getID("Interpreter::Breakpoint")); |
| 90 | // Just use an Annotation directly, Breakpoint is currently just a marker |
| 91 | |
Chris Lattner | 2e42d3a | 2001-10-15 05:51:48 +0000 | [diff] [blame] | 92 | |
| 93 | //===----------------------------------------------------------------------===// |
| 94 | // Support for the GlobalAddress annotation |
| 95 | //===----------------------------------------------------------------------===// |
| 96 | |
| 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 Method's, |
| 99 | // this pointer is the Method object pointer that represents it. For global |
| 100 | // variables, this is the dynamically allocated (and potentially initialized) |
| 101 | // chunk of memory for the global. This annotation is created on demand. |
| 102 | // |
| 103 | static AnnotationID GlobalAddressAID( |
| 104 | AnnotationManager::getID("Interpreter::GlobalAddress")); |
| 105 | |
| 106 | struct GlobalAddress : public Annotation { |
| 107 | void *Ptr; // The pointer itself |
| 108 | bool Delete; // Should I delete them memory on destruction? |
| 109 | |
| 110 | GlobalAddress(void *ptr, bool d) : Annotation(GlobalAddressAID), Ptr(ptr), |
| 111 | Delete(d) {} |
| 112 | ~GlobalAddress() { if (Delete) free(Ptr); } |
| 113 | |
| 114 | // Create - Factory function to allow GlobalAddress annotations to be |
| 115 | // created on demand. |
| 116 | // |
| 117 | static Annotation *Create(AnnotationID AID, const Annotable *O, void *); |
| 118 | }; |
| 119 | |
Chris Lattner | 92101ac | 2001-08-23 17:05:04 +0000 | [diff] [blame] | 120 | #endif |