1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00
Commit Graph

263 Commits

Author SHA1 Message Date
Daniel Dunbar
dc5840c57c Update llvm-mc / MCAsmStreamer to print the instruction using the actual target
specific printer (this only works on x86, for now).
 - This makes it possible to do some correctness checking of the parsing and
   matching, since we can compare the results of 'as' on the original input, to
   those of 'as' on the output from llvm-mc.

 - In theory, we could now have an easy ATT -> Intel syntax converter. :)

llvm-svn: 78986
2009-08-14 03:48:55 +00:00
Daniel Dunbar
da9a46b9de llvm-mc: Move MCAsmToken::getLoc() into MC library where it belongs.
llvm-svn: 78980
2009-08-14 02:18:40 +00:00
Daniel Dunbar
d4f20f9186 llvm-mc: Fix a crash on invalid due to a typo in relocatable expression
evaluation.

llvm-svn: 78692
2009-08-11 17:47:52 +00:00
Daniel Dunbar
8b8ee45c05 llvm-mc: Accept .word as a synonym for .short
llvm-svn: 78641
2009-08-11 04:44:00 +00:00
Daniel Dunbar
712f6f40ed llvm-mc: Honor -o option (and add -f).
llvm-svn: 78640
2009-08-11 04:34:48 +00:00
Daniel Dunbar
9c03cc13de llvm-mc: Sketch parsing for .file, .line, and .loc. No streamer hooks for these
yet (I'm not even sure what they do).

llvm-svn: 78639
2009-08-11 04:24:50 +00:00
Daniel Dunbar
677e05c42d llvm-mc: Fix darwin .section parsing. It was skipping the section name and a ','
(and outputting a diagnostic pointing at the wrong place), all of which lead to
much confusion.

llvm-svn: 78637
2009-08-11 03:42:33 +00:00
Chris Lattner
3e6da637f6 split MachO section handling stuff out to its out .h/.cpp file.
llvm-svn: 78576
2009-08-10 18:15:01 +00:00
Chris Lattner
f14da636ad add a fixme
llvm-svn: 78575
2009-08-10 18:05:55 +00:00
Chris Lattner
cc70d578be Make the big switch: Change MCSectionMachO to represent a section *semantically*
instead of syntactically as a string.  This means that it keeps track of the 
segment, section, flags, etc directly and asmprints them in the right format.
This also includes parsing and validation support for llvm-mc and 
"attribute(section)", so we should now start getting errors about invalid 
section attributes from the compiler instead of the assembler on darwin.

Still todo: 
1) Uniquing of darwin mcsections
2) Move all the Darwin stuff out to MCSectionMachO.[cpp|h]
3) there are a few FIXMEs, for example what is the syntax to get the
   S_GB_ZEROFILL segment type?

llvm-svn: 78547
2009-08-10 01:39:42 +00:00
Chris Lattner
9e2c3aa666 sink the 'name' and 'isdirective' state out of MCSection into its derived classes.
This totally optimizes PIC16 sections by not having an 'isdirective' bit anymore!! ;-)

llvm-svn: 78517
2009-08-08 23:39:42 +00:00
Chris Lattner
f8ab7ad73a switch this to create coff sections for now, it doesn't really matter for
llvm-mc's purpose yet and we'll want to switch to creating semantic sections
at some point.

llvm-svn: 78509
2009-08-08 22:38:48 +00:00
Benjamin Kramer
1b44e6e359 Always initialize AsmConds.
llvm-svn: 78463
2009-08-08 11:26:50 +00:00
Kevin Enderby
dd20299f97 Added Mac OS X assembler style conditional assembly. I may come back and see if
I can clean this up a bit more and do way with the TheCondState and just use
the top element on the TheCondStack if not empty.  Also may tweak the code
around ParseConditionalAssemblyDirectives() to simplify the AsmParser code.

