Commit Graph

455 Commits

Author SHA1 Message Date
Anders Waldenborg
f4094e5ed7 llvm-c: Add LLVMIntPtrType{,ForAS}InContext
All of the Core API functions have versions which accept explicit context, in
addition to ones which work on global context. This commit adds functions
which accept explicit context to the Target API for consistency.

Patch by Peter Zotov

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192913 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-17 18:51:01 +00:00
Filip Pizlo
0739140b05 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.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192864 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-17 01:38:28 +00:00
Anders Waldenborg
75a5df1d1e 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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192852 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-16 21:30:25 +00:00
Anders Waldenborg
2906b519d1 [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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192821 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-16 18:00:54 +00:00
Anders Waldenborg
bfcd45cfe1 Revert "Add AllTargetsBindings sublibrary" as it breaks cmake build on (atleast) windows and darwin.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192697 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-15 13:04:27 +00:00
Anders Waldenborg
6480db4b3a Add AllTargetsBindings sublibrary instead of having static inlines in the llvm-c headers.
This new library will be linked in when using the "all-targets"
component and contains the LLVMInitializeAll* functions.

This means that those functions will exist as real symbols in
the shared library, and can therefore can be called from
bindings that are using ffi the shared library.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192690 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-15 12:08:59 +00:00
Rui Ueyama
6bba6bb12f Revert "llvm-c: Make target initializer functions external functions in lib."
This reverts commit r192316. The original change introduced circular
dependencies between libTarget and backends. That would broke a build unless
link everything into one big binary.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192329 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-09 23:15:49 +00:00
Anders Waldenborg
9360e64e60 llvm-c: Make target initializer functions external functions in lib.
Making them proper functions defined in the (shared)lib instead of
static inlines defined in the header files makes it possible to
actually distribute a binary compiled against the shared library
without having to worry about getting undefined symbol errors when
calling e.g LLVMInitializeAllTargetInfos because the shared library on
the other system was compiled with different targets.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192316 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-09 19:02:09 +00:00
Rafael Espindola
438900938c Optimize linkonce_odr unnamed_addr functions during LTO.
Generalize the API so we can distinguish symbols that are needed just for a DSO
symbol table from those that are used from some native .o.

The symbols that are only wanted for the dso symbol table can be dropped if
llvm can prove every other dso has a copy (linkonce_odr) and the address is not
important (unnamed_addr).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191922 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-03 18:29:09 +00:00
Quentin Colombet
797f06e19b [llvm-c][Disassembler] Add an option to print latency information in
disassembled output alongside the instructions.
E.g., on a vector shuffle operation with a memory operand, disassembled
outputs are:
* Without the option:
    vpshufd $-0x79, (%rsp), %xmm0
    
* With the option:
    vpshufd $-0x79, (%rsp), %xmm0   ## Latency: 5

The printed latency is extracted from the schedule model available in the
disassembler context. Thus, this option has no effect if there is not a
scheduling model for the target.
This boils down to one may need to specify the CPU string, so that this
option could have an effect.

Note: Latency < 2 are not printed.

This part of <rdar://problem/14687488>.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191859 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-02 22:07:57 +00:00
Filip Pizlo
6eb43d2956 This threads SectionName through the allocateCodeSection/allocateDataSection APIs, both in C++ and C land.
It's useful for the memory managers that are allocating a section to know what the name of the section is.  
At a minimum, this is useful for low-level debugging - it's customary for JITs to be able to tell you what 
memory they allocated, and as part of any such dump, they should be able to tell you some meta-data about 
what each allocation is for.  This allows clients that supply their own memory managers to do this.  
Additionally, we also envision the SectionName being useful for passing meta-data from within LLVM to an LLVM 
client.

This changes both the C and C++ APIs, and all of the clients of those APIs within LLVM.  I'm assuming that 
it's safe to change the C++ API because that API is allowed to change.  I'm assuming that it's safe to change 
the C API because we haven't shipped the API in a release yet (LLVM 3.3 doesn't include the MCJIT memory 
management C API).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191804 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-02 00:59:25 +00:00
Quentin Colombet
76502a756d [llvm-c][Disassembler] Add an option to reproduce in disassembled output the
comments issued with verbose assembly.
E.g., on a vector shuffle operation, disassembled output are:
* Without the option:
vpshufd $-0x79, (%rsp), %xmm0

* With the option:
vpshufd $-0x79, (%rsp), %xmm0   ## xmm0 = mem[3,1,0,2]

