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

1595 Commits

Author SHA1 Message Date
Jim Grosbach
2f728674cf Move some ELF directives into ELF asm parser.
The .local, .hidden, .internal, and .protected are not legal for all supported
file formats (in particular, they're invalid for MachO). Move the parsing for
them into the ELF assembly parser since that's the format they're for.
Similarly, .weak is used by COFF and ELF, but not MachO, so move the parsing
to the COFF and ELF asm parsers. Previously, using any of these directives
on Darwin would result in an assertion failure in the parser; now we get
a diagnostic as we should.

rdar://9827089

llvm-svn: 135921
2011-07-25 17:55:35 +00:00
Jim Grosbach
feb91f5361 Tidy up. 80 columns.
llvm-svn: 135917
2011-07-25 17:11:29 +00:00
Evan Cheng
13d54fc7c9 Move TargetAsmParser.h TargetAsmBackend.h and TargetAsmLexer.h to MC where they belong.
llvm-svn: 135833
2011-07-23 00:45:41 +00:00
Evan Cheng
41aa34c417 Sink ARM mc routines into MCTargetDesc.
llvm-svn: 135825
2011-07-23 00:00:19 +00:00
Evan Cheng
7b4cb12a95 Combine all MC initialization routines into one. e.g. InitializeX86MCAsmInfo,
InitializeX86MCInstrInfo, etc. are combined into InitializeX86TargetMC.

llvm-svn: 135812
2011-07-22 21:58:54 +00:00
Bill Wendling
d319d42aea Emit the __compact_unwind section first. If there are any frames which weren't
emitted, emit them next as CIE/FDEs.

llvm-svn: 135807
2011-07-22 21:18:59 +00:00
Evan Cheng
882618fe7d X86 is the only target that uses coff format. This should fixes test failures running on Windows, Cygwin, or MingW hosts.
llvm-svn: 135639
2011-07-20 23:53:54 +00:00
Evan Cheng
c9bc5a9011 Goodbye TargetAsmInfo. This eliminate last bit of CodeGen and Target in llvm-mc.
There is still a bit more refactoring left to do in Targets. But we are now very
close to fixing all the layering issues in MC.

llvm-svn: 135611
2011-07-20 19:50:42 +00:00
Benjamin Kramer
7636a9969a Initialize the EHFrameSection pointer to zero.
This should fix the spurious buildbot errors.

llvm-svn: 135594
2011-07-20 18:13:23 +00:00
Evan Cheng
55d7fcc5f7 - Move CodeModel from a TargetMachine global option to MCCodeGenInfo.
- Introduce JITDefault code model. This tells targets to set different default
  code model for JIT. This eliminates the ugly hack in TargetMachine where
  code model is changed after construction.

llvm-svn: 135580
2011-07-20 07:51:56 +00:00
Evan Cheng
abb07a0c9d Include MCRegisterInfo to eliminate a compilation warning.
llvm-svn: 135575
2011-07-20 06:54:19 +00:00
Francois Pichet
74e35bf8ec Fix the CMake build.
llvm-svn: 135573
2011-07-20 06:35:24 +00:00
Evan Cheng
380dc98371 Add MCObjectFileInfo and sink the MCSections initialization code from
TargetLoweringObjectFileImpl down to MCObjectFileInfo.

TargetAsmInfo is done to one last method. It's *almost* gone!

llvm-svn: 135569
2011-07-20 05:58:47 +00:00
Evan Cheng
bfc0cac54d Introduce MCCodeGenInfo, which keeps information that can affect codegen
(including compilation, assembly). Move relocation model Reloc::Model from
TargetMachine to MCCodeGenInfo so it's accessible even without TargetMachine.

llvm-svn: 135468
2011-07-19 06:37:02 +00:00
Bill Wendling
cd5cb5b44e Micro-opt: Only emit compact unwind if there is a compact unwind encoding to emit.
llvm-svn: 135452
2011-07-19 00:09:25 +00:00
Bill Wendling
8dd021da20 Use the CompactUnwindEncoding from the Frame, if it's defined.
llvm-svn: 135451
2011-07-19 00:06:12 +00:00
Bill Wendling
6211e2602f Add a method to set compact unwind encoding information in a frame.
llvm-svn: 135449
2011-07-19 00:01:42 +00:00
Sean Callanan
b5cc61ce9a Fixed a bug where the MC subtarget information
wasn't being initialized by the enhanced disassembler,
leading to assertion failures. 

llvm-svn: 135447
2011-07-19 00:00:41 +00:00
Evan Cheng
10c6820ff4 Move getInitialFrameState from TargetFrameInfo to MCAsmInfo (suggestions for
better location welcome).

llvm-svn: 135438
2011-07-18 22:29:13 +00:00
Evan Cheng
561d71ce7b Sink getDwarfRegNum, getLLVMRegNum, getSEHRegNum from TargetRegisterInfo down
to MCRegisterInfo. Also initialize the mapping at construction time.

This patch eliminate TargetRegisterInfo from TargetAsmInfo. It's another step
towards fixing the layering violation.

llvm-svn: 135424
2011-07-18 20:57:22 +00:00
Evan Cheng
1ae06d95e0 Move some parts of TargetAsmInfo down to MCAsmInfo. This is not the greatest
solution but it is a small step towards removing the horror that is
TargetAsmInfo.

llvm-svn: 135237
2011-07-15 02:09:41 +00:00
Bill Wendling
953f7ddcc2 Remove setting the bit for personality function. It should be set by the linker.
llvm-svn: 135236
2011-07-15 01:42:32 +00:00
Bill Wendling
6d36444dc5 Encode that we have a personality function.
llvm-svn: 135227
2011-07-15 00:07:31 +00:00
Evan Cheng
9e8f90a020 Rename createAsmInfo to createMCAsmInfo and move registration code to MCTargetDesc to prepare for next round of changes.
llvm-svn: 135219
2011-07-14 23:50:31 +00:00
Bill Wendling
fb25bf95c9 * If we have an LSDA, we need to mark it in the encoding.
* The personality function should be encoded as an absolute pointer to the function.

llvm-svn: 135215
2011-07-14 23:34:45 +00:00
Evan Cheng
3d2be55d6c Unfortunately several files in MC are badly violating layering rule by using
TargetAsmInfo, which in turn pulls in TargetRegisterInfo, etc. :-( There are
other cases of violations, but this is probably the worst.

This patch is but one small step towards fixing this. 500 more steps to go. :-(

llvm-svn: 135131
2011-07-14 05:43:07 +00:00
Jim Grosbach
e0fc4019f9 Update MCParsedAsmOperand debug methods.
Update the debug output interface for MCParsedAsmOperand to have a print()
method which takes an output stream argument, an << operator which invokes
the print method using the given stream, and a dump() method which prints
the operand to the dbgs() stream. This makes the interface more consistent
with the rest of LLVM, and more convenient to use at the debugger command
line.

llvm-svn: 135043
2011-07-13 15:34:57 +00:00
Bill Wendling
e6de1eeb86 Don't emit the FDE end label if the last thing emitted was a compact unwind and
not the FDE

llvm-svn: 135020
2011-07-13 00:49:09 +00:00
Shantonu Sen
004cce78e1 Resynchronize EDInfo.h and EDEmitter.cpp.
The enum names as well as order (i.e. value)
had skewed, which means that consumers of the
tablegen-ed table would see different values than
intended. Make both files have a superset of enums,
and add classification as needed for numMCOperands.

Reviewed by Owen Anderson

llvm-svn: 134905
2011-07-11 17:57:30 +00:00
Evan Cheng
1346a63a0f - Eliminate MCCodeEmitter's dependency on TargetMachine. It now uses MCInstrInfo
and MCSubtargetInfo.
- Added methods to update subtarget features (used when targets automatically
  detect subtarget features or switch modes).
- Teach X86Subtarget to update MCSubtargetInfo features bits since the
  MCSubtargetInfo layer can be shared with other modules.
- These fixes .code 16 / .code 32 support since mode switch is updated in
  MCSubtargetInfo so MC code emitter can do the right thing.

llvm-svn: 134884
2011-07-11 03:57:24 +00:00
Evan Cheng
c9e252df68 Change createAsmParser to take a MCSubtargetInfo instead of triple,
CPU, and feature string. Parsing some asm directives can change
subtarget state (e.g. .code 16) and it must be reflected in other
modules (e.g. MCCodeEmitter). That is, the MCSubtargetInfo instance
must be shared.

llvm-svn: 134795
2011-07-09 05:47:46 +00:00
Evan Cheng
c7842ef950 Fix comment.
llvm-svn: 134763
2011-07-08 22:49:42 +00:00
Evan Cheng
34f67f2dda TargetAsmParser doesn't need reference to Target.
llvm-svn: 134721
2011-07-08 19:33:14 +00:00
Evan Cheng
50f2d8d304 Eliminate asm parser's dependency on TargetMachine:
- Each target asm parser now creates its own MCSubtatgetInfo (if needed).
- Changed AssemblerPredicate to take subtarget features which tablegen uses
  to generate asm matcher subtarget feature queries. e.g.
  "ModeThumb,FeatureThumb2" is translated to
  "(Bits & ModeThumb) != 0 && (Bits & FeatureThumb2) != 0".

llvm-svn: 134678
2011-07-08 01:53:10 +00:00
Akira Hatanaka
b4c145253b This patch adds a flag in MCAsmInfo that indicates whether dwarf register
numbers should be printed instead of symbolic register names in
MCAsmStreamer::EmitRegisterName. This is necessary because some versions of
GNU assembler won't accept code in which symbolic register names are used in
cfi directives. There is no change in behavior unless the flag is explicitly
set to true by a backend.

llvm-svn: 134635
2011-07-07 20:30:33 +00:00
Evan Cheng
18acf2200c Compute feature bits at time of MCSubtargetInfo initialization.
llvm-svn: 134606
2011-07-07 07:07:08 +00:00
Bill Wendling
ba39846c2b Add a target hook to encode the compact unwind information.
llvm-svn: 134577
2011-07-07 00:54:13 +00:00
Bill Wendling
fd3f4e7040 Clean up the #includes.
llvm-svn: 134557
2011-07-06 22:52:32 +00:00
Evan Cheng
dcd3ea7062 createMCInstPrinter doesn't need TargetMachine anymore.
llvm-svn: 134525
2011-07-06 19:45:42 +00:00
Evan Cheng
09210c224a Add getFeatureBits to extract feature bits for a given CPU.
llvm-svn: 134298
2011-07-02 00:43:44 +00:00
Evan Cheng
771cdf9b5d - Added MCSubtargetInfo to capture subtarget features and scheduling
itineraries.
- Refactor TargetSubtarget to be based on MCSubtargetInfo.
- Change tablegen generated subtarget info to initialize MCSubtargetInfo
  and hide more details from targets.

llvm-svn: 134257
2011-07-01 20:45:01 +00:00
Evan Cheng
a4b2c3d5ba Eliminate one extra conversion.
llvm-svn: 134240
2011-07-01 16:59:30 +00:00
Francois Pichet
f143a222d0 Another misuse of StringRef. MSVC is very sensitive to that kind of error.
llvm-svn: 134236
2011-07-01 09:23:41 +00:00
Rafael Espindola
018ca8fea8 Fix use after free.
llvm-svn: 134234
2011-07-01 04:40:50 +00:00
Evan Cheng
1fa6460e3f Switch SubtargetFeatures from std::string to StringRef.
llvm-svn: 134219
2011-07-01 00:23:10 +00:00
Bill Wendling
770794cc60 Remove tabs.
llvm-svn: 134212
2011-06-30 23:59:38 +00:00
Bill Wendling
995ebcfd4c Improve comment: Show the register the DWARF label is added to.
llvm-svn: 134209
2011-06-30 23:47:40 +00:00
Bill Wendling
80c39ac9a5 Add one more comment to the FDE verbose asm output.
llvm-svn: 134200
2011-06-30 22:35:49 +00:00
Bill Wendling
834cb876e6 Add comments to the FDE.
llvm-svn: 134196
2011-06-30 22:02:20 +00:00
Bill Wendling
eace9970bd Add more comments to the ASM output for the CIE's "moves".
llvm-svn: 134194
2011-06-30 21:45:12 +00:00
Bill Wendling
7a94c43c7a Add comments to the ASM output to help understand the compact unwind and CIE tables.
llvm-svn: 134191
2011-06-30 21:25:51 +00:00
Evan Cheng
034261674b Fix the ridiculous SubtargetFeatures API where it implicitly expects CPU name to
be the first encoded as the first feature. It then uses the CPU name to look up
features / scheduling itineray even though clients know full well the CPU name
being used to query these properties.

The fix is to just have the clients explictly pass the CPU name!

llvm-svn: 134127
2011-06-30 01:53:36 +00:00
Bill Wendling
3080b09d31 * Use the proper size to output the range size.
* Rough in the compact encoding part.

llvm-svn: 134119
2011-06-30 00:30:52 +00:00
Bill Wendling
5a7a3562e0 Stupid error: If the LSDA and Personality functions aren't there, emit 0 instead
of the encoding.

llvm-svn: 134117
2011-06-29 23:53:16 +00:00
Bill Wendling
d394aea75e We don't want to use relocations inside the compact unwind section. Just use the
symbols instead.

llvm-svn: 134115
2011-06-29 23:49:12 +00:00
Jim Grosbach
88387d64d6 Asm parser range checking on .<size> <value> directives.
For example, ".byte 256" would previously assert() when emitting an object
file. Now it generates a diagnostic that the literal value is out of range.

rdar://9686950

llvm-svn: 134069
2011-06-29 16:05:14 +00:00
NAKAMURA Takumi
63570a1cf3 Fix CMake build.
llvm-svn: 134055
2011-06-29 03:26:17 +00:00
Evan Cheng
b4dc8bdd22 Sink SubtargetFeature and TargetInstrItineraries (renamed MCInstrItineraries) into MC.
llvm-svn: 134049
2011-06-29 01:14:12 +00:00
Jim Grosbach
440526a1e8 Refactor MachO relocation generaration into the Target directories.
Move the target-specific RecordRelocation logic out of the generic MC
MachObjectWriter and into the target-specific object writers. This allows
nuking quite a bit of target knowledge from the supposedly target-independent
bits in lib/MC.

llvm-svn: 133844
2011-06-24 23:44:37 +00:00
Jim Grosbach
c3b24db27e tidy up whitespace.
llvm-svn: 133815
2011-06-24 19:43:27 +00:00
Jim Grosbach
4ba3d51f23 Fixup info for Thumb2 unconditional branch.
rdar://9667872

llvm-svn: 133808
2011-06-24 18:48:32 +00:00
Jim Grosbach
e216f0411d Tidy up.
llvm-svn: 133770
2011-06-23 22:29:00 +00:00
Jay Foad
75b709336d Reinstate r133513 (reverted in r133700) with an additional fix for a
-Wshorten-64-to-32 warning in Instructions.h.

llvm-svn: 133708
2011-06-23 09:09:15 +00:00
Bill Wendling
4d12748388 Use a reference. Don't make a useless copy of the vector.
llvm-svn: 133707
2011-06-23 07:55:41 +00:00
Bill Wendling
e7fc1a8d9e Formatting changes. No functionality change.
llvm-svn: 133706
2011-06-23 07:44:54 +00:00
Eric Christopher
d38d7f3300 Revert r133513:
"Reinstate r133435 and r133449 (reverted in r133499) now that the clang
self-hosted build failure has been fixed (r133512)."

Due to some additional warnings.

llvm-svn: 133700
2011-06-23 06:24:52 +00:00
Bill Wendling
42866c8944 Use the presence of the __compact_unwind section to indicate that a target
supports compact unwind info instead of having a separate flag indicating this.

llvm-svn: 133685
2011-06-23 05:13:28 +00:00
Bill Wendling
538dc8cc6f Some skeleton code to emit the compact unwind. If the information is unable to
be emitted in a compact way, we then default to emitting a CIE and FDE.

llvm-svn: 133676
2011-06-23 01:06:23 +00:00
Bill Wendling
c62a961c09 80-column violations.
llvm-svn: 133668
2011-06-23 00:09:43 +00:00
Bill Wendling
19f2f807eb Move class methods out-of-line. This reduces the indentation, and is more in
line with LLVM's general coding style.
No functionality change.

llvm-svn: 133645
2011-06-22 21:07:27 +00:00
Bill Wendling
c04086de5c Remove the subclassing. This will be moved to the ASM printer.
llvm-svn: 133473
2011-06-20 22:12:24 +00:00
Benjamin Kramer
1525b80eef Directly print to a raw_ostream instead of printing to a buffer first.
llvm-svn: 133352
2011-06-18 14:42:47 +00:00
Hans Wennborg
6229bbd9c0 MC: Allow .common as alias for .comm assembler directive. PR10116.
llvm-svn: 133349
2011-06-18 13:51:54 +00:00
Bill Wendling
265a3f9032 * Override the "EmitBytes" function, since it can sneak values in that way.
* Make this used only if CFI is used.

llvm-svn: 133319
2011-06-18 00:19:35 +00:00
Bill Wendling
83d5b74f00 Remove false assertion.
llvm-svn: 133314
2011-06-17 23:42:01 +00:00
Bill Wendling
918a35a41b Disable for another investigation.
llvm-svn: 133299
2011-06-17 21:44:15 +00:00
Bill Wendling
be4fd10d84 Support only DwarfCFI or SjLj exception handling in LSDA decoder.
llvm-svn: 133297
2011-06-17 21:31:43 +00:00
Bill Wendling
530eece33e SjLj exception handling LSDA decoding support wasn't represented correctly. Use
the correct values, etc. In particular, the exception handling type is SjLj, not
ARM.

llvm-svn: 133296
2011-06-17 21:29:06 +00:00
Bill Wendling
a31de72e6a Disable to investigate ARM failure.
llvm-svn: 133293
2011-06-17 21:09:50 +00:00
Bill Wendling
1d4e48661b Use the verbose asm flag instead of a new flag for decoding the LSDA.
llvm-svn: 133292
2011-06-17 20:55:01 +00:00
Bill Wendling
88bb5d74ab Add an option that allows one to "decode" the LSDA.
The LSDA is a bit difficult for the non-initiated to read. Even with comments,
it's not always clear what's going on. This wraps the ASM streamer in a class
that retains the LSDA and then emits a human-readable description of what's
going on in it.

So instead of having to make sense of:

Lexception1:
        .byte   255
        .byte   155
        .byte   168
        .space  1
        .byte   3
        .byte   26
Lset0 = Ltmp7-Leh_func_begin1
      .long     Lset0
Lset1 = Ltmp812-Ltmp7
      .long     Lset1
Lset2 = Ltmp913-Leh_func_begin1
      .long     Lset2
      .byte     3
Lset3 = Ltmp812-Leh_func_begin1
      .long     Lset3
Lset4 = Leh_func_end1-Ltmp812
      .long     Lset4
      .long     0
      .byte     0
      .byte     1
      .byte     0
      .byte     2
      .byte     125
      .long     __ZTIi@GOTPCREL+4
      .long     __ZTIPKc@GOTPCREL+4

you can read this instead:

## Exception Handling Table: Lexception1
##  @LPStart Encoding: omit
##    @TType Encoding: indirect pcrel sdata4
##        @TType Base: 40 bytes
## @CallSite Encoding: udata4
## @Action Table Size: 26 bytes

## Action 1:
##   A throw between Ltmp7 and Ltmp812 jumps to Ltmp913 on an exception.
##     For type(s):  __ZTIi@GOTPCREL+4 __ZTIPKc@GOTPCREL+4
## Action 2:
##   A throw between Ltmp812 and Leh_func_end1 does not have a landing pad.

llvm-svn: 133286
2011-06-17 20:35:21 +00:00
Benjamin Kramer
28b93c078a Remove a useless copy of MCELFStreamer. Patch by Logan Chien!
llvm-svn: 133272
2011-06-17 18:05:30 +00:00
Jim Grosbach
2ec534dffe Diagnostic for undefined assembler local symbols.
Re-apply 133010, with fixes for inline assembler.

Original commit message:
"When an assembler local symbol is used but not defined in a module, a
Darwin assembler wants to issue a diagnostic to that effect."

Added fix to only perform the check when finalizing, as otherwise we're not
done and undefined symbols may simply not have been encountered yet.

Passes "make check" and a self-host check on Darwin.

llvm-svn: 133071
2011-06-15 18:33:28 +00:00
Jim Grosbach
e5f4cecf01 Revert 133010. Self-hosted buildbot unhappy.
Apparently llvm itself generates undefined assembler local labels, causing
self-hosting problems with this patch. Reverting until that's sorted out.

llvm-svn: 133013
2011-06-14 21:51:20 +00:00
Jim Grosbach
596a1b7d98 Diagnostic for undefined assembler local symbols.
When an assembler local symbol is used but not defined in a module, a
Darwin assembler wants to issue a diagnostic to that effect.

rdar://9559714

llvm-svn: 133010
2011-06-14 21:13:25 +00:00
Roman Divacky
9b1aea9b45 Fix emission of PPC64 assembler on non-darwin platforms by splitting
VK_PPC_{HA,LO}16 into darwin and gas variants.

Darwin wants {ha,lo}16(symbol) while gnu as wants symbol@{ha,l}.

llvm-svn: 132802
2011-06-09 20:25:38 +00:00
Jason W Kim
a5b62f4fc7 Remove an uneeded switch - Turns out reloc results are identical w/o the switch. (face+palm)
llvm-svn: 132790
2011-06-09 19:13:45 +00:00
Roman Divacky
0a62f9906f Make EmitIntValue() work properly on big-endian targets.
llvm-svn: 132715
2011-06-07 17:31:02 +00:00
Rafael Espindola
f500121fcf Basic support for macros with explicit arguments.
We still don't handle

* default values
* :req
* :vararg
* \()

llvm-svn: 132656
2011-06-05 02:43:45 +00:00
Rafael Espindola
358f2ee1d2 Produce an undefined reference to _GLOBAL_OFFSET_TABLE_ if we have a
VK_GOTOFF reloc. This matches as' behavior, but it is not clear why the linker
might need this, so I added a FIXME.

I could test this by duplicating test/MC/ELF/got.s, but it doesn't look
worthwhile.

llvm-svn: 132655
2011-06-05 01:20:06 +00:00
Nick Lewycky
36e7570fb3 Add support for @GOTPTOFF in i386 mode.
llvm-svn: 132643
2011-06-04 17:38:07 +00:00
Jim Grosbach
8a7731f951 .cfi directive register parsing flexibility.
Parsing a register name/number for .cfi directives can't assume that a
register name starts with a '%' token. Be more flexible and check for a
register number instead. Still unlikely to be perfect, but it allows us
to parse both plain identifiers as register names and integers as register
numbers, which is what we're wanting to support at this point.

llvm-svn: 132466
2011-06-02 17:14:04 +00:00
Rafael Espindola
ee123951a2 Don't hardcode the %reg format in the streamer.
llvm-svn: 132451
2011-06-02 02:34:55 +00:00
Joerg Sonnenberger
ffa79cb359 Add new -d option to tblgen. It writes a make(1)-style dependency file.
llvm-svn: 132395
2011-06-01 13:10:15 +00:00
Rafael Espindola
33f7d7f9fa Use the dwarf->llvm mapping to print register names in the cfi
directives.

Fixes PR9826.

llvm-svn: 132317
2011-05-30 20:20:15 +00:00
Charles Davis
f835c87c83 Add a parameter to the Win64 EH section getters to get a section with a
suffix (e.g. .xdata$myfunc). The suffix part isn't implemented yet, but
I'll get to it in the next patch.

Fix up all callers of the affected functions. Make them pass said suffix to
the function.

llvm-svn: 132205
2011-05-27 19:09:24 +00:00
Charles Davis
01cde4d080 Assorted fixes for Win64 EH unwind info emission:
- Flip order of bitfields. This gets our output matching GAS.
- Handle case where the end of the prolog wasn't specified.
- If the resulting unwind info struct is less than 8 bytes, pad to 8 bytes.

Add a test for the latter two.

llvm-svn: 132188
2011-05-27 15:10:25 +00:00
Charles Davis
5ebea6fc5f Start keeping track of where the various unwind instructions are in the prolog.
Use them to calculate the offset inside the prolog. Emit this value when
emitting the unwind codes.

llvm-svn: 132177
2011-05-27 03:25:01 +00:00
Charles Davis
f64d56f9e2 Add missing break statements. Align UNWIND_INFO and RUNTIME_FUNCTION structs
to 4 bytes.

I'm surprised no one caught the missing break statements.

llvm-svn: 132176
2011-05-27 02:43:19 +00:00
Charles Davis
823e8a90ce My attempt at fixing the leak reported by the valgrind buildbots. Valgrind will
still report leaks, but they're spurious now. Valgrind cannot peer into
std::vector objects--or any dynamic array, for that matter--because it doesn't
know how big the array is.

llvm-svn: 132174
2011-05-27 02:01:08 +00:00
Charles Davis
32b363ded1 Fix inverted conditional in SaveReg and SaveXMM. Err when the frame pointer is
already defined, and err when the PushMachFrame operation isn't the first
operation (if specified at all).

llvm-svn: 132173
2011-05-27 01:42:17 +00:00
Charles Davis
0021487a8e Test .seh_startchained and .seh_endchained parsing.
Rework how the MCWin64EHUnwindInfo instances are stored. Fix issues with
chained unwind areas exposed by the test that were related to this.

The ChainedParent field had the wrong address, because when the chained unwind
info was added, the addresses shifted around. Now we store the pointers to the
structures, which are now allocated from the MC heap.

llvm-svn: 132106
2011-05-26 02:45:47 +00:00
Charles Davis
ede0f07dae Add tests for .seh_setframe and .seh_handlerdata parsing. Fix issues with
them.

I had to add a special SwitchSectionNoChange method to MCStreamer just for
.seh_handlerdata. If this isn't OK, please let me know, and I'll find some
other way to fix .seh_handlerdata streaming.

llvm-svn: 132084
2011-05-25 21:43:45 +00:00
Charles Davis
6b67ee5130 Add tests for .seh_savereg and .seh_savexmm parsing. Once again, fix the
buggy methods that parse these directives.

llvm-svn: 132045
2011-05-25 04:51:25 +00:00
Charles Davis
14a32a9608 Add a test for .seh_pushframe parsing. Fix the bug exposed by it (and another
one I found by inspection).

llvm-svn: 132037
2011-05-25 04:08:15 +00:00
Charles Davis
967ee6a30b Add a test for the .seh_handler directive. Fix problems with the parsing
method exposed by the test. While we're at it, simplify the .seh_proc
parsing method.

llvm-svn: 132028
2011-05-25 01:33:42 +00:00
Charles Davis
d943eb05ed Test basic SEH directive-parsing functionality. Fix a latent bug exposed by
this test.

llvm-svn: 132004
2011-05-24 21:22:53 +00:00
Charles Davis
1084ac5bb1 Implement the rest of the SEH directive-parsing methods in the COFFAsmParser.
Add a size alignment check to the .seh_stackalloc directive parser. Add a
more descriptive error message to the .seh_handler directive parser.

Add methods to the TargetAsmInfo struct in support of all this.

llvm-svn: 131992
2011-05-24 20:06:30 +00:00
Jim Grosbach
76f8f3d479 Propagate error correctly in the MC Asm parser for leading '$' expressions.
llvm-svn: 131918
2011-05-23 20:36:04 +00:00
Charles Davis
b38506e3a7 Implement .seh_stackalloc and .seh_pushframe parsing.
I haven't implemented any of the ones that take registers yet. The problem is
that for x86-64 the streamer methods expect a native x86 register number (note:
%r8-%r15 want 8-15 instead of 0-7; same for %xmm8-%xmm15). I haven't figured
out exactly how I want to do that yet.

llvm-svn: 131899
2011-05-23 16:43:09 +00:00
Charles Davis
a4187a96c9 Add methods to parse the SEH directives to the COFFAsmParser. Implement some
of them, particularly the ones that don't take arguments. Also implement
.seh_proc and .seh_handler.

llvm-svn: 131866
2011-05-22 21:12:15 +00:00
Chris Lattner
7eb3367809 switch to using a smallvector to avoid allocations for most normal size instructions.
llvm-svn: 131837
2011-05-22 04:53:24 +00:00
Chris Lattner
b58a888c57 tidy some things up.
llvm-svn: 131836
2011-05-22 04:52:24 +00:00
Charles Davis
d74119d139 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
c23700bb65 Make the COFF streamer emit unwind info when processing a .seh_handlerdata
directive.

Implement emission of Win64 EH unwind info.

Pull in <cassert> in MCWin64EH.h so it can use the assert() macro.

llvm-svn: 131832
2011-05-22 03:01:05 +00:00
Charles Davis
a537e589c9 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
525855fe48 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
7f9c007dce 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
520128d52f 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
Jim Grosbach
909aff492f No reason not to allow defining the CFA as a reg w/ offset zero.
llvm-svn: 131760
2011-05-20 21:50:09 +00:00
Jim Grosbach
8c02dcbe8e Add missing leading \t when printing .cfi_def_cfa in the asmstreamer.
llvm-svn: 131755
2011-05-20 21:22:37 +00:00
Rafael Espindola
27dbdbdf4c fixes target address tBL and tBLX and sets relocation type
of tBL/tBLX to R_ARM_THM_CALL (ARM ELF 4.7.1.6)

Patch by koan-sin tan.

llvm-svn: 131748
2011-05-20 20:01:01 +00:00
Charles Davis
6b8caffdb2 Now that they're implemented, make the Win64 EH MCAsmStreamer methods call
super.

llvm-svn: 131743
2011-05-20 18:19:22 +00:00
Charles Davis
5e5cc95580 "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
97c81eee80 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
c03bb178a0 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
300a470f45 Implement the EndProlog Win64 EH method on the base MCStreamer.
llvm-svn: 131679
2011-05-19 21:24:54 +00:00
Charles Davis
925eab3fd7 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
Joerg Sonnenberger
5efd18ca60 Reapply 131644 including the missing header changes:
Introduce -fatal-assembler-warnings for the obvious purpose

llvm-svn: 131655
2011-05-19 18:00:13 +00:00
Eli Friedman
8cb4a78596 Revert r131644; it's breaking the build.
llvm-svn: 131653
2011-05-19 17:48:09 +00:00
Charles Davis
bb99a68546 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
Joerg Sonnenberger
951d2761f6 Introduce -fatal-assembler-warnings for the obvious purpose
llvm-svn: 131644
2011-05-19 17:27:01 +00:00
Charles Davis
e6942fd10b Implement the StartChained and EndChained Win64 EH methods on MCStreamer.
llvm-svn: 131629
2011-05-19 04:04:13 +00:00
Charles Davis
2940df3099 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
844da78338 Remove comments as Chris requested.
llvm-svn: 131590
2011-05-18 22:13:51 +00:00
Cameron Zwarich
e410478ca7 Fix an obvious typo in r131572.
llvm-svn: 131579
2011-05-18 21:29:07 +00:00
Charles Davis
48ea9389dc 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
2e7d0eef98 Implement the Win64 EH directive methods for the assembly language streamer.
GAS has no such directives (not even mingw-w64 GAS has them), so I took
creative license with their names in assembly. I prefixed them all with
"w64_" to avoid namespace collisions, for example. If I discover that GAS
has taken a different approach, I'll change ours to match.

llvm-svn: 131525
2011-05-18 04:58:05 +00:00
Charles Davis
81fa5ec5c3 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
173b0d324a 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
Jason W Kim
4b3c43cf90 Add a FIXME reminder to remove ForceARMElfPIC switch.
llvm-svn: 131411
2011-05-16 16:35:21 +00:00
Rafael Espindola
e0b15205c1 sets bit 0 of the function address of thumb function in .symtab
("T is 1 if the target symbol S has type STT_FUNC and the
symbol addresses a Thumb instruction ;it is 0 otherwise."
from "ELF for the ARM Architecture" 4.7.1.2)

Patch by Koan-Sin Tan!

llvm-svn: 131406
2011-05-16 16:17:21 +00:00
Charles Davis
576f65b4b2 Fix copy-pasto.
llvm-svn: 131384
2011-05-15 17:28:27 +00:00
Charles Davis
900df11077 Add stub methods to MCStreamer for emitting Win64 exception-handling
information.

llvm-svn: 131382
2011-05-15 17:20:01 +00:00
Matt Beaumont-Gay
20dbed0a8b Remove an unused variable and move a couple others inside DEBUG.
llvm-svn: 131208
2011-05-11 23:34:51 +00:00
Jason W Kim
f6c2c6a38e Address the last bit of relocation flag related divergence betweeen
LLVM and binutils.

With this patch, there are no functional differences between the .o
produced directly from LLVM versus the .s to .o via GNU as, for relocation tags
at least, for both PIC and non-PIC modes.

Because some non-PIC reloc tags are used (legally) on PIC, so IsPCRel flag is
necessary but not sufficient to determine whether the overall codegen mode is
PIC or not. Why is this necessary? There is an incompatibility of how relocs
are emitted in the .rodata section.  Binutils PIC likes to emit certain relocs
as section relative offsets.  Non-PIC does not do this.

So I added a hidden switch on the ELFObjectwriter "-arm-elf-force-pic" which
forces the objectwriter to pretend that all relocs are for PIC mode.


Todo: Activate ForceARMElfPIC to true if -relocation-model=pic is selected
on llc.

Todo: There are probably more issues for PIC mode on ARM/MC/ELF...

Todo: Existing tests in MC/ARM/elf-reloc*.ll need to be converted over to .s 
tests as well as expanded to cover the gamut.

llvm-svn: 131205
2011-05-11 22:53:06 +00:00
Rafael Espindola
ce84130f0f Avoid a gcc warning.
llvm-svn: 131161
2011-05-10 22:28:35 +00:00
Rafael Espindola
e8890f4b16 On MachO, unlike ELF, there should be no relocation to produce the CIE pointer.
llvm-svn: 131149
2011-05-10 20:59:42 +00:00
Rafael Espindola
9b3e6a9cb4 Rename DwarfRequiresRelocationForStmtList to
DwarfRequiresRelocationForSectionOffset as this is not specific to StmtList.

llvm-svn: 131148
2011-05-10 20:35:05 +00:00
Rafael Espindola
ec3d43391f The EH symbols are only needed in eh_frame, not debug_frame.
llvm-svn: 131146
2011-05-10 19:51:53 +00:00
Rafael Espindola
ff4443c82c In a debug_frame the cfi offset is to the start of the debug_frame section!
llvm-svn: 131129
2011-05-10 15:20:23 +00:00
Rafael Espindola
33cc7a8f74 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
b7c942431f Add support for producing .deubg_frame sections.
llvm-svn: 131121
2011-05-10 03:54:12 +00:00
Rafael Espindola
566d48be51 Small cleanups.
llvm-svn: 131120
2011-05-10 03:26:21 +00:00
Rafael Espindola
3d5f7d1fc1 Factor some code into a new EmitFrames method.
llvm-svn: 131119
2011-05-10 03:14:15 +00:00
Rafael Espindola
dce419e62b Remove unused argument.
llvm-svn: 131118
2011-05-10 03:01:39 +00:00
Rafael Espindola
c5f10dda05 Parsing and plumbing for .cfi_sections.
llvm-svn: 131117
2011-05-10 01:10:18 +00:00
NAKAMURA Takumi
b8bfce2165 Eliminate an unused line to fix a warning.
llvm-svn: 131078
2011-05-08 23:19:04 +00:00
Rafael Espindola
0baeced1f4 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
Rafael Espindola
003a45810d Switch Darwin to the generic CIE/FDE printer.
llvm-svn: 131031
2011-05-06 22:29:04 +00:00
Rafael Espindola
59462d8ae3 Dead code elimination.
llvm-svn: 130984
2011-05-06 14:56:22 +00:00
Rafael Espindola
ab39b8319b Don't produce a __debug_frame.
I tested both gdb on a bootstrapped clang and and the gdb testsuite on OS X (snow leopard)
and both are happy using __eh_frame.

llvm-svn: 130937
2011-05-05 18:43:39 +00:00
Rafael Espindola
8346c59e6a Producing a DW_FORM_addr for DW_AT_stmt_list is probably correct, but
it is both inefficient and unexpected by dwarfdump. Change to
a DW_FORM_data4.

While in here, change the predicate name to reflect that the position
is not really absolute (it is an offset), just that the linker needs a
relocation.

llvm-svn: 130846
2011-05-04 17:44:06 +00:00
Daniel Dunbar
3cd9c46c3a MCDwarf: Don't save Twine to local variable, this is almost never safe to do
(and should thus never be done).
 - Should fix a crash on win32.

llvm-svn: 130793
2011-05-03 21:33:37 +00:00
Rafael Espindola
d49e7769a7 Add r130623 back now that ELF has been fixed to work with -fno-dwarf2-cfi-asm.
llvm-svn: 130658
2011-05-01 15:44:13 +00:00
Rafael Espindola
eb5d0cb4f4 GCC uses a different encoding of pointers in the FDE when using
-fno-dwarf2-cfi-asm. Implement the same behavior.

llvm-svn: 130637
2011-05-01 04:49:54 +00:00
Rafael Espindola
2f2c3bf31f 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
886aa563be Revert the previous patch while I figure out how to make llvm-gcc
less agressive about disabling cfi on linux :-(

llvm-svn: 130626
2011-04-30 23:03:44 +00:00
Rafael Espindola
9455887b10 Enable CFI on OS X.
Currently the output should be almost identical to the one produced by CodeGen
to make the transition easier.

The only two differences I know of are:

* Some files get an extra advance loc of size 0. This will be fixed when
relaxations are enabled.
* The optimization of declaring an EH symbol as an external variable is not
implemented. This is a subset of adding the nounwind attribute, so we if really
this at -O0 we should probably do it at the IL level.

llvm-svn: 130623
2011-04-30 22:29:54 +00:00
Rafael Espindola
dfbd3e7412 Implement MCAsmStreamer::EmitEHSymAttributes. Doing this in the asm streamer
is a bit ugly, but doing it on the base MCStreamer would be redundant
with the object streamer which does it using SD.

llvm-svn: 130611
2011-04-30 16:34:57 +00:00
Rafael Espindola
969f9f552c Handle PrivateExtern eh symbols.
llvm-svn: 130609
2011-04-30 16:22:46 +00:00
Rafael Espindola
7901d3790e Add all the plumbing needed for MC to expand cfi to the old tables in
the final assembly. It is the same technique used when targeting
assemblers that don't support .loc.

llvm-svn: 130587
2011-04-30 03:44:37 +00:00
Rafael Espindola
17e6a392af Implement MCAsmStreamer::EmitDwarfAdvanceFrameAddr.
llvm-svn: 130585
2011-04-30 03:21:04 +00:00
Rafael Espindola
13b74fd203 Avoid some uses of .uleb128. This is a small speedup and more importantly
lets this code be used when producing assembly code for old assemblers without
uleb support.

llvm-svn: 130544
2011-04-29 21:50:57 +00:00
Rafael Espindola
c4e90a84c4 Implement MCAsmStreamer::EmitCFIDefCfa.
llvm-svn: 130543
2011-04-29 21:41:06 +00:00
Daniel Dunbar
9a87852114 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
Daniel Dunbar
1488659798 MC: Change variable symbols to be recognized as defined, by assigning their sections based on FindAssociatedSection().
llvm-svn: 130523
2011-04-29 18:20:17 +00:00
Daniel Dunbar
32545135b1 MC/Mach-O: Update getSymbolAddress() to support evaluation of variables.
llvm-svn: 130522
2011-04-29 18:13:42 +00:00
Daniel Dunbar
f419ec6362 MC/Mach-O: Allow emission of relocations for variables in some more cases.
llvm-svn: 130520
2011-04-29 18:10:47 +00:00
Daniel Dunbar
6178302330 MC/Mach-O: Find section ordinal's by looking at the symbol, instead of assuming they are present in a fragment.
llvm-svn: 130519
2011-04-29 18:07:43 +00:00
Devang Patel
acce3eb6b2 Hoist MCLineEntry construction AsmPrinter so that anyone who derives from AsmPrinter can have line number entries.
PR 9810

llvm-svn: 130518
2011-04-29 18:00:54 +00:00
Daniel Dunbar
c52dfd4349 MCExpr: Add FindAssociatedSection, which attempts to mirror the 'as' semantics
that associate sections with expressions.

llvm-svn: 130517
2011-04-29 18:00:03 +00:00
Daniel Dunbar
2727693326 MC/AsmParser: Generalize a check.
llvm-svn: 130515
2011-04-29 17:53:11 +00:00
Rafael Espindola
6c6e1622a8 Last bit by bit compatibility patch to MCDwarf.cpp: If a FDE with no LSDA is
assigned to a CIE that requires one, just output a 0.

llvm-svn: 130472
2011-04-29 03:06:29 +00:00
Rafael Espindola
a664fdf4cd Add an alternative implementation of CIE and FDE emission that outputs them
in the same order as the one in CodeGen.

llvm-svn: 130471
2011-04-29 02:42:28 +00:00
Rafael Espindola
be5cb08cf8 Add the getExprForFDESymbol method that responsible for computing the
expressions used in the FDE to refer to symbols.

llvm-svn: 130437
2011-04-28 21:04:39 +00:00
Rafael Espindola
f75a67d261 Add a getExprForPersonalitySymbol method to MCAsmInfo. Use it when
converting the symbol passed to .cfi_personality into bytes is the file.

llvm-svn: 130400
2011-04-28 16:09:09 +00:00
Rafael Espindola
4f9a76ab0b 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
7bc992c8d3 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
d63b896d05 Produce the EH_frame# symbols if needed.
llvm-svn: 130378
2011-04-28 03:26:11 +00:00
Rafael Espindola
d2ef63ca76 Forward isFunctionEHFrameSymbolPrivate. If it is false, produce the foo.eh
symbols.

llvm-svn: 130375
2011-04-28 02:46:42 +00:00
Rafael Espindola
133c684456 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
Rafael Espindola
7728a01105 Force some values to be absolute and align based on the FDE pointers size. A small
step towards using .cfi_* on OS X.

llvm-svn: 130273
2011-04-27 01:43:49 +00:00
Rafael Espindola
c115df57cc 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
Sebastian Redl
0d36a0b806 Give MC/MCDisassembler/Disassembler.h a header guard.
llvm-svn: 130096
2011-04-24 15:46:56 +00:00
Jay Foad
c146569beb Remove unused STL header includes.
llvm-svn: 130068
2011-04-23 19:53:52 +00:00
Chandler Carruth
d09040ad66 Delete the other unused variable in this function. Sorry I missed this
the first time through.

llvm-svn: 129969
2011-04-22 01:29:18 +00:00
Chandler Carruth
a0a38b7d6e Remove an unused variable from a function. This is a likely cut-paste-o.
Silences GCC warning.

I wonder why Clang doesn't warn on this...

llvm-svn: 129968
2011-04-22 01:21:06 +00:00
Rafael Espindola
717fc5112a Compute the size of the FDE encoding instead of hard coding it. Update
X8664_ELFTargetObjectFile::getFDEEncoding to match reality.

llvm-svn: 129959
2011-04-22 00:08:43 +00:00
Rafael Espindola
856ed14418 Remove unused argument.
llvm-svn: 129955
2011-04-21 23:39:26 +00:00
Rafael Espindola
1afc1304c7 Don't pass address spaces to EmitULEB128IntValue.
llvm-svn: 129953
2011-04-21 23:26:40 +00:00
Rafael Espindola
e206800036 Fix relative relocations. This is sufficient for running the rust testsuite with
MC :-)

llvm-svn: 129923
2011-04-21 18:36:50 +00:00
Rafael Espindola
032ab8c114 Behave like gnu as when a relocation crosses sections.
llvm-svn: 129850
2011-04-20 14:01:45 +00:00
Sean Callanan
c550ce0d48 Made the MC disassembler check before accessing
MCInst operands for ARM.  This allows it to be
more tolerant of malformed MCInsts or incorrect
instruction metadata.

llvm-svn: 129840
2011-04-20 00:43:34 +00:00
Eli Friedman
9009047cff malloc elimination: it's a bad idea to use raw_svector_ostream on a
small heap-allocated SmallString because it unconditionally forces a malloc.

(Revised version of r129688, with the necessary flush() call.)

llvm-svn: 129716
2011-04-18 20:54:46 +00:00
Devang Patel
7220c1a021 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
Eli Friedman
9654b5718d Revert r129688; it's breaking buildbots.
llvm-svn: 129689
2011-04-18 05:54:54 +00:00
Eli Friedman
fe593ec2d0 More malloc elimination: it's a bad idea to use raw_svector_ostream on a
small heap-allocated SmallString because it unconditionally forces a malloc.

llvm-svn: 129688
2011-04-18 05:38:58 +00:00
Eli Friedman
819c450b25 Make the StringMaps attached to MCContext use the MCContext's allocator;
reduces the number of calls to malloc().

llvm-svn: 129687
2011-04-18 05:02:31 +00:00
Chris Lattner
0304b82f80 Fix a ton of comment typos found by codespell. Patch by
Luis Felipe Strano Moraes!

llvm-svn: 129558
2011-04-15 05:18:47 +00:00
Rafael Espindola
63f8a9ad72 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
9f6146c464 Remove LastOffset from the asm parser.
llvm-svn: 129378
2011-04-12 18:53:30 +00:00
Rafael Espindola
5c5bb3e9a6 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
7c4de15c7b Implement .cfi_same_value.
llvm-svn: 129361
2011-04-12 15:31:05 +00:00
Eric Christopher
b01713088d Match case for invalid constant error messages and add a new
test for invalid hexadecimals.

llvm-svn: 129326
2011-04-12 00:18:03 +00:00
Eric Christopher
b653bac7ce To avoid printing out multiple error messages for cases like:
.long 80+08

go ahead and assume that if we've got an Error token that we handled it
already. Otherwise if it's a token we can't handle then go ahead and
return the default error.

llvm-svn: 129322
2011-04-12 00:03:13 +00:00
Eric Christopher
a7c5e42cbe Lex, and then fail on invalid constants.
Testcase forthcoming.

rdar://8490596

llvm-svn: 129309
2011-04-11 22:24:56 +00:00
Rafael Espindola
a1fb8a36f9 Implement cfi_rel_offset
llvm-svn: 129306
2011-04-11 21:49:50 +00:00
Rafael Espindola
986ec356fc implement .cfi_adjust_cfa_offset.
llvm-svn: 129296
2011-04-11 20:29:16 +00:00
Kevin Enderby
6e09a5d065 Adding support for printing operands symbolically to llvm's public 'C'
disassembler API.  Hooked this up to the ARM target so such tools as Darwin's
otool(1) can now print things like branch targets for example this:
  blx _puts
instead of this:
  blx #-36
And even print the expression encoded in the Mach-O relocation entried for
things like this:
  movt r0, :upper16:((_foo-_bar)+1234)

llvm-svn: 129284
2011-04-11 18:08:50 +00:00
Benjamin Kramer
3af55c1e2e Fix potential buffer overflow on win32.
llvm-svn: 129214
2011-04-09 14:06:12 +00:00
Benjamin Kramer
6f39531981 Don't store Twine temporaries, it's not safe.
And don't append the name over and over again in the loop.

llvm-svn: 129210
2011-04-09 11:26:27 +00:00
Sean Callanan
0c1aa958e2 Redirected errors from the AsmParser to the proper
error stream, in cases where the AsmParser is
being invoked by EDDisassembler.  Before, they
were being sent to errs() because no error handler
was installed in the SourceMgr.

llvm-svn: 129177
2011-04-09 00:37:25 +00:00
Rafael Espindola
19119075c4 Micro optimization and improved similarity with gas' output:
When two section names share a suffix, reuse the entry in shstrtab.

llvm-svn: 129115
2011-04-07 23:21:52 +00:00
Rafael Espindola
a27969f537 Add support for .skip.
Patch by Roman Divacky.
Fixes PR9361.

llvm-svn: 129106
2011-04-07 20:26:23 +00:00
Sean Callanan
b1e6d05325 Fixed a bug where missing EDInstInfo would cause
tokenization to crash and burn.

llvm-svn: 129051
2011-04-07 01:56:01 +00:00
Shantonu Sen
a1467abb18 An MCDisassembler has the option to not implement
getEDInfo(), in which case this code would dereference
NULL. EDInst can already handle NULL info, so avoid
the dereference and pass NULL through.

Reviewed by Sean Callanan

llvm-svn: 128904
2011-04-05 18:40:45 +00:00
Kevin Enderby
1ece39d99c Added support symbolic floating point constants in the MC assembler for Infinity
and Nans with the same strings as GAS supports.  rdar://8673024

llvm-svn: 128488
2011-03-29 21:11:52 +00:00
Francois Pichet
b4a845ecbe Fix the MSVC build.
llvm-svn: 128441
2011-03-29 00:30:01 +00:00
Daniel Dunbar
5d8c7d0d36 MC: Add support for disabling "temporary label" behavior. Useful for debugging
on Darwin.

llvm-svn: 128430
2011-03-28 22:49:15 +00:00
Ted Kremenek
737cbac625 Unbreak CMake build.
llvm-svn: 128426
2011-03-28 20:43:53 +00:00
Kevin Enderby
8c488cb152 Again adding a C API to the disassembler for use by such tools as Darwin's
otool(1), this time with the needed fix for case sensitive file systems :) .
This is a work in progress as the interface for producing symbolic operands is
not done.  But a hacked prototype using information from the object file's
relocation entiries and replacing immediate operands with MCExpr's has been
shown to work with no changes to the instrucion printer.  These APIs will be
moved into a dynamic library at some point.

llvm-svn: 128415
2011-03-28 18:25:07 +00:00
NAKAMURA Takumi
dcd45bec2e Fix whitespace.
llvm-svn: 128370
2011-03-27 01:44:40 +00:00
Kevin Enderby
b05e6939a0 Remove the files for r128308 as it is causing a buildbot failure.
llvm-svn: 128309
2011-03-26 00:23:05 +00:00
Kevin Enderby
872ebb4fff Adding a C API to the disassembler for use by such tools as Darwin's otool(1).
This is a work in progress as the interface for producing symbolic operands is
not done.  But a hacked prototype using information from the object file's
relocation entiries and replacing immediate operands with MCExpr's has been
shown to work with no changes to the instrucion printer.  These APIs will be
moved into a dynamic library at some point.

llvm-svn: 128308
2011-03-26 00:06:33 +00:00
Daniel Dunbar
1cbd2c6c88 MC: Improve some diagnostics on uses of '.' pseudo-symbol.
llvm-svn: 128289
2011-03-25 17:47:17 +00:00
Daniel Dunbar
70235789e1 Tidyness.
llvm-svn: 128288
2011-03-25 17:47:14 +00:00
Bruno Cardoso Lopes
a5de5df6d8 Add asm parsing support w/ testcases for strex/ldrex family of instructions
llvm-svn: 128236
2011-03-24 21:04:58 +00:00
Jim Grosbach
213800d44b Clean up assembly statement separator support.
The MC asm lexer wasn't honoring a non-default (anything but ';') statement
separator. Fix that, and generalize a bit to support multi-character
statement separators.

llvm-svn: 128227
2011-03-24 18:46:34 +00:00
Owen Anderson
b201c7dede Fix a bug introduced by my patch yesterday: BL is a 4-byte instructions like BLX, rather than a 2-byte instruction like B.
llvm-svn: 128169
2011-03-23 21:19:56 +00:00
Owen Anderson
7785f055b9 RIT_ARM_ThumbBranch32Bit relocations are not used and should never be generated.
This fixes kimwitu++, bullet, and tramp3dv4 with the ARM integrated assembler.
Fixes <rdar://problem/9165738>.

llvm-svn: 128117
2011-03-22 22:52:54 +00:00
Owen Anderson
1264624890 Add support for Thumb interworking addresses for symbol offsets that get constant folded very early.
This fixes SPASS with -integrated-as.  <rdar://problem/9165399>

llvm-svn: 128037
2011-03-21 23:13:43 +00:00
Bill Wendling
a2eec46242 We need to pass the TargetMachine object to the InstPrinter if we are printing
the alias of an InstAlias instead of the thing being aliased. Because we need to
know the features that are valid for an InstAlias.

This is part of a work-in-progress.

llvm-svn: 127986
2011-03-21 04:13:46 +00:00
Rafael Espindola
b5c6ae67ac Write the section table and the section data in the same order that
gun as does. This makes it a lot easier to compare the output of both
as the addresses are now a lot closer.

llvm-svn: 127972
2011-03-20 18:44:20 +00:00
Stuart Hastings
0c1298989f Reapply 127939 since Daniel fixed the breakage. <rdar://problem/9012638>
llvm-svn: 127944
2011-03-19 02:42:31 +00:00
Stuart Hastings
0b337d0fe8 Revert 127939. <rdar://problem/9012638>
llvm-svn: 127943
2011-03-19 02:33:56 +00:00
Stuart Hastings
4a2b1ca9c1 Revise r126127 to address Daniel's comments. <rdar://problem/9012638>
llvm-svn: 127939
2011-03-19 01:32:01 +00:00
Daniel Dunbar
0e9d7aeb1f MC/Mach-O: Fix regression introduced in r126127, this assignment shouldn't have
been removed.

llvm-svn: 127812
2011-03-17 16:25:24 +00:00
Joerg Sonnenberger
e37bdf4386 Fix handling of @IDNTPOFF relocations, they need to get STT_TLS.
While here, add VK_ARM_TPOFF and VK_ARM_GOTTPOFF, too.

llvm-svn: 127780
2011-03-17 00:35:10 +00:00
Duncan Sands
e91289191a Silence compiler warning about case values not being in the enumerated type
MCFixupKind.  This is the same technique that is used elsewhere in MC.

llvm-svn: 127676
2011-03-15 08:54:51 +00:00
Sean Callanan
4f6e58ff09 Fixed the comparison operator for the enhanced
disassembler's disassembler map.

llvm-svn: 127527
2011-03-12 03:27:54 +00:00
Jan Sjödin
6791bc64a2 Add constructors to MCElfStreamer and MCObjectStreamer to take an extra MCAssembler * argument.
llvm-svn: 127343
2011-03-09 17:33:05 +00:00
Jim Grosbach
bdf8053571 Darwin 'as' silently ignores the '.ident' directive.
llvm-svn: 127258
2011-03-08 19:17:19 +00:00
Anton Korobeynikov
917ca94111 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
62e48532b9 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
5f2f5fa638 Be nice to Xcore and the XMOS assembler and avoid quoting section names
that contain only letters, digits and the characters "_" and ".".

llvm-svn: 127028
2011-03-04 20:03:14 +00:00
Joerg Sonnenberger
bb93506f95 Bug#9033: For the ELF assembler output, always quote the section name.
llvm-svn: 126963
2011-03-03 22:31:08 +00:00
Jan Sjödin
3c1fa9a68b Split MCEELFStreamer and ELFObjectWriter into .h and .cpp files, so that other components can use them.
llvm-svn: 126942
2011-03-03 14:52:12 +00:00
Eli Friedman
f7eb4cce13 PR9352: Always emit a relocation for weak symbols. Not emitting relocations
for calls to weak symbols with a definition has the appearance of working
with LLVM-generated code because weak symbol definitions are put in their
own sections.

llvm-svn: 126933
2011-03-03 07:24:36 +00:00
Oscar Fuentes
15a668f50b Fixes warnings emitted by Visual Studio 2010 compiler.
Patch by Erik Olofsson!

llvm-svn: 126796
2011-03-01 23:11:57 +00:00
Jan Sjödin
6bc6d6ab39 Make all static functions become static class methods. Move shared (duplicated) functions to new MCELF class.
llvm-svn: 126686
2011-02-28 21:45:04 +00:00
Cameron Zwarich
974208a607 Roll out r126425 and r126450 to see if it fixes the failures on the buildbots.
llvm-svn: 126488
2011-02-25 16:30:32 +00:00
Joerg Sonnenberger
9c30c492df Restore r125595 (reverted in r126336) with modifications:
Introduce a variable in the AsmParserExtension whether [] is valid in an
expression. If it is true, parse them like (). Enable this for ELF only.

llvm-svn: 126443
2011-02-24 21:59:22 +00:00
Devang Patel
f2b2417c2c Enable DebugInfo support for COFF object files.
Patch by Nathan Jeffords!

llvm-svn: 126425
2011-02-24 21:04:00 +00:00
Benjamin Kramer
feccb33180 Plug some leaks in edis.
- Don't leak parsed operands during tokenization.
- Don't leak printed insts in llvm-mc.

llvm-svn: 126381
2011-02-24 11:03:19 +00:00
Jim Grosbach
e7be1f2990 Revert r125595, which is an X86-only undocumented assembly syntax extension
enabled for all targets. Non-X86 targets should not have this behavior
enabled by default.

Joerg, if you would like to resubmit with the behavior conditionalized to be
X86-ELF only, that's fine.

llvm-svn: 126336
2011-02-23 21:26:51 +00:00
Rafael Espindola
993a4ef35c Put in the symbol table symbols only used in a .globl statement.
Fixes PR9292.

llvm-svn: 126330
2011-02-23 20:22:07 +00:00
Sean Callanan
e1308394f1 Fixed a bug in the enhanced disassembler that caused
it to ignore valid uses of FS and GS as additional
base registers in address computations.  Added a test
case for this.

llvm-svn: 126302
2011-02-23 03:31:28 +00:00
Stuart Hastings
c0c38e8673 Omit private_extern declarations of extern symbols; followup to
r124468.  Patch by Rafael Avila de Espindola!

llvm-svn: 126297
2011-02-23 02:27:05 +00:00
Joerg Sonnenberger
cbdd830a75 Bug#9172: Don't use static in file scope, use an attribute on the
parser.

llvm-svn: 126225
2011-02-22 16:53:11 +00:00
Joerg Sonnenberger
dfe33572b5 Handle FK_PCRel_1 and add a test case for this and FK_PCRel_4.
llvm-svn: 126157
2011-02-21 23:25:41 +00:00
Stuart Hastings
8181f2d5a3 End the line if we return early. Radar 9012638.
llvm-svn: 126141
2011-02-21 21:07:07 +00:00
Stuart Hastings
d7ca2e5b61 Fix to correctly support attribute((section("__DATA, __common"))).
Radar 9012638.

llvm-svn: 126127
2011-02-21 17:27:17 +00:00
Joerg Sonnenberger
2204260330 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
5fd4a261e7 Add some limited support for labels in org directives. Hopefully enough to fix
PR9245.

llvm-svn: 126091
2011-02-20 20:20:07 +00:00
Oscar Fuentes
6e5d344a2e Move library stuff out of the toplevel CMakeLists.txt file.
llvm-svn: 125968
2011-02-18 22:06:14 +00:00
Rafael Espindola
4ef1268b39 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
b59fdeb3de Add support for pushsection and popsection. Patch by Joerg Sonnenberger.
llvm-svn: 125629
2011-02-16 01:08:29 +00:00
Roman Divacky
3277e18a42 Add support for parsing [expr].
This is submitted by Joerg Sonnenberger and fixes his PR8685.

llvm-svn: 125595
2011-02-15 20:43:39 +00:00
Rafael Espindola
3c32af5834 Switch llvm to using comdats. For now always use groups with a single
section.

llvm-svn: 125526
2011-02-14 22:23:49 +00:00
Rafael Espindola
a667a598aa Move broken HasCommonSymbols to ELFWriter.cpp.
llvm-svn: 125490
2011-02-14 16:51:08 +00:00
Jim Grosbach
79e4b6b045 More whitespace cleanup...
llvm-svn: 125388
2011-02-11 19:05:56 +00:00
Shantonu Sen
70e390fa15 Fix comparator used for looking up previously instantiated EDDisassemblers.
Now, Syntax is only used as a tie-breaker if the Arch
matches. Previously, a request for x86_64 disassembler followed by the
i386 disassembler in a single process would return the cached x86_64
disassembler. Fixes <rdar://problem/8958982>

llvm-svn: 125215
2011-02-09 21:03:19 +00:00
Benjamin Kramer
8ff71a1384 Support for .ifdef / .ifndef in the assembler parser. Patch by Joerg Sonnenberger.
llvm-svn: 125120
2011-02-08 22:29:56 +00:00
Jason W Kim
7342155b4c Teach ARM/MC/ELF about gcc compatible reloc output to get past odd linkage
failures with relocations.

The code committed is a first cut at compatibility for emitted relocations in
ELF .o.

Why do this? because existing ARM tools like emitting relocs symbols as
explicit relocations, not as section-offset relocs.

Result is that with these changes,
1) relocs are now substantially identical what to gcc outputs.
2) larger apps (including many spec2k tests) compile, cross-link, and pass

