Commit Graph

184 Commits

Author SHA1 Message Date
Rafael Espindola 5e874982f2 Add support for expressions in .sleb/.uleb directives.
llvm-svn: 118023
2010-11-02 17:22:24 +00:00
Rafael Espindola 1614597873 Implement .weakref.
llvm-svn: 117911
2010-11-01 14:28:48 +00:00
Jason W Kim 645f6c2bef Tiny patch for proof-of-concept cleanup of ARMAsmPrinter::EmitStartOfAsmFile()
Small test for sanity check of resulting ARM .s file.
Tested against -r115129.

llvm-svn: 115133
2010-09-30 02:45:56 +00:00
Chris Lattner 7bce0596a7 allow target-specific label suffixes, patch by Yuri Gribov!
llvm-svn: 114592
2010-09-22 22:19:53 +00:00
Jim Grosbach 6ebd728067 grammar tweakage
llvm-svn: 114561
2010-09-22 18:18:30 +00:00
Jim Grosbach 3bde49aa29 remove trailing whitespace
llvm-svn: 114560
2010-09-22 18:16:55 +00:00
Rafael Espindola f667d929ce Add a InitSections method to the streamer interface.
The ELF implementation now creates text, data and bss to match the gnu as
behavior.

The text streamer still has the old MachO specific behavior since
the testsuite checks that it will error when a directive is given
before a setting the current section for example.

A nice benefit is that -n is not required anymore when producing
ELF files.

llvm-svn: 114027
2010-09-15 21:48:40 +00:00
Benjamin Kramer e39017cb97 Add AsmParser support for the ELF .previous directive. Patch by Roman Divacky.
llvm-svn: 112849
2010-09-02 18:53:37 +00:00
Benjamin Kramer a3e0ddb564 Plug the remaining MC leaks by giving MCObjectStreamer/MCAsmStreamer ownership of the TargetAsmBackend and the MCCodeEmitter.
llvm-svn: 109767
2010-07-29 17:48:06 +00:00
Kevin Enderby 082d0fd7ad Added the darwin .weak_def_can_be_hidden directive.
llvm-svn: 107886
2010-07-08 17:22:42 +00:00
Chris Lattner 79d2075e4a "This is just a cosmetic change in MCAsmStreamer.cpp/EmitSymbolAttribute: all attributes have now a \t before and after, as done for '.type'.
This makes the output look consistent, as well as help some third party assemblers expecting the attributes to be in the second column."

Patch by Arnaud de Grandmaison!

llvm-svn: 106469
2010-06-21 20:35:01 +00:00
Dan Gohman a76715fc88 Don't call flush() at a library level which isn't checking for errors
and doesn't know where the output is going.

llvm-svn: 105274
2010-06-01 16:31:34 +00:00
Daniel Dunbar 3627af5da4 MC: Change MCInst::dump_pretty to not include a trailing newline.
llvm-svn: 104696
2010-05-26 15:18:13 +00:00
Eric Christopher 5c87be766d Make EmitTBSSSymbol take a section argument so that we can find it later.
Fix up callers and users.

llvm-svn: 104057
2010-05-18 21:16:04 +00:00
Eric Christopher 68b1bbe66a Assume that we'll handle mangling the symbols earlier and just put the
symbol to the file as we have it.  Simplifies out tbss handling.

llvm-svn: 103928
2010-05-17 02:13:02 +00:00
Eric Christopher 9fb6bb07ca Add AsmParser support for darwin tbss directive.
Nothing uses this yet.

llvm-svn: 103757
2010-05-14 01:50:28 +00:00
Chris Lattner 72afa956db break coff symbol definition stuff out into proper MCStreamer callbacks,
patch by Nathan Jeffords!

llvm-svn: 103346
2010-05-08 19:54:22 +00:00
Daniel Dunbar f3a53baf00 MC/Mach-O: Mark absolute variable's appropriately, and add Mach-O support for
writing them.
 - <rdar://problem/7885351> integrated assembler broken for i386 objc code

