1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00
Commit Graph

372 Commits

Author SHA1 Message Date
Daniel Dunbar
241d3cb048 MC: Allow modifiers in MCSymbolRefExpr, and eliminate X86MCTargetExpr.
- Although it would be nice to allow this decoupling, the assembler needs to be able to reason about MCSymbolRefExprs in too many places to make this viable. We can use a target specific encoding of the variant if this becomes an issue.
 - This patch also extends llvm-mc to support parsing of the modifiers, as opposed to lumping them in with the symbol.

llvm-svn: 98592
2010-03-15 23:51:06 +00:00
Daniel Dunbar
476b525e01 MC/Mach-O/x86_64: Temporary labels in cstring sections require symbols (and external relocations, but we don't have x86_64 relocations yet).
llvm-svn: 98583
2010-03-15 21:56:50 +00:00
Daniel Dunbar
27eab8e4f7 MC/Mach-O: Add MCSectionMachO::getType()
llvm-svn: 98582
2010-03-15 21:56:38 +00:00
Chris Lattner
1b10191d18 fix a memory leak yjasskin pointed out: MCSymbol is bump pointer
allocated and thus not freed.  This is cool except that it contains
and std::string so the string data didn't get freed.  In any case
there is no reason to redundantly store the string data in the 
MCSymbol anyway, just make the MCSymbol ref the string data in the
MCContext StringMap.

llvm-svn: 98536
2010-03-15 06:15:35 +00:00
Chris Lattner
3eb55835b5 add a new CreateTempSymbol method, the use case for
CreateTempSymbol vs GetOrCreateTemporarySymbol are
completely different.

llvm-svn: 98486
2010-03-14 08:23:30 +00:00
Daniel Dunbar
03a9f8588c MC: Fix a crash on invalid, attempting to evaluate undefined symbols.
llvm-svn: 98464
2010-03-14 03:10:40 +00:00
Daniel Dunbar
eb158a88db MC/X86_64: Symbol support.
llvm-svn: 98456
2010-03-13 22:49:35 +00:00
Daniel Dunbar
fec15da5d7 MC/Mach-O: Initial x86_64 support.
llvm-svn: 98454
2010-03-13 22:10:17 +00:00
Chris Lattner
58097a4b82 add a hack to allow parsing negative minint. rdar://7751341
llvm-svn: 98442
2010-03-13 19:25:13 +00:00
Daniel Dunbar
e8b67adb94 MC/Mach-O: PCrel relocations weren't using the right base address, they are
relative to the fragment address, not its offset. This was masked by the text
section normally being at address 0.

llvm-svn: 98420
2010-03-13 02:38:00 +00:00
Daniel Dunbar
33c92a1a88 llvm-mc: Support -n, useful for comparing -integrated-as output since the
compiler may not lead with the text section.

llvm-svn: 98418
2010-03-13 02:20:57 +00:00
Daniel Dunbar
8ad9589475 MC/Mach-O: Implement initial support for relaxation.
- The implementation is currently very brain dead and inefficient, but I have a
   clear plan on how to fix it.

 - The good news is, it works and correctly assembles 403.gcc (when built with
   Clang, at '-Os', '-Os -g', and '-O3'). Even better, at '-Os' and '-Os -g',
   the resulting binary is exactly equivalent to that when built with the system
   assembler. So it probably works! :)

llvm-svn: 98396
2010-03-12 22:07:14 +00:00
Chris Lattner
ff05ae7a33 move fastcall/stdcall mangling up into Mangler.
llvm-svn: 98384
2010-03-12 21:03:47 +00:00
Daniel Dunbar
642fbbe84d MC: Factor out MCAssembler::EvaluateFixup, and simplify.
llvm-svn: 98381
2010-03-12 21:00:49 +00:00
Daniel Dunbar
14b9ff70e1 MC: Constify MCAsmLayout argument to MCExpr::EvaluteAs...
llvm-svn: 98380
2010-03-12 21:00:45 +00:00
Daniel Dunbar
71473e6b15 MC: Add MCAssembler::addFixup, which enforces that fixups are added in order.
llvm-svn: 98379
2010-03-12 21:00:38 +00:00
Chris Lattner
f4dce6a6d8 remove MAI argument from createAsmStreamer since it
can get it from the context now.