llvm-svn: 78423
2009-08-07 22:46:00 +00:00
Daniel Dunbar
2781e4bd89 Remove now unused arguments from TargetRegistry::lookupTarget.
llvm-svn: 77950
2009-08-03 04:20:57 +00:00
Chris Lattner
506b49ffa0 Make SectionKind::get() private.
llvm-svn: 77835
2009-08-02 00:02:44 +00:00
Chris Lattner
944a154399 update for API change.
llvm-svn: 77804
2009-08-01 21:14:30 +00:00
Chris Lattner
04ae6629fe All MCSections are now required to have a SectionKind.
llvm-svn: 77787
2009-08-01 18:25:49 +00:00
Daniel Dunbar
7fd7e31119 llvm-mc: More quoted identifier support.
llvm-svn: 77761
2009-08-01 00:48:30 +00:00
Daniel Dunbar
e150b07b71 llvm-mc: Support quoted identifiers.
- Uses MCAsmToken::getIdentifier which returns the (sub)string representing the
   meaningfull contents a string or identifier token.

 - Directives aren't done yet.

llvm-svn: 77739
2009-07-31 21:55:09 +00:00
Chris Lattner
4d1b33e52e fix some more issues where we expected GetSection to do "get or create"
llvm-svn: 77700
2009-07-31 18:27:48 +00:00
Chris Lattner
dd53131aee fix a bunch of failing tests now that MCContext::GetSection doesn't create sections.
llvm-svn: 77689
2009-07-31 17:47:16 +00:00
Daniel Dunbar
48d0ed9534 Update CMakeLists
llvm-svn: 77385
2009-07-28 22:46:39 +00:00
Daniel Dunbar
4ed0e9b76c Move X86 instruction parsing into X86/AsmParser.
llvm-svn: 77384
2009-07-28 22:40:46 +00:00
Daniel Dunbar
ec1ea2e240 Make expression parsing and error/warning reporting available through the
generic MCAsmParser interface.

llvm-svn: 77381
2009-07-28 22:22:31 +00:00
Daniel Dunbar
d0d6b26e87 Provide generic MCAsmParser when constructing target specific parsers.
llvm-svn: 77362
2009-07-28 20:47:52 +00:00
Daniel Dunbar
20903ee1b9 Switch X86 assembly parser to using the generic lexer interface.
llvm-svn: 77341
2009-07-28 18:17:26 +00:00
Daniel Dunbar
6e2f7db6b6 Expose Tokens to target specific assembly parsers.
llvm-svn: 77337
2009-07-28 17:58:44 +00:00
Daniel Dunbar
45429b2b1e Switch AsmLexer::Lex to returning a reference to the current token.
llvm-svn: 77328
2009-07-28 16:56:42 +00:00
Daniel Dunbar
61ef1ddfb4 Drop some AsmLexer methods in favor of their AsmToken equivalents.
llvm-svn: 77323
2009-07-28 16:38:40 +00:00
Daniel Dunbar
1c373fc85a llvm-mc: Sink token enum into AsmToken.
llvm-svn: 77322
2009-07-28 16:08:33 +00:00
Daniel Dunbar
f7ad1ea8dd llvm-mc: Factor AsmToken class out of AsmLexer.
llvm-svn: 77292
2009-07-28 03:00:54 +00:00
Daniel Dunbar
9e627e8dc8 llvm-mc: Stop uniqueing string tokens, nothing actually uses this.
llvm-svn: 77287
2009-07-28 00:58:50 +00:00
Daniel Dunbar
3edfc4bb16 llvm-mc: Implement .abort fully in the front end
llvm-svn: 77272
2009-07-27 23:20:52 +00:00
Daniel Dunbar
5f73e9d3f8 llvm-mc: Move AsmLexer::getCurStrVal to StringRef based API.
- My DFS traversal of LLVM is, at least for now, nearly complete! :)

llvm-svn: 77258
2009-07-27 21:49:56 +00:00
Daniel Dunbar
a7a01acc7c Factor commonality in triple match routines into helper template for registering
classes, and migrate existing targets over.