llvm-svn: 103112
2010-05-05 19:01:05 +00:00
Daniel Dunbar deb7ba9cc0 MC: Reject attempts to define a variable symbol.
llvm-svn: 103111
2010-05-05 19:01:00 +00:00
Daniel Dunbar 7a989da0af MC: Rename MCSymbol::{g,s}etValue -> MCSymbol::{g,s}etVariableValue.
llvm-svn: 103095
2010-05-05 17:41:00 +00:00
Chris Lattner 7012916275 fix an ugly wart in the MCInstPrinter api where the
raw_ostream to print an instruction to had to be specified
at MCInstPrinter construction time instead of being able
to pick at each call to printInstruction.

llvm-svn: 100307
2010-04-04 05:04:31 +00:00
Chris Lattner aca014e24e allow attaching comments to raw text.
llvm-svn: 100292
2010-04-03 22:06:56 +00:00
Chris Lattner 8a87fb7633 add a new EmitInlineAsm function to asmprinter to handle inline asm.
If we have an MCAsmStreamer, we continue to emit asm textually, 
otherwise we (currently) emit an error to errs and ignore it.

llvm-svn: 100289
2010-04-03 21:35:55 +00:00
Daniel Dunbar 04047fbe14 MCInst: Add ::dump_pretty.
llvm-svn: 99216
2010-03-22 21:49:34 +00:00
Chris Lattner 90a7859ebc fix an MCInstPrinter leak that jyasskin pointed out:
createAsmStreamer now takes ownership of the instprinter.

llvm-svn: 98939
2010-03-19 05:48:53 +00:00
Chris Lattner ac77bf5d1e remove MAI argument from createAsmStreamer since it
can get it from the context now.

llvm-svn: 98361
2010-03-12 18:28:53 +00:00
Chris Lattner eebaf6a76f genericize MCAsmStreamer::EmitCodeAlignment to support other targets
so that it doesn't break them when the code generator starts using it.

llvm-svn: 96966
2010-02-23 18:44:31 +00:00
Kevin Enderby e83d74f626 This is the first patch to put the needed bits in place to eventually allow code
to be aligned with optimal nops.  This patch does not change any functionality
and when the compiler is changed to use EmitCodeAlignment() it should also not
change the resulting output.  Once the compiler change is made and everything
looks good the next patch with the table of optimal X86 nops will be added to
WriteNopData() changing the output.  There are many FIXMEs in this patch which
will be removed when we have better target hooks (coming soon I hear).

llvm-svn: 96963
2010-02-23 18:26:34 +00:00
Chris Lattner 524138176d add a new MCInstPrinter::getOpcodeName interface, when it is
implemented, llvm-mc --show-inst now uses it to print the
instruction opcode as well as the number.

llvm-svn: 95929
2010-02-11 22:39:10 +00:00
Chris Lattner ddeceae839 make getFixupKindInfo return a const reference, allowing
the tables to be const.  Teach MCCodeEmitter to handle
the target-indep kinds so that we don't crash on them.

llvm-svn: 95924
2010-02-11 21:27:18 +00:00
Daniel Dunbar 605474463f MC: Switch MCFixup to just hold an MCExpr pointer instead of index into the
MCInst it came from.

llvm-svn: 95767
2010-02-10 04:47:08 +00:00
Daniel Dunbar 75c9a4eeae llvm-mc: Remove --show-fixups and always show as part of --show-encoding.
Also, fix a silly memory leak.

llvm-svn: 95752
2010-02-10 01:41:14 +00:00
Chris Lattner 69920c5c8a daniel *really* likes fixups!
llvm-svn: 95742
2010-02-10 01:05:28 +00:00
Chris Lattner 482bf69bfe Add ability for MCInstPrinters to add comments for instructions.
Enhance the x86 backend to show the hex values of immediates in
comments when they are large.  For example:

        movl    $1072693248, 4(%esp)    ## imm = 0x3FF00000

