OLD | NEW |
1 //===- subzero/src/IceAssemblerARM32.h - Assembler for ARM32 ----*- C++ -*-===// | 1 //===- subzero/src/IceAssemblerARM32.h - 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 } | 107 } |
108 } | 108 } |
109 | 109 |
110 MoveRelocatableFixup *createMoveFixup(bool IsMovW, const Constant *Value); | 110 MoveRelocatableFixup *createMoveFixup(bool IsMovW, const Constant *Value); |
111 | 111 |
112 BlRelocatableFixup *createBlFixup(const ConstantRelocatable *BlTarget); | 112 BlRelocatableFixup *createBlFixup(const ConstantRelocatable *BlTarget); |
113 | 113 |
114 void alignFunction() override { | 114 void alignFunction() override { |
115 const SizeT Align = 1 << getBundleAlignLog2Bytes(); | 115 const SizeT Align = 1 << getBundleAlignLog2Bytes(); |
116 SizeT BytesNeeded = Utils::OffsetToAlignment(Buffer.getPosition(), Align); | 116 SizeT BytesNeeded = Utils::OffsetToAlignment(Buffer.getPosition(), Align); |
117 constexpr IValueT UndefinedInst = 0xe7fedef0; // udf #60896 | |
118 constexpr SizeT InstSize = sizeof(IValueT); | 117 constexpr SizeT InstSize = sizeof(IValueT); |
119 assert(BytesNeeded % InstARM32::InstSize == 0); | 118 assert(BytesNeeded % InstARM32::InstSize == 0); |
120 while (BytesNeeded > 0) { | 119 while (BytesNeeded > 0) { |
121 AssemblerBuffer::EnsureCapacity ensured(&Buffer); | 120 trap(); |
122 emitInst(UndefinedInst); | |
123 BytesNeeded -= InstSize; | 121 BytesNeeded -= InstSize; |
124 } | 122 } |
125 } | 123 } |
126 | 124 |
127 SizeT getBundleAlignLog2Bytes() const override { return 4; } | 125 SizeT getBundleAlignLog2Bytes() const override { return 4; } |
128 | 126 |
129 const char *getAlignDirective() const override { return ".p2alignl"; } | 127 const char *getAlignDirective() const override { return ".p2alignl"; } |
130 | 128 |
131 llvm::ArrayRef<uint8_t> getNonExecBundlePadding() const override { | 129 llvm::ArrayRef<uint8_t> getNonExecBundlePadding() const override; |
132 // Use a particular UDF encoding -- TRAPNaCl in LLVM: 0xE7FEDEF0 | |
133 // http://llvm.org/viewvc/llvm-project?view=revision&revision=173943 | |
134 static const uint8_t Padding[] = {0xE7, 0xFE, 0xDE, 0xF0}; | |
135 return llvm::ArrayRef<uint8_t>(Padding, 4); | |
136 } | |
137 | 130 |
138 void padWithNop(intptr_t Padding) override; | 131 void padWithNop(intptr_t Padding) override; |
139 | 132 |
140 Ice::Label *getCfgNodeLabel(SizeT NodeNumber) override { | 133 Ice::Label *getCfgNodeLabel(SizeT NodeNumber) override { |
141 assert(NodeNumber < CfgNodeLabels.size()); | 134 assert(NodeNumber < CfgNodeLabels.size()); |
142 return CfgNodeLabels[NodeNumber]; | 135 return CfgNodeLabels[NodeNumber]; |
143 } | 136 } |
144 | 137 |
145 Label *getOrCreateCfgNodeLabel(SizeT NodeNumber) { | 138 Label *getOrCreateCfgNodeLabel(SizeT NodeNumber) { |
146 return getOrCreateLabel(NodeNumber, CfgNodeLabels); | 139 return getOrCreateLabel(NodeNumber, CfgNodeLabels); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 const TargetInfo TInfo(Lowering); | 293 const TargetInfo TInfo(Lowering); |
301 strex(OpRd, OpRt, OpAddress, Cond, TInfo); | 294 strex(OpRd, OpRt, OpAddress, Cond, TInfo); |
302 } | 295 } |
303 | 296 |
304 void sub(const Operand *OpRd, const Operand *OpRn, const Operand *OpSrc1, | 297 void sub(const Operand *OpRd, const Operand *OpRn, const Operand *OpSrc1, |
305 bool SetFlags, CondARM32::Cond Cond); | 298 bool SetFlags, CondARM32::Cond Cond); |
306 | 299 |
307 // Implements sxtb/sxth depending on type of OpSrc0. | 300 // Implements sxtb/sxth depending on type of OpSrc0. |
308 void sxt(const Operand *OpRd, const Operand *OpSrc0, CondARM32::Cond Cond); | 301 void sxt(const Operand *OpRd, const Operand *OpSrc0, CondARM32::Cond Cond); |
309 | 302 |
| 303 void trap(); |
| 304 |
310 void tst(const Operand *OpRn, const Operand *OpSrc1, CondARM32::Cond Cond); | 305 void tst(const Operand *OpRn, const Operand *OpSrc1, CondARM32::Cond Cond); |
311 | 306 |
312 void udiv(const Operand *OpRd, const Operand *OpRn, const Operand *OpSrc1, | 307 void udiv(const Operand *OpRd, const Operand *OpRn, const Operand *OpSrc1, |
313 CondARM32::Cond Cond); | 308 CondARM32::Cond Cond); |
314 | 309 |
315 void umull(const Operand *OpRdLo, const Operand *OpRdHi, const Operand *OpRn, | 310 void umull(const Operand *OpRdLo, const Operand *OpRdHi, const Operand *OpRn, |
316 const Operand *OpRm, CondARM32::Cond Cond); | 311 const Operand *OpRm, CondARM32::Cond Cond); |
317 | 312 |
318 // Implements uxtb/uxth depending on type of OpSrc0. | 313 // Implements uxtb/uxth depending on type of OpSrc0. |
319 void uxt(const Operand *OpRd, const Operand *OpSrc0, CondARM32::Cond Cond); | 314 void uxt(const Operand *OpRd, const Operand *OpSrc0, CondARM32::Cond Cond); |
320 | 315 |
321 static bool classof(const Assembler *Asm) { | 316 static bool classof(const Assembler *Asm) { |
322 return Asm->getKind() == Asm_ARM32; | 317 return Asm->getKind() == Asm_ARM32; |
323 } | 318 } |
324 | 319 |
325 void emitTextInst(const std::string &Text, SizeT InstSize); | 320 void emitTextInst(const std::string &Text, SizeT InstSize); |
326 | 321 |
327 private: | 322 private: |
328 // A vector of pool-allocated x86 labels for CFG nodes. | 323 // A vector of pool-allocated x86 labels for CFG nodes. |
329 using LabelVector = std::vector<Label *>; | 324 using LabelVector = std::vector<Label *>; |
330 LabelVector CfgNodeLabels; | 325 LabelVector CfgNodeLabels; |
331 // A vector of pool-allocated x86 labels for Local labels. | 326 // A vector of pool-allocated x86 labels for Local labels. |
332 LabelVector LocalLabels; | 327 LabelVector LocalLabels; |
333 // Number of bytes emitted by InstARM32::emit() methods, when run inside | 328 // Number of bytes emitted by InstARM32::emit() methods, when run inside |
334 // InstARM32::emitUsingTextFixup(). | 329 // InstARM32::emitUsingTextFixup(). |
335 size_t EmitTextSize = 0; | 330 size_t EmitTextSize = 0; |
| 331 // Trap instruction (defined in little-endian byte order). |
| 332 static const uint8_t TrapInst[]; |
336 | 333 |
337 // Load/store multiple addressing mode. | 334 // Load/store multiple addressing mode. |
338 enum BlockAddressMode { | 335 enum BlockAddressMode { |
339 // bit encoding P U W | 336 // bit encoding P U W |
340 DA = (0 | 0 | 0) << 21, // decrement after | 337 DA = (0 | 0 | 0) << 21, // decrement after |
341 IA = (0 | 4 | 0) << 21, // increment after | 338 IA = (0 | 4 | 0) << 21, // increment after |
342 DB = (8 | 0 | 0) << 21, // decrement before | 339 DB = (8 | 0 | 0) << 21, // decrement before |
343 IB = (8 | 4 | 0) << 21, // increment before | 340 IB = (8 | 4 | 0) << 21, // increment before |
344 DA_W = (0 | 0 | 1) << 21, // decrement after with writeback to base | 341 DA_W = (0 | 0 | 1) << 21, // decrement after with writeback to base |
345 IA_W = (0 | 4 | 1) << 21, // increment after with writeback to base | 342 IA_W = (0 | 4 | 1) << 21, // increment after with writeback to base |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 // where cccc=Cond, xxxxxxx<<21=Opcode, dddd=Rd, s=SetFlags, and | 448 // where cccc=Cond, xxxxxxx<<21=Opcode, dddd=Rd, s=SetFlags, and |
452 // iiiiiiiiiiiiiiii=Imm16. | 449 // iiiiiiiiiiiiiiii=Imm16. |
453 void emitMovwt(CondARM32::Cond Cond, bool IsMovw, const Operand *OpRd, | 450 void emitMovwt(CondARM32::Cond Cond, bool IsMovw, const Operand *OpRd, |
454 const Operand *OpSrc, const char *MovName); | 451 const Operand *OpSrc, const char *MovName); |
455 }; | 452 }; |
456 | 453 |
457 } // end of namespace ARM32 | 454 } // end of namespace ARM32 |
458 } // end of namespace Ice | 455 } // end of namespace Ice |
459 | 456 |
460 #endif // SUBZERO_SRC_ICEASSEMBLERARM32_H | 457 #endif // SUBZERO_SRC_ICEASSEMBLERARM32_H |
OLD | NEW |