Commit Graph

380 Commits

Author SHA1 Message Date
Rafael Espindola
5128bc1e74 Remove unused includes and out of date comment. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224413 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-17 03:07:20 +00:00
Craig Topper
2c86ed89ae Pass output stream to AsLexInput instead of the whole tool_output_file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224109 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-12 07:52:19 +00:00
Craig Topper
b8e1d7998b Use unique_ptr to remove an explicit delete. Change return type to pass the unique_ptr to caller.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224108 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-12 07:52:16 +00:00
Rafael Espindola
a48b83ebfd Remove the now unused StringRefMemoryObject.h.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221755 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-12 02:13:27 +00:00
Rafael Espindola
6a222ec893 Pass an ArrayRef to MCDisassembler::getInstruction.
With this patch MCDisassembler::getInstruction takes an ArrayRef<uint8_t>
instead of a MemoryObject.

Even on X86 there is a maximum size an instruction can have. Given
that, it seems way simpler and more efficient to just pass an ArrayRef
to the disassembler instead of a MemoryObject and have it do a virtual
call every time it wants some extra bytes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221751 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-12 02:04:27 +00:00
Colin LeMahieu
6d093fd78a [llvm-mc] Fixing case where if a file ended with non-newline whitespace or a comma it would access invalid memory.
Cleaned up parse loop.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221707 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-11 21:03:09 +00:00
Rafael Espindola
0cb58206b1 Use StringRefMemoryObject in llvm-mc. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221536 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-07 17:59:05 +00:00
Rafael Espindola
90ce9f70e2 Simplify handling of --noexecstack by using getNonexecutableStackSection.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219799 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-15 16:12:52 +00:00
Rafael Espindola
8c96862847 Modernize raw_fd_ostream's constructor a bit.
Take a StringRef instead of a "const char *".
Take a "std::error_code &" instead of a "std::string &" for error.

A create static method would be even better, but this patch is already a bit too
big.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216393 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-25 18:16:47 +00:00
David Blaikie
95ca0fb247 Explicitly pass ownership of the MemoryBuffer to AddNewSourceBuffer using std::unique_ptr
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216223 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-21 20:44:56 +00:00
Benjamin Kramer
00e08fcaa0 Canonicalize header guards into a common format.
Add header guards to files that were missing guards. Remove #endif comments
as they don't seem common in LLVM (we can easily add them back if we decide
they're useful)

Changes made by clang-tidy with minor tweaks.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215558 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-13 16:26:38 +00:00
Rafael Espindola
7cba2a973f Update the MemoryBuffer API to use ErrorOr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212405 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-06 17:43:13 +00:00
Rafael Espindola
26a84a6e7c This only needs a StringRef.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212401 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-06 14:17:29 +00:00
Alp Toker
1508c82095 SourceMgr: make valid buffer IDs start from one
Use 0 for the invalid buffer instead of -1/~0 and switch to unsigned
representation to enable more idiomatic usage.

Also introduce a trivial SourceMgr::getMainFileID() instead of hard-coding 0/1
to identify the main file.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212398 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-06 10:33:31 +00:00
Rafael Espindola
8d5114e46f Simplify code a bit, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211985 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-28 17:46:19 +00:00
Eric Christopher
179bb4e0ee Move -dwarf-version to an MC level command line option so it's
used by all of the MC level tools and codegen. Fix up all uses
in the compiler to use this and set it on the context accordingly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211257 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-19 06:22:08 +00:00
Eric Christopher
e793899a07 80-column fixups.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211255 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-19 06:22:01 +00:00
Rafael Espindola
1ad45020ec Remove 'using std::error_code' from tools.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210876 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-13 03:07:50 +00:00
Rafael Espindola
5c792faa0e Don't use 'using std::error_code' in include/llvm.
This should make sure that most new uses use the std prefix.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210835 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-12 21:46:39 +00:00
Jim Grosbach
7ca0567652 llvm-mc: Add option for prefering hex format disassembly.
Previously there was a separate mode entirely (--hdis vs.
--disassemble). It makes a bit more sense for the immediate printing
style to be a flag for --disassmeble rather than an entirely different
thing.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210700 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-11 20:26:40 +00:00
Eric Christopher
d1b5bdaebd Move MCOptions that aren't shared between programs into their specific
program and have them initialize the MCOptions struct explicitly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209321 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-21 21:05:09 +00:00
Eric Christopher
e648d75c60 This command line option is only used in one place. Move it there and
rename it to something more descriptive.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209263 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-21 00:20:01 +00:00
Eric Christopher
475ac5d302 Unify command line handling of MCTargetOptions and remove extra
options and code. No functional change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208833 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-15 01:10:50 +00:00
Rafael Espindola
2842c051b3 Remove the UseCFI option from createAsmStreamer.
We were already always passing true, this just removes the option.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208205 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-07 13:00:43 +00:00
Oliver Stannard
5604ab9da4 Record the DWARF version in MCContext
Record the DWARF version in MCContext, and use it when
emitting the dwarf version into the debug info.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207739 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-01 08:46:02 +00:00
Craig Topper
573faecacf [C++] Use 'nullptr'. Tools edition.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207176 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-25 04:24:47 +00:00
Evgeniy Stepanov
d6af41b2eb Create MCTargetOptions.
For now it contains a single flag, SanitizeAddress, which enables
AddressSanitizer instrumentation of inline assembly.

