Commit Graph

3446 Commits

Author SHA1 Message Date
Paul Robinson
28ca8c3c86 [DWARFv5] llvm-mc support for new unit header.
This is for running the assembler with -g (to emit DWARF describing
the assembler source).

Differential Revision: http://reviews.llvm.org/D30475


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296541 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-28 23:40:46 +00:00
Dan Gohman
4b87fbfe6e [MC] Implement the COFF directives in MCNullStreamer.
This fixes -filetype=null errors introduced in r296403.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296410 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-27 23:10:18 +00:00
Dan Gohman
d5cb2d625b [MC] Factor out non-COFF handling of COFF-specific directives.
Instead of requiring every non-COFF MCObjectStreamer to implement the
COFF hooks just to do an llvm_unreachable to say that they're not
supported, do the llvm_unreachable in the default implementation, as
suggested by rnk in https://reviews.llvm.org/D26722.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296403 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-27 22:44:37 +00:00
Dan Gohman
6d8f20c219 [WebAssembly] Add some comments and tidy up whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296402 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-27 22:41:39 +00:00
Dan Gohman
8f5a7d69cc [WebAssembly] Add support for using a wasm global for the stack pointer.
This replaces the __stack_pointer variable which was allocated in linear
memory.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296201 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-24 23:46:05 +00:00
Dan Gohman
53ff96ab08 [WebAssembly] Basic support for Wasm object file encoding.
With the "wasm32-unknown-unknown-wasm" triple, this allows writing out
simple wasm object files, and is another step in a larger series toward
migrating from ELF to general wasm object support. Note that this code
and the binary format itself is still experimental.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296190 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-24 23:18:00 +00:00
Evgeniy Stepanov
89efd71a88 Disallow redefinition of section symbols.
Differential Revision: https://reviews.llvm.org/D30235

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296180 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-24 21:44:58 +00:00
Evgeniy Stepanov
5982b2c089 Initialize MCContext::InlineSrcMgr in the constructor.
Found with ASan (and a local source change) on test/CodeGen/XCore/section-name.ll.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296179 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-24 21:44:52 +00:00
Dan Gohman
6d5b578789 [WebAssembly] Implement the wasm binary container header.
Also, update the version number to 0x1, which is what engines are now
expecting.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295860 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-22 18:50:20 +00:00
Dan Gohman
d660a5d68c [WebAssembly] Add skeleton MC support for the Wasm container format
This just adds the basic skeleton for supporting a new object file format.
All of the actual encoding will be implemented in followup patches.

Differential Revision: https://reviews.llvm.org/D26722


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295803 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-22 01:23:18 +00:00
Matthias Braun
60202aba32 SubtargetFeature: Cleanup; NFC
- Fix doxygen comments
- Remove duplicated comments
- Remove section comments (which became wrong over time)
- Use more `const` and references but less `auto`

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295687 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-21 01:27:29 +00:00
Rui Ueyama
a24db2314e MC/COFF: Do not emit forward associative section referenceds.
MSVC link.exe cannot handle associative sections that refer later
sections in the section header. Technically, such COFF object doesn't
violate the Microsoft COFF spec, as the spec doesn't say anything
about that, but still we should avoid doing that to make it compatible
with MS tools.

This patch assigns smaller section numbers to non-associative sections
and larger numbers to associative sections. This should resolve the
compatibility issue.

