Commit Graph

126 Commits

Author SHA1 Message Date
Charles Davis bc2daa0f93 Implement emission of all Win64 exception tables. Make the COFF streamer emit
these tables.

llvm-svn: 131833
2011-05-22 04:15:07 +00:00
Charles Davis e636022b4d Don't allow unaligned offsets and sizes in the Win64 EH directives.
Also, fix threshold for 'Big' register saves.

llvm-svn: 131830
2011-05-22 00:56:20 +00:00
Charles Davis 6879634efd Don't allow .seh_handler and .seh_handlerdata directives inside chained
unwind areas.

llvm-svn: 131795
2011-05-21 17:36:25 +00:00
Charles Davis 8e8f59bdfb A handler for a function in the Win64 EH scheme can be both an unwind handler
and an exception handler. Handle that case.

Also, add an 'Emitted' member to the MCWin64EHUnwindInfo struct. It will be
needed later.

llvm-svn: 131791
2011-05-21 15:57:49 +00:00
Charles Davis 54254008ba Set the "LastFrameInst" field when streaming a .seh_setframe directive. This
is needed for an upcoming patch.

llvm-svn: 131772
2011-05-21 00:09:04 +00:00
Charles Davis 24b31b6b7d "Implement" the HandlerData Win64 EH method in the base MCStreamer.
There's really nothing to implement. All this really does is swap to a
pseudo-section that later gets written to the unwind info struct. That
needs to be implemented in the object streamers.

llvm-svn: 131734
2011-05-20 16:06:22 +00:00
Rafael Espindola 1edfb17bc2 Looks like OS X assemblers (including MC) don't like
foo:
bar = foo
.quad bar

Avoid producing it. Fixes PR9951.

llvm-svn: 131687
2011-05-19 22:05:56 +00:00
Rafael Espindola 8e129296fe Misc code refactorings:
* Remove unnecessary arguments now that ForceExpAbs is a method.
* Use ForceExpAbs in EmitAbsValue.

llvm-svn: 131683
2011-05-19 21:40:34 +00:00
Charles Davis de745ba396 Implement the EndProlog Win64 EH method on the base MCStreamer.
llvm-svn: 131679
2011-05-19 21:24:54 +00:00
Charles Davis 7e6e8951af Implement the Win64 EH prolog instruction methods on the base MCStreamer.
I had to change the API slightly to avoid overloading issues.

llvm-svn: 131666
2011-05-19 19:35:55 +00:00
Charles Davis 4cd8856704 Turns out GAS does have Win64 EH directives. (It also supports WinCE EH.) Make
ours compatible with GAS.

In retrospect, I should have emailed binutils about this earlier. Thanks to
Kai Tietz for pointing out that GAS already had SEH directives.

llvm-svn: 131652
2011-05-19 17:46:39 +00:00
Charles Davis b4222589bf Implement the StartChained and EndChained Win64 EH methods on MCStreamer.
llvm-svn: 131629
2011-05-19 04:04:13 +00:00
Charles Davis d991ec4e68 Implement the StartProc and EndProc Win64 EH methods on the base MCStreamer.
Based largely on Rafael Espindola's work on CFI. Other methods soon to follow.

llvm-svn: 131623
2011-05-19 02:49:00 +00:00
Charles Davis 77e0610d7c Add some more Win64 EH directives:
- StartChained and EndChained delimit a chained unwind area, which can contain
  additional operations to be undone if an exception occurs inside of it.
- UnwindOnly declares that this function doesn't handle any exceptions. If it
  has a handler, it's an unwind handler instead of an exception handler.
- Lsda declares the location and size of the LSDA, which in the Win64 EH
  scheme is kept inside the UNWIND_INFO struct. Windows itself ignores the
  LSDA; it's used by the Language-Specific Handler (the "Personality Function"
  from DWARF).

llvm-svn: 131572
2011-05-18 20:54:10 +00:00
Charles Davis 384041d0dc While thinking about how to know where the functions' boundaries are for
the purposes of the Win64 EH tables, I realized we had no way to tell where
the function ends. (MASM bounds functions with PROC and ENDP keywords.)
Add a directive to delimit the end of the function, and rename the 'frame'
directive to more accurately reflect its duality with the new directive.

