summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/X86/X86CodeEmitter.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Make X86-64 in the Large model always emit 64-bit calls.Jeffrey Yasskin2009-11-161-19/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The large code model is documented at http://www.x86-64.org/documentation/abi.pdf and says that calls should assume their target doesn't live within the 32-bit pc-relative offset that fits in the call instruction. To do this, we turn off the global-address->target-global-address conversion in X86TargetLowering::LowerCall(). The first attempt at this broke the lazy JIT because it can separate the movabs(imm->reg) from the actual call instruction. The lazy JIT receives the address of the movabs as a relocation and needs to record the return address from the call; and then when that call happens, it needs to patch the movabs with the newly-compiled target. We could thread the call instruction into the relocation and record the movabs<->call mapping explicitly, but that seems to require at least as much new complication in the code generator as this change. To fix this, we make lazy functions _always_ go through a call stub. You'd think we'd only have to force lazy calls through a stub on difficult platforms, but that turns out to break indirect calls through a function pointer. The right fix for that is to distinguish between calls and address-of operations on uncompiled functions, but that's complex enough to leave for someone else to do. Another attempt at this defined a new CALL64i pseudo-instruction, which expanded to a 2-instruction sequence in the assembly output and was special-cased in the X86CodeEmitter's emitInstruction() function. That broke indirect calls in the same way as above. This patch also removes a hack forcing Darwin to the small code model. Without far-call-stubs, the small code model requires things of the JITMemoryManager that the DefaultJITMemoryManager can't provide. Thanks to echristo for lots of testing! llvm-svn: 88984
* Make the need-stub variables accurate and consistent. In the case ofJeffrey Yasskin2009-11-071-14/+14
| | | | | | | | | | | | | MachineRelocations, "stub" always refers to a far-call stub or a load-a-faraway-global stub, so this patch adds "Far" to the term. (Other stubs are used for lazy compilation and dlsym address replacement.) The variable was also inconsistent between the positive and negative sense, and the positive sense ("NeedStub") was more demanding than is accurate (since a nearby-enough function can be called directly even if the platform often requires a stub). Since the negative sense causes double-negatives, I switched to "MayNeedFarStub" globally. llvm-svn: 86363
* apparently the X86 JIT isn't fully contextized, it is still using ↵Chris Lattner2009-10-271-0/+1
| | | | | | getGlobalContext() :( llvm-svn: 85252
* Remove includes of Support/Compiler.h that are no longer needed after theNick Lewycky2009-10-251-1/+0
| | | | | | VISIBILITY_HIDDEN removal. llvm-svn: 85043
* Remove VISIBILITY_HIDDEN from class/struct found inside anonymous namespaces.Nick Lewycky2009-10-251-1/+1
| | | | | | | Chris claims we should never have visibility_hidden inside any .cpp file but that's still not true even after this commit. llvm-svn: 85042
* Fix PR5087, patch by Jakub Staszak!Chris Lattner2009-10-121-2/+2
| | | | llvm-svn: 83822
* Update processDebugLoc() so that it can be used to process debug info before ↵Devang Patel2009-10-061-1/+3
| | | | | | and after printing an instruction. llvm-svn: 83363
* Introduce the TargetInstrInfo::KILL machine instruction and get rid of theJakob Stoklund Olesen2009-09-281-0/+1
| | | | | | | | | | unused DECLARE instruction. KILL is not yet used anywhere, it will replace TargetInstrInfo::IMPLICIT_DEF in the places where IMPLICIT_DEF is just used to alter liveness of physical registers. llvm-svn: 83006
* Also emit a label for TargetInstrInfo::GC_LABEL.Nicolas Geoffray2009-09-081-0/+1
| | | | llvm-svn: 81206
* just use dump()Chris Lattner2009-09-031-1/+1
| | | | llvm-svn: 80889
* Simplify.Daniel Dunbar2009-09-011-18/+8
| | | | llvm-svn: 80729
* Fix what I believe is a copy-n-pasto introduced in r78129.Daniel Dunbar2009-09-011-3/+3
| | | | | | - Bruno, please check!! llvm-svn: 80728
* X86/Encoding: Support ExternalSymbol operands in emitDisplacementField (for ↵Daniel Dunbar2009-09-011-0/+7
| | | | | | consistency). llvm-svn: 80727
* llvm-mc: Switch MCInst to storing an MCExpr* instead of an MCValue.Daniel Dunbar2009-08-311-7/+7
| | | | | | Also, use MCInst::print instead of custom code in MCAsmPrinter. llvm-svn: 80575
* llvm-mc/X86: Encode constant MCValue's correctly.Daniel Dunbar2009-08-301-0/+6
| | | | llvm-svn: 80485
* llvm-mc/X86: Implement single instruction encoding interface for MC.Daniel Dunbar2009-08-271-0/+250
| | | | | | | | | | | | - Note, this is a gigantic hack, with the sole purpose of unblocking further work on the assembler (its also possible to test the mathcer more completely now). - Despite being a hack, its actually good enough to work over all of 403.gcc (although some encodings are probably incorrect). This is a testament to the beauty of X86's MachineInstr, no doubt! ;) llvm-svn: 80234
* Record variable debug info at ISel time directly.Devang Patel2009-08-221-1/+0
| | | | llvm-svn: 79742
* more formatting improvements, no functionality change.Chris Lattner2009-08-161-57/+65
| | | | llvm-svn: 79167
* code formatting improvements, no functionality change.Chris Lattner2009-08-161-74/+85
| | | | llvm-svn: 79165
* Add crc32 instruction and intrinsics. Add a new class of prefixEric Christopher2009-08-081-0/+5
| | | | | | | | | bytes for F2 0F 38 and propagate. Add a FIXME for a set of possibilities which correspond to intrinsics already used. New test. llvm-svn: 78508
* Use reloc_absolute_word_sext relocation for X86::MOV64(ri/mi)32 ↵Bruno Cardoso Lopes2009-08-081-2/+2
| | | | | | | | | instructions, since they are in 64 bit mode with i64immSExt32 imms. JIT is not affected since it handles both word absolute relocations in the same way llvm-svn: 78479
* 1) Proper emit displacements for x86, using absolute relocations where necessaryBruno Cardoso Lopes2009-08-051-26/+40
| | | | | | | | | | for ELF to work. 2) RIP addressing: Use SIB bytes for absolute relocations where RegBase=0, IndexReg=0. 3) The JIT can get the real address of cstpools and jmptables during code emission, fix that for object code emission llvm-svn: 78129
* - s/DOUT/DEBUG(errs()/gBill Wendling2009-08-031-6/+6
| | | | | | - Tidy up some headers. llvm-svn: 77929
* Use setPreservesAll in X86CodeEmitter.Dan Gohman2009-07-311-0/+1
| | | | llvm-svn: 77755
* More migration to raw_ostream, the water has dried up around the iostream hole.Daniel Dunbar2009-07-251-2/+4
| | | | | | | | | | - Some clients which used DOUT have moved to DEBUG. We are deprecating the "magic" DOUT behavior which avoided calling printing functions when the statement was disabled. In addition to being unnecessary magic, it had the downside of leaving code in -Asserts builds, and of hiding potentially unnecessary computations. llvm-svn: 77019
* Add line numbers to OProfile. To do this, I added a processDebugLoc()Jeffrey Yasskin2009-07-161-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | call to the MachineCodeEmitter interface and made copying the start line of a function not conditional on whether we're emitting Dwarf debug information. I'll propagate the processDebugLoc() calls to the non-X86 targets in a followup patch. In the long run, it'll probably be better to gather this information through the DwarfWriter, but the DwarfWriter currently depends on the AsmPrinter and TargetAsmInfo, and fixing that would be out of the way for this patch. There's a bug in OProfile 0.9.4 that makes it ignore line numbers for addresses above 4G, and a patch fixing it at http://thread.gmane.org/gmane.linux.oprofile/7634 Sample output: $ sudo opcontrol --reset; sudo opcontrol --start-daemon; sudo opcontrol --start; `pwd`/Debug/bin/lli fib.bc; sudo opcontrol --stop Signalling daemon... done Profiler running. fib(40) == 165580141 Stopping profiling. $ opreport -g -d -l `pwd`/Debug/bin/lli|head -60 Overflow stats not available CPU: Core 2, speed 1998 MHz (estimated) Counted CPU_CLK_UNHALTED events (Clock cycles when not halted) with a unit mask of 0x00 (Unhalted core cycles) count 100000 vma samples % linenr info image name symbol name 00007f67a30370b0 25489 61.2554 fib.c:24 10946.jo fib_left 00007f67a30370b0 1634 6.4106 fib.c:24 00007f67a30370b1 83 0.3256 fib.c:24 00007f67a30370b9 1997 7.8348 fib.c:24 00007f67a30370c6 2080 8.1604 fib.c:27 00007f67a30370c8 988 3.8762 fib.c:27 00007f67a30370cd 1315 5.1591 fib.c:27 00007f67a30370cf 251 0.9847 fib.c:27 00007f67a30370d3 1191 4.6726 fib.c:27 00007f67a30370d6 975 3.8252 fib.c:27 00007f67a30370db 1010 3.9625 fib.c:27 00007f67a30370dd 242 0.9494 fib.c:27 00007f67a30370e1 2782 10.9145 fib.c:28 00007f67a30370e5 3768 14.7828 fib.c:28 00007f67a30370eb 615 2.4128 (no location information) 00007f67a30370f3 6558 25.7287 (no location information) 00007f67a3037100 15603 37.4973 fib.c:29 10946.jo fib_right 00007f67a3037100 1646 10.5493 fib.c:29 00007f67a3037101 45 0.2884 fib.c:29 00007f67a3037109 2372 15.2022 fib.c:29 00007f67a3037116 2234 14.3178 fib.c:32 00007f67a3037118 612 3.9223 fib.c:32 00007f67a303711d 622 3.9864 fib.c:32 00007f67a303711f 385 2.4675 fib.c:32 00007f67a3037123 404 2.5892 fib.c:32 00007f67a3037126 634 4.0633 fib.c:32 00007f67a303712b 870 5.5759 fib.c:32 00007f67a303712d 62 0.3974 fib.c:32 00007f67a3037131 1848 11.8439 fib.c:33 00007f67a3037135 2840 18.2016 fib.c:33 00007f67a303713a 1 0.0064 fib.c:33 00007f67a303713b 1023 6.5564 (no location information) 00007f67a3037143 5 0.0320 (no location information) 000000000080c1e4 15 0.0360 MachineOperand.h:150 lli llvm::MachineOperand::isReg() const 000000000080c1e4 6 40.0000 MachineOperand.h:150 000000000080c1ec 2 13.3333 MachineOperand.h:150 ... llvm-svn: 76102
* Use the right relocation type for X86::MOV64ri64i32Bruno Cardoso Lopes2009-07-141-0/+2
| | | | llvm-svn: 75687
* llvm_unreachable->llvm_unreachable(0), LLVM_UNREACHABLE->llvm_unreachable.Torok Edwin2009-07-141-7/+7
| | | | | | | | | This adds location info for all llvm_unreachable calls (which is a macro now) in !NDEBUG builds. In NDEBUG builds location info and the message is off (it only prints "UREACHABLE executed"). llvm-svn: 75640
* assert(0) -> LLVM_UNREACHABLE.Torok Edwin2009-07-111-6/+6
| | | | | | | | | Make llvm_unreachable take an optional string, thus moving the cerr<< out of line. LLVM_UNREACHABLE is now a simple wrapper that makes the message go away for NDEBUG builds. llvm-svn: 75379
* change isGlobalStubReference to take target flags instead of a MachineOperand.Chris Lattner2009-07-101-1/+1
| | | | llvm-svn: 75236
* convert some late code (called by regalloc and code emission)Chris Lattner2009-07-101-3/+3
| | | | | | | to use isGlobalStubReference instead of GVRequiresExtraLoad (which should really be part of isel). llvm-svn: 75234
* GVRequiresExtraLoad is now never used for calls, simplify it based on this.Chris Lattner2009-07-101-1/+1
| | | | llvm-svn: 75232
* convert a helper method to be a static function instead of a Chris Lattner2009-07-101-11/+14
| | | | | | template. Also convert it to take a MachineOperand instead of a GV* llvm-svn: 75227
* Implement changes from Chris's feedback.Torok Edwin2009-07-081-5/+4
| | | | | | Finish converting lib/Target. llvm-svn: 75043
* Start converting to new error handling API.Torok Edwin2009-07-081-6/+7
| | | | | | | cerr+abort -> llvm_report_error assert(0)+abort -> LLVM_UNREACHABLE (assert(0)+llvm_unreachable-> abort() included) llvm-svn: 75018
* Add the Object Code Emitter class. Original patch by Aaron Gray, I did someBruno Cardoso Lopes2009-07-061-8/+9
| | | | | | cleanup, removed some #includes and moved Object Code Emitter out-of-line. llvm-svn: 74813
* fix a bunch of failures in the X86-64 JIT by tolerating RIP asChris Lattner2009-06-271-3/+5
| | | | | | a base register. We just ignore it for now. llvm-svn: 74374
* Fix new CodeEmitter stuff to follow LLVM codying style. Patch by Aaron GrayBruno Cardoso Lopes2009-06-011-44/+48
| | | | llvm-svn: 72697
* First patch in the direction of splitting MachineCodeEmitter in two subclasses:Bruno Cardoso Lopes2009-05-301-23/+55
| | | | | | JITCodeEmitter and ObjectCodeEmitter. No functional changes yet. Patch by Aaron Gray llvm-svn: 72631
* The MONITOR and MWAIT instructions have insufficient information forBill Wendling2009-05-281-3/+16
| | | | | | | | | | | decoding. Essentially, they both map to the same column in the "opcode extensions for one- and two-byte opcodes" table in the x86 manual. The RawFrm complicates decoding this. Instead, use opcode 0x01, prefix 0x01, and form MRM1r. Then have the code emitter special case these, a la [SML]FENCE. llvm-svn: 72556
* Avoid unneeded SIB byte encoding. Patch by Zoltan Varga.Evan Cheng2009-05-121-1/+2
| | | | llvm-svn: 71520
* Use X86AddrNumOperands instead of magic constant oneDale Johannesen2009-05-061-1/+2
| | | | | | | | | | more place. This fixes a bunch of x86-64 JIT regressions. (Introduced when the value of the magic constant changed in 68645. At the time apparently nobody noticed; failures were hidden in 70343-70439 by an unrelated bug, so showed up again as "new" failures in 70440.) llvm-svn: 71106
* Revert part of 70929 that has to do with determining whether a SIB byte is ↵Evan Cheng2009-05-051-2/+2
| | | | | | needed. It causes a lot of x86_64 JIT failures. llvm-svn: 70986
* - Avoid the longer SIB encoding on x86_64 when it's not needed.Evan Cheng2009-05-041-2/+2
| | | | | | | - Synchronize instruction length computation code in X86InstrInfo with code in X86CodeEmitter.cpp Patch by Zoltan Varga. llvm-svn: 70929
* Re-apply 68552.Rafael Espindola2009-04-081-19/+10
| | | | | | Tested by bootstrapping llvm-gcc and using that to build llvm. llvm-svn: 68645
* Temporarily revert r68552. This was causing a failure in the self-hosting LLVMBill Wendling2009-04-071-10/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | builds. --- Reverse-merging (from foreign repository) r68552 into '.': U test/CodeGen/X86/tls8.ll U test/CodeGen/X86/tls10.ll U test/CodeGen/X86/tls2.ll U test/CodeGen/X86/tls6.ll U lib/Target/X86/X86Instr64bit.td U lib/Target/X86/X86InstrSSE.td U lib/Target/X86/X86InstrInfo.td U lib/Target/X86/X86RegisterInfo.cpp U lib/Target/X86/X86ISelLowering.cpp U lib/Target/X86/X86CodeEmitter.cpp U lib/Target/X86/X86FastISel.cpp U lib/Target/X86/X86InstrInfo.h U lib/Target/X86/X86ISelDAGToDAG.cpp U lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp U lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp U lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h U lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.h U lib/Target/X86/X86ISelLowering.h U lib/Target/X86/X86InstrInfo.cpp U lib/Target/X86/X86InstrBuilder.h U lib/Target/X86/X86RegisterInfo.td llvm-svn: 68560
* Reduce code duplication on the TLS implementation.Rafael Espindola2009-04-071-19/+10
| | | | | | | | | | This introduces a small regression on the generated code quality in the case we are just computing addresses, not loading values. Will work on it and on X86-64 support. llvm-svn: 68552
* Have only one definition of X86AddrNumOperands.Rafael Espindola2009-03-281-3/+0
| | | | llvm-svn: 67949
* Make code a bit less brittle by no hardcoding the numberRafael Espindola2009-03-281-6/+12
| | | | | | of operands in an address in so many places. llvm-svn: 67945
* Re-apply 66024 with fixes: 1. Fixed indirect call to immediate address ↵Evan Cheng2009-03-121-1/+7
| | | | | | assembly. 2. Fixed JIT encoding by making the address pc-relative. llvm-svn: 66803
OpenPOWER on IntegriCloud