summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC
Commit message (Collapse)AuthorAgeFilesLines
* [MC] Support @ variants with directional labelsUlrich Weigand2013-06-201-2/+12
| | | | | | | | | | | The assembler parser common code supports recognizing symbol variants using the @ modifer. On PowerPC, it should also be possible to use (some of) those modifiers with directional labels, like "1f@l". This patch adds support for accepting symbol variants on directional labels as well. llvm-svn: 184437
* [MC/DWARF] Generate multiple .debug_line entries for adjacent .loc directivesUlrich Weigand2013-06-191-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | The compiler occasionally generates multiple .loc directives in a row (at the same instruction address). These need to be transformed into multple actual .debug_line table entries, since they are used to signal certain information to the debugger (e.g. if the opening brace of a function body is on the same line as the declaration). The MCAsmStreamer version of EmitDwarfLocDirective handles this correctly by emitting a .loc directive every time it is called. However, the MCObjectStream version simply defaults to recording the information and emitting only a single table entry later, e.g. when EmitInstruction is called. This patch introduces a MCAsmStreamer::EmitDwarfLocDirective version that emits a line table entry for a .loc directive that may already be pending before recording the new directive. (This is similar to how this is handled in GNU as.) With this patch (and the code alignment factor patch) applied, I'm now getting identical DWARF .debug sections for all test-suite object files on PowerPC for the internal and the external assembler. llvm-svn: 184357
* Allow creation of single-byte MCAtoms.Ahmed Bougacha2013-06-192-2/+2
| | | | llvm-svn: 184344
* Use pointers to the MCAsmInfo and MCRegInfo.Bill Wendling2013-06-187-98/+95
| | | | | | | | | Someone may want to do something crazy, like replace these objects if they change or something. No functionality change intended. llvm-svn: 184175
* Silence warning in Release builds.Benjamin Kramer2013-06-161-0/+1
| | | | llvm-svn: 184059
* Replace use of PathV1.h in MCContext.cpp.Rafael Espindola2013-06-141-2/+4
| | | | | | GetCurrentDirectory is now unused. Remove it. llvm-svn: 184003
* Don't use PathV1.h in Signals.h.Rafael Espindola2013-06-131-0/+1
| | | | llvm-svn: 183947
* [MC/DWARF] Support .debug_frame / .debug_line code alignment factorsUlrich Weigand2013-06-123-31/+24
| | | | | | | | | | | | | | | | | | | | | | | | | I've been comparing the object file output of LLVM's integrated assembler against the external assembler on PowerPC, and one area where differences still remain are in DWARF sections. In particular, the GNU assembler generates .debug_frame and .debug_line sections using a code alignment factor of 4, since all PowerPC instructions have size 4 and must be aligned to a multiple of 4. However, current MC code hard-codes a code alignment factor of 1. This patch changes this by adding a "minimum instruction alignment" data element to MCAsmInfo and using this as code alignment factor. This requires passing a MCContext into MCDwarfLineAddr::Encode and MCDwarfLineAddr::EncodeAdvanceLoc. Note that one caller, MCDwarfLineAddr::Write, didn't actually have that information available. However, it turns out that this routine is in fact never used in the whole code base, so the patch simply removes it. If it turns out to be needed again at a later time, it could be re-added with an updated interface. llvm-svn: 183834
* Move PathV2.h to Path.hRafael Espindola2013-06-111-1/+1
| | | | | | | Most clients have already been moved from Path V1 to V2. The ones using V1 now include PathV1.h explicitly. llvm-svn: 183801
* Make SubRegIndex size mandatory, following r183020.Ahmed Bougacha2013-05-311-9/+8
| | | | | | | This also makes TableGen able to compute sizes/offsets of synthesized indices representing tuples. llvm-svn: 183061
* Add a way to define the bit range covered by a SubRegIndex.Ahmed Bougacha2013-05-311-0/+13
| | | | | | | | | | | | | NOTE: If this broke your out-of-tree backend, in *RegisterInfo.td, change the instances of SubRegIndex that have a comps template arg to use the ComposedSubRegIndex class instead. In TableGen land, this adds Size and Offset attributes to SubRegIndex, and the ComposedSubRegIndex class, for which the Size and Offset are computed by TableGen. This also adds an accessor in MCRegisterInfo, and Size/Offsets for the X86 and ARM subreg indices. llvm-svn: 183020
* Remove debug print added in r182949.Ahmed Bougacha2013-05-301-1/+0
| | | | llvm-svn: 182973
* Use the const_cast only where necessary.Bill Wendling2013-05-301-4/+4
| | | | llvm-svn: 182950
* MCObjectSymbolizer: Switch from IntervalMap to sorted vector, following r182625.Ahmed Bougacha2013-05-301-10/+46
| | | | | | | This removes the need for the missing SectionRef operator< workaround, and fixes an IntervalMap assert about alignment on MSVC. llvm-svn: 182949
* Change how we iterate over relocations on ELF.Rafael Espindola2013-05-301-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | For COFF and MachO, sections semantically have relocations that apply to them. That is not the case on ELF. In relocatable objects (.o), a section with relocations in ELF has offsets to another section where the relocations should be applied. In dynamic objects and executables, relocations don't have an offset, they have a virtual address. The section sh_info may or may not point to another section, but that is not actually used for resolving the relocations. This patch exposes that in the ObjectFile API. It has the following advantages: * Most (all?) clients can handle this more efficiently. They will normally walk all relocations, so doing an effort to iterate in a particular order doesn't save time. * llvm-readobj now prints relocations in the same way the native readelf does. * probably most important, relocations that don't point to any section are now visible. This is the case of relocations in the rela.dyn section. See the updated relocation-executable.test for example. llvm-svn: 182908
* Add support for DWARF line number table entries for values in the instructionCameron Zwarich2013-05-251-0/+2
| | | | | | stream. llvm-svn: 182712
* Follow up of the introduction of MCSymbolizer.Quentin Colombet2013-05-244-4/+27
| | | | | | | - Ressurect old MCDisassemble API to soften transition. - Extend MCTargetDesc to set target specific symbolizer. llvm-svn: 182688
* Fix unused warning in opt builds.Daniel Jasper2013-05-241-4/+3
| | | | | | | | In these builds, the asserts() are completely compiled out of the code leaving "End" unused. Directly accessing it, should not have a performance impact, as it is just a data member. llvm-svn: 182634
* MC: Disassembled CFG reconstruction.Ahmed Bougacha2013-05-246-71/+411
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch builds on some existing code to do CFG reconstruction from a disassembled binary: - MCModule represents the binary, and has a list of MCAtoms. - MCAtom represents either disassembled instructions (MCTextAtom), or contiguous data (MCDataAtom), and covers a specific range of addresses. - MCBasicBlock and MCFunction form the reconstructed CFG. An MCBB is backed by an MCTextAtom, and has the usual successors/predecessors. - MCObjectDisassembler creates a module from an ObjectFile using a disassembler. It first builds an atom for each section. It can also construct the CFG, and this splits the text atoms into basic blocks. MCModule and MCAtom were only sketched out; MCFunction and MCBB were implemented under the experimental "-cfg" llvm-objdump -macho option. This cleans them up for further use; llvm-objdump -d -cfg now generates graphviz files for each function found in the binary. In the future, MCObjectDisassembler may be the right place to do "intelligent" disassembly: for example, handling constant islands is just a matter of splitting the atom, using information that may be available in the ObjectFile. Also, better initial atom formation than just using sections is possible using symbols (and things like Mach-O's function_starts load command). This brings two minor regressions in llvm-objdump -macho -cfg: - The printing of a relocation's referenced symbol. - An annotation on loop BBs, i.e., which are their own successor. Relocation printing is replaced by the MCSymbolizer; the basic CFG annotation will be superseded by more related functionality. llvm-svn: 182628
* Add MCSymbolizer for symbolic/annotated disassembly.Ahmed Bougacha2013-05-247-1/+430
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a basic first step towards symbolization of disassembled instructions. This used to be done using externally provided (C API) callbacks. This patch introduces: - the MCSymbolizer class, that mimics the same functions that were used in the X86 and ARM disassemblers to symbolize immediate operands and to annotate loads based off PC (for things like c string literals). - the MCExternalSymbolizer class, which implements the old C API. - the MCRelocationInfo class, which provides a way for targets to translate relocations (either object::RelocationRef, or disassembler C API VariantKinds) to MCExprs. - the MCObjectSymbolizer class, which does symbolization using what it finds in an object::ObjectFile. This makes simple symbolization (with no fancy relocation stuff) work for all object formats! - x86-64 Mach-O and ELF MCRelocationInfos. - A basic ARM Mach-O MCRelocationInfo, that provides just enough to support the C API VariantKinds. Most of what works in otool (the only user of the old symbolization API that I know of) for x86-64 symbolic disassembly (-tvV) works, namely: - symbol references: call _foo; jmp 15 <_foo+50> - relocations: call _foo-_bar; call _foo-4 - __cf?string: leaq 193(%rip), %rax ## literal pool for "hello" Stub support is the main missing part (because libObject doesn't know, among other things, about mach-o indirect symbols). As for the MCSymbolizer API, instead of relying on the disassemblers to call the tryAdding* methods, maybe this could be done automagically using InstrInfo? For instance, even though PC-relative LEAs are used to get the address of string literals in a typical Mach-O file, a MOV would be used in an ELF file. And right now, the explicit symbolization only recognizes PC-relative LEAs. InstrInfo should have already have most of what is needed to know what to symbolize, so this can definitely be improved. I'd also like to remove object::RelocationRef::getValueString (it seems only used by relocation printing in objdump), as simply printing the created MCExpr is definitely enough (and cleaner than string concats). llvm-svn: 182625
* [PowerPC] Clean up generation of ha16() / lo16() markersUlrich Weigand2013-05-231-18/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When targeting the Darwin assembler, we need to generate markers ha16() and lo16() to designate the high and low parts of a (symbolic) immediate. This is necessary not just for plain symbols, but also for certain symbolic expression, typically along the lines of ha16(A - B). The latter doesn't work when simply using VariantKind flags on the symbol reference. This is why the current back-end uses hacks (explicitly called out as such via multiple FIXMEs) in the symbolLo/symbolHi print methods. This patch uses target-defined MCExpr codes to represent the Darwin ha16/lo16 constructs, following along the lines of the equivalent solution used by the ARM back end to handle their :upper16: / :lower16: markers. This allows us to get rid of special handling both in the symbolLo/symbolHi print method and in the common code MCExpr::print routine. Instead, the ha16 / lo16 markers are printed simply in a custom print routine for the target MCExpr types. (As a result, the symbolLo/symbolHi print methods can now replaced by a single printS16ImmOperand routine that also handles symbolic operands.) The patch also provides a EvaluateAsRelocatableImpl routine to handle ha16/lo16 constructs. This is not actually used at the moment by any in-tree code, but is provided as it makes merging into David Fang's out-of-tree Mach-O object writer simpler. Since there is no longer any need to treat VK_PPC_GAS_HA16 and VK_PPC_DARWIN_HA16 differently, they are merged into a single VK_PPC_ADDR16_HA (and likewise for the _LO16 types). llvm-svn: 182616
* Missed removing one of the assert()'s from the LLVMCreateDisasmCPU() libraryKevin Enderby2013-05-231-1/+2
| | | | | | | | | | API with my 176880 revision. If a bad Triple is passed in it can also assert. In this case too it should just return 0 to indicate failure to create the disassembler. rdar://13955214 llvm-svn: 182542
* Cleanup relocation sorting for ELF.Rafael Espindola2013-05-151-2/+16
| | | | | | | | | | We want the order to be deterministic on all platforms. NAKAMURA Takumi fixed that in r181864. This patch is just two small cleanups: * Move the function to the cpp file. It is only passed to array_pod_sort. * Remove the ppc implementation which is now redundant llvm-svn: 181910
* Remove MCELFObjectTargetWriter::adjustFixupOffset hackUlrich Weigand2013-05-152-7/+0
| | | | | | | | Now that PowerPC no longer uses adjustFixupOffset, and no other back-end (ever?) did, we can remove the infrastructure itself (incidentally addressing a FIXME to that effect). llvm-svn: 181895
* Fix two typoSylvestre Ledru2013-05-141-1/+1
| | | | llvm-svn: 181848
* Remove the MachineMove class.Rafael Espindola2013-05-132-42/+7
| | | | | | | | | | | | 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. llvm-svn: 181680
* Fix a bug in the MC asm parser evaluating expressions. It was treating:Kevin Enderby2013-05-071-1/+1
| | | | | | | | | A = 9 B = 3 * A - 2 * A + 1 as B = 3 * A - (2 * A + 1) rdar://13816516 llvm-svn: 181366
* MCStreamer: Also clear vector of W64UnwindInfos on reset().Charles Davis2013-05-071-0/+1
| | | | | | Patch by Kai Nacke! llvm-svn: 181363
* Remove redundant check and use cached FrameArray values.Bob Wilson2013-05-071-12/+8
| | | | | | No functional change. llvm-svn: 181355
* [SystemZ] Update non-pic DWARF encodingsUlrich Weigand2013-05-061-6/+13
| | | | | | | | | | | | As pointed out by Rafael Espindola, we should match the DWARF encodings produced by GCC in both pic and non-pic modes. This was not the case for the non-pic case. This patch changes all DWARF encodings to DW_EH_PE_absptr for the non-pic case, just like GCC does. The test case is updated to check for both variants. llvm-svn: 181222
* [SystemZ] Define DWARF encodingUlrich Weigand2013-05-061-0/+9
| | | | | | | | | | This is another patch in preparation for adding the SystemZ target. It defines the appropriate values for DWARF encodings; the intent is to be compatible with what GCC currently does on the target. Patch by Richard Sandiford. llvm-svn: 181201
* Add ArrayRef constructor from None, and do the cleanups that this ↵Dmitri Gribenko2013-05-051-3/+3
| | | | | | | | constructor enables Patch by Robert Wilhelm. llvm-svn: 181138
* [PowerPC] Parse platform-specifc variant kinds in AsmParserUlrich Weigand2013-05-031-0/+34
| | | | | | | | | This patch adds support for PowerPC platform-specific variant kinds in MCSymbolRefExpr::getVariantKindForName, and also adds a test case to verify they are translated to the appropriate fixup type. llvm-svn: 181053
* Fix section relocation for SECTIONREL32 with immediate offset.Rafael Espindola2013-04-251-0/+2
| | | | | | Patch by Kai Nacke. This matches the gnu as output. llvm-svn: 180568
* Align the __LD,__compact_unwind section.Bill Wendling2013-04-241-7/+16
| | | | | | | | I know what would be cool! We should align the compact unwind section because aligned data access is faster. <rdar://problem/13723271> llvm-svn: 180171
* Remove unused DwarfSectionOffsetDirective stringMatt Arsenault2013-04-222-2/+2
| | | | | | | The value isn't actually used, and setting it emits a COFF specific directive. llvm-svn: 180064
* [ms-inline asm] Get the OpDecl and remove a redundant lookup.Chad Rosier2013-04-221-2/+1
| | | | | | Part of rdar://13663589 llvm-svn: 180057
* COFF: Fix weak external aliases.Peter Collingbourne2013-04-221-28/+29
| | | | | | Differential Revision: http://llvm-reviews.chandlerc.com/D700 llvm-svn: 180034
* [ms-inline asm] Refactor/clean up the SemaLookup interface. No functionalChad Rosier2013-04-221-5/+2
| | | | | | | change indended. Part of rdar://13663589 llvm-svn: 180028
* Fix indentation. No functional change.Craig Topper2013-04-221-5/+5
| | | | llvm-svn: 179994
* Put 'else' on same line as preceding curly brace per coding standards. No ↵Craig Topper2013-04-221-12/+6
| | | | | | functional change. llvm-svn: 179993
* Remove an unreachable 'break' following a 'return'.Craig Topper2013-04-221-1/+0
| | | | llvm-svn: 179991
* Relax this assert. It may not hold in all cases.Bill Wendling2013-04-181-1/+1
| | | | llvm-svn: 179814
* Assert if we're trying to generate a null compact unwind entry.Bill Wendling2013-04-181-4/+2
| | | | llvm-svn: 179809
* Add support for subsections to the ELF assembler. Fixes PR8717.Peter Collingbourne2013-04-1715-71/+169
| | | | | | Differential Revision: http://llvm-reviews.chandlerc.com/D598 llvm-svn: 179725
* Use object file specific section type for initial text sectionNico Rieck2013-04-142-12/+3
| | | | llvm-svn: 179494
* [ms-inline asm] Add the implementation for the AOK_Delete kind, which was addedChad Rosier2013-04-121-3/+5
| | | | | | | in r179325. Test case coming shortly on the clang side. Part of rdar://13453209 llvm-svn: 179383
* [ms-inline asm] Remove brackets from around a symbol reference in the targetChad Rosier2013-04-111-10/+1
| | | | | | | | specific logic. This makes the code much less fragile. Test case coming on the clang side in a moment. rdar://13634327 llvm-svn: 179323
* MC: Support COFF image-relative MCSymbolRefsNico Rieck2013-04-102-7/+5
| | | | | | | | | | | | | | | | Add support for the COFF relocation types IMAGE_REL_I386_DIR32NB and IMAGE_REL_AMD64_ADDR32NB for 32- and 64-bit respectively. These are similar to normal 4-byte relocations except that they do not include the base address of the image. Image-relative relocations are used for debug information (32-bit) and SEH unwind tables (64-bit). A new MCSymbolRef variant called 'VK_COFF_IMGREL32' is introduced to specify such relocations. For AT&T assembly, this variant can be accessed using the symbol suffix '@imgrel'. llvm-svn: 179240
* No need to have this return a bool.Bill Wendling2013-04-101-4/+4
| | | | llvm-svn: 179226
OpenPOWER on IntegriCloud