llvm-svn: 98361
2010-03-12 18:28:53 +00:00
Chris Lattner
de47dfab1d enhance MCContext::GetOrCreateTemporarySymbol() to create a new symbol
with an arbitrary unique name.

llvm-svn: 98294
2010-03-11 22:56:10 +00:00
Chris Lattner
debc026df2 change MCContext to always have an MCAsmInfo.
llvm-svn: 98293
2010-03-11 22:53:35 +00:00
Chris Lattner
8fc3ad6384 empty symbols aren't possible, the mcsymbol ctor aborts on them.
llvm-svn: 98288
2010-03-11 21:38:58 +00:00
Daniel Dunbar
8790f4ce4b MC/Mach-O: Add MCSymbolData::getAddress() utility.
llvm-svn: 98266
2010-03-11 18:22:51 +00:00
Daniel Dunbar
ee26fc9e9f MC/Mach-O: Implement "absolutizing" semantics of .set, by evaluating the assembly time value of variables.
llvm-svn: 98241
2010-03-11 05:53:37 +00:00
Daniel Dunbar
aefde2abfd MC/Mach-O: Start passing in the basic MCAsmLayout object.
- Also, drop the current location part of AsmLayout, I think I prefer to implement this via explicit symbols.

llvm-svn: 98240
2010-03-11 05:53:33 +00:00
Daniel Dunbar
285a34c8c8 MC: Sketch initial MCAsmLayout class, which encapsulates the current layout of an assembly file. The MCAsmLayout is also available for use by MCExpr::EvaluateAs{Absolute,Relocatable}, to allow target specific hooks and "absolutizing" of symbols.
llvm-svn: 98227
2010-03-11 02:28:59 +00:00
Daniel Dunbar
687d99cfa8 MC: Provide MCAssembler with a TargetAsmBackend.
llvm-svn: 98222
2010-03-11 01:34:27 +00:00
Daniel Dunbar
a1827f9853 MC/Mach-O: Use the MCAssembler symbol map instead of reconstructing.
llvm-svn: 98187
2010-03-10 20:58:31 +00:00
Daniel Dunbar
fc99f844eb MC: Move the backend section and symbol data maps to MCAssembler.
llvm-svn: 98186
2010-03-10 20:58:29 +00:00
Daniel Dunbar
8f981447a6 Remove unneeded includes.
llvm-svn: 98167
2010-03-10 17:56:05 +00:00
Chris Lattner
e34dde1e83 move three lowering hooks from MAI to TLOF and make one of them
semantic instead of syntactic.  This completes MCization of
darwin/x86[-64]!

llvm-svn: 98145
2010-03-10 07:20:42 +00:00
Chris Lattner
ed0b8d36e4 set the temporary bit on MCSymbols correctly.
llvm-svn: 98124
2010-03-10 02:25:11 +00:00
Daniel Dunbar
54df3cead6 MC/Mach-O: Resolve a FIXME; these relocation types are no longer semanticaly different.
llvm-svn: 98120
2010-03-10 02:10:29 +00:00
Chris Lattner
554f323da8 eliminate MCContext::CreateSymbol and CreateTemporarySymbol.
Add a new GetOrCreateTemporarySymbol method and a version that
takes a twine.

llvm-svn: 98118
2010-03-10 01:29:27 +00:00
Daniel Dunbar
14b4e621b0 MC/Mach-O: Use the SECTDIFF relocation type for (A - B + constant) where A is external.
- I'm not sure why, but this is what 'as' does.

