Commit Graph

1038 Commits

Author SHA1 Message Date
Nate Begeman 664cf27602 Allow cross-process JIT to handle MachineRelocations of the ExternalSymbol
variety.  For example, an i64 div might turn into a call to __divdi3 during
legalization.

llvm-svn: 66646
2009-03-11 07:03:43 +00:00
Chris Lattner 26161cdc6c Fix PR3724 by searching for the largest free block when
allocating memory in the JIT.  This is insanely inefficient, but
hey, most people implement their own memory managers anyway.

Patch by Eric Yew!

llvm-svn: 66472
2009-03-09 21:34:10 +00:00
Duncan Sands 12da8ce3d2 Introduce new linkage types linkonce_odr, weak_odr, common_odr
and extern_weak_odr.  These are the same as the non-odr versions,
except that they indicate that the global will only be overridden
by an *equivalent* global.  In C, a function with weak linkage can
be overridden by a function which behaves completely differently.
This means that IP passes have to skip weak functions, since any
deductions made from the function definition might be wrong, since
the definition could be replaced by something completely different
at link time.   This is not allowed in C++, thanks to the ODR
(One-Definition-Rule): if a function is replaced by another at
link-time, then the new function must be the same as the original
function.  If a language knows that a function or other global can
only be overridden by an equivalent global, it can give it the
weak_odr linkage type, and the optimizers will understand that it
is alright to make deductions based on the function body.  The
code generators on the other hand map weak and weak_odr linkage
to the same thing.

llvm-svn: 66339
2009-03-07 15:45:40 +00:00
Nate Begeman 52b696c7ad Finish cross-process JIT work, and clean up previous work.
1. When the JIT is asked to remove a function, updating it's
   mapping to 0, we invalidate any function stubs used only 
   by that function.  Now, also invalidate the JIT's mapping
   from the GV the stub pointed to, to the address of the GV.

2. When dlsym stubs for cross-process JIT are enabled, do not
   abort just because a named function cannot be found in the
   JIT's process.

3. Fix various assumptions about when it is ok to use the lazy
   resolver when non-lazy JITing is enabled.

llvm-svn: 66324
2009-03-07 06:41:19 +00:00
Chris Lattner 0c33d436b3 switch this message back to only being in -debug mode.
llvm-svn: 66143
2009-03-05 06:48:16 +00:00
Nate Begeman 359df7420f When allocating stubs, keep track of which Functions are referencing the stub.
This invalidates the stubs in the resolver map when they are no longer referenced,
and should the JIT memory manager ever pick up a deallocateStub interface, the
JIT could reclaim the memory for unused stubs as well.

llvm-svn: 66141
2009-03-05 06:34:37 +00:00
Nate Begeman 920438ef1d Fix a thinko in the JIT where the address of a GV was only recorded in the map
on failure to resolve it.
Do not abort on failure to resolve an external symbol when using dlsym stubs,
  since the symbol may not be in the JIT's address space.  Just use 0.
Allow dlsym stubs to differentiate between GlobalVars and Functions.

llvm-svn: 66050
2009-03-04 19:10:38 +00:00
Chris Lattner 7956bba545 don't #include a header into the middle of an anon namespace.
llvm-svn: 65967
2009-03-03 20:10:23 +00:00
Nate Begeman aa06843c56 Fix the calculation for how big the allocated stub needs to be.
llvm-svn: 65895
2009-03-02 23:10:14 +00:00
Dan Gohman c0ae249b22 Fix the logic in this assertion to properly validate the number
of arguments.

llvm-svn: 64999
2009-02-19 02:55:18 +00:00
Dan Gohman 6c109b4979 Reapply r57340. VMKit does not presently rely on materializeFunction
being called with the lock released, and this fixes a race condition
in the JIT as used by lli.

llvm-svn: 64997
2009-02-19 02:40:15 +00:00
Nate Begeman 18d85e7403 Add support to the JIT for true non-lazy operation. When a call to a function
that has not been JIT'd yet, the callee is put on a list of pending functions
to JIT.  The call is directed through a stub, which is updated with the address
of the function after it has been JIT'd.  A new interface for allocating and
updating empty stubs is provided.

Add support for removing the ModuleProvider the JIT was created with, which
would otherwise invalidate the JIT's PassManager, which is initialized with the
ModuleProvider's Module.

Add support under a new ExecutionEngine flag for emitting the infomration 
necessary to update Function and GlobalVariable stubs after JITing them, by
recording the address of the stub and the name of the GlobalValue.  This allows
code to be copied from one address space to another, where libraries may live
at different virtual addresses, and have the stubs updated with their new
correct target addresses.

llvm-svn: 64906
2009-02-18 08:31:02 +00:00
Nicolas Geoffray 7f543ba9fa On 64bit we may have a personality function which requires 64 bits to
be encoded.

llvm-svn: 64600
2009-02-15 20:49:23 +00:00
Dan Gohman 21cb4114fb Split the locking out of JIT::runJITOnFunction so that callers
that already hold the lock can call an entry point that doesn't
re-acquire the lock.

llvm-svn: 63965
2009-02-06 21:25:08 +00:00
Chris Lattner 370ec10dad allow main to have any integer type.
llvm-svn: 63743
2009-02-04 17:48:18 +00:00
Nick Lewycky a89ec99fa2 Reapply patch from r62553, with a fix to avoid looking for an ffi.h that isn't
there.

This changes the interpreter to use libffi. After this patch, the interpreter
will barely be able to call any external functions if built on a system without
libffi installed (just enough to pass 'make check' really). But with libffi,
we can now call any function that isn't variadic or taking a struct or vector
parameter (but pointer to struct is fine). Patch by Alexei Svitkine!

llvm-svn: 63723
2009-02-04 06:26:47 +00:00
Evan Cheng 676130f2e1 Fix PR3423: Link llvm on ARM EABI machines. Patch by Robert Schuster.
llvm-svn: 63489
2009-02-01 06:42:27 +00:00
Nate Begeman 617001d842 Add support for deleting a module provider from a JIT in such a way that it does not cause the owned module to be fully materialized.
llvm-svn: 62864
2009-01-23 19:27:28 +00:00
Tanya Lattner 9a8602ce50 Revert r62553 and r62616 due to issues with portability.
llvm-svn: 62777
2009-01-22 20:09:20 +00:00
Chris Lattner aa1212271a rename methods in System/Host to be more consistent.
llvm-svn: 62776
2009-01-22 19:53:00 +00:00
Chris Lattner 41b43da217 add getPointerToGlobal to the C bindings, patch by Lennart Augustsson!
PR3364

llvm-svn: 62697
2009-01-21 18:11:10 +00:00
Duncan Sands 363501d09b Fix typo. Patch by Alexei Svitkine.
llvm-svn: 62616
2009-01-20 21:20:23 +00:00
Nick Lewycky 766ac10452 Make the Interpreter use libffi if it's available. Patch from Alexei Svitkine!
This requires a rebuild of 'configure' itself. I will be committing that next, but
built with the wrong version of autoconf. Somebody who has the right one, please update
it.

