[llvm-commits] [llvm] r96492 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h include/llvm/CodeGen/MachineBasicBlock.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/CodeGen/MachineBasicBlock.cpp lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp utils/TableGen/DAGISelEmitter.cpp

Dan Gohman gohman at apple.com
Wed Feb 17 11:12:08 PST 2010


On Feb 17, 2010, at 10:52 AM, Chris Lattner wrote:
> +/// isBlockOnlyReachableByFallthough - Return true if the basic block has
> +/// exactly one predecessor and the control transfer mechanism between
> +/// the predecessor and this block is a fall-through.
> +/// Override AsmPrinter implementation to handle delay slots
> +bool SparcAsmPrinter::isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) 
> +    const {
> +  // If this is a landing pad, it isn't a fall through.  If it has no preds,
> +  // then nothing falls through to it.
> +  if (MBB->isLandingPad() || MBB->pred_empty())
> +    return false;
> +  
> +  // If there isn't exactly one predecessor, it can't be a fall through.
> +  MachineBasicBlock::const_pred_iterator PI = MBB->pred_begin(), PI2 = PI;
> +  ++PI2;
> +  if (PI2 != MBB->pred_end())
> +    return false;
> +  
> +  // The predecessor has to be immediately before this block.
> +  const MachineBasicBlock *Pred = *PI;
> +  
> +  if (!Pred->isLayoutSuccessor(MBB))
> +    return false;
> +  
> +  // Check if the last terminator is an unconditional branch
> +  MachineBasicBlock::const_iterator I = Pred->end();
> +  while( I != Pred->begin() && !(--I)->getDesc().isTerminator() )
> +      ; /* Noop */
> +  return I == Pred->end() || !I->getDesc().isBarrier();

Please follow LLVM whitespace conventions.

This code is non-obvious. The rest of CodeGen does not support terminator
instructions that aren't at the end of the block. Please add a comment
mentioning that this is for delay slots.

> +}
> +
> +
> +
> // Force static initialization.
> extern "C" void LLVMInitializeSparcAsmPrinter() { 
>   RegisterAsmPrinter<SparcAsmPrinter> X(TheSparcTarget);
> 
> Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelEmitter.cpp?rev=96492&r1=96491&r2=96492&view=diff
> 
> ==============================================================================
> --- llvm/trunk/utils/TableGen/DAGISelEmitter.cpp (original)
> +++ llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Wed Feb 17 12:52:56 2010
> @@ -1975,7 +1975,7 @@
>   // definitions.  Emit the resultant instruction selector.
>   EmitInstructionSelector(OS);  
> 
> -#if 0
> +#if 1

This probably wasn't intended.

Dan






More information about the llvm-commits mailing list