Continuing Quick compiler refactoring
With this CL, we no longer include any .cc files - all source
files compile stand-alone. We still build a separate .so for
each target, but all code in the target-independent "codegen"
directory is now truly independent and doesn't rely on any
target-specific macros to compile.
Header file inclusion is still a bit of a mess, but that will be
addressed in a subsequent CL.
Next up: create a codegen class to hold code generator routines
overrideable by target.
Change-Id: I3a93118d11afeab11f310950a6a73381a99e26e1
diff --git a/src/compiler/codegen/arm/arm_lir.h b/src/compiler/codegen/arm/arm_lir.h
index a3c4ca1..bc3277f 100644
--- a/src/compiler/codegen/arm/arm_lir.h
+++ b/src/compiler/codegen/arm/arm_lir.h
@@ -232,8 +232,6 @@
kArmRor = 0x3
};
-#define isPseudoOpcode(opcode) (static_cast<int>(opcode) < 0)
-
/*
* The following enum defines the list of supported Thumb instructions by the
* assembler. Their corresponding EncodingMap positions will be defined in
diff --git a/src/compiler/codegen/arm/backend_arm.cc b/src/compiler/codegen/arm/backend_arm.cc
deleted file mode 100644
index 47d1967..0000000
--- a/src/compiler/codegen/arm/backend_arm.cc
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#define _CODEGEN_C
-#define _ARMV7_A
-
-#include "arm_lir.h"
-#include "../ralloc_util.h"
-
-/* Common codegen utility code */
-#include "../codegen_util.cc"
-
-#include "utility_arm.cc"
-#include "../gen_loadstore.cc"
-#include "../gen_common.cc"
-#include "../gen_invoke.cc"
-#include "call_arm.cc"
-#include "fp_arm.cc"
-#include "int_arm.cc"
-
-/* Bitcode conversion */
-#include "../method_bitcode.cc"
-
-/* MIR2LIR dispatcher and architectural independent codegen routines */
-#include "../method_codegen_driver.cc"
-
-/* Target-independent local optimizations */
-#include "../local_optimizations.cc"
diff --git a/src/compiler/codegen/arm/call_arm.cc b/src/compiler/codegen/arm/call_arm.cc
index acf825a..0964226 100644
--- a/src/compiler/codegen/arm/call_arm.cc
+++ b/src/compiler/codegen/arm/call_arm.cc
@@ -18,6 +18,9 @@
#include "oat_compilation_unit.h"
#include "oat/runtime/oat_support_entrypoints.h"
+#include "arm_lir.h"
+#include "../codegen_util.h"
+#include "../ralloc_util.h"
namespace art {
@@ -504,7 +507,7 @@
oatClobberCalleeSave(cUnit);
LIR* callInst = opReg(cUnit, kOpBlx, rARM_LR);
markSafepointPC(cUnit, callInst);
- oatGenMemBarrier(cUnit, kSY);
+ oatGenMemBarrier(cUnit, kLoadLoad);
}
/*
@@ -536,7 +539,7 @@
oatClobberCalleeSave(cUnit);
LIR* callInst = opReg(cUnit, kOpBlx, rARM_LR);
markSafepointPC(cUnit, callInst);
- oatGenMemBarrier(cUnit, kSY);
+ oatGenMemBarrier(cUnit, kStoreLoad);
}
/*
diff --git a/src/compiler/codegen/arm/fp_arm.cc b/src/compiler/codegen/arm/fp_arm.cc
index 70783a4..3b0d540 100644
--- a/src/compiler/codegen/arm/fp_arm.cc
+++ b/src/compiler/codegen/arm/fp_arm.cc
@@ -14,6 +14,10 @@
* limitations under the License.
*/
+#include "arm_lir.h"
+#include "../codegen_util.h"
+#include "../ralloc_util.h"
+
namespace art {
bool genArithOpFloat(CompilationUnit* cUnit, Instruction::Code opcode, RegLocation rlDest,
diff --git a/src/compiler/codegen/arm/int_arm.cc b/src/compiler/codegen/arm/int_arm.cc
index 159b329..f54c58c 100644
--- a/src/compiler/codegen/arm/int_arm.cc
+++ b/src/compiler/codegen/arm/int_arm.cc
@@ -18,6 +18,9 @@
#include "oat_compilation_unit.h"
#include "oat/runtime/oat_support_entrypoints.h"
+#include "arm_lir.h"
+#include "../codegen_util.h"
+#include "../ralloc_util.h"
namespace art {
@@ -378,8 +381,8 @@
RegLocation rlDest = inlineTarget(cUnit, info); // boolean place for result
- // Release store semantics, get the barrier out of the way.
- oatGenMemBarrier(cUnit, kSY);
+ // Release store semantics, get the barrier out of the way. TODO: revisit
+ oatGenMemBarrier(cUnit, kStoreLoad);
RegLocation rlObject = loadValue(cUnit, rlSrcObj, kCoreReg);
RegLocation rlNewValue = loadValue(cUnit, rlSrcNewValue, kCoreReg);
@@ -474,10 +477,22 @@
return opCondBranch(cUnit, cCode, target);
}
-void oatGenMemBarrier(CompilationUnit* cUnit, int barrierKind)
+void oatGenMemBarrier(CompilationUnit* cUnit, MemBarrierKind barrierKind)
{
#if ANDROID_SMP != 0
- LIR* dmb = newLIR1(cUnit, kThumb2Dmb, barrierKind);
+ int dmbFlavor;
+ // TODO: revisit Arm barrier kinds
+ switch (barrierKind) {
+ case kLoadStore: dmbFlavor = kSY; break;
+ case kLoadLoad: dmbFlavor = kSY; break;
+ case kStoreStore: dmbFlavor = kST; break;
+ case kStoreLoad: dmbFlavor = kSY; break;
+ default:
+ LOG(FATAL) << "Unexpected MemBarrierKind: " << barrierKind;
+ dmbFlavor = kSY; // quiet gcc.
+ break;
+ }
+ LIR* dmb = newLIR1(cUnit, kThumb2Dmb, dmbFlavor);
dmb->defMask = ENCODE_ALL;
#endif
}
diff --git a/src/compiler/codegen/arm/target_arm.cc b/src/compiler/codegen/arm/target_arm.cc
index 6640707..aa67be1 100644
--- a/src/compiler/codegen/arm/target_arm.cc
+++ b/src/compiler/codegen/arm/target_arm.cc
@@ -802,4 +802,19 @@
return rARM_LR;
}
+uint64_t getTargetInstFlags(int opcode)
+{
+ return EncodingMap[opcode].flags;
+}
+
+const char* getTargetInstName(int opcode)
+{
+ return EncodingMap[opcode].name;
+}
+
+const char* getTargetInstFmt(int opcode)
+{
+ return EncodingMap[opcode].fmt;
+}
+
} // namespace art
diff --git a/src/compiler/codegen/arm/utility_arm.cc b/src/compiler/codegen/arm/utility_arm.cc
index 1873c2a..35f4a2d 100644
--- a/src/compiler/codegen/arm/utility_arm.cc
+++ b/src/compiler/codegen/arm/utility_arm.cc
@@ -14,6 +14,10 @@
* limitations under the License.
*/
+#include "arm_lir.h"
+#include "../codegen_util.h"
+#include "../ralloc_util.h"
+
namespace art {
/* This file contains codegen for the Thumb ISA. */