As a side-note, because of the way autoconf works, all built tools will link against
libffi, not just lli. If you know how to fix this, please let me know ...

llvm-svn: 62553
2009-01-20 00:51:40 +00:00
Chris Lattner 762edbc074 don't assert and die on out of range (undefined) shifts. This fixes
PR3334.

llvm-svn: 62352
2009-01-16 20:17:02 +00:00
Evan Cheng 5f936ef1ac Change isGVCompilationDisabled() semantics again. It should abort on any GV that's not constant whether it's "internal" or not. In a server / client environment, GV is returned in the same block of memory as code. However, the memory might not be writable.
llvm-svn: 62336
2009-01-16 19:14:49 +00:00
Mikhail Glushenkov 6e8d814d36 Registry.h should not depend on CommandLine.h.
Split Support/Registry.h into two files so that we have less to
recompile every time CommandLine.h is changed.

llvm-svn: 62312
2009-01-16 07:02:28 +00:00
Mikhail Glushenkov b2f9a73029 Delete trailing whitespace.
llvm-svn: 62307
2009-01-16 06:53:46 +00:00
Rafael Espindola 6de96a1b5d Add the private linkage.
llvm-svn: 62279
2009-01-15 20:18:42 +00:00
Duncan Sands dc020f9c3c Rename getABITypeSize to getTypePaddedSize, as
suggested by Chris.

llvm-svn: 62099
2009-01-12 20:38:59 +00:00
Misha Brukman 5cbf223916 Removed trailing whitespace from Makefiles.
llvm-svn: 61991
2009-01-09 16:44:42 +00:00
Dan Gohman 906152a20f Tidy up #includes, deleting a bunch of unnecessary #includes.
llvm-svn: 61715
2009-01-05 17:59:02 +00:00
Evan Cheng 70b42590b0 Fix misplaced right parentheses.
llvm-svn: 61699
2009-01-05 17:17:04 +00:00
Dan Gohman d32ec016cc Handle weak_extern in the JIT. This fixes
SingleSource/UnitTests/2007-04-25-weak.c in JIT mode. The test
now passes on systems which are able to produce a correct
reference output to compare with.

llvm-svn: 61674
2009-01-05 05:32:42 +00:00
Evan Cheng 0b77319742 Fix MachineCodeEmitter to use uintptr_t instead of intptr_t. This avoids some overflow issues. Patch by Thomas Jablin.
llvm-svn: 60828
2008-12-10 02:32:19 +00:00
Evan Cheng 15e0481d39 Fix a bug introduced by r59265. If lazy compilation is disabled, return actual function ptr instead of ptr to stub if function is already compiled.
llvm-svn: 60822
2008-12-10 01:33:59 +00:00
Evan Cheng 75900bf5cd DisableGVCompilation should not abort on internal GlobalValue's.
llvm-svn: 60750
2008-12-09 07:31:49 +00:00
Chris Lattner ddd7581c73 Make JIT::runFunction handle functions with non-C calling conventions.
llvm-svn: 59904
2008-11-23 08:00:11 +00:00
Nicolas Geoffray 7aa444c031 Implement support for JIT exceptions on X86_64. Relative offsets are
encoded on 32 bytes, and the personality function is not encoded as
relative.

llvm-svn: 59516
2008-11-18 10:44:46 +00:00
Evan Cheng bf9a055c98 Always emit a function pointer as a pointer to the function stub (if there is one). This makes it possible to compare function pointer values in lazy compilation mode. This fixes PR3043.
llvm-svn: 59265
2008-11-13 21:50:50 +00:00
Evan Cheng e4df875dd6 Change binary dump format.
llvm-svn: 59119
2008-11-12 08:22:43 +00:00
Evan Cheng b172c66af3 Comments and indentation.
llvm-svn: 59007
2008-11-10 23:26:16 +00:00
Evan Cheng 0d9db40994 Forgot these.
llvm-svn: 58952
2008-11-10 01:52:24 +00:00
Evan Cheng 686a725b45 Remove a InvalidateInstructionCache call with incorrect size.
llvm-svn: 58898
2008-11-08 08:15:39 +00:00
Evan Cheng b31a717527 Rename startFunctionStub to startGVStub since it's also used for GV non-lazy ptr.
llvm-svn: 58897
2008-11-08 08:02:53 +00:00
Evan Cheng 1b889b16da Rename isString -> isExternalSymbol; getString -> getExternalSymbol since these work on externsym machine relocations.
llvm-svn: 58895
2008-11-08 07:37:34 +00:00
Evan Cheng 776f5922fb More debug output.
llvm-svn: 58894
2008-11-08 07:22:53 +00:00
Evan Cheng 077f686d4b More debug output.
llvm-svn: 58868
2008-11-07 22:30:29 +00:00
Evan Cheng 00203155ad Jump tables may be emitted by target.
llvm-svn: 58835
2008-11-07 09:02:17 +00:00
Evan Cheng 972fd1a1e0 Improve JIT debugging outputs format consistency.
llvm-svn: 58807
2008-11-06 17:46:04 +00:00
Evan Cheng 3aeeb3a47c Need a \n.
llvm-svn: 58788
2008-11-06 01:18:29 +00:00
Evan Cheng d1c5c7f499 Undo 58778 but makes the binary dump prettier.
llvm-svn: 58782
2008-11-05 23:44:08 +00:00
Evan Cheng 51b9b9f6e2 Remove debug output that's not really useful.
llvm-svn: 58778
2008-11-05 23:21:11 +00:00
Evan Cheng 132de1983f Rename isGVLazyPtr to isGVNonLazyPtr relocation. This represents Mac OS X
indirect gv reference. Please don't call it lazy.

llvm-svn: 58746
2008-11-05 01:50:32 +00:00
Evan Cheng 33ba5e78d2 Debugging output tweak.
llvm-svn: 58737
2008-11-05 00:22:28 +00:00
Evan Cheng 9340be4641 For some targets, it's not possible to place GVs in the same memory buffer as the MachineCodeEmitter allocated memory. Code and data has different read / write / execution privilege requirements.
This is a short term workaround. The current solution is for the JIT memory manager to manage code and data memory separately.

llvm-svn: 58688
2008-11-04 09:30:48 +00:00
Evan Cheng 09053e62a9 80 col violation.
llvm-svn: 58684
2008-11-04 06:10:31 +00:00
Evan Cheng 3a9aead4d4 Silence a compiler warning.
llvm-svn: 58598
2008-11-03 07:14:02 +00:00
Jim Grosbach 2589604d85 Revert errant deletion. The target needs to be able to specify that it doesn't want the generic constant pool to be emitted.
llvm-svn: 58475
2008-10-30 23:44:39 +00:00
Evan Cheng 4421a114bb Let target resolve some relocation results.
llvm-svn: 58407
2008-10-29 23:54:46 +00:00
Jim Grosbach ff2b4948ce Support for constant islands in the ARM JIT.
Since the ARM constant pool handling supercedes the standard LLVM constant
pool entirely, the JIT emitter does not allocate space for the constants,
nor initialize the memory. The constant pool is considered part of the 
instruction stream.