This part of <rdar://problem/14687488>.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191799 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-01 22:14:56 +00:00
Anders Waldenborg
5be81238f0 llvm-c: use typedef for function pointers
This makes it consistent with other function pointers used in llvm-c

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191693 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-30 19:11:32 +00:00
Peter Collingbourne
e8a665f696 Try again to fix the MSVC build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191359 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-25 07:52:21 +00:00
Peter Collingbourne
aca74f0e0d Wrap the #include of <stdbool.h> in an #ifndef __cplusplus.
This should fix the MSVC build.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191357 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-25 07:11:58 +00:00
Anders Waldenborg
f46e5eadc3 Revert "llvm-c: Add LLVMGetPointerToFunction"
This reverts r191030


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191075 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-20 07:00:36 +00:00
Anders Waldenborg
f2144ed439 llvm-c: Add LLVMGetPointerToFunction
Differential Revision: http://llvm-reviews.chandlerc.com/D1715



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191030 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-19 19:55:06 +00:00
Anders Waldenborg
f89dacb782 llvm-c: Make LLVMGetFirstTarget a proper prototype
This avoids warnings when included in a application that
uses -Wstrict-prototypes.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191029 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-19 19:43:55 +00:00
Shuxin Yang
00c198042e Revert 189297, the original commit message is following.
----
  Add new API lto_codegen_compile_parallel().

  This API is proposed by Nick Kledzik. The semantic is:

  --------------------------------------------------------------------------
   Generate code for merged module into an array of native object files. On 
   success returns a pointer to an array of NativeObjectFile.  The count 
   parameter returns the number of elements in the array.  Each element is 
   a pointer/length for a generated mach-o/ELF buffer.  The buffer is owned
   by the lto_code_gen_t and will be freed when lto_codegen_dispose() is called, 
   or lto_codegen_compile() is called again. On failure, returns NULL 
   (check lto_get_error_message() for details).

   extern const struct  NativeObjectFile*
   lto_codegen_compile_parallel(lto_code_gen_t cg, size_t *count);
  ---------------------------------------------------------------------------

  This API is currently only called on OSX platform. Linux or other Unixes
using GNU gold are not supposed to call this function, because on these systems, 
object files are fed back to linker via disk file instead of memory buffer.

  In this commit, lto_codegen_compile_parallel() simply calls
lto_codegen_compile() to return a single object file. In the near future,
this function is the entry point for compilation with partition. Linker can
blindly call this function even if partition is turned off; in this case,
compiler will return only one object file.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189386 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-27 17:15:54 +00:00
Shuxin Yang
e3427a5815 Add new API lto_codegen_compile_parallel().
This API is proposed by Nick Kledzik. The semantic is:

  --------------------------------------------------------------------------
   Generate code for merged module into an array of native object files. On 
   success returns a pointer to an array of NativeObjectFile.  The count 
   parameter returns the number of elements in the array.  Each element is 
   a pointer/length for a generated mach-o/ELF buffer.  The buffer is owned
   by the lto_code_gen_t and will be freed when lto_codegen_dispose() is called, 
   or lto_codegen_compile() is called again. On failure, returns NULL 
   (check lto_get_error_message() for details).

   extern const struct  NativeObjectFile*
   lto_codegen_compile_parallel(lto_code_gen_t cg, size_t *count);
  ---------------------------------------------------------------------------

  This API is currently only called on OSX platform. Linux or other Unixes
using GNU gold are not supposed to call this function, because on these systems, 
object files are fed back to linker via disk file instead of memory buffer.

  In this commit, lto_codegen_compile_parallel() simply calls
lto_codegen_compile() to return a single object file. In the near future,
this function is the entry point for compilation with partition. Linker can
blindly call this function even if partition is turned off; in this case,
compiler will return only one object file.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189297 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-27 00:03:23 +00:00
Andrea Di Biagio
5768bb8d77 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.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189101 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-23 11:53:55 +00:00
Richard Sandiford
a8a7099c18 Turn MipsOptimizeMathLibCalls into a target-independent scalar transform
...so that it can be used for z too.  Most of the code is the same.
The only real change is to use TargetTransformInfo to test when a sqrt
instruction is available.

The pass is opt-in because at the moment it only handles sqrt.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189097 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-23 10:27:02 +00:00
Daniel Dunbar
1323006423 [typo] An LLVM.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188589 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-16 23:30:19 +00:00
Shuxin Yang
cfaa636a1d Revert r188188 and r188200.
In order to appease people (in Apple) who accuse me for committing "huge change" (?) without proper review. 