Differential Revision: https://reviews.llvm.org/D30080

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295464 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-17 17:32:54 +00:00
Rui Ueyama
458e24287e Split WinCOFFObjectWriter::writeSection.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295276 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-16 02:56:06 +00:00
Rui Ueyama
1e5304f32f Split WinCOFFObjectWriter::writeObject function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295273 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-16 02:35:48 +00:00
Rui Ueyama
0ddf101757 Remove useless local variable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295268 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-16 01:41:04 +00:00
Rui Ueyama
5ececce5a8 Rename variables to match the LLVM style.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295265 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-16 01:06:45 +00:00
Rui Ueyama
da87ca0f4c Revert r295138: Instead of a series of string operations, use snprintf().
This broke buildbots.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295142 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-15 01:48:33 +00:00
Rui Ueyama
7855b94bca Instead of a series of string operations, use snprintf().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295138 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-15 01:09:40 +00:00
Rui Ueyama
070aca8b5a Return early. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295137 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-15 01:09:20 +00:00
Rui Ueyama
fb44f2a90d Use LLVM-style naming scheme.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295136 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-15 01:09:01 +00:00
Rui Ueyama
52b918216d Use LLVM-style naming scheme.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295132 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-15 00:28:48 +00:00
Rui Ueyama
cdb6cd3738 Remove useless local variable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295131 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-15 00:28:26 +00:00
Rui Ueyama
766de4dd24 Split WinCOFFObjectWriter::defineSection. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295128 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-15 00:15:54 +00:00
Rui Ueyama
6b607dcc2e Simplify WinCOFFObjectWriter by removing a template member function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295126 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-14 23:58:19 +00:00
Rui Ueyama
7c1b5b039c Do not lookup a DenseMap twice using the same key.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295124 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-14 23:47:34 +00:00
Rui Ueyama
d5265b3065 Use endian::write32le instead of endian::write.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295120 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-14 23:28:19 +00:00
Rui Ueyama
3afdebfea9 Use zero-initialization instead of memset.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295119 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-14 23:28:01 +00:00
Eugene Zelenko
7211c537b1 [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
Same changes in files affected by reduced MC headers dependencies.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295009 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-14 00:33:36 +00:00
Eugene Zelenko
a700a60bfc [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294813 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-11 00:27:28 +00:00
Rafael Espindola
940b0c036d Move some error handling down to MCStreamer.
This makes sure we get the same redefinition rules regardless of who
is printing (asm parser, codegen) and to what (asm, obj).

This fixes an unintentional regression in r293936.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294752 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-10 15:13:12 +00:00
Eugene Zelenko
c51124b83c [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294685 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-10 01:33:54 +00:00
Rafael Espindola
5a2d92c7cf Make it possible to set SHF_LINK_ORDER explicitly.
This will make it possible to add support for gcing user metadata
(asan for example).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294589 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-09 14:59:20 +00:00
Eugene Zelenko
3a124c0e3d [MC] Fix some Clang-tidy modernize and Include What You Use warnings in SubtargetFeature; other minor fixes (NFC).
Same changes in files affected by reduced SubtargetFeature.h dependencies.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294548 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-09 01:09:54 +00:00
Eugene Zelenko
498b48e527 [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294526 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-08 22:23:19 +00:00
Sanne Wouda
5896003cc3 [Assembler] Enable nicer diagnostics for inline assembly.
Fixed test.

Summary:
Enables source location in diagnostic messages from the backend.  This
is after parsing, during finalization.  This requires the SourceMgr, the
inline assembly string buffer, and DiagInfo to still be alive after
EmitInlineAsm returns.

This patch creates a single SourceMgr for inline assembly inside the
AsmPrinter.  MCContext gets a pointer to this SourceMgr.  Using one
SourceMgr per call to EmitInlineAsm would make it difficult for
MCContext to figure out in which SourceMgr the SMLoc is located, while a
single SourceMgr can figure it out if it has multiple buffers.

The Str argument to EmitInlineAsm is copied into a buffer and owned by
the inline asm SourceMgr.  This ensures that DiagHandlers won't print
garbage.  (Clang emits a "note: instantiated into assembly here", which
refers to this string.)

The AsmParser gets destroyed before finalization, which means that the
DiagHandlers the AsmParser installs into the SourceMgr will be stale.
Restore the saved DiagHandlers.

Since now we're using just one SourceMgr for multiple inline asm
strings, we need to tell the AsmParser which buffer it needs to parse
currently.  Hand a buffer id -- returned from SourceMgr::
AddNewSourceBuffer -- to the AsmParser.

Reviewers: rnk, grosbach, compnerd, rengolin, rovka, anemet

Reviewed By: rnk

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D29441
    


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294458 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-08 14:48:05 +00:00
Diana Picus
a32d7c935e Revert "[Assembler] Enable nicer diagnostics for inline assembly."
This reverts commit r294433 because it seems it broke the buildbots.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294448 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-08 14:02:16 +00:00
Sanne Wouda
5ddc432093 [Assembler] Enable nicer diagnostics for inline assembly.
Summary:
Enables source location in diagnostic messages from the backend.  This
is after parsing, during finalization.  This requires the SourceMgr, the
inline assembly string buffer, and DiagInfo to still be alive after
EmitInlineAsm returns.

This patch creates a single SourceMgr for inline assembly inside the
AsmPrinter.  MCContext gets a pointer to this SourceMgr.  Using one
SourceMgr per call to EmitInlineAsm would make it difficult for
MCContext to figure out in which SourceMgr the SMLoc is located, while a
single SourceMgr can figure it out if it has multiple buffers.

The Str argument to EmitInlineAsm is copied into a buffer and owned by
the inline asm SourceMgr.  This ensures that DiagHandlers won't print
garbage.  (Clang emits a "note: instantiated into assembly here", which
refers to this string.)

The AsmParser gets destroyed before finalization, which means that the
DiagHandlers the AsmParser installs into the SourceMgr will be stale.
Restore the saved DiagHandlers.

Since now we're using just one SourceMgr for multiple inline asm
strings, we need to tell the AsmParser which buffer it needs to parse
currently.  Hand a buffer id -- returned from SourceMgr::
AddNewSourceBuffer -- to the AsmParser.

Reviewers: rnk, grosbach, compnerd, rengolin, rovka, anemet

Reviewed By: rnk

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D29441


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294433 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-08 10:20:07 +00:00
Eugene Zelenko
f31871c702 [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294369 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-07 23:02:00 +00:00
Rafael Espindola
7931a61c18 Change how we handle section symbols on ELF.
On ELF every section can have a corresponding section symbol. When in
an assembly file we have

.quad .text

the '.text' refers to that symbol.

The way we used to handle them is to leave .text an undefined symbol
until the very end when the object writer would map them to the
actual section symbol.

The problem with that is that anything before the end would see an
undefined symbol. This could result in bad diagnostics
(test/MC/AArch64/label-arithmetic-diags-elf.s), or incorrect results
when using the asm streamer (est/MC/Mips/expansion-jal-sym-pic.s).

Fixing this will also allow using the section symbol earlier for
setting sh_link of SHF_METADATA sections.

This patch includes a few hacks to avoid changing our behaviour when
handling conflicts between section symbols and other symbols. I
reported pr31850 to track that.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293936 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-02 21:26:06 +00:00
Matthias Braun
c7e7654a88 MCMacho: Allow __thread_ptr section after dwarf sections
Differential Revision: https://reviews.llvm.org/D29315

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293730 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-01 01:31:36 +00:00
Rafael Espindola
8f159c8d92 Move more code to helper functions. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293715 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-31 23:26:32 +00:00
Rafael Espindola
d99a5ea737 Move some code to a helper function. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293712 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-31 23:07:08 +00:00
Peter Collingbourne
043d1a96c9 MC: Introduce the ABS8 symbol modifier.
@ABS8 can be applied to symbols which appear as immediate operands to
instructions that have a 8-bit immediate form for that operand. It causes
the assembler to use the 8-bit form and an 8-bit relocation (e.g. R_386_8
or R_X86_64_8) for the symbol.

Differential Revision: https://reviews.llvm.org/D28688

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293667 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-31 18:28:44 +00:00
Benjamin Kramer
4337d89ed5 Fix the GCC build.
This is fairly ugly, but apparently GCC still doesn't understand C++11.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293535 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-30 19:05:09 +00:00
Benjamin Kramer
b49b75015b [MC] Remove global constructors from MCSectionMachO.cpp.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293526 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-30 18:46:26 +00:00
Rafael Espindola
d5702b77f0 Only print architecture dependent flags for that architecture.
Different architectures can have different meaning for flags in the
SHF_MASKPROC mask, so we should always check what the architecture use
before checking the flag.

NFC for now, but will allow fixing the value of an xmos flag.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293484 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-30 15:38:43 +00:00
Matthias Braun
88d207542b Cleanup dump() functions.
We had various variants of defining dump() functions in LLVM. Normalize
them (this should just consistently implement the things discussed in
http://lists.llvm.org/pipermail/cfe-dev/2014-January/034323.html

For reference:
- Public headers should just declare the dump() method but not use
  LLVM_DUMP_METHOD or #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
- The definition of a dump method should look like this:
  #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
  LLVM_DUMP_METHOD void MyClass::dump() {
    // print stuff to dbgs()...
  }
  #endif

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293359 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-28 02:02:38 +00:00
Reid Kleckner
f3bea97594 [CodeView] Fix off-by-one error in def range gap emission
Also fixes a much worse bug where we emitted the wrong gap size for the
def range uncovered by the test for this issue.

Fixes PR31726.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292949 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-24 16:57:55 +00:00
Chad Rosier
b1330a5678 [Assembler] Improve error when unable to evaluate expression.
Add a SMLoc to MCExpr. Most code does not generate or consume the SMLoc (yet).

Patch by Sanne Wouda <sanne.wouda@arm.com>!
Differential Revision: https://reviews.llvm.org/D28861

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292515 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-19 20:06:32 +00:00
Evgeniy Stepanov
e2c3142274 Fix aliases to thumbfunc-based exprs to be thumbfunc.
If F is a Thumb function symbol, and G = F + const, and G is a
function symbol, then G is Thumb. Because what else could it be?

Differential Revision: https://reviews.llvm.org/D28878

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292514 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-19 20:04:11 +00:00