Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: src/IceAssemblerARM32.cpp

Issue 1619703008: Fix vldrd/vstrd handling of immediate offsets in ARM. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix issues in last patch. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/IceInstARM32.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceAssemblerARM32.cpp - Assembler for ARM32 --*- C++ -*-===// 1 //===- subzero/src/IceAssemblerARM32.cpp - Assembler for ARM32 --*- C++ -*-===//
2 // 2 //
3 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 3 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
4 // for details. All rights reserved. Use of this source code is governed by a 4 // for details. All rights reserved. Use of this source code is governed by a
5 // BSD-style license that can be found in the LICENSE file. 5 // BSD-style license that can be found in the LICENSE file.
6 // 6 //
7 // Modified by the Subzero authors. 7 // Modified by the Subzero authors.
8 // 8 //
9 //===----------------------------------------------------------------------===// 9 //===----------------------------------------------------------------------===//
10 // 10 //
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 // Returns the GPR register at given Shift in Value. 173 // Returns the GPR register at given Shift in Value.
174 RegARM32::GPRRegister getGPRReg(IValueT Shift, IValueT Value) { 174 RegARM32::GPRRegister getGPRReg(IValueT Shift, IValueT Value) {
175 return decodeGPRRegister((Value >> Shift) & 0xF); 175 return decodeGPRRegister((Value >> Shift) & 0xF);
176 } 176 }
177 177
178 // Defines alternate layouts of instruction operands, should the (common) 178 // Defines alternate layouts of instruction operands, should the (common)
179 // default pattern not be used. 179 // default pattern not be used.
180 enum OpEncoding { 180 enum OpEncoding {
181 // No alternate layout specified. 181 // No alternate layout specified.
182 DefaultOpEncoding, 182 DefaultOpEncoding,
183 // Alternate encoding for ImmRegOffset, where the offset is divided by 4
184 // before encoding.
185 ImmRegOffsetDiv4,
183 // Alternate encoding 3 for memory operands (like in strb, strh, ldrb, and 186 // Alternate encoding 3 for memory operands (like in strb, strh, ldrb, and
184 // ldrh. 187 // ldrh.
185 OpEncoding3, 188 OpEncoding3,
186 // Alternate encoding for memory operands for ldrex and strex, which only 189 // Alternate encoding for memory operands for ldrex and strex, which only
187 // actually expect a register. 190 // actually expect a register.
188 OpEncodingMemEx 191 OpEncodingMemEx
189 }; 192 };
190 193
191 IValueT getEncodedGPRegNum(const Variable *Var) { 194 IValueT getEncodedGPRegNum(const Variable *Var) {
192 assert(Var->hasReg()); 195 assert(Var->hasReg());
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 assert(Imm8 < (1 << 8)); 377 assert(Imm8 < (1 << 8));
375 Value = Value | B22 | ((Imm8 & 0xf0) << 4) | (Imm8 & 0x0f); 378 Value = Value | B22 | ((Imm8 & 0xf0) << 4) | (Imm8 & 0x0f);
376 return Value; 379 return Value;
377 } 380 }
378 381
379 IValueT encodeImmRegOffset(OpEncoding AddressEncoding, IValueT Reg, 382 IValueT encodeImmRegOffset(OpEncoding AddressEncoding, IValueT Reg,
380 IOffsetT Offset, OperandARM32Mem::AddrMode Mode) { 383 IOffsetT Offset, OperandARM32Mem::AddrMode Mode) {
381 switch (AddressEncoding) { 384 switch (AddressEncoding) {
382 case DefaultOpEncoding: 385 case DefaultOpEncoding:
383 return encodeImmRegOffset(Reg, Offset, Mode); 386 return encodeImmRegOffset(Reg, Offset, Mode);
387 case ImmRegOffsetDiv4:
388 assert((Offset & 0x3) == 0);
389 return encodeImmRegOffset(Reg, Offset >> 2, Mode);
384 case OpEncoding3: 390 case OpEncoding3:
385 return encodeImmRegOffsetEnc3(Reg, Offset, Mode); 391 return encodeImmRegOffsetEnc3(Reg, Offset, Mode);
386 case OpEncodingMemEx: 392 case OpEncodingMemEx:
387 assert(Offset == 0); 393 assert(Offset == 0);
388 assert(Mode == OperandARM32Mem::Offset); 394 assert(Mode == OperandARM32Mem::Offset);
389 return Reg << kRnShift; 395 return Reg << kRnShift;
390 } 396 }
391 llvm_unreachable("(silence g++ warning)"); 397 llvm_unreachable("(silence g++ warning)");
392 } 398 }
393 399
(...skipping 1813 matching lines...) Expand 10 before | Expand all | Expand 10 after
2207 (getYInRegYXXXX(Dm) << 5) | getXXXXInRegYXXXX(Dm); 2213 (getYInRegYXXXX(Dm) << 5) | getXXXXInRegYXXXX(Dm);
2208 emitInst(Encoding); 2214 emitInst(Encoding);
2209 } 2215 }
2210 2216
2211 void AssemblerARM32::vldrd(const Operand *OpDd, const Operand *OpAddress, 2217 void AssemblerARM32::vldrd(const Operand *OpDd, const Operand *OpAddress,
2212 CondARM32::Cond Cond, const TargetInfo &TInfo) { 2218 CondARM32::Cond Cond, const TargetInfo &TInfo) {
2213 // VLDR - ARM section A8.8.333, encoding A1. 2219 // VLDR - ARM section A8.8.333, encoding A1.
2214 // vldr<c> <Dd>, [<Rn>{, #+/-<imm>}] 2220 // vldr<c> <Dd>, [<Rn>{, #+/-<imm>}]
2215 // 2221 //
2216 // cccc1101UD01nnnndddd1011iiiiiiii where cccc=Cond, nnnn=Rn, Ddddd=Rd, 2222 // cccc1101UD01nnnndddd1011iiiiiiii where cccc=Cond, nnnn=Rn, Ddddd=Rd,
2217 // iiiiiiii=abs(Opcode), and U=1 if Opcode>=0, 2223 // iiiiiiii=abs(Imm >> 2), and U=1 if Opcode>=0.
2218 constexpr const char *Vldrd = "vldrd"; 2224 constexpr const char *Vldrd = "vldrd";
2219 IValueT Dd = encodeDRegister(OpDd, "Dd", Vldrd); 2225 IValueT Dd = encodeDRegister(OpDd, "Dd", Vldrd);
2220 assert(CondARM32::isDefined(Cond)); 2226 assert(CondARM32::isDefined(Cond));
2221 IValueT Address; 2227 IValueT Address;
2222 EncodedOperand AddressEncoding = encodeAddress(OpAddress, Address, TInfo); 2228 EncodedOperand AddressEncoding =
2223 (void)AddressEncoding; 2229 encodeAddress(OpAddress, Address, TInfo, ImmRegOffsetDiv4);
2224 assert(AddressEncoding == EncodedAsImmRegOffset); 2230 if (AddressEncoding != EncodedAsImmRegOffset)
2231 // TODO(kschimpf) Fix this.
2232 return setNeedsTextFixup();
2225 AssemblerBuffer::EnsureCapacity ensured(&Buffer); 2233 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
2226 IValueT Encoding = B27 | B26 | B24 | B20 | B11 | B9 | B8 | 2234 IValueT Encoding = B27 | B26 | B24 | B20 | B11 | B9 | B8 |
2227 (encodeCondition(Cond) << kConditionShift) | 2235 (encodeCondition(Cond) << kConditionShift) |
2228 (getYInRegYXXXX(Dd) << 22) | 2236 (getYInRegYXXXX(Dd) << 22) |
2229 (getXXXXInRegYXXXX(Dd) << 12) | Address; 2237 (getXXXXInRegYXXXX(Dd) << 12) | Address;
2230 emitInst(Encoding); 2238 emitInst(Encoding);
2231 } 2239 }
2232 2240
2233 void AssemblerARM32::vldrs(const Operand *OpSd, const Operand *OpAddress, 2241 void AssemblerARM32::vldrs(const Operand *OpSd, const Operand *OpAddress,
2234 CondARM32::Cond Cond, const TargetInfo &TInfo) { 2242 CondARM32::Cond Cond, const TargetInfo &TInfo) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2278 IValueT Dd = encodeDRegister(OpDd, "Dd", Vmuld); 2286 IValueT Dd = encodeDRegister(OpDd, "Dd", Vmuld);
2279 IValueT Dn = encodeDRegister(OpDn, "Dn", Vmuld); 2287 IValueT Dn = encodeDRegister(OpDn, "Dn", Vmuld);
2280 IValueT Dm = encodeDRegister(OpDm, "Dm", Vmuld); 2288 IValueT Dm = encodeDRegister(OpDm, "Dm", Vmuld);
2281 constexpr IValueT VmuldOpcode = B21; 2289 constexpr IValueT VmuldOpcode = B21;
2282 emitVFPddd(Cond, VmuldOpcode, Dd, Dn, Dm); 2290 emitVFPddd(Cond, VmuldOpcode, Dd, Dn, Dm);
2283 } 2291 }
2284 2292
2285 void AssemblerARM32::vstrd(const Operand *OpDd, const Operand *OpAddress, 2293 void AssemblerARM32::vstrd(const Operand *OpDd, const Operand *OpAddress,
2286 CondARM32::Cond Cond, const TargetInfo &TInfo) { 2294 CondARM32::Cond Cond, const TargetInfo &TInfo) {
2287 // VSTR - ARM section A8.8.413, encoding A1: 2295 // VSTR - ARM section A8.8.413, encoding A1:
2288 // vstr<c> <Dd>, [<Rn>{, #+/-<imm>}] 2296 // vstr<c> <Dd>, [<Rn>{, #+/-<Imm>}]
2289 // 2297 //
2290 // cccc1101UD00nnnndddd1011iiiiiiii where cccc=Cond, nnnn=Rn, Ddddd=Rd, 2298 // cccc1101UD00nnnndddd1011iiiiiiii where cccc=Cond, nnnn=Rn, Ddddd=Rd,
2291 // iiiiiiii=abs(Opcode), and U=1 if Opcode>=0, 2299 // iiiiiiii=abs(Imm >> 2), and U=1 if Imm>=0.
2292 constexpr const char *Vstrd = "vstrd"; 2300 constexpr const char *Vstrd = "vstrd";
2293 IValueT Dd = encodeDRegister(OpDd, "Dd", Vstrd); 2301 IValueT Dd = encodeDRegister(OpDd, "Dd", Vstrd);
2294 assert(CondARM32::isDefined(Cond)); 2302 assert(CondARM32::isDefined(Cond));
2295 IValueT Address; 2303 IValueT Address;
2296 if (encodeAddress(OpAddress, Address, TInfo) != EncodedAsImmRegOffset) 2304 IValueT AddressEncoding =
2297 assert(false); 2305 encodeAddress(OpAddress, Address, TInfo, ImmRegOffsetDiv4);
2306 if (AddressEncoding != EncodedAsImmRegOffset)
2307 // TODO(kschimpf) Fix this.
2308 return setNeedsTextFixup();
2298 AssemblerBuffer::EnsureCapacity ensured(&Buffer); 2309 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
2299 IValueT Encoding = B27 | B26 | B24 | B11 | B9 | B8 | 2310 IValueT Encoding = B27 | B26 | B24 | B11 | B9 | B8 |
2300 (encodeCondition(Cond) << kConditionShift) | 2311 (encodeCondition(Cond) << kConditionShift) |
2301 (getYInRegYXXXX(Dd) << 22) | 2312 (getYInRegYXXXX(Dd) << 22) |
2302 (getXXXXInRegYXXXX(Dd) << 12) | Address; 2313 (getXXXXInRegYXXXX(Dd) << 12) | Address;
2303 emitInst(Encoding); 2314 emitInst(Encoding);
2304 } 2315 }
2305 2316
2306 void AssemblerARM32::vstrs(const Operand *OpSd, const Operand *OpAddress, 2317 void AssemblerARM32::vstrs(const Operand *OpSd, const Operand *OpAddress,
2307 CondARM32::Cond Cond, const TargetInfo &TInfo) { 2318 CondARM32::Cond Cond, const TargetInfo &TInfo) {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
2395 // 2406 //
2396 // cccc11010D101101dddd1010iiiiiiii where cccc=Cond, ddddD=BaseReg, and 2407 // cccc11010D101101dddd1010iiiiiiii where cccc=Cond, ddddD=BaseReg, and
2397 // iiiiiiii=NumConsecRegs. 2408 // iiiiiiii=NumConsecRegs.
2398 constexpr IValueT VpushOpcode = 2409 constexpr IValueT VpushOpcode =
2399 B27 | B26 | B24 | B21 | B19 | B18 | B16 | B11 | B9; 2410 B27 | B26 | B24 | B21 | B19 | B18 | B16 | B11 | B9;
2400 emitVStackOp(Cond, VpushOpcode, OpBaseReg, NumConsecRegs); 2411 emitVStackOp(Cond, VpushOpcode, OpBaseReg, NumConsecRegs);
2401 } 2412 }
2402 2413
2403 } // end of namespace ARM32 2414 } // end of namespace ARM32
2404 } // end of namespace Ice 2415 } // end of namespace Ice
OLDNEW
« no previous file with comments | « no previous file | src/IceInstARM32.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698