llvm-6502/include/llvm
Duncan Sands 514ab348fd Executive summary: getTypeSize -> getTypeStoreSize / getABITypeSize.
The meaning of getTypeSize was not clear - clarifying it is important
now that we have x86 long double and arbitrary precision integers.
The issue with long double is that it requires 80 bits, and this is
not a multiple of its alignment.  This gives a primitive type for
which getTypeSize differed from getABITypeSize.  For arbitrary precision
integers it is even worse: there is the minimum number of bits needed to
hold the type (eg: 36 for an i36), the maximum number of bits that will
be overwriten when storing the type (40 bits for i36) and the ABI size
(i.e. the storage size rounded up to a multiple of the alignment; 64 bits
for i36).

This patch removes getTypeSize (not really - it is still there but
deprecated to allow for a gradual transition).  Instead there is:

(1) getTypeSizeInBits - a number of bits that suffices to hold all
values of the type.  For a primitive type, this is the minimum number
of bits.  For an i36 this is 36 bits.  For x86 long double it is 80.
This corresponds to gcc's TYPE_PRECISION.

(2) getTypeStoreSizeInBits - the maximum number of bits that is
written when storing the type (or read when reading it).  For an
i36 this is 40 bits, for an x86 long double it is 80 bits.  This
is the size alias analysis is interested in (getTypeStoreSize
returns the number of bytes).  There doesn't seem to be anything
corresponding to this in gcc.

(3) getABITypeSizeInBits - this is getTypeStoreSizeInBits rounded
up to a multiple of the alignment.  For an i36 this is 64, for an
x86 long double this is 96 or 128 depending on the OS.  This is the
spacing between consecutive elements when you form an array out of
this type (getABITypeSize returns the number of bytes).  This is
TYPE_SIZE in gcc.

Since successive elements in a SequentialType (arrays, pointers
and vectors) need to be aligned, the spacing between them will be
given by getABITypeSize.  This means that the size of an array
is the length times the getABITypeSize.  It also means that GEP
computations need to use getABITypeSize when computing offsets.
Furthermore, if an alloca allocates several elements at once then
these too need to be aligned, so the size of the alloca has to be
the number of elements multiplied by getABITypeSize.  Logically
speaking this doesn't have to be the case when allocating just
one element, but it is simpler to also use getABITypeSize in this
case.  So alloca's and mallocs should use getABITypeSize.  Finally,
since gcc's only notion of size is that given by getABITypeSize, if
you want to output assembler etc the same as gcc then getABITypeSize
is the size you want.

Since a store will overwrite no more than getTypeStoreSize bytes,
and a read will read no more than that many bytes, this is the
notion of size appropriate for alias analysis calculations.

In this patch I have corrected all type size uses except some of
those in ScalarReplAggregates, lib/Codegen, lib/Target (the hard
cases).  I will get around to auditing these too at some point,
but I could do with some help.

