Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/x64/assembler-x64-inl.h

Issue 113841: Implement memory operands for instructions in the x64 assembler. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/x64/assembler-x64.h ('k') | test/cctest/test-assembler-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 *call_object_address() = target; 166 *call_object_address() = target;
167 } 167 }
168 168
169 169
170 Object** RelocInfo::call_object_address() { 170 Object** RelocInfo::call_object_address() {
171 UNIMPLEMENTED(); // IA32 code below. 171 UNIMPLEMENTED(); // IA32 code below.
172 ASSERT(IsCallInstruction()); 172 ASSERT(IsCallInstruction());
173 return reinterpret_cast<Object**>(pc_ + 1); 173 return reinterpret_cast<Object**>(pc_ + 1);
174 } 174 }
175 175
176 // -----------------------------------------------------------------------------
177 // Implementation of Operand
178
179 Operand::Operand(Register base, int32_t disp) {
180 len_ = 1;
181 if (base.is(rsp) || base.is(r12)) {
182 // SIB byte is needed to encode (rsp + offset) or (r12 + offset).
183 set_sib(times_1, rsp, base);
184 }
185
186 if (disp == 0 && !base.is(rbp) && !base.is(r13)) {
187 set_modrm(0, rsp);
188 } else if (is_int8(disp)) {
189 set_modrm(1, base);
190 set_disp8(disp);
191 } else {
192 set_modrm(2, base);
193 set_disp32(disp);
194 }
195 }
176 196
177 void Operand::set_modrm(int mod, Register rm) { 197 void Operand::set_modrm(int mod, Register rm) {
178 ASSERT((mod & -4) == 0); 198 ASSERT((mod & -4) == 0);
179 buf_[0] = mod << 6 | (rm.code() & 0x7); 199 buf_[0] = mod << 6 | (rm.code() & 0x7);
180 // Set REX.B to the high bit of rm.code(). 200 // Set REX.B to the high bit of rm.code().
181 rex_ |= (rm.code() >> 3); 201 rex_ |= (rm.code() >> 3);
182 len_ = 1;
183 } 202 }
184 203
185 204
186 void Operand::set_sib(ScaleFactor scale, Register index, Register base) { 205 void Operand::set_sib(ScaleFactor scale, Register index, Register base) {
187 ASSERT(len_ == 1); 206 ASSERT(len_ == 1);
188 ASSERT((scale & -4) == 0); 207 ASSERT((scale & -4) == 0);
189 // Use SIB with no index register only for base rsp or r12. 208 // Use SIB with no index register only for base rsp or r12.
190 ASSERT(!index.is(rsp) || base.is(rsp) || base.is(r12)); 209 ASSERT(!index.is(rsp) || base.is(rsp) || base.is(r12));
191 buf_[1] = scale << 6 | (index.code() & 0x7) << 3 | (base.code() & 0x7); 210 buf_[1] = scale << 6 | (index.code() & 0x7) << 3 | (base.code() & 0x7);
192 rex_ |= (index.code() >> 3) << 1 | base.code() >> 3; 211 rex_ |= (index.code() >> 3) << 1 | base.code() >> 3;
193 len_ = 2; 212 len_ = 2;
194 } 213 }
195 214
215 void Operand::set_disp8(int disp) {
216 ASSERT(is_int8(disp));
217 ASSERT(len_ == 1 || len_ == 2);
218 int8_t* p = reinterpret_cast<int8_t*>(&buf_[len_]);
219 *p = disp;
220 len_ += sizeof(int8_t);
221 }
196 222
197 void Operand::set_disp32(int32_t disp) { 223 void Operand::set_disp32(int disp) {
198 ASSERT(len_ == 1 || len_ == 2); 224 ASSERT(len_ == 1 || len_ == 2);
199 int32_t* p = reinterpret_cast<int32_t*>(&buf_[len_]); 225 int32_t* p = reinterpret_cast<int32_t*>(&buf_[len_]);
200 *p = disp; 226 *p = disp;
201 len_ += sizeof(int32_t); 227 len_ += sizeof(int32_t);
202 } 228 }
203 229
204 230
205 Operand::Operand(Register reg) {
206 // reg
207 set_modrm(3, reg);
208 }
209
210 } } // namespace v8::internal 231 } } // namespace v8::internal
211 232
212 #endif // V8_X64_ASSEMBLER_X64_INL_H_ 233 #endif // V8_X64_ASSEMBLER_X64_INL_H_
OLDNEW
« no previous file with comments | « src/x64/assembler-x64.h ('k') | test/cctest/test-assembler-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698