Likewise, when resolving relocations into the constant pool, a hook into
the target back end is used to resolve from the constant ID# to the
address where the constant is stored.

For now, the support in the ARM emitter is limited to 32-bit integer. Future
patches will expand this to the full range of constants necessary.

llvm-svn: 58338
2008-10-28 18:25:49 +00:00
Nicolas Geoffray 5457ce9ac3 Support for allocation of TLS variables in the JIT. Allocation of a global
variable is moved to the execution engine. The JIT calls the TargetJITInfo
to allocate thread local storage. Currently, only linux/x86 knows how to
allocate thread local global variables.

llvm-svn: 58142
2008-10-25 15:41:43 +00:00
Oscar Fuentes f3c03b02dc CMake: Turned some libraries into partially linked objects. Corrected
names of LLVMCore and ARMCodeGen.

llvm-svn: 57943
2008-10-22 02:51:53 +00:00
Nuno Lopes 94844e2054 fix a tricky bug in the JIT global variable emitter, that was triggered when JITing a variable independently of a function. This lead to sharing memory memory between functions and GVs thus changing the value of a GV could change the code in execution. more details on the ML.
llvm-svn: 57900
2008-10-21 11:42:16 +00:00
Nuno Lopes a67f06b9c7 little optimization: reuse getPointerToGlobalIfAvailable(CGV) value in emitGlobals()
llvm-svn: 57484
2008-10-14 10:04:52 +00:00
Mon P Wang 297364cd3b Revert r57340 move guard mutex in getPointerToFunction as this can cause
deadlock issues with java

llvm-svn: 57356
2008-10-10 18:07:10 +00:00
Mon P Wang 6e5eccf86b Moved guard mutex upwards to guard materializing a function
in getPointerToFunction

llvm-svn: 57340
2008-10-10 01:47:42 +00:00
Dale Johannesen 4f0bd68cfe Add a "loses information" return value to APFloat::convert
and APFloat::convertToInteger.  Restore return value to
IEEE754.  Adjust all users accordingly.

llvm-svn: 57329
2008-10-09 23:00:39 +00:00
Dale Johannesen 54306fe499 Rename APFloat::convertToAPInt to bitcastToAPInt to
make it clearer what the function does.  No functional
change.

llvm-svn: 57325
2008-10-09 18:53:47 +00:00
Duncan Sands 26ff6f9c54 Add <cstdio> include where needed by gcc-4.4.
Patch by Samuel Tardieu.

llvm-svn: 57291
2008-10-08 07:23:46 +00:00
Daniel Dunbar a8c424bf61 Unbreak build.
llvm-svn: 57017
2008-10-03 17:11:57 +00:00
Jim Grosbach b22ef71d46 On Darwin ARM, memory needs special handling to do JIT. This patch expands
this handling to work properly for modifying stub functions, relocations
back to entry points after JIT compilation, etc..

llvm-svn: 57013
2008-10-03 16:17:20 +00:00
Dan Gohman 0d1e9a8e04 Switch the MachineOperand accessors back to the short names like
isReg, etc., from isRegister, etc.

llvm-svn: 57006
2008-10-03 15:45:36 +00:00
Nicolas Geoffray 74056ae3d5 Acquire the lock only when necessary. More precisely, do not acquire
the lock when calling a method which may materialize the llvm::Function.

llvm-svn: 56995
2008-10-03 07:27:08 +00:00
Evan Cheng 1a9a0b7b4e Add runStaticConstructorsDestructors which runs ctors / dtors of a single module. Patch by David Chisnall.
llvm-svn: 56849
2008-09-30 15:51:21 +00:00
Devang Patel 4c758ea3e0 Large mechanical patch.
s/ParamAttr/Attribute/g
s/PAList/AttrList/g
s/FnAttributeWithIndex/AttributeWithIndex/g
s/FnAttr/Attribute/g

This sets the stage 
- to implement function notes as function attributes and 
- to distinguish between function attributes and return value attributes.

This requires corresponding changes in llvm-gcc and clang.

llvm-svn: 56622
2008-09-25 21:00:45 +00:00
Evan Cheng cdc0060e27 Add DisableGVCompilation which forces the JIT to assert when it tries to allocate space for a GlobalVariable.
llvm-svn: 56557
2008-09-24 16:25:55 +00:00
Devang Patel ba3fa6c6e1 s/ParameterAttributes/Attributes/g
llvm-svn: 56513
2008-09-23 23:03:40 +00:00
Oscar Fuentes a229b3c9a7 Initial support for the CMake build system.
llvm-svn: 56419
2008-09-22 01:08:49 +00:00
Evan Cheng 5cc53c34c3 Preliminary support for systems which require changing JIT memory regions privilege from read / write to read / executable.
llvm-svn: 56303
2008-09-18 07:54:21 +00:00
Anton Korobeynikov 1a1140429e Make safer variant of alias resolution routine to be default
llvm-svn: 56005
2008-09-09 20:05:04 +00:00
Evan Cheng 52b181206f MMI may be null.
llvm-svn: 55626
2008-09-02 08:14:01 +00:00
Nicolas Geoffray b011a8f611 Add support for JIT exceptions on Darwin. Since we're dealing with libgcc,
whose darwin code was written after the ability to dynamically register frames,
we need to do special hacks to make things work.

llvm-svn: 55507
2008-08-28 22:34:49 +00:00
Dan Gohman cf3e3017c8 Avoid a warning about isTargetNullPtr being unused in release builds.
llvm-svn: 55350
2008-08-26 01:38:29 +00:00
Evan Cheng d5834e90dc Get rid of a couple of dynamic_cast.
llvm-svn: 55022
2008-08-20 00:28:12 +00:00
Nicolas Geoffray d58c8e759f Update the JIT exception writer to better mimic the codegen exception writer.
Also skip indirect encoding for platforms that ask for one: we direclty
write an address, not a pointer to the address.

llvm-svn: 54987
2008-08-19 14:48:14 +00:00
Nicolas Geoffray ba694a32dc Register the frame register function when allocating the JIT,
so that lli works out of the box with -enable-eh.

llvm-svn: 54920
2008-08-18 14:53:56 +00:00
Anton Korobeynikov bd890b1faf Move SLEB/ULEB size calculation routines from AsmPrinter to TargetAsmInfo. This makes JIT asmprinter-free.
llvm-svn: 54843
2008-08-16 12:57:46 +00:00
Dale Johannesen dafdbf77b3 Some fixes for x86-64 JIT. Make it use small code
model, except for external calls; this makes
addressing modes PC-relative.  Incomplete.

The assertion at the top of Emitter::runOnMachineFunction
was obviously bogus (always true) so I removed it.
If someone knows what the correct test should be to cover
all the various targets, please fix.

llvm-svn: 54656
2008-08-11 23:46:25 +00:00
Gordon Henriksen 5225cd66cf Fix the LLVMCreateJITCompiler C binding.
Evan broke it in r54523 by adding a parameter in the implementation without
updating the header correspondingly.