llvm-svn: 77126
2009-07-26 05:03:33 +00:00
Daniel Dunbar
62e74f03c7 Add TargetRegistry::lookupTarget.
- This is a simplified mechanism which just looks up a target based on the
   target triple, with a few additional flags.

 - Remove getClosestStaticTargetForModule, the moral equivalent is now:
     lookupTarget(Mod->getTargetTriple, true, false, ...);

 - This no longer does the fuzzy matching with target data (based on endianness
   and pointer width) that getClosestStaticTargetForModule was doing, but this
   was deemed unnecessary.

llvm-svn: 77111
2009-07-26 02:12:58 +00:00
Daniel Dunbar
b5adc13728 Convert StringMap to using StringRef for its APIs.
- Yay for '-'s and simplifications!

 - I kept StringMap::GetOrCreateValue for compatibility purposes, this can
   eventually go away. Likewise the StringMapEntry Create functions still follow
   the old style.

 - NIFC.

llvm-svn: 76888
2009-07-23 18:17:34 +00:00
Kevin Enderby
f1c0daa6a7 Removed the DumpSymbolsandMacros and LoadSymbolsandMacros MCStreamer API as
the parsing of the .dump and .load should be done in the assembly parser and
not have any need for an MCStreamer API.  Changed the code for now so these
just produce an error saying these specific directives are not yet implemented
since they are likely no longer used and may never need to be implemented.

llvm-svn: 76462
2009-07-20 20:25:37 +00:00
Daniel Dunbar
2e4aeceacd Add MCAsmLexer interface.
- This provides the AsmLexer interface to the target specific assembly parsers.

llvm-svn: 76460
2009-07-20 20:01:54 +00:00
Daniel Dunbar
fca75cd98e Add MCAsmParser interface.
- This provides the AsmParser interface to the target specific assembly
   parsers.

llvm-svn: 76453
2009-07-20 18:55:04 +00:00
Daniel Dunbar
961c43b2b0 llvm-mc: Default -triple to LLVM_HOSTTRIPLE.
llvm-svn: 76260
2009-07-17 22:51:20 +00:00
Daniel Dunbar
ab1316fbaf llvm-mc: Add -triple, and start fetching the target asm printer.
llvm-svn: 76257
2009-07-17 22:38:58 +00:00
Kevin Enderby
f641ecc6e8 Removed the SubsectionsViaSymbols MCStreamer API and replaced it with a generic
EmitAssemblerFlag API which takes a value from the added AssemblerFlag
enumerated constants.

llvm-svn: 76087
2009-07-16 17:56:39 +00:00
Kevin Enderby
b5346feb10 Clean up the definition of Str in AsmParser::ParseDirectiveDarwinDumpOrLoad
so it is defined with a lifetime that is as short as possible.

llvm-svn: 76082
2009-07-16 17:17:46 +00:00
Chris Lattner
4939bd13ad implement .include in the lexer/parser instead of passing it into the streamer.
llvm-svn: 75896
2009-07-16 06:14:39 +00:00
Kevin Enderby
312f8559cb Added llvm-mc support for parsing the .dump and .load directives.
llvm-svn: 75786
2009-07-15 15:30:11 +00:00
Kevin Enderby
3e47cf1dda Added llvm-mc support for parsing the .include directive.
llvm-svn: 75711
2009-07-14 23:21:55 +00:00
Kevin Enderby
5821cee99b Added llvm-mc support for parsing the .lsym directive.
llvm-svn: 75685
2009-07-14 21:35:03 +00:00
Kevin Enderby
0b1331c43b Added llvm-mc support for parsing the .desc directive.
llvm-svn: 75645
2009-07-14 18:17:10 +00:00
Kevin Enderby
af095fcfb8 Added llvm-mc support for parsing the .abort directive.
llvm-svn: 75545
2009-07-13 23:15:14 +00:00
Kevin Enderby
a461788d6a add llvm-mc support for parsing the .subsections_via_symbols directive.
llvm-svn: 75500
2009-07-13 21:03:15 +00:00
Chris Lattner
1e7e5e5de0 silence vc++ warning.
llvm-svn: 75394
2009-07-11 22:32:37 +00:00
Chris Lattner
84bf9fed2b add support for .zerofill, patch by Kevin Enderby!
llvm-svn: 75301
2009-07-10 22:20:30 +00:00
Chris Lattner
56638bb644 add llvm-mc support for parsing the .lcomm directive, patch by Kevin Enderby!
llvm-svn: 75148
2009-07-09 17:25:12 +00:00
Chris Lattner
2bea79b45b Implement parsing support for the .comm directive. Patch by
Kevin Enderby!

