//===- lib/MC/MCDwarf.cpp - MCDwarf implementation ------------------------===////// The LLVM Compiler Infrastructure//// This file is distributed under the University of Illinois Open Source// License. See LICENSE.TXT for details.////===----------------------------------------------------------------------===//#include"llvm/MC/MCDwarf.h"#include"llvm/MC/MCAsmInfo.h"#include"llvm/MC/MCContext.h"#include"llvm/MC/MCObjectFileInfo.h"#include"llvm/MC/MCObjectWriter.h"#include"llvm/MC/MCRegisterInfo.h"#include"llvm/MC/MCStreamer.h"#include"llvm/MC/MCSymbol.h"#include"llvm/MC/MCExpr.h"#include"llvm/Support/Debug.h"#include"llvm/Support/ErrorHandling.h"#include"llvm/Support/raw_ostream.h"#include"llvm/Support/Path.h"#include"llvm/Support/SourceMgr.h"#include"llvm/ADT/FoldingSet.h"#include"llvm/ADT/SmallString.h"#include"llvm/ADT/Twine.h"#include"llvm/Config/config.h"usingnamespacellvm;// Given a special op, return the address skip amount (in units of// DWARF2_LINE_MIN_INSN_LENGTH.#define SPECIAL_ADDR(op) (((op) - DWARF2_LINE_OPCODE_BASE)/DWARF2_LINE_RANGE)// The maximum address skip amount that can be encoded with a special op.#define MAX_SPECIAL_ADDR_DELTA SPECIAL_ADDR(255)// First special line opcode - leave room for the standard opcodes.// Note: If you want to change this, you'll have to update the// "standard_opcode_lengths" table that is emitted in DwarfFileTable::Emit(). #define DWARF2_LINE_OPCODE_BASE 13// Minimum line offset in a special line info. opcode. This value// was chosen to give a reasonable range of values.#define DWARF2_LINE_BASE -5// Range of line offsets in a special line info. opcode.#define DWARF2_LINE_RANGE 14// Define the architecture-dependent minimum instruction length (in bytes).// This value should be rather too small than too big.#define DWARF2_LINE_MIN_INSN_LENGTH 1// Note: when DWARF2_LINE_MIN_INSN_LENGTH == 1 which is the current setting,// this routine is a nop and will be optimized away.staticinlineuint64_tScaleAddrDelta(uint64_tAddrDelta){if(DWARF2_LINE_MIN_INSN_LENGTH==1)returnAddrDelta;if(AddrDelta%DWARF2_LINE_MIN_INSN_LENGTH!=0){// TODO: report this error, but really only once.;}returnAddrDelta/DWARF2_LINE_MIN_INSN_LENGTH;}//// This is called when an instruction is assembled into the specified section// and if there is information from the last .loc directive that has yet to have// a line entry made for it is made.//voidMCLineEntry::Make(MCStreamer*MCOS,constMCSection*Section){if(!MCOS->getContext().getDwarfLocSeen())return;// Create a symbol at in the current section for use in the line entry.