summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCParser
Commit message (Collapse)AuthorAgeFilesLines
...
* [AsmParser] Recommit: Hash is not a comment on some targetsOliver Stannard2017-08-212-18/+0
| | | | | | | | | | | | | | | Re-committing after r311325 fixed an unintentional use of '#' comments in clang. The '#' token is not a comment for all targets (on ARM and AArch64 it marks an immediate operand), so we shouldn't treat it as such. Comments are already converted to AsmToken::EndOfStatement by AsmLexer::LexLineComment, so this check was unnecessary. Differential Revision: https://reviews.llvm.org/D36405 llvm-svn: 311326
* Revert "[AsmParser] Hash is not a comment on some targets"Ahmed Bougacha2017-08-102-0/+18
| | | | | | | | This reverts commit r310457. It causes clang-produced IR to fail llvm codegen. llvm-svn: 310662
* [AsmParser] Hash is not a comment on some targetsOliver Stannard2017-08-092-18/+0
| | | | | | | | | | | | The '#' token is not a comment for all targets (on ARM and AArch64 it marks an immediate operand), so we shouldn't treat it as such. Comments are already converted to AsmToken::EndOfStatement by AsmLexer::LexLineComment, so this check was unnecessary. Differential Revision: https://reviews.llvm.org/D36405 llvm-svn: 310457
* [AsmParser][GAS-compatibility] Ignore an empty 'p2align' directiveCoby Tayree2017-08-021-1/+8
| | | | | | | | | GAS ignores the aforementioned issue this patch aligns LLVM + throws in an appropriate warning Differential Revision: https://reviews.llvm.org/D36060 llvm-svn: 309841
* MC: add support for cfi_return_columnSaleem Abdulrasool2017-07-281-0/+15
| | | | | | | | | This adds support for the CFI pseudo-op return_column. This specifies the frame table column which contains the return address. Addresses PR33953! llvm-svn: 309360
* MC: clang-format enumeration (NFC)Saleem Abdulrasool2017-07-281-29/+146
| | | | | | | This was hard to insert elements into. clang-format it so that it is easier. NFC. llvm-svn: 309359
* MC, Object: Reserve a section type, SHT_LLVM_ODRTAB, for the ODR table.Peter Collingbourne2017-06-141-0/+2
| | | | | | | | | | | | | | This is part of the ODR checker proposal: http://lists.llvm.org/pipermail/llvm-dev/2017-June/113820.html Per discussion on the gnu-gabi mailing list [1] the section type range 0x6fff4c00..0x6fff4cff is reserved for LLVM. [1] https://sourceware.org/ml/gnu-gabi/2017-q2/msg00030.html Differential Revision: https://reviews.llvm.org/D33978 llvm-svn: 305407
* [MC] Fix compiler crash in AsmParser::LexNirav Dave2017-06-091-2/+2
| | | | | | | | | | | | | | | | When an empty comment is present in an assembly file, the compiler will crash because it checks the first character for '\n' or '\r'. The fix consists of also checking if the string is empty before accessing the *front* method of the StringRef. A test is included for the x86 target, but this issue is reproducible with other targets as well. Patch by Alexandru Guduleasa! Reviewers: niravd, grosbach, llvm-commits Reviewed By: niravd Differential Revision: https://reviews.llvm.org/D33993 llvm-svn: 305077
* Move Object format code to lib/BinaryFormat.Zachary Turner2017-06-074-4/+4
| | | | | | | | | | | | This creates a new library called BinaryFormat that has all of the headers from llvm/Support containing structure and layout definitions for various types of binary formats like dwarf, coff, elf, etc as well as the code for identifying a file from its magic. Differential Revision: https://reviews.llvm.org/D33843 llvm-svn: 304864
* Sort the remaining #include lines in include/... and lib/....Chandler Carruth2017-06-068-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | I did this a long time ago with a janky python script, but now clang-format has built-in support for this. I fed clang-format every line with a #include and let it re-sort things according to the precise LLVM rules for include ordering baked into clang-format these days. I've reverted a number of files where the results of sorting includes isn't healthy. Either places where we have legacy code relying on particular include ordering (where possible, I'll fix these separately) or where we have particular formatting around #include lines that I didn't want to disturb in this patch. This patch is *entirely* mechanical. If you get merge conflicts or anything, just ignore the changes in this patch and run clang-format over your #include lines in the files. Sorry for any noise here, but it is important to keep these things stable. I was seeing an increasing number of patches with irrelevant re-ordering of #include lines because clang-format was used. This patch at least isolates that churn, makes it easy to skip when resolving conflicts, and gets us to a clean baseline (again). llvm-svn: 304787
* chang type from 'int' to 'size_t'. This will fix revision number 302652Michael Zuckerman2017-05-101-1/+1
| | | | llvm-svn: 302660
* [LLVM][inline-asm] Altmacro string escape character '!'Michael Zuckerman2017-05-101-0/+21
| | | | | | | | | | | | | This patch is the fourth patch in a series of reviews for the Altmacro feature. This patch introduces a new escape character '!' and it depends on D32701. according to https://sourceware.org/binutils/docs/as/Altmacro.html: "single-character string escape To include any single character literally in a string (even if the character would otherwise have some special meaning), you can prefix the character with !' (an exclamation mark). For example, you can write <4.3 !> 5.4!!>' to get the literal text `4.3 > 5.4!'. " Differential Revision: https://reviews.llvm.org/D32792 llvm-svn: 302652
* [LLVM][inline-asm][Altmacor] Altmacro string delimiter '<..>'Michael Zuckerman2017-05-041-4/+38
| | | | | | | | | | | | | | | | | | | | | | | | In this patch, I introduce a new altmacro string delimiter. This review is the second review in a series of four reviews. (one for each altmacro feature: LOCAL, string delimiter, string '!' escape sign and absolute expression as a string '%' ). In the alternate macro mode, you can delimit strings with matching angle brackets <..> when using it as a part of calling macro arguments. As described in the https://sourceware.org/binutils/docs-2.27/as/Altmacro.html "<string> You can delimit strings with matching angle brackets." assumptions: 1. If an argument begins with '<' and ends with '>'. The argument is considered as a string. 2. Except adding new string mark '<..>', a regular macro behavior is expected. 3. The altmacro cannot affect the regular less/greater behavior. 4. If a comma is present inside an angle brackets it considered as a character and not as a separator. Differential Revision: https://reviews.llvm.org/D32701 llvm-svn: 302135
* [LLVM][inline-asm] Altmacro absolute expression '%' featureMichael Zuckerman2017-05-012-7/+51
| | | | | | | | | | | | | | | | | | | | | In this patch, I introduce a new alt macro feature. This feature adds meaning for the % when using it as a prefix to the calling macro arguments. In the altmacro mode, the percent sign '%' before an absolute expression convert the expression first to a string. As described in the https://sourceware.org/binutils/docs-2.27/as/Altmacro.html "Expression results as strings You can write `%expr' to evaluate the expression expr and use the result as a string." expression assumptions: 1. '%' can only evaluate an absolute expression. 2. Altmacro '%' must be the first character of the evaluated expression. 3. If no '%' is located before the expression, a regular module operation is expected. 4. The result of Absolute Expressions can be only integer. Differential Revision: https://reviews.llvm.org/D32526 llvm-svn: 301797
* PR31007 and PR27884 will be closed: a possibility to compile constants like ↵Andrew V. Tischenko2017-04-261-6/+7
| | | | | | 0bH is now supported in MS asm. llvm-svn: 301390
* Distinguish between code pointer size and DataLayout::getPointerSize() in ↵Konstantin Zhuravlyov2017-04-171-2/+2
| | | | | | DWARF info generation llvm-svn: 300463
* [AsmParser]Emit an error if a macro has two (or more) parameters sharing the ↵Coby Tayree2017-04-081-0/+6
| | | | | | | | | | | | | same name Introducing a new error to macro parameters' parsing: currently, llvm-mc won't complain if a macro have two (or more) named params with the same name. this behavior is false, as there's no merit in having some params sharing a name. now, instead of tolerate such a phenomena - emit an appropriate error. Differential Revision: https://reviews.llvm.org/D31674 llvm-svn: 299815
* [MC] Set defaults based on section names and support name suffixesPetr Hosek2017-04-041-6/+15
| | | | | | | | | | | | | Set correct default flags and section type based on its name for .text, .data, .bss, .init_array, .fini_array, .preinit_array, .tdata, and .tbss and support section name suffixes for .data.*, .rodata.*, .text.*, .bss.*, .tdata.* and .tbss.* which matches the behavior of GAS. Fixes PR31888. Differential Revision: https://reviews.llvm.org/D30229 llvm-svn: 299484
* Change section flag character for SHF_LINK_ORDER to "o".Evgeniy Stepanov2017-04-041-1/+1
| | | | | | | | GAS uses "m" as a compatibility alias for "M" (SHF_MERGE). "o" is free, except on ia64, where it already means SHF_LINK_ORDER. llvm-svn: 299479
* [X86][inline-asm] Add support for MS 'EVEN' directiveCoby Tayree2017-04-041-1/+1
| | | | | | | | | | | | MS assembly syntax provide us with the 'EVEN' directive as a synonymous to at&t '.even'. This patch include the (small, simple) changes need to allow it. Test is provided at the following (clang-side) review: https://reviews.llvm.org/D27418 Differential Revision: https://reviews.llvm.org/D27417 llvm-svn: 299453
* Add default typo to .tbss.*Rafael Espindola2017-03-221-0/+2
| | | | | | This matches gas behavior and is part of pr31888. llvm-svn: 298508
* Set the default type for .bss.foo.Rafael Espindola2017-03-221-0/+2
| | | | | | This matches gas and is part of pr31888. llvm-svn: 298506
* Produce INIT_ARRAY for sections named .init_array.*Rafael Espindola2017-03-221-1/+5
| | | | | | | These sections are merged together by the linker, so they should have the same time. llvm-svn: 298505
* [Asm] Don't list '@<type>' in diag when '@' is a commentOliver Stannard2017-03-171-2/+6
| | | | | | | | This fixes https://bugs.llvm.org//show_bug.cgi?id=31280 Differential revision: https://reviews.llvm.org/D31026 llvm-svn: 298067
* Fix asm printing of associated sections.Evgeniy Stepanov2017-03-141-8/+8
| | | | | | | Make MCSectionELF::AssociatedSection be a link to a symbol, because that's how it works in the assembly, and use it in the asm printer. llvm-svn: 297769
* [Assembler] Add location info to unary expressions.Sanne Wouda2017-03-101-4/+4
| | | | | | | | | | | | | | | | | Summary: This is a continuation of D28861. Add an SMLoc to MCUnaryExpr such that a better diagnostic can be given in case of an error in later stages of assembling. Reviewers: rengolin, grosbach, javed.absar, olista01 Reviewed By: olista01 Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D30581 llvm-svn: 297454
* [MC] Accept a numeric value as an ELF section header's typeSimon Atanasyan2017-03-101-2/+5
| | | | | | | | | | | | | | | | | | | | | | GAS supports specification of section header's type using a numeric value [1]. This patch brings the same functionality to LLVM. That allows to setup some target-specific section types belong to the SHT_LOPROC - SHT_HIPROC range. If we attempt to print unknown section type, MCSectionELF class shows an error message. It's better than print sole '@' sign without any section type name. In case of MIPS, example of such section's type is SHT_MIPS_DWARF. Without the patch we will have to implement some workarounds in probably not-MIPS-specific part of code base to convert SHT_MIPS_DWARF to the @progbits while printing assembly and to assign SHT_MIPS_DWARF for @progbits sections named .debug_* if we encounter such section in an input assembly. [1] https://sourceware.org/binutils/docs/as/Section.html Differential Revision: https://reviews.llvm.org/D29719 llvm-svn: 297446
* Perform symbol binding for .symver versioned symbolsTeresa Johnson2017-03-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: In a .symver assembler directive like: .symver name, name2@@nodename "name2@@nodename" should get the same symbol binding as "name". While the ELF object writer is updating the symbol binding for .symver aliases before emitting the object file, not doing so when the module inline assembly is handled by the RecordStreamer is causing the wrong behavior in *LTO mode. E.g. when "name" is global, "name2@@nodename" must also be marked as global. Otherwise, the symbol is skipped when iterating over the LTO InputFile symbols (InputFile::Symbol::shouldSkip). So, for example, when performing any *LTO via the gold-plugin, the versioned symbol definition is not recorded by the plugin and passed back to the linker. If the object was in an archive, and there were no other symbols needed from that object, the object would not be included in the final link and references to the versioned symbol are undefined. The llvm-lto2 tests added will give an error about an unused symbol resolution without the fix. Reviewers: rafael, pcc Reviewed By: pcc Subscribers: mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D30485 llvm-svn: 297332
* [WebAssembly] Add skeleton MC support for the Wasm container formatDan Gohman2017-02-221-0/+3
| | | | | | | | | 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 llvm-svn: 295803
* Move some error handling down to MCStreamer.Rafael Espindola2017-02-101-7/+1
| | | | | | | | | 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. llvm-svn: 294752
* [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other ↵Eugene Zelenko2017-02-107-69/+123
| | | | | | minor fixes (NFC). llvm-svn: 294685
* Make it possible to set SHF_LINK_ORDER explicitly.Rafael Espindola2017-02-091-2/+25
| | | | | | | This will make it possible to add support for gcing user metadata (asan for example). llvm-svn: 294589
* [Assembler] Enable nicer diagnostics for inline assembly.Sanne Wouda2017-02-081-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 294458
* Revert "[Assembler] Enable nicer diagnostics for inline assembly."Diana Picus2017-02-081-10/+5
| | | | | | This reverts commit r294433 because it seems it broke the buildbots. llvm-svn: 294448
* [Assembler] Enable nicer diagnostics for inline assembly.Sanne Wouda2017-02-081-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 294433
* [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other ↵Eugene Zelenko2017-02-072-15/+26
| | | | | | minor fixes (NFC). llvm-svn: 294369
* Change how we handle section symbols on ELF.Rafael Espindola2017-02-021-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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. llvm-svn: 293936
* Move more code to helper functions. NFC.Rafael Espindola2017-01-311-39/+60
| | | | llvm-svn: 293715
* Move some code to a helper function. NFC.Rafael Espindola2017-01-311-48/+59
| | | | llvm-svn: 293712
* Cleanup dump() functions.Matthias Braun2017-01-281-1/+4
| | | | | | | | | | | | | | | | | | 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 llvm-svn: 293359
* [Assembler] Improve error when unable to evaluate expression.Chad Rosier2017-01-191-2/+3
| | | | | | | | | 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 llvm-svn: 292515
* Apply clang-tidy's performance-unnecessary-value-param to LLVM.Benjamin Kramer2017-01-131-1/+1
| | | | | | | With some minor manual fixes for using function_ref instead of std::function. No functional change intended. llvm-svn: 291904
* Reapply "[CodeGen] Fix invalid DWARF info on Win64"Keno Fischer2017-01-021-1/+14
| | | | | | | This reapplies rL289013 (reverted in rL289014) with the fixes identified in D21731. Should hopefully pass the buildbots this time. llvm-svn: 290809
* Allow ELF section flags to be specified numericallyPrakhar Bahuguna2016-12-151-0/+4
| | | | | | | | | | | | | | | | | Summary: GAS already allows flags for sections to be specified directly as a numeric value. This functionality is particularly useful for setting processor or application-specific values that may not be directly supported or understood by LLVM. This patch allows LLVM to use numeric section flag values verbatim if specified by the assembly file. Reviewers: grosbach, rafael, t.p.northover, rengolin Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D27451 llvm-svn: 289785
* [ARM] Implement execute-only support in CodeGenPrakhar Bahuguna2016-12-151-0/+3
| | | | | | | | | | | | | | | | | | | | This implements execute-only support for ARM code generation, which prevents the compiler from generating data accesses to code sections. The following changes are involved: * Add the CodeGen option "-arm-execute-only" to the ARM code generator. * Add the clang flag "-mexecute-only" as well as the GCC-compatible alias "-mpure-code" to enable this option. * When enabled, literal pools are replaced with MOVW/MOVT instructions, with VMOV used in addition for floating-point literals. As the MOVT instruction is required, execute-only support is only available in Thumb mode for targets supporting ARMv8-M baseline or Thumb2. * Jump tables are placed in data sections when in execute-only mode. * The execute-only text section is assigned section ID 0, and is marked as unreadable with the SHF_ARM_PURECODE flag with symbol 'y'. This also overrides selection of ELF sections for globals. llvm-svn: 289784
* Replace APFloatBase static fltSemantics data members with getter functionsStephan Bergmann2016-12-141-5/+5
| | | | | | | | | | | | | At least the plugin used by the LibreOffice build (<https://wiki.documentfoundation.org/Development/Clang_plugins>) indirectly uses those members (through inline functions in LLVM/Clang include files in turn using them), but they are not exported by utils/extract_symbols.py on Windows, and accessing data across DLL/EXE boundaries on Windows is generally problematic. Differential Revision: https://reviews.llvm.org/D26671 llvm-svn: 289647
* [Assembler] Better error messages for .org directiveOliver Stannard2016-12-141-2/+3
| | | | | | | | | | | | | | | | | | | | | Currently, the error messages we emit for the .org directive when the expression is not absolute or is out of range do not include the line number of the directive, so it can be hard to track down the problem if a file contains many .org directives. This patch stores the source location in the MCOrgFragment, so that it can be used for diagnostics emitted during layout. Since layout is an iterative process, and the errors are detected during each iteration, it would have been possible for errors to be reported multiple times. To prevent this, I've made the assembler bail out after each iteration if any errors have been reported. This will still allow multiple unrelated errors to be reported in the common case where they are all detected in the first round of layout. Differential Revision: https://reviews.llvm.org/D27411 llvm-svn: 289643
* Add a comment consumer mechanism to MCAsmLexerOliver Stannard2016-12-082-1/+17
| | | | | | | | | This allows clients to register an AsmCommentConsumer with the MCAsmLexer, which receives a callback each time a comment is parsed. Differential Revision: https://reviews.llvm.org/D27511 llvm-svn: 289036
* Revert "[CodeGen] Fix invalid DWARF info on Win64"Keno Fischer2016-12-081-14/+1
| | | | | | Appears to break on build bots. Reverting pending investigation. llvm-svn: 289014
* [CodeGen] Fix invalid DWARF info on Win64Keno Fischer2016-12-081-1/+14
| | | | | | | | | | | | | | | The relocations for `DIEEntry::EmitValue` were wrong for Win64 (emitting FK_Data_4 instead of FK_SecRel_4). This corrects that oversight so that the DWARF data is correct in Win64 COFF files. Fixes PR15393. Patch by Jameson Nash <jameson@juliacomputing.com> based on a patch by David Majnemer. Differential Revision: https://reviews.llvm.org/D21731 llvm-svn: 289013
OpenPOWER on IntegriCloud