llvm-svn: 98115
2010-03-10 00:58:25 +00:00
Chris Lattner
13cbdb1549 make the NullStreamer set the section on a label when emitted so that isDefined() works.
llvm-svn: 98100
2010-03-09 23:12:18 +00:00
Daniel Dunbar
f33a8c5ab6 MC/Mach-O: For PCrel relocations, we need to compensate for the PCrel adjustment when determining if we need a scattered relocation.
llvm-svn: 98082
2010-03-09 21:27:58 +00:00
Daniel Dunbar
94ed4ba5e0 MC/Mach-O: Also set the PCrel bit in the second half of paired relocation entries.
llvm-svn: 98081
2010-03-09 21:27:47 +00:00
Daniel Dunbar
90e934ff65 MC/Mach-O: Don't generate relocations for PCrel fixups to local labels.
llvm-svn: 98080
2010-03-09 21:27:30 +00:00
Daniel Dunbar
8e3e2688b5 MC/Mach-O: Tweak .dump() formatting.
llvm-svn: 98028
2010-03-09 01:12:23 +00:00
Daniel Dunbar
e3986eb967 MC/Mach-O: Don't adjust section sizes when aligning zero fill sections, just pad the address.
llvm-svn: 98027
2010-03-09 01:12:20 +00:00
Chris Lattner
8147c144d9 add a EmitSymbolValue convenience method to MCStreamer.
llvm-svn: 98017
2010-03-09 00:39:24 +00:00
Daniel Dunbar
42f1b1b255 MC/Macho-O: Align the zerofill section itself to the maximum alignment.
llvm-svn: 97991
2010-03-08 22:03:42 +00:00
Daniel Dunbar
3292ad448b MC/Mach-O: Fix address compution for zero fill sections.
llvm-svn: 97984
2010-03-08 21:10:42 +00:00
Daniel Dunbar
ea24e77d30 MC/Mach-O: Error out instead of crashing on invalid scattered relocation expressions.
llvm-svn: 97983
2010-03-08 21:10:39 +00:00
Chris Lattner
2a0ccfc916 pass in more section kinds, enough to get the .align 0x90
stuff to emit optimal nops in the right places.

llvm-svn: 97233
2010-02-26 18:32:26 +00:00
Kevin Enderby
11cce486ac This is a patch to the assembler frontend to detect when aligning a text
section with TextAlignFillValue and calls EmitCodeAlignment() instead of
calling EmitValueToAlignment().  This allows x86 assembly code to be aligned
with optimal nops.

llvm-svn: 97158
2010-02-25 18:46:04 +00:00
Kevin Enderby
69d643ba20 This is the second patch to allow x86 code to be aligned with optimal nops.
With the compiler changed to use EmitCodeAlignment() it does change the
functionality.  But X86 assembly code assembled with llvm-mc does not change
its output.  For that we will eventually change the assembler frontend to
detect a '.align x, 0x90' when used in a section that 'hasInstructions' and use
EmitCodeAlignment, but will wait until we have better target hooks.

llvm-svn: 96988
2010-02-23 21:41:24 +00:00
Chris Lattner
405e4a1d63 genericize MCAsmStreamer::EmitCodeAlignment to support other targets
so that it doesn't break them when the code generator starts using it.

llvm-svn: 96966
2010-02-23 18:44:31 +00:00
Kevin Enderby
c11390f758 This is the first patch to put the needed bits in place to eventually allow code
to be aligned with optimal nops.  This patch does not change any functionality
and when the compiler is changed to use EmitCodeAlignment() it should also not
change the resulting output.  Once the compiler change is made and everything
looks good the next patch with the table of optimal X86 nops will be added to
WriteNopData() changing the output.  There are many FIXMEs in this patch which
will be removed when we have better target hooks (coming soon I hear).

