1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 11:33:24 +02:00
Commit Graph

622 Commits

Author SHA1 Message Date
Craig Topper
dcf0462f2d Fix indentation. No functional change.
llvm-svn: 179994
2013-04-22 04:24:02 +00:00
Craig Topper
04e44a9181 Put 'else' on same line as preceding curly brace per coding standards. No functional change.
llvm-svn: 179993
2013-04-22 04:22:40 +00:00
Craig Topper
9541948bfa Remove an unreachable 'break' following a 'return'.
llvm-svn: 179991
2013-04-22 04:06:59 +00:00
Peter Collingbourne
a0d11d0e11 Add support for subsections to the ELF assembler. Fixes PR8717.
Differential Revision: http://llvm-reviews.chandlerc.com/D598

llvm-svn: 179725
2013-04-17 21:18:16 +00:00
Chad Rosier
524aa6c52d [ms-inline asm] Add the implementation for the AOK_Delete kind, which was added
in r179325.  Test case coming shortly on the clang side.
Part of rdar://13453209

llvm-svn: 179383
2013-04-12 16:26:42 +00:00
Chad Rosier
b3012065df [ms-inline asm] Remove brackets from around a symbol reference in the target
specific logic.  This makes the code much less fragile.  Test case coming on the
clang side in a moment.
rdar://13634327

llvm-svn: 179323
2013-04-11 21:49:30 +00:00
Chad Rosier
411fdc3a74 Reapply r179115, but use parsePrimaryExpression a little more judiciously.
Test cases that regressed due to r179115, plus a few more, were added in
r179182.  Original commit message below:

[ms-inline asm] Use parsePrimaryExpr in lieu of parseExpression if we need to
parse an identifier.  Otherwise, parseExpression may parse multiple tokens,
which makes it impossible to properly compute an immediate displacement.
An example of such a case is the source operand (i.e., [Symbol + ImmDisp]) in
the below example:

 __asm mov eax, [Symbol + ImmDisp]

Part of rdar://13611297

llvm-svn: 179187
2013-04-10 17:35:30 +00:00
Chad Rosier
e040ffba05 Revert r179115 as it looks to have killed the ASan tests.
llvm-svn: 179120
2013-04-09 19:59:12 +00:00
Chad Rosier
4ef6c35911 [ms-inline asm] Use parsePrimaryExpr in lieu of parseExpression if we need to
parse an identifier.  Otherwise, parseExpression may parse multiple tokens,
which makes it impossible to properly compute an immediate displacement.
An example of such a case is the source operand (i.e., [Symbol + ImmDisp]) in
the below example:

 __asm mov eax, [Symbol + ImmDisp]

The existing test cases exercise this patch.
rdar://13611297

llvm-svn: 179115
2013-04-09 19:34:59 +00:00
Chad Rosier
5ec822982c [ms-inline asm] Maintain a StringRef to reference a symbol in a parsed operand,
rather than deriving the StringRef from the Start and End SMLocs.

Using the Start and End SMLocs works fine for operands such as [Symbol], but
not for operands such as [Symbol + ImmDisp].  All existing test cases that
reference a variable exercise this patch.
rdar://13602265

llvm-svn: 179109
2013-04-09 17:53:49 +00:00
Chad Rosier
7583b0a3c3 [ms-inline asm] Add support for ImmDisp [ Symbol ] memory operands.
rdar://13521249

llvm-svn: 179030
2013-04-08 17:43:47 +00:00
Chad Rosier
f40ec930c8 Dead code.
llvm-svn: 177451
2013-03-19 22:13:05 +00:00
Chad Rosier
3019e30cac [ms-inline asm] Move the immediate asm rewrite into the target specific
logic as a QOI cleanup.  No functional change.  Tests already in place.
rdar://13456414

llvm-svn: 177446
2013-03-19 21:58:18 +00:00
Chad Rosier
c72a354062 [ms-inline asm] Remove the brackets from X86Operand in the IR. These will be
added back in by X86AsmPrinter::printIntelMemReference() during codegen.
Previously, this following example

  void t() {
    int i;
    __asm mov eax, [i]
  }

would generate the below assembly

  mov eax, dword ptr [[eax]]

which resulted in a fatal error when compiling.  Test case coming on the
clang side.
rdar://13444264

llvm-svn: 177440
2013-03-19 21:12:14 +00:00
Chad Rosier
758abf9ba0 [ms-inline asm] Move the size directive asm rewrite into the target specific
logic as a QOI cleanup.
rdar://13445327

llvm-svn: 177413
2013-03-19 17:32:17 +00:00
Manman Ren
a557c34a03 Debug Info: use SmallVector instead of std::vector in MCDwarfDirsCUMap and MCDwarfFilesCUMap
llvm-svn: 176893
2013-03-12 20:17:00 +00:00
Jim Grosbach
45dec6440d AsmParser: More generic support for integer type suffices.
For integer constants, allow 'L', 'UL' as well as 'ULL' and 'LL'. This provides
better support for shared headers between .s and .c files that define bunches
of constant values.

rdar://9321056

llvm-svn: 176118
2013-02-26 20:17:10 +00:00
Matt Beaumont-Gay
c6ce965ace 'Hexadecimal' has two 'a's and only one 'i'.
llvm-svn: 176031
2013-02-25 18:11:18 +00:00
Jim Grosbach
89c0252c2a MCParser: Update method names per coding guidelines.
s/AddDirectiveHandler/addDirectiveHandler/
s/ParseMSInlineAsm/parseMSInlineAsm/
s/ParseIdentifier/parseIdentifier/
s/ParseStringToEndOfStatement/parseStringToEndOfStatement/
s/ParseEscapedString/parseEscapedString/
s/EatToEndOfStatement/eatToEndOfStatement/
s/ParseExpression/parseExpression/
s/ParseParenExpression/parseParenExpression/
s/ParseAbsoluteExpression/parseAbsoluteExpression/
s/CheckForValidSection/checkForValidSection/

http://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly

No functional change intended.

llvm-svn: 175675
2013-02-20 22:21:35 +00:00
Benjamin Kramer
7731c957a6 MCParser: Reject .balign with non-pow2 alignments.
GNU as rejects them and there are configure scripts in the wild that check if
the assembler rejects ".align 3" to determine whether the alignment is in bytes
or powers of two.

llvm-svn: 175360
2013-02-16 15:00:16 +00:00
Joerg Sonnenberger
e67dea422d Derive ELF section type from the name in some cases where GNU as does
so.

llvm-svn: 175327
2013-02-16 00:32:53 +00:00
Chad Rosier
d630718ae9 c[ms-inline asm] It's possible to have a SizeDirective rewrite and an
Input/Output rewrite to the same location.  Make sure the SizeDirective rewrite
is performed first.  This also ensure the sort algorithm is stable.

llvm-svn: 175317
2013-02-15 22:54:16 +00:00
Benjamin Kramer
121eaac90f AsmParser: Reformat the MS asm parser to reduce nesting.
While there postpone register name printing after uniquing.
No intended functionality change.

llvm-svn: 175292
2013-02-15 20:37:21 +00:00
Rafael Espindola
ead97036ea Revert r15266. This fixes llvm.org/pr15266.
llvm-svn: 175173
2013-02-14 16:23:08 +00:00
Chad Rosier
0c12b80a10 [ms-inline asm] Add a comment about the determinism of the rewrite sort.
llvm-svn: 175082
2013-02-13 21:27:17 +00:00
Chad Rosier
5ead8d3901 [ms-inline-asm] Use an array_pod_sort, rather than a std:sort.
llvm-svn: 175063
2013-02-13 18:38:58 +00:00
Chad Rosier
271b9e136a [ms-inline-asm] Make sure the AsmRewrite list is sorted in lexical order.
rdar://13202662