Thank Eric for fixing a compile-warning. 


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188204 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-12 21:07:31 +00:00
Shuxin Yang
67d135ae40 Misc enhancements to LTO:
1. Add some helper classes for partitions. They are designed in a
     way such that the top-level LTO driver will not see much difference 
     with or without partitioning.

  2. Introduce work-dir. Now all intermediate files generated during 
     LTO phases will be saved under work-dir. User can specify the workdir
     via -lto-workdir=/path/to/dir. By default the work-dir will be 
     erased before linker exit. To keep the workdir, do -lto-keep, or -lto-keep=1.

    TODO: Erase the workdir, if the linker exit prematurely.  
      We are currently not able to remove directory on signal. The support 
      routines simply ignore directory.

  3. Add one new API lto_codegen_get_files_need_remove().
     Linker and LTO plugin will communicate via this API about which files
    (including directories) need to removed before linker exit.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188188 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-12 18:29:43 +00:00
Diego Novillo
77226a03dc 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182638 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-24 12:26:52 +00:00
Filip Pizlo
6cfed36338 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).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182448 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-22 02:46:43 +00:00
Filip Pizlo
1441bf7a41 Roll out r182407 and r182408 because they broke builds.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182409 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-21 20:03:01 +00:00
Filip Pizlo
52755c472a 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).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182408 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-21 20:00:56 +00:00
Duncan Sands
5d042c6374 Fix formatting. Patch by o11c.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181189 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-06 08:55:45 +00:00
Filip Pizlo
0e1327e4aa This exposes more MCJIT options via the C API:
CodeModel: It's now possible to create an MCJIT instance with any CodeModel you like.  Previously it was only possible to 
create an MCJIT that used CodeModel::JITDefault.

EnableFastISel: It's now possible to turn on the fast instruction selector.

The CodeModel option required some trickery.  The problem is that previously, we were ensuring future binary compatibility in 
the MCJITCompilerOptions by mandating that the user bzero's the options struct and passes the sizeof() that he saw; the 
bindings then bzero the remaining bits.  This works great but assumes that the bitwise zero equivalent of any field is a 
sensible default value.

But this is not the case for LLVMCodeModel, or its internal equivalent, llvm::CodeModel::Model.  In both of those, the default 
for a JIT is CodeModel::JITDefault (or LLVMCodeModelJITDefault), which is not bitwise zero.