llvm-svn: 131522
2011-05-18 04:47:22 +00:00
Charles Davis 2701815ed8 Add a method I forgot in the last commit. Don't worry, this one passed
self-host :).

llvm-svn: 131421
2011-05-16 21:13:58 +00:00
Charles Davis 2f10078ae7 Fix copy-pasto.
llvm-svn: 131384
2011-05-15 17:28:27 +00:00
Charles Davis af18d07ed6 Add stub methods to MCStreamer for emitting Win64 exception-handling
information.

llvm-svn: 131382
2011-05-15 17:20:01 +00:00
Rafael Espindola ec53aa9485 Add CFIStartSections to the asm printer. Add an assert that at least
one of the sections is created.

llvm-svn: 131124
2011-05-10 13:39:48 +00:00
Rafael Espindola 1ecb12fc57 Add support for producing .deubg_frame sections.
llvm-svn: 131121
2011-05-10 03:54:12 +00:00
Rafael Espindola b6089d6cac Factor some code into a new EmitFrames method.
llvm-svn: 131119
2011-05-10 03:14:15 +00:00
Rafael Espindola 74b101f3e3 Parsing and plumbing for .cfi_sections.
llvm-svn: 131117
2011-05-10 01:10:18 +00:00
Rafael Espindola fd05785324 Simplify the handling of pcrel relocations on ELF. Now we do the right thing
for all symbol differences and can drop the old EmitPCRelSymbolValue
method.

This also make getExprForFDESymbol on ELF equal to the one on MachO, and it
can be made non-virtual.

llvm-svn: 130634
2011-05-01 03:50:49 +00:00
Rafael Espindola 1d1eced025 Implement MCAsmStreamer::EmitDwarfAdvanceFrameAddr.
llvm-svn: 130585
2011-04-30 03:21:04 +00:00
Rafael Espindola 349c3298da Mark the EH symbol global or weak if the corresponding function is.
llvm-svn: 130397
2011-04-28 12:50:37 +00:00
Rafael Espindola 27c0c9bb87 Factor a bit of code to MCStreamer::EmitLabel. Keep track of the last
non private symbol. This will be use for handling

foo:
  .cfi_startproc
  ...

On OS X where we have to create a foo.eh symbol.

llvm-svn: 130305
2011-04-27 15:21:19 +00:00
Devang Patel 17740e70d5 Reduce clutter in asm output. Do not emit source location as comment for each instruction.
llvm-svn: 129715
2011-04-18 20:26:49 +00:00
Rafael Espindola 539d96f01d Be consistent about being virtual and returning void in the cfi methods.
Implement the ones that were missing in the asm streamer.

llvm-svn: 129413
2011-04-12 23:59:07 +00:00
Rafael Espindola fd794affe5 Remove LastOffset from the asm parser.
llvm-svn: 129378
2011-04-12 18:53:30 +00:00
Rafael Espindola 1ec0f46169 Fix the case of a .cfi_rel_offset before any .cfi_def_cfa_offset.
llvm-svn: 129362
2011-04-12 16:12:03 +00:00
Rafael Espindola 2e1c9d2188 Implement .cfi_same_value.
llvm-svn: 129361
2011-04-12 15:31:05 +00:00
Anton Korobeynikov e7410dd0d5 Preliminary support for ARM frame save directives emission via MI flags.
This is just very first approximation how the stuff should be done
(e.g. ARM-only for now). More to follow.

llvm-svn: 127101
2011-03-05 18:43:32 +00:00
Anton Korobeynikov a7ec2dcefd Some first rudimentary support for ARM EHABI: print exception table in "text mode".
llvm-svn: 127099
2011-03-05 18:43:15 +00:00
Joerg Sonnenberger eef2f9009d Use a vector of pairs to implement the section stack, not two
independent vectors.

