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 | 130 return llvm::ArrayRef<uint8_t>(TrapInst, 4); |
Jim Stichnoth
2015/12/11 23:31:08
Can you move the implementation into the .cpp file
Karl
2015/12/17 16:23:09
Done.
| |
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 } | 131 } |
137 | 132 |
138 void padWithNop(intptr_t Padding) override; | 133 void padWithNop(intptr_t Padding) override; |
139 | 134 |
140 Ice::Label *getCfgNodeLabel(SizeT NodeNumber) override { | 135 Ice::Label *getCfgNodeLabel(SizeT NodeNumber) override { |
141 assert(NodeNumber < CfgNodeLabels.size()); | 136 assert(NodeNumber < CfgNodeLabels.size()); |
142 return CfgNodeLabels[NodeNumber]; | 137 return CfgNodeLabels[NodeNumber]; |
143 } | 138 } |
144 | 139 |
145 Label *getOrCreateCfgNodeLabel(SizeT NodeNumber) { | 140 Label *getOrCreateCfgNodeLabel(SizeT NodeNumber) { |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
280 const TargetInfo TInfo(Lowering); | 275 const TargetInfo TInfo(Lowering); |
281 str(OpRt, OpAddress, Cond, TInfo); | 276 str(OpRt, OpAddress, Cond, TInfo); |
282 } | 277 } |
283 | 278 |
284 void sub(const Operand *OpRd, const Operand *OpRn, const Operand *OpSrc1, | 279 void sub(const Operand *OpRd, const Operand *OpRn, const Operand *OpSrc1, |
285 bool SetFlags, CondARM32::Cond Cond); | 280 bool SetFlags, CondARM32::Cond Cond); |
286 | 281 |
287 // Implements sxtb/sxth depending on type of OpSrc0. | 282 // Implements sxtb/sxth depending on type of OpSrc0. |
288 void sxt(const Operand *OpRd, const Operand *OpSrc0, CondARM32::Cond Cond); | 283 void sxt(const Operand *OpRd, const Operand *OpSrc0, CondARM32::Cond Cond); |
289 | 284 |
285 void trap(); | |
286 | |
290 void tst(const Operand *OpRn, const Operand *OpSrc1, CondARM32::Cond Cond); | 287 void tst(const Operand *OpRn, const Operand *OpSrc1, CondARM32::Cond Cond); |
291 | 288 |
292 void udiv(const Operand *OpRd, const Operand *OpRn, const Operand *OpSrc1, | 289 void udiv(const Operand *OpRd, const Operand *OpRn, const Operand *OpSrc1, |
293 CondARM32::Cond Cond); | 290 CondARM32::Cond Cond); |
294 | 291 |
295 void umull(const Operand *OpRdLo, const Operand *OpRdHi, const Operand *OpRn, | 292 void umull(const Operand *OpRdLo, const Operand *OpRdHi, const Operand *OpRn, |
296 const Operand *OpRm, CondARM32::Cond Cond); | 293 const Operand *OpRm, CondARM32::Cond Cond); |
297 | 294 |
298 // Implements uxtb/uxth depending on type of OpSrc0. | 295 // Implements uxtb/uxth depending on type of OpSrc0. |
299 void uxt(const Operand *OpRd, const Operand *OpSrc0, CondARM32::Cond Cond); | 296 void uxt(const Operand *OpRd, const Operand *OpSrc0, CondARM32::Cond Cond); |
300 | 297 |
301 static bool classof(const Assembler *Asm) { | 298 static bool classof(const Assembler *Asm) { |
302 return Asm->getKind() == Asm_ARM32; | 299 return Asm->getKind() == Asm_ARM32; |
303 } | 300 } |
304 | 301 |
305 void emitTextInst(const std::string &Text, SizeT InstSize); | 302 void emitTextInst(const std::string &Text, SizeT InstSize); |
306 | 303 |
307 private: | 304 private: |
308 // A vector of pool-allocated x86 labels for CFG nodes. | 305 // A vector of pool-allocated x86 labels for CFG nodes. |
309 using LabelVector = std::vector<Label *>; | 306 using LabelVector = std::vector<Label *>; |
310 LabelVector CfgNodeLabels; | 307 LabelVector CfgNodeLabels; |
311 // A vector of pool-allocated x86 labels for Local labels. | 308 // A vector of pool-allocated x86 labels for Local labels. |
312 LabelVector LocalLabels; | 309 LabelVector LocalLabels; |
313 // Number of bytes emitted by InstARM32::emit() methods, when run inside | 310 // Number of bytes emitted by InstARM32::emit() methods, when run inside |
314 // InstARM32::emitUsingTextFixup(). | 311 // InstARM32::emitUsingTextFixup(). |
315 size_t EmitTextSize = 0; | 312 size_t EmitTextSize = 0; |
313 // Trap instruction (defined in textual byte order). | |
Jim Stichnoth
2015/12/11 23:31:08
"textual"? Maybe "little-endian" instead?
Karl
2015/12/17 16:23:09
Done.
| |
314 static const uint8_t TrapInst[]; | |
316 | 315 |
317 // Load/store multiple addressing mode. | 316 // Load/store multiple addressing mode. |
318 enum BlockAddressMode { | 317 enum BlockAddressMode { |
319 // bit encoding P U W | 318 // bit encoding P U W |
320 DA = (0 | 0 | 0) << 21, // decrement after | 319 DA = (0 | 0 | 0) << 21, // decrement after |
321 IA = (0 | 4 | 0) << 21, // increment after | 320 IA = (0 | 4 | 0) << 21, // increment after |
322 DB = (8 | 0 | 0) << 21, // decrement before | 321 DB = (8 | 0 | 0) << 21, // decrement before |
323 IB = (8 | 4 | 0) << 21, // increment before | 322 IB = (8 | 4 | 0) << 21, // increment before |
324 DA_W = (0 | 0 | 1) << 21, // decrement after with writeback to base | 323 DA_W = (0 | 0 | 1) << 21, // decrement after with writeback to base |
325 IA_W = (0 | 4 | 1) << 21, // increment after with writeback to base | 324 IA_W = (0 | 4 | 1) << 21, // increment after with writeback to base |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
425 // where cccc=Cond, xxxxxxx<<21=Opcode, dddd=Rd, s=SetFlags, and | 424 // where cccc=Cond, xxxxxxx<<21=Opcode, dddd=Rd, s=SetFlags, and |
426 // iiiiiiiiiiiiiiii=Imm16. | 425 // iiiiiiiiiiiiiiii=Imm16. |
427 void emitMovwt(CondARM32::Cond Cond, bool IsMovw, const Operand *OpRd, | 426 void emitMovwt(CondARM32::Cond Cond, bool IsMovw, const Operand *OpRd, |
428 const Operand *OpSrc, const char *MovName); | 427 const Operand *OpSrc, const char *MovName); |
429 }; | 428 }; |
430 | 429 |
431 } // end of namespace ARM32 | 430 } // end of namespace ARM32 |
432 } // end of namespace Ice | 431 } // end of namespace Ice |
433 | 432 |
434 #endif // SUBZERO_SRC_ICEASSEMBLERARM32_H | 433 #endif // SUBZERO_SRC_ICEASSEMBLERARM32_H |
OLD | NEW |