Index: src/arm64/instructions-arm64.cc |
diff --git a/src/arm64/instructions-arm64.cc b/src/arm64/instructions-arm64.cc |
index 7a5effe427847582dd71e3bff9e14a29e97edca2..814ead318c749960cebcd3ace5767f36cfa87bb1 100644 |
--- a/src/arm64/instructions-arm64.cc |
+++ b/src/arm64/instructions-arm64.cc |
@@ -93,9 +93,9 @@ static uint64_t RepeatBitsAcrossReg(unsigned reg_size, |
// met. |
uint64_t Instruction::ImmLogical() { |
unsigned reg_size = SixtyFourBits() ? kXRegSizeInBits : kWRegSizeInBits; |
- int64_t n = BitN(); |
- int64_t imm_s = ImmSetBits(); |
- int64_t imm_r = ImmRotate(); |
+ int32_t n = BitN(); |
+ int32_t imm_s = ImmSetBits(); |
+ int32_t imm_r = ImmRotate(); |
// An integer is constructed from the n, imm_s and imm_r bits according to |
// the following table: |
@@ -211,7 +211,7 @@ Instruction* Instruction::ImmPCOffsetTarget() { |
bool Instruction::IsValidImmPCOffset(ImmBranchType branch_type, |
- int32_t offset) { |
+ ptrdiff_t offset) { |
return is_intn(offset, ImmBranchRangeBitwidth(branch_type)); |
} |
@@ -242,7 +242,7 @@ void Instruction::SetPCRelImmTarget(Instruction* target) { |
ptrdiff_t target_offset = DistanceTo(target); |
Instr imm; |
if (Instruction::IsValidPCRelOffset(target_offset)) { |
- imm = Assembler::ImmPCRelAddress(target_offset); |
+ imm = Assembler::ImmPCRelAddress(static_cast<int>(target_offset)); |
SetInstructionBits(Mask(~ImmPCRel_mask) | imm); |
} else { |
PatchingAssembler patcher(this, |
@@ -254,9 +254,11 @@ void Instruction::SetPCRelImmTarget(Instruction* target) { |
void Instruction::SetBranchImmTarget(Instruction* target) { |
DCHECK(IsAligned(DistanceTo(target), kInstructionSize)); |
+ DCHECK(IsValidImmPCOffset(BranchType(), |
+ DistanceTo(target) >> kInstructionSizeLog2)); |
+ int offset = static_cast<int>(DistanceTo(target) >> kInstructionSizeLog2); |
Instr branch_imm = 0; |
uint32_t imm_mask = 0; |
- ptrdiff_t offset = DistanceTo(target) >> kInstructionSizeLog2; |
switch (BranchType()) { |
case CondBranchType: { |
branch_imm = Assembler::ImmCondBranch(offset); |
@@ -287,9 +289,9 @@ void Instruction::SetBranchImmTarget(Instruction* target) { |
void Instruction::SetUnresolvedInternalReferenceImmTarget(Instruction* target) { |
DCHECK(IsUnresolvedInternalReference()); |
DCHECK(IsAligned(DistanceTo(target), kInstructionSize)); |
- |
- ptrdiff_t target_offset = DistanceTo(target) >> kInstructionSizeLog2; |
- DCHECK(is_int32(target_offset)); |
+ DCHECK(is_int32(DistanceTo(target) >> kInstructionSizeLog2)); |
+ int32_t target_offset = |
+ static_cast<int32_t>(DistanceTo(target) >> kInstructionSizeLog2); |
uint32_t high16 = unsigned_bitextract_32(31, 16, target_offset); |
uint32_t low16 = unsigned_bitextract_32(15, 0, target_offset); |
@@ -302,8 +304,9 @@ void Instruction::SetUnresolvedInternalReferenceImmTarget(Instruction* target) { |
void Instruction::SetImmLLiteral(Instruction* source) { |
DCHECK(IsLdrLiteral()); |
DCHECK(IsAligned(DistanceTo(source), kInstructionSize)); |
- ptrdiff_t offset = DistanceTo(source) >> kLoadLiteralScaleLog2; |
- Instr imm = Assembler::ImmLLiteral(offset); |
+ DCHECK(Assembler::IsImmLLiteral(DistanceTo(source))); |
+ Instr imm = Assembler::ImmLLiteral( |
+ static_cast<int>(DistanceTo(source) >> kLoadLiteralScaleLog2)); |
Instr mask = ImmLLiteral_mask; |
SetInstructionBits(Mask(~mask) | imm); |