summaryrefslogtreecommitdiffstats
path: root/compiler/optimizing/codegen_test.cc
diff options
context:
space:
mode:
authorNicolas Geoffray <ngeoffray@google.com>2015-01-26 12:49:35 +0000
committerNicolas Geoffray <ngeoffray@google.com>2015-01-26 12:52:16 +0000
commita0bb2bd5b6a049ad806c223f00672d1f0210db67 (patch)
tree206723aac52d4ccdf692f1d6a3c82c059f1cf6a1 /compiler/optimizing/codegen_test.cc
parent2dadc9df0ffb822870a150f81257792b83241c77 (diff)
downloadart-a0bb2bd5b6a049ad806c223f00672d1f0210db67.zip
art-a0bb2bd5b6a049ad806c223f00672d1f0210db67.tar.gz
art-a0bb2bd5b6a049ad806c223f00672d1f0210db67.tar.bz2
Fix codegen_test.
Native and ART do not have the same calling convention for ART, so we need to adjust blocked and allocated registers. Change-Id: I606b2620c0e5a54bd60d6100a137c06616ad40b4
Diffstat (limited to 'compiler/optimizing/codegen_test.cc')
-rw-r--r--compiler/optimizing/codegen_test.cc35
1 files changed, 30 insertions, 5 deletions
diff --git a/compiler/optimizing/codegen_test.cc b/compiler/optimizing/codegen_test.cc
index aa4fc8f..2d59136 100644
--- a/compiler/optimizing/codegen_test.cc
+++ b/compiler/optimizing/codegen_test.cc
@@ -36,9 +36,34 @@
#include "utils.h"
#include "gtest/gtest.h"
-
+
namespace art {
+// Provide our own codegen, that ensures the C calling conventions
+// are preserved. Currently, ART and C do not match as R4 is caller-save
+// in ART, and callee-save in C. Alternatively, we could use or write
+// the stub that saves and restores all registers, but it is easier
+// to just overwrite the code generator.
+class TestCodeGeneratorARM : public arm::CodeGeneratorARM {
+ public:
+ TestCodeGeneratorARM(HGraph* graph,
+ const ArmInstructionSetFeatures& isa_features,
+ const CompilerOptions& compiler_options)
+ : arm::CodeGeneratorARM(graph, isa_features, compiler_options) {
+ AddAllocatedRegister(Location::RegisterLocation(6));
+ AddAllocatedRegister(Location::RegisterLocation(7));
+ }
+
+ void SetupBlockedRegisters(bool is_baseline) const OVERRIDE {
+ arm::CodeGeneratorARM::SetupBlockedRegisters(is_baseline);
+ blocked_core_registers_[4] = true;
+ blocked_core_registers_[6] = false;
+ blocked_core_registers_[7] = false;
+ // Makes pari R6-R7 available.
+ blocked_register_pairs_[6 >> 1] = false;
+ }
+};
+
class InternalCodeAllocator : public CodeAllocator {
public:
InternalCodeAllocator() : size_(0) { }
@@ -92,7 +117,7 @@ static void RunCodeBaseline(HGraph* graph, bool has_result, Expected expected) {
std::unique_ptr<const ArmInstructionSetFeatures> features(
ArmInstructionSetFeatures::FromCppDefines());
- arm::CodeGeneratorARM codegenARM(graph, *features.get(), compiler_options);
+ TestCodeGeneratorARM codegenARM(graph, *features.get(), compiler_options);
codegenARM.CompileBaseline(&allocator, true);
if (kRuntimeISA == kArm || kRuntimeISA == kThumb2) {
Run(allocator, codegenARM, has_result, expected);
@@ -136,9 +161,9 @@ static void RunCodeOptimized(HGraph* graph,
Expected expected) {
CompilerOptions compiler_options;
if (kRuntimeISA == kArm || kRuntimeISA == kThumb2) {
- arm::CodeGeneratorARM codegenARM(graph,
- *ArmInstructionSetFeatures::FromCppDefines(),
- compiler_options);
+ TestCodeGeneratorARM codegenARM(graph,
+ *ArmInstructionSetFeatures::FromCppDefines(),
+ compiler_options);
RunCodeOptimized(&codegenARM, graph, hook_before_codegen, has_result, expected);
} else if (kRuntimeISA == kArm64) {
arm64::CodeGeneratorARM64 codegenARM64(graph, compiler_options);