Patch by Yuri Gorshenin.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206971 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-23 11:16:03 +00:00
Lang Hames
508bd63046 [MC] Require an MCContext when constructing an MCDisassembler.
This patch re-introduces the MCContext member that was removed from
MCDisassembler in r206063, and requires that an MCContext be passed in at
MCDisassembler construction time. (Previously the MCContext member had been
initialized in an ad-hoc fashion after construction). The MCCContext member
can be used by MCDisassembler sub-classes to construct constant or
target-specific MCExprs.

This patch updates disassemblers for in-tree targets, and provides the
MCRegisterInfo instance that some disassemblers were using through the
MCContext (previously those backends were constructing their own
MCRegisterInfo instances).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206241 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-15 04:40:56 +00:00
David Blaikie
8a21cb2433 Add missing include (for r205050)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205053 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-28 21:00:25 +00:00
David Blaikie
4a9c2585ab llvm-mc: error when -compress-debug-sections is requested and zlib is not linked
This is a bit of a stab in the dark, since I have zlib on my machine.
Just going to bounce it off the bots & see if it sticks.

Do we have some convention for negative REQUIRES: checks? Or do I just
need to add a feature like I've done here?

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205050 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-28 20:45:24 +00:00
David Blaikie
0a0c4cc56f DebugInfo: Support for compressed debug info sections
1) When creating a .debug_* section and instead create a .zdebug_
   section.
2) When creating a fragment in a .zdebug_* section, make it a compressed
   fragment.
3) When computing the size of a compressed section, compress the data
   and use the size of the compressed data.
4) Emit the compressed bytes.

Also, check that only if a section has a compressed fragment, then that
is the only fragment in the section.

Assert-fail if the fragment's data is modified after it is compressed.

Initial review on llvm-commits by Eric Christopher and Rafael Espindola.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204958 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-27 20:45:58 +00:00
Rafael Espindola
a5913682cb Remove llvm-mc's disable-cfi option.
It was dead.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204404 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-20 21:48:20 +00:00
Craig Topper
c83e68f732 [C++11] Add 'override' keyword to virtual methods that override their base class.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203345 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-08 08:27:28 +00:00
Ahmed Charles
f4ccd11075 Replace OwningPtr<T> with std::unique_ptr<T>.
This compiles with no changes to clang/lld/lldb with MSVC and includes
overloads to various functions which are used by those projects and llvm
which have OwningPtr's as parameters. This should allow out of tree
projects some time to move. There are also no changes to libs/Target,
which should help out of tree targets have time to move, if necessary.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203083 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-06 05:51:42 +00:00
Ahmed Charles
1a6eca243f [C++11] Replace OwningPtr::take() with OwningPtr::release().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202957 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-05 10:19:29 +00:00
Rafael Espindola
ac69459e0f Replace the F_Binary flag with a F_Text one.
After this I will set the default back to F_None. The advantage is that
before this patch forgetting to set F_Binary would corrupt a file on windows.
Forgetting to set F_Text produces one that cannot be read in notepad, which
is a better failure mode :-)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202052 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-24 18:20:12 +00:00
Rafael Espindola
f39297678b Remove support for not using .loc directives.
Clang itself was not using this. The only way to access it was via llc.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200862 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-05 18:00:21 +00:00
David Woodhouse
4396f5d9d2 Change MCStreamer EmitInstruction interface to take subtarget info
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200345 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-28 23:12:42 +00:00
Rafael Espindola
550d791907 Pass a MCSubtargetInfo down to the TargetStreamer creation.
With this the target streamers will be able to know the target features that
are in use.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200135 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-26 06:38:58 +00:00
NAKAMURA Takumi
ad8d69bfdd Whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199785 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-22 03:12:43 +00:00
NAKAMURA Takumi
3aabdebde2 [CMake] Update LLVM_LINK_COMPONENTS for each CMakeLists.txt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196908 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-10 11:13:32 +00:00
Joey Gouly
715d98d657 Add an instruction deprecation feature to TableGen.
The 'Deprecated' class allows you to specify a SubtargetFeature that the
instruction is deprecated on.

