[llvm-commits] [llvm] r164173 - in /llvm/trunk: include/llvm/Transforms/Utils/IntegerDivision.h lib/Transforms/Utils/CMakeLists.txt lib/Transforms/Utils/IntegerDivision.cpp

Michael Ilseman milseman at apple.com
Wed Sep 19 09:33:32 PDT 2012


On Sep 18, 2012, at 7:17 PM, Chandler Carruth <chandlerc at google.com> wrote:
> 
> +
> +} // End llvm namespace
> +
> +#endif
> 
> Modified: llvm/trunk/lib/Transforms/Utils/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CMakeLists.txt?rev=164173&r1=164172&r2=164173&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Utils/CMakeLists.txt (original)
> +++ llvm/trunk/lib/Transforms/Utils/CMakeLists.txt Tue Sep 18 17:02:40 2012
> @@ -11,6 +11,7 @@
>    DemoteRegToStack.cpp
>    InlineFunction.cpp
>    InstructionNamer.cpp
> +  IntegerDivision.cpp
>    LCSSA.cpp
>    Local.cpp
>    LoopSimplify.cpp
> 
> Added: llvm/trunk/lib/Transforms/Utils/IntegerDivision.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/IntegerDivision.cpp?rev=164173&view=auto
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Utils/IntegerDivision.cpp (added)
> +++ llvm/trunk/lib/Transforms/Utils/IntegerDivision.cpp Tue Sep 18 17:02:40 2012
> @@ -0,0 +1,306 @@
> +//===-- IntegerDivision.cpp - Expand integer division ---------------------===//
> +//
> +//                     The LLVM Compiler Infrastructure
> +//
> +// This file is distributed under the University of Illinois Open Source
> +// License. See LICENSE.TXT for details.
> +//
> +//===----------------------------------------------------------------------===//
> +//
> +// This file contains an implementation of 32bit scalar integer division for
> +// targets that don't have native support. It's largely derived from
> +// compiler-rt's implementation of __udivsi3, but hand-tuned to reduce the
> +// amount of control flow
> +//
> +//===----------------------------------------------------------------------===//
> +
> +#define DEBUG_TYPE "integer-division"
> +#include "llvm/Function.h"
> +#include "llvm/Instructions.h"
> +#include "llvm/Intrinsics.h"
> +#include "llvm/IRBuilder.h"
> +#include "llvm/Transforms/Utils/IntegerDivision.h"
> +
> +using namespace llvm;
> +
> +// Generate code to divide two signed integers. Returns the quotient, rounded
> +// towards 0. Builder's insert point should be pointing at the sdiv
> +// instruction. This will generate a udiv in the process, and Builder's insert
> +// point will be pointing at the udiv (if present, i.e. not folded), ready to be
> +// expanded if the user wishes.
> +static Value* GenerateSignedDivisionCode(Value* Dividend, Value* Divisor,
> +                                         IRBuilder<>& Builder) {
> +  // Implementation taken from compiler-rt's __divsi3
> +
> +  ConstantInt* ThirtyOne = Builder.getInt32(31);
> 
> The "*" are consistently in the wrong place. Also this doesn't follow the style guide's naming conventions. Also it should have a doxygen comment.
>  

About the naming conventions, I'm a little confused. The coding standard says that function names should begin lower case, but all the static function examples shown begin in upper case. Should those really be lower case instead, or are static functions to be upper case? Are there other violations of the naming convention here?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120919/ec596635/attachment.html>


More information about the llvm-commits mailing list