llvm-svn: 95728
2010-02-10 00:10:18 +00:00
Daniel Dunbar 9a0a46163d llvm-mc: Add --show-fixups option, for displaying the instruction fixup information in the asm comments.
llvm-svn: 95710
2010-02-09 23:00:14 +00:00
Daniel Dunbar b311a6b3ae MC: First cut at MCFixup, for getting fixup/relocation information out of an MCCodeEmitter.
llvm-svn: 95708
2010-02-09 22:59:55 +00:00
Chris Lattner 89261502cb make -show-inst be formatted a bit nicer. Before:
movl	$3735928559, a          ## inst: <MCInst 1273 <MCOperand Reg:0> <MCOperand Imm:1> <MCOperand Reg:0> <MCOperand Expr:(a)> <MCOperand Reg:0> <MCOperand Expr:(3735928559)>>

after:

	movl	$3735928559, a          ## <MCInst #1273
                                        ##   <MCOperand Reg:0>
                                        ##   <MCOperand Imm:1>
                                        ##   <MCOperand Reg:0>
                                        ##   <MCOperand Expr:(a)>
                                        ##   <MCOperand Reg:0>
                                        ##   <MCOperand Expr:(3735928559)>>

llvm-svn: 95637
2010-02-09 00:54:51 +00:00
Chris Lattner 175629608e print encodings like this:
pslld	69, %mm3                ## encoding: [0x0f,0xf2,0x1c,0x25,0x45,0x00,0x00,0x00]

instead of like this:
	pslld	69, %mm3                ## encoding: [0x0f,0xf2,0x1c,0x25,0x45,0000,0000,0000]

this only affects 0.

llvm-svn: 95441
2010-02-05 22:20:08 +00:00
Dan Gohman 77fe07a93a Use a tab instead of space after .type, for consistency.
llvm-svn: 95272
2010-02-04 01:42:13 +00:00
Daniel Dunbar e3ee332fe0 llvm-mc: Add --show-inst option, for showing the MCInst inline with the assembly
output.

llvm-svn: 95227
2010-02-03 18:18:30 +00:00
Chris Lattner 44f7325de5 print instruction encodings with the existing comment facilities,
so that llvm-mc -show-encoding prints like this:

	hlt                                                 ## encoding: [0xf4]

instead of like this:

	hlt
                     # encoding: [0xf4]

llvm-svn: 95207
2010-02-03 06:28:13 +00:00
Chris Lattner b0d44c3807 refactor code so that LLVMTargetMachine creates the asmstreamer and
mccontext instead of having AsmPrinter do it.  This allows other 
types of MCStreamer's to be passed in.

llvm-svn: 95155
2010-02-02 23:37:42 +00:00
Rafael Espindola dcb03f0f6b Emit .comm alignment in bytes but .align in powers of 2 for ARM ELF.
Original patch by Sandeep Patel and updated by me.

llvm-svn: 94582
2010-01-26 20:21:43 +00:00
Chris Lattner 3cde760023 mcstreamerize gprel32 emission.
llvm-svn: 94452
2010-01-25 21:28:50 +00:00
Chris Lattner 601ef33c77 mcstreamerize .file and .file. This also fixes an issue where the
normal form of .file would fail if the filename had a weird character
in it.

llvm-svn: 94437
2010-01-25 18:58:59 +00:00
Chris Lattner bc696445e1 emit ELF .type directives through MCStreamer instead of doing it textually.
llvm-svn: 94436
2010-01-25 18:33:40 +00:00
Chris Lattner bc8f638531 add symbol attribute support for the ELF .type directive.
llvm-svn: 94435
2010-01-25 18:30:45 +00:00
Chris Lattner 91dac6d570 emit the .size directive for global variables on ELF through
mcstreamer.