llvm-svn: 96963
2010-02-23 18:26:34 +00:00
Daniel Dunbar
2097684f80 MC/Mach-O: Remove non-sensical comment, and add a missing AddValueSymbols call.
llvm-svn: 96809
2010-02-22 22:08:57 +00:00
Daniel Dunbar
a6d1ef6ee9 MC/X86: Add stub AsmBackend.
llvm-svn: 96763
2010-02-21 21:54:14 +00:00
Daniel Dunbar
b6b58bff88 MC: Sketch registry support for target specific assembler backends.
llvm-svn: 96762
2010-02-21 21:53:53 +00:00
Daniel Dunbar
2f311d34fb MC/Mach-O: Update fixup values for change to X86 offsets.
llvm-svn: 96532
2010-02-17 23:45:16 +00:00
Duncan Sands
e2bc75b41e Pacify gcc-4.5, which warns (correctly) that these switches have
cases that are not part of the enum.

llvm-svn: 96477
2010-02-17 14:52:22 +00:00
Daniel Dunbar
e6679afaa7 MCAssembler: Fix pcrel relocations. Oh and,
--
ddunbar@ozzy:tmp$ clang -m32 -integrated-as hello.c && ./a.out
hello world!
--

llvm-svn: 96096
2010-02-13 09:45:59 +00:00
Daniel Dunbar
c05a38a3d3 MC/Mach-O: Start emitting fixups/relocations for instructions.
llvm-svn: 96095
2010-02-13 09:29:02 +00:00
Daniel Dunbar
7a1fd21459 MCAssembler: Switch MCAsmFixup to storing MCFixupKind instead of just a size.
llvm-svn: 96094
2010-02-13 09:28:54 +00:00
Daniel Dunbar
8e9044353a MCAssembler: Sink fixup list into MCDataFragment.
llvm-svn: 96093
2010-02-13 09:28:43 +00:00
Daniel Dunbar
95ae012b0e MCAssembler: Switch MCFillFragment to only taking constant values. Symbolic expressions can always be emitted as data + fixups.
llvm-svn: 96092
2010-02-13 09:28:32 +00:00
Daniel Dunbar
cc282ba52e MC/Mach-O: Implement EmitValue using data fragments + fixups instead of fill fragment.
llvm-svn: 96091
2010-02-13 09:28:22 +00:00
Daniel Dunbar
481e926468 MCAssembler: Start applying fixups in the data section.
llvm-svn: 96090
2010-02-13 09:28:15 +00:00
Daniel Dunbar
a699e834fb MCAssembler: Add assorted dump() methods.
llvm-svn: 96089
2010-02-13 09:28:03 +00:00
Daniel Dunbar
09733841aa MC/AsmParser: Attempt to constant fold expressions up-front. This ensures we avoid fixups for obvious cases like '-(16)'.
llvm-svn: 96064
2010-02-13 01:28:07 +00:00
Chris Lattner
144a1b7a24 add a new MCInstPrinter::getOpcodeName interface, when it is
implemented, llvm-mc --show-inst now uses it to print the
instruction opcode as well as the number.

llvm-svn: 95929
2010-02-11 22:39:10 +00:00
Daniel Dunbar
3ee9e4a9a5 MC: Move assembler-backend's fixup list into the fragment.
llvm-svn: 95926
2010-02-11 21:29:46 +00:00
Daniel Dunbar
fa324dd09b MC: Move MCSectionData::Fixup out to MCAsmFixup.
llvm-svn: 95925
2010-02-11 21:29:29 +00:00
Chris Lattner
b82b965968 make getFixupKindInfo return a const reference, allowing
the tables to be const.  Teach MCCodeEmitter to handle
the target-indep kinds so that we don't crash on them.

llvm-svn: 95924
2010-02-11 21:27:18 +00:00
Daniel Dunbar
d2035fb242 MC: Switch MCFixup to just hold an MCExpr pointer instead of index into the
MCInst it came from.

llvm-svn: 95767
2010-02-10 04:47:08 +00:00
Daniel Dunbar
75df429af0 llvm-mc: Remove --show-fixups and always show as part of --show-encoding.
Also, fix a silly memory leak.

