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 | //===----------------------------------------------------------------------===// |
Chris Lattner | da82ed5 | 2003-05-08 16:18:31 +0000 | [diff] [blame] | 11 | // Support for FunctionInfo annotations |
Chris Lattner | 92101ac | 2001-08-23 17:05:04 +0000 | [diff] [blame] | 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Chris Lattner | 2fbfdcf | 2002-04-07 20:49:59 +0000 | [diff] [blame] | 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. |
Chris Lattner | 92101ac | 2001-08-23 17:05:04 +0000 | [diff] [blame] | 17 | // |
| 18 | // This annotation object is created on demand, and attaches other annotation |
Chris Lattner | 2fbfdcf | 2002-04-07 20:49:59 +0000 | [diff] [blame] | 19 | // objects to the instructions in the function when it's created. |
Chris Lattner | 92101ac | 2001-08-23 17:05:04 +0000 | [diff] [blame] | 20 | // |
Chris Lattner | da82ed5 | 2003-05-08 16:18:31 +0000 | [diff] [blame] | 21 | static AnnotationID FunctionInfoAID( |
Chris Lattner | 2fbfdcf | 2002-04-07 20:49:59 +0000 | [diff] [blame] | 22 | AnnotationManager::getID("Interpreter::FunctionInfo")); |
Chris Lattner | 92101ac | 2001-08-23 17:05:04 +0000 | [diff] [blame] | 23 | |
Chris Lattner | da82ed5 | 2003-05-08 16:18:31 +0000 | [diff] [blame] | 24 | struct FunctionInfo : public Annotation { |
| 25 | FunctionInfo(Function *F); |
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 | da82ed5 | 2003-05-08 16:18:31 +0000 | [diff] [blame] | 28 | // Create - Factory function to allow FunctionInfo annotations to be |
Chris Lattner | 2e42d3a | 2001-10-15 05:51:48 +0000 | [diff] [blame] | 29 | // created on demand. |
| 30 | // |
| 31 | static Annotation *Create(AnnotationID AID, const Annotable *O, void *) { |
Chris Lattner | da82ed5 | 2003-05-08 16:18:31 +0000 | [diff] [blame] | 32 | assert(AID == FunctionInfoAID); |
| 33 | return new FunctionInfo(cast<Function>((Value*)O)); |
Chris Lattner | 2e42d3a | 2001-10-15 05:51:48 +0000 | [diff] [blame] | 34 | } |
| 35 | |
Chris Lattner | 92101ac | 2001-08-23 17:05:04 +0000 | [diff] [blame] | 36 | private: |
| 37 | unsigned getValueSlot(const Value *V); |
| 38 | }; |
| 39 | |
Chris Lattner | 9a3d696 | 2002-03-26 18:02:30 +0000 | [diff] [blame] | 40 | |
Chris Lattner | 92101ac | 2001-08-23 17:05:04 +0000 | [diff] [blame] | 41 | //===----------------------------------------------------------------------===// |
| 42 | // Support for the SlotNumber annotation |
| 43 | //===----------------------------------------------------------------------===// |
| 44 | |
Chris Lattner | b972f95 | 2002-04-09 19:40:40 +0000 | [diff] [blame] | 45 | // This annotation (attached only to Argument & Instruction objects) is used to |
| 46 | // hold the the slot number for the value in its type plane. |
Chris Lattner | 92101ac | 2001-08-23 17:05:04 +0000 | [diff] [blame] | 47 | // |
| 48 | // Entities have this annotation attached to them when the containing |
Chris Lattner | da82ed5 | 2003-05-08 16:18:31 +0000 | [diff] [blame] | 49 | // function has it's FunctionInfo created (by the FunctionInfo ctor). |
Chris Lattner | 92101ac | 2001-08-23 17:05:04 +0000 | [diff] [blame] | 50 | // |
| 51 | static AnnotationID SlotNumberAID( |
| 52 | AnnotationManager::getID("Interpreter::SlotNumber")); |
| 53 | |
| 54 | struct 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 | // |
Chris Lattner | 2fbfdcf | 2002-04-07 20:49:59 +0000 | [diff] [blame] | 73 | // Instructions have this annotation attached to them when the containing |
Chris Lattner | da82ed5 | 2003-05-08 16:18:31 +0000 | [diff] [blame] | 74 | // function has it's FunctionInfo created (by the FunctionInfo ctor). |
Chris Lattner | 92101ac | 2001-08-23 17:05:04 +0000 | [diff] [blame] | 75 | // |
| 76 | struct 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 | |
| 87 | static AnnotationID BreakpointAID( |
| 88 | AnnotationManager::getID("Interpreter::Breakpoint")); |
| 89 | // Just use an Annotation directly, Breakpoint is currently just a marker |
| 90 | |
Chris Lattner | 2e42d3a | 2001-10-15 05:51:48 +0000 | [diff] [blame] | 91 | |
Chris Lattner | 92101ac | 2001-08-23 17:05:04 +0000 | [diff] [blame] | 92 | #endif |