llvm-svn: 126099
2011-02-21 01:07:42 +00:00
Rafael Espindola 58ac6e1677 Add support for pushsection and popsection. Patch by Joerg Sonnenberger.
llvm-svn: 125629
2011-02-16 01:08:29 +00:00
Rafael Espindola 2ae93b2c9c Remove second return.
llvm-svn: 122616
2010-12-29 02:42:33 +00:00
Rafael Espindola 290d71671e Implement cfi_def_cfa. Also don't convert to dwarf reg numbers twice. Looks
like 6 is a fixed point of that and so the previous tests were OK :-)

llvm-svn: 122614
2010-12-29 01:42:56 +00:00
Rafael Espindola 426e68f793 Implement cfi_def_cfa_register.
llvm-svn: 122612
2010-12-29 00:26:06 +00:00
Rafael Espindola 86d347dd31 Initial .cfi_offset implementation.
llvm-svn: 122611
2010-12-29 00:09:59 +00:00
Rafael Espindola 85d91982ca Implement .cfi_remember_state and .cfi_restore_state.
llvm-svn: 122602
2010-12-28 18:36:23 +00:00
Rafael Espindola a75b87b55a Start adding basic support for emitting the call frame instructions.
llvm-svn: 122590
2010-12-28 04:15:37 +00:00
Rafael Espindola 1de2dd0e5e Add support for .cfi_lsda.
llvm-svn: 122584
2010-12-27 15:56:22 +00:00
Rafael Espindola 2ac8355ecd Add support for the same encodings of the personality function that gnu as
supports.

llvm-svn: 122577
2010-12-27 00:36:05 +00:00
Rafael Espindola a6cd2d821a Rename NeedsSetToChangeDiffSize to HasAggressiveSymbolFolding which is a much
better name and matches what is used in the MachO writer.

llvm-svn: 122443
2010-12-22 21:51:29 +00:00
Matt Beaumont-Gay f991d4f587 Better fix for opt build
llvm-svn: 121910
2010-12-15 23:14:45 +00:00
Matt Beaumont-Gay 15f96baa01 Fix opt -Werror build
llvm-svn: 121904
2010-12-15 22:21:20 +00:00
Rafael Espindola f80f18a11a Generalize an assert.
llvm-svn: 121851
2010-12-15 07:12:24 +00:00
Rafael Espindola 0a017a6db2 Fixed version of 121434 with no new memory leaks.
llvm-svn: 121471
2010-12-10 07:39:47 +00:00
Rafael Espindola a945a34c73 Revert my previous patch to make the valgrind bots happy.
llvm-svn: 121461
2010-12-10 04:01:09 +00:00
Rafael Espindola 56eb741237 Initial support for the cfi directives. This is just enough to get
f:
        .cfi_startproc
        nop
        .cfi_endproc

assembled (on ELF).

llvm-svn: 121434
2010-12-09 23:48:29 +00:00
Devang Patel 3ebe3defe3 Add assert to catch an attempt to emit .byte 256
llvm-svn: 121402
2010-12-09 19:26:21 +00:00
Rafael Espindola 44bbe36de6 Second try at making direct object emission produce the same results
as llc + llvm-mc. This time ELF is not changed and I tested that llvm-gcc
bootstrap on darwin10 using darwin9's assembler and linker.

