blob: e17aa4b3552bf5b24dfa8e50479422d305376b55 [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//===----------------------------------------------------------------------===//
Chris Lattnerda82ed52003-05-08 16:18:31 +000011// Support for FunctionInfo annotations
Chris Lattner92101ac2001-08-23 17:05:04 +000012//===----------------------------------------------------------------------===//
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//
Chris Lattnerda82ed52003-05-08 16:18:31 +000021static AnnotationID FunctionInfoAID(
Chris Lattner2fbfdcf2002-04-07 20:49:59 +000022 AnnotationManager::getID("Interpreter::FunctionInfo"));
Chris Lattner92101ac2001-08-23 17:05:04 +000023
Chris Lattnerda82ed52003-05-08 16:18:31 +000024struct FunctionInfo : public Annotation {
25 FunctionInfo(Function *F);
Chris Lattner697954c2002-01-20 22:54:45 +000026 std::vector<unsigned> NumPlaneElements;
Chris Lattner92101ac2001-08-23 17:05:04 +000027
Chris Lattnerda82ed52003-05-08 16:18:31 +000028 // Create - Factory function to allow FunctionInfo annotations to be
Chris Lattner2e42d3a2001-10-15 05:51:48 +000029 // created on demand.
30 //
31 static Annotation *Create(AnnotationID AID, const Annotable *O, void *) {
Chris Lattnerda82ed52003-05-08 16:18:31 +000032 assert(AID == FunctionInfoAID);
33 return new FunctionInfo(cast<Function>((Value*)O));
Chris Lattner2e42d3a2001-10-15 05:51:48 +000034 }
35
Chris Lattner92101ac2001-08-23 17:05:04 +000036private:
37 unsigned getValueSlot(const Value *V);
38};
39
Chris Lattner92101ac2001-08-23 17:05:04 +000040//===----------------------------------------------------------------------===//
41// Support for the SlotNumber annotation
42//===----------------------------------------------------------------------===//
43
Chris Lattnerb972f952002-04-09 19:40:40 +000044// This annotation (attached only to Argument & Instruction objects) is used to
45// hold the the slot number for the value in its type plane.
Chris Lattner92101ac2001-08-23 17:05:04 +000046//
47// Entities have this annotation attached to them when the containing
Chris Lattnerda82ed52003-05-08 16:18:31 +000048// function has it's FunctionInfo created (by the FunctionInfo ctor).
Chris Lattner92101ac2001-08-23 17:05:04 +000049//
50static AnnotationID SlotNumberAID(
51 AnnotationManager::getID("Interpreter::SlotNumber"));
52
53struct SlotNumber : public Annotation {
54 unsigned SlotNum; // Ranges from 0->
55
56 SlotNumber(unsigned sn) : Annotation(SlotNumberAID),
57 SlotNum(sn) {}
58};
59
Chris Lattner92101ac2001-08-23 17:05:04 +000060//===----------------------------------------------------------------------===//
61// Support for the InstNumber annotation
62//===----------------------------------------------------------------------===//
63
64// This annotation (attached only to Instruction objects) is used to hold the
65// instruction number of the instruction, and the slot number for the value in
66// its type plane. InstNumber's are used for user interaction, and for
67// calculating which value slot to store the result of the instruction in.
68//
Chris Lattner2fbfdcf2002-04-07 20:49:59 +000069// Instructions have this annotation attached to them when the containing
Chris Lattnerda82ed52003-05-08 16:18:31 +000070// function has it's FunctionInfo created (by the FunctionInfo ctor).
Chris Lattner92101ac2001-08-23 17:05:04 +000071//
72struct InstNumber : public SlotNumber {
73 unsigned InstNum; // Ranges from 1->
74
75 InstNumber(unsigned in, unsigned sn) : SlotNumber(sn), InstNum(in) {}
76};
77
Chris Lattner92101ac2001-08-23 17:05:04 +000078#endif