[llvm-commits] [llvm] r58623 - in /llvm/trunk: include/llvm/CodeGen/ValueTypes.h lib/VMCore/ValueTypes.cpp test/CodeGen/X86/i2k.ll utils/TableGen/CMakeLists.txt utils/TableGen/TGValueTypes.cpp

Duncan Sands duncan.sands at math.u-psud.fr
Tue Nov 4 01:38:35 PST 2008


Hi Dan,

> Change how extended types are represented in MVTs. Instead of fiddling
> bits, use a union of a SimpleValueType enum and a regular Type*.

this is a wonderful improvement!

> there are no libcalls defined for very large integers so operations
> like multiply and divide aren't supported.

Here's a crazy idea.  I hear that people are working on "libllvm",
a reimplementation of libgcc.  Maybe instead the code generator
could be taught to generate library functions on the fly.  For
example, suppose a call to __udivsi3 is needed.  Then the code
generator creates the function __udivsi3 in the assembler, with
weak linkage.  Thanks to weak linkage there will be only one
copy no matter how many object files it turns up in, and there
is no need to link with libllvm.  Now imagine that you need a
similar library function to __udivsi3, but for i1024.  Then you
can have the code generators squirt out __udivsiXYZ!

> This also introduces a minimal tablgen Type library, capable of
> handling IntegerType and VectorType. This will allow parts of
> TableGen that don't depend on using SimpleValueType values to handle
> arbitrary integer and vector types.

Are there any such parts?  Or, rather, can such parts be changed
to only use SimpleValueType?

>      /// isSimple - Test if the given MVT is simple (as opposed to being
>      /// extended).
>      bool isSimple() const {
> -      return V <= SimpleTypeMask;
> +      return V <= LastSimpleValueType;
>      }

I see that you are confident that heap allocations never occur in the
first 256 bytes of memory! :)

> +unsigned MVT::getExtendedSizeInBits() const {
> +  assert(isExtended() && "Type is not extended!");
> +  if (const IntegerType *ITy = dyn_cast<IntegerType>(LLVMTy))
> +    return ITy->getBitWidth();
> +  if (const VectorType *VTy = dyn_cast<VectorType>(LLVMTy))
> +    return VTy->getBitWidth();
> +  assert(false && "Unrecognized extended type!");

You probably want a return statement here so as not to get
compiler warnings when assertions are turned off.
> +}

Finally, I notice that you didn't touch getTypeForMVT.  For extended
value types that function could be simplified to return LLVMTy.

Ciao,

Duncan.



More information about the llvm-commits mailing list