llvm-svn: 54555
2008-08-08 20:49:28 +00:00
Evan Cheng 7ff05bf541 Add new parameter Fast to createJIT to enable the fast codegen path.
llvm-svn: 54523
2008-08-08 08:11:34 +00:00
Dale Johannesen b086d3820d Rewrite JIT handling of GlobalVariables so they
are allocated in the same buffer as the code,
jump tables, etc.

The default JIT memory manager does not handle buffer
overflow well.  I didn't introduce this and I'm not
attempting to fix it here, but it is more likely to
be hit now since we're putting more stuff in the
buffer.  This affects one test that I know of so far,
MultiSource/Benchmarks/NPB-serial/is.

llvm-svn: 54442
2008-08-07 01:30:15 +00:00
Dan Gohman ced4857365 Use strcpy instead of sprintf here. This avoids a GCC 4.3 format-string
warning. There wasn't actually a problem here, because the contents of
the string are known.

llvm-svn: 54385
2008-08-05 23:36:35 +00:00
Dan Gohman 3da016d137 Trim #includes.
llvm-svn: 54350
2008-08-05 15:32:23 +00:00
Evan Cheng bf83579b30 Fix for PR2578. Do not split off a block whose size is less than FreeRangeHeader::getMinBlockSize(). Patch by Damien.
llvm-svn: 54152
2008-07-29 07:38:32 +00:00
Chris Lattner 2528d63ba7 Add a new hidden option to the interpreter to cause it to print
out every volatile load and store.  This is useful for tracking 
down insane volatile memory bugs.

llvm-svn: 53241
2008-07-08 17:25:49 +00:00
Dan Gohman e916fd5b96 Use empty() instead of size().
llvm-svn: 53178
2008-07-07 17:52:43 +00:00
Dan Gohman 4c6db53a36 Correct a comment.
llvm-svn: 53064
2008-07-03 00:51:05 +00:00
Dan Gohman e61e120c17 Prune a few dependencies on MachineFunction.h.
llvm-svn: 52976
2008-07-01 18:15:35 +00:00
Dan Gohman fb19f9402b Split ISD::LABEL into ISD::DBG_LABEL and ISD::EH_LABEL, eliminating
the need for a flavor operand, and add a new SDNode subclass,
LabelSDNode, for use with them to eliminate the need for a label id
operand.

Change instruction selection to let these label nodes through
unmodified instead of creating copies of them. Teach the MachineInstr
emitter how to emit a MachineInstr directly from an ISD label node.

This avoids the need for allocating SDNodes for the label id and
flavor value, as well as SDNodes for each of the post-isel label,
label id, and label flavor.

llvm-svn: 52943
2008-07-01 00:05:16 +00:00
Chris Lattner 58ecfbdad6 Implement JIT support for global aliases, patch by David Chisnall!
llvm-svn: 52738
2008-06-25 20:21:35 +00:00
Chris Lattner d3406fc2a7 Switch the PPC backend and target-independent JIT to use the libsystem
InvalidateInstructionCache method instead of calling through
a hook on the JIT.  This is a host feature, not a target feature.

llvm-svn: 52734
2008-06-25 17:18:44 +00:00
Dan Gohman 1ac5813726 Use back() instead of [size()-1].
llvm-svn: 52600
2008-06-21 22:00:54 +00:00
Dan Gohman 1cf5af9e42 Use static_cast instead of reinterpret_cast for casting void*.
llvm-svn: 52592
2008-06-21 20:17:03 +00:00
Gordon Henriksen 9f337549a7 Add C binding for ExecutionEngine::addGlobalMapping.
llvm-svn: 52523
2008-06-20 02:16:11 +00:00
Anton Korobeynikov 7d7dcd52db Provide generic hooks for icache invalidation. Add PPC implementation.
Patch by Gary Benson!

llvm-svn: 52418
2008-06-17 17:30:05 +00:00
Evan Cheng 84a9055e27 Don't forget to initialize SymbolSearchingDisabled.
llvm-svn: 52414
2008-06-17 16:49:02 +00:00
Chris Lattner 86d4f3a2a9 Add a new flag that disables symbol lookup with dlsym when set. This allows
a JIT client to completely control symbol lookup with the LazyFunctionCreator
interface.

llvm-svn: 52335
2008-06-16 17:44:14 +00:00
Dan Gohman 643b3a0581 Add #includes to make some dependencies explicit.
llvm-svn: 51496
2008-05-23 20:40:06 +00:00
Nate Begeman 8f83fc4d9b Fix a couple issues with the JIT and multiple modules:
1. The "JITState" object creates a PassManager with the ModuleProvider that the
   jit is created with.  If the ModuleProvider is removed and deleted, the
   PassManager is invalid.

2. The Global maps in the JIT were not invalidated with a ModuleProvider was 
   removed.  This could lead to a case where the Module would be freed, and a 
   new Module with Globals at the same addresses could return invalid results.

llvm-svn: 51384
2008-05-21 16:34:48 +00:00
Dan Gohman 69ddfbfe9e Fix ExecutionEngine's constant code to work properly when structs and arrays
will become first-class types.

llvm-svn: 51293
2008-05-20 03:20:09 +00:00
Nate Begeman 7af15f17b5 Fix a backwards check in the JIT symbol table code
llvm-svn: 51229
2008-05-18 19:09:10 +00:00
Evan Cheng d37a6cf669 Disable JIT symbol table for now.
llvm-svn: 51152
2008-05-15 17:31:35 +00:00
Gabor Greif 697e94cc22 Fix a bunch of 80col violations that arose from the Create API change. Tweak makefile targets to find these better.
llvm-svn: 51143
2008-05-15 10:04:30 +00:00
Dale Johannesen ce4396bc92 Add CommonLinkage; currently tentative definitions
are represented as "weak", but there are subtle differences
in some cases on Darwin, so we need both.  The intent
is that "common" will behave identically to "weak" unless
somebody changes their target to do something else.
No functional change as yet.

llvm-svn: 51118
2008-05-14 20:12:51 +00:00
Dan Gohman d78c400b5b Clean up the use of static and anonymous namespaces. This turned up
several things that were neither in an anonymous namespace nor static
but not intended to be global.

llvm-svn: 51017
2008-05-13 00:00:25 +00:00
Gordon Henriksen 7993f4a6d1 PR2202: LLVMCreateInterpreter creates a JIT
Applying fix by Frits van Bommel.

llvm-svn: 50249
2008-04-25 02:52:30 +00:00
Nicolas Geoffray 481f44e12f Be pessimistic in computing the buffer size when aligning.
llvm-svn: 50008
2008-04-20 23:39:44 +00:00
Nicolas Geoffray f77618e6e8 Cosmetic changes, as suggested by Evan. No functionality changes.
llvm-svn: 49993
2008-04-20 17:44:19 +00:00
Nicolas Geoffray 568f9818f7 Do not hold the JIT lock when materializing a function and verify if the
function has already been codegen'd. This is required by the Java class loading
mechanism which executes Java code when materializing a function.