Hence this change introduces LLVMInitializeMCJITCompilerOptions(), which will initialize the user's options struct with
defaults. The user will use this in the same way that they would have previously used memset() or bzero(). MCJITCAPITest.cpp
illustrates the change, as does the comment in ExecutionEngine.h.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180893 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-01 22:58:00 +00:00
Filip Pizlo
c9e180aaea Rename 'struct LLVMTargetMachine' to 'struct LLVMOpaqueTargetMachine'.
This avoids namespace collisions with llvm::LLVMTargetMachine.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180891 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-01 22:41:26 +00:00
Andrew Kaylor
d2755af8bd Exposing MCJIT through C API
Re-submitting with fix for OCaml dependency problems (removing dependency on SectionMemoryManager when it isn't used).

Patch by Fili Pizlo



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180720 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-29 17:49:40 +00:00
Rafael Espindola
7467e5ed1c Revert "Exposing MCJIT through C API"
This reverts commit 8c31b29814.

It looks like this commit broke some bots:

http://lab.llvm.org:8011/builders/llvm-ppc64-linux2/builds/5209

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180248 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-25 03:19:12 +00:00
Andrew Kaylor
8c31b29814 Exposing MCJIT through C API
Patch by Filip Pizlo



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180229 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-24 23:33:53 +00:00
Carlo Kok
d86871dd71 c vs c++ mistake in header file typedef for AtomicRMW fix in rev 180100.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180104 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-23 13:45:37 +00:00
Carlo Kok
8effd8dc98 Expose IRBuilder::CreateAtomicRMW as LLVMBuildAtomicRMW in llvm-c.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180100 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-23 13:21:19 +00:00
Eric Christopher
3e39731e88 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180063 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-22 22:47:22 +00:00
Tom Stellard
4bfeee1302 C API: Fix coding style
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179785 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-18 19:50:53 +00:00
Tom Stellard
ad74f335ef C API: Add LLVMTargetMachineEmitToMemoryBuffer()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179648 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-16 23:12:56 +00:00
Tom Stellard
edc93b356d C API: Add LLVMGetBufferSize()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179647 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-16 23:12:51 +00:00
Tom Stellard
4074343b2d C API: Add LLVMGetBufferStart()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179646 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-16 23:12:47 +00:00
Tom Stellard
68ee1520ce C API: Add LLVMAddTargetDependentFunctionAttr()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179645 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-16 23:12:43 +00:00
Hans Wennborg
6334e1351f 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!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179588 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-16 08:58:59 +00:00
Benjamin Kramer
acc897a5e1 Rename the C function to create a SLPVectorizerPass to something sane and expose it in the header file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179272 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-11 11:36:36 +00:00
Evan Cheng
9313da5a90 Revert r178713
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178769 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-04 17:40:53 +00:00
Evan Cheng
7d2166a643 Make it possible to include llvm-c without including C++ headers. Patch by Filip Pizlo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178713 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-03 23:12:39 +00:00
Nick Lewycky
0ebc084132 Use LLVMBool instead of 'bool' in the C API. Based on a patch by Peter Zotov!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176793 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-10 21:58:22 +00:00
Duncan Sands
906727dcfe Add multithreading functions and shutdown to the C API. Patch by Moritz
Maxeiner.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175398 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-17 16:35:51 +00:00
Bill Wendling
296756a2b5 s/bool/LLVMBool/
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175203 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-14 19:39:14 +00:00
Bill Wendling
31cfc70705 Add two new functions to the C API:
LLVMCreateMemoryBufferWithMemoryRange - exposes MemoryBuffer::getMemBuffer
 LLVMCreateMemoryBufferWithMemoryRangeCopy - exposes MemoryBuffer::getMemBufferCopy

Patch by Moritz Maxeiner!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175199 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-14 19:11:28 +00:00
Michael Gottesman
24c4898973 Extracted ObjCARC.cpp into its own library libLLVMObjCARCOpts in preparation for refactoring the ARC Optimizer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173647 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-28 01:35:51 +00:00
Bill Wendling
114baee1fa 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173230 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-23 06:41:41 +00:00
Jakub Staszak
674be02d52 Fix include guards so they exactly match file names.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172025 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-10 00:45:19 +00:00
Chandler Carruth
0b8c9a80f2 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171366 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-02 11:36:10 +00:00
Roman Divacky
759e3fa641 Remove edis - the enhanced disassembler. Fixes PR14654.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170578 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-19 19:55:47 +00:00
Kevin Enderby
5469f605fe Add to the disassembler C API an option to print the disassembled
instructions in the assembly code variant if one exists.

The intended use for this is so tools like lldb and darwin's otool(1)
can be switched to print Intel-flavored disassembly.

I discussed extensively this API with Jim Grosbach and we feel
while it may not be fully general, in reality there is only one syntax
for each assembly with the exception of X86 which has exactly
two for historical reasons.

rdar://10989182


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170477 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-18 23:47:28 +00:00
Bill Wendling
50f318384c Revert r169656.
The linker will call `lto_codegen_add_must_preserve_symbol' on all globals that
should be kept around. The linker will pretend that a dylib is being created.
<rdar://problem/12528059>


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169770 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-10 21:33:45 +00:00
Bill Wendling
f62b9cd890 Add the `lto_codegen_set_export_dynamic' function.
This function sets the `_exportDynamic' ivar. When that's set, we export all
symbols (e.g. we don't run the internalize pass). This is equivalent to the
`--export-dynamic' linker flag in GNU land:

--export-dynamic
  When creating a dynamically linked executable, add all symbols to the dynamic
  symbol table. The dynamic symbol table is the set of symbols which are visible
  from dynamic objects at run time. If you do not use this option, the dynamic
  symbol table will normally contain only those symbols which are referenced by
  some dynamic object mentioned in the link. If you use dlopen to load a dynamic
  object which needs to refer back to the symbols defined by the program, rather
  than some other dynamic object, then you will probably need to use this option
  when linking the program itself.

The Darwin linker will support this via the `-export_dynamic' flag. We should
modify clang to support this via the `-rdynamic' flag.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169656 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-08 00:18:16 +00:00
Jim Grosbach
68a590df13 Add C API for specifying CPU to the disassembler.
It was a nasty oversight that we didn't include this when we added this
API in the first place. Blech.

rdar://12839439

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169653 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-07 23:53:27 +00:00
Kevin Enderby
14ccc9007a Added a option to the disassembler to print immediates as hex.
This is for the lldb team so most of but not all of the values are
to be printed as hex with this option.  Some small values like the
scale in an X86 address were requested to printed in decimal
without the leading 0x.

There may be some tweaks need to places that may still be in
decimal that they want in hex.  Specially for arm.  I made my best
guess.  Any tweaks from here should be simple.

I also did the best I know now with help from the C++ gurus
creating the cleanest formatImm() utility function and containing
the changes.  But if someone has a better idea to make something
cleaner I'm all ears and game for changing the implementation.

rdar://8109283



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169393 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-05 18:13:19 +00:00
Chandler Carruth
d04a8d4b33 Use the new script to sort the includes of every file under lib.
Sooooo many of these had incorrect or strange main module includes.
I have manually inspected all of these, and fixed the main module
include to be the nearest plausible thing I could find. If you own or
care about any of these source files, I encourage you to take some time
and check that these edits were sensible. I can't have broken anything
(I strictly added headers, and reordered them, never removed), but they
may not be the headers you'd really like to identify as containing the
API being implemented.

Many forward declarations and missing includes were added to a header
files to allow them to parse cleanly when included first. The main
module rule does in fact have its merits. =]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169131 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-03 16:50:05 +00:00
Benjamin Kramer
8a2ce5d329 libLTO: Add a utility method to initialize the disassemblers.
Necessary to give disassembler users (like darwin's otool) a possibility to
dlopen libLTO and still initialize the required LLVM bits. This used to go
through libMCDisassembler but that's a gross layering violation, the MC layer
can't pull in functions from the targets. Adding a function to libLTO is a bit
of a hack but not worse than exposing other disassembler bits from libLTO.

Fixes PR14362.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168545 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-24 16:59:10 +00:00
Kevin Enderby
3ed0316f75 Add support for annotated disassembly output for X86 and arm.
Per the October 12, 2012 Proposal for annotated disassembly output sent out by
Jim Grosbach this set of changes implements this for X86 and arm.  The llvm-mc
tool now has a -mdis option to produced the marked up disassembly and a couple
of small example test cases have been added.

rdar://11764962


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166445 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-22 22:31:46 +00:00
Benjamin Kramer
63a4c24616 Symbol hygiene: Make sure declarations and definitions match, make helper functions static.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166376 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-20 12:53:26 +00:00
Bill Wendling
702cc91aa1 Move the Attributes::Builder outside of the Attributes class and into its own class named AttrBuilder. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165960 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-15 20:35:56 +00:00
Micah Villmow
2c39b15073 Resubmit the changes to llvm core to update the functions to support different pointer sizes on a per address space basis.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165941 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-15 16:24:29 +00:00
Bill Wendling
da3f9d8edc Use builder to create alignment attributes. Remove dead function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165890 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-14 03:58:29 +00:00
Micah Villmow
fb384d61c7 Revert 165732 for further review.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165747 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-11 21:27:41 +00:00
Micah Villmow
f3840d2c16 Add in the first iteration of support for llvm/clang/lldb to allow variable per address space pointer sizes to be optimized correctly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165726 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-11 17:21:41 +00:00
Bill Wendling
408aad5031 Update comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165461 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-08 23:51:19 +00:00
Micah Villmow
3574eca1b0 Move TargetData to DataLayout.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165402 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-08 16:38:25 +00:00
Duncan Sands
4caf5281bf Add support for accessing an MDNode's operands via the C binding. Patch by
Anthony Bryant.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164247 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-19 20:29:39 +00:00
Bob Wilson
e20cf3d149 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>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163148 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-04 17:42:53 +00:00
Nuno Lopes
2d892c5a72 replace a couple of single-line comments with /* */ to fix the build of stuff depending on the C headers
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163095 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-02 14:19:21 +00:00
Bill Wendling
32811bef95 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>


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162114 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-17 18:33:14 +00:00
Eli Bendersky
ac8a4ad47d A couple of addition comment fixes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161678 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-10 18:30:44 +00:00
Eli Bendersky
dadace036e Fix a couple of typos in comments
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161677 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-10 18:26:20 +00:00
Bill Wendling
8c51e3995d Remove tabs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160473 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-19 00:01:33 +00:00
Chandler Carruth
06cb8ed006 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159421 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-29 12:38:19 +00:00
Benjamin Kramer
d9b0b02561 Fix typos found by http://github.com/lyda/misspell-check
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157885 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-02 10:20:22 +00:00
Hans Wennborg
5c87b4958d 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!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156479 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-09 16:54:17 +00:00
Bill Wendling
f24fde20c8 Supply a C interface to the "LinkModules" method.
Patch by Andrew Wilkins!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156469 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-09 08:55:40 +00:00
Anders Waldenborg
8ed9951c3a [llvm-c] Make a few function declarations proper prototypes
This avoids warnings when included in a application that
uses -Wstrict-prototypes. 

e.g: AsmPrinters.def:27:1: warning: function declaration isn't a prototype [-Wstrict-prototypes]



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155997 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-02 16:15:32 +00:00
Rafael Espindola
4d2e9d9a1c Remove lto_codegen_set_whole_program_optimization. It is a work in progress,
so we don't want it to show up in the stable 3.1 interface.

While at it, add a comment about why LTOCodeGenerator manually creates the
internalize pass.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154807 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-16 10:58:38 +00:00
Duncan Sands
d6b7b8f49b Add a C binding to the Target and TargetMachine classes to allow for emitting
binary and assembly. Patch by Carlo Kok.  Emitting was inspired by but not based
on the D llvm bindings. 


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154493 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-11 10:25:24 +00:00
Bill Wendling
a3706d6754 s/lto_codegen_whole_program_optimization/lto_codegen_set_whole_program_optimization/
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154312 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-09 08:32:21 +00:00
Bill Wendling
3029a0c56a Add a hook to turn on the internalize pass through the LTO interface.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154306 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-09 05:26:48 +00:00
Bill Wendling
168f142834 Cleanup whitespace and remove unneeded 'extern' keyword on function definitions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153802 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-31 10:44:20 +00:00
Bill Wendling
29a776b824 Add 'undef's to make SWIG happier. Patch by Baozeng Ding.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153479 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-26 22:15:12 +00:00
Chris Lattner
eabe3ad57d add load/store volatility control to the C API, patch by Yiannis Tsiouris!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153238 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-22 03:54:15 +00:00
Gregory Szorc
57f33c86c7 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153169 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-21 07:28:27 +00:00
Gregory Szorc
6244b51888 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).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153157 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-21 03:54:29 +00:00
Bill Wendling
8833ef03b9 [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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149906 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-06 21:44:22 +00:00
Hal Finkel
7e004d177f A few of the changes suggested in code review (by Nick Lewycky)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149472 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 05:51:45 +00:00
Hal Finkel
de5e5ec304 Add a basic-block autovectorization pass.
This is the initial checkin of the basic-block autovectorization pass along with some supporting vectorization infrastructure.
Special thanks to everyone who helped review this code over the last several months (especially Tobias Grosser).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149468 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 03:51:43 +00:00
Bill Wendling
9a5c0e8d93 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149326 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-31 01:46:13 +00:00
Chandler Carruth
8f7fe08fee 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148937 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-25 07:40:15 +00:00
Benjamin Kramer
88e900808a Don't use my favorite C++11 feature (comma at end of enum).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148555 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-20 18:08:30 +00:00
Kostya Serebryany
164b86b439 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148553 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-20 17:56:17 +00:00
Devang Patel
45ca049f1f Add support to add named metadata operand.
Patch by Andrew Wilkins!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146984 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-20 19:29:36 +00:00
Dan Gohman
ce16339930 The powers that be have decided that LLVM IR should now support 16-bit
"half precision" floating-point with a first-class type.

This patch adds basic IR support (but not codegen support).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146786 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-17 00:04:22 +00:00
Danil Malyshev
b0436a7305 Fixed ObjectFile functions:
- getSymbolOffset() renamed as getSymbolFileOffset()
- getSymbolFileOffset(), getSymbolAddress(), getRelocationAddress() returns same result for ELFObjectFile, MachOObjectFile and COFFObjectFile.
- added getRelocationOffset()
- fixed MachOObjectFile::getSymbolSize()
- fixed MachOObjectFile::getSymbolSection()
- fixed MachOObjectFile::getSymbolOffset() for symbols without section data.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145408 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-29 17:40:10 +00:00
Daniel Dunbar
72736d1aa3 llvm-c: Add a few missing InitializeAll* functions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145330 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-29 00:06:55 +00:00
Chandler Carruth
790552c20f Revert r145180 as it is causing test failures on all the bots.
Original commit message:
Fixed ObjectFile functions:
- getSymbolOffset() renamed as getSymbolFileOffset()
- getSymbolFileOffset(), getSymbolAddress(), getRelocationAddress() returns same result for ELFObjectFile, MachOObjectFile and COFFObjectFile.
- added getRelocationOffset()
- fixed MachOObjectFile::getSymbolSize()
- fixed MachOObjectFile::getSymbolSection()
- fixed MachOObjectFile::getSymbolOffset() for symbols without section data.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145182 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-27 10:37:47 +00:00
Danil Malyshev
9b24738bd1 Fixed ObjectFile functions:
- getSymbolOffset() renamed as getSymbolFileOffset()
- getSymbolFileOffset(), getSymbolAddress(), getRelocationAddress() returns same result for ELFObjectFile, MachOObjectFile and COFFObjectFile.
- added getRelocationOffset()
- fixed MachOObjectFile::getSymbolSize()
- fixed MachOObjectFile::getSymbolSection()
- fixed MachOObjectFile::getSymbolOffset() for symbols without section data.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145180 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-27 10:12:52 +00:00
Chad Rosier
2fb655eefe Remove declarations for functions that don't exist (and never have).
Patch by Anders Waldenborg <anders@0x63.nu>.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143705 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-04 17:07:11 +00:00
Owen Anderson
3529c53d2f Expose relocation accessors through the libObject C API.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143109 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-27 17:32:36 +00:00
Owen Anderson
d8b0b915c5 Add relocation iterators to the libObject C API.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143107 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-27 17:15:47 +00:00
Owen Anderson
ca7eb3e171 Use LLVMBool for a function that logically returns a boolean value.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142683 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-21 20:35:58 +00:00
Owen Anderson
65f73abf07 Fix typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142681 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-21 20:28:19 +00:00
Owen Anderson
e2fa64ef22 Bind libObject API for obtaining the section containing a Symbol.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142667 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-21 18:21:22 +00:00
Owen Anderson
3cb056797b Expand the coverage of the libObject C bindings to include more SectionRef accessors as well as Symbol iterators.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142661 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-21 17:50:59 +00:00
Torok Edwin
3dd1674186 ocaml bindings: introduce classify_value
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141991 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-14 20:37:56 +00:00
Torok Edwin
6563c87996 ocaml bindings: add getopcode for constant and instruction, and int64_of_const.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141990 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-14 20:37:49 +00:00
Michael J. Spencer
4344b1ef9b Change relocation API to be per section. This time without breaking GCC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141385 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-07 19:25:32 +00:00
Bill Wendling
a48ad13339 Revert 141376 and 141377 due to breaking the build.
--- Reverse-merging r141377 into '.':
U    tools/llvm-objdump/MachODump.cpp
--- Reverse-merging r141376 into '.':
U    include/llvm/Object/COFF.h
U    include/llvm/Object/ObjectFile.h
U    include/llvm-c/Object.h
U    tools/llvm-objdump/llvm-objdump.cpp
U    lib/Object/MachOObjectFile.cpp
U    lib/Object/COFFObjectFile.cpp
U    lib/Object/Object.cpp
U    lib/Object/ELFObjectFile.cpp



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141379 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-07 18:25:37 +00:00
Michael J. Spencer
f1164a2487 Change relocation API to be per section.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141376 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-07 18:15:25 +00:00
Torok Edwin
4df1557f40 Don't require C bindings opcode numbers to be kept in sync.
They are not in sync now, for example Bitcast would show up as LLVMCall.
So instead introduce 2 functions that map to and from the opcodes in the C
bindings.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141290 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-06 12:39:34 +00:00
Torok Edwin
6831b7c645 Add uwtable, returnstwice and nonlazybind to the C bindings also.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141289 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-06 12:13:32 +00:00
Torok Edwin
ff12c99d13 ocaml/C bindings: type->isSized()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141288 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-06 12:13:28 +00:00
Torok Edwin
4917ec9ec7 add binding to read icmp predicate
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141287 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-06 12:13:20 +00:00
Torok Edwin
4f661ab0fb ocaml/C bindings: getmdstring, add num_op, get_op should work on metadata too
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141286 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-06 12:13:11 +00:00
Torok Edwin
c44943ed4f C/OCaml API to retrieve struct name.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141285 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-06 12:12:50 +00:00
Kevin Enderby
9e5887b17e Adding back support for printing operands symbolically to ARM's new disassembler
using llvm's public 'C' disassembler API now including annotations.

Hooked this up to Darwin's otool(1) so it can again print things like branch
targets for example this:
 blx _puts
instead of this:
 blx #-36
and includes support for annotations for branches to symbol stubs like:
 bl	0x40 @ symbol stub for: _puts
and annotations for pc relative loads like this:
 ldr	r3, #8 @ literal pool for: Hello, world!
Also again can print the expression encoded in the Mach-O relocation entries for
things like this:
 movt r0, :upper16:((_foo-_bar)+1234)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141129 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-04 22:44:48 +00:00
Devang Patel
0e6a24d92a Add C api for Instruction->eraseFromParent().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141023 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-03 20:59:18 +00:00
Nate Begeman
7ced7763ca Add some useful accessors to c++ api that appear to be missing from the c api
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138371 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-23 20:27:46 +00:00
Benjamin Kramer
613d13beb0 C API functions must be able to see their extern "C" definitions, or it will be impossible to call them from C.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138022 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-19 01:36:54 +00:00
Bill Wendling
e6e8826870 Initial commit of the 'landingpad' instruction.
This implements the 'landingpad' instruction. It's used to indicate that a basic
block is a landing pad. There are several restrictions on its use (see
LangRef.html for more detail). These restrictions allow the exception handling
code to gather the information it needs in a much more sane way.

This patch has the definition, implementation, C interface, parsing, and bitcode
support in it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137501 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-12 20:24:12 +00:00
Rafael Espindola
dd3d68f7a9 Add missing file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137162 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-09 22:19:52 +00:00
Bill Wendling
2626dba9c5 Remove the LowerSetJmp pass. It wasn't used effectively by any of the targets.
This is some of my original LLVM code. *wipes tear*


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136821 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-03 22:18:20 +00:00
Bill Wendling
1600525385 Remove the LLVMBuildUnwind C API function.
The 'unwind' function is going away with the new EH rewrite. This is step 0 in
keeping front-ends from using it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136683 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-02 06:20:17 +00:00
Bill Wendling
dccc03b242 Add the 'resume' instruction for the new EH rewrite.
This adds the 'resume' instruction class, IR parsing, and bitcode reading and
writing. The 'resume' instruction resumes propagation of an existing (in-flight)
exception whose unwinding was interrupted with a 'landingpad' instruction (to be
added later).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136589 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-31 06:30:59 +00:00
Bill Wendling
10c6d12a9f Revert r136253, r136263, r136269, r136313, r136325, r136326, r136329, r136338,
r136339, r136341, r136369, r136387, r136392, r136396, r136429, r136430, r136444,
r136445, r136446, r136253 pending review.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136556 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-30 05:42:50 +00:00
Eli Friedman
ff03048c13 LangRef and basic memory-representation/reading/writing for 'cmpxchg' and
'atomicrmw' instructions, which allow representing all the current atomic
rmw intrinsics.

The allowed operands for these instructions are heavily restricted at the
moment; we can probably loosen it a bit, but supporting general
first-class types (where it makes sense) might get a bit complicated,
given how SelectionDAG works.

As an initial cut, these operations do not support specifying an alignment,
but it would be possible to add if we think it's useful. Specifying an
alignment lower than the natural alignment would be essentially
impossible to support on anything other than x86, but specifying a greater
alignment would be possible.  I can't think of any useful optimizations which
would use that information, but maybe someone else has ideas.

Optimizer/codegen support coming soon.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136404 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-28 21:48:00 +00:00
Bill Wendling
c94eefb258 Keep enums stable. Append EH stuff to the end.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136263 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-27 21:00:28 +00:00
Bill Wendling
772fe17a6d Merge the contents from exception-handling-rewrite to the mainline.
This adds the new instructions 'landingpad' and 'resume'.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136253 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-27 20:18:04 +00:00
Eli Friedman
abcd715fdf The numbering of LLVMOpcode is supposed to be stable; revert my earlier change, and append Fence onto the end.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136245 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-27 18:59:19 +00:00
Eli Friedman
be9a9afee5 Fix a couple minor mistakes pointed out by Bill in adding 'fence' instruction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136124 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-26 20:24:06 +00:00
Rafael Espindola
3d72290ecb Add LLVMAddAlwaysInlinerPass to the C API.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136083 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-26 15:23:23 +00:00
Rafael Espindola
a03084d86e LLVM 3.0 is here, remove old do nothing method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136082 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-26 15:17:32 +00:00
Rafael Espindola
5160d38166 Add LLVMAddTargetLibraryInfo to the C API.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135975 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-25 21:20:54 +00:00
Rafael Espindola
0335a14ae7 Add LLVMAddLowerExpectIntrinsicPass to the C API.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135966 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-25 20:57:59 +00:00
Evan Cheng
e78085a3c0 Combine all MC initialization routines into one. e.g. InitializeX86MCAsmInfo,
InitializeX86MCInstrInfo, etc. are combined into InitializeX86TargetMC.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135812 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-22 21:58:54 +00:00
Evan Cheng
439661395f Introduce MCCodeGenInfo, which keeps information that can affect codegen
(including compilation, assembly). Move relocation model Reloc::Model from
TargetMachine to MCCodeGenInfo so it's accessible even without TargetMachine.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135468 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-19 06:37:02 +00:00
Chris Lattner
db125cfaf5 land David Blaikie's patch to de-constify Type, with a few tweaks.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135375 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-18 04:54:35 +00:00
Chris Lattner
ef58218b8d remove the InvalidateStructLayoutInfo API, which is dead and unnecessary now
that type refinement is toast.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135245 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-15 05:21:59 +00:00
Evan Cheng
1abf2cb59b Rename createAsmInfo to createMCAsmInfo and move registration code to MCTargetDesc to prepare for next round of changes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135219 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-14 23:50:31 +00:00
Rafael Espindola
64090bd2d4 Add LLVMConstNamedStruct to the C api to let its users create constants
of named struct types.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135178 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-14 19:09:08 +00:00
Chris Lattner
61afc8820f add a couple more missing C api, patch by Vitaly Lugovskiy!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135151 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-14 16:20:28 +00:00