@@ -364,13 +364,8 @@ void Assembler::mls(Register rd,
364364 Register ra,
365365 Condition cond) {
366366 // rd <- ra - rn * rm.
367- if (TargetCPUFeatures::arm_version () == ARMv7) {
368- // Assembler registers rd, rn, rm, ra are encoded as rn, rm, rs, rd.
369- EmitMulOp (cond, B22 | B21, ra, rd, rn, rm);
370- } else {
371- mul (IP, rn, rm, cond);
372- sub (rd, ra, Operand (IP), cond);
373- }
367+ // Assembler registers rd, rn, rm, ra are encoded as rn, rm, rs, rd.
368+ EmitMulOp (cond, B22 | B21, ra, rd, rn, rm);
374369}
375370
376371void Assembler::smull (Register rd_lo,
@@ -978,9 +973,6 @@ void Assembler::vmovd(DRegister dd, DRegister dm, Condition cond) {
978973}
979974
980975bool Assembler::vmovs (SRegister sd, float s_imm, Condition cond) {
981- if (TargetCPUFeatures::arm_version () != ARMv7) {
982- return false ;
983- }
984976 uint32_t imm32 = bit_cast<uint32_t , float >(s_imm);
985977 if (((imm32 & ((1 << 19 ) - 1 )) == 0 ) &&
986978 ((((imm32 >> 25 ) & ((1 << 6 ) - 1 )) == (1 << 5 )) ||
@@ -995,9 +987,6 @@ bool Assembler::vmovs(SRegister sd, float s_imm, Condition cond) {
995987}
996988
997989bool Assembler::vmovd (DRegister dd, double d_imm, Condition cond) {
998- if (TargetCPUFeatures::arm_version () != ARMv7) {
999- return false ;
1000- }
1001990 uint64_t imm64 = bit_cast<uint64_t , double >(d_imm);
1002991 if (((imm64 & ((1LL << 48 ) - 1 )) == 0 ) &&
1003992 ((((imm64 >> 54 ) & ((1 << 9 ) - 1 )) == (1 << 8 )) ||
@@ -2074,69 +2063,15 @@ static int32_t DecodeARMv7LoadImmediate(int32_t movt, int32_t movw) {
20742063 return offset;
20752064}
20762065
2077- static int32_t DecodeARMv6LoadImmediate (int32_t mov,
2078- int32_t or1,
2079- int32_t or2,
2080- int32_t or3) {
2081- int32_t offset = 0 ;
2082- offset |= (mov & 0xff ) << 24 ;
2083- offset |= (or1 & 0xff ) << 16 ;
2084- offset |= (or2 & 0xff ) << 8 ;
2085- offset |= (or3 & 0xff );
2086- return offset;
2087- }
2088-
20892066class PatchFarBranch : public AssemblerFixup {
20902067 public:
20912068 PatchFarBranch () {}
20922069
20932070 void Process (const MemoryRegion& region, intptr_t position) {
2094- const ARMVersion version = TargetCPUFeatures::arm_version ();
2095- if (version == ARMv6) {
2096- ProcessARMv6 (region, position);
2097- } else {
2098- ASSERT (version == ARMv7);
2099- ProcessARMv7 (region, position);
2100- }
2071+ ProcessARMv7 (region, position);
21012072 }
21022073
21032074 private:
2104- void ProcessARMv6 (const MemoryRegion& region, intptr_t position) {
2105- const int32_t mov = region.Load <int32_t >(position);
2106- const int32_t or1 = region.Load <int32_t >(position + 1 * Instr::kInstrSize );
2107- const int32_t or2 = region.Load <int32_t >(position + 2 * Instr::kInstrSize );
2108- const int32_t or3 = region.Load <int32_t >(position + 3 * Instr::kInstrSize );
2109- const int32_t bx = region.Load <int32_t >(position + 4 * Instr::kInstrSize );
2110-
2111- if (((mov & 0xffffff00 ) == 0xe3a0c400 ) && // mov IP, (byte3 rot 4)
2112- ((or1 & 0xffffff00 ) == 0xe38cc800 ) && // orr IP, IP, (byte2 rot 8)
2113- ((or2 & 0xffffff00 ) == 0xe38ccc00 ) && // orr IP, IP, (byte1 rot 12)
2114- ((or3 & 0xffffff00 ) == 0xe38cc000 )) { // orr IP, IP, byte0
2115- const int32_t offset = DecodeARMv6LoadImmediate (mov, or1, or2, or3);
2116- const int32_t dest = region.start () + offset;
2117- const int32_t dest0 = (dest & 0x000000ff );
2118- const int32_t dest1 = (dest & 0x0000ff00 ) >> 8 ;
2119- const int32_t dest2 = (dest & 0x00ff0000 ) >> 16 ;
2120- const int32_t dest3 = (dest & 0xff000000 ) >> 24 ;
2121- const int32_t patched_mov = 0xe3a0c400 | dest3;
2122- const int32_t patched_or1 = 0xe38cc800 | dest2;
2123- const int32_t patched_or2 = 0xe38ccc00 | dest1;
2124- const int32_t patched_or3 = 0xe38cc000 | dest0;
2125-
2126- region.Store <int32_t >(position + 0 * Instr::kInstrSize , patched_mov);
2127- region.Store <int32_t >(position + 1 * Instr::kInstrSize , patched_or1);
2128- region.Store <int32_t >(position + 2 * Instr::kInstrSize , patched_or2);
2129- region.Store <int32_t >(position + 3 * Instr::kInstrSize , patched_or3);
2130- return ;
2131- }
2132-
2133- // If the offset loading instructions aren't there, we must have replaced
2134- // the far branch with a near one, and so these instructions
2135- // should be NOPs.
2136- ASSERT ((or1 == Instr::kNopInstruction ) && (or2 == Instr::kNopInstruction ) &&
2137- (or3 == Instr::kNopInstruction ) && (bx == Instr::kNopInstruction ));
2138- }
2139-
21402075 void ProcessARMv7 (const MemoryRegion& region, intptr_t position) {
21412076 const int32_t movw = region.Load <int32_t >(position);
21422077 const int32_t movt = region.Load <int32_t >(position + Instr::kInstrSize );
@@ -2198,85 +2133,6 @@ void Assembler::EmitBranch(Condition cond, Label* label, bool link) {
21982133 }
21992134}
22002135
2201- void Assembler::BindARMv6 (Label* label) {
2202- ASSERT (!label->IsBound ());
2203- intptr_t bound_pc = buffer_.Size ();
2204- while (label->IsLinked ()) {
2205- const int32_t position = label->Position ();
2206- int32_t dest = bound_pc - position;
2207- if (use_far_branches () && !CanEncodeBranchDistance (dest)) {
2208- // Far branches are enabled and we can't encode the branch offset.
2209-
2210- // Grab instructions that load the offset.
2211- const int32_t mov = buffer_.Load <int32_t >(position);
2212- const int32_t or1 =
2213- buffer_.Load <int32_t >(position + 1 * Instr::kInstrSize );
2214- const int32_t or2 =
2215- buffer_.Load <int32_t >(position + 2 * Instr::kInstrSize );
2216- const int32_t or3 =
2217- buffer_.Load <int32_t >(position + 3 * Instr::kInstrSize );
2218-
2219- // Change from relative to the branch to relative to the assembler
2220- // buffer.
2221- dest = buffer_.Size ();
2222- const int32_t dest0 = (dest & 0x000000ff );
2223- const int32_t dest1 = (dest & 0x0000ff00 ) >> 8 ;
2224- const int32_t dest2 = (dest & 0x00ff0000 ) >> 16 ;
2225- const int32_t dest3 = (dest & 0xff000000 ) >> 24 ;
2226- const int32_t patched_mov = 0xe3a0c400 | dest3;
2227- const int32_t patched_or1 = 0xe38cc800 | dest2;
2228- const int32_t patched_or2 = 0xe38ccc00 | dest1;
2229- const int32_t patched_or3 = 0xe38cc000 | dest0;
2230-
2231- // Rewrite the instructions.
2232- buffer_.Store <int32_t >(position + 0 * Instr::kInstrSize , patched_mov);
2233- buffer_.Store <int32_t >(position + 1 * Instr::kInstrSize , patched_or1);
2234- buffer_.Store <int32_t >(position + 2 * Instr::kInstrSize , patched_or2);
2235- buffer_.Store <int32_t >(position + 3 * Instr::kInstrSize , patched_or3);
2236- label->position_ = DecodeARMv6LoadImmediate (mov, or1, or2, or3);
2237- } else if (use_far_branches () && CanEncodeBranchDistance (dest)) {
2238- // Grab instructions that load the offset, and the branch.
2239- const int32_t mov = buffer_.Load <int32_t >(position);
2240- const int32_t or1 =
2241- buffer_.Load <int32_t >(position + 1 * Instr::kInstrSize );
2242- const int32_t or2 =
2243- buffer_.Load <int32_t >(position + 2 * Instr::kInstrSize );
2244- const int32_t or3 =
2245- buffer_.Load <int32_t >(position + 3 * Instr::kInstrSize );
2246- const int32_t branch =
2247- buffer_.Load <int32_t >(position + 4 * Instr::kInstrSize );
2248-
2249- // Grab the branch condition, and encode the link bit.
2250- const int32_t cond = branch & 0xf0000000 ;
2251- const int32_t link = (branch & 0x20 ) << 19 ;
2252-
2253- // Encode the branch and the offset.
2254- const int32_t new_branch = cond | link | 0x0a000000 ;
2255- const int32_t encoded = EncodeBranchOffset (dest, new_branch);
2256-
2257- // Write the encoded branch instruction followed by two nops.
2258- buffer_.Store <int32_t >(position, encoded);
2259- buffer_.Store <int32_t >(position + 1 * Instr::kInstrSize ,
2260- Instr::kNopInstruction );
2261- buffer_.Store <int32_t >(position + 2 * Instr::kInstrSize ,
2262- Instr::kNopInstruction );
2263- buffer_.Store <int32_t >(position + 3 * Instr::kInstrSize ,
2264- Instr::kNopInstruction );
2265- buffer_.Store <int32_t >(position + 4 * Instr::kInstrSize ,
2266- Instr::kNopInstruction );
2267-
2268- label->position_ = DecodeARMv6LoadImmediate (mov, or1, or2, or3);
2269- } else {
2270- BailoutIfInvalidBranchOffset (dest);
2271- int32_t next = buffer_.Load <int32_t >(position);
2272- int32_t encoded = Assembler::EncodeBranchOffset (dest, next);
2273- buffer_.Store <int32_t >(position, encoded);
2274- label->position_ = Assembler::DecodeBranchOffset (next);
2275- }
2276- }
2277- label->BindTo (bound_pc);
2278- }
2279-
22802136void Assembler::BindARMv7 (Label* label) {
22812137 ASSERT (!label->IsBound ());
22822138 intptr_t bound_pc = buffer_.Size ();
@@ -2345,13 +2201,7 @@ void Assembler::BindARMv7(Label* label) {
23452201}
23462202
23472203void Assembler::Bind (Label* label) {
2348- const ARMVersion version = TargetCPUFeatures::arm_version ();
2349- if (version == ARMv6) {
2350- BindARMv6 (label);
2351- } else {
2352- ASSERT (version == ARMv7);
2353- BindARMv7 (label);
2354- }
2204+ BindARMv7 (label);
23552205}
23562206
23572207OperandSize Address::OperandSizeFor (intptr_t cid) {
@@ -2794,45 +2644,19 @@ void Assembler::BranchLinkOffset(Register base, int32_t offset) {
27942644void Assembler::LoadPatchableImmediate (Register rd,
27952645 int32_t value,
27962646 Condition cond) {
2797- const ARMVersion version = TargetCPUFeatures::arm_version ();
2798- if (version == ARMv6) {
2799- // This sequence is patched in a few places, and should remain fixed.
2800- const uint32_t byte0 = (value & 0x000000ff );
2801- const uint32_t byte1 = (value & 0x0000ff00 ) >> 8 ;
2802- const uint32_t byte2 = (value & 0x00ff0000 ) >> 16 ;
2803- const uint32_t byte3 = (value & 0xff000000 ) >> 24 ;
2804- mov (rd, Operand (4 , byte3), cond);
2805- orr (rd, rd, Operand (8 , byte2), cond);
2806- orr (rd, rd, Operand (12 , byte1), cond);
2807- orr (rd, rd, Operand (byte0), cond);
2808- } else {
2809- ASSERT (version == ARMv7);
2810- const uint16_t value_low = Utils::Low16Bits (value);
2811- const uint16_t value_high = Utils::High16Bits (value);
2812- movw (rd, value_low, cond);
2813- movt (rd, value_high, cond);
2814- }
2647+ const uint16_t value_low = Utils::Low16Bits (value);
2648+ const uint16_t value_high = Utils::High16Bits (value);
2649+ movw (rd, value_low, cond);
2650+ movt (rd, value_high, cond);
28152651}
28162652
28172653void Assembler::LoadDecodableImmediate (Register rd,
28182654 int32_t value,
28192655 Condition cond) {
2820- const ARMVersion version = TargetCPUFeatures::arm_version ();
2821- if (version == ARMv6) {
2822- if (constant_pool_allowed ()) {
2823- const int32_t offset =
2824- target::ObjectPool::element_offset (FindImmediate (value));
2825- LoadWordFromPoolOffset (rd, offset - kHeapObjectTag , PP, cond);
2826- } else {
2827- LoadPatchableImmediate (rd, value, cond);
2828- }
2829- } else {
2830- ASSERT (version == ARMv7);
2831- movw (rd, Utils::Low16Bits (value), cond);
2832- const uint16_t value_high = Utils::High16Bits (value);
2833- if (value_high != 0 ) {
2834- movt (rd, value_high, cond);
2835- }
2656+ movw (rd, Utils::Low16Bits (value), cond);
2657+ const uint16_t value_high = Utils::High16Bits (value);
2658+ if (value_high != 0 ) {
2659+ movt (rd, value_high, cond);
28362660 }
28372661}
28382662
0 commit comments