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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 intptr_t CurPosition = 0; | 125 intptr_t CurPosition = 0; |
126 const intptr_t FixupSize = 4; | 126 const intptr_t FixupSize = 4; |
127 for (const AssemblerFixup *NextFixup : fixups()) { | 127 for (const AssemblerFixup *NextFixup : fixups()) { |
128 intptr_t NextFixupLoc = NextFixup->position(); | 128 intptr_t NextFixupLoc = NextFixup->position(); |
129 for (intptr_t i = CurPosition; i < NextFixupLoc; ++i) { | 129 for (intptr_t i = CurPosition; i < NextFixupLoc; ++i) { |
130 Str << "\t.byte 0x"; | 130 Str << "\t.byte 0x"; |
131 Str.write_hex(Buffer.load<uint8_t>(i)); | 131 Str.write_hex(Buffer.load<uint8_t>(i)); |
132 Str << "\n"; | 132 Str << "\n"; |
133 } | 133 } |
134 Str << "\t.long "; | 134 Str << "\t.long "; |
| 135 // For PCRel fixups, we write the pc-offset from a symbol into the Buffer |
| 136 // (e.g., -4), but we don't represent that in the fixup's offset. |
| 137 // Otherwise the fixup holds the true offset, and so does the Buffer. |
| 138 // Just load the offset from the buffer. |
135 NextFixup->emit(Ctx, Buffer.load<RelocOffsetT>(NextFixupLoc)); | 139 NextFixup->emit(Ctx, Buffer.load<RelocOffsetT>(NextFixupLoc)); |
136 if (fixupIsPCRel(NextFixup->kind())) | 140 if (fixupIsPCRel(NextFixup->kind())) |
137 Str << " - ."; | 141 Str << " - ."; |
138 Str << "\n"; | 142 Str << "\n"; |
139 CurPosition = NextFixupLoc + FixupSize; | 143 CurPosition = NextFixupLoc + FixupSize; |
140 assert(CurPosition <= EndPosition); | 144 assert(CurPosition <= EndPosition); |
141 } | 145 } |
142 // Handle any bytes that are not prefixed by a fixup. | 146 // Handle any bytes that are not prefixed by a fixup. |
143 for (intptr_t i = CurPosition; i < EndPosition; ++i) { | 147 for (intptr_t i = CurPosition; i < EndPosition; ++i) { |
144 Str << "\t.byte 0x"; | 148 Str << "\t.byte 0x"; |
145 Str.write_hex(Buffer.load<uint8_t>(i)); | 149 Str.write_hex(Buffer.load<uint8_t>(i)); |
146 Str << "\n"; | 150 Str << "\n"; |
147 } | 151 } |
148 } | 152 } |
149 | 153 |
150 } // end of namespace Ice | 154 } // end of namespace Ice |
OLD | NEW |