Commit Graph

38 Commits

Author SHA1 Message Date
John McCall c8e0170578 Standardize accesses to the TargetInfo in IR-gen.
Patch by Stephen Lin!

llvm-svn: 179638
2013-04-16 22:48:15 +00:00
John McCall 882987f30c Use the actual ABI-determined C calling convention for runtime
calls and declarations.

LLVM has a default CC determined by the target triple.  This is
not always the actual default CC for the ABI we've been asked to
target, and so we sometimes find ourselves annotating all user
functions with an explicit calling convention.  Since these
calling conventions usually agree for the simple set of argument
types passed to most runtime functions, using the LLVM-default CC
in principle has no effect.  However, the LLVM optimizer goes
into histrionics if it sees this kind of formal CC mismatch,
since it has no concept of CC compatibility.  Therefore, if this
module happens to define the "runtime" function, or got LTO'ed
with such a definition, we can miscompile;  so it's quite
important to get this right.

Defining runtime functions locally is quite common in embedded
applications.

llvm-svn: 176286
2013-02-28 19:01:20 +00:00
Tim Northover 9bb857a4f1 Add support for AArch64 target.
In cooperation with the LLVM patch, this should implement all scalar front-end
parts of the C and C++ ABIs for AArch64.

This patch excludes the NEON support also reviewed due to an outbreak of
batshit insanity in our legal department. That will be committed soon bringing
the changes to precisely what has been approved.

Further reviews would be gratefully received.

llvm-svn: 174055
2013-01-31 12:13:10 +00:00
Chandler Carruth ffd5551bc7 Rewrite #includes for llvm/Foo.h to llvm/IR/Foo.h as appropriate to
reflect the migration in r171366.

Re-sort the #include lines to reflect the new paths.

llvm-svn: 171369
2013-01-02 11:45:17 +00:00
Rafael Espindola fad28de40c Add padding inreg registers to cause llvm to skip ecx when needed with
the x86_fastcallcc calling convention.

llvm-svn: 166538
2012-10-24 01:59:00 +00:00
Rafael Espindola 703c47f807 Fix handling of the regparm attribute in the presence of classes with copy
constructors.

When I first moved regparm support to TargetInfo.cpp I tried to isolate it
in classifyArgumentTypeWithReg, but it is actually a lot easier to flip the
code around and check for regparm at the end of the decision tree.

Without this refactoring classifyArgumentTypeWithReg would have to duplicate
the logic about when to use non-byval indirect arguments.

llvm-svn: 166266
2012-10-19 05:04:37 +00:00
Micah Villmow dd31ca10ef Move TargetData to DataLayout.
llvm-svn: 165395
2012-10-08 16:25:52 +00:00
Rafael Espindola 06b2b4a7c9 Handle functions with struct arguments or return types and the regparm
attribute. It is a variation of the x86_64 ABI:

* A struct returned indirectly uses the first register argument to pass the
  pointer.
* Floats, Doubles and structs containing only one of them are not passed in
  registers.
* Other structs are split into registers if they fit on the remaining ones.
  Otherwise they are passed in memory.
* When a struct doesn't fit it still consumes the registers.

llvm-svn: 161022
2012-07-31 02:44:24 +00:00
Rafael Espindola 4d3487b44b ABIArgInfo's constructor is private and only used by the static get* methods.
No need to abuse default arguments.

llvm-svn: 160684
2012-07-24 19:30:23 +00:00
Akira Hatanaka f64e1adcbb Add field PaddingType to ABIArgInfo which specifies the type of padding that
is inserted before the real argument. Padding is needed to ensure the backend
reads from or writes to the correct argument slots when the original alignment
of a byval structure is unavailable due to flattening.

llvm-svn: 147699
2012-01-07 00:25:33 +00:00
Chris Lattner a5f58b05e8 clang side to match the LLVM IR type system rewrite patch.
llvm-svn: 134831
2011-07-09 17:41:47 +00:00
Michael J. Spencer f5a1fbcdf3 Fix Whitespace.
llvm-svn: 116798
2010-10-19 06:39:39 +00:00
Daniel Dunbar 7b7c2937ef IRgen/ABI: Add support for realigning structures which are passed by indirect
reference.

