1818#include " hphp/runtime/vm/jit/relocation.h"
1919#include " hphp/util/arch.h"
2020#include " hphp/util/data-block.h"
21- #include " hphp/vixl/a64/macro-assembler-a64 .h"
21+ #include " hphp/vixl/hphp-compat .h"
2222
2323#include < gtest/gtest.h>
2424
@@ -89,30 +89,30 @@ TEST(Relocation, RelocateBccImm2MovzMovkBccReg) {
8989 // 3. Call relocate()
9090 RelocationInfo rel;
9191 AreaIndex ai = AreaIndex::Main;
92- auto instr = Instruction::Cast (end);
92+ const Instruction* instr = Instruction::Cast (end);
9393 relocate (rel, main, start, end, main, meta, nullptr , ai);
9494
9595 // 4. Expect !b.cc, movz/movk X and br X where with imm in X
9696 auto bcc = instr;
9797 EXPECT_TRUE (bcc->IsCondBranchImm ());
9898 EXPECT_EQ (bcc->ConditionBranch (), InvertCondition (cond));
9999
100- auto movz = bcc->NextInstruction ();
100+ auto movz = bcc->GetNextInstruction ();
101101 EXPECT_TRUE (movz->IsMovz ());
102102 const auto rd = movz->Rd ();
103- uint64_t target = movz->ImmMoveWide () << (16 * movz->ShiftMoveWide ());
104- instr = movz->NextInstruction ();
103+ uint64_t target = ( uint64_t ) movz->ImmMoveWide () << (16 * movz->ShiftMoveWide ());
104+ instr = movz->GetNextInstruction ();
105105 while (instr->IsMovk ()) {
106106 EXPECT_EQ (instr->Rd (), rd);
107- target |= instr->ImmMoveWide () << (16 * instr->ShiftMoveWide ());
108- instr = instr->NextInstruction ();
107+ target |= ( uint64_t ) instr->ImmMoveWide () << (16 * instr->ShiftMoveWide ());
108+ instr = instr->GetNextInstruction ();
109109 }
110110 EXPECT_EQ (Instruction::Cast (target), bccOrig->ImmPCOffsetTarget ());
111111
112112 auto br = instr;
113113 EXPECT_TRUE (br->IsUncondBranchReg ());
114114 EXPECT_EQ (br->Rn (), rd);
115- EXPECT_EQ (bcc->ImmPCOffsetTarget (), br->NextInstruction ());
115+ EXPECT_EQ (bcc->ImmPCOffsetTarget (), br->GetNextInstruction ());
116116}
117117
118118/*
@@ -153,7 +153,7 @@ TEST(Relocation, RelocateCbz2MovzMovkCbnzReg) {
153153 // 3. Call relocate()
154154 RelocationInfo rel;
155155 AreaIndex ai = AreaIndex::Main;
156- auto instr = Instruction::Cast (end);
156+ const Instruction* instr = Instruction::Cast (end);
157157 relocate (rel, main, start, end, main, meta, nullptr , ai);
158158
159159 // 4. Expect cbnz, movz/movk X and br X where with imm in X
@@ -162,22 +162,22 @@ TEST(Relocation, RelocateCbz2MovzMovkCbnzReg) {
162162 const auto rt = cbnz->Rt ();
163163 EXPECT_EQ (cbzOrig->Rt (), rt);
164164
165- auto movz = cbnz->NextInstruction ();
165+ auto movz = cbnz->GetNextInstruction ();
166166 EXPECT_TRUE (movz->IsMovz ());
167167 const auto rd = movz->Rd ();
168- uint64_t target = movz->ImmMoveWide () << (16 * movz->ShiftMoveWide ());
169- instr = movz->NextInstruction ();
168+ uint64_t target = ( uint64_t ) movz->ImmMoveWide () << (16 * movz->ShiftMoveWide ());
169+ instr = movz->GetNextInstruction ();
170170 while (instr->IsMovk ()) {
171171 EXPECT_EQ (instr->Rd (), rd);
172- target |= instr->ImmMoveWide () << (16 * instr->ShiftMoveWide ());
173- instr = instr->NextInstruction ();
172+ target |= ( uint64_t ) instr->ImmMoveWide () << (16 * instr->ShiftMoveWide ());
173+ instr = instr->GetNextInstruction ();
174174 }
175175 EXPECT_EQ (Instruction::Cast (target), cbzOrig->ImmPCOffsetTarget ());
176176
177177 auto br = instr;
178178 EXPECT_TRUE (br->IsUncondBranchReg ());
179179 EXPECT_EQ (br->Rn (), rd);
180- EXPECT_EQ (cbnz->ImmPCOffsetTarget (), br->NextInstruction ());
180+ EXPECT_EQ (cbnz->ImmPCOffsetTarget (), br->GetNextInstruction ());
181181}
182182
183183/*
@@ -218,7 +218,7 @@ TEST(Relocation, RelocateTbz2MovzMovkTbnzReg) {
218218 // 3. Call relocate()
219219 RelocationInfo rel;
220220 AreaIndex ai = AreaIndex::Main;
221- auto instr = Instruction::Cast (end);
221+ const Instruction* instr = Instruction::Cast (end);
222222 relocate (rel, main, start, end, main, meta, nullptr , ai);
223223
224224 // 4. Expect tbnz, movz/movk X and br X where with imm in X
@@ -229,22 +229,22 @@ TEST(Relocation, RelocateTbz2MovzMovkTbnzReg) {
229229 const auto bit_pos = tbnz->ImmTestBranchBit40 ();
230230 EXPECT_EQ (bit_pos, 3 );
231231
232- auto movz = tbnz->NextInstruction ();
232+ auto movz = tbnz->GetNextInstruction ();
233233 EXPECT_TRUE (movz->IsMovz ());
234234 const auto rd = movz->Rd ();
235- uint64_t target = movz->ImmMoveWide () << (16 * movz->ShiftMoveWide ());
236- instr = movz->NextInstruction ();
235+ uint64_t target = ( uint64_t ) movz->ImmMoveWide () << (16 * movz->ShiftMoveWide ());
236+ instr = movz->GetNextInstruction ();
237237 while (instr->IsMovk ()) {
238238 EXPECT_EQ (instr->Rd (), rd);
239- target |= instr->ImmMoveWide () << (16 * instr->ShiftMoveWide ());
240- instr = instr->NextInstruction ();
239+ target |= ( uint64_t ) instr->ImmMoveWide () << (16 * instr->ShiftMoveWide ());
240+ instr = instr->GetNextInstruction ();
241241 }
242242 EXPECT_EQ (Instruction::Cast (target), tbzOrig->ImmPCOffsetTarget ());
243243
244244 auto br = instr;
245245 EXPECT_TRUE (br->IsUncondBranchReg ());
246246 EXPECT_EQ (br->Rn (), rd);
247- EXPECT_EQ (tbnz->ImmPCOffsetTarget (), br->NextInstruction ());
247+ EXPECT_EQ (tbnz->ImmPCOffsetTarget (), br->GetNextInstruction ());
248248}
249249
250250/*
@@ -275,7 +275,7 @@ TEST(Relocation, RelocateMovzMovkLdr2LdrLiteral) {
275275 // with this test.
276276 a.dc64 (0xdeadbeef );
277277 meta.addressImmediates .insert (main.frontier ());
278- a.Mov (x17, start + 4 );
278+ a.Mov (x17, reinterpret_cast < uint64_t >( start + 4 ) );
279279
280280 a.Ldr (x0, MemOperand (x17, 0 ));
281281
@@ -284,13 +284,13 @@ TEST(Relocation, RelocateMovzMovkLdr2LdrLiteral) {
284284 // 3. Call relocate()
285285 RelocationInfo rel;
286286 AreaIndex ai = AreaIndex::Main;
287- auto instr = Instruction::Cast (end + 8 );
287+ const Instruction* instr = Instruction::Cast (end + 8 );
288288 relocate (rel, main, start, end, main, meta, nullptr , ai);
289289
290290 // 4. Expect a Ldr Literal to $x0 from addr
291291 EXPECT_TRUE (instr->IsLoadLiteral ());
292292 EXPECT_EQ (instr->Rd (), 0 );
293- EXPECT_EQ (reinterpret_cast <TCA >(instr->LiteralAddress ()), end);
293+ EXPECT_EQ (reinterpret_cast <TCA >(instr->GetLiteralAddress < uint8_t *> ()), end);
294294}
295295
296296/*
@@ -317,26 +317,26 @@ TEST(Relocation, RelocateAdjustedMovzMovk) {
317317 main.setFrontier (start + (2 << 20 ) + 16 );
318318 MacroAssembler a { main };
319319 meta.addressImmediates .insert (main.frontier ());
320- a.Mov (x17, start + 8 );
320+ a.Mov (x17, reinterpret_cast < uint64_t >( start + 8 ) );
321321
322322 auto end = main.frontier ();
323323
324324 // 3. Call relocate()
325325 RelocationInfo rel;
326326 AreaIndex ai = AreaIndex::Main;
327- auto instr = Instruction::Cast (end);
327+ const Instruction* instr = Instruction::Cast (end);
328328 relocate (rel, main, start, end, main, meta, nullptr , ai);
329329
330330 // 4. Expect movz/movk of new target
331331 auto movz = instr + (2 << 20 ) + 16 ;
332332 EXPECT_TRUE (movz->IsMovz ());
333333 EXPECT_EQ (movz->Rd (), 17 );
334- uint64_t target = movz->ImmMoveWide () << (16 * movz->ShiftMoveWide ());
335- instr = movz->NextInstruction ();
334+ uint64_t target = ( uint64_t ) movz->ImmMoveWide () << (16 * movz->ShiftMoveWide ());
335+ instr = movz->GetNextInstruction ();
336336 while (instr->IsMovk ()) {
337337 EXPECT_EQ (instr->Rd (), 17 );
338- target |= instr->ImmMoveWide () << (16 * instr->ShiftMoveWide ());
339- instr = instr->NextInstruction ();
338+ target |= ( uint64_t ) instr->ImmMoveWide () << (16 * instr->ShiftMoveWide ());
339+ instr = instr->GetNextInstruction ();
340340 }
341341 EXPECT_EQ (Instruction::Cast (target), Instruction::Cast (end + 8 ));
342342}
@@ -367,27 +367,27 @@ TEST(Relocation, RelocateInternalAdjustedMovzMovk) {
367367
368368 MacroAssembler a { main };
369369 meta.addressImmediates .insert (main.frontier ());
370- a.Mov (x17, start + (2 << 20 ) + 16 );
370+ a.Mov (x17, reinterpret_cast < uint64_t >( start + (2 << 20 ) + 16 ) );
371371 main.setFrontier (start + (4 << 20 ) + 32 );
372372
373373 auto end = main.frontier ();
374374
375375 // 3. Call relocate()
376376 RelocationInfo rel;
377377 AreaIndex ai = AreaIndex::Main;
378- auto instr = Instruction::Cast (end);
378+ const Instruction* instr = Instruction::Cast (end);
379379 relocate (rel, main, start, end, main, meta, nullptr , ai);
380380
381381 // 4. Expect movz/movk of new target
382382 auto movz = instr;
383383 EXPECT_TRUE (movz->IsMovz ());
384384 EXPECT_EQ (movz->Rd (), 17 );
385- uint64_t target = movz->ImmMoveWide () << (16 * movz->ShiftMoveWide ());
386- instr = movz->NextInstruction ();
385+ uint64_t target = ( uint64_t ) movz->ImmMoveWide () << (16 * movz->ShiftMoveWide ());
386+ instr = movz->GetNextInstruction ();
387387 while (instr->IsMovk ()) {
388388 EXPECT_EQ (instr->Rd (), 17 );
389- target |= instr->ImmMoveWide () << (16 * instr->ShiftMoveWide ());
390- instr = instr->NextInstruction ();
389+ target |= ( uint64_t ) instr->ImmMoveWide () << (16 * instr->ShiftMoveWide ());
390+ instr = instr->GetNextInstruction ();
391391 }
392392 EXPECT_EQ (Instruction::Cast (target), Instruction::Cast (end + (2 << 20 ) + 16 ));
393393}
@@ -416,7 +416,7 @@ TEST(Relocation, AdjustMovzMovk) {
416416
417417 MacroAssembler a { main };
418418 meta.addressImmediates .insert (main.frontier ());
419- a.Mov (x17, orig + (2 << 20 ) + 16 );
419+ a.Mov (x17, reinterpret_cast < uint64_t >( orig + (2 << 20 ) + 16 ) );
420420 main.setFrontier (orig + (2 << 20 ) + 16 );
421421
422422 auto start = main.frontier ();
@@ -433,12 +433,12 @@ TEST(Relocation, AdjustMovzMovk) {
433433 auto movz = Instruction::Cast (orig);
434434 EXPECT_TRUE (movz->IsMovz ());
435435 EXPECT_EQ (movz->Rd (), 17 );
436- uint64_t target = movz->ImmMoveWide () << (16 * movz->ShiftMoveWide ());
437- auto instr = movz->NextInstruction ();
436+ uint64_t target = ( uint64_t ) movz->ImmMoveWide () << (16 * movz->ShiftMoveWide ());
437+ auto instr = movz->GetNextInstruction ();
438438 while (instr->IsMovk ()) {
439439 EXPECT_EQ (instr->Rd (), 17 );
440- target |= instr->ImmMoveWide () << (16 * instr->ShiftMoveWide ());
441- instr = instr->NextInstruction ();
440+ target |= ( uint64_t ) instr->ImmMoveWide () << (16 * instr->ShiftMoveWide ());
441+ instr = instr->GetNextInstruction ();
442442 }
443443 EXPECT_EQ (Instruction::Cast (target), Instruction::Cast (end));
444444}
0 commit comments