llvm-svn: 74944
2009-07-07 20:30:46 +00:00
Chris Lattner
448c0a2708 implement error recovery in the llvm-mc parser. Feel the power!
llvm-svn: 74728
2009-07-02 21:53:43 +00:00
Daniel Dunbar
0afb18f239 llvm-mc/x86: Fix various nit-picky bugs in displacement parsing.
- Test case to follow.

llvm-svn: 74687
2009-07-02 02:26:39 +00:00
Daniel Dunbar
b87d6f328e llvm-mc/x86: Fix bug in disambiguation of displacement operand, introduced by me
(I think).
 - We weren't properly parsing the leading parenthesized expression in something
   like 'push (4)(%eax)'.
 
 - Added ParseParenRelocatableExpression to support this. I suspect we should
   just use lookahead, though.

 - Test case to follow.

llvm-svn: 74685
2009-07-02 02:09:07 +00:00
Daniel Dunbar
ffbf6228a2 llvm-mc/x86: Factor out ParseX86Register.
llvm-svn: 74684
2009-07-02 01:58:24 +00:00
Daniel Dunbar
7c83d0ed14 llvm-mc/x86: Rename X86Operand::ScaleReg to IndexReg and make order consistent
with syntax.

llvm-svn: 74679
2009-07-02 00:51:52 +00:00
Daniel Dunbar
351a228c46 llvm-mc: Add some more doxyments.
llvm-svn: 74607
2009-07-01 15:14:50 +00:00
Daniel Dunbar
f234f1f312 llvm-mc: Fill in the rest of tokens for 'as-lex' mode.
llvm-svn: 74598
2009-07-01 06:56:54 +00:00
Daniel Dunbar
7f47cc9423 Rename MCValue::isConstant to isAbsolute.
llvm-svn: 74596
2009-07-01 06:48:00 +00:00
Chris Lattner
db3d640a42 add some of the new tokens, others are still missing.
llvm-svn: 74595
2009-07-01 06:36:49 +00:00
Daniel Dunbar
1960440e70 llvm-mc: Emit parsed instructions to the MCStreamer.
llvm-svn: 74594
2009-07-01 06:35:48 +00:00
Daniel Dunbar
cae97fa7a9 llvm-mc: Introduce method to match a parsed x86 instruction into an MCInst.
llvm-svn: 74573
2009-06-30 23:38:38 +00:00
Daniel Dunbar
3f34774b4a llvm-mc: Accept relocatable expressions when parsing displacements and
immediates.

llvm-svn: 74568
2009-06-30 23:02:44 +00:00
Daniel Dunbar
d0589c59b3 llvm-mc: Symbols in a relocatable expression of the (a - b + cst) form are
allowed to be undefined when the expression is seen, we cannot enforce the
same-section requirement until the entire assembly file has been seen.

llvm-svn: 74565
2009-06-30 22:49:27 +00:00
Daniel Dunbar
f3f3e60b4f Suppress may-be-used-uninitialized warning.
llvm-svn: 74529
2009-06-30 16:02:47 +00:00
Douglas Gregor
2373782453 Fix CMake build
llvm-svn: 74527
2009-06-30 14:37:26 +00:00
Daniel Dunbar
2d92d62fb2 llvm-mc: Accept relocatable expressions for .org, assignments, .byte, etc.
llvm-svn: 74498
2009-06-30 02:10:03 +00:00
Daniel Dunbar
a702c280bb llvm-mc: Rewrite binary subtraction for relocatable expressions, we can't always
legally negate an MCValue.

llvm-svn: 74497
2009-06-30 02:08:27 +00:00
Daniel Dunbar
c3cac19cfe llvm-mc: Evaluation for relocatable expressions.
llvm-svn: 74496
2009-06-30 01:49:52 +00:00
Daniel Dunbar
5bec168037 Normalize SourceMgr messages.
- Don't print "Parsing" in front of every message.

 - Take additional "type" argument which is prepended to the message (with ": ")
   if given.

 - Update clients to print errors (warnings) as:
<filename>:<line number>: error(warning): ...

llvm-svn: 74489
2009-06-30 00:49:23 +00:00
Daniel Dunbar
e4fd18eda8 llvm-mc: Parse symbol attribute directives.
llvm-svn: 74487
2009-06-30 00:33:19 +00:00
Daniel Dunbar
72c0434597 llvm-mc: Parse .{,b,p2}align{,w,l} directives.
llvm-svn: 74478
2009-06-29 23:46:59 +00:00
Daniel Dunbar
37b8fe7db3 llvm-mc: Diagnose misuse (mix) of defined symbols and labels.
- For example, we diagnose errors on:
--
a:
a = 10
--

 - For now we reject code like:
--
.long a
a = 10
--
   which "as" accepts (on Darwin).

llvm-svn: 74476
2009-06-29 23:43:14 +00:00
Daniel Dunbar
fca88cf26b llvm-mc: Recognize C++ style comments.
llvm-svn: 74463
2009-06-29 22:00:57 +00:00
Daniel Dunbar
67828e6e0a llvm-mc: Recognize C++ style comments.
llvm-svn: 74462
2009-06-29 21:58:22 +00:00
Daniel Dunbar
8be858eeb4 Fix uninitialized variable warning.
llvm-svn: 74457
2009-06-29 21:14:21 +00:00
Daniel Dunbar
41782dbbcd MC: Improve expression parsing and implement evaluation of absolute expressions
(missed files).

llvm-svn: 74450
2009-06-29 20:40:36 +00:00
Daniel Dunbar
ade4f03bd0 MC: Improve expression parsing and implement evaluation of absolute expressions.
llvm-svn: 74448
2009-06-29 20:37:27 +00:00
Daniel Dunbar
bfc585a86e MC: Parse .org directives.
llvm-svn: 74218
2009-06-25 22:44:51 +00:00
Daniel Dunbar
d7a883b5e5 MC: Parse .set and assignments.
llvm-svn: 74208
2009-06-25 21:56:11 +00:00
Daniel Dunbar
5cf59dd842 Basic .s parsing for .asci[iz], .fill, .space, {.byte, .short, ... }
- Includes some DG tests in test/MC/AsmParser, which are rather primitive since
   we don't have a -verify mode yet.

llvm-svn: 74139
2009-06-24 23:30:00 +00:00
Chris Lattner
f8a7746988 implement a bunch of synonyms for section switching.
llvm-svn: 74062
2009-06-24 05:13:15 +00:00
Chris Lattner
0945d20ceb add support for parsing and emitting .section directives. We can now parse
things like:
.section __TEXT,__cstring,cstring_literals

llvm-svn: 74058
2009-06-24 04:43:34 +00:00
Chris Lattner
61a6509f6a add trivial support for passing label definitions through the MCStreamer.
This is suboptimal in several aspects, see the commented out assertion.
I need to talk to Daniel about this.

llvm-svn: 74057
2009-06-24 04:31:49 +00:00
Chris Lattner
f76b48bc93 create an MCStreamer and provide it to AsmParser.
llvm-svn: 74039
2009-06-24 00:52:40 +00:00
Chris Lattner
d3b90f1344 make the lexer unique strings it lexes instead of passing them back as
std::strings.

llvm-svn: 74036
2009-06-24 00:33:19 +00:00
Daniel Dunbar
323218db15 Start flushing out MCContext.
- Lives inside new library lib/MC (LLVMMC.a)

llvm-svn: 74013
2009-06-23 22:01:43 +00:00
Chris Lattner
43f200c74a refactor a bunch of X86 specific stuff out to its own file.
llvm-svn: 73982
2009-06-23 18:41:30 +00:00
Chris Lattner
43a2dca0e4 implement a trivial binary expression parser, we can now parse all of 176.gcc.llc.s
llvm-svn: 73950
2009-06-23 05:57:07 +00:00
Chris Lattner
c3b0266a77 get a definition of strull on windows, thanks to Howard Su.
llvm-svn: 73929
2009-06-23 00:24:36 +00:00
Duncan Sands
5e54310d7d Include cstdio to get EOF, needed with gcc-4.4.
llvm-svn: 73879
2009-06-22 06:59:32 +00:00
Chris Lattner
886ab50a50 process memory operands with a parenthesized expression for a displacement,
like "(4+5)(%eax)".

llvm-svn: 73878
2009-06-22 06:35:58 +00:00
Chris Lattner
5927443800 Implement full support for parsing primary expressions. We can now parse
all of health and voronoi (ignoring directives).  We only get 409 lines into
176.gcc though because we don't have binary operators yet:

Parsing 176.gcc.llc.s:409: unexpected token in operand list
	movsbl	_arityvec+1(,%edi,8), %eax
	      	         ^

llvm-svn: 73877
2009-06-22 06:32:03 +00:00
Chris Lattner
370f52dc85 implement parser support for '*' operands, as in "call *%eax".
llvm-svn: 73876
2009-06-22 06:02:13 +00:00
Chris Lattner
06378f9853 implement memory operand parsing.
llvm-svn: 73875
2009-06-22 05:51:26 +00:00
Chris Lattner
82084cf5a1 start implementing some simple operand parsing.
llvm-svn: 73867
2009-06-22 01:29:09 +00:00
Chris Lattner
dd95ab3ca9 rename SourceMgr::PrintError to PrintMessage.
llvm-svn: 73861
2009-06-21 21:22:11 +00:00
Chris Lattner
f896c01361 set up the top-level parsing loop.
llvm-svn: 73860
2009-06-21 20:54:55 +00:00
Chris Lattner
89e17d02b1 stub out parser for asm files. Change invariant on lexer to always
print its error message when it returns an asmtok::Error token.
Compute a proper error code for llvm-mc in 'lex' mode.  Add new
-as-lex option to enable lexing mode (vs parsing mode).

llvm-svn: 73859
2009-06-21 20:16:42 +00:00
Chris Lattner
26507d1082 add string literals.
llvm-svn: 73858
2009-06-21 19:56:35 +00:00
Chris Lattner
9f3189ec41 hopefully fix the build on linux.
llvm-svn: 73857
2009-06-21 19:43:50 +00:00
Chris Lattner
b6cfcfadd4 implement enough of a lexer to get through Olden/health/Output/health.llc.s
without errors.

llvm-svn: 73855
2009-06-21 19:21:25 +00:00
Chris Lattner
f0c5d670e0 oh yeah, cmake needs to be told explicitly about new files :)
llvm-svn: 73849
2009-06-21 07:19:34 +00:00
Chris Lattner
7a7ac287db some baby steps.
llvm-svn: 73848
2009-06-21 07:19:10 +00:00
Chris Lattner
c94208cf9c start wiring up support for asm parsing.
llvm-svn: 73846
2009-06-21 05:22:37 +00:00
Chris Lattner
aa193955e5 fix build problem pointed out by John Thompson!
llvm-svn: 73739
2009-06-18 23:46:04 +00:00
Chris Lattner
821cb96b3b fix file header
llvm-svn: 73733
2009-06-18 23:05:21 +00:00
Chris Lattner
698abf1ad4 Add a skeleton driver for new machine code level fun. llvm-mc is meant
to be a test driver of other components in the system, which will develop
over time.

llvm-svn: 73732
2009-06-18 23:04:45 +00:00