llvm-svn: 175021
2013-02-13 01:03:13 +00:00
Chad Rosier
fccc6d00f0 [ms-inline-asm] Implement align directive (which is roughly equivalent to .align).
Also, allow _EMIT and __EMIT for the emit directive.  We already do the same
for TYPE, SIZE, and LENGTH.
rdar://13200215

llvm-svn: 175008
2013-02-12 21:33:51 +00:00
Guy Benyei
92dac48079 Add static cast to unsigned char whenever a character classification function is called with a signed char argument, in order to avoid assertions in Windows Debug configuration.
llvm-svn: 175006
2013-02-12 21:21:59 +00:00
Chad Rosier
3eb029b4c7 [ms-inline asm] Pass the length of the IDVal, so we can do a proper AsmRewrite.
llvm-svn: 174999
2013-02-12 19:42:32 +00:00
Chad Rosier
24b5149dc9 [ms-inline asm] Accept the emit directive as either _emit or __emit.
llvm-svn: 174998
2013-02-12 19:31:23 +00:00
Chad Rosier
5fc603a34e [ms-inline asm] Add support for lexing binary integers with a [bB] suffix.
This is complicated by backward labels (e.g., 0b can be both a backward label
and a binary zero).  The current implementation assumes [0-9]b is always a
label and thus it's possible for 0b and 1b to not be interpreted correctly for
ms-style inline assembly.  However, this is relatively simple to fix in the
inline assembly (i.e., drop the [bB]).

This patch also limits backward labels to [0-9]b, so that only 0b and 1b are
ambiguous.
Part of rdar://12470373

llvm-svn: 174983
2013-02-12 18:29:02 +00:00
Chad Rosier
0422258982 Update error message due to previous commit, r174926.
llvm-svn: 174927
2013-02-12 01:12:24 +00:00
Chad Rosier
eb4399962e [ms-inline asm] Add support for lexing hexidecimal integers with a [hH] suffix.
Part of rdar://12470373

llvm-svn: 174926
2013-02-12 01:00:01 +00:00
Kevin Enderby
042547700a Add a warning when there is a macro defintion that has named parameters but
the body does not use them and it appears the body has positional parameters.

This can cause unexpected results as in the added test case.  As the darwin
version of gas(1) which only supported positional parameters, happened to
ignore the named parameters.  Now that we want to support both styles of
macros we issue a warning in this specific case.

rdar://12861644

llvm-svn: 173199
2013-01-22 21:44:53 +00:00
Kevin Enderby
8bfddfebbb Have the integrated assembler give an error if $1 is used as an identifier in
an expression.  Currently this bug causes the line to be ignored in a
release build and an assert in a debug build.

rdar://13062484

llvm-svn: 173195
2013-01-22 21:09:20 +00:00
Daniel Dunbar
4f5f37798a [MC/Mach-O] Add AsmParser support for .linker_option directive.
llvm-svn: 172778
2013-01-18 01:25:48 +00:00
Daniel Dunbar
870ae74b9b [MC] Expose ParseEscapedString to target AsmParser implementations.
llvm-svn: 172777
2013-01-18 01:25:33 +00:00
Daniel Dunbar
0307f1c8e9 [MC] Fix 80-col violas.
llvm-svn: 172776
2013-01-18 01:25:25 +00:00
Chad Rosier
bb513e22fa [ms-inline asm] Add support for the 'SIZE' and 'LENGTH' operators.
Part of rdar://12576868

llvm-svn: 172743
2013-01-17 19:21:48 +00:00
Eli Bendersky
b713627125 Some small (and mostly cosmetic) fixes.
llvm-svn: 172640
2013-01-16 19:32:36 +00:00
Eli Bendersky
9748b9b3ad Now that GenericAsmParser was folded into AsmParser, some methods and types can
return into the safe harbor of AsmParser's private areas.

llvm-svn: 172637
2013-01-16 18:56:50 +00:00
Eli Bendersky
039d07cadd Use the ExtensionDirectiveHandler type in other places where it makes sense.
Since we already have this type it's a shame to keep dragging a pair of object
and method around explicitly.

llvm-svn: 172584
2013-01-16 00:50:52 +00:00
Chad Rosier
99207e5c20 [ms-inline asm] Address the FIXME in AsmParser.cpp.
// FIXME: Constraints are hard coded to 'm', but we need an 'r'
// constraint for addressof.  This needs to be cleaned up!

Test cases are already in place.  Specifically,
clang/test/CodeGen/ms-inline-asm.c t15(), t16(), and t24().

llvm-svn: 172569
2013-01-15 23:07:53 +00:00
Eli Bendersky
2e1c083b6f Refactor generic Asm directive parsing.
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.

llvm-svn: 172568
2013-01-15 22:59:42 +00:00
Eli Bendersky
44d6a7cbd6 Now GenericAsmParser and AsmParser are no longer friends, GenericAsmParser can
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.

llvm-svn: 172491
2013-01-14 23:43:18 +00:00
Eli Bendersky
d065fef2d9 Properly encapsulate additional methods and data from AsmParser.
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.

llvm-svn: 172490
2013-01-14 23:22:36 +00:00
Eli Bendersky
87b2978a18 Move CheckForValidSection to the MCAsmParser interface.
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

llvm-svn: 172451
2013-01-14 19:15:01 +00:00
Eli Bendersky
abe1a77c03 Expose an InitToTextSection through MCStreamer.
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.

llvm-svn: 172450
2013-01-14 19:04:57 +00:00
Eli Bendersky
38501d372e Move ParseMacroArgument to the MCAsmParser interfance.
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.

llvm-svn: 172449
2013-01-14 19:00:26 +00:00
Eli Bendersky
0b7c192145 Encapsulate the MacroEnabled flag in AsmParser behind accessor methods.
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).

llvm-svn: 172440
2013-01-14 18:08:41 +00:00
Eli Bendersky
3857c4275f Stop hiding the interface-exposed EatToEndOfStatement (see r172276).
llvm-svn: 172277
2013-01-12 00:23:24 +00:00
Eli Bendersky
326f4b5f48 Make ParseIdentifier a public method instead of private.
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.

llvm-svn: 172276
2013-01-12 00:05:00 +00:00
Eli Bendersky
70f1007034 Proof of concept moving of generic directive parsing from AsmParser to the
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.

llvm-svn: 172268
2013-01-11 22:55:28 +00:00
NAKAMURA Takumi
1a798ac8dc Revert r172153, "llvm/lib/MC/MCParser/AsmParser.cpp: [ms-inline-asm] Fix a couple of undefined behaviors. Operand->needAddressOf() is not initialized at !Operand->isReg()."
It has been redundant since r172157.

llvm-svn: 172166
2013-01-11 02:50:09 +00:00
NAKAMURA Takumi
eaffa07ccd llvm/lib/MC/MCParser/AsmParser.cpp: [ms-inline-asm] Fix a couple of undefined behaviors. Operand->needAddressOf() is not initialized at !Operand->isReg().
llvm-svn: 172153
2013-01-11 00:37:35 +00:00
Eli Bendersky
1c110a3457 Rename enumerations s/VK/DK/ to conform to naming convention
llvm-svn: 172149
2013-01-10 23:40:56 +00:00
Eli Bendersky
e4b4e5f076 fix comments a bit
llvm-svn: 172146
2013-01-10 23:32:57 +00:00
Eli Bendersky
7247cfaf23 Remove a couple of if-else chains in parsing directives, replacing them by a
switch. Committed with Jim's and Chris's approval.

llvm-svn: 172136
2013-01-10 22:44:57 +00:00
Chad Rosier
f66d08be5c [ms-inline asm] Add support for calling functions from inline assembly.
Part of rdar://12991541

llvm-svn: 172121
2013-01-10 22:10:27 +00:00
Eric Christopher
38c8e00aa9 These functions have default arguments of 0 for the last arg. Use
them.

