Minor change to make lli print out characters numerically as well as symbolically
[oota-llvm.git] / lib / ExecutionEngine / Interpreter / Execution.cpp
index 07ad8003c332e91ee33c2e431c890bff76fba6e4..9add907131f3e656064150bcc86ba6727eba46a4 100644 (file)
@@ -24,10 +24,18 @@ using std::vector;
 using std::cout;
 using std::cerr;
 
-cl::Flag   QuietMode ("quiet"  , "Do not emit any non-program output");
-cl::Alias  QuietModeA("q"      , "Alias for -quiet", cl::NoFlags, QuietMode);
-cl::Flag   ArrayChecksEnabled("array-checks", "Enable array bound checks");
-cl::Flag   AbortOnExceptions("abort-on-exception", "Halt execution on a machine exception");
+static cl::opt<bool>
+QuietMode("quiet", cl::desc("Do not emit any non-program output"));
+
+static cl::alias 
+QuietModeA("q", cl::desc("Alias for -quiet"), cl::aliasopt(QuietMode));
+
+static cl::opt<bool>
+ArrayChecksEnabled("array-checks", cl::desc("Enable array bound checks"));
+
+static cl::opt<bool>
+AbortOnExceptions("abort-on-exception",
+                  cl::desc("Halt execution on a machine exception"));
 
 // Create a TargetData structure to handle memory addressing and size/alignment
 // computations
@@ -37,8 +45,9 @@ CachedWriter CW;     // Object to accelerate printing of LLVM
 
 
 #ifdef PROFILE_STRUCTURE_FIELDS
-static cl::Flag ProfileStructureFields("profilestructfields", 
-                                       "Profile Structure Field Accesses");
+static cl::opt<bool>
+ProfileStructureFields("profilestructfields", 
+                       cl::desc("Profile Structure Field Accesses"));
 #include <map>
 static std::map<const StructType *, vector<unsigned> > FieldAccessCounts;
 #endif
@@ -958,6 +967,7 @@ static void executeShlInst(ShiftInst &I, ExecutionContext &SF) {
     IMPLEMENT_SHIFT(<<, Int);
     IMPLEMENT_SHIFT(<<, ULong);
     IMPLEMENT_SHIFT(<<, Long);
+    IMPLEMENT_SHIFT(<<, Pointer);
   default:
     cout << "Unhandled type for Shl instruction: " << Ty << "\n";
   }
@@ -979,6 +989,7 @@ static void executeShrInst(ShiftInst &I, ExecutionContext &SF) {
     IMPLEMENT_SHIFT(>>, Int);
     IMPLEMENT_SHIFT(>>, ULong);
     IMPLEMENT_SHIFT(>>, Long);
+    IMPLEMENT_SHIFT(>>, Pointer);
   default:
     cout << "Unhandled type for Shr instruction: " << Ty << "\n";
   }
@@ -1027,7 +1038,7 @@ static void executeCastInst(CastInst &I, ExecutionContext &SF) {
     IMPLEMENT_CAST_CASE(UByte  , (unsigned char));
     IMPLEMENT_CAST_CASE(SByte  , (  signed char));
     IMPLEMENT_CAST_CASE(UShort , (unsigned short));
-    IMPLEMENT_CAST_CASE(Short  , (  signed char));
+    IMPLEMENT_CAST_CASE(Short  , (  signed short));
     IMPLEMENT_CAST_CASE(UInt   , (unsigned int ));
     IMPLEMENT_CAST_CASE(Int    , (  signed int ));
     IMPLEMENT_CAST_CASE(ULong  , (uint64_t));
@@ -1312,8 +1323,10 @@ void Interpreter::printCurrentInstruction() {
 void Interpreter::printValue(const Type *Ty, GenericValue V) {
   switch (Ty->getPrimitiveID()) {
   case Type::BoolTyID:   cout << (V.BoolVal?"true":"false"); break;
-  case Type::SByteTyID:  cout << V.SByteVal;  break;
-  case Type::UByteTyID:  cout << V.UByteVal;  break;
+  case Type::SByteTyID:
+    cout << (int)V.SByteVal << " '" << V.SByteVal << "'";  break;
+  case Type::UByteTyID:
+    cout << (unsigned)V.UByteVal << " '" << V.UByteVal << "'";  break;
   case Type::ShortTyID:  cout << V.ShortVal;  break;
   case Type::UShortTyID: cout << V.UShortVal; break;
   case Type::IntTyID:    cout << V.IntVal;    break;
@@ -1365,7 +1378,7 @@ void Interpreter::infoValue(const std::string &Name) {
 // printStackFrame - Print information about the specified stack frame, or -1
 // for the default one.
 //
-void Interpreter::printStackFrame(int FrameNo = -1) {
+void Interpreter::printStackFrame(int FrameNo) {
   if (FrameNo == -1) FrameNo = CurFrame;
   Function *F = ECStack[FrameNo].CurMethod;
   const Type *RetTy = F->getReturnType();