Commit a12f1191 authored by balazs.kilvady's avatar balazs.kilvady Committed by Commit bot

MIPS64: Reland 'Enable shorten-64-to-32 warning.'

Port cdc43bc5

Original review: https://codereview.chromium.org/1133163005/

Original commit message:
Enable clang's shorten-64-to-32 warning flag on ARM64, and fix the warnings
that arise.

BUG=

Review URL: https://codereview.chromium.org/1182193004

Cr-Commit-Position: refs/heads/master@{#29024}
parent 9efb230d
......@@ -473,7 +473,8 @@
],
'ldflags': [ '-pthread', ],
'conditions': [
[ 'clang==1 and (v8_target_arch=="x64" or v8_target_arch=="arm64")', {
[ 'clang==1 and (v8_target_arch=="x64" or v8_target_arch=="arm64" \
or v8_target_arch=="mips64el")', {
'cflags': [ '-Wshorten-64-to-32' ],
}],
[ 'host_arch=="ppc64" and OS!="aix"', {
......
......@@ -310,7 +310,7 @@ FPUCondition FlagsConditionToConditionCmpD(bool& predicate,
__ Daddu(at, i.InputRegister(2), offset); \
__ asm_instr(result, MemOperand(at, 0)); \
} else { \
auto offset = i.InputOperand(0).immediate(); \
int offset = static_cast<int>(i.InputOperand(0).immediate()); \
__ Branch(ool->entry(), ls, i.InputRegister(1), Operand(offset)); \
__ asm_instr(result, MemOperand(i.InputRegister(2), offset)); \
} \
......@@ -328,7 +328,7 @@ FPUCondition FlagsConditionToConditionCmpD(bool& predicate,
__ Daddu(at, i.InputRegister(2), offset); \
__ asm_instr(result, MemOperand(at, 0)); \
} else { \
auto offset = i.InputOperand(0).immediate(); \
int offset = static_cast<int>(i.InputOperand(0).immediate()); \
__ Branch(ool->entry(), ls, i.InputRegister(1), Operand(offset)); \
__ asm_instr(result, MemOperand(i.InputRegister(2), offset)); \
} \
......@@ -346,7 +346,7 @@ FPUCondition FlagsConditionToConditionCmpD(bool& predicate,
__ Daddu(at, i.InputRegister(3), offset); \
__ asm_instr(value, MemOperand(at, 0)); \
} else { \
auto offset = i.InputOperand(0).immediate(); \
int offset = static_cast<int>(i.InputOperand(0).immediate()); \
auto value = i.Input##width##Register(2); \
__ Branch(&done, ls, i.InputRegister(1), Operand(offset)); \
__ asm_instr(value, MemOperand(i.InputRegister(3), offset)); \
......@@ -365,7 +365,7 @@ FPUCondition FlagsConditionToConditionCmpD(bool& predicate,
__ Daddu(at, i.InputRegister(3), offset); \
__ asm_instr(value, MemOperand(at, 0)); \
} else { \
auto offset = i.InputOperand(0).immediate(); \
int offset = static_cast<int>(i.InputOperand(0).immediate()); \
auto value = i.InputRegister(2); \
__ Branch(&done, ls, i.InputRegister(1), Operand(offset)); \
__ asm_instr(value, MemOperand(i.InputRegister(3), offset)); \
......@@ -559,24 +559,27 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
if (instr->InputAt(1)->IsRegister()) {
__ sllv(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1));
} else {
int32_t imm = i.InputOperand(1).immediate();
__ sll(i.OutputRegister(), i.InputRegister(0), imm);
int64_t imm = i.InputOperand(1).immediate();
__ sll(i.OutputRegister(), i.InputRegister(0),
static_cast<uint16_t>(imm));
}
break;
case kMips64Shr:
if (instr->InputAt(1)->IsRegister()) {
__ srlv(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1));
} else {
int32_t imm = i.InputOperand(1).immediate();
__ srl(i.OutputRegister(), i.InputRegister(0), imm);
int64_t imm = i.InputOperand(1).immediate();
__ srl(i.OutputRegister(), i.InputRegister(0),
static_cast<uint16_t>(imm));
}
break;
case kMips64Sar:
if (instr->InputAt(1)->IsRegister()) {
__ srav(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1));
} else {
int32_t imm = i.InputOperand(1).immediate();
__ sra(i.OutputRegister(), i.InputRegister(0), imm);
int64_t imm = i.InputOperand(1).immediate();
__ sra(i.OutputRegister(), i.InputRegister(0),
static_cast<uint16_t>(imm));
}
break;
case kMips64Ext:
......@@ -591,11 +594,13 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
if (instr->InputAt(1)->IsRegister()) {
__ dsllv(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1));
} else {
int32_t imm = i.InputOperand(1).immediate();
int64_t imm = i.InputOperand(1).immediate();
if (imm < 32) {
__ dsll(i.OutputRegister(), i.InputRegister(0), imm);
__ dsll(i.OutputRegister(), i.InputRegister(0),
static_cast<uint16_t>(imm));
} else {
__ dsll32(i.OutputRegister(), i.InputRegister(0), imm - 32);
__ dsll32(i.OutputRegister(), i.InputRegister(0),
static_cast<uint16_t>(imm - 32));
}
}
break;
......@@ -603,11 +608,13 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
if (instr->InputAt(1)->IsRegister()) {
__ dsrlv(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1));
} else {
int32_t imm = i.InputOperand(1).immediate();
int64_t imm = i.InputOperand(1).immediate();
if (imm < 32) {
__ dsrl(i.OutputRegister(), i.InputRegister(0), imm);
__ dsrl(i.OutputRegister(), i.InputRegister(0),
static_cast<uint16_t>(imm));
} else {
__ dsrl32(i.OutputRegister(), i.InputRegister(0), imm - 32);
__ dsrl32(i.OutputRegister(), i.InputRegister(0),
static_cast<uint16_t>(imm - 32));
}
}
break;
......@@ -615,7 +622,7 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
if (instr->InputAt(1)->IsRegister()) {
__ dsrav(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1));
} else {
int32_t imm = i.InputOperand(1).immediate();
int64_t imm = i.InputOperand(1).immediate();
if (imm < 32) {
__ dsra(i.OutputRegister(), i.InputRegister(0), imm);
} else {
......@@ -1096,7 +1103,7 @@ void CodeGenerator::AssembleArchTableSwitch(Instruction* instr) {
Label here;
__ Branch(GetLabel(i.InputRpo(1)), hs, input, Operand(case_count));
__ BlockTrampolinePoolFor(case_count * 2 + 7);
__ BlockTrampolinePoolFor(static_cast<int>(case_count) * 2 + 7);
// Ensure that dd-ed labels use 8 byte aligned addresses.
if ((masm()->pc_offset() & 7) != 0) {
__ nop();
......
......@@ -393,7 +393,7 @@ void InstructionSelector::VisitInt64Mul(Node* node) {
Int64BinopMatcher m(node);
// TODO(dusmil): Add optimization for shifts larger than 32.
if (m.right().HasValue() && m.right().Value() > 0) {
int64_t value = m.right().Value();
int32_t value = static_cast<int32_t>(m.right().Value());
if (base::bits::IsPowerOfTwo32(value)) {
Emit(kMips64Dshl | AddressingModeField::encode(kMode_None),
g.DefineAsRegister(node), g.UseRegister(m.left().node()),
......@@ -666,8 +666,8 @@ void InstructionSelector::VisitCall(Node* node, BasicBlock* handler) {
FrameStateDescriptor* frame_state_descriptor = nullptr;
if (descriptor->NeedsFrameState()) {
frame_state_descriptor =
GetFrameStateDescriptor(node->InputAt(descriptor->InputCount()));
frame_state_descriptor = GetFrameStateDescriptor(
node->InputAt(static_cast<int>(descriptor->InputCount())));
}
CallBuffer buffer(zone(), descriptor, frame_state_descriptor);
......@@ -675,12 +675,12 @@ void InstructionSelector::VisitCall(Node* node, BasicBlock* handler) {
// Compute InstructionOperands for inputs and outputs.
InitializeCallBuffer(node, &buffer, true, false);
int push_count = buffer.pushed_nodes.size();
const int32_t push_count = static_cast<int32_t>(buffer.pushed_nodes.size());
if (push_count > 0) {
Emit(kMips64StackClaim, g.NoOutput(),
g.TempImmediate(push_count << kPointerSizeLog2));
}
int slot = buffer.pushed_nodes.size() - 1;
int32_t slot = push_count - 1;
for (Node* node : base::Reversed(buffer.pushed_nodes)) {
Emit(kMips64StoreToStackSlot, g.NoOutput(), g.UseRegister(node),
g.TempImmediate(slot << kPointerSizeLog2));
......@@ -771,12 +771,12 @@ void InstructionSelector::VisitTailCall(Node* node) {
// Compute InstructionOperands for inputs and outputs.
InitializeCallBuffer(node, &buffer, true, false);
int push_count = buffer.pushed_nodes.size();
const int32_t push_count = static_cast<int32_t>(buffer.pushed_nodes.size());
if (push_count > 0) {
Emit(kMips64StackClaim, g.NoOutput(),
g.TempImmediate(push_count << kPointerSizeLog2));
}
int slot = buffer.pushed_nodes.size() - 1;
int slot = push_count - 1;
for (Node* node : base::Reversed(buffer.pushed_nodes)) {
Emit(kMips64StoreToStackSlot, g.NoOutput(), g.UseRegister(node),
g.TempImmediate(slot << kPointerSizeLog2));
......
......@@ -57,14 +57,16 @@ static void ProbeTable(Isolate* isolate, MacroAssembler* masm,
__ Branch(&miss, ne, name, Operand(at));
// Check the map matches.
__ ld(at, MemOperand(base_addr, map_off_addr - key_off_addr));
__ ld(at, MemOperand(base_addr,
static_cast<int32_t>(map_off_addr - key_off_addr)));
__ ld(scratch2, FieldMemOperand(receiver, HeapObject::kMapOffset));
__ Branch(&miss, ne, at, Operand(scratch2));
// Get the code entry from the cache.
Register code = scratch2;
scratch2 = no_reg;
__ ld(code, MemOperand(base_addr, value_off_addr - key_off_addr));
__ ld(code, MemOperand(base_addr,
static_cast<int32_t>(value_off_addr - key_off_addr)));
// Check that the flags match what we're looking for.
Register flags_reg = base_addr;
......
......@@ -211,13 +211,14 @@ Operand::Operand(Handle<Object> handle) {
}
MemOperand::MemOperand(Register rm, int64_t offset) : Operand(rm) {
MemOperand::MemOperand(Register rm, int32_t offset) : Operand(rm) {
offset_ = offset;
}
MemOperand::MemOperand(Register rm, int64_t unit, int64_t multiplier,
OffsetAddend offset_addend) : Operand(rm) {
MemOperand::MemOperand(Register rm, int32_t unit, int32_t multiplier,
OffsetAddend offset_addend)
: Operand(rm) {
offset_ = unit * multiplier + offset_addend;
}
......@@ -290,7 +291,8 @@ void Assembler::GetCode(CodeDesc* desc) {
desc->buffer = buffer_;
desc->buffer_size = buffer_size_;
desc->instr_size = pc_offset();
desc->reloc_size = (buffer_ + buffer_size_) - reloc_info_writer.pos();
desc->reloc_size =
static_cast<int>((buffer_ + buffer_size_) - reloc_info_writer.pos());
desc->origin = this;
}
......@@ -741,7 +743,7 @@ void Assembler::target_at_put(int pos, int target_pos, bool is_internal) {
DCHECK((imm28 & 3) == 0);
instr &= ~kImm26Mask;
uint32_t imm26 = imm28 >> 2;
uint32_t imm26 = static_cast<uint32_t>(imm28 >> 2);
DCHECK(is_uint26(imm26));
instr_at_put(pos, instr | (imm26 & kImm26Mask));
......@@ -1385,7 +1387,7 @@ void Assembler::j(int64_t target) {
DCHECK(in_range && ((target & 3) == 0));
}
#endif
GenInstrJump(J, (target >> 2) & kImm26Mask);
GenInstrJump(J, static_cast<uint32_t>(target >> 2) & kImm26Mask);
}
......@@ -1414,7 +1416,7 @@ void Assembler::jal(int64_t target) {
}
#endif
positions_recorder()->WriteRecordedPositions();
GenInstrJump(JAL, (target >> 2) & kImm26Mask);
GenInstrJump(JAL, static_cast<uint32_t>(target >> 2) & kImm26Mask);
}
......@@ -2901,7 +2903,8 @@ void Assembler::GrowBuffer() {
desc.buffer = NewArray<byte>(desc.buffer_size);
desc.instr_size = pc_offset();
desc.reloc_size = (buffer_ + buffer_size_) - reloc_info_writer.pos();
desc.reloc_size =
static_cast<int>((buffer_ + buffer_size_) - reloc_info_writer.pos());
// Copy the data.
intptr_t pc_delta = desc.buffer - buffer_;
......
......@@ -404,8 +404,8 @@ class MemOperand : public Operand {
offset_zero = 0
};
explicit MemOperand(Register rn, int64_t offset = 0);
explicit MemOperand(Register rn, int64_t unit, int64_t multiplier,
explicit MemOperand(Register rn, int32_t offset = 0);
explicit MemOperand(Register rn, int32_t unit, int32_t multiplier,
OffsetAddend offset_addend = offset_zero);
int32_t offset() const { return offset_; }
......@@ -1138,7 +1138,9 @@ class Assembler : public AssemblerBase {
inline bool overflow() const { return pc_ >= reloc_info_writer.pos() - kGap; }
// Get the number of bytes available in the buffer.
inline int available_space() const { return reloc_info_writer.pos() - pc_; }
inline intptr_t available_space() const {
return reloc_info_writer.pos() - pc_;
}
// Read/patch instructions.
static Instr instr_at(byte* pc) { return *reinterpret_cast<Instr*>(pc); }
......
......@@ -272,7 +272,7 @@ void Decoder::PrintXImm21(Instruction* instr) {
// Print 26-bit immediate value.
void Decoder::PrintXImm26(Instruction* instr) {
uint32_t imm = instr->Imm26Value() << kImmFieldShift;
uint32_t imm = static_cast<uint32_t>(instr->Imm26Value()) << kImmFieldShift;
out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x", imm);
}
......
......@@ -489,8 +489,8 @@ int32_t LCodeGen::ToInteger32(LConstantOperand* op) const {
}
int32_t LCodeGen::ToRepresentation_donotuse(LConstantOperand* op,
const Representation& r) const {
int64_t LCodeGen::ToRepresentation_donotuse(LConstantOperand* op,
const Representation& r) const {
HConstant* constant = chunk_->LookupConstant(op);
int32_t value = constant->Integer32Value();
if (r.IsInteger32()) return value;
......
......@@ -75,7 +75,7 @@ class LCodeGen: public LCodeGenBase {
DoubleRegister EmitLoadDoubleRegister(LOperand* op,
FloatRegister flt_scratch,
DoubleRegister dbl_scratch);
int32_t ToRepresentation_donotuse(LConstantOperand* op,
int64_t ToRepresentation_donotuse(LConstantOperand* op,
const Representation& r) const;
int32_t ToInteger32(LConstantOperand* op) const;
Smi* ToSmi(LConstantOperand* op) const;
......
This diff is collapsed.
This diff is collapsed.
......@@ -326,57 +326,55 @@ class Simulator {
inline int32_t SetDoubleLOW(double* addr);
// functions called from DecodeTypeRegister
void DecodeTypeRegisterCOP1(Instruction* instr, const int32_t& rs_reg,
const int64_t& rs, const uint64_t& rs_u,
const int32_t& rt_reg, const int64_t& rt,
const uint64_t& rt_u, const int32_t& rd_reg,
const int32_t& fr_reg, const int32_t& fs_reg,
const int32_t& ft_reg, const int32_t& fd_reg,
void DecodeTypeRegisterCOP1(Instruction* instr, const int32_t rs_reg,
const int64_t rs, const uint64_t rs_u,
const int32_t rt_reg, const int64_t rt,
const uint64_t rt_u, const int32_t rd_reg,
const int32_t fr_reg, const int32_t fs_reg,
const int32_t ft_reg, const int32_t fd_reg,
int64_t& alu_out);
void DecodeTypeRegisterCOP1X(Instruction* instr, const int32_t& fr_reg,
const int32_t& fs_reg, const int32_t& ft_reg,
const int32_t& fd_reg);
void DecodeTypeRegisterCOP1X(Instruction* instr, const int32_t fr_reg,
const int32_t fs_reg, const int32_t ft_reg,
const int32_t fd_reg);
void DecodeTypeRegisterSPECIAL(
Instruction* instr, const int64_t& rs_reg, const int64_t& rs,
const uint64_t& rs_u, const int64_t& rt_reg, const int64_t& rt,
const uint64_t& rt_u, const int64_t& rd_reg, const int32_t& fr_reg,
const int32_t& fs_reg, const int32_t& ft_reg, const int64_t& fd_reg,
int64_t& i64hilo, uint64_t& u64hilo, int64_t& alu_out, bool& do_interrupt,
int64_t& current_pc, int64_t& next_pc, int64_t& return_addr_reg,
int64_t& i128resultH, int64_t& i128resultL);
Instruction* instr, const int32_t rs_reg, const int64_t rs,
const uint64_t rs_u, const int32_t rt_reg, const int64_t rt,
const uint64_t rt_u, const int32_t rd_reg, const int32_t fr_reg,
const int32_t fs_reg, const int32_t ft_reg, const int32_t fd_reg,
const int64_t i64hilo, const uint64_t u64hilo, const int64_t alu_out,
const bool do_interrupt, const int64_t current_pc, const int64_t next_pc,
const int32_t return_addr_reg, const int64_t i128resultH,
const int64_t i128resultL);
void DecodeTypeRegisterSPECIAL2(Instruction* instr, const int64_t& rd_reg,
int64_t& alu_out);
void DecodeTypeRegisterSPECIAL3(Instruction* instr, const int64_t& rt_reg,
const int64_t& rd_reg, int64_t& alu_out);
void DecodeTypeRegisterSPECIAL2(Instruction* instr, const int32_t rd_reg,
const int64_t alu_out);
void DecodeTypeRegisterSRsType(Instruction* instr, const int32_t& fs_reg,
const int32_t& ft_reg, const int32_t& fd_reg);
void DecodeTypeRegisterSPECIAL3(Instruction* instr, const int32_t rt_reg,
const int32_t rd_reg, const int64_t alu_out);
void DecodeTypeRegisterDRsType(Instruction* instr, const int32_t& fs_reg,
const int32_t& ft_reg, const int32_t& fd_reg);
void DecodeTypeRegisterSRsType(Instruction* instr, const int32_t fs_reg,
const int32_t ft_reg, const int32_t fd_reg);
void DecodeTypeRegisterWRsType(Instruction* instr, const int32_t& fs_reg,
const int32_t& ft_reg, const int32_t& fd_reg,
void DecodeTypeRegisterDRsType(Instruction* instr, const int32_t fs_reg,
const int32_t ft_reg, const int32_t fd_reg);
void DecodeTypeRegisterWRsType(Instruction* instr, const int32_t fs_reg,
const int32_t ft_reg, const int32_t fd_reg,
int64_t& alu_out);
void DecodeTypeRegisterLRsType(Instruction* instr, const int32_t& fs_reg,
const int32_t& fd_reg, const int32_t& ft_reg);
void DecodeTypeRegisterLRsType(Instruction* instr, const int32_t fs_reg,
const int32_t fd_reg, const int32_t ft_reg);
// Executing is handled based on the instruction type.
void DecodeTypeRegister(Instruction* instr);
// Helper function for DecodeTypeRegister.
void ConfigureTypeRegister(Instruction* instr,
int64_t* alu_out,
int64_t* i64hilo,
uint64_t* u64hilo,
int64_t* next_pc,
int64_t* return_addr_reg,
bool* do_interrupt,
int64_t* result128H,
void ConfigureTypeRegister(Instruction* instr, int64_t* alu_out,
int64_t* i64hilo, uint64_t* u64hilo,
int64_t* next_pc, int* return_addr_reg,
bool* do_interrupt, int64_t* result128H,
int64_t* result128L);
void DecodeTypeImmediate(Instruction* instr);
......@@ -418,7 +416,7 @@ class Simulator {
// ICache.
static void CheckICache(v8::internal::HashMap* i_cache, Instruction* instr);
static void FlushOnePage(v8::internal::HashMap* i_cache, intptr_t start,
int size);
size_t size);
static CachePage* GetCachePage(v8::internal::HashMap* i_cache, void* page);
enum Exception {
......@@ -498,12 +496,14 @@ class Simulator {
#ifdef MIPS_ABI_N64
#define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7, p8) \
Simulator::current(Isolate::Current())->Call( \
entry, 10, p0, p1, p2, p3, p4, p5, p6, p7, NULL, p8)
static_cast<int>( \
Simulator::current(Isolate::Current()) \
->Call(entry, 10, p0, p1, p2, p3, p4, p5, p6, p7, NULL, p8))
#else // Must be O32 Abi.
#define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7, p8) \
Simulator::current(Isolate::Current())->Call( \
entry, 10, p0, p1, p2, p3, NULL, p4, p5, p6, p7, p8)
static_cast<int>( \
Simulator::current(Isolate::Current()) \
->Call(entry, 10, p0, p1, p2, p3, NULL, p4, p5, p6, p7, p8))
#endif // MIPS_ABI_N64
......
......@@ -3121,8 +3121,9 @@ TEST(jump_tables1) {
#endif
F1 f = FUNCTION_CAST<F1>(code->entry());
for (int i = 0; i < kNumCases; ++i) {
int res = reinterpret_cast<int64_t>(CALL_GENERATED_CODE(f, i, 0, 0, 0, 0));
::printf("f(%d) = %d\n", i, res);
int64_t res = reinterpret_cast<int64_t>(
CALL_GENERATED_CODE(f, i, 0, 0, 0, 0));
::printf("f(%d) = %" PRId64 "\n", i, res);
CHECK_EQ(values[i], static_cast<int>(res));
}
}
......@@ -3192,8 +3193,9 @@ TEST(jump_tables2) {
#endif
F1 f = FUNCTION_CAST<F1>(code->entry());
for (int i = 0; i < kNumCases; ++i) {
int res = reinterpret_cast<int64_t>(CALL_GENERATED_CODE(f, i, 0, 0, 0, 0));
::printf("f(%d) = %d\n", i, res);
int64_t res = reinterpret_cast<int64_t>(
CALL_GENERATED_CODE(f, i, 0, 0, 0, 0));
::printf("f(%d) = %" PRId64 "\n", i, res);
CHECK_EQ(values[i], res);
}
}
......
......@@ -144,7 +144,8 @@ int32_t RunGeneratedCodeCallWrapper(ConvertDToIFunc func,
double from) {
#ifdef USE_SIMULATOR
Simulator::current(Isolate::Current())->CallFP(FUNCTION_ADDR(func), from, 0.);
return Simulator::current(Isolate::Current())->get_register(v0.code());
return static_cast<int32_t>(
Simulator::current(Isolate::Current())->get_register(v0.code()));
#else
return (*func)(from);
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment