Commit Graph

192 Commits

Author SHA1 Message Date
Anders Waldenborg 213a63fe53 llvm-c: Make LLVM{Get,Set}Alignment work on {Load,Store}Inst too
Patch by Peter Zotov

Differential Revision: http://llvm-reviews.chandlerc.com/D1910

llvm-svn: 193597
2013-10-29 09:02:02 +00:00
NAKAMURA Takumi a3a8135f45 include/llvm-c: Whitespace.
llvm-svn: 193253
2013-10-23 17:56:29 +00:00
Benjamin Kramer 325ec89508 Mark zero-argument functions explicitly in C headers.
Pacifies GCC's -Wstrict-prototypes.

llvm-svn: 193249
2013-10-23 16:57:34 +00:00
Anders Waldenborg 47b3bd3fbb llvm-c: Add LLVMPrintTypeToString
Differential Revision: http://llvm-reviews.chandlerc.com/D1963

llvm-svn: 193149
2013-10-22 06:58:34 +00:00
Filip Pizlo a535b14157 Expose install_fatal_error_handler() through the C API.
I expose the API with some caveats:

- The C++ API involves a traditional void* opaque pointer for the fatal 
error callback.  The C API doesn’t do this.  I don’t think that the void* 
opaque pointer makes any sense since this is a global callback - there will 
only be one of them.  So if you need to pass some data to your callback, 
just put it in a global variable.

- The bindings will ignore the gen_crash_diag boolean.  I ignore it because 
(1) I don’t know what it does, (2) it’s not documented AFAIK, and (3) I 
couldn’t imagine any use for it.  I made the gut call that it probably 
wasn’t important enough to expose through the C API.

llvm-svn: 192864
2013-10-17 01:38:28 +00:00
Anders Waldenborg b822cffad2 llvm-c: Add LLVMDumpType
The C API currently allows to dump values (LLVMDumpValue), but a similar method for types was not exported.

Patch by Peter Zotov

Differential Revision: http://llvm-reviews.chandlerc.com/D1911

llvm-svn: 192852
2013-10-16 21:30:25 +00:00
Anders Waldenborg 84355db7f9 [llvm-c] Add LLVMPrintModuleToString.
Like LLVMDumpModule but returns the string (that needs to be freed
with LLVMDisposeMessage) instead of printing it to stderr.

Differential Revision: http://llvm-reviews.chandlerc.com/D1941

llvm-svn: 192821
2013-10-16 18:00:54 +00:00
Andrea Di Biagio 377496bbad Add function attribute 'optnone'.
This function attribute indicates that the function is not optimized
by any optimization or code generator passes with the 
exception of interprocedural optimization passes.

llvm-svn: 189101
2013-08-23 11:53:55 +00:00
Daniel Dunbar 06b9f9ecaa [typo] An LLVM.
llvm-svn: 188589
2013-08-16 23:30:19 +00:00
Diego Novillo c63995394d Add a new function attribute 'cold' to functions.
Other than recognizing the attribute, the patch does little else.
It changes the branch probability analyzer so that edges into
blocks postdominated by a cold function are given low weight.

Added analysis and code generation tests.  Added documentation for the
new attribute.

llvm-svn: 182638
2013-05-24 12:26:52 +00:00
Filip Pizlo 3fdbaff3b9 Expose the RTDyldMemoryManager through the C API. This allows clients of
the C API to provide their own way of allocating JIT memory (both code 
and data) and finalizing memory permissions (page protections, cache 
flush).

llvm-svn: 182448
2013-05-22 02:46:43 +00:00
Filip Pizlo 5aefb1339c Roll out r182407 and r182408 because they broke builds.
llvm-svn: 182409
2013-05-21 20:03:01 +00:00
Filip Pizlo e1e3f7cc01 Expose the RTDyldMemoryManager through the C API. This allows clients of
the C API to provide their own way of allocating JIT memory (both code 
and data) and finalizing memory permissions (page protections, cache 
flush).

llvm-svn: 182408
2013-05-21 20:00:56 +00:00
Duncan Sands 5e37e99ba6 Fix formatting. Patch by o11c.
llvm-svn: 181189
2013-05-06 08:55:45 +00:00
Carlo Kok da0ac7253c c vs c++ mistake in header file typedef for AtomicRMW fix in rev 180100.
llvm-svn: 180104
2013-04-23 13:45:37 +00:00
Carlo Kok 8c6719bf07 Expose IRBuilder::CreateAtomicRMW as LLVMBuildAtomicRMW in llvm-c.
llvm-svn: 180100
2013-04-23 13:21:19 +00:00
Eric Christopher 04d4e9312c Move C++ code out of the C headers and into either C++ headers
or the C++ files themselves. This enables people to use
just a C compiler to interoperate with LLVM.

llvm-svn: 180063
2013-04-22 22:47:22 +00:00
Tom Stellard 62c03207d5 C API: Fix coding style
llvm-svn: 179785
2013-04-18 19:50:53 +00:00
Tom Stellard b7fb724b04 C API: Add LLVMGetBufferSize()
llvm-svn: 179647
2013-04-16 23:12:51 +00:00
Tom Stellard 385fa26f9a C API: Add LLVMGetBufferStart()
llvm-svn: 179646
2013-04-16 23:12:47 +00:00
Tom Stellard e8f35e1557 C API: Add LLVMAddTargetDependentFunctionAttr()
llvm-svn: 179645
2013-04-16 23:12:43 +00:00
Hans Wennborg 5ff71205ee Add four new functions and one new enum to the C API:
LLVMGetThreadLocalMode - exposes GlobalVariable::getThreadLocalMode
LLVMSetThreadLocalMode - exposes GlobalVariable::setThreadLocalMode
LLVMIsExternallyInitialized - exposes GlobalVariable::isExternallyInitialized
LLVMSetExternallyInitialized - exposes GlobalVariable::setExternallyInitialized
LLVMThreadLocalMode - maps to GlobalVariable::ThreadLocalMode

Patch by Moritz Maxeiner!

llvm-svn: 179588
2013-04-16 08:58:59 +00:00
Evan Cheng 2e254d041e Revert r178713
llvm-svn: 178769
2013-04-04 17:40:53 +00:00
Evan Cheng 51a7a9d712 Make it possible to include llvm-c without including C++ headers. Patch by Filip Pizlo.
llvm-svn: 178713
2013-04-03 23:12:39 +00:00
Duncan Sands 1cba0a8e0a Add multithreading functions and shutdown to the C API. Patch by Moritz
Maxeiner.

llvm-svn: 175398
2013-02-17 16:35:51 +00:00
Bill Wendling c9baa96e67 s/bool/LLVMBool/
llvm-svn: 175203
2013-02-14 19:39:14 +00:00
Bill Wendling 526276af71 Add two new functions to the C API:
LLVMCreateMemoryBufferWithMemoryRange - exposes MemoryBuffer::getMemBuffer
 LLVMCreateMemoryBufferWithMemoryRangeCopy - exposes MemoryBuffer::getMemBufferCopy

Patch by Moritz Maxeiner!

llvm-svn: 175199
2013-02-14 19:11:28 +00:00
Bill Wendling d154e283f2 Add the IR attribute 'sspstrong'.
SSPStrong applies a heuristic to insert stack protectors in these situations:

* A Protector is required for functions which contain an array, regardless of
  type or length.

* A Protector is required for functions which contain a structure/union which
  contains an array, regardless of type or length.  Note, there is no limit to
  the depth of nesting.

* A protector is required when the address of a local variable (i.e., stack
  based variable) is exposed. (E.g., such as through a local whose address is
  taken as part of the RHS of an assignment or a local whose address is taken as
  part of a function argument.)

This patch implements the SSPString attribute to be equivalent to
SSPRequired. This will change in a subsequent patch.

llvm-svn: 173230
2013-01-23 06:41:41 +00:00
Chandler Carruth 9fb823bbd4 Move all of the header files which are involved in modelling the LLVM IR
into their new header subdirectory: include/llvm/IR. This matches the
directory structure of lib, and begins to correct a long standing point
of file layout clutter in LLVM.

There are still more header files to move here, but I wanted to handle
them in separate commits to make tracking what files make sense at each
layer easier.

The only really questionable files here are the target intrinsic
tablegen files. But that's a battle I'd rather not fight today.

I've updated both CMake and Makefile build systems (I think, and my
tests think, but I may have missed something).

I've also re-sorted the includes throughout the project. I'll be
committing updates to Clang, DragonEgg, and Polly momentarily.

llvm-svn: 171366
2013-01-02 11:36:10 +00:00
Bill Wendling 50d27849f6 Move the Attributes::Builder outside of the Attributes class and into its own class named AttrBuilder. No functionality change.
llvm-svn: 165960
2012-10-15 20:35:56 +00:00
Bill Wendling abd5ba2523 Use builder to create alignment attributes. Remove dead function.
llvm-svn: 165890
2012-10-14 03:58:29 +00:00
Bill Wendling 7cf8f3c9c2 Update comment.
llvm-svn: 165461
2012-10-08 23:51:19 +00:00
Duncan Sands 12ccbe7a8e Add support for accessing an MDNode's operands via the C binding. Patch by
Anthony Bryant.

llvm-svn: 164247
2012-09-19 20:29:39 +00:00
Bob Wilson d43a50d38e Make sure macros in the include subdirectory are not used without being defined.
Rationale: For each preprocessor macro, either the definedness is what's
meaningful, or the value is what's meaningful, or both. If definedness is
meaningful, we should use #ifdef. If the value is meaningful, we should use
and #ifdef interchangeably for the same macro, seems ugly to me, even if
undefined macros are zero if used.

This also has the benefit that including an LLVM header doesn't prevent
you from compiling with -Wundef -Werror.

Patch by John Garvin!
<rdar://problem/12189979>

llvm-svn: 163148
2012-09-04 17:42:53 +00:00
Nuno Lopes def4229973 replace a couple of single-line comments with /* */ to fix the build of stuff depending on the C headers
llvm-svn: 163095
2012-09-02 14:19:21 +00:00
Bill Wendling 34bc34ecae Change the `linker_private_weak_def_auto' linkage to `linkonce_odr_auto_hide' to
make it more consistent with its intended semantics.

The `linker_private_weak_def_auto' linkage type was meant to automatically hide
globals which never had their addresses taken. It has nothing to do with the
`linker_private' linkage type, which outputs the symbols with a `l' (ell) prefix
among other things.

The intended semantic is more like the `linkonce_odr' linkage type.

Change the name of the linkage type to `linkonce_odr_auto_hide'. And therefore
changing the semantics so that it produces the correct output for the linker.

Note: The old linkage name `linker_private_weak_def_auto' will still parse but
is not a synonym for `linkonce_odr_auto_hide'. This should be removed in 4.0.
<rdar://problem/11754934>

llvm-svn: 162114
2012-08-17 18:33:14 +00:00
Eli Bendersky c52863cd36 A couple of addition comment fixes
llvm-svn: 161678
2012-08-10 18:30:44 +00:00
Eli Bendersky 870d057ec8 Fix a couple of typos in comments
llvm-svn: 161677
2012-08-10 18:26:20 +00:00
Chandler Carruth aafe0918bc Move llvm/Support/IRBuilder.h -> llvm/IRBuilder.h
This was always part of the VMCore library out of necessity -- it deals
entirely in the IR. The .cpp file in fact was already part of the VMCore
library. This is just a mechanical move.

I've tried to go through and re-apply the coding standard's preferred
header sort, but at 40-ish files, I may have gotten some wrong. Please
let me know if so.

I'll be committing the corresponding updates to Clang and Polly, and
Duncan has DragonEgg.

Thanks to Bill and Eric for giving the green light for this bit of cleanup.

llvm-svn: 159421
2012-06-29 12:38:19 +00:00
Benjamin Kramer bde9176663 Fix typos found by http://github.com/lyda/misspell-check
llvm-svn: 157885
2012-06-02 10:20:22 +00:00
Hans Wennborg b7ef2fe8ae Introduce llvm-c function LLVMPrintModuleToFile.
This lets you save the textual representation of the LLVM IR to a file.
Before this patch it could only be printed to STDERR from llvm-c.

Patch by Carlo Kok!

llvm-svn: 156479
2012-05-09 16:54:17 +00:00
Chris Lattner 2cc6f9dd90 add load/store volatility control to the C API, patch by Yiannis Tsiouris!
llvm-svn: 153238
2012-03-22 03:54:15 +00:00
Gregory Szorc 52d2660441 Finish organizing C API docs.
Remaining "uncategorized" functions have been organized into their
proper place in the hierarchy. Some functions were moved around so
groups are defined together.

No code changes were made.

llvm-svn: 153169
2012-03-21 07:28:27 +00:00
Gregory Szorc 34c863a031 Organize LLVM C API docs into doxygen modules; add docs
This gives a lot of love to the docs for the C API. Like Clang's
documentation, the C API is now organized into a Doxygen "module"
(LLVMC). Each C header file is a child of the main module. Some modules
(like Core) have a hierarchy of there own. The produced documentation is
thus better organized (before everything was in one monolithic list).

This patch also includes a lot of new documentation for APIs in Core.h.
It doesn't document them all, but is better than none. Function docs are
missing @param and @return annotation, but the documentation body now
commonly provides help details (like the expected llvm::Value sub-type
to expect).

llvm-svn: 153157
2012-03-21 03:54:29 +00:00
Bill Wendling 0aef16afd5 [unwind removal] Remove all of the code for the dead 'unwind' instruction. There
were no 'unwind' instructions being generated before this, so this is in effect
a no-op.

llvm-svn: 149906
2012-02-06 21:44:22 +00:00
Bill Wendling a4237652d2 Remove the eh.exception and eh.selector intrinsics. Also remove a hack to copy
over the catch information. The catch information is now tacked to the invoke
instruction.

llvm-svn: 149326
2012-01-31 01:46:13 +00:00
Chandler Carruth 44d69d9c25 Revert a tiny bit of r148553 which extended LLVM's function attributes
to 64-bits, and added a new attribute in bit #32. Specifically, remove
this new attribute from the enum used in the C API. It's not yet clear
what the best approach is for exposing these new attributes in the
C API, and several different proposals are on the table. Until then, we
can simply not expose this bit in the API at all.

Also, I've reverted a somewhat unrelated change in the same revision
which switched from "1 << 31" to "1U << 31" for the top enum. While "1
<< 31" is technically undefined behavior, implementations DTRT here.
However, MS and -pedantic mode warn about non-'int' type enumerator
values. If folks feel strongly about this I can put the 'U' back in, but
it seemed best to wait for the proper solution.

llvm-svn: 148937
2012-01-25 07:40:15 +00:00
Benjamin Kramer e2456055ef Don't use my favorite C++11 feature (comma at end of enum).
llvm-svn: 148555
2012-01-20 18:08:30 +00:00
Kostya Serebryany a5054ad2f3 Extend Attributes to 64 bits
Problem: LLVM needs more function attributes than currently available (32 bits).
One such proposed attribute is "address_safety", which shows that a function is being checked for address safety (by AddressSanitizer, SAFECode, etc).

Solution:
- extend the Attributes from 32 bits to 64-bits
- wrap the object into a class so that unsigned is never erroneously used instead
- change "unsigned" to "Attributes" throughout the code, including one place in clang.
- the class has no "operator uint64 ()", but it has "uint64_t Raw() " to support packing/unpacking.
- the class has "safe operator bool()" to support the common idiom:  if (Attributes attr = getAttrs()) useAttrs(attr);
- The CTOR from uint64_t is marked explicit, so I had to add a few explicit CTOR calls
- Add the new attribute "address_safety". Doing it in the same commit to check that attributes beyond first 32 bits actually work.
- Some of the functions from the Attribute namespace are worth moving inside the class, but I'd prefer to have it as a separate commit.

Tested:
"make check" on Linux (32-bit and 64-bit) and Mac (10.6)
built/run spec CPU 2006 on Linux with clang -O2.


This change will break clang build in lib/CodeGen/CGCall.cpp.
The following patch will fix it.

llvm-svn: 148553
2012-01-20 17:56:17 +00:00
Devang Patel 9224540efc Add support to add named metadata operand.
Patch by Andrew Wilkins!

llvm-svn: 146984
2011-12-20 19:29:36 +00:00