llvm-svn: 171933
2013-01-09 01:57:54 +00:00
Eli Bendersky
4236f7b1ee Add the align_to_end option to .bundle_lock in the MC implementation of aligned
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

llvm-svn: 171797
2013-01-07 21:51:08 +00:00
Chad Rosier
515c53ac4f [ms-inline asm] Make sure the NullStreamParser doesn't try to emit labels when
parsing MS-style inline assembly.

llvm-svn: 171784
2013-01-07 20:34:12 +00:00
Jordan Rose
c95190a559 Change SMRange to be half-open (exclusive end) instead of closed (inclusive)
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.

llvm-svn: 171765
2013-01-07 19:00:49 +00:00
Eli Bendersky
b0643bbb71 Aligned bundling support. Following the discussion here:
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.

llvm-svn: 170718
2012-12-20 19:05:53 +00:00
Eric Christopher
ed859a3fb8 Add support for passing -main-file-name all the way through to
the assembler.

Part of PR14624

llvm-svn: 170390
2012-12-18 00:31:01 +00:00
Eric Christopher
41e750e835 Cleanup formatting and whitespace.
llvm-svn: 170389
2012-12-18 00:30:54 +00:00
Eli Bendersky
689b282ca8 fix indentation
llvm-svn: 170381
2012-12-17 22:50:56 +00:00
Tim Northover
5f7dc099cf Teach MachO which sections contain code
llvm-svn: 170349
2012-12-17 17:59:32 +00:00
Chad Rosier
2b1f874fc0 [ms-inline asm] Make sure we fail gracefully on parse errors. Parse errors
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

llvm-svn: 170037
2012-12-12 22:45:52 +00:00
Chandler Carruth
a490793037 Use the new script to sort the includes of every file under lib.
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. =]

llvm-svn: 169131
2012-12-03 16:50:05 +00:00
Daniel Dunbar
3d783b87ae MC/AsmParser: Avoid unnecessary use of SourceMgr::FindBufferForLoc()
- Each macro instantiation introduces a new buffer, and FindBufferForLoc() is
   linear, so previously macro instantiation could be N^2 for some pathological
   inputs.

llvm-svn: 169073
2012-12-01 01:38:48 +00:00
Rafael Espindola
81ee486113 Add support for .cfi_register now that it is easy to extent the representation
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.

llvm-svn: 168565
2012-11-25 15:14:49 +00:00
Rafael Espindola
a6e1d5393f Implement .cfi_undefined. Based on a patch from PaX team, updated by
Roman Divacky. I just added the testcase.

llvm-svn: 168520
2012-11-23 16:59:41 +00:00
Kevin Enderby
d988c6daf6 Fix for PR14264 cause by commit r167237 which did not take into account a
possible buffer change with a .macro directive.

rdar://12637628

llvm-svn: 167408
2012-11-05 21:55:41 +00:00
Kevin Enderby
efec4e2817 Add support for generating dwarf debugging info with assembly files
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

llvm-svn: 167237
2012-11-01 17:31:35 +00:00
Chad Rosier
3f9673a66a [ms-inline asm] Add support for the TYPE operator.
Part of rdar://12576868

llvm-svn: 166790
2012-10-26 18:04:20 +00:00
Chad Rosier
bcf86ecdf2 [ms-inline asm] Have the target AsmParser create the asmrewrite for the offsetof
operator.

llvm-svn: 166779
2012-10-26 16:09:20 +00:00
Chad Rosier
749087c4ca [ms-inline asm] Add support for creating AsmRewrites in the target specific
AsmParser logic.  To be used/tested in a subsequent commit.

llvm-svn: 166714
2012-10-25 20:41:34 +00:00
Chad Rosier
dcfcb1d240 [ms-inline asm] Create a register operand, rather than a memory operand when we
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

llvm-svn: 166592
2012-10-24 17:22:29 +00:00
Chad Rosier
143dbdd411 [ms-inline asm] Add an implementation of the offset operator. This is a follow
on patch to r166433.
rdar://12470317

llvm-svn: 166488
2012-10-23 17:43:43 +00:00
Eli Friedman
65c919ee7c [ms-inline-asm] Implement _emit directive (which is roughly equivalent to .byte).
<rdar://problem/12470345>.

llvm-svn: 166451
2012-10-22 23:58:19 +00:00
Eli Friedman
f906b0e674 [ms-inline asm] Don't rewrite out parts of an inline-asm skipped by .if 0 and friends.
It's unnecessary and makes the generated assembly less faithful to the original source.

llvm-svn: 166440
2012-10-22 20:50:25 +00:00
Chad Rosier
f81bc67275 [ms-inline asm] Rename AsmOpRewrite to just AsmRewrite to be more generic. No functional change intended.
llvm-svn: 166360
2012-10-20 01:02:45 +00:00
Chad Rosier
be98459bfd [ms-inline asm] If the state of the parser is ignore, then don't parse the
inline assembly.  Also make sure the remove the ignored statements from the IR.

llvm-svn: 166357
2012-10-20 00:47:08 +00:00
Chad Rosier
03179afe79 [ms-inline asm] Continue parsing even when we're in an ignore block.
llvm-svn: 166352
2012-10-19 23:15:00 +00:00
Chad Rosier
3d1b58e0f9 [ms-inline asm] Reset the opcode prior to parsing a statement.
llvm-svn: 166349
2012-10-19 22:57:33 +00:00
Chad Rosier
b2e9c0e226 [ms-inline asm] Have the TargetParser callback to Sema to determine the size of
a memory operand.  Retain this information and then add the sizing directives
to the IR.  This allows the backend to do proper instruction selection.

llvm-svn: 166316
2012-10-19 20:57:14 +00:00
Chad Rosier
2f344f2453 [ms-inline asm] Add the isParsingInlineAsm() function to the MCAsmTargetParser.
llvm-svn: 166292
2012-10-19 17:57:49 +00:00
Nick Lewycky
c111dcf2c1 Pacify -Wnon-virtual-dtor.
llvm-svn: 166270
2012-10-19 07:00:09 +00:00
Chad Rosier
2a7f9576bc [ms-inline asm] Add a size argument to the LookupInlineAsmIdentifier() callback,
which will be used by the asm matcher in the near future.

llvm-svn: 166222
2012-10-18 20:27:15 +00:00
Chad Rosier
5c17ae1754 [ms-inline asm] Have the LookupInlineAsmIdentifier() callback function return a
*NamedDecl.  In turn, build the expressions after we're finished parsing the
asm.  This avoids a crasher if the lookup fails.

llvm-svn: 166212
2012-10-18 19:39:30 +00:00
Chad Rosier
72377848a3 [ms-inline asm] Move most of the AsmParsing logic in clang back into the MC
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.

llvm-svn: 166183
2012-10-18 15:49:34 +00:00
Chad Rosier
d87fb99e77 [ms-inline asm] Add the helper function, isParseringInlineAsm(). To be used in a future commit.
llvm-svn: 166054
2012-10-16 20:16:20 +00:00
Chad Rosier
860153bf6d [ms-inline asm] If we parsed a statement and the opcode is valid, then it's an instruction.
llvm-svn: 165955
2012-10-15 19:08:18 +00:00
Chad Rosier
77614bbd0e [ms-inline asm] Add a few new APIs to the AsmParser class in support of MS-Style
inline assembly.  For the time being, these will be called directly by clang.
However, in the near future I expect these to be sunk back into the MC layer
and more basic APIs (e.g., getClobbers(), getConstraints(), etc.) will be called
by clang.

llvm-svn: 165946
2012-10-15 17:19:13 +00:00
Chad Rosier
2627b4fea7 [ms-inline asm] Remove the MatchInstruction() function. Previously, this was
the interface between the front-end and the MC layer when parsing inline
assembly.  Unfortunately, this is too deep into the parsing stack. Specifically,
we're unable to handle target-independent assembly (i.e., assembly directives,
labels, etc.).  Note the MatchAndEmitInstruction() isn't the correct
abstraction either.  I'll be exposing target-independent hooks shortly, so this
is really just a cleanup.

