Jim Grosbach
d856fd0d99
Source information in 'expected relocatable expression' diagnostic.
...
llvm-svn: 149105
2012-01-27 00:51:23 +00:00
Jim Grosbach
aba3de99c0
Tidy up. MCAsmBackend naming conventions.
...
llvm-svn: 148400
2012-01-18 18:52:16 +00:00
Jim Grosbach
3b50c9ec7f
Move some ARM specific MCAssmebler bits into the ARMAsmBackend.
...
llvm-svn: 148364
2012-01-18 00:23:57 +00:00
David Blaikie
a379b18173
Unweaken vtables as per http://llvm.org/docs/CodingStandards.html#ll_virtual_anch
...
llvm-svn: 146960
2011-12-20 02:50:00 +00:00
Jim Grosbach
25b63fa117
Move target-specific logic out of generic MCAssembler.
...
Whether a fixup needs relaxation for the associated instruction is a
target-specific function, as the FIXME indicated. Create a hook for that
and use it.
llvm-svn: 145881
2011-12-06 00:47:03 +00:00
Jim Grosbach
46be301c4c
Tidy up. Hard tabs.
...
llvm-svn: 145878
2011-12-06 00:13:09 +00:00
Jim Grosbach
18e2fe47fa
Switch MCAssembler to method names starting w/ lower-case.
...
per http://llvm.org/docs/CodingStandards.html#ll_naming
llvm-svn: 145873
2011-12-06 00:03:48 +00:00
Jim Grosbach
ae9132207f
Better fix for ARM MOVT relocation encoding of thumb bit.
...
Replaces r145318 with a more targetted fix for the relocation handling.
llvm-svn: 145346
2011-11-29 01:15:25 +00:00
Jim Grosbach
30168fbde5
Thumb2 only force the fixup thumb bit for data relocations.
...
rdar://10493453
llvm-svn: 145318
2011-11-28 23:39:00 +00:00
Jim Grosbach
6485a7991d
Trailing whitespace.
...
llvm-svn: 143071
2011-10-26 22:44:41 +00:00
Evan Cheng
2bb4035707
Move TargetRegistry and TargetSelect from Target to Support where they belong.
...
These are strictly utilities for registering targets and components.
llvm-svn: 138450
2011-08-24 18:08:43 +00:00
Evan Cheng
5928e69d20
Rename TargetAsmBackend to MCAsmBackend; rename createAsmBackend to createMCAsmBackend.
...
llvm-svn: 136010
2011-07-25 23:24:55 +00:00
Evan Cheng
f2596bc62a
Move TargetAsmParser.h TargetAsmBackend.h and TargetAsmLexer.h to MC where they belong.
...
llvm-svn: 135833
2011-07-23 00:45:41 +00:00
Rafael Espindola
ab39c63538
Don't force relaxation of AdvanceLoc instructions on OS X. gdb is happy with
...
the smaller encoding and this cuts 270336 bytes from a release version of
clang and 1246272 bytes from a debug build.
llvm-svn: 131067
2011-05-08 14:35:21 +00:00
Daniel Dunbar
72032861c6
MCAsmLayout: Add support for computing the symbol offset of variables. Not
...
currently used, because variables don't get reported as being "defined".
llvm-svn: 130524
2011-04-29 18:20:20 +00:00
Rafael Espindola
2eeee8cfef
Add a small temporary hack for producing identical eh_frame sections on OS X.
...
This removes one of the main advantages of moving eh_frame to MC, but
makes the transition a lot easier to debug (run md5).
llvm-svn: 130379
2011-04-28 04:04:14 +00:00
Rafael Espindola
3584ab6cc6
No relocation produces a SLEB or ULEB, make sure they are handled in MC.
...
llvm-svn: 130181
2011-04-26 02:17:58 +00:00
Jay Foad
1a180156b6
Remove unused STL header includes.
...
llvm-svn: 130068
2011-04-23 19:53:52 +00:00
Rafael Espindola
490d02a334
Gas is very inconsistent about when a relaxation/relocation is needed. Do
...
the right thing and stop trying to copy it. Fixes PR8944.
llvm-svn: 125648
2011-02-16 03:25:55 +00:00
Rafael Espindola
b3eca9bb71
Add support for the --noexecstack option.
...
llvm-svn: 124077
2011-01-23 17:55:27 +00:00
Rafael Espindola
736a35d9ab
Relax address updates in the eh_frame section.
...
llvm-svn: 122591
2010-12-28 05:39:27 +00:00
Rafael Espindola
0f8abeba1d
Merge IsFixupFullyResolved and IsSymbolRefDifferenceFullyResolved. We now
...
have a single point where targets test if a relocation is needed.
llvm-svn: 122549
2010-12-24 21:22:02 +00:00
Rafael Espindola
d91e11932c
Assert that the AddrDelta expression is really constant and wrap it in a set
...
if we have a lame assembler.
llvm-svn: 122446
2010-12-22 22:04:28 +00:00
Rafael Espindola
50ce2f06de
Use references and simplify.
...
llvm-svn: 122405
2010-12-22 16:11:57 +00:00
Rafael Espindola
6bdb49ded8
Don't relax org or align. They change size as the relaxation happens, but they
...
are not actually relaxed. For example, a section with only alignments will never
needs relaxation.
llvm-svn: 122356
2010-12-21 20:35:18 +00:00
Rafael Espindola
98d93c5294
Layout one section until no relaxations are done and then move to the next
...
section.
This helps because in practice sections form a dag with debug sections pointing
to text sections. Finishing up the text sections first makes the debug section
relaxation trivial.
llvm-svn: 122314
2010-12-21 04:22:09 +00:00
Owen Anderson
79855298b9
Thumb's forced-PC-alignment requirement applies to the _total_ displacement, not just to the fragment relative
...
portion. While the fragment boundary is usually already aligned, it is possible for it not to be, which
would lead to a non-aligned final displacement.
llvm-svn: 122091
2010-12-17 21:49:48 +00:00
Daniel Dunbar
50269280f8
MC/Assembler: Strip out object writer arguments, now that it is always available
...
-- and remove FIXME asking for the same!
llvm-svn: 122032
2010-12-17 02:45:59 +00:00
Daniel Dunbar
42a037abb1
MC/Assembler: Make the MCObjectWriter available through the lifetime of the
...
assembler.
llvm-svn: 122031
2010-12-17 02:45:41 +00:00
Daniel Dunbar
0c9d9fdd81
MC: Move target specific fixup info descriptors to TargetAsmBackend instead of
...
the MCCodeEmitter, which seems like a better organization.
- Also, cleaned up some magic constants while in the area.
llvm-svn: 121953
2010-12-16 03:20:06 +00:00
Owen Anderson
c8fa5fcc42
Fix typo in r121875.
...
llvm-svn: 121880
2010-12-15 19:24:24 +00:00
Owen Anderson
622ad5170b
Implement cleanups suggested by Daniel.
...
llvm-svn: 121875
2010-12-15 18:48:27 +00:00
Rafael Espindola
844f6b6cfb
Relax alignment fragments.
...
With this we don't need the EffectiveSize field anymore. Without that field
LayoutFragment only updates offsets and we don't need to invalidate the
current fragment when it is relaxed (only the ones following it).
This is also a very small improvement in the accuracy of the layout info as
we now use the after relaxation size immediately.
llvm-svn: 121857
2010-12-15 08:45:53 +00:00
Rafael Espindola
8911d03504
Patch by David Meyer to avoid a O(N^2) behaviour when relaxing fragments.
...
Since we now don't update addresses so early, we might relax a bit more than
we need to. This is simillar to the issue in PR8467.
llvm-svn: 121856
2010-12-15 07:39:29 +00:00
Jim Grosbach
41955ff958
ARM Fixups relative to thumb functions need to have the low bit of the value
...
set for interworking to work properly. rdar://8755956
llvm-svn: 121778
2010-12-14 18:46:57 +00:00
Owen Anderson
3ef19d9d48
Fix an issue in some Thumb fixups, where the effective PC address needs to be 4-byte aligned when calculating
...
the offset. Add a new fixup flag to represent this, and use it for the one fixups that I have a testcase for needing
this. It's quite likely that the other Thumb fixups will need this too, and to have their fixup encoding logic
adjusted accordingly.
llvm-svn: 121408
2010-12-09 20:27:52 +00:00
Rafael Espindola
6624f47272
Layout each section independently. With the testcase in PR8711:
...
before:
4 assembler - Number of assembler layout and relaxation steps
78563 assembler - Number of emitted assembler fragments
8693904 assembler - Number of emitted object file bytes
271223 assembler - Number of evaluated fixups
330771677 assembler - Number of fragment layouts
5958 assembler - Number of relaxed instructions
2508361 mcexpr - Number of MCExpr evaluations
real 0m26.123s
user 0m25.694s
sys 0m0.388s
after:
4 assembler - Number of assembler layout and relaxation steps
78563 assembler - Number of emitted assembler fragments
8693904 assembler - Number of emitted object file bytes
271223 assembler - Number of evaluated fixups
231507 assembler - Number of fragment layouts
5958 assembler - Number of relaxed instructions
2508361 mcexpr - Number of MCExpr evaluations
real 0m2.500s
user 0m2.113s
sys 0m0.273s
And yes, the outputs are identical :-)
llvm-svn: 121207
2010-12-07 23:32:26 +00:00
Rafael Espindola
93e3cf0ebd
Sorry for such a large commit. The summary is that only MachO cares about the
...
actuall addresses in a .o file, so it is better to let the MachO writer compute
it.
This is good for two reasons. First, areas that shouldn't care about
addresses now don't have access to it. Second, the layout of each section
is independent. I should use this in a subsequent commit to speed it up.
Most of the patch is just removing the section address computation. The two
interesting parts are the change on how we handle padding in the end
of sections and how MachO can get the address of a-b when a and b are in
different sections.
Since now the expression evaluation normally doesn't know the section address,
it will think that a-b needs relocation and let the MachO writer know. Once
it has computed the section addresses, it calls back the expression evaluation
with the section addresses to resolve these expressions.
The remaining problem is the handling of padding. Currently it will create
a special alignment fragment at the end. Since that fragment doesn't update
the alignment of the section, it needs the real address to be computed.
Since now the layout will not compute a-b with a and b in different sections,
the only effect that the special alignment fragment has is update the
address size of the section. This can also be done by the MachO writer.
llvm-svn: 121076
2010-12-07 00:27:36 +00:00
Rafael Espindola
1055f72b97
Use references to simplify the code a bit.
...
llvm-svn: 121050
2010-12-06 22:30:54 +00:00
Rafael Espindola
0f30fec0bd
Remove the instruction fragment to data fragment lowering since it was causing
...
freed data to be read. I will open a bug to track it being reenabled.
llvm-svn: 121028
2010-12-06 19:08:48 +00:00
Rafael Espindola
baf2f3b3eb
Remove the getAddress getter, initialize Ordinal in the constructor and use
...
that on the ELF writer to detect a section we created.
llvm-svn: 120981
2010-12-06 03:48:09 +00:00
Rafael Espindola
e7284c3671
Add a getSymbolOffset method and use it in the ELF writer.
...
llvm-svn: 120977
2010-12-06 02:57:26 +00:00
Rafael Espindola
8867390cf2
Once the layout is done we don't need to keep updating which fragments are
...
valid. Addresses will not change.
llvm-svn: 120921
2010-12-04 22:47:22 +00:00
Rafael Espindola
99e026dbca
Remember the contents of leb and dwarfline fragments when relaxing. This avoids
...
having to evaluate the expression again when writing.
llvm-svn: 120920
2010-12-04 21:58:52 +00:00
Rafael Espindola
60ebca9aaf
The sections that the ELF object writer has to create are very simple and
...
contain only data. Handle them specially instead of using AddSectionToTheEnd.
This moves a hack from the generic assembler to the elf writer. It is also
a bit faster and should make other improvements easier.
llvm-svn: 120683
2010-12-02 03:09:06 +00:00
Rafael Espindola
50fe5c5138
Remove unused argument.
...
llvm-svn: 120621
2010-12-01 22:48:11 +00:00
Rafael Espindola
5c1d4e3b1e
Invalidate the layout on any relaxation, not just Instructions. Bug found by David Meyer.
...
While here, remove unused argument and rename UpdateForSlide to Invalidate.
llvm-svn: 120009
2010-11-23 08:08:33 +00:00
Rafael Espindola
6e13aa1d3b
Reuse data fragments while lowering. Patch by David Meyer.
...
llvm-svn: 119999
2010-11-23 05:49:35 +00:00
Rafael Espindola
0b4c9aa9a9
Add an assert.
...
llvm-svn: 119788
2010-11-19 04:55:36 +00:00
Rafael Espindola
7a2cd8b540
make isVirtualSection a virtual method on MCSection. Chris' suggestion.
...
llvm-svn: 119547
2010-11-17 20:03:54 +00:00
Rafael Espindola
8c3039b67b
Change MCExpr::EvaluateAsRelocatableImpl of variables to return the original
...
variable if recursing fails to simplify it.
Factor AliasedSymbol to be a method of MCSymbol.
Update MCAssembler::EvaluateFixup to match the change in
EvaluateAsRelocatableImpl.
Remove the WeakRefExpr hack, as the object writer now sees the weakref with
no extra effort needed.
Nothing else is using MCTargetExpr, but keep it for now.
Now that the ELF writer sees relocations with aliases, handle
.weak foo2
foo2:
.weak bar2
.set bar2,foo2
.quad bar2
the same way gas does and produce a relocation with bar2.
llvm-svn: 119152
2010-11-15 16:33:49 +00:00
Rafael Espindola
20b11eaa01
Speed up AddSectionToTheEnd. It was walking all fragments in all sections.
...
This is really slow with we have 1000s of sections each with a corresponding
relocation section. Also, it is only used by the ELF writer to add
basic data, so there is no need to force a new layout pass.
Should fix PR8563.
llvm-svn: 118377
2010-11-07 15:03:27 +00:00
Rafael Espindola
5665a93bc5
Relax dwarf line fragments. This fixes a crash in the included testcase.
...
llvm-svn: 118365
2010-11-07 02:07:12 +00:00
Rafael Espindola
f8343f87e7
Do relaxations with FT_Org fragments. Fixes the FIXME:
...
// FIXME: We should compute this sooner, we don't want to recurse here, and
// we would like to be more functional.
In MCAssembler::ComputeFragmentSize.
llvm-svn: 118080
2010-11-02 21:38:23 +00:00
Rafael Espindola
5e874982f2
Add support for expressions in .sleb/.uleb directives.
...
llvm-svn: 118023
2010-11-02 17:22:24 +00:00
Kevin Enderby
e46564a4a8
This is the last major patch to implement support for the .loc directive
...
and output the dwarf line number tables. This contains the code to emit and
encode the dwarf line tables from the previously gathered information in the
MCLineSection objects. This contains all the details to encode the line and
address deltas into the dwarf line table.
To do this an MCDwarfLineAddrFragment has been added.
Also this moves the interface code out of Mach-O streamer into
MCDwarf so it should be useable by other object file formats.
There is now one call to be made from an MCObjectStreamer
EmitInstruction() method:
MCLineEntry::Make(this, getCurrentSection());
to create a line entry after each instruction is assembled.
And one call call to be made from an MCObjectStreamer Finish() method:
MCDwarfFileTable::Emit(this, DwarfLineSection);
when getContext().hasDwarfFiles() is true and is passed a object file specific
MCSection where to emit the dwarf file and the line tables.
This appears to now be correct for 32-bit targets, at least x86. But the
relocation entries for 64-bit Darwin needs some further work which is next
up to work on. So for now the 64-bit Mach-O target does not output the
dwarf file and line tables.
llvm-svn: 115157
2010-09-30 16:52:03 +00:00
Rafael Espindola
2ebaee9c75
Make it possible for the MCObjectWriter to decide if a given fixup is fully
...
resolved or not. Different object files have different restrictions and
different native assemblers have different idiosyncrasies we want to emulate
for now.
Move the existing MachO logic to the new place and implement an ELF one that
gets fixups to globals right.
llvm-svn: 115131
2010-09-30 02:22:20 +00:00
Rafael Espindola
cceded493f
Remove unused argument.
...
llvm-svn: 114852
2010-09-27 18:13:03 +00:00
Daniel Dunbar
74c1f1192c
MC: Add missing ')' in diagnostic.
...
llvm-svn: 114717
2010-09-24 01:58:56 +00:00
Rafael Espindola
dee12d8110
Avoid some Mach-O specific alignment being done on ELF.
...
llvm-svn: 114594
2010-09-22 22:27:05 +00:00
Rafael Espindola
f667d929ce
Add a InitSections method to the streamer interface.
...
The ELF implementation now creates text, data and bss to match the gnu as
behavior.
The text streamer still has the old MachO specific behavior since
the testsuite checks that it will error when a directive is given
before a setting the current section for example.
A nice benefit is that -n is not required anymore when producing
ELF files.
llvm-svn: 114027
2010-09-15 21:48:40 +00:00
Daniel Dunbar
a90e25cc64
MC: Give a (lame) hard error if a .org directive would create an unreasonably
...
large object file (> 1GB).
llvm-svn: 113494
2010-09-09 16:23:33 +00:00
Daniel Dunbar
8e92d9b68d
MC/ELF: Allow null values in virtual sections, ELF doesn't use special
...
directives for putting contents in .bss, for example.
llvm-svn: 111376
2010-08-18 18:22:37 +00:00
Matt Fleming
9cecd63b07
Layout helper function.
...
Introduce a helper method to add a section to the end of a layout. This
will be used by the ELF ObjectWriter code to add the metadata sections
(symbol table, etc) to the end of an object file.
llvm-svn: 111171
2010-08-16 18:35:06 +00:00
Matt Fleming
c6beca522c
Record a symbol's size which is needed for ELF symbol tables.
...
llvm-svn: 111170
2010-08-16 18:34:31 +00:00
Daniel Dunbar
5dc31317dd
MC: Initialize MCFragment::Offset, noticed by Cameron Esfahani.
...
llvm-svn: 109875
2010-07-30 18:32:09 +00:00
Daniel Dunbar
e397dded7b
MC: Put back the MCFragment vtable, so subclasses are destroyed properly (duh).
...
llvm-svn: 109649
2010-07-28 20:28:45 +00:00
Reid Kleckner
d85e3c5a86
Initial modifications to MCAssembler and TargetMachine for the MCJIT.
...
Patch by Olivier Meurant!
llvm-svn: 109080
2010-07-22 05:58:53 +00:00
Duncan Sands
a85a90773c
The variable ValueSize is set to 1 on both code paths, and then
...
ignored! Remove it.
llvm-svn: 107138
2010-06-29 13:30:08 +00:00
Daniel Dunbar
aa627c39e4
MC: Simplify MCAssembler::isSymbolLinkerVisible to only take an MCSymbol.
...
llvm-svn: 106142
2010-06-16 20:04:29 +00:00
Dan Gohman
a76715fc88
Don't call flush() at a library level which isn't checking for errors
...
and doesn't know where the output is going.
llvm-svn: 105274
2010-06-01 16:31:34 +00:00
Daniel Dunbar
b889fc987e
MC: When running with -mc-relax-all, we can eagerly relax instructions and avoid creating unnecessary MCInstFragments.
...
llvm-svn: 104736
2010-05-26 20:37:03 +00:00
Daniel Dunbar
7c8bd0fc98
MC: Change RelaxInstruction to only take the input and output instructions.
...
llvm-svn: 104713
2010-05-26 18:15:06 +00:00
Daniel Dunbar
a19838e107
MC: Simplify MayNeedRelaxation to not provide the fixups, so we can query it
...
before encoding.
llvm-svn: 104707
2010-05-26 17:45:29 +00:00
Daniel Dunbar
b34440a6a8
MC: Eliminate MCAsmFixup, replace with MCFixup.
...
llvm-svn: 104699
2010-05-26 15:18:56 +00:00
Daniel Dunbar
353a91ff76
MC: Use accessors for access to MCAsmFixup.
...
llvm-svn: 104697
2010-05-26 15:18:31 +00:00
Daniel Dunbar
870e5759e7
MC: Eliminate MCFragment vtable, which was unnecessary.
...
llvm-svn: 104689
2010-05-26 06:50:57 +00:00
Daniel Dunbar
4bce748aa2
MC: Switch to completely lazy layout.
...
- The eliminates the last major algorithmic problem with MC.
llvm-svn: 103754
2010-05-14 00:51:14 +00:00
Daniel Dunbar
9abade1017
MC: Extend MCAsmLayout to explicitly track which fragments have been layed out, and enforce several invariants to LayoutFragment to ensure we only do layout in a sensible order.
...
llvm-svn: 103753
2010-05-14 00:37:21 +00:00
Daniel Dunbar
3eedc26e18
MC: Implicitly assign section addresses when the previous fragment is layed out.
...
llvm-svn: 103752
2010-05-14 00:37:17 +00:00
Daniel Dunbar
8f9d2266e6
MC: Switch MCFragment to storing the layout order index, not its index in the file.
...
llvm-svn: 103751
2010-05-14 00:37:14 +00:00
Daniel Dunbar
a99a23b061
MC: Change LayoutSection() to only do the section initializiation.
...
Also, elimminate MCAsmLayout::set*, which are no longer needed.
llvm-svn: 103750
2010-05-14 00:37:11 +00:00
Daniel Dunbar
b9f6ac094a
MC: Move Layout{Fragment,Section} into MCAsmLayout, and add LayoutFile().
...
llvm-svn: 103738
2010-05-13 20:40:12 +00:00
Daniel Dunbar
454ea716a3
MC: Factor out MCAssembler::ComputeFragmentSize.
...
llvm-svn: 103724
2010-05-13 18:35:06 +00:00
Daniel Dunbar
484c6fc825
MC: Add section layout order indices to MCSectionData.
...
llvm-svn: 103715
2010-05-13 15:17:26 +00:00
Daniel Dunbar
aa8bd69886
MC: Move ordinal calculation, to make sure fragments synthesized for layout get assigned ordinals properly.
...
llvm-svn: 103711
2010-05-13 08:43:37 +00:00
Daniel Dunbar
e73353c720
MC: Create dummy fragments to avoid ever having empty sections, which simplifies layout.
...
llvm-svn: 103710
2010-05-13 08:43:34 +00:00
Daniel Dunbar
e8845ef4db
MC: Add MCAsmLayout::FragmentReplaced() helper function.
...
llvm-svn: 103709
2010-05-13 08:43:31 +00:00
Daniel Dunbar
5a93253fc8
Fix -Asserts warning.
...
llvm-svn: 103697
2010-05-13 03:50:50 +00:00
Daniel Dunbar
d83889bd87
MC: Eliminate MCSectionData::{,Address,File}Size, which can now be computed by
...
utility functions.
llvm-svn: 103695
2010-05-13 03:19:50 +00:00
Daniel Dunbar
c7c53ea715
MC: Switch to using explicit MCAlignFragments with OnlyAlignAddress bit instead
...
of manually doing padding/editing layout in LayoutSection().
- This probably seems like six-of-one and half-dozen of another, but there
is a method to my madness.
llvm-svn: 103693
2010-05-13 02:34:14 +00:00
Daniel Dunbar
a6780da661
MC: Add MCAlignFragment::OnlyAlignAddress bit. This is a bit of magic that says the align fragment shouldn't contribute to the logical section size, it is will be used for cleaning up the code to handle section alignment.
...
llvm-svn: 103690
2010-05-13 01:10:26 +00:00
Daniel Dunbar
4dac59dcb7
MC: Add MCSectionData::AddressSize, which is the size of the address space consumed by the section. This can differ from both the section logical size, and the section size on disk (although the current code handles this without making an explicit distinction).
...
llvm-svn: 103689
2010-05-13 01:10:22 +00:00
Daniel Dunbar
b76df22a2e
MC: Move MCAlignFragment::EmitNops value out of the constructor.
...
llvm-svn: 103665
2010-05-12 22:56:23 +00:00
Daniel Dunbar
4405ffc688
MC: Eliminate MCZeroFillFragment, it is no longer needed.
...
llvm-svn: 103664
2010-05-12 22:51:38 +00:00
Daniel Dunbar
7cd309f7dc
MC: Explicitly check that only virtual fragments appear in virtual sections.
...
llvm-svn: 103663
2010-05-12 22:51:35 +00:00
Daniel Dunbar
597eb48168
MC: Switch MCFillFragment to storing total fill size instead of a count. This allows using ValueSize==0 to represent a virtual fill.
...
llvm-svn: 103662
2010-05-12 22:51:32 +00:00
Daniel Dunbar
51402b79e4
MC: Drop support for alignment in ZeroFill fragment, we can just use
...
MCAlignFragments for this.
llvm-svn: 103661
2010-05-12 22:51:27 +00:00
Daniel Dunbar
7d73564b82
Simplify.
...
llvm-svn: 103651
2010-05-12 21:47:55 +00:00
Daniel Dunbar
a7cc32a7b6
MC: Factor out MCAssembler::LayoutFragment
...
llvm-svn: 103649
2010-05-12 21:35:25 +00:00
Daniel Dunbar
2abec791f1
MC: Tweak section layout to not relying on accumulating address value.
...
llvm-svn: 103648
2010-05-12 21:35:22 +00:00
Daniel Dunbar
a11479eb49
MC: Simplify LayoutSection to just take the index of the section to layout.
...
llvm-svn: 103627
2010-05-12 17:56:47 +00:00
Daniel Dunbar
e02c1f6834
MC: Track section layout order explicitly, and use to simplify.
...
llvm-svn: 103616
2010-05-12 15:42:59 +00:00
Daniel Dunbar
ba2f4c3884
MC/Mach-O/x86_64: Add a new hook for checking whether a particular section can
...
be diced into atoms, and adjust getAtom() to take this into account.
- This fixes relocations to symbols in fixed size literal sections, for
example.
llvm-svn: 103532
2010-05-12 00:38:17 +00:00
Daniel Dunbar
3937e28da0
MC/Mach-O x86_64: Switch to using fragment atom symbol.
...
- This eliminates getAtomForAddress() (which was a linear search) and
simplifies getAtom().
- This also fixes some correctness problems where local labels at the same
address as non-local labels could be assigned to the wrong atom.
llvm-svn: 103480
2010-05-11 17:22:50 +00:00
Daniel Dunbar
aadb2cac49
MC/Mach-O: Explicitly track atoms, as represented by their defining symbol, for each fragment (not yet used).
...
llvm-svn: 103438
2010-05-10 22:45:09 +00:00
Daniel Dunbar
ce0c1e11ce
llvm-mc: Fix case were we would skip a line in the .s file after an instruction
...
match failure.
Also, fixes a few memory leak FIXMEs.
llvm-svn: 102986
2010-05-04 00:33:07 +00:00
Chris Lattner
2104b8d36e
rename llvm::llvm_report_error -> llvm::report_fatal_error
...
llvm-svn: 100709
2010-04-07 22:58:41 +00:00
Daniel Dunbar
d821f4ac60
llvm-mc: Add a -mc-relax-all option, which relaxes every fixup. We always need
...
exactly two passes in that case, and don't ever need to recompute any layout,
so this is a nice baseline for relaxation performance.
llvm-svn: 99563
2010-03-25 22:49:09 +00:00
Daniel Dunbar
6432bd744e
MC: Stop restarting layout on every relaxation.
...
- Still O(N^2), just a faster form, and now its the MCAsmLayout's fault.
On the .s I am tuning against (combine.s from 403.gcc):
--
ddunbar@lordcrumb:MC$ diff stats-before.txt stats-after.txt
5,10c5,10
< 1728 assembler - Number of assembler layout and relaxation steps
< 7707 assembler - Number of emitted assembler fragments
< 120588 assembler - Number of emitted object file bytes
< 2233448 assembler - Number of evaluated fixups
< 1727 assembler - Number of relaxed instructions
< 6723845 mcexpr - Number of MCExpr evaluations
---
> 3 assembler - Number of assembler layout and relaxation steps
> 7707 assembler - Number of emitted assembler fragments
> 120588 assembler - Number of emitted object file bytes
> 14796 assembler - Number of evaluated fixups
> 1727 assembler - Number of relaxed instructions
> 67889 mcexpr - Number of MCExpr evaluations
--
Feel free to LOL at the -before numbers, if you like.
I am a little surprised we make more than 2 relaxation passes. It's pretty
trivial for us to do relaxation out-of-order if that would give a speedup.
llvm-svn: 99543
2010-03-25 19:35:56 +00:00
Daniel Dunbar
0ba6a671d4
MC: Simplify main section layout process by moving alignment into LayoutSection.
...
llvm-svn: 99529
2010-03-25 18:16:42 +00:00
Daniel Dunbar
25d114b2b2
MC: Sink Section address assignment into LayoutSection.
...
llvm-svn: 99528
2010-03-25 18:16:38 +00:00
Daniel Dunbar
4108802628
MC: Explicity track section and fragment ordinals.
...
llvm-svn: 99500
2010-03-25 07:10:11 +00:00
Daniel Dunbar
5b07334c0d
MC: Route access to SectionData offset and file size through MCAsmLayout.
...
llvm-svn: 99474
2010-03-25 02:00:07 +00:00
Daniel Dunbar
2522dd1c49
MC: Route access to Fragment offset and effective size through MCAsmLayout.
...
llvm-svn: 99473
2010-03-25 02:00:02 +00:00
Daniel Dunbar
5d98824615
MC: Eliminate MC{Fragment,{Section,Symbol}Data}::getAddress.
...
llvm-svn: 99467
2010-03-25 01:03:24 +00:00
Daniel Dunbar
7c969558d9
MC: Direct all {fragment,section,symbol} address access through the MCAsmLayout object.
...
llvm-svn: 99380
2010-03-24 03:43:40 +00:00
Daniel Dunbar
5376c2a431
MC: Sprinkle in some more interesting statistics.
...
llvm-svn: 99350
2010-03-23 23:47:14 +00:00
Daniel Dunbar
de04b3f62c
MC: Switch to using MCInst fragments to do relaxation.
...
Also, both MCMachOStreamer and MCAssembler are now target independent!
llvm-svn: 99256
2010-03-23 05:09:03 +00:00
Daniel Dunbar
86face8333
MC: Add TargetAsmBackend::MayNeedRelaxation, for checking whether a particular instruction + fixups might need relaxation.
...
llvm-svn: 99249
2010-03-23 03:13:05 +00:00
Daniel Dunbar
a9ae3ae698
MC: Add TargetAsmBackend::WriteNopData and use to eliminate some target dependencies in MCMachOStreamer and MCAssembler.
...
llvm-svn: 99248
2010-03-23 02:36:58 +00:00
Daniel Dunbar
16cbe95dd6
MC: Tweak MCInstFragment to include the encoded data and fixups, so that we don't need to recompute them during relaxation. I will revisit this once all the other pieces of fast relaxation are in place.
...
llvm-svn: 99244
2010-03-23 01:39:05 +00:00
Daniel Dunbar
b31c49a70d
MC: Add MCInstFragment, not used yet.
...
llvm-svn: 99229
2010-03-22 23:16:48 +00:00
Daniel Dunbar
fdc7ccc4e4
MC: Fix a few more cases we were passing an MCDataFragment when a MCFragment would do, and sprinkle in some const.
...
llvm-svn: 99218
2010-03-22 21:49:41 +00:00
Daniel Dunbar
20ea02fde2
Simplify.
...
llvm-svn: 99217
2010-03-22 21:49:38 +00:00
Daniel Dunbar
a0ab4bf989
MC: Change MCObjectWriter::RecordRelocation to take an MCFragment (instead of a MCDataFragment). Object files should only need the generic MCFragment features.
...
llvm-svn: 99205
2010-03-22 20:35:50 +00:00
Daniel Dunbar
9213355a91
MC: Eliminate MCFragment::getMaxFileSize.
...
llvm-svn: 99203
2010-03-22 20:35:43 +00:00
Daniel Dunbar
32ffc58ca9
MC: Share the MCAsmLayout object, although its still not used for anything important.
...
llvm-svn: 99202
2010-03-22 20:35:35 +00:00
Daniel Dunbar
4d7c8645fd
MC: Add TargetAsmBackend::createObjectWriter.
...
- MCAssembler is now object-file independent, although we will surely need more work to fully support ELF/COFF.
llvm-svn: 98955
2010-03-19 10:43:26 +00:00
Daniel Dunbar
eaa367f5ae
MCCodeEmitter: Add target independent fixup flag for is-pc-relative.
...
llvm-svn: 98954
2010-03-19 10:43:23 +00:00
Daniel Dunbar
1bd7171c95
MC: Sink code emitter into MCAssembler.
...
llvm-svn: 98953
2010-03-19 10:43:18 +00:00
Daniel Dunbar
79e0e5a631
MC/Mach-O: Move to MachObjectWriter.{h,cpp}.
...
llvm-svn: 98952
2010-03-19 10:43:15 +00:00
Daniel Dunbar
c5084cccc8
MC: Add TargetAsmBackend::isVirtualSection hook.
...
llvm-svn: 98950
2010-03-19 09:29:03 +00:00
Daniel Dunbar
f027abf7de
MC: Split MCObjectWriter out of MCAssembler.cpp.
...
llvm-svn: 98949
2010-03-19 09:28:59 +00:00
Daniel Dunbar
49e5a8ac2a
MCAssembler: Pull out MCObjectWriter class.
...
llvm-svn: 98948
2010-03-19 09:28:55 +00:00
Daniel Dunbar
f0517efc6c
MCAssembler: Move ApplyFixup to the TargetAsmBackend, this is a target specific not object writer specific task.
...
llvm-svn: 98947
2010-03-19 09:28:12 +00:00
Daniel Dunbar
3cab275783
MC/Mach-O: Lift the fixup evaluation and application up (to the same place), and eliminate MCAsmFixup::FixedValue.
...
llvm-svn: 98944
2010-03-19 07:09:47 +00:00
Daniel Dunbar
d84d196a86
MC/Mach-O: Factor out ExecutePostLayoutBinding, to separate the post-layout changes the object writer may need to make to the assembler from the actual .o writing.
...
llvm-svn: 98943
2010-03-19 07:09:33 +00:00
Daniel Dunbar
563d40eda6
MC/Mach-O: Lift relocation emission logic a bit higher to separate evaluation / relocation handling from the actual .o writing.
...
llvm-svn: 98942
2010-03-19 07:09:18 +00:00
Daniel Dunbar
0f7fbb3d00
MC/Mach-O: Add isScatteredFixupFullyResolved, which implements the correct algorithm (used on x86_64) for determining whether an evaluated fixup is fully resolved (doesn't need relocation).
...
- Test cases will follow, once we have x86_64 relocation support.
llvm-svn: 98926
2010-03-19 03:18:18 +00:00
Daniel Dunbar
6e13bb07fb
MC/Mach-O/x86_64: Add getAtom[ForAddress].
...
- These find the defining symbol which identifies the containing atom for a symbol or address. They are currently very slow, but will be eliminated eventually.
llvm-svn: 98925
2010-03-19 03:18:15 +00:00
Daniel Dunbar
5ec4bdd1b3
MC/Mach-O: Factor out isScatteredFixupFullyResolvedSimple predicate, and fix some corner cases.
...
llvm-svn: 98924
2010-03-19 03:18:12 +00:00
Daniel Dunbar
c558ec211f
MC/Mach-O: Factor out isSymbolLinkerVisible method; "linker visible" is a made up term to refer to non-temporary labels + temporary labels in sections-which-require symbols. For Darwin, it corresponds to symbols which effectively define an atom.
...
llvm-svn: 98923
2010-03-19 03:18:09 +00:00
Daniel Dunbar
9c64ec0a7e
MCValue: Change to holding MCSymbolRefExprs instead of MCSymbols, we will need this for accessing to symbol modifiers.
...
llvm-svn: 98791
2010-03-18 00:59:10 +00:00
Daniel Dunbar
fe8d866fc7
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
232dc953ac
MC/Mach-O: Add MCSectionMachO::getType()
...
llvm-svn: 98582
2010-03-15 21:56:38 +00:00
Daniel Dunbar
7c1f3d8cad
MC/X86_64: Symbol support.
...
llvm-svn: 98456
2010-03-13 22:49:35 +00:00
Daniel Dunbar
56597588f0
MC/Mach-O: Initial x86_64 support.
...
llvm-svn: 98454
2010-03-13 22:10:17 +00:00
Daniel Dunbar
34b8e553ea
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
12f1e32d59
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
Daniel Dunbar
ea9e2f8a15
MC: Factor out MCAssembler::EvaluateFixup, and simplify.
...
llvm-svn: 98381
2010-03-12 21:00:49 +00:00
Daniel Dunbar
64b408b124
MC/Mach-O: Add MCSymbolData::getAddress() utility.
...
llvm-svn: 98266
2010-03-11 18:22:51 +00:00
Daniel Dunbar
5c5228a8f6
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
cf55f96214
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
c5ddbad237
MC: Provide MCAssembler with a TargetAsmBackend.
...
llvm-svn: 98222
2010-03-11 01:34:27 +00:00
Daniel Dunbar
dc765e9f03
MC/Mach-O: Use the MCAssembler symbol map instead of reconstructing.
...
llvm-svn: 98187
2010-03-10 20:58:31 +00:00
Daniel Dunbar
46ed804180
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
Daniel Dunbar
27b984ac85
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
Daniel Dunbar
3dde457b94
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
d49794e703
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
4680000b27
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
cb01210eca
MC/Mach-O: Tweak .dump() formatting.
...
llvm-svn: 98028
2010-03-09 01:12:23 +00:00
Daniel Dunbar
97d64717c4
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
Daniel Dunbar
3a3f472cb4
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
6622fe7873
MC/Mach-O: Fix address compution for zero fill sections.
...
llvm-svn: 97984
2010-03-08 21:10:42 +00:00
Daniel Dunbar
c6ac7940d9
MC/Mach-O: Error out instead of crashing on invalid scattered relocation expressions.
...
llvm-svn: 97983
2010-03-08 21:10:39 +00:00
Kevin Enderby
c26ddccf38
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
Kevin Enderby
e83d74f626
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
1d7179ad63
MC/Mach-O: Update fixup values for change to X86 offsets.
...
llvm-svn: 96532
2010-02-17 23:45:16 +00:00
Duncan Sands
fe562b6598
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
8408c126c1
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
1e2fad3de8
MC/Mach-O: Start emitting fixups/relocations for instructions.
...
llvm-svn: 96095
2010-02-13 09:29:02 +00:00
Daniel Dunbar
3374835b46
MCAssembler: Switch MCAsmFixup to storing MCFixupKind instead of just a size.
...
llvm-svn: 96094
2010-02-13 09:28:54 +00:00
Daniel Dunbar
97867a9cfc
MCAssembler: Sink fixup list into MCDataFragment.
...
llvm-svn: 96093
2010-02-13 09:28:43 +00:00
Daniel Dunbar
056bc60336
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
8e53203154
MCAssembler: Start applying fixups in the data section.
...
llvm-svn: 96090
2010-02-13 09:28:15 +00:00
Daniel Dunbar
bedf1d4a41
MCAssembler: Add assorted dump() methods.
...
llvm-svn: 96089
2010-02-13 09:28:03 +00:00
Daniel Dunbar
1d34759721
MC: Move assembler-backend's fixup list into the fragment.
...
llvm-svn: 95926
2010-02-11 21:29:46 +00:00
Daniel Dunbar
ee82e763e6
MC: Move MCSectionData::Fixup out to MCAsmFixup.
...
llvm-svn: 95925
2010-02-11 21:29:29 +00:00
Daniel Dunbar
9a0a46163d
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
255a8c8b13
MC/Mach-O: Set SOME_INSTRUCTIONS bit for sections.
...
llvm-svn: 95135
2010-02-02 21:44:01 +00:00
Chris Lattner
809ae81ff9
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
Nate Begeman
e945172ba4
Remove this fixme, looking at the linker source, all targets pad to 4 bytes.
...
llvm-svn: 93835
2010-01-19 01:32:44 +00:00
Daniel Dunbar
ad36e8aceb
Pass StringRef by value.
...
llvm-svn: 86251
2009-11-06 10:58:06 +00:00
Daniel Dunbar
e024def785
Minor formatting tweaks.
...
llvm-svn: 84235
2009-10-16 01:58:15 +00:00
Daniel Dunbar
8e6d889d4c
MC: Switch assembler API to using MCExpr instead of MCValue.
...
llvm-svn: 84234
2009-10-16 01:58:03 +00:00
Daniel Dunbar
4fa0595b94
llvm-mc: Store MCSymbolData value as a pointer (to make MSVC happy).
...
llvm-svn: 80652
2009-09-01 04:09:03 +00:00
Daniel Dunbar
945e257e99
llvm-mc: Make MCSymbolData symbol member const.
...
llvm-svn: 80573
2009-08-31 08:08:06 +00:00
Daniel Dunbar
02c7254f6d
llvm-mc: Add MCContext to MCAssembler.
...
llvm-svn: 80572
2009-08-31 08:07:55 +00:00
Daniel Dunbar
2701eee0ad
llvm-mc: Support .comm emission.
...
llvm-svn: 80351
2009-08-28 07:08:35 +00:00
Daniel Dunbar
42a39d038a
llvm-mc: Support .zerofill emission.
...
- I'm still trying to figure out the cleanest way to implement this and match the assembler, currently there are some substantial differences.
llvm-svn: 80347
2009-08-28 05:49:21 +00:00
Daniel Dunbar
a468a12dfa
llvm-mc: Tweak section alignment and size computation to match 'as' closer.
...
llvm-svn: 80345
2009-08-28 05:49:04 +00:00
Daniel Dunbar
93665faad0
llvm-mc: Fix thinko in emitting values.
...
llvm-svn: 80340
2009-08-28 05:48:10 +00:00
Daniel Dunbar
47f11ac5b5
Try to make MSVC just a little happier.
...
llvm-svn: 80187
2009-08-27 00:38:04 +00:00
Daniel Dunbar
e73b267301
llvm-mc/Mach-O: Don't put assembler temporary labels in the symbol table.
...
- I moved section creation back into AsmParser. I think policy decisions like
this should be pushed higher, not lower, when possible (in addition the
assembler has flags which change this behavior, for example).
llvm-svn: 80162
2009-08-26 22:13:22 +00:00
Daniel Dunbar
e2697738a4
llvm-mc/Mach-O: Set .subsections_via_symbols flag properly.
...
llvm-svn: 80144
2009-08-26 21:22:22 +00:00
Daniel Dunbar
c4581eaca8
llvm-mc/Mach-O: Add support for relocations.
...
- I haven't really tried to find the "right" way to store the fixups or apply
them, yet. This works, but isn't particularly elegant or fast.
- Still no evaluation support, so we don't actually ever not turn a fixup into
a relocation entry.
llvm-svn: 80089
2009-08-26 13:58:10 +00:00
Daniel Dunbar
a9eeb78ed5
llvm-mc/Mach-O: Move symbol indices into the MCSymbolData structure.
...
llvm-svn: 80088
2009-08-26 13:57:54 +00:00
Daniel Dunbar
066d0f93bf
llvm-mc/Mach-O: Add section padding where needed (to align the next section).
...
Also, simplify some of Mach-O writer code which can now use section addresses.
llvm-svn: 80067
2009-08-26 04:13:32 +00:00
Daniel Dunbar
aef5317edd
llvm-mc/Mach-O: Set addresses for symbols.
...
llvm-svn: 80065
2009-08-26 02:48:04 +00:00