blob: 85ada9d7f8d16501c401d6fcfd318624c9f9db72 [file] [log] [blame]
Ian Rogersbdb03912011-09-14 00:55:44 -07001// Copyright 2011 Google Inc. All Rights Reserved.
2
3#include "context_arm.h"
4
5#include "object.h"
6
7namespace art {
8namespace arm {
9
10ArmContext::ArmContext() {
Ian Rogers67375ac2011-09-14 00:55:44 -070011#ifndef NDEBUG
Ian Rogersbdb03912011-09-14 00:55:44 -070012 for (int i=0; i < 16; i++) {
Ian Rogers67375ac2011-09-14 00:55:44 -070013 gprs_[i] = 0xEBAD6070+i;
Ian Rogersbdb03912011-09-14 00:55:44 -070014 }
Ian Rogers67375ac2011-09-14 00:55:44 -070015#endif
Ian Rogersbdb03912011-09-14 00:55:44 -070016 memset(fprs_, 0, sizeof(fprs_));
17}
18
19void ArmContext::FillCalleeSaves(const Frame& fr) {
20 Method* method = fr.GetMethod();
21 uint32_t core_spills = method->GetCoreSpillMask();
22 size_t spill_count = __builtin_popcount(core_spills);
23 CHECK_EQ(method->GetFpSpillMask(), 0u);
24 if (spill_count > 0) {
25 // Lowest number spill is furthest away, walk registers and fill into context
26 int j = 1;
27 for(int i = 0; i < 16; i++) {
28 if (((core_spills >> i) & 1) != 0) {
29 gprs_[i] = fr.LoadCalleeSave(spill_count - j);
30 j++;
31 }
32 }
33 }
34}
35
36void ArmContext::DoLongJump() {
Elliott Hughes85d15452011-09-16 17:33:01 -070037#if defined(__arm__)
Ian Rogersbdb03912011-09-14 00:55:44 -070038 // TODO: Load all GPRs and FPRs, currently the code restores registers R4 to PC
39 asm volatile ( "mov %%r0, %0\n"
40 "mov %%r1, %1\n"
41 "ldm %%r0, {%%r4, %%r5, %%r6, %%r7,%%r8,%%r9,%%r10,%%r11,%%r12,%%r13,%%r14}\n"
42 "mov %%pc,%%r1\n"
43 : // output
44 : "r"(&gprs_[4]), "r"(gprs_[R15]) // input
45#if 0 // TODO: FPRs..
46 "w0" (fprs_[0] ), "w1" (fprs_[1] ), "w2" (fprs_[2] ), "w3" (fprs_[3]),
47 "w4" (fprs_[4] ), "w5" (fprs_[5] ), "w6" (fprs_[6] ), "w7" (fprs_[7]),
48 "w8" (fprs_[8] ), "w9" (fprs_[9] ), "w10"(fprs_[10]), "w11"(fprs_[11]),
49 "w12"(fprs_[12]), "w13"(fprs_[13]), "w14"(fprs_[14]), "w15"(fprs_[15]),
50 "w16"(fprs_[16]), "w17"(fprs_[17]), "w18"(fprs_[18]), "w19"(fprs_[19]),
51 "w20"(fprs_[20]), "w21"(fprs_[21]), "w22"(fprs_[22]), "w23"(fprs_[23]),
52 "w24"(fprs_[24]), "w25"(fprs_[25]), "w26"(fprs_[26]), "w27"(fprs_[27]),
53 "w28"(fprs_[28]), "w29"(fprs_[29]), "w30"(fprs_[30]), "w31"(fprs_[31])
54#endif
55 :); // clobber
Elliott Hughes85d15452011-09-16 17:33:01 -070056#else
57 UNIMPLEMENTED(FATAL);
58#endif
Ian Rogersbdb03912011-09-14 00:55:44 -070059}
60
61} // namespace arm
62} // namespace art