llvm-svn: 114114
2010-09-16 20:42:02 +00:00
Chris Lattner 8a2f3c778e fix PR5179 and correctly fix PR5831 to not miscompile.
The X86-64 ABI code didn't handle the case when a struct
would get classified and turn up as "NoClass INTEGER" for
example.  This is perfectly possible when the first slot
is all padding (e.g. due to empty base classes).  In this
situation, the first 8-byte doesn't take a register at all,
only the second 8-byte does.

This fixes this by enhancing the x86-64 abi stuff to allow
and handle this case, reverts the broken fix for PR5831,
and enhances the target independent stuff to be able to 
handle an argument value in registers being accessed at an
offset from the memory value.

This is the last x86-64 calling convention related miscompile
that I'm aware of.

llvm-svn: 109848
2010-07-30 04:02:24 +00:00
Chris Lattner 1f3a063f00 move the last hunk of getCoerceResult into the place
that needs it and remove getCoerceResult.

llvm-svn: 109807
2010-07-29 21:42:50 +00:00
Chris Lattner 2cdfda44a1 fix a builder, why didn't clang++ catch this?
llvm-svn: 109735
2010-07-29 06:44:09 +00:00
Chris Lattner fe34c1d53e Kill off the 'coerce' ABI passing form. Now 'direct' and 'extend' always
have a "coerce to" type which often matches the default lowering of Clang
type to LLVM IR type, but the coerce case can be handled by making them
not be the same.

This simplifies things and fixes issues where X86-64 abi lowering would 
return coerce after making preferred types exactly match up.  This caused
us to compile:

typedef float v4f32 __attribute__((__vector_size__(16)));
v4f32 foo(v4f32 X) {
  return X+X;
}

into this code at -O0:

define <4 x float> @foo(<4 x float> %X.coerce) nounwind {
entry:
  %retval = alloca <4 x float>, align 16          ; <<4 x float>*> [#uses=2]
  %coerce = alloca <4 x float>, align 16          ; <<4 x float>*> [#uses=2]
  %X.addr = alloca <4 x float>, align 16          ; <<4 x float>*> [#uses=3]
  store <4 x float> %X.coerce, <4 x float>* %coerce
  %X = load <4 x float>* %coerce                  ; <<4 x float>> [#uses=1]
  store <4 x float> %X, <4 x float>* %X.addr
  %tmp = load <4 x float>* %X.addr                ; <<4 x float>> [#uses=1]
  %tmp1 = load <4 x float>* %X.addr               ; <<4 x float>> [#uses=1]
  %add = fadd <4 x float> %tmp, %tmp1             ; <<4 x float>> [#uses=1]
  store <4 x float> %add, <4 x float>* %retval
  %0 = load <4 x float>* %retval                  ; <<4 x float>> [#uses=1]
  ret <4 x float> %0
}

Now we get:

define <4 x float> @foo(<4 x float> %X) nounwind {
entry:
  %X.addr = alloca <4 x float>, align 16          ; <<4 x float>*> [#uses=3]
  store <4 x float> %X, <4 x float>* %X.addr
  %tmp = load <4 x float>* %X.addr                ; <<4 x float>> [#uses=1]
  %tmp1 = load <4 x float>* %X.addr               ; <<4 x float>> [#uses=1]
  %add = fadd <4 x float> %tmp, %tmp1             ; <<4 x float>> [#uses=1]
  ret <4 x float> %add
}

This implements rdar://8248065

llvm-svn: 109733
2010-07-29 06:26:06 +00:00
Chris Lattner 22326a10a7 dissolve some more complexity: make the x86-64 abi lowering code
compute its own preferred types instead of having CGT compute
them then pass them (circuituously) down into ABIInfo.

llvm-svn: 109726
2010-07-29 02:31:05 +00:00
Chris Lattner 458b2aaee0 now that ABIInfo depends on CGT, it has trivial access to such
things as TargetData, ASTContext, LLVMContext etc.  Stop passing
them through so many APIs.

llvm-svn: 109723
2010-07-29 02:16:43 +00:00
Chris Lattner 2b03797222 cave in to reality and make ABIInfo depend on CodeGenTypes.
This will simplify a bunch of code, coming up next.

llvm-svn: 109722
2010-07-29 02:01:43 +00:00
Chris Lattner 4b8585ef6a tidy up
llvm-svn: 109699
2010-07-28 23:46:15 +00:00
Chris Lattner cccaad9584 change ABIArgInfo to hold its llvm type with PATypeHolder so that
it doesn't dangle as types get refined.  This fixes Shootout-C++/lists1
and probably also PR7522.

llvm-svn: 107196
2010-06-29 19:21:36 +00:00
Chris Lattner 1d7c9f7f4b Pass the LLVM IR version of argument types down into computeInfo.
This is somewhat annoying to do this at this level, but it avoids
having ABIInfo know depend on CodeGenTypes for a hint.

Nothing is using this yet, so no functionality change.

llvm-svn: 107111
2010-06-29 01:08:48 +00:00
Anders Carlsson 20759ad54c x86-64 ABI: If a type is a C++ record with either a non-trivial destructor or a non-trivial copy constructor, it should be passed in a pointer. Daniel, plz review.
llvm-svn: 82050
2009-09-16 15:53:40 +00:00
Benjamin Kramer 9cd050ab07 LLVMContext is a class now.
llvm-svn: 78691
2009-08-11 17:46:57 +00:00
Owen Anderson 758428f4e3 Update for LLVM API change.
llvm-svn: 78259
2009-08-05 23:18:46 +00:00
Owen Anderson 170229f68d Update for LLVM API change, and contextify a bunch of related stuff.
llvm-svn: 75705
2009-07-14 23:10:40 +00:00
Anton Korobeynikov 18adbf5f07 Add new ABIArgInfo kind: Extend. This allows target to implement its own argument
zero/sign extension logic (consider, e.g. target has only 64 bit registers and thus
i32's should be extended as well).

llvm-svn: 72998
2009-06-06 09:36:29 +00:00
Anton Korobeynikov 244360d62b Factor out TargetABIInfo stuff into separate file. No functionality change.
llvm-svn: 72962
2009-06-05 22:08:42 +00:00
Daniel Dunbar e46506eaea Pull CodeGenFunction::EmitVAArg into target specific ABIInfo classes.
- Missed this file.

llvm-svn: 64238
2009-02-10 21:44:36 +00:00
Daniel Dunbar b8b1c679c4 Merge ABIInfo StructRet/ByVal into Indirect.
- No (intended) functionality change, the semantic changes are to come.

llvm-svn: 63850
2009-02-05 08:00:50 +00:00
Daniel Dunbar 8045343ca2 Initialize alignment field for ByVal ABIInfo correctly.
llvm-svn: 63809
2009-02-05 01:01:30 +00:00
Daniel Dunbar 56e7552c73 Add ABIArgInfo::dump()
llvm-svn: 63794
2009-02-04 23:24:38 +00:00
Daniel Dunbar 32931eb21d Change ABIInfo to compute information for a full signature at a time
(the main point of this restructing).

llvm-svn: 63619
2009-02-03 06:51:18 +00:00
Daniel Dunbar 0136282a9c Remove ABIArgInfo::Default kind, ABI is now responsible for specifying
acceptable kind with more precise semantics.

llvm-svn: 63617
2009-02-03 06:30:17 +00:00
Daniel Dunbar 67dace890f Add ABIArgInfo::Direct kind, which passes arguments using whatever the
native IRgen type is. This is like Default, but without any extra
semantics (like automatic tweaking of structures or void).

llvm-svn: 63615
2009-02-03 06:17:37 +00:00
Daniel Dunbar 313321ea23 Move ABIArgInfo into CGFunctionInfo, computed on creation.
- Still have to convert some consumers over.

llvm-svn: 63610
2009-02-03 05:31:23 +00:00
Daniel Dunbar 6d6b0d309a Move ABIInfo/ABIArgInfo classes into ABIInfo.h
llvm-svn: 63586
2009-02-03 01:05:53 +00:00