12#define Reg(index) (static_cast<Register>(index))
13#define Fpu(index) (static_cast<FpuRegister>(index))
15#define ReqReg Location::RequiresRegister()
16#define ReqFpu Location::RequiresFpuRegister()
17#define RegLoc(index) Location::RegisterLocation(Reg(index))
18#define FpuLoc(index) Location::FpuRegisterLocation(Fpu(index))
46 for (intptr_t
i = 0;
i < expected_inputs->
length();
i++) {
50 for (intptr_t
i = 0;
i < expected_temps->
length();
i++) {
60 for (intptr_t
i = 0;
i < expected_inputs->
length();
i++) {
63 for (intptr_t
i = 0;
i < expected_temps->
length();
i++) {
73 if (locs_ ==
nullptr) {
86#define INSTRUCTION_TEST(Name, Arity, Signature, ExpectedOut, ExpectedIn, \
87 ExpectedTemp, AllocatedOut, AllocatedIn, \
89 class Name##Instr : public MockInstruction { \
91 LocationSummary* MakeLocationSummary(Zone* zone, bool opt) const; \
92 void EmitNativeCode(FlowGraphCompiler* compiler); \
93 virtual intptr_t InputCount() const { \
97 TEST_CASE(LocationsHelpers_##Name) { \
98 const Location expected_out = ExpectedOut; \
99 const LocationArray* expected_inputs = MakeLocationArray ExpectedIn; \
100 const LocationArray* expected_temps = MakeLocationArray ExpectedTemp; \
102 const Location allocated_out = AllocatedOut; \
103 const LocationArray* allocated_inputs = MakeLocationArray AllocatedIn; \
104 const LocationArray* allocated_temps = MakeLocationArray AllocatedTemp; \
106 Name##Instr* instr = new Name##Instr(); \
107 LocationSummary* locs = instr->locs(); \
109 ValidateSummary(locs, expected_out, expected_inputs, expected_temps); \
110 FillSummary(locs, allocated_out, allocated_inputs, allocated_temps); \
112 instr->EmitNativeCode(nullptr); \
114 DEFINE_BACKEND(Name, Signature)
127 EXPECT_EQ(
Reg(1), in);
141 EXPECT_EQ(
Reg(1), in0);
142 EXPECT_EQ(
Fpu(2), in1);
156 EXPECT_EQ(
Fpu(1), in0);
157 EXPECT_EQ(
Reg(2), in1);
184 EXPECT_EQ(
Fpu(3),
Fpu(in));
197 EXPECT_EQ(
Reg(0), in0);
198 EXPECT_EQ(
Reg(1), in1);
216 EXPECT_EQ(
Reg(1), in0);
217 EXPECT_EQ(
Fpu(2), in1);
218 EXPECT_EQ(
Fpu(3),
Fpu(temp0));
219 EXPECT_EQ(
Reg(4),
Reg(temp1));
233 EXPECT_EQ(
Fpu(3),
Fpu(temp));
const T & At(intptr_t index) const
Location temp(intptr_t index) const
Location out(intptr_t index) const
intptr_t input_count() const
void set_temp(intptr_t index, Location loc)
intptr_t temp_count() const
void set_out(intptr_t index, Location loc)
Location in(intptr_t index) const
void set_in(intptr_t index, Location loc)
static Location SameAsFirstInput()
bool Equals(Location other) const
static Location RequiresFpuRegister()
virtual ~MockInstruction()
virtual void EmitNativeCode(FlowGraphCompiler *compiler)=0
virtual LocationSummary * MakeLocationSummary(Zone *zone, bool opt) const =0
static Thread * Current()
static void ValidateSummary(LocationSummary *locs, Location expected_output, const LocationArray *expected_inputs, const LocationArray *expected_temps)
static void FillSummary(LocationSummary *locs, Location expected_output, const LocationArray *expected_inputs, const LocationArray *expected_temps)
ZoneGrowableArray< Location > LocationArray
INSTRUCTION_TEST(Unary, 1,(Register out, Register in), ReqReg,(ReqReg),(), RegLoc(0),(RegLoc(1)),())
static LocationArray * MakeLocationArray()