llvm-svn: 95752
2010-02-10 01:41:14 +00:00
Chris Lattner
477ce1773c daniel *really* likes fixups!
llvm-svn: 95742
2010-02-10 01:05:28 +00:00
Chris Lattner
ca01d26903 Add ability for MCInstPrinters to add comments for instructions.
Enhance the x86 backend to show the hex values of immediates in
comments when they are large.  For example:

        movl    $1072693248, 4(%esp)    ## imm = 0x3FF00000

llvm-svn: 95728
2010-02-10 00:10:18 +00:00
Daniel Dunbar
1b050afd4e llvm-mc: Add --show-fixups option, for displaying the instruction fixup information in the asm comments.
llvm-svn: 95710
2010-02-09 23:00:14 +00:00
Daniel Dunbar
ddfda89472 MC: First cut at MCFixup, for getting fixup/relocation information out of an MCCodeEmitter.
llvm-svn: 95708
2010-02-09 22:59:55 +00:00
Chris Lattner
18fed3c934 make -show-inst be formatted a bit nicer. Before:
movl	$3735928559, a          ## inst: <MCInst 1273 <MCOperand Reg:0> <MCOperand Imm:1> <MCOperand Reg:0> <MCOperand Expr:(a)> <MCOperand Reg:0> <MCOperand Expr:(3735928559)>>

after:

	movl	$3735928559, a          ## <MCInst #1273
                                        ##   <MCOperand Reg:0>
                                        ##   <MCOperand Imm:1>
                                        ##   <MCOperand Reg:0>
                                        ##   <MCOperand Expr:(a)>
                                        ##   <MCOperand Reg:0>
                                        ##   <MCOperand Expr:(3735928559)>>

llvm-svn: 95637
2010-02-09 00:54:51 +00:00
Dan Gohman
30845777be Document that MCExpr::Mod is actually remainder.
Document that MCExpr::Div, Mod, and the comparison operators are all
signed operators.

Document that the comparison operators' results are target-dependent.

Document that the behavior of shr is target-dependent.

llvm-svn: 95619
2010-02-08 23:58:47 +00:00
Chris Lattner
39d41535ad don't make hte dtor private or we can't construct the class.
llvm-svn: 95587
2010-02-08 22:07:36 +00:00
Chris Lattner
b3fe7597f5 add scaffolding for target-specific MCExprs.
llvm-svn: 95559
2010-02-08 19:41:07 +00:00
Chris Lattner
b79cdb101f print encodings like this:
pslld	69, %mm3                ## encoding: [0x0f,0xf2,0x1c,0x25,0x45,0x00,0x00,0x00]

instead of like this:
	pslld	69, %mm3                ## encoding: [0x0f,0xf2,0x1c,0x25,0x45,0000,0000,0000]

this only affects 0.

llvm-svn: 95441
2010-02-05 22:20:08 +00:00
Daniel Dunbar
96bc973155 MC: Change default comment column to 40 characters.
llvm-svn: 95378
2010-02-05 07:32:18 +00:00
Dan Gohman
05d47a0cf5 Use a tab instead of space after .type, for consistency.
llvm-svn: 95272
2010-02-04 01:42:13 +00:00
Daniel Dunbar
d997cd69cd llvm-mc: Add --show-inst option, for showing the MCInst inline with the assembly
output.

llvm-svn: 95227
2010-02-03 18:18:30 +00:00
Chris Lattner
6fe16de58e print instruction encodings with the existing comment facilities,
so that llvm-mc -show-encoding prints like this:

	hlt                                                 ## encoding: [0xf4]

instead of like this:

	hlt
                     # encoding: [0xf4]

llvm-svn: 95207
2010-02-03 06:28:13 +00:00
Chris Lattner
643f2f9bc4 refactor code so that LLVMTargetMachine creates the asmstreamer and
mccontext instead of having AsmPrinter do it.  This allows other 
types of MCStreamer's to be passed in.

