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

Side by Side Diff: src/a64/instructions-a64.h

Issue 169893002: A64: Let the MacroAssembler resolve branches to distant targets. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed Ulan's comments. Created 6 years, 10 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
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 return UncondBranchType; 273 return UncondBranchType;
274 } else if (IsCompareBranch()) { 274 } else if (IsCompareBranch()) {
275 return CompareBranchType; 275 return CompareBranchType;
276 } else if (IsTestBranch()) { 276 } else if (IsTestBranch()) {
277 return TestBranchType; 277 return TestBranchType;
278 } else { 278 } else {
279 return UnknownBranchType; 279 return UnknownBranchType;
280 } 280 }
281 } 281 }
282 282
283 static int ImmBranchRangeBitwidth(ImmBranchType branch_type) {
284 switch (branch_type) {
285 case UncondBranchType:
286 return ImmUncondBranch_width;
287 case CondBranchType:
288 return ImmCondBranch_width;
289 case CompareBranchType:
290 return ImmCmpBranch_width;
291 case TestBranchType:
292 return ImmTestBranch_width;
293 default:
294 UNREACHABLE();
295 return 0;
296 }
297 }
298
299 // The range of the branch instruction, expressed as 'instr +- range'.
300 static int32_t ImmBranchRange(ImmBranchType branch_type) {
301 return
302 (1 << (ImmBranchRangeBitwidth(branch_type) + kInstructionSizeLog2)) / 2 -
303 kInstructionSize;
304 }
305
283 int ImmBranch() const { 306 int ImmBranch() const {
284 switch (BranchType()) { 307 switch (BranchType()) {
285 case CondBranchType: return ImmCondBranch(); 308 case CondBranchType: return ImmCondBranch();
286 case UncondBranchType: return ImmUncondBranch(); 309 case UncondBranchType: return ImmUncondBranch();
287 case CompareBranchType: return ImmCmpBranch(); 310 case CompareBranchType: return ImmCmpBranch();
288 case TestBranchType: return ImmTestBranch(); 311 case TestBranchType: return ImmTestBranch();
289 default: UNREACHABLE(); 312 default: UNREACHABLE();
290 } 313 }
291 return 0; 314 return 0;
292 } 315 }
(...skipping 29 matching lines...) Expand all
322 345
323 // Find the PC offset encoded in this instruction. 'this' may be a branch or 346 // Find the PC offset encoded in this instruction. 'this' may be a branch or
324 // a PC-relative addressing instruction. 347 // a PC-relative addressing instruction.
325 // The offset returned is unscaled. 348 // The offset returned is unscaled.
326 ptrdiff_t ImmPCOffset(); 349 ptrdiff_t ImmPCOffset();
327 350
328 // Find the target of this instruction. 'this' may be a branch or a 351 // Find the target of this instruction. 'this' may be a branch or a
329 // PC-relative addressing instruction. 352 // PC-relative addressing instruction.
330 Instruction* ImmPCOffsetTarget(); 353 Instruction* ImmPCOffsetTarget();
331 354
355 static bool IsValidImmPCOffset(ImmBranchType branch_type, int32_t offset);
356 bool IsTargetInImmPCOffsetRange(Instruction* target);
332 // Patch a PC-relative offset to refer to 'target'. 'this' may be a branch or 357 // Patch a PC-relative offset to refer to 'target'. 'this' may be a branch or
333 // a PC-relative addressing instruction. 358 // a PC-relative addressing instruction.
334 void SetImmPCOffsetTarget(Instruction* target); 359 void SetImmPCOffsetTarget(Instruction* target);
335 // Patch a literal load instruction to load from 'source'. 360 // Patch a literal load instruction to load from 'source'.
336 void SetImmLLiteral(Instruction* source); 361 void SetImmLLiteral(Instruction* source);
337 362
338 uint8_t* LiteralAddress() { 363 uint8_t* LiteralAddress() {
339 int offset = ImmLLiteral() << kLiteralEntrySizeLog2; 364 int offset = ImmLLiteral() << kLiteralEntrySizeLog2;
340 return reinterpret_cast<uint8_t*>(this) + offset; 365 return reinterpret_cast<uint8_t*>(this) + offset;
341 } 366 }
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 TRACE_ENABLE = 1 << 6, 507 TRACE_ENABLE = 1 << 6,
483 TRACE_DISABLE = 2 << 6, 508 TRACE_DISABLE = 2 << 6,
484 TRACE_OVERRIDE = 3 << 6 509 TRACE_OVERRIDE = 3 << 6
485 }; 510 };
486 511
487 512
488 } } // namespace v8::internal 513 } } // namespace v8::internal
489 514
490 515
491 #endif // V8_A64_INSTRUCTIONS_A64_H_ 516 #endif // V8_A64_INSTRUCTIONS_A64_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698