llvm-svn: 94416
2010-01-25 07:52:13 +00:00
Chris Lattner 0375d2fbe7 all supported target now have aligned common support.
llvm-svn: 94413
2010-01-25 07:29:13 +00:00
Chris Lattner b1301f7bce mcize lcomm, simplify .comm, extend both to support 64-bit sizes.
llvm-svn: 94299
2010-01-23 07:47:02 +00:00
Chris Lattner 685508cf49 move the various directive enums out of the MCStreamer class
into a new MCDirectives.h file.

llvm-svn: 94294
2010-01-23 06:39:22 +00:00
Chris Lattner 4225a7b987 mcize jump table and constant pool entry labels, .local on elf,
and some .weak directives.

llvm-svn: 94284
2010-01-23 05:19:23 +00:00
Chris Lattner ded9af63bb teach MCAsmStreamer::EmitBytes to use .ascii and .asciz
llvm-svn: 94259
2010-01-23 00:15:00 +00:00
Chris Lattner 1386a88c95 Changes to fix buffering that I forgot to commit with previous patch.
llvm-svn: 94222
2010-01-22 21:16:10 +00:00
Chris Lattner a3eee3cb69 Convert some more random-comment-printing stuff to use
AddComment and GetCommentOS.  Add a blank line between globals
(even in non-verbose mode) to make the assembly more readable.

llvm-svn: 94202
2010-01-22 19:52:01 +00:00
Chris Lattner 8fa0e35f97 add a new MCAsmStreamer::GetCommentOS method to simplify stuff
that doesn't want to use twines.

llvm-svn: 94199
2010-01-22 19:17:48 +00:00
Chris Lattner e1d8a319a1 rename addComment -> AddComment for consistency.
llvm-svn: 94190
2010-01-22 18:21:35 +00:00
Chris Lattner cfa5ebc336 add comment support to the rest of the directives.
llvm-svn: 94168
2010-01-22 07:36:39 +00:00
Chris Lattner 38e9219f71 Add the ability for MCStreamer to emit comments on the same line as directives.
Switch over the asm-verbose comment for double values to use it.  We now get:

_x:
	.long	343597384                                   ## double 1.231200e+02
	.long	1079953326

For example, note that the comment is on the same line as the .long.  Woo.

llvm-svn: 94166
2010-01-22 07:29:22 +00:00
Chris Lattner 0522eb2160 pass "-fasm-verbose" into createAsmStreamer.
llvm-svn: 94165
2010-01-22 07:06:15 +00:00
Chris Lattner 1edfeb2c46 don't forget to initialize an instance variable!
llvm-svn: 94021
2010-01-20 20:48:59 +00:00
Chris Lattner 9fc980403e use getGlobalDirective(), don't hardcode .globl. PR6093
llvm-svn: 94006
2010-01-20 17:50:30 +00:00
Chris Lattner 45eeffcc2a make mcasmstreamer handle expanding 8 byte integer constants to
4-byte constants if .quad isn't supported.  Switch a bunch of
methods used by the dwarf writer to use OutStreamer.EmitIntValue.

llvm-svn: 93987
2010-01-20 06:45:39 +00:00
Chris Lattner 38caaf14c1 give createAsmStreamer an 'isLittleEndian' argument.
llvm-svn: 93986
2010-01-20 06:39:07 +00:00
Chris Lattner dc50e5d128 add a new EmitIntValue method that MCStreamer impls can optionally define
and that clients can use.

llvm-svn: 93923
2010-01-19 22:03:38 +00:00
Chris Lattner c35681b298 Generalize mcasmstreamer data emission APIs to take an address space
identifier.  There is no way to work around it.

llvm-svn: 93896
2010-01-19 19:46:13 +00:00
Chris Lattner ed89f60f5e mcstreamerize AsmPrinter::EmitZeros, at least when emitting to the
default address space.