llvm-svn: 121006
2010-12-06 17:27:56 +00:00
Rafael Espindola dee3062373 Revert previous two patches while I try to find out how to make both
linux and darwin assemblers happy :-(

llvm-svn: 121004
2010-12-06 15:35:15 +00:00
Rafael Espindola 34a06a0802 Add an EmitAbsValue helper method and use it in cases where we want to be sure
that no relocations are used (on MochO).
Fixes llc producing different output from llc + llvm-mc.

llvm-svn: 121000
2010-12-06 14:53:14 +00:00
Rafael Espindola 4c70eeaf33 Make EmitIntValue more efficient and more like what we do for leb128. The
difference is much smaller (about 0.3s) but significant.

llvm-svn: 120787
2010-12-03 02:54:21 +00:00
Rafael Espindola 675fbb2ad1 Do with uleb the same trick we now do with dwarf line/address advances. This
avoids creating leb128 fragments and speeds up the test in PR8711 to 33s.

llvm-svn: 120774
2010-12-03 01:19:49 +00:00
Rafael Espindola 57ab708bdd Try to resolve symbol differences early, and if successful create a plain
data fragment. This reduces the time to assemble the test in 8711 from 60s to
54s.

llvm-svn: 120767
2010-12-03 00:55:40 +00:00
Rafael Espindola b746531c2c Avoid code duplication in the many unsupported EmitGPRel32Value implementations.
llvm-svn: 120243
2010-11-28 15:09:24 +00:00
Rafael Espindola 3c227b0b89 Add basic CFI methods to the streamer interface.
llvm-svn: 119972
2010-11-22 14:27:24 +00:00
Rafael Espindola c653a895c8 Add .loc methods to the streamer.
Next: Add support for the !HasDotLocAndDotFile case to the MCAsmStreamer
and then switch codegen to use it.

llvm-svn: 119384
2010-11-16 21:20:32 +00:00
Rafael Espindola 5e874982f2 Add support for expressions in .sleb/.uleb directives.
llvm-svn: 118023
2010-11-02 17:22:24 +00:00
Rafael Espindola 1614597873 Implement .weakref.
llvm-svn: 117911
2010-11-01 14:28:48 +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
Benjamin Kramer e39017cb97 Add AsmParser support for the ELF .previous directive. Patch by Roman Divacky.
llvm-svn: 112849
2010-09-02 18:53:37 +00:00
Michael J. Spencer 2ed9f4bd39 _[A-Z] identifiers are reserved for the implementation.
llvm-svn: 108682
2010-07-19 06:26:19 +00:00
Matt Fleming 141791c6d1 Grammar fix. This is a test commit.
llvm-svn: 104264
2010-05-20 19:45:09 +00:00
Chris Lattner 1716721df1 add a twine form of MCStreamer::EmitRawText, and mc'ize
a few more things in AsmPrinter.cpp.

llvm-svn: 100294
2010-04-03 22:12:35 +00:00
Chris Lattner 6ec72d2e8f add <cstdlib> header for abort() on linux builders.
llvm-svn: 100290
2010-04-03 21:48:59 +00:00
Chris Lattner 8a87fb7633 add a new EmitInlineAsm function to asmprinter to handle inline asm.
If we have an MCAsmStreamer, we continue to emit asm textually, 
otherwise we (currently) emit an error to errs and ignore it.

llvm-svn: 100289
2010-04-03 21:35:55 +00:00
Chris Lattner b14490d912 add a EmitSymbolValue convenience method to MCStreamer.
llvm-svn: 98017
2010-03-09 00:39:24 +00:00
Chris Lattner 8fa0e35f97 add a new MCAsmStreamer::GetCommentOS method to simplify stuff
that doesn't want to use twines.

llvm-svn: 94199
2010-01-22 19:17:48 +00:00
Chris Lattner dc50e5d128 add a new EmitIntValue method that MCStreamer impls can optionally define
and that clients can use.

llvm-svn: 93923
2010-01-19 22:03:38 +00:00
Chris Lattner c35681b298 Generalize mcasmstreamer data emission APIs to take an address space
identifier.  There is no way to work around it.

llvm-svn: 93896
2010-01-19 19:46:13 +00:00
Chris Lattner 0c65fd4902 add a "MCStreamer::EmitFill" method, and move the default implementation
(which just iteratively emits bytes) to MCStreamer.

llvm-svn: 93888
2010-01-19 18:45:47 +00:00
Chris Lattner 0adae25ec1 Make AsmStreamer maintain a notion of the current section, pushing it up from the
MCAsmStreamer.  Based on this, eliminate the current section from AsmPrinter.

While I'm at it, clean up the last of the horrible "switch to null section" stuff
and add an assert.  This change is in preparation for completely eliminating 
asmprinter::switchtosection.

llvm-svn: 79324
2009-08-18 06:15:16 +00:00
Daniel Dunbar 9faf273fc4 Start MCAsmStreamer implementation.
llvm-svn: 74044
2009-06-24 01:03:06 +00:00