aboutsummaryrefslogtreecommitdiff
path: root/lib/ExecutionEngine/Interpreter
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ExecutionEngine/Interpreter')
-rw-r--r--lib/ExecutionEngine/Interpreter/Execution.cpp57
-rw-r--r--lib/ExecutionEngine/Interpreter/ExecutionAnnotations.h29
-rw-r--r--lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp20
-rw-r--r--lib/ExecutionEngine/Interpreter/Interpreter.h22
-rw-r--r--lib/ExecutionEngine/Interpreter/Support.cpp4
-rw-r--r--lib/ExecutionEngine/Interpreter/UserInput.cpp8
6 files changed, 72 insertions, 68 deletions
diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp
index 2260625b66..484dbe2ee6 100644
--- a/lib/ExecutionEngine/Interpreter/Execution.cpp
+++ b/lib/ExecutionEngine/Interpreter/Execution.cpp
@@ -233,15 +233,15 @@ Annotation *GlobalAddress::Create(AnnotationID AID, const Annotable *O, void *){
// This annotation will only be created on GlobalValue objects...
GlobalValue *GVal = cast<GlobalValue>((Value*)O);
- if (isa<Method>(GVal)) {
- // The GlobalAddress object for a method is just a pointer to method itself.
- // Don't delete it when the annotation is gone though!
+ if (isa<Function>(GVal)) {
+ // The GlobalAddress object for a function is just a pointer to function
+ // itself. Don't delete it when the annotation is gone though!
return new GlobalAddress(GVal, false);
}
// Handle the case of a global variable...
assert(isa<GlobalVariable>(GVal) &&
- "Global value found that isn't a method or global variable!");
+ "Global value found that isn't a function or global variable!");
GlobalVariable *GV = cast<GlobalVariable>(GVal);
// First off, we must allocate space for the global variable to point at...
@@ -667,7 +667,7 @@ void Interpreter::executeRetInst(ReturnInst *I, ExecutionContext &SF) {
}
// Save previously executing meth
- const Method *M = ECStack.back().CurMethod;
+ const Function *M = ECStack.back().CurMethod;
// Pop the current stack frame... this invalidates SF
ECStack.pop_back();
@@ -675,7 +675,7 @@ void Interpreter::executeRetInst(ReturnInst *I, ExecutionContext &SF) {
if (ECStack.empty()) { // Finished main. Put result into exit code...
if (RetTy) { // Nonvoid return type?
if (!QuietMode) {
- CW << "Method " << M->getType() << " \"" << M->getName()
+ CW << "Function " << M->getType() << " \"" << M->getName()
<< "\" returned ";
print(RetTy, Result);
cout << "\n";
@@ -703,7 +703,7 @@ void Interpreter::executeRetInst(ReturnInst *I, ExecutionContext &SF) {
} else if (!QuietMode) {
// This must be a function that is executing because of a user 'call'
// instruction.
- CW << "Method " << M->getType() << " \"" << M->getName()
+ CW << "Function " << M->getType() << " \"" << M->getName()
<< "\" returned ";
print(RetTy, Result);
cout << "\n";
@@ -894,10 +894,10 @@ void Interpreter::executeCallInst(CallInst *I, ExecutionContext &SF) {
ArgVals.push_back(getOperandValue(I->getOperand(i), SF));
// To handle indirect calls, we must get the pointer value from the argument
- // and treat it as a method pointer.
+ // and treat it as a function pointer.
GenericValue SRC = getOperandValue(I->getCalledValue(), SF);
- callMethod((Method*)SRC.PointerVal, ArgVals);
+ callMethod((Function*)SRC.PointerVal, ArgVals);
}
static void executePHINode(PHINode *I, ExecutionContext &SF) {
@@ -1024,16 +1024,16 @@ static void executeCastInst(CastInst *I, ExecutionContext &SF) {
// Dispatch and Execution Code
//===----------------------------------------------------------------------===//
-MethodInfo::MethodInfo(Method *M) : Annotation(MethodInfoAID) {
- // Assign slot numbers to the method arguments...
- const Method::ArgumentListType &ArgList = M->getArgumentList();
- for (Method::ArgumentListType::const_iterator AI = ArgList.begin(),
+MethodInfo::MethodInfo(Function *M) : Annotation(MethodInfoAID) {
+ // Assign slot numbers to the function arguments...
+ const Function::ArgumentListType &ArgList = M->getArgumentList();
+ for (Function::ArgumentListType::const_iterator AI = ArgList.begin(),
AE = ArgList.end(); AI != AE; ++AI)
(*AI)->addAnnotation(new SlotNumber(getValueSlot(*AI)));
// Iterate over all of the instructions...
unsigned InstNum = 0;
- for (Method::iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI) {
+ for (Function::iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI) {
BasicBlock *BB = *MI;
for (BasicBlock::iterator II = BB->begin(), IE = BB->end(); II != IE; ++II){
Instruction *I = *II; // For each instruction... Add Annote
@@ -1051,9 +1051,9 @@ unsigned MethodInfo::getValueSlot(const Value *V) {
//===----------------------------------------------------------------------===//
-// callMethod - Execute the specified method...
+// callMethod - Execute the specified function...
//
-void Interpreter::callMethod(Method *M, const vector<GenericValue> &ArgVals) {
+void Interpreter::callMethod(Function *M, const vector<GenericValue> &ArgVals) {
assert((ECStack.empty() || ECStack.back().Caller == 0 ||
ECStack.back().Caller->getNumOperands()-1 == ArgVals.size()) &&
"Incorrect number of arguments passed into function call!");
@@ -1071,7 +1071,7 @@ void Interpreter::callMethod(Method *M, const vector<GenericValue> &ArgVals) {
SF.Caller = 0; // We returned from the call...
} else if (!QuietMode) {
// print it.
- CW << "Method " << M->getType() << " \"" << M->getName()
+ CW << "Function " << M->getType() << " \"" << M->getName()
<< "\" returned ";
print(RetTy, Result);
cout << "\n";
@@ -1084,8 +1084,9 @@ void Interpreter::callMethod(Method *M, const vector<GenericValue> &ArgVals) {
return;
}
- // Process the method, assigning instruction numbers to the instructions in
- // the method. Also calculate the number of values for each type slot active.
+ // Process the function, assigning instruction numbers to the instructions in
+ // the function. Also calculate the number of values for each type slot
+ // active.
//
MethodInfo *MethInfo = (MethodInfo*)M->getOrCreateAnnotation(MethodInfoAID);
ECStack.push_back(ExecutionContext()); // Make a new stack frame...
@@ -1109,11 +1110,11 @@ void Interpreter::callMethod(Method *M, const vector<GenericValue> &ArgVals) {
StackFrame.PrevBB = 0; // No previous BB for PHI nodes...
- // Run through the method arguments and initialize their values...
+ // Run through the function arguments and initialize their values...
assert(ArgVals.size() == M->getArgumentList().size() &&
- "Invalid number of values passed to method invocation!");
+ "Invalid number of values passed to function invocation!");
unsigned i = 0;
- for (Method::ArgumentListType::iterator MI = M->getArgumentList().begin(),
+ for (Function::ArgumentListType::iterator MI = M->getArgumentList().begin(),
ME = M->getArgumentList().end(); MI != ME; ++MI, ++i) {
SetValue(*MI, ArgVals[i], StackFrame);
}
@@ -1319,8 +1320,8 @@ void Interpreter::print(const std::string &Name) {
Value *PickedVal = ChooseOneOption(Name, LookupMatchingNames(Name));
if (!PickedVal) return;
- if (const Method *M = dyn_cast<const Method>(PickedVal)) {
- CW << M; // Print the method
+ if (const Function *F = dyn_cast<const Function>(PickedVal)) {
+ CW << F; // Print the function
} else if (const Type *Ty = dyn_cast<const Type>(PickedVal)) {
CW << "type %" << Name << " = " << Ty->getDescription() << "\n";
} else if (const BasicBlock *BB = dyn_cast<const BasicBlock>(PickedVal)) {
@@ -1348,13 +1349,13 @@ void Interpreter::infoValue(const std::string &Name) {
//
void Interpreter::printStackFrame(int FrameNo = -1) {
if (FrameNo == -1) FrameNo = CurFrame;
- Method *Meth = ECStack[FrameNo].CurMethod;
- const Type *RetTy = Meth->getReturnType();
+ Function *Func = ECStack[FrameNo].CurMethod;
+ const Type *RetTy = Func->getReturnType();
CW << ((FrameNo == CurFrame) ? '>' : '-') << "#" << FrameNo << ". "
- << (Value*)RetTy << " \"" << Meth->getName() << "\"(";
+ << (Value*)RetTy << " \"" << Func->getName() << "\"(";
- Method::ArgumentListType &Args = Meth->getArgumentList();
+ Function::ArgumentListType &Args = Func->getArgumentList();
for (unsigned i = 0; i < Args.size(); ++i) {
if (i != 0) cout << ", ";
CW << (Value*)Args[i] << "=";
diff --git a/lib/ExecutionEngine/Interpreter/ExecutionAnnotations.h b/lib/ExecutionEngine/Interpreter/ExecutionAnnotations.h
index 537d18c35a..03abd20bb4 100644
--- a/lib/ExecutionEngine/Interpreter/ExecutionAnnotations.h
+++ b/lib/ExecutionEngine/Interpreter/ExecutionAnnotations.h
@@ -11,18 +11,18 @@
// Support for MethodInfo annotations
//===----------------------------------------------------------------------===//
-// This annotation (attached only to Method objects) is used to cache useful
-// information about the method, including the number of types present in the
-// method, and the number of values for each type.
+// 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.
//
// This annotation object is created on demand, and attaches other annotation
-// objects to the instructions in the method when it's created.
+// objects to the instructions in the function when it's created.
//
static AnnotationID MethodInfoAID(
- AnnotationManager::getID("Interpreter::MethodInfo"));
+ AnnotationManager::getID("Interpreter::FunctionInfo"));
struct MethodInfo : public Annotation {
- MethodInfo(Method *M);
+ MethodInfo(Function *F);
std::vector<unsigned> NumPlaneElements;
@@ -31,7 +31,7 @@ struct MethodInfo : public Annotation {
//
static Annotation *Create(AnnotationID AID, const Annotable *O, void *) {
assert(AID == MethodInfoAID);
- return new MethodInfo(cast<Method>((Value*)O)); // Simply invoke the ctor
+ return new MethodInfo(cast<Function>((Value*)O)); // Simply invoke the ctor
}
private:
@@ -47,7 +47,7 @@ private:
// used to hold the the slot number for the value in its type plane.
//
// Entities have this annotation attached to them when the containing
-// method has it's MethodInfo created (by the MethodInfo ctor).
+// function has it's MethodInfo created (by the MethodInfo ctor).
//
static AnnotationID SlotNumberAID(
AnnotationManager::getID("Interpreter::SlotNumber"));
@@ -71,8 +71,8 @@ struct SlotNumber : public Annotation {
// its type plane. InstNumber's are used for user interaction, and for
// calculating which value slot to store the result of the instruction in.
//
-// Instructions have this annotation attached to them when the containing method
-// has it's MethodInfo created (by the MethodInfo ctor).
+// Instructions have this annotation attached to them when the containing
+// function has it's MethodInfo created (by the MethodInfo ctor).
//
struct InstNumber : public SlotNumber {
unsigned InstNum; // Ranges from 1->
@@ -95,10 +95,11 @@ static AnnotationID BreakpointAID(
//===----------------------------------------------------------------------===//
// This annotation (attached only to GlobalValue objects) is used to hold the
-// address of the chunk of memory that represents a global value. For Method's,
-// this pointer is the Method 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.
+// 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.
//
static AnnotationID GlobalAddressAID(
AnnotationManager::getID("Interpreter::GlobalAddress"));
diff --git a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
index c8aa46a186..8f486e84ce 100644
--- a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
+++ b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
@@ -1,11 +1,12 @@
-//===-- ExternalMethods.cpp - Implement External Functions ----------------===//
+//===-- ExternalFunctions.cpp - Implement External Functions --------------===//
//
-// This file contains both code to deal with invoking "external" methods, but
-// also contains code that implements "exported" external methods.
+// This file contains both code to deal with invoking "external" functions, but
+// also contains code that implements "exported" external functions.
//
-// External methods in LLI are implemented by dlopen'ing the lli executable and
-// using dlsym to look op the methods that we want to invoke. If a method is
-// found, then the arguments are mangled and passed in to the function call.
+// External functions in LLI are implemented by dlopen'ing the lli executable
+// and using dlsym to look op the functions that we want to invoke. If a
+// function is found, then the arguments are mangled and passed in to the
+// function call.
//
//===----------------------------------------------------------------------===//
@@ -91,18 +92,19 @@ GenericValue Interpreter::callExternalMethod(Function *M,
const vector<GenericValue> &ArgVals) {
TheInterpreter = this;
- // Do a lookup to see if the method is in our cache... this should just be a
+ // Do a lookup to see if the function is in our cache... this should just be a
// defered annotation!
std::map<const Function *, ExFunc>::iterator FI = Functions.find(M);
ExFunc Fn = (FI == Functions.end()) ? lookupFunction(M) : FI->second;
if (Fn == 0) {
- cout << "Tried to execute an unknown external method: "
+ cout << "Tried to execute an unknown external function: "
<< M->getType()->getDescription() << " " << M->getName() << "\n";
return GenericValue();
}
// TODO: FIXME when types are not const!
- GenericValue Result = Fn(const_cast<FunctionType*>(M->getFunctionType()),ArgVals);
+ GenericValue Result = Fn(const_cast<FunctionType*>(M->getFunctionType()),
+ ArgVals);
return Result;
}
diff --git a/lib/ExecutionEngine/Interpreter/Interpreter.h b/lib/ExecutionEngine/Interpreter/Interpreter.h
index 8576f9ce22..e7c7942b0c 100644
--- a/lib/ExecutionEngine/Interpreter/Interpreter.h
+++ b/lib/ExecutionEngine/Interpreter/Interpreter.h
@@ -12,7 +12,7 @@
#include "llvm/Module.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
#include "llvm/BasicBlock.h"
#include "Support/DataTypes.h"
#include "llvm/Assembly/CachedWriter.h"
@@ -78,10 +78,10 @@ typedef std::vector<GenericValue> ValuePlaneTy;
// executing.
//
struct ExecutionContext {
- Method *CurMethod; // The currently executing method
+ Function *CurMethod; // The currently executing function
BasicBlock *CurBB; // The currently executing BB
BasicBlock::iterator CurInst; // The next instruction to execute
- MethodInfo *MethInfo; // The MethInfo annotation for the method
+ MethodInfo *MethInfo; // The MethInfo annotation for the function
std::vector<ValuePlaneTy> Values;// ValuePlanes for each type
BasicBlock *PrevBB; // The previous BB or null if in first BB
@@ -100,7 +100,7 @@ class Interpreter {
int CurFrame; // The current stack frame being inspected
// The runtime stack of executing code. The top of the stack is the current
- // method record.
+ // function record.
std::vector<ExecutionContext> ECStack;
public:
@@ -135,7 +135,7 @@ public:
void printStackTrace(); // Do the 'backtrace' command
// Code execution methods...
- void callMethod(Method *Meth, const std::vector<GenericValue> &ArgVals);
+ void callMethod(Function *F, const std::vector<GenericValue> &ArgVals);
bool executeInstruction(); // Execute one instruction...
void stepInstruction(); // Do the 'step' command
@@ -148,12 +148,12 @@ public:
void executeRetInst(ReturnInst *I, ExecutionContext &SF);
void executeBrInst(BranchInst *I, ExecutionContext &SF);
void executeAllocInst(AllocationInst *I, ExecutionContext &SF);
- GenericValue callExternalMethod(Method *Meth,
+ GenericValue callExternalMethod(Function *F,
const std::vector<GenericValue> &ArgVals);
void exitCalled(GenericValue GV);
// getCurrentMethod - Return the currently executing method
- inline Method *getCurrentMethod() const {
+ inline Function *getCurrentMethod() const {
return CurFrame < 0 ? 0 : ECStack[CurFrame].CurMethod;
}
@@ -178,10 +178,10 @@ private: // Helper functions
//
void printStackFrame(int FrameNo = -1);
- // LookupMatchingNames - Search the current method namespace, then the global
- // namespace looking for values that match the specified name. Return ALL
- // matches to that name. This is obviously slow, and should only be used for
- // user interaction.
+ // LookupMatchingNames - Search the current function namespace, then the
+ // global namespace looking for values that match the specified name. Return
+ // ALL matches to that name. This is obviously slow, and should only be used
+ // for user interaction.
//
std::vector<Value*> LookupMatchingNames(const std::string &Name);
diff --git a/lib/ExecutionEngine/Interpreter/Support.cpp b/lib/ExecutionEngine/Interpreter/Support.cpp
index ca89ae3333..cac3b74c82 100644
--- a/lib/ExecutionEngine/Interpreter/Support.cpp
+++ b/lib/ExecutionEngine/Interpreter/Support.cpp
@@ -31,14 +31,14 @@ static inline void LookupMatchingNames(const std::string &Name,SymTabValue &STV,
}
}
-// LookupMatchingNames - Search the current method namespace, then the global
+// LookupMatchingNames - Search the current function namespace, then the global
// namespace looking for values that match the specified name. Return ALL
// matches to that name. This is obviously slow, and should only be used for
// user interaction.
//
std::vector<Value*> Interpreter::LookupMatchingNames(const std::string &Name) {
std::vector<Value*> Results;
- Method *CurMeth = getCurrentMethod();
+ Function *CurMeth = getCurrentMethod();
if (CurMeth) ::LookupMatchingNames(Name, *CurMeth, Results);
if (CurMod ) ::LookupMatchingNames(Name, *CurMod , Results);
diff --git a/lib/ExecutionEngine/Interpreter/UserInput.cpp b/lib/ExecutionEngine/Interpreter/UserInput.cpp
index 99ee6ecaf7..b35463fc0b 100644
--- a/lib/ExecutionEngine/Interpreter/UserInput.cpp
+++ b/lib/ExecutionEngine/Interpreter/UserInput.cpp
@@ -124,7 +124,7 @@ void Interpreter::handleUserInput() {
case Finish: finish(); break;
case Call:
cin >> Command;
- callMethod(Command); // Enter the specified method
+ callMethod(Command); // Enter the specified function
finish(); // Run until it's complete
break;
@@ -215,7 +215,7 @@ void Interpreter::setBreakpoint(const string &Name) {
bool Interpreter::callMethod(const string &Name) {
std::vector<Value*> Options = LookupMatchingNames(Name);
- for (unsigned i = 0; i < Options.size(); ++i) { // Remove nonmethod matches...
+ for (unsigned i = 0; i < Options.size(); ++i) { // Remove non-fn matches...
if (!isa<Function>(Options[i])) {
Options.erase(Options.begin()+i);
--i;
@@ -263,7 +263,7 @@ bool Interpreter::callMainMethod(const string &Name,
const std::vector<string> &InputArgv) {
std::vector<Value*> Options = LookupMatchingNames(Name);
- for (unsigned i = 0; i < Options.size(); ++i) { // Remove nonmethod matches...
+ for (unsigned i = 0; i < Options.size(); ++i) { // Remove non-fn matches...
if (!isa<Function>(Options[i])) {
Options.erase(Options.begin()+i);
--i;
@@ -321,7 +321,7 @@ void Interpreter::list() {
if (ECStack.empty())
cout << "Error: No program executing!\n";
else
- CW << ECStack[CurFrame].CurMethod; // Just print the method out...
+ CW << ECStack[CurFrame].CurMethod; // Just print the function out...
}
void Interpreter::printStackTrace() {