Fix a Thumb vs Thumb2 codegen bug.

A Thumb2 pc-relative load is slipped into the codegen stream even though
the selected platform is armv5te (eg the emulator).

Bug: 4399358
Change-Id: I61dd6853cad6c82de43f384814c903dd9f3ae302
diff --git a/vm/compiler/codegen/CodegenFactory.cpp b/vm/compiler/codegen/CodegenFactory.cpp
index ef7a0a9..61e29d7 100644
--- a/vm/compiler/codegen/CodegenFactory.cpp
+++ b/vm/compiler/codegen/CodegenFactory.cpp
@@ -263,33 +263,3 @@
         }
     }
 }
-
-/*
- * Load a class pointer value into a fixed or temp register.  Target
- * register is clobbered, and marked inUse.
- */
-static ArmLIR *loadClassPointer(CompilationUnit *cUnit, int rDest, int value)
-{
-    ArmLIR *res;
-    cUnit->hasClassLiterals = true;
-    if (dvmCompilerIsTemp(cUnit, rDest)) {
-        dvmCompilerClobber(cUnit, rDest);
-        dvmCompilerMarkInUse(cUnit, rDest);
-    }
-    ArmLIR *dataTarget = scanLiteralPool(cUnit->classPointerList, value, 0);
-    if (dataTarget == NULL) {
-        dataTarget = addWordData(cUnit, &cUnit->classPointerList, value);
-        /* Counts the number of class pointers in this translation */
-        cUnit->numClassPointers++;
-    }
-    ArmLIR *loadPcRel = (ArmLIR *) dvmCompilerNew(sizeof(ArmLIR), true);
-    loadPcRel->opcode = kThumb2LdrPcRel12;
-    loadPcRel->generic.target = (LIR *) dataTarget;
-    loadPcRel->operands[0] = rDest;
-    setupResourceMasks(loadPcRel);
-    setMemRefType(loadPcRel, true, kLiteral);
-    loadPcRel->aliasInfo = dataTarget->operands[0];
-    res = loadPcRel;
-    dvmCompilerAppendLIR(cUnit, (LIR *) loadPcRel);
-    return res;
-}
diff --git a/vm/compiler/codegen/arm/Thumb/Factory.cpp b/vm/compiler/codegen/arm/Thumb/Factory.cpp
index 7b51df1..9cdd75f 100644
--- a/vm/compiler/codegen/arm/Thumb/Factory.cpp
+++ b/vm/compiler/codegen/arm/Thumb/Factory.cpp
@@ -110,6 +110,36 @@
     return loadConstantNoClobber(cUnit, rDest, value);
 }
 
+/*
+ * Load a class pointer value into a fixed or temp register.  Target
+ * register is clobbered, and marked inUse.
+ */
+static ArmLIR *loadClassPointer(CompilationUnit *cUnit, int rDest, int value)
+{
+    ArmLIR *res;
+    cUnit->hasClassLiterals = true;
+    if (dvmCompilerIsTemp(cUnit, rDest)) {
+        dvmCompilerClobber(cUnit, rDest);
+        dvmCompilerMarkInUse(cUnit, rDest);
+    }
+    ArmLIR *dataTarget = scanLiteralPool(cUnit->classPointerList, value, 0);
+    if (dataTarget == NULL) {
+        dataTarget = addWordData(cUnit, &cUnit->classPointerList, value);
+        /* Counts the number of class pointers in this translation */
+        cUnit->numClassPointers++;
+    }
+    ArmLIR *loadPcRel = (ArmLIR *) dvmCompilerNew(sizeof(ArmLIR), true);
+    loadPcRel->opcode = kThumbLdrPcRel;
+    loadPcRel->generic.target = (LIR *) dataTarget;
+    loadPcRel->operands[0] = rDest;
+    setupResourceMasks(loadPcRel);
+    setMemRefType(loadPcRel, true, kLiteral);
+    loadPcRel->aliasInfo = dataTarget->operands[0];
+    res = loadPcRel;
+    dvmCompilerAppendLIR(cUnit, (LIR *) loadPcRel);
+    return res;
+}
+
 static ArmLIR *opNone(CompilationUnit *cUnit, OpKind op)
 {
     ArmOpcode opcode = kThumbBkpt;
@@ -661,7 +691,7 @@
     if (load2 != NULL && cUnit->heapMemOp)
         load2->flags.insertWrapper = true;
 #endif
-    return res;
+    return load;
 }
 
 static ArmLIR *loadBaseDisp(CompilationUnit *cUnit, MIR *mir, int rBase,
diff --git a/vm/compiler/codegen/arm/Thumb2/Factory.cpp b/vm/compiler/codegen/arm/Thumb2/Factory.cpp
index 8045450..9c9ce13 100644
--- a/vm/compiler/codegen/arm/Thumb2/Factory.cpp
+++ b/vm/compiler/codegen/arm/Thumb2/Factory.cpp
@@ -201,6 +201,36 @@
     return loadConstantNoClobber(cUnit, rDest, value);
 }
 
+/*
+ * Load a class pointer value into a fixed or temp register.  Target
+ * register is clobbered, and marked inUse.
+ */
+static ArmLIR *loadClassPointer(CompilationUnit *cUnit, int rDest, int value)
+{
+    ArmLIR *res;
+    cUnit->hasClassLiterals = true;
+    if (dvmCompilerIsTemp(cUnit, rDest)) {
+        dvmCompilerClobber(cUnit, rDest);
+        dvmCompilerMarkInUse(cUnit, rDest);
+    }
+    ArmLIR *dataTarget = scanLiteralPool(cUnit->classPointerList, value, 0);
+    if (dataTarget == NULL) {
+        dataTarget = addWordData(cUnit, &cUnit->classPointerList, value);
+        /* Counts the number of class pointers in this translation */
+        cUnit->numClassPointers++;
+    }
+    ArmLIR *loadPcRel = (ArmLIR *) dvmCompilerNew(sizeof(ArmLIR), true);
+    loadPcRel->opcode = kThumb2LdrPcRel12;
+    loadPcRel->generic.target = (LIR *) dataTarget;
+    loadPcRel->operands[0] = rDest;
+    setupResourceMasks(loadPcRel);
+    setMemRefType(loadPcRel, true, kLiteral);
+    loadPcRel->aliasInfo = dataTarget->operands[0];
+    res = loadPcRel;
+    dvmCompilerAppendLIR(cUnit, (LIR *) loadPcRel);
+    return res;
+}
+
 static ArmLIR *opNone(CompilationUnit *cUnit, OpKind op)
 {
     ArmOpcode opcode = kThumbBkpt;
@@ -923,7 +953,7 @@
     if (cUnit->heapMemOp)
         load->flags.insertWrapper = true;
 #endif
-    return res;
+    return load;
 }
 
 static ArmLIR *loadBaseDisp(CompilationUnit *cUnit, MIR *mir, int rBase,