Finally, I made one change which I think wise but others might
consider pointless and suboptimal: in an unpacked struct the
amount of space allocated for a field is now given by the ABI
size rather than getTypeStoreSize.  I did this because every
other place that reserves memory for a type (eg: alloca) now
uses getABITypeSize, and I didn't want to make an exception
for unpacked structs, i.e. I did it to make things more uniform.
This only effects structs containing long doubles and arbitrary
precision integers.  If someone wants to pack these types more
tightly they can always use a packed struct.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43620 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-01 20:53:16 +00:00
..
ADT Added typedef "value_type" to DenseMap (similar typedef appears in std::map). 2007-11-01 00:54:57 +00:00
Analysis Some fixes to get MachineDomTree working better. 2007-10-31 03:30:14 +00:00
Assembly More fleshing out of docs/Passes.html, plus some typo fixes and 2007-10-26 03:03:51 +00:00
Bitcode Rewrote backpatcher. Backpatcher now stores the "has final pointer" 2007-11-01 00:57:37 +00:00
CodeGen - Coalesce extract_subreg when both intervals are relatively small. 2007-11-01 06:22:48 +00:00
Config Regenerate. 2007-10-03 12:07:14 +00:00
Debugger For PR797: 2006-08-22 16:06:27 +00:00
ExecutionEngine add a mechanism for the JIT to invoke a function to lazily create functions as they are referenced. 2007-10-22 02:50:12 +00:00
Support The guaranteed alignment of ptr+offset is only the minimum of 2007-10-28 12:59:45 +00:00
System Fix minor doxygen nits. 2007-08-05 20:06:04 +00:00
Target Executive summary: getTypeSize -> getTypeStoreSize / getABITypeSize. 2007-11-01 20:53:16 +00:00
Transforms Reg2Mem cleanup and optimizations: 2007-10-21 23:05:16 +00:00
AbstractTypeUser.h Here is the bulk of the sanitizing. 2007-07-05 17:07:56 +00:00
Argument.h make these accessors private. 2007-05-23 05:46:04 +00:00
AutoUpgrade.h This is the patch to provide clean intrinsic function overloading support in LLVM. It cleans up the intrinsic definitions and generally smooths the process for more complicated intrinsic writing. It will be used by the upcoming atomic intrinsics as well as vector and float intrinsics in the future. 2007-08-04 01:51:18 +00:00
BasicBlock.h better portability for intptr_t. 2007-05-18 07:07:05 +00:00
CallGraphSCCPass.h Add explicit keywords. 2007-07-02 14:53:37 +00:00
CallingConv.h Fix 80 col violations. 2007-04-16 21:24:12 +00:00
Constant.h add a Constant::getAllOnesValue helper function, which works on integers 2007-06-15 06:10:53 +00:00
Constants.h Get rid of compilation warning during release builds 2007-11-01 08:24:40 +00:00
DerivedTypes.h Updated VC++ build system. 2007-10-17 14:56:40 +00:00
Function.h clarify precedence, no functionality change. 2007-08-20 21:31:08 +00:00
GlobalAlias.h Implement review feedback 2007-04-29 18:02:48 +00:00
GlobalValue.h Change casts from old style to new style. This helps document the details 2007-08-12 08:12:35 +00:00
GlobalVariable.h Implement review feedback. Aliasees can be either GlobalValue's or 2007-04-28 13:45:00 +00:00
InlineAsm.h represent indirect operands explicitly in inline asm strings. 2007-04-28 01:02:58 +00:00
InstrTypes.h Updated VC++ build system. 2007-10-17 14:56:40 +00:00
Instruction.def Changes to support making the shift instructions be true BinaryOperators. 2007-02-02 02:16:23 +00:00
Instruction.h Instruction:: Next/Prev accessors are now private 2007-04-17 18:03:55 +00:00
Instructions.h Updated VC++ build system. 2007-10-17 14:56:40 +00:00
IntrinsicInst.h For PR950: 2006-10-20 07:07:24 +00:00
Intrinsics.h For PR1297: 2007-04-01 07:26:35 +00:00
Intrinsics.td Model stacksave and stackrestore as both writing memory, since we 2007-10-29 05:47:52 +00:00
IntrinsicsPowerPC.td Convert the intrinsic function definitions to use llvm_i32_ty instead of 2006-12-31 22:24:55 +00:00
IntrinsicsX86.td Add missing SSE builtins: CVTPD2PI, CVTPS2PI, 2007-10-30 22:15:38 +00:00
LinkAllPasses.h Remove RLE from the headers, since the pass itself is gone now. 2007-09-14 22:54:46 +00:00
LinkAllVMCore.h For PR780: 2006-07-26 16:55:39 +00:00
Linker.h Fix minor doxygen nits. 2007-08-05 20:06:04 +00:00
LinkTimeOptimizer.h Add printVersion(). Linker can use it to print LLVM version number. 2007-02-01 01:46:06 +00:00
Module.h Fixing an comment in Module.h that refers to a nonexistent parameter. 2007-09-18 02:09:34 +00:00
ModuleProvider.h add a hook to demat functions. 2007-03-29 18:30:26 +00:00
ParameterAttributes.h Support for trampolines, except for X86 codegen which is 2007-07-27 12:58:54 +00:00
Pass.h Allow passes to just pass up "FunctionPass(&ID)" instead of "FunctionPass((intptr_t)&ID)" 2007-10-08 03:45:44 +00:00
PassAnalysisSupport.h Add a addRequiredTransitiveID member function, which is to 2007-05-14 14:21:46 +00:00
PassManager.h remove unimplemented ctor, add some comments. 2007-10-25 05:19:24 +00:00
PassManagers.h Fix a using namespace llvm; in a header file. 2007-10-03 19:04:09 +00:00
PassSupport.h update comment. 2007-10-18 16:10:17 +00:00
SymbolTableListTraits.h Change casts from old style to new style. This helps document the details 2007-08-12 08:12:35 +00:00
Type.h Fix spelling. 2007-09-25 13:53:22 +00:00
TypeSymbolTable.h Properly initialize value :) 2007-07-19 15:32:47 +00:00
Use.h Add a new use_iterator::atEnd() method, which allows us to shrink 2007-10-11 04:18:11 +00:00
User.h Switch ValueSymbolTable to use StringMap<Value*> instead of std::map<std::string, Value*> 2007-02-12 05:18:08 +00:00
Value.h add Value::getNameStart/getNameLen() accessors. 2007-08-10 15:34:35 +00:00
ValueSymbolTable.h better portability for intptr_t. 2007-05-18 07:07:05 +00:00