OLD | NEW |
1 //===- subzero/src/IceAssembler.cpp - Assembler base class ----------------===// | 1 //===- subzero/src/IceAssembler.cpp - Assembler base class ----------------===// |
2 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
5 // | 5 // |
6 // Modified by the Subzero authors. | 6 // Modified by the Subzero authors. |
7 // | 7 // |
8 // This is forked from Dart revision 39313. | 8 // This is forked from Dart revision 39313. |
9 // Please update the revision if we merge back changes from Dart. | 9 // Please update the revision if we merge back changes from Dart. |
10 // https://code.google.com/p/dart/wiki/GettingTheSource | 10 // https://code.google.com/p/dart/wiki/GettingTheSource |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 // Verify internal state. | 136 // Verify internal state. |
137 assert(capacity() == new_capacity); | 137 assert(capacity() == new_capacity); |
138 assert(size() == old_size); | 138 assert(size() == old_size); |
139 } | 139 } |
140 | 140 |
141 llvm::StringRef Assembler::getBufferView() const { | 141 llvm::StringRef Assembler::getBufferView() const { |
142 return llvm::StringRef(reinterpret_cast<const char *>(Buffer.contents()), | 142 return llvm::StringRef(reinterpret_cast<const char *>(Buffer.contents()), |
143 Buffer.size()); | 143 Buffer.size()); |
144 } | 144 } |
145 | 145 |
| 146 void Assembler::bindRelocOffset(RelocOffset *Offset) { |
| 147 if (!getPreliminary()) { |
| 148 Offset->setOffset(Buffer.getPosition()); |
| 149 } |
| 150 } |
| 151 |
146 void Assembler::emitIASBytes(GlobalContext *Ctx) const { | 152 void Assembler::emitIASBytes(GlobalContext *Ctx) const { |
147 Ostream &Str = Ctx->getStrEmit(); | 153 Ostream &Str = Ctx->getStrEmit(); |
148 intptr_t EndPosition = Buffer.size(); | 154 intptr_t EndPosition = Buffer.size(); |
149 intptr_t CurPosition = 0; | 155 intptr_t CurPosition = 0; |
150 for (const AssemblerFixup *NextFixup : fixups()) { | 156 for (const AssemblerFixup *NextFixup : fixups()) { |
151 intptr_t NextFixupLoc = NextFixup->position(); | 157 intptr_t NextFixupLoc = NextFixup->position(); |
152 for (intptr_t i = CurPosition; i < NextFixupLoc; ++i) { | 158 for (intptr_t i = CurPosition; i < NextFixupLoc; ++i) { |
153 Str << "\t.byte 0x"; | 159 Str << "\t.byte 0x"; |
154 Str.write_hex(Buffer.load<uint8_t>(i)); | 160 Str.write_hex(Buffer.load<uint8_t>(i)); |
155 Str << "\n"; | 161 Str << "\n"; |
156 } | 162 } |
157 CurPosition = NextFixupLoc + NextFixup->emit(Ctx, *this); | 163 CurPosition = NextFixupLoc + NextFixup->emit(Ctx, *this); |
158 assert(CurPosition <= EndPosition); | 164 assert(CurPosition <= EndPosition); |
159 } | 165 } |
160 // Handle any bytes that are not prefixed by a fixup. | 166 // Handle any bytes that are not prefixed by a fixup. |
161 for (intptr_t i = CurPosition; i < EndPosition; ++i) { | 167 for (intptr_t i = CurPosition; i < EndPosition; ++i) { |
162 Str << "\t.byte 0x"; | 168 Str << "\t.byte 0x"; |
163 Str.write_hex(Buffer.load<uint8_t>(i)); | 169 Str.write_hex(Buffer.load<uint8_t>(i)); |
164 Str << "\n"; | 170 Str << "\n"; |
165 } | 171 } |
166 } | 172 } |
167 | 173 |
168 } // end of namespace Ice | 174 } // end of namespace Ice |
OLD | NEW |