diff options
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/optimizing/code_generator.h | 19 | ||||
-rw-r--r-- | compiler/optimizing/code_generator_arm.cc | 6 | ||||
-rw-r--r-- | compiler/optimizing/code_generator_arm.h | 17 | ||||
-rw-r--r-- | compiler/optimizing/code_generator_arm64.cc | 8 | ||||
-rw-r--r-- | compiler/optimizing/code_generator_arm64.h | 19 | ||||
-rw-r--r-- | compiler/optimizing/code_generator_x86.cc | 8 | ||||
-rw-r--r-- | compiler/optimizing/code_generator_x86.h | 19 | ||||
-rw-r--r-- | compiler/optimizing/code_generator_x86_64.cc | 8 | ||||
-rw-r--r-- | compiler/optimizing/code_generator_x86_64.h | 19 | ||||
-rw-r--r-- | compiler/optimizing/intrinsics_arm.cc | 2 | ||||
-rw-r--r-- | compiler/optimizing/intrinsics_arm64.cc | 2 | ||||
-rw-r--r-- | compiler/optimizing/intrinsics_x86.cc | 2 | ||||
-rw-r--r-- | compiler/optimizing/intrinsics_x86_64.cc | 2 |
13 files changed, 66 insertions, 65 deletions
diff --git a/compiler/optimizing/code_generator.h b/compiler/optimizing/code_generator.h index 6342f91684..beaff5cc4c 100644 --- a/compiler/optimizing/code_generator.h +++ b/compiler/optimizing/code_generator.h @@ -105,6 +105,25 @@ class SlowPathCode : public ArenaObject<kArenaAllocSlowPaths> { DISALLOW_COPY_AND_ASSIGN(SlowPathCode); }; +class InvokeDexCallingConventionVisitor { + public: + virtual Location GetNextLocation(Primitive::Type type) = 0; + + protected: + InvokeDexCallingConventionVisitor() {} + virtual ~InvokeDexCallingConventionVisitor() {} + + // The current index for core registers. + uint32_t gp_index_ = 0u; + // The current index for floating-point registers. + uint32_t float_index_ = 0u; + // The current stack index. + uint32_t stack_index_ = 0u; + + private: + DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConventionVisitor); +}; + class CodeGenerator { public: // Compiles the graph to executable instructions. Returns whether the compilation diff --git a/compiler/optimizing/code_generator_arm.cc b/compiler/optimizing/code_generator_arm.cc index 159bd30e45..e4c37deb8b 100644 --- a/compiler/optimizing/code_generator_arm.cc +++ b/compiler/optimizing/code_generator_arm.cc @@ -605,7 +605,7 @@ Location CodeGeneratorARM::GetStackLocation(HLoadLocal* load) const { UNREACHABLE(); } -Location InvokeDexCallingConventionVisitor::GetNextLocation(Primitive::Type type) { +Location InvokeDexCallingConventionVisitorARM::GetNextLocation(Primitive::Type type) { switch (type) { case Primitive::kPrimBoolean: case Primitive::kPrimByte: @@ -680,7 +680,7 @@ Location InvokeDexCallingConventionVisitor::GetNextLocation(Primitive::Type type return Location(); } -Location InvokeDexCallingConventionVisitor::GetReturnLocation(Primitive::Type type) { +Location InvokeDexCallingConventionVisitorARM::GetReturnLocation(Primitive::Type type) { switch (type) { case Primitive::kPrimBoolean: case Primitive::kPrimByte: @@ -1288,7 +1288,7 @@ void LocationsBuilderARM::HandleInvoke(HInvoke* invoke) { new (GetGraph()->GetArena()) LocationSummary(invoke, LocationSummary::kCall); locations->AddTemp(Location::RegisterLocation(R0)); - InvokeDexCallingConventionVisitor calling_convention_visitor; + InvokeDexCallingConventionVisitorARM calling_convention_visitor; for (size_t i = 0; i < invoke->GetNumberOfArguments(); i++) { HInstruction* input = invoke->InputAt(i); locations->SetInAt(i, calling_convention_visitor.GetNextLocation(input->GetType())); diff --git a/compiler/optimizing/code_generator_arm.h b/compiler/optimizing/code_generator_arm.h index 600903621d..1a498e1148 100644 --- a/compiler/optimizing/code_generator_arm.h +++ b/compiler/optimizing/code_generator_arm.h @@ -78,22 +78,19 @@ class InvokeDexCallingConvention : public CallingConvention<Register, SRegister> DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConvention); }; -class InvokeDexCallingConventionVisitor { +class InvokeDexCallingConventionVisitorARM : public InvokeDexCallingConventionVisitor { public: - InvokeDexCallingConventionVisitor() - : gp_index_(0), float_index_(0), double_index_(0), stack_index_(0) {} + InvokeDexCallingConventionVisitorARM() {} + virtual ~InvokeDexCallingConventionVisitorARM() {} - Location GetNextLocation(Primitive::Type type); + Location GetNextLocation(Primitive::Type type) OVERRIDE; Location GetReturnLocation(Primitive::Type type); private: InvokeDexCallingConvention calling_convention; - uint32_t gp_index_; - uint32_t float_index_; - uint32_t double_index_; - uint32_t stack_index_; + uint32_t double_index_ = 0; - DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConventionVisitor); + DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConventionVisitorARM); }; class ParallelMoveResolverARM : public ParallelMoveResolverWithSwap { @@ -151,7 +148,7 @@ class LocationsBuilderARM : public HGraphVisitor { void HandleFieldGet(HInstruction* instruction, const FieldInfo& field_info); CodeGeneratorARM* const codegen_; - InvokeDexCallingConventionVisitor parameter_visitor_; + InvokeDexCallingConventionVisitorARM parameter_visitor_; DISALLOW_COPY_AND_ASSIGN(LocationsBuilderARM); }; diff --git a/compiler/optimizing/code_generator_arm64.cc b/compiler/optimizing/code_generator_arm64.cc index 946ffc8ea8..9e02a1d850 100644 --- a/compiler/optimizing/code_generator_arm64.cc +++ b/compiler/optimizing/code_generator_arm64.cc @@ -372,15 +372,15 @@ class DeoptimizationSlowPathARM64 : public SlowPathCodeARM64 { #undef __ -Location InvokeDexCallingConventionVisitor::GetNextLocation(Primitive::Type type) { +Location InvokeDexCallingConventionVisitorARM64::GetNextLocation(Primitive::Type type) { Location next_location; if (type == Primitive::kPrimVoid) { LOG(FATAL) << "Unreachable type " << type; } if (Primitive::IsFloatingPointType(type) && - (fp_index_ < calling_convention.GetNumberOfFpuRegisters())) { - next_location = LocationFrom(calling_convention.GetFpuRegisterAt(fp_index_++)); + (float_index_ < calling_convention.GetNumberOfFpuRegisters())) { + next_location = LocationFrom(calling_convention.GetFpuRegisterAt(float_index_++)); } else if (!Primitive::IsFloatingPointType(type) && (gp_index_ < calling_convention.GetNumberOfRegisters())) { next_location = LocationFrom(calling_convention.GetRegisterAt(gp_index_++)); @@ -1907,7 +1907,7 @@ void LocationsBuilderARM64::HandleInvoke(HInvoke* invoke) { new (GetGraph()->GetArena()) LocationSummary(invoke, LocationSummary::kCall); locations->AddTemp(LocationFrom(x0)); - InvokeDexCallingConventionVisitor calling_convention_visitor; + InvokeDexCallingConventionVisitorARM64 calling_convention_visitor; for (size_t i = 0; i < invoke->GetNumberOfArguments(); i++) { HInstruction* input = invoke->InputAt(i); locations->SetInAt(i, calling_convention_visitor.GetNextLocation(input->GetType())); diff --git a/compiler/optimizing/code_generator_arm64.h b/compiler/optimizing/code_generator_arm64.h index 5a358671cc..8aeea5400f 100644 --- a/compiler/optimizing/code_generator_arm64.h +++ b/compiler/optimizing/code_generator_arm64.h @@ -119,25 +119,20 @@ class InvokeDexCallingConvention : public CallingConvention<vixl::Register, vixl DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConvention); }; -class InvokeDexCallingConventionVisitor { +class InvokeDexCallingConventionVisitorARM64 : public InvokeDexCallingConventionVisitor { public: - InvokeDexCallingConventionVisitor() : gp_index_(0), fp_index_(0), stack_index_(0) {} + InvokeDexCallingConventionVisitorARM64() {} + virtual ~InvokeDexCallingConventionVisitorARM64() {} - Location GetNextLocation(Primitive::Type type); + Location GetNextLocation(Primitive::Type type) OVERRIDE; Location GetReturnLocation(Primitive::Type return_type) { return calling_convention.GetReturnLocation(return_type); } private: InvokeDexCallingConvention calling_convention; - // The current index for core registers. - uint32_t gp_index_; - // The current index for floating-point registers. - uint32_t fp_index_; - // The current stack index. - uint32_t stack_index_; - - DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConventionVisitor); + + DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConventionVisitorARM64); }; class InstructionCodeGeneratorARM64 : public HGraphVisitor { @@ -193,7 +188,7 @@ class LocationsBuilderARM64 : public HGraphVisitor { void HandleShift(HBinaryOperation* instr); CodeGeneratorARM64* const codegen_; - InvokeDexCallingConventionVisitor parameter_visitor_; + InvokeDexCallingConventionVisitorARM64 parameter_visitor_; DISALLOW_COPY_AND_ASSIGN(LocationsBuilderARM64); }; diff --git a/compiler/optimizing/code_generator_x86.cc b/compiler/optimizing/code_generator_x86.cc index 7df4b53cbe..5ee091f92c 100644 --- a/compiler/optimizing/code_generator_x86.cc +++ b/compiler/optimizing/code_generator_x86.cc @@ -551,7 +551,7 @@ Location CodeGeneratorX86::GetStackLocation(HLoadLocal* load) const { UNREACHABLE(); } -Location InvokeDexCallingConventionVisitor::GetNextLocation(Primitive::Type type) { +Location InvokeDexCallingConventionVisitorX86::GetNextLocation(Primitive::Type type) { switch (type) { case Primitive::kPrimBoolean: case Primitive::kPrimByte: @@ -582,7 +582,7 @@ Location InvokeDexCallingConventionVisitor::GetNextLocation(Primitive::Type type } case Primitive::kPrimFloat: { - uint32_t index = fp_index_++; + uint32_t index = float_index_++; stack_index_++; if (index < calling_convention.GetNumberOfFpuRegisters()) { return Location::FpuRegisterLocation(calling_convention.GetFpuRegisterAt(index)); @@ -592,7 +592,7 @@ Location InvokeDexCallingConventionVisitor::GetNextLocation(Primitive::Type type } case Primitive::kPrimDouble: { - uint32_t index = fp_index_++; + uint32_t index = float_index_++; stack_index_ += 2; if (index < calling_convention.GetNumberOfFpuRegisters()) { return Location::FpuRegisterLocation(calling_convention.GetFpuRegisterAt(index)); @@ -1238,7 +1238,7 @@ void LocationsBuilderX86::HandleInvoke(HInvoke* invoke) { new (GetGraph()->GetArena()) LocationSummary(invoke, LocationSummary::kCall); locations->AddTemp(Location::RegisterLocation(EAX)); - InvokeDexCallingConventionVisitor calling_convention_visitor; + InvokeDexCallingConventionVisitorX86 calling_convention_visitor; for (size_t i = 0; i < invoke->GetNumberOfArguments(); i++) { HInstruction* input = invoke->InputAt(i); locations->SetInAt(i, calling_convention_visitor.GetNextLocation(input->GetType())); diff --git a/compiler/optimizing/code_generator_x86.h b/compiler/optimizing/code_generator_x86.h index 8bd3cd3585..79dec7a1ac 100644 --- a/compiler/optimizing/code_generator_x86.h +++ b/compiler/optimizing/code_generator_x86.h @@ -75,22 +75,17 @@ class InvokeDexCallingConvention : public CallingConvention<Register, XmmRegiste DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConvention); }; -class InvokeDexCallingConventionVisitor { +class InvokeDexCallingConventionVisitorX86 : public InvokeDexCallingConventionVisitor { public: - InvokeDexCallingConventionVisitor() : gp_index_(0), fp_index_(0), stack_index_(0) {} + InvokeDexCallingConventionVisitorX86() {} + virtual ~InvokeDexCallingConventionVisitorX86() {} - Location GetNextLocation(Primitive::Type type); + Location GetNextLocation(Primitive::Type type) OVERRIDE; private: InvokeDexCallingConvention calling_convention; - // The current index for cpu registers. - uint32_t gp_index_; - // The current index for fpu registers. - uint32_t fp_index_; - // The current stack index. - uint32_t stack_index_; - - DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConventionVisitor); + + DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConventionVisitorX86); }; class ParallelMoveResolverX86 : public ParallelMoveResolverWithSwap { @@ -137,7 +132,7 @@ class LocationsBuilderX86 : public HGraphVisitor { void HandleFieldGet(HInstruction* instruction, const FieldInfo& field_info); CodeGeneratorX86* const codegen_; - InvokeDexCallingConventionVisitor parameter_visitor_; + InvokeDexCallingConventionVisitorX86 parameter_visitor_; DISALLOW_COPY_AND_ASSIGN(LocationsBuilderX86); }; diff --git a/compiler/optimizing/code_generator_x86_64.cc b/compiler/optimizing/code_generator_x86_64.cc index 37b00c8d52..5ac68668ba 100644 --- a/compiler/optimizing/code_generator_x86_64.cc +++ b/compiler/optimizing/code_generator_x86_64.cc @@ -1240,7 +1240,7 @@ void InstructionCodeGeneratorX86_64::VisitReturn(HReturn* ret) { codegen_->GenerateFrameExit(); } -Location InvokeDexCallingConventionVisitor::GetNextLocation(Primitive::Type type) { +Location InvokeDexCallingConventionVisitorX86_64::GetNextLocation(Primitive::Type type) { switch (type) { case Primitive::kPrimBoolean: case Primitive::kPrimByte: @@ -1270,7 +1270,7 @@ Location InvokeDexCallingConventionVisitor::GetNextLocation(Primitive::Type type } case Primitive::kPrimFloat: { - uint32_t index = fp_index_++; + uint32_t index = float_index_++; stack_index_++; if (index < calling_convention.GetNumberOfFpuRegisters()) { return Location::FpuRegisterLocation(calling_convention.GetFpuRegisterAt(index)); @@ -1280,7 +1280,7 @@ Location InvokeDexCallingConventionVisitor::GetNextLocation(Primitive::Type type } case Primitive::kPrimDouble: { - uint32_t index = fp_index_++; + uint32_t index = float_index_++; stack_index_ += 2; if (index < calling_convention.GetNumberOfFpuRegisters()) { return Location::FpuRegisterLocation(calling_convention.GetFpuRegisterAt(index)); @@ -1338,7 +1338,7 @@ void LocationsBuilderX86_64::HandleInvoke(HInvoke* invoke) { new (GetGraph()->GetArena()) LocationSummary(invoke, LocationSummary::kCall); locations->AddTemp(Location::RegisterLocation(RDI)); - InvokeDexCallingConventionVisitor calling_convention_visitor; + InvokeDexCallingConventionVisitorX86_64 calling_convention_visitor; for (size_t i = 0; i < invoke->GetNumberOfArguments(); i++) { HInstruction* input = invoke->InputAt(i); locations->SetInAt(i, calling_convention_visitor.GetNextLocation(input->GetType())); diff --git a/compiler/optimizing/code_generator_x86_64.h b/compiler/optimizing/code_generator_x86_64.h index e3fd5d7ec1..13f9c46b5e 100644 --- a/compiler/optimizing/code_generator_x86_64.h +++ b/compiler/optimizing/code_generator_x86_64.h @@ -68,22 +68,17 @@ class InvokeDexCallingConvention : public CallingConvention<Register, FloatRegis DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConvention); }; -class InvokeDexCallingConventionVisitor { +class InvokeDexCallingConventionVisitorX86_64 : public InvokeDexCallingConventionVisitor { public: - InvokeDexCallingConventionVisitor() : gp_index_(0), fp_index_(0), stack_index_(0) {} + InvokeDexCallingConventionVisitorX86_64() {} + virtual ~InvokeDexCallingConventionVisitorX86_64() {} - Location GetNextLocation(Primitive::Type type); + Location GetNextLocation(Primitive::Type type) OVERRIDE; private: InvokeDexCallingConvention calling_convention; - // The current index for cpu registers. - uint32_t gp_index_; - // The current index for fpu registers. - uint32_t fp_index_; - // The current stack index. - uint32_t stack_index_; - - DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConventionVisitor); + + DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConventionVisitorX86_64); }; class CodeGeneratorX86_64; @@ -147,7 +142,7 @@ class LocationsBuilderX86_64 : public HGraphVisitor { void HandleFieldGet(HInstruction* instruction); CodeGeneratorX86_64* const codegen_; - InvokeDexCallingConventionVisitor parameter_visitor_; + InvokeDexCallingConventionVisitorX86_64 parameter_visitor_; DISALLOW_COPY_AND_ASSIGN(LocationsBuilderX86_64); }; diff --git a/compiler/optimizing/intrinsics_arm.cc b/compiler/optimizing/intrinsics_arm.cc index e3fa272d22..259d554dbe 100644 --- a/compiler/optimizing/intrinsics_arm.cc +++ b/compiler/optimizing/intrinsics_arm.cc @@ -84,7 +84,7 @@ static void MoveArguments(HInvoke* invoke, ArenaAllocator* arena, CodeGeneratorA } LocationSummary* locations = invoke->GetLocations(); - InvokeDexCallingConventionVisitor calling_convention_visitor; + InvokeDexCallingConventionVisitorARM calling_convention_visitor; // We're moving potentially two or more locations to locations that could overlap, so we need // a parallel move resolver. diff --git a/compiler/optimizing/intrinsics_arm64.cc b/compiler/optimizing/intrinsics_arm64.cc index d71b49e6f1..9cfa78219d 100644 --- a/compiler/optimizing/intrinsics_arm64.cc +++ b/compiler/optimizing/intrinsics_arm64.cc @@ -93,7 +93,7 @@ static void MoveArguments(HInvoke* invoke, ArenaAllocator* arena, CodeGeneratorA } LocationSummary* locations = invoke->GetLocations(); - InvokeDexCallingConventionVisitor calling_convention_visitor; + InvokeDexCallingConventionVisitorARM64 calling_convention_visitor; // We're moving potentially two or more locations to locations that could overlap, so we need // a parallel move resolver. diff --git a/compiler/optimizing/intrinsics_x86.cc b/compiler/optimizing/intrinsics_x86.cc index 18fb3c4d43..62cf3eb0e5 100644 --- a/compiler/optimizing/intrinsics_x86.cc +++ b/compiler/optimizing/intrinsics_x86.cc @@ -118,7 +118,7 @@ static void MoveArguments(HInvoke* invoke, ArenaAllocator* arena, CodeGeneratorX } LocationSummary* locations = invoke->GetLocations(); - InvokeDexCallingConventionVisitor calling_convention_visitor; + InvokeDexCallingConventionVisitorX86 calling_convention_visitor; // We're moving potentially two or more locations to locations that could overlap, so we need // a parallel move resolver. diff --git a/compiler/optimizing/intrinsics_x86_64.cc b/compiler/optimizing/intrinsics_x86_64.cc index db7b58bc66..7e24dca99a 100644 --- a/compiler/optimizing/intrinsics_x86_64.cc +++ b/compiler/optimizing/intrinsics_x86_64.cc @@ -110,7 +110,7 @@ static void MoveArguments(HInvoke* invoke, ArenaAllocator* arena, CodeGeneratorX } LocationSummary* locations = invoke->GetLocations(); - InvokeDexCallingConventionVisitor calling_convention_visitor; + InvokeDexCallingConventionVisitorX86_64 calling_convention_visitor; // We're moving potentially two or more locations to locations that could overlap, so we need // a parallel move resolver. |