The 'ComplexDeprecationPredicate' class allows you to define a custom
predicate that is called to check for deprecation.
For example:
  ComplexDeprecationPredicate<"MCR">

would mean you would have to define the following function:
  bool getMCRDeprecationInfo(MCInst &MI, MCSubtargetInfo &STI,
                             std::string &Info)

Which returns 'false' for not deprecated, and 'true' for deprecated
and store the warning message in 'Info'.

The MCTargetAsmParser constructor was chaned to take an extra argument of
the MCInstrInfo class, so out-of-tree targets will need to be changed.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190598 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-12 10:28:05 +00:00
Bill Wendling
c3cee57f7d Generate compact unwind encoding from CFI directives.
We used to generate the compact unwind encoding from the machine
instructions. However, this had the problem that if the user used `-save-temps'
or compiled their hand-written `.s' file (with CFI directives), we wouldn't
generate the compact unwind encoding.

Move the algorithm that generates the compact unwind encoding into the
MCAsmBackend. This way we can generate the encoding whether the code is from a
`.ll' or `.s' file.

<rdar://problem/13623355>


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190290 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-09 02:37:14 +00:00
Tim Northover
38c6ff6c11 Improve llvm-mc disassembler mode and refactor ARM tests to use it
This allows "llvm-mc -disassemble" to accept two new features:
  + Using comma as a byte separator
  + Grouping bytes with '[' and ']' pairs.

The behaviour outside a [...] group is unchanged. But within the group once
llvm-mc encounters a true error, it stops rather than trying to resynchronise
the stream at the next byte. This is more useful for disassembly tests, where
we have an almost-instruction in mind and don't care what the misaligned
interpretation would be. Particularly if it means llvm-mc won't actually see
the next intended almost-instruction.

As a side effect, this means llvm-mc can disassemble its own -show-encoding
output if copy-pasted.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186661 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-19 10:05:04 +00:00
Rafael Espindola
c1b49b56d4 Add a wrapper for open.
This centralizes the handling of O_BINARY and opens the way for hiding more
differences (like how open behaves with directories).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186447 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-16 19:44:17 +00:00
Bill Wendling
99cb622041 Use pointers to the MCAsmInfo and MCRegInfo.
Someone may want to do something crazy, like replace these objects if they
change or something.

No functionality change intended.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184175 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-18 07:20:20 +00:00
Rafael Espindola
4a971705bc Remove the MachineMove class.
It was just a less powerful and more confusing version of
MCCFIInstruction. A side effect is that, since MCCFIInstruction uses
dwarf register numbers, calls to getDwarfRegNum are pushed out, which
should allow further simplifications.

I left the MachineModuleInfo::addFrameMove interface unchanged since
this patch was already fairly big.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181680 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-13 01:16:13 +00:00
Rafael Espindola
730d718b73 Remove some redundant includes in llvm-mc.cpp.
Patch by Jun Koi!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181231 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-06 18:19:24 +00:00
Eli Bendersky
533048228f Try to get rid of a -wunitialized warning: explicitly initialize the pointer
to NULL and use asserts to check in relevant places.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176134 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-26 23:04:17 +00:00
Eli Bendersky
be2afb6408 Remove unneeded include and empty line
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172642 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-16 19:42:16 +00:00