llvm-svn: 49988
2008-04-20 08:33:02 +00:00
Chris Lattner 3b18762f40 Switch to using Simplified ConstantFP::get API.
llvm-svn: 49977
2008-04-20 00:41:09 +00:00
Nicolas Geoffray 85a9f1911e Enable jitting with a known memory size.
llvm-svn: 49924
2008-04-18 20:59:31 +00:00
Nicolas Geoffray a7557dfe71 Correlate stubs with functions in JIT: when emitting a stub, the JIT tells the memory manager which function
the stub will resolve.

llvm-svn: 49814
2008-04-16 20:46:05 +00:00
Chris Lattner 4d232bccca Fix some serious logic errors that broke the jit on darwin/x86-64.
llvm-svn: 49606
2008-04-13 07:04:56 +00:00
Evan Cheng 213ea6b276 Add debugging code.
llvm-svn: 49566
2008-04-12 00:22:01 +00:00
Chris Lattner ad281e8e19 Reenable JIT symbol table.
llvm-svn: 49548
2008-04-11 18:11:56 +00:00
Chris Lattner 982e8502c9 fix warnings with assertions disabled.
llvm-svn: 49285
2008-04-06 21:50:58 +00:00
Gabor Greif e9ecc68d8f API changes for class Use size reduction, wave 1.
Specifically, introduction of XXX::Create methods
for Users that have a potentially variable number of
Uses.

llvm-svn: 49277
2008-04-06 20:25:17 +00:00
Chris Lattner 8519c0ead8 disable this for now.
llvm-svn: 49248
2008-04-05 04:12:01 +00:00
Chris Lattner 318d3ef88e Provide an initial cut at exposing JIT compiled symbols to performance
tools.  This is currently only enabled on the mac, but could easily be
supported by other hosts that are interested.

llvm-svn: 49207
2008-04-04 05:51:42 +00:00
Chris Lattner ee1817300a Make ExecutionEngine::updateGlobalMapping return the old mapping.
llvm-svn: 49206
2008-04-04 04:47:41 +00:00
Chris Lattner 0f760dfe09 Fix "Control reaches the end of non-void function" warnings,
patch by David Chisnall.

llvm-svn: 48963
2008-03-30 18:22:13 +00:00
Erick Tryzelaar 8ac07c2834 Expose ExecutionEngine::getTargetData() to c and ocaml bindings.
llvm-svn: 48851
2008-03-27 00:27:14 +00:00
Dan Gohman c60c67fc37 Add explicit keywords.
llvm-svn: 48801
2008-03-25 22:06:05 +00:00
Anton Korobeynikov 7ebdd255b5 Register EH frames emitted in JIT when using gcc unwinding runtime
llvm-svn: 48688
2008-03-22 08:53:09 +00:00
Duncan Sands cd4a6bed89 Fix formatting.
llvm-svn: 48151
2008-03-10 16:38:37 +00:00
Nick Lewycky a53414fd79 Load the symbols first so that the interpreter constructor can find them when
it tries to initialize them.

llvm-svn: 48046
2008-03-08 02:49:45 +00:00
Chris Lattner c1969de3e9 fix 80 col violations
llvm-svn: 48019
2008-03-07 20:05:43 +00:00
Dan Gohman ca24fd9096 Simplify code using convertFromZeroExtendedInteger with an APInt
by using the new convertFromAPInt directly.

llvm-svn: 47739
2008-02-29 01:27:13 +00:00
Anton Korobeynikov 035eaacd1f Update gcc 4.3 warnings fix patch with recent head changes
llvm-svn: 47368
2008-02-20 11:10:28 +00:00
Anton Korobeynikov 579f07135a Unbreak build with gcc 4.3: provide missed includes and silence most annoying warnings.
llvm-svn: 47367
2008-02-20 11:08:44 +00:00
Evan Cheng ab5729cfe6 Added memmove to interpreter external functions list. Patch by Daniel Dunbar.
llvm-svn: 47363
2008-02-20 07:55:26 +00:00
Chris Lattner 1dd86b1154 Support vector constant zeros, thanks to Zack Rusin for the testcase.
llvm-svn: 47148
2008-02-15 00:57:28 +00:00
Nicolas Geoffray 21ad494f67 Enable exception handling int JIT
llvm-svn: 47079
2008-02-13 18:39:37 +00:00
Dan Gohman 70de4cb1cd Use empty() instead of comparing size() with zero.
llvm-svn: 46514
2008-01-29 13:02:09 +00:00
Duncan Sands 05837edae7 Use getPreferredAlignmentLog or getPreferredAlignment
to get the alignment of global variables, rather than
using hand-made versions.

llvm-svn: 46495
2008-01-29 06:23:44 +00:00
Chris Lattner 919ad97c01 JITEmitter.cpp was trying to sync the icache for function stubs, but
was actually passing a completely incorrect size to sys_icache_invalidate.
Instead of having the JITEmitter do this (which doesn't have the correct 
size), just make the target sync its own stubs.

llvm-svn: 46354
2008-01-25 16:41:09 +00:00
Duncan Sands c50c210d76 I doubt the address of the Error string was intended
to be used for the force_interpreter parameter...
Spotted by gcc-4.2.

llvm-svn: 45714
2008-01-07 19:14:42 +00:00
Evan Cheng 880b080887 X86 JIT PIC jumptable support.
llvm-svn: 45616
2008-01-05 02:26:58 +00:00
Evan Cheng 49ff8ecd03 X86 PIC JIT support fixes: encoding bugs, add lazy pointer stubs support.
llvm-svn: 45575
2008-01-04 10:46:51 +00:00
Chris Lattner 84cea329d5 Remove symbols that don't exist, remove tabs, fix comment typo
llvm-svn: 45553
2008-01-03 22:15:32 +00:00
Chris Lattner 705dc51f2c Fix PR1873, a problem finding stat-related symbols on linux, due to
"libc_nonshared.a". Patch by Edwin Török!

llvm-svn: 45532
2008-01-03 07:10:51 +00:00
Evan Cheng 563fcc3428 Change MachineRelocation::DoesntNeedFnStub to NeedStub. This fields will be used
for non-function GV relocations that require function address stubs (e.g. Mac OS X in non-static mode).

llvm-svn: 45527
2008-01-03 02:56:28 +00:00
Chris Lattner f3ebc3f3d2 Remove attribution from file headers, per discussion on llvmdev.
llvm-svn: 45418
2007-12-29 20:36:04 +00:00
Chris Lattner a087a8d2ce remove attribution from lib Makefiles.
llvm-svn: 45415
2007-12-29 20:09:26 +00:00
Gordon Henriksen 2a8cd89d03 C and Ocaml bindings for ExecutionEngine (i.e., the JIT compiler).
llvm-svn: 45335
2007-12-23 16:59:28 +00:00
Christopher Lamb edf0788758 Change the PointerType api for creating pointer types. The old functionality of PointerType::get() has become PointerType::getUnqual(), which returns a pointer in the generic address space. The new prototype of PointerType::get() requires both a type and an address space.
llvm-svn: 45082
2007-12-17 01:12:55 +00:00
Duncan Sands 26d6539e70 These are more correctly called signaling NaNs.
llvm-svn: 45059
2007-12-15 17:37:40 +00:00
Duncan Sands 1202d1b1c4 Teach the interpreter to read and write memory in the
endianness of the target not of the host.  Done by the
simple expedient of reversing bytes for primitive types
if the host and target endianness don't match.  This is
correct for integer and pointer types.  I don't know if
it is correct for floating point types.

