Commit Graph

575 Commits

Author SHA1 Message Date
Richard Smith 81ef0e1adb Fix some typos.
llvm-svn: 269528
2016-05-14 01:21:40 +00:00
Oleg Ranevskyy 7232f66051 [CodeGen] Clang does not choose aapcs-vfp calling convention for ARM bare metal target with hard float (EABIHF)
Summary:
Clang does not detect `aapcs-vfp` for the EABIHF environment. The reason is that only GNUEABIHF is considered while choosing calling convention, EABIHF is ignored.

This causes clang to use `aapcs` for EABIHF and add the `arm_aapcscc` specifier to functions in generated IR.

The modified `arm-cc.c` test checks that no calling convention specifier is added to functions for EABIHF, which means the default one is used (`CallingConv::ARM_AAPCS_VFP`).

Reviewers: rengolin, compnerd, t.p.northover

Subscribers: aemerson, rengolin, asl, cfe-commits

Differential Revision: http://reviews.llvm.org/D20219

llvm-svn: 269419
2016-05-13 14:45:57 +00:00
Nikolay Haustov 1771948d72 Revert "AMDGPU/SI: Use amdgpu_kernel calling convention for OpenCL kernels."
This reverts commit f7053ec90d0fc56f0837e43c2c759e85b56c21a1.

It broke calling OpenCL kernel from another kernel.

llvm-svn: 268740
2016-05-06 15:00:51 +00:00
Nikolay Haustov 4961ea85d7 AMDGPU/SI: Use amdgpu_kernel calling convention for OpenCL kernels.
Reviewers: tstellarAMD, arsenm

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D19918

llvm-svn: 268718
2016-05-06 09:15:24 +00:00
Tim Northover 34fd4fb459 AArch64: fixup comment after change
llvm-svn: 268423
2016-05-03 19:24:47 +00:00
Tim Northover 360d2b3325 AArch64: simplify illegal vector check. NFC.
Use a utility function to check whether the number of elements is a power of 2
and drop the redundant upper limit (a 128-bit vector with more than 16 elements
would have each element < 8 bits, not possible).

llvm-svn: 268422
2016-05-03 19:22:41 +00:00
Reid Kleckner 0404605dda Expand aggregate arguments more often on 32-bit Windows
Before this change, we would pass all non-HFA record arguments on
Windows with byval. Byval often blocks optimizations and results in bad
code generation. Windows now uses the existing workaround that other
x86_32 platforms use.

I also expanded the workaround to handle C++ records with constructors
on Windows. On non-Windows platforms, we have to keep generating the
same LLVM IR prototypes if we want our bitcode to be ABI compatible.
Otherwise we will encounter mismatch issues like PR21573.

Essentially fixes PR27522 in Clang instead of LLVM.

Reviewers: hans

Differential Revision: http://reviews.llvm.org/D19756

llvm-svn: 268261
2016-05-02 17:41:07 +00:00
Bryan Chan e3f1ed5805 [SystemZ] Support Swift calling convention
Summary:
Port rL265324 to SystemZ to allow using the 'swiftcall' attribute on that architecture.

Depends on D19414.

Reviewers: kbarton, rjmccall, uweigand

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D19432

llvm-svn: 267879
2016-04-28 13:56:43 +00:00
Anastasia Stulova 0937a7d814 [SPIR] Remove an assert mandating SPIR for OpenCL sources only.
SPIR target can be used for C/C++ inputs too (i.e. in OpenCL compatible mode for the libs creation).

Patch by Neil Henning!

Review: http://reviews.llvm.org/D19478
llvm-svn: 267561
2016-04-26 15:14:01 +00:00
Kostya Serebryany 0da4442f14 trying to fix the windows build broken by r267496
llvm-svn: 267513
2016-04-26 01:53:49 +00:00
Jacques Pienaar e74d91314a [lanai] Update handling of structs in arguments to be passed in registers.
Previously aggregate types were passed byval, change the ABI to pass these in registers instead.

llvm-svn: 267496
2016-04-26 00:09:29 +00:00
Ahmed Bougacha 40a34c2e2a [CodeGen] Widen non-power-of-2 vector HFA base types.
Currently, for the ppc64--gnu and aarch64 ABIs, we recognize:
  typedef __attribute__((__ext_vector_type__(3))) float v3f32;
  typedef __attribute__((__ext_vector_type__(16))) char v16i8;
  struct HFA {
    v3f32 a;
    v16i8 b;
  };

as an HFA. Since the first type encountered is used as the base type,
we pass the HFA as:
    [2 x <3 x float>]
Which leads to incorrect IR (relying on padding values) when the
second field is used.

Instead, explicitly widen the vector (after size rounding) in
isHomogeneousAggregate.

Differential Revision: http://reviews.llvm.org/D18998

llvm-svn: 266784
2016-04-19 17:54:29 +00:00
Ahmed Bougacha 8862cae75b [CodeGen] Fix whitespace. NFC.
llvm-svn: 266783
2016-04-19 17:54:24 +00:00
Reid Kleckner 9305fd1f86 [CodeGen] Avoid ctor/dtor boilerplate with some C++11
Non-owning pointers that cache LLVM types and constants can use
'nullptr' default member initializers so that we don't need to mention
them in the constructor initializer list.

Owning pointers should use std::unique_ptr so that we don't need to
manually delete them in the destructor. They also don't need to be
mentioned in the constructor at that point.

NFC

llvm-svn: 266263
2016-04-13 23:37:17 +00:00
Saleem Abdulrasool 10a4972a8d revert SVN r265702, r265640
Revert the two changes to thread CodeGenOptions into the TargetInfo allocation
and to fix the layering violation by moving CodeGenOptions into Basic.
Code Generation is arguably not particularly "basic".  This addresses Richard's
post-commit review comments.  This change purely does the mechanical revert and
will be followed up with an alternate approach to thread the desired information
into TargetInfo.

llvm-svn: 265806
2016-04-08 16:52:00 +00:00
Saleem Abdulrasool 94cfc603d1 Basic: move CodeGenOptions from Frontend
This is a mechanical move of CodeGenOptions from libFrontend to libBasic.  This
fixes the layering violation introduced earlier by threading CodeGenOptions into
TargetInfo.  It should also fix the modules based self-hosting builds.  NFC.

llvm-svn: 265702
2016-04-07 17:49:44 +00:00
Benjamin Kramer 5d28c7f9a2 Move class into an anonymous namespace. NFC.
llvm-svn: 265654
2016-04-07 10:14:54 +00:00
John McCall 12f2352152 IRGen-level lowering for the Swift calling convention.
llvm-svn: 265324
2016-04-04 18:33:08 +00:00
Jacques Pienaar d964cc22d1 [lanai] Add Lanai backend to clang driver.
Changes to clang to add Lanai backend. Adds a new target, ABI and toolchain.

