summaryrefslogtreecommitdiff
path: root/src/ortho/llvm
diff options
context:
space:
mode:
authorTristan Gingold2014-12-13 07:42:55 +0100
committerTristan Gingold2014-12-13 07:42:55 +0100
commitaa38995f30b7d0ed3d040622aecdb3e6e11385f0 (patch)
tree10597ed5ff5aa3df7472732343fa6ccb480a002e /src/ortho/llvm
parentca2aa9ead46672e57109497e9b69bebe76dd1959 (diff)
downloadghdl-aa38995f30b7d0ed3d040622aecdb3e6e11385f0.tar.gz
ghdl-aa38995f30b7d0ed3d040622aecdb3e6e11385f0.tar.bz2
ghdl-aa38995f30b7d0ed3d040622aecdb3e6e11385f0.zip
llvm: add generation of only debug lines table.
Diffstat (limited to 'src/ortho/llvm')
-rw-r--r--src/ortho/llvm/ortho_code_main.adb7
-rw-r--r--src/ortho/llvm/ortho_llvm.adb43
-rw-r--r--src/ortho/llvm/ortho_llvm.private.ads5
3 files changed, 38 insertions, 17 deletions
diff --git a/src/ortho/llvm/ortho_code_main.adb b/src/ortho/llvm/ortho_code_main.adb
index 300bb32..f80979f 100644
--- a/src/ortho/llvm/ortho_code_main.adb
+++ b/src/ortho/llvm/ortho_code_main.adb
@@ -151,7 +151,12 @@ begin
Exec_Func := new String'(Argument (Optind + 1));
Exec_Val := Integer'Value (Argument (Optind + 2));
Optind := Optind + 2;
+ elsif Arg = "-glines"
+ or else Arg = "-gline-tables-only"
+ then
+ Flag_Debug_Line := True;
elsif Arg = "-g" then
+ Flag_Debug_Line := True;
Flag_Debug := True;
else
-- This is really an argument.
@@ -278,7 +283,7 @@ begin
end loop;
end if;
- if Flag_Debug then
+ if Flag_Debug_Line then
Ortho_LLVM.Finish_Debug;
end if;
diff --git a/src/ortho/llvm/ortho_llvm.adb b/src/ortho/llvm/ortho_llvm.adb
index dd8e649..b004961 100644
--- a/src/ortho/llvm/ortho_llvm.adb
+++ b/src/ortho/llvm/ortho_llvm.adb
@@ -116,7 +116,7 @@ package body Ortho_LLVM is
Dbg_Current_Line : unsigned := 0;
- Dbg_Current_Scope : ValueRef;
+ Dbg_Current_Scope : ValueRef := Null_ValueRef;
Scope_Uniq_Id : Unsigned_64 := 0;
-- Metadata for the instruction
@@ -248,7 +248,7 @@ package body Ortho_LLVM is
-- FIXME: check if INSN is really an instruction
procedure Set_Insn_Dbg (Insn : ValueRef) is
begin
- if Flag_Debug then
+ if Flag_Debug_Line then
if Dbg_Current_Line /= Dbg_Insn_MD_Line then
declare
Vals : ValueRefArray (0 .. 3);
@@ -1820,7 +1820,7 @@ package body Ortho_LLVM is
procedure New_Debug_Filename_Decl (Filename : String) is
Vals : ValueRefArray (1 .. 2);
begin
- if Flag_Debug then
+ if Flag_Debug_Line then
Vals := (MDString (Filename),
MDString (Current_Directory));
Dbg_Current_Filedir := MDNode (Vals, 2);
@@ -2130,9 +2130,10 @@ package body Ortho_LLVM is
PositionBuilderAtEnd (Builder, Cur_Declare_Block.Stmt_Bb);
- if Flag_Debug then
+ if Flag_Debug_Line then
declare
Type_Vals : ValueRefArray (0 .. Func.Nbr_Args);
+ Types : ValueRef;
Vals : ValueRefArray (0 .. 14);
Arg : O_Inter_Acc;
Subprg_Type : ValueRef;
@@ -2140,17 +2141,27 @@ package body Ortho_LLVM is
Subprg_Vals : ValueRefArray (0 .. 19);
Name : ValueRef;
begin
- Arg := Func.Subprg_Inters;
- if Func.Dtype /= O_Tnode_Null then
- Type_Vals (0) := Func.Dtype.Dbg;
+ if Flag_Debug then
+ -- Create a full subroutine_type.
+ Arg := Func.Subprg_Inters;
+ if Func.Dtype /= O_Tnode_Null then
+ Type_Vals (0) := Func.Dtype.Dbg;
+ else
+ -- Void
+ Type_Vals (0) := Null_ValueRef;
+ end if;
+ for I in 1 .. Type_Vals'Last loop
+ Type_Vals (I) := Arg.Itype.Dbg;
+ Arg := Arg.Next;
+ end loop;
+ Types := MDNode (Type_Vals, Type_Vals'Length);
else
- -- Void
- Type_Vals (0) := Null_ValueRef;
+ -- Create a dummy subroutine_type.
+ -- FIXME: create only one subroutine_type ?
+ Type_Vals (0) := ConstInt (Int32Type, 0, 0);
+ Types := MDNode (Type_Vals, 1);
end if;
- for I in 1 .. Type_Vals'Last loop
- Type_Vals (I) := Arg.Itype.Dbg;
- Arg := Arg.Next;
- end loop;
+
Vals :=
(ConstInt (Int32Type, DW_TAG_Subroutine_Type, 0),
ConstInt (Int32Type, 0, 0), -- 1 ??
@@ -2162,7 +2173,7 @@ package body Ortho_LLVM is
ConstInt (Int64Type, 0, 0), -- 7 offset
ConstInt (Int32Type, 0, 0), -- 8 flags
Null_ValueRef, -- 9 derived from
- MDNode (Type_Vals, Type_Vals'Length), -- 10 type
+ Types, -- 10 type
ConstInt (Int32Type, 0, 0), -- 11 runtime lang
Null_ValueRef, -- 12 containing type
Null_ValueRef, -- 13 template params
@@ -2198,7 +2209,9 @@ package body Ortho_LLVM is
Append (Subprg_Nodes, Cur_Declare_Block.Dbg_Scope);
Dbg_Current_Scope := Cur_Declare_Block.Dbg_Scope;
end;
+ end if;
+ if Flag_Debug then
-- Create local variables for arguments.
declare
Arg : O_Inter_Acc;
@@ -2861,7 +2874,7 @@ package body Ortho_LLVM is
(Module, Stackrestore_Name'Address,
FunctionType (VoidType, (1 => I8_Ptr_Type), 1, 0));
- if Flag_Debug then
+ if Flag_Debug_Line then
Debug_ID := GetMDKindID (Dbg_Str, Dbg_Str'Length);
declare
diff --git a/src/ortho/llvm/ortho_llvm.private.ads b/src/ortho/llvm/ortho_llvm.private.ads
index 842a119..b1bd23c 100644
--- a/src/ortho/llvm/ortho_llvm.private.ads
+++ b/src/ortho/llvm/ortho_llvm.private.ads
@@ -40,9 +40,12 @@ package Ortho_LLVM is
Optimization : LLVM.TargetMachine.CodeGenOptLevel :=
LLVM.TargetMachine.CodeGenLevelDefault;
- -- Set by -g to generate debug info.
+ -- Set by -g to generate full debug info.
Flag_Debug : Boolean := False;
+ -- Set by -g or -glines to generate line debug info.
+ Flag_Debug_Line : Boolean := False;
+
private
-- No support for nested subprograms in LLVM.
Has_Nested_Subprograms : constant Boolean := False;