diff options
author | Jim Laskey <jlaskey@mac.com> | 2006-04-07 16:34:46 +0000 |
---|---|---|
committer | Jim Laskey <jlaskey@mac.com> | 2006-04-07 16:34:46 +0000 |
commit | 4188699f80c233a20b6ddc61570a8a8c1804cb85 (patch) | |
tree | a711460fdce84b3c1fdd9c1dcce8be21fef48786 /include/llvm/CodeGen | |
parent | 38ab6d887c660c7e2fe08707e8f982ab451fb224 (diff) | |
download | external_llvm-4188699f80c233a20b6ddc61570a8a8c1804cb85.tar.gz external_llvm-4188699f80c233a20b6ddc61570a8a8c1804cb85.tar.bz2 external_llvm-4188699f80c233a20b6ddc61570a8a8c1804cb85.zip |
Foundation for call frame information.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27491 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/CodeGen')
-rw-r--r-- | include/llvm/CodeGen/DwarfWriter.h | 31 | ||||
-rw-r--r-- | include/llvm/CodeGen/MachineDebugInfo.h | 24 | ||||
-rw-r--r-- | include/llvm/CodeGen/MachineFrameInfo.h | 18 | ||||
-rw-r--r-- | include/llvm/CodeGen/MachineLocation.h | 40 |
4 files changed, 100 insertions, 13 deletions
diff --git a/include/llvm/CodeGen/DwarfWriter.h b/include/llvm/CodeGen/DwarfWriter.h index 7ac5aa6ba4..34c69b907d 100644 --- a/include/llvm/CodeGen/DwarfWriter.h +++ b/include/llvm/CodeGen/DwarfWriter.h @@ -41,10 +41,13 @@ class DIE; class DIEAbbrev; class GlobalVariableDesc; class MachineDebugInfo; -class MachineLocation; class MachineFunction; +class MachineLocation; +class MachineMove; class Module; +class MRegisterInfo; class SubprogramDesc; +class TargetData; class Type; class TypeDesc; @@ -81,6 +84,12 @@ protected: /// AsmPrinter *Asm; + /// TD - Target data. + const TargetData &TD; + + /// RI - Register Information. + const MRegisterInfo *RI; + /// M - Current module. /// Module *M; @@ -324,7 +333,8 @@ private: /// AddAddress - Add an address attribute to a die based on the location /// provided. - void AddAddress(DIE *Die, unsigned Attribute, MachineLocation &Location); + void AddAddress(DIE *Die, unsigned Attribute, + const MachineLocation &Location); /// NewType - Create a new type DIE. /// @@ -375,6 +385,11 @@ private: /// void SizeAndOffsets(); + /// EmitFrameMoves - Emit frame instructions to describe the layout of the + /// frame. + void EmitFrameMoves(const char *BaseLabel, unsigned BaseLabelID, + std::vector<MachineMove *> &Moves); + /// EmitDebugInfo - Emit the debug info section. /// void EmitDebugInfo() const; @@ -387,10 +402,14 @@ private: /// void EmitDebugLines() const; - /// EmitDebugFrame - Emit info into a debug frame section. + /// EmitInitialDebugFrame - Emit common frame info into a debug frame section. /// - void EmitDebugFrame(); - + void EmitInitialDebugFrame(); + + /// EmitFunctionDebugFrame - Emit per function frame info into a debug frame + /// section. + void EmitFunctionDebugFrame(); + /// EmitDebugPubNames - Emit info into a debug pubnames section. /// void EmitDebugPubNames(); @@ -439,7 +458,7 @@ public: /// SetDebugInfo - Set DebugInfo when it's known that pass manager has /// created it. Set by the target AsmPrinter. - void SetDebugInfo(MachineDebugInfo *DI) { DebugInfo = DI; } + void SetDebugInfo(MachineDebugInfo *DI); //===--------------------------------------------------------------------===// // Main entry points. diff --git a/include/llvm/CodeGen/MachineDebugInfo.h b/include/llvm/CodeGen/MachineDebugInfo.h index 2e20e94e78..0a95f4b235 100644 --- a/include/llvm/CodeGen/MachineDebugInfo.h +++ b/include/llvm/CodeGen/MachineDebugInfo.h @@ -47,6 +47,8 @@ namespace llvm { class Constant; class DebugInfoDesc; class GlobalVariable; +class MachineFunction; +class MachineMove; class Module; class PointerType; class StructType; @@ -574,7 +576,7 @@ public: void setName(const std::string &N) { Name = N; } void setFile(CompileUnitDesc *U) { File = U; } void setLine(unsigned L) { Line = L; } - void setTypeDesc(TypeDesc *T) { TyDesc = T; } + void setType(TypeDesc *T) { TyDesc = T; } void setIsStatic(bool IS) { IsStatic = IS; } void setIsDefinition(bool ID) { IsDefinition = ID; } @@ -940,6 +942,10 @@ private: // RootScope - Top level scope for the current function. // DebugScope *RootScope; + + // FrameMoves - List of moves done by a function's prolog. Used to construct + // frame maps by debug consumers. + std::vector<MachineMove *> FrameMoves; public: MachineDebugInfo(); @@ -953,6 +959,14 @@ public: /// bool doFinalization(); + /// BeginFunction - Begin gathering function debug information. + /// + void BeginFunction(MachineFunction *MF); + + /// EndFunction - Discard function debug information. + /// + void EndFunction(); + /// getDescFor - Convert a Value to a debug information descriptor. /// // FIXME - use new Value type when available. @@ -1060,10 +1074,10 @@ public: /// getOrCreateScope - Returns the scope associated with the given descriptor. /// DebugScope *getOrCreateScope(DebugInfoDesc *ScopeDesc); - - /// ClearScopes - Delete the scope and variable info after a function is - /// completed. - void ClearScopes(); + + /// getFrameMoves - Returns a reference to a list of moves done in the current + /// function's prologue. Used to construct frame maps for debug comsumers. + std::vector<MachineMove *> &getFrameMoves() { return FrameMoves; } }; // End class MachineDebugInfo diff --git a/include/llvm/CodeGen/MachineFrameInfo.h b/include/llvm/CodeGen/MachineFrameInfo.h index d6810bf4e5..baeb47c47d 100644 --- a/include/llvm/CodeGen/MachineFrameInfo.h +++ b/include/llvm/CodeGen/MachineFrameInfo.h @@ -44,6 +44,7 @@ namespace llvm { class TargetData; class TargetRegisterClass; class Type; +class MachineDebugInfo; class MachineFunction; class MachineFrameInfo { @@ -106,12 +107,21 @@ class MachineFrameInfo { /// insertion. /// unsigned MaxCallFrameSize; + + /// DebugInfo - This field is set (via setMachineDebugInfo) by a debug info + /// consumer (ex. DwarfWriter) to indicate that frame layout information + /// should be acquired. Typically, it's the responsibility of the target's + /// MRegisterInfo prologue/epilogue emitting code to inform MachineDebugInfo + /// of frame layouts. + MachineDebugInfo *DebugInfo; + public: MachineFrameInfo() { NumFixedObjects = StackSize = MaxAlignment = 0; HasVarSizedObjects = false; HasCalls = false; MaxCallFrameSize = 0; + DebugInfo = 0; } /// hasStackObjects - Return true if there are any stack objects in this @@ -230,6 +240,14 @@ public: return Objects.size()-NumFixedObjects-1; } + /// getMachineDebugInfo - Used by a prologue/epilogue emitter (MRegisterInfo) + /// to provide frame layout information. + MachineDebugInfo *getMachineDebugInfo() const { return DebugInfo; } + + /// setMachineDebugInfo - Used by a debug consumer (DwarfWriter) to indicate + /// that frame layout information should be gathered. + void setMachineDebugInfo(MachineDebugInfo *DI) { DebugInfo = DI; } + /// print - Used by the MachineFunction printer to print information about /// stack objects. Implemented in MachineFunction.cpp /// diff --git a/include/llvm/CodeGen/MachineLocation.h b/include/llvm/CodeGen/MachineLocation.h index 1756d325a2..ab6a82b14f 100644 --- a/include/llvm/CodeGen/MachineLocation.h +++ b/include/llvm/CodeGen/MachineLocation.h @@ -8,7 +8,13 @@ //===----------------------------------------------------------------------===// // The MachineLocation class is used to represent a simple location in a machine // frame. Locations will be one of two forms; a register or an address formed -// from a base address plus an offset. +// from a base address plus an offset. Register indirection can be specified by +// using an offset of zero. +// +// The MachineMove class is used to represent abstract move operations in the +// prolog/epilog of a compiled function. A collection of these objects can be +// used by a debug consumer to track the location of values when unwinding stack +// frames. //===----------------------------------------------------------------------===// @@ -24,6 +30,11 @@ private: int Offset; // Displacement if not register. public: + enum { + // The target register number for an abstract frame pointer. The value is + // an arbitrary value greater than MRegisterInfo::FirstVirtualRegister. + VirtualFP = ~0U + }; MachineLocation() : IsRegister(false) , Register(0) @@ -37,7 +48,7 @@ public: MachineLocation(unsigned R, int O) : IsRegister(false) , Register(R) - , Offset(0) + , Offset(O) {} // Accessors @@ -57,6 +68,31 @@ public: Register = R; Offset = O; } + +#ifndef NDEBUG + void dump(); +#endif +}; + +class MachineMove { +private: + unsigned LabelID; // Label ID number for post-instruction + // address when result of move takes + // effect. + const MachineLocation Destination; // Move to location. + const MachineLocation Source; // Move from location. + +public: + MachineMove(unsigned ID, MachineLocation &D, MachineLocation &S) + : LabelID(ID) + , Destination(D) + , Source(S) + {} + + // Accessors + unsigned getLabelID() const { return LabelID; } + const MachineLocation &getDestination() const { return Destination; } + const MachineLocation &getSource() const { return Source; } }; } // End llvm namespace |