llvm-svn: 45039
2007-12-14 19:38:31 +00:00
Dan Gohman 8a332b235d Add explicit keywords, and fix a minor typo that they uncovered.
llvm-svn: 45034
2007-12-14 15:41:34 +00:00
Duncan Sands fde556745b Remove host endianness info from TargetData and
put it in a new header System/Host.h instead.
Instead of getting the endianness from configure,
calculate it directly.

llvm-svn: 44959
2007-12-12 23:03:45 +00:00
Zhou Sheng 3115ba39e8 Add a guard to cxxabi header as other platform may
not support it.

llvm-svn: 44914
2007-12-12 06:16:47 +00:00
Zhou Sheng ed5d693d67 Fixed PR1629.
Make lli interpreter correctly call external functions sin()/cos(),
__cxa_guard_acquire() and __cxa_guard_release().

llvm-svn: 44910
2007-12-12 04:55:43 +00:00
Duncan Sands 5c65cb4633 Fix PR1836: in the interpreter, read and write apints
using the minimum possible number of bytes.  For little
endian targets run on little endian machines, apints are
stored in memory from LSB to MSB as before.  For big endian
targets on big endian machines they are stored from MSB to
LSB which wasn't always the case before (if the target and
host endianness doesn't match values are stored according
to the host's endianness).  Doing this requires knowing the
endianness of the host, which is determined when configuring -
thanks go to Anton for this.  Only having access to little
endian machines I was unable to properly test the big endian
part, which is also the most complicated...

llvm-svn: 44796
2007-12-10 17:43:13 +00:00
Duncan Sands 81b25817f9 It looks like this has been broken for some time -
get it to compile.

llvm-svn: 44791
2007-12-10 14:43:10 +00:00
Chuck Rose III cc2a661322 Adjust VStudio files to add JITMemoryManager files + include <cassert> from same.
llvm-svn: 44651
2007-12-06 02:03:01 +00:00
Chris Lattner 7f3587e344 add a new ExecutionEngine::createJIT which can be used if you only want
to create a JIT.  This lets you specify JIT-specific configuration items
like the JITMemoryManager to use.

llvm-svn: 44647
2007-12-06 01:34:04 +00:00
Chris Lattner dc351b94f9 simplify creation of the interpreter, make ExecutionEngine ctor protected,
delete one ExecutionEngine ctor, minor cleanup.

llvm-svn: 44646
2007-12-06 01:08:09 +00:00
Chris Lattner 55d8c3f71b split the JIT memory management code out from the main JIT logic into its
own JITMemoryManager interface.  There is no functionality change with 
this patch.

llvm-svn: 44640
2007-12-05 23:39:57 +00:00
Chris Lattner 749478a61b for consistency, allow a fallthrough if the final check returns null.
llvm-svn: 44406
2007-11-28 18:30:18 +00:00
Duncan Sands 5208d1ab4a Add some convenience methods for querying attributes, and
use them.

llvm-svn: 44403
2007-11-28 17:07:01 +00:00
Duncan Sands ff306287ff My compiler complains that "x always evaluates to true"
in this call:

	Result.IntVal = APInt(80, 2, x);

What is x?

	uint16_t x[8];

I deduce that the APInt constructor being used is this one:

  APInt(uint32_t numBits, uint64_t val, bool isSigned = false);

rather than this one:

  APInt(uint32_t numBits, uint32_t numWords, const uint64_t bigVal[]);

That doesn't seem right!  This fix compiles but is otherwise completely
untested.

llvm-svn: 44400
2007-11-28 10:36:19 +00:00
Chris Lattner be5f3cb6f1 Make this actually work on systems that support ppc long double.
llvm-svn: 44374
2007-11-27 20:45:25 +00:00
Chris Lattner fffd0ae2f1 Unbreak all of the darwin/ppc32 JIT failures having to do
with not being able to find printf.

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

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

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

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

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

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

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

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

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

llvm-svn: 43620
2007-11-01 20:53:16 +00:00
Chris Lattner fd6f3257b8 add a mechanism for the JIT to invoke a function to lazily create functions as they are referenced.
llvm-svn: 43210
2007-10-22 02:50:12 +00:00
Chris Lattner bf5e958ba0 llvm-gcc3 is dead, along with it __main.
llvm-svn: 43209
2007-10-22 02:39:47 +00:00
Chris Lattner edaf0b4651 LoadLibraryPermanently doesn't throw.
llvm-svn: 43207
2007-10-21 22:58:11 +00:00
Chris Lattner b5163bb9f0 Add a convenience method for creating EE's.
llvm-svn: 43206
2007-10-21 22:57:11 +00:00
Gordon Henriksen ef5d08f4ea Switching TargetMachineRegistry to use the new generic Registry.
llvm-svn: 43094
2007-10-17 21:28:48 +00:00
Devang Patel 324fe8904f Add removeModuleProvider()
llvm-svn: 43002
2007-10-15 19:56:32 +00:00
Gabor Greif cb6832efe0 Fix an assertion abort on sparc. malloc(0) is allowed to
return NULL.

llvm-svn: 42871
2007-10-11 19:40:35 +00:00
Neil Booth 5f00973393 convertFromInteger, as originally written, expected sign-extended
input.  APInt unfortunately zero-extends signed integers, so Dale
modified the function to expect zero-extended input.  Make this
assumption explicit in the function name.

llvm-svn: 42732
2007-10-07 11:45:55 +00:00
Dale Johannesen 9150652b21 Constant fold int-to-long-double conversions;
use APFloat for int-to-float/double; use
round-to-nearest for these (implementation-defined,
seems to match gcc).

llvm-svn: 42484
2007-09-30 18:19:03 +00:00
Dale Johannesen 4230512f32 Change APFloat::convertFromInteger to take the incoming
bit width instead of number of words allocated, which
makes it actually work for int->APF conversions.
Adjust callers.  Add const to one of the APInt constructors
to prevent surprising match when called with const
argument.

llvm-svn: 42210
2007-09-21 22:09:37 +00:00
Chris Lattner 87ce0bec91 #ifdef out unsafe tracing code, which fixes PR1689
llvm-svn: 42205
2007-09-21 18:30:39 +00:00
Dale Johannesen a1336cf57e Implement x86 long double in jit (not really
complete, but common cases work)

llvm-svn: 42043
2007-09-17 18:44:13 +00:00
Dale Johannesen bed9dc423c Next round of APFloat changes.
Use APFloat in UpgradeParser and AsmParser.
Change all references to ConstantFP to use the
APFloat interface rather than double.  Remove
the ConstantFP double interfaces.
Use APFloat functions for constant folding arithmetic
and comparisons.
(There are still way too many places APFloat is
just a wrapper around host float/double, but we're
getting there.)

