diff options
| author | 2012-11-21 15:39:13 -0800 | |
|---|---|---|
| committer | 2012-11-21 15:39:13 -0800 | |
| commit | 28c9a83398a6e48eefb9b79a390920629bbb8519 (patch) | |
| tree | 9d12fec60f41a3f185243d0195f9ed31a945005e /src/compiler/codegen | |
| parent | dd20a8d64a8cd120361b44078074bd242913da0a (diff) | |
Quick Compiler: pointer/boolean cleanup
More minor code cleanup - follow the Art convention of not treating
pointers as booleans in "for" loop tests.
Change-Id: I2fcd06efe6a51d1195c0900f7fa110fc01110001
Diffstat (limited to 'src/compiler/codegen')
| -rw-r--r-- | src/compiler/codegen/arm/assemble_arm.cc | 4 | ||||
| -rw-r--r-- | src/compiler/codegen/codegen_util.cc | 4 | ||||
| -rw-r--r-- | src/compiler/codegen/local_optimizations.cc | 16 | ||||
| -rw-r--r-- | src/compiler/codegen/method_bitcode.cc | 17 | ||||
| -rw-r--r-- | src/compiler/codegen/method_codegen_driver.cc | 2 | ||||
| -rw-r--r-- | src/compiler/codegen/mips/assemble_mips.cc | 4 | ||||
| -rw-r--r-- | src/compiler/codegen/x86/assemble_x86.cc | 20 | ||||
| -rw-r--r-- | src/compiler/codegen/x86/target_x86.cc | 2 |
8 files changed, 28 insertions, 41 deletions
diff --git a/src/compiler/codegen/arm/assemble_arm.cc b/src/compiler/codegen/arm/assemble_arm.cc index f89915b82c..8cb0b97b2b 100644 --- a/src/compiler/codegen/arm/assemble_arm.cc +++ b/src/compiler/codegen/arm/assemble_arm.cc @@ -993,7 +993,7 @@ AssemblerStatus AssembleInstructions(CompilationUnit* cu, LIR* lir; AssemblerStatus res = kSuccess; // Assume success - for (lir = cu->first_lir_insn; lir; lir = NEXT_LIR(lir)) { + for (lir = cu->first_lir_insn; lir != NULL; lir = NEXT_LIR(lir)) { if (lir->opcode < 0) { /* 1 means padding is needed */ @@ -1374,7 +1374,7 @@ int AssignInsnOffsets(CompilationUnit* cu) LIR* arm_lir; int offset = 0; - for (arm_lir = cu->first_lir_insn; arm_lir; arm_lir = NEXT_LIR(arm_lir)) { + for (arm_lir = cu->first_lir_insn; arm_lir != NULL; arm_lir = NEXT_LIR(arm_lir)) { arm_lir->offset = offset; if (arm_lir->opcode >= 0) { if (!arm_lir->flags.is_nop) { diff --git a/src/compiler/codegen/codegen_util.cc b/src/compiler/codegen/codegen_util.cc index 9373291a64..9af5578587 100644 --- a/src/compiler/codegen/codegen_util.cc +++ b/src/compiler/codegen/codegen_util.cc @@ -312,10 +312,10 @@ void CodegenDump(CompilationUnit* cu) LOG(INFO) << "expansion factor: " << static_cast<float>(cu->total_size) / static_cast<float>(insns_size * 2); DumpPromotionMap(cu); - for (lir_insn = cu->first_lir_insn; lir_insn; lir_insn = lir_insn->next) { + for (lir_insn = cu->first_lir_insn; lir_insn != NULL; lir_insn = lir_insn->next) { DumpLIRInsn(cu, lir_insn, 0); } - for (lir_insn = cu->literal_list; lir_insn; lir_insn = lir_insn->next) { + for (lir_insn = cu->literal_list; lir_insn != NULL; lir_insn = lir_insn->next) { LOG(INFO) << StringPrintf("%x (%04x): .word (%#x)", lir_insn->offset, lir_insn->offset, lir_insn->operands[0]); } diff --git a/src/compiler/codegen/local_optimizations.cc b/src/compiler/codegen/local_optimizations.cc index d1a74441ae..cf04b21bd7 100644 --- a/src/compiler/codegen/local_optimizations.cc +++ b/src/compiler/codegen/local_optimizations.cc @@ -78,9 +78,7 @@ static void ApplyLoadStoreElimination(CompilationUnit* cu, LIR* head_lir, LIR* t if (head_lir == tail_lir) return; - for (this_lir = PREV_LIR(tail_lir); - this_lir != head_lir; - this_lir = PREV_LIR(this_lir)) { + for (this_lir = PREV_LIR(tail_lir); this_lir != head_lir; this_lir = PREV_LIR(this_lir)) { int sink_distance = 0; /* Skip non-interesting instructions */ @@ -124,9 +122,7 @@ static void ApplyLoadStoreElimination(CompilationUnit* cu, LIR* head_lir, LIR* t stop_use_reg_mask = (GetPCUseDefEncoding() | this_lir->use_mask) & ~ENCODE_MEM; } - for (check_lir = NEXT_LIR(this_lir); - check_lir != tail_lir; - check_lir = NEXT_LIR(check_lir)) { + for (check_lir = NEXT_LIR(this_lir); check_lir != tail_lir; check_lir = NEXT_LIR(check_lir)) { /* * Skip already dead instructions (whose dataflow information is @@ -275,9 +271,7 @@ void ApplyLoadHoisting(CompilationUnit* cu, LIR* head_lir, LIR* tail_lir) if (head_lir == tail_lir) return; /* Start from the second instruction */ - for (this_lir = NEXT_LIR(head_lir); - this_lir != tail_lir; - this_lir = NEXT_LIR(this_lir)) { + for (this_lir = NEXT_LIR(head_lir); this_lir != tail_lir; this_lir = NEXT_LIR(this_lir)) { /* Skip non-interesting instructions */ if ((this_lir->flags.is_nop == true) || @@ -308,9 +302,7 @@ void ApplyLoadHoisting(CompilationUnit* cu, LIR* head_lir, LIR* tail_lir) bool stop_here = false; /* Try to hoist the load to a good spot */ - for (check_lir = PREV_LIR(this_lir); - check_lir != head_lir; - check_lir = PREV_LIR(check_lir)) { + for (check_lir = PREV_LIR(this_lir); check_lir != head_lir; check_lir = PREV_LIR(check_lir)) { /* * Skip already dead instructions (whose dataflow information is diff --git a/src/compiler/codegen/method_bitcode.cc b/src/compiler/codegen/method_bitcode.cc index cedf3b7530..7a9446fdde 100644 --- a/src/compiler/codegen/method_bitcode.cc +++ b/src/compiler/codegen/method_bitcode.cc @@ -1856,7 +1856,7 @@ static bool BlockBitcodeConversion(CompilationUnit* cu, BasicBlock* bb) return false; } - for (MIR* mir = bb->first_mir_insn; mir; mir = mir->next) { + for (MIR* mir = bb->first_mir_insn; mir != NULL; mir = mir->next) { SetDexOffset(cu, mir->offset); @@ -3385,8 +3385,7 @@ void MethodBitcode2LIR(CompilationUnit* cu) static_cast<LIR*>(NewMem(cu, sizeof(LIR) * num_basic_blocks, true, kAllocLIR)); LIR* label_list = cu->block_label_list; int next_label = 0; - for (llvm::Function::iterator i = func->begin(), - e = func->end(); i != e; ++i) { + for (llvm::Function::iterator i = func->begin(), e = func->end(); i != e; ++i) { cu->block_to_label_map.Put(static_cast<llvm::BasicBlock*>(i), &label_list[next_label++]); } @@ -3397,8 +3396,7 @@ void MethodBitcode2LIR(CompilationUnit* cu) */ cu->loc_map.clear(); // Start fresh cu->reg_location = NULL; - for (int i = 0; i < cu->num_dalvik_registers + cu->num_compiler_temps + 1; - i++) { + for (int i = 0; i < cu->num_dalvik_registers + cu->num_compiler_temps + 1; i++) { cu->promotion_map[i].core_location = kLocDalvikFrame; cu->promotion_map[i].fp_location = kLocDalvikFrame; } @@ -3416,8 +3414,7 @@ void MethodBitcode2LIR(CompilationUnit* cu) * be the first instruction we encounter, so we won't have to iterate * through everything. */ - for (llvm::inst_iterator i = llvm::inst_begin(func), - e = llvm::inst_end(func); i != e; ++i) { + for (llvm::inst_iterator i = llvm::inst_begin(func), e = llvm::inst_end(func); i != e; ++i) { llvm::CallInst* call_inst = llvm::dyn_cast<llvm::CallInst>(&*i); if (call_inst != NULL) { llvm::Function* callee = call_inst->getCalledFunction(); @@ -3489,8 +3486,7 @@ void MethodBitcode2LIR(CompilationUnit* cu) CreateLocFromValue(cu, val); } // Create RegLocations for all non-argument defintions - for (llvm::inst_iterator i = llvm::inst_begin(func), - e = llvm::inst_end(func); i != e; ++i) { + for (llvm::inst_iterator i = llvm::inst_begin(func), e = llvm::inst_end(func); i != e; ++i) { llvm::Value* val = &*i; if (val->hasName() && (val->getName().str().c_str()[0] == 'v')) { CreateLocFromValue(cu, val); @@ -3498,8 +3494,7 @@ void MethodBitcode2LIR(CompilationUnit* cu) } // Walk the blocks, generating code. - for (llvm::Function::iterator i = cu->func->begin(), - e = cu->func->end(); i != e; ++i) { + for (llvm::Function::iterator i = cu->func->begin(), e = cu->func->end(); i != e; ++i) { BitcodeBlockCodeGen(cu, static_cast<llvm::BasicBlock*>(i)); } diff --git a/src/compiler/codegen/method_codegen_driver.cc b/src/compiler/codegen/method_codegen_driver.cc index 9f7f692c6f..fe5d522216 100644 --- a/src/compiler/codegen/method_codegen_driver.cc +++ b/src/compiler/codegen/method_codegen_driver.cc @@ -729,7 +729,7 @@ static bool MethodBlockCodeGen(CompilationUnit* cu, BasicBlock* bb) GenExitSequence(cu); } - for (mir = bb->first_mir_insn; mir; mir = mir->next) { + for (mir = bb->first_mir_insn; mir != NULL; mir = mir->next) { ResetRegPool(cu); if (cu->disable_opt & (1 << kTrackLiveTemps)) { ClobberAllRegs(cu); diff --git a/src/compiler/codegen/mips/assemble_mips.cc b/src/compiler/codegen/mips/assemble_mips.cc index b80784fd57..933cb608e2 100644 --- a/src/compiler/codegen/mips/assemble_mips.cc +++ b/src/compiler/codegen/mips/assemble_mips.cc @@ -520,7 +520,7 @@ AssemblerStatus AssembleInstructions(CompilationUnit *cu, LIR *lir; AssemblerStatus res = kSuccess; // Assume success - for (lir = cu->first_lir_insn; lir; lir = NEXT_LIR(lir)) { + for (lir = cu->first_lir_insn; lir != NULL; lir = NEXT_LIR(lir)) { if (lir->opcode < 0) { continue; } @@ -723,7 +723,7 @@ int AssignInsnOffsets(CompilationUnit* cu) LIR* mips_lir; int offset = 0; - for (mips_lir = cu->first_lir_insn; mips_lir; mips_lir = NEXT_LIR(mips_lir)) { + for (mips_lir = cu->first_lir_insn; mips_lir != NULL; mips_lir = NEXT_LIR(mips_lir)) { mips_lir->offset = offset; if (mips_lir->opcode >= 0) { if (!mips_lir->flags.is_nop) { diff --git a/src/compiler/codegen/x86/assemble_x86.cc b/src/compiler/codegen/x86/assemble_x86.cc index 78ba331675..2363c209f2 100644 --- a/src/compiler/codegen/x86/assemble_x86.cc +++ b/src/compiler/codegen/x86/assemble_x86.cc @@ -1194,7 +1194,7 @@ AssemblerStatus AssembleInstructions(CompilationUnit *cu, uintptr_t start_addr) AssemblerStatus res = kSuccess; // Assume success const bool kVerbosePcFixup = false; - for (lir = cu->first_lir_insn; lir; lir = NEXT_LIR(lir)) { + for (lir = cu->first_lir_insn; lir != NULL; lir = NEXT_LIR(lir)) { if (lir->opcode < 0) { continue; } @@ -1420,21 +1420,21 @@ AssemblerStatus AssembleInstructions(CompilationUnit *cu, uintptr_t start_addr) */ int AssignInsnOffsets(CompilationUnit* cu) { - LIR* x86LIR; + LIR* x86_lir; int offset = 0; - for (x86LIR = cu->first_lir_insn; x86LIR; x86LIR = NEXT_LIR(x86LIR)) { - x86LIR->offset = offset; - if (x86LIR->opcode >= 0) { - if (!x86LIR->flags.is_nop) { - offset += x86LIR->flags.size; + for (x86_lir = cu->first_lir_insn; x86_lir != NULL; x86_lir = NEXT_LIR(x86_lir)) { + x86_lir->offset = offset; + if (x86_lir->opcode >= 0) { + if (!x86_lir->flags.is_nop) { + offset += x86_lir->flags.size; } - } else if (x86LIR->opcode == kPseudoPseudoAlign4) { + } else if (x86_lir->opcode == kPseudoPseudoAlign4) { if (offset & 0x2) { offset += 2; - x86LIR->operands[0] = 1; + x86_lir->operands[0] = 1; } else { - x86LIR->operands[0] = 0; + x86_lir->operands[0] = 0; } } /* Pseudo opcodes don't consume space */ diff --git a/src/compiler/codegen/x86/target_x86.cc b/src/compiler/codegen/x86/target_x86.cc index c51e9e9003..ee5c2152b7 100644 --- a/src/compiler/codegen/x86/target_x86.cc +++ b/src/compiler/codegen/x86/target_x86.cc @@ -512,7 +512,7 @@ void CompilerInitializeRegAlloc(CompilationUnit* cu) { for (int i = 0; i < cu->num_ssa_regs; i++) { cu->phi_alias_map[i] = i; } - for (MIR* phi = cu->phi_list; phi; phi = phi->meta.phi_next) { + for (MIR* phi = cu->phi_list; phi != NULL; phi = phi->meta.phi_next) { int def_reg = phi->ssa_rep->defs[0]; for (int i = 0; i < phi->ssa_rep->num_uses; i++) { for (int j = 0; j < cu->num_ssa_regs; j++) { |