summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCParser
Commit message (Collapse)AuthorAgeFilesLines
...
* [AsmParser] Diagnose empty symbol for .set directiveWeiming Zhao2016-12-011-0/+3
| | | | | | | | | | | | Summary: Diagnose empty symbol to avoid hitting assertion in MCContext::getOrCreateSymbol Reviewers: eli.friedman, rengolin Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D26728 llvm-svn: 288390
* Fix Clang-tidy readability-redundant-string-cstr warningsMalcolm Parsons2016-11-021-1/+1
| | | | | | | | | | Reviewers: beanz, lattner, jlebar Subscribers: jholewinski, llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D26235 llvm-svn: 285832
* [MC] Fix comma typo in .loc parsingNirav Dave2016-10-261-1/+1
| | | | llvm-svn: 285214
* [MC] Fix Various End Of Line Comment checkingsNirav Dave2016-10-242-340/+286
| | | | | | | | | | | | | Fix AsmParser lines to correctly handle end-of-line pre-processor comments parsing when '#' is not the assembly line comment prefix. Reviewers: rnk Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D25567 llvm-svn: 284978
* Tidy the calls to getCurrentSection().first -> getCurrentSectionOnly to helpEric Christopher2016-10-143-8/+8
| | | | | | readability a bit. llvm-svn: 284202
* [MC] Fix Error Location for ParseIdentifierNirav Dave2016-10-121-4/+11
| | | | | | | Prevent partial parsing of '$' or '@' of invalid identifiers and fixup workaround points. NFC Intended. llvm-svn: 284017
* Add return type for checkForValidSection parsing function. NFC Intended.Nirav Dave2016-10-101-41/+35
| | | | llvm-svn: 283761
* Use StringRef in DarwinAsmParser (NFC)Mehdi Amini2016-10-051-4/+3
| | | | llvm-svn: 283283
* Prevent out of order HashDirective lexing in AsmLexer.Nirav Dave2016-10-031-26/+17
| | | | | | | | | | | | | | | | | | | Retrying after buildbot reset. To lex hash directives we peek ahead to find component tokens, create a unified token, and unlex the peeked tokens so the parser does not need to parse the tokens then. Make sure we do not to lex another hash directive during peek operation. This fixes PR28921. Reviewers: rnk, loladiro Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D24839 llvm-svn: 283111
* Revert "[MC] Prevent out of order HashDirective lexing in AsmLexer."Nirav Dave2016-10-011-17/+26
| | | | | | This reverts commit r282992 which appears to be causing an LTO test failure. llvm-svn: 283034
* Use StringRef instead of raw pointers in MCAsmInfo/MCInstrInfo APIs (NFC)Mehdi Amini2016-10-011-3/+3
| | | | llvm-svn: 283018
* [MC] Prevent out of order HashDirective lexing in AsmLexer.Nirav Dave2016-10-011-26/+17
| | | | | | | | | | | | | | | | | To lex hash directives we peek ahead to find component tokens, create a unified token, and unlex the peeked tokens so the parser does not need to parse the tokens then. Make sure we do not to lex another hash directive during peek operation. This fixes PR28921. Reviewers: rnk, loladiro Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D24839 llvm-svn: 282992
* [MC] Support .ds directives in assembler parserPetr Hosek2016-09-231-0/+49
| | | | | | | | These directives are already supported by GNU assembler. Differential Revision: https://reviews.llvm.org/D24740 llvm-svn: 282303
* [MC] Support .dcb directives in assembler parserPetr Hosek2016-09-231-35/+149
| | | | | | | | These directives are already supported by GNU assembler. Differential Revision: https://reviews.llvm.org/D24741 llvm-svn: 282283
* [MC] Support skip and count for .incbin directivePetr Hosek2016-09-231-7/+45
| | | | | | | | These optional arguments are supported by GNU assembler. Differential Revision: https://reviews.llvm.org/D24714 llvm-svn: 282217
* Defer asm errors to post-statement failureNirav Dave2016-09-163-129/+147
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Recommitting after fixing AsmParser initialization and X86 inline asm error cleanup. Allow errors to be deferred and emitted as part of clean up to simplify and shorten Assembly parser code. This will allow error messages to be emitted in helper functions and be modified by the caller which has better context. As part of this many minor cleanups to the Parser: * Unify parser cleanup on error * Add Workaround for incorrect return values in ParseDirective instances * Tighten checks on error-signifying return values for parser functions and fix in-tree TargetParsers to be more consistent with the changes. * Fix AArch64 test cases checking for spurious error messages that are now fixed. These changes should be backwards compatible with current Target Parsers so long as the error status are correctly returned in appropriate functions. Reviewers: rnk, majnemer Subscribers: aemerson, jyknight, llvm-commits Differential Revision: https://reviews.llvm.org/D24047 llvm-svn: 281762
* [MC] Handle discardable COFF sections in assemblyReid Kleckner2016-09-141-13/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This fixes a dumpbin warning on objects produced by the MC assembler when starting from text. All .debug$S sections are supposed to be marked IMAGE_SCN_MEM_DISCARDABLE. The main, non-COMDAT .debug$S section had this set, but any comdat ones were not being marked discardable because there was no .section flag for it. This change does two things: - If the section name starts with .debug, implicitly mark the section as discardable. This means we do the same thing as gas on .s files with DWARF from GCC, which is important. - Adds the 'D' flag to the .section directive on COFF to explicitly say a section is discardable. We only emit this flag if the section name does not start with .debug. This allows the user to explicitly tweak their section flags without worrying about magic section names. The only thing you can't do in this scheme is to create a non-discardable section with a name starting with ".debug", but hopefully users don't need that. Reviewers: majnemer, rafael Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D24582 llvm-svn: 281554
* Revert r281336 (and r281337), it caused PR30372.Nico Weber2016-09-133-147/+129
| | | | llvm-svn: 281361
* Apply Clang-format to MCAsmParser.cpp NFC.Nirav Dave2016-09-131-1/+2
| | | | llvm-svn: 281337
* Defer asm errors to post-statement failureNirav Dave2016-09-133-129/+146
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Recommitting after fixing AsmParser Initialization. Allow errors to be deferred and emitted as part of clean up to simplify and shorten Assembly parser code. This will allow error messages to be emitted in helper functions and be modified by the caller which has better context. As part of this many minor cleanups to the Parser: * Unify parser cleanup on error * Add Workaround for incorrect return values in ParseDirective instances * Tighten checks on error-signifying return values for parser functions and fix in-tree TargetParsers to be more consistent with the changes. * Fix AArch64 test cases checking for spurious error messages that are now fixed. These changes should be backwards compatible with current Target Parsers so long as the error status are correctly returned in appropriate functions. Reviewers: rnk, majnemer Subscribers: aemerson, jyknight, llvm-commits Differential Revision: https://reviews.llvm.org/D24047 llvm-svn: 281336
* Temporarily Revert "[MC] Defer asm errors to post-statement failure" as it's ↵Eric Christopher2016-09-133-145/+129
| | | | | | | | causing errors on the sanitizer bots. This reverts commit r281249. llvm-svn: 281280
* [MC] Defer asm errors to post-statement failureNirav Dave2016-09-123-129/+145
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow errors to be deferred and emitted as part of clean up to simplify and shorten Assembly parser code. This will allow error messages to be emitted in helper functions and be modified by the caller which has better context. As part of this many minor cleanups to the Parser: * Unify parser cleanup on error * Add Workaround for incorrect return values in ParseDirective instances * Tighten checks on error-signifying return values for parser functions and fix in-tree TargetParsers to be more consistent with the changes. * Fix AArch64 test cases checking for spurious error messages that are now fixed. These changes should be backwards compatible with current Target Parsers so long as the error status are correctly returned in appropriate functions. Reviewers: rnk, majnemer Subscribers: aemerson, jyknight, llvm-commits Differential Revision: https://reviews.llvm.org/D24047 llvm-svn: 281249
* [codeview] Add new directives to record inlined call site line infoReid Kleckner2016-09-071-44/+125
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Previously we were trying to represent this with the "contains" list of the .cv_inline_linetable directive, which was not enough information. Now we directly represent the chain of inlined call sites, so we know what location to emit when we encounter a .cv_loc directive of an inner inlined call site while emitting the line table of an outer function or inlined call site. Fixes PR29146. Also fixes PR29147, where we would crash when .cv_loc directives crossed sections. Now we write down the section of the first .cv_loc directive, and emit an error if any other .cv_loc directive for that function is in a different section. Also fixes issues with discontiguous inlined source locations, like in this example: volatile int unlikely_cond = 0; extern void __declspec(noreturn) abort(); __forceinline void f() { if (!unlikely_cond) abort(); } int main() { unlikely_cond = 0; f(); unlikely_cond = 0; } Previously our tables gave bad location information for the 'abort' call, and the debugger wouldn't snow the inlined stack frame for 'f'. It is important to emit good line tables for this code pattern, because it comes up whenever an asan bug occurs in an inlined function. The __asan_report* stubs are generally placed after the normal function epilogue, leading to discontiguous regions of inlined code. Reviewers: majnemer, amccarth Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D24014 llvm-svn: 280822
* (LLVM part) Implement MASM-flavor intel syntax behavior for inline MS asm block:Yunzhong Gao2016-09-022-3/+46
| | | | | | | | | | | 1. 0xNN and NNh are accepted as valid hexadecimal numbers, but 0xNNh is not. 0xNN and NNh may come with optional U or L suffix. 2. NNb is accepted as a valid binary (base-2) number, but 0bNN is not. NNb may come with optional U or L suffix. Differential Revision: https://reviews.llvm.org/D22112 llvm-svn: 280555
* [MC] Move parser helper functions from Asmparser to MCAsmParserNirav Dave2016-08-302-65/+69
| | | | | | NFC Intended. llvm-svn: 280092
* [MC] Move .cv_loc management logic out of MCContextReid Kleckner2016-08-261-3/+6
| | | | | | | | | | | MCContext already has many tasks, and separating CodeView out from it is probably a good idea. The .cv_loc tracking was modelled on the DWARF tracking which lived directly in MCContext. Removes the inclusion of MCCodeView.h from MCContext.h, so now there are only 10 build actions while I hack on CodeView support instead of 265. llvm-svn: 279847
* [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-232-27/+53
| | | | | | | | other minor fixes. Differential revision: https://reviews.llvm.org/D23789 llvm-svn: 279535
* [MC] Remove guard(s). NFCI.Davide Italiano2016-08-221-2/+0
| | | | | | | All the methods are already marked with LLVM_DUMP_METHOD. llvm-svn: 279428
* 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
* 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-291-1/+1
| | | | | | seperator llvm-svn: 277146
* [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
* [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-183-426/+338
| | | | | | | | | | | | | | | 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
* [MC] Fix lexing ordering in assembly label parsing to preserve same lineNirav Dave2016-07-131-7/+7
| | | | | | comment placement. llvm-svn: 275265
* Provide support for preserving assembly commentsNirav Dave2016-07-112-1/+13
| | | | | | | | | | | | | | | | | 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/Darwin] Fix a -Wmisleading-indentation warning, reported by GCC 6.Davide Italiano2016-07-051-2/+2
| | | | llvm-svn: 274563
* Apply clang-tidy's modernize-loop-convert to lib/MC.Benjamin Kramer2016-06-261-2/+2
| | | | | | Only minor manual fixes. No functionality change intended. llvm-svn: 273814
* 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
* 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
* 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
OpenPOWER on IntegriCloud