summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine
diff options
context:
space:
mode:
authorBrian Gaeke <gaeke@uiuc.edu>2003-09-05 04:46:26 +0000
committerBrian Gaeke <gaeke@uiuc.edu>2003-09-05 04:46:26 +0000
commit8421765778da9df4fce1886556be916e9f3a95e3 (patch)
treee67c851c226b2a2d7b525de09b59775f2f7f5fce /llvm/lib/ExecutionEngine
parentd15598bfe05351f4ce07174520bb49d322b338cb (diff)
downloadbcm5719-llvm-8421765778da9df4fce1886556be916e9f3a95e3.tar.gz
bcm5719-llvm-8421765778da9df4fce1886556be916e9f3a95e3.zip
Remove support for interactive (step finish next) instructions.
Remove printCurrentInstruction, printStackFrame and infoValue (only used interactively) and other unused methods of Interpreter. Fold UserInput.cpp containing only callMainFunction() into Interpreter.cpp. Remove unused Profile flag. llvm-svn: 8359
Diffstat (limited to 'llvm/lib/ExecutionEngine')
-rw-r--r--llvm/lib/ExecutionEngine/Interpreter/Execution.cpp115
-rw-r--r--llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp44
-rw-r--r--llvm/lib/ExecutionEngine/Interpreter/Interpreter.h20
-rw-r--r--llvm/lib/ExecutionEngine/Interpreter/UserInput.cpp51
4 files changed, 44 insertions, 186 deletions
diff --git a/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp b/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
index fc0beeaf7a4..6881ff9ed7d 100644
--- a/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
+++ b/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
@@ -1048,46 +1048,6 @@ void Interpreter::executeInstruction() {
CurFrame = ECStack.size()-1;
}
-void Interpreter::stepInstruction() { // Do the 'step' command
- if (ECStack.empty()) {
- std::cout << "Error: no program running, cannot step!\n";
- return;
- }
-
- // Run an instruction...
- executeInstruction();
-
- // Print the next instruction to execute...
- printCurrentInstruction();
-}
-
-// --- UI Stuff...
-void Interpreter::nextInstruction() { // Do the 'next' command
- if (ECStack.empty()) {
- std::cout << "Error: no program running, cannot 'next'!\n";
- return;
- }
-
- // If this is a call instruction, step over the call instruction...
- // TODO: ICALL, CALL WITH, ...
- if (ECStack.back().CurInst->getOpcode() == Instruction::Call) {
- unsigned StackSize = ECStack.size();
- // Step into the function...
- executeInstruction();
-
- // If we we able to step into the function, finish it now. We might not be
- // able the step into a function, if it's external for example.
- if (ECStack.size() != StackSize)
- finish(); // Finish executing the function...
- else
- printCurrentInstruction();
-
- } else {
- // Normal instruction, just step...
- stepInstruction();
- }
-}
-
void Interpreter::run() {
if (ECStack.empty()) {
std::cout << "Error: no program running, cannot run!\n";
@@ -1098,40 +1058,6 @@ void Interpreter::run() {
// Run an instruction...
executeInstruction();
}
-
- // Print the next instruction to execute...
- printCurrentInstruction();
-}
-
-void Interpreter::finish() {
- if (ECStack.empty()) {
- std::cout << "Error: no program running, cannot run!\n";
- return;
- }
-
- unsigned StackSize = ECStack.size();
- while (ECStack.size() >= StackSize) {
- // Run an instruction...
- executeInstruction();
- }
-
- // Print the next instruction to execute...
- printCurrentInstruction();
-}
-
-// printCurrentInstruction - Print out the instruction that the virtual PC is
-// at, or fail silently if no program is running.
-//
-void Interpreter::printCurrentInstruction() {
- if (!ECStack.empty()) {
- if (ECStack.back().CurBB->begin() == ECStack.back().CurInst) // print label
- WriteAsOperand(std::cout, ECStack.back().CurBB) << ":\n";
-
- Instruction &I = *ECStack.back().CurInst;
- InstNumber *IN = (InstNumber*)I.getAnnotation(SlotNumberAID);
- assert(IN && "Instruction has no numbering annotation!");
- std::cout << "#" << IN->InstNum << I;
- }
}
void Interpreter::printValue(const Type *Ty, GenericValue V) {
@@ -1177,44 +1103,3 @@ void Interpreter::print(const std::string &Name) {
std::cout << "\n";
}
}
-
-void Interpreter::infoValue(const std::string &Name) {
- Value *PickedVal = ChooseOneOption(Name, LookupMatchingNames(Name));
- if (!PickedVal) return;
-
- std::cout << "Value: ";
- print(PickedVal->getType(),
- getOperandValue(PickedVal, ECStack[CurFrame]));
- std::cout << "\n";
- printOperandInfo(PickedVal, ECStack[CurFrame]);
-}
-
-// printStackFrame - Print information about the specified stack frame, or -1
-// for the default one.
-//
-void Interpreter::printStackFrame(int FrameNo) {
- if (FrameNo == -1) FrameNo = CurFrame;
- Function *F = ECStack[FrameNo].CurFunction;
- const Type *RetTy = F->getReturnType();
-
- CW << ((FrameNo == CurFrame) ? '>' : '-') << "#" << FrameNo << ". "
- << (Value*)RetTy << " \"" << F->getName() << "\"(";
-
- unsigned i = 0;
- for (Function::aiterator I = F->abegin(), E = F->aend(); I != E; ++I, ++i) {
- if (i != 0) std::cout << ", ";
- CW << *I << "=";
-
- printValue(I->getType(), getOperandValue(I, ECStack[FrameNo]));
- }
-
- std::cout << ")\n";
-
- if (FrameNo != int(ECStack.size()-1)) {
- BasicBlock::iterator I = ECStack[FrameNo].CurInst;
- CW << --I;
- } else {
- CW << *ECStack[FrameNo].CurInst;
- }
-}
-
diff --git a/llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp b/llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp
index 4f8c407340a..6b82dada339 100644
--- a/llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp
+++ b/llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp
@@ -8,6 +8,8 @@
#include "Interpreter.h"
#include "llvm/Module.h"
+#include "llvm/DerivedTypes.h"
+#include "llvm/Function.h"
/// create - Create a new interpreter object. This can never fail.
///
@@ -76,3 +78,45 @@ int Interpreter::run(const std::string &MainFunction,
return ExitCode;
}
+
+// callMainFunction - Construct call to typical C main() function and
+// call it using callFunction().
+//
+bool Interpreter::callMainFunction(const std::string &Name,
+ const std::vector<std::string> &InputArgv) {
+ Function *M = getModule().getNamedFunction(Name);
+ if (M == 0) {
+ std::cerr << "Could not find function '" << Name << "' in module!\n";
+ return 1;
+ }
+ const FunctionType *MT = M->getFunctionType();
+
+ std::vector<GenericValue> Args;
+ if (MT->getParamTypes().size() >= 2) {
+ PointerType *SPP = PointerType::get(PointerType::get(Type::SByteTy));
+ if (MT->getParamTypes()[1] != SPP) {
+ CW << "Second argument of '" << Name << "' should have type: '"
+ << SPP << "'!\n";
+ return true;
+ }
+ Args.push_back(PTOGV(CreateArgv(InputArgv)));
+ }
+
+ if (MT->getParamTypes().size() >= 1) {
+ if (!MT->getParamTypes()[0]->isInteger()) {
+ std::cout << "First argument of '" << Name
+ << "' should be an integer!\n";
+ return true;
+ } else {
+ GenericValue GV; GV.UIntVal = InputArgv.size();
+ Args.insert(Args.begin(), GV);
+ }
+ }
+
+ callFunction(M, Args); // Start executing it...
+
+ // Reset the current frame location to the top of stack
+ CurFrame = ECStack.size()-1;
+
+ return false;
+}
diff --git a/llvm/lib/ExecutionEngine/Interpreter/Interpreter.h b/llvm/lib/ExecutionEngine/Interpreter/Interpreter.h
index 3af6726f8fb..9ea2bb1f6da 100644
--- a/llvm/lib/ExecutionEngine/Interpreter/Interpreter.h
+++ b/llvm/lib/ExecutionEngine/Interpreter/Interpreter.h
@@ -71,7 +71,6 @@ struct ExecutionContext {
//
class Interpreter : public ExecutionEngine, public InstVisitor<Interpreter> {
int ExitCode; // The exit code to be returned by the lli util
- bool Profile; // Profiling enabled?
bool Trace; // Tracing enabled?
int CurFrame; // The current stack frame being inspected
TargetData TD;
@@ -91,11 +90,6 @@ public:
///
static ExecutionEngine *create(Module *M, bool TraceMode);
- /// getExitCode - return the code that should be the exit code for the lli
- /// utility.
- ///
- inline int getExitCode() const { return ExitCode; }
-
/// run - Start execution with the specified function and arguments.
///
virtual int run(const std::string &FnName,
@@ -103,15 +97,12 @@ public:
const char ** envp);
- // enableProfiling() - Turn profiling on, clear stats?
- void enableProfiling() { Profile = true; }
void enableTracing() { Trace = true; }
void handleUserInput();
// User Interation Methods...
bool callFunction(const std::string &Name); // return true on failure
- void infoValue(const std::string &Name);
void print(const std::string &Name);
static void print(const Type *Ty, GenericValue V);
static void printValue(const Type *Ty, GenericValue V);
@@ -119,17 +110,11 @@ public:
bool callMainFunction(const std::string &MainName,
const std::vector<std::string> &InputFilename);
- void list(); // Do the 'list' command
- void printStackTrace(); // Do the 'backtrace' command
-
// Code execution methods...
void callFunction(Function *F, const std::vector<GenericValue> &ArgVals);
void executeInstruction(); // Execute one instruction...
- void stepInstruction(); // Do the 'step' command
- void nextInstruction(); // Do the 'next' command
void run(); // Do the 'run' command
- void finish(); // Do the 'finish' command
// Opcode Implementations
void visitReturnInst(ReturnInst &I);
@@ -196,11 +181,6 @@ private: // Helper functions
//
void printCurrentInstruction();
- // printStackFrame - Print information about the specified stack frame, or -1
- // for the default one.
- //
- void printStackFrame(int FrameNo = -1);
-
// 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
diff --git a/llvm/lib/ExecutionEngine/Interpreter/UserInput.cpp b/llvm/lib/ExecutionEngine/Interpreter/UserInput.cpp
deleted file mode 100644
index 135c990c652..00000000000
--- a/llvm/lib/ExecutionEngine/Interpreter/UserInput.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-//===-- UserInput.cpp - Interpreter Input Loop support --------------------===//
-//
-// This file implements the interpreter Input I/O loop.
-//
-//===----------------------------------------------------------------------===//
-
-#include "Interpreter.h"
-#include "llvm/DerivedTypes.h"
-#include "llvm/Function.h"
-#include "llvm/Module.h"
-
-// callMainFunction - This is a nasty gross hack that will dissapear when
-// callFunction can parse command line options and stuff for us.
-//
-bool Interpreter::callMainFunction(const std::string &Name,
- const std::vector<std::string> &InputArgv) {
- Function *M = getModule().getNamedFunction(Name);
- if (M == 0) {
- std::cerr << "Could not find function '" << Name << "' in module!\n";
- return 1;
- }
- const FunctionType *MT = M->getFunctionType();
-
- std::vector<GenericValue> Args;
- if (MT->getParamTypes().size() >= 2) {
- PointerType *SPP = PointerType::get(PointerType::get(Type::SByteTy));
- if (MT->getParamTypes()[1] != SPP) {
- CW << "Second argument of '" << Name << "' should have type: '"
- << SPP << "'!\n";
- return true;
- }
- Args.push_back(PTOGV(CreateArgv(InputArgv)));
- }
-
- if (MT->getParamTypes().size() >= 1) {
- if (!MT->getParamTypes()[0]->isInteger()) {
- std::cout << "First argument of '" << Name << "' should be an integer!\n";
- return true;
- } else {
- GenericValue GV; GV.UIntVal = InputArgv.size();
- Args.insert(Args.begin(), GV);
- }
- }
-
- callFunction(M, Args); // Start executing it...
-
- // Reset the current frame location to the top of stack
- CurFrame = ECStack.size()-1;
-
- return false;
-}
OpenPOWER on IntegriCloud