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 20 matching lines...) Expand all Loading... | |
31 #include "IceConditionCodesARM32.h" | 31 #include "IceConditionCodesARM32.h" |
32 #include "IceDefs.h" | 32 #include "IceDefs.h" |
33 #include "IceFixups.h" | 33 #include "IceFixups.h" |
34 #include "IceInstARM32.h" | 34 #include "IceInstARM32.h" |
35 #include "IceRegistersARM32.h" | 35 #include "IceRegistersARM32.h" |
36 #include "IceTargetLowering.h" | 36 #include "IceTargetLowering.h" |
37 | 37 |
38 namespace Ice { | 38 namespace Ice { |
39 namespace ARM32 { | 39 namespace ARM32 { |
40 | 40 |
41 /// Extends a fixup to be a textual, instruction fixup. That is, it emits text | |
42 /// containing an instruction. This class is used to implement unimplemented | |
43 /// emitIAS methods, allowing them to generate compilable assembly code. | |
44 class TextInstFixup : public AssemblerFixup { | |
45 public: | |
46 TextInstFixup(const std::string &Message) | |
47 : AssemblerFixup(), Message(Message) {} | |
48 ~TextInstFixup() = default; | |
49 virtual size_t emit(GlobalContext *Ctx, RelocOffsetT OverrideOffset, | |
50 bool isPcRel) const; | |
51 | |
52 private: | |
53 std::string Message; | |
Jim Stichnoth
2015/10/20 16:28:27
Can/should this be const?
Karl
2015/10/20 21:29:31
Done.
| |
54 }; | |
55 | |
41 class AssemblerARM32 : public Assembler { | 56 class AssemblerARM32 : public Assembler { |
42 AssemblerARM32(const AssemblerARM32 &) = delete; | 57 AssemblerARM32(const AssemblerARM32 &) = delete; |
43 AssemblerARM32 &operator=(const AssemblerARM32 &) = delete; | 58 AssemblerARM32 &operator=(const AssemblerARM32 &) = delete; |
44 | 59 |
45 public: | 60 public: |
46 explicit AssemblerARM32(GlobalContext *Ctx, bool use_far_branches = false) | 61 explicit AssemblerARM32(GlobalContext *Ctx, bool use_far_branches = false) |
47 : Assembler(Asm_ARM32, Ctx) { | 62 : Assembler(Asm_ARM32, Ctx) { |
48 // TODO(kschimpf): Add mode if needed when branches are handled. | 63 // TODO(kschimpf): Add mode if needed when branches are handled. |
49 (void)use_far_branches; | 64 (void)use_far_branches; |
50 } | 65 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 } | 99 } |
85 | 100 |
86 void bindCfgNodeLabel(SizeT NodeNumber) override { | 101 void bindCfgNodeLabel(SizeT NodeNumber) override { |
87 assert(!getPreliminary()); | 102 assert(!getPreliminary()); |
88 Label *L = getOrCreateCfgNodeLabel(NodeNumber); | 103 Label *L = getOrCreateCfgNodeLabel(NodeNumber); |
89 this->bind(L); | 104 this->bind(L); |
90 } | 105 } |
91 | 106 |
92 bool fixupIsPCRel(FixupKind Kind) const override { | 107 bool fixupIsPCRel(FixupKind Kind) const override { |
93 (void)Kind; | 108 (void)Kind; |
94 llvm_unreachable("Not yet implemented."); | 109 // TODO(kschimpf) Decide if we need this. |
110 return false; | |
95 } | 111 } |
96 | 112 |
97 void bind(Label *label); | 113 void bind(Label *label); |
98 | 114 |
99 // List of instructions implemented by integrated assembler. | 115 // List of instructions implemented by integrated assembler. Returns true |
116 // if able to generate corresponding instruction from given arguments. | |
100 | 117 |
101 void add(const Operand *OpRd, const Operand *OpRn, const Operand *OpSrc1, | 118 bool add(const Operand *OpRd, const Operand *OpRn, const Operand *OpSrc1, |
102 bool SetFlags, CondARM32::Cond Cond); | 119 bool SetFlags, CondARM32::Cond Cond); |
103 | 120 |
104 void bkpt(uint16_t Imm16); | 121 bool bkpt(uint16_t Imm16); |
105 | 122 |
106 void ldr(const Operand *OpRt, const Operand *OpAddress, CondARM32::Cond Cond); | 123 bool ldr(const Operand *OpRt, const Operand *OpAddress, CondARM32::Cond Cond); |
107 | 124 |
108 void mov(const Operand *OpRd, const Operand *OpSrc, CondARM32::Cond Cond); | 125 bool mov(const Operand *OpRd, const Operand *OpSrc, CondARM32::Cond Cond); |
109 | 126 |
110 void bx(RegARM32::GPRRegister Rm, CondARM32::Cond Cond = CondARM32::AL); | 127 bool bx(RegARM32::GPRRegister Rm, CondARM32::Cond Cond = CondARM32::AL); |
111 | 128 |
112 void str(const Operand *OpRt, const Operand *OpAddress, CondARM32::Cond Cond); | 129 bool str(const Operand *OpRt, const Operand *OpAddress, CondARM32::Cond Cond); |
113 | 130 |
114 void sub(const Operand *OpRd, const Operand *OpRn, const Operand *OpSrc1, | 131 bool sub(const Operand *OpRd, const Operand *OpRn, const Operand *OpSrc1, |
115 bool SetFlags, CondARM32::Cond Cond); | 132 bool SetFlags, CondARM32::Cond Cond); |
116 | 133 |
117 static bool classof(const Assembler *Asm) { | 134 static bool classof(const Assembler *Asm) { |
118 return Asm->getKind() == Asm_ARM32; | 135 return Asm->getKind() == Asm_ARM32; |
119 } | 136 } |
120 | 137 |
138 void emitTextInst(const std::string &Text); | |
139 | |
121 private: | 140 private: |
122 // A vector of pool-allocated x86 labels for CFG nodes. | 141 // A vector of pool-allocated x86 labels for CFG nodes. |
123 using LabelVector = std::vector<Label *>; | 142 using LabelVector = std::vector<Label *>; |
124 LabelVector CfgNodeLabels; | 143 LabelVector CfgNodeLabels; |
125 | 144 |
126 Label *getOrCreateLabel(SizeT Number, LabelVector &Labels); | 145 Label *getOrCreateLabel(SizeT Number, LabelVector &Labels); |
127 Label *getOrCreateCfgNodeLabel(SizeT NodeNumber) { | 146 Label *getOrCreateCfgNodeLabel(SizeT NodeNumber) { |
128 return getOrCreateLabel(NodeNumber, CfgNodeLabels); | 147 return getOrCreateLabel(NodeNumber, CfgNodeLabels); |
129 } | 148 } |
130 | 149 |
131 void emitInst(uint32_t Value) { Buffer.emit<uint32_t>(Value); } | 150 void emitInst(uint32_t Value) { Buffer.emit<uint32_t>(Value); } |
132 | 151 |
133 // Pattern cccctttoooosnnnnddddiiiiiiiiiiii where cccc=Cond, ttt=Type, | 152 // Pattern cccctttoooosnnnnddddiiiiiiiiiiii where cccc=Cond, ttt=Type, |
134 // oooo=Opcode, nnnn=Rn, dddd=Rd, iiiiiiiiiiii=imm12 (See ARM section A5.2.3). | 153 // 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, | 154 void emitType01(CondARM32::Cond Cond, uint32_t Type, uint32_t Opcode, |
136 bool SetCc, uint32_t Rn, uint32_t Rd, uint32_t imm12); | 155 bool SetCc, uint32_t Rn, uint32_t Rd, uint32_t imm12); |
137 | 156 |
138 // Pattern ccccoooaabalnnnnttttaaaaaaaaaaaa where cccc=Cond, ooo=InstType, | 157 // Pattern ccccoooaabalnnnnttttaaaaaaaaaaaa where cccc=Cond, ooo=InstType, |
139 // l=isLoad, b=isByte, and aaa0a0aaaa0000aaaaaaaaaaaa=Address. Note that | 158 // l=isLoad, b=isByte, and aaa0a0aaaa0000aaaaaaaaaaaa=Address. Note that |
140 // Address is assumed to be defined by decodeAddress() in | 159 // Address is assumed to be defined by decodeAddress() in |
141 // IceAssemblerARM32.cpp. | 160 // IceAssemblerARM32.cpp. |
142 void emitMemOp(CondARM32::Cond Cond, uint32_t InstType, bool IsLoad, | 161 void emitMemOp(CondARM32::Cond Cond, uint32_t InstType, bool IsLoad, |
143 bool IsByte, uint32_t Rt, uint32_t Address); | 162 bool IsByte, uint32_t Rt, uint32_t Address); |
144 }; | 163 }; |
145 | 164 |
146 } // end of namespace ARM32 | 165 } // end of namespace ARM32 |
147 } // end of namespace Ice | 166 } // end of namespace Ice |
148 | 167 |
149 #endif // SUBZERO_SRC_ICEASSEMBLERARM32_H | 168 #endif // SUBZERO_SRC_ICEASSEMBLERARM32_H |
OLD | NEW |