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

Side by Side Diff: src/IceAssemblerARM32.cpp

Issue 1424773002: Add ADC (immediate) instruction to ARM integrated assembler. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 5 years, 1 month 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
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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 AssemblerBuffer::EnsureCapacity ensured(&Buffer); 254 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
255 AssemblerFixup *F = createTextFixup(Text, InstSize); 255 AssemblerFixup *F = createTextFixup(Text, InstSize);
256 emitFixup(F); 256 emitFixup(F);
257 for (SizeT I = 0; I < InstSize; ++I) 257 for (SizeT I = 0; I < InstSize; ++I)
258 Buffer.emit<char>(0); 258 Buffer.emit<char>(0);
259 } 259 }
260 260
261 void ARM32::AssemblerARM32::emitType01(CondARM32::Cond Cond, uint32_t Type, 261 void ARM32::AssemblerARM32::emitType01(CondARM32::Cond Cond, uint32_t Type,
262 uint32_t Opcode, bool SetCc, uint32_t Rn, 262 uint32_t Opcode, bool SetCc, uint32_t Rn,
263 uint32_t Rd, uint32_t Imm12) { 263 uint32_t Rd, uint32_t Imm12) {
264 assert(isGPRRegisterDefined(Rd)); 264 if (!isGPRRegisterDefined(Rd) || !isConditionDefined(Cond))
265 // TODO(kschimpf): Remove void cast when MINIMAL build allows. 265 return setNeedsTextFixup();
266 (void)isGPRRegisterDefined(Rd);
267 assert(Cond != CondARM32::kNone);
268 AssemblerBuffer::EnsureCapacity ensured(&Buffer); 266 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
269 const uint32_t Encoding = (encodeCondition(Cond) << kConditionShift) | 267 const uint32_t Encoding = (encodeCondition(Cond) << kConditionShift) |
270 (Type << kTypeShift) | (Opcode << kOpcodeShift) | 268 (Type << kTypeShift) | (Opcode << kOpcodeShift) |
271 (encodeBool(SetCc) << kSShift) | (Rn << kRnShift) | 269 (encodeBool(SetCc) << kSShift) | (Rn << kRnShift) |
272 (Rd << kRdShift) | Imm12; 270 (Rd << kRdShift) | Imm12;
273 emitInst(Encoding); 271 emitInst(Encoding);
274 } 272 }
275 273
276 void ARM32::AssemblerARM32::emitMemOp(CondARM32::Cond Cond, uint32_t InstType, 274 void ARM32::AssemblerARM32::emitMemOp(CondARM32::Cond Cond, uint32_t InstType,
277 bool IsLoad, bool IsByte, uint32_t Rt, 275 bool IsLoad, bool IsByte, uint32_t Rt,
278 uint32_t Address) { 276 uint32_t Address) {
279 assert(isGPRRegisterDefined(Rt)); 277 if (!isGPRRegisterDefined(Rt) || !isConditionDefined(Cond))
280 assert(Cond != CondARM32::kNone); 278 return setNeedsTextFixup();
281 AssemblerBuffer::EnsureCapacity ensured(&Buffer); 279 AssemblerBuffer::EnsureCapacity ensured(&Buffer);
282 const uint32_t Encoding = (encodeCondition(Cond) << kConditionShift) | 280 const uint32_t Encoding = (encodeCondition(Cond) << kConditionShift) |
283 (InstType << kTypeShift) | (IsLoad ? L : 0) | 281 (InstType << kTypeShift) | (IsLoad ? L : 0) |
284 (IsByte ? B : 0) | (Rt << kRdShift) | Address; 282 (IsByte ? B : 0) | (Rt << kRdShift) | Address;
285 emitInst(Encoding); 283 emitInst(Encoding);
286 } 284 }
287 285
286 void ARM32::AssemblerARM32::adc(const Operand *OpRd, const Operand *OpRn,
287 const Operand *OpSrc1, bool SetFlags,
288 CondARM32::Cond Cond) {
289 uint32_t Rd;
290 if (decodeOperand(OpRd, Rd) != DecodedAsRegister)
291 return setNeedsTextFixup();
292 uint32_t Rn;
293 if (decodeOperand(OpRn, Rn) != DecodedAsRegister)
294 return setNeedsTextFixup();
295 constexpr uint32_t Adc = B2 | B0; // 0101
296 uint32_t Src1Value;
297 // TODO(kschimpf) Other possible decodings of adc.
298 switch (decodeOperand(OpSrc1, Src1Value)) {
299 default:
300 return setNeedsTextFixup();
301 case DecodedAsRotatedImm8: {
302 // ADC (Immediated) = ARM section A8.8.1, encoding A1:
303 // adc{s}<c> <Rd>, <Rn>, #<RotatedImm8>
304 //
305 // cccc0010101snnnnddddiiiiiiiiiiii where cccc=Cond, dddd=Rd, nnnn=Rn,
306 // s=SetFlags and iiiiiiiiiiii=Src1Value=RotatedImm8.
307 if ((Rd == RegARM32::Encoded_Reg_pc && SetFlags))
308 // Conditions of rule violated.
309 return setNeedsTextFixup();
310 emitType01(Cond, kInstTypeDataImmediate, Adc, SetFlags, Rn, Rd, Src1Value);
311 return;
312 }
313 };
314 }
315
288 void ARM32::AssemblerARM32::add(const Operand *OpRd, const Operand *OpRn, 316 void ARM32::AssemblerARM32::add(const Operand *OpRd, const Operand *OpRn,
289 const Operand *OpSrc1, bool SetFlags, 317 const Operand *OpSrc1, bool SetFlags,
290 CondARM32::Cond Cond) { 318 CondARM32::Cond Cond) {
291 uint32_t Rd; 319 uint32_t Rd;
292 if (decodeOperand(OpRd, Rd) != DecodedAsRegister) 320 if (decodeOperand(OpRd, Rd) != DecodedAsRegister)
293 return setNeedsTextFixup(); 321 return setNeedsTextFixup();
294 uint32_t Rn; 322 uint32_t Rn;
295 if (decodeOperand(OpRn, Rn) != DecodedAsRegister) 323 if (decodeOperand(OpRn, Rn) != DecodedAsRegister)
296 return setNeedsTextFixup(); 324 return setNeedsTextFixup();
297 constexpr uint32_t Add = B2; // 0100 325 constexpr uint32_t Add = B2; // 0100
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 if (Rd == RegARM32::Encoded_Reg_pc) 522 if (Rd == RegARM32::Encoded_Reg_pc)
495 // Conditions of rule violated. 523 // Conditions of rule violated.
496 return setNeedsTextFixup(); 524 return setNeedsTextFixup();
497 emitType01(Cond, kInstTypeDataImmediate, Sub, SetFlags, Rn, Rd, Src1Value); 525 emitType01(Cond, kInstTypeDataImmediate, Sub, SetFlags, Rn, Rd, Src1Value);
498 return; 526 return;
499 } 527 }
500 } 528 }
501 } 529 }
502 530
503 } // end of namespace Ice 531 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698