C++'ification of Quick compiler's casts

 o Eliminate old useless LIR casts.
 o Replace remaining C-style casts with new C++ versions.
 o Unified instruction encoding enum
 o Expand usage of the auto-generated ostream helpers for enum LOG messages.
 o Replaced all usages of intptr_t with uintptr_t.
 o Fixed bug in removeRedundantBranches, and moved to common code

Change-Id: I53211c0de1be913f958c8fde915296ac08345b7e
diff --git a/src/compiler/compiler_ir.h b/src/compiler/compiler_ir.h
index f73fe92..bc09a9c 100644
--- a/src/compiler/compiler_ir.h
+++ b/src/compiler/compiler_ir.h
@@ -25,6 +25,7 @@
 #include "safe_map.h"
 #include "greenland/ir_builder.h"
 #include "llvm/Module.h"
+#include "compiler_enums.h"
 
 namespace art {
 
@@ -42,39 +43,6 @@
 struct LIR;
 class LLVMInfo;
 
-enum RegisterClass {
-  kCoreReg,
-  kFPReg,
-  kAnyReg,
-};
-
-enum SpecialTargetRegister {
-  kSelf,            // Thread
-  kSuspend,         // Used to reduce suspend checks
-  kLr,
-  kPc,
-  kSp,
-  kArg0,
-  kArg1,
-  kArg2,
-  kArg3,
-  kFArg0,
-  kFArg1,
-  kFArg2,
-  kFArg3,
-  kRet0,
-  kRet1,
-  kInvokeTgt,
-  kCount
-};
-
-enum RegLocationType {
-  kLocDalvikFrame = 0, // Normal Dalvik register
-  kLocPhysReg,
-  kLocCompilerTemp,
-  kLocInvalid
-};
-
 struct PromotionMap {
   RegLocationType coreLocation:3;
   uint8_t coreReg;
@@ -170,14 +138,6 @@
 #define MANY_BLOCKS_INITIALIZER 1000 /* Threshold for switching dataflow off */
 #define MANY_BLOCKS 4000 /* Non-initializer threshold */
 
-enum BBType {
-  kEntryBlock,
-  kDalvikByteCode,
-  kExitBlock,
-  kExceptionHandling,
-  kDead,
-};
-
 /* Utility macros to traverse the LIR list */
 #define NEXT_LIR(lir) (lir->next)
 #define PREV_LIR(lir) (lir->prev)
@@ -188,22 +148,6 @@
 #define DECODE_ALIAS_INFO_WIDE(X)       ((X & DECODE_ALIAS_INFO_WIDE_FLAG) ? 1 : 0)
 #define ENCODE_ALIAS_INFO(REG, ISWIDE)  (REG | (ISWIDE ? DECODE_ALIAS_INFO_WIDE_FLAG : 0))
 
-/*
- * Def/Use encoding in 64-bit useMask/defMask.  Low positions used for target-specific
- * registers (and typically use the register number as the position).  High positions
- * reserved for common and abstract resources.
- */
-
-enum ResourceEncodingPos {
-  kMustNotAlias = 63,
-  kHeapRef = 62,          // Default memory reference type
-  kLiteral = 61,          // Literal pool memory reference
-  kDalvikReg = 60,        // Dalvik vReg memory reference
-  kFPStatus = 59,
-  kCCode = 58,
-  kLowestCommonResource = kCCode
-};
-
 /* Common resource macros */
 #define ENCODE_CCODE            (1ULL << kCCode)
 #define ENCODE_FP_STATUS        (1ULL << kFPStatus)
@@ -237,60 +181,10 @@
   uint64_t defMask;           // Resource mask for def
 };
 
-/* Shared pseudo opcodes - must be < 0 */
-enum LIRPseudoOpcode {
-  kPseudoExportedPC = -18,
-  kPseudoSafepointPC = -17,
-  kPseudoIntrinsicRetry = -16,
-  kPseudoSuspendTarget = -15,
-  kPseudoThrowTarget = -14,
-  kPseudoCaseLabel = -13,
-  kPseudoMethodEntry = -12,
-  kPseudoMethodExit = -11,
-  kPseudoBarrier = -10,
-  kPseudoExtended = -9,
-  kPseudoSSARep = -8,
-  kPseudoEntryBlock = -7,
-  kPseudoExitBlock = -6,
-  kPseudoTargetLabel = -5,
-  kPseudoDalvikByteCodeBoundary = -4,
-  kPseudoPseudoAlign4 = -3,
-  kPseudoEHBlockLabel = -2,
-  kPseudoNormalBlockLabel = -1,
-};
-
-enum ExtendedMIROpcode {
-  kMirOpFirst = kNumPackedOpcodes,
-  kMirOpPhi = kMirOpFirst,
-  kMirOpCopy,
-  kMirOpFusedCmplFloat,
-  kMirOpFusedCmpgFloat,
-  kMirOpFusedCmplDouble,
-  kMirOpFusedCmpgDouble,
-  kMirOpFusedCmpLong,
-  kMirOpNop,
-  kMirOpNullCheck,
-  kMirOpRangeCheck,
-  kMirOpDivZeroCheck,
-  kMirOpCheck,
-  kMirOpLast,
-};
+extern const char* extendedMIROpNames[kMirOpLast - kMirOpFirst];
 
 struct SSARepresentation;
 
-enum MIROptimizationFlagPositons {
-  kMIRIgnoreNullCheck = 0,
-  kMIRNullCheckOnly,
-  kMIRIgnoreRangeCheck,
-  kMIRRangeCheckOnly,
-  kMIRInlined,                        // Invoke is inlined (ie dead)
-  kMIRInlinedPred,                    // Invoke is inlined via prediction
-  kMIRCallee,                         // Instruction is inlined from callee
-  kMIRIgnoreSuspendCheck,
-  kMIRDup,
-  kMIRMark,                           // Temporary node mark
-};
-
 #define MIR_IGNORE_NULL_CHECK           (1 << kMIRIgnoreNullCheck)
 #define MIR_NULL_CHECK_ONLY             (1 << kMIRNullCheckOnly)
 #define MIR_IGNORE_RANGE_CHECK          (1 << kMIRIgnoreRangeCheck)
@@ -327,14 +221,6 @@
 
 struct BasicBlockDataFlow;
 
-/* For successorBlockList */
-enum BlockListType {
-  kNotUsed = 0,
-  kCatch,
-  kPackedSwitch,
-  kSparseSwitch,
-};
-
 struct BasicBlock {
   int id;
   int dfsId;
@@ -379,11 +265,6 @@
 struct ArenaMemBlock;
 struct Memstats;
 
-enum AssemblerStatus {
-  kSuccess,
-  kRetryAll,
-};
-
 #define NOTVISITED (-1)
 
 struct CompilationUnit {
@@ -653,152 +534,6 @@
   int* opcodeCount;    // Count Dalvik opcodes for tuning
 };
 
-enum OpSize {
-  kWord,
-  kLong,
-  kSingle,
-  kDouble,
-  kUnsignedHalf,
-  kSignedHalf,
-  kUnsignedByte,
-  kSignedByte,
-};
-
-enum OpKind {
-  kOpMov,
-  kOpMvn,
-  kOpCmp,
-  kOpLsl,
-  kOpLsr,
-  kOpAsr,
-  kOpRor,
-  kOpNot,
-  kOpAnd,
-  kOpOr,
-  kOpXor,
-  kOpNeg,
-  kOpAdd,
-  kOpAdc,
-  kOpSub,
-  kOpSbc,
-  kOpRsub,
-  kOpMul,
-  kOpDiv,
-  kOpRem,
-  kOpBic,
-  kOpCmn,
-  kOpTst,
-  kOpBkpt,
-  kOpBlx,
-  kOpPush,
-  kOpPop,
-  kOp2Char,
-  kOp2Short,
-  kOp2Byte,
-  kOpCondBr,
-  kOpUncondBr,
-  kOpBx,
-  kOpInvalid,
-};
-
-std::ostream& operator<<(std::ostream& os, const OpKind& kind);
-
-enum ConditionCode {
-  kCondEq,  // equal
-  kCondNe,  // not equal
-  kCondCs,  // carry set (unsigned less than)
-  kCondUlt = kCondCs,
-  kCondCc,  // carry clear (unsigned greater than or same)
-  kCondUge = kCondCc,
-  kCondMi,  // minus
-  kCondPl,  // plus, positive or zero
-  kCondVs,  // overflow
-  kCondVc,  // no overflow
-  kCondHi,  // unsigned greater than
-  kCondLs,  // unsigned lower or same
-  kCondGe,  // signed greater than or equal
-  kCondLt,  // signed less than
-  kCondGt,  // signed greater than
-  kCondLe,  // signed less than or equal
-  kCondAl,  // always
-  kCondNv,  // never
-};
-
-// Target specific condition encodings
-enum ArmConditionCode {
-  kArmCondEq = 0x0,  /* 0000 */
-  kArmCondNe = 0x1,  /* 0001 */
-  kArmCondCs = 0x2,  /* 0010 */
-  kArmCondCc = 0x3,  /* 0011 */
-  kArmCondMi = 0x4,  /* 0100 */
-  kArmCondPl = 0x5,  /* 0101 */
-  kArmCondVs = 0x6,  /* 0110 */
-  kArmCondVc = 0x7,  /* 0111 */
-  kArmCondHi = 0x8,  /* 1000 */
-  kArmCondLs = 0x9,  /* 1001 */
-  kArmCondGe = 0xa,  /* 1010 */
-  kArmCondLt = 0xb,  /* 1011 */
-  kArmCondGt = 0xc,  /* 1100 */
-  kArmCondLe = 0xd,  /* 1101 */
-  kArmCondAl = 0xe,  /* 1110 */
-  kArmCondNv = 0xf,  /* 1111 */
-};
-
-enum X86ConditionCode {
-  kX86CondO   = 0x0,    // overflow
-  kX86CondNo  = 0x1,    // not overflow
-
-  kX86CondB   = 0x2,    // below
-  kX86CondNae = kX86CondB,  // not-above-equal
-  kX86CondC   = kX86CondB,  // carry
-
-  kX86CondNb  = 0x3,    // not-below
-  kX86CondAe  = kX86CondNb, // above-equal
-  kX86CondNc  = kX86CondNb, // not-carry
-
-  kX86CondZ   = 0x4,    // zero
-  kX86CondEq  = kX86CondZ,  // equal
-
-  kX86CondNz  = 0x5,    // not-zero
-  kX86CondNe  = kX86CondNz, // not-equal
-
-  kX86CondBe  = 0x6,    // below-equal
-  kX86CondNa  = kX86CondBe, // not-above
-
-  kX86CondNbe = 0x7,    // not-below-equal
-  kX86CondA   = kX86CondNbe,// above
-
-  kX86CondS   = 0x8,    // sign
-  kX86CondNs  = 0x9,    // not-sign
-
-  kX86CondP   = 0xA,    // 8-bit parity even
-  kX86CondPE  = kX86CondP,
-
-  kX86CondNp  = 0xB,    // 8-bit parity odd
-  kX86CondPo  = kX86CondNp,
-
-  kX86CondL   = 0xC,    // less-than
-  kX86CondNge = kX86CondL,  // not-greater-equal
-
-  kX86CondNl  = 0xD,    // not-less-than
-  kX86CondGe  = kX86CondNl, // not-greater-equal
-
-  kX86CondLe  = 0xE,    // less-than-equal
-  kX86CondNg  = kX86CondLe, // not-greater
-
-  kX86CondNle = 0xF,    // not-less-than
-  kX86CondG   = kX86CondNle,// greater
-};
-
-
-enum ThrowKind {
-  kThrowNullPointer,
-  kThrowDivZero,
-  kThrowArrayBounds,
-  kThrowNoSuchMethod,
-  kThrowStackOverflow,
-};
-
 struct SwitchTable {
   int offset;
   const uint16_t* table;            // Original dex table
@@ -816,27 +551,6 @@
 
 #define MAX_PATTERN_LEN 5
 
-enum SpecialCaseHandler {
-  kNoHandler,
-  kNullMethod,
-  kConstFunction,
-  kIGet,
-  kIGetBoolean,
-  kIGetObject,
-  kIGetByte,
-  kIGetChar,
-  kIGetShort,
-  kIGetWide,
-  kIPut,
-  kIPutBoolean,
-  kIPutObject,
-  kIPutByte,
-  kIPutChar,
-  kIPutShort,
-  kIPutWide,
-  kIdentity,
-};
-
 struct CodePattern {
   const Instruction::Code opcodes[MAX_PATTERN_LEN];
   const SpecialCaseHandler handlerCode;