llvm-svn: 41747
2007-09-06 18:13:44 +00:00
Chris Lattner b0f158cfdf rename APInt::toString -> toStringUnsigned for symmetry with toStringSigned()
Add an APSInt::toString() method.

llvm-svn: 41309
2007-08-23 05:15:32 +00:00
Chris Lattner 2b40caa861 move assertion into mutex guard, a partial fix for PR1606.
llvm-svn: 41050
2007-08-13 20:08:16 +00:00
Reid Spencer 2dc9f13278 Fix a comment typo noticed by Sandro Magi.
llvm-svn: 41018
2007-08-11 15:57:56 +00:00
Chris Lattner d1fd0db2ae eliminate redundant conditions from the signless types conversion.
llvm-svn: 40927
2007-08-08 16:19:57 +00:00
David Greene 17a5dfe6f7 New CallInst interface to address GLIBCXX_DEBUG errors caused by
indexing an empty std::vector.

Updates to all clients.

llvm-svn: 40660
2007-08-01 03:43:44 +00:00
Anton Korobeynikov 187bf73b5d Add a comment: don't expect from external function resolver in interpreter
things, it wasn't designed to handle.

llvm-svn: 40608
2007-07-30 23:03:25 +00:00
Anton Korobeynikov 7ac2521021 Add detection of __dso_handle presence during configure. Use this information in the
JITer (short path is added for darwin). This is needed to properly JIT llvm-gcc-4.2-built
binaries, since cxa_atexit is enabled by default on much more targets.

llvm-svn: 40600
2007-07-30 20:02:02 +00:00
Dan Gohman e379f08b19 More explicit keywords.
llvm-svn: 40589
2007-07-30 14:51:59 +00:00
Chuck Rose III 1a39a2d13d VStudio compiler errors and placing Function*->ExFunc map under ManagedStatic control.
This commit fixes two things.  One is a pair of VStudio compiler errors stemming from variables
which defined within the for loop statement and also within the body of the for loop.  I fixed these 
by renaming one of the two variables.  Additionally, I've made the Function*->ExFunc map in 
ExternalFunctions.cpp a ManagedStatic object, so that cleanup will be done on llvm_shutdown.  In repeated
uses of the interpreter, where the same Function* address may get used for completely differnet functions,
this was causing a crash.

llvm-svn: 40558
2007-07-27 18:26:35 +00:00
Reid Spencer 68ee4e8efc Hush a noisy warning from GCC 4.2 about overflow during conversion by using
the type "unsigned" instead of uintptr_t for a 1-bit structure field.

llvm-svn: 40066
2007-07-19 21:05:30 +00:00
Gabor Greif ef3d8362a3 fix typos
llvm-svn: 38453
2007-07-09 12:00:59 +00:00
Gabor Greif e16561cd5d Here is the bulk of the sanitizing.
Almost all occurrences of "bytecode" in the sources have been eliminated.

llvm-svn: 37913
2007-07-05 17:07:56 +00:00
Evan Cheng a1a3cc130d (For Chris): Fix failure where we rejected compiling stubs when lazy compilation is disabled.
llvm-svn: 37825
2007-06-30 00:10:37 +00:00
Anton Korobeynikov b781886de7 Add comments to fallsthrough cases. Also, this fixes PR1492
llvm-svn: 37405
2007-06-03 19:20:49 +00:00
Anton Korobeynikov 8c32c1114f Check arguments & return types of main(). Abort in case of no match.
llvm-svn: 37404
2007-06-03 19:17:35 +00:00
Reid Spencer ff38cf8880 For PR1486:
Avoid overwriting the APInt instance with 0 bytes which causes the bitwidth
to be set to 0 (illegal) producing a subsequent assert.

llvm-svn: 37391
2007-06-01 22:23:29 +00:00
Zhou Sheng 8ff9ff7975 Compute the correct word number.
llvm-svn: 37322
2007-05-24 15:03:18 +00:00
Reid Spencer 80fcb754d9 On Linux platforms and at optimization levels -O1 and above, llvm-gcc can
turn "putchar" calls into _IO_putc calls which is a lower-level interface.
This patch allows these calls to be executed by lli in interpreter mode.

llvm-svn: 37254
2007-05-19 01:36:17 +00:00
Reid Spencer 07ae5465cd Print integer values as both decimal and hexadecimal for convenience
of verifying result values when debugging.

llvm-svn: 37156
2007-05-17 06:47:54 +00:00
Reid Spencer 1925c537f2 Avoid a "loss of precision" error in gcc 4.1.3.
llvm-svn: 37105
2007-05-16 16:39:29 +00:00
Reid Spencer 65ba7501fc Implement printing of instruction result values when debug info is turned
on. This helps to speed up the debugging time by showing computational
results as the program executes.

llvm-svn: 37095
2007-05-16 02:05:13 +00:00
Reid Spencer 0454316c79 Bitcast all the bits of a floating point value, not just one. The zero
extension is needed because the constructor for the Destination value
causes the APInt to have a bit width of 1.
Patch by Guoling Han.

llvm-svn: 36733
2007-05-04 03:37:38 +00:00
Reid Spencer 1d48207f5b 1. Don't swap byte order in scanf. It isn't necessary and leads to
incorrect results (canonicalization was dropped several commits ago).
2. Add support for fscanf.
3. Suppress a warning about cast to pointer from non-pointer-sized integer.

llvm-svn: 36482
2007-04-26 18:19:35 +00:00
Reid Spencer a68c374e7e We only need one putchar which gives it a shot at getting matched by its
users.

llvm-svn: 36305
2007-04-21 17:11:45 +00:00
Chris Lattner 7786713181 avoid mutating a global in an accessor
llvm-svn: 36289
2007-04-20 22:57:20 +00:00
Chris Lattner 1e999c4164 fit in 80 cols
llvm-svn: 36288
2007-04-20 22:40:40 +00:00
Chris Lattner 6a309848c1 rename JIT::state -> JIT::jitstate to avoid shadowing ExecutionEngine::state
llvm-svn: 36286
2007-04-20 22:40:05 +00:00
Chris Lattner d9b7511928 eliminate use of Instruction::getPrev(). Patch by Gabor Greif in 2005.
llvm-svn: 36198
2007-04-17 17:38:28 +00:00
Reid Spencer c57be6cb4e Implement @sext and @zext parameter attribute handling properly instead of
forcing every small argument of every function regardless of attributes or
calling convention to be expanded.

llvm-svn: 36174
2007-04-16 21:50:40 +00:00
Reid Spencer 8c3d3dce2b For PR1293:
* Rename the FunctionType* parameter from M to FT on all the functions.
* Implement a fix for PR1293 by just asserting that library functions that
  must return pointers should have pointer typed results. This just makes
  sure that we don't attempt to use an uninitialized integer or something
  later on.

llvm-svn: 35508
2007-03-30 16:41:50 +00:00
Jeff Cohen 72ac14ed29 Unbreak C++ build.
llvm-svn: 35067
2007-03-12 17:57:00 +00:00
Bill Wendling 16574a72e1 Don't use std::hex.
llvm-svn: 35038
2007-03-08 23:37:24 +00:00
Bill Wendling 61a2773977 Don't use a cast. It causes an error on some platforms.
llvm-svn: 35037
2007-03-08 23:26:50 +00:00
Reid Spencer 4fd528f213 Fix all of last night's JIT failures in Prolangs-C++ by finishing the
implementation of getConstantValue().