llvm-svn: 165858
2012-10-13 00:26:04 +00:00
Chad Rosier
be73f6690c Whitespace.
llvm-svn: 165540
2012-10-09 20:15:02 +00:00
Preston Gurd
79d6f55f89 Add support for macro parameters/arguments delimited by spaces,
to improve compatibility with GNU as.

Based on a patch by PaX Team.

Fixed assertion failures on non-Darwin and added additional test cases.

llvm-svn: 164248
2012-09-19 20:36:12 +00:00
Preston Gurd
ba1ce20a7b Support default parameters/arguments for assembler macros.
This patch is based on the one by PaX Team.

Patch by Andy Zhang!

llvm-svn: 164246
2012-09-19 20:29:04 +00:00
Preston Gurd
033b204a1f Enhance unmatched '.endr' directive error message in assembler.
The directive can be matched with directives other than '.rept'

Patch by Andy Zhang!

llvm-svn: 164245
2012-09-19 20:23:43 +00:00
Craig Topper
f3bd737f5d Use LLVM_DELETED_FUNCTION in place of 'DO NOT IMPLEMENT' comments.
llvm-svn: 163970
2012-09-15 16:23:52 +00:00
Dmitri Gribenko
93c7ec80b7 Fix Doxygen issues:
* wrap code blocks in \code ... \endcode;
* refer to parameter names in paragraphs correctly (\arg is not what most
  people want -- it starts a new paragraph);
* use \param instead of \arg to document parameters in order to be consistent
  with the rest of the codebase.

llvm-svn: 163902
2012-09-14 14:57:36 +00:00
Jim Grosbach
7cb6ddb81b Assembler: Darwin variables defined via .set are no-dead-strip.
For gas compatibility.

rdar://12219394

llvm-svn: 163854
2012-09-13 23:11:31 +00:00
Manman Ren
fdeb41a212 Release build: guard dump functions with
"#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)"

No functional change. Update r163344.

llvm-svn: 163679
2012-09-12 05:06:18 +00:00
Dmitri Gribenko
1d75adbbb2 Remove redundant semicolons which are null statements.
llvm-svn: 163547
2012-09-10 21:26:47 +00:00
Benjamin Kramer
f7e00de5d0 Fix alignment of .comm and .lcomm on mingw32.
For some reason .lcomm uses byte alignment and .comm log2 alignment so we can't
use the same setting for both. Fix this by reintroducing the LCOMM enum.
I verified this against mingw's gcc.

llvm-svn: 163420
2012-09-07 21:08:01 +00:00
Benjamin Kramer
f7fdee3ce3 MC: Overhaul handling of .lcomm
- Darwin lied about not supporting .lcomm and turned it into zerofill in the
  asm parser. Push the zerofill-conversion down into macho-specific code.
- This makes the tri-state LCOMMType enum superfluous, there are no targets
  without .lcomm.
- Do proper error reporting when trying to use .lcomm with alignment on a target
  that doesn't support it.
- .comm and .lcomm alignment was parsed in bytes on COFF, should be power of 2.
- Fixes PR13755 (.lcomm crashes on ELF).

llvm-svn: 163395
2012-09-07 17:25:13 +00:00
Manman Ren
3f0d6dd93f Release build: guard dump functions with "ifndef NDEBUG"
No functional change.

llvm-svn: 163344
2012-09-06 19:55:56 +00:00
Craig Topper
ed7a8c9ddf Add virtual keywords for methods that override the base class.
llvm-svn: 162826
2012-08-29 05:48:09 +00:00
Rafael Espindola
f67c62714f Fix macros arguments with an underscore, dot or dollar in them. This is based
on a patch by Andy/PaX. I added the support for dot and dollar.

llvm-svn: 162298
2012-08-21 18:29:30 +00:00
Rafael Espindola
2683030b12 Make the wording in of the "expected identifier" error in the .macro directive
consistent with the other "expected identifier" errors.
Extracted from the Andy/PaX patch. I added the test.

llvm-svn: 162291
2012-08-21 17:12:05 +00:00
Rafael Espindola
4599a394a3 Use typedefs. Fix indentation. Extracted from the Andy/PaX patch.
llvm-svn: 162283
2012-08-21 16:06:48 +00:00
Rafael Espindola
5ff87e610b Remove unused variable. Extracted from the Andy/PaX patch.
llvm-svn: 162282
2012-08-21 16:01:14 +00:00
Rafael Espindola
53d3b8d089 Fix typo. Extracted from the Andy/PaX patch.
llvm-svn: 162281
2012-08-21 15:55:04 +00:00
Rafael Espindola
5d2595ed26 Typedefs and indentation fixes from the Andy Zhang/PAX macro argument patch.
Committing it first as it makes the "real" patch a lot easier to read.

llvm-svn: 161491
2012-08-08 14:51:03 +00:00
Bill Wendling
33bd6a2d6c Add .pushsection', .popsection', and `.previous' directives to Darwin ASM.
There are situations where inline ASM may want to change the section -- for
instance, to create a variable in the .data section. However, it cannot do this
without (potentially) restoring to the wrong section. E.g.:

  asm volatile (".section __DATA, __data\n\t"
                ".globl _fnord\n\t"
                "_fnord: .quad 1f\n\t"
                ".text\n\t"
                "1:" :::);

This may be wrong if this is inlined into a function that has a "section"
attribute. The user should use `.pushsection' and `.popsection' here instead.