Added reminder fixme to tests for future conversion to .s form.

llvm-svn: 124996
2011-02-07 01:11:15 +00:00
Jason W Kim
056e5aacb7 Teach ARM/MC/ELF about EF_ARM_EABI_VERSION. The magic number is set to
5 to match the current doc.
Added FIXME reminder Make it really configurable later.

llvm-svn: 124899
2011-02-04 21:41:11 +00:00
Jason W Kim
10c1a81736 Teach ARM/MC/ELF to handle R_ARM_JUMP24 relocation type for conditional jumps.
(yes, this is different from R_ARM_CALL)

- Adds a new method getARMBranchTargetOpValue() which handles the
  necessary distinction between the conditional and unconditional br/bl
  needed for ARM/ELF

At least for ARM mode, the needed fixup for conditional versus unconditional
br/bl is identical, but the ARM docs and existing ARM tools expect this
reloc type...

Added a few FIXME's for future naming fixups in ARMInstrInfo.td

llvm-svn: 124895
2011-02-04 19:47:15 +00:00
Bob Wilson
f6a7104e41 Do not sign extend floating-point values in the asm parser.
llvm-svn: 124831
2011-02-03 23:17:47 +00:00
Evan Cheng
3689d1302d Fix bogus assert condition noticed by Csaba Raduly.
llvm-svn: 124645
2011-02-01 01:50:49 +00:00
Roman Divacky
254f2ab16a Enumerate .code16/32/64 instead of checking .code prefix. This
unbreaks some ARM tests.