llvm-svn: 34988
2007-03-06 22:23:15 +00:00
Anton Korobeynikov 666d23d4e6 Implement PR1240
llvm-svn: 34959
2007-03-06 05:32:48 +00:00
Reid Spencer 4e42790c43 1. Make StoreValueToMemory a little more efficient by not requiring caller
to make a copy of the GenericValue.
2. Fix a copy & paste bug in StoreValueToMemory where 64-bit values were
   truncated to 32

llvm-svn: 34958
2007-03-06 05:03:16 +00:00
Reid Spencer 1efc4aaf84 Fix some thinko's in the last patch. PtrSize has to be in bits and we
might need to zext not just trunc the value.

llvm-svn: 34955
2007-03-06 03:46:41 +00:00
Reid Spencer 10dbc1e896 Fix a bug in IntToPtr. Truncating to 64-bits only works if the integer
is larger. Adjust so that it truncates to pointer width, only if necessary.

llvm-svn: 34954
2007-03-06 03:41:50 +00:00
Reid Spencer c764c55745 Simplify code as a result of the change in GenericValue to have a single
integer field of type APInt instead of different sized integer fields.

llvm-svn: 34952
2007-03-06 03:11:31 +00:00
Reid Spencer 40015aad5a Radically simplify execution. This patch gets rid of all the special
handling for integer of various sizes. GenericValue now has just a single
integer field of type APInt. We use its facilities directly in the
execution of all instructions.

llvm-svn: 34951
2007-03-06 03:09:31 +00:00
Reid Spencer c45e10474a Adjust and simplify external function processing now that GenericValue has
a single integer field of type APInt.

llvm-svn: 34950
2007-03-06 03:08:12 +00:00
Reid Spencer 7f68713eb8 APInt's are no longer allocated on the heap because they are direct
members of GenericValue. Consequently the code to clean them up isn't
needed.

llvm-svn: 34948
2007-03-06 03:06:48 +00:00
Reid Spencer 2d89fa84bc Remove the insufficient code in Interpreter::create that computed the
Target DataLayout incorrectly. For now, we'll trust that the module has
got the correct DataLayout. In the future, this needs to be changed to
tell the TargetData to be "current host".

llvm-svn: 34947
2007-03-06 03:05:57 +00:00
Reid Spencer 87aa65f40e Simplify things significantly because GenericValue now has a single integer
field, of type APInt, instead of multiple integer fields. Also, get rid of
the special endianness code in StoreValueToMemory and LoadValueToMemory.
ExecutionEngine is always used to execute on the host platform so this is
now unnecessary.

llvm-svn: 34946
2007-03-06 03:04:04 +00:00
Reid Spencer 04a1829559 Remove unnecessary #include.
llvm-svn: 34889
2007-03-03 18:29:16 +00:00
Reid Spencer 603682ad1d Deal with error handling better.
llvm-svn: 34887
2007-03-03 18:19:18 +00:00
Reid Spencer ec8c51c1b1 Complete the APIntification of the interpreter. All asserts for > 64 bits
have been removed and dealt with. The interpreter should now be able to
execute any LLVM program using any bit width.

llvm-svn: 34884
2007-03-03 08:38:04 +00:00
Reid Spencer 00919f5769 Avoid memory leakage by having caller construct the APInt for the
destination value of LoadValueFromMemory.

llvm-svn: 34883
2007-03-03 08:36:29 +00:00
Reid Spencer 54c6e84c83 Implement APInt support for the binary operators.
Move the getConstantExpr function towards the end of the file so we don't
need a dozen forward declarations.

llvm-svn: 34877
2007-03-03 06:22:22 +00:00
Reid Spencer 72aafa1d49 1. Have the ExecutionContext keep track of the APInt's allocated and
ensure they are cleaned up when the stack frame exits.
2. Move a function to the Execution.cpp file where it belongs.

llvm-svn: 34876
2007-03-03 06:19:55 +00:00
Reid Spencer 815f8dd225 Implement loading and storing of APInt values from memory.
llvm-svn: 34874
2007-03-03 06:18:03 +00:00
Chris Lattner 05858a9e32 Fix PR1216 by cleaning up the ownership of JITResolver.
llvm-svn: 34552
2007-02-24 02:57:03 +00:00
Reid Spencer d84d35ba70 For PR1195:
Rename PackedType -> VectorType, ConstantPacked -> ConstantVector, and
PackedTyID -> VectorTyID. No functional changes.

llvm-svn: 34293
2007-02-15 02:26:10 +00:00
Chris Lattner 4da5e17cfc From Dan Gohman:
While preparing http://llvm.org/PR1198 I noticed several asserts
protecting unprepared code from i128 types that weren't actually failing
when they should because they were written as assert("foo") instead of
something like assert(0 && "foo"). This patch fixes all the cases that a
quick grep found.

llvm-svn: 34267
2007-02-14 06:20:04 +00:00
Chris Lattner 945e437c65 Generalize TargetData strings, to support more interesting forms of data.
Patch by Scott Michel.

llvm-svn: 34266
2007-02-14 05:52:17 +00:00
Chris Lattner 6ea07f178c eliminate vector-related allocations
llvm-svn: 34223
2007-02-13 06:01:22 +00:00
Chris Lattner c44bd78a2e eliminate use of TargetData::getIndexedOffset that takes a vector
llvm-svn: 34163
2007-02-10 20:35:22 +00:00
Chris Lattner c473d8e431 Privatize StructLayout::MemberOffsets, adding an accessor
llvm-svn: 34156
2007-02-10 19:55:17 +00:00
Reid Spencer 0690d442ab For PR1188:
Compute BitMask correctly.

Patch by Leo (wenwenti@hotmail.com).

llvm-svn: 34026
2007-02-08 00:29:31 +00:00
Reid Spencer 1241d6d5ab For PR411:
Adjust to changes in Module interface:
getMainFunction() -> getFunction("main")
getNamedFunction(X) -> getFunction(X)

llvm-svn: 33922
2007-02-05 21:19:13 +00:00
Reid Spencer 2341c22ec7 Changes to support making the shift instructions be true BinaryOperators.
This feature is needed in order to support shifts of more than 255 bits
on large integer types.  This changes the syntax for llvm assembly to
make shl, ashr and lshr instructions look like a binary operator:
   shl i32 %X, 1
instead of
   shl i32 %X, i8 1
Additionally, this should help a few passes perform additional optimizations.

llvm-svn: 33776
2007-02-02 02:16:23 +00:00
Reid Spencer 5301e7c605 For PR1136: Rename GlobalVariable::isExternal as isDeclaration to avoid
confusion with external linkage types.

llvm-svn: 33663
2007-01-30 20:08:39 +00:00
Reid Spencer 42b2c08e3a Remove tabs.
llvm-svn: 33620
2007-01-29 17:55:50 +00:00