General Lanai backend discussion on llvm-dev thread "[RFC] Lanai backend" (http://lists.llvm.org/pipermail/llvm-dev/2016-February/095118.html).

Differential Revision: http://reviews.llvm.org/D17002

llvm-svn: 264655
2016-03-28 21:02:54 +00:00
Xiuli Pan 972bea8a2e [OpenCL] Add ocl and spir version for spir target
Summary: Add opencl.spir.version and opencl.ocl.version metadata for CodeGen to identify OpenCL version. 

Reviewers: yaxunl, Anastasia

Subscribers: cfe-commits, pekka.jaaskelainen

Differential Revision: http://reviews.llvm.org/D17596

llvm-svn: 264241
2016-03-24 03:57:17 +00:00
Pirama Arumuga Nainar 8e2e9d6f4c Add -fnative-half-arguments-and-returns
Summary:
r246764 handled __fp16 arguments and returns for AAPCS, but skipped this
handling for OpenCL.  Simlar to OpenCL, RenderScript also handles __fp16
type natively.

This patch adds the -fnative-half-arguments-and-returns command line
flag to allow such languages to skip this coercion of __fp16.

Reviewers: srhines, olista01

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D18138

llvm-svn: 263795
2016-03-18 16:58:36 +00:00
John McCall f26e73df75 Add a coerce-and-expand ABIArgInfo as a generalization of some
of the things we do with Expand / Direct.

NFC for now, but this will be used by swiftcall expansion.

llvm-svn: 263192
2016-03-11 04:30:43 +00:00
David Majnemer e2ae228c76 [X86] Pass __m64 types via SSE registers for GCC compatibility
For compatibility with GCC, classify __m64 as SSE.
However, clang is a platform compiler for certain targets; retain our
old behavior on those targets: classify __m64 as integer.

This fixes PR26832.

llvm-svn: 262688
2016-03-04 05:26:16 +00:00
James Y Knight 29b5f086ca Default vaarg lowering should support indirect struct types.
Fixes PR11517 for SPARC.

On most targets, clang lowers va_arg itself, eschewing the use of the
llvm vaarg instruction. This is necessary (at least for now) as the type
argument to the vaarg instruction cannot represent all the ABI
information that is needed to support complex calling conventions.

However, on targets with a simpler varrags ABIs, the LLVM instruction
can work just fine, and clang can simply lower to it. Unfortunately,
even on such targets, vaarg with a struct argument would fail, because
the default lowering to vaarg was naive: it didn't take into account the
ABI attribute computed by classifyArgumentType. In particular, for the
DefaultABIInfo, structs are supposed to be passed indirectly and so
llvm's vaarg instruction should be emitted with a pointer argument.

Now, vaarg instruction emission is able to use computed ABIArgInfo for
the provided argument type, which allows the default ABI support to work
for structs too.

I haven't touched the EmitVAArg implementation for PPC32_SVR4 or XCore,
although I believe both are now redundant, and could be switched over to
use the default implementation as well.

Differential Revision: http://reviews.llvm.org/D16154

llvm-svn: 261717
2016-02-24 02:59:33 +00:00
Dan Gohman 1fcd10ca4e [WebAssembly] Lower va_arg in clang.
This uses the general emitVoidPtrVAArg lowering logic for everything, since
this supports all types, and we don't have any special requirements.

llvm-svn: 261557
2016-02-22 19:17:40 +00:00
Nirav Dave 9a8f97e967 Add support for Android Vector calling convention for AArch64
This modification applies the following Android commit when we have an
Android environment. This is the sole non-renderscript in the Android repo

	commit 9212d4fb30a3ca2f4ee966dd2748c35573d9682c
	Author: Tim Murray <timmurray@google.com>
	Date:   Fri Aug 15 16:00:15 2014 -0700

	    Update vector calling convention for AArch64.

	    bug 16846318

	    Change-Id: I3cfd167758b4bd634d8480ee6ba6bb55d61f82a7

Reviewers: srhines, jyknight

Subscribers: mcrosier, aemerson, rengolin, tberghammer, danalbert, srhines

Differential Revision: http://reviews.llvm.org/D17448

llvm-svn: 261533
2016-02-22 16:48:42 +00:00
Roman Divacky 039b970c97 Fix handling of vaargs on PPC32 when going from regsave to overflow.
It can happen that when we only have 1 more register left in the regsave
area we need to store a value bigger than 1 register and therefore we
go to the overflow area. In this case we have to leave the last slot
in the regsave area unused and keep using overflow area. Do this
by storing a limit value to the used register counter in the overflow block.

Issue diagnosed by and solution tested by Mark Millard!

llvm-svn: 261422
2016-02-20 08:31:24 +00:00
Denis Zobnin 380b224359 [MCU] Fix assertion failure on function returning empty union.
Treat empty struct/union in return type as void for MCU ABI. PR26438.

Differential Revision: http://reviews.llvm.org/D16808

llvm-svn: 260510
2016-02-11 11:26:03 +00:00
John McCall 0139178e1b Add an ARC autoreleased-return-value caller marker on i386.
rdar://24531556

llvm-svn: 259932
2016-02-05 21:37:38 +00:00
Saleem Abdulrasool d0807aee51 CodeGen: correct Windows ARM C++ assertion
Because the Decl is explicitly passed as nullptr further up the call chain, it
is possible to invoke isa on a nullptr, which will assert.  Guard against the
nullptr.

Take the opportunity to reuse the helper method rather than re-implementing this
logic.

llvm-svn: 259874
2016-02-05 04:12:40 +00:00
Yaron Keren cdae941e03 Annotate dump() methods with LLVM_DUMP_METHOD, addressing Richard Smith r259192 post commit comment.
llvm-svn: 259232
2016-01-29 19:38:18 +00:00
Tim Northover d88ecb30a1 ARMv7k: select ABI based on v7k Arch rather than watchos OS.
Various bits we'd like to use the new ABI actually compile with "-arch armv7k
-miphoneos-version-min=9.0". Not ideal, but also not ridiculous given how
slices work.

llvm-svn: 258976
2016-01-27 19:32:40 +00:00
Alexey Bataev d51e9933b6 [X86] Support 'interrupt' attribute for x86
This attribute may be attached to a function definition and instructs the backend to generate appropriate function entry/exit code so that
it can be used directly as an interrupt handler.
The IRET instruction, instead of the RET instruction, is used to return from interrupt or exception handlers. All registers, except for the EFLAGS register which is restored by the IRET instruction, are preserved by the compiler.
Any interruptible-without-stack-switch code must be compiled with -mno-red-zone since interrupt handlers can and will, because of the hardware design, touch
the red zone.

interrupt handler must be declared with a mandatory pointer argument:
struct interrupt_frame;

__attribute__ ((interrupt))
void f (struct interrupt_frame *frame) {
    ...
}
and user must properly define the structure the pointer pointing to.

exception handler: 

The exception handler is very similar to the interrupt handler with a different mandatory function signature:
#ifdef __x86_64__
typedef unsigned long long int uword_t;
#else
typedef unsigned int uword_t;
#endif

struct interrupt_frame;

__attribute__ ((interrupt))
void f (struct interrupt_frame *frame, uword_t error_code) {
    ...
}
and compiler pops the error code off stack before the IRET instruction.

The exception handler should only be used for exceptions which push an error code and all other exceptions must use the interrupt handler.
The system will crash if the wrong handler is used.
Differential Revision: http://reviews.llvm.org/D15709

llvm-svn: 257867
2016-01-15 04:06:31 +00:00
Rui Ueyama 83aa97941f Update for LLVM function name change.
llvm-svn: 257802
2016-01-14 21:00:27 +00:00
Michael Kuperstein f3163dc461 [X86] Better support for the MCU psABI (clang part)
This adds support for the MCU psABI in a way different from r251223 and r251224,
basically reverting most of these two patches. The problem with the approach
taken in r251223/4 is that it only handled libcalls that originated from the backend.
However, the mid-end also inserts quite a few libcalls and assumes these use the
platform's default calling convention.

The previous patch tried to insert inregs when necessary both in the FE and,
somewhat hackily, in the CG. Instead, we now define a new default calling convention
for the MCU, which doesn't use inreg marking at all, similarly to what x86-64 does.

Differential Revision: http://reviews.llvm.org/D15055

llvm-svn: 256495
2015-12-28 14:39:54 +00:00
Petar Jovanovic 88a328fbbe [Power PC] add soft float support for ppc32
This patch enables soft float support for ppc32 architecture and fixes
the ABI for variadic functions. This is the first in a set of patches
for soft float support in LLVM.

Patch by Strahinja Petrovic.

Differential Revision: http://reviews.llvm.org/D13351

llvm-svn: 255515
2015-12-14 17:51:50 +00:00
Stephen Hines 8267e7d456 LLDB JIT needs android vector passing rules.
Summary:
Looking into some recent issues with LLDBs expression parser highlighted that upstream clang passes vectors types differently to Android Open Source Project's clang for Arm Android targets.
This patch reflects the changes present in the AOSP and allows LLDB's JIT expression evaluation to work correctly for Arm Android targets when passing vectors.

This is submitted with consent of the original author Stephen Hines.

Reviewers: asl, rsmith, ADodds, rnk

Subscribers: rnk, aemerson, tberghammer, danalbert, srhines, cfe-commits, pirama

Differential Revision: http://reviews.llvm.org/D14639

llvm-svn: 254682
2015-12-04 01:39:30 +00:00
Petar Jovanovic 402257b84e [PowerPC] Fix calculating address of arguments on stack for variadic func
Fix calculating address of arguments larger than 32 bit on stack for
variadic functions (rounding up address to alignment) on ppc32 architecture.

Patch by Strahinja Petrovic.

Differential Revision: http://reviews.llvm.org/D14871

llvm-svn: 254670
2015-12-04 00:26:47 +00:00
Daniel Sanders 54dd84d48f Fixed default label in fully covered switch warning that was introduced in r254203.
llvm-svn: 254208
2015-11-27 19:49:24 +00:00
Daniel Sanders bd3f47f5b5 [mips] Interrupt attribute support.
Summary: This patch adds support for the interrupt attribute for mips32r2+.

Patch by Simon Dardis.

Reviewers: dsanders, aaron.ballman

Subscribers: aaron.ballman, cfe-commits

Differential Revision: http://reviews.llvm.org/D10802

llvm-svn: 254205
2015-11-27 18:03:44 +00:00
Daniel Sanders 8f8eb8f545 Revert r254203: [mips] Interrupt attribute support.
I forgot to credit the author.

llvm-svn: 254204
2015-11-27 18:00:36 +00:00
Daniel Sanders 586be02495 [mips] Interrupt attribute support.
Summary: This patch adds support for the interrupt attribute for mips32r2+.

Reviewers: dsanders, aaron.ballman

Subscribers: aaron.ballman, cfe-commits

Differential Revision: http://reviews.llvm.org/D10802

llvm-svn: 254203
2015-11-27 17:39:20 +00:00
Martell Malone eec224eef7 Remove some legacy mingw-w64 gcc struct info
As of gcc 4.7 mingw-w64 no longer emits 128-bit structs as i128

Differential Revision: http://reviews.llvm.org/D14179

llvm-svn: 251930
2015-11-03 15:57:45 +00:00
Tim Northover 4c5cb9c1da Fix va_arg on watchOS.
As in other contexts, alignments can go up to 16 bytes in a va_list.

llvm-svn: 251821
2015-11-02 19:32:23 +00:00
Tim Northover 5627d3935a ARMv7k: implement ABI changes for watchOS from standard iOS.
llvm-svn: 251710
2015-10-30 16:30:45 +00:00
Reid Kleckner 11a17198e0 Fix the calling convention of Mingw64 long double values
GCC uses the x87DoubleExtended model for long doubles, and passes them
indirectly by address through function calls.

Also replace the existing mingw-long-double assembly emitting test with
an IR-level test.

llvm-svn: 251567
2015-10-28 22:29:52 +00:00
Michael Kuperstein d749f235ed Access the right triple field for IAMCU.
llvm-svn: 251396
2015-10-27 07:46:22 +00:00
Michael Kuperstein 6890188ea3 [X86] Mark inregs correctly for MCU psABI
The MCU psABI calling convention is somewhat, but not quite, like -mregparm 3.
In particular, the rules involving structs are different.

Differential Revision: http://reviews.llvm.org/D13978

llvm-svn: 251224
2015-10-25 08:18:20 +00:00
Angel Garcia Gomez 637d1e6694 Roll-back r250822.
Summary: It breaks the build for the ASTMatchers

Subscribers: klimek, cfe-commits

Differential Revision: http://reviews.llvm.org/D13893

llvm-svn: 250827
2015-10-20 13:23:58 +00:00
Angel Garcia Gomez b5250d3448 Apply modernize-use-default to clang.
Summary: Replace empty bodies of default constructors and destructors with '= default'.

Reviewers: bkramer, klimek

Subscribers: klimek, alexfh, cfe-commits

Differential Revision: http://reviews.llvm.org/D13890

llvm-svn: 250822
2015-10-20 12:52:55 +00:00