The addition of `.previous' is added for completeness.
<rdar://problem/12048387>

llvm-svn: 161477
2012-08-08 06:30:30 +00:00
Jim Grosbach
51fff56d58 Keep empty assembly macro argument values in the middle of the list.
Empty macro arguments at the end of the list should be as-if not specified at
all, but those in the middle of the list need to be kept so as not to screw
up the positional numbering. E.g.:
.macro foo
foo_-bash___:
  nop
.endm

foo 1, 2, 3, 4
foo 1, , 3, 4

Should create two labels, "foo_1_2_3_4" and "foo_1__3_4".

rdar://11948769

llvm-svn: 161002
2012-07-30 22:44:17 +00:00
Sylvestre Ledru
bf8acb65ac Fix a typo (the the => the)
llvm-svn: 160621
2012-07-23 08:51:15 +00:00
Bill Wendling
343eebdbe4 Remove tabs.
llvm-svn: 160475
2012-07-19 00:04:14 +00:00
Akira Hatanaka
4ce0c1ffe9 Enable target dependent directive parsing to hook before standard parser in
AsmParser::ParseStatement.

Patch by Vladimir Medic.

llvm-svn: 159768
2012-07-05 19:09:33 +00:00
Rafael Espindola
e1fee137d2 Implement irpc. Extracted from a patch by the PaX team. I just added the test.
llvm-svn: 158604
2012-06-16 18:03:25 +00:00
Rafael Espindola
9efec1f548 Factor macro argument parsing into helper methods and add support for .irp.
Patch extracted from a larger one by the PaX team. I added the testcases
and tightened error handling a bit.

llvm-svn: 158523
2012-06-15 14:02:34 +00:00
Rafael Espindola
a6ed019c71 Represent .rept as an anonymous macro. This removes the need for the ActiveRept
vector. No functionality change.
Extracted from a patch by the PaX Team.

llvm-svn: 157909
2012-06-03 23:57:14 +00:00
Rafael Espindola
454587b972 Add a typedef to simplify the code a bit. Not functionality change.
Part of a patch by the PaX Team.

llvm-svn: 157908
2012-06-03 22:41:23 +00:00
Benjamin Kramer
bb30e1face Fix typos found by http://github.com/lyda/misspell-check
llvm-svn: 157885
2012-06-02 10:20:22 +00:00
Jim Grosbach
343a996ca5 Refactor data-in-code annotations.
Use a dedicated MachO load command to annotate data-in-code regions.
This is the same format the linker produces for final executable images,
allowing consistency of representation and use of introspection tools
for both object and executable files.

Data-in-code regions are annotated via ".data_region"/".end_data_region"
directive pairs, with an optional region type.

data_region_directive := ".data_region" { region_type }
region_type := "jt8" | "jt16" | "jt32" | "jta32"
end_data_region_directive := ".end_data_region"

The previous handling of ARM-style "$d.*" labels was broken and has
been removed. Specifically, it didn't handle ARM vs. Thumb mode when
marking the end of the section.

rdar://11459456

llvm-svn: 157062
2012-05-18 19:12:01 +00:00
Benjamin Kramer
5c3f73c96c Fix spacing after if.
llvm-svn: 156716
2012-05-12 16:52:21 +00:00
Rafael Espindola
b6ca820fbb Add support for the .rept directive. Patch by Vladmir Sorokin. I added support
for nesting.

llvm-svn: 156714
2012-05-12 16:31:10 +00:00
Benjamin Kramer
b778bbd91b ELF: Add support for the asm .version directive.
llvm-svn: 156712
2012-05-12 14:30:47 +00:00
Benjamin Kramer
549c257415 AsmParser: Add support for the .purgem directive.
Based on a patch by Team PaX.

llvm-svn: 156709
2012-05-12 11:21:46 +00:00
Benjamin Kramer
f80ca369a1 AsmParser: Give a nice error message for .code16gcc, which is currently unsupported.
Patch by Team PaX!

llvm-svn: 156708
2012-05-12 11:19:04 +00:00
Benjamin Kramer
3cf84357e0 AsmParser: ignore the .extern directive.
llvm-svn: 156707
2012-05-12 11:18:59 +00:00
Benjamin Kramer
09b38e9f61 AsmParser: Add support for .ifc and .ifnc directives.
Based on a patch from PaX Team.

llvm-svn: 156706
2012-05-12 11:18:51 +00:00
Benjamin Kramer
dc54b252bb AsmParser: Add support for .ifb and .ifnb directives.
Based on a patch from PaX Team.

llvm-svn: 156705
2012-05-12 11:18:42 +00:00
Jim Grosbach
a538b5240e MC: Unknown assembler directives are now hard errors.
Previously, an unsupported/unknown assembler directive issued a warning.
That's generally unsafe, and inconsistent with the behaviour of pretty
much every system assembler. Now that the MC assemblers are mature
enough to be the default on multiple targets, it's reasonable to
issue errors for these.

For target or platform directives that need to stay warnings, we
should add explicit handlers for them in, e.g., ELFAsmParser.cpp,
DarwinAsmParser.cpp, et. al., and issue the warning there.

rdar://9246275

llvm-svn: 155926
2012-05-01 18:38:27 +00:00
Jim Grosbach
fc228ff796 MC: Remove errant EatToEndOfStatement() in asm parser.
The caller is already responsible for eating any additional input on the
line. Putting an additional EatToEndOfStatement() in ParseStatement()
causes an entire extra statement to be consumed when treating warnings
as errors. For example, test/MC/macros.s will assert() because the
.endmacro directive is missed as a result.

rdar://11355843

llvm-svn: 155925
2012-05-01 18:38:24 +00:00
Jim Grosbach
9e97ef84db MC assembly parser handling for trailing comma in macro instantiation.
A trailing comma means no argument at all (i.e., as if the comma were not
present), not an empty argument to the invokee.

rdar://11252521

llvm-svn: 154863
2012-04-16 21:18:49 +00:00
Craig Topper
bf6a47d0ec Prune some includes
llvm-svn: 153502
2012-03-27 07:54:11 +00:00
Jim Grosbach
984b0f5ffe Assembler should accept redefinitions of unused variable symbols.
rdar://11027851

llvm-svn: 153137
2012-03-20 21:33:21 +00:00
Jim Grosbach
138c2143c3 MC asm parser macro argument count was wrong when empty.
evaluated to '1' when the argument list was empty (should be '0').

rdar://11057257

llvm-svn: 152967
2012-03-17 00:11:42 +00:00
Craig Topper
639b152ca5 Convert assert(0) to llvm_unreachable
llvm-svn: 149967
2012-02-07 05:05:23 +00:00
Devang Patel
b8688eac99 Add assembler dialect attribute in asm parser which lets target specific asm parser change dialect on the fly.
llvm-svn: 149396
2012-01-31 18:14:05 +00:00
Benjamin Kramer
d10dc94cac Silence GCC's -Wreturn-type warning.
llvm-svn: 149179
2012-01-28 15:28:41 +00:00
Rafael Espindola
c74f450f77 Small improvement to the recursion detection logic from the previous commit.
llvm-svn: 149175
2012-01-28 06:22:14 +00:00
Rafael Espindola
82e15e4544 Handle recursive variable definitions directly. This gives us better error
messages and allows us to fix PR11865.

llvm-svn: 149174
2012-01-28 05:57:00 +00:00
Jim Grosbach
6280a1137f Better diagnostic for malformed .org assembly directive.
Provide source line number information.

llvm-svn: 149101
2012-01-27 00:37:08 +00:00
Rafael Espindola
9f3a003d3c Add support for .cfi_signal_frame. Fixes pr11762.
llvm-svn: 148733
2012-01-23 21:51:52 +00:00
David Blaikie
06ecc99a56 More dead code removal (using -Wunreachable-code)
llvm-svn: 148578
2012-01-20 21:51:11 +00:00
Kevin Enderby
9c7eec9282 The error check for using -g with a .s file already containing dwarf .file
directives was in the wrong place and getting triggered incorectly with a
cpp .file directive.  This change fixes that and adds a test case.

llvm-svn: 147951
2012-01-11 18:04:47 +00:00
Devang Patel
90a5a47ef8 Let asm parser query asm syntax dialect.
llvm-svn: 147880
2012-01-10 21:49:42 +00:00
Kevin Enderby
21c229f1fb This is the matching change for the data structure name changes for the
functional change in r147860 to use DW_TAG_label's instead TAG_subprogram's.
This only changes names and updates comments.  No functional change.

llvm-svn: 147877
2012-01-10 21:12:34 +00:00
Rafael Espindola
db7319d272 Implement cfi_restore. Patch by Brian Anderson!
llvm-svn: 147356
2011-12-29 21:43:03 +00:00
Rafael Espindola
27298c6f33 Implement .cfi_escape. Patch by Brian Anderson!
llvm-svn: 147352
2011-12-29 20:24:47 +00:00
Rafael Espindola
549d0683b1 Add back the MC bits of 126425. Original patch by Nathan Jeffords. I added the
asm parsing and testcase.

llvm-svn: 146801
2011-12-17 01:14:52 +00:00
Kevin Enderby
c65cec89e5 Another improvement to the implementation of .incbin directive by avoiding a
buffer copy.  Suggestion by Chris Lattner!

llvm-svn: 146614
2011-12-15 00:00:27 +00:00
Kevin Enderby
bc6d6388c2 Improve the implementation of .incbin directive by replacing a loop by using
getStreamer().EmitBytes.  Suggestion by Benjamin Kramer!

llvm-svn: 146599
2011-12-14 22:34:45 +00:00
Kevin Enderby
b0b669eb26 Add the .incbin directive which takes the binary data from a file and emits
it to the streamer.  rdar://10383898

llvm-svn: 146592
2011-12-14 21:47:48 +00:00
Daniel Dunbar
30d6a45140 LLVMBuild: Remove trailing newline, which irked me.
llvm-svn: 146409
2011-12-12 19:48:00 +00:00
Roman Divacky
a450b8b2c8 Add support for gnu_indirect_function.
llvm-svn: 146377
2011-12-12 17:34:04 +00:00
Kevin Enderby
63cf89d532 The second part of support for generating dwarf for assembly source files. This
generates the dwarf Compile Unit DIE and a dwarf subprogram DIE for each
non-temporary label.

The next part will be to get the clang driver to enable this when assembling
a .s file.  rdar://9275556

llvm-svn: 146262
2011-12-09 18:09:40 +00:00
Daniel Dunbar
4e00f5f8fd build/CMake: Finish removal of add_llvm_library_dependencies.
llvm-svn: 145420
2011-11-29 19:25:30 +00:00
Daniel Dunbar
3760ebeebb build: Add initial cut at LLVMBuild.txt files.
llvm-svn: 143634
2011-11-03 18:53:17 +00:00
Kevin Enderby
f637eabadd Replace tabs I added in this new line of code with spaces.
Thanks to Nick for spotting this!

llvm-svn: 143556
2011-11-02 17:56:38 +00:00
Kevin Enderby
64fe093030 First part of support for generating dwarf for assembly source files with the
-g flag.  In this part we generate the .file for the source being assembled and
the .loc's for the assembled instructions.

The next part will be to generate the dwarf Compile Unit DIE and a dwarf
subprogram DIE for each non-temporary label.

Once the next part is done test cases will be added.  rdar://9275556

llvm-svn: 143509
2011-11-01 22:27:22 +00:00
Rafael Espindola
01d11bcdf0 Fix parsing of a line with only a # in it.
llvm-svn: 142537
2011-10-19 18:48:52 +00:00
Nick Lewycky
c551c1c5f9 Add support for a new extension to the .file directive:
.file filenumber "directory" "filename"

This removes one join+split of the directory+filename in MC internals. Because
bitcode files have independent fields for directory and filenames in debug info,
this patch may change the .o files written by existing .bc files.

llvm-svn: 142300
2011-10-17 23:05:28 +00:00
Benjamin Kramer
3fed5faf01 Add AsmToken::getEndLoc and use it to add ranges to x86 asm register parsing.
<stdin>:1:12: error: register %rax is only available in 64-bit mode
   incl    %rax
           ^~~~

llvm-svn: 142137
2011-10-16 12:10:27 +00:00
Benjamin Kramer
8f3fa2bc50 PR11143: Save the old diagnostic handler and call it when munging diagnostics for #line directives.
This reenables proper inline asm diagnostics in clang

llvm-svn: 142132
2011-10-16 10:48:29 +00:00
Chris Lattner
0ab0d49640 remove the dead 'ShowLine' argument from SMDiagnostic.
llvm-svn: 142108
2011-10-16 05:47:55 +00:00
Chris Lattner
391d90c9a6 Make SMDiagnostic a little more sane. Instead of passing around note/warning/error as a
string, pass it around as an enum.

llvm-svn: 142107
2011-10-16 05:43:57 +00:00
Chris Lattner
321335142c Enhance llvm::SourceMgr to support diagnostic ranges, the same way clang does. Enhance
the X86 asmparser to produce ranges in the one case that was annoying me, for example:

test.s:10:15: error: invalid operand for instruction
movl 0(%rax), 0(%edx)
              ^~~~~~~

It should be straight-forward to enhance filecheck, tblgen, and/or the .ll parser to use 
ranges where appropriate if someone is interested.

llvm-svn: 142106
2011-10-16 04:47:35 +00:00
Kevin Enderby
974c799a5a Finish supporting cpp #file/line comments in assembler for error messages. So
for cpp pre-processed assembly we give correct filename and line numbers when
reporting errors in assembly files when using clang and -integrated-as on .s
files. rdar://8998895

llvm-svn: 141814
2011-10-12 21:38:39 +00:00
Jim Grosbach
e341895736 Assmebler symbol attribute directives don't work on temporary symbols.
Assembler private local symbols aren't legal targets of symbol attributes,
so issue a diagnostic for them.

Based on patch by Stepan Dyatkovskiy.

llvm-svn: 139807
2011-09-15 17:56:49 +00:00
Jim Grosbach
00e28bee78 Handle missing newline at EOF more gracefully in MC AsmLexer.
If we see an EOF w/o a preceding end-of-line, return an EndOfStatement
token before returning the Eof token.

Based on patch by Stepan Dyatkovskiy.

llvm-svn: 139798
2011-09-15 16:52:06 +00:00
Jim Grosbach
36d319e831 Move state var to private class member.
llvm-svn: 139697
2011-09-14 16:37:04 +00:00
Kevin Enderby
4a91571f82 First step in supporting #line directives in assembler. This step parses the
#line directives with the needed support in the lexer.  Next will be to build
a simple file/line# table mapping source SMLoc's for later use by diagnostics.
And the last step will be to get the diagnostics to use the mapping for file
and line numbers.

llvm-svn: 139669
2011-09-13 23:45:18 +00:00
Jim Grosbach
a6e1ed8f2b Fix AsmParser binary precedence for shift operators.
rdar://9976729

llvm-svn: 138208
2011-08-20 16:24:13 +00:00
Jim Grosbach
a9a0c62719 Remove unused Target argument from AsmParser construction methods.
The argument is unused, and is a layering violation in any case.

llvm-svn: 137735
2011-08-16 18:33:49 +00:00
Chris Lattner
e34bef3d5e allow \r's in .s files.
llvm-svn: 136908
2011-08-04 19:31:26 +00:00
Chandler Carruth
f7890e34b9 Rewrite the CMake build to use explicit dependencies between libraries,
specified in the same file that the library itself is created. This is
more idiomatic for CMake builds, and also allows us to correctly specify
dependencies that are missed due to bugs in the GenLibDeps perl script,
or change from compiler to compiler. On Linux, this returns CMake to
a place where it can relably rebuild several targets of LLVM.

I have tried not to change the dependencies from the ones in the current
auto-generated file. The only places I've really diverged are in places
where I was seeing link failures, and added a dependency. The goal of
this patch is not to start changing the dependencies, merely to move
them into the correct location, and an explicit form that we can control
and change when necessary.

This also removes a serialization point in the build because we don't
have to scan all the libraries before we begin building various tools.
We no longer have a step of the build that regenerates a file inside the
source tree. A few other associated cleanups fall out of this.

This isn't really finished yet though. After talking to dgregor he urged
switching to a single CMake macro to construct libraries with both
sources and dependencies in the arguments. Migrating from the two macros
to that style will be a follow-up patch.

Also, llvm-config is still generated with GenLibDeps.pl, which means it
still has slightly buggy dependencies. The internal CMake
'llvm-config-like' macro uses the correct explicitly specified
dependencies however. A future patch will switch llvm-config generation
(when using CMake) to be based on these deps as well.

This may well break Windows. I'm getting a machine set up now to dig
into any failures there. If anyone can chime in with problems they see
or ideas of how to solve them for Windows, much appreciated.

llvm-svn: 136433
2011-07-29 00:14:25 +00:00
Evan Cheng
bff9934d9a Support .code32 and .code64 in X86 assembler.
llvm-svn: 136197
2011-07-27 00:38:12 +00:00
Evan Cheng
2e96785311 Rename TargetAsmParser to MCTargetAsmParser and TargetAsmLexer to MCTargetAsmLexer; rename createAsmLexer to createMCAsmLexer and createAsmParser to createMCAsmParser.
llvm-svn: 136027
2011-07-26 00:24:13 +00:00
Jim Grosbach
2f728674cf Move some ELF directives into ELF asm parser.
The .local, .hidden, .internal, and .protected are not legal for all supported
file formats (in particular, they're invalid for MachO). Move the parsing for
them into the ELF assembly parser since that's the format they're for.
Similarly, .weak is used by COFF and ELF, but not MachO, so move the parsing
to the COFF and ELF asm parsers. Previously, using any of these directives
on Darwin would result in an assertion failure in the parser; now we get
a diagnostic as we should.

rdar://9827089

llvm-svn: 135921
2011-07-25 17:55:35 +00:00
Jim Grosbach
feb91f5361 Tidy up. 80 columns.
llvm-svn: 135917
2011-07-25 17:11:29 +00:00
Evan Cheng
13d54fc7c9 Move TargetAsmParser.h TargetAsmBackend.h and TargetAsmLexer.h to MC where they belong.
llvm-svn: 135833
2011-07-23 00:45:41 +00:00
Evan Cheng
c9bc5a9011 Goodbye TargetAsmInfo. This eliminate last bit of CodeGen and Target in llvm-mc.
There is still a bit more refactoring left to do in Targets. But we are now very
close to fixing all the layering issues in MC.

llvm-svn: 135611
2011-07-20 19:50:42 +00:00
Evan Cheng
380dc98371 Add MCObjectFileInfo and sink the MCSections initialization code from
TargetLoweringObjectFileImpl down to MCObjectFileInfo.

TargetAsmInfo is done to one last method. It's *almost* gone!

llvm-svn: 135569
2011-07-20 05:58:47 +00:00
Evan Cheng
561d71ce7b Sink getDwarfRegNum, getLLVMRegNum, getSEHRegNum from TargetRegisterInfo down
to MCRegisterInfo. Also initialize the mapping at construction time.

This patch eliminate TargetRegisterInfo from TargetAsmInfo. It's another step
towards fixing the layering violation.

llvm-svn: 135424
2011-07-18 20:57:22 +00:00
Evan Cheng
1ae06d95e0 Move some parts of TargetAsmInfo down to MCAsmInfo. This is not the greatest
solution but it is a small step towards removing the horror that is
TargetAsmInfo.

llvm-svn: 135237
2011-07-15 02:09:41 +00:00
Jim Grosbach
e0fc4019f9 Update MCParsedAsmOperand debug methods.
Update the debug output interface for MCParsedAsmOperand to have a print()
method which takes an output stream argument, an << operator which invokes
the print method using the given stream, and a dump() method which prints
the operand to the dbgs() stream. This makes the interface more consistent
with the rest of LLVM, and more convenient to use at the debugger command
line.

llvm-svn: 135043
2011-07-13 15:34:57 +00:00
Evan Cheng
34f67f2dda TargetAsmParser doesn't need reference to Target.
llvm-svn: 134721
2011-07-08 19:33:14 +00:00
Jim Grosbach
88387d64d6 Asm parser range checking on .<size> <value> directives.
For example, ".byte 256" would previously assert() when emitting an object
file. Now it generates a diagnostic that the literal value is out of range.

rdar://9686950

llvm-svn: 134069
2011-06-29 16:05:14 +00:00
Hans Wennborg
6229bbd9c0 MC: Allow .common as alias for .comm assembler directive. PR10116.
llvm-svn: 133349
2011-06-18 13:51:54 +00:00
Jim Grosbach
2ec534dffe Diagnostic for undefined assembler local symbols.
Re-apply 133010, with fixes for inline assembler.

Original commit message:
"When an assembler local symbol is used but not defined in a module, a
Darwin assembler wants to issue a diagnostic to that effect."

Added fix to only perform the check when finalizing, as otherwise we're not
done and undefined symbols may simply not have been encountered yet.

Passes "make check" and a self-host check on Darwin.

llvm-svn: 133071
2011-06-15 18:33:28 +00:00
Jim Grosbach
e5f4cecf01 Revert 133010. Self-hosted buildbot unhappy.
Apparently llvm itself generates undefined assembler local labels, causing
self-hosting problems with this patch. Reverting until that's sorted out.

llvm-svn: 133013
2011-06-14 21:51:20 +00:00
Jim Grosbach
596a1b7d98 Diagnostic for undefined assembler local symbols.
When an assembler local symbol is used but not defined in a module, a
Darwin assembler wants to issue a diagnostic to that effect.

rdar://9559714

llvm-svn: 133010
2011-06-14 21:13:25 +00:00
Rafael Espindola
f500121fcf Basic support for macros with explicit arguments.
We still don't handle

* default values
* :req
* :vararg
* \()

llvm-svn: 132656
2011-06-05 02:43:45 +00:00
Jim Grosbach
8a7731f951 .cfi directive register parsing flexibility.
Parsing a register name/number for .cfi directives can't assume that a
register name starts with a '%' token. Be more flexible and check for a
register number instead. Still unlikely to be perfect, but it allows us
to parse both plain identifiers as register names and integers as register
numbers, which is what we're wanting to support at this point.

llvm-svn: 132466
2011-06-02 17:14:04 +00:00
Joerg Sonnenberger
ffa79cb359 Add new -d option to tblgen. It writes a make(1)-style dependency file.
llvm-svn: 132395
2011-06-01 13:10:15 +00:00
Charles Davis
ede0f07dae Add tests for .seh_setframe and .seh_handlerdata parsing. Fix issues with
them.

I had to add a special SwitchSectionNoChange method to MCStreamer just for
.seh_handlerdata. If this isn't OK, please let me know, and I'll find some
other way to fix .seh_handlerdata streaming.

llvm-svn: 132084
2011-05-25 21:43:45 +00:00
Charles Davis
6b67ee5130 Add tests for .seh_savereg and .seh_savexmm parsing. Once again, fix the
buggy methods that parse these directives.

llvm-svn: 132045
2011-05-25 04:51:25 +00:00
Charles Davis
14a32a9608 Add a test for .seh_pushframe parsing. Fix the bug exposed by it (and another
one I found by inspection).

llvm-svn: 132037
2011-05-25 04:08:15 +00:00
Charles Davis
967ee6a30b Add a test for the .seh_handler directive. Fix problems with the parsing
method exposed by the test. While we're at it, simplify the .seh_proc
parsing method.

llvm-svn: 132028
2011-05-25 01:33:42 +00:00
Charles Davis
1084ac5bb1 Implement the rest of the SEH directive-parsing methods in the COFFAsmParser.
Add a size alignment check to the .seh_stackalloc directive parser. Add a
more descriptive error message to the .seh_handler directive parser.

Add methods to the TargetAsmInfo struct in support of all this.

llvm-svn: 131992
2011-05-24 20:06:30 +00:00
Jim Grosbach
76f8f3d479 Propagate error correctly in the MC Asm parser for leading '$' expressions.
llvm-svn: 131918
2011-05-23 20:36:04 +00:00
Charles Davis
b38506e3a7 Implement .seh_stackalloc and .seh_pushframe parsing.
I haven't implemented any of the ones that take registers yet. The problem is
that for x86-64 the streamer methods expect a native x86 register number (note:
%r8-%r15 want 8-15 instead of 0-7; same for %xmm8-%xmm15). I haven't figured
out exactly how I want to do that yet.

llvm-svn: 131899
2011-05-23 16:43:09 +00:00
Charles Davis
a4187a96c9 Add methods to parse the SEH directives to the COFFAsmParser. Implement some
of them, particularly the ones that don't take arguments. Also implement
.seh_proc and .seh_handler.

llvm-svn: 131866
2011-05-22 21:12:15 +00:00
Joerg Sonnenberger
5efd18ca60 Reapply 131644 including the missing header changes:
Introduce -fatal-assembler-warnings for the obvious purpose

llvm-svn: 131655
2011-05-19 18:00:13 +00:00
Eli Friedman
8cb4a78596 Revert r131644; it's breaking the build.
llvm-svn: 131653
2011-05-19 17:48:09 +00:00
Joerg Sonnenberger
951d2761f6 Introduce -fatal-assembler-warnings for the obvious purpose
llvm-svn: 131644
2011-05-19 17:27:01 +00:00
Rafael Espindola
c5f10dda05 Parsing and plumbing for .cfi_sections.
llvm-svn: 131117
2011-05-10 01:10:18 +00:00
Daniel Dunbar
2727693326 MC/AsmParser: Generalize a check.
llvm-svn: 130515
2011-04-29 17:53:11 +00:00
Devang Patel
7220c1a021 Reduce clutter in asm output. Do not emit source location as comment for each instruction.
llvm-svn: 129715
2011-04-18 20:26:49 +00:00
Rafael Espindola
63f8a9ad72 Be consistent about being virtual and returning void in the cfi methods.
Implement the ones that were missing in the asm streamer.

llvm-svn: 129413
2011-04-12 23:59:07 +00:00
Rafael Espindola
9f6146c464 Remove LastOffset from the asm parser.
llvm-svn: 129378
2011-04-12 18:53:30 +00:00
Rafael Espindola
5c5bb3e9a6 Fix the case of a .cfi_rel_offset before any .cfi_def_cfa_offset.
llvm-svn: 129362
2011-04-12 16:12:03 +00:00
Rafael Espindola
7c4de15c7b Implement .cfi_same_value.
llvm-svn: 129361
2011-04-12 15:31:05 +00:00
Eric Christopher
b01713088d Match case for invalid constant error messages and add a new
test for invalid hexadecimals.

llvm-svn: 129326
2011-04-12 00:18:03 +00:00
Eric Christopher
b653bac7ce To avoid printing out multiple error messages for cases like:
.long 80+08

go ahead and assume that if we've got an Error token that we handled it
already. Otherwise if it's a token we can't handle then go ahead and
return the default error.

llvm-svn: 129322
2011-04-12 00:03:13 +00:00
Eric Christopher
a7c5e42cbe Lex, and then fail on invalid constants.
Testcase forthcoming.

rdar://8490596

llvm-svn: 129309
2011-04-11 22:24:56 +00:00
Rafael Espindola
a1fb8a36f9 Implement cfi_rel_offset
llvm-svn: 129306
2011-04-11 21:49:50 +00:00
Rafael Espindola
986ec356fc implement .cfi_adjust_cfa_offset.
llvm-svn: 129296
2011-04-11 20:29:16 +00:00
Rafael Espindola
a27969f537 Add support for .skip.
Patch by Roman Divacky.
Fixes PR9361.

llvm-svn: 129106
2011-04-07 20:26:23 +00:00
Kevin Enderby
1ece39d99c Added support symbolic floating point constants in the MC assembler for Infinity
and Nans with the same strings as GAS supports.  rdar://8673024

llvm-svn: 128488
2011-03-29 21:11:52 +00:00
Daniel Dunbar
1cbd2c6c88 MC: Improve some diagnostics on uses of '.' pseudo-symbol.
llvm-svn: 128289
2011-03-25 17:47:17 +00:00
Daniel Dunbar
70235789e1 Tidyness.
llvm-svn: 128288
2011-03-25 17:47:14 +00:00
Jim Grosbach
213800d44b Clean up assembly statement separator support.
The MC asm lexer wasn't honoring a non-default (anything but ';') statement
separator. Fix that, and generalize a bit to support multi-character
statement separators.

llvm-svn: 128227
2011-03-24 18:46:34 +00:00
Stuart Hastings
0c1298989f Reapply 127939 since Daniel fixed the breakage. <rdar://problem/9012638>
llvm-svn: 127944
2011-03-19 02:42:31 +00:00
Stuart Hastings
0b337d0fe8 Revert 127939. <rdar://problem/9012638>
llvm-svn: 127943
2011-03-19 02:33:56 +00:00
Stuart Hastings
4a2b1ca9c1 Revise r126127 to address Daniel's comments. <rdar://problem/9012638>
llvm-svn: 127939
2011-03-19 01:32:01 +00:00
Daniel Dunbar
0e9d7aeb1f MC/Mach-O: Fix regression introduced in r126127, this assignment shouldn't have
been removed.

llvm-svn: 127812
2011-03-17 16:25:24 +00:00
Jim Grosbach
bdf8053571 Darwin 'as' silently ignores the '.ident' directive.
llvm-svn: 127258
2011-03-08 19:17:19 +00:00
Joerg Sonnenberger
9c30c492df Restore r125595 (reverted in r126336) with modifications:
Introduce a variable in the AsmParserExtension whether [] is valid in an
expression. If it is true, parse them like (). Enable this for ELF only.

llvm-svn: 126443
2011-02-24 21:59:22 +00:00
Jim Grosbach
e7be1f2990 Revert r125595, which is an X86-only undocumented assembly syntax extension
enabled for all targets. Non-X86 targets should not have this behavior
enabled by default.

Joerg, if you would like to resubmit with the behavior conditionalized to be
X86-ELF only, that's fine.

llvm-svn: 126336
2011-02-23 21:26:51 +00:00
Joerg Sonnenberger
cbdd830a75 Bug#9172: Don't use static in file scope, use an attribute on the
parser.

llvm-svn: 126225
2011-02-22 16:53:11 +00:00
Rafael Espindola
b59fdeb3de Add support for pushsection and popsection. Patch by Joerg Sonnenberger.
llvm-svn: 125629
2011-02-16 01:08:29 +00:00
Roman Divacky
3277e18a42 Add support for parsing [expr].
This is submitted by Joerg Sonnenberger and fixes his PR8685.

llvm-svn: 125595
2011-02-15 20:43:39 +00:00
Jim Grosbach
79e4b6b045 More whitespace cleanup...
llvm-svn: 125388
2011-02-11 19:05:56 +00:00
Benjamin Kramer
8ff71a1384 Support for .ifdef / .ifndef in the assembler parser. Patch by Joerg Sonnenberger.
llvm-svn: 125120
2011-02-08 22:29:56 +00:00
Bob Wilson
f6a7104e41 Do not sign extend floating-point values in the asm parser.
llvm-svn: 124831
2011-02-03 23:17:47 +00:00
Roman Divacky
254f2ab16a Enumerate .code16/32/64 instead of checking .code prefix. This
unbreaks some ARM tests.

llvm-svn: 124608
2011-01-31 21:19:43 +00:00
Roman Divacky
9a8a680ed2 Error on all .code* directives instead of just .code16 as they
all lead to a silent miscompilation of code.

llvm-svn: 124603
2011-01-31 20:56:49 +00:00
Roman Divacky
82612f08c2 Error on .code16 instead of producing wrong (32bit) code.
llvm-svn: 124498
2011-01-28 19:29:48 +00:00
Roman Divacky
c6a20d1728 Add support for parsing .float
llvm-svn: 124485
2011-01-28 14:20:32 +00:00
Nico Weber
66fd0e8119 PR8951: Support for .equiv in integrated assembler, patch by Jörg Sonnenberger!
llvm-svn: 124467
2011-01-28 03:04:41 +00:00
Roman Divacky
f817c82cf3 Add support for specifying register name in cfi-register/offset/def
as well as register number.

llvm-svn: 124379
2011-01-27 17:16:37 +00:00
Bill Wendling
195d8c3988 Add support for parsing a Real value. It stores the Real value as its binary
encoding. It's up to the individual back-ends to convert it to their preferred
representation when printing.

llvm-svn: 124229
2011-01-25 21:26:41 +00:00
Rafael Espindola
ead58a5259 Handle strings in section names the same way as gas:
* If the name is a single string, we remove the quotes
* If the name starts without a quote, we include any quotes in the name

llvm-svn: 124127
2011-01-24 18:02:54 +00:00
Rafael Espindola
aefd549139 Delay the creation of eh_frame so that the user can change the defaults.
Add support for SHT_X86_64_UNWIND.

llvm-svn: 124059
2011-01-23 05:43:40 +00:00