llvm-svn: 95155
2010-02-02 23:37:42 +00:00
Daniel Dunbar
eb0b81040a MC/Mach-O: Set SOME_INSTRUCTIONS bit for sections.
llvm-svn: 95135
2010-02-02 21:44:01 +00:00
Chris Lattner
3cae149179 Add a new top-level MachO.h file for manifest constants, fixing
a layering violation from MC -> Target.

llvm-svn: 95113
2010-02-02 19:38:14 +00:00
Chris Lattner
ef32178400 use EmitLinkage for functions as well as globals. One output
change is that we now use ".linkonce discard" for global variables
instead of ".linkonce samesize".  These should be the same, just less
strict.  If anyone is interested in mcizing MCSection for COFF targets,
this should be easy to fix.

llvm-svn: 94623
2010-01-26 23:51:52 +00:00
Chris Lattner
325a36c358 Eliminate SetDirective, and replace it with HasSetDirective.
Default HasSetDirective to true, since most targets have it.

The targets that claim to not have it probably do, or it is
spelled differently. These include Blackfin, Mips, Alpha, and
PIC16.  All of these except pic16 are normal ELF targets, so
they almost certainly have it.

llvm-svn: 94585
2010-01-26 20:40:54 +00:00
Rafael Espindola
f46baf3304 Emit .comm alignment in bytes but .align in powers of 2 for ARM ELF.
Original patch by Sandeep Patel and updated by me.

llvm-svn: 94582
2010-01-26 20:21:43 +00:00
Chris Lattner
044439c9bc eliminate MCAsmInfo::NeedsSet: we now just use .set on any platform
that has it.

llvm-svn: 94581
2010-01-26 20:20:43 +00:00
Chris Lattner
3559d9a38a mcstreamerize gprel32 emission.
llvm-svn: 94452
2010-01-25 21:28:50 +00:00
Chris Lattner
ac1144c110 rename MAI::PICJumpTableDirective to MAI::GPRel32Directive to
make it clear what it is, instead of how it is used.

llvm-svn: 94448
2010-01-25 21:10:10 +00:00
Chris Lattner
fafb52a75a remove JumpTableDirective, it is always null.
llvm-svn: 94445
2010-01-25 20:52:54 +00:00
Chris Lattner
5f919913e8 wirte up .file and .file to the mc asmparser.
llvm-svn: 94438
2010-01-25 19:02:58 +00:00
Chris Lattner
20d89c382c mcstreamerize .file and .file. This also fixes an issue where the
normal form of .file would fail if the filename had a weird character
in it.

llvm-svn: 94437
2010-01-25 18:58:59 +00:00
Chris Lattner
4746185ef2 emit ELF .type directives through MCStreamer instead of doing it textually.
llvm-svn: 94436
2010-01-25 18:33:40 +00:00
Chris Lattner
7a5c8c15bd add symbol attribute support for the ELF .type directive.
llvm-svn: 94435
2010-01-25 18:30:45 +00:00
Chris Lattner
9834b7f300 emit the .size directive for global variables on ELF through
mcstreamer.

llvm-svn: 94416
2010-01-25 07:52:13 +00:00
Chris Lattner
474395e815 all supported target now have aligned common support.
llvm-svn: 94413
2010-01-25 07:29:13 +00:00
Chris Lattner
0b42d3ef45 coff targets support alignment on .comm
llvm-svn: 94410
2010-01-25 07:20:44 +00:00
Chris Lattner
5a57121631 make -fno-rtti the default unless a directory builds with REQUIRES_RTTI.
llvm-svn: 94378
2010-01-24 20:43:08 +00:00
Chris Lattner
5d31547fec fix a parsing problem on instructions like:
movw	$8, (_cost_table_-L97$pb)+66(%eax)

After the parens, we could still have a binop.

llvm-svn: 94345
2010-01-24 01:07:33 +00:00