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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 explicit AssemblerARM32(GlobalContext *Ctx, bool use_far_branches = false) | 46 explicit AssemblerARM32(GlobalContext *Ctx, bool use_far_branches = false) |
47 : Assembler(Asm_ARM32, Ctx) { | 47 : Assembler(Asm_ARM32, Ctx) { |
48 // TODO(kschimpf): Add mode if needed when branches are handled. | 48 // TODO(kschimpf): Add mode if needed when branches are handled. |
49 (void)use_far_branches; | 49 (void)use_far_branches; |
50 } | 50 } |
51 ~AssemblerARM32() override = default; | 51 ~AssemblerARM32() override = default; |
52 | 52 |
53 void alignFunction() override { | 53 void alignFunction() override { |
54 const SizeT Align = 1 << getBundleAlignLog2Bytes(); | 54 const SizeT Align = 1 << getBundleAlignLog2Bytes(); |
55 SizeT BytesNeeded = Utils::OffsetToAlignment(Buffer.getPosition(), Align); | 55 SizeT BytesNeeded = Utils::OffsetToAlignment(Buffer.getPosition(), Align); |
| 56 constexpr uint32_t UndefinedInst = 0xe7fedef0; // udf #60896 |
56 constexpr SizeT InstSize = sizeof(int32_t); | 57 constexpr SizeT InstSize = sizeof(int32_t); |
57 assert(BytesNeeded % InstSize == 0); | 58 assert(BytesNeeded % InstSize == 0); |
58 while (BytesNeeded > 0) { | 59 while (BytesNeeded > 0) { |
59 // TODO(kschimpf) Should this be NOP or some other instruction? | 60 AssemblerBuffer::EnsureCapacity ensured(&Buffer); |
60 bkpt(0); | 61 emitInst(UndefinedInst); |
61 BytesNeeded -= InstSize; | 62 BytesNeeded -= InstSize; |
62 } | 63 } |
63 } | 64 } |
64 | 65 |
65 SizeT getBundleAlignLog2Bytes() const override { return 4; } | 66 SizeT getBundleAlignLog2Bytes() const override { return 4; } |
66 | 67 |
67 const char *getAlignDirective() const override { return ".p2alignl"; } | 68 const char *getAlignDirective() const override { return ".p2alignl"; } |
68 | 69 |
69 llvm::ArrayRef<uint8_t> getNonExecBundlePadding() const override { | 70 llvm::ArrayRef<uint8_t> getNonExecBundlePadding() const override { |
70 // Use a particular UDF encoding -- TRAPNaCl in LLVM: 0xE7FEDEF0 | 71 // Use a particular UDF encoding -- TRAPNaCl in LLVM: 0xE7FEDEF0 |
(...skipping 13 matching lines...) Expand all Loading... |
84 } | 85 } |
85 | 86 |
86 void bindCfgNodeLabel(SizeT NodeNumber) override { | 87 void bindCfgNodeLabel(SizeT NodeNumber) override { |
87 assert(!getPreliminary()); | 88 assert(!getPreliminary()); |
88 Label *L = getOrCreateCfgNodeLabel(NodeNumber); | 89 Label *L = getOrCreateCfgNodeLabel(NodeNumber); |
89 this->bind(L); | 90 this->bind(L); |
90 } | 91 } |
91 | 92 |
92 bool fixupIsPCRel(FixupKind Kind) const override { | 93 bool fixupIsPCRel(FixupKind Kind) const override { |
93 (void)Kind; | 94 (void)Kind; |
94 llvm_unreachable("Not yet implemented."); | 95 // TODO(kschimpf) Decide if we need this. |
| 96 return false; |
95 } | 97 } |
96 | 98 |
97 void bind(Label *label); | 99 void bind(Label *label); |
98 | 100 |
99 // List of instructions implemented by integrated assembler. | 101 // List of instructions implemented by integrated assembler. |
100 | 102 |
101 void add(const Operand *OpRd, const Operand *OpRn, const Operand *OpSrc1, | 103 void add(const Operand *OpRd, const Operand *OpRn, const Operand *OpSrc1, |
102 bool SetFlags, CondARM32::Cond Cond); | 104 bool SetFlags, CondARM32::Cond Cond); |
103 | 105 |
104 void bkpt(uint16_t Imm16); | 106 void bkpt(uint16_t Imm16); |
105 | 107 |
106 void ldr(const Operand *OpRt, const Operand *OpAddress, CondARM32::Cond Cond); | 108 void ldr(const Operand *OpRt, const Operand *OpAddress, CondARM32::Cond Cond); |
107 | 109 |
108 void mov(const Operand *OpRd, const Operand *OpSrc, CondARM32::Cond Cond); | 110 void mov(const Operand *OpRd, const Operand *OpSrc, CondARM32::Cond Cond); |
109 | 111 |
110 void bx(RegARM32::GPRRegister Rm, CondARM32::Cond Cond = CondARM32::AL); | 112 void bx(RegARM32::GPRRegister Rm, CondARM32::Cond Cond = CondARM32::AL); |
111 | 113 |
112 void str(const Operand *OpRt, const Operand *OpAddress, CondARM32::Cond Cond); | 114 void str(const Operand *OpRt, const Operand *OpAddress, CondARM32::Cond Cond); |
113 | 115 |
114 void sub(const Operand *OpRd, const Operand *OpRn, const Operand *OpSrc1, | 116 void sub(const Operand *OpRd, const Operand *OpRn, const Operand *OpSrc1, |
115 bool SetFlags, CondARM32::Cond Cond); | 117 bool SetFlags, CondARM32::Cond Cond); |
116 | 118 |
117 static bool classof(const Assembler *Asm) { | 119 static bool classof(const Assembler *Asm) { |
118 return Asm->getKind() == Asm_ARM32; | 120 return Asm->getKind() == Asm_ARM32; |
119 } | 121 } |
120 | 122 |
| 123 void emitTextInst(const std::string &Text); |
| 124 |
121 private: | 125 private: |
122 // A vector of pool-allocated x86 labels for CFG nodes. | 126 // A vector of pool-allocated x86 labels for CFG nodes. |
123 using LabelVector = std::vector<Label *>; | 127 using LabelVector = std::vector<Label *>; |
124 LabelVector CfgNodeLabels; | 128 LabelVector CfgNodeLabels; |
125 | 129 |
126 Label *getOrCreateLabel(SizeT Number, LabelVector &Labels); | 130 Label *getOrCreateLabel(SizeT Number, LabelVector &Labels); |
127 Label *getOrCreateCfgNodeLabel(SizeT NodeNumber) { | 131 Label *getOrCreateCfgNodeLabel(SizeT NodeNumber) { |
128 return getOrCreateLabel(NodeNumber, CfgNodeLabels); | 132 return getOrCreateLabel(NodeNumber, CfgNodeLabels); |
129 } | 133 } |
130 | 134 |
131 void emitInst(uint32_t Value) { Buffer.emit<uint32_t>(Value); } | 135 void emitInst(uint32_t Value) { Buffer.emit<uint32_t>(Value); } |
132 | 136 |
133 // Pattern cccctttoooosnnnnddddiiiiiiiiiiii where cccc=Cond, ttt=Type, | 137 // Pattern cccctttoooosnnnnddddiiiiiiiiiiii where cccc=Cond, ttt=Type, |
134 // oooo=Opcode, nnnn=Rn, dddd=Rd, iiiiiiiiiiii=imm12 (See ARM section A5.2.3). | 138 // oooo=Opcode, nnnn=Rn, dddd=Rd, iiiiiiiiiiii=imm12 (See ARM section A5.2.3). |
135 void emitType01(CondARM32::Cond Cond, uint32_t Type, uint32_t Opcode, | 139 void emitType01(CondARM32::Cond Cond, uint32_t Type, uint32_t Opcode, |
136 bool SetCc, uint32_t Rn, uint32_t Rd, uint32_t imm12); | 140 bool SetCc, uint32_t Rn, uint32_t Rd, uint32_t imm12); |
137 | 141 |
138 // Pattern ccccoooaabalnnnnttttaaaaaaaaaaaa where cccc=Cond, ooo=InstType, | 142 // Pattern ccccoooaabalnnnnttttaaaaaaaaaaaa where cccc=Cond, ooo=InstType, |
139 // l=isLoad, b=isByte, and aaa0a0aaaa0000aaaaaaaaaaaa=Address. Note that | 143 // l=isLoad, b=isByte, and aaa0a0aaaa0000aaaaaaaaaaaa=Address. Note that |
140 // Address is assumed to be defined by decodeAddress() in | 144 // Address is assumed to be defined by decodeAddress() in |
141 // IceAssemblerARM32.cpp. | 145 // IceAssemblerARM32.cpp. |
142 void emitMemOp(CondARM32::Cond Cond, uint32_t InstType, bool IsLoad, | 146 void emitMemOp(CondARM32::Cond Cond, uint32_t InstType, bool IsLoad, |
143 bool IsByte, uint32_t Rt, uint32_t Address); | 147 bool IsByte, uint32_t Rt, uint32_t Address); |
144 }; | 148 }; |
145 | 149 |
146 } // end of namespace ARM32 | 150 } // end of namespace ARM32 |
147 } // end of namespace Ice | 151 } // end of namespace Ice |
148 | 152 |
149 #endif // SUBZERO_SRC_ICEASSEMBLERARM32_H | 153 #endif // SUBZERO_SRC_ICEASSEMBLERARM32_H |
OLD | NEW |