aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/X86/X86CodeEmitter.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Handle a displacement location in 64-bit as an RIP-relative displacement. ItBill Wendling2010-04-211-1/+11
| | | | | | | | | | | | | | | | | | | fixes a bug (<rdar://problem/7880900>) in the JIT. This code wouldn't work: target triple = "x86_64-apple-darwin" define double @func(double %a) { %tmp1 = fmul double %a, 5.000000e-01 ; <double> [#uses=1] ret double %tmp1 } define i32 @main() nounwind { %1 = call double @func(double 4.770000e-04) ; <i64> [#uses=0] ret i32 0 } git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101965 91177308-0d34-0410-b5e6-96231b3b80d8
* Add const qualifiers to CodeGen's use of LLVM IR constructs.Dan Gohman2010-04-151-4/+6
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101334 91177308-0d34-0410-b5e6-96231b3b80d8
* rename llvm::llvm_report_error -> llvm::report_fatal_errorChris Lattner2010-04-071-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100709 91177308-0d34-0410-b5e6-96231b3b80d8
* change the DBG_LABEL MachineInstr to always be createdChris Lattner2010-03-141-2/+0
| | | | | | | with an MCSymbol instead of an immediate. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98481 91177308-0d34-0410-b5e6-96231b3b80d8
* switch GC_LABEL to use an MCSymbol operand instead of a label ID operand.Chris Lattner2010-03-141-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98474 91177308-0d34-0410-b5e6-96231b3b80d8
* change the LabelSDNode to be EHLabelSDNode and make it holdChris Lattner2010-03-141-1/+4
| | | | | | | | | an MCSymbol. Make the EH_LABEL MachineInstr hold its label with an MCSymbol instead of ID. Fix a bug in MMI.cpp which would return labels named "Label4" instead of "label4". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98463 91177308-0d34-0410-b5e6-96231b3b80d8
* change EH related stuff (other than EH_LABEL) to use MCSymbolChris Lattner2010-03-141-3/+4
| | | | | | | | | | | | | | | | | | instead of label ID's. This cleans up and regularizes a bunch of code and makes way for future progress. Unfortunately, this pointed out to me that JITDwarfEmitter.cpp is largely copy and paste from DwarfException/MachineModuleInfo and other places. This is very sad and disturbing. :( One major change here is that TidyLandingPads moved from being called in DwarfException::BeginFunction to being called in DwarfException::EndFunction. There should not be any functionality change from doing this, but I'm not an EH expert. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98459 91177308-0d34-0410-b5e6-96231b3b80d8
* rip out the 'heinous' x86 MCCodeEmitter implementation.Chris Lattner2010-02-131-333/+0
| | | | | | | | We still have the templated X86 JIT emitter, *and* the almost-copy in X86InstrInfo for getting instruction sizes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96059 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove special cases for [LM]FENCE, MONITOR and MWAIT fromChris Lattner2010-02-121-21/+2
| | | | | | | encoder and decoder by using new MRM_ forms. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96048 91177308-0d34-0410-b5e6-96231b3b80d8
* give MCCodeEmitters access to the current MCContext.Chris Lattner2010-02-121-3/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96038 91177308-0d34-0410-b5e6-96231b3b80d8
* add a bunch of mod/rm encoding types for fixed mod/rm bytes.Chris Lattner2010-02-121-0/+21
| | | | | | | | This will work better for the disassembler for modeling things like lfence/monitor/vmcall etc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95960 91177308-0d34-0410-b5e6-96231b3b80d8
* dont' call getX86RegNum on X86::RIP, it doesn't like that. ThisChris Lattner2010-02-111-1/+3
| | | | | | | fixes the remaining x86-64 jit failures afaik. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95867 91177308-0d34-0410-b5e6-96231b3b80d8
* fix a really nasty bug I introduced in r95693: r12 (and r12d, Chris Lattner2010-02-111-3/+6
| | | | | | | | | | r12b, etc) also encodes to a R/M value of 4, which is just as illegal as ESP/RSP for the non-sib version an address. This fixes x86-64 jit miscompilations of a bunch of programs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95866 91177308-0d34-0410-b5e6-96231b3b80d8
* MC: Switch MCFixup to just hold an MCExpr pointer instead of index into theDaniel Dunbar2010-02-101-4/+8
| | | | | | MCInst it came from. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95767 91177308-0d34-0410-b5e6-96231b3b80d8
* MC/X86: Add a dummy implementation of MCFixup generation for hacky X86 ↵Daniel Dunbar2010-02-091-8/+44
| | | | | | MCCodeEmitter. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95709 91177308-0d34-0410-b5e6-96231b3b80d8
* MC: First cut at MCFixup, for getting fixup/relocation information out of an ↵Daniel Dunbar2010-02-091-1/+20
| | | | | | MCCodeEmitter. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95708 91177308-0d34-0410-b5e6-96231b3b80d8
* fix X86 encoder to output [disp] only addresses with no SIB byteChris Lattner2010-02-091-73/+85
| | | | | | | | | in X86-32 mode. This is still required in x86-64 mode to avoid forming [disp+rip] encoding. Rewrite the SIB byte decision logic to be actually understandable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95693 91177308-0d34-0410-b5e6-96231b3b80d8
* revert r95689: getX86RegNum(BaseReg) != N86::ESP isChris Lattner2010-02-091-2/+2
| | | | | | | a confusing idiom to check for ESP or RSP. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95690 91177308-0d34-0410-b5e6-96231b3b80d8
* simplify.Chris Lattner2010-02-091-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95689 91177308-0d34-0410-b5e6-96231b3b80d8
* move target-independent opcodes out of TargetInstrInfoChris Lattner2010-02-091-6/+6
| | | | | | | | | | into TargetOpcodes.h. #include the new TargetOpcodes.h into MachineInstr. Add new inline accessors (like isPHI()) to MachineInstr, and start using them throughout the codebase. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95687 91177308-0d34-0410-b5e6-96231b3b80d8
* wire up 64-bit MCCodeEmitter.Chris Lattner2010-02-051-2/+5
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95438 91177308-0d34-0410-b5e6-96231b3b80d8
* move functions for decoding X86II values into the X86II namespace.Chris Lattner2010-02-051-13/+13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95410 91177308-0d34-0410-b5e6-96231b3b80d8
* change getSizeOfImm and getBaseOpcodeFor to just takeChris Lattner2010-02-051-13/+13
| | | | | | | TSFlags directly instead of a TargetInstrDesc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95405 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a few more encodings, we can now encode all of:Chris Lattner2010-02-051-1/+1
| | | | | | | | | | | | pushl %ebp movl %esp, %ebp movl $42, %eax popl %ebp ret git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95344 91177308-0d34-0410-b5e6-96231b3b80d8
* Disable external stubs for X86-32 and X86-64Evan Phoenix2010-02-041-1/+8
| | | | | | | | | | Instruction selection for X86 now can choose an instruction sequence that will fit any address of any symbol, no matter the pointer width. X86-64 uses a mov+call-via-reg sequence for this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95323 91177308-0d34-0410-b5e6-96231b3b80d8
* enhance new encoder to support prefixes + RawFrm Chris Lattner2010-02-031-1/+1
| | | | | | | | | | instructions with no operands. It can now handle define void @test2() nounwind { ret void } git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95261 91177308-0d34-0410-b5e6-96231b3b80d8
* stub out a new X86 encoder, which can be tried withChris Lattner2010-02-031-1/+12
| | | | | | | -enable-new-x86-encoder until its stable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95256 91177308-0d34-0410-b5e6-96231b3b80d8
* rename createX86MCCodeEmitter to more accurately reflect what it creates.Chris Lattner2010-02-031-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95254 91177308-0d34-0410-b5e6-96231b3b80d8
* remove dead code.Chris Lattner2010-02-021-11/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95144 91177308-0d34-0410-b5e6-96231b3b80d8
* MCCodeEmitter/X86: Handle tied registers better when converting MCInst ->Daniel Dunbar2010-02-021-6/+18
| | | | | | | MCMachineInstr. This also fixes handling of tied registers for MRMSrcMem instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95136 91177308-0d34-0410-b5e6-96231b3b80d8
* make MachineFunction keep track of its ID and make Chris Lattner2010-01-261-1/+1
| | | | | | | | | MachineFunctionAnalysis dole them out, instead of having AsmPrinter do both. Have the AsmPrinter::SetupMachineFunction method set the 'AsmPrinter::MF' variable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94509 91177308-0d34-0410-b5e6-96231b3b80d8
* Change errs() to dbgs().David Greene2010-01-051-10/+10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92644 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove ISD::DEBUG_LOC and ISD::DBG_LABEL, which are no longer used.Dan Gohman2009-11-231-1/+0
| | | | | | | | | Note that "hasDotLocAndDotFile"-style debug info was already broken; people wanting this functionality should implement it in the AsmPrinter/DwarfWriter code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89711 91177308-0d34-0410-b5e6-96231b3b80d8
* 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! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@88984 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86363 91177308-0d34-0410-b5e6-96231b3b80d8
* apparently the X86 JIT isn't fully contextized, it is still using ↵Chris Lattner2009-10-271-0/+1
| | | | | | getGlobalContext() :( git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85252 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove includes of Support/Compiler.h that are no longer needed after theNick Lewycky2009-10-251-1/+0
| | | | | | | VISIBILITY_HIDDEN removal. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85043 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85042 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix PR5087, patch by Jakub Staszak!Chris Lattner2009-10-121-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83822 91177308-0d34-0410-b5e6-96231b3b80d8
* Update processDebugLoc() so that it can be used to process debug info before ↵Devang Patel2009-10-061-1/+3
| | | | | | and after printing an instruction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83363 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83006 91177308-0d34-0410-b5e6-96231b3b80d8
* Also emit a label for TargetInstrInfo::GC_LABEL.Nicolas Geoffray2009-09-081-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81206 91177308-0d34-0410-b5e6-96231b3b80d8
* just use dump()Chris Lattner2009-09-031-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80889 91177308-0d34-0410-b5e6-96231b3b80d8
* Simplify.Daniel Dunbar2009-09-011-18/+8
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80729 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix what I believe is a copy-n-pasto introduced in r78129.Daniel Dunbar2009-09-011-3/+3
| | | | | | - Bruno, please check!! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80728 91177308-0d34-0410-b5e6-96231b3b80d8
* X86/Encoding: Support ExternalSymbol operands in emitDisplacementField (for ↵Daniel Dunbar2009-09-011-0/+7
| | | | | | consistency). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80727 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80575 91177308-0d34-0410-b5e6-96231b3b80d8
* llvm-mc/X86: Encode constant MCValue's correctly.Daniel Dunbar2009-08-301-0/+6
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80485 91177308-0d34-0410-b5e6-96231b3b80d8
* 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! ;) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80234 91177308-0d34-0410-b5e6-96231b3b80d8
* Record variable debug info at ISel time directly.Devang Patel2009-08-221-1/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79742 91177308-0d34-0410-b5e6-96231b3b80d8