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

Side by Side Diff: src/IceAssemblerARM32.cpp

Issue 1414043015: Fix frame pointer loads/stores in the ARM integrated assembler. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix column issue in test case. 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 if (Offset < 0) { 226 if (Offset < 0) {
227 Value = (Value ^ U) | -Offset; // Flip U to adjust sign. 227 Value = (Value ^ U) | -Offset; // Flip U to adjust sign.
228 } else { 228 } else {
229 Value |= Offset; 229 Value |= Offset;
230 } 230 }
231 return Value; 231 return Value;
232 } 232 }
233 233
234 // Decodes memory address Opnd, and encodes that information into Value, 234 // Decodes memory address Opnd, and encodes that information into Value,
235 // based on how ARM represents the address. Returns how the value was encoded. 235 // based on how ARM represents the address. Returns how the value was encoded.
236 DecodedResult decodeAddress(const Operand *Opnd, IValueT &Value) { 236 DecodedResult decodeAddress(const Operand *Opnd, IValueT &Value,
237 const AssemblerARM32::TargetInfo &Target) {
Jim Stichnoth 2015/11/11 20:42:09 Can you rename the "Target" parameter? When I see
Karl 2015/11/11 22:42:57 Used TInfo.
237 if (const auto *Var = llvm::dyn_cast<Variable>(Opnd)) { 238 if (const auto *Var = llvm::dyn_cast<Variable>(Opnd)) {
238 // Should be a stack variable, with an offset. 239 // Should be a stack variable, with an offset.
239 if (Var->hasReg()) 240 if (Var->hasReg())
240 return CantDecode; 241 return CantDecode;
241 const IOffsetT Offset = Var->getStackOffset(); 242 IOffsetT Offset = Var->getStackOffset();
242 if (!Utils::IsAbsoluteUint(12, Offset)) 243 if (!Utils::IsAbsoluteUint(12, Offset))
243 return CantDecode; 244 return CantDecode;
244 RegARM32::GPRRegister BaseReg = RegARM32::Encoded_Reg_sp; 245 int32_t BaseRegNum = Var->getBaseRegNum();
245 if (const auto *StackVar = llvm::dyn_cast<StackVariable>(Var)) 246 if (BaseRegNum == Variable::NoRegister) {
246 BaseReg = decodeGPRRegister(StackVar->getBaseRegNum()); 247 BaseRegNum = Target.FrameOrStackReg;
247 Value = decodeImmRegOffset(BaseReg, Offset, OperandARM32Mem::Offset); 248 if (Target.HasFramePointer)
Jim Stichnoth 2015/11/11 20:42:09 I thought that we need to adjust the offset only i
Karl 2015/11/11 22:42:57 I was wrong. "(!" looked like "(" when I looked at
249 Offset += Target.StackAdjustment;
250 }
251 Value = decodeImmRegOffset(decodeGPRRegister(BaseRegNum), Offset,
252 OperandARM32Mem::Offset);
248 return DecodedAsImmRegOffset; 253 return DecodedAsImmRegOffset;
249 } 254 }
250 if (const auto *Mem = llvm::dyn_cast<OperandARM32Mem>(Opnd)) { 255 if (const auto *Mem = llvm::dyn_cast<OperandARM32Mem>(Opnd)) {
251 if (Mem->isRegReg()) 256 if (Mem->isRegReg())
252 // TODO(kschimpf) Add this case. 257 // TODO(kschimpf) Add this case.
253 return CantDecode; 258 return CantDecode;
254 Variable *Var = Mem->getBase(); 259 Variable *Var = Mem->getBase();
255 if (!Var->hasReg()) 260 if (!Var->hasReg())
256 return CantDecode; 261 return CantDecode;
257 ConstantInteger32 *Offset = Mem->getOffset(); 262 ConstantInteger32 *Offset = Mem->getOffset();
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 // EOR (Immediate) - ARM section A8.*.46, encoding A1: 693 // EOR (Immediate) - ARM section A8.*.46, encoding A1:
689 // eor{s}<c> <Rd>, <Rn>, #RotatedImm8 694 // eor{s}<c> <Rd>, <Rn>, #RotatedImm8
690 // 695 //
691 // cccc0010001snnnnddddiiiiiiiiiiii where cccc=Cond, dddd=Rd, nnnn=Rn, 696 // cccc0010001snnnnddddiiiiiiiiiiii where cccc=Cond, dddd=Rd, nnnn=Rn,
692 // s=SetFlags and iiiiiiiiiiii=Src1Value defining RotatedImm8. 697 // s=SetFlags and iiiiiiiiiiii=Src1Value defining RotatedImm8.
693 constexpr IValueT Eor = B0; // 0001 698 constexpr IValueT Eor = B0; // 0001
694 emitType01(Eor, OpRd, OpRn, OpSrc1, SetFlags, Cond); 699 emitType01(Eor, OpRd, OpRn, OpSrc1, SetFlags, Cond);
695 } 700 }
696 701
697 void AssemblerARM32::ldr(const Operand *OpRt, const Operand *OpAddress, 702 void AssemblerARM32::ldr(const Operand *OpRt, const Operand *OpAddress,
698 CondARM32::Cond Cond) { 703 CondARM32::Cond Cond, const TargetInfo &Target) {
699 IValueT Rt; 704 IValueT Rt;
700 if (decodeOperand(OpRt, Rt) != DecodedAsRegister) 705 if (decodeOperand(OpRt, Rt) != DecodedAsRegister)
701 return setNeedsTextFixup(); 706 return setNeedsTextFixup();
702 IValueT Address; 707 IValueT Address;
703 if (decodeAddress(OpAddress, Address) != DecodedAsImmRegOffset) 708 if (decodeAddress(OpAddress, Address, Target) != DecodedAsImmRegOffset)
704 return setNeedsTextFixup(); 709 return setNeedsTextFixup();
705 // LDR (immediate) - ARM section A8.8.63, encoding A1: 710 // LDR (immediate) - ARM section A8.8.63, encoding A1:
706 // ldr<c> <Rt>, [<Rn>{, #+/-<imm12>}] ; p=1, w=0 711 // ldr<c> <Rt>, [<Rn>{, #+/-<imm12>}] ; p=1, w=0
707 // ldr<c> <Rt>, [<Rn>], #+/-<imm12> ; p=1, w=1 712 // ldr<c> <Rt>, [<Rn>], #+/-<imm12> ; p=1, w=1
708 // ldr<c> <Rt>, [<Rn>, #+/-<imm12>]! ; p=0, w=1 713 // ldr<c> <Rt>, [<Rn>, #+/-<imm12>]! ; p=0, w=1
709 // 714 //
710 // LDRB (immediate) - ARM section A8.8.68, encoding A1: 715 // LDRB (immediate) - ARM section A8.8.68, encoding A1:
711 // ldrb<c> <Rt>, [<Rn>{, #+/-<imm12>}] ; p=1, w=0 716 // ldrb<c> <Rt>, [<Rn>{, #+/-<imm12>}] ; p=1, w=0
712 // ldrb<c> <Rt>, [<Rn>], #+/-<imm12> ; p=1, w=1 717 // ldrb<c> <Rt>, [<Rn>], #+/-<imm12> ; p=1, w=1
713 // ldrb<c> <Rt>, [<Rn>, #+/-<imm12>]! ; p=0, w=1 718 // ldrb<c> <Rt>, [<Rn>, #+/-<imm12>]! ; p=0, w=1
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 return setNeedsTextFixup(); 851 return setNeedsTextFixup();
847 if (Rd == RegARM32::Encoded_Reg_pc || Rn == RegARM32::Encoded_Reg_pc || 852 if (Rd == RegARM32::Encoded_Reg_pc || Rn == RegARM32::Encoded_Reg_pc ||
848 Rm == RegARM32::Encoded_Reg_pc) 853 Rm == RegARM32::Encoded_Reg_pc)
849 llvm::report_fatal_error("Sdiv instruction unpredictable on pc"); 854 llvm::report_fatal_error("Sdiv instruction unpredictable on pc");
850 // Assembler registers rd, rn, rm are encoded as rn, rm, rs. 855 // Assembler registers rd, rn, rm are encoded as rn, rm, rs.
851 constexpr IValueT Opcode = 0; 856 constexpr IValueT Opcode = 0;
852 emitDivOp(Cond, Opcode, Rd, Rn, Rm); 857 emitDivOp(Cond, Opcode, Rd, Rn, Rm);
853 } 858 }
854 859
855 void AssemblerARM32::str(const Operand *OpRt, const Operand *OpAddress, 860 void AssemblerARM32::str(const Operand *OpRt, const Operand *OpAddress,
856 CondARM32::Cond Cond) { 861 CondARM32::Cond Cond, const TargetInfo &Target) {
857 IValueT Rt; 862 IValueT Rt;
858 if (decodeOperand(OpRt, Rt) != DecodedAsRegister) 863 if (decodeOperand(OpRt, Rt) != DecodedAsRegister)
859 return setNeedsTextFixup(); 864 return setNeedsTextFixup();
860 IValueT Address; 865 IValueT Address;
861 if (decodeAddress(OpAddress, Address) != DecodedAsImmRegOffset) 866 if (decodeAddress(OpAddress, Address, Target) != DecodedAsImmRegOffset)
862 return setNeedsTextFixup(); 867 return setNeedsTextFixup();
863 // STR (immediate) - ARM section A8.8.204, encoding A1: 868 // STR (immediate) - ARM section A8.8.204, encoding A1:
864 // str<c> <Rt>, [<Rn>{, #+/-<imm12>}] ; p=1, w=0 869 // str<c> <Rt>, [<Rn>{, #+/-<imm12>}] ; p=1, w=0
865 // str<c> <Rt>, [<Rn>], #+/-<imm12> ; p=1, w=1 870 // str<c> <Rt>, [<Rn>], #+/-<imm12> ; p=1, w=1
866 // str<c> <Rt>, [<Rn>, #+/-<imm12>]! ; p=0, w=1 871 // str<c> <Rt>, [<Rn>, #+/-<imm12>]! ; p=0, w=1
867 // STRB (immediate) - ARM section A8.8.207, encoding A1: 872 // STRB (immediate) - ARM section A8.8.207, encoding A1:
868 // strb<c> <Rt>, [<Rn>{, #+/-<imm12>}] ; p=1, w=0 873 // strb<c> <Rt>, [<Rn>{, #+/-<imm12>}] ; p=1, w=0
869 // strb<c> <Rt>, [<Rn>], #+/-<imm12> ; p=1, w=1 874 // strb<c> <Rt>, [<Rn>], #+/-<imm12> ; p=1, w=1
870 // strb<c> <Rt>, [<Rn>, #+/-<imm12>]! ; p=0, w=1 875 // strb<c> <Rt>, [<Rn>, #+/-<imm12>]! ; p=0, w=1
871 // 876 //
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 if (RdHi == RegARM32::Encoded_Reg_pc || RdLo == RegARM32::Encoded_Reg_pc || 1075 if (RdHi == RegARM32::Encoded_Reg_pc || RdLo == RegARM32::Encoded_Reg_pc ||
1071 Rn == RegARM32::Encoded_Reg_pc || Rm == RegARM32::Encoded_Reg_pc || 1076 Rn == RegARM32::Encoded_Reg_pc || Rm == RegARM32::Encoded_Reg_pc ||
1072 RdHi == RdLo) 1077 RdHi == RdLo)
1073 llvm::report_fatal_error("Umull instruction unpredictable on pc"); 1078 llvm::report_fatal_error("Umull instruction unpredictable on pc");
1074 constexpr bool SetFlags = false; 1079 constexpr bool SetFlags = false;
1075 emitMulOp(Cond, B23, RdLo, RdHi, Rn, Rm, SetFlags); 1080 emitMulOp(Cond, B23, RdLo, RdHi, Rn, Rm, SetFlags);
1076 } 1081 }
1077 1082
1078 } // end of namespace ARM32 1083 } // end of namespace ARM32
1079 } // end of namespace Ice 1084 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698