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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 // Verify internal state. | 126 // Verify internal state. |
127 assert(capacity() == new_capacity); | 127 assert(capacity() == new_capacity); |
128 assert(size() == old_size); | 128 assert(size() == old_size); |
129 } | 129 } |
130 | 130 |
131 llvm::StringRef Assembler::getBufferView() const { | 131 llvm::StringRef Assembler::getBufferView() const { |
132 return llvm::StringRef(reinterpret_cast<const char *>(Buffer.contents()), | 132 return llvm::StringRef(reinterpret_cast<const char *>(Buffer.contents()), |
133 Buffer.size()); | 133 Buffer.size()); |
134 } | 134 } |
135 | 135 |
136 void Assembler::emitIASBytes() const { | 136 void Assembler::emitIASBytes(GlobalContext *Ctx) const { |
137 Ostream &Str = Ctx->getStrEmit(); | 137 Ostream &Str = Ctx->getStrEmit(); |
138 intptr_t EndPosition = Buffer.size(); | 138 intptr_t EndPosition = Buffer.size(); |
139 intptr_t CurPosition = 0; | 139 intptr_t CurPosition = 0; |
140 for (const AssemblerFixup *NextFixup : fixups()) { | 140 for (const AssemblerFixup *NextFixup : fixups()) { |
141 intptr_t NextFixupLoc = NextFixup->position(); | 141 intptr_t NextFixupLoc = NextFixup->position(); |
142 for (intptr_t i = CurPosition; i < NextFixupLoc; ++i) { | 142 for (intptr_t i = CurPosition; i < NextFixupLoc; ++i) { |
143 Str << "\t.byte 0x"; | 143 Str << "\t.byte 0x"; |
144 Str.write_hex(Buffer.load<uint8_t>(i)); | 144 Str.write_hex(Buffer.load<uint8_t>(i)); |
145 Str << "\n"; | 145 Str << "\n"; |
146 } | 146 } |
147 // For PCRel fixups, we write the pc-offset from a symbol into the Buffer | 147 // For PCRel fixups, we write the pc-offset from a symbol into the Buffer |
148 // (e.g., -4), but we don't represent that in the fixup's offset. Otherwise | 148 // (e.g., -4), but we don't represent that in the fixup's offset. Otherwise |
149 // the fixup holds the true offset, and so does the Buffer. Just load the | 149 // the fixup holds the true offset, and so does the Buffer. Just load the |
150 // offset from the buffer. | 150 // offset from the buffer. |
151 CurPosition = NextFixupLoc + | 151 CurPosition = NextFixupLoc + |
152 NextFixup->emit(Ctx, Buffer.load<RelocOffsetT>(NextFixupLoc), | 152 NextFixup->emit(Ctx, Buffer.load<RelocOffsetT>(NextFixupLoc), |
153 fixupIsPCRel(NextFixup->kind())); | 153 fixupIsPCRel(NextFixup->kind())); |
154 assert(CurPosition <= EndPosition); | 154 assert(CurPosition <= EndPosition); |
155 } | 155 } |
156 // Handle any bytes that are not prefixed by a fixup. | 156 // Handle any bytes that are not prefixed by a fixup. |
157 for (intptr_t i = CurPosition; i < EndPosition; ++i) { | 157 for (intptr_t i = CurPosition; i < EndPosition; ++i) { |
158 Str << "\t.byte 0x"; | 158 Str << "\t.byte 0x"; |
159 Str.write_hex(Buffer.load<uint8_t>(i)); | 159 Str.write_hex(Buffer.load<uint8_t>(i)); |
160 Str << "\n"; | 160 Str << "\n"; |
161 } | 161 } |
162 } | 162 } |
163 | 163 |
164 } // end of namespace Ice | 164 } // end of namespace Ice |
OLD | NEW |