llvm-svn: 124608
2011-01-31 21:19:43 +00:00
Roman Divacky
9a8a680ed2 Error on all .code* directives instead of just .code16 as they
all lead to a silent miscompilation of code.

llvm-svn: 124603
2011-01-31 20:56:49 +00:00
Roman Divacky
82612f08c2 Error on .code16 instead of producing wrong (32bit) code.
llvm-svn: 124498
2011-01-28 19:29:48 +00:00
Roman Divacky
c6a20d1728 Add support for parsing .float
llvm-svn: 124485
2011-01-28 14:20:32 +00:00
Nico Weber
66fd0e8119 PR8951: Support for .equiv in integrated assembler, patch by Jörg Sonnenberger!
llvm-svn: 124467
2011-01-28 03:04:41 +00:00
Roman Divacky
f817c82cf3 Add support for specifying register name in cfi-register/offset/def
as well as register number.

llvm-svn: 124379
2011-01-27 17:16:37 +00:00
Bill Wendling
195d8c3988 Add support for parsing a Real value. It stores the Real value as its binary
encoding. It's up to the individual back-ends to convert it to their preferred
representation when printing.

llvm-svn: 124229
2011-01-25 21:26:41 +00:00
Rafael Espindola
ead58a5259 Handle strings in section names the same way as gas:
* If the name is a single string, we remove the quotes
* If the name starts without a quote, we include any quotes in the name

llvm-svn: 124127
2011-01-24 18:02:54 +00:00
Rafael Espindola
547873da60 Add support for the --noexecstack option.
llvm-svn: 124077
2011-01-23 17:55:27 +00:00
Rafael Espindola
14333be1af Add support for lowercase variants.
llvm-svn: 124071
2011-01-23 16:11:25 +00:00
Rafael Espindola
aefd549139 Delay the creation of eh_frame so that the user can change the defaults.
Add support for SHT_X86_64_UNWIND.

llvm-svn: 124059
2011-01-23 05:43:40 +00:00