2001-08-24 01:05:04 +08:00
|
|
|
//===-- ExecutionAnnotations.h ---------------------------------*- C++ -*--===//
|
|
|
|
//
|
|
|
|
// This header file defines annotations used by the execution engine.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLI_EXECUTION_ANNOTATIONS_H
|
|
|
|
#define LLI_EXECUTION_ANNOTATIONS_H
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Support for MethodInfo annotations
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2002-04-08 04:49:59 +08:00
|
|
|
// This annotation (attached only to Function objects) is used to cache useful
|
|
|
|
// information about the function, including the number of types present in the
|
|
|
|
// function, and the number of values for each type.
|
2001-08-24 01:05:04 +08:00
|
|
|
//
|
|
|
|
// This annotation object is created on demand, and attaches other annotation
|
2002-04-08 04:49:59 +08:00
|
|
|
// objects to the instructions in the function when it's created.
|
2001-08-24 01:05:04 +08:00
|
|
|
//
|
|
|
|
static AnnotationID MethodInfoAID(
|
2002-04-08 04:49:59 +08:00
|
|
|
AnnotationManager::getID("Interpreter::FunctionInfo"));
|
2001-08-24 01:05:04 +08:00
|
|
|
|
|
|
|
struct MethodInfo : public Annotation {
|
2002-04-08 04:49:59 +08:00
|
|
|
MethodInfo(Function *F);
|
2002-01-21 06:54:45 +08:00
|
|
|
std::vector<unsigned> NumPlaneElements;
|
2001-08-24 01:05:04 +08:00
|
|
|
|
2001-10-15 13:51:48 +08:00
|
|
|
|
|
|
|
// Create - Factory function to allow MethodInfo annotations to be
|
|
|
|
// created on demand.
|
|
|
|
//
|
|
|
|
static Annotation *Create(AnnotationID AID, const Annotable *O, void *) {
|
|
|
|
assert(AID == MethodInfoAID);
|
2002-04-08 04:49:59 +08:00
|
|
|
return new MethodInfo(cast<Function>((Value*)O)); // Simply invoke the ctor
|
2001-10-15 13:51:48 +08:00
|
|
|
}
|
|
|
|
|
2001-08-24 01:05:04 +08:00
|
|
|
private:
|
|
|
|
unsigned getValueSlot(const Value *V);
|
|
|
|
};
|
|
|
|
|
2002-03-27 02:02:30 +08:00
|
|
|
|
2001-08-24 01:05:04 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Support for the SlotNumber annotation
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2002-03-27 02:02:30 +08:00
|
|
|
// This annotation (attached only to FunctionArgument & Instruction objects) is
|
2001-08-24 01:05:04 +08:00
|
|
|
// used to hold the the slot number for the value in its type plane.
|
|
|
|
//
|
|
|
|
// Entities have this annotation attached to them when the containing
|
2002-04-08 04:49:59 +08:00
|
|
|
// function has it's MethodInfo created (by the MethodInfo ctor).
|
2001-08-24 01:05:04 +08:00
|
|
|
//
|
|
|
|
static AnnotationID SlotNumberAID(
|
|
|
|
AnnotationManager::getID("Interpreter::SlotNumber"));
|
|
|
|
|
|
|
|
struct SlotNumber : public Annotation {
|
|
|
|
unsigned SlotNum; // Ranges from 0->
|
|
|
|
|
|
|
|
SlotNumber(unsigned sn) : Annotation(SlotNumberAID),
|
|
|
|
SlotNum(sn) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Support for the InstNumber annotation
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// This annotation (attached only to Instruction objects) is used to hold the
|
|
|
|
// instruction number of the instruction, and the slot number for the value in
|
|
|
|
// its type plane. InstNumber's are used for user interaction, and for
|
|
|
|
// calculating which value slot to store the result of the instruction in.
|
|
|
|
//
|
2002-04-08 04:49:59 +08:00
|
|
|
// Instructions have this annotation attached to them when the containing
|
|
|
|
// function has it's MethodInfo created (by the MethodInfo ctor).
|
2001-08-24 01:05:04 +08:00
|
|
|
//
|
|
|
|
struct InstNumber : public SlotNumber {
|
|
|
|
unsigned InstNum; // Ranges from 1->
|
|
|
|
|
|
|
|
InstNumber(unsigned in, unsigned sn) : SlotNumber(sn), InstNum(in) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Support for the Breakpoint annotation
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
static AnnotationID BreakpointAID(
|
|
|
|
AnnotationManager::getID("Interpreter::Breakpoint"));
|
|
|
|
// Just use an Annotation directly, Breakpoint is currently just a marker
|
|
|
|
|
2001-10-15 13:51:48 +08:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Support for the GlobalAddress annotation
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// This annotation (attached only to GlobalValue objects) is used to hold the
|
2002-04-08 04:49:59 +08:00
|
|
|
// address of the chunk of memory that represents a global value. For
|
|
|
|
// Functions, this pointer is the Function object pointer that represents it.
|
|
|
|
// For global variables, this is the dynamically allocated (and potentially
|
|
|
|
// initialized) chunk of memory for the global. This annotation is created on
|
|
|
|
// demand.
|
2001-10-15 13:51:48 +08:00
|
|
|
//
|
|
|
|
static AnnotationID GlobalAddressAID(
|
|
|
|
AnnotationManager::getID("Interpreter::GlobalAddress"));
|
|
|
|
|
|
|
|
struct GlobalAddress : public Annotation {
|
|
|
|
void *Ptr; // The pointer itself
|
|
|
|
bool Delete; // Should I delete them memory on destruction?
|
|
|
|
|
|
|
|
GlobalAddress(void *ptr, bool d) : Annotation(GlobalAddressAID), Ptr(ptr),
|
|
|
|
Delete(d) {}
|
|
|
|
~GlobalAddress() { if (Delete) free(Ptr); }
|
|
|
|
|
|
|
|
// Create - Factory function to allow GlobalAddress annotations to be
|
|
|
|
// created on demand.
|
|
|
|
//
|
|
|
|
static Annotation *Create(AnnotationID AID, const Annotable *O, void *);
|
|
|
|
};
|
|
|
|
|
2001-08-24 01:05:04 +08:00
|
|
|
#endif
|