aboutsummaryrefslogtreecommitdiffstats
path: root/lib/MC/MCParser
Commit message (Collapse)AuthorAgeFilesLines
...
* Refactor generic Asm directive parsing.Eli Bendersky2013-01-151-790/+802
| | | | | | | | | | | | | | | | | | | | After discussing the refactoring with Jim and Daniel, the following changes were made: * All generic directive parsing is now done by AsmParser itself. The previous division between it and GenericAsmParser did not have clear boundaries and just produced unnatural code of GenericAsmParser juggling the internals of AsmParser through an interface. The division of responsibilities is now clear: target-specific directives, other extensions (used by platform-specific parseres), and generic directives. * Priority for directive parsing was reshuffled to ask extensions first and check the generic directives later. No change in functionality. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172568 91177308-0d34-0410-b5e6-96231b3b80d8
* Now GenericAsmParser and AsmParser are no longer friends, GenericAsmParser canEli Bendersky2013-01-141-4/+0
| | | | | | | | | | simply use the getParser method from MCAsmParserExtension, working through the MCAsmParser interface. There's no longer a need to overload that method to cast it to the concrete AsmParser. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172491 91177308-0d34-0410-b5e6-96231b3b80d8
* Properly encapsulate additional methods and data from AsmParser.Eli Bendersky2013-01-141-67/+72
| | | | | | | | | | | This finally allows AsmParser to no longer list GenericAsmParser as a friend. All member vars directly accessed by GenericAsmParser have been properly encapsulated and exposed through the MCAsmParser interface. This reduces the coupling between AsmParser and GenericAsmParser. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172490 91177308-0d34-0410-b5e6-96231b3b80d8
* Move CheckForValidSection to the MCAsmParser interface.Eli Bendersky2013-01-141-1/+1
| | | | | | | | | | | | | | Now that it behaves itself in terms of streamer independence (r172450), this method can be moved to MCAsmParser to be available to all extensions, overriding, etc. -- -This line, and those below, will be ignored-- M lib/MC/MCParser/AsmParser.cpp M include/llvm/MC/MCParser/MCAsmParser.h git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172451 91177308-0d34-0410-b5e6-96231b3b80d8
* Expose an InitToTextSection through MCStreamer.Eli Bendersky2013-01-141-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The aim of this patch is to fix the following piece of code in the platform-independent AsmParser: void AsmParser::CheckForValidSection() { if (!ParsingInlineAsm && !getStreamer().getCurrentSection()) { TokError("expected section directive before assembly directive"); Out.SwitchSection(Ctx.getMachOSection( "__TEXT", "__text", MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS, 0, SectionKind::getText())); } } This was added for the "-n" option of llvm-mc. The proposed fix adds another virtual method to MCStreamer, called InitToTextSection. Conceptually, it's similar to the existing InitSections which initializes all common sections and switches to text. The new method is implemented by each platform streamer in a way that it sees fit. So AsmParser can now do this: void AsmParser::CheckForValidSection() { if (!ParsingInlineAsm && !getStreamer().getCurrentSection()) { TokError("expected section directive before assembly directive"); Out.InitToTextSection(); } } Which is much more reasonable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172450 91177308-0d34-0410-b5e6-96231b3b80d8
* Move ParseMacroArgument to the MCAsmParser interfance.Eli Bendersky2013-01-141-12/+8
| | | | | | | | | | | | | | Since it's used by extensions. One further step to fully decoupling GenericAsmParser from an intimate knowledge of the internals of AsmParser, pointing it to the MCASmParser interface instead (like all other parser extensions do). Since this change moves the MacroArgument type to the interface header, it's renamed to be a bit more descriptive in a general context. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172449 91177308-0d34-0410-b5e6-96231b3b80d8
* Encapsulate the MacroEnabled flag in AsmParser behind accessor methods.Eli Bendersky2013-01-141-4/+7
| | | | | | | | | | The methods are also exposed via the MCAsmParser interface, which allows more than one client to control them. Previously, GenericAsmParser was playing with a member var in AsmParser directly (by virtue of being its friend). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172440 91177308-0d34-0410-b5e6-96231b3b80d8
* Stop hiding the interface-exposed EatToEndOfStatement (see r172276).Eli Bendersky2013-01-121-2/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172277 91177308-0d34-0410-b5e6-96231b3b80d8
* Make ParseIdentifier a public method instead of private.Eli Bendersky2013-01-121-4/+4
| | | | | | | | | | | | | | | | | | | | The MCAsmParser interface defines ParseIdentifier is public. There's no reason whatsoever for AsmParser (which implements the MCAsmParser interface) to hide this method. This is all part of a bigger scheme. Several asm parsing "extensions" use the main parser properly through the MCAsmParser interface. However, GenericAsmParser has much more exclusive access and uses implementation details from the concrete implementation - AsmParser, in which it is also declared as a friend. This makes for overly coupled code, and even makes it hard to split GenericAsmParser into a separate file. There's no reason why GenericAsmParser shouldn't be able to access AsmParser through an abstract interface, as long as it's actually registered as an extension. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172276 91177308-0d34-0410-b5e6-96231b3b80d8
* Proof of concept moving of generic directive parsing from AsmParser to theEli Bendersky2013-01-111-41/+38
| | | | | | | | | | GenericAsmParser extension, where a lot of directives are already being parsed. The end goal is having just a single place (and a single lookup table) for all directive parsing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172268 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r172153, "llvm/lib/MC/MCParser/AsmParser.cpp: [ms-inline-asm] Fix a ↵NAKAMURA Takumi2013-01-111-4/+2
| | | | | | | | couple of undefined behaviors. Operand->needAddressOf() is not initialized at !Operand->isReg()." It has been redundant since r172157. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172166 91177308-0d34-0410-b5e6-96231b3b80d8
* llvm/lib/MC/MCParser/AsmParser.cpp: [ms-inline-asm] Fix a couple of ↵NAKAMURA Takumi2013-01-111-2/+4
| | | | | | undefined behaviors. Operand->needAddressOf() is not initialized at !Operand->isReg(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172153 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename enumerations s/VK/DK/ to conform to naming conventionEli Bendersky2013-01-101-153/+153
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172149 91177308-0d34-0410-b5e6-96231b3b80d8
* fix comments a bitEli Bendersky2013-01-101-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172146 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove a couple of if-else chains in parsing directives, replacing them by aEli Bendersky2013-01-101-149/+240
| | | | | | | | switch. Committed with Jim's and Chris's approval. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172136 91177308-0d34-0410-b5e6-96231b3b80d8
* [ms-inline asm] Add support for calling functions from inline assembly.Chad Rosier2013-01-101-12/+13
| | | | | | Part of rdar://12991541 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172121 91177308-0d34-0410-b5e6-96231b3b80d8
* These functions have default arguments of 0 for the last arg. UseEric Christopher2013-01-091-2/+2
| | | | | | them. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171933 91177308-0d34-0410-b5e6-96231b3b80d8
* Add the align_to_end option to .bundle_lock in the MC implementation of alignedEli Bendersky2013-01-071-4/+20
| | | | | | | | | | bundling. The document describing this feature and the implementation has also been updated: https://sites.google.com/a/chromium.org/dev/nativeclient/pnacl/aligned-bundling-support-in-llvm git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171797 91177308-0d34-0410-b5e6-96231b3b80d8
* [ms-inline asm] Make sure the NullStreamParser doesn't try to emit labels whenChad Rosier2013-01-071-1/+2
| | | | | | parsing MS-style inline assembly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171784 91177308-0d34-0410-b5e6-96231b3b80d8
* Change SMRange to be half-open (exclusive end) instead of closed (inclusive)Jordan Rose2013-01-072-11/+12
| | | | | | | | | | This is necessary not only for representing empty ranges, but for handling multibyte characters in the input. (If the end pointer in a range refers to a multibyte character, should it point to the beginning or the end of the character in a char array?) Some of the code in the asm parsers was already assuming this anyway. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171765 91177308-0d34-0410-b5e6-96231b3b80d8
* Aligned bundling support. Following the discussion here:Eli Bendersky2012-12-201-0/+67
| | | | | | | | | | | | http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-December/056754.html The proposal and implementation are fully documented here: https://sites.google.com/a/chromium.org/dev/nativeclient/pnacl/aligned-bundling-support-in-llvm Tests will follow shortly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170718 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support for passing -main-file-name all the way through toEric Christopher2012-12-181-1/+2
| | | | | | | | the assembler. Part of PR14624 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170390 91177308-0d34-0410-b5e6-96231b3b80d8
* Cleanup formatting and whitespace.Eric Christopher2012-12-181-9/+10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170389 91177308-0d34-0410-b5e6-96231b3b80d8
* fix indentationEli Bendersky2012-12-171-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170381 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach MachO which sections contain codeTim Northover2012-12-171-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170349 91177308-0d34-0410-b5e6-96231b3b80d8
* [ms-inline asm] Make sure we fail gracefully on parse errors. Parse errorsChad Rosier2012-12-121-2/+9
| | | | | | | | should only occur on invalid input. Instruction matching errors aren't unexpected, so we can't rely on the AsmParsers HadError variable directly. rdar://12840278 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170037 91177308-0d34-0410-b5e6-96231b3b80d8
* Use the new script to sort the includes of every file under lib.Chandler Carruth2012-12-034-10/+10
| | | | | | | | | | | | | | | | | Sooooo many of these had incorrect or strange main module includes. I have manually inspected all of these, and fixed the main module include to be the nearest plausible thing I could find. If you own or care about any of these source files, I encourage you to take some time and check that these edits were sensible. I can't have broken anything (I strictly added headers, and reordered them, never removed), but they may not be the headers you'd really like to identify as containing the API being implemented. Many forward declarations and missing includes were added to a header files to allow them to parse cleanly when included first. The main module rule does in fact have its merits. =] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169131 91177308-0d34-0410-b5e6-96231b3b80d8
* MC/AsmParser: Avoid unnecessary use of SourceMgr::FindBufferForLoc()Daniel Dunbar2012-12-011-7/+21
| | | | | | | | - Each macro instantiation introduces a new buffer, and FindBufferForLoc() is linear, so previously macro instantiation could be N^2 for some pathological inputs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169073 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support for .cfi_register now that it is easy to extent the representationRafael Espindola2012-11-251-0/+26
| | | | | | | to support it. Original patch with the parsing and plumbing by the PaX team and Roman Divacky. I added the bits in MCDwarf.cpp and the test. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168565 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement .cfi_undefined. Based on a patch from PaX team, updated byRafael Espindola2012-11-231-0/+17
| | | | | | Roman Divacky. I just added the testcase. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168520 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix for PR14264 cause by commit r167237 which did not take into account aKevin Enderby2012-11-051-1/+3
| | | | | | | | | possible buffer change with a .macro directive. rdar://12637628 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167408 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support for generating dwarf debugging info with assembly filesKevin Enderby2012-11-011-2/+19
| | | | | | | | | | | | run through the 'C' preprocessor. That is pick up the file name and line numbers from the cpp hash file line comments for the dwarf file and line numbers tables. rdar://9275556 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167237 91177308-0d34-0410-b5e6-96231b3b80d8
* [ms-inline asm] Add support for the TYPE operator.Chad Rosier2012-10-261-5/+10
| | | | | | | Part of rdar://12576868 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166790 91177308-0d34-0410-b5e6-96231b3b80d8
* [ms-inline asm] Have the target AsmParser create the asmrewrite for the offsetofChad Rosier2012-10-261-6/+0
| | | | | | operator. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166779 91177308-0d34-0410-b5e6-96231b3b80d8
* [ms-inline asm] Add support for creating AsmRewrites in the target specificChad Rosier2012-10-251-25/+8
| | | | | | AsmParser logic. To be used/tested in a subsequent commit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166714 91177308-0d34-0410-b5e6-96231b3b80d8
* [ms-inline asm] Create a register operand, rather than a memory operand when weChad Rosier2012-10-241-2/+2
| | | | | | | | | | | | see the offsetof operator. Previously, we were matching something like MOVrm in the front-end and later matching MOVrr in the back-end. This change makes things more consistent. It also fixes cases where we can't match against a memory operand as the source (test cases coming). Part of rdar://12470317 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166592 91177308-0d34-0410-b5e6-96231b3b80d8
* [ms-inline asm] Add an implementation of the offset operator. This is a followChad Rosier2012-10-231-19/+38
| | | | | | | on patch to r166433. rdar://12470317 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166488 91177308-0d34-0410-b5e6-96231b3b80d8
* [ms-inline-asm] Implement _emit directive (which is roughly equivalent to ↵Eli Friedman2012-10-221-44/+68
| | | | | | | | | | .byte). <rdar://problem/12470345>. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166451 91177308-0d34-0410-b5e6-96231b3b80d8
* [ms-inline asm] Don't rewrite out parts of an inline-asm skipped by .if 0 ↵Eli Friedman2012-10-221-24/+1
| | | | | | | | | | and friends. It's unnecessary and makes the generated assembly less faithful to the original source. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166440 91177308-0d34-0410-b5e6-96231b3b80d8
* [ms-inline asm] Rename AsmOpRewrite to just AsmRewrite to be more generic. ↵Chad Rosier2012-10-201-13/+13
| | | | | | No functional change intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166360 91177308-0d34-0410-b5e6-96231b3b80d8
* [ms-inline asm] If the state of the parser is ignore, then don't parse theChad Rosier2012-10-201-2/+25
| | | | | | | | inline assembly. Also make sure the remove the ignored statements from the IR. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166357 91177308-0d34-0410-b5e6-96231b3b80d8
* [ms-inline asm] Continue parsing even when we're in an ignore block.Chad Rosier2012-10-191-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166352 91177308-0d34-0410-b5e6-96231b3b80d8
* [ms-inline asm] Reset the opcode prior to parsing a statement.Chad Rosier2012-10-191-1/+6
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166349 91177308-0d34-0410-b5e6-96231b3b80d8
* [ms-inline asm] Have the TargetParser callback to Sema to determine the size ofChad Rosier2012-10-191-11/+35
| | | | | | | | | a memory operand. Retain this information and then add the sizing directives to the IR. This allows the backend to do proper instruction selection. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166316 91177308-0d34-0410-b5e6-96231b3b80d8
* [ms-inline asm] Add the isParsingInlineAsm() function to the MCAsmTargetParser.Chad Rosier2012-10-191-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166292 91177308-0d34-0410-b5e6-96231b3b80d8
* Pacify -Wnon-virtual-dtor.Nick Lewycky2012-10-191-0/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166270 91177308-0d34-0410-b5e6-96231b3b80d8
* [ms-inline asm] Add a size argument to the LookupInlineAsmIdentifier() callback,Chad Rosier2012-10-181-1/+3
| | | | | | | | which will be used by the asm matcher in the near future. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166222 91177308-0d34-0410-b5e6-96231b3b80d8
* [ms-inline asm] Have the LookupInlineAsmIdentifier() callback function return aChad Rosier2012-10-181-24/+13
| | | | | | | | *NamedDecl. In turn, build the expressions after we're finished parsing the asm. This avoids a crasher if the lookup fails. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166212 91177308-0d34-0410-b5e6-96231b3b80d8
* [ms-inline asm] Move most of the AsmParsing logic in clang back into the MCChad Rosier2012-10-181-18/+201
| | | | | | | | | layer. Add the ParseMSInlineAsm() function, which is the new interface to clang. Also expose the new MCAsmParserSemaCallback interface, which is used by the back-end to do name lookup in Sema. Finally, remove the now defunct APIs introduced in r165946. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166183 91177308-0d34-0410-b5e6-96231b3b80d8
* [ms-inline asm] Add the helper function, isParseringInlineAsm(). To be used ↵Chad Rosier2012-10-161-0/+1
| | | | | | in a future commit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166054 91177308-0d34-0410-b5e6-96231b3b80d8