mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-12 14:06:36 +00:00
docs: Update Kaleidoscope for recent DI changes
This has been bit-rotting, so fix it up. I'll have to edit this again once the MD* classes have been renamed to DI* -- I'll try to remember to do that with the commit that renames them. llvm-svn: 235244
This commit is contained in:
parent
6c08d94243
commit
35fd651420
@ -187,13 +187,13 @@ expressions:
|
||||
static DIBuilder *DBuilder;
|
||||
|
||||
struct DebugInfo {
|
||||
DICompileUnit TheCU;
|
||||
DIType DblTy;
|
||||
MDCompileUnit *TheCU;
|
||||
MDType *DblTy;
|
||||
|
||||
DIType getDoubleTy();
|
||||
MDType *getDoubleTy();
|
||||
} KSDbgInfo;
|
||||
|
||||
DIType DebugInfo::getDoubleTy() {
|
||||
MDType *DebugInfo::getDoubleTy() {
|
||||
if (DblTy.isValid())
|
||||
return DblTy;
|
||||
|
||||
@ -245,26 +245,26 @@ So the context:
|
||||
|
||||
.. code-block:: c++
|
||||
|
||||
DIFile Unit = DBuilder->createFile(KSDbgInfo.TheCU.getFilename(),
|
||||
KSDbgInfo.TheCU.getDirectory());
|
||||
MDFile *Unit = DBuilder->createFile(KSDbgInfo.TheCU.getFilename(),
|
||||
KSDbgInfo.TheCU.getDirectory());
|
||||
|
||||
giving us a DIFile and asking the ``Compile Unit`` we created above for the
|
||||
giving us an MDFile and asking the ``Compile Unit`` we created above for the
|
||||
directory and filename where we are currently. Then, for now, we use some
|
||||
source locations of 0 (since our AST doesn't currently have source location
|
||||
information) and construct our function definition:
|
||||
|
||||
.. code-block:: c++
|
||||
|
||||
DIDescriptor FContext(Unit);
|
||||
MDScope *FContext = Unit;
|
||||
unsigned LineNo = 0;
|
||||
unsigned ScopeLine = 0;
|
||||
DISubprogram SP = DBuilder->createFunction(
|
||||
MDSubprogram *SP = DBuilder->createFunction(
|
||||
FContext, Name, StringRef(), Unit, LineNo,
|
||||
CreateFunctionType(Args.size(), Unit), false /* internal linkage */,
|
||||
true /* definition */, ScopeLine, DIDescriptor::FlagPrototyped, false, F);
|
||||
true /* definition */, ScopeLine, DebugNode::FlagPrototyped, false, F);
|
||||
|
||||
and we now have a DISubprogram that contains a reference to all of our metadata
|
||||
for the function.
|
||||
and we now have an MDSubprogram that contains a reference to all of our
|
||||
metadata for the function.
|
||||
|
||||
Source Locations
|
||||
================
|
||||
@ -330,13 +330,13 @@ by constructing another small function:
|
||||
.. code-block:: c++
|
||||
|
||||
void DebugInfo::emitLocation(ExprAST *AST) {
|
||||
DIScope *Scope;
|
||||
MDScope *Scope;
|
||||
if (LexicalBlocks.empty())
|
||||
Scope = &TheCU;
|
||||
Scope = TheCU;
|
||||
else
|
||||
Scope = LexicalBlocks.back();
|
||||
Builder.SetCurrentDebugLocation(
|
||||
DebugLoc::get(AST->getLine(), AST->getCol(), DIScope(*Scope)));
|
||||
DebugLoc::get(AST->getLine(), AST->getCol(), Scope));
|
||||
}
|
||||
|
||||
that both tells the main ``IRBuilder`` where we are, but also what scope
|
||||
@ -347,11 +347,11 @@ of scopes:
|
||||
|
||||
.. code-block:: c++
|
||||
|
||||
std::vector<DIScope *> LexicalBlocks;
|
||||
std::map<const PrototypeAST *, DIScope> FnScopeMap;
|
||||
std::vector<MDScope *> LexicalBlocks;
|
||||
std::map<const PrototypeAST *, MDScope *> FnScopeMap;
|
||||
|
||||
and keep a map of each function to the scope that it represents (a DISubprogram
|
||||
is also a DIScope).
|
||||
and keep a map of each function to the scope that it represents (an
|
||||
MDSubprogram is also an MDScope).
|
||||
|
||||
Then we make sure to:
|
||||
|
||||
@ -392,16 +392,16 @@ argument allocas in ``PrototypeAST::CreateArgumentAllocas``.
|
||||
|
||||
.. code-block:: c++
|
||||
|
||||
DIScope *Scope = KSDbgInfo.LexicalBlocks.back();
|
||||
DIFile Unit = DBuilder->createFile(KSDbgInfo.TheCU.getFilename(),
|
||||
KSDbgInfo.TheCU.getDirectory());
|
||||
DIVariable D = DBuilder->createLocalVariable(dwarf::DW_TAG_arg_variable,
|
||||
*Scope, Args[Idx], Unit, Line,
|
||||
KSDbgInfo.getDoubleTy(), Idx);
|
||||
MDScope *Scope = KSDbgInfo.LexicalBlocks.back();
|
||||
MDFile *Unit = DBuilder->createFile(KSDbgInfo.TheCU.getFilename(),
|
||||
KSDbgInfo.TheCU.getDirectory());
|
||||
MDLocalVariable D = DBuilder->createLocalVariable(
|
||||
dwarf::DW_TAG_arg_variable, Scope, Args[Idx], Unit, Line,
|
||||
KSDbgInfo.getDoubleTy(), Idx);
|
||||
|
||||
Instruction *Call = DBuilder->insertDeclare(
|
||||
Alloca, D, DBuilder->createExpression(), Builder.GetInsertBlock());
|
||||
Call->setDebugLoc(DebugLoc::get(Line, 0, *Scope));
|
||||
Call->setDebugLoc(DebugLoc::get(Line, 0, Scope));
|
||||
|
||||
Here we're doing a few things. First, we're grabbing our current scope
|
||||
for the variable so we can say what range of code our variable is valid
|
||||
|
Loading…
Reference in New Issue
Block a user