summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC
Commit message (Collapse)AuthorAgeFilesLines
* [MC] Support .dc directives in assembler parserPetr Hosek2016-08-231-0/+26
| | | | | | | | | | While these directives are mostly aliases for the existing integer and float value directives, some of them like .dc.a have no direct equivalents and are sometimes being used for convenience. Differential Revision: https://reviews.llvm.org/D23810 llvm-svn: 279577
* Fix some Clang-tidy modernize-use-using and Include What You Use warnings; ↵Eugene Zelenko2016-08-233-37/+72
| | | | | | | | other minor fixes. Differential revision: https://reviews.llvm.org/D23789 llvm-svn: 279535
* ADT: Remove ilist_*sentinel_traits, NFCDuncan P. N. Exon Smith2016-08-221-4/+0
| | | | | | | | | | Remove all the dead code around ilist_*sentinel_traits. This is a follow-up to gutting them as part of r279314 (originally r278974), staged to prevent broken builds in sub-projects. Uses were removed from clang in r279457 and lld in r279458. llvm-svn: 279473
* [mips][ias] Support .dtprel[d]word and .tprel[d]word directivesSimon Atanasyan2016-08-224-1/+94
| | | | | | | | | | | | | Assembler directives .dtprelword, .dtpreldword, .tprelword, and .tpreldword generates relocations R_MIPS_TLS_DTPREL32, R_MIPS_TLS_DTPREL64, R_MIPS_TLS_TPREL32, and R_MIPS_TLS_TPREL64 respectively. The main motivation for this patch is to be able to write test cases for checking correctness of the LLD linker's behaviour. Differential Revision: https://reviews.llvm.org/D23669 llvm-svn: 279439
* [MC] Remove guard(s). NFCI.Davide Italiano2016-08-229-20/+0
| | | | | | | All the methods are already marked with LLVM_DUMP_METHOD. llvm-svn: 279428
* Replace a few more "fall through" comments with LLVM_FALLTHROUGHJustin Bogner2016-08-171-0/+1
| | | | | | Follow up to r278902. I had missed "fall through", with a space. llvm-svn: 278970
* Avoid accessing LLVM/DWARF register mappings if undefinedDominic Chen2016-08-121-0/+4
| | | | | | | | | | | | | | | | | Summary: If the backend does not define LLVM/DWARF register mappings, the associated variables are undefined since the map initializer is called by auto-generated TableGen routines. This patch initializes the pointers and sizes to nullptr and zero, respectively, and checks that they are valid before searching for a mapping. Reviewers: grosbach, dschuff Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D23458 llvm-svn: 278574
* Re-commit r277988: [mips][ias] Fix all the hacks related to MIPS-specific ↵Daniel Sanders2016-08-082-1/+80
| | | | | | | | | unary operators (%hi/%lo/%gp_rel/etc.). Hopefully with the MSVC builds fixed. I've added a missing '#include <tuple>' that gcc and clang don't seem to need. llvm-svn: 277995
* Revert r277988: [mips][ias] Fix all the hacks related to MIPS-specific unary ↵Daniel Sanders2016-08-082-78/+1
| | | | | | | | operators (%hi/%lo/%gp_rel/etc.). It seems that MSVC doesn't like std::tie(). llvm-svn: 277990
* [mips][ias] Fix all the hacks related to MIPS-specific unary operators ↵Daniel Sanders2016-08-082-1/+78
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (%hi/%lo/%gp_rel/etc.). Summary: They are now lexed as a single token on targets where MCAsmInfo::HasMipsExpressions is true and then parsed in a similar way to the '~' operator as part of MCExpr::parseExpression. As a result: * expressions and immediates no longer have different parsing rules. The difference is now solely down to whether evaluateAsAbsolute() succeeds. * %hi(%neg(%gp_rel(x))) are no longer parsed as a single operator and decomposed into the three MipsMCExpr nodes. They are parsed directly as three MipsMCExpr nodes. * parseMemOperand no longer needs to eat all the surrounding parenthesis to get at the outermost operator to make this work * %hi(%neg(%gp_rel(x))) and %lo(%neg(%gp_rel(x))) are no longer the only 3-in-1 relocs that parse for N64. They're still the only combinations that are permitted in relocatable expressions though. Fixing that should be a later patch. * We no longer need to list all the tokens that can occur as the first token of an expression or immediate. test/MC/Mips/expr1.s: This change also prevents the incorrect lowering of %lo(2*4)+foo to %lo(8+foo) which is not an equivalent expression (the difference is whether foo is truncated to 16-bit or not) and the test has been updated to account for the macro expansion the correct expression requires. Reviewers: sdardis Subscribers: dsanders, sdardis, llvm-commits Differential Revision: https://reviews.llvm.org/D23110 llvm-svn: 277988
* [MC] Delete use of *structors_used.Davide Italiano2016-08-082-2/+0
| | | | | | | Jim Grosbach and Kevin Enderby think those are not used anymore. Originally submitted by: Rafael Espindola llvm-svn: 277973
* [mips] Set Personality and LSDA encoding for FreeBSDDaniel Sanders2016-08-041-0/+8
| | | | | | | | | | Reviewers: seanbruno, sdardis Subscribers: tberghammer, danalbert, srhines, dsanders, sdardis, llvm-commits, seanbruno Differential Revision: https://reviews.llvm.org/D23113 llvm-svn: 277732
* Fix handling of end-of-line preprocessor comments Attempt 2Nirav Dave2016-08-021-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | Attempt 2: Retryign after Tsan.mman test fix. Attempt 1: Recommitting after fixing test. When parsing assembly where the line comment syntax is not hash, the lexer cannot distinguish between hash's that start a hash line comment and one that is part of an assembly statement and must be distinguished during parsing. Previously, this was incompletely handled by not checking for EndOfStatement at the end of statements and interpreting hash prefixed statements as comments. Change EndOfStatement Parsing to check for Hash comments and reintroduce Hash statement parsing to catch previously handled cases. Reviewers: rnk, majnemer Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D23017 llvm-svn: 277501
* Revert "[MC] Fix handling of end-of-line preprocessor comments"Nirav Dave2016-08-021-34/+0
| | | | | | | | Causes TSan failure on PPC64 This reverts commit r277459. llvm-svn: 277468
* [MC] Fix handling of end-of-line preprocessor commentsNirav Dave2016-08-021-0/+34
| | | | | | | | | | | | | | | | | | | | | | Recommitting after fixing test. When parsing assembly where the line comment syntax is not hash, the lexer cannot distinguish between hash's that start a hash line comment and one that is part of an assembly statement and must be distinguished during parsing. Previously, this was incompletely handled by not checking for EndOfStatement at the end of statements and interpreting hash prefixed statements as comments. Change EndOfStatement Parsing to check for Hash comments and reintroduce Hash statement parsing to catch previously handled cases. Reviewers: rnk, majnemer Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D23017 llvm-svn: 277459
* Revert r277408 and r277407Bruno Cardoso Lopes2016-08-021-34/+0
| | | | | | | | | | Revert r277408 "Fix test from rL277407." Revert r277407 "[MC] Fix handling of end-of-line preprocessor comments" This is currently breaking: http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/20731 llvm-svn: 277412
* [MC] Fix handling of end-of-line preprocessor commentsNirav Dave2016-08-021-0/+34
| | | | | | | | | | | | | | | | | | | | | Summary: When parsing assembly where the line comment syntax is not hash, the lexer cannot distinguish between hash's that start a hash line comment and one that is part of an assembly statement and must be distinguished during parsing. Previously, this was incompletely handled by not checking for EndOfStatement at the end of statements and interpreting hash prefixed statements as comments. Change EndOfStatement Parsing to check for Hash comments and reintroduce Hash statement parsing to catch previously handled cases. Reviewers: rnk, majnemer Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D23017 llvm-svn: 277407
* [MC] When emitting output hash comments always use standard line comment ↵Nirav Dave2016-07-292-4/+5
| | | | | | seperator llvm-svn: 277146
* Initialize PreserveAsmComments in MCTargetOptionsNirav Dave2016-07-271-1/+1
| | | | llvm-svn: 276905
* [MC] Add command-line option to choose the max nest level in asm macros.Davide Italiano2016-07-271-4/+17
| | | | | | | Submitted by: t83wCSLq Differential Revision: https://reviews.llvm.org/D22313 llvm-svn: 276842
* [MC] Don't crash when trying to emit a relocation against .bss.Davide Italiano2016-07-261-2/+2
| | | | | | Turn that into an error instead. llvm-svn: 276783
* [ARM] Implement -mimplicit-it assembler optionOliver Stannard2016-07-261-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This option, compatible with gas's -mimplicit-it, controls the generation/checking of implicit IT blocks in ARM/Thumb assembly. This option allows two behaviours that were not possible before: - When in ARM mode, emit a warning when assembling a conditional instruction that is not in an IT block. This is enabled with -mimplicit-it=never and -mimplicit-it=thumb. - When in Thumb mode, automatically generate IT instructions when an instruction with a condition code appears outside of an IT block. This is enabled with -mimplicit-it=thumb and -mimplicit-it=always. The default option is -mimplicit-it=arm, which matches the existing behaviour (allow conditional ARM instructions outside IT blocks without warning, and error if a conditional Thumb instruction is outside an IT block). The general strategy for generating IT blocks in Thumb mode is to keep a small list of instructions which should be in the IT block, and only emit them when we encounter something in the input which means we cannot continue the block. This could be caused by: - A non-predicable instruction - An instruction with a condition not compatible with the IT block - The IT block already contains 4 instructions - A branch-like instruction (including ALU instructions with the PC as the destination), which cannot appear in the middle of an IT block - A label (branching into an IT block is not legal) - A change of section, architecture, ISA, etc - The end of the assembly file. Some of these, such as change of section and end of file, are parsed outside of the ARM asm parser, so I've added a new virtual function to AsmParser to ensure any previously-parsed instructions have been emitted. The ARM implementation of this flushes the currently pending IT block. We now have to try instruction matching up to 3 times, because we cannot know if the current IT block is valid before matching, and instruction matching changes depending on the IT block state (due to the 16-bit ALU instructions, which set the flags iff not in an IT block). In the common case of not having an open implicit IT block and the instruction being matched not needing one, we still only have to run the matcher once. I've removed the ITState.FirstCond variable, because it does not store any information that isn't already represented by CurPosition. I've also updated the comment on CurPosition to accurately describe it's meaning (which this patch doesn't change). Differential Revision: https://reviews.llvm.org/D22760 llvm-svn: 276747
* [MC] Separate non-parsing operations from conditional chains. NFC.Nirav Dave2016-07-181-15/+20
| | | | llvm-svn: 275888
* [MC] Cleanup Error Handling in AsmParserNirav Dave2016-07-184-430/+342
| | | | | | | | | | | | | | | Add parseToken and compatriot functions to stitch error checks in straight linear code. As part of this fix some erronous handling of directives where the EndOfStatement token either was not checked or Lexed on termination. Reviewers: rnk, majnemer Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D22312 llvm-svn: 275795
* [codeview] Shrink inlined call site line info tablesReid Kleckner2016-07-141-5/+11
| | | | | | | | | | | For a fully inlined call chain like a -> b -> c -> d, we were emitting line info for 'd' 3 separate times: once for d's actual InlineSite line table, and twice for 'b' and 'c'. This is particularly inefficient when all these functions are in different headers, because now we need to encode the file change. Windbg was coping with our suboptimal output, so this should not be noticeable from the debugger. llvm-svn: 275502
* [MC] Fix lexing ordering in assembly label parsing to preserve same lineNirav Dave2016-07-131-7/+7
| | | | | | comment placement. llvm-svn: 275265
* Fix branch relaxation in 16-bit mode.Nirav Dave2016-07-112-3/+3
| | | | | | | | | | | | | | | Thread through MCSubtargetInfo to relaxInstruction function allowing relaxation to generate jumps with 16-bit sized immediates in 16-bit mode. This fixes PR22097. Reviewers: dwmw2, tstellarAMD, craig.topper, jyknight Subscribers: jfb, arsenm, jyknight, llvm-commits, dsanders Differential Revision: http://reviews.llvm.org/D20830 llvm-svn: 275068
* Provide support for preserving assembly commentsNirav Dave2016-07-115-3/+70
| | | | | | | | | | | | | | | | | Preserve assembly comments from input in output assembly and flags to toggle property. This is on by default for inline assembly and off in llvm-mc. Parsed comments are emitted immediately before an EOL which generally places them on the expected line. Reviewers: rtrieu, dwmw2, rnk, majnemer Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D20020 llvm-svn: 275058
* [MC, COFF] Permit a variable to be redefinedDavid Majnemer2016-07-081-19/+11
| | | | | | | | | Our assertions in WinCOFFStreamer had unexpected side effects resulting in symbols getting unexpectedly marked as used. This fixes PR28462. llvm-svn: 274941
* [MC/Darwin] Fix a -Wmisleading-indentation warning, reported by GCC 6.Davide Italiano2016-07-051-2/+2
| | | | llvm-svn: 274563
* Add support for allowing us to create uniquely identified "COMDAT" or "ELFEric Christopher2016-07-011-7/+15
| | | | | | | | | | | | | Group" sections while lowering. In particular, for ELF sections this is useful for creating function-specific groups that get merged into the same named section. Also use const Twine& instead of StringRef for the getELF functions while we're here. Differential Revision: http://reviews.llvm.org/D21743 llvm-svn: 274336
* Delete MCCodeGenInfo.Rafael Espindola2016-06-302-24/+0
| | | | | | | MC doesn't really care about CodeGen stuff, so this was just complicating target initialization. llvm-svn: 274258
* [ARM] Fix Thumb text sections' flags under COFF/WindowsRenato Golin2016-06-271-2/+5
| | | | | | | | | | | | | | | | The main issue here is that the "thumb" flag wasn't set for some of these sections, making MSVC's link.exe fails to correctly relocate code against the symbols inside these sections. link.exe could fail for instance with the "fixup is not aligned for target 'XX'" error. If linking doesn't fail, the relocation process goes wrong in the end and invalid code is generated by the linker. This patch adds Thumb/ARM information so that the right flags are set on COFF/Windows. Patch by Adrien Guinet. llvm-svn: 273880
* Apply clang-tidy's modernize-loop-convert to lib/MC.Benjamin Kramer2016-06-266-67/+56
| | | | | | Only minor manual fixes. No functionality change intended. llvm-svn: 273814
* Fix instance of -Wdelete-incompleteReid Kleckner2016-06-221-0/+1
| | | | llvm-svn: 273508
* Prune some includes from headers and sink some inline functionsReid Kleckner2016-06-223-0/+28
| | | | | | | | MCSymbol.h shouldn't pull in MCAssembler.h, just MCFragment.h. MCLinkerOptimizationHint.h shouldn't need MCMachObjectWriter.h. The rest is fixing the fallout. llvm-svn: 273507
* Delete some dead code.Rafael Espindola2016-06-212-11/+0
| | | | | | Found by gcc 6. llvm-svn: 273303
* doesSetDirectiveSuppressesReloc -> doesSetDirectiveSuppressReloc, theJoerg Sonnenberger2016-06-181-1/+1
| | | | | | former is grammatically incorrect. llvm-svn: 273100
* Refactor and cleanup Assembly Parsing / LexingNirav Dave2016-06-172-111/+114
| | | | | | | | | | | | | | | | | | | | | | | | | | Recommiting after fixing non-atomic insert to front of SmallVector in MCAsmLexer.h Add explicit Comment Token in Assembly Lexing for future support for outputting explicit comments from inline assembly. As part of this, CPPHash Directives are now explicitly distinguished from Hash line comments in Lexer. Line comments are recorded as EndOfStatement tokens, not Comment tokens to simplify compatibility with current TargetParsers. This slightly complicates comment output. This remove all lexing tasks out of the parser, does minor cleanup to remove extraneous newlines Asm Output, and some improvements white space handling. Reviewers: rtrieu, dwmw2, rnk Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D20009 llvm-svn: 273007
* [MCContext] Don't use getenv inside class constructorIgor Laevsky2016-06-171-1/+9
| | | | | | Differential Revision: http://reviews.llvm.org/D21471 llvm-svn: 273005
* Revert "Refactor and cleanup Assembly Parsing / Lexing"Nirav Dave2016-06-162-114/+111
| | | | | | | | Reverting for unexpected crashes on various platforms. This reverts commit r272953. llvm-svn: 272957
* Refactor and cleanup Assembly Parsing / LexingNirav Dave2016-06-162-111/+114
| | | | | | | | | | | | | | | | | | | | | | | Add explicit Comment Token in Assembly Lexing for future support for outputting explicit comments from inline assembly. As part of this, CPPHash Directives are now explicitly distinguished from Hash line comments in Lexer. Line comments are recorded as EndOfStatement tokens, not Comment tokens to simplify compatibility with current TargetParsers. This slightly complicates comment output. This remove all lexing tasks out of the parser, does minor cleanup to remove extraneous newlines Asm Output, and some improvements white space handling. Reviewers: rtrieu, dwmw2, rnk Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D20009 llvm-svn: 272953
* Apply most suggestions of clang-tidy's performance-unnecessary-value-paramBenjamin Kramer2016-06-081-3/+3
| | | | | | | Avoids unnecessary copies. All changes audited & pass tests with asan. No functional change intended. llvm-svn: 272190
* [codeview] Avoid emitting an empty file checksum tableReid Kleckner2016-06-081-0/+5
| | | | | | | | | | Again, the Microsoft linker does not like empty substreams. We still emit an empty string table if CodeView is enabled, but that doesn't cause problems because it always contains at least one null byte. llvm-svn: 272183
* [MC] Check the upper bound in truncate assertionPetr Hosek2016-06-041-1/+1
| | | | | | | | | | The truncateToSize function already has assertion to check the lower boundary for the number bytes, but it does not check the upper boundary which could still lead to usage errors. Differential Revision: http://reviews.llvm.org/D20755 llvm-svn: 271773
* Ignore Lexing errors in macro body definitionsNirav Dave2016-06-023-23/+36
| | | | | | | | | | | | | | | | | | | | Do not issue lexing errors found during the parsing of macro body definitions and parseIdentifier function in AsmParser. This changes the Parser to not issue a lexing error when we reach an error, but rather when it is consumed allowing us time to examine and recover from an error. As a result, of this, we stop issuing a both lexing error and a parsing error in floating-literals test. Minor tweak to parseDirectiveRealValue to favor more meaningful lexing error over less helpful parse error. Reviewers: rnk, majnemer Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D20535 llvm-svn: 271542
* [MC] Rename EmitFill to emitFillPetr Hosek2016-06-014-11/+11
| | | | | | | | This is to match the overloaded variants as well as the new style. Differential Revision: http://reviews.llvm.org/D20690 llvm-svn: 271359
* [codeview] Improve readability of type record assemblyReid Kleckner2016-05-312-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds the method MCStreamer::EmitBinaryData, which is usually an alias for EmitBytes. In the MCAsmStreamer case, it is overridden to emit hex dump output like this: .byte 0x0e, 0x00, 0x08, 0x10 .byte 0x03, 0x00, 0x00, 0x00 .byte 0x00, 0x00, 0x00, 0x00 .byte 0x00, 0x10, 0x00, 0x00 Also, when verbose asm comments are enabled, this patch prints the dump output for each comment before its record, like this: # ArgList (0x1000) { # TypeLeafKind: LF_ARGLIST (0x1201) # NumArgs: 0 # Arguments [ # ] # } .byte 0x06, 0x00, 0x01, 0x12 .byte 0x00, 0x00, 0x00, 0x00 This should make debugging easier and testing more convenient. Reviewers: aaboud Subscribers: majnemer, zturner, amccarth, aaboud, llvm-commits Differential Revision: http://reviews.llvm.org/D20711 llvm-svn: 271313
* [MC] Return early when .fill size is negativePetr Hosek2016-05-281-1/+1
| | | | | | | | | Rather than invoking emitFill with negative size, which may trigger an undefined behavior, return immediately after emitting the warning. Differential Revision: http://reviews.llvm.org/D20768 llvm-svn: 271107
* [MC] Support symbolic expressions in assembly directivesPetr Hosek2016-05-284-34/+102
| | | | | | | | | This matches the behavior of GNU assembler which supports symbolic expressions in absolute expressions used in assembly directives. Differential Revision: http://reviews.llvm.org/D20752 llvm-svn: 271102
OpenPOWER on IntegriCloud