llvm-svn: 93890
2010-01-19 18:58:52 +00:00
Chris Lattner 4340cb3246 add an MCAsmStreamer::EmitFill specialization of EmitFill that
emits one directive instead of N.  Not doing this would be a
significant regression on the # bytes generated by .fill.

llvm-svn: 93889
2010-01-19 18:52:28 +00:00
Chris Lattner 95b98959b0 mc'ize some stuff, don't comment out .lcomm directive in -fverbose-asm mode.
llvm-svn: 93860
2010-01-19 06:01:04 +00:00
Chris Lattner c8f7717808 remove the MAI argument to MCExpr::print and switch overthing to use << when printing them.
llvm-svn: 93699
2010-01-18 00:37:40 +00:00
Chris Lattner 8b5d55ed06 now that MCSymbol::print doesn't use it's MAI argument, we can
remove it and change all the code that prints MCSymbols to use 
<< instead, which is much simpler and cleaner.

llvm-svn: 93695
2010-01-17 21:43:43 +00:00
Daniel Dunbar ad36e8aceb Pass StringRef by value.
llvm-svn: 86251
2009-11-06 10:58:06 +00:00
Daniel Dunbar e024def785 Minor formatting tweaks.
llvm-svn: 84235
2009-10-16 01:58:15 +00:00
Daniel Dunbar 5f339244fb MC: Tweak variable assignment diagnostics, and make reassignment of non-absolute
variables and symbols invalid.

llvm-svn: 84232
2009-10-16 01:57:39 +00:00
Daniel Dunbar d20cda028a MC: When parsing a variable reference, substitute absolute variables immediately
since they are allowed to be redefined.

llvm-svn: 84230
2009-10-16 01:34:54 +00:00
Chris Lattner 11b2fc9ea4 Change MCAsmStreamer to take an MCInstPrinter instead of a
full AsmPrinter, and change TargetRegistry to keep track
of registered MCInstPrinters.

llvm-mc is still linking in the entire
target foo to get the code emitter stuff, but this is an
important step in the right direction.

llvm-svn: 81754
2009-09-14 03:02:37 +00:00
Chris Lattner a4760f3642 'printMCInst' doesn't print newlines after instructions anymore.
llvm-svn: 81723
2009-09-13 22:24:34 +00:00
Chris Lattner f4366a3998 Thread an MCAsmInfo pointer through the various MC printing APIs,
and fix a few things using << on MCSymbols to use ->print(). No
functionality change other than unbreaking my previous patch.

llvm-svn: 80890
2009-09-03 05:46:51 +00:00
Chris Lattner 1800dff44e inline insertion operators.
llvm-svn: 80888
2009-09-03 05:33:01 +00:00
Chris Lattner f16a122213 output alignment value in hex so that we get:
.align 3, 0x90
instead of,
  .align 3, 144

suggested by eric.

llvm-svn: 80875
2009-09-03 04:01:10 +00:00
Daniel Dunbar 897ffadd2d llvm-mc: Pass values to MCStreamer as MCExprs, not MCValues.
llvm-svn: 80578
2009-08-31 08:09:28 +00:00
Daniel Dunbar b7b2097aac llvm-mc: Simplify EmitAssignment ('.set' is identical to '=').
llvm-svn: 80577
2009-08-31 08:09:09 +00:00
Daniel Dunbar 73da11ebda llvm-mc: Switch MCInst to storing an MCExpr* instead of an MCValue.
Also, use MCInst::print instead of custom code in MCAsmPrinter.

llvm-svn: 80575
2009-08-31 08:08:38 +00:00
Daniel Dunbar 6a715dccdf llvm-mc: MCStreamer cleanups. - Remove EmitLocalSymbol, this is unsupported for now.
- Switch Emit{CommonSymbol,Zerofill} to take alignment in bytes (for consistency).

llvm-svn: 80484
2009-08-30 06:17:16 +00:00
Daniel Dunbar 96abad185d llvm-mc: Emit .lcomm as .zerofill.
llvm-svn: 80343
2009-08-28 05:48:46 +00:00
Daniel Dunbar cf72e1c03e llvm-mc: Add const to EmitZeroFill section argument.
llvm-svn: 80341
2009-08-28 05:48:22 +00:00
Daniel Dunbar c4f0e7e28d llvm-mc: Print encodings after the instruction, and only when we have an asm
printer.

llvm-svn: 80233
2009-08-27 07:58:57 +00:00
Daniel Dunbar 65105174a6 Sketch TargetRegistry support for MCCodeEmitter abstract interface.
- Of course, nothing actually can provide this interface yet.

llvm-svn: 80188
2009-08-27 00:51:57 +00:00
Chris Lattner e9a75a6654 rename TAI -> MAI, being careful not to make MAILJMP instructions :)
llvm-svn: 79777
2009-08-22 21:43:10 +00:00
Chris Lattner 7b26fce23e Rename TargetAsmInfo (and its subclasses) to MCAsmInfo.
llvm-svn: 79763
2009-08-22 20:48:53 +00:00
Daniel Dunbar 6860ac7375 llvm-mc: Clean up some handling of symbol/section association to be more correct
(external was really undefined and there wasn't an explicit representation for
absolute symbols).
 - This still needs some cleanup to how the absolute "pseudo" section is dealt
   with, but I haven't figured out the nicest approach yet.

llvm-svn: 79733
2009-08-22 07:22:36 +00:00
Chris Lattner 78b23b0e3f fix asmstreaming of 2/4 byte elements with pow-2 alignments.
llvm-svn: 79408
2009-08-19 06:35:36 +00:00
Chris Lattner 37b7234a75 switch asmprinter to emit alignments through OutStreamer.
llvm-svn: 79406
2009-08-19 06:12:02 +00:00
Chris Lattner 4b7dadb76e eliminate AsmPrinter::SwitchToSection and just have clients
talk to the MCStreamer directly instead.

llvm-svn: 79405
2009-08-19 05:49:37 +00:00
Chris Lattner 0adae25ec1 Make AsmStreamer maintain a notion of the current section, pushing it up from the
MCAsmStreamer.  Based on this, eliminate the current section from AsmPrinter.

While I'm at it, clean up the last of the horrible "switch to null section" stuff
and add an assert.  This change is in preparation for completely eliminating 
asmprinter::switchtosection.

llvm-svn: 79324
2009-08-18 06:15:16 +00:00
Chris Lattner aa1526419c change AsmPrinter to switch sections using AsmStreamer instead of
doing it directly.  This requires const'izing a bunch of stuff that
took sections, but this seems like the right semantic thing to do:
emitting a label to a section shouldn't mutate the MCSection object
itself, for example.

llvm-svn: 79227
2009-08-17 05:49:08 +00:00
Chris Lattner a61e93d4b5 give MCAsmStreamer a TargetAsmInfo.
llvm-svn: 79222
2009-08-17 04:23:44 +00:00
Chris Lattner 962c5bd803 formatting cleanups, no functionality change.
llvm-svn: 79221
2009-08-17 04:17:34 +00:00
Daniel Dunbar 6cb1eb5a6d llvm-mc: Fix bugs where bytes were unintentionally being printed as signed.
- We now print all of 403.gcc cleanly (llvm-mc -> 'as' as diffed to 'as'), minus two 
   'rep;movsl' instructions (which I missed before).

llvm-svn: 79031
2009-08-14 19:59:24 +00:00
Daniel Dunbar c2346a3037 llvm-mc: When handling a .set, make sure to print subsequent references to the
symbol as the symbol name itself, not the expression it was defined to. These
have different semantics due to the quirky .set behavior (which absolutizes an
expression that would otherwise be treated as a relocation).

llvm-